]>
Commit | Line | Data |
---|---|---|
6d7e8eda | 1 | /* Copyright (C) 1996-2023 Free Software Foundation, Inc. |
68dbb3a6 | 2 | This file is part of the GNU C Library. |
5f0e6fc7 | 3 | |
68dbb3a6 | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
5f0e6fc7 | 8 | |
68dbb3a6 UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
5f0e6fc7 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
5f0e6fc7 | 17 | |
3fdf0a20 | 18 | #include <assert.h> |
5f0e6fc7 RM |
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 *| | |
6d52618b | 25 | |* (e.g., hosts, services, ...) *| |
5f0e6fc7 | 26 | |* *| |
bba7bb78 RM |
27 | |* One additional symbol may optionally be defined: *| |
28 | |* *| | |
5a97622d UD |
29 | |* ALTERNATE_NAME - name of another service which is examined in *| |
30 | |* case DATABASE_NAME is not found *| | |
31 | |* *| | |
b99b0f93 | 32 | |* DEFAULT_CONFIG - string for default conf (e.g. "files dns") *| |
bba7bb78 | 33 | |* *| |
5f0e6fc7 RM |
34 | \*******************************************************************/ |
35 | ||
384ca551 | 36 | #define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2) |
5f0e6fc7 RM |
37 | #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post) |
38 | #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post | |
39 | ||
9b456c5d DD |
40 | #define DATABASE_NAME_ID CONCAT2_1 (nss_database_, DATABASE_NAME) |
41 | #define CONCAT2_1(Pre, Name) CONCAT2_2 (Pre, Name) | |
42 | #define CONCAT2_2(Pre, Name) Pre##Name | |
43 | ||
a8874ead | 44 | #define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database) |
5f0e6fc7 RM |
45 | #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME) |
46 | #define STRINGIFY1(Name) STRINGIFY2 (Name) | |
47 | #define STRINGIFY2(Name) #Name | |
48 | ||
5f0e6fc7 | 49 | int |
f4f3b091 | 50 | DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name, |
384ca551 | 51 | void **fctp) |
5f0e6fc7 | 52 | { |
9b456c5d | 53 | if (! __nss_database_get (DATABASE_NAME_ID, &DATABASE_NAME_SYMBOL)) |
5f0e6fc7 RM |
54 | return -1; |
55 | ||
a8874ead | 56 | *ni = DATABASE_NAME_SYMBOL; |
5f0e6fc7 | 57 | |
3fdf0a20 SJ |
58 | /* We want to know about it if we've somehow got a NULL action list; |
59 | in the past, we had bad state if seccomp interfered with setup. */ | |
60 | assert(*ni != NULL); | |
61 | ||
384ca551 | 62 | return __nss_lookup (ni, fct_name, fct2_name, fctp); |
5f0e6fc7 | 63 | } |
37ba7d66 | 64 | libc_hidden_def (DB_LOOKUP_FCT) |