Bug Summary

File:src/idn_cmd.c
Warning:line 535, column 3
Value stored to 'check_required' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name idn_cmd.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib/llvm-7/lib/clang/7.0.1 -D HAVE_CONFIG_H -I . -I .. -I ../lib -I ../lib -I ../gl -I ../gl -D LOCALEDIR="/usr/local/share/locale" -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir /home/jas/src/libidn/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -o /home/jas/src/libidn/scan.tmp/2020-07-22-175430-13732-1 -x c idn_cmd.c -faddrsig
1/*
2 File autogenerated by gengetopt version 2.22.6
3 generated with the following command:
4 gengetopt --unamed-opts --no-handle-version --no-handle-error --no-handle-help --set-package=idn --input idn.ggo --file-name idn_cmd Makefile.am
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_H1
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) (void) (X) /* avoid warnings for unused params */
22#endif
23
24#include <getopt.h>
25
26#include "idn_cmd.h"
27
28const char *gengetopt_args_info_purpose = "";
29
30const char *gengetopt_args_info_usage = "Usage: idn [OPTION]... [STRING]...";
31
32const char *gengetopt_args_info_versiontext = "";
33
34const char *gengetopt_args_info_description = "";
35
36const char *gengetopt_args_info_full_help[] = {
37 " -h, --help Print help and exit",
38 " --full-help Print help, including hidden options, and exit",
39 " -V, --version Print version and exit",
40 " -s, --stringprep Prepare string according to nameprep profile",
41 " -d, --punycode-decode Decode Punycode",
42 " -e, --punycode-encode Encode Punycode",
43 " -a, --idna-to-ascii Convert to ACE according to IDNA (default)",
44 " -u, --idna-to-unicode Convert from ACE according to IDNA",
45 " --allow-unassigned Toggle IDNA AllowUnassigned flag (default=off)",
46 " --usestd3asciirules Toggle IDNA UseSTD3ASCIIRules flag (default=off)",
47 " -t, --tld Check string for TLD specific rules\n Only for --idna-to-ascii and --idna-to-unicode\n (default=on)",
48 " --no-tld Don't check string for TLD specific rules\n Only for --idna-to-ascii and --idna-to-unicode\n (default=off)",
49 " -n, --nfkc Normalize string according to Unicode v3.2 NFKC",
50 " -k, --hidden-nfkc Hidden parameter for backwards compatibility",
51 " -p, --profile=STRING Use specified stringprep profile instead\n Valid stringprep profiles are: Nameprep iSCSI\n Nodeprep Resourceprep trace SASLprep",
52 " --debug Print debugging information (default=off)",
53 " --quiet Silent operation (default=off)",
54 0
55};
56
57static void
58init_help_array(void)
59{
60 gengetopt_args_info_help[0] = gengetopt_args_info_full_help[0];
61 gengetopt_args_info_help[1] = gengetopt_args_info_full_help[1];
62 gengetopt_args_info_help[2] = gengetopt_args_info_full_help[2];
63 gengetopt_args_info_help[3] = gengetopt_args_info_full_help[3];
64 gengetopt_args_info_help[4] = gengetopt_args_info_full_help[4];
65 gengetopt_args_info_help[5] = gengetopt_args_info_full_help[5];
66 gengetopt_args_info_help[6] = gengetopt_args_info_full_help[6];
67 gengetopt_args_info_help[7] = gengetopt_args_info_full_help[7];
68 gengetopt_args_info_help[8] = gengetopt_args_info_full_help[8];
69 gengetopt_args_info_help[9] = gengetopt_args_info_full_help[9];
70 gengetopt_args_info_help[10] = gengetopt_args_info_full_help[10];
71 gengetopt_args_info_help[11] = gengetopt_args_info_full_help[11];
72 gengetopt_args_info_help[12] = gengetopt_args_info_full_help[12];
73 gengetopt_args_info_help[13] = gengetopt_args_info_full_help[14];
74 gengetopt_args_info_help[14] = gengetopt_args_info_full_help[15];
75 gengetopt_args_info_help[15] = gengetopt_args_info_full_help[16];
76 gengetopt_args_info_help[16] = 0;
77
78}
79
80const char *gengetopt_args_info_help[17];
81
82typedef enum {ARG_NO
83 , ARG_FLAG
84 , ARG_STRING
85} cmdline_parser_arg_type;
86
87static
88void clear_given (struct gengetopt_args_info *args_info);
89static
90void clear_args (struct gengetopt_args_info *args_info);
91
92static int
93cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
94 struct cmdline_parser_params *params, const char *additional_error);
95
96
97static char *
98gengetopt_strdup (const char *s);
99
100static
101void clear_given (struct gengetopt_args_info *args_info)
102{
103 args_info->help_given = 0 ;
104 args_info->full_help_given = 0 ;
105 args_info->version_given = 0 ;
106 args_info->stringprep_given = 0 ;
107 args_info->punycode_decode_given = 0 ;
108 args_info->punycode_encode_given = 0 ;
109 args_info->idna_to_ascii_given = 0 ;
110 args_info->idna_to_unicode_given = 0 ;
111 args_info->allow_unassigned_given = 0 ;
112 args_info->usestd3asciirules_given = 0 ;
113 args_info->tld_given = 0 ;
114 args_info->no_tld_given = 0 ;
115 args_info->nfkc_given = 0 ;
116 args_info->hidden_nfkc_given = 0 ;
117 args_info->profile_given = 0 ;
118 args_info->debug_given = 0 ;
119 args_info->quiet_given = 0 ;
120}
121
122static
123void clear_args (struct gengetopt_args_info *args_info)
124{
125 FIX_UNUSED (args_info)(void) (args_info);
126 args_info->allow_unassigned_flag = 0;
127 args_info->usestd3asciirules_flag = 0;
128 args_info->tld_flag = 1;
129 args_info->no_tld_flag = 0;
130 args_info->profile_arg = NULL((void*)0);
131 args_info->profile_orig = NULL((void*)0);
132 args_info->debug_flag = 0;
133 args_info->quiet_flag = 0;
134
135}
136
137static
138void init_args_info(struct gengetopt_args_info *args_info)
139{
140
141 init_help_array();
142 args_info->help_help = gengetopt_args_info_full_help[0] ;
143 args_info->full_help_help = gengetopt_args_info_full_help[1] ;
144 args_info->version_help = gengetopt_args_info_full_help[2] ;
145 args_info->stringprep_help = gengetopt_args_info_full_help[3] ;
146 args_info->punycode_decode_help = gengetopt_args_info_full_help[4] ;
147 args_info->punycode_encode_help = gengetopt_args_info_full_help[5] ;
148 args_info->idna_to_ascii_help = gengetopt_args_info_full_help[6] ;
149 args_info->idna_to_unicode_help = gengetopt_args_info_full_help[7] ;
150 args_info->allow_unassigned_help = gengetopt_args_info_full_help[8] ;
151 args_info->usestd3asciirules_help = gengetopt_args_info_full_help[9] ;
152 args_info->tld_help = gengetopt_args_info_full_help[10] ;
153 args_info->no_tld_help = gengetopt_args_info_full_help[11] ;
154 args_info->nfkc_help = gengetopt_args_info_full_help[12] ;
155 args_info->hidden_nfkc_help = gengetopt_args_info_full_help[13] ;
156 args_info->profile_help = gengetopt_args_info_full_help[14] ;
157 args_info->debug_help = gengetopt_args_info_full_help[15] ;
158 args_info->quiet_help = gengetopt_args_info_full_help[16] ;
159
160}
161
162void
163cmdline_parser_print_version (void)
164{
165 printf ("%s %s\n",
166 (strlen(CMDLINE_PARSER_PACKAGE_NAME"idn") ? CMDLINE_PARSER_PACKAGE_NAME"idn" : CMDLINE_PARSER_PACKAGE"idn"),
167 CMDLINE_PARSER_VERSION"1.36");
168
169 if (strlen(gengetopt_args_info_versiontext) > 0)
170 printf("\n%s\n", gengetopt_args_info_versiontext);
171}
172
173static void print_help_common(void) {
174 cmdline_parser_print_version ();
175
176 if (strlen(gengetopt_args_info_purpose) > 0)
177 printf("\n%s\n", gengetopt_args_info_purpose);
178
179 if (strlen(gengetopt_args_info_usage) > 0)
180 printf("\n%s\n", gengetopt_args_info_usage);
181
182 printf("\n");
183
184 if (strlen(gengetopt_args_info_description) > 0)
185 printf("%s\n\n", gengetopt_args_info_description);
186}
187
188void
189cmdline_parser_print_help (void)
190{
191 int i = 0;
192 print_help_common();
193 while (gengetopt_args_info_help[i])
194 printf("%s\n", gengetopt_args_info_help[i++]);
195}
196
197void
198cmdline_parser_print_full_help (void)
199{
200 int i = 0;
201 print_help_common();
202 while (gengetopt_args_info_full_help[i])
203 printf("%s\n", gengetopt_args_info_full_help[i++]);
204}
205
206void
207cmdline_parser_init (struct gengetopt_args_info *args_info)
208{
209 clear_given (args_info);
210 clear_args (args_info);
211 init_args_info (args_info);
212
213 args_info->inputs = 0;
214 args_info->inputs_num = 0;
215}
216
217void
218cmdline_parser_params_init(struct cmdline_parser_params *params)
219{
220 if (params)
221 {
222 params->override = 0;
223 params->initialize = 1;
224 params->check_required = 1;
225 params->check_ambiguity = 0;
226 params->print_errors = 1;
227 }
228}
229
230struct cmdline_parser_params *
231cmdline_parser_params_create(void)
232{
233 struct cmdline_parser_params *params =
234 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
235 cmdline_parser_params_init(params);
236 return params;
237}
238
239static void
240free_string_field (char **s)
241{
242 if (*s)
243 {
244 free (*s);
245 *s = 0;
246 }
247}
248
249
250static void
251cmdline_parser_release (struct gengetopt_args_info *args_info)
252{
253 unsigned int i;
254 free_string_field (&(args_info->profile_arg));
255 free_string_field (&(args_info->profile_orig));
256
257
258 for (i = 0; i < args_info->inputs_num; ++i)
259 free (args_info->inputs [i]);
260
261 if (args_info->inputs_num)
262 free (args_info->inputs);
263
264 clear_given (args_info);
265}
266
267
268static void
269write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
270{
271 FIX_UNUSED (values)(void) (values);
272 if (arg) {
273 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
274 } else {
275 fprintf(outfile, "%s\n", opt);
276 }
277}
278
279
280int
281cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
282{
283 int i = 0;
284
285 if (!outfile)
286 {
287 fprintf (stderrstderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE"idn");
288 return EXIT_FAILURE1;
289 }
290
291 if (args_info->help_given)
292 write_into_file(outfile, "help", 0, 0 );
293 if (args_info->full_help_given)
294 write_into_file(outfile, "full-help", 0, 0 );
295 if (args_info->version_given)
296 write_into_file(outfile, "version", 0, 0 );
297 if (args_info->stringprep_given)
298 write_into_file(outfile, "stringprep", 0, 0 );
299 if (args_info->punycode_decode_given)
300 write_into_file(outfile, "punycode-decode", 0, 0 );
301 if (args_info->punycode_encode_given)
302 write_into_file(outfile, "punycode-encode", 0, 0 );
303 if (args_info->idna_to_ascii_given)
304 write_into_file(outfile, "idna-to-ascii", 0, 0 );
305 if (args_info->idna_to_unicode_given)
306 write_into_file(outfile, "idna-to-unicode", 0, 0 );
307 if (args_info->allow_unassigned_given)
308 write_into_file(outfile, "allow-unassigned", 0, 0 );
309 if (args_info->usestd3asciirules_given)
310 write_into_file(outfile, "usestd3asciirules", 0, 0 );
311 if (args_info->tld_given)
312 write_into_file(outfile, "tld", 0, 0 );
313 if (args_info->no_tld_given)
314 write_into_file(outfile, "no-tld", 0, 0 );
315 if (args_info->nfkc_given)
316 write_into_file(outfile, "nfkc", 0, 0 );
317 if (args_info->hidden_nfkc_given)
318 write_into_file(outfile, "hidden-nfkc", 0, 0 );
319 if (args_info->profile_given)
320 write_into_file(outfile, "profile", args_info->profile_orig, 0);
321 if (args_info->debug_given)
322 write_into_file(outfile, "debug", 0, 0 );
323 if (args_info->quiet_given)
324 write_into_file(outfile, "quiet", 0, 0 );
325
326
327 i = EXIT_SUCCESS0;
328 return i;
329}
330
331int
332cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
333{
334 FILE *outfile;
335 int i = 0;
336
337 outfile = fopen(filename, "w");
338
339 if (!outfile)
340 {
341 fprintf (stderrstderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE"idn", filename);
342 return EXIT_FAILURE1;
343 }
344
345 i = cmdline_parser_dump(outfile, args_info);
346 fclose (outfile);
347
348 return i;
349}
350
351void
352cmdline_parser_free (struct gengetopt_args_info *args_info)
353{
354 cmdline_parser_release (args_info);
355}
356
357/** @brief replacement of strdup, which is not standard */
358char *
359gengetopt_strdup (const char *s)
360{
361 char *result = 0;
362 if (!s)
363 return result;
364
365 result = (char*)malloc(strlen(s) + 1);
366 if (result == (char*)0)
367 return (char*)0;
368 strcpy(result, s);
369 return result;
370}
371
372int
373cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
374{
375 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
376}
377
378int
379cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
380 struct cmdline_parser_params *params)
381{
382 int result;
383 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
384
385 return result;
386}
387
388int
389cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
390{
391 int result;
392 struct cmdline_parser_params params;
393
394 params.override = override;
395 params.initialize = initialize;
396 params.check_required = check_required;
397 params.check_ambiguity = 0;
398 params.print_errors = 1;
399
400 result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
401
402 return result;
403}
404
405int
406cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
407{
408 FIX_UNUSED (args_info)(void) (args_info);
409 FIX_UNUSED (prog_name)(void) (prog_name);
410 return EXIT_SUCCESS0;
411}
412
413
414static char *package_name = 0;
415
416/**
417 * @brief updates an option
418 * @param field the generic pointer to the field to update
419 * @param orig_field the pointer to the orig field
420 * @param field_given the pointer to the number of occurrence of this option
421 * @param prev_given the pointer to the number of occurrence already seen
422 * @param value the argument for this option (if null no arg was specified)
423 * @param possible_values the possible values for this option (if specified)
424 * @param default_value the default value (in case the option only accepts fixed values)
425 * @param arg_type the type of this option
426 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
427 * @param override @see cmdline_parser_params.override
428 * @param no_free whether to free a possible previous value
429 * @param multiple_option whether this is a multiple option
430 * @param long_opt the corresponding long option
431 * @param short_opt the corresponding short option (or '-' if none)
432 * @param additional_error possible further error specification
433 */
434static
435int update_arg(void *field, char **orig_field,
436 unsigned int *field_given, unsigned int *prev_given,
437 char *value, const char *possible_values[],
438 const char *default_value,
439 cmdline_parser_arg_type arg_type,
440 int check_ambiguity, int override,
441 int no_free, int multiple_option,
442 const char *long_opt, char short_opt,
443 const char *additional_error)
444{
445 char *stop_char = 0;
446 const char *val = value;
447 int found;
448 char **string_field;
449 FIX_UNUSED (field)(void) (field);
450
451 stop_char = 0;
452 found = 0;
453
454 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
455 {
456 if (short_opt != '-')
457 fprintf (stderrstderr, "%s: `--%s' (`-%c') option given more than once%s\n",
458 package_name, long_opt, short_opt,
459 (additional_error ? additional_error : ""));
460 else
461 fprintf (stderrstderr, "%s: `--%s' option given more than once%s\n",
462 package_name, long_opt,
463 (additional_error ? additional_error : ""));
464 return 1; /* failure */
465 }
466
467 FIX_UNUSED (default_value)(void) (default_value);
468
469 if (field_given && *field_given && ! override)
470 return 0;
471 if (prev_given)
472 (*prev_given)++;
473 if (field_given)
474 (*field_given)++;
475 if (possible_values)
476 val = possible_values[found];
477
478 switch(arg_type) {
479 case ARG_FLAG:
480 *((int *)field) = !*((int *)field);
481 break;
482 case ARG_STRING:
483 if (val) {
484 string_field = (char **)field;
485 if (!no_free && *string_field)
486 free (*string_field); /* free previous string */
487 *string_field = gengetopt_strdup (val);
488 }
489 break;
490 default:
491 break;
492 };
493
494
495 /* store the original value */
496 switch(arg_type) {
497 case ARG_NO:
498 case ARG_FLAG:
499 break;
500 default:
501 if (value && orig_field) {
502 if (no_free) {
503 *orig_field = value;
504 } else {
505 if (*orig_field)
506 free (*orig_field); /* free previous string */
507 *orig_field = gengetopt_strdup (value);
508 }
509 }
510 };
511
512 return 0; /* OK */
513}
514
515
516int
517cmdline_parser_internal (
518 int argc, char **argv, struct gengetopt_args_info *args_info,
519 struct cmdline_parser_params *params, const char *additional_error)
520{
521 int c; /* Character of the parsed option. */
522
523 int error_occurred = 0;
524 struct gengetopt_args_info local_args_info;
525
526 int override;
527 int initialize;
528 int check_required;
529 int check_ambiguity;
530
531 package_name = argv[0];
532
533 override = params->override;
534 initialize = params->initialize;
535 check_required = params->check_required;
Value stored to 'check_required' is never read
536 check_ambiguity = params->check_ambiguity;
537
538 if (initialize)
539 cmdline_parser_init (args_info);
540
541 cmdline_parser_init (&local_args_info);
542
543 optarg = 0;
544 optind = 0;
545 opterr = params->print_errors;
546 optopt = '?';
547
548 while (1)
549 {
550 int option_index = 0;
551
552 static struct option long_options[] = {
553 { "help", 0, NULL((void*)0), 'h' },
554 { "full-help", 0, NULL((void*)0), 0 },
555 { "version", 0, NULL((void*)0), 'V' },
556 { "stringprep", 0, NULL((void*)0), 's' },
557 { "punycode-decode", 0, NULL((void*)0), 'd' },
558 { "punycode-encode", 0, NULL((void*)0), 'e' },
559 { "idna-to-ascii", 0, NULL((void*)0), 'a' },
560 { "idna-to-unicode", 0, NULL((void*)0), 'u' },
561 { "allow-unassigned", 0, NULL((void*)0), 0 },
562 { "usestd3asciirules", 0, NULL((void*)0), 0 },
563 { "tld", 0, NULL((void*)0), 't' },
564 { "no-tld", 0, NULL((void*)0), 0 },
565 { "nfkc", 0, NULL((void*)0), 'n' },
566 { "hidden-nfkc", 0, NULL((void*)0), 'k' },
567 { "profile", 1, NULL((void*)0), 'p' },
568 { "debug", 0, NULL((void*)0), 0 },
569 { "quiet", 0, NULL((void*)0), 0 },
570 { 0, 0, 0, 0 }
571 };
572
573 c = getopt_long (argc, argv, "hVsdeautnkp:", long_options, &option_index);
574
575 if (c == -1) break; /* Exit from `while (1)' loop. */
576
577 switch (c)
578 {
579 case 'h': /* Print help and exit. */
580
581
582 if (update_arg( 0 ,
583 0 , &(args_info->help_given),
584 &(local_args_info.help_given), optarg, 0, 0, ARG_NO,
585 check_ambiguity, override, 0, 0,
586 "help", 'h',
587 additional_error))
588 goto failure;
589 cmdline_parser_free (&local_args_info);
590 return 0;
591
592 break;
593 case 'V': /* Print version and exit. */
594
595
596 if (update_arg( 0 ,
597 0 , &(args_info->version_given),
598 &(local_args_info.version_given), optarg, 0, 0, ARG_NO,
599 check_ambiguity, override, 0, 0,
600 "version", 'V',
601 additional_error))
602 goto failure;
603 cmdline_parser_free (&local_args_info);
604 return 0;
605
606 break;
607 case 's': /* Prepare string according to nameprep profile. */
608
609
610 if (update_arg( 0 ,
611 0 , &(args_info->stringprep_given),
612 &(local_args_info.stringprep_given), optarg, 0, 0, ARG_NO,
613 check_ambiguity, override, 0, 0,
614 "stringprep", 's',
615 additional_error))
616 goto failure;
617
618 break;
619 case 'd': /* Decode Punycode. */
620
621
622 if (update_arg( 0 ,
623 0 , &(args_info->punycode_decode_given),
624 &(local_args_info.punycode_decode_given), optarg, 0, 0, ARG_NO,
625 check_ambiguity, override, 0, 0,
626 "punycode-decode", 'd',
627 additional_error))
628 goto failure;
629
630 break;
631 case 'e': /* Encode Punycode. */
632
633
634 if (update_arg( 0 ,
635 0 , &(args_info->punycode_encode_given),
636 &(local_args_info.punycode_encode_given), optarg, 0, 0, ARG_NO,
637 check_ambiguity, override, 0, 0,
638 "punycode-encode", 'e',
639 additional_error))
640 goto failure;
641
642 break;
643 case 'a': /* Convert to ACE according to IDNA (default). */
644
645
646 if (update_arg( 0 ,
647 0 , &(args_info->idna_to_ascii_given),
648 &(local_args_info.idna_to_ascii_given), optarg, 0, 0, ARG_NO,
649 check_ambiguity, override, 0, 0,
650 "idna-to-ascii", 'a',
651 additional_error))
652 goto failure;
653
654 break;
655 case 'u': /* Convert from ACE according to IDNA. */
656
657
658 if (update_arg( 0 ,
659 0 , &(args_info->idna_to_unicode_given),
660 &(local_args_info.idna_to_unicode_given), optarg, 0, 0, ARG_NO,
661 check_ambiguity, override, 0, 0,
662 "idna-to-unicode", 'u',
663 additional_error))
664 goto failure;
665
666 break;
667 case 't': /* Check string for TLD specific rules
668 Only for --idna-to-ascii and --idna-to-unicode. */
669
670
671 if (update_arg((void *)&(args_info->tld_flag), 0, &(args_info->tld_given),
672 &(local_args_info.tld_given), optarg, 0, 0, ARG_FLAG,
673 check_ambiguity, override, 1, 0, "tld", 't',
674 additional_error))
675 goto failure;
676
677 break;
678 case 'n': /* Normalize string according to Unicode v3.2 NFKC. */
679
680
681 if (update_arg( 0 ,
682 0 , &(args_info->nfkc_given),
683 &(local_args_info.nfkc_given), optarg, 0, 0, ARG_NO,
684 check_ambiguity, override, 0, 0,
685 "nfkc", 'n',
686 additional_error))
687 goto failure;
688
689 break;
690 case 'k': /* Hidden parameter for backwards compatibility. */
691
692
693 if (update_arg( 0 ,
694 0 , &(args_info->hidden_nfkc_given),
695 &(local_args_info.hidden_nfkc_given), optarg, 0, 0, ARG_NO,
696 check_ambiguity, override, 0, 0,
697 "hidden-nfkc", 'k',
698 additional_error))
699 goto failure;
700
701 break;
702 case 'p': /* Use specified stringprep profile instead
703 Valid stringprep profiles are: Nameprep iSCSI Nodeprep Resourceprep trace SASLprep. */
704
705
706 if (update_arg( (void *)&(args_info->profile_arg),
707 &(args_info->profile_orig), &(args_info->profile_given),
708 &(local_args_info.profile_given), optarg, 0, 0, ARG_STRING,
709 check_ambiguity, override, 0, 0,
710 "profile", 'p',
711 additional_error))
712 goto failure;
713
714 break;
715
716 case 0: /* Long option with no short option */
717 /* Print help, including hidden options, and exit. */
718 if (strcmp (long_options[option_index].name, "full-help") == 0)
719 {
720
721
722 if (update_arg( 0 ,
723 0 , &(args_info->full_help_given),
724 &(local_args_info.full_help_given), optarg, 0, 0, ARG_NO,
725 check_ambiguity, override, 0, 0,
726 "full-help", '-',
727 additional_error))
728 goto failure;
729 cmdline_parser_free (&local_args_info);
730 return 0;
731
732 }
733 /* Toggle IDNA AllowUnassigned flag. */
734 else if (strcmp (long_options[option_index].name, "allow-unassigned") == 0)
735 {
736
737
738 if (update_arg((void *)&(args_info->allow_unassigned_flag), 0, &(args_info->allow_unassigned_given),
739 &(local_args_info.allow_unassigned_given), optarg, 0, 0, ARG_FLAG,
740 check_ambiguity, override, 1, 0, "allow-unassigned", '-',
741 additional_error))
742 goto failure;
743
744 }
745 /* Toggle IDNA UseSTD3ASCIIRules flag. */
746 else if (strcmp (long_options[option_index].name, "usestd3asciirules") == 0)
747 {
748
749
750 if (update_arg((void *)&(args_info->usestd3asciirules_flag), 0, &(args_info->usestd3asciirules_given),
751 &(local_args_info.usestd3asciirules_given), optarg, 0, 0, ARG_FLAG,
752 check_ambiguity, override, 1, 0, "usestd3asciirules", '-',
753 additional_error))
754 goto failure;
755
756 }
757 /* Don't check string for TLD specific rules
758 Only for --idna-to-ascii and --idna-to-unicode. */
759 else if (strcmp (long_options[option_index].name, "no-tld") == 0)
760 {
761
762
763 if (update_arg((void *)&(args_info->no_tld_flag), 0, &(args_info->no_tld_given),
764 &(local_args_info.no_tld_given), optarg, 0, 0, ARG_FLAG,
765 check_ambiguity, override, 1, 0, "no-tld", '-',
766 additional_error))
767 goto failure;
768
769 }
770 /* Print debugging information. */
771 else if (strcmp (long_options[option_index].name, "debug") == 0)
772 {
773
774
775 if (update_arg((void *)&(args_info->debug_flag), 0, &(args_info->debug_given),
776 &(local_args_info.debug_given), optarg, 0, 0, ARG_FLAG,
777 check_ambiguity, override, 1, 0, "debug", '-',
778 additional_error))
779 goto failure;
780
781 }
782 /* Silent operation. */
783 else if (strcmp (long_options[option_index].name, "quiet") == 0)
784 {
785
786
787 if (update_arg((void *)&(args_info->quiet_flag), 0, &(args_info->quiet_given),
788 &(local_args_info.quiet_given), optarg, 0, 0, ARG_FLAG,
789 check_ambiguity, override, 1, 0, "quiet", '-',
790 additional_error))
791 goto failure;
792
793 }
794
795 break;
796 case '?': /* Invalid option. */
797 /* `getopt_long' already printed an error message. */
798 goto failure;
799
800 default: /* bug: option not considered. */
801 fprintf (stderrstderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE"idn", c, (additional_error ? additional_error : ""));
802 abort ();
803 } /* switch */
804 } /* while */
805
806
807
808
809 cmdline_parser_release (&local_args_info);
810
811 if ( error_occurred )
812 return (EXIT_FAILURE1);
813
814 if (optind < argc)
815 {
816 int i = 0 ;
817 int found_prog_name = 0;
818 /* whether program name, i.e., argv[0], is in the remaining args
819 (this may happen with some implementations of getopt,
820 but surely not with the one included by gengetopt) */
821
822 i = optind;
823 while (i < argc)
824 if (argv[i++] == argv[0]) {
825 found_prog_name = 1;
826 break;
827 }
828 i = 0;
829
830 args_info->inputs_num = argc - optind - found_prog_name;
831 args_info->inputs =
832 (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
833 while (optind < argc)
834 if (argv[optind++] != argv[0])
835 args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ;
836 }
837
838 return 0;
839
840failure:
841
842 cmdline_parser_release (&local_args_info);
843 return (EXIT_FAILURE1);
844}