]> git.ipfire.org Git - thirdparty/glibc.git/blame - nss/XXX-lookup.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nss / XXX-lookup.c
CommitLineData
f7a9f785 1/* Copyright (C) 1996-2016 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 5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
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
41bdb6e2 13 Lesser General Public License for more details.
5f0e6fc7 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
5f0e6fc7
RM
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 *|
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|* *|
bba7bb78
RM
32|* DEFAULT_CONFIG - string for default conf (e.g. "dns files") *|
33|* *|
5f0e6fc7
RM
34\*******************************************************************/
35
384ca551
UD
36#define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
37#define DB_COMPAT_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup)
5f0e6fc7
RM
38#define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
39#define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
40
a8874ead 41#define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
5f0e6fc7
RM
42#define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
43#define STRINGIFY1(Name) STRINGIFY2 (Name)
44#define STRINGIFY2(Name) #Name
45
68dbb3a6
UD
46#ifdef ALTERNATE_NAME
47#define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME)
48#else
49#define ALTERNATE_NAME_STRING NULL
50#endif
51
bba7bb78 52#ifndef DEFAULT_CONFIG
a8874ead 53#define DEFAULT_CONFIG NULL
bba7bb78 54#endif
5f0e6fc7 55
6455d255 56service_user *DATABASE_NAME_SYMBOL attribute_hidden;
5f0e6fc7 57
6455d255 58extern int DB_LOOKUP_FCT (service_user **ni, const char *fct_name,
384ca551
UD
59 const char *fct2_name, void **fctp)
60 internal_function;
37ba7d66 61libc_hidden_proto (DB_LOOKUP_FCT)
ed073f0e 62
5f0e6fc7 63int
dff07c4b 64internal_function
384ca551
UD
65DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
66 void **fctp)
5f0e6fc7 67{
a8874ead 68 if (DATABASE_NAME_SYMBOL == NULL
68dbb3a6
UD
69 && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
70 DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
5f0e6fc7
RM
71 return -1;
72
a8874ead 73 *ni = DATABASE_NAME_SYMBOL;
5f0e6fc7 74
384ca551 75 return __nss_lookup (ni, fct_name, fct2_name, fctp);
5f0e6fc7 76}
37ba7d66 77libc_hidden_def (DB_LOOKUP_FCT)
384ca551
UD
78
79
80#ifndef NO_COMPAT
81int
82internal_function attribute_compat_text_section
83DB_COMPAT_FCT (service_user **ni, const char *fct_name, void **fctp)
84{
85 return DB_LOOKUP_FCT (ni, fct_name, NULL, fctp);
86}
87#endif