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