Merge from vendor branch FILE:
[dragonfly.git] / contrib / bind-9.3 / lib / bind / include / irs.h
1 /*
2  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (c) 1996,1999 by 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
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /*
19  * $Id: irs.h,v 1.2.2.1.4.1 2004/03/09 08:33:29 marka Exp $
20  */
21
22 #ifndef _IRS_H_INCLUDED
23 #define _IRS_H_INCLUDED
24
25 #include <sys/types.h>
26
27 #include <arpa/nameser.h>
28
29 #include <grp.h>
30 #include <netdb.h>
31 #include <resolv.h>
32 #include <pwd.h>
33
34 /*
35  * This is the group map class.
36  */
37 struct irs_gr {
38         void *          private;
39         void            (*close) __P((struct irs_gr *));
40         struct group *  (*next) __P((struct irs_gr *));
41         struct group *  (*byname) __P((struct irs_gr *, const char *));
42         struct group *  (*bygid) __P((struct irs_gr *, gid_t));
43         int             (*list) __P((struct irs_gr *, const char *,
44                                      gid_t, gid_t *, int *));
45         void            (*rewind) __P((struct irs_gr *));
46         void            (*minimize) __P((struct irs_gr *));
47         struct __res_state * (*res_get) __P((struct irs_gr *));
48         void            (*res_set) __P((struct irs_gr *, res_state,
49                                         void (*)(void *)));
50 };
51
52 /*
53  * This is the password map class.
54  */
55 struct irs_pw {
56         void *          private;
57         void            (*close) __P((struct irs_pw *));
58         struct passwd * (*next) __P((struct irs_pw *));
59         struct passwd * (*byname) __P((struct irs_pw *, const char *));
60         struct passwd * (*byuid) __P((struct irs_pw *, uid_t));
61         void            (*rewind) __P((struct irs_pw *));
62         void            (*minimize) __P((struct irs_pw *));
63         struct __res_state * (*res_get) __P((struct irs_pw *));
64         void            (*res_set) __P((struct irs_pw *, res_state,
65                                         void (*)(void *)));
66 };
67
68 /*
69  * This is the service map class.
70  */
71 struct irs_sv {
72         void *          private;
73         void            (*close) __P((struct irs_sv *));
74         struct servent *(*byname) __P((struct irs_sv *,
75                                        const char *, const char *));
76         struct servent *(*byport) __P((struct irs_sv *, int, const char *));
77         struct servent *(*next) __P((struct irs_sv *));
78         void            (*rewind) __P((struct irs_sv *));
79         void            (*minimize) __P((struct irs_sv *));
80         struct __res_state * (*res_get) __P((struct irs_sv *));
81         void            (*res_set) __P((struct irs_sv *, res_state,
82                                         void (*)(void *)));
83 };
84
85 /*
86  * This is the protocols map class.
87  */
88 struct irs_pr {
89         void *          private;
90         void            (*close) __P((struct irs_pr *));
91         struct protoent *(*byname) __P((struct irs_pr *, const char *));
92         struct protoent *(*bynumber) __P((struct irs_pr *, int));
93         struct protoent *(*next) __P((struct irs_pr *));
94         void            (*rewind) __P((struct irs_pr *));
95         void            (*minimize) __P((struct irs_pr *));
96         struct __res_state * (*res_get) __P((struct irs_pr *));
97         void            (*res_set) __P((struct irs_pr *, res_state,
98                                         void (*)(void *)));
99 };
100
101 /*
102  * This is the hosts map class.
103  */
104 struct irs_ho {
105         void *          private;
106         void            (*close) __P((struct irs_ho *));
107         struct hostent *(*byname) __P((struct irs_ho *, const char *));
108         struct hostent *(*byname2) __P((struct irs_ho *, const char *, int));
109         struct hostent *(*byaddr) __P((struct irs_ho *,
110                                        const void *, int, int));
111         struct hostent *(*next) __P((struct irs_ho *));
112         void            (*rewind) __P((struct irs_ho *));
113         void            (*minimize) __P((struct irs_ho *));
114         struct __res_state * (*res_get) __P((struct irs_ho *));
115         void            (*res_set) __P((struct irs_ho *, res_state,
116                                         void (*)(void *)));
117         struct addrinfo *(*addrinfo) __P((struct irs_ho *, const char *,
118                                           const struct addrinfo *));
119 };
120
121 /*
122  * This is the networks map class.
123  */
124 struct irs_nw {
125         void *          private;
126         void            (*close) __P((struct irs_nw *));
127         struct nwent *  (*byname) __P((struct irs_nw *, const char *, int));
128         struct nwent *  (*byaddr) __P((struct irs_nw *, void *, int, int));
129         struct nwent *  (*next) __P((struct irs_nw *));
130         void            (*rewind) __P((struct irs_nw *));
131         void            (*minimize) __P((struct irs_nw *));
132         struct __res_state * (*res_get) __P((struct irs_nw *));
133         void            (*res_set) __P((struct irs_nw *, res_state,
134                                         void (*)(void *)));
135 };
136
137 /*
138  * This is the netgroups map class.
139  */
140 struct irs_ng {
141         void *          private;
142         void            (*close) __P((struct irs_ng *));
143         int             (*next) __P((struct irs_ng *, const char **,
144                                      const char **, const char **));
145         int             (*test) __P((struct irs_ng *, const char *,
146                                      const char *, const char *,
147                                      const char *));
148         void            (*rewind) __P((struct irs_ng *, const char *));
149         void            (*minimize) __P((struct irs_ng *));
150 };
151
152 /*
153  * This is the generic map class, which copies the front of all others.
154  */
155 struct irs_map {
156         void *          private;
157         void            (*close) __P((void *));
158 };
159
160 /*
161  * This is the accessor class.  It contains pointers to all of the
162  * initializers for the map classes for a particular accessor.
163  */
164 struct irs_acc {
165         void *          private;
166         void            (*close) __P((struct irs_acc *));
167         struct irs_gr * (*gr_map) __P((struct irs_acc *));
168         struct irs_pw * (*pw_map) __P((struct irs_acc *));
169         struct irs_sv * (*sv_map) __P((struct irs_acc *));
170         struct irs_pr * (*pr_map) __P((struct irs_acc *));
171         struct irs_ho * (*ho_map) __P((struct irs_acc *));
172         struct irs_nw * (*nw_map) __P((struct irs_acc *));
173         struct irs_ng * (*ng_map) __P((struct irs_acc *));
174         struct __res_state * (*res_get) __P((struct irs_acc *));
175         void            (*res_set) __P((struct irs_acc *, res_state,
176                                         void (*)(void *)));
177 };
178
179 /*
180  * This is because the official definition of "struct netent" has no
181  * concept of CIDR even though it allows variant address families (on
182  * output but not input).  The compatibility stubs convert the structs
183  * below into "struct netent"'s.
184  */
185 struct nwent {
186         char            *n_name;        /* official name of net */
187         char            **n_aliases;    /* alias list */
188         int             n_addrtype;     /* net address type */
189         void            *n_addr;        /* network address */
190         int             n_length;       /* address length, in bits */
191 };
192
193 /*
194  * Hide external function names from POSIX.
195  */
196 #define irs_gen_acc     __irs_gen_acc
197 #define irs_lcl_acc     __irs_lcl_acc
198 #define irs_dns_acc     __irs_dns_acc
199 #define irs_nis_acc     __irs_nis_acc
200 #define irs_irp_acc     __irs_irp_acc
201 #define irs_destroy     __irs_destroy
202 #define irs_dns_gr      __irs_dns_gr
203 #define irs_dns_ho      __irs_dns_ho
204 #define irs_dns_nw      __irs_dns_nw
205 #define irs_dns_pr      __irs_dns_pr
206 #define irs_dns_pw      __irs_dns_pw
207 #define irs_dns_sv      __irs_dns_sv
208 #define irs_gen_gr      __irs_gen_gr
209 #define irs_gen_ho      __irs_gen_ho
210 #define irs_gen_ng      __irs_gen_ng
211 #define irs_gen_nw      __irs_gen_nw
212 #define irs_gen_pr      __irs_gen_pr
213 #define irs_gen_pw      __irs_gen_pw
214 #define irs_gen_sv      __irs_gen_sv
215 #define irs_irp_get_full_response       __irs_irp_get_full_response
216 #define irs_irp_gr      __irs_irp_gr
217 #define irs_irp_ho      __irs_irp_ho
218 #define irs_irp_is_connected    __irs_irp_is_connected
219 #define irs_irp_ng      __irs_irp_ng
220 #define irs_irp_nw      __irs_irp_nw
221 #define irs_irp_pr      __irs_irp_pr
222 #define irs_irp_pw      __irs_irp_pw
223 #define irs_irp_read_line       __irs_irp_read_line
224 #define irs_irp_sv      __irs_irp_sv
225 #define irs_lcl_gr      __irs_lcl_gr
226 #define irs_lcl_ho      __irs_lcl_ho
227 #define irs_lcl_ng      __irs_lcl_ng
228 #define irs_lcl_nw      __irs_lcl_nw
229 #define irs_lcl_pr      __irs_lcl_pr
230 #define irs_lcl_pw      __irs_lcl_pw
231 #define irs_lcl_sv      __irs_lcl_sv
232 #define irs_nis_gr      __irs_nis_gr
233 #define irs_nis_ho      __irs_nis_ho
234 #define irs_nis_ng      __irs_nis_ng
235 #define irs_nis_nw      __irs_nis_nw
236 #define irs_nis_pr      __irs_nis_pr
237 #define irs_nis_pw      __irs_nis_pw
238 #define irs_nis_sv      __irs_nis_sv
239 #define net_data_create __net_data_create
240 #define net_data_destroy        __net_data_destroy
241 #define net_data_minimize       __net_data_minimize
242
243 /*
244  * Externs.
245  */
246 extern struct irs_acc * irs_gen_acc __P((const char *, const char *));
247 extern struct irs_acc * irs_lcl_acc __P((const char *));
248 extern struct irs_acc * irs_dns_acc __P((const char *));
249 extern struct irs_acc * irs_nis_acc __P((const char *));
250 extern struct irs_acc * irs_irp_acc __P((const char *));
251
252 extern void             irs_destroy __P((void));
253
254 /*
255  * These forward declarations are for the semi-private functions in
256  * the get*.c files. Each of these funcs implements the real get*
257  * functionality and the standard versions are just wrappers that
258  * call these. Apart from the wrappers, only irpd is expected to
259  * call these directly, hence these decls are put here and not in
260  * the /usr/include replacements.
261  */
262
263 struct net_data;                        /* forward */
264
265 /*
266  * net_data_create gets a singleton net_data object.  net_data_init
267  * creates as many net_data objects as times it is called.  Clients using
268  * the default interface will use net_data_create by default.  Servers will
269  * probably want net_data_init (one call per client)
270  */
271 struct net_data *net_data_create __P((const char *));
272 struct net_data *net_data_init __P((const char *));
273 void            net_data_destroy __P((void *));
274         
275 extern struct group    *getgrent_p __P((struct net_data *));
276 extern struct group    *getgrnam_p __P((const char *, struct net_data *));
277 extern struct group    *getgrgid_p __P((gid_t, struct net_data *));
278 extern int              setgroupent_p __P((int, struct net_data *));
279 extern void             endgrent_p __P((struct net_data *));
280 extern int              getgrouplist_p __P((const char *, gid_t, gid_t *, int *,
281                                             struct net_data *));
282
283 #ifdef SETGRENT_VOID
284 extern void             setgrent_p __P((struct net_data *));
285 #else
286 extern int              setgrent_p __P((struct net_data *));
287 #endif
288
289 extern struct hostent   *gethostbyname_p __P((const char *,
290                                               struct net_data *));
291 extern struct hostent   *gethostbyname2_p __P((const char *, int,
292                                                struct net_data *));
293 extern struct hostent   *gethostbyaddr_p __P((const char *, int, int,
294                                               struct net_data *));
295 extern struct hostent   *gethostent_p __P((struct net_data *));
296 extern void             sethostent_p __P((int, struct net_data *));
297 extern void             endhostent_p __P((struct net_data *));
298 extern struct hostent   *getipnodebyname_p __P((const char *, int, int, int *,
299                                                struct net_data *));
300 extern struct hostent   *getipnodebyaddr_p __P((const void *, size_t,
301                                               int, int *, struct net_data *));
302
303 extern struct netent    *getnetent_p __P((struct net_data *));
304 extern struct netent    *getnetbyname_p __P((const char *, struct net_data *));
305 extern struct netent    *getnetbyaddr_p __P((unsigned long, int,
306                                              struct net_data *));
307 extern void             setnetent_p __P((int, struct net_data *));
308 extern void             endnetent_p __P((struct net_data *));
309
310 extern void             setnetgrent_p __P((const char *, struct net_data *));
311 extern void             endnetgrent_p __P((struct net_data *));
312 extern int              innetgr_p __P((const char *, const char *, const char *,
313                                        const char *, struct net_data *));
314 extern int              getnetgrent_p __P((const char **, const char **,
315                                            const char **, struct net_data *));
316
317 extern struct protoent  *getprotoent_p __P((struct net_data *));
318 extern struct protoent  *getprotobyname_p __P((const char *,
319                                                struct net_data *));
320 extern struct protoent  *getprotobynumber_p __P((int, struct net_data *));
321 extern void             setprotoent_p __P((int, struct net_data *));
322 extern void             endprotoent_p __P((struct net_data *));
323
324
325 extern struct passwd    *getpwent_p __P((struct net_data *));
326 extern struct passwd    *getpwnam_p __P((const char *, struct net_data *));
327 extern struct passwd    *getpwuid_p __P((uid_t, struct net_data *));
328 extern int              setpassent_p __P((int, struct net_data *));
329 extern void             endpwent_p __P((struct net_data *));
330
331 #ifdef SETPWENT_VOID
332 extern void             setpwent_p __P((struct net_data *));
333 #else
334 extern int              setpwent_p __P((struct net_data *));
335 #endif
336
337 extern struct servent   *getservent_p __P((struct net_data *));
338 extern struct servent   *getservbyname_p __P((const char *, const char *,
339                                               struct net_data *));
340 extern struct servent   *getservbyport_p __P((int, const char *,
341                                               struct net_data *));
342 extern void             setservent_p __P((int, struct net_data *));
343 extern void             endservent_p __P((struct net_data *));
344
345 #endif /*_IRS_H_INCLUDED*/