Update.
[glibc.git] / nss / nsswitch.h
blob369e64a46665a66c7d2453436ba71a4fdbfcb3be
1 /* Copyright (C) 1996, 1997, 1998, 1999, 2001 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #ifndef _NSSWITCH_H
20 #define _NSSWITCH_H 1
22 /* This is an *internal* header. */
24 #include <arpa/nameser.h>
25 #include <netinet/in.h>
26 #include <nss.h>
27 #include <resolv.h>
28 #include <search.h>
29 #include <dlfcn.h>
31 /* Actions performed after lookup finished. */
32 typedef enum
34 NSS_ACTION_CONTINUE,
35 NSS_ACTION_RETURN
36 } lookup_actions;
39 typedef struct service_library
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;
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. */
53 typedef struct
55 const char *fct_name;
56 void *fct_ptr;
57 } known_function;
60 typedef struct service_user
62 /* And the link to the next entry. */
63 struct service_user *next;
64 /* Action according to result. */
65 lookup_actions actions[5];
66 /* Link to the underlying library object. */
67 service_library *library;
68 /* Collection of known functions. */
69 struct entry *known;
70 /* Name of the service (`files', `dns', `nis', ...). */
71 char name[0];
72 } service_user;
74 /* To access the action based on the status value use this macro. */
75 #define nss_next_action(ni, status) ((ni)->actions[2 + status])
78 typedef struct name_database_entry
80 /* And the link to the next entry. */
81 struct name_database_entry *next;
82 /* List of service to be used. */
83 service_user *service;
84 /* Name of the database. */
85 char name[0];
86 } name_database_entry;
89 typedef struct name_database
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;
98 /* Interface functions for NSS. */
100 /* Get the data structure representing the specified database.
101 If there is no configuration for this database in the file,
102 parse a service list from DEFCONFIG and use that. More
103 than one function can use the database. */
104 int __nss_database_lookup (const char *database, const char *alternative_name,
105 const char *defconfig, service_user **ni);
108 /* Put first function with name FCT_NAME for SERVICE in FCTP. The
109 position is remembered in NI. The function returns a value < 0 if
110 an error occurred or no such function exists. */
111 int __nss_lookup (service_user **ni, const char *fct_name, void **fctp);
113 /* Determine the next step in the lookup process according to the
114 result STATUS of the call to the last function returned by
115 `__nss_lookup' or `__nss_next'. NI specifies the last function
116 examined. The function return a value > 0 if the process should
117 stop with the last result of the last function call to be the
118 result of the entire lookup. The returned value is 0 if there is
119 another function to use and < 0 if an error occurred.
121 If ALL_VALUES is nonzero, the return value will not be > 0 as long as
122 there is a possibility the lookup process can ever use following
123 services. In other words, only if all four lookup results have
124 the action RETURN associated the lookup process stops before the
125 natural end. */
126 int __nss_next (service_user **ni, const char *fct_name, void **fctp,
127 int status, int all_values);
129 /* Search for the service described in NI for a function named FCT_NAME
130 and return a pointer to this function if successful. */
131 void *__nss_lookup_function (service_user *ni, const char *fct_name);
134 typedef int (*db_lookup_function) (service_user **, const char *, void **);
135 typedef enum nss_status (*setent_function) (int);
136 typedef enum nss_status (*endent_function) (void);
137 typedef enum nss_status (*getent_function) (void *, char *, size_t,
138 int *, int *);
139 typedef int (*getent_r_function) (void *, char *, size_t,
140 void **result, int *);
142 extern void __nss_setent (const char *func_name,
143 db_lookup_function lookup_fct,
144 service_user **nip, service_user **startp,
145 service_user **last_nip, int stayon,
146 int *stayon_tmp, int res);
147 extern void __nss_endent (const char *func_name,
148 db_lookup_function lookup_fct,
149 service_user **nip, service_user **startp,
150 service_user **last_nip, int res);
151 extern int __nss_getent_r (const char *getent_func_name,
152 const char *setent_func_name,
153 db_lookup_function lookup_fct,
154 service_user **nip, service_user **startp,
155 service_user **last_nip, int *stayon_tmp,
156 int res,
157 void *resbuf, char *buffer, size_t buflen,
158 void **result, int *h_errnop);
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 struct hostent;
163 extern int __nss_hostname_digits_dots (const char *name,
164 struct hostent *resbuf, char **buffer,
165 size_t *buffer_size, size_t buflen,
166 struct hostent **result,
167 enum nss_status *status, int *typep,
168 int flags, int *afp, int *h_errnop);
170 #endif /* nsswitch.h */