]> git.ipfire.org Git - thirdparty/glibc.git/blob - nss/XXX-lookup.c
cb0900d68fac901ed3d9f8b86b25c9a8cd1e6c75
[thirdparty/glibc.git] / nss / XXX-lookup.c
1 /* Copyright (C) 1996-2019 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 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.
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #include "nsswitch.h"
20
21 /*******************************************************************\
22 |* Here we assume one symbol to be defined: *|
23 |* *|
24 |* DATABASE_NAME - name of the database the function accesses *|
25 |* (e.g., hosts, services, ...) *|
26 |* *|
27 |* One additional symbol may optionally be defined: *|
28 |* *|
29 |* ALTERNATE_NAME - name of another service which is examined in *|
30 |* case DATABASE_NAME is not found *|
31 |* *|
32 |* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *|
33 |* *|
34 \*******************************************************************/
35
36 #define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
37 #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
38 #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
39
40 #define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
41 #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
42 #define STRINGIFY1(Name) STRINGIFY2 (Name)
43 #define STRINGIFY2(Name) #Name
44
45 #ifdef ALTERNATE_NAME
46 #define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME)
47 #else
48 #define ALTERNATE_NAME_STRING NULL
49 #endif
50
51 #ifndef DEFAULT_CONFIG
52 #define DEFAULT_CONFIG NULL
53 #endif
54
55 int
56 DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
57 void **fctp)
58 {
59 if (DATABASE_NAME_SYMBOL == NULL
60 && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
61 DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
62 return -1;
63
64 *ni = DATABASE_NAME_SYMBOL;
65
66 return __nss_lookup (ni, fct_name, fct2_name, fctp);
67 }
68 libc_hidden_def (DB_LOOKUP_FCT)