|
10 | 10 | * This file was produced by using the `rename.pl` script included with
|
11 | 11 | * adopt. The command-line specified was:
|
12 | 12 | *
|
13 |
| - * ./rename.pl --out=../ntlmclient/cli/ --filename=ntlm_cli_opt ntlm_opt |
| 13 | + * ./rename.pl --filename=ntlm_cli_opt ntlm_opt |
14 | 14 | */
|
15 | 15 |
|
16 | 16 | #include <stdlib.h>
|
|
22 | 22 | #include "ntlm_cli_opt.h"
|
23 | 23 |
|
24 | 24 | #ifdef _WIN32
|
25 |
| -# include <Windows.h> |
| 25 | +# include <windows.h> |
26 | 26 | #else
|
27 | 27 | # include <fcntl.h>
|
28 | 28 | # include <sys/ioctl.h>
|
@@ -78,7 +78,7 @@ INLINE(const ntlm_opt_spec *) spec_for_long(
|
78 | 78 |
|
79 | 79 | /* Handle --option=value arguments */
|
80 | 80 | if (spec->type == NTLM_OPT_TYPE_VALUE &&
|
81 |
| - eql && |
| 81 | + spec->name && eql && |
82 | 82 | strncmp(arg, spec->name, eql_pos) == 0 &&
|
83 | 83 | spec->name[eql_pos] == '\0') {
|
84 | 84 | *has_value = 1;
|
@@ -580,6 +580,28 @@ ntlm_opt_status_t ntlm_opt_parse(
|
580 | 580 | return validate_required(opt, specs, given_specs);
|
581 | 581 | }
|
582 | 582 |
|
| 583 | +int ntlm_opt_foreach( |
| 584 | + const ntlm_opt_spec specs[], |
| 585 | + char **args, |
| 586 | + size_t args_len, |
| 587 | + unsigned int flags, |
| 588 | + int (*callback)(ntlm_opt *, void *), |
| 589 | + void *callback_data) |
| 590 | +{ |
| 591 | + ntlm_opt_parser parser; |
| 592 | + ntlm_opt opt; |
| 593 | + int ret; |
| 594 | + |
| 595 | + ntlm_opt_parser_init(&parser, specs, args, args_len, flags); |
| 596 | + |
| 597 | + while (ntlm_opt_parser_next(&opt, &parser)) { |
| 598 | + if ((ret = callback(&opt, callback_data)) != 0) |
| 599 | + return ret; |
| 600 | + } |
| 601 | + |
| 602 | + return 0; |
| 603 | +} |
| 604 | + |
583 | 605 | static int spec_name_fprint(FILE *file, const ntlm_opt_spec *spec)
|
584 | 606 | {
|
585 | 607 | int error;
|
@@ -621,7 +643,7 @@ int ntlm_opt_status_fprint(
|
621 | 643 | if ((error = fprintf(file, "argument '")) < 0 ||
|
622 | 644 | (error = spec_name_fprint(file, opt->spec)) < 0 ||
|
623 | 645 | (error = fprintf(file, "' requires a value.\n")) < 0)
|
624 |
| - ; |
| 646 | + break; |
625 | 647 | break;
|
626 | 648 | case NTLM_OPT_STATUS_MISSING_ARGUMENT:
|
627 | 649 | if (spec_is_choice(opt->spec)) {
|
|
0 commit comments