xref: /netbsd-src/external/bsd/libbind/dist/irs/gen_p.h (revision 5bbd2a12505d72a8177929a37b5cee489d0a1cfd)
1*5bbd2a12Schristos /*	$NetBSD: gen_p.h,v 1.1.1.2 2012/09/09 16:07:54 christos Exp $	*/
2b5677b36Schristos 
3b5677b36Schristos /*
4b5677b36Schristos  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
5b5677b36Schristos  * Copyright (c) 1996,1999 by Internet Software Consortium.
6b5677b36Schristos  *
7b5677b36Schristos  * Permission to use, copy, modify, and distribute this software for any
8b5677b36Schristos  * purpose with or without fee is hereby granted, provided that the above
9b5677b36Schristos  * copyright notice and this permission notice appear in all copies.
10b5677b36Schristos  *
11b5677b36Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
12b5677b36Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13b5677b36Schristos  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
14b5677b36Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15b5677b36Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16b5677b36Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
17b5677b36Schristos  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18b5677b36Schristos  */
19b5677b36Schristos 
20b5677b36Schristos /*
21b5677b36Schristos  * Id: gen_p.h,v 1.3 2005/04/27 04:56:23 sra Exp
22b5677b36Schristos  */
23b5677b36Schristos 
24b5677b36Schristos /*! \file
25b5677b36Schristos  *  Notes:
26b5677b36Schristos  *	We hope to create a complete set of thread-safe entry points someday,
27b5677b36Schristos  *	which will mean a set of getXbyY() functions that take as an argument
28b5677b36Schristos  *	a pointer to the map class, which will have a pointer to the private
29b5677b36Schristos  *	data, which will be used preferentially to the static variables that
30b5677b36Schristos  *	are necessary to support the "classic" interface.  This "classic"
31b5677b36Schristos  *	interface will then be reimplemented as stubs on top of the thread
32b5677b36Schristos  *	safe modules, and will keep the map class pointers as their only
33b5677b36Schristos  *	static data.  HOWEVER, we are not there yet.  So while we will call
34b5677b36Schristos  *	the just-barely-converted map class methods with map class pointers,
35b5677b36Schristos  *	right now they probably all still use statics.  We're not fooling
36b5677b36Schristos  *	anybody, and we're not trying to (yet).
37b5677b36Schristos  */
38b5677b36Schristos 
39b5677b36Schristos #ifndef _GEN_P_H_INCLUDED
40b5677b36Schristos #define _GEN_P_H_INCLUDED
41b5677b36Schristos 
42b5677b36Schristos /*%
43b5677b36Schristos  * These are the access methods.
44b5677b36Schristos  */
45b5677b36Schristos enum irs_acc_id {
46b5677b36Schristos 	irs_lcl,	/*%< Local. */
47b5677b36Schristos 	irs_dns,	/*%< DNS or Hesiod. */
48b5677b36Schristos 	irs_nis,	/*%< Sun NIS ("YP"). */
49b5677b36Schristos 	irs_irp,	/*%< IR protocol. */
50b5677b36Schristos 	irs_nacc
51b5677b36Schristos };
52b5677b36Schristos 
53b5677b36Schristos /*%
54b5677b36Schristos  * These are the map types.
55b5677b36Schristos  */
56b5677b36Schristos enum irs_map_id {
57b5677b36Schristos 	irs_gr,		/*%< "group" */
58b5677b36Schristos 	irs_pw,		/*%< "passwd" */
59b5677b36Schristos 	irs_sv,		/*%< "services" */
60b5677b36Schristos 	irs_pr,		/*%< "protocols" */
61b5677b36Schristos 	irs_ho,		/*%< "hosts" */
62b5677b36Schristos 	irs_nw,		/*%< "networks" */
63b5677b36Schristos 	irs_ng,		/*%< "netgroup" */
64b5677b36Schristos 	irs_nmap
65b5677b36Schristos };
66b5677b36Schristos 
67b5677b36Schristos /*%
68b5677b36Schristos  * This is an accessor instance.
69b5677b36Schristos  */
70b5677b36Schristos struct irs_inst {
71b5677b36Schristos 	struct irs_acc *acc;
72b5677b36Schristos 	struct irs_gr *	gr;
73b5677b36Schristos 	struct irs_pw *	pw;
74b5677b36Schristos 	struct irs_sv *	sv;
75b5677b36Schristos 	struct irs_pr *	pr;
76b5677b36Schristos 	struct irs_ho *	ho;
77b5677b36Schristos 	struct irs_nw *	nw;
78b5677b36Schristos 	struct irs_ng *	ng;
79b5677b36Schristos };
80b5677b36Schristos 
81b5677b36Schristos /*%
82b5677b36Schristos  * This is a search rule for some map type.
83b5677b36Schristos  */
84b5677b36Schristos struct irs_rule {
85b5677b36Schristos 	struct irs_rule *	next;
86b5677b36Schristos 	struct irs_inst *	inst;
87b5677b36Schristos 	int			flags;
88b5677b36Schristos };
89b5677b36Schristos #define IRS_MERGE		0x0001	/*%< Don't stop if acc. has data? */
90b5677b36Schristos #define	IRS_CONTINUE		0x0002	/*%< Don't stop if acc. has no data? */
91b5677b36Schristos /*
92b5677b36Schristos  * This is the private data for a search access class.
93b5677b36Schristos  */
94b5677b36Schristos struct gen_p {
95b5677b36Schristos 	char *			options;
96b5677b36Schristos 	struct irs_rule *	map_rules[(int)irs_nmap];
97b5677b36Schristos 	struct irs_inst		accessors[(int)irs_nacc];
98b5677b36Schristos 	struct __res_state *	res;
99b5677b36Schristos 	void			(*free_res) __P((void *));
100b5677b36Schristos };
101b5677b36Schristos 
102b5677b36Schristos /*
103b5677b36Schristos  * Externs.
104b5677b36Schristos  */
105b5677b36Schristos 
106b5677b36Schristos extern struct irs_acc *	irs_gen_acc __P((const char *, const char *conf_file));
107b5677b36Schristos extern struct irs_gr *	irs_gen_gr __P((struct irs_acc *));
108b5677b36Schristos extern struct irs_pw *	irs_gen_pw __P((struct irs_acc *));
109b5677b36Schristos extern struct irs_sv *	irs_gen_sv __P((struct irs_acc *));
110b5677b36Schristos extern struct irs_pr *	irs_gen_pr __P((struct irs_acc *));
111b5677b36Schristos extern struct irs_ho *	irs_gen_ho __P((struct irs_acc *));
112b5677b36Schristos extern struct irs_nw *	irs_gen_nw __P((struct irs_acc *));
113b5677b36Schristos extern struct irs_ng *	irs_gen_ng __P((struct irs_acc *));
114b5677b36Schristos 
115b5677b36Schristos #endif /*_IRS_P_H_INCLUDED*/
116