void eatIgnored() { bool stop(false); while (!stop){ while (isIgnored(pickChar())) eatChar(); if (_ignore_flag == ignoreFlag::None) return; stop = true; if (_ignore_flag == ignoreFlag::CppC) { if (pickString(sizeof("//") - 1) == "//") { eatString(sizeof("//") - 1); while (stream_cursor != stream_buffer.end() || pickChar() != '\n') eatChar(); stop = false; } if (pickString(sizeof("/*") - 1) == "/*") {eatString(sizeof("/*") - 1); while (pickString(sizeof("*/")-1) != "*/") eatChar(); eatString(sizeof("/*") - 1); stop = false; } } } }
static int setopt(const char *string) { char option[NAME_LEN], *ptr; int i; i = pickString(string, option, sizeof option); if (i == 0) { fprintf(stderr, ";*** Invalid option: %s\n", string); /* this is ugly, but fixing the caller to behave properly with an error return value would require a major cleanup. */ exit(9); } if (strncmp(option, "aa", 2) == 0) { /* aaonly */ res.options |= RES_AAONLY; } else if (strncmp(option, "noaa", 4) == 0) { res.options &= ~RES_AAONLY; } else if (strncmp(option, "deb", 3) == 0) { /* debug */ res.options |= RES_DEBUG; } else if (strncmp(option, "nodeb", 5) == 0) { res.options &= ~(RES_DEBUG | RES_DEBUG2); } else if (strncmp(option, "ko", 2) == 0) { /* keepopen */ res.options |= (RES_STAYOPEN | RES_USEVC); } else if (strncmp(option, "noko", 4) == 0) { res.options &= ~RES_STAYOPEN; } else if (strncmp(option, "d2", 2) == 0) { /* d2 (more debug) */ res.options |= (RES_DEBUG | RES_DEBUG2); } else if (strncmp(option, "nod2", 4) == 0) { res.options &= ~RES_DEBUG2; } else if (strncmp(option, "def", 3) == 0) { /* defname */ res.options |= RES_DEFNAMES; } else if (strncmp(option, "nodef", 5) == 0) { res.options &= ~RES_DEFNAMES; } else if (strncmp(option, "dn", 2) == 0) { /* dnssec */ res.options |= RES_USE_DNSSEC; } else if (strncmp(option, "nodn", 4) == 0) { res.options &= ~RES_USE_DNSSEC; } else if (strncmp(option, "sea", 3) == 0) { /* search list */ res.options |= RES_DNSRCH; } else if (strncmp(option, "nosea", 5) == 0) { res.options &= ~RES_DNSRCH; } else if (strncmp(option, "do", 2) == 0) { /* domain */ ptr = strchr(option, '='); if (ptr != NULL) { i = pickString(++ptr, res.defdname, sizeof res.defdname); if (i == 0) { /* value's too long or non-existant. This actually shouldn't happen due to pickString() above */ fprintf(stderr, "*** Invalid domain: %s\n", ptr) ; exit(9); /* see comment at previous call to exit()*/ } } } else if (strncmp(option, "ti", 2) == 0) { /* timeout */ ptr = strchr(option, '='); if (ptr != NULL) sscanf(++ptr, "%d", &res.retrans); } else if (strncmp(option, "ret", 3) == 0) { /* retry */ ptr = strchr(option, '='); if (ptr != NULL) sscanf(++ptr, "%d", &res.retry); } else if (strncmp(option, "i", 1) == 0) { /* ignore */ res.options |= RES_IGNTC; } else if (strncmp(option, "noi", 3) == 0) { res.options &= ~RES_IGNTC; } else if (strncmp(option, "pr", 2) == 0) { /* primary */ res.options |= RES_PRIMARY; } else if (strncmp(option, "nop", 3) == 0) { res.options &= ~RES_PRIMARY; } else if (strncmp(option, "rec", 3) == 0) { /* recurse */ res.options |= RES_RECURSE; } else if (strncmp(option, "norec", 5) == 0) { res.options &= ~RES_RECURSE; } else if (strncmp(option, "v", 1) == 0) { /* vc */ res.options |= RES_USEVC; } else if (strncmp(option, "nov", 3) == 0) { res.options &= ~RES_USEVC; } else if (strncmp(option, "pfset", 5) == 0) { ptr = strchr(option, '='); if (ptr != NULL) res.pfcode = xstrtonum(++ptr); } else if (strncmp(option, "pfand", 5) == 0) { ptr = strchr(option, '='); if (ptr != NULL) res.pfcode = res.pfcode & xstrtonum(++ptr); } else if (strncmp(option, "pfor", 4) == 0) { ptr = strchr(option, '='); if (ptr != NULL) res.pfcode |= xstrtonum(++ptr); } else if (strncmp(option, "pfmin", 5) == 0) { res.pfcode = PRF_MIN; } else if (strncmp(option, "pfdef", 5) == 0) { res.pfcode = PRF_DEF; } else if (strncmp(option, "an", 2) == 0) { /* answer section */ res.pfcode |= RES_PRF_ANS; } else if (strncmp(option, "noan", 4) == 0) { res.pfcode &= ~RES_PRF_ANS; } else if (strncmp(option, "qu", 2) == 0) { /* question section */ res.pfcode |= RES_PRF_QUES; } else if (strncmp(option, "noqu", 4) == 0) { res.pfcode &= ~RES_PRF_QUES; } else if (strncmp(option, "au", 2) == 0) { /* authority section */ res.pfcode |= RES_PRF_AUTH; } else if (strncmp(option, "noau", 4) == 0) { res.pfcode &= ~RES_PRF_AUTH; } else if (strncmp(option, "ad", 2) == 0) { /* addition section */ res.pfcode |= RES_PRF_ADD; } else if (strncmp(option, "noad", 4) == 0) { res.pfcode &= ~RES_PRF_ADD; } else if (strncmp(option, "tt", 2) == 0) { /* TTL & ID */ res.pfcode |= RES_PRF_TTLID; } else if (strncmp(option, "nott", 4) == 0) { res.pfcode &= ~RES_PRF_TTLID; } else if (strncmp(option, "tr", 2) == 0) { /* TTL & ID */ res.pfcode |= RES_PRF_TRUNC; } else if (strncmp(option, "notr", 4) == 0) { res.pfcode &= ~RES_PRF_TRUNC; } else if (strncmp(option, "he", 2) == 0) { /* head flags stats */ res.pfcode |= RES_PRF_HEAD2; } else if (strncmp(option, "nohe", 4) == 0) { res.pfcode &= ~RES_PRF_HEAD2; } else if (strncmp(option, "H", 1) == 0) { /* header all */ res.pfcode |= RES_PRF_HEADX; } else if (strncmp(option, "noH", 3) == 0) { res.pfcode &= ~(RES_PRF_HEADX); } else if (strncmp(option, "qr", 2) == 0) { /* query */ res.pfcode |= RES_PRF_QUERY; } else if (strncmp(option, "noqr", 4) == 0) { res.pfcode &= ~RES_PRF_QUERY; } else if (strncmp(option, "rep", 3) == 0) { /* reply */ res.pfcode |= RES_PRF_REPLY; } else if (strncmp(option, "norep", 5) == 0) { res.pfcode &= ~RES_PRF_REPLY; } else if (strncmp(option, "cm", 2) == 0) { /* command line */ res.pfcode |= RES_PRF_CMD; } else if (strncmp(option, "nocm", 4) == 0) { res.pfcode &= ~RES_PRF_CMD; } else if (strncmp(option, "cl", 2) == 0) { /* class mnemonic */ res.pfcode |= RES_PRF_CLASS; } else if (strncmp(option, "nocl", 4) == 0) { res.pfcode &= ~RES_PRF_CLASS; } else if (strncmp(option, "st", 2) == 0) { /* stats*/ res.pfcode |= RES_PRF_STATS; } else if (strncmp(option, "nost", 4) == 0) { res.pfcode &= ~RES_PRF_STATS; } else { fprintf(stderr, "; *** Invalid option: %s\n", option); return (ERROR); } res_re_init(); return (SUCCESS); }