libasyncns  0.8
asyncns.h
Go to the documentation of this file.
00001 #ifndef fooasyncnshfoo
00002 #define fooasyncnshfoo
00003 
00004 /***
00005   This file is part of libasyncns.
00006 
00007   Copyright 2005-2008 Lennart Poettering
00008 
00009   libasyncns is free software; you can redistribute it and/or modify
00010   it under the terms of the GNU Lesser General Public License as
00011   published by the Free Software Foundation, either version 2.1 of the
00012   License, or (at your option) any later version.
00013 
00014   libasyncns is distributed in the hope that it will be useful, but
00015   WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with libasyncns. If not, see
00021   <http://www.gnu.org/licenses/>.
00022 ***/
00023 
00024 #include <sys/types.h>
00025 #include <sys/socket.h>
00026 #include <netdb.h>
00027 
00046 #ifdef  __cplusplus
00047 extern "C" {
00048 #endif
00049 
00051 typedef struct asyncns asyncns_t;
00052 
00054 typedef struct asyncns_query asyncns_query_t;
00055 
00057 asyncns_t* asyncns_new(unsigned n_proc);
00058 
00061 void asyncns_free(asyncns_t *asyncns);
00062 
00066 int asyncns_fd(asyncns_t *asyncns);
00067 
00073 int asyncns_wait(asyncns_t *asyncns, int block);
00074 
00080 asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
00081 
00089 int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
00090 
00097 asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
00098 
00104 int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
00105 
00110 asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
00111 
00116 asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
00117 
00125 int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer);
00126 
00130 asyncns_query_t* asyncns_getnext(asyncns_t *asyncns);
00131 
00134 int asyncns_getnqueries(asyncns_t *asyncns);
00135 
00138 void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q);
00139 
00143 void asyncns_freeaddrinfo(struct addrinfo *ai);
00144 
00146 void asyncns_freeanswer(unsigned char *answer);
00147 
00149 int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q);
00150 
00152 void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
00153 
00157 void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q);
00158 
00159 #ifdef  __cplusplus
00160 }
00161 #endif
00162 
00163 #endif