Back to index

glibc  2.9
nislib.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 1998, 1999, 2006, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef       __RPCSVC_NISLIB_H__
00021 #define       __RPCSVC_NISLIB_H__
00022 
00023 #include <features.h>
00024 
00025 __BEGIN_DECLS
00026 
00027 typedef const char *const_nis_name;
00028 
00029 /* nis_names: These functions are used to locate and manipulate all NIS+
00030  * objects except the NIS+ entry objects.
00031  *
00032  * nis_lookup (name, flags) resolves a NIS+ name and returns a copy of
00033  *                          that object  from a NIS+ server.
00034  *    const nis_name name: name of the object to be resolved
00035  *    unsigned int flags: logically ORing zero or more flags (FOLLOW_LINKS,
00036  *                          HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME)
00037  *
00038  * nis_add (name, obj) adds objects to the NIS+ namespace.
00039  *    const nis_name name: fully qualified NIS+ name.
00040  *    const nis_object *obj: object members zo_name and zo_domain will be
00041  *                           constructed from name.
00042  *
00043  * nis_remove (name, obj) removes objects from the NIS+ namespace.
00044  *    const nis_name name: fully qualified NIS+ name.
00045  *    const nis_object *obj: if not NULL, it is assumed to point to a copy
00046  *                           of the object being removed. In this case, if
00047  *                           the object on the server does not have the same
00048  *                           object identifier as the  object  being  passed,
00049  *                           the operation will fail with the NIS_NOTSAMEOBJ
00050  *                           error.
00051  *
00052  * nis_modify (name, obj) can change specific attributes of an object
00053  *                        that already exists in the namespace.
00054  */
00055 extern nis_result *nis_lookup (const_nis_name name, unsigned int flags)
00056      __THROW;
00057 extern nis_result *nis_add (const_nis_name name, const nis_object *obj)
00058      __THROW;
00059 extern nis_result *nis_remove (const_nis_name name,
00060                             const nis_object *obj) __THROW;
00061 extern nis_result *nis_modify (const_nis_name name,
00062                             const nis_object *obj) __THROW;
00063 
00064 /* nis_tables: These functions are used to search and modify NIS+ tables.
00065  *
00066  * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata)
00067  *           search a table in the NIS+ namespace.
00068  *    const nis_name table_name: indexed name ([xx=yy],table.dir)
00069  *    unsigned int flags: logically ORing one or more flags (FOLLOW_LINKS,
00070  *                      [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE],
00071  *                      MASTER_ONLY, EXPAND_NAME, RETURN_RESULT)
00072  *    callback(): callback is an optional pointer to a function that will
00073  *                process the ENTRY type objects that are returned from the
00074  *                search. If this pointer is NULL, then all entries that match
00075  *                the search criteria are returned in the nis_result structure,
00076  *                otherwise  this  function  will  be  called once for each
00077  *                entry returned.
00078  *    void *userdata: passed to callback function along with the returned
00079  *                    entry object.
00080  *
00081  * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the
00082  *                                        NIS+ table_name.
00083  *    const nis_name table_name
00084  *    const nis_object *obj
00085  *    unsigned int flags: 0, ADD_OVERWRITE, RETURN_RESULT
00086  *
00087  * nis_modify_entry (name, obj, flags) modifies an object identified by name.
00088  *    const nis_name name: object identifier
00089  *    const nis_object *obj: should point to an entry with the EN_MODIFIED
00090  *                           flag set in each column that contains new
00091  *                           information.
00092  *    unsigned int flags: 0, MOD_SAMEOBJ, RETURN_RESULT
00093  *
00094  * nis_remove_entry (table_name, obj, flags) removes a set of entries
00095  *                                 identified by table_name from the table.
00096  *    const nis_name table_name: indexed NIS+ name
00097  *    const nis_object *obj: if obj is non-null, it is presumed to point to
00098  *                           a cached copy of the entry. When the removal is
00099  *                           attempted, and the object that would be removed
00100  *                           is not the same as the cached object pointed to
00101  *                           by object then the operation will fail with an
00102  *                           NIS_NOTSAMEOBJ error
00103  *    unsigned int flags: 0, REM_MULTIPLE
00104  *
00105  * nis_first_entry (table_name) fetches entries from a table one at a time.
00106  *    const nis_name table_name
00107  *
00108  * nis_next_entry (table_name, cookie) retrieves the "next" entry from a
00109  *                                     table specified by table_name.
00110  *    const nis_name table_name:
00111  *    const netobj *cookie: The value of cookie from the nis_result structure
00112  *                          form the previous call.
00113  */
00114 extern nis_result *nis_list (const_nis_name name, unsigned int flags,
00115                           int (*callback)(const_nis_name table_name,
00116                                         const nis_object *obj,
00117                                         const void *userdata),
00118                           const void *userdata) __THROW;
00119 extern nis_result *nis_add_entry (const_nis_name table_name,
00120                               const nis_object *obj,
00121                               unsigned int flags) __THROW;
00122 extern nis_result *nis_modify_entry (const_nis_name name,
00123                                  const nis_object *obj,
00124                                  unsigned int flags) __THROW;
00125 extern nis_result *nis_remove_entry (const_nis_name table_name,
00126                                  const nis_object *obj,
00127                                  unsigned int flags) __THROW;
00128 extern nis_result *nis_first_entry (const_nis_name table_name) __THROW;
00129 extern nis_result *nis_next_entry (const_nis_name table_name,
00130                                const netobj *cookie) __THROW;
00131 /*
00132 ** nis_server
00133 */
00134 extern nis_error nis_mkdir (const_nis_name dirname,
00135                          const nis_server *machine) __THROW;
00136 extern nis_error nis_rmdir (const_nis_name dirname,
00137                          const nis_server *machine) __THROW;
00138 extern nis_error nis_servstate (const nis_server *machine,
00139                             const nis_tag *tags, int numtags,
00140                             nis_tag **result) __THROW;
00141 extern nis_error nis_stats (const nis_server *machine,
00142                          const nis_tag *tags, int numtags,
00143                          nis_tag **result) __THROW;
00144 extern void nis_freetags (nis_tag *tags, int numtags) __THROW;
00145 extern nis_server **nis_getservlist (const_nis_name dirname) __THROW;
00146 extern void nis_freeservlist (nis_server **machines) __THROW;
00147 
00148 /*
00149 ** nis_subr
00150 */
00151 extern nis_name nis_leaf_of (const_nis_name name) __THROW;
00152 extern nis_name nis_leaf_of_r (const_nis_name name, char *buffer,
00153                             size_t buflen) __THROW;
00154 extern nis_name nis_name_of (const_nis_name name) __THROW;
00155 extern nis_name nis_name_of_r (const_nis_name name, char *buffer,
00156                             size_t buflen) __THROW;
00157 extern nis_name nis_domain_of (const_nis_name name) __THROW;
00158 extern nis_name nis_domain_of_r (const_nis_name name, char *buffer,
00159                              size_t buflen) __THROW;
00160 extern nis_name *nis_getnames (const_nis_name name) __THROW;
00161 extern void nis_freenames (nis_name *namelist) __THROW;
00162 extern name_pos nis_dir_cmp (const_nis_name n1, const_nis_name n2) __THROW;
00163 extern nis_object *nis_clone_object (const nis_object *src,
00164                                  nis_object *dest) __THROW;
00165 extern void nis_destroy_object (nis_object *obj) __THROW;
00166 extern void nis_print_object (const nis_object *obj) __THROW;
00167 
00168 /*
00169 ** nis_local_names
00170 */
00171 extern nis_name nis_local_group (void) __THROW;
00172 extern nis_name nis_local_directory (void) __THROW;
00173 extern nis_name nis_local_principal (void) __THROW;
00174 extern nis_name nis_local_host (void) __THROW;
00175 
00176 /*
00177 ** nis_error
00178 */
00179 extern const char *nis_sperrno (const nis_error status) __THROW;
00180 extern void nis_perror (const nis_error status, const char *label) __THROW;
00181 extern void nis_lerror (const nis_error status, const char *label) __THROW;
00182 extern char *nis_sperror (const nis_error status, const char *label) __THROW;
00183 extern char *nis_sperror_r (const nis_error status, const char *label,
00184                          char *buffer, size_t buflen) __THROW;
00185 /*
00186 ** nis_groups
00187 */
00188 extern bool_t nis_ismember (const_nis_name principal,
00189                          const_nis_name group) __THROW;
00190 extern nis_error nis_addmember (const_nis_name member,
00191                             const_nis_name group) __THROW;
00192 extern nis_error nis_removemember (const_nis_name member,
00193                                const_nis_name group) __THROW;
00194 extern nis_error nis_creategroup (const_nis_name group,
00195                               unsigned int flags) __THROW;
00196 extern nis_error nis_destroygroup (const_nis_name group) __THROW;
00197 extern void nis_print_group_entry (const_nis_name group) __THROW;
00198 extern nis_error nis_verifygroup (const_nis_name group) __THROW;
00199 
00200 /*
00201 ** nis_ping
00202 */
00203 extern void nis_ping (const_nis_name dirname, uint32_t utime,
00204                     const nis_object *dirobj) __THROW;
00205 extern nis_result *nis_checkpoint (const_nis_name dirname) __THROW;
00206 
00207 /*
00208 ** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
00209 */
00210 extern void nis_print_result (const nis_result *result) __THROW;
00211 extern void nis_print_rights (unsigned int rights) __THROW;
00212 extern void nis_print_directory (const directory_obj *dirobj) __THROW;
00213 extern void nis_print_group (const group_obj *grpobj) __THROW;
00214 extern void nis_print_table (const table_obj *tblobj) __THROW;
00215 extern void nis_print_link (const link_obj *lnkobj) __THROW;
00216 extern void nis_print_entry (const entry_obj *enobj) __THROW;
00217 
00218 /*
00219 ** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
00220 */
00221 extern directory_obj *readColdStartFile (void) __THROW;
00222 extern bool_t writeColdStartFile (const directory_obj *dirobj) __THROW;
00223 extern nis_object *nis_read_obj (const char *obj) __THROW;
00224 extern bool_t nis_write_obj (const char *file, const nis_object *obj) __THROW;
00225 
00226 /*
00227 ** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
00228 */
00229 extern directory_obj *nis_clone_directory (const directory_obj *src,
00230                                       directory_obj *dest) __THROW;
00231 extern nis_result *nis_clone_result (const nis_result *src,
00232                                  nis_result *dest) __THROW;
00233 
00234 /* nis_free - nis_freeresult */
00235 extern void nis_freeresult (nis_result *result) __THROW;
00236 /* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
00237 extern void nis_free_request (ib_request *req) __THROW;
00238 extern void nis_free_directory (directory_obj *dirobj) __THROW;
00239 extern void nis_free_object (nis_object *obj) __THROW;
00240 
00241 /* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
00242 extern nis_name __nis_default_owner (char *) __THROW;
00243 extern nis_name __nis_default_group (char *) __THROW;
00244 extern uint32_t __nis_default_ttl (char *) __THROW;
00245 extern unsigned int __nis_default_access (char *, unsigned int) __THROW;
00246 extern fd_result *__nis_finddirectory (directory_obj *, const_nis_name) __THROW;
00247 extern void __free_fdresult (fd_result *) __THROW;
00248 extern uint32_t __nis_hash (const void *keyarg, register size_t len) __THROW;
00249 
00250 /* NIS+ cache locking */
00251 extern int __nis_lock_cache (void) __THROW;
00252 extern int __nis_unlock_cache (void) __THROW;
00253 
00254 /* (XXX INTERNAL FUNCTIONS, ONLY FOR rpc.nisd AND glibc !!) */
00255 #if defined (NIS_INTERNAL) || defined (_LIBC)
00256 
00257 struct dir_binding
00258 {
00259   CLIENT *clnt;                  /* RPC CLIENT handle */
00260   nis_server *server_val;        /* List of servers */
00261   unsigned int server_len;       /* # of servers */
00262   unsigned int server_used;      /* Which server we are bind in the moment ? */
00263   unsigned int current_ep;       /* Which endpoint of the server are in use? */
00264   unsigned int trys;             /* How many server have we tried ? */
00265   unsigned int class;            /* From which class is server_val ? */
00266   bool_t master_only;            /* Is only binded to the master */
00267   bool_t use_auth;               /* Do we use AUTH ? */
00268   bool_t use_udp;                /* Do we use UDP ? */
00269   struct sockaddr_in addr;       /* Server's IP address */
00270   int socket;                    /* Server's local socket */
00271 };
00272 typedef struct dir_binding dir_binding;
00273 
00274 extern nis_error __nisbind_create (dir_binding *, const nis_server *,
00275                                unsigned int, unsigned int, unsigned int,
00276                                unsigned int) __THROW;
00277 extern nis_error __nisbind_connect (dir_binding *) __THROW;
00278 extern nis_error __nisbind_next (dir_binding *) __THROW;
00279 extern void __nisbind_destroy (dir_binding *) __THROW;
00280 extern nis_error __nisfind_server (const_nis_name, int, directory_obj **,
00281                                dir_binding *, unsigned int) __THROW;
00282 
00283 #endif
00284 
00285 __END_DECLS
00286 
00287 #endif /* __RPCSVC_NISLIB_H__ */