1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/nsswitch.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,222 @@
1.4 +/* $NetBSD: nsswitch.h,v 1.6 1999/01/26 01:04:07 lukem Exp $ */
1.5 +/* $FreeBSD: src/include/nsswitch.h,v 1.3 2003/04/17 14:14:21 nectar Exp $ */
1.6 +
1.7 +/*-
1.8 + * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
1.9 + * All rights reserved.
1.10 + *
1.11 + * This code is derived from software contributed to The NetBSD Foundation
1.12 + * by Luke Mewburn.
1.13 + *
1.14 + * Redistribution and use in source and binary forms, with or without
1.15 + * modification, are permitted provided that the following conditions
1.16 + * are met:
1.17 + * 1. Redistributions of source code must retain the above copyright
1.18 + * notice, this list of conditions and the following disclaimer.
1.19 + * 2. Redistributions in binary form must reproduce the above copyright
1.20 + * notice, this list of conditions and the following disclaimer in the
1.21 + * documentation and/or other materials provided with the distribution.
1.22 + * 4. Neither the name of The NetBSD Foundation nor the names of its
1.23 + * contributors may be used to endorse or promote products derived
1.24 + * from this software without specific prior written permission.
1.25 + *
1.26 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1.27 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1.28 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.29 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
1.30 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1.31 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1.32 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1.33 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1.34 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.35 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1.36 + * POSSIBILITY OF SUCH DAMAGE.
1.37 + * Portions Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.38 + */
1.39 +
1.40 +#ifndef _NSSWITCH_H
1.41 +#define _NSSWITCH_H 1
1.42 +
1.43 +#include <sys/types.h>
1.44 +#include <stdarg.h>
1.45 +
1.46 +#define NSS_MODULE_INTERFACE_VERSION 1
1.47 +
1.48 +#ifndef _PATH_NS_CONF
1.49 +#define _PATH_NS_CONF "/etc/nsswitch.conf"
1.50 +#endif
1.51 +
1.52 +/* NSS source actions */
1.53 +#define NS_ACTION_CONTINUE 0 /* try the next source */
1.54 +#define NS_ACTION_RETURN 1 /* look no further */
1.55 +
1.56 +#define NS_SUCCESS (1<<0) /* entry was found */
1.57 +#define NS_UNAVAIL (1<<1) /* source not responding, or corrupt */
1.58 +#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */
1.59 +#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retry */
1.60 +#define NS_RETURN (1<<4) /* stop search, e.g. for ERANGE */
1.61 +#define NS_TERMINATE (NS_SUCCESS|NS_RETURN) /* flags that end search */
1.62 +#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */
1.63 +
1.64 +/*
1.65 + * currently implemented sources
1.66 + */
1.67 +#define NSSRC_FILES "files" /* local files */
1.68 +#define NSSRC_DNS "dns" /* DNS; IN for hosts, HS for others */
1.69 +#define NSSRC_NIS "nis" /* YP/NIS */
1.70 +#define NSSRC_COMPAT "compat" /* passwd,group in YP compat mode */
1.71 +
1.72 +/*
1.73 + * currently implemented databases
1.74 + */
1.75 +#define NSDB_HOSTS "hosts"
1.76 +#define NSDB_GROUP "group"
1.77 +#define NSDB_GROUP_COMPAT "group_compat"
1.78 +#define NSDB_NETGROUP "netgroup"
1.79 +#define NSDB_NETWORKS "networks"
1.80 +#define NSDB_PASSWD "passwd"
1.81 +#define NSDB_PASSWD_COMPAT "passwd_compat"
1.82 +#define NSDB_SHELLS "shells"
1.83 +
1.84 +/*
1.85 + * suggested databases to implement
1.86 + */
1.87 +#define NSDB_ALIASES "aliases"
1.88 +#define NSDB_AUTH "auth"
1.89 +#define NSDB_AUTOMOUNT "automount"
1.90 +#define NSDB_BOOTPARAMS "bootparams"
1.91 +#define NSDB_ETHERS "ethers"
1.92 +#define NSDB_EXPORTS "exports"
1.93 +#define NSDB_NETMASKS "netmasks"
1.94 +#define NSDB_PHONES "phones"
1.95 +#define NSDB_PRINTCAP "printcap"
1.96 +#define NSDB_PROTOCOLS "protocols"
1.97 +#define NSDB_REMOTE "remote"
1.98 +#define NSDB_RPC "rpc"
1.99 +#define NSDB_SENDMAILVARS "sendmailvars"
1.100 +#define NSDB_SERVICES "services"
1.101 +#define NSDB_TERMCAP "termcap"
1.102 +#define NSDB_TTYS "ttys"
1.103 +
1.104 +/*
1.105 + * ns_dtab `method' function signature.
1.106 + */
1.107 +typedef int (*nss_method)(void *_retval, void *_mdata, va_list _ap);
1.108 +
1.109 +/*
1.110 + * Macro for generating method prototypes.
1.111 + */
1.112 +#define NSS_METHOD_PROTOTYPE(method) \
1.113 + int method(void *, void *, va_list)
1.114 +
1.115 +/*
1.116 + * ns_dtab - `nsswitch dispatch table'
1.117 + * Contains an entry for each source and the appropriate function to
1.118 + * call. ns_dtabs are used in the nsdispatch() API in order to allow
1.119 + * the application to override built-in actions.
1.120 + */
1.121 +typedef struct _ns_dtab {
1.122 + const char *src; /* Source this entry implements */
1.123 + nss_method method; /* Method to be called */
1.124 + void *mdata; /* Data passed to method */
1.125 +} ns_dtab;
1.126 +
1.127 +/*
1.128 + * macros to help build an ns_dtab[]
1.129 + */
1.130 +#define NS_FILES_CB(F,C) { NSSRC_FILES, F, C },
1.131 +#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, C },
1.132 +
1.133 +#ifdef HESIOD
1.134 +# define NS_DNS_CB(F,C) { NSSRC_DNS, F, C },
1.135 +#else
1.136 +# define NS_DNS_CB(F,C)
1.137 +#endif
1.138 +
1.139 +#ifdef YP
1.140 +# define NS_NIS_CB(F,C) { NSSRC_NIS, F, C },
1.141 +#else
1.142 +# define NS_NIS_CB(F,C)
1.143 +#endif
1.144 +
1.145 +/*
1.146 + * ns_src - `nsswitch source'
1.147 + * used by the nsparser routines to store a mapping between a source
1.148 + * and its dispatch control flags for a given database.
1.149 + */
1.150 +typedef struct _ns_src {
1.151 + const char *name;
1.152 + u_int32_t flags;
1.153 +} ns_src;
1.154 +
1.155 +
1.156 +/*
1.157 + * default sourcelist (if nsswitch.conf is missing, corrupt,
1.158 + * or the requested database doesn't have an entry.
1.159 + */
1.160 +extern const ns_src __nsdefaultsrc[];
1.161 +
1.162 +/*
1.163 + * ns_mtab - NSS method table
1.164 + * An NSS module provides a mapping from (database name, method name)
1.165 + * tuples to the nss_method and associated data.
1.166 + */
1.167 +typedef struct _ns_mtab {
1.168 + const char *database;
1.169 + const char *name;
1.170 + nss_method method;
1.171 + void *mdata;
1.172 +} ns_mtab;
1.173 +
1.174 +/*
1.175 + * NSS module de-registration, called at module unload.
1.176 + */
1.177 +typedef void (*nss_module_unregister_fn)(ns_mtab *, unsigned int);
1.178 +
1.179 +/*
1.180 + * NSS module registration, called at module load.
1.181 + */
1.182 +typedef ns_mtab *(*nss_module_register_fn)(const char *, unsigned int *,
1.183 + nss_module_unregister_fn *);
1.184 +
1.185 +/*
1.186 + * Many NSS interfaces follow the getXXnam, getXXid, getXXent pattern.
1.187 + * Developers are encouraged to use nss_lookup_type where approriate.
1.188 + */
1.189 +enum nss_lookup_type {
1.190 + nss_lt_name = 1,
1.191 + nss_lt_id = 2,
1.192 + nss_lt_all = 3
1.193 +};
1.194 +
1.195 +#ifdef _NS_PRIVATE
1.196 +
1.197 +/*
1.198 + * private data structures for back-end nsswitch implementation
1.199 + */
1.200 +
1.201 +/*
1.202 + * ns_dbt - `nsswitch database thang'
1.203 + * for each database in /etc/nsswitch.conf there is a ns_dbt, with its
1.204 + * name and a list of ns_src's containing the source information.
1.205 + */
1.206 +typedef struct _ns_dbt {
1.207 + const char *name; /* name of database */
1.208 + ns_src *srclist; /* list of sources */
1.209 + int srclistsize; /* size of srclist */
1.210 +} ns_dbt;
1.211 +
1.212 +/*
1.213 + * ns_mod - NSS module
1.214 + */
1.215 +typedef struct _ns_mod {
1.216 + char *name; /* module name */
1.217 + void *handle; /* handle from dlopen */
1.218 + ns_mtab *mtab; /* method table */
1.219 + unsigned int mtabsize; /* count of entries in method table */
1.220 + nss_module_unregister_fn unregister; /* called to unload module */
1.221 +} ns_mod;
1.222 +
1.223 +#endif /* _NS_PRIVATE */
1.224 +
1.225 +#endif /* !_NSSWITCH_H */