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