nsswitch.h revision 1.3
1/* $NetBSD: nsswitch.h,v 1.3 1999/01/16 02:58:28 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Luke Mewburn. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 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. 25 * 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. 37 */ 38 39#ifndef _NSSWITCH_H 40#define _NSSWITCH_H 1 41 42#include <sys/types.h> 43 44#if __STDC__ 45#include <stdarg.h> 46#else 47#include <varargs.h> 48#endif 49 50#ifndef _PATH_NS_CONF 51#define _PATH_NS_CONF "/etc/nsswitch.conf" 52#endif 53 54#define NS_CONTINUE 0 55#define NS_RETURN 1 56 57#define NS_SUCCESS (1<<0) /* entry was found */ 58#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */ 59#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */ 60#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */ 61#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */ 62 63/* 64 * currently implemented sources 65 */ 66#define NSSRC_FILES "files" /* local files */ 67#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */ 68#define NSSRC_NIS "nis" /* YP/NIS */ 69#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */ 70 71/* 72 * currently implemented databases 73 */ 74#define NSDB_HOSTS "hosts" 75#define NSDB_GROUP "group" 76#define NSDB_GROUP_COMPAT "group_compat" 77#define NSDB_NETGROUP "netgroup" 78#define NSDB_NETWORKS "networks" 79#define NSDB_PASSWD "passwd" 80#define NSDB_PASSWD_COMPAT "passwd_compat" 81#define NSDB_SHELLS "shells" 82 83/* 84 * suggested databases to implement 85 */ 86#define NSDB_ALIASES "aliases" 87#define NSDB_AUTH "auth" 88#define NSDB_AUTOMOUNT "automount" 89#define NSDB_BOOTPARAMS "bootparams" 90#define NSDB_ETHERS "ethers" 91#define NSDB_EXPORTS "exports" 92#define NSDB_NETMASKS "netmasks" 93#define NSDB_PHONES "phones" 94#define NSDB_PRINTCAP "printcap" 95#define NSDB_PROTOCOLS "protocols" 96#define NSDB_REMOTE "remote" 97#define NSDB_RPC "rpc" 98#define NSDB_SENDMAILVARS "sendmailvars" 99#define NSDB_SERVICES "services" 100#define NSDB_TERMCAP "termcap" 101#define NSDB_TTYS "ttys" 102 103/* 104 * ns_dtab - `nsswitch dispatch table' 105 * contains an entry for each source and the appropriate function to call 106 */ 107typedef struct ns_dtab { 108 const char *src; 109 int (*callback)(void *retval, void *cb_data, va_list ap); 110 void *cb_data; 111} ns_dtab; 112 113/* 114 * macros to help build an ns_dtab[] 115 */ 116#define NS_FILES_CB(F,C) { NSSRC_FILES, F, NULL } 117 118#ifdef HESIOD 119# define NS_DNS_CB(F,C) { NSSRC_DNS, F, NULL } 120#else 121# define NS_DNS_CB(F,C) { NSSRC_DNS, NULL, NULL } 122#endif 123 124#ifdef YP 125# define NS_NIS_CB(F,C) { NSSRC_NIS, F, NULL } 126#else 127# define NS_NIS_CB(F,C) { NSSRC_NIS, NULL, NULL } 128#endif 129 130#if defined(HESIOD) || defined(YP) 131# define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, NULL } 132#else 133# define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, NULL, NULL } 134#endif 135 136 137#ifdef _NS_PRIVATE 138 139/* 140 * private data structures for back-end nsswitch implementation 141 */ 142 143/* 144 * ns_src - `nsswitch source' 145 * used by the nsparser routines to store a mapping between a source 146 * and its dispatch control flags for a given database. 147 */ 148typedef struct ns_src { 149 const char *name; 150 u_int32_t flags; 151} ns_src; 152 153/* 154 * ns_dbt - `nsswitch database thang' 155 * for each database in /etc/nsswitch.conf there is a ns_dbt, with its 156 * name and a list of ns_src's containing the source information. 157 */ 158typedef struct ns_dbt { 159 const char *name; /* name of database */ 160 ns_src *srclist; /* list of sources */ 161 int srclistsize; /* size of srclist */ 162} ns_dbt; 163 164#endif /* _NS_PRIVATE */ 165 166 167#include <sys/cdefs.h> 168 169__BEGIN_DECLS 170extern int nsdispatch __P((void *, const ns_dtab [], const char *, 171 ...)); 172 173#ifdef _NS_PRIVATE 174extern void _nsdbtaddsrc __P((ns_dbt *, const ns_src *)); 175extern void _nsdbtdump __P((const ns_dbt *)); 176extern const ns_dbt *_nsdbtget __P((const char *)); 177extern void _nsdbtput __P((const ns_dbt *)); 178extern void _nsyyerror __P((const char *)); 179extern int _nsyylex __P((void)); 180extern int _nsyylineno; 181#endif /* _NS_PRIVATE */ 182 183__END_DECLS 184 185#endif /* !_NSSWITCH_H */ 186