author | Dafydd Harries <dafydd.harries@collabora.co.uk> |
Wed, 31 Oct 2007 15:34:52 +0000 | |
changeset 315 | eafeecd05c9a |
parent 271 | 52ea4e0b897a |
child 518 | cdd6a0c5b439 |
permissions | -rw-r--r-- |
271
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
1 |
#ifndef fooasyncnshfoo |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
2 |
#define fooasyncnshfoo |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
3 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
4 |
/* $Id: asyncns.h 23 2007-02-16 12:49:17Z lennart $ */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
5 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
6 |
/*** |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
7 |
This file is part of libasyncns. |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
8 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
9 |
libasyncns is free software; you can redistribute it and/or modify |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
10 |
it under the terms of the GNU Lesser General Public License as |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
11 |
published by the Free Software Foundation; either version 2 of the |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
12 |
License, or (at your option) any later version. |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
13 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
14 |
libasyncns is distributed in the hope that it will be useful, but |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
17 |
General Public License for more details. |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
18 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
19 |
You should have received a copy of the GNU Lesser General Public |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
20 |
License along with libasyncns; if not, write to the Free Software |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
21 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
22 |
USA. |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
23 |
***/ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
24 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
25 |
#include <sys/types.h> |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
26 |
#include <sys/socket.h> |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
27 |
#include <netdb.h> |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
28 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
29 |
/** \mainpage |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
30 |
* |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
31 |
* \section moo Method of operation |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
32 |
* |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
33 |
* To use libasyncns allocate an asyncns_t object with |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
34 |
* asyncns_new(). This will spawn a number of worker threads (or processes, depending on what is available) which |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
35 |
* are subsequently used to process the queries the controlling |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
36 |
* program issues via asyncns_getaddrinfo() and |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
37 |
* asyncns_getnameinfo(). Use asyncns_free() to shut down the worker |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
38 |
* threads/processes. |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
39 |
* |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
40 |
* Since libasyncns may fork off new processes you have to make sure that |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
41 |
* your program is not irritated by spurious SIGCHLD signals. |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
42 |
*/ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
43 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
44 |
/** \example asyncns-test.c |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
45 |
* An example program */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
46 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
47 |
#ifdef __cplusplus |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
48 |
extern "C" { |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
49 |
#endif |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
50 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
51 |
/** An opaque libasyncns session structure */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
52 |
typedef struct asyncns asyncns_t; |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
53 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
54 |
/** An opaque libasyncns query structure */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
55 |
typedef struct asyncns_query asyncns_query_t; |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
56 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
57 |
/** Allocate a new libasyncns session with n_proc worker processes */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
58 |
asyncns_t* asyncns_new(unsigned n_proc); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
59 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
60 |
/** Free a libasyncns session. This destroys all attached |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
61 |
* asyncns_query_t objects automatically */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
62 |
void asyncns_free(asyncns_t *asyncns); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
63 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
64 |
/** Return the UNIX file descriptor to select() for readability |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
65 |
* on. Use this function to integrate libasyncns with your custom main |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
66 |
* loop. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
67 |
int asyncns_fd(asyncns_t *asyncns); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
68 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
69 |
/** Process pending responses. After this function is called you can |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
70 |
* get the next completed query object(s) using asyncns_getnext(). If |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
71 |
* block is non-zero wait until at least one response has been |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
72 |
* processed. If block is zero, process all pending responses and |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
73 |
* return. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
74 |
int asyncns_wait(asyncns_t *asyncns, int block); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
75 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
76 |
/** Issue a name to address query on the specified session. The |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
77 |
* arguments are compatible with the ones of libc's |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
78 |
* getaddrinfo(3). The function returns a new query object. When the |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
79 |
* query is completed you may retrieve the results using |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
80 |
* asyncns_getaddrinfo_done().*/ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
81 |
asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
82 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
83 |
/** Retrieve the results of a preceding asyncns_getaddrinfo() |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
84 |
* call. Returns a addrinfo structure and a return value compatible |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
85 |
* with libc's getaddrinfo(3). The query object q is destroyed by this |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
86 |
* call and may not be used any further. Make sure to free the |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
87 |
* returned addrinfo structure with asyncns_freeaddrinfo() and not |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
88 |
* libc's freeaddrinfo(3)! If the query is not completed yet EAI_AGAIN |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
89 |
* is returned.*/ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
90 |
int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
91 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
92 |
/** Issue an address to name query on the specified session. The |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
93 |
arguments are compatible with the ones of libc's getnameinfo(3). The |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
94 |
function returns a new query object. When the query is completed you |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
95 |
may retrieve the results using asyncns_getnameinfo_done(). Set gethost |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
96 |
(resp. getserv) to non-zero if you want to query the hostname |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
97 |
(resp. the service name). */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
98 |
asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
99 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
100 |
/** Retrieve the results of a preceding asyncns_getnameinfo)( |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
101 |
* call. Returns the hostname and the service name in ret_host and |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
102 |
* ret_serv. The query object q is destroyed by this call and may not |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
103 |
* be used any further. If the query is not completed yet EAI_AGAIN is |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
104 |
* returned. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
105 |
int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
106 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
107 |
/** Issue an resolver query on the specified session. The arguments are |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
108 |
* compatible with the ones of libc's res_query(3). The function returns a new |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
109 |
* query object. When the query is completed you may retrieve the results using |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
110 |
* asyncns_res_done(). */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
111 |
asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
112 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
113 |
/** Issue an resolver query on the specified session. The arguments are |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
114 |
* compatible with the ones of libc's res_search(3). The function returns a new |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
115 |
* query object. When the query is completed you may retrieve the results using |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
116 |
* asyncns_res_done(). */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
117 |
asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
118 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
119 |
/** Retrieve the results of a preceding asyncns_res_query)( or |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
120 |
* asyncns_res_search call. The query object q is destroyed by this call and |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
121 |
* may not be used any further. Returns a pointer to the answer of the |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
122 |
* res_query call. If the query is not completed yet -EAGAIN is returned, on |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
123 |
* failure -errno is returned otherwise the length of answer is returned. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
124 |
int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
125 |
**answer); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
126 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
127 |
/** Return the next completed query object. If no query has been |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
128 |
* completed yet, return NULL. Please note that you need to run |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
129 |
* asyncns_wait() before this function will return sensible data. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
130 |
asyncns_query_t* asyncns_getnext(asyncns_t *asyncns); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
131 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
132 |
/** Return the number of query objects (completed or not) attached to |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
133 |
* this session */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
134 |
int asyncns_getnqueries(asyncns_t *asyncns); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
135 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
136 |
/** Cancel a currently running query. q is is destroyed by this call |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
137 |
* and may not be used any futher. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
138 |
void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
139 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
140 |
/** Free the addrinfo structure as returned by |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
141 |
asyncns_getaddrinfo_done(). Make sure to use this functions instead of |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
142 |
the libc's freeaddrinfo()! */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
143 |
void asyncns_freeaddrinfo(struct addrinfo *ai); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
144 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
145 |
/** Returns non-zero when the query operation specified by q has been completed */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
146 |
int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
147 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
148 |
/** Assign some opaque userdata with a query object */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
149 |
void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
150 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
151 |
/** Return userdata assigned to a query object. Use |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
152 |
* asyncns_setuserdata() to set this data. If no data has been set |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
153 |
* prior to this call it returns NULL. */ |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
154 |
void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q); |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
155 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
156 |
#ifdef __cplusplus |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
157 |
} |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
158 |
#endif |
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
159 |
|
52ea4e0b897a
Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff
changeset
|
160 |
#endif |