static void idnsParseWIN32SearchList(const char *Separator) { char *t; char *token; HKEY hndKey; if (RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", &hndKey) == ERROR_SUCCESS) { DWORD Type = 0; DWORD Size = 0; LONG Result; Result = RegQueryValueEx(hndKey, "Domain", NULL, &Type, NULL, &Size); if (Result == ERROR_SUCCESS && Size) { t = (char *) xmalloc(Size); RegQueryValueEx(hndKey, "Domain", NULL, &Type, (LPBYTE) t, &Size); debug(78, 1) ("Adding domain %s from Registry\n", t); idnsAddPathComponent(t); xfree(t); } Result = RegQueryValueEx(hndKey, "SearchList", NULL, &Type, NULL, &Size); if (Result == ERROR_SUCCESS && Size) { t = (char *) xmalloc(Size); RegQueryValueEx(hndKey, "SearchList", NULL, &Type, (LPBYTE) t, &Size); token = strtok(t, Separator); idnsFreeSearchpath(); while (token) { idnsAddPathComponent(token); debug(78, 1) ("Adding domain %s from Registry\n", token); token = strtok(NULL, Separator); } xfree(t); } RegCloseKey(hndKey); } if (npc == 0 && ((const char *) t = getMyHostname())) { t = strchr(t, '.'); if (t) idnsAddPathComponent(t + 1); } }
static void idnsParseWIN32SearchList(const char *Separator) { char *t; const char *token; HKEY hndKey; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_TCPIP_PARA, 0, KEY_QUERY_VALUE, &hndKey) == ERROR_SUCCESS) { DWORD Type = 0; DWORD Size = 0; LONG Result; Result = RegQueryValueEx(hndKey, "Domain", NULL, &Type, NULL, &Size); if (Result == ERROR_SUCCESS && Size) { t = (char *) xmalloc(Size); RegQueryValueEx(hndKey, "Domain", NULL, &Type, (LPBYTE) t, &Size); debug(78, 1) ("Adding domain %s from Registry\n", t); idnsAddPathComponent(t); xfree(t); } Result = RegQueryValueEx(hndKey, "SearchList", NULL, &Type, NULL, &Size); if (Result == ERROR_SUCCESS && Size) { t = (char *) xmalloc(Size); RegQueryValueEx(hndKey, "SearchList", NULL, &Type, (LPBYTE) t, &Size); token = strtok(t, Separator); idnsFreeSearchpath(); while (token) { idnsAddPathComponent(token); debug(78, 1) ("Adding domain %s from Registry\n", token); token = strtok(NULL, Separator); } xfree(t); } RegCloseKey(hndKey); } if (npc == 0 && (token = getMyHostname())) { token = strchr(token, '.'); if (token) idnsAddPathComponent(token + 1); } }
static void idnsParseResolvConf(void) { FILE *fp; char buf[RESOLV_BUFSZ]; const char *t; fp = fopen(_PATH_RESCONF, "r"); if (fp == NULL) { debug(78, 1) ("%s: %s\n", _PATH_RESCONF, xstrerror()); return; } #if defined(_SQUID_CYGWIN_) setmode(fileno(fp), O_TEXT); #endif while (fgets(buf, RESOLV_BUFSZ, fp)) { t = strtok(buf, w_space); if (NULL == t) { continue; } else if (strcasecmp(t, "nameserver") == 0) { t = strtok(NULL, w_space); if (NULL == t) continue; debug(78, 1) ("Adding nameserver %s from %s\n", t, _PATH_RESCONF); idnsAddNameserver(t); } else if (strcasecmp(t, "domain") == 0) { idnsFreeSearchpath(); t = strtok(NULL, w_space); if (NULL == t) continue; debug(78, 1) ("Adding domain %s from %s\n", t, _PATH_RESCONF); idnsAddPathComponent(t); } else if (strcasecmp(t, "search") == 0) { idnsFreeSearchpath(); while (NULL != t) { t = strtok(NULL, w_space); if (NULL == t) continue; debug(78, 1) ("Adding domain %s from %s\n", t, _PATH_RESCONF); idnsAddPathComponent(t); } } else if (strcasecmp(t, "options") == 0) { while (NULL != t) { t = strtok(NULL, w_space); if (NULL == t) continue; if (strncmp(t, "ndots:", 6) == 0) { ndots = atoi(t + 6); if (ndots < 1) ndots = 1; if (ndots > RES_MAXNDOTS) ndots = RES_MAXNDOTS; debug(78, 1) ("Adding ndots %d from %s\n", ndots, _PATH_RESCONF); } } } } fclose(fp); if (npc == 0 && (t = getMyHostname())) { t = strchr(t, '.'); if (t) idnsAddPathComponent(t + 1); } }