summaryrefslogtreecommitdiff
path: root/ares_search.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-10-06 07:50:18 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-10-06 07:50:18 +0000
commit3e748f4b50224e43b916dda5de438c785bdcd49d (patch)
tree53bbfe3dae88be1fd482d3fc392cd1465214f4f3 /ares_search.c
parent47bd7d7548103c44b466fceb1dbda425ce8774bc (diff)
downloadc-ares-3e748f4b50224e43b916dda5de438c785bdcd49d.tar.gz
c-ares-3e748f4b50224e43b916dda5de438c785bdcd49d.tar.bz2
c-ares-3e748f4b50224e43b916dda5de438c785bdcd49d.zip
removed tabs and trailing whitespace from source
Diffstat (limited to 'ares_search.c')
-rw-r--r--ares_search.c146
1 files changed, 73 insertions, 73 deletions
diff --git a/ares_search.c b/ares_search.c
index 37826ee..dc416c0 100644
--- a/ares_search.c
+++ b/ares_search.c
@@ -29,26 +29,26 @@
struct search_query {
/* Arguments passed to ares_search */
ares_channel channel;
- char *name; /* copied into an allocated buffer */
+ char *name; /* copied into an allocated buffer */
int dnsclass;
int type;
ares_callback callback;
void *arg;
- int status_as_is; /* error status from trying as-is */
- int next_domain; /* next search domain to try */
- int trying_as_is; /* current query is for name as-is */
+ int status_as_is; /* error status from trying as-is */
+ int next_domain; /* next search domain to try */
+ int trying_as_is; /* current query is for name as-is */
};
static void search_callback(void *arg, int status, unsigned char *abuf,
- int alen);
+ int alen);
static void end_squery(struct search_query *squery, int status,
- unsigned char *abuf, int alen);
+ unsigned char *abuf, int alen);
static int cat_domain(const char *name, const char *domain, char **s);
static int single_domain(ares_channel channel, const char *name, char **s);
void ares_search(ares_channel channel, const char *name, int dnsclass,
- int type, ares_callback callback, void *arg)
+ int type, ares_callback callback, void *arg)
{
struct search_query *squery;
char *s;
@@ -99,7 +99,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
for (p = name; *p; p++)
{
if (*p == '.')
- ndots++;
+ ndots++;
}
/* If ndots is at least the channel ndots threshold (usually 1),
@@ -120,22 +120,22 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
squery->trying_as_is = 0;
status = cat_domain(name, channel->domains[0], &s);
if (status == ARES_SUCCESS)
- {
- ares_query(channel, s, dnsclass, type, search_callback, squery);
- free(s);
- }
+ {
+ ares_query(channel, s, dnsclass, type, search_callback, squery);
+ free(s);
+ }
else
{
/* failed, free the malloc()ed memory */
free(squery->name);
free(squery);
- callback(arg, status, NULL, 0);
+ callback(arg, status, NULL, 0);
}
}
}
static void search_callback(void *arg, int status, unsigned char *abuf,
- int alen)
+ int alen)
{
struct search_query *squery = (struct search_query *) arg;
ares_channel channel = squery->channel;
@@ -149,37 +149,37 @@ static void search_callback(void *arg, int status, unsigned char *abuf,
{
/* Save the status if we were trying as-is. */
if (squery->trying_as_is)
- squery->status_as_is = status;
+ squery->status_as_is = status;
if (squery->next_domain < channel->ndomains)
- {
- /* Try the next domain. */
- status = cat_domain(squery->name,
- channel->domains[squery->next_domain], &s);
- if (status != ARES_SUCCESS)
- end_squery(squery, status, NULL, 0);
- else
- {
- squery->trying_as_is = 0;
- squery->next_domain++;
- ares_query(channel, s, squery->dnsclass, squery->type,
- search_callback, squery);
- free(s);
- }
- }
+ {
+ /* Try the next domain. */
+ status = cat_domain(squery->name,
+ channel->domains[squery->next_domain], &s);
+ if (status != ARES_SUCCESS)
+ end_squery(squery, status, NULL, 0);
+ else
+ {
+ squery->trying_as_is = 0;
+ squery->next_domain++;
+ ares_query(channel, s, squery->dnsclass, squery->type,
+ search_callback, squery);
+ free(s);
+ }
+ }
else if (squery->status_as_is == -1)
- {
- /* Try the name as-is at the end. */
- squery->trying_as_is = 1;
- ares_query(channel, squery->name, squery->dnsclass, squery->type,
- search_callback, squery);
- }
+ {
+ /* Try the name as-is at the end. */
+ squery->trying_as_is = 1;
+ ares_query(channel, squery->name, squery->dnsclass, squery->type,
+ search_callback, squery);
+ }
else
- end_squery(squery, squery->status_as_is, NULL, 0);
+ end_squery(squery, squery->status_as_is, NULL, 0);
}
}
static void end_squery(struct search_query *squery, int status,
- unsigned char *abuf, int alen)
+ unsigned char *abuf, int alen)
{
squery->callback(squery->arg, status, abuf, alen);
free(squery->name);
@@ -229,41 +229,41 @@ static int single_domain(ares_channel channel, const char *name, char **s)
/* The name might be a host alias. */
hostaliases = getenv("HOSTALIASES");
if (hostaliases)
- {
- fp = fopen(hostaliases, "r");
- if (fp)
- {
- while ((status = ares__read_line(fp, &line, &linesize))
- == ARES_SUCCESS)
- {
- if (strncasecmp(line, name, len) != 0 ||
- !isspace((unsigned char)line[len]))
- continue;
- p = line + len;
- while (isspace((unsigned char)*p))
- p++;
- if (*p)
- {
- q = p + 1;
- while (*q && !isspace((unsigned char)*q))
- q++;
- *s = malloc(q - p + 1);
- if (*s)
- {
- memcpy(*s, p, q - p);
- (*s)[q - p] = 0;
- }
- free(line);
- fclose(fp);
- return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
- }
- }
- free(line);
- fclose(fp);
- if (status != ARES_SUCCESS)
- return status;
- }
- }
+ {
+ fp = fopen(hostaliases, "r");
+ if (fp)
+ {
+ while ((status = ares__read_line(fp, &line, &linesize))
+ == ARES_SUCCESS)
+ {
+ if (strncasecmp(line, name, len) != 0 ||
+ !isspace((unsigned char)line[len]))
+ continue;
+ p = line + len;
+ while (isspace((unsigned char)*p))
+ p++;
+ if (*p)
+ {
+ q = p + 1;
+ while (*q && !isspace((unsigned char)*q))
+ q++;
+ *s = malloc(q - p + 1);
+ if (*s)
+ {
+ memcpy(*s, p, q - p);
+ (*s)[q - p] = 0;
+ }
+ free(line);
+ fclose(fp);
+ return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
+ }
+ }
+ free(line);
+ fclose(fp);
+ if (status != ARES_SUCCESS)
+ return status;
+ }
+ }
}
if (channel->flags & ARES_FLAG_NOSEARCH || channel->ndomains == 0)