| .. | .. |
|---|
| 116 | 116 | case OPTION_INTEGER: |
|---|
| 117 | 117 | case OPTION_UINTEGER: |
|---|
| 118 | 118 | case OPTION_LONG: |
|---|
| 119 | + case OPTION_ULONG: |
|---|
| 119 | 120 | case OPTION_U64: |
|---|
| 120 | 121 | default: |
|---|
| 121 | 122 | break; |
|---|
| .. | .. |
|---|
| 166 | 167 | case OPTION_INTEGER: |
|---|
| 167 | 168 | case OPTION_UINTEGER: |
|---|
| 168 | 169 | case OPTION_LONG: |
|---|
| 170 | + case OPTION_ULONG: |
|---|
| 169 | 171 | case OPTION_U64: |
|---|
| 170 | 172 | default: |
|---|
| 171 | 173 | break; |
|---|
| .. | .. |
|---|
| 235 | 237 | return err; |
|---|
| 236 | 238 | |
|---|
| 237 | 239 | case OPTION_CALLBACK: |
|---|
| 240 | + if (opt->set) |
|---|
| 241 | + *(bool *)opt->set = true; |
|---|
| 242 | + |
|---|
| 238 | 243 | if (unset) |
|---|
| 239 | 244 | return (*opt->callback)(opt, NULL, 1) ? (-1) : 0; |
|---|
| 240 | 245 | if (opt->flags & PARSE_OPT_NOARG) |
|---|
| .. | .. |
|---|
| 291 | 296 | if (get_arg(p, opt, flags, &arg)) |
|---|
| 292 | 297 | return -1; |
|---|
| 293 | 298 | *(long *)opt->value = strtol(arg, (char **)&s, 10); |
|---|
| 299 | + if (*s) |
|---|
| 300 | + return opterror(opt, "expects a numerical value", flags); |
|---|
| 301 | + return 0; |
|---|
| 302 | + |
|---|
| 303 | + case OPTION_ULONG: |
|---|
| 304 | + if (unset) { |
|---|
| 305 | + *(unsigned long *)opt->value = 0; |
|---|
| 306 | + return 0; |
|---|
| 307 | + } |
|---|
| 308 | + if (opt->flags & PARSE_OPT_OPTARG && !p->opt) { |
|---|
| 309 | + *(unsigned long *)opt->value = opt->defval; |
|---|
| 310 | + return 0; |
|---|
| 311 | + } |
|---|
| 312 | + if (get_arg(p, opt, flags, &arg)) |
|---|
| 313 | + return -1; |
|---|
| 314 | + *(unsigned long *)opt->value = strtoul(arg, (char **)&s, 10); |
|---|
| 294 | 315 | if (*s) |
|---|
| 295 | 316 | return opterror(opt, "expects a numerical value", flags); |
|---|
| 296 | 317 | return 0; |
|---|
| .. | .. |
|---|
| 703 | 724 | case OPTION_ARGUMENT: |
|---|
| 704 | 725 | break; |
|---|
| 705 | 726 | case OPTION_LONG: |
|---|
| 727 | + case OPTION_ULONG: |
|---|
| 706 | 728 | case OPTION_U64: |
|---|
| 707 | 729 | case OPTION_INTEGER: |
|---|
| 708 | 730 | case OPTION_UINTEGER: |
|---|