]> andersk Git - moira.git/blobdiff - clients/moira/namespace.c
Need to fill in the "user" variable with mrcl_krb_user().
[moira.git] / clients / moira / namespace.c
index 080bbc3a218fc34a3de98aa0df181b114fcc0996..9bc6bfe9003e537b3efa29fd9c9b235154aa2706 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <mit-copyright.h>
 #include <moira.h>
+#include <mrclient.h>
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
-#if 0
-#include <pwd.h>
-#include <sys/types.h>
-#endif
 
 #include <krb.h>
 
@@ -164,7 +161,9 @@ Menu namespace_menu = {
   }
 };
 
+#ifdef HAVE_CURSES
 Bool use_menu = TRUE;          /* whether or not we are using a menu. */
+#endif
 
 /*     Function Name: main
  *     Description: The main driver for the Moira Client.
@@ -172,7 +171,7 @@ Bool use_menu = TRUE;               /* whether or not we are using a menu. */
  *     Returns: doesn't return.
  */
 
-void main(int argc, char **argv)
+int main(int argc, char **argv)
 {
   int status;
   Menu *menu;
@@ -187,6 +186,10 @@ void main(int argc, char **argv)
   program_name = strdup(program_name);
   whoami = strdup(program_name); /* used by menu.c,  ugh !!! */
 
+  user = mrcl_krb_user();
+  if (!user)
+    exit(1);
+
   verbose = TRUE;
   arg = argv;
   moira_server = NULL;
@@ -196,7 +199,22 @@ void main(int argc, char **argv)
       if (**arg == '-')
        {
          if (!strcmp(*arg, "-nomenu"))
-           use_menu = FALSE;
+           {
+#ifdef HAVE_CURSES
+             use_menu = FALSE;
+#else
+             ;
+#endif
+           }
+         else if (!strcmp(*arg, "-menu"))
+           {
+#ifdef HAVE_CURSES
+             use_menu = TRUE;
+#else
+             fprintf(stderr, "%s: No curses support. -menu option ignored\n",
+                     whoami);
+#endif
+           }
          else if (!strcmp(*arg, "-db"))
            if (arg - argv < argc - 1)
              {
@@ -210,30 +228,9 @@ void main(int argc, char **argv)
        }
     }
 
-  if ((status = mr_connect(moira_server)))
-    ErrorExit("\nConnection to Moira server failed", status);
-
-  /* do this now since calling mr_connect initialized the krb error table
-   * for us.
-   */
-  if ((status = tf_init(TKT_FILE, R_TKT_FIL)) ||
-      (status = tf_get_pname(pname)))
-    {
-      com_err(whoami, status, "cannot find your ticket file");
-      exit(1);
-    }
-  tf_close();
-  user = strdup(pname);
-
-  if ((status = mr_motd(&motd)))
-    ErrorExit("\nUnable to check server status", status);
-  if (motd)
-    {
-      fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
-             motd);
-      mr_disconnect();
-      exit(1);
-    }
+  if (mrcl_connect(moira_server, program_name, QUERY_VERSION, 0)
+      != MRCL_SUCCESS)
+    exit(1);
 
   if ((status = mr_auth(program_name)))
     {
@@ -257,9 +254,11 @@ void main(int argc, char **argv)
   act.sa_handler = Signal_Handler;
   sigaction(SIGHUP, &act, NULL);
   sigaction(SIGQUIT, &act, NULL);
+#ifdef HAVE_CURSES
   if (use_menu)
     sigaction(SIGINT, &act, NULL);
   else
+#endif
     {
       act.sa_handler = CatchInterrupt;
       sigaction(SIGINT, &act, NULL);
@@ -267,6 +266,7 @@ void main(int argc, char **argv)
 
   menu = &namespace_menu;
 
+#ifdef HAVE_CURSES
   if (use_menu)                /* Start menus that execute program */
     {
       Start_paging();
@@ -274,6 +274,7 @@ void main(int argc, char **argv)
       Stop_paging();
     }
   else                 /* Start program without menus. */
+#endif
     Start_no_menu(menu);
 
   mr_disconnect();
@@ -315,8 +316,10 @@ static void Usage(void)
 static void Signal_Handler(void)
 {
   Put_message("Signal caught - exiting");
+#ifdef HAVE_CURSES
   if (use_menu)
     Cleanup_menu();
+#endif
   mr_disconnect();
   exit(1);
 }
This page took 0.041501 seconds and 4 git commands to generate.