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