epoc32/include/stdapis/nsswitch.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*	$NetBSD: nsswitch.h,v 1.6 1999/01/26 01:04:07 lukem Exp $	*/
williamr@2
     2
/*	$FreeBSD: src/include/nsswitch.h,v 1.3 2003/04/17 14:14:21 nectar Exp $ */
williamr@2
     3
williamr@2
     4
/*-
williamr@2
     5
 * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
williamr@2
     6
 * All rights reserved.
williamr@2
     7
 *
williamr@2
     8
 * This code is derived from software contributed to The NetBSD Foundation
williamr@2
     9
 * by Luke Mewburn.
williamr@2
    10
 *
williamr@2
    11
 * Redistribution and use in source and binary forms, with or without
williamr@2
    12
 * modification, are permitted provided that the following conditions
williamr@2
    13
 * are met:
williamr@2
    14
 * 1. Redistributions of source code must retain the above copyright
williamr@2
    15
 *    notice, this list of conditions and the following disclaimer.
williamr@2
    16
 * 2. Redistributions in binary form must reproduce the above copyright
williamr@2
    17
 *    notice, this list of conditions and the following disclaimer in the
williamr@2
    18
 *    documentation and/or other materials provided with the distribution.
williamr@2
    19
 * 4. Neither the name of The NetBSD Foundation nor the names of its
williamr@2
    20
 *    contributors may be used to endorse or promote products derived
williamr@2
    21
 *    from this software without specific prior written permission.
williamr@2
    22
 *
williamr@2
    23
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
williamr@2
    24
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
williamr@2
    25
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
williamr@2
    26
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
williamr@2
    27
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
williamr@2
    28
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
williamr@2
    29
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
williamr@2
    30
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
williamr@2
    31
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
williamr@2
    32
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
williamr@2
    33
 * POSSIBILITY OF SUCH DAMAGE.
williamr@2
    34
 * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
williamr@2
    35
 */
williamr@2
    36
williamr@2
    37
#ifndef _NSSWITCH_H
williamr@2
    38
#define _NSSWITCH_H	1
williamr@2
    39
williamr@2
    40
#include <sys/types.h>
williamr@2
    41
#include <stdarg.h>
williamr@2
    42
williamr@2
    43
#define NSS_MODULE_INTERFACE_VERSION 1
williamr@2
    44
williamr@2
    45
#ifndef _PATH_NS_CONF
williamr@2
    46
#define _PATH_NS_CONF	"/etc/nsswitch.conf"
williamr@2
    47
#endif
williamr@2
    48
williamr@2
    49
/* NSS source actions */
williamr@2
    50
#define	NS_ACTION_CONTINUE	0	/* try the next source */
williamr@2
    51
#define	NS_ACTION_RETURN	1	/* look no further */
williamr@2
    52
williamr@2
    53
#define	NS_SUCCESS	(1<<0)		/* entry was found */
williamr@2
    54
#define	NS_UNAVAIL	(1<<1)		/* source not responding, or corrupt */
williamr@2
    55
#define	NS_NOTFOUND	(1<<2)		/* source responded 'no such entry' */
williamr@2
    56
#define	NS_TRYAGAIN	(1<<3)		/* source busy, may respond to retry */
williamr@2
    57
#define NS_RETURN	(1<<4)		/* stop search, e.g. for ERANGE */
williamr@2
    58
#define NS_TERMINATE	(NS_SUCCESS|NS_RETURN) /* flags that end search */
williamr@2
    59
#define	NS_STATUSMASK	0x000000ff	/* bitmask to get the status flags */
williamr@2
    60
williamr@2
    61
/*
williamr@2
    62
 * currently implemented sources
williamr@2
    63
 */
williamr@2
    64
#define NSSRC_FILES	"files"		/* local files */
williamr@2
    65
#define	NSSRC_DNS	"dns"		/* DNS; IN for hosts, HS for others */
williamr@2
    66
#define	NSSRC_NIS	"nis"		/* YP/NIS */
williamr@2
    67
#define	NSSRC_COMPAT	"compat"	/* passwd,group in YP compat mode */
williamr@2
    68
williamr@2
    69
/*
williamr@2
    70
 * currently implemented databases
williamr@2
    71
 */
williamr@2
    72
#define NSDB_HOSTS		"hosts"
williamr@2
    73
#define NSDB_GROUP		"group"
williamr@2
    74
#define NSDB_GROUP_COMPAT	"group_compat"
williamr@2
    75
#define NSDB_NETGROUP		"netgroup"
williamr@2
    76
#define NSDB_NETWORKS		"networks"
williamr@2
    77
#define NSDB_PASSWD		"passwd"
williamr@2
    78
#define NSDB_PASSWD_COMPAT	"passwd_compat"
williamr@2
    79
#define NSDB_SHELLS		"shells"
williamr@2
    80
williamr@2
    81
/*
williamr@2
    82
 * suggested databases to implement
williamr@2
    83
 */
williamr@2
    84
#define NSDB_ALIASES		"aliases"
williamr@2
    85
#define NSDB_AUTH		"auth"
williamr@2
    86
#define NSDB_AUTOMOUNT		"automount"
williamr@2
    87
#define NSDB_BOOTPARAMS		"bootparams"
williamr@2
    88
#define NSDB_ETHERS		"ethers"
williamr@2
    89
#define NSDB_EXPORTS		"exports"
williamr@2
    90
#define NSDB_NETMASKS		"netmasks"
williamr@2
    91
#define NSDB_PHONES		"phones"
williamr@2
    92
#define NSDB_PRINTCAP		"printcap"
williamr@2
    93
#define NSDB_PROTOCOLS		"protocols"
williamr@2
    94
#define NSDB_REMOTE		"remote"
williamr@2
    95
#define NSDB_RPC		"rpc"
williamr@2
    96
#define NSDB_SENDMAILVARS	"sendmailvars"
williamr@2
    97
#define NSDB_SERVICES		"services"
williamr@2
    98
#define NSDB_TERMCAP		"termcap"
williamr@2
    99
#define NSDB_TTYS		"ttys"
williamr@2
   100
williamr@2
   101
/*
williamr@2
   102
 * ns_dtab `method' function signature.
williamr@2
   103
 */ 
williamr@2
   104
typedef int (*nss_method)(void *_retval, void *_mdata, va_list _ap);
williamr@2
   105
williamr@2
   106
/*
williamr@2
   107
 * Macro for generating method prototypes.
williamr@2
   108
 */
williamr@2
   109
#define NSS_METHOD_PROTOTYPE(method) \
williamr@2
   110
	int method(void *, void *, va_list)
williamr@2
   111
williamr@2
   112
/*
williamr@2
   113
 * ns_dtab - `nsswitch dispatch table'
williamr@2
   114
 * Contains an entry for each source and the appropriate function to
williamr@2
   115
 * call.  ns_dtabs are used in the nsdispatch() API in order to allow
williamr@2
   116
 * the application to override built-in actions.
williamr@2
   117
 */
williamr@2
   118
typedef struct _ns_dtab {
williamr@2
   119
	const char	 *src;		/* Source this entry implements */
williamr@2
   120
	nss_method	  method;	/* Method to be called */
williamr@2
   121
	void		 *mdata;	/* Data passed to method */
williamr@2
   122
} ns_dtab;
williamr@2
   123
williamr@2
   124
/*
williamr@2
   125
 * macros to help build an ns_dtab[]
williamr@2
   126
 */
williamr@2
   127
#define NS_FILES_CB(F,C)	{ NSSRC_FILES,	F,	C },
williamr@2
   128
#define NS_COMPAT_CB(F,C)	{ NSSRC_COMPAT,	F,	C },
williamr@2
   129
 
williamr@2
   130
#ifdef HESIOD
williamr@2
   131
#   define NS_DNS_CB(F,C)	{ NSSRC_DNS,	F,	C },
williamr@2
   132
#else
williamr@2
   133
#   define NS_DNS_CB(F,C)
williamr@2
   134
#endif
williamr@2
   135
williamr@2
   136
#ifdef YP
williamr@2
   137
#   define NS_NIS_CB(F,C)	{ NSSRC_NIS,	F,	C },
williamr@2
   138
#else
williamr@2
   139
#   define NS_NIS_CB(F,C)
williamr@2
   140
#endif
williamr@2
   141
williamr@2
   142
/*
williamr@2
   143
 * ns_src - `nsswitch source'
williamr@2
   144
 * used by the nsparser routines to store a mapping between a source
williamr@2
   145
 * and its dispatch control flags for a given database.
williamr@2
   146
 */
williamr@2
   147
typedef struct _ns_src {
williamr@2
   148
	const char	*name;
williamr@2
   149
	u_int32_t	 flags;
williamr@2
   150
} ns_src;
williamr@2
   151
williamr@2
   152
williamr@2
   153
/*
williamr@2
   154
 * default sourcelist (if nsswitch.conf is missing, corrupt,
williamr@2
   155
 * or the requested database doesn't have an entry.
williamr@2
   156
 */
williamr@2
   157
extern const ns_src __nsdefaultsrc[];
williamr@2
   158
williamr@2
   159
/*
williamr@2
   160
 * ns_mtab - NSS method table
williamr@2
   161
 * An NSS module provides a mapping from (database name, method name)
williamr@2
   162
 * tuples to the nss_method and associated data.
williamr@2
   163
 */
williamr@2
   164
typedef struct _ns_mtab {
williamr@2
   165
	const char	*database;
williamr@2
   166
	const char	*name;
williamr@2
   167
	nss_method	 method;
williamr@2
   168
	void		*mdata;
williamr@2
   169
} ns_mtab;
williamr@2
   170
williamr@2
   171
/*
williamr@2
   172
 * NSS module de-registration, called at module unload.
williamr@2
   173
 */
williamr@2
   174
typedef void	 (*nss_module_unregister_fn)(ns_mtab *, unsigned int);
williamr@2
   175
williamr@2
   176
/*
williamr@2
   177
 * NSS module registration, called at module load.
williamr@2
   178
 */
williamr@2
   179
typedef ns_mtab *(*nss_module_register_fn)(const char *, unsigned int *,
williamr@2
   180
		       nss_module_unregister_fn *);
williamr@2
   181
williamr@2
   182
/* 
williamr@2
   183
 * Many NSS interfaces follow the getXXnam, getXXid, getXXent pattern.
williamr@2
   184
 * Developers are encouraged to use nss_lookup_type where approriate.
williamr@2
   185
 */
williamr@2
   186
enum nss_lookup_type {
williamr@2
   187
	nss_lt_name = 1,
williamr@2
   188
	nss_lt_id   = 2,
williamr@2
   189
	nss_lt_all  = 3
williamr@2
   190
};
williamr@2
   191
williamr@2
   192
#ifdef _NS_PRIVATE
williamr@2
   193
williamr@2
   194
/*
williamr@2
   195
 * private data structures for back-end nsswitch implementation
williamr@2
   196
 */
williamr@2
   197
williamr@2
   198
/*
williamr@2
   199
 * ns_dbt - `nsswitch database thang'
williamr@2
   200
 * for each database in /etc/nsswitch.conf there is a ns_dbt, with its
williamr@2
   201
 * name and a list of ns_src's containing the source information.
williamr@2
   202
 */
williamr@2
   203
typedef struct _ns_dbt {
williamr@2
   204
	const char	*name;		/* name of database */
williamr@2
   205
	ns_src		*srclist;	/* list of sources */
williamr@2
   206
	int		 srclistsize;	/* size of srclist */
williamr@2
   207
} ns_dbt;
williamr@2
   208
williamr@2
   209
/*
williamr@2
   210
 * ns_mod - NSS module
williamr@2
   211
 */
williamr@2
   212
typedef struct _ns_mod {
williamr@2
   213
	char		*name;		/* module name */
williamr@2
   214
	void		*handle;	/* handle from dlopen */
williamr@2
   215
	ns_mtab		*mtab;		/* method table */
williamr@2
   216
	unsigned int	 mtabsize;	/* count of entries in method table */
williamr@2
   217
	nss_module_unregister_fn unregister; /* called to unload module */
williamr@2
   218
} ns_mod;
williamr@2
   219
williamr@2
   220
#endif /* _NS_PRIVATE */
williamr@2
   221
williamr@2
   222
#endif /* !_NSSWITCH_H */