comparison th_args.c @ 380:ac10155d2b4a

Rename th_optarg_t to t_optarg. API break.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 01 Mar 2016 17:21:22 +0200
parents f4e182720870
children 1b3472ba7b23
comparison
equal deleted inserted replaced
379:f4e182720870 380:ac10155d2b4a
15 /* Parse long and short options 15 /* Parse long and short options
16 */ 16 */
17 static BOOL th_args_process_opt( 17 static BOOL th_args_process_opt(
18 char *currArg, int *argIndex, 18 char *currArg, int *argIndex,
19 int argc, char *argv[], 19 int argc, char *argv[],
20 const th_optarg_t opts[], int nopts, 20 const th_optarg opts[], int nopts,
21 BOOL (*handle_option)(int id, char *, char *), 21 BOOL (*handle_option)(int id, char *, char *),
22 BOOL doProcess, BOOL isLong) 22 BOOL doProcess, BOOL isLong)
23 { 23 {
24 const th_optarg_t *opt = NULL; 24 const th_optarg *opt = NULL;
25 char *optArg = NULL; 25 char *optArg = NULL;
26 int optIndex; 26 int optIndex;
27 27
28 for (optIndex = 0; optIndex < nopts; optIndex++) 28 for (optIndex = 0; optIndex < nopts; optIndex++)
29 { 29 {
30 const th_optarg_t *node = &opts[optIndex]; 30 const th_optarg *node = &opts[optIndex];
31 if (isLong && node->o_long != NULL) 31 if (isLong && node->o_long != NULL)
32 { 32 {
33 if (strcmp(currArg, node->o_long) == 0) 33 if (strcmp(currArg, node->o_long) == 0)
34 { 34 {
35 opt = node; 35 opt = node;
97 97
98 /* Process arguments, handling short and long options by 98 /* Process arguments, handling short and long options by
99 * calling the given callback functions. 99 * calling the given callback functions.
100 */ 100 */
101 BOOL th_args_process(int argc, char *argv[], 101 BOOL th_args_process(int argc, char *argv[],
102 const th_optarg_t *opts, const int nopts, 102 const th_optarg *opts, const int nopts,
103 BOOL(*handle_option)(int id, char *, char *), 103 BOOL(*handle_option)(int id, char *, char *),
104 BOOL(*handle_other)(char *), const int flags) 104 BOOL(*handle_other)(char *), const int flags)
105 { 105 {
106 int argIndex, handleFlags = flags & OPTH_ONLY_MASK; 106 int argIndex, handleFlags = flags & OPTH_ONLY_MASK;
107 BOOL optionsOK = TRUE, endOfOptions = FALSE; 107 BOOL optionsOK = TRUE, endOfOptions = FALSE;
158 158
159 159
160 /* Print help for commandline arguments/options 160 /* Print help for commandline arguments/options
161 */ 161 */
162 void th_args_help(FILE *fh, 162 void th_args_help(FILE *fh,
163 const th_optarg_t *opts, const int nopts, 163 const th_optarg *opts, const int nopts,
164 const int flags) 164 const int flags)
165 { 165 {
166 int index; 166 int index;
167 (void) flags; 167 (void) flags;
168 168
169 // Print out option list 169 // Print out option list
170 for (index = 0; index < nopts; index++) 170 for (index = 0; index < nopts; index++)
171 { 171 {
172 const th_optarg_t *opt = &opts[index]; 172 const th_optarg *opt = &opts[index];
173 char tmpStr[128]; 173 char tmpStr[128];
174 174
175 // Print short option 175 // Print short option
176 if (opt->o_short != 0) 176 if (opt->o_short != 0)
177 { 177 {