]>
Commit | Line | Data |
---|---|---|
5f0e6fc7 | 1 | /* Copyright (C) 1996 Free Software Foundation, Inc. |
68dbb3a6 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | |
5f0e6fc7 | 4 | |
68dbb3a6 UD |
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. | |
5f0e6fc7 | 9 | |
68dbb3a6 UD |
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. | |
5f0e6fc7 | 14 | |
68dbb3a6 UD |
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 not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
5f0e6fc7 RM |
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 *| | |
6d52618b | 26 | |* (e.g., hosts, services, ...) *| |
5f0e6fc7 | 27 | |* *| |
bba7bb78 RM |
28 | |* One additional symbol may optionally be defined: *| |
29 | |* *| | |
30 | |* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *| | |
31 | |* *| | |
5f0e6fc7 RM |
32 | \*******************************************************************/ |
33 | ||
34 | #define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup) | |
35 | #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post) | |
36 | #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post | |
37 | ||
a8874ead | 38 | #define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database) |
5f0e6fc7 RM |
39 | #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME) |
40 | #define STRINGIFY1(Name) STRINGIFY2 (Name) | |
41 | #define STRINGIFY2(Name) #Name | |
42 | ||
68dbb3a6 UD |
43 | #ifdef ALTERNATE_NAME |
44 | #define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME) | |
45 | #else | |
46 | #define ALTERNATE_NAME_STRING NULL | |
47 | #endif | |
48 | ||
bba7bb78 | 49 | #ifndef DEFAULT_CONFIG |
a8874ead | 50 | #define DEFAULT_CONFIG NULL |
bba7bb78 | 51 | #endif |
5f0e6fc7 | 52 | |
a8874ead | 53 | service_user *DATABASE_NAME_SYMBOL = NULL; |
5f0e6fc7 RM |
54 | |
55 | int | |
56 | DB_LOOKUP_FCT (service_user **ni, const char *fct_name, void **fctp) | |
57 | { | |
a8874ead | 58 | if (DATABASE_NAME_SYMBOL == NULL |
68dbb3a6 UD |
59 | && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING, |
60 | DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0) | |
5f0e6fc7 RM |
61 | return -1; |
62 | ||
a8874ead | 63 | *ni = DATABASE_NAME_SYMBOL; |
5f0e6fc7 RM |
64 | |
65 | return __nss_lookup (ni, fct_name, fctp); | |
66 | } |