Merge from vendor branch FILE:
[dragonfly.git] / contrib / bind-9.3 / lib / lwres / include / lwres / context.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2000, 2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: context.h,v 1.14.206.1 2004/03/06 08:15:34 marka Exp $ */
19
20 #ifndef LWRES_CONTEXT_H
21 #define LWRES_CONTEXT_H 1
22
23 #include <stddef.h>
24
25 #include <lwres/lang.h>
26 #include <lwres/int.h>
27 #include <lwres/result.h>
28
29 /*
30  * Used to set various options such as timeout, authentication, etc
31  */
32 typedef struct lwres_context lwres_context_t;
33
34 LWRES_LANG_BEGINDECLS
35
36 typedef void *(*lwres_malloc_t)(void *arg, size_t length);
37 typedef void (*lwres_free_t)(void *arg, void *mem, size_t length);
38
39 /*
40  * XXXMLG
41  *
42  * Make the server reload /etc/resolv.conf periodically.
43  *
44  * Make the server do sortlist/searchlist.
45  *
46  * Client side can disable the search/sortlist processing.
47  *
48  * Use an array of addresses/masks and searchlist for client-side, and
49  * if added to the client disable the processing on the server.
50  *
51  * Share /etc/resolv.conf data between contexts.
52  */
53
54 /*
55  * _SERVERMODE
56  *      Don't allocate and connect a socket to the server, since the
57  *      caller _is_ a server.
58  */
59 #define LWRES_CONTEXT_SERVERMODE        0x00000001U
60
61 lwres_result_t
62 lwres_context_create(lwres_context_t **contextp, void *arg,
63                      lwres_malloc_t malloc_function,
64                      lwres_free_t free_function,
65                      unsigned int flags);
66 /*
67  * Allocate a lwres context.  This is used in all lwres calls.
68  *
69  * Memory management can be replaced here by passing in two functions.
70  * If one is non-NULL, they must both be non-NULL.  "arg" is passed to
71  * these functions.
72  *
73  * Contexts are not thread safe.  Document at the top of the file.
74  * XXXMLG
75  *
76  * If they are NULL, the standard malloc() and free() will be used.
77  *
78  * Requires:
79  *
80  *      contextp != NULL && contextp == NULL.
81  *
82  * Returns:
83  *
84  *      Returns 0 on success, non-zero on failure.
85  */
86
87 void
88 lwres_context_destroy(lwres_context_t **contextp);
89 /*
90  * Frees all memory associated with a lwres context.
91  *
92  * Requires:
93  *
94  *      contextp != NULL && contextp == NULL.
95  */
96
97 lwres_uint32_t
98 lwres_context_nextserial(lwres_context_t *ctx);
99 /*
100  * XXXMLG Document
101  */
102
103 void
104 lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);
105
106 void
107 lwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);
108
109 void *
110 lwres_context_allocmem(lwres_context_t *ctx, size_t len);
111
112 int
113 lwres_context_getsocket(lwres_context_t *ctx);
114
115 lwres_result_t
116 lwres_context_send(lwres_context_t *ctx,
117                    void *sendbase, int sendlen);
118
119 lwres_result_t
120 lwres_context_recv(lwres_context_t *ctx,
121                    void *recvbase, int recvlen,
122                    int *recvd_len);
123
124 lwres_result_t
125 lwres_context_sendrecv(lwres_context_t *ctx,
126                        void *sendbase, int sendlen,
127                        void *recvbase, int recvlen,
128                        int *recvd_len);
129
130 LWRES_LANG_ENDDECLS
131
132 #endif /* LWRES_CONTEXT_H */
133