1 #if (!defined(lint) && !defined(SABER))
2 static char rcsid_module_c[] = "$Header$";
5 /* This is the file main.c for the SMS Client, which allows a nieve
6 * user to quickly and easily maintain most parts of the SMS database.
7 * It Contains: The main driver for the SMS Client.
10 * By: Chris D. Peterson
16 * Copyright 1988 by the Massachusetts Institute of Technology.
18 * For further information on copyright and distribution
19 * see the file mit-copyright.h
26 #include <sys/types.h>
30 #include "mit-copyright.h"
35 char * whoami; /* used by menu.c ugh!!! */
37 extern Menu sms_top_menu, list_menu, user_menu, dcm_menu;
40 static void SignalHandler();
43 static void ErrorExit(), Usage();
46 struct passwd *getpwuid();
48 Bool use_menu = TRUE; /* whether or not we are using a menu. */
50 /* Function Name: main
51 * Description: The main driver for the SMS Client.
52 * Arguments: argc, argv - standard command line args.
53 * Returns: doesn't return.
64 if ((user = getlogin()) == NULL)
65 user = getpwuid((int) getuid())->pw_name;
66 user = (user && strlen(user)) ? Strsave(user) : "";
68 if ((program_name = rindex(argv[0], '/')) == NULL)
69 program_name = argv[0];
72 program_name = Strsave(program_name);
73 whoami = Strsave(program_name); /* used by menu.c, ugh !!! */
79 if (strcmp(argv[1], "-nomenu") == 0)
91 if ( status = sms_connect(SMS_SERVER) )
92 ErrorExit("\nConnection to SMS server failed", status);
94 if ( status = sms_auth(program_name) )
95 ErrorExit("\nAuthorization failed -- please run kinit", status);
98 * These signals should not be set until just before we fire up the menu
103 (void) signal(SIGHUP, SignalHandler);
104 (void) signal(SIGINT, SignalHandler);
105 (void) signal(SIGQUIT, SignalHandler);
108 if (!strcmp(program_name, "listmaint"))
110 else if (!strcmp(program_name, "usermaint"))
112 else if (!strcmp(program_name, "dcmmaint"))
115 menu = &sms_top_menu;
117 if (use_menu) { /* Start menus that execute program */
122 else /* Start program without menus. */
129 /* Function Name: ErrorExit
130 * Description: This function does the error handling and exits.
131 * Arguments: buf - the error message to print.
132 * status - the error code.
133 * Returns: doesn't return.
137 ErrorExit(buf,status)
141 com_err(program_name, status, buf);
146 /* Function Name: usage
147 * Description: Prints usage info and then exits.
149 * Returns: doesn't return.
155 fprintf(stderr, "Usage: %s [-nomenu]\n", program_name);
160 /* Function Name: SignalHandler
161 * Description: This function cleans up from a signal interrupt.
169 Put_message("Signal caught - exiting");