]> andersk Git - moira.git/commitdiff
use libmrclient to simplify connecting to the server
authordanw <danw>
Thu, 13 May 1999 18:53:28 +0000 (18:53 +0000)
committerdanw <danw>
Thu, 13 May 1999 18:53:28 +0000 (18:53 +0000)
clients/addusr/Makefile.in
clients/addusr/addusr.c
clients/blanche/Makefile.in
clients/blanche/blanche.c
clients/mailmaint/Makefile.in
clients/mailmaint/mailmaint.c
clients/mrcheck/Makefile.in
clients/mrcheck/mrcheck.c
clients/mrtest/Makefile.in

index 6b62e51e10b8cecdff796fd61368fa35e159f5aa..a01ffd3ecbc9e448aedd0525f44fa5a4cfc75c83 100644 (file)
@@ -9,7 +9,7 @@ CFLAGS=@CFLAGS@
 DEFS=@DEFS@
 ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) $(DEFS)
 LDFLAGS=@LDFLAGS@
-LIBS=@LIBS@
+LIBS=../lib/libmrclient.a @LIBS@
 MR_LIBDEP=@MR_LIBDEP@
 INSTALL=@INSTALL@
 INSTALL_PROGRAM=@INSTALL_PROGRAM@
@@ -39,5 +39,5 @@ depend:
 install: all
        $(INSTALL_PROGRAM) -m 755 addusr $(bindir)
 
-$(TARGET): $(OBJS) $(MR_LIBDEP)
+$(TARGET): $(OBJS) ../lib/libmrclient.a $(MR_LIBDEP)
        $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
index 694271253568ebab2afc983e41af5f0c5b707115..96f18f3fd3c230116421ce15c70d234647437185 100644 (file)
@@ -12,6 +12,7 @@
 #include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+#include <mrclient.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -44,7 +45,7 @@ int main(int argc, char **argv)
 {
   int status, lineno;
   char **arg = argv, *qargv[U_END];
-  char *motd, *p, *first, *middle, *last, *id, *login, *server;
+  char *p, *first, *middle, *last, *id, *login, *server;
   char buf[BUFSIZ], idbuf[32];
   FILE *input;
 
@@ -154,34 +155,8 @@ int main(int argc, char **argv)
     }
 
   /* fire up Moira */
-  if ((status = mr_connect(server)))
-    {
-      com_err(whoami, status, "unable to connect to the Moira server");
-      exit(2);
-    }
-  if ((status = mr_motd(&motd)))
-    {
-      com_err(whoami, status, "unable to check server status");
-      exit(2);
-    }
-  if (motd)
-    {
-      fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
-             motd);
-      mr_disconnect();
-      exit(2);
-    }
-
-  if ((status = mr_auth("addusr")))
-    {
-      if (status == MR_USER_AUTH)
-       com_err(whoami, status, "");
-      else
-       {
-         com_err(whoami, status, "unable to authenticate to Moira");
-         exit(2);
-       }
-    }
+  if (mrcl_connect(server, "addusr", 1) != MRCL_SUCCESS)
+    exit(2);
 
   qargv[U_NAME] = UNIQUE_LOGIN;
   qargv[U_UID] = UNIQUE_UID;
index d00867cab76fedf7cda76429d1312e55c2aa6fb8..7757ba20b1940fca0779fae07c27507102cafd09 100644 (file)
@@ -9,7 +9,7 @@ CFLAGS=@CFLAGS@
 DEFS=@DEFS@
 ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) $(DEFS)
 LDFLAGS=@LDFLAGS@
-LIBS=@LIBS@
+LIBS=../lib/libmrclient.a @LIBS@
 MR_LIBDEP=@MR_LIBDEP@
 INSTALL=@INSTALL@
 INSTALL_PROGRAM=@INSTALL_PROGRAM@
@@ -39,5 +39,5 @@ depend:
 install: all
        $(INSTALL_PROGRAM) blanche $(bindir)
 
-$(TARGET): $(OBJS) $(MR_LIBDEP)
+$(TARGET): $(OBJS) ../lib/libmrclient.a $(MR_LIBDEP)
        $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
index 019630fe9e687ee470776d64ec9495a62a26a47f..9eced03c38fa9aed180fc9cb56bfe3f6980da057 100644 (file)
@@ -12,6 +12,7 @@
 #include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+#include <mrclient.h>
 
 #include <ctype.h>
 #include <errno.h>
@@ -66,7 +67,7 @@ int main(int argc, char **argv)
 {
   int status, success;
   char **arg = argv;
-  char *membervec[3], *motd;
+  char *membervec[3];
   struct member *memberstruct;
   char *server = NULL, *p;
 
@@ -277,36 +278,14 @@ int main(int argc, char **argv)
     showusers = showstrings = showlists = showkerberos = 1;
 
   /* fire up Moira */
-  if ((status = mr_connect(server)))
+  status = mrcl_connect(server, "blanche", !noauth);
+  if (status == MRCL_AUTH_ERROR)
     {
-      com_err(whoami, status, "unable to connect to the Moira server");
-      exit(2);
-    }
-  if ((status = mr_motd(&motd)))
-    {
-      com_err(whoami, status, "unable to check server status");
-      exit(2);
-    }
-  if (motd)
-    {
-      fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
-             motd);
-      mr_disconnect();
-      exit(2);
-    }
-
-  if (!noauth && (status = mr_auth("blanche")))
-    {
-      if (status == MR_USER_AUTH)
-       com_err(whoami, status, "");
-      else
-       {
-         com_err(whoami, status, "unable to authenticate to Moira");
-         com_err(whoami, 0,
-                 " Try the -noauth flag if you don't need authentication");
-         exit(2);
-       }
+      com_err(whoami, 0, "Try the -noauth flag if you don't "
+             "need authentication.");
     }
+  if (status)
+    exit(2);
 
   /* check for username/listname clash */
   if (createflag || (setinfo && newname && strcmp(newname, listname)))
index 2192c51aee0b51362b8503a36513994e2ba036a2..36b6d5d9210ca3f62e655cdd083a09d6fc425831 100644 (file)
@@ -9,7 +9,7 @@ CFLAGS=@CFLAGS@
 DEFS=@DEFS@
 ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) $(DEFS)
 LDFLAGS=@LDFLAGS@
-LIBS=@CURSES_LIBS@ @LIBS@
+LIBS=../lib/libmrclient.a @CURSES_LIBS@ @LIBS@
 MR_LIBDEP=@MR_LIBDEP@
 INSTALL=@INSTALL@
 INSTALL_PROGRAM=@INSTALL_PROGRAM@
@@ -39,5 +39,5 @@ depend:
 install: all
        $(INSTALL_PROGRAM) mailmaint $(bindir)
 
-$(TARGET): $(OBJS) $(MR_LIBDEP)
+$(TARGET): $(OBJS) ../lib/libmrclient.a $(MR_LIBDEP)
        $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
index 274ba9f55c3fec52995f00ae09aeb88851e51823..ea850103b43bb7341cf0ad3c1d2d3708870a2568 100644 (file)
@@ -12,6 +12,7 @@
 #include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+#include <mrclient.h>
 
 #include <ctype.h>
 #ifdef HAVE_CURSES
@@ -112,7 +113,7 @@ int main(int argc, char *argv[])
 {
   void (*old_hook)(const char *, long, const char *, va_list);
   int use_menu = 1, k_errno;
-  char buf[BUFSIZ], pname[ANAME_SZ], *motd;
+  char buf[BUFSIZ], pname[ANAME_SZ];
 
   if ((whoami = strrchr(argv[0], '/')) == NULL)
     whoami = argv[0];
@@ -144,33 +145,8 @@ int main(int argc, char *argv[])
 
   printf("Connecting to database for %s...please hold on.\n", username);
 
-  status = mr_connect(NULL);
-  if (status)
-    {
-      sprintf(buf, "\nConnection to Moira server failed");
-      goto punt;
-    }
-
-  status = mr_motd(&motd);
-  if (status)
-    {
-      com_err(whoami, status, " unable to check server status");
-      mr_disconnect();
-      exit(2);
-    }
-  if (motd)
-    {
-      fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
-             motd);
-      mr_disconnect();
-      exit(2);
-    }
-  status = mr_auth("mailmaint");
-  if (status)
-    {
-      sprintf(buf, "\nAuthorization failed.\n");
-      goto punt;
-    }
+  if (mrcl_connect(NULL, "mailmaint", 1))
+    exit(2);
 
   initscr();
   if ((LINES < 24) || (COLS < 60))
index 457e4f1a14f9c32bde0cfd17af1832f204fce092..fa1ce0b72c81e3235102fc809700ec79091c1126 100644 (file)
@@ -9,7 +9,7 @@ CFLAGS=@CFLAGS@
 DEFS=@DEFS@
 ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) $(DEFS)
 LDFLAGS=@LDFLAGS@
-LIBS=@LIBS@
+LIBS=../lib/libmrclient.a @LIBS@
 MR_LIBDEP=@MR_LIBDEP@
 INSTALL=@INSTALL@
 INSTALL_PROGRAM=@INSTALL_PROGRAM@
@@ -39,5 +39,5 @@ depend:
 install: all
        $(INSTALL_PROGRAM) mrcheck $(bindir)
 
-$(TARGET): $(OBJS) $(MR_LIBDEP)
+$(TARGET): $(OBJS) ../lib/libmrclient.a $(MR_LIBDEP)
        $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
index 43dea5b23d397ed9007a5ca7ca5ef58517491930..d996eda049a67e4368582ae1e2746571dca28844 100644 (file)
@@ -10,6 +10,7 @@
 #include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
+#include <mrclient.h>
 
 #include <sys/time.h>
 
@@ -27,8 +28,8 @@ int process_host(int argc, char **argv, void *sqv);
 void disp_sh(char **argv, char *msg);
 void usage(void);
 
+char *whoami;
 static int count = 0;
-static char *whoami;
 static struct timeval now;
 
 struct service {
@@ -162,7 +163,7 @@ void disp_sh(char **argv, char *msg)
 
 int main(int argc, char *argv[])
 {
-  char *args[2], buf[BUFSIZ], *motd;
+  char *args[2], buf[BUFSIZ];
   struct save_queue *sq;
   int status;
   int auth_required = 1;
@@ -177,26 +178,8 @@ int main(int argc, char *argv[])
   else if (argc > 1)
     usage();
 
-  status = mr_connect(NULL);
-  if (status)
-    {
-      sprintf(buf, "\nConnection to the Moira server failed.");
-      goto punt;
-    }
-
-  status = mr_motd(&motd);
-  if (status)
-    {
-      com_err(whoami, status, " unable to check server status");
-      exit(2);
-    }
-  if (motd)
-    {
-      fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
-             motd);
-      mr_disconnect();
-      exit(2);
-    }
+  if (mrcl_connect(NULL, NULL, 0) != MRCL_SUCCESS)
+    exit(2);
   status = mr_auth("mrcheck");
   if (status && auth_required)
     {
index ec225f284eb21311797cfec4b5b61fe66bcdd556..e49f4a6cfdd2089e24bd254658529a22fc1b79b2 100644 (file)
@@ -9,7 +9,7 @@ CFLAGS=@CFLAGS@
 DEFS=@DEFS@
 ALL_CFLAGS=$(CPPFLAGS) $(CFLAGS) $(DEFS)
 LDFLAGS=@LDFLAGS@
-LIBS=@READLINE_LIBS@ @LIBS@
+LIBS=../lib/libmrclient.a @READLINE_LIBS@ @LIBS@
 MR_LIBDEP=@MR_LIBDEP@
 INSTALL=@INSTALL@
 INSTALL_PROGRAM=@INSTALL_PROGRAM@
@@ -39,5 +39,5 @@ depend:
 install: all
        $(INSTALL_PROGRAM) mrtest $(bindir)
 
-$(TARGET): $(OBJS) $(MR_LIBDEP)
+$(TARGET): $(OBJS) ../lib/libmrclient.a $(MR_LIBDEP)
        $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
This page took 0.20538 seconds and 5 git commands to generate.