loudmouth/asyncns.h
author Jayson Vantuyl <jvantuyl@engineyard.com>
Wed, 25 Mar 2009 11:28:18 -0700
changeset 596 9096d2549372
parent 549 99a387fdb1bb
permissions -rw-r--r--
Removed Dangerous Instructions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
     4
/***
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
     5
  This file is part of libasyncns.
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
     6
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
     7
  Copyright 2005-2008 Lennart Poettering
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
     8
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
     9
  libasyncns is free software; you can redistribute it and/or modify
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    10
  it under the terms of the GNU Lesser General Public License as
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    11
  published by the Free Software Foundation, either version 2.1 of the
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    12
  License, or (at your option) any later version.
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    13
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    14
  libasyncns is distributed in the hope that it will be useful, but
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    15
  WITHOUT ANY WARRANTY; without even the implied warranty of
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    17
  Lesser General Public License for more details.
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    18
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    19
  You should have received a copy of the GNU Lesser General Public
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    20
  License along with libasyncns. If not, see
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    21
  <http://www.gnu.org/licenses/>.
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    22
***/
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
#include <sys/types.h>
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    25
#include <sys/socket.h>
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    26
#include <netdb.h>
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    27
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    28
/** \mainpage
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    29
 *
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    30
 * \section moo Method of operation
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    31
 *
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    32
 * 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
    33
 * 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
    34
 * 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
    35
 * program issues via asyncns_getaddrinfo() and
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    36
 * 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
    37
 * threads/processes.
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    38
 *
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    39
 * 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
    40
 * 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
    41
 */
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
/** \example asyncns-test.c
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    44
 * An example program */
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    45
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    46
#ifdef  __cplusplus
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    47
extern "C" {
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    48
#endif
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    49
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    50
/** An opaque libasyncns session structure */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    51
typedef struct asyncns asyncns_t;
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    52
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    53
/** An opaque libasyncns query structure */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    54
typedef struct asyncns_query asyncns_query_t;
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    55
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    56
/** Allocate a new libasyncns session with n_proc worker processes/threads */
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    57
asyncns_t* asyncns_new(unsigned n_proc);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    58
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    59
/** 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
    60
 * asyncns_query_t objects automatically */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    61
void asyncns_free(asyncns_t *asyncns);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    62
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    63
/** 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
    64
 * 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
    65
 * loop. */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    66
int asyncns_fd(asyncns_t *asyncns);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    67
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    68
/** 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
    69
 * 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
    70
 * 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
    71
 * 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
    72
 * return. */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    73
int asyncns_wait(asyncns_t *asyncns, int block);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    74
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    75
/** 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
    76
 * 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
    77
 * 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
    78
 * 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
    79
 * asyncns_getaddrinfo_done().*/
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    80
asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    81
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    82
/** 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
    83
 * 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
    84
 * 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
    85
 * 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
    86
 * 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
    87
 * 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
    88
 * is returned.*/
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    89
int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    90
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    91
/** Issue an address to name query on the specified session. The
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    92
 * arguments are compatible with the ones of libc's
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    93
 * getnameinfo(3). The function returns a new query object. When the
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    94
 * query is completed you may retrieve the results using
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    95
 * asyncns_getnameinfo_done(). Set gethost (resp. getserv) to non-zero
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    96
 * if you want to query the hostname (resp. the service name). */
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    97
asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
    98
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    99
/** Retrieve the results of a preceding asyncns_getnameinfo()
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   100
 * 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
   101
 * 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
   102
 * 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
   103
 * returned. */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   104
int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   105
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   106
/** Issue a resolver query on the specified session. The arguments are
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   107
 * 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
   108
 * 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
   109
 * asyncns_res_done().  */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   110
asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   111
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   112
/** 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
   113
 * 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
   114
 * 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
   115
 * asyncns_res_done().  */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   116
asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   117
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   118
/** Retrieve the results of a preceding asyncns_res_query() or
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   119
 * asyncns_res_search call.  The query object q is destroyed by this
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   120
 * call and may not be used any further. Returns a pointer to the
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   121
 * answer of the res_query call. If the query is not completed yet
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   122
 * -EAGAIN is returned, on failure -errno is returned, otherwise the
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   123
 * length of answer is returned. Make sure to free the answer is a
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   124
 * call to asyncns_freeanswer(). */
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   125
int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer);
271
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.  */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   130
asyncns_query_t* asyncns_getnext(asyncns_t *asyncns);
271
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 */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   134
int asyncns_getnqueries(asyncns_t *asyncns);
271
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. */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   138
void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q);
271
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
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   141
 * asyncns_getaddrinfo_done(). Make sure to use this functions instead
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   142
 * of the libc's freeaddrinfo()! */
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   143
void asyncns_freeaddrinfo(struct addrinfo *ai);
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   144
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   145
/** Free the answer data as returned by asyncns_res_done().*/
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   146
void asyncns_freeanswer(unsigned char *answer);
271
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
/** Returns non-zero when the query operation specified by q has been completed */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   149
int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q);
271
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
/** Assign some opaque userdata with a query object */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   152
void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   153
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   154
/** 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
   155
 * 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
   156
 * prior to this call it returns NULL. */
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   157
void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q);
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   158
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   159
#ifdef  __cplusplus
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   160
}
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   161
#endif
549
99a387fdb1bb Updated asyncns.[ch]
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   162
271
52ea4e0b897a Perform name resolution asynchronously. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
diff changeset
   163
#endif