Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/tests/resolv/resolv_test.c
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
static void run(int *); | static void run(int *); | ||||
static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER; | static pthread_mutex_t stats = PTHREAD_MUTEX_INITIALIZER; | ||||
static void | static void | ||||
load(const char *fname) | load(const char *fname) | ||||
{ | { | ||||
FILE *fp; | FILE *fp; | ||||
size_t len; | size_t linecap; | ||||
char *line; | char *line; | ||||
if ((fp = fopen(fname, "r")) == NULL) | fp = fopen(fname, "r"); | ||||
ATF_REQUIRE(fp != NULL); | ATF_REQUIRE(fp != NULL); | ||||
while ((line = fgetln(fp, &len)) != NULL) { | line = NULL; | ||||
char c = line[len - 1]; | linecap = 0; | ||||
while (getline(&line, &linecap, fp) >= 0) { | |||||
char *ptr; | char *ptr; | ||||
line[len - 1] = '\0'; | |||||
for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) { | for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) { | ||||
if (ptr == '\0' || ptr[0] == '#') | if (ptr[0] == '#') | ||||
continue; | break; | ||||
sl_add(hosts, strdup(ptr)); | sl_add(hosts, strdup(ptr)); | ||||
} | } | ||||
line[len - 1] = c; | |||||
} | } | ||||
free(line); | |||||
(void)fclose(fp); | (void)fclose(fp); | ||||
} | } | ||||
static int | static int | ||||
resolv_getaddrinfo(pthread_t self, char *host, int port) | resolv_getaddrinfo(pthread_t self, char *host, int port) | ||||
{ | { | ||||
char portstr[6], buf[1024], hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; | char portstr[6], buf[1024], hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; | ||||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |