1 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #ifndef __RPCSVC_NISLIB_H__
21 #define __RPCSVC_NISLIB_H__
27 typedef const char *const_nis_name
;
29 /* nis_names: These functions are used to locate and manipulate all NIS+
30 * objects except the NIS+ entry objects.
32 * nis_lookup (name, flags) resolves a NIS+ name and returns a copy of
33 * that object from a NIS+ server.
34 * const nis_name name: name of the object to be resolved
35 * unsigned int flags: logically ORing zero or more flags (FOLLOW_LINKS,
36 * HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME)
38 * nis_add (name, obj) adds objects to the NIS+ namespace.
39 * const nis_name name: fully qualified NIS+ name.
40 * const nis_object *obj: object members zo_name and zo_domain will be
41 * constructed from name.
43 * nis_remove (name, obj) removes objects from the NIS+ namespace.
44 * const nis_name name: fully qualified NIS+ name.
45 * const nis_object *obj: if not NULL, it is assumed to point to a copy
46 * of the object being removed. In this case, if
47 * the object on the server does not have the same
48 * object identifier as the object being passed,
49 * the operation will fail with the NIS_NOTSAMEOBJ
52 * nis_modify (name, obj) can change specific attributes of an object
53 * that already exists in the namespace.
55 extern nis_result
*nis_lookup
__P ((const_nis_name name
, unsigned int flags
));
56 extern nis_result
*nis_add
__P ((const_nis_name name
, const nis_object
*obj
));
57 extern nis_result
*nis_remove
__P ((const_nis_name name
,
58 const nis_object
*obj
));
59 extern nis_result
*nis_modify
__P ((const_nis_name name
,
60 const nis_object
*obj
));
62 /* nis_tables: These functions are used to search and modify NIS+ tables.
64 * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata)
65 * search a table in the NIS+ namespace.
66 * const nis_name table_name: indexed name ([xx=yy],table.dir)
67 * unsigned int flags: logically ORing one or more flags (FOLLOW_LINKS,
68 * [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE],
69 * MASTER_ONLY, EXPAND_NAME, RETURN_RESULT)
70 * callback(): callback is an optional pointer to a function that will
71 * process the ENTRY type objects that are returned from the
72 * search. If this pointer is NULL, then all entries that match
73 * the search criteria are returned in the nis_result structure,
74 * otherwise this function will be called once for each
76 * void *userdata: passed to callback function along with the returned
79 * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the
81 * const nis_name table_name
82 * const nis_object *obj
83 * unsigned int flags: 0, ADD_OVERWRITE, RETURN_RESULT
85 * nis_modify_entry (name, obj, flags) modifies an object identified by name.
86 * const nis_name name: object identifier
87 * const nis_object *obj: should point to an entry with the EN_MODIFIED
88 * flag set in each column that contains new
90 * unsigned int flags: 0, MOD_SAMEOBJ, RETURN_RESULT
92 * nis_remove_entry (table_name, obj, flags) removes a set of entries
93 * identified by table_name from the table.
94 * const nis_name table_name: indexed NIS+ name
95 * const nis_object *obj: if obj is non-null, it is presumed to point to
96 * a cached copy of the entry. When the removal is
97 * attempted, and the object that would be removed
98 * is not the same as the cached object pointed to
99 * by object then the operation will fail with an
100 * NIS_NOTSAMEOBJ error
101 * unsigned int flags: 0, REM_MULTIPLE
103 * nis_first_entry (table_name) fetches entries from a table one at a time.
104 * const nis_name table_name
106 * nis_next_entry (table_name, cookie) retrieves the "next" entry from a
107 * table specified by table_name.
108 * const nis_name table_name:
109 * const netobj *cookie: The value of cookie from the nis_result structure
110 * form the previous call.
112 extern nis_result
*nis_list
__P ((const_nis_name name
, unsigned int flags
,
113 int (*callback
)(const_nis_name table_name
,
114 const nis_object
*obj
,
115 const void *userdata
),
116 const void *userdata
));
117 extern nis_result
*nis_add_entry
__P ((const_nis_name table_name
,
118 const nis_object
*obj
,
119 unsigned int flags
));
120 extern nis_result
*nis_modify_entry
__P ((const_nis_name name
,
121 const nis_object
*obj
,
122 unsigned int flags
));
123 extern nis_result
*nis_remove_entry
__P ((const_nis_name table_name
,
124 const nis_object
*obj
,
125 unsigned int flags
));
126 extern nis_result
*nis_first_entry
__P ((const_nis_name table_name
));
127 extern nis_result
*nis_next_entry
__P ((const_nis_name table_name
,
128 const netobj
*cookie
));
132 extern nis_error nis_mkdir
__P ((const_nis_name dirname
,
133 const nis_server
*machine
));
134 extern nis_error nis_rmdir
__P ((const_nis_name dirname
,
135 const nis_server
*machine
));
136 extern nis_error nis_servstate
__P ((const nis_server
*machine
,
137 const nis_tag
*tags
, int numtags
,
139 extern nis_error nis_stats
__P ((const nis_server
*machine
,
140 const nis_tag
*tags
, int numtags
,
142 extern void nis_freetags
__P ((nis_tag
*tags
, int numtags
));
143 extern nis_server
**nis_getservlist
__P ((const_nis_name dirname
));
144 extern void nis_freeservlist
__P ((nis_server
**machines
));
149 extern nis_name nis_leaf_of
__P ((const_nis_name name
));
150 extern nis_name nis_leaf_of_r
__P ((const_nis_name name
, char *buffer
,
152 extern nis_name nis_name_of
__P ((const_nis_name name
));
153 extern nis_name nis_name_of_r
__P ((const_nis_name name
, char *buffer
,
155 extern nis_name nis_domain_of
__P ((const_nis_name name
));
156 extern nis_name nis_domain_of_r
__P ((const_nis_name name
, char *buffer
,
158 extern nis_name
*nis_getnames
__P ((const_nis_name name
));
159 extern void nis_freenames
__P ((nis_name
*namelist
));
160 extern name_pos nis_dir_cmp
__P ((const_nis_name n1
, const_nis_name n2
));
161 extern nis_object
*nis_clone_object
__P ((const nis_object
*src
,
163 extern void nis_destroy_object
__P ((nis_object
*obj
));
164 extern void nis_print_object
__P ((const nis_object
*obj
));
169 extern nis_name nis_local_group
__P ((void));
170 extern nis_name nis_local_directory
__P ((void));
171 extern nis_name nis_local_principal
__P ((void));
172 extern nis_name nis_local_host
__P ((void));
177 extern const char *nis_sperrno
__P ((const nis_error status
));
178 extern void nis_perror
__P ((const nis_error status
, const char *label
));
179 extern void nis_lerror
__P ((const nis_error status
, const char *label
));
180 extern char *nis_sperror
__P ((const nis_error status
, const char *label
));
181 extern char *nis_sperror_r
__P ((const nis_error status
, const char *label
,
182 char *buffer
, size_t buflen
));
186 extern bool_t nis_ismember
__P ((const_nis_name principal
,
187 const_nis_name group
));
188 extern nis_error nis_addmember
__P ((const_nis_name member
,
189 const_nis_name group
));
190 extern nis_error nis_removemember
__P ((const_nis_name member
,
191 const_nis_name group
));
192 extern nis_error nis_creategroup
__P ((const_nis_name group
,
193 unsigned int flags
));
194 extern nis_error nis_destroygroup
__P ((const_nis_name group
));
195 extern void nis_print_group_entry
__P ((const_nis_name group
));
196 extern nis_error nis_verifygroup
__P ((const_nis_name group
));
201 extern void nis_ping
__P ((const_nis_name dirname
, uint32_t utime
,
202 const nis_object
*dirobj
));
203 extern nis_result
*nis_checkpoint
__P ((const_nis_name dirname
));
206 ** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
208 extern void nis_print_result
__P ((const nis_result
*result
));
209 extern void nis_print_rights
__P ((unsigned int rights
));
210 extern void nis_print_directory
__P ((const directory_obj
*dirobj
));
211 extern void nis_print_group
__P ((const group_obj
*grpobj
));
212 extern void nis_print_table
__P ((const table_obj
*tblobj
));
213 extern void nis_print_link
__P ((const link_obj
*lnkobj
));
214 extern void nis_print_entry
__P ((const entry_obj
*enobj
));
217 ** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
219 extern directory_obj
*readColdStartFile
__P ((void));
220 extern bool_t writeColdStartFile
__P ((const directory_obj
*dirobj
));
221 extern nis_object
*nis_read_obj
__P ((const char *obj
));
222 extern bool_t nis_write_obj
__P ((const char *file
, const nis_object
*obj
));
225 ** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
227 extern directory_obj
*nis_clone_directory
__P ((const directory_obj
*src
,
228 directory_obj
*dest
));
229 extern nis_result
*nis_clone_result
__P ((const nis_result
*src
,
232 /* nis_free - nis_freeresult */
233 extern void nis_freeresult
__P ((nis_result
*result
));
234 /* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
235 extern void nis_free_request
__P ((ib_request
*req
));
236 extern void nis_free_directory
__P ((directory_obj
*dirobj
));
237 extern void nis_free_object
__P ((nis_object
*obj
));
239 /* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
240 extern nis_name __nis_default_owner
__P ((char *));
241 extern nis_name __nis_default_group
__P ((char *));
242 extern uint32_t __nis_default_ttl
__P ((char *));
243 extern unsigned int __nis_default_access
__P ((char *, unsigned int));
244 extern fd_result
*__nis_finddirectory
__P ((directory_obj
*, const_nis_name
));
245 extern void __free_fdresult
__P ((fd_result
*));
246 extern uint32_t __nis_hash
__P ((const void *keyarg
, register size_t len
));
248 /* NIS+ cache locking */
249 extern int __nis_lock_cache
__P ((void));
250 extern int __nis_unlock_cache
__P ((void));
252 /* (XXX INTERNAL FUNCTIONS, ONLY FOR rpc.nisd AND glibc !!) */
253 #if defined (NIS_INTERNAL) || defined (_LIBC)
257 CLIENT
*clnt
; /* RPC CLIENT handle */
258 nis_server
*server_val
; /* List of servers */
259 unsigned int server_len
; /* # of servers */
260 unsigned int server_used
; /* Which server we are bind in the moment ? */
261 unsigned int current_ep
; /* Which endpoint of the server are in use? */
262 unsigned int trys
; /* How many server have we tried ? */
263 unsigned int class; /* From which class is server_val ? */
264 bool_t master_only
; /* Is only binded to the master */
265 bool_t use_auth
; /* Do we use AUTH ? */
266 bool_t use_udp
; /* Do we use UDP ? */
267 struct sockaddr_in addr
; /* Server's IP address */
268 int socket
; /* Server's local socket */
270 typedef struct dir_binding dir_binding
;
272 extern nis_error __nisbind_create
__P ((dir_binding
*, const nis_server
*,
273 unsigned int, unsigned int));
274 extern nis_error __nisbind_connect
__P ((dir_binding
*));
275 extern nis_error __nisbind_next
__P ((dir_binding
*));
276 extern void __nisbind_destroy
__P ((dir_binding
*));
277 extern nis_error __nisfind_server
__P ((const_nis_name
, directory_obj
**));
283 #endif /* __RPCSVC_NISLIB_H__ */