/* Parse the debug command found in CMD. */ static void ui_debug(char *cmd) { int cls, level; char subcmd[3]; if (sscanf(cmd, "D %d %d", &cls, &level) == 2) { log_debug_cmd(cls, level); return; } else if (sscanf(cmd, "D %2s %d", subcmd, &level) == 2) { switch (subcmd[0]) { case 'A': for (cls = 0; cls < LOG_ENDCLASS; cls++) log_debug_cmd(cls, level); return; } } else if (sscanf(cmd, "D %2s", subcmd) == 1) { switch (subcmd[0]) { case 'T': log_debug_toggle(); return; } } log_print("ui_debug: command \"%s\" malformed", cmd); }
static void parse_args(int argc, char *argv[]) { int ch; int cls, level; int do_packetlog = 0; while ((ch = getopt(argc, argv, "46ac:dD:f:i:KnN:p:Lerror:l:R:STv")) != -1) { switch (ch) { case '4': bind_family |= BIND_FAMILY_INET4; break; case '6': bind_family |= BIND_FAMILY_INET6; break; case 'a': acquire_only++; break; case 'c': conf_path = optarg; break; case 'd': debug++; break; case 'D': if (sscanf(optarg, "%d=%d", &cls, &level) != 2) { if (sscanf(optarg, "A=%d", &level) == 1) { for (cls = 0; cls < LOG_ENDCLASS; cls++) log_debug_cmd(cls, level); } else log_print("parse_args: -D argument " "unparseable: %s", optarg); } else log_debug_cmd(cls, level); break; case 'f': ui_fifo = optarg; break; case 'i': pid_file = optarg; break; case 'K': ignore_policy++; break; case 'n': app_none++; break; case 'N': udp_encap_default_port = optarg; break; case 'p': udp_default_port = optarg; break; case 'l': pcap_file = optarg; /* FALLTHROUGH */ case 'L': do_packetlog++; break; case 'R': report_file = optarg; break; case 'S': delete_sas = 0; ui_daemon_passive = 1; break; case 'T': disable_nat_t = 1; break; case 'v': verbose_logging = 1; break; case '?': default: usage(); } } argc -= optind; argv += optind; if (argc > 0) usage(); if (do_packetlog && !pcap_file) pcap_file = PCAP_FILE_DEFAULT; }
static void parse_args (int argc, char *argv[]) { int ch; char *ep; #ifdef USE_DEBUG int cls, level; int do_packetlog = 0; #endif while ((ch = getopt (argc, argv, "46c:dD:f:i:np:P:Ll:r:R:v")) != -1) { switch (ch) { case '4': bind_family |= BIND_FAMILY_INET4; break; case '6': bind_family |= BIND_FAMILY_INET6; break; case 'c': conf_path = optarg; break; case 'd': debug++; break; #ifdef USE_DEBUG case 'D': if (sscanf (optarg, "%d=%d", &cls, &level) != 2) { if (sscanf (optarg, "A=%d", &level) == 1) { for (cls = 0; cls < LOG_ENDCLASS; cls++) log_debug_cmd (cls, level); } else log_print ("parse_args: -D argument unparseable: %s", optarg); } else log_debug_cmd (cls, level); break; #endif /* USE_DEBUG */ case 'f': ui_fifo = optarg; break; case 'i': pid_file = optarg; break; case 'n': app_none++; break; case 'p': udp_default_port = optarg; break; case 'P': udp_bind_port = optarg; break; #ifdef USE_DEBUG case 'l': pcap_file = optarg; /* Fallthrough intended. */ case 'L': do_packetlog++; break; #endif /* USE_DEBUG */ case 'r': seed = strtoul (optarg, &ep, 0); srandom (seed); if (*ep != '\0') log_fatal ("parse_args: invalid numeric arg to -r (%s)", optarg); regrand = 1; break; case 'R': report_file = optarg; break; case 'v': verbose_logging = 1; break; case '?': default: usage (); } } argc -= optind; argv += optind; #ifdef USE_DEBUG if (do_packetlog && !pcap_file) pcap_file = PCAP_FILE_DEFAULT; #endif }