]> andersk Git - moira.git/blobdiff - clients/moira/main.c
fix program name stuff correctly
[moira.git] / clients / moira / main.c
index f970811c095c3130351b99e7343f02f3f35e859a..1d46fd2e52616015bbc4cca708e9850c7ecb04f4 100644 (file)
@@ -1,10 +1,10 @@
-#ifndef lint
+#if (!defined(lint) && !defined(SABER))
   static char rcsid_module_c[] = "$Header$";
 #endif lint
 
-/*     This is the file main.c for allmaint, the SMS client that allows
- *      a user to maintaint most important parts of the SMS database.
- *     It Contains:  The main driver for this program.
+/*     This is the file main.c for the SMS Client, which allows a nieve
+ *      user to quickly and easily maintain most parts of the SMS database.
+ *     It Contains: The main driver for the SMS Client.
  *     
  *     Created:        4/12/88
  *     By:             Chris D. Peterson
@@ -13,7 +13,7 @@
  *      $Author$
  *      $Header$
  *     
- *     Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ *     Copyright 1988 by the Massachusetts Institute of Technology.
  *
  *     For further information on copyright and distribution 
  *     see the file mit-copyright.h
 #include <signal.h>
 #include <stdio.h>
 #include <strings.h>
+#include <sys/types.h>
 #include <sms.h>
 #include <menu.h>
 
 #include "mit-copyright.h"
-#include "allmaint.h"
+#include "defs.h"
+#include "f_defs.h"
 #include "globals.h"
 
-static void init_listmaint(), error_exit(), usage();
-void Put_message();
+char * whoami;                 /* used by menu.c ugh!!! */
+
+extern Menu sms_top_menu, list_menu, user_menu, dcm_menu;
+
+#ifndef DEBUG
+static void SignalHandler();
+#endif DEBUG
+
+static void ErrorExit(), Usage();
 char *getlogin();
 uid_t getuid();
 struct passwd *getpwuid();
@@ -39,7 +48,7 @@ struct passwd *getpwuid();
 Bool use_menu = TRUE;          /* whether or not we are using a menu. */
 
 /*     Function Name: main
- *     Description: The main driver for allmaint.
+ *     Description: The main driver for the SMS Client.
  *     Arguments: argc, argv - standard command line args.
  *     Returns: doesn't return.
  */
@@ -49,60 +58,77 @@ main(argc, argv)
     int argc;
     char ** argv;
 {
-    char buf[BUFSIZ];
+    int status;
+    Menu *menu;
 
     if ((user = getlogin()) == NULL) 
        user = getpwuid((int) getuid())->pw_name;
     user = (user && strlen(user)) ? Strsave(user) : "";
 
+    if ((program_name = rindex(argv[0], '/')) == NULL)
+      program_name = argv[0];
+    else
+      program_name++;
+    program_name = Strsave(program_name);
+    whoami = Strsave(program_name); /* used by menu.c,  ugh !!! */
+
     init_sms_err_tbl();
     init_krb_err_tbl();
+    verbose = TRUE;
 
     switch (argc) {
     case 2:
       if (strcmp(argv[1], "-nomenu") == 0)
        use_menu = FALSE;
-      else
-       usage();
-                               /* Fall Through. */
+      else 
+       Usage();
+      break;
     case 1:
-      if ((program_name = rindex(argv[0], '/')) == NULL)
-       program_name = argv[0];
-      else
-       program_name++;
       break;
     default:
-      usage();
+      Usage();
       break;
     }
-    
+
     if ( status = sms_connect() ) 
-       error_exit("\nConnection to SMS server failed", status);
+       ErrorExit("\nConnection to SMS server failed", status);
 
-    if ( status = sms_auth(argv[0]) ) 
-       error_exit("\nAuthorization failed -- please run kinit", status);
+    if ( status = sms_auth(program_name) ) 
+       ErrorExit("\nAuthorization failed -- please run kinit", status);
 
 /*
  * These signals should not be set until just before we fire up the menu
  * system. 
  */
-    (void) signal(SIGHUP, signal_handler);
-    (void) signal(SIGINT, signal_handler);
-    (void) signal(SIGQUIT, signal_handler);
+
+#ifndef DEBUG
+    (void) signal(SIGHUP, SignalHandler);
+    (void) signal(SIGINT, SignalHandler); 
+    (void) signal(SIGQUIT, SignalHandler);
+#endif DEBUG
+
+    if (!strcmp(program_name, "listmaint"))
+      menu = &list_menu;
+    else if (!strcmp(program_name, "usermaint"))
+      menu = &user_menu;
+    else if (!strcmp(program_name, "dcmmaint"))
+      menu = &dcm_menu;
+    else
+      menu = &sms_top_menu;
 
     if (use_menu) {            /* Start menus that execute program */
         Start_paging();
-       Start_menu(&allmaint_top_menu);
+       Start_menu(menu);
        Stop_paging();
     }
     else                       /* Start program without menus. */
-       Start_no_menu(&allmaint_top_menu);
+       Start_no_menu(menu);
 
     sms_disconnect();
     exit(0);
 }
 
-/*     Function Name: error_exit
+/*     Function Name: ErrorExit
  *     Description: This function does the error handling and exits.
  *     Arguments: buf - the error message to print.
  *                 status - the error code.
@@ -110,9 +136,9 @@ main(argc, argv)
  */
 
 static void
-error_exit(buf,status);
+ErrorExit(buf,status)
 int status;
-char * whoami, *buf;    
+char * buf;    
 {
     com_err(program_name, status, buf);
     sms_disconnect();
@@ -126,20 +152,21 @@ char * whoami, *buf;
  */
 
 static void
-usage()
+Usage()
 {
     fprintf(stderr, "Usage: %s [-nomenu]\n", program_name);
     exit(1);
 }
 
-/*     Function Name: signal_handler
+#ifndef DEBUG
+/*     Function Name: SignalHandler
  *     Description: This function cleans up from a signal interrupt.
  *     Arguments: none.
  *     Returns: doesn't
  */
 
-static int *
-signal_handler()
+static void
+SignalHandler()
 {
     Put_message("Signal caught - exiting");
     if (use_menu)
@@ -147,3 +174,4 @@ signal_handler()
     sms_disconnect();
     exit(1);
 }
+#endif DEBUG
This page took 0.040578 seconds and 4 git commands to generate.