diff options
| -rw-r--r-- | src/tinyrad.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/tinyrad.c b/src/tinyrad.c index a626f5e..1d0fdb9 100644 --- a/src/tinyrad.c +++ b/src/tinyrad.c | |||
| @@ -194,9 +194,6 @@ int main(int argc, char * argv[]) | |||
| 194 | int rc; | 194 | int rc; |
| 195 | TinyRadDict * dict; | 195 | TinyRadDict * dict; |
| 196 | TinyRad * tr; | 196 | TinyRad * tr; |
| 197 | const char * url; | ||
| 198 | char ** dict_files; | ||
| 199 | char ** dict_paths; | ||
| 200 | TinyRadConf cnfdata; | 197 | TinyRadConf cnfdata; |
| 201 | TinyRadConf * cnf; | 198 | TinyRadConf * cnf; |
| 202 | 199 | ||
| @@ -221,10 +218,7 @@ int main(int argc, char * argv[]) | |||
| 221 | 218 | ||
| 222 | memset(&cnfdata, 0, sizeof(cnfdata)); | 219 | memset(&cnfdata, 0, sizeof(cnfdata)); |
| 223 | cnf = &cnfdata; | 220 | cnf = &cnfdata; |
| 224 | url = NULL; | ||
| 225 | dict = NULL; | 221 | dict = NULL; |
| 226 | dict_files = NULL; | ||
| 227 | dict_paths = NULL; | ||
| 228 | 222 | ||
| 229 | while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) | 223 | while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) |
| 230 | { | 224 | { |
| @@ -247,11 +241,11 @@ int main(int argc, char * argv[]) | |||
| 247 | break; | 241 | break; |
| 248 | 242 | ||
| 249 | case 'D': | 243 | case 'D': |
| 250 | if (tinyrad_strsadd(&dict_files, optarg) != TRAD_SUCCESS) | 244 | if (tinyrad_strsadd(&cnf->dict_files, optarg) != TRAD_SUCCESS) |
| 251 | { | 245 | { |
| 252 | trutils_error(cnf->opts, NULL, "out of virtual memory"); | 246 | trutils_error(cnf->opts, NULL, "out of virtual memory"); |
| 253 | tinyrad_strsfree(dict_files); | 247 | tinyrad_strsfree(cnf->dict_files); |
| 254 | tinyrad_strsfree(dict_paths); | 248 | tinyrad_strsfree(cnf->dict_paths); |
| 255 | return(trutils_exit_code(TRAD_ENOMEM)); | 249 | return(trutils_exit_code(TRAD_ENOMEM)); |
| 256 | }; | 250 | }; |
| 257 | break; | 251 | break; |
| @@ -266,11 +260,11 @@ int main(int argc, char * argv[]) | |||
| 266 | return(0); | 260 | return(0); |
| 267 | 261 | ||
| 268 | case 'I': | 262 | case 'I': |
| 269 | if (tinyrad_strsadd(&dict_paths, optarg) != TRAD_SUCCESS) | 263 | if (tinyrad_strsadd(&cnf->dict_paths, optarg) != TRAD_SUCCESS) |
| 270 | { | 264 | { |
| 271 | trutils_error(cnf->opts, NULL, "out of virtual memory"); | 265 | trutils_error(cnf->opts, NULL, "out of virtual memory"); |
| 272 | tinyrad_strsfree(dict_files); | 266 | tinyrad_strsfree(cnf->dict_files); |
| 273 | tinyrad_strsfree(dict_paths); | 267 | tinyrad_strsfree(cnf->dict_paths); |
| 274 | return(trutils_exit_code(TRAD_ENOMEM)); | 268 | return(trutils_exit_code(TRAD_ENOMEM)); |
| 275 | }; | 269 | }; |
| 276 | break; | 270 | break; |
| @@ -301,22 +295,22 @@ int main(int argc, char * argv[]) | |||
| 301 | }; | 295 | }; |
| 302 | if (optind < argc) | 296 | if (optind < argc) |
| 303 | { | 297 | { |
| 304 | url = argv[optind]; | 298 | cnf->url = argv[optind]; |
| 305 | optind++; | 299 | optind++; |
| 306 | }; | 300 | }; |
| 307 | if (optind < argc) | 301 | if (optind < argc) |
| 308 | { | 302 | { |
| 309 | fprintf(stderr, "%s: unrecognized argument -- %s\n", PROGRAM_NAME, argv[optind]); | 303 | fprintf(stderr, "%s: unrecognized argument -- %s\n", PROGRAM_NAME, argv[optind]); |
| 310 | fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); | 304 | fprintf(stderr, "Try `%s --help' for more information.\n", PROGRAM_NAME); |
| 311 | tinyrad_strsfree(dict_files); | 305 | tinyrad_strsfree(cnf->dict_files); |
| 312 | tinyrad_strsfree(dict_paths); | 306 | tinyrad_strsfree(cnf->dict_paths); |
| 313 | return(1); | 307 | return(1); |
| 314 | }; | 308 | }; |
| 315 | 309 | ||
| 316 | // load TinyRad handle | 310 | // load TinyRad handle |
| 317 | rc = tinyrad_load_dict(cnf->opts, cnf->tr_opts, &tr, url, dict_files, dict_paths); | 311 | rc = tinyrad_load_dict(cnf->opts, cnf->tr_opts, &tr, cnf->url, cnf->dict_files, cnf->dict_paths); |
| 318 | tinyrad_strsfree(dict_files); | 312 | tinyrad_strsfree(cnf->dict_files); |
| 319 | tinyrad_strsfree(dict_paths); | 313 | tinyrad_strsfree(cnf->dict_paths); |
| 320 | if (rc != TRAD_SUCCESS) | 314 | if (rc != TRAD_SUCCESS) |
| 321 | return(trutils_exit_code(rc)); | 315 | return(trutils_exit_code(rc)); |
| 322 | 316 | ||
