]> git.ipfire.org Git - thirdparty/glibc.git/blame - nss/nsswitch.h
Fix math/test-fenvinline for no-exceptions configurations.
[thirdparty/glibc.git] / nss / nsswitch.h
CommitLineData
bfff8b1b 1/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
19361cb7
UD
2 This file is part of the GNU C Library.
3
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.
19361cb7
UD
8
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.
19361cb7 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
5f0e6fc7
RM
17
18#ifndef _NSSWITCH_H
19#define _NSSWITCH_H 1
20
21/* This is an *internal* header. */
22
23#include <arpa/nameser.h>
24#include <netinet/in.h>
a8874ead 25#include <nss.h>
5f0e6fc7
RM
26#include <resolv.h>
27#include <search.h>
94e365c6 28#include <dlfcn.h>
c3e2f19b 29#include <stdbool.h>
5f0e6fc7 30
5f0e6fc7
RM
31/* Actions performed after lookup finished. */
32typedef enum
33{
34 NSS_ACTION_CONTINUE,
ced8f893
SG
35 NSS_ACTION_RETURN,
36 NSS_ACTION_MERGE
5f0e6fc7
RM
37} lookup_actions;
38
39
40typedef struct service_library
41{
42 /* Name of service (`files', `dns', `nis', ...). */
43 const char *name;
44 /* Pointer to the loaded shared library. */
45 void *lib_handle;
46 /* And the link to the next entry. */
47 struct service_library *next;
48} service_library;
49
50
dbe31b9a
RM
51/* For mapping a function name to a function pointer. It is known in
52 nsswitch.c:nss_lookup_function that a string pointer for the lookup key
53 is the first member. */
5f0e6fc7
RM
54typedef struct
55{
56 const char *fct_name;
57 void *fct_ptr;
58} known_function;
59
60
61typedef struct service_user
62{
1a989e00
UD
63 /* And the link to the next entry. */
64 struct service_user *next;
5f0e6fc7 65 /* Action according to result. */
a68b0d31 66 lookup_actions actions[5];
5f0e6fc7
RM
67 /* Link to the underlying library object. */
68 service_library *library;
69 /* Collection of known functions. */
701666b7 70 void *known;
1a989e00
UD
71 /* Name of the service (`files', `dns', `nis', ...). */
72 char name[0];
5f0e6fc7
RM
73} service_user;
74
75/* To access the action based on the status value use this macro. */
76#define nss_next_action(ni, status) ((ni)->actions[2 + status])
77
78
79typedef struct name_database_entry
80{
5f0e6fc7
RM
81 /* And the link to the next entry. */
82 struct name_database_entry *next;
1a989e00
UD
83 /* List of service to be used. */
84 service_user *service;
85 /* Name of the database. */
86 char name[0];
5f0e6fc7
RM
87} name_database_entry;
88
89
90typedef struct name_database
91{
92 /* List of all known databases. */
93 name_database_entry *entry;
94 /* List of libraries with service implementation. */
95 service_library *library;
96} name_database;
97
98
c3e2f19b
UD
99/* Indices into DATABASES in nsswitch.c and __NSS_DATABASE_CUSTOM. */
100enum
101 {
102#define DEFINE_DATABASE(arg) NSS_DBSIDX_##arg,
103#include "databases.def"
104#undef DEFINE_DATABASE
105 NSS_DBSIDX_max
106 };
107
108/* Flags whether custom rules for database is set. */
109extern bool __nss_database_custom[NSS_DBSIDX_max];
110
01767843
CM
111/* Warning for NSS functions, which don't require dlopen if glibc
112 was built with --enable-static-nss. */
113#ifdef DO_STATIC_NSS
114# define nss_interface_function(name)
115#else
116# define nss_interface_function(name) static_link_warning (name)
117#endif
118
c3e2f19b 119
5f0e6fc7
RM
120/* Interface functions for NSS. */
121
bba7bb78
RM
122/* Get the data structure representing the specified database.
123 If there is no configuration for this database in the file,
124 parse a service list from DEFCONFIG and use that. More
5f0e6fc7 125 than one function can use the database. */
ef4d5b32
UD
126extern int __nss_database_lookup (const char *database,
127 const char *alternative_name,
128 const char *defconfig, service_user **ni);
37ba7d66 129libc_hidden_proto (__nss_database_lookup)
5f0e6fc7
RM
130
131/* Put first function with name FCT_NAME for SERVICE in FCTP. The
132 position is remembered in NI. The function returns a value < 0 if
6d52618b 133 an error occurred or no such function exists. */
384ca551 134extern int __nss_lookup (service_user **ni, const char *fct_name,
684ae515
UD
135 const char *fct2_name, void **fctp);
136libc_hidden_proto (__nss_lookup)
5f0e6fc7
RM
137
138/* Determine the next step in the lookup process according to the
139 result STATUS of the call to the last function returned by
140 `__nss_lookup' or `__nss_next'. NI specifies the last function
141 examined. The function return a value > 0 if the process should
142 stop with the last result of the last function call to be the
6d52618b
UD
143 result of the entire lookup. The returned value is 0 if there is
144 another function to use and < 0 if an error occurred.
5f0e6fc7
RM
145
146 If ALL_VALUES is nonzero, the return value will not be > 0 as long as
147 there is a possibility the lookup process can ever use following
148 services. In other words, only if all four lookup results have
149 the action RETURN associated the lookup process stops before the
150 natural end. */
384ca551
UD
151extern int __nss_next2 (service_user **ni, const char *fct_name,
152 const char *fct2_name, void **fctp, int status,
153 int all_values) attribute_hidden;
154libc_hidden_proto (__nss_next2)
ef4d5b32
UD
155extern int __nss_next (service_user **ni, const char *fct_name, void **fctp,
156 int status, int all_values);
5f0e6fc7 157
899d423e
UD
158/* Search for the service described in NI for a function named FCT_NAME
159 and return a pointer to this function if successful. */
ef4d5b32 160extern void *__nss_lookup_function (service_user *ni, const char *fct_name);
5556fc6a 161libc_hidden_proto (__nss_lookup_function)
ef4d5b32
UD
162
163
319b9ad4
UD
164/* Called by NSCD to disable recursive calls and enable special handling
165 when used in nscd. */
166struct traced_file;
167extern void __nss_disable_nscd (void (*) (size_t, struct traced_file *));
5f0e6fc7 168
8b801829 169
384ca551
UD
170typedef int (*db_lookup_function) (service_user **, const char *, const char *,
171 void **)
dff07c4b 172 internal_function;
8b801829 173typedef enum nss_status (*setent_function) (int);
a5fdf99b 174typedef enum nss_status (*endent_function) (void);
8b801829 175typedef enum nss_status (*getent_function) (void *, char *, size_t,
a5fdf99b 176 int *, int *);
8b801829 177typedef int (*getent_r_function) (void *, char *, size_t,
a5fdf99b 178 void **result, int *);
8b801829
UD
179
180extern void __nss_setent (const char *func_name,
181 db_lookup_function lookup_fct,
182 service_user **nip, service_user **startp,
183 service_user **last_nip, int stayon,
184 int *stayon_tmp, int res);
185extern void __nss_endent (const char *func_name,
186 db_lookup_function lookup_fct,
187 service_user **nip, service_user **startp,
188 service_user **last_nip, int res);
189extern int __nss_getent_r (const char *getent_func_name,
190 const char *setent_func_name,
191 db_lookup_function lookup_fct,
192 service_user **nip, service_user **startp,
193 service_user **last_nip, int *stayon_tmp,
194 int res,
195 void *resbuf, char *buffer, size_t buflen,
196 void **result, int *h_errnop);
197extern void *__nss_getent (getent_r_function func,
198 void **resbuf, char **buffer, size_t buflen,
199 size_t *buffer_size, int *h_errnop);
a5fdf99b
UD
200struct hostent;
201extern int __nss_hostname_digits_dots (const char *name,
202 struct hostent *resbuf, char **buffer,
203 size_t *buffer_size, size_t buflen,
204 struct hostent **result,
1773d1ba
UD
205 enum nss_status *status, int af,
206 int *h_errnop);
5656e294 207libc_hidden_proto (__nss_hostname_digits_dots)
8b801829 208
7b6e99be
JB
209/* Maximum number of aliases we allow. */
210#define MAX_NR_ALIASES 48
211#define MAX_NR_ADDRS 48
212
5f0e6fc7 213#endif /* nsswitch.h */