xref: /titanic_44/usr/src/lib/libc/inc/nsswitch_priv.h (revision 5c46c6a053defc1bf25f2e08df2653bc7717ed0b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * nsswitch_priv.h
28  *
29  * The original switch low level interface to switch was defined in
30  * /usr/include/nsswitch.h.  Although it was marked "Project Private",
31  * it was none-the-less "exposed" and used by several apps.  This
32  * file, nsswitch_priv.h will *not* go in /usr/include to limit "exposure"
33  * and contains new versions of the switch low level interface.
34  *
35  * This is a Project Private interface.  It may change in future releases.
36  *	==== ^^^^^^^^^^^^^^^ ?
37  */
38 
39 #ifndef _NSSWITCH_PRIV_H
40 #define	_NSSWITCH_PRIV_H
41 
42 #pragma ident	"%Z%%M%	%I%	%E% SMI"
43 
44 #include <nsswitch.h>
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 
51 #define	__NSW_STD_ERRS_V1	5 /* V1 number of reserved errors */
52 
53 /*
54  * Results: the first of which are from /usr/include/nsswitch.h
55  *
56  * #define	__NSW_SUCCESS	0	 found the required data
57  * #define	__NSW_NOTFOUND	1 the naming service returned lookup failure
58  * #define	__NSW_UNAVAIL	2	 could not call the naming service
59  * #define	__NSW_TRYAGAIN	3	 bind error to suggest a retry
60  */
61 
62 /* nis server in dns forwarding mode and dns server non-response */
63 #define	__NSW_NISSERVDNS_TRYAGAIN	4
64 
65 /*
66  * Actions: the first of which are from /usr/include/nsswitch.h
67  *
68  * #define	__NSW_CONTINUE	0 the action is to continue to next service
69  * #define	__NSW_RETURN	1 the action is to return to the user
70  */
71 
72 /* the action is to retry the request until we get an answer */
73 #define	__NSW_TRYAGAIN_FOREVER	2
74 /* the action is to retry the request N times maximum */
75 #define	__NSW_TRYAGAIN_NTIMES	3
76 /* retried N times so disable try-again until service is restored */
77 #define	__NSW_TRYAGAIN_PAUSED	4
78 
79 /* is this action available to all switch errs? */
80 #define	__NSW_COMMON_ACTION(act)\
81 	(((act) == __NSW_CONTINUE) || ((act) == __NSW_RETURN))
82 
83 #define	__NSW_SUCCESS_ACTION(act)	__NSW_COMMON_ACTION(act)
84 #define	__NSW_NOTFOUND_ACTION(act)	__NSW_COMMON_ACTION(act)
85 #define	__NSW_UNAVAIL_ACTION(act)	__NSW_COMMON_ACTION(act)
86 #define	__NSW_TRYAGAIN_ACTION(act) \
87 	(__NSW_COMMON_ACTION(act) || \
88 	    ((act) == __NSW_TRYAGAIN_FOREVER) || \
89 	    ((act) == __NSW_TRYAGAIN_NTIMES))
90 #define	__NSW_UNPAUSE_ACTION(act)\
91 	(((act) == __NSW_TRYAGAIN_PAUSED) && ((act) = __NSW_TRYAGAIN_NTIMES))
92 
93 #define	__NSW_STR_FOREVER	"forever"
94 
95 #ifdef __NSS_PRIVATE_INTERFACE
96 
97 struct __nsw_lookup_v1 {
98 	char *service_name;
99 	action_t actions[__NSW_STD_ERRS_V1];
100 	int max_retries;  /* for TRYAGAIN=N */
101 	struct __nsw_long_err *long_errs;
102 	struct __nsw_lookup_v1 *next;
103 };
104 
105 struct __nsw_switchconfig_v1 {
106 	int vers;
107 	char *dbase;
108 	int num_lookups;
109 	struct __nsw_lookup_v1 *lookups;
110 };
111 
112 #define	__NSW_ACTION_V1(lkp, err) 	\
113 	((lkp)->next == NULL ? \
114 		__NSW_RETURN \
115 	: \
116 		((err) >= 0 && (err) < __NSW_STD_ERRS_V1 ? \
117 			(lkp)->actions[err] \
118 		: \
119 			__nsw_extended_action_v1(lkp, err)))
120 
121 
122 struct __nsw_switchconfig_v1 *__nsw_getconfig_v1
123 	(const char *, enum __nsw_parse_err *);
124 int __nsw_freeconfig_v1(struct __nsw_switchconfig_v1 *);
125 action_t __nsw_extended_action_v1(struct __nsw_lookup_v1 *, int);
126 
127 #endif /* __NSS_PRIVATE_INTERFACE */
128 
129 #ifdef	__cplusplus
130 }
131 #endif
132 
133 #endif /* _NSSWITCH_PRIV_H */
134