aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-03-28 11:30:37 -0800
committerDavid M. Syzdek <david@syzdek.net>2022-03-28 11:30:37 -0800
commita026948ee3f8839cb9d789493306a9b55f9cd638 (patch)
tree98207e0085fb5a73440127824dac77f6226ff300
parentacc8b9a411071f9b4c38f860095700e3a142dbcf (diff)
downloadtinyrad-a026948ee3f8839cb9d789493306a9b55f9cd638.tar.gz
tinyrad-a026948ee3f8839cb9d789493306a9b55f9cd638.tar.bz2
tinyrad-a026948ee3f8839cb9d789493306a9b55f9cd638.tar.xz
tinyrad-a026948ee3f8839cb9d789493306a9b55f9cd638.zip
tinyrad: updating member names in TinyRadUtilConf
-rw-r--r--src/tru/tinyradutil.c40
-rw-r--r--src/tru/tinyradutil.h10
2 files changed, 25 insertions, 25 deletions
diff --git a/src/tru/tinyradutil.c b/src/tru/tinyradutil.c
index 5524931..9fb8ffc 100644
--- a/src/tru/tinyradutil.c
+++ b/src/tru/tinyradutil.c
@@ -198,14 +198,14 @@ int main(int argc, char * argv[])
198 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); 198 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
199 return(1); 199 return(1);
200 }; 200 };
201 cnf->cmd_argc = (argc - optind); 201 cnf->argc = (argc - optind);
202 cnf->cmd_argv = &argv[optind]; 202 cnf->argv = &argv[optind];
203 cnf->cmd_name = cnf->cmd_argv[0]; 203 cnf->widget_name = cnf->argv[0];
204 204
205 // looks up widget 205 // looks up widget
206 if ((cnf->cmd = tru_widget_lookup(cnf->cmd_argv[0], TRAD_NO)) == NULL) 206 if ((cnf->widget = tru_widget_lookup(cnf->argv[0], TRAD_NO)) == NULL)
207 { 207 {
208 fprintf(stderr, "%s: unknown or ambiguous widget -- \"%s\"\n", PROGRAM_NAME, cnf->cmd_argv[0]); 208 fprintf(stderr, "%s: unknown or ambiguous widget -- \"%s\"\n", PROGRAM_NAME, cnf->argv[0]);
209 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); 209 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
210 return(1); 210 return(1);
211 }; 211 };
@@ -213,7 +213,7 @@ int main(int argc, char * argv[])
213 // process widget cli options 213 // process widget cli options
214 optind = 1; 214 optind = 1;
215 opt_index = 0; 215 opt_index = 0;
216 while((c = tru_getopt(cnf, cnf->cmd_argc, cnf->cmd_argv, cnf->cmd->shortopts, cnf->cmd->longopts, &opt_index)) != -1) 216 while((c = tru_getopt(cnf, cnf->argc, cnf->argv, cnf->widget->shortopts, cnf->widget->longopts, &opt_index)) != -1)
217 { 217 {
218 switch(c) 218 switch(c)
219 { 219 {
@@ -231,30 +231,30 @@ int main(int argc, char * argv[])
231 return(1); 231 return(1);
232 232
233 case '?': 233 case '?':
234 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->cmd_name); 234 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->widget_name);
235 return(1); 235 return(1);
236 236
237 default: 237 default:
238 fprintf(stderr, "%s: %s: unrecognized option `--%c'\n", PROGRAM_NAME, cnf->cmd_name, c); 238 fprintf(stderr, "%s: %s: unrecognized option `--%c'\n", PROGRAM_NAME, cnf->widget_name, c);
239 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->cmd_name); 239 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->widget_name);
240 return(1); 240 return(1);
241 }; 241 };
242 }; 242 };
243 if ((cnf->cmd_argc - optind) < cnf->cmd->min_arg) 243 if ((cnf->argc - optind) < cnf->widget->min_arg)
244 { 244 {
245 fprintf(stderr, "%s: missing required argument\n", PROGRAM_NAME); 245 fprintf(stderr, "%s: missing required argument\n", PROGRAM_NAME);
246 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->cmd_name); 246 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->widget_name);
247 return(1); 247 return(1);
248 }; 248 };
249 if ((optind+cnf->cmd->max_arg) > cnf->cmd_argc) 249 if ((optind+cnf->widget->max_arg) > cnf->argc)
250 { 250 {
251 fprintf(stderr, "%s: unrecognized argument `-- %s'\n", PROGRAM_NAME, cnf->cmd_argv[optind+1]); 251 fprintf(stderr, "%s: unrecognized argument `-- %s'\n", PROGRAM_NAME, cnf->argv[optind+1]);
252 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->cmd_name); 252 fprintf(stderr, "Try `%s %s --help' for more information.\n", PROGRAM_NAME, cnf->widget_name);
253 return(1); 253 return(1);
254 }; 254 };
255 255
256 // call widget 256 // call widget
257 rc = cnf->cmd->func(cnf); 257 rc = cnf->widget->func(cnf);
258 tru_cleanup(cnf); 258 tru_cleanup(cnf);
259 return(trutils_exit_code(rc)); 259 return(trutils_exit_code(rc));
260} 260}
@@ -397,9 +397,9 @@ tru_usage(
397 const char * help; 397 const char * help;
398 const char * s; 398 const char * s;
399 399
400 name = (!(cnf->cmd)) ? "widget" : cnf->cmd->name; 400 name = (!(cnf->widget)) ? "widget" : cnf->widget->name;
401 help = (!(cnf->cmd)) ? " ..." : (((cnf->cmd->usage)) ? cnf->cmd->usage : ""); 401 help = (!(cnf->widget)) ? " ..." : (((cnf->widget->usage)) ? cnf->widget->usage : "");
402 s = (!(cnf->cmd)) ? TRU_COMMON_SHORT : (((cnf->cmd->shortopts)) ? cnf->cmd->shortopts : TRU_COMMON_SHORT); 402 s = (!(cnf->widget)) ? TRU_COMMON_SHORT : (((cnf->widget->shortopts)) ? cnf->widget->shortopts : TRU_COMMON_SHORT);
403 403
404 printf("Usage: %s %s [OPTIONS]%s\n", PROGRAM_NAME, name, help); 404 printf("Usage: %s %s [OPTIONS]%s\n", PROGRAM_NAME, name, help);
405 printf("OPTIONS:\n"); 405 printf("OPTIONS:\n");
@@ -412,9 +412,9 @@ tru_usage(
412 if ((strchr(s, 'q'))) printf(" -q, --quiet, --silent do not print messages\n"); 412 if ((strchr(s, 'q'))) printf(" -q, --quiet, --silent do not print messages\n");
413 if ((strchr(s, 'V'))) printf(" -V, --version print version number and exit\n"); 413 if ((strchr(s, 'V'))) printf(" -V, --version print version number and exit\n");
414 if ((strchr(s, 'v'))) printf(" -v, --verbose print verbose messages\n"); 414 if ((strchr(s, 'v'))) printf(" -v, --verbose print verbose messages\n");
415 if (!(cnf->cmd)) 415 if (!(cnf->widget))
416 { 416 {
417 printf("COMMANDS:\n"); 417 printf("WIDGETS:\n");
418 for(i = 0; tru_widget_map[i].name != NULL; i++) 418 for(i = 0; tru_widget_map[i].name != NULL; i++)
419 if ((tru_widget_map[i].desc)) 419 if ((tru_widget_map[i].desc))
420 printf(" %-25s %s\n", tru_widget_map[i].name, tru_widget_map[i].desc); 420 printf(" %-25s %s\n", tru_widget_map[i].name, tru_widget_map[i].desc);
diff --git a/src/tru/tinyradutil.h b/src/tru/tinyradutil.h
index 0e92e49..c470257 100644
--- a/src/tru/tinyradutil.h
+++ b/src/tru/tinyradutil.h
@@ -116,12 +116,12 @@ struct tinyrad_util_config
116 unsigned opts; 116 unsigned opts;
117 unsigned tr_opts; 117 unsigned tr_opts;
118 int padint; 118 int padint;
119 int cmd_argc; 119 int argc;
120 char ** cmd_argv; 120 char ** argv;
121 const char * cmd_name; 121 const char * widget_name;
122 size_t cmd_len; 122 size_t widget_name_len;
123 void * padptr; 123 void * padptr;
124 const TinyRadUtilWidget * cmd; 124 const TinyRadUtilWidget * widget;
125 TinyRad * tr; 125 TinyRad * tr;
126 const char * url; 126 const char * url;
127 char ** dict_files; 127 char ** dict_files;