2.9
[glibc/nacl-glibc.git] / nss / XXX-lookup.c
blobf88d69e9ec059f4918f1ae6d91a097fe342709db
1 /* Copyright (C) 1996, 1997, 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include "nsswitch.h"
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, services, ...) *|
27 |* *|
28 |* One additional symbol may optionally be defined: *|
29 |* *|
30 |* ALTERNATE_NAME - name of another service which is examined in *|
31 |* case DATABASE_NAME is not found *|
32 |* *|
33 |* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *|
34 |* *|
35 \*******************************************************************/
37 #define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
38 #define DB_COMPAT_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup)
39 #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
40 #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
42 #define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
43 #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
44 #define STRINGIFY1(Name) STRINGIFY2 (Name)
45 #define STRINGIFY2(Name) #Name
47 #ifdef ALTERNATE_NAME
48 #define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME)
49 #else
50 #define ALTERNATE_NAME_STRING NULL
51 #endif
53 #ifndef DEFAULT_CONFIG
54 #define DEFAULT_CONFIG NULL
55 #endif
57 service_user *DATABASE_NAME_SYMBOL attribute_hidden;
59 extern int DB_LOOKUP_FCT (service_user **ni, const char *fct_name,
60 const char *fct2_name, void **fctp)
61 internal_function;
62 libc_hidden_proto (DB_LOOKUP_FCT)
64 int
65 internal_function
66 DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
67 void **fctp)
69 if (DATABASE_NAME_SYMBOL == NULL
70 && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
71 DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
72 return -1;
74 *ni = DATABASE_NAME_SYMBOL;
76 return __nss_lookup (ni, fct_name, fct2_name, fctp);
78 libc_hidden_def (DB_LOOKUP_FCT)
81 #ifndef NO_COMPAT
82 int
83 internal_function attribute_compat_text_section
84 DB_COMPAT_FCT (service_user **ni, const char *fct_name, void **fctp)
86 return DB_LOOKUP_FCT (ni, fct_name, NULL, fctp);
88 #endif