manual: clarify defintions of floating point exponent bounds (bug 31518)
[glibc.git] / nss / nsswitch.h
blob26c2f0e50459f86e0d496fa90500646f12b33fb9
1 /* Copyright (C) 1996-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
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.
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
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #ifndef _NSSWITCH_H
19 #define _NSSWITCH_H 1
21 /* This is an *internal* header. */
23 #include <arpa/nameser.h>
24 #include <netinet/in.h>
25 #include <nss.h>
26 #include <resolv.h>
27 #include <search.h>
28 #include <dlfcn.h>
29 #include <stdbool.h>
31 /* Actions performed after lookup finished. */
32 typedef enum
34 NSS_ACTION_CONTINUE,
35 NSS_ACTION_RETURN,
36 NSS_ACTION_MERGE
37 } lookup_actions;
39 struct nss_action;
41 typedef struct service_library
43 /* Name of service (`files', `dns', `nis', ...). */
44 const char *name;
45 /* Pointer to the loaded shared library. */
46 void *lib_handle;
47 /* And the link to the next entry. */
48 struct service_library *next;
49 } service_library;
52 /* For mapping a function name to a function pointer. It is known in
53 nsswitch.c:nss_lookup_function that a string pointer for the lookup key
54 is the first member. */
55 typedef struct
57 const char *fct_name;
58 void *fct_ptr;
59 } known_function;
62 /* To access the action based on the status value use this macro. */
63 #define nss_next_action(ni, status) nss_action_get (ni, status)
66 #ifdef USE_NSCD
67 /* Indices into DATABASES in nsswitch.c and __NSS_DATABASE_CUSTOM. */
68 enum
70 # define DEFINE_DATABASE(arg) NSS_DBSIDX_##arg,
71 # include "databases.def"
72 # undef DEFINE_DATABASE
73 NSS_DBSIDX_max
76 /* Flags whether custom rules for database is set. */
77 extern bool __nss_database_custom[NSS_DBSIDX_max] attribute_hidden;
78 #endif
80 /* Warning for NSS functions, which don't require dlopen if glibc
81 was built with --enable-static-nss. */
82 #ifdef DO_STATIC_NSS
83 # define nss_interface_function(name)
84 #else
85 # define nss_interface_function(name) static_link_warning (name)
86 #endif
89 /* Interface functions for NSS. */
91 /* Put first function with name FCT_NAME for SERVICE in FCTP. The
92 position is remembered in NI. The function returns a value < 0 if
93 an error occurred or no such function exists. */
94 extern int __nss_lookup (struct nss_action **ni, const char *fct_name,
95 const char *fct2_name, void **fctp);
96 libc_hidden_proto (__nss_lookup)
98 /* Determine the next step in the lookup process according to the
99 result STATUS of the call to the last function returned by
100 `__nss_lookup' or `__nss_next'. NI specifies the last function
101 examined. The function return a value > 0 if the process should
102 stop with the last result of the last function call to be the
103 result of the entire lookup. The returned value is 0 if there is
104 another function to use and < 0 if an error occurred.
106 If ALL_VALUES is nonzero, the return value will not be > 0 as long as
107 there is a possibility the lookup process can ever use following
108 services. In other words, only if all four lookup results have
109 the action RETURN associated the lookup process stops before the
110 natural end. */
111 extern int __nss_next2 (struct nss_action **ni, const char *fct_name,
112 const char *fct2_name, void **fctp, int status,
113 int all_values) attribute_hidden;
114 libc_hidden_proto (__nss_next2)
115 extern int __nss_next (struct nss_action **ni, const char *fct_name, void **fctp,
116 int status, int all_values);
118 /* Search for the service described in NI for a function named FCT_NAME
119 and return a pointer to this function if successful. */
120 extern void *__nss_lookup_function (struct nss_action *ni, const char *fct_name);
121 libc_hidden_proto (__nss_lookup_function)
124 /* Called by NSCD to disable recursive calls and enable special handling
125 when used in nscd. */
126 struct traced_file;
127 extern void __nss_disable_nscd (void (*) (size_t, struct traced_file *));
130 typedef int (*db_lookup_function) (struct nss_action **, const char *, const char *,
131 void **);
132 typedef enum nss_status (*setent_function) (int);
133 typedef enum nss_status (*endent_function) (void);
134 typedef enum nss_status (*getent_function) (void *, char *, size_t,
135 int *, int *);
136 typedef int (*getent_r_function) (void *, char *, size_t,
137 void **result, int *);
139 extern void __nss_setent (const char *func_name,
140 db_lookup_function lookup_fct,
141 struct nss_action **nip, struct nss_action **startp,
142 struct nss_action **last_nip, int stayon,
143 int *stayon_tmp, int res)
144 attribute_hidden;
145 extern void __nss_endent (const char *func_name,
146 db_lookup_function lookup_fct,
147 struct nss_action **nip, struct nss_action **startp,
148 struct nss_action **last_nip, int res)
149 attribute_hidden;
150 extern int __nss_getent_r (const char *getent_func_name,
151 const char *setent_func_name,
152 db_lookup_function lookup_fct,
153 struct nss_action **nip, struct nss_action **startp,
154 struct nss_action **last_nip, int *stayon_tmp,
155 int res,
156 void *resbuf, char *buffer, size_t buflen,
157 void **result, int *h_errnop)
158 attribute_hidden;
159 extern void *__nss_getent (getent_r_function func,
160 void **resbuf, char **buffer, size_t buflen,
161 size_t *buffer_size, int *h_errnop)
162 attribute_hidden;
163 struct resolv_context;
164 struct hostent;
165 extern int __nss_hostname_digits_dots_context (struct resolv_context *,
166 const char *name,
167 struct hostent *resbuf,
168 char **buffer,
169 size_t *buffer_size,
170 size_t buflen,
171 struct hostent **result,
172 enum nss_status *status, int af,
173 int *h_errnop) attribute_hidden;
174 extern int __nss_hostname_digits_dots (const char *name,
175 struct hostent *resbuf, char **buffer,
176 size_t *buffer_size, size_t buflen,
177 struct hostent **result,
178 enum nss_status *status, int af,
179 int *h_errnop);
180 libc_hidden_proto (__nss_hostname_digits_dots)
182 /* Maximum number of aliases we allow. */
183 #define MAX_NR_ALIASES 48
184 #define MAX_NR_ADDRS 48
186 /* Prototypes for __nss_*_lookup2 functions. */
187 #define DEFINE_DATABASE(arg) \
188 extern struct nss_action *__nss_##arg##_database attribute_hidden; \
189 int __nss_##arg##_lookup2 (struct nss_action **, const char *, \
190 const char *, void **); \
191 libc_hidden_proto (__nss_##arg##_lookup2)
192 #include "databases.def"
193 #undef DEFINE_DATABASE
195 #include <nss/nss_module.h>
196 #include <nss/nss_action.h>
197 #include <nss/nss_database.h>
199 #endif /* nsswitch.h */