1 .\" $NetBSD: nsdispatch.3,v 1.8 1999/03/22 19:44:53 garbled Exp $
3 .\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
18 .\" contributors may be used to endorse or promote products derived
19 .\" from this software without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 .\" POSSIBILITY OF SUCH DAMAGE.
33 .\" $FreeBSD: src/lib/libc/net/nsdispatch.3,v 1.14 2007/01/22 11:45:25 bms Exp $
40 .Nd name-service switch dispatcher routine
50 .Fa "const ns_dtab dtab[]"
51 .Fa "const char *database"
52 .Fa "const char *method_name"
53 .Fa "const ns_src defaults[]"
59 function invokes the methods specified in
65 until a successful entry is found.
68 is passed to each method to modify as necessary, to pass back results to
72 Each method has the function signature described by the typedef:
75 .Fn (*nss_method) "void *retval" "void *mdata" "va_list *ap" ;
81 structures, which have the following format:
82 .Bl -item -offset indent
85 typedef struct _ns_dtab {
94 array should consist of one entry for each source type that is
97 as the name of the source,
99 as a function which handles that source, and
101 as a handle on arbitrary data to be passed to the method.
113 Additionally, methods may be implemented in NSS modules, in
114 which case they are selected using the
118 arguments along with the configured source.
119 (The methods supplied via
121 take priority over those implemented in NSS modules in the event
125 contains a list of default sources to try if
127 is missing or corrupted, or if there is no relevant entry for
131 structures, which have the following format:
132 .Bl -item -offset indent
135 typedef struct _ns_src {
143 array should consist of one entry for each source to be configured by
148 set to the criterion desired
152 .Sx Method return values
153 for more information).
164 For convenience, a global variable defined as:
165 .Dl extern const ns_src __nsdefaultsrc[];
166 exists which contains a single default entry for the source
168 that may be used by callers which do not require complicated default
173 are optional extra arguments, which are passed to the appropriate method
174 as a variable argument list of the type
177 .Ss Valid source types
178 While there is support for arbitrary sources, the following
179 #defines for commonly implemented sources are available:
180 .Bl -column NSSRC_COMPAT compat -offset indent
181 .It Sy "#define value"
182 .It Dv NSSRC_FILES Ta \&"files"
183 .It Dv NSSRC_DNS Ta \&"dns"
184 .It Dv NSSRC_NIS Ta \&"nis"
185 .It Dv NSSRC_COMPAT Ta \&"compat"
190 for a complete description of what each source type is.
191 .Ss Method return values
194 functions must return one of the following values depending upon status
196 .Bl -column "Return value" "Status code"
197 .It Sy "Return value Status code"
198 .It Dv NS_SUCCESS Ta success
199 .It Dv NS_NOTFOUND Ta notfound
200 .It Dv NS_UNAVAIL Ta unavail
201 .It Dv NS_TRYAGAIN Ta tryagain
202 .It Dv NS_RETURN Ta -none-
207 for a complete description of each status code.
211 function returns the value of the method that caused the dispatcher to
218 provides stubs for compatibility with NSS modules
224 However, these stubs only support the use of the
232 .Xr nsswitch.conf 5 ,
237 function first appeared in
239 It was imported from the
242 where it appeared first in
245 .An Luke Mewburn Aq Mt lukem@netbsd.org
246 wrote this freely-distributable name-service switch implementation,
257 added the support for threads and NSS modules, and normalized the uses
260 within the standard C library.