/*-
* Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Luke Mewburn.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ns_dtab `callback' function signature.
*/
typedef int (*nss_method)(void *, void *, va_list);
/*
* ns_dtab - `nsswitch dispatch table'
* Contains an entry for each source and the appropriate function to call.
*/
typedef struct {
const char *src;
nss_method callback;
void *cb_data;
} ns_dtab;
/*
* Macros to help build an ns_dtab[]
*/
#define NS_FILES_CB(F,C) { NSSRC_FILES, F, __UNCONST(C) },
#define NS_COMPAT_CB(F,C) { NSSRC_COMPAT, F, __UNCONST(C) },
/*
* ns_src - `nsswitch source'
* Used by the nsparser routines to store a mapping between a source
* and its dispatch control flags for a given database.
*/
typedef struct {
const char *name;
uint32_t flags;
} ns_src;
/*
* Default sourcelists (if nsswitch.conf is missing, corrupt,
* or the requested database doesn't have an entry)
*/
extern const ns_src __nsdefaultsrc[];
extern const ns_src __nsdefaultcompat[];
extern const ns_src __nsdefaultcompat_forceall[];
extern const ns_src __nsdefaultfiles[];
extern const ns_src __nsdefaultfiles_forceall[];
extern const ns_src __nsdefaultnis[];
extern const ns_src __nsdefaultnis_forceall[];
/*
* ns_mtab - `nsswitch method table'
* An nsswitch module provides a mapping from (database name, method name)
* tuples to the nss_method and associated callback data. Effectively,
* ns_dtab, but used for dynamically loaded modules.
*/
typedef struct {
const char *database;
const char *name;
nss_method method;
void *mdata;
} ns_mtab;
/*
* nss_module_register_fn - module registration function
* called at module load
* nss_module_unregister_fn - module un-registration function
* called at module unload
*/
typedef void (*nss_module_unregister_fn)(ns_mtab *, unsigned int);
typedef ns_mtab *(*nss_module_register_fn)(const char *, unsigned int *,
nss_module_unregister_fn *);
#ifdef _NS_PRIVATE
/*
* Private data structures for back-end nsswitch implementation.
*/
/*
* ns_dbt - `nsswitch database thang'
* For each database in /etc/nsswitch.conf there is a ns_dbt, with its
* name and a list of ns_src's containing the source information.
*/
typedef struct {
const char *name; /* name of database */
ns_src *srclist; /* list of sources */
unsigned int srclistsize; /* size of srclist */
} ns_dbt;
/*
* ns_mod - `nsswitch module'
*/
typedef struct {
const char *name; /* module name */
void *handle; /* handle from dlopen() */
ns_mtab *mtab; /* method table */
unsigned int mtabsize; /* size of mtab */
/* called to unload module */
nss_module_unregister_fn unregister;
} ns_mod;