]> andersk Git - moira.git/blobdiff - clients/moira/main.c
init gdss et
[moira.git] / clients / moira / main.c
index 070b90652b6e90bba382a45c5cff202ead9f001c..6a6059f0b721dea78a6ed8744a73c78145b6242c 100644 (file)
@@ -24,8 +24,9 @@
 #include <stdio.h>
 #include <strings.h>
 #include <sys/types.h>
-#include <sms.h>
+#include <moira.h>
 #include <menu.h>
+#include <krb_et.h>
 
 #include "mit-copyright.h"
 #include "defs.h"
 
 char * whoami;                 /* used by menu.c ugh!!! */
 char * moira_server;
+int interrupt = 0;
 
-extern Menu sms_top_menu, list_menu, user_menu, dcm_menu;
+extern Menu moira_top_menu, list_menu, user_menu, dcm_menu;
 
 #ifndef DEBUG
-static void SignalHandler();
+static void SignalHandler(), CatchInterrupt();
 #endif DEBUG
 
 static void ErrorExit(), Usage();
@@ -46,7 +48,11 @@ char *getlogin();
 uid_t getuid();
 struct passwd *getpwuid();
 
+#ifdef _AIX
+Bool use_menu = FALSE;         /* whether or not we are using a menu. */
+#else
 Bool use_menu = TRUE;          /* whether or not we are using a menu. */
+#endif
 
 /*     Function Name: main
  *     Description: The main driver for the Moira Client.
@@ -76,7 +82,7 @@ main(argc, argv)
 
     verbose = TRUE;
     arg = argv;
-    moira_server = SMS_SERVER;
+    moira_server = NULL;
 
     while (++arg - argv < argc) {
        if (**arg == '-') {
@@ -93,24 +99,29 @@ main(argc, argv)
        }
     }
 
-    if ( status = sms_connect(moira_server) ) 
+    if ( status = mr_connect(moira_server) ) 
        ErrorExit("\nConnection to Moira server failed", status);
 
-    if ( status = sms_motd(&motd) )
+    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);
-       sms_disconnect();
+       mr_disconnect();
        exit(1);
     }
 
-    if ( status = sms_auth(program_name) ) {
-       if (status == SMS_USER_AUTH) {
+    if ( status = mr_auth(program_name) ) {
+       if (status == MR_USER_AUTH) {
            char buf[BUFSIZ];
            com_err(program_name, status, "\nPress [RETURN] to continue");
            gets(buf);
-       } else
-         ErrorExit("\nAuthorization failed -- please run kinit", status);
+       } else {
+         if (status >= ERROR_TABLE_BASE_krb &&
+             status <= ERROR_TABLE_BASE_krb + 256)
+           ErrorExit("\nAuthorization failed -- please run kinit", status);
+         else
+           ErrorExit("\nAuthorization failed.", status);
+       }
     }
 
 /*
@@ -120,10 +131,15 @@ main(argc, argv)
 
 #ifndef DEBUG
     (void) signal(SIGHUP, SignalHandler);
-    (void) signal(SIGINT, SignalHandler); 
     (void) signal(SIGQUIT, SignalHandler);
+    if (use_menu)
+      (void) signal(SIGINT, SignalHandler); 
+    else
+      (void) signal(SIGINT, CatchInterrupt); 
 #endif DEBUG
 
+    initialize_gdss_error_table();
+
     if (!strcmp(program_name, "listmaint"))
       menu = &list_menu;
     else if (!strcmp(program_name, "usermaint"))
@@ -131,7 +147,7 @@ main(argc, argv)
     else if (!strcmp(program_name, "dcmmaint"))
       menu = &dcm_menu;
     else
-      menu = &sms_top_menu;
+      menu = &moira_top_menu;
 
     if (use_menu) {            /* Start menus that execute program */
         Start_paging();
@@ -141,7 +157,7 @@ main(argc, argv)
     else                       /* Start program without menus. */
        Start_no_menu(menu);
 
-    sms_disconnect();
+    mr_disconnect();
     exit(0);
 }
 
@@ -158,7 +174,7 @@ int status;
 char * buf;    
 {
     com_err(program_name, status, buf);
-    sms_disconnect();
+    mr_disconnect();
     exit(1);
 }
 
@@ -188,7 +204,15 @@ SignalHandler()
     Put_message("Signal caught - exiting");
     if (use_menu)
       Cleanup_menu();
-    sms_disconnect();
+    mr_disconnect();
     exit(1);
 }
+
+
+static void
+CatchInterrupt()
+{
+    Put_message("Interrupt! Press RETURN to continue");
+    interrupt = 1;
+}
 #endif DEBUG
This page took 0.031362 seconds and 4 git commands to generate.