Back to index

glibc  2.9
XXX-lookup.c
Go to the documentation of this file.
00001 /* Copyright (C) 1996, 1997, 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include "nsswitch.h"
00021 
00022 /*******************************************************************\
00023 |* Here we assume one symbol to be defined:                       *|
00024 |*                                                         *|
00025 |* DATABASE_NAME - name of the database the function accesses     *|
00026 |*               (e.g., hosts, services, ...)                     *|
00027 |*                                                         *|
00028 |* One additional symbol may optionally be defined:               *|
00029 |*                                                         *|
00030 |* ALTERNATE_NAME - name of another service which is examined in   *|
00031 |*                  case DATABASE_NAME is not found                *|
00032 |*                                                         *|
00033 |* DEFAULT_CONFIG - string for default conf (e.g. "dns files")    *|
00034 |*                                                         *|
00035 \*******************************************************************/
00036 
00037 #define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
00038 #define DB_COMPAT_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup)
00039 #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
00040 #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
00041 
00042 #define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
00043 #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
00044 #define STRINGIFY1(Name) STRINGIFY2 (Name)
00045 #define STRINGIFY2(Name) #Name
00046 
00047 #ifdef ALTERNATE_NAME
00048 #define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME)
00049 #else
00050 #define ALTERNATE_NAME_STRING NULL
00051 #endif
00052 
00053 #ifndef DEFAULT_CONFIG
00054 #define DEFAULT_CONFIG NULL
00055 #endif
00056 
00057 service_user *DATABASE_NAME_SYMBOL attribute_hidden;
00058 
00059 extern int DB_LOOKUP_FCT (service_user **ni, const char *fct_name,
00060                        const char *fct2_name, void **fctp)
00061   internal_function;
00062 libc_hidden_proto (DB_LOOKUP_FCT)
00063 
00064 int
00065 internal_function
00066 DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
00067               void **fctp)
00068 {
00069   if (DATABASE_NAME_SYMBOL == NULL
00070       && __nss_database_lookup (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
00071                             DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
00072     return -1;
00073 
00074   *ni = DATABASE_NAME_SYMBOL;
00075 
00076   return __nss_lookup (ni, fct_name, fct2_name, fctp);
00077 }
00078 libc_hidden_def (DB_LOOKUP_FCT)
00079 
00080 
00081 #ifndef NO_COMPAT
00082 int
00083 internal_function attribute_compat_text_section
00084 DB_COMPAT_FCT (service_user **ni, const char *fct_name, void **fctp)
00085 {
00086   return DB_LOOKUP_FCT (ni, fct_name, NULL, fctp);
00087 }
00088 #endif