nsswitch.h revision 1.1.4.1 1 1.1.4.1 lukem /*-
2 1.1.4.1 lukem * Copyright (c) 1997 Luke Mewburn <lukem (at) netbsd.org>
3 1.1.4.1 lukem * All rights reserved.
4 1.1.4.1 lukem *
5 1.1.4.1 lukem * Redistribution and use in source and binary forms, with or without
6 1.1.4.1 lukem * modification, are permitted provided that the following conditions
7 1.1.4.1 lukem * are met:
8 1.1.4.1 lukem * 1. Redistributions of source code must retain the above copyright
9 1.1.4.1 lukem * notice, this list of conditions and the following disclaimer.
10 1.1.4.1 lukem * 2. Redistributions in binary form must reproduce the above copyright
11 1.1.4.1 lukem * notice, this list of conditions and the following disclaimer in the
12 1.1.4.1 lukem * documentation and/or other materials provided with the distribution.
13 1.1.4.1 lukem * 3. All advertising materials mentioning features or use of this software
14 1.1.4.1 lukem * must display the following acknowledgement:
15 1.1.4.1 lukem * This product includes software developed by Luke Mewburn.
16 1.1.4.1 lukem * 4. The name of the author may not be used to endorse or promote products
17 1.1.4.1 lukem * derived from this software without specific prior written permission.
18 1.1.4.1 lukem *
19 1.1.4.1 lukem * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 1.1.4.1 lukem * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 1.1.4.1 lukem * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 1.1.4.1 lukem * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 1.1.4.1 lukem * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 1.1.4.1 lukem * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 1.1.4.1 lukem * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 1.1.4.1 lukem * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 1.1.4.1 lukem * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
28 1.1.4.1 lukem * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 1.1.4.1 lukem *
30 1.1.4.1 lukem */
31 1.1.4.1 lukem #ifndef _NSSWITCH_H
32 1.1.4.1 lukem #define _NSSWITCH_H 1
33 1.1.4.1 lukem
34 1.1.4.1 lukem #if __STDC__
35 1.1.4.1 lukem #include <stdarg.h>
36 1.1.4.1 lukem #else
37 1.1.4.1 lukem #include <varargs.h>
38 1.1.4.1 lukem #endif
39 1.1.4.1 lukem #include <sys/types.h>
40 1.1.4.1 lukem
41 1.1.4.1 lukem #ifndef _PATH_NS_CONF
42 1.1.4.1 lukem #define _PATH_NS_CONF "/etc/nsswitch.conf"
43 1.1.4.1 lukem #endif
44 1.1.4.1 lukem
45 1.1.4.1 lukem #define NS_CONTINUE 0
46 1.1.4.1 lukem #define NS_RETURN 1
47 1.1.4.1 lukem
48 1.1.4.1 lukem #define NS_SUCCESS 0x10 /* entry was found */
49 1.1.4.1 lukem #define NS_UNAVAIL 0x20 /* source not responding, or corrupt */
50 1.1.4.1 lukem #define NS_NOTFOUND 0x40 /* source responded 'no such entry' */
51 1.1.4.1 lukem #define NS_TRYAGAIN 0x80 /* source busy, may respond to retrys */
52 1.1.4.1 lukem #define NS_STATUSMASK 0xf0 /* bitmask to get the status */
53 1.1.4.1 lukem
54 1.1.4.1 lukem #define NS_FILES 0x00 /* local files */
55 1.1.4.1 lukem #define NS_DNS 0x01 /* DNS; class IN for hosts, HS for others */
56 1.1.4.1 lukem #define NS_NIS 0x02 /* yp/nis */
57 1.1.4.1 lukem #define NS_NISPLUS 0x03 /* nis+ */
58 1.1.4.1 lukem #define NS_COMPAT 0x04 /* passwd,group in yp compat mode */
59 1.1.4.1 lukem #define NS_MAXSOURCE 0x0f /* last possible source */
60 1.1.4.1 lukem #define NS_SOURCEMASK 0x0f /* bitmask to get the source */
61 1.1.4.1 lukem
62 1.1.4.1 lukem /*
63 1.1.4.1 lukem * currently implemented databases
64 1.1.4.1 lukem */
65 1.1.4.1 lukem #define NSDB_HOSTS "hosts"
66 1.1.4.1 lukem #define NSDB_GROUP "group"
67 1.1.4.1 lukem #define NSDB_GROUP_COMPAT "group_compat"
68 1.1.4.1 lukem #define NSDB_NETGROUP "netgroup"
69 1.1.4.1 lukem #define NSDB_PASSWD "passwd"
70 1.1.4.1 lukem #define NSDB_PASSWD_COMPAT "passwd_compat"
71 1.1.4.1 lukem #define NSDB_SHELLS "shells"
72 1.1.4.1 lukem
73 1.1.4.1 lukem /*
74 1.1.4.1 lukem * suggested databases to implement
75 1.1.4.1 lukem */
76 1.1.4.1 lukem #define NSDB_ALIASES "aliases"
77 1.1.4.1 lukem #define NSDB_AUTH "auth"
78 1.1.4.1 lukem #define NSDB_AUTOMOUNT "automount"
79 1.1.4.1 lukem #define NSDB_BOOTPARAMS "bootparams"
80 1.1.4.1 lukem #define NSDB_ETHERS "ethers"
81 1.1.4.1 lukem #define NSDB_EXPORTS "exports"
82 1.1.4.1 lukem #define NSDB_NETMASKS "netmasks"
83 1.1.4.1 lukem #define NSDB_NETWORKS "networks"
84 1.1.4.1 lukem #define NSDB_PHONES "phones"
85 1.1.4.1 lukem #define NSDB_PRINTCAP "printcap"
86 1.1.4.1 lukem #define NSDB_PROTOCOLS "protocols"
87 1.1.4.1 lukem #define NSDB_REMOTE "remote"
88 1.1.4.1 lukem #define NSDB_RPC "rpc"
89 1.1.4.1 lukem #define NSDB_SENDMAILVARS "sendmailvars"
90 1.1.4.1 lukem #define NSDB_SERVICES "services"
91 1.1.4.1 lukem #define NSDB_TERMCAP "termcap"
92 1.1.4.1 lukem #define NSDB_TTYS "ttys"
93 1.1.4.1 lukem
94 1.1.4.1 lukem #define NS_MAXDBLEN 32 /* max len of a database name */
95 1.1.4.1 lukem
96 1.1.4.1 lukem typedef struct {
97 1.1.4.1 lukem int (*cb)(void *retval, void *cb_data, va_list ap);
98 1.1.4.1 lukem void *cb_data;
99 1.1.4.1 lukem } ns_dtab [NS_MAXSOURCE];
100 1.1.4.1 lukem
101 1.1.4.1 lukem typedef struct {
102 1.1.4.1 lukem char name[NS_MAXDBLEN]; /* name of database */
103 1.1.4.1 lukem int size; /* number of entries of map */
104 1.1.4.1 lukem u_char map[NS_MAXSOURCE]; /* map, described below */
105 1.1.4.1 lukem } ns_DBT;
106 1.1.4.1 lukem /*
107 1.1.4.1 lukem * ns_DBT.map --
108 1.1.4.1 lukem * array of sources to try in order. each number is a bitmask:
109 1.1.4.1 lukem * - lower 4 bits is source type
110 1.1.4.1 lukem * - upper 4 bits is action bitmap
111 1.1.4.1 lukem * If source has already been set, don't add again to array
112 1.1.4.1 lukem */
113 1.1.4.1 lukem
114 1.1.4.1 lukem #define NS_DEFAULTMAP (NS_FILES | NS_SUCCESS)
115 1.1.4.1 lukem
116 1.1.4.1 lukem #define NS_CB(D,E,F,C) { D[E].cb = F; D[E].cb_data = C; }
117 1.1.4.1 lukem
118 1.1.4.1 lukem #define NS_FILES_CB(D,F,C) NS_CB(D, NS_FILES, F, C)
119 1.1.4.1 lukem
120 1.1.4.1 lukem #ifdef HESIOD
121 1.1.4.1 lukem # define NS_DNS_CB(D,F,C) NS_CB(D, NS_DNS, F, C)
122 1.1.4.1 lukem #else
123 1.1.4.1 lukem # define NS_DNS_CB(D,F,C) NS_CB(D, NS_DNS, NULL, NULL)
124 1.1.4.1 lukem #endif
125 1.1.4.1 lukem
126 1.1.4.1 lukem #ifdef YP
127 1.1.4.1 lukem # define NS_NIS_CB(D,F,C) NS_CB(D, NS_NIS, F, C)
128 1.1.4.1 lukem #else
129 1.1.4.1 lukem # define NS_NIS_CB(D,F,C) NS_CB(D, NS_NIS, NULL, NULL)
130 1.1.4.1 lukem #endif
131 1.1.4.1 lukem
132 1.1.4.1 lukem #ifdef NISPLUS
133 1.1.4.1 lukem # define NS_NISPLUS_CB(D,F,C) NS_CB(D, NS_NISPLUS, F, C)
134 1.1.4.1 lukem #else
135 1.1.4.1 lukem # define NS_NISPLUS_CB(D,F,C) NS_CB(D, NS_NISPLUS, NULL, NULL)
136 1.1.4.1 lukem #endif
137 1.1.4.1 lukem
138 1.1.4.1 lukem #if defined(HESIOD) || defined(YP) || defined(NISPLUS)
139 1.1.4.1 lukem # define NS_COMPAT_CB(D,F,C) NS_CB(D, NS_COMPAT, F, C)
140 1.1.4.1 lukem #else
141 1.1.4.1 lukem # define NS_COMPAT_CB(D,F,C) NS_CB(D, NS_COMPAT, NULL, NULL)
142 1.1.4.1 lukem #endif
143 1.1.4.1 lukem
144 1.1.4.1 lukem
145 1.1.4.1 lukem #include <sys/cdefs.h>
146 1.1.4.1 lukem
147 1.1.4.1 lukem __BEGIN_DECLS
148 1.1.4.1 lukem extern void _nsgetdbt __P((const char *, ns_DBT *));
149 1.1.4.1 lukem extern void _nsdumpdbt __P((const ns_DBT *));
150 1.1.4.1 lukem extern int nsdispatch __P((void *, ns_dtab, const char *, ...));
151 1.1.4.1 lukem __END_DECLS
152 1.1.4.1 lukem
153 1.1.4.1 lukem #endif /* !_NSSWITCH_H */
154