nsswitch.h revision 65532
165532Snectar/*	$NetBSD: nsswitch.h,v 1.6 1999/01/26 01:04:07 lukem Exp $	*/
265532Snectar/*	$FreeBSD: head/include/nsswitch.h 65532 2000-09-06 18:16:48Z nectar $ */
365532Snectar
465532Snectar/*-
565532Snectar * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
665532Snectar * All rights reserved.
765532Snectar *
865532Snectar * This code is derived from software contributed to The NetBSD Foundation
965532Snectar * by Luke Mewburn.
1065532Snectar *
1165532Snectar * Redistribution and use in source and binary forms, with or without
1265532Snectar * modification, are permitted provided that the following conditions
1365532Snectar * are met:
1465532Snectar * 1. Redistributions of source code must retain the above copyright
1565532Snectar *    notice, this list of conditions and the following disclaimer.
1665532Snectar * 2. Redistributions in binary form must reproduce the above copyright
1765532Snectar *    notice, this list of conditions and the following disclaimer in the
1865532Snectar *    documentation and/or other materials provided with the distribution.
1965532Snectar * 3. All advertising materials mentioning features or use of this software
2065532Snectar *    must display the following acknowledgement:
2165532Snectar *        This product includes software developed by the NetBSD
2265532Snectar *        Foundation, Inc. and its contributors.
2365532Snectar * 4. Neither the name of The NetBSD Foundation nor the names of its
2465532Snectar *    contributors may be used to endorse or promote products derived
2565532Snectar *    from this software without specific prior written permission.
2665532Snectar *
2765532Snectar * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2865532Snectar * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2965532Snectar * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3065532Snectar * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
3165532Snectar * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3265532Snectar * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3365532Snectar * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3465532Snectar * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3565532Snectar * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3665532Snectar * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3765532Snectar * POSSIBILITY OF SUCH DAMAGE.
3865532Snectar */
3965532Snectar
4065532Snectar#ifndef _NSSWITCH_H
4165532Snectar#define _NSSWITCH_H	1
4265532Snectar
4365532Snectar#include <sys/types.h>
4465532Snectar
4565532Snectar#if __STDC__
4665532Snectar#include <stdarg.h>
4765532Snectar#else
4865532Snectar#include <varargs.h>
4965532Snectar#endif
5065532Snectar
5165532Snectar#ifndef _PATH_NS_CONF
5265532Snectar#define _PATH_NS_CONF	"/etc/nsswitch.conf"
5365532Snectar#endif
5465532Snectar
5565532Snectar#define	NS_CONTINUE	0
5665532Snectar#define	NS_RETURN	1
5765532Snectar
5865532Snectar#define	NS_SUCCESS	(1<<0)		/* entry was found */
5965532Snectar#define	NS_UNAVAIL	(1<<1)		/* source not responding, or corrupt */
6065532Snectar#define	NS_NOTFOUND	(1<<2)		/* source responded 'no such entry' */
6165532Snectar#define	NS_TRYAGAIN	(1<<3)		/* source busy, may respond to retrys */
6265532Snectar#define	NS_STATUSMASK	0x000000ff	/* bitmask to get the status flags */
6365532Snectar
6465532Snectar/*
6565532Snectar * currently implemented sources
6665532Snectar */
6765532Snectar#define NSSRC_FILES	"files"		/* local files */
6865532Snectar#define	NSSRC_DNS	"dns"		/* DNS; IN for hosts, HS for others */
6965532Snectar#define	NSSRC_NIS	"nis"		/* YP/NIS */
7065532Snectar#define	NSSRC_COMPAT	"compat"	/* passwd,group in YP compat mode */
7165532Snectar
7265532Snectar/*
7365532Snectar * currently implemented databases
7465532Snectar */
7565532Snectar#define NSDB_HOSTS		"hosts"
7665532Snectar#define NSDB_GROUP		"group"
7765532Snectar#define NSDB_GROUP_COMPAT	"group_compat"
7865532Snectar#define NSDB_NETGROUP		"netgroup"
7965532Snectar#define NSDB_NETWORKS		"networks"
8065532Snectar#define NSDB_PASSWD		"passwd"
8165532Snectar#define NSDB_PASSWD_COMPAT	"passwd_compat"
8265532Snectar#define NSDB_SHELLS		"shells"
8365532Snectar
8465532Snectar/*
8565532Snectar * suggested databases to implement
8665532Snectar */
8765532Snectar#define NSDB_ALIASES		"aliases"
8865532Snectar#define NSDB_AUTH		"auth"
8965532Snectar#define NSDB_AUTOMOUNT		"automount"
9065532Snectar#define NSDB_BOOTPARAMS		"bootparams"
9165532Snectar#define NSDB_ETHERS		"ethers"
9265532Snectar#define NSDB_EXPORTS		"exports"
9365532Snectar#define NSDB_NETMASKS		"netmasks"
9465532Snectar#define NSDB_PHONES		"phones"
9565532Snectar#define NSDB_PRINTCAP		"printcap"
9665532Snectar#define NSDB_PROTOCOLS		"protocols"
9765532Snectar#define NSDB_REMOTE		"remote"
9865532Snectar#define NSDB_RPC		"rpc"
9965532Snectar#define NSDB_SENDMAILVARS	"sendmailvars"
10065532Snectar#define NSDB_SERVICES		"services"
10165532Snectar#define NSDB_TERMCAP		"termcap"
10265532Snectar#define NSDB_TTYS		"ttys"
10365532Snectar
10465532Snectar/*
10565532Snectar * ns_dtab - `nsswitch dispatch table'
10665532Snectar * contains an entry for each source and the appropriate function to call
10765532Snectar */
10865532Snectartypedef struct {
10965532Snectar	const char	 *src;
11065532Snectar	int		(*callback)(void *retval, void *cb_data, va_list ap);
11165532Snectar	void		 *cb_data;
11265532Snectar} ns_dtab;
11365532Snectar
11465532Snectar/*
11565532Snectar * macros to help build an ns_dtab[]
11665532Snectar */
11765532Snectar#define NS_FILES_CB(F,C)	{ NSSRC_FILES,	F,	C },
11865532Snectar#define NS_COMPAT_CB(F,C)	{ NSSRC_COMPAT,	F,	C },
11965532Snectar
12065532Snectar#ifdef HESIOD
12165532Snectar#   define NS_DNS_CB(F,C)	{ NSSRC_DNS,	F,	C },
12265532Snectar#else
12365532Snectar#   define NS_DNS_CB(F,C)
12465532Snectar#endif
12565532Snectar
12665532Snectar#ifdef YP
12765532Snectar#   define NS_NIS_CB(F,C)	{ NSSRC_NIS,	F,	C },
12865532Snectar#else
12965532Snectar#   define NS_NIS_CB(F,C)
13065532Snectar#endif
13165532Snectar
13265532Snectar/*
13365532Snectar * ns_src - `nsswitch source'
13465532Snectar * used by the nsparser routines to store a mapping between a source
13565532Snectar * and its dispatch control flags for a given database.
13665532Snectar */
13765532Snectartypedef struct {
13865532Snectar	const char	*name;
13965532Snectar	u_int32_t	 flags;
14065532Snectar} ns_src;
14165532Snectar
14265532Snectar
14365532Snectar/*
14465532Snectar * default sourcelist (if nsswitch.conf is missing, corrupt,
14565532Snectar * or the requested database doesn't have an entry.
14665532Snectar */
14765532Snectarextern const ns_src __nsdefaultsrc[];
14865532Snectar
14965532Snectar
15065532Snectar#ifdef _NS_PRIVATE
15165532Snectar
15265532Snectar/*
15365532Snectar * private data structures for back-end nsswitch implementation
15465532Snectar */
15565532Snectar
15665532Snectar/*
15765532Snectar * ns_dbt - `nsswitch database thang'
15865532Snectar * for each database in /etc/nsswitch.conf there is a ns_dbt, with its
15965532Snectar * name and a list of ns_src's containing the source information.
16065532Snectar */
16165532Snectartypedef struct {
16265532Snectar	const char	*name;		/* name of database */
16365532Snectar	ns_src		*srclist;	/* list of sources */
16465532Snectar	int		 srclistsize;	/* size of srclist */
16565532Snectar} ns_dbt;
16665532Snectar
16765532Snectar#endif /* _NS_PRIVATE */
16865532Snectar
16965532Snectar
17065532Snectar#include <sys/cdefs.h>
17165532Snectar
17265532Snectar__BEGIN_DECLS
17365532Snectarextern	int	nsdispatch	__P((void *, const ns_dtab [], const char *,
17465532Snectar				    const char *, const ns_src [], ...));
17565532Snectar
17665532Snectar#ifdef _NS_PRIVATE
17765532Snectarextern	void		 _nsdbtaddsrc __P((ns_dbt *, const ns_src *));
17865532Snectarextern	void		 _nsdbtdump __P((const ns_dbt *));
17965532Snectarextern	const ns_dbt	*_nsdbtget __P((const char *));
18065532Snectarextern	void		 _nsdbtput __P((const ns_dbt *));
18165532Snectarextern	void		 _nsyyerror __P((const char *));
18265532Snectarextern	int		 _nsyylex __P((void));
18365532Snectarextern	int		 _nsyylineno;
18465532Snectar#endif /* _NS_PRIVATE */
18565532Snectar
18665532Snectar__END_DECLS
18765532Snectar
18865532Snectar#endif /* !_NSSWITCH_H */
189