Remove misleading comment in ~/.glivrc.
[gliv.git] / src / cmdline.c
blobb3e5b8042c78d5efae38dbc0df6be9ba5ecc3347
1 /*
2 File autogenerated by gengetopt version 2.11
3 generated with the following command:
4 gengetopt --input=../tools/gliv.ggo --unamed-opts --no-handle-error
6 The developers of gengetopt consider the fixed text that goes in all
7 gengetopt output files to be in the public domain:
8 we make no copyright claims on it.
9 */
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
16 /* If we use autoconf. */
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
21 #include "getopt.h"
23 #include "cmdline.h"
25 void
26 cmdline_parser_print_version (void)
28 printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
31 void
32 cmdline_parser_print_help (void)
34 cmdline_parser_print_version ();
35 printf("\n"
36 "Purpose:\n"
37 " Image Viewer using OpenGL\n"
38 "\n"
39 "Usage: %s [OPTIONS]... [FILES]...\n", CMDLINE_PARSER_PACKAGE);
40 printf("\n");
41 printf(" -h, --help Print help and exit\n");
42 printf(" -V, --version Print version and exit\n");
43 printf(" -a, --duration=delay Delay between each image\n");
44 printf(" -b, --menu=on|off Hide the menu bar\n");
45 printf(" -C, --client=on|off Connect to an already running gliv\n");
46 printf(" -c, --alpha-checks=on|off No alpha checks in the background\n");
47 printf(" -d, --delay=hide-delay Delay before hiding the cursor\n");
48 printf(" -E, --no-center=on|off No automatic image centering\n");
49 printf(" -e, --build-menus=on|off No images menu at startup\n");
50 printf(" -F, --force-load=on|off Try to load every file\n");
51 printf(" -f, --full-screen=on|off Start in full screen mode\n");
52 printf(" -g, --glivrc=on|off Ignore ~/.glivrc\n");
53 printf(" -i, --info=on|off Hide the status bar\n");
54 printf(" -L, --loop=on|off Make the slide show loop at the end\n");
55 printf(" -l, --scale-down=on|off Reduce the image to the window\n");
56 printf(" -M, --maximize=on|off Maximize the image to the window\n");
57 printf(" -m, --make-fit=on|off Make the image fit the window\n");
58 printf(" -n, --mnemonics=on|off No mnemonics in images menus\n");
59 printf(" -o, --scrollbars=on|off Hide the scrollbars\n");
60 printf(" -P, --fps=fps Maximum framerate\n");
61 printf(" -p, --mipmap=on|off Build Mipmaps\n");
62 printf(" -R, --recursive=on|off Process directories recursively\n");
63 printf(" -S, --sort=on|off Show images in sorted order\n");
64 printf(" -s, --shuffle=on|off Show images in random order\n");
65 printf(" -T, --thumbnails=on|off No thumbnails in images menus\n");
66 printf(" -t, --dither=on|off Enable dithering\n");
67 printf(" -u, --history=length Length of history\n");
68 printf(" -W, --resize-win=on|off No automatic window resizing\n");
69 printf(" -w, --slide-show=on|off Start the slide show immediately\n");
70 printf(" -z, --zoom-pointer=on|off Zoom centered on pointer\n");
71 printf(" -0, --null=on|off Read null-terminated filenames\n");
72 printf(" -1, --one-image=on|off Keep only one image in memory\n");
76 static char *gengetopt_strdup (const char *s);
78 /* gengetopt_strdup() */
79 /* strdup.c replacement of strdup, which is not standard */
80 char *
81 gengetopt_strdup (const char *s)
83 char *result;
85 if (s == (char*)0)
86 return (char*)0;
88 result = (char*)malloc(strlen(s) + 1);
89 if (result == (char*)0)
90 return (char*)0;
91 strcpy(result, s);
92 return result;
95 int
96 cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
98 int c; /* Character of the parsed option. */
99 int missing_required_options = 0;
101 args_info->help_given = 0 ;
102 args_info->version_given = 0 ;
103 args_info->duration_given = 0 ;
104 args_info->menu_given = 0 ;
105 args_info->client_given = 0 ;
106 args_info->alpha_checks_given = 0 ;
107 args_info->delay_given = 0 ;
108 args_info->no_center_given = 0 ;
109 args_info->build_menus_given = 0 ;
110 args_info->force_load_given = 0 ;
111 args_info->full_screen_given = 0 ;
112 args_info->glivrc_given = 0 ;
113 args_info->info_given = 0 ;
114 args_info->loop_given = 0 ;
115 args_info->scale_down_given = 0 ;
116 args_info->maximize_given = 0 ;
117 args_info->make_fit_given = 0 ;
118 args_info->mnemonics_given = 0 ;
119 args_info->scrollbars_given = 0 ;
120 args_info->fps_given = 0 ;
121 args_info->mipmap_given = 0 ;
122 args_info->recursive_given = 0 ;
123 args_info->sort_given = 0 ;
124 args_info->shuffle_given = 0 ;
125 args_info->thumbnails_given = 0 ;
126 args_info->dither_given = 0 ;
127 args_info->history_given = 0 ;
128 args_info->resize_win_given = 0 ;
129 args_info->slide_show_given = 0 ;
130 args_info->zoom_pointer_given = 0 ;
131 args_info->null_given = 0 ;
132 args_info->one_image_given = 0 ;
133 #define clear_args() { \
134 args_info->menu_arg = NULL; \
135 args_info->client_arg = NULL; \
136 args_info->alpha_checks_arg = NULL; \
137 args_info->no_center_arg = NULL; \
138 args_info->build_menus_arg = NULL; \
139 args_info->force_load_arg = NULL; \
140 args_info->full_screen_arg = NULL; \
141 args_info->glivrc_arg = NULL; \
142 args_info->info_arg = NULL; \
143 args_info->loop_arg = NULL; \
144 args_info->scale_down_arg = NULL; \
145 args_info->maximize_arg = NULL; \
146 args_info->make_fit_arg = NULL; \
147 args_info->mnemonics_arg = NULL; \
148 args_info->scrollbars_arg = NULL; \
149 args_info->mipmap_arg = NULL; \
150 args_info->recursive_arg = NULL; \
151 args_info->sort_arg = NULL; \
152 args_info->shuffle_arg = NULL; \
153 args_info->thumbnails_arg = NULL; \
154 args_info->dither_arg = NULL; \
155 args_info->resize_win_arg = NULL; \
156 args_info->slide_show_arg = NULL; \
157 args_info->zoom_pointer_arg = NULL; \
158 args_info->null_arg = NULL; \
159 args_info->one_image_arg = NULL; \
162 clear_args();
164 args_info->inputs = NULL;
165 args_info->inputs_num = 0;
167 optarg = 0;
168 optind = 1;
169 opterr = 1;
170 optopt = '?';
172 while (1)
174 int option_index = 0;
175 char *stop_char;
177 static struct option long_options[] = {
178 { "help", 0, NULL, 'h' },
179 { "version", 0, NULL, 'V' },
180 { "duration", 1, NULL, 'a' },
181 { "menu", 2, NULL, 'b' },
182 { "client", 2, NULL, 'C' },
183 { "alpha-checks", 2, NULL, 'c' },
184 { "delay", 1, NULL, 'd' },
185 { "no-center", 2, NULL, 'E' },
186 { "build-menus", 2, NULL, 'e' },
187 { "force-load", 2, NULL, 'F' },
188 { "full-screen", 2, NULL, 'f' },
189 { "glivrc", 2, NULL, 'g' },
190 { "info", 2, NULL, 'i' },
191 { "loop", 2, NULL, 'L' },
192 { "scale-down", 2, NULL, 'l' },
193 { "maximize", 2, NULL, 'M' },
194 { "make-fit", 2, NULL, 'm' },
195 { "mnemonics", 2, NULL, 'n' },
196 { "scrollbars", 2, NULL, 'o' },
197 { "fps", 1, NULL, 'P' },
198 { "mipmap", 2, NULL, 'p' },
199 { "recursive", 2, NULL, 'R' },
200 { "sort", 2, NULL, 'S' },
201 { "shuffle", 2, NULL, 's' },
202 { "thumbnails", 2, NULL, 'T' },
203 { "dither", 2, NULL, 't' },
204 { "history", 1, NULL, 'u' },
205 { "resize-win", 2, NULL, 'W' },
206 { "slide-show", 2, NULL, 'w' },
207 { "zoom-pointer", 2, NULL, 'z' },
208 { "null", 2, NULL, '0' },
209 { "one-image", 2, NULL, '1' },
210 { NULL, 0, NULL, 0 }
213 stop_char = 0;
214 c = getopt_long (argc, argv, "hVa:b::C::c::d:E::e::F::f::g::i::L::l::M::m::n::o::P:p::R::S::s::T::t::u:W::w::z::0::1::", long_options, &option_index);
216 if (c == -1) break; /* Exit from `while (1)' loop. */
218 switch (c)
220 case 'h': /* Print help and exit. */
221 clear_args ();
222 cmdline_parser_print_help ();
223 exit (EXIT_SUCCESS);
225 case 'V': /* Print version and exit. */
226 clear_args ();
227 cmdline_parser_print_version ();
228 exit (EXIT_SUCCESS);
230 case 'a': /* Delay between each image. */
231 if (args_info->duration_given)
233 fprintf (stderr, "%s: `--duration' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE);
234 clear_args ();
235 return (EXIT_FAILURE);
237 args_info->duration_given = 1;
238 args_info->duration_arg = strtol (optarg,&stop_char,0);
239 break;
241 case 'b': /* Hide the menu bar. */
242 if (args_info->menu_given)
244 fprintf (stderr, "%s: `--menu' (`-b') option given more than once\n", CMDLINE_PARSER_PACKAGE);
245 clear_args ();
246 return (EXIT_FAILURE);
248 args_info->menu_given = 1;
249 args_info->menu_arg = gengetopt_strdup (optarg);
250 break;
252 case 'C': /* Connect to an already running gliv. */
253 if (args_info->client_given)
255 fprintf (stderr, "%s: `--client' (`-C') option given more than once\n", CMDLINE_PARSER_PACKAGE);
256 clear_args ();
257 return (EXIT_FAILURE);
259 args_info->client_given = 1;
260 args_info->client_arg = gengetopt_strdup (optarg);
261 break;
263 case 'c': /* No alpha checks in the background. */
264 if (args_info->alpha_checks_given)
266 fprintf (stderr, "%s: `--alpha-checks' (`-c') option given more than once\n", CMDLINE_PARSER_PACKAGE);
267 clear_args ();
268 return (EXIT_FAILURE);
270 args_info->alpha_checks_given = 1;
271 args_info->alpha_checks_arg = gengetopt_strdup (optarg);
272 break;
274 case 'd': /* Delay before hiding the cursor. */
275 if (args_info->delay_given)
277 fprintf (stderr, "%s: `--delay' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE);
278 clear_args ();
279 return (EXIT_FAILURE);
281 args_info->delay_given = 1;
282 args_info->delay_arg = strtol (optarg,&stop_char,0);
283 break;
285 case 'E': /* No automatic image centering. */
286 if (args_info->no_center_given)
288 fprintf (stderr, "%s: `--no-center' (`-E') option given more than once\n", CMDLINE_PARSER_PACKAGE);
289 clear_args ();
290 return (EXIT_FAILURE);
292 args_info->no_center_given = 1;
293 args_info->no_center_arg = gengetopt_strdup (optarg);
294 break;
296 case 'e': /* No images menu at startup. */
297 if (args_info->build_menus_given)
299 fprintf (stderr, "%s: `--build-menus' (`-e') option given more than once\n", CMDLINE_PARSER_PACKAGE);
300 clear_args ();
301 return (EXIT_FAILURE);
303 args_info->build_menus_given = 1;
304 args_info->build_menus_arg = gengetopt_strdup (optarg);
305 break;
307 case 'F': /* Try to load every file. */
308 if (args_info->force_load_given)
310 fprintf (stderr, "%s: `--force-load' (`-F') option given more than once\n", CMDLINE_PARSER_PACKAGE);
311 clear_args ();
312 return (EXIT_FAILURE);
314 args_info->force_load_given = 1;
315 args_info->force_load_arg = gengetopt_strdup (optarg);
316 break;
318 case 'f': /* Start in full screen mode. */
319 if (args_info->full_screen_given)
321 fprintf (stderr, "%s: `--full-screen' (`-f') option given more than once\n", CMDLINE_PARSER_PACKAGE);
322 clear_args ();
323 return (EXIT_FAILURE);
325 args_info->full_screen_given = 1;
326 args_info->full_screen_arg = gengetopt_strdup (optarg);
327 break;
329 case 'g': /* Ignore ~/.glivrc. */
330 if (args_info->glivrc_given)
332 fprintf (stderr, "%s: `--glivrc' (`-g') option given more than once\n", CMDLINE_PARSER_PACKAGE);
333 clear_args ();
334 return (EXIT_FAILURE);
336 args_info->glivrc_given = 1;
337 args_info->glivrc_arg = gengetopt_strdup (optarg);
338 break;
340 case 'i': /* Hide the status bar. */
341 if (args_info->info_given)
343 fprintf (stderr, "%s: `--info' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE);
344 clear_args ();
345 return (EXIT_FAILURE);
347 args_info->info_given = 1;
348 args_info->info_arg = gengetopt_strdup (optarg);
349 break;
351 case 'L': /* Make the slide show loop at the end. */
352 if (args_info->loop_given)
354 fprintf (stderr, "%s: `--loop' (`-L') option given more than once\n", CMDLINE_PARSER_PACKAGE);
355 clear_args ();
356 return (EXIT_FAILURE);
358 args_info->loop_given = 1;
359 args_info->loop_arg = gengetopt_strdup (optarg);
360 break;
362 case 'l': /* Reduce the image to the window. */
363 if (args_info->scale_down_given)
365 fprintf (stderr, "%s: `--scale-down' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE);
366 clear_args ();
367 return (EXIT_FAILURE);
369 args_info->scale_down_given = 1;
370 args_info->scale_down_arg = gengetopt_strdup (optarg);
371 break;
373 case 'M': /* Maximize the image to the window. */
374 if (args_info->maximize_given)
376 fprintf (stderr, "%s: `--maximize' (`-M') option given more than once\n", CMDLINE_PARSER_PACKAGE);
377 clear_args ();
378 return (EXIT_FAILURE);
380 args_info->maximize_given = 1;
381 args_info->maximize_arg = gengetopt_strdup (optarg);
382 break;
384 case 'm': /* Make the image fit the window. */
385 if (args_info->make_fit_given)
387 fprintf (stderr, "%s: `--make-fit' (`-m') option given more than once\n", CMDLINE_PARSER_PACKAGE);
388 clear_args ();
389 return (EXIT_FAILURE);
391 args_info->make_fit_given = 1;
392 args_info->make_fit_arg = gengetopt_strdup (optarg);
393 break;
395 case 'n': /* No mnemonics in images menus. */
396 if (args_info->mnemonics_given)
398 fprintf (stderr, "%s: `--mnemonics' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE);
399 clear_args ();
400 return (EXIT_FAILURE);
402 args_info->mnemonics_given = 1;
403 args_info->mnemonics_arg = gengetopt_strdup (optarg);
404 break;
406 case 'o': /* Hide the scrollbars. */
407 if (args_info->scrollbars_given)
409 fprintf (stderr, "%s: `--scrollbars' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE);
410 clear_args ();
411 return (EXIT_FAILURE);
413 args_info->scrollbars_given = 1;
414 args_info->scrollbars_arg = gengetopt_strdup (optarg);
415 break;
417 case 'P': /* Maximum framerate. */
418 if (args_info->fps_given)
420 fprintf (stderr, "%s: `--fps' (`-P') option given more than once\n", CMDLINE_PARSER_PACKAGE);
421 clear_args ();
422 return (EXIT_FAILURE);
424 args_info->fps_given = 1;
425 args_info->fps_arg = strtol (optarg,&stop_char,0);
426 break;
428 case 'p': /* Build Mipmaps. */
429 if (args_info->mipmap_given)
431 fprintf (stderr, "%s: `--mipmap' (`-p') option given more than once\n", CMDLINE_PARSER_PACKAGE);
432 clear_args ();
433 return (EXIT_FAILURE);
435 args_info->mipmap_given = 1;
436 args_info->mipmap_arg = gengetopt_strdup (optarg);
437 break;
439 case 'R': /* Process directories recursively. */
440 if (args_info->recursive_given)
442 fprintf (stderr, "%s: `--recursive' (`-R') option given more than once\n", CMDLINE_PARSER_PACKAGE);
443 clear_args ();
444 return (EXIT_FAILURE);
446 args_info->recursive_given = 1;
447 args_info->recursive_arg = gengetopt_strdup (optarg);
448 break;
450 case 'S': /* Show images in sorted order. */
451 if (args_info->sort_given)
453 fprintf (stderr, "%s: `--sort' (`-S') option given more than once\n", CMDLINE_PARSER_PACKAGE);
454 clear_args ();
455 return (EXIT_FAILURE);
457 args_info->sort_given = 1;
458 args_info->sort_arg = gengetopt_strdup (optarg);
459 break;
461 case 's': /* Show images in random order. */
462 if (args_info->shuffle_given)
464 fprintf (stderr, "%s: `--shuffle' (`-s') option given more than once\n", CMDLINE_PARSER_PACKAGE);
465 clear_args ();
466 return (EXIT_FAILURE);
468 args_info->shuffle_given = 1;
469 args_info->shuffle_arg = gengetopt_strdup (optarg);
470 break;
472 case 'T': /* No thumbnails in images menus. */
473 if (args_info->thumbnails_given)
475 fprintf (stderr, "%s: `--thumbnails' (`-T') option given more than once\n", CMDLINE_PARSER_PACKAGE);
476 clear_args ();
477 return (EXIT_FAILURE);
479 args_info->thumbnails_given = 1;
480 args_info->thumbnails_arg = gengetopt_strdup (optarg);
481 break;
483 case 't': /* Enable dithering. */
484 if (args_info->dither_given)
486 fprintf (stderr, "%s: `--dither' (`-t') option given more than once\n", CMDLINE_PARSER_PACKAGE);
487 clear_args ();
488 return (EXIT_FAILURE);
490 args_info->dither_given = 1;
491 args_info->dither_arg = gengetopt_strdup (optarg);
492 break;
494 case 'u': /* Length of history. */
495 if (args_info->history_given)
497 fprintf (stderr, "%s: `--history' (`-u') option given more than once\n", CMDLINE_PARSER_PACKAGE);
498 clear_args ();
499 return (EXIT_FAILURE);
501 args_info->history_given = 1;
502 args_info->history_arg = strtol (optarg,&stop_char,0);
503 break;
505 case 'W': /* No automatic window resizing. */
506 if (args_info->resize_win_given)
508 fprintf (stderr, "%s: `--resize-win' (`-W') option given more than once\n", CMDLINE_PARSER_PACKAGE);
509 clear_args ();
510 return (EXIT_FAILURE);
512 args_info->resize_win_given = 1;
513 args_info->resize_win_arg = gengetopt_strdup (optarg);
514 break;
516 case 'w': /* Start the slide show immediately. */
517 if (args_info->slide_show_given)
519 fprintf (stderr, "%s: `--slide-show' (`-w') option given more than once\n", CMDLINE_PARSER_PACKAGE);
520 clear_args ();
521 return (EXIT_FAILURE);
523 args_info->slide_show_given = 1;
524 args_info->slide_show_arg = gengetopt_strdup (optarg);
525 break;
527 case 'z': /* Zoom centered on pointer. */
528 if (args_info->zoom_pointer_given)
530 fprintf (stderr, "%s: `--zoom-pointer' (`-z') option given more than once\n", CMDLINE_PARSER_PACKAGE);
531 clear_args ();
532 return (EXIT_FAILURE);
534 args_info->zoom_pointer_given = 1;
535 args_info->zoom_pointer_arg = gengetopt_strdup (optarg);
536 break;
538 case '0': /* Read null-terminated filenames. */
539 if (args_info->null_given)
541 fprintf (stderr, "%s: `--null' (`-0') option given more than once\n", CMDLINE_PARSER_PACKAGE);
542 clear_args ();
543 return (EXIT_FAILURE);
545 args_info->null_given = 1;
546 args_info->null_arg = gengetopt_strdup (optarg);
547 break;
549 case '1': /* Keep only one image in memory. */
550 if (args_info->one_image_given)
552 fprintf (stderr, "%s: `--one-image' (`-1') option given more than once\n", CMDLINE_PARSER_PACKAGE);
553 clear_args ();
554 return (EXIT_FAILURE);
556 args_info->one_image_given = 1;
557 args_info->one_image_arg = gengetopt_strdup (optarg);
558 break;
561 case 0: /* Long option with no short option */
563 case '?': /* Invalid option. */
564 /* `getopt_long' already printed an error message. */
565 return (EXIT_FAILURE);
567 default: /* bug: option not considered. */
568 fprintf (stderr, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE, c);
569 abort ();
570 } /* switch */
571 } /* while */
574 if ( missing_required_options )
575 return (EXIT_FAILURE);
577 if (optind < argc)
579 int i = 0 ;
581 args_info->inputs_num = argc - optind ;
582 args_info->inputs =
583 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
584 while (optind < argc)
585 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
588 return 0;