info_nis.c (38494) | info_nis.c (41142) |
---|---|
1/* 2 * Copyright (c) 1997-1998 Erez Zadok 3 * Copyright (c) 1989 Jan-Simon Pendry 4 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine 5 * Copyright (c) 1989 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 38 unchanged lines hidden (view full) --- 47 */ 48 49#ifdef HAVE_CONFIG_H 50# include <config.h> 51#endif /* HAVE_CONFIG_H */ 52#include <am_defs.h> 53#include <amd.h> 54 | 1/* 2 * Copyright (c) 1997-1998 Erez Zadok 3 * Copyright (c) 1989 Jan-Simon Pendry 4 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine 5 * Copyright (c) 1989 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 38 unchanged lines hidden (view full) --- 47 */ 48 49#ifdef HAVE_CONFIG_H 50# include <config.h> 51#endif /* HAVE_CONFIG_H */ 52#include <am_defs.h> 53#include <amd.h> 54 |
55 |
|
55/* 56 * NIS+ servers in NIS compat mode don't have yp_order() 57 */ 58static int has_yp_order = FALSE; 59 60/* forward declarations */ 61int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); 62int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp); 63int nis_init(mnt_map *m, char *map, time_t *tp); | 56/* 57 * NIS+ servers in NIS compat mode don't have yp_order() 58 */ 59static int has_yp_order = FALSE; 60 61/* forward declarations */ 62int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); 63int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp); 64int nis_init(mnt_map *m, char *map, time_t *tp); |
65int nis_isup(mnt_map *m, char *map); |
|
64int nis_mtime(mnt_map *m, char *map, time_t *tp); 65 66/* typedefs */ 67typedef void (*nis_callback_fxn_t)(mnt_map *, char *, char *); 68#ifndef DEFINED_YPALL_CALLBACK_FXN_T 69typedef int (*ypall_callback_fxn_t)(); 70#endif /* DEFINED_YPALL_CALLBACK_FXN_T */ 71 --- 43 unchanged lines hidden (view full) --- 115 */ 116static int 117callback(int status, char *key, int kl, char *val, int vl, char *data) 118{ 119 struct nis_callback_data *ncdp = (struct nis_callback_data *) data; 120 121 if (status == YP_TRUE) { 122 | 66int nis_mtime(mnt_map *m, char *map, time_t *tp); 67 68/* typedefs */ 69typedef void (*nis_callback_fxn_t)(mnt_map *, char *, char *); 70#ifndef DEFINED_YPALL_CALLBACK_FXN_T 71typedef int (*ypall_callback_fxn_t)(); 72#endif /* DEFINED_YPALL_CALLBACK_FXN_T */ 73 --- 43 unchanged lines hidden (view full) --- 117 */ 118static int 119callback(int status, char *key, int kl, char *val, int vl, char *data) 120{ 121 struct nis_callback_data *ncdp = (struct nis_callback_data *) data; 122 123 if (status == YP_TRUE) { 124 |
123 /* 124 * Add to list of maps 125 */ | 125 /* add to list of maps */ |
126 char *kp = strnsave(key, kl); 127 char *vp = strnsave(val, vl); | 126 char *kp = strnsave(key, kl); 127 char *vp = strnsave(val, vl); |
128 |
|
128 (*ncdp->ncd_fn) (ncdp->ncd_m, kp, vp); 129 | 129 (*ncdp->ncd_fn) (ncdp->ncd_m, kp, vp); 130 |
130 /* 131 * We want more ... 132 */ | 131 /* we want more ... */ |
133 return FALSE; 134 135 } else { 136 | 132 return FALSE; 133 134 } else { 135 |
137 /* 138 * NOMORE means end of map - otherwise log error 139 */ | 136 /* NOMORE means end of map - otherwise log error */ |
140 if (status != YP_NOMORE) { | 137 if (status != YP_NOMORE) { |
141 /* 142 * Check what went wrong 143 */ | 138 /* check what went wrong */ |
144 int e = ypprot_err(status); 145 146#ifdef DEBUG 147 plog(XLOG_ERROR, "yp enumeration of %s: %s, status=%d, e=%d", 148 ncdp->ncd_map, yperr_string(e), status, e); 149#else /* not DEBUG */ 150 plog(XLOG_ERROR, "yp enumeration of %s: %s", ncdp->ncd_map, yperr_string(e)); 151#endif /* not DEBUG */ --- 221 unchanged lines hidden (view full) --- 373 j = (incallback->foreach)(YP_TRUE, 374 outkey, 375 outkeylen, 376 outval, 377 outvallen, 378 incallback->data); 379 if (j != FALSE) /* terminate loop */ 380 break; | 139 int e = ypprot_err(status); 140 141#ifdef DEBUG 142 plog(XLOG_ERROR, "yp enumeration of %s: %s, status=%d, e=%d", 143 ncdp->ncd_map, yperr_string(e), status, e); 144#else /* not DEBUG */ 145 plog(XLOG_ERROR, "yp enumeration of %s: %s", ncdp->ncd_map, yperr_string(e)); 146#endif /* not DEBUG */ --- 221 unchanged lines hidden (view full) --- 368 j = (incallback->foreach)(YP_TRUE, 369 outkey, 370 outkeylen, 371 outval, 372 outvallen, 373 incallback->data); 374 if (j != FALSE) /* terminate loop */ 375 break; |
376 377 /* 378 * We have to manually free all char ** arguments to yp_first/yp_next 379 * outval must be freed *before* calling yp_next again, outkey can be 380 * freed as outkey_old *after* the call (this saves one call to 381 * strnsave). 382 */ 383 XFREE(outval); |
|
381 outkey_old = outkey; 382 outkeylen_old = outkeylen; 383 i = yp_next(indomain, 384 inmap, 385 outkey_old, 386 outkeylen_old, | 384 outkey_old = outkey; 385 outkeylen_old = outkeylen; 386 i = yp_next(indomain, 387 inmap, 388 outkey_old, 389 outkeylen_old, |
387 &outkey, | 390 &outkey, |
388 &outkeylen, 389 &outval, 390 &outvallen); | 391 &outkeylen, 392 &outval, 393 &outvallen); |
394 XFREE(outkey_old); |
|
391 } while (!i); 392#ifdef DEBUG 393 if (i) { 394 dlog("yp_next() returned error: %s\n", yperr_string(i)); 395 } 396#endif /* DEBUG */ 397 if (i == YPERR_NOMORE) 398 return 0; 399 return i; 400} 401#endif /* HAVE_BAD_YP_ALL */ | 395 } while (!i); 396#ifdef DEBUG 397 if (i) { 398 dlog("yp_next() returned error: %s\n", yperr_string(i)); 399 } 400#endif /* DEBUG */ 401 if (i == YPERR_NOMORE) 402 return 0; 403 return i; 404} 405#endif /* HAVE_BAD_YP_ALL */ |