Switch to using the ypstuff interface to YP server.
authormdw <mdw>
Thu, 23 Apr 1998 13:27:46 +0000 (13:27 +0000)
committermdw <mdw>
Thu, 23 Apr 1998 13:27:46 +0000 (13:27 +0000)
src/netg.c
src/userdb.c

index ab46385..c198219 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: netg.c,v 1.3 1998/01/12 16:46:17 mdw Exp $
+ * $Id: netg.c,v 1.4 1998/04/23 13:24:49 mdw Exp $
  *
  * A local database of netgroups
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: netg.c,v $
+ * Revision 1.4  1998/04/23 13:24:49  mdw
+ * Switch to using the ypstuff interface to YP server.
+ *
  * Revision 1.3  1998/01/12 16:46:17  mdw
  * Fix copyright date.
  *
 
 #include <sys/types.h>
 
-#ifdef HAVE_YP
-#  include <rpc/rpc.h>
-#  include <rpcsvc/ypclnt.h>
-#  include <rpcsvc/yp_prot.h>
-#endif
-
 #include <netinet/in.h>
 
 #include <arpa/inet.h>
@@ -78,6 +75,7 @@
 #include "sym.h"
 #include "userdb.h"
 #include "utils.h"
+#include "ypstuff.h"
 
 /*----- Type definitions --------------------------------------------------*/
 
@@ -557,29 +555,23 @@ static void netg__breakCycle(netg__cons *c)
 
 void netg_init(void)
 {
-  char *ypdom;
-
   /* --- Initialise my symbol table --- */
 
   sym_createTable(&netg__table);
 
   /* --- Bind myself unto a YP server --- */
 
-  if (yp_get_default_domain(&ypdom) ||
-      yp_bind(ypdom))
+  ypstuff_bind();
+  if (!yp_domain)
     return;
   
   /* --- Now try to read all the netgroup entries --- */
 
   {
     static struct ypall_callback ncb = { netg__foreach, 0 };
-    yp_all(ypdom, "netgroup", &ncb);
+    yp_all(yp_domain, "netgroup", &ncb);
   }
 
-  /* --- Unbind from the server --- */
-
-  yp_unbind(ypdom);
-
   /* --- Dump the table --- */
 
   IF_TRACING(TRACE_DEBUG, netg__dump(); )
index 2db8ee5..05ace82 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: userdb.c,v 1.6 1998/01/12 16:46:33 mdw Exp $
+ * $Id: userdb.c,v 1.7 1998/04/23 13:27:46 mdw Exp $
  *
  * User database management
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: userdb.c,v $
+ * Revision 1.7  1998/04/23 13:27:46  mdw
+ * Switch to using the ypstuff interface to YP server.
+ *
  * Revision 1.6  1998/01/12 16:46:33  mdw
  * Fix copyright date.
  *
 
 #include <sys/types.h>
 
-#ifdef HAVE_YP
-#  include <rpc/rpc.h>
-#  include <rpcsvc/ypclnt.h>
-#  include <rpcsvc/yp_prot.h>
-#endif
-
 #include <grp.h>
 #include <pwd.h>
 #include <unistd.h>
@@ -84,6 +81,7 @@
 #include "sym.h"
 #include "userdb.h"
 #include "utils.h"
+#include "ypstuff.h"
 
 /*----- Type definitions --------------------------------------------------*/
 
@@ -683,12 +681,10 @@ static int userdb__foreachGroup(int st, char *k, int ksz,
 
 void userdb_yp(void)
 {
-  char *ypdom;
-
   /* --- Bind to a server --- */
 
-  if (yp_get_default_domain(&ypdom) ||
-      yp_bind(ypdom))
+  ypstuff_bind();
+  if (!yp_domain)
     return;
 
   T( trace(TRACE_DEBUG, "debug: adding NIS users"); )
@@ -697,17 +693,15 @@ void userdb_yp(void)
 
   {
     static struct ypall_callback ucb = { userdb__foreachUser, 0 };
-    yp_all(ypdom, "passwd.byuid", &ucb);
+    yp_all(yp_domain, "passwd.byuid", &ucb);
   }
 
   /* --- Fetch the groups map --- */
 
   {
     static struct ypall_callback gcb = { userdb__foreachGroup, 0 };
-    yp_all(ypdom, "group.bygid", &gcb);
+    yp_all(yp_domain, "group.bygid", &gcb);
   }
-
-  yp_unbind(ypdom);
 }
 
 #else
@@ -816,20 +810,21 @@ void dumpit(const char *msg)
 int main(void)
 {
   ego("userdb-test");
-/*   traceon(stdout, TRACE_ALL); */
+  traceon(stdout, TRACE_ALL);
   userdb_init();
   userdb_local();
   userdb_yp();
-  printf("loaded (%lu)\n", track_memused());
+  dumpit("spong");
+/*  printf("loaded (%lu)\n", track_memused()); */
   getchar();
   for (;;) {
     userdb_end();
-    printf("cleared (%lu)\n", track_memused());
+/*    printf("cleared (%lu)\n", track_memused()); */
 /*    track_memlist(); */
     userdb_init();
     userdb_local();
     userdb_yp();
-    printf("reloaded (%lu)\n", track_memused());
+/*    printf("reloaded (%lu)\n", track_memused()); */
     getchar();
   }
   return (0);