]> git.ipfire.org Git - thirdparty/glibc.git/blame - nis/rpcsvc/nislib.h
Update.
[thirdparty/glibc.git] / nis / rpcsvc / nislib.h
CommitLineData
d8cf93f4 1/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
55c14926 2 This file is part of the GNU C Library.
d8cf93f4 3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
55c14926
UD
4
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.
9
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.
14
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. */
19
20#ifndef __RPCSVC_NISLIB_H__
21#define __RPCSVC_NISLIB_H__
22
23#include <features.h>
24
25__BEGIN_DECLS
26
27typedef const char *const_nis_name;
28
29/* nis_names: These functions are used to locate and manipulate all NIS+
30 * objects except the NIS+ entry objects.
31 *
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
a1129917
UD
35 * unsigned int flags: logically ORing zero or more flags (FOLLOW_LINKS,
36 * HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME)
55c14926
UD
37 *
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.
42 *
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
50 * error.
51 *
52 * nis_modify (name, obj) can change specific attributes of an object
53 * that already exists in the namespace.
54 */
d8cf93f4
UD
55extern nis_result *nis_lookup (const_nis_name name, unsigned int flags)
56 __THROW;
57extern nis_result *nis_add (const_nis_name name, const nis_object *obj)
58 __THROW;
59extern nis_result *nis_remove (const_nis_name name,
60 const nis_object *obj) __THROW;
61extern nis_result *nis_modify (const_nis_name name,
62 const nis_object *obj) __THROW;
55c14926
UD
63
64/* nis_tables: These functions are used to search and modify NIS+ tables.
65 *
66 * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata)
67 * search a table in the NIS+ namespace.
68 * const nis_name table_name: indexed name ([xx=yy],table.dir)
a1129917
UD
69 * unsigned int flags: logically ORing one or more flags (FOLLOW_LINKS,
70 * [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE],
71 * MASTER_ONLY, EXPAND_NAME, RETURN_RESULT)
55c14926
UD
72 * callback(): callback is an optional pointer to a function that will
73 * process the ENTRY type objects that are returned from the
74 * search. If this pointer is NULL, then all entries that match
75 * the search criteria are returned in the nis_result structure,
76 * otherwise this function will be called once for each
77 * entry returned.
78 * void *userdata: passed to callback function along with the returned
79 * entry object.
80 *
81 * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the
82 * NIS+ table_name.
83 * const nis_name table_name
84 * const nis_object *obj
a1129917 85 * unsigned int flags: 0, ADD_OVERWRITE, RETURN_RESULT
55c14926
UD
86 *
87 * nis_modify_entry (name, obj, flags) modifies an object identified by name.
88 * const nis_name name: object identifier
89 * const nis_object *obj: should point to an entry with the EN_MODIFIED
90 * flag set in each column that contains new
91 * information.
a1129917 92 * unsigned int flags: 0, MOD_SAMEOBJ, RETURN_RESULT
55c14926
UD
93 *
94 * nis_remove_entry (table_name, obj, flags) removes a set of entries
95 * identified by table_name from the table.
96 * const nis_name table_name: indexed NIS+ name
97 * const nis_object *obj: if obj is non-null, it is presumed to point to
98 * a cached copy of the entry. When the removal is
99 * attempted, and the object that would be removed
100 * is not the same as the cached object pointed to
101 * by object then the operation will fail with an
102 * NIS_NOTSAMEOBJ error
a1129917 103 * unsigned int flags: 0, REM_MULTIPLE
55c14926
UD
104 *
105 * nis_first_entry (table_name) fetches entries from a table one at a time.
106 * const nis_name table_name
107 *
108 * nis_next_entry (table_name, cookie) retrieves the "next" entry from a
109 * table specified by table_name.
110 * const nis_name table_name:
111 * const netobj *cookie: The value of cookie from the nis_result structure
112 * form the previous call.
113 */
d8cf93f4
UD
114extern nis_result *nis_list (const_nis_name name, unsigned int flags,
115 int (*callback)(const_nis_name table_name,
116 const nis_object *obj,
117 const void *userdata),
118 const void *userdata) __THROW;
119extern nis_result *nis_add_entry (const_nis_name table_name,
120 const nis_object *obj,
121 unsigned int flags) __THROW;
122extern nis_result *nis_modify_entry (const_nis_name name,
123 const nis_object *obj,
124 unsigned int flags) __THROW;
125extern nis_result *nis_remove_entry (const_nis_name table_name,
126 const nis_object *obj,
127 unsigned int flags) __THROW;
128extern nis_result *nis_first_entry (const_nis_name table_name) __THROW;
129extern nis_result *nis_next_entry (const_nis_name table_name,
130 const netobj *cookie) __THROW;
55c14926
UD
131/*
132** nis_server
133*/
d8cf93f4
UD
134extern nis_error nis_mkdir (const_nis_name dirname,
135 const nis_server *machine) __THROW;
136extern nis_error nis_rmdir (const_nis_name dirname,
137 const nis_server *machine) __THROW;
138extern nis_error nis_servstate (const nis_server *machine,
139 const nis_tag *tags, int numtags,
140 nis_tag **result) __THROW;
141extern nis_error nis_stats (const nis_server *machine,
142 const nis_tag *tags, int numtags,
143 nis_tag **result) __THROW;
144extern void nis_freetags (nis_tag *tags, int numtags) __THROW;
145extern nis_server **nis_getservlist (const_nis_name dirname) __THROW;
146extern void nis_freeservlist (nis_server **machines) __THROW;
55c14926
UD
147
148/*
149** nis_subr
150*/
d8cf93f4
UD
151extern nis_name nis_leaf_of (const_nis_name name) __THROW;
152extern nis_name nis_leaf_of_r (const_nis_name name, char *buffer,
153 size_t buflen) __THROW;
154extern nis_name nis_name_of (const_nis_name name) __THROW;
155extern nis_name nis_name_of_r (const_nis_name name, char *buffer,
156 size_t buflen) __THROW;
157extern nis_name nis_domain_of (const_nis_name name) __THROW;
158extern nis_name nis_domain_of_r (const_nis_name name, char *buffer,
159 size_t buflen) __THROW;
160extern nis_name *nis_getnames (const_nis_name name) __THROW;
161extern void nis_freenames (nis_name *namelist) __THROW;
162extern name_pos nis_dir_cmp (const_nis_name n1, const_nis_name n2) __THROW;
163extern nis_object *nis_clone_object (const nis_object *src,
164 nis_object *dest) __THROW;
165extern void nis_destroy_object (nis_object *obj) __THROW;
166extern void nis_print_object (const nis_object *obj) __THROW;
55c14926
UD
167
168/*
169** nis_local_names
170*/
d8cf93f4
UD
171extern nis_name nis_local_group (void) __THROW;
172extern nis_name nis_local_directory (void) __THROW;
173extern nis_name nis_local_principal (void) __THROW;
174extern nis_name nis_local_host (void) __THROW;
55c14926
UD
175
176/*
177** nis_error
178*/
d8cf93f4
UD
179extern const char *nis_sperrno (const nis_error status) __THROW;
180extern void nis_perror (const nis_error status, const char *label) __THROW;
181extern void nis_lerror (const nis_error status, const char *label) __THROW;
182extern char *nis_sperror (const nis_error status, const char *label) __THROW;
183extern char *nis_sperror_r (const nis_error status, const char *label,
184 char *buffer, size_t buflen) __THROW;
55c14926
UD
185/*
186** nis_groups
187*/
d8cf93f4
UD
188extern bool_t nis_ismember (const_nis_name principal,
189 const_nis_name group) __THROW;
190extern nis_error nis_addmember (const_nis_name member,
191 const_nis_name group) __THROW;
192extern nis_error nis_removemember (const_nis_name member,
193 const_nis_name group) __THROW;
194extern nis_error nis_creategroup (const_nis_name group,
195 unsigned int flags) __THROW;
196extern nis_error nis_destroygroup (const_nis_name group) __THROW;
197extern void nis_print_group_entry (const_nis_name group) __THROW;
198extern nis_error nis_verifygroup (const_nis_name group) __THROW;
55c14926
UD
199
200/*
201** nis_ping
202*/
d8cf93f4
UD
203extern void nis_ping (const_nis_name dirname, uint32_t utime,
204 const nis_object *dirobj) __THROW;
205extern nis_result *nis_checkpoint (const_nis_name dirname) __THROW;
55c14926
UD
206
207/*
208** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
209*/
d8cf93f4
UD
210extern void nis_print_result (const nis_result *result) __THROW;
211extern void nis_print_rights (unsigned int rights) __THROW;
212extern void nis_print_directory (const directory_obj *dirobj) __THROW;
213extern void nis_print_group (const group_obj *grpobj) __THROW;
214extern void nis_print_table (const table_obj *tblobj) __THROW;
215extern void nis_print_link (const link_obj *lnkobj) __THROW;
216extern void nis_print_entry (const entry_obj *enobj) __THROW;
55c14926
UD
217
218/*
219** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
220*/
d8cf93f4
UD
221extern directory_obj *readColdStartFile (void) __THROW;
222extern bool_t writeColdStartFile (const directory_obj *dirobj) __THROW;
223extern nis_object *nis_read_obj (const char *obj) __THROW;
224extern bool_t nis_write_obj (const char *file, const nis_object *obj) __THROW;
55c14926
UD
225
226/*
227** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
228*/
d8cf93f4
UD
229extern directory_obj *nis_clone_directory (const directory_obj *src,
230 directory_obj *dest) __THROW;
231extern nis_result *nis_clone_result (const nis_result *src,
232 nis_result *dest) __THROW;
55c14926
UD
233
234/* nis_free - nis_freeresult */
d8cf93f4 235extern void nis_freeresult (nis_result *result) __THROW;
55c14926 236/* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
d8cf93f4
UD
237extern void nis_free_request (ib_request *req) __THROW;
238extern void nis_free_directory (directory_obj *dirobj) __THROW;
239extern void nis_free_object (nis_object *obj) __THROW;
55c14926
UD
240
241/* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
d8cf93f4
UD
242extern nis_name __nis_default_owner (char *) __THROW;
243extern nis_name __nis_default_group (char *) __THROW;
244extern uint32_t __nis_default_ttl (char *) __THROW;
245extern unsigned int __nis_default_access (char *, unsigned int) __THROW;
246extern fd_result *__nis_finddirectory (directory_obj *, const_nis_name) __THROW;
247extern void __free_fdresult (fd_result *) __THROW;
248extern uint32_t __nis_hash (const void *keyarg, register size_t len) __THROW;
dfd2257a 249
55c14926 250/* NIS+ cache locking */
d8cf93f4
UD
251extern int __nis_lock_cache (void) __THROW;
252extern int __nis_unlock_cache (void) __THROW;
55c14926 253
e852e889
UD
254/* (XXX INTERNAL FUNCTIONS, ONLY FOR rpc.nisd AND glibc !!) */
255#if defined (NIS_INTERNAL) || defined (_LIBC)
256
257struct dir_binding
258{
259 CLIENT *clnt; /* RPC CLIENT handle */
260 nis_server *server_val; /* List of servers */
a1129917
UD
261 unsigned int server_len; /* # of servers */
262 unsigned int server_used; /* Which server we are bind in the moment ? */
263 unsigned int current_ep; /* Which endpoint of the server are in use? */
264 unsigned int trys; /* How many server have we tried ? */
265 unsigned int class; /* From which class is server_val ? */
e852e889
UD
266 bool_t master_only; /* Is only binded to the master */
267 bool_t use_auth; /* Do we use AUTH ? */
268 bool_t use_udp; /* Do we use UDP ? */
269 struct sockaddr_in addr; /* Server's IP address */
270 int socket; /* Server's local socket */
271};
272typedef struct dir_binding dir_binding;
273
d8cf93f4
UD
274extern nis_error __nisbind_create (dir_binding *, const nis_server *,
275 unsigned int, unsigned int) __THROW;
276extern nis_error __nisbind_connect (dir_binding *) __THROW;
277extern nis_error __nisbind_next (dir_binding *) __THROW;
278extern void __nisbind_destroy (dir_binding *) __THROW;
279extern nis_error __nisfind_server (const_nis_name, directory_obj **) __THROW;
e852e889
UD
280
281#endif
282
55c14926
UD
283__END_DECLS
284
285#endif /* __RPCSVC_NISLIB_H__ */