.
[glibc/history.git] / nss / nsswitch.h
blobb80edef651dde3bf10495c5f421f4c890605b11c
1 /* Copyright (C) 1996-1999,2001,2002,2003,2004,2007
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _NSSWITCH_H
21 #define _NSSWITCH_H 1
23 /* This is an *internal* header. */
25 #include <arpa/nameser.h>
26 #include <netinet/in.h>
27 #include <nss.h>
28 #include <resolv.h>
29 #include <search.h>
30 #include <dlfcn.h>
32 /* Actions performed after lookup finished. */
33 typedef enum
35 NSS_ACTION_CONTINUE,
36 NSS_ACTION_RETURN
37 } lookup_actions;
40 typedef struct service_library
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;
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. */
54 typedef struct
56 const char *fct_name;
57 void *fct_ptr;
58 } known_function;
61 typedef struct service_user
63 /* And the link to the next entry. */
64 struct service_user *next;
65 /* Action according to result. */
66 lookup_actions actions[5];
67 /* Link to the underlying library object. */
68 service_library *library;
69 /* Collection of known functions. */
70 void *known;
71 /* Name of the service (`files', `dns', `nis', ...). */
72 char name[0];
73 } service_user;
75 /* To access the action based on the status value use this macro. */
76 #define nss_next_action(ni, status) ((ni)->actions[2 + status])
79 typedef struct name_database_entry
81 /* And the link to the next entry. */
82 struct name_database_entry *next;
83 /* List of service to be used. */
84 service_user *service;
85 /* Name of the database. */
86 char name[0];
87 } name_database_entry;
90 typedef struct name_database
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;
99 /* Interface functions for NSS. */
101 /* Get the data structure representing the specified database.
102 If there is no configuration for this database in the file,
103 parse a service list from DEFCONFIG and use that. More
104 than one function can use the database. */
105 extern int __nss_database_lookup (const char *database,
106 const char *alternative_name,
107 const char *defconfig, service_user **ni);
108 libc_hidden_proto (__nss_database_lookup)
110 /* Put first function with name FCT_NAME for SERVICE in FCTP. The
111 position is remembered in NI. The function returns a value < 0 if
112 an error occurred or no such function exists. */
113 extern int __nss_lookup (service_user **ni, const char *fct_name,
114 const char *fct2_name, void **fctp) attribute_hidden;
116 /* Determine the next step in the lookup process according to the
117 result STATUS of the call to the last function returned by
118 `__nss_lookup' or `__nss_next'. NI specifies the last function
119 examined. The function return a value > 0 if the process should
120 stop with the last result of the last function call to be the
121 result of the entire lookup. The returned value is 0 if there is
122 another function to use and < 0 if an error occurred.
124 If ALL_VALUES is nonzero, the return value will not be > 0 as long as
125 there is a possibility the lookup process can ever use following
126 services. In other words, only if all four lookup results have
127 the action RETURN associated the lookup process stops before the
128 natural end. */
129 extern int __nss_next2 (service_user **ni, const char *fct_name,
130 const char *fct2_name, void **fctp, int status,
131 int all_values) attribute_hidden;
132 libc_hidden_proto (__nss_next2)
133 extern int __nss_next (service_user **ni, const char *fct_name, void **fctp,
134 int status, int all_values);
136 /* Search for the service described in NI for a function named FCT_NAME
137 and return a pointer to this function if successful. */
138 extern void *__nss_lookup_function (service_user *ni, const char *fct_name);
139 libc_hidden_proto (__nss_lookup_function)
142 /* Called by NSCD to disable recursive calls. */
143 extern void __nss_disable_nscd (void);
146 typedef int (*db_lookup_function) (service_user **, const char *, const char *,
147 void **)
148 internal_function;
149 typedef enum nss_status (*setent_function) (int);
150 typedef enum nss_status (*endent_function) (void);
151 typedef enum nss_status (*getent_function) (void *, char *, size_t,
152 int *, int *);
153 typedef int (*getent_r_function) (void *, char *, size_t,
154 void **result, int *);
156 extern void __nss_setent (const char *func_name,
157 db_lookup_function lookup_fct,
158 service_user **nip, service_user **startp,
159 service_user **last_nip, int stayon,
160 int *stayon_tmp, int res);
161 extern void __nss_endent (const char *func_name,
162 db_lookup_function lookup_fct,
163 service_user **nip, service_user **startp,
164 service_user **last_nip, int res);
165 extern int __nss_getent_r (const char *getent_func_name,
166 const char *setent_func_name,
167 db_lookup_function lookup_fct,
168 service_user **nip, service_user **startp,
169 service_user **last_nip, int *stayon_tmp,
170 int res,
171 void *resbuf, char *buffer, size_t buflen,
172 void **result, int *h_errnop);
173 extern void *__nss_getent (getent_r_function func,
174 void **resbuf, char **buffer, size_t buflen,
175 size_t *buffer_size, int *h_errnop);
176 struct hostent;
177 extern int __nss_hostname_digits_dots (const char *name,
178 struct hostent *resbuf, char **buffer,
179 size_t *buffer_size, size_t buflen,
180 struct hostent **result,
181 enum nss_status *status, int af,
182 int *h_errnop);
183 libc_hidden_proto (__nss_hostname_digits_dots)
185 #endif /* nsswitch.h */