nsswitch.h revision 65532
1/* $NetBSD: nsswitch.h,v 1.6 1999/01/26 01:04:07 lukem Exp $ */ 2/* $FreeBSD: head/include/nsswitch.h 65532 2000-09-06 18:16:48Z nectar $ */ 3 4/*- 5 * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Luke Mewburn. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40#ifndef _NSSWITCH_H 41#define _NSSWITCH_H 1 42 43#include <sys/types.h> 44 45#if __STDC__ 46#include <stdarg.h> 47#else 48#include <varargs.h> 49#endif 50 51#ifndef _PATH_NS_CONF 52#define _PATH_NS_CONF "/etc/nsswitch.conf" 53#endif 54 55#define NS_CONTINUE 0 56#define NS_RETURN 1 57 58#define NS_SUCCESS (1<<0) /* entry was found */ 59#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */ 60#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */ 61#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */ 62#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */ 63 64/* 65 * currently implemented sources 66 */ 67#define NSSRC_FILES "files" /* local files */ 68#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */ 69#define NSSRC_NIS "nis" /* YP/NIS */ 70#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */ 71 72/* 73 * currently implemented databases 74 */ 75#define NSDB_HOSTS "hosts" 76#define NSDB_GROUP "group" 77#define NSDB_GROUP_COMPAT "group_compat" 78#define NSDB_NETGROUP "netgroup" 79#define NSDB_NETWORKS "networks" 80#define NSDB_PASSWD "passwd" 81#define NSDB_PASSWD_COMPAT "passwd_compat" 82#define NSDB_SHELLS "shells" 83 84/* 85 * suggested databases to implement 86 */ 87#define NSDB_ALIASES "aliases" 88#define NSDB_AUTH "auth" 89#define NSDB_AUTOMOUNT "automount" 90#define NSDB_BOOTPARAMS "bootparams" 91#define NSDB_ETHERS "ethers" 92#define NSDB_EXPORTS "exports" 93#define NSDB_NETMASKS "netmasks" 94#define NSDB_PHONES "phones" 95#define NSDB_PRINTCAP "printcap" 96#define NSDB_PROTOCOLS "protocols" 97#define NSDB_REMOTE "remote" 98#define NSDB_RPC "rpc" 99#define NSDB_SENDMAILVARS "sendmailvars" 100#define NSDB_SERVICES "services" 101#define NSDB_TERMCAP "termcap" 102#define NSDB_TTYS "ttys" 103 104/* 105 * ns_dtab - `nsswitch dispatch table' 106 * contains an entry for each source and the appropriate function to call 107 */ 108typedef struct { 109 const char *src; 110 int (*callback)(void *retval, void *cb_data, va_list ap); 111 void *cb_data; 112} ns_dtab; 113 114/* 115 * macros to help build an ns_dtab[] 116 */ 117#define NS_FILES_CB(F,C) { NSSRC_FILES, F, C }, 118#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, C }, 119 120#ifdef HESIOD 121# define NS_DNS_CB(F,C) { NSSRC_DNS, F, C }, 122#else 123# define NS_DNS_CB(F,C) 124#endif 125 126#ifdef YP 127# define NS_NIS_CB(F,C) { NSSRC_NIS, F, C }, 128#else 129# define NS_NIS_CB(F,C) 130#endif 131 132/* 133 * ns_src - `nsswitch source' 134 * used by the nsparser routines to store a mapping between a source 135 * and its dispatch control flags for a given database. 136 */ 137typedef struct { 138 const char *name; 139 u_int32_t flags; 140} ns_src; 141 142 143/* 144 * default sourcelist (if nsswitch.conf is missing, corrupt, 145 * or the requested database doesn't have an entry. 146 */ 147extern const ns_src __nsdefaultsrc[]; 148 149 150#ifdef _NS_PRIVATE 151 152/* 153 * private data structures for back-end nsswitch implementation 154 */ 155 156/* 157 * ns_dbt - `nsswitch database thang' 158 * for each database in /etc/nsswitch.conf there is a ns_dbt, with its 159 * name and a list of ns_src's containing the source information. 160 */ 161typedef struct { 162 const char *name; /* name of database */ 163 ns_src *srclist; /* list of sources */ 164 int srclistsize; /* size of srclist */ 165} ns_dbt; 166 167#endif /* _NS_PRIVATE */ 168 169 170#include <sys/cdefs.h> 171 172__BEGIN_DECLS 173extern int nsdispatch __P((void *, const ns_dtab [], const char *, 174 const char *, const ns_src [], ...)); 175 176#ifdef _NS_PRIVATE 177extern void _nsdbtaddsrc __P((ns_dbt *, const ns_src *)); 178extern void _nsdbtdump __P((const ns_dbt *)); 179extern const ns_dbt *_nsdbtget __P((const char *)); 180extern void _nsdbtput __P((const ns_dbt *)); 181extern void _nsyyerror __P((const char *)); 182extern int _nsyylex __P((void)); 183extern int _nsyylineno; 184#endif /* _NS_PRIVATE */ 185 186__END_DECLS 187 188#endif /* !_NSSWITCH_H */ 189