1 /*
2   File autogenerated by gengetopt version 2.22.6
3   generated with the following command:
4   /usr/bin/gengetopt -u -i options.ggo -f options -F options
5 
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 */
10 
11 /* If we use autoconf.  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #ifndef FIX_UNUSED
21 #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
22 #endif
23 
24 #include <getopt.h>
25 
26 #include "options.h"
27 
28 const char *gengetopt_args_info_purpose = "convert SVG gradient to other formats";
29 
30 const char *gengetopt_args_info_usage = "Usage: svgx [OPTIONS]... [FILES]...";
31 
32 const char *gengetopt_args_info_versiontext = "";
33 
34 const char *gengetopt_args_info_description = "";
35 
36 const char *gengetopt_args_info_help[] = {
37   "  -h, --help                    Print help and exit",
38   "  -V, --version                 Print version and exit",
39   "  -a, --all                     convert all gradients  (default=off)",
40   "  -b, --background=STRING       background colour (cpt)  (default=`0/0/0')",
41   "      --backtrace-file=STRING   write backtrace to file",
42   "      --backtrace-format=STRING backtrace format",
43   "  -f, --foreground=STRING       foreground colour (cpt)\n                                  (default=`255/255/255')",
44   "  -g, --geometry=STRING         image size (png, svg)  (default=`340x36')",
45   "  -n, --nan=STRING              nan colour (cpt)  (default=`255/0/0')",
46   "  -l, --list                    list gradients in file  (default=off)",
47   "  -s, --select=STRING           convert gradient with specifed name",
48   "      --strict                  obey format limits on output  (default=off)",
49   "  -o, --output=STRING           output filename (not with -a)",
50   "  -p, --preview                 include preview (svg)  (default=off)",
51   "  -t, --type=STRING             output format (see manual)",
52   "  -T, --transparency=STRING     replace transparency by colour\n                                  (default=`255/255/255')",
53   "  -v, --verbose                 verbose operation  (default=off)",
54     0
55 };
56 
57 typedef enum {ARG_NO
58   , ARG_FLAG
59   , ARG_STRING
60 } options_arg_type;
61 
62 static
63 void clear_given (struct gengetopt_args_info *args_info);
64 static
65 void clear_args (struct gengetopt_args_info *args_info);
66 
67 static int
68 options_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
69                         struct options_params *params, const char *additional_error);
70 
71 
72 static char *
73 gengetopt_strdup (const char *s);
74 
75 static
clear_given(struct gengetopt_args_info * args_info)76 void clear_given (struct gengetopt_args_info *args_info)
77 {
78   args_info->help_given = 0 ;
79   args_info->version_given = 0 ;
80   args_info->all_given = 0 ;
81   args_info->background_given = 0 ;
82   args_info->backtrace_file_given = 0 ;
83   args_info->backtrace_format_given = 0 ;
84   args_info->foreground_given = 0 ;
85   args_info->geometry_given = 0 ;
86   args_info->nan_given = 0 ;
87   args_info->list_given = 0 ;
88   args_info->select_given = 0 ;
89   args_info->strict_given = 0 ;
90   args_info->output_given = 0 ;
91   args_info->preview_given = 0 ;
92   args_info->type_given = 0 ;
93   args_info->transparency_given = 0 ;
94   args_info->verbose_given = 0 ;
95 }
96 
97 static
clear_args(struct gengetopt_args_info * args_info)98 void clear_args (struct gengetopt_args_info *args_info)
99 {
100   FIX_UNUSED (args_info);
101   args_info->all_flag = 0;
102   args_info->background_arg = gengetopt_strdup ("0/0/0");
103   args_info->background_orig = NULL;
104   args_info->backtrace_file_arg = NULL;
105   args_info->backtrace_file_orig = NULL;
106   args_info->backtrace_format_arg = NULL;
107   args_info->backtrace_format_orig = NULL;
108   args_info->foreground_arg = gengetopt_strdup ("255/255/255");
109   args_info->foreground_orig = NULL;
110   args_info->geometry_arg = gengetopt_strdup ("340x36");
111   args_info->geometry_orig = NULL;
112   args_info->nan_arg = gengetopt_strdup ("255/0/0");
113   args_info->nan_orig = NULL;
114   args_info->list_flag = 0;
115   args_info->select_arg = NULL;
116   args_info->select_orig = NULL;
117   args_info->strict_flag = 0;
118   args_info->output_arg = NULL;
119   args_info->output_orig = NULL;
120   args_info->preview_flag = 0;
121   args_info->type_arg = NULL;
122   args_info->type_orig = NULL;
123   args_info->transparency_arg = gengetopt_strdup ("255/255/255");
124   args_info->transparency_orig = NULL;
125   args_info->verbose_flag = 0;
126 
127 }
128 
129 static
init_args_info(struct gengetopt_args_info * args_info)130 void init_args_info(struct gengetopt_args_info *args_info)
131 {
132 
133 
134   args_info->help_help = gengetopt_args_info_help[0] ;
135   args_info->version_help = gengetopt_args_info_help[1] ;
136   args_info->all_help = gengetopt_args_info_help[2] ;
137   args_info->background_help = gengetopt_args_info_help[3] ;
138   args_info->backtrace_file_help = gengetopt_args_info_help[4] ;
139   args_info->backtrace_format_help = gengetopt_args_info_help[5] ;
140   args_info->foreground_help = gengetopt_args_info_help[6] ;
141   args_info->geometry_help = gengetopt_args_info_help[7] ;
142   args_info->nan_help = gengetopt_args_info_help[8] ;
143   args_info->list_help = gengetopt_args_info_help[9] ;
144   args_info->select_help = gengetopt_args_info_help[10] ;
145   args_info->strict_help = gengetopt_args_info_help[11] ;
146   args_info->output_help = gengetopt_args_info_help[12] ;
147   args_info->preview_help = gengetopt_args_info_help[13] ;
148   args_info->type_help = gengetopt_args_info_help[14] ;
149   args_info->transparency_help = gengetopt_args_info_help[15] ;
150   args_info->verbose_help = gengetopt_args_info_help[16] ;
151 
152 }
153 
154 void
options_print_version(void)155 options_print_version (void)
156 {
157   printf ("%s %s\n",
158      (strlen(OPTIONS_PACKAGE_NAME) ? OPTIONS_PACKAGE_NAME : OPTIONS_PACKAGE),
159      OPTIONS_VERSION);
160 
161   if (strlen(gengetopt_args_info_versiontext) > 0)
162     printf("\n%s\n", gengetopt_args_info_versiontext);
163 }
164 
print_help_common(void)165 static void print_help_common(void) {
166   options_print_version ();
167 
168   if (strlen(gengetopt_args_info_purpose) > 0)
169     printf("\n%s\n", gengetopt_args_info_purpose);
170 
171   if (strlen(gengetopt_args_info_usage) > 0)
172     printf("\n%s\n", gengetopt_args_info_usage);
173 
174   printf("\n");
175 
176   if (strlen(gengetopt_args_info_description) > 0)
177     printf("%s\n\n", gengetopt_args_info_description);
178 }
179 
180 void
options_print_help(void)181 options_print_help (void)
182 {
183   int i = 0;
184   print_help_common();
185   while (gengetopt_args_info_help[i])
186     printf("%s\n", gengetopt_args_info_help[i++]);
187 }
188 
189 void
options_init(struct gengetopt_args_info * args_info)190 options_init (struct gengetopt_args_info *args_info)
191 {
192   clear_given (args_info);
193   clear_args (args_info);
194   init_args_info (args_info);
195 
196   args_info->inputs = 0;
197   args_info->inputs_num = 0;
198 }
199 
200 void
options_params_init(struct options_params * params)201 options_params_init(struct options_params *params)
202 {
203   if (params)
204     {
205       params->override = 0;
206       params->initialize = 1;
207       params->check_required = 1;
208       params->check_ambiguity = 0;
209       params->print_errors = 1;
210     }
211 }
212 
213 struct options_params *
options_params_create(void)214 options_params_create(void)
215 {
216   struct options_params *params =
217     (struct options_params *)malloc(sizeof(struct options_params));
218   options_params_init(params);
219   return params;
220 }
221 
222 static void
free_string_field(char ** s)223 free_string_field (char **s)
224 {
225   if (*s)
226     {
227       free (*s);
228       *s = 0;
229     }
230 }
231 
232 
233 static void
options_release(struct gengetopt_args_info * args_info)234 options_release (struct gengetopt_args_info *args_info)
235 {
236   unsigned int i;
237   free_string_field (&(args_info->background_arg));
238   free_string_field (&(args_info->background_orig));
239   free_string_field (&(args_info->backtrace_file_arg));
240   free_string_field (&(args_info->backtrace_file_orig));
241   free_string_field (&(args_info->backtrace_format_arg));
242   free_string_field (&(args_info->backtrace_format_orig));
243   free_string_field (&(args_info->foreground_arg));
244   free_string_field (&(args_info->foreground_orig));
245   free_string_field (&(args_info->geometry_arg));
246   free_string_field (&(args_info->geometry_orig));
247   free_string_field (&(args_info->nan_arg));
248   free_string_field (&(args_info->nan_orig));
249   free_string_field (&(args_info->select_arg));
250   free_string_field (&(args_info->select_orig));
251   free_string_field (&(args_info->output_arg));
252   free_string_field (&(args_info->output_orig));
253   free_string_field (&(args_info->type_arg));
254   free_string_field (&(args_info->type_orig));
255   free_string_field (&(args_info->transparency_arg));
256   free_string_field (&(args_info->transparency_orig));
257 
258 
259   for (i = 0; i < args_info->inputs_num; ++i)
260     free (args_info->inputs [i]);
261 
262   if (args_info->inputs_num)
263     free (args_info->inputs);
264 
265   clear_given (args_info);
266 }
267 
268 
269 static void
write_into_file(FILE * outfile,const char * opt,const char * arg,const char * values[])270 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
271 {
272   FIX_UNUSED (values);
273   if (arg) {
274     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
275   } else {
276     fprintf(outfile, "%s\n", opt);
277   }
278 }
279 
280 
281 int
options_dump(FILE * outfile,struct gengetopt_args_info * args_info)282 options_dump(FILE *outfile, struct gengetopt_args_info *args_info)
283 {
284   int i = 0;
285 
286   if (!outfile)
287     {
288       fprintf (stderr, "%s: cannot dump options to stream\n", OPTIONS_PACKAGE);
289       return EXIT_FAILURE;
290     }
291 
292   if (args_info->help_given)
293     write_into_file(outfile, "help", 0, 0 );
294   if (args_info->version_given)
295     write_into_file(outfile, "version", 0, 0 );
296   if (args_info->all_given)
297     write_into_file(outfile, "all", 0, 0 );
298   if (args_info->background_given)
299     write_into_file(outfile, "background", args_info->background_orig, 0);
300   if (args_info->backtrace_file_given)
301     write_into_file(outfile, "backtrace-file", args_info->backtrace_file_orig, 0);
302   if (args_info->backtrace_format_given)
303     write_into_file(outfile, "backtrace-format", args_info->backtrace_format_orig, 0);
304   if (args_info->foreground_given)
305     write_into_file(outfile, "foreground", args_info->foreground_orig, 0);
306   if (args_info->geometry_given)
307     write_into_file(outfile, "geometry", args_info->geometry_orig, 0);
308   if (args_info->nan_given)
309     write_into_file(outfile, "nan", args_info->nan_orig, 0);
310   if (args_info->list_given)
311     write_into_file(outfile, "list", 0, 0 );
312   if (args_info->select_given)
313     write_into_file(outfile, "select", args_info->select_orig, 0);
314   if (args_info->strict_given)
315     write_into_file(outfile, "strict", 0, 0 );
316   if (args_info->output_given)
317     write_into_file(outfile, "output", args_info->output_orig, 0);
318   if (args_info->preview_given)
319     write_into_file(outfile, "preview", 0, 0 );
320   if (args_info->type_given)
321     write_into_file(outfile, "type", args_info->type_orig, 0);
322   if (args_info->transparency_given)
323     write_into_file(outfile, "transparency", args_info->transparency_orig, 0);
324   if (args_info->verbose_given)
325     write_into_file(outfile, "verbose", 0, 0 );
326 
327 
328   i = EXIT_SUCCESS;
329   return i;
330 }
331 
332 int
options_file_save(const char * filename,struct gengetopt_args_info * args_info)333 options_file_save(const char *filename, struct gengetopt_args_info *args_info)
334 {
335   FILE *outfile;
336   int i = 0;
337 
338   outfile = fopen(filename, "w");
339 
340   if (!outfile)
341     {
342       fprintf (stderr, "%s: cannot open file for writing: %s\n", OPTIONS_PACKAGE, filename);
343       return EXIT_FAILURE;
344     }
345 
346   i = options_dump(outfile, args_info);
347   fclose (outfile);
348 
349   return i;
350 }
351 
352 void
options_free(struct gengetopt_args_info * args_info)353 options_free (struct gengetopt_args_info *args_info)
354 {
355   options_release (args_info);
356 }
357 
358 /** @brief replacement of strdup, which is not standard */
359 char *
gengetopt_strdup(const char * s)360 gengetopt_strdup (const char *s)
361 {
362   char *result = 0;
363   if (!s)
364     return result;
365 
366   result = (char*)malloc(strlen(s) + 1);
367   if (result == (char*)0)
368     return (char*)0;
369   strcpy(result, s);
370   return result;
371 }
372 
373 int
options(int argc,char ** argv,struct gengetopt_args_info * args_info)374 options (int argc, char **argv, struct gengetopt_args_info *args_info)
375 {
376   return options2 (argc, argv, args_info, 0, 1, 1);
377 }
378 
379 int
options_ext(int argc,char ** argv,struct gengetopt_args_info * args_info,struct options_params * params)380 options_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
381                    struct options_params *params)
382 {
383   int result;
384   result = options_internal (argc, argv, args_info, params, 0);
385 
386   if (result == EXIT_FAILURE)
387     {
388       options_free (args_info);
389       exit (EXIT_FAILURE);
390     }
391 
392   return result;
393 }
394 
395 int
options2(int argc,char ** argv,struct gengetopt_args_info * args_info,int override,int initialize,int check_required)396 options2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
397 {
398   int result;
399   struct options_params params;
400 
401   params.override = override;
402   params.initialize = initialize;
403   params.check_required = check_required;
404   params.check_ambiguity = 0;
405   params.print_errors = 1;
406 
407   result = options_internal (argc, argv, args_info, &params, 0);
408 
409   if (result == EXIT_FAILURE)
410     {
411       options_free (args_info);
412       exit (EXIT_FAILURE);
413     }
414 
415   return result;
416 }
417 
418 int
options_required(struct gengetopt_args_info * args_info,const char * prog_name)419 options_required (struct gengetopt_args_info *args_info, const char *prog_name)
420 {
421   FIX_UNUSED (args_info);
422   FIX_UNUSED (prog_name);
423   return EXIT_SUCCESS;
424 }
425 
426 
427 static char *package_name = 0;
428 
429 /**
430  * @brief updates an option
431  * @param field the generic pointer to the field to update
432  * @param orig_field the pointer to the orig field
433  * @param field_given the pointer to the number of occurrence of this option
434  * @param prev_given the pointer to the number of occurrence already seen
435  * @param value the argument for this option (if null no arg was specified)
436  * @param possible_values the possible values for this option (if specified)
437  * @param default_value the default value (in case the option only accepts fixed values)
438  * @param arg_type the type of this option
439  * @param check_ambiguity @see options_params.check_ambiguity
440  * @param override @see options_params.override
441  * @param no_free whether to free a possible previous value
442  * @param multiple_option whether this is a multiple option
443  * @param long_opt the corresponding long option
444  * @param short_opt the corresponding short option (or '-' if none)
445  * @param additional_error possible further error specification
446  */
447 static
update_arg(void * field,char ** orig_field,unsigned int * field_given,unsigned int * prev_given,char * value,const char * possible_values[],const char * default_value,options_arg_type arg_type,int check_ambiguity,int override,int no_free,int multiple_option,const char * long_opt,char short_opt,const char * additional_error)448 int update_arg(void *field, char **orig_field,
449                unsigned int *field_given, unsigned int *prev_given,
450                char *value, const char *possible_values[],
451                const char *default_value,
452                options_arg_type arg_type,
453                int check_ambiguity, int override,
454                int no_free, int multiple_option,
455                const char *long_opt, char short_opt,
456                const char *additional_error)
457 {
458   char *stop_char = 0;
459   const char *val = value;
460   int found;
461   char **string_field;
462   FIX_UNUSED (field);
463 
464   stop_char = 0;
465   found = 0;
466 
467   if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
468     {
469       if (short_opt != '-')
470         fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
471                package_name, long_opt, short_opt,
472                (additional_error ? additional_error : ""));
473       else
474         fprintf (stderr, "%s: `--%s' option given more than once%s\n",
475                package_name, long_opt,
476                (additional_error ? additional_error : ""));
477       return 1; /* failure */
478     }
479 
480   FIX_UNUSED (default_value);
481 
482   if (field_given && *field_given && ! override)
483     return 0;
484   if (prev_given)
485     (*prev_given)++;
486   if (field_given)
487     (*field_given)++;
488   if (possible_values)
489     val = possible_values[found];
490 
491   switch(arg_type) {
492   case ARG_FLAG:
493     *((int *)field) = !*((int *)field);
494     break;
495   case ARG_STRING:
496     if (val) {
497       string_field = (char **)field;
498       if (!no_free && *string_field)
499         free (*string_field); /* free previous string */
500       *string_field = gengetopt_strdup (val);
501     }
502     break;
503   default:
504     break;
505   };
506 
507 
508   /* store the original value */
509   switch(arg_type) {
510   case ARG_NO:
511   case ARG_FLAG:
512     break;
513   default:
514     if (value && orig_field) {
515       if (no_free) {
516         *orig_field = value;
517       } else {
518         if (*orig_field)
519           free (*orig_field); /* free previous string */
520         *orig_field = gengetopt_strdup (value);
521       }
522     }
523   };
524 
525   return 0; /* OK */
526 }
527 
528 
529 int
options_internal(int argc,char ** argv,struct gengetopt_args_info * args_info,struct options_params * params,const char * additional_error)530 options_internal (
531   int argc, char **argv, struct gengetopt_args_info *args_info,
532                         struct options_params *params, const char *additional_error)
533 {
534   int c;	/* Character of the parsed option.  */
535 
536   int error_occurred = 0;
537   struct gengetopt_args_info local_args_info;
538 
539   int override;
540   int initialize;
541   int check_required;
542   int check_ambiguity;
543 
544   package_name = argv[0];
545 
546   override = params->override;
547   initialize = params->initialize;
548   check_required = params->check_required;
549   check_ambiguity = params->check_ambiguity;
550 
551   if (initialize)
552     options_init (args_info);
553 
554   options_init (&local_args_info);
555 
556   optarg = 0;
557   optind = 0;
558   opterr = params->print_errors;
559   optopt = '?';
560 
561   while (1)
562     {
563       int option_index = 0;
564 
565       static struct option long_options[] = {
566         { "help",	0, NULL, 'h' },
567         { "version",	0, NULL, 'V' },
568         { "all",	0, NULL, 'a' },
569         { "background",	1, NULL, 'b' },
570         { "backtrace-file",	1, NULL, 0 },
571         { "backtrace-format",	1, NULL, 0 },
572         { "foreground",	1, NULL, 'f' },
573         { "geometry",	1, NULL, 'g' },
574         { "nan",	1, NULL, 'n' },
575         { "list",	0, NULL, 'l' },
576         { "select",	1, NULL, 's' },
577         { "strict",	0, NULL, 0 },
578         { "output",	1, NULL, 'o' },
579         { "preview",	0, NULL, 'p' },
580         { "type",	1, NULL, 't' },
581         { "transparency",	1, NULL, 'T' },
582         { "verbose",	0, NULL, 'v' },
583         { 0,  0, 0, 0 }
584       };
585 
586       c = getopt_long (argc, argv, "hVab:f:g:n:ls:o:pt:T:v", long_options, &option_index);
587 
588       if (c == -1) break;	/* Exit from `while (1)' loop.  */
589 
590       switch (c)
591         {
592         case 'h':	/* Print help and exit.  */
593           options_print_help ();
594           options_free (&local_args_info);
595           exit (EXIT_SUCCESS);
596 
597         case 'V':	/* Print version and exit.  */
598           options_print_version ();
599           options_free (&local_args_info);
600           exit (EXIT_SUCCESS);
601 
602         case 'a':	/* convert all gradients.  */
603 
604 
605           if (update_arg((void *)&(args_info->all_flag), 0, &(args_info->all_given),
606               &(local_args_info.all_given), optarg, 0, 0, ARG_FLAG,
607               check_ambiguity, override, 1, 0, "all", 'a',
608               additional_error))
609             goto failure;
610 
611           break;
612         case 'b':	/* background colour (cpt).  */
613 
614 
615           if (update_arg( (void *)&(args_info->background_arg),
616                &(args_info->background_orig), &(args_info->background_given),
617               &(local_args_info.background_given), optarg, 0, "0/0/0", ARG_STRING,
618               check_ambiguity, override, 0, 0,
619               "background", 'b',
620               additional_error))
621             goto failure;
622 
623           break;
624         case 'f':	/* foreground colour (cpt).  */
625 
626 
627           if (update_arg( (void *)&(args_info->foreground_arg),
628                &(args_info->foreground_orig), &(args_info->foreground_given),
629               &(local_args_info.foreground_given), optarg, 0, "255/255/255", ARG_STRING,
630               check_ambiguity, override, 0, 0,
631               "foreground", 'f',
632               additional_error))
633             goto failure;
634 
635           break;
636         case 'g':	/* image size (png, svg).  */
637 
638 
639           if (update_arg( (void *)&(args_info->geometry_arg),
640                &(args_info->geometry_orig), &(args_info->geometry_given),
641               &(local_args_info.geometry_given), optarg, 0, "340x36", ARG_STRING,
642               check_ambiguity, override, 0, 0,
643               "geometry", 'g',
644               additional_error))
645             goto failure;
646 
647           break;
648         case 'n':	/* nan colour (cpt).  */
649 
650 
651           if (update_arg( (void *)&(args_info->nan_arg),
652                &(args_info->nan_orig), &(args_info->nan_given),
653               &(local_args_info.nan_given), optarg, 0, "255/0/0", ARG_STRING,
654               check_ambiguity, override, 0, 0,
655               "nan", 'n',
656               additional_error))
657             goto failure;
658 
659           break;
660         case 'l':	/* list gradients in file.  */
661 
662 
663           if (update_arg((void *)&(args_info->list_flag), 0, &(args_info->list_given),
664               &(local_args_info.list_given), optarg, 0, 0, ARG_FLAG,
665               check_ambiguity, override, 1, 0, "list", 'l',
666               additional_error))
667             goto failure;
668 
669           break;
670         case 's':	/* convert gradient with specifed name.  */
671 
672 
673           if (update_arg( (void *)&(args_info->select_arg),
674                &(args_info->select_orig), &(args_info->select_given),
675               &(local_args_info.select_given), optarg, 0, 0, ARG_STRING,
676               check_ambiguity, override, 0, 0,
677               "select", 's',
678               additional_error))
679             goto failure;
680 
681           break;
682         case 'o':	/* output filename (not with -a).  */
683 
684 
685           if (update_arg( (void *)&(args_info->output_arg),
686                &(args_info->output_orig), &(args_info->output_given),
687               &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
688               check_ambiguity, override, 0, 0,
689               "output", 'o',
690               additional_error))
691             goto failure;
692 
693           break;
694         case 'p':	/* include preview (svg).  */
695 
696 
697           if (update_arg((void *)&(args_info->preview_flag), 0, &(args_info->preview_given),
698               &(local_args_info.preview_given), optarg, 0, 0, ARG_FLAG,
699               check_ambiguity, override, 1, 0, "preview", 'p',
700               additional_error))
701             goto failure;
702 
703           break;
704         case 't':	/* output format (see manual).  */
705 
706 
707           if (update_arg( (void *)&(args_info->type_arg),
708                &(args_info->type_orig), &(args_info->type_given),
709               &(local_args_info.type_given), optarg, 0, 0, ARG_STRING,
710               check_ambiguity, override, 0, 0,
711               "type", 't',
712               additional_error))
713             goto failure;
714 
715           break;
716         case 'T':	/* replace transparency by colour.  */
717 
718 
719           if (update_arg( (void *)&(args_info->transparency_arg),
720                &(args_info->transparency_orig), &(args_info->transparency_given),
721               &(local_args_info.transparency_given), optarg, 0, "255/255/255", ARG_STRING,
722               check_ambiguity, override, 0, 0,
723               "transparency", 'T',
724               additional_error))
725             goto failure;
726 
727           break;
728         case 'v':	/* verbose operation.  */
729 
730 
731           if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given),
732               &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG,
733               check_ambiguity, override, 1, 0, "verbose", 'v',
734               additional_error))
735             goto failure;
736 
737           break;
738 
739         case 0:	/* Long option with no short option */
740           /* write backtrace to file.  */
741           if (strcmp (long_options[option_index].name, "backtrace-file") == 0)
742           {
743 
744 
745             if (update_arg( (void *)&(args_info->backtrace_file_arg),
746                  &(args_info->backtrace_file_orig), &(args_info->backtrace_file_given),
747                 &(local_args_info.backtrace_file_given), optarg, 0, 0, ARG_STRING,
748                 check_ambiguity, override, 0, 0,
749                 "backtrace-file", '-',
750                 additional_error))
751               goto failure;
752 
753           }
754           /* backtrace format.  */
755           else if (strcmp (long_options[option_index].name, "backtrace-format") == 0)
756           {
757 
758 
759             if (update_arg( (void *)&(args_info->backtrace_format_arg),
760                  &(args_info->backtrace_format_orig), &(args_info->backtrace_format_given),
761                 &(local_args_info.backtrace_format_given), optarg, 0, 0, ARG_STRING,
762                 check_ambiguity, override, 0, 0,
763                 "backtrace-format", '-',
764                 additional_error))
765               goto failure;
766 
767           }
768           /* obey format limits on output.  */
769           else if (strcmp (long_options[option_index].name, "strict") == 0)
770           {
771 
772 
773             if (update_arg((void *)&(args_info->strict_flag), 0, &(args_info->strict_given),
774                 &(local_args_info.strict_given), optarg, 0, 0, ARG_FLAG,
775                 check_ambiguity, override, 1, 0, "strict", '-',
776                 additional_error))
777               goto failure;
778 
779           }
780 
781           break;
782         case '?':	/* Invalid option.  */
783           /* `getopt_long' already printed an error message.  */
784           goto failure;
785 
786         default:	/* bug: option not considered.  */
787           fprintf (stderr, "%s: option unknown: %c%s\n", OPTIONS_PACKAGE, c, (additional_error ? additional_error : ""));
788           abort ();
789         } /* switch */
790     } /* while */
791 
792 
793 
794 
795   options_release (&local_args_info);
796 
797   if ( error_occurred )
798     return (EXIT_FAILURE);
799 
800   if (optind < argc)
801     {
802       int i = 0 ;
803       int found_prog_name = 0;
804       /* whether program name, i.e., argv[0], is in the remaining args
805          (this may happen with some implementations of getopt,
806           but surely not with the one included by gengetopt) */
807 
808       i = optind;
809       while (i < argc)
810         if (argv[i++] == argv[0]) {
811           found_prog_name = 1;
812           break;
813         }
814       i = 0;
815 
816       args_info->inputs_num = argc - optind - found_prog_name;
817       args_info->inputs =
818         (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
819       while (optind < argc)
820         if (argv[optind++] != argv[0])
821           args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
822     }
823 
824   return 0;
825 
826 failure:
827 
828   options_release (&local_args_info);
829   return (EXIT_FAILURE);
830 }
831