2 * Read some text from standard input and format it with help_print_desc,
3 * for testing. Each pair of program arguments is converted to an int and
4 * passed as the two integer arguments to help_print_desc.
17 static char buf[1000];
19 int arg_to_int(const char *s)
25 val = strtol(s, &end, 0);
27 tap_bail_out("%s: numeric argument expected", s);
28 else if (val < INT_MIN || val > INT_MAX || errno == ERANGE)
29 tap_bail_out("%s: %s", s, strerror(ERANGE));
31 tap_bail_out("%s: %s", s, strerror(errno));
36 void print_opt(struct option *opt, const char *argname, int w)
38 w = help_print_optstring(opt, argname, w);
42 int main(int argc, char **argv)
44 struct option opt = {0};
45 const char *argname = 0;
48 for (i = 1; i < argc; i++) {
49 if (argv[i][0] == '-' && argv[i][1] == '-') {
51 print_opt(&opt, argname, w);
52 opt.val = UCHAR_MAX+1;
55 } else if (argv[i][0] == '-') {
57 } else if (argv[i][0] == '[') {
61 if ((c = strchr(argname, ']')))
64 } else if (argv[i][0] >= '0' && argv[i][0] <= '9') {
65 w = arg_to_int(argv[i]);
73 print_opt(&opt, argname, w);