aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tinyrad.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tinyrad.c')
-rw-r--r--src/tinyrad.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/tinyrad.c b/src/tinyrad.c
index 1d0fdb9..e5b740d 100644
--- a/src/tinyrad.c
+++ b/src/tinyrad.c
@@ -143,6 +143,11 @@ main(
143 char * argv[] ); 143 char * argv[] );
144 144
145 145
146void
147tinyrad_cleanup(
148 TinyRadConf * cnf );
149
150
146int 151int
147tinyrad_load_dict( 152tinyrad_load_dict(
148 int opts, 153 int opts,
@@ -244,8 +249,7 @@ int main(int argc, char * argv[])
244 if (tinyrad_strsadd(&cnf->dict_files, optarg) != TRAD_SUCCESS) 249 if (tinyrad_strsadd(&cnf->dict_files, optarg) != TRAD_SUCCESS)
245 { 250 {
246 trutils_error(cnf->opts, NULL, "out of virtual memory"); 251 trutils_error(cnf->opts, NULL, "out of virtual memory");
247 tinyrad_strsfree(cnf->dict_files); 252 tinyrad_cleanup(cnf);
248 tinyrad_strsfree(cnf->dict_paths);
249 return(trutils_exit_code(TRAD_ENOMEM)); 253 return(trutils_exit_code(TRAD_ENOMEM));
250 }; 254 };
251 break; 255 break;
@@ -263,8 +267,7 @@ int main(int argc, char * argv[])
263 if (tinyrad_strsadd(&cnf->dict_paths, optarg) != TRAD_SUCCESS) 267 if (tinyrad_strsadd(&cnf->dict_paths, optarg) != TRAD_SUCCESS)
264 { 268 {
265 trutils_error(cnf->opts, NULL, "out of virtual memory"); 269 trutils_error(cnf->opts, NULL, "out of virtual memory");
266 tinyrad_strsfree(cnf->dict_files); 270 tinyrad_cleanup(cnf);
267 tinyrad_strsfree(cnf->dict_paths);
268 return(trutils_exit_code(TRAD_ENOMEM)); 271 return(trutils_exit_code(TRAD_ENOMEM));
269 }; 272 };
270 break; 273 break;
@@ -302,24 +305,24 @@ int main(int argc, char * argv[])
302 { 305 {
303 fprintf(stderr, "%s: unrecognized argument -- %s\n", PROGRAM_NAME, argv[optind]); 306 fprintf(stderr, "%s: unrecognized argument -- %s\n", PROGRAM_NAME, argv[optind]);
304 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); 307 fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME);
305 tinyrad_strsfree(cnf->dict_files); 308 tinyrad_cleanup(cnf);
306 tinyrad_strsfree(cnf->dict_paths);
307 return(1); 309 return(1);
308 }; 310 };
309 311
310 // load TinyRad handle 312 // load TinyRad handle
311 rc = tinyrad_load_dict(cnf->opts, cnf->tr_opts, &tr, cnf->url, cnf->dict_files, cnf->dict_paths); 313 rc = tinyrad_load_dict(cnf->opts, cnf->tr_opts, &tr, cnf->url, cnf->dict_files, cnf->dict_paths);
312 tinyrad_strsfree(cnf->dict_files);
313 tinyrad_strsfree(cnf->dict_paths);
314 if (rc != TRAD_SUCCESS) 314 if (rc != TRAD_SUCCESS)
315 {
316 tinyrad_cleanup(cnf);
315 return(trutils_exit_code(rc)); 317 return(trutils_exit_code(rc));
318 };
316 319
317 // display dictionary 320 // display dictionary
318 if ((cnf->opts & MY_OPT_DICT_DUMP)) 321 if ((cnf->opts & MY_OPT_DICT_DUMP))
319 { 322 {
320 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict); 323 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict);
321 tinyrad_dict_print(dict, 0xffff); 324 tinyrad_dict_print(dict, 0xffff);
322 tinyrad_free(tr); 325 tinyrad_cleanup(cnf);
323 tinyrad_free(dict); 326 tinyrad_free(dict);
324 return(0); 327 return(0);
325 }; 328 };
@@ -329,17 +332,28 @@ int main(int argc, char * argv[])
329 { 332 {
330 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict); 333 tinyrad_get_option(tr, TRAD_OPT_DICTIONARY, &dict);
331 tinyrad_conf_print(tr, dict); 334 tinyrad_conf_print(tr, dict);
332 tinyrad_free(tr); 335 tinyrad_cleanup(cnf);
333 tinyrad_free(dict); 336 tinyrad_free(dict);
334 return(0); 337 return(0);
335 }; 338 };
336 339
337 tinyrad_free(tr); 340 tinyrad_cleanup(cnf);
338 341
339 return(0); 342 return(0);
340} 343}
341 344
342 345
346void
347tinyrad_cleanup(
348 TinyRadConf * cnf )
349{
350 tinyrad_free(cnf->tr);
351 tinyrad_strsfree(cnf->dict_files);
352 tinyrad_strsfree(cnf->dict_paths);
353 return;
354}
355
356
343int 357int
344tinyrad_load_dict( 358tinyrad_load_dict(
345 int opts, 359 int opts,