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