static void get_next_command (void) { char *buf; char *ptr, *arg; char *input; fflush (stdout); buf = isc_mem_allocate (mctx, COMMSIZE); if (buf == NULL) fatal ("memory allocation failure"); fputs ("> ", stderr); fflush (stderr); isc_app_block (); ptr = fgets (buf, COMMSIZE, stdin); isc_app_unblock (); if (ptr == NULL) { in_use = ISC_FALSE; goto cleanup; } input = buf; ptr = next_token (&input, " \t\r\n"); if (ptr == NULL) goto cleanup; arg = next_token (&input, " \t\r\n"); if ((strcasecmp (ptr, "set") == 0) && (arg != NULL)) setoption (arg); else if ((strcasecmp (ptr, "server") == 0) || (strcasecmp (ptr, "lserver") == 0)) { isc_app_block (); set_nameserver (arg); check_ra = ISC_FALSE; isc_app_unblock (); show_settings (ISC_TRUE, ISC_TRUE); } else if (strcasecmp (ptr, "exit") == 0) { in_use = ISC_FALSE; goto cleanup; } else if (strcasecmp (ptr, "help") == 0 || strcasecmp (ptr, "?") == 0) { printf ("The '%s' command is not yet implemented.\n", ptr); goto cleanup; } else if (strcasecmp (ptr, "finger") == 0 || strcasecmp (ptr, "root") == 0 || strcasecmp (ptr, "ls") == 0 || strcasecmp (ptr, "view") == 0) { printf ("The '%s' command is not implemented.\n", ptr); goto cleanup; } else addlookup (ptr); cleanup: isc_mem_free (mctx, buf); }
static void get_next_command(void) { char *buf; char *ptr; fflush(stdout); buf = isc_mem_allocate(mctx, COMMSIZE); if (buf == NULL) fatal("memory allocation failure"); isc_app_block(); if (interactive) { #ifdef HAVE_READLINE ptr = readline("> "); if (ptr != NULL) add_history(ptr); #else fputs("> ", stderr); fflush(stderr); ptr = fgets(buf, COMMSIZE, stdin); #endif } else ptr = fgets(buf, COMMSIZE, stdin); isc_app_unblock(); if (ptr == NULL) { in_use = ISC_FALSE; } else do_next_command(ptr); #ifdef HAVE_READLINE if (interactive) free(ptr); #endif isc_mem_free(mctx, buf); }
static void do_next_command(char *input) { char *ptr, *arg; ptr = next_token(&input, " \t\r\n"); if (ptr == NULL) return; arg = next_token(&input, " \t\r\n"); if ((strcasecmp(ptr, "set") == 0) && (arg != NULL)) setoption(arg); else if ((strcasecmp(ptr, "server") == 0) || (strcasecmp(ptr, "lserver") == 0)) { isc_app_block(); set_nameserver(arg); check_ra = ISC_FALSE; isc_app_unblock(); show_settings(ISC_TRUE, ISC_TRUE); } else if (strcasecmp(ptr, "exit") == 0) { in_use = ISC_FALSE; } else if (strcasecmp(ptr, "help") == 0 || strcasecmp(ptr, "?") == 0) { printf("The '%s' command is not yet implemented.\n", ptr); } else if (strcasecmp(ptr, "finger") == 0 || strcasecmp(ptr, "root") == 0 || strcasecmp(ptr, "ls") == 0 || strcasecmp(ptr, "view") == 0) { printf("The '%s' command is not implemented.\n", ptr); } else addlookup(ptr); }
static void get_addresses(const char *host, in_port_t port) { isc_result_t result; isc_app_block(); result = bind9_getaddresses(servername, port, serveraddrs, SERVERADDRS, &nserveraddrs); isc_app_unblock(); if (result != ISC_R_SUCCESS) fatal("couldn't get address for '%s': %s", host, isc_result_totext(result)); INSIST(nserveraddrs > 0); }