+++ /dev/null
-/* $NetBSD: nsswitch.h,v 1.20 2008/04/28 20:22:54 martin Exp $ */\r
-\r
-/*-\r
- * Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.\r
- * All rights reserved.\r
- *\r
- * This code is derived from software contributed to The NetBSD Foundation\r
- * by Luke Mewburn.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\r
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\r
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
- * POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-#ifndef _NSSWITCH_H\r
-#define _NSSWITCH_H 1\r
-\r
-/*\r
- * Don't use va_list in prototypes. va_list is typedef'd in two places\r
- * (<machine/varargs.h> and <machine/stdarg.h>), so if we include one of\r
- * them here we may collide with the utility's includes. It's unreasonable\r
- * for utilities to have to include one of them to include nsswitch.h, so\r
- * we get _BSD_VA_LIST_ from <machine/ansi.h> and use it.\r
- */\r
-#include <machine/ansi.h>\r
-#include <sys/types.h>\r
-\r
-#define NSS_MODULE_INTERFACE_VERSION 0\r
-\r
-#ifndef _PATH_NS_CONF\r
-#define _PATH_NS_CONF "/etc/nsswitch.conf"\r
-#endif\r
-\r
-#define NS_CONTINUE 0\r
-#define NS_RETURN 1\r
-\r
-/*\r
- * Layout of:\r
- * uint32_t ns_src.flags\r
- */ \r
- /* nsswitch.conf status codes and nsdispatch(3) return values */\r
-#define NS_SUCCESS (1<<0) /* entry was found */\r
-#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */\r
-#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */\r
-#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retrys */\r
-#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */\r
-\r
- /* internal nsdispatch(3) flags; not settable in nsswitch.conf(5) */\r
-#define NS_FORCEALL (1<<8) /* force all methods to be invoked; */\r
-\r
-/*\r
- * Currently implemented sources.\r
- */\r
-#define NSSRC_FILES "files" /* local files */\r
-#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */\r
-#define NSSRC_NIS "nis" /* YP/NIS */\r
-#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */\r
-\r
-/*\r
- * Currently implemented databases.\r
- */\r
-#define NSDB_HOSTS "hosts"\r
-#define NSDB_GROUP "group"\r
-#define NSDB_GROUP_COMPAT "group_compat"\r
-#define NSDB_NETGROUP "netgroup"\r
-#define NSDB_NETWORKS "networks"\r
-#define NSDB_PASSWD "passwd"\r
-#define NSDB_PASSWD_COMPAT "passwd_compat"\r
-#define NSDB_SHELLS "shells"\r
-\r
-/*\r
- * Suggested databases to implement.\r
- */\r
-#define NSDB_ALIASES "aliases"\r
-#define NSDB_AUTH "auth"\r
-#define NSDB_AUTOMOUNT "automount"\r
-#define NSDB_BOOTPARAMS "bootparams"\r
-#define NSDB_ETHERS "ethers"\r
-#define NSDB_EXPORTS "exports"\r
-#define NSDB_NETMASKS "netmasks"\r
-#define NSDB_PHONES "phones"\r
-#define NSDB_PRINTCAP "printcap"\r
-#define NSDB_PROTOCOLS "protocols"\r
-#define NSDB_REMOTE "remote"\r
-#define NSDB_RPC "rpc"\r
-#define NSDB_SENDMAILVARS "sendmailvars"\r
-#define NSDB_SERVICES "services"\r
-#define NSDB_TERMCAP "termcap"\r
-#define NSDB_TTYS "ttys"\r
-\r
-/*\r
- * ns_dtab `callback' function signature.\r
- */\r
-typedef int (*nss_method)(void *, void *, _BSD_VA_LIST_);\r
-\r
-/*\r
- * ns_dtab - `nsswitch dispatch table'\r
- * Contains an entry for each source and the appropriate function to call.\r
- */\r
-typedef struct {\r
- const char *src;\r
- nss_method callback;\r
- void *cb_data;\r
-} ns_dtab;\r
-\r
-/*\r
- * Macros to help build an ns_dtab[]\r
- */\r
-#define NS_FILES_CB(F,C) { NSSRC_FILES, F, __UNCONST(C) },\r
-#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, __UNCONST(C) },\r
- \r
-#ifdef HESIOD\r
-# define NS_DNS_CB(F,C) { NSSRC_DNS, F, __UNCONST(C) },\r
-#else\r
-# define NS_DNS_CB(F,C)\r
-#endif\r
-\r
-#ifdef YP\r
-# define NS_NIS_CB(F,C) { NSSRC_NIS, F, __UNCONST(C) },\r
-#else\r
-# define NS_NIS_CB(F,C)\r
-#endif\r
-#define NS_NULL_CB { NULL, NULL, NULL },\r
-\r
-/*\r
- * ns_src - `nsswitch source'\r
- * Used by the nsparser routines to store a mapping between a source\r
- * and its dispatch control flags for a given database.\r
- */\r
-typedef struct {\r
- const char *name;\r
- uint32_t flags;\r
-} ns_src;\r
-\r
-\r
-/*\r
- * Default sourcelists (if nsswitch.conf is missing, corrupt,\r
- * or the requested database doesn't have an entry)\r
- */\r
-extern const ns_src __nsdefaultsrc[];\r
-extern const ns_src __nsdefaultcompat[];\r
-extern const ns_src __nsdefaultcompat_forceall[];\r
-extern const ns_src __nsdefaultfiles[];\r
-extern const ns_src __nsdefaultfiles_forceall[];\r
-extern const ns_src __nsdefaultnis[];\r
-extern const ns_src __nsdefaultnis_forceall[];\r
-\r
-\r
-/*\r
- * ns_mtab - `nsswitch method table'\r
- * An nsswitch module provides a mapping from (database name, method name)\r
- * tuples to the nss_method and associated callback data. Effectively,\r
- * ns_dtab, but used for dynamically loaded modules.\r
- */\r
-typedef struct {\r
- const char *database;\r
- const char *name;\r
- nss_method method;\r
- void *mdata;\r
-} ns_mtab;\r
-\r
-/*\r
- * nss_module_register_fn - module registration function\r
- * called at module load\r
- * nss_module_unregister_fn - module un-registration function\r
- * called at module unload\r
- */\r
-typedef void (*nss_module_unregister_fn)(ns_mtab *, u_int);\r
-typedef ns_mtab *(*nss_module_register_fn)(const char *, u_int *,\r
- nss_module_unregister_fn *);\r
-\r
-#ifdef _NS_PRIVATE\r
-\r
-/*\r
- * Private data structures for back-end nsswitch implementation.\r
- */\r
-\r
-/*\r
- * ns_dbt - `nsswitch database thang'\r
- * For each database in /etc/nsswitch.conf there is a ns_dbt, with its\r
- * name and a list of ns_src's containing the source information.\r
- */\r
-typedef struct {\r
- const char *name; /* name of database */\r
- ns_src *srclist; /* list of sources */\r
- u_int srclistsize; /* size of srclist */\r
-} ns_dbt;\r
-\r
-/*\r
- * ns_mod - `nsswitch module'\r
- */\r
-typedef struct {\r
- const char *name; /* module name */\r
- void *handle; /* handle from dlopen() */\r
- ns_mtab *mtab; /* method table */\r
- u_int mtabsize; /* size of mtab */\r
- /* called to unload module */\r
- nss_module_unregister_fn unregister;\r
-} ns_mod;\r
-\r
-#endif /* _NS_PRIVATE */\r
-\r
-\r
-#include <sys/cdefs.h>\r
-\r
-__BEGIN_DECLS\r
-int nsdispatch(void *, const ns_dtab [], const char *,\r
- const char *, const ns_src [], ...);\r
-\r
-#ifdef _NS_PRIVATE\r
-int _nsdbtaddsrc(ns_dbt *, const ns_src *);\r
-void _nsdbtdump(const ns_dbt *);\r
-int _nsdbtput(const ns_dbt *);\r
-void _nsyyerror(const char *);\r
-int _nsyylex(void);\r
-#endif /* _NS_PRIVATE */\r
-\r
-__END_DECLS\r
-\r
-#endif /* !_NSSWITCH_H */\r