int main(int argc, char **argv) { isc_result_t result; interactive = ISC_TF(isatty(0)); ISC_LIST_INIT(lookup_list); ISC_LIST_INIT(server_list); ISC_LIST_INIT(search_list); check_ra = ISC_TRUE; result = isc_app_start(); check_result(result, "isc_app_start"); setup_libs(); progname = argv[0]; setup_system(); parse_args(argc, argv); if (keyfile[0] != 0) setup_file_key(); else if (keysecret[0] != 0) setup_text_key(); if (domainopt[0] != '\0') set_search_domain(domainopt); if (in_use) result = isc_app_onrun(mctx, global_task, onrun_callback, NULL); else result = isc_app_onrun(mctx, global_task, getinput, NULL); check_result(result, "isc_app_onrun"); in_use = ISC_TF(!in_use); (void)isc_app_run(); puts(""); debug("done, and starting to shut down"); if (global_event != NULL) isc_event_free(&global_event); cancel_all(); destroy_libs(); isc_app_finish(); return (query_error | print_error); }
/*% Main processing routine for dig */ int main(int argc, char **argv) { isc_result_t result; ISC_LIST_INIT(lookup_list); ISC_LIST_INIT(server_list); ISC_LIST_INIT(search_list); debug("main()"); preparse_args(argc, argv); progname = argv[0]; result = isc_app_start(); check_result(result, "isc_app_start"); setup_libs(); parse_args(ISC_FALSE, ISC_FALSE, argc, argv); setup_system(); if (domainopt[0] != '\0') { set_search_domain(domainopt); usesearch = ISC_TRUE; } result = isc_app_onrun(mctx, global_task, onrun_callback, NULL); check_result(result, "isc_app_onrun"); isc_app_run(); destroy_lookup(default_lookup); if (batchname != NULL) { if (batchfp != stdin) fclose(batchfp); batchname = NULL; } #ifdef DIG_SIGCHASE clean_trustedkey(); #endif cancel_all(); destroy_libs(); isc_app_finish(); return (exitcode); }
static void setoption(char *opt) { if (strncasecmp(opt, "all", 3) == 0) { show_settings(ISC_TRUE, ISC_FALSE); } else if (strncasecmp(opt, "class=", 6) == 0) { if (testclass(&opt[6])) strlcpy(defclass, &opt[6], sizeof(defclass)); } else if (strncasecmp(opt, "cl=", 3) == 0) { if (testclass(&opt[3])) strlcpy(defclass, &opt[3], sizeof(defclass)); } else if (strncasecmp(opt, "type=", 5) == 0) { if (testtype(&opt[5])) strlcpy(deftype, &opt[5], sizeof(deftype)); } else if (strncasecmp(opt, "ty=", 3) == 0) { if (testtype(&opt[3])) strlcpy(deftype, &opt[3], sizeof(deftype)); } else if (strncasecmp(opt, "querytype=", 10) == 0) { if (testtype(&opt[10])) strlcpy(deftype, &opt[10], sizeof(deftype)); } else if (strncasecmp(opt, "query=", 6) == 0) { if (testtype(&opt[6])) strlcpy(deftype, &opt[6], sizeof(deftype)); } else if (strncasecmp(opt, "qu=", 3) == 0) { if (testtype(&opt[3])) strlcpy(deftype, &opt[3], sizeof(deftype)); } else if (strncasecmp(opt, "q=", 2) == 0) { if (testtype(&opt[2])) strlcpy(deftype, &opt[2], sizeof(deftype)); } else if (strncasecmp(opt, "domain=", 7) == 0) { strlcpy(domainopt, &opt[7], sizeof(domainopt)); set_search_domain(domainopt); usesearch = ISC_TRUE; } else if (strncasecmp(opt, "do=", 3) == 0) { strlcpy(domainopt, &opt[3], sizeof(domainopt)); set_search_domain(domainopt); usesearch = ISC_TRUE; } else if (strncasecmp(opt, "port=", 5) == 0) { set_port(&opt[5]); } else if (strncasecmp(opt, "po=", 3) == 0) { set_port(&opt[3]); } else if (strncasecmp(opt, "timeout=", 8) == 0) { set_timeout(&opt[8]); } else if (strncasecmp(opt, "t=", 2) == 0) { set_timeout(&opt[2]); } else if (strncasecmp(opt, "rec", 3) == 0) { recurse = ISC_TRUE; } else if (strncasecmp(opt, "norec", 5) == 0) { recurse = ISC_FALSE; } else if (strncasecmp(opt, "retry=", 6) == 0) { set_tries(&opt[6]); } else if (strncasecmp(opt, "ret=", 4) == 0) { set_tries(&opt[4]); } else if (strncasecmp(opt, "def", 3) == 0) { usesearch = ISC_TRUE; } else if (strncasecmp(opt, "nodef", 5) == 0) { usesearch = ISC_FALSE; } else if (strncasecmp(opt, "vc", 3) == 0) { tcpmode = ISC_TRUE; } else if (strncasecmp(opt, "novc", 5) == 0) { tcpmode = ISC_FALSE; } else if (strncasecmp(opt, "deb", 3) == 0) { short_form = ISC_FALSE; showsearch = ISC_TRUE; } else if (strncasecmp(opt, "nodeb", 5) == 0) { short_form = ISC_TRUE; showsearch = ISC_FALSE; } else if (strncasecmp(opt, "d2", 2) == 0) { debugging = ISC_TRUE; } else if (strncasecmp(opt, "nod2", 4) == 0) { debugging = ISC_FALSE; } else if (strncasecmp(opt, "search", 3) == 0) { usesearch = ISC_TRUE; } else if (strncasecmp(opt, "nosearch", 5) == 0) { usesearch = ISC_FALSE; } else if (strncasecmp(opt, "sil", 3) == 0) { /* deprecation_msg = ISC_FALSE; */ } else if (strncasecmp(opt, "fail", 3) == 0) { nofail=ISC_FALSE; } else if (strncasecmp(opt, "nofail", 3) == 0) { nofail=ISC_TRUE; } else if (strncasecmp(opt, "ndots=", 6) == 0) { set_ndots(&opt[6]); } else { printf("*** Invalid option: %s\n", opt); } }