2 File autogenerated by gengetopt version 2.10
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.
16 /* If we use autoconf. */
26 cmdline_parser_print_version (void)
28 printf ("%s %s\n", CMDLINE_PARSER_PACKAGE
, CMDLINE_PARSER_VERSION
);
32 cmdline_parser_print_help (void)
34 cmdline_parser_print_version ();
37 " Image Viewer using OpenGL\n"
39 "Usage: %s [OPTIONS]... [FILES]...\n", CMDLINE_PARSER_PACKAGE
);
40 printf(" -h --help Print help and exit\n");
41 printf(" -V --version Print version and exit\n");
43 printf(" Group: sort\n");
44 printf(" -s --shuffle Show images in random order\n");
45 printf(" -S --sort Show images in sorted order\n");
46 printf(" -R --recursive Process directories recursively (default=off)\n");
47 printf(" -f --full-screen Start in full screen mode (default=off)\n");
48 printf(" -l --scale-down Reduce the image to the window (default=off)\n");
49 printf(" -M --maximize Maximize the image to the window (default=off)\n");
50 printf(" -m --make-fit Make the image fit the window (default=off)\n");
51 printf(" -z --zoom-pointer Zoom centered on pointer (default=off)\n");
52 printf(" -t --dither Enable dithering (default=off)\n");
53 printf(" -F --force-load Try to load every file (default=off)\n");
54 printf(" -p --mipmap Build Mipmaps (default=off)\n");
55 printf(" -n --mnemonics Make mnemonics for images menus (default=off)\n");
56 printf(" -w --slide-show Start the slide show immediately (default=off)\n");
57 printf(" -L --loop Make the slide show loop at the end (default=off)\n");
58 printf(" -1 --one-image Keep only one image in memory (default=off)\n");
59 printf(" -0 --null Read null-terminated filenames (default=off)\n");
60 printf(" -e --build-menus Build images menu at startup (default=on)\n");
61 printf(" -b --menu Display the menu bar (default=on)\n");
62 printf(" -i --info Show infos about displayed image (default=on)\n");
63 printf(" -o --scrollbars Display scrollbars (default=on)\n");
64 printf(" -g --glivrc Load ~/.glivrc (default=on)\n");
65 printf(" -c --alpha-checks Alpha checks in the background (default=on)\n");
66 printf(" -T --thumbnails Show thumbnails in images menus (default=on)\n");
67 printf(" -W --resize-win Automatic window resizing (default=on)\n");
68 printf(" -dINT --delay=INT Delay before hiding the cursor\n");
69 printf(" -uINT --history=INT Length of history\n");
70 printf(" -aINT --duration=INT Delay between each image\n");
71 printf(" -PINT --fps=INT Maximum framerate\n");
75 static char *gengetopt_strdup (const char *s
);
77 /* gengetopt_strdup() */
78 /* strdup.c replacement of strdup, which is not standard */
80 gengetopt_strdup (const char *s
)
82 char *result
= (char*)malloc(strlen(s
) + 1);
83 if (result
== (char*)0)
90 cmdline_parser (int argc
, char * const *argv
, struct gengetopt_args_info
*args_info
)
92 int c
; /* Character of the parsed option. */
93 int missing_required_options
= 0;
94 int sort_group_counter
= 0;
97 args_info
->help_given
= 0 ;
98 args_info
->version_given
= 0 ;
99 args_info
->shuffle_given
= 0 ;
100 args_info
->sort_given
= 0 ;
101 args_info
->recursive_given
= 0 ;
102 args_info
->full_screen_given
= 0 ;
103 args_info
->scale_down_given
= 0 ;
104 args_info
->maximize_given
= 0 ;
105 args_info
->make_fit_given
= 0 ;
106 args_info
->zoom_pointer_given
= 0 ;
107 args_info
->dither_given
= 0 ;
108 args_info
->force_load_given
= 0 ;
109 args_info
->mipmap_given
= 0 ;
110 args_info
->mnemonics_given
= 0 ;
111 args_info
->slide_show_given
= 0 ;
112 args_info
->loop_given
= 0 ;
113 args_info
->one_image_given
= 0 ;
114 args_info
->null_given
= 0 ;
115 args_info
->build_menus_given
= 0 ;
116 args_info
->menu_given
= 0 ;
117 args_info
->info_given
= 0 ;
118 args_info
->scrollbars_given
= 0 ;
119 args_info
->glivrc_given
= 0 ;
120 args_info
->alpha_checks_given
= 0 ;
121 args_info
->thumbnails_given
= 0 ;
122 args_info
->resize_win_given
= 0 ;
123 args_info
->delay_given
= 0 ;
124 args_info
->history_given
= 0 ;
125 args_info
->duration_given
= 0 ;
126 args_info
->fps_given
= 0 ;
127 #define clear_args() { \
128 args_info->recursive_flag = 0;\
129 args_info->full_screen_flag = 0;\
130 args_info->scale_down_flag = 0;\
131 args_info->maximize_flag = 0;\
132 args_info->make_fit_flag = 0;\
133 args_info->zoom_pointer_flag = 0;\
134 args_info->dither_flag = 0;\
135 args_info->force_load_flag = 0;\
136 args_info->mipmap_flag = 0;\
137 args_info->mnemonics_flag = 0;\
138 args_info->slide_show_flag = 0;\
139 args_info->loop_flag = 0;\
140 args_info->one_image_flag = 0;\
141 args_info->null_flag = 0;\
142 args_info->build_menus_flag = 1;\
143 args_info->menu_flag = 1;\
144 args_info->info_flag = 1;\
145 args_info->scrollbars_flag = 1;\
146 args_info->glivrc_flag = 1;\
147 args_info->alpha_checks_flag = 1;\
148 args_info->thumbnails_flag = 1;\
149 args_info->resize_win_flag = 1;\
154 args_info
->inputs
= NULL
;
155 args_info
->inputs_num
= 0;
164 int option_index
= 0;
167 static struct option long_options
[] = {
168 { "help", 0, NULL
, 'h' },
169 { "version", 0, NULL
, 'V' },
170 { "shuffle", 0, NULL
, 's' },
171 { "sort", 0, NULL
, 'S' },
172 { "recursive", 0, NULL
, 'R' },
173 { "full-screen", 0, NULL
, 'f' },
174 { "scale-down", 0, NULL
, 'l' },
175 { "maximize", 0, NULL
, 'M' },
176 { "make-fit", 0, NULL
, 'm' },
177 { "zoom-pointer", 0, NULL
, 'z' },
178 { "dither", 0, NULL
, 't' },
179 { "force-load", 0, NULL
, 'F' },
180 { "mipmap", 0, NULL
, 'p' },
181 { "mnemonics", 0, NULL
, 'n' },
182 { "slide-show", 0, NULL
, 'w' },
183 { "loop", 0, NULL
, 'L' },
184 { "one-image", 0, NULL
, '1' },
185 { "null", 0, NULL
, '0' },
186 { "build-menus", 0, NULL
, 'e' },
187 { "menu", 0, NULL
, 'b' },
188 { "info", 0, NULL
, 'i' },
189 { "scrollbars", 0, NULL
, 'o' },
190 { "glivrc", 0, NULL
, 'g' },
191 { "alpha-checks", 0, NULL
, 'c' },
192 { "thumbnails", 0, NULL
, 'T' },
193 { "resize-win", 0, NULL
, 'W' },
194 { "delay", 1, NULL
, 'd' },
195 { "history", 1, NULL
, 'u' },
196 { "duration", 1, NULL
, 'a' },
197 { "fps", 1, NULL
, 'P' },
202 c
= getopt_long (argc
, argv
, "hVsSRflMmztFpnwL10ebiogcTWd:u:a:P:", long_options
, &option_index
);
204 if (c
== -1) break; /* Exit from `while (1)' loop. */
208 case 'h': /* Print help and exit. */
210 cmdline_parser_print_help ();
213 case 'V': /* Print version and exit. */
215 cmdline_parser_print_version ();
218 case 's': /* Show images in random order. */
219 if (args_info
->shuffle_given
)
221 fprintf (stderr
, "%s: `--shuffle' (`-s') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
223 return (EXIT_FAILURE
);
225 args_info
->shuffle_given
= 1;
226 sort_group_counter
+= 1;
229 case 'S': /* Show images in sorted order. */
230 if (args_info
->sort_given
)
232 fprintf (stderr
, "%s: `--sort' (`-S') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
234 return (EXIT_FAILURE
);
236 args_info
->sort_given
= 1;
237 sort_group_counter
+= 1;
240 case 'R': /* Process directories recursively. */
241 if (args_info
->recursive_given
)
243 fprintf (stderr
, "%s: `--recursive' (`-R') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
245 return (EXIT_FAILURE
);
247 args_info
->recursive_given
= 1;
248 args_info
->recursive_flag
= !(args_info
->recursive_flag
);
251 case 'f': /* Start in full screen mode. */
252 if (args_info
->full_screen_given
)
254 fprintf (stderr
, "%s: `--full-screen' (`-f') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
256 return (EXIT_FAILURE
);
258 args_info
->full_screen_given
= 1;
259 args_info
->full_screen_flag
= !(args_info
->full_screen_flag
);
262 case 'l': /* Reduce the image to the window. */
263 if (args_info
->scale_down_given
)
265 fprintf (stderr
, "%s: `--scale-down' (`-l') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
267 return (EXIT_FAILURE
);
269 args_info
->scale_down_given
= 1;
270 args_info
->scale_down_flag
= !(args_info
->scale_down_flag
);
273 case 'M': /* Maximize the image to the window. */
274 if (args_info
->maximize_given
)
276 fprintf (stderr
, "%s: `--maximize' (`-M') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
278 return (EXIT_FAILURE
);
280 args_info
->maximize_given
= 1;
281 args_info
->maximize_flag
= !(args_info
->maximize_flag
);
284 case 'm': /* Make the image fit the window. */
285 if (args_info
->make_fit_given
)
287 fprintf (stderr
, "%s: `--make-fit' (`-m') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
289 return (EXIT_FAILURE
);
291 args_info
->make_fit_given
= 1;
292 args_info
->make_fit_flag
= !(args_info
->make_fit_flag
);
295 case 'z': /* Zoom centered on pointer. */
296 if (args_info
->zoom_pointer_given
)
298 fprintf (stderr
, "%s: `--zoom-pointer' (`-z') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
300 return (EXIT_FAILURE
);
302 args_info
->zoom_pointer_given
= 1;
303 args_info
->zoom_pointer_flag
= !(args_info
->zoom_pointer_flag
);
306 case 't': /* Enable dithering. */
307 if (args_info
->dither_given
)
309 fprintf (stderr
, "%s: `--dither' (`-t') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
311 return (EXIT_FAILURE
);
313 args_info
->dither_given
= 1;
314 args_info
->dither_flag
= !(args_info
->dither_flag
);
317 case 'F': /* Try to load every file. */
318 if (args_info
->force_load_given
)
320 fprintf (stderr
, "%s: `--force-load' (`-F') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
322 return (EXIT_FAILURE
);
324 args_info
->force_load_given
= 1;
325 args_info
->force_load_flag
= !(args_info
->force_load_flag
);
328 case 'p': /* Build Mipmaps. */
329 if (args_info
->mipmap_given
)
331 fprintf (stderr
, "%s: `--mipmap' (`-p') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
333 return (EXIT_FAILURE
);
335 args_info
->mipmap_given
= 1;
336 args_info
->mipmap_flag
= !(args_info
->mipmap_flag
);
339 case 'n': /* Make mnemonics for images menus. */
340 if (args_info
->mnemonics_given
)
342 fprintf (stderr
, "%s: `--mnemonics' (`-n') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
344 return (EXIT_FAILURE
);
346 args_info
->mnemonics_given
= 1;
347 args_info
->mnemonics_flag
= !(args_info
->mnemonics_flag
);
350 case 'w': /* Start the slide show immediately. */
351 if (args_info
->slide_show_given
)
353 fprintf (stderr
, "%s: `--slide-show' (`-w') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
355 return (EXIT_FAILURE
);
357 args_info
->slide_show_given
= 1;
358 args_info
->slide_show_flag
= !(args_info
->slide_show_flag
);
361 case 'L': /* Make the slide show loop at the end. */
362 if (args_info
->loop_given
)
364 fprintf (stderr
, "%s: `--loop' (`-L') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
366 return (EXIT_FAILURE
);
368 args_info
->loop_given
= 1;
369 args_info
->loop_flag
= !(args_info
->loop_flag
);
372 case '1': /* Keep only one image in memory. */
373 if (args_info
->one_image_given
)
375 fprintf (stderr
, "%s: `--one-image' (`-1') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
377 return (EXIT_FAILURE
);
379 args_info
->one_image_given
= 1;
380 args_info
->one_image_flag
= !(args_info
->one_image_flag
);
383 case '0': /* Read null-terminated filenames. */
384 if (args_info
->null_given
)
386 fprintf (stderr
, "%s: `--null' (`-0') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
388 return (EXIT_FAILURE
);
390 args_info
->null_given
= 1;
391 args_info
->null_flag
= !(args_info
->null_flag
);
394 case 'e': /* Build images menu at startup. */
395 if (args_info
->build_menus_given
)
397 fprintf (stderr
, "%s: `--build-menus' (`-e') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
399 return (EXIT_FAILURE
);
401 args_info
->build_menus_given
= 1;
402 args_info
->build_menus_flag
= !(args_info
->build_menus_flag
);
405 case 'b': /* Display the menu bar. */
406 if (args_info
->menu_given
)
408 fprintf (stderr
, "%s: `--menu' (`-b') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
410 return (EXIT_FAILURE
);
412 args_info
->menu_given
= 1;
413 args_info
->menu_flag
= !(args_info
->menu_flag
);
416 case 'i': /* Show infos about displayed image. */
417 if (args_info
->info_given
)
419 fprintf (stderr
, "%s: `--info' (`-i') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
421 return (EXIT_FAILURE
);
423 args_info
->info_given
= 1;
424 args_info
->info_flag
= !(args_info
->info_flag
);
427 case 'o': /* Display scrollbars. */
428 if (args_info
->scrollbars_given
)
430 fprintf (stderr
, "%s: `--scrollbars' (`-o') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
432 return (EXIT_FAILURE
);
434 args_info
->scrollbars_given
= 1;
435 args_info
->scrollbars_flag
= !(args_info
->scrollbars_flag
);
438 case 'g': /* Load ~/.glivrc. */
439 if (args_info
->glivrc_given
)
441 fprintf (stderr
, "%s: `--glivrc' (`-g') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
443 return (EXIT_FAILURE
);
445 args_info
->glivrc_given
= 1;
446 args_info
->glivrc_flag
= !(args_info
->glivrc_flag
);
449 case 'c': /* Alpha checks in the background. */
450 if (args_info
->alpha_checks_given
)
452 fprintf (stderr
, "%s: `--alpha-checks' (`-c') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
454 return (EXIT_FAILURE
);
456 args_info
->alpha_checks_given
= 1;
457 args_info
->alpha_checks_flag
= !(args_info
->alpha_checks_flag
);
460 case 'T': /* Show thumbnails in images menus. */
461 if (args_info
->thumbnails_given
)
463 fprintf (stderr
, "%s: `--thumbnails' (`-T') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
465 return (EXIT_FAILURE
);
467 args_info
->thumbnails_given
= 1;
468 args_info
->thumbnails_flag
= !(args_info
->thumbnails_flag
);
471 case 'W': /* Automatic window resizing. */
472 if (args_info
->resize_win_given
)
474 fprintf (stderr
, "%s: `--resize-win' (`-W') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
476 return (EXIT_FAILURE
);
478 args_info
->resize_win_given
= 1;
479 args_info
->resize_win_flag
= !(args_info
->resize_win_flag
);
482 case 'd': /* Delay before hiding the cursor. */
483 if (args_info
->delay_given
)
485 fprintf (stderr
, "%s: `--delay' (`-d') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
487 return (EXIT_FAILURE
);
489 args_info
->delay_given
= 1;
490 args_info
->delay_arg
= strtol (optarg
,&stop_char
,0);
493 case 'u': /* Length of history. */
494 if (args_info
->history_given
)
496 fprintf (stderr
, "%s: `--history' (`-u') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
498 return (EXIT_FAILURE
);
500 args_info
->history_given
= 1;
501 args_info
->history_arg
= strtol (optarg
,&stop_char
,0);
504 case 'a': /* Delay between each image. */
505 if (args_info
->duration_given
)
507 fprintf (stderr
, "%s: `--duration' (`-a') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
509 return (EXIT_FAILURE
);
511 args_info
->duration_given
= 1;
512 args_info
->duration_arg
= strtol (optarg
,&stop_char
,0);
515 case 'P': /* Maximum framerate. */
516 if (args_info
->fps_given
)
518 fprintf (stderr
, "%s: `--fps' (`-P') option given more than once\n", CMDLINE_PARSER_PACKAGE
);
520 return (EXIT_FAILURE
);
522 args_info
->fps_given
= 1;
523 args_info
->fps_arg
= strtol (optarg
,&stop_char
,0);
527 case 0: /* Long option with no short option */
529 case '?': /* Invalid option. */
530 /* `getopt_long' already printed an error message. */
531 return (EXIT_FAILURE
);
533 default: /* bug: option not considered. */
534 fprintf (stderr
, "%s: option unknown: %c\n", CMDLINE_PARSER_PACKAGE
, c
);
539 if ( sort_group_counter
> 1)
541 fprintf (stderr
, "%s: %d options of group sort were given. At most one is required\n", CMDLINE_PARSER_PACKAGE
, sort_group_counter
);
542 missing_required_options
= 1;
546 if ( missing_required_options
)
547 return (EXIT_FAILURE
);
553 args_info
->inputs_num
= argc
- optind
;
555 (char **)(malloc ((args_info
->inputs_num
)*sizeof(char *))) ;
556 while (optind
< argc
)
557 args_info
->inputs
[ i
++ ] = gengetopt_strdup (argv
[optind
++]) ;