summaryrefslogtreecommitdiff
path: root/lib/libc/asr/getaddrinfo_async.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2014-03-25 19:48:12 +0000
committerEric Faurot <eric@cvs.openbsd.org>2014-03-25 19:48:12 +0000
commit1a090236bf712741c66bb951190b19b8606e20de (patch)
tree6355a65f2168b0e5be6fe216d4dc4cfed415633c /lib/libc/asr/getaddrinfo_async.c
parent2d06d16ca6569b9936404a79bf3821691d0fb951 (diff)
Cleanup and simplify the API to be exposed. Use better names for
structures, functions and defines. discussed with and ok deraadt@ guenther@
Diffstat (limited to 'lib/libc/asr/getaddrinfo_async.c')
-rw-r--r--lib/libc/asr/getaddrinfo_async.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c
index b730d8c87d5..bf7328803a5 100644
--- a/lib/libc/asr/getaddrinfo_async.c
+++ b/lib/libc/asr/getaddrinfo_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo_async.c,v 1.24 2014/03/14 11:07:33 eric Exp $ */
+/* $OpenBSD: getaddrinfo_async.c,v 1.25 2014/03/25 19:48:11 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -43,15 +43,15 @@ struct match {
int protocol;
};
-static int getaddrinfo_async_run(struct async *, struct async_res *);
+static int getaddrinfo_async_run(struct asr_query *, struct asr_result *);
static int get_port(const char *, const char *, int);
-static int iter_family(struct async *, int);
-static int iter_domain(struct async *, const char *, char *, size_t);
-static int addrinfo_add(struct async *, const struct sockaddr *, const char *);
-static int addrinfo_from_file(struct async *, int, FILE *);
-static int addrinfo_from_pkt(struct async *, char *, size_t);
+static int iter_family(struct asr_query *, int);
+static int iter_domain(struct asr_query *, const char *, char *, size_t);
+static int addrinfo_add(struct asr_query *, const struct sockaddr *, const char *);
+static int addrinfo_from_file(struct asr_query *, int, FILE *);
+static int addrinfo_from_pkt(struct asr_query *, char *, size_t);
#ifdef YP
-static int addrinfo_from_yp(struct async *, int, char *);
+static int addrinfo_from_yp(struct asr_query *, int, char *);
#endif
static const struct match matches[] = {
@@ -76,13 +76,13 @@ enum {
DOM_DONE
};
-struct async *
+struct asr_query *
getaddrinfo_async(const char *hostname, const char *servname,
- const struct addrinfo *hints, struct asr *asr)
+ const struct addrinfo *hints, void *asr)
{
- struct asr_ctx *ac;
- struct async *as;
- char alias[MAXDNAME];
+ struct asr_ctx *ac;
+ struct asr_query *as;
+ char alias[MAXDNAME];
ac = asr_use_resolver(asr);
if ((as = asr_async_new(ac, ASR_GETADDRINFO)) == NULL)
@@ -114,7 +114,7 @@ getaddrinfo_async(const char *hostname, const char *servname,
}
static int
-getaddrinfo_async_run(struct async *as, struct async_res *ar)
+getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
{
#ifdef YP
static char *domain = NULL;
@@ -422,8 +422,9 @@ getaddrinfo_async_run(struct async *as, struct async_res *ar)
break;
case ASR_STATE_SUBQUERY:
- if ((r = asr_async_run(as->as.ai.subq, ar)) == ASYNC_COND)
+ if ((r = asr_run(as->as.ai.subq, ar)) == ASYNC_COND)
return (ASYNC_COND);
+
as->as.ai.subq = NULL;
if (ar->ar_datalen == -1) {
@@ -512,7 +513,7 @@ get_port(const char *servname, const char *proto, int numonly)
* list on the async context, unless a specific family was given in hints.
*/
static int
-iter_family(struct async *as, int first)
+iter_family(struct asr_query *as, int first)
{
if (first) {
as->as_family_idx = 0;
@@ -561,7 +562,7 @@ domcat(const char *name, const char *domain, char *buf, size_t buflen)
* error generating the next name, or the resulting name length.
*/
static int
-iter_domain(struct async *as, const char *name, char * buf, size_t len)
+iter_domain(struct asr_query *as, const char *name, char * buf, size_t len)
{
const char *c;
int dots;
@@ -644,7 +645,7 @@ iter_domain(struct async *as, const char *name, char * buf, size_t len)
* entry per protocol/socktype match.
*/
static int
-addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname)
+addrinfo_add(struct asr_query *as, const struct sockaddr *sa, const char *cname)
{
struct addrinfo *ai;
int i, port, proto;
@@ -706,7 +707,7 @@ addrinfo_add(struct async *as, const struct sockaddr *sa, const char *cname)
}
static int
-addrinfo_from_file(struct async *as, int family, FILE *f)
+addrinfo_from_file(struct asr_query *as, int family, FILE *f)
{
char *tokens[MAXTOKEN], *c;
int n, i;
@@ -743,7 +744,7 @@ addrinfo_from_file(struct async *as, int family, FILE *f)
}
static int
-addrinfo_from_pkt(struct async *as, char *pkt, size_t pktlen)
+addrinfo_from_pkt(struct asr_query *as, char *pkt, size_t pktlen)
{
struct asr_unpack p;
struct asr_dns_header h;
@@ -815,7 +816,7 @@ strsplit(char *line, char **tokens, int ntokens)
}
static int
-addrinfo_from_yp(struct async *as, int family, char *line)
+addrinfo_from_yp(struct asr_query *as, int family, char *line)
{
char *next, *tokens[MAXTOKEN], *c;
int ntok;