1/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#include "nsswitch.h"
19
20/*******************************************************************\
21|* Here we assume one symbol to be defined: *|
22|* *|
23|* DATABASE_NAME - name of the database the function accesses *|
24|* (e.g., hosts, services, ...) *|
25|* *|
26|* One additional symbol may optionally be defined: *|
27|* *|
28|* ALTERNATE_NAME - name of another service which is examined in *|
29|* case DATABASE_NAME is not found *|
30|* *|
31|* DEFAULT_CONFIG - string for default conf (e.g. "files dns") *|
32|* *|
33\*******************************************************************/
34
35#define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
36#define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
37#define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
38
39#define DATABASE_NAME_ID CONCAT2_1 (nss_database_, DATABASE_NAME)
40#define CONCAT2_1(Pre, Name) CONCAT2_2 (Pre, Name)
41#define CONCAT2_2(Pre, Name) Pre##Name
42
43#define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
44#define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
45#define STRINGIFY1(Name) STRINGIFY2 (Name)
46#define STRINGIFY2(Name) #Name
47
48int
49DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name,
50 void **fctp)
51{
52 if (! __nss_database_get (DATABASE_NAME_ID, &DATABASE_NAME_SYMBOL))
53 return -1;
54
55 *ni = DATABASE_NAME_SYMBOL;
56
57 return __nss_lookup (ni, fct_name, fct2_name, fctp);
58}
59libc_hidden_def (DB_LOOKUP_FCT)
60