]> git.ipfire.org Git - thirdparty/glibc.git/blob - nss/XXX-lookup.c
Tue Jun 25 02:59:11 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[thirdparty/glibc.git] / nss / XXX-lookup.c
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20 #include "nsswitch.h"
21
22 /*******************************************************************\
23 |* Here we assume one symbol to be defined: *|
24 |* *|
25 |* DATABASE_NAME - name of the database the function accesses *|
26 |* (e.g., hosts, servicess, ...) *|
27 |* *|
28 \*******************************************************************/
29
30 #define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup)
31 #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
32 #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
33
34 #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
35 #define STRINGIFY1(Name) STRINGIFY2 (Name)
36 #define STRINGIFY2(Name) #Name
37
38
39 static service_user *database = NULL;
40
41 int
42 DB_LOOKUP_FCT (service_user **ni, const char *fct_name, void **fctp)
43 {
44 if (database == NULL
45 && __nss_database_lookup (DATABASE_NAME_STRING, &database) < 0)
46 return -1;
47
48 *ni = database;
49
50 return __nss_lookup (ni, fct_name, fctp);
51 }