1 /*
2 * Mp3Splt -- Utility for mp3/ogg splitting without decoding
3 *
4 * Copyright (c) 2002-2005 M. Trotta - <mtrotta@users.sourceforge.net>
5 * Copyright (c) 2005-2014 Alexandru Munteanu - <m@ioalex.net>
6 *
7 * http://mp3splt.sourceforge.net
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23
24 #include <string.h>
25
26 #include "common.h"
27 #include "data_manager.h"
28 #include "print_utils.h"
29
30 #include "options_checker.h"
31
32 extern FILE *console_out;
33
check_args(int argc,main_data * data)34 void check_args(int argc, main_data *data)
35 {
36 options *opt = data->opt;
37
38 if (argc < 2)
39 {
40 console_out = stderr;
41 show_small_help_exit(data);
42 return;
43 }
44
45 if (opt->k_option)
46 {
47 if (we_have_incompatible_stdin_option(opt))
48 {
49 print_error_exit(_("cannot use -k option (or STDIN) with"
50 " one of the following options: -S -s -r -w -l -e -i -a -p -F"), data);
51 }
52 }
53
54 if (opt->w_option)
55 {
56 if (opt->t_option || opt->c_option ||
57 opt->s_option || opt->l_option ||
58 opt->e_option || opt->i_option ||
59 opt->f_option || opt->a_option ||
60 opt->p_option || opt->o_option ||
61 opt->g_option || opt->n_option ||
62 opt->x_option || opt->A_option ||
63 opt->E_option || opt->S_option ||
64 opt->G_option || opt->r_option ||
65 opt->F_option)
66 {
67 print_error_exit(_("the -w option can only be used with -m, -d, -q and -Q"), data);
68 }
69 }
70
71 if (opt->l_option)
72 {
73 if (opt->t_option || opt->c_option ||
74 opt->s_option || opt->e_option ||
75 opt->i_option || opt->m_option ||
76 opt->f_option || opt->a_option ||
77 opt->p_option || opt->o_option ||
78 opt->g_option || opt->d_option ||
79 opt->n_option || opt->qq_option ||
80 opt->x_option || opt->A_option ||
81 opt->S_option || opt->G_option ||
82 opt->r_option || opt->F_option)
83 {
84 print_error_exit(_("the -l option can only be used with -q"), data);
85 }
86 }
87
88 if (opt->e_option)
89 {
90 if (opt->t_option || opt->c_option ||
91 opt->s_option || opt->i_option ||
92 opt->a_option || opt->p_option ||
93 opt->g_option || opt->n_option ||
94 opt->A_option || opt->E_option ||
95 opt->S_option || opt->G_option ||
96 opt->r_option || opt->F_option)
97 {
98 print_error_exit(_("the -e option can only be used with -m, -f, -o, -d, -q, -Q"), data);
99 }
100 }
101
102 if (opt->f_option)
103 {
104 }
105
106 if (opt->c_option)
107 {
108 if (opt->t_option || opt->s_option ||
109 opt->i_option || opt->g_option ||
110 opt->A_option || opt->S_option ||
111 opt->G_option || opt->r_option ||
112 opt->F_option)
113 {
114 print_error_exit(_("the -c option cannot be used with -t, -g, -G, -s, -r, -A, -i, -S or -F"), data);
115 }
116 }
117
118 if (opt->A_option)
119 {
120 if (opt->t_option || opt->s_option ||
121 opt->i_option || opt->S_option ||
122 opt->r_option || opt->F_option)
123 {
124 print_error_exit(_("the -A option cannot be used with -t, -s, -r, -i, -S or -F"), data);
125 }
126 }
127
128 if (opt->t_option)
129 {
130 if (opt->s_option || opt->i_option ||
131 opt->S_option || opt->r_option ||
132 opt->F_option)
133 {
134 print_error_exit(_("the -t option cannot be used with -s, -r, -i, -S or -F"), data);
135 }
136 }
137
138 if (opt->s_option)
139 {
140 if (opt->a_option || opt->i_option ||
141 opt->S_option || opt->r_option)
142 {
143 print_error_exit(_("-s option cannot be used with -a, -r, -i or -S"), data);
144 }
145 }
146
147 if (opt->a_option)
148 {
149 if (opt->i_option)
150 {
151 print_error_exit(_("-a option cannot be used with -i"), data);
152 }
153 }
154
155 if (opt->S_option)
156 {
157 }
158
159 if (opt->p_option)
160 {
161 if (!opt->a_option && !opt->s_option && !opt->i_option && !opt->r_option)
162 {
163 print_error_exit(_("the -p option cannot be used without -a, -s, -r or -i"), data);
164 }
165 }
166
167 if (opt->o_option)
168 {
169 if (opt->i_option)
170 {
171 print_error_exit(_("the -o option cannot be used with -i"), data);
172 }
173 if (opt->output_format)
174 {
175 if ((strcmp(opt->output_format,"-") == 0) && (opt->m_option || opt->d_option))
176 {
177 print_error_exit(_("cannot use '-o -' (STDOUT) with -m or -d"), data);
178 }
179 }
180 }
181
182 if (opt->g_option)
183 {
184 if (opt->i_option || opt->n_option || opt->G_option)
185 {
186 print_error_exit(_("the -g option cannot be used with -n, -i or -G"), data);
187 }
188 }
189
190 if (opt->d_option)
191 {
192 if (opt->i_option)
193 {
194 print_error_exit(_("the -d option cannot be used with -i"), data);
195 }
196 }
197
198 if (opt->n_option)
199 {
200 if (opt->i_option || opt->T_option)
201 {
202 print_error_exit(_("the -n option cannot be used with -i or -T"), data);
203 }
204 }
205
206 if (opt->m_option)
207 {
208 if (opt->i_option)
209 {
210 print_error_exit(_("the -m option cannot be used with -i"), data);
211 }
212 }
213
214 if (opt->i_option)
215 {
216 }
217
218 if (opt->q_option)
219 {
220 }
221
222 if (opt->qq_option)
223 {
224 if (opt->o_option)
225 {
226 if (strcmp(opt->output_format,"-") == 0)
227 {
228 print_error_exit(_("the -Q option cannot be used with"
229 " STDOUT output ('-o -')"), data);
230 }
231 }
232 if (opt->c_option)
233 {
234 if (strncmp(opt->cddb_arg, "query", 5) == 0)
235 {
236 print_error_exit(_("the -Q option cannot be used with"
237 " interactive freedb query ('-c query')"), data);
238 }
239 }
240 }
241
242 if (opt->N_option)
243 {
244 if (!opt->s_option)
245 {
246 print_error_exit(_("the -N option must be used with silence detection (-s option)"), data);
247 }
248 }
249
250 if (opt->O_option)
251 {
252 if (opt->w_option || opt->e_option ||
253 opt->l_option || opt->i_option)
254 {
255 print_error_exit(_("the -O option cannot be used with -w, -e, -l or -i"), data);
256 }
257 }
258
259 if (opt->x_option)
260 {
261 }
262
263 if (opt->T_option)
264 {
265 int force_tags_version = opt->T_option_value;
266 if ((force_tags_version != 1) && (force_tags_version != 2) &&
267 (force_tags_version != 12))
268 {
269 print_error_exit("the -T option can only have values 1, 2 or 12", data);
270 }
271 }
272
273 if (opt->G_option)
274 {
275 }
276
277 if (opt->F_option)
278 {
279 if (!opt->s_option)
280 {
281 print_error_exit(_("the -F option cannot be used without -s"), data);
282 }
283 }
284
285 if (opt->K_option)
286 {
287 if (!opt->c_option)
288 {
289 print_error_exit(_("the -K option cannot be used without -c"), data);
290 }
291 }
292 }
293
we_have_incompatible_stdin_option(options * opt)294 int we_have_incompatible_stdin_option(options *opt)
295 {
296 return opt->s_option || opt->w_option ||
297 opt->l_option || opt->e_option ||
298 opt->i_option || opt->a_option ||
299 opt->p_option || opt->S_option || opt->r_option || opt->F_option || opt->K_option;
300 }
301
302