]> git.ipfire.org Git - thirdparty/glibc.git/blob - nss/nsswitch.h
* nss/nss_files/files-parse.c (parse_list): Set EOL from LINE if it
[thirdparty/glibc.git] / nss / nsswitch.h
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
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
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.
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
12 Library General Public License for more details.
13
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
16 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 #ifndef _NSSWITCH_H
20 #define _NSSWITCH_H 1
21
22 /* This is an *internal* header. */
23
24 #include <arpa/nameser.h>
25 #include <netinet/in.h>
26 #include <resolv.h>
27 #include <search.h>
28
29
30 /* Revision number of NSS interface (must be a string). */
31 #define NSS_SHLIB_REVISION ".1"
32
33
34 /* Possible results of lookup using a nss_* function. */
35 enum nss_status
36 {
37 NSS_STATUS_TRYAGAIN = -2,
38 NSS_STATUS_UNAVAIL,
39 NSS_STATUS_NOTFOUND,
40 NSS_STATUS_SUCCESS,
41 };
42
43
44 /* Actions performed after lookup finished. */
45 typedef enum
46 {
47 NSS_ACTION_CONTINUE,
48 NSS_ACTION_RETURN
49 } lookup_actions;
50
51
52 typedef struct service_library
53 {
54 /* Name of service (`files', `dns', `nis', ...). */
55 const char *name;
56 /* Pointer to the loaded shared library. */
57 void *lib_handle;
58 /* And the link to the next entry. */
59 struct service_library *next;
60 } service_library;
61
62
63 /* For mapping a function name to a function pointer. It is known in
64 nsswitch.c:nss_lookup_function that a string pointer for the lookup key
65 is the first member. */
66 typedef struct
67 {
68 const char *fct_name;
69 void *fct_ptr;
70 } known_function;
71
72
73 typedef struct service_user
74 {
75 /* Name of the service (`files', `dns', `nis', ...). */
76 const char *name;
77 /* Action according to result. */
78 lookup_actions actions[4];
79 /* Link to the underlying library object. */
80 service_library *library;
81 /* Collection of known functions. */
82 struct entry *known;
83 /* And the link to the next entry. */
84 struct service_user *next;
85 } service_user;
86
87 /* To access the action based on the status value use this macro. */
88 #define nss_next_action(ni, status) ((ni)->actions[2 + status])
89
90
91 typedef struct name_database_entry
92 {
93 /* Name of the database. */
94 const char *name;
95 /* List of service to be used. */
96 service_user *service;
97 /* And the link to the next entry. */
98 struct name_database_entry *next;
99 } name_database_entry;
100
101
102 typedef struct name_database
103 {
104 /* List of all known databases. */
105 name_database_entry *entry;
106 /* List of libraries with service implementation. */
107 service_library *library;
108 } name_database;
109
110
111 /* Interface functions for NSS. */
112
113 /* Get the data structure representing the specified database.
114 If there is no configuration for this database in the file,
115 parse a service list from DEFCONFIG and use that. More
116 than one function can use the database. */
117 int __nss_database_lookup (const char *database, const char *defconfig,
118 service_user **ni);
119
120
121 /* Put first function with name FCT_NAME for SERVICE in FCTP. The
122 position is remembered in NI. The function returns a value < 0 if
123 an error occured or no such function exists. */
124 int __nss_lookup (service_user **ni, const char *fct_name, void **fctp);
125
126 /* Determine the next step in the lookup process according to the
127 result STATUS of the call to the last function returned by
128 `__nss_lookup' or `__nss_next'. NI specifies the last function
129 examined. The function return a value > 0 if the process should
130 stop with the last result of the last function call to be the
131 result of the entire lookup. The returned valie is 0 if there is
132 another function to use and < 0 if an error occured.
133
134 If ALL_VALUES is nonzero, the return value will not be > 0 as long as
135 there is a possibility the lookup process can ever use following
136 services. In other words, only if all four lookup results have
137 the action RETURN associated the lookup process stops before the
138 natural end. */
139 int __nss_next (service_user **ni, const char *fct_name, void **fctp,
140 int status, int all_values);
141
142
143 #endif /* nsswitch.h */