1 /* metaflac - Command-line FLAC metadata editor 2 * Copyright (C) 2001-2009 Josh Coalson 3 * Copyright (C) 2011-2016 Xiph.Org Foundation 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef metaflac__options_h 21 #define metaflac__options_h 22 23 #include "FLAC/format.h" 24 25 #if 0 26 /*[JEC] was:#if HAVE_GETOPT_LONG*/ 27 /*[JEC] see flac/include/share/getopt.h as to why the change */ 28 # include <getopt.h> 29 #else 30 # include "share/getopt.h" 31 #endif 32 33 extern struct share__option long_options_[]; 34 35 typedef enum { 36 OP__SHOW_MD5SUM, 37 OP__SHOW_MIN_BLOCKSIZE, 38 OP__SHOW_MAX_BLOCKSIZE, 39 OP__SHOW_MIN_FRAMESIZE, 40 OP__SHOW_MAX_FRAMESIZE, 41 OP__SHOW_SAMPLE_RATE, 42 OP__SHOW_CHANNELS, 43 OP__SHOW_BPS, 44 OP__SHOW_TOTAL_SAMPLES, 45 OP__SET_MD5SUM, 46 OP__SET_MIN_BLOCKSIZE, 47 OP__SET_MAX_BLOCKSIZE, 48 OP__SET_MIN_FRAMESIZE, 49 OP__SET_MAX_FRAMESIZE, 50 OP__SET_SAMPLE_RATE, 51 OP__SET_CHANNELS, 52 OP__SET_BPS, 53 OP__SET_TOTAL_SAMPLES, 54 OP__SHOW_VC_VENDOR, 55 OP__SHOW_VC_FIELD, 56 OP__REMOVE_VC_ALL, 57 OP__REMOVE_VC_FIELD, 58 OP__REMOVE_VC_FIRSTFIELD, 59 OP__SET_VC_FIELD, 60 OP__IMPORT_VC_FROM, 61 OP__EXPORT_VC_TO, 62 OP__IMPORT_CUESHEET_FROM, 63 OP__EXPORT_CUESHEET_TO, 64 OP__IMPORT_PICTURE_FROM, 65 OP__EXPORT_PICTURE_TO, 66 OP__ADD_SEEKPOINT, 67 OP__ADD_REPLAY_GAIN, 68 OP__SCAN_REPLAY_GAIN, 69 OP__ADD_PADDING, 70 OP__LIST, 71 OP__APPEND, 72 OP__REMOVE, 73 OP__REMOVE_ALL, 74 OP__MERGE_PADDING, 75 OP__SORT_PADDING 76 } OperationType; 77 78 typedef enum { 79 ARG__BLOCK_NUMBER, 80 ARG__BLOCK_TYPE, 81 ARG__EXCEPT_BLOCK_TYPE, 82 ARG__DATA_FORMAT, 83 ARG__FROM_FILE 84 } ArgumentType; 85 86 typedef struct { 87 FLAC__byte value[16]; 88 } Argument_StreaminfoMD5; 89 90 typedef struct { 91 FLAC__uint32 value; 92 } Argument_StreaminfoUInt32; 93 94 typedef struct { 95 FLAC__uint64 value; 96 } Argument_StreaminfoUInt64; 97 98 typedef struct { 99 char *value; 100 } Argument_VcFieldName; 101 102 typedef struct { 103 char *field; /* the whole field as passed on the command line, i.e. "NAME=VALUE" */ 104 char *field_name; 105 /* according to the vorbis spec, field values can contain \0 so simple C strings are not enough here */ 106 unsigned field_value_length; 107 char *field_value; 108 FLAC__bool field_value_from_file; /* true if field_value holds a filename for the value, false for plain value */ 109 } Argument_VcField; 110 111 typedef struct { 112 char *value; 113 } Argument_String; 114 115 typedef struct { 116 unsigned num_entries; 117 unsigned *entries; 118 } Argument_BlockNumber; 119 120 typedef struct { 121 FLAC__MetadataType type; 122 char application_id[4]; /* only relevant if type == FLAC__STREAM_METADATA_TYPE_APPLICATION */ 123 FLAC__bool filter_application_by_id; 124 } Argument_BlockTypeEntry; 125 126 typedef struct { 127 unsigned num_entries; 128 Argument_BlockTypeEntry *entries; 129 } Argument_BlockType; 130 131 typedef struct { 132 FLAC__bool is_binary; 133 } Argument_DataFormat; 134 135 typedef struct { 136 char *file_name; 137 } Argument_FromFile; 138 139 typedef struct { 140 char *specification; 141 } Argument_AddSeekpoint; 142 143 typedef struct { 144 char *filename; 145 Argument_AddSeekpoint *add_seekpoint_link; 146 } Argument_ImportCuesheetFrom; 147 148 typedef struct { 149 char *filename; 150 const Argument_BlockNumber *block_number_link; /* may be NULL to mean 'first PICTURE block' */ 151 } Argument_ExportPictureTo; 152 153 typedef struct { 154 unsigned length; 155 } Argument_AddPadding; 156 157 typedef struct { 158 OperationType type; 159 union { 160 Argument_StreaminfoMD5 streaminfo_md5; 161 Argument_StreaminfoUInt32 streaminfo_uint32; 162 Argument_StreaminfoUInt64 streaminfo_uint64; 163 Argument_VcFieldName vc_field_name; 164 Argument_VcField vc_field; 165 Argument_String filename; 166 Argument_String specification; 167 Argument_ImportCuesheetFrom import_cuesheet_from; 168 Argument_ExportPictureTo export_picture_to; 169 Argument_AddSeekpoint add_seekpoint; 170 Argument_AddPadding add_padding; 171 } argument; 172 } Operation; 173 174 typedef struct { 175 ArgumentType type; 176 union { 177 Argument_BlockNumber block_number; 178 Argument_BlockType block_type; 179 Argument_DataFormat data_format; 180 Argument_FromFile from_file; 181 } value; 182 } Argument; 183 184 typedef struct { 185 FLAC__bool preserve_modtime; 186 FLAC__bool prefix_with_filename; 187 FLAC__bool utf8_convert; 188 FLAC__bool use_padding; 189 FLAC__bool cued_seekpoints; 190 FLAC__bool show_long_help; 191 FLAC__bool show_version; 192 FLAC__bool application_data_format_is_hexdump; 193 struct { 194 Operation *operations; 195 unsigned num_operations; 196 unsigned capacity; 197 } ops; 198 struct { 199 struct { 200 unsigned num_shorthand_ops; 201 unsigned num_major_ops; 202 FLAC__bool has_block_type; 203 FLAC__bool has_except_block_type; 204 } checks; 205 Argument *arguments; 206 unsigned num_arguments; 207 unsigned capacity; 208 } args; 209 unsigned num_files; 210 char **filenames; 211 } CommandLineOptions; 212 213 void init_options(CommandLineOptions *options); 214 FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options); 215 void free_options(CommandLineOptions *options); 216 217 #endif 218