1 .\" $NetBSD: nsdispatch.3,v 1.8 1999/03/22 19:44:53 garbled Exp $
2 .\" $FreeBSD: src/lib/libc/net/nsdispatch.3,v 1.5 2001/10/01 16:08:56 ru Exp $
4 .\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
5 .\" All rights reserved.
7 .\" This code is derived from software contributed to The NetBSD Foundation
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. All advertising materials mentioning features or use of this software
19 .\" must display the following acknowledgement:
20 .\" This product includes software developed by the NetBSD
21 .\" Foundation, Inc. and its contributors.
22 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
23 .\" contributors may be used to endorse or promote products derived
24 .\" from this software without specific prior written permission.
26 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 .\" POSSIBILITY OF SUCH DAMAGE.
43 .Nd name-service switch dispatcher routine
51 .Fa "const ns_dtab dtab[]"
52 .Fa "const char *database"
53 .Fa "const char *method"
54 .Fa "const ns_src defaults[]"
60 function invokes the callback functions specified in
63 .Pa /etc/nsswitch.conf
66 until a successful entry is found.
69 is passed to each callback function to modify as necessary
70 (to pass back to the caller of
76 structures, which have the following format:
77 .Bd -literal -offset indent
80 int (*cb)(void *retval, void *cb_data, va_list ap);
85 .Bd -ragged -offset indent
86 For each source type that is implemented, an entry with
88 set to the name of the source,
90 defined as a function which handles that source, and
92 is used to pass arbritrary data to the callback function.
105 is usually the name of the function calling
107 When dynamic loading is supported, a symbol constructed from
109 the current source, and
111 will be used as the name to invoke the dynamically loaded function.
114 contains a list of default sources to try in the case of
116 .Xr nsswitch.conf 5 ,
117 or if there isn't a relevant entry for
121 structures, which have the following format:
122 .Bd -literal -offset indent
129 .Bd -ragged -offset indent
130 For each default source type, an entry with
132 set to the name of the source, and
134 set to the relevant flags
138 .Sx Callback return values
139 for more information).
150 For convenience, a global variable defined as:
151 .Dl extern const ns_src __nsdefaultsrc[];
152 exists which contains a single default entry for
154 for use by callers which don't require complicated default rules.
158 are optional extra arguments, which
159 are passed to the appropriate callback function as a variable argument
162 .Ss Valid source types
163 Whilst there is support for arbitrary sources, the following
164 #defines for commonly implementated sources are available:
165 .Bl -column NS_COMPAT COMPAT -offset indent
166 .It Sy "#define value"
167 .It "NSSRC_FILES ""files"""
168 .It "NSSRC_DNS ""dns"""
169 .It "NSSRC_NIS ""nis"""
170 .It "NSSRC_COMPAT ""compat"""
175 for a complete description of what each source type is.
177 .Ss Callback return values
178 The callback functions should return one of the following values
179 depending upon status of the lookup:
180 .Bl -column NS_NOTFOUND -offset indent
181 .It Sy "Return value Status code"
182 .It "NS_SUCCESS success"
183 .It "NS_NOTFOUND notfound"
184 .It "NS_UNAVAIL unavail"
185 .It "NS_TRYAGAIN tryagain"
190 for a complete description of what each status code is.
193 returns the value of the callback that caused the dispatcher to finish,
194 or NS_NOTFOUND otherwise.
203 routines first appeared in
205 They were imported from the
208 where they appeared first in
213 wrote this freely distributable name-service switch implementation,
224 routines are not thread safe.
225 This will be rectified in the future.
227 Currently there is no support for dynamically loadable dispatcher callback
229 It is anticipated that this will be added in the future in the back-end
230 without requiring changes to code that invokes