diff options
| author | David M. Syzdek <david@syzdek.net> | 2023-01-16 11:50:52 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2023-01-16 12:32:20 -0900 |
| commit | 07d1f1608918fdc1e7685ccf75fb01208cbfa476 (patch) | |
| tree | f769cf0f4ecca0fffd7e34d9685ce8b97b115a75 /src | |
| parent | 2c7dce030f8c538ce70d361ec5c2ff83a05c14d2 (diff) | |
| download | otputils-07d1f1608918fdc1e7685ccf75fb01208cbfa476.tar.gz otputils-07d1f1608918fdc1e7685ccf75fb01208cbfa476.tar.bz2 otputils-07d1f1608918fdc1e7685ccf75fb01208cbfa476.tar.xz otputils-07d1f1608918fdc1e7685ccf75fb01208cbfa476.zip | |
otputil: addig 'debug' widget
Adding widget which shows usage for all widgets.
Diffstat (limited to 'src')
| -rw-r--r-- | src/otputil.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/otputil.c b/src/otputil.c index 8528010..7df9045 100644 --- a/src/otputil.c +++ b/src/otputil.c | |||
| @@ -117,6 +117,11 @@ otputil_widget_lookup( | |||
| 117 | #pragma mark widgets prototypes | 117 | #pragma mark widgets prototypes |
| 118 | 118 | ||
| 119 | static int | 119 | static int |
| 120 | otputil_widget_debug( | ||
| 121 | otputil_config_t * cnf ); | ||
| 122 | |||
| 123 | |||
| 124 | static int | ||
| 120 | otputil_widget_usage( | 125 | otputil_widget_usage( |
| 121 | otputil_config_t * cnf ); | 126 | otputil_config_t * cnf ); |
| 122 | 127 | ||
| @@ -137,6 +142,18 @@ otputil_widget_version( | |||
| 137 | #pragma mark otputil_widget_map[] | 142 | #pragma mark otputil_widget_map[] |
| 138 | static otputil_widget_t otputil_widget_map[] = | 143 | static otputil_widget_t otputil_widget_map[] = |
| 139 | { | 144 | { |
| 145 | #ifdef USE_DEBUG | ||
| 146 | { .name = "debug", | ||
| 147 | .desc = NULL, | ||
| 148 | .usage = NULL, | ||
| 149 | .short_opt = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", | ||
| 150 | .arg_min = 0, | ||
| 151 | .arg_max = 4096, | ||
| 152 | .aliases = NULL, | ||
| 153 | .func_exec = &otputil_widget_debug, | ||
| 154 | .func_usage = NULL, | ||
| 155 | }, | ||
| 156 | #endif | ||
| 140 | { .name = "help", | 157 | { .name = "help", |
| 141 | .desc = "display help", | 158 | .desc = "display help", |
| 142 | .usage = NULL, | 159 | .usage = NULL, |
| @@ -550,6 +567,27 @@ otputil_widget_lookup( | |||
| 550 | //-------------------// | 567 | //-------------------// |
| 551 | #pragma mark widgets functions | 568 | #pragma mark widgets functions |
| 552 | 569 | ||
| 570 | int | ||
| 571 | otputil_widget_debug( | ||
| 572 | otputil_config_t * cnf ) | ||
| 573 | { | ||
| 574 | int rc; | ||
| 575 | int pos; | ||
| 576 | |||
| 577 | // initial processing of cli arguments | ||
| 578 | if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) | ||
| 579 | return((rc == -1) ? 0 : 1); | ||
| 580 | if (optind != cnf->argc) | ||
| 581 | { | ||
| 582 | printf("Arguments:\n"); | ||
| 583 | for(pos = optind; (pos < cnf->argc); pos++) | ||
| 584 | printf(" %2i: \"%s\"\n", pos, cnf->argv[pos]); | ||
| 585 | }; | ||
| 586 | |||
| 587 | return(0); | ||
| 588 | } | ||
| 589 | |||
| 590 | |||
| 553 | /// displays usage information | 591 | /// displays usage information |
| 554 | int | 592 | int |
| 555 | otputil_widget_usage( | 593 | otputil_widget_usage( |
