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