aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tinyrad.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tinyrad.c')
-rw-r--r--src/tinyrad.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/tinyrad.c b/src/tinyrad.c
index 6e530e5..a626f5e 100644
--- a/src/tinyrad.c
+++ b/src/tinyrad.c
@@ -108,8 +108,12 @@ typedef struct my_request_av
108struct tinyrad_config 108struct tinyrad_config
109{ 109{
110 unsigned opts; 110 unsigned opts;
111 unsigned padint; 111 unsigned tr_opts;
112 TinyRadCommand * cmd; 112 TinyRadCommand * cmd;
113 TinyRad * tr;
114 const char * url;
115 char ** dict_files;
116 char ** dict_paths;
113}; 117};
114 118
115 119
@@ -188,14 +192,13 @@ int main(int argc, char * argv[])
188 int c; 192 int c;
189 int opt_index; 193 int opt_index;
190 int rc; 194 int rc;
191 unsigned tr_opts;
192 TinyRadDict * dict; 195 TinyRadDict * dict;
193 TinyRad * tr; 196 TinyRad * tr;
194 const char * url; 197 const char * url;
195 char ** dict_files; 198 char ** dict_files;
196 char ** dict_paths; 199 char ** dict_paths;
197 unsigned opts; 200 TinyRadConf cnfdata;
198 TinyRadConf cnf; 201 TinyRadConf * cnf;
199 202
200 // getopt options 203 // getopt options
201 static char short_opt[] = "D:d:f:hI:qVv"; 204 static char short_opt[] = "D:d:f:hI:qVv";
@@ -216,9 +219,8 @@ int main(int argc, char * argv[])
216 219
217 trutils_initialize(PROGRAM_NAME); 220 trutils_initialize(PROGRAM_NAME);
218 221
219 memset(&cnf, 0, sizeof(cnf)); 222 memset(&cnfdata, 0, sizeof(cnfdata));
220 opts = 0; 223 cnf = &cnfdata;
221 tr_opts = 0;
222 url = NULL; 224 url = NULL;
223 dict = NULL; 225 dict = NULL;
224 dict_files = NULL; 226 dict_files = NULL;
@@ -233,21 +235,21 @@ int main(int argc, char * argv[])
233 break; 235 break;
234 236
235 case 1: 237 case 1:
236 opts |= MY_OPT_DICT_DUMP; 238 cnf->opts |= MY_OPT_DICT_DUMP;
237 break; 239 break;
238 240
239 case 2: 241 case 2:
240 tr_opts |= TRAD_BUILTIN_DICT; 242 cnf->tr_opts |= TRAD_BUILTIN_DICT;
241 break; 243 break;
242 244
243 case 3: 245 case 3:
244 opts |= MY_OPT_CONFIG_PRINT; 246 cnf->opts |= MY_OPT_CONFIG_PRINT;
245 break; 247 break;
246 248
247 case 'D': 249 case 'D':
248 if (tinyrad_strsadd(&dict_files, optarg) != TRAD_SUCCESS) 250 if (tinyrad_strsadd(&dict_files, optarg) != TRAD_SUCCESS)
249 { 251 {
250 trutils_error(opts, NULL, "out of virtual memory"); 252 trutils_error(cnf->opts, NULL, "out of virtual memory");
251 tinyrad_strsfree(dict_files); 253 tinyrad_strsfree(dict_files);
252 tinyrad_strsfree(dict_paths); 254 tinyrad_strsfree(dict_paths);
253 return(trutils_exit_code(TRAD_ENOMEM)); 255 return(trutils_exit_code(TRAD_ENOMEM));
@@ -260,13 +262,13 @@ int main(int argc, char * argv[])
260 break; 262 break;
261 263
262 case 'h': 264 case 'h':
263 tinyrad_usage(&cnf); 265 tinyrad_usage(cnf);
264 return(0); 266 return(0);
265 267
266 case 'I': 268 case 'I':
267 if (tinyrad_strsadd(&dict_paths, optarg) != TRAD_SUCCESS) 269 if (tinyrad_strsadd(&dict_paths, optarg) != TRAD_SUCCESS)
268 { 270 {
269 trutils_error(opts, NULL, "out of virtual memory"); 271 trutils_error(cnf->opts, NULL, "out of virtual memory");
270 tinyrad_strsfree(dict_files); 272 tinyrad_strsfree(dict_files);
271 tinyrad_strsfree(dict_paths); 273 tinyrad_strsfree(dict_paths);
272 return(trutils_exit_code(TRAD_ENOMEM)); 274 return(trutils_exit_code(TRAD_ENOMEM));
@@ -274,8 +276,8 @@ int main(int argc, char * argv[])
274 break; 276 break;
275 277
276 case 'q': 278 case 'q':
277 opts |= TRUTILS_OPT_QUIET; 279 cnf->opts |= TRUTILS_OPT_QUIET;
278 opts &= ~TRUTILS_OPT_VERBOSE; 280 cnf->opts &= ~TRUTILS_OPT_VERBOSE;
279 break; 281 break;
280 282
281 case 'V': 283 case 'V':
@@ -283,8 +285,8 @@ int main(int argc, char * argv[])
283 return(0); 285 return(0);
284 286
285 case 'v': 287 case 'v':
286 opts |= TRUTILS_OPT_VERBOSE; 288 cnf->opts |= TRUTILS_OPT_VERBOSE;
287 opts &= ~TRUTILS_OPT_QUIET; 289 cnf->opts &= ~TRUTILS_OPT_QUIET;
288 break; 290 break;
289 291
290 case '?': 292 case '?':
@@ -312,14 +314,14 @@ int main(int argc, char * argv[])
312 }; 314 };
313 315
314 // load TinyRad handle 316 // load TinyRad handle
315 rc = tinyrad_load_dict(opts, tr_opts, &tr, url, dict_files, dict_paths); 317 rc = tinyrad_load_dict(cnf->opts, cnf->tr_opts, &tr, url, dict_files, dict_paths);
316 tinyrad_strsfree(dict_files); 318 tinyrad_strsfree(dict_files);
317 tinyrad_strsfree(dict_paths); 319 tinyrad_strsfree(dict_paths);
318 if (rc != TRAD_SUCCESS) 320 if (rc != TRAD_SUCCESS)
319 return(trutils_exit_code(rc)); 321 return(trutils_exit_code(rc));
320 322
321 // display dictionary 323 // display dictionary
322 if ((opts & MY_OPT_DICT_DUMP)) 324 if ((cnf->opts & MY_OPT_DICT_DUMP))
323 { 325 {
324 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict); 326 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict);
325 tinyrad_dict_print(dict, 0xffff); 327 tinyrad_dict_print(dict, 0xffff);
@@ -329,7 +331,7 @@ int main(int argc, char * argv[])
329 }; 331 };
330 332
331 // display configuration 333 // display configuration
332 if ((opts & MY_OPT_CONFIG_PRINT)) 334 if ((cnf->opts & MY_OPT_CONFIG_PRINT))
333 { 335 {
334 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict); 336 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict);
335 tinyrad_conf_print(tr, dict); 337 tinyrad_conf_print(tr, dict);