Blame nss/XXX-lookup.c

Packit 6c4009
/* Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include "nsswitch.h"
Packit 6c4009
Packit 6c4009
/*******************************************************************\
Packit 6c4009
|* Here we assume one symbol to be defined:			   *|
Packit 6c4009
|* 								   *|
Packit 6c4009
|* DATABASE_NAME - name of the database the function accesses	   *|
Packit 6c4009
|*		   (e.g., hosts, services, ...)			   *|
Packit 6c4009
|* 								   *|
Packit 6c4009
|* One additional symbol may optionally be defined:		   *|
Packit 6c4009
|* 								   *|
Packit 6c4009
|* ALTERNATE_NAME - name of another service which is examined in   *|
Packit 6c4009
|*                  case DATABASE_NAME is not found                *|
Packit 6c4009
|* 								   *|
Packit 6c4009
|* DEFAULT_CONFIG - string for default conf (e.g. "dns files")	   *|
Packit 6c4009
|* 								   *|
Packit 6c4009
\*******************************************************************/
Packit 6c4009
Packit 6c4009
#define DB_LOOKUP_FCT CONCAT3_1 (__nss_, DATABASE_NAME, _lookup2)
Packit 6c4009
#define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post)
Packit 6c4009
#define CONCAT3_2(Pre, Name, Post) Pre##Name##Post
Packit 6c4009
Packit 6c4009
#define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database)
Packit 6c4009
#define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME)
Packit 6c4009
#define STRINGIFY1(Name) STRINGIFY2 (Name)
Packit 6c4009
#define STRINGIFY2(Name) #Name
Packit 6c4009
Packit 6c4009
#ifdef ALTERNATE_NAME
Packit 6c4009
#define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME)
Packit 6c4009
#else
Packit 6c4009
#define ALTERNATE_NAME_STRING NULL
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifndef DEFAULT_CONFIG
Packit 6c4009
#define DEFAULT_CONFIG NULL
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
Packit 6c4009
	       void **fctp)
Packit 6c4009
{
Packit 6c4009
  if (DATABASE_NAME_SYMBOL == NULL
Packit Service 904dc6
      && __nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING,
Packit Service 904dc6
				 DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0)
Packit 6c4009
    return -1;
Packit 6c4009
Packit 6c4009
  *ni = DATABASE_NAME_SYMBOL;
Packit 6c4009
Packit 6c4009
  return __nss_lookup (ni, fct_name, fct2_name, fctp);
Packit 6c4009
}
Packit 6c4009
libc_hidden_def (DB_LOOKUP_FCT)