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
47extern "C" {
48#endif
49
51typedef struct asyncns asyncns_t;
52
54typedef struct asyncns_query asyncns_query_t;
55
57asyncns_t* asyncns_new(unsigned n_proc);
58
61void asyncns_free(asyncns_t *asyncns);
62
66int asyncns_fd(asyncns_t *asyncns);
67
73int asyncns_wait(asyncns_t *asyncns, int block);
74
80asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
81
89int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
90
97asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
98
104int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
105
110asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
111
116asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
117
125int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer);
126
131
135
139
143void asyncns_freeaddrinfo(struct addrinfo *ai);
144
146void asyncns_freeanswer(unsigned char *answer);
147
150
152void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
153
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif
void asyncns_free(asyncns_t *asyncns)
Free a libasyncns session.
struct asyncns asyncns_t
An opaque libasyncns session structure.
Definition asyncns.h:51
asyncns_query_t * asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type)
Issue a resolver query on the specified session.
int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t *q)
Returns non-zero when the query operation specified by q has been completed.
int asyncns_wait(asyncns_t *asyncns, int block)
Process pending responses.
void asyncns_freeanswer(unsigned char *answer)
Free the answer data as returned by asyncns_res_done().
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.
void asyncns_freeaddrinfo(struct addrinfo *ai)
Free the addrinfo structure as returned by asyncns_getaddrinfo_done().
asyncns_query_t * asyncns_getnext(asyncns_t *asyncns)
Return the next completed query object.
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.
struct asyncns_query asyncns_query_t
An opaque libasyncns query structure.
Definition asyncns.h:54
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.
int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t *q, struct addrinfo **ret_res)
Retrieve the results of a preceding asyncns_getaddrinfo() call.
int asyncns_fd(asyncns_t *asyncns)
Return the UNIX file descriptor to select() for readability on.
asyncns_t * asyncns_new(unsigned n_proc)
Allocate a new libasyncns session with n_proc worker processes/threads.
void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata)
Assign some opaque userdata with a query object.
void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t *q)
Cancel a currently running query.
asyncns_query_t * asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type)
Issue an resolver query on the specified session.
int asyncns_getnqueries(asyncns_t *asyncns)
Return the number of query objects (completed or not) attached to this session.
void * asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q)
Return userdata assigned to a query object.
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.