libasyncns  0.8
asyncns.h
Go to the documentation of this file.
1 #ifndef fooasyncnshfoo
2 #define fooasyncnshfoo
3 
4 /***
5  This file is part of libasyncns.
6 
7  Copyright 2005-2008 Lennart Poettering
8 
9  libasyncns is free software; you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as
11  published by the Free Software Foundation, either version 2.1 of the
12  License, or (at your option) any later version.
13 
14  libasyncns is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with libasyncns. If not, see
21  <http://www.gnu.org/licenses/>.
22 ***/
23 
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <netdb.h>
27 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
51 typedef struct asyncns asyncns_t;
52 
54 typedef struct asyncns_query asyncns_query_t;
55 
57 asyncns_t* asyncns_new(unsigned n_proc);
58 
61 void asyncns_free(asyncns_t *asyncns);
62 
66 int asyncns_fd(asyncns_t *asyncns);
67 
73 int asyncns_wait(asyncns_t *asyncns, int block);
74 
80 asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
81 
89 int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
90 
97 asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
98 
104 int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
105 
110 asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
111 
116 asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
117 
125 int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer);
126 
131 
134 int asyncns_getnqueries(asyncns_t *asyncns);
135 
138 void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q);
139 
143 void asyncns_freeaddrinfo(struct addrinfo *ai);
144 
146 void asyncns_freeanswer(unsigned char *answer);
147 
149 int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q);
150 
152 void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
153 
157 void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif
asyncns_query_t
struct asyncns_query asyncns_query_t
An opaque libasyncns query structure.
Definition: asyncns.h:54
asyncns_getnameinfo
asyncns_query_t * asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv)
Issue an address to name query on the specified session.
asyncns_getuserdata
void * asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q)
Return userdata assigned to a query object.
asyncns_free
void asyncns_free(asyncns_t *asyncns)
Free a libasyncns session.
asyncns_res_done
int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t *q, unsigned char **answer)
Retrieve the results of a preceding asyncns_res_query() or asyncns_res_search call.
asyncns_cancel
void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t *q)
Cancel a currently running query.
asyncns_t
struct asyncns asyncns_t
An opaque libasyncns session structure.
Definition: asyncns.h:51
asyncns_new
asyncns_t * asyncns_new(unsigned n_proc)
Allocate a new libasyncns session with n_proc worker processes/threads.
asyncns_wait
int asyncns_wait(asyncns_t *asyncns, int block)
Process pending responses.
asyncns_freeaddrinfo
void asyncns_freeaddrinfo(struct addrinfo *ai)
Free the addrinfo structure as returned by asyncns_getaddrinfo_done().
asyncns_getnqueries
int asyncns_getnqueries(asyncns_t *asyncns)
Return the number of query objects (completed or not) attached to this session.
asyncns_fd
int asyncns_fd(asyncns_t *asyncns)
Return the UNIX file descriptor to select() for readability on.
asyncns_getnameinfo_done
int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t *q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen)
Retrieve the results of a preceding asyncns_getnameinfo() call.
asyncns_res_query
asyncns_query_t * asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type)
Issue a resolver query on the specified session.
asyncns_res_search
asyncns_query_t * asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type)
Issue an resolver query on the specified session.
asyncns_setuserdata
void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata)
Assign some opaque userdata with a query object.
asyncns_getaddrinfo
asyncns_query_t * asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints)
Issue a name to address query on the specified session.
asyncns_getnext
asyncns_query_t * asyncns_getnext(asyncns_t *asyncns)
Return the next completed query object.
asyncns_isdone
int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t *q)
Returns non-zero when the query operation specified by q has been completed.
asyncns_getaddrinfo_done
int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t *q, struct addrinfo **ret_res)
Retrieve the results of a preceding asyncns_getaddrinfo() call.
asyncns_freeanswer
void asyncns_freeanswer(unsigned char *answer)
Free the answer data as returned by asyncns_res_done().