3 * Copyright 1991 by the Massachusetts Institute of Technology.
5 * For further information on copyright and distribution
6 * see the file mit-copyright.h
9 #include <mit-copyright.h>
13 #include <Xm/BulletinB.h>
16 extern MenuItem MenuRoot;
18 Widget CreateMenu(), CreateForm();
19 Widget BuildMenuTree();
20 void popup_error_hook(), mr_x_input();
23 char *user, *program_name, *moira_server;
29 Widget button, bboard, menuwidget;
33 if ((user = getlogin()) == NULL)
34 user = getpwuid((int) getuid())->pw_name;
35 user = (user && strlen(user)) ? Strsave(user) : "";
37 if ((program_name = rindex(argv[0], '/')) == NULL)
38 program_name = argv[0];
41 program_name = Strsave(program_name);
43 /* Need to parse command line argument here */
46 status = mr_connect(moira_server);
48 com_err(program_name, status, " connecting to server");
51 status = mr_motd(&motd);
53 com_err(program_name, status, " connecting to server");
57 fprintf(stderr, "The Moira server is currently unavailable:\n%s\n",
63 status = mr_auth("mmoira");
64 if (status == MR_USER_AUTH) {
66 com_err(program_name, status, "\nPress [RETURN] to continue");
69 if (status >= ERROR_TABLE_BASE_krb &&
70 status <= ERROR_TABLE_BASE_krb + 256)
71 com_err(program_name, status, "; authorization failed - please run kinit");
73 com_err(program_name, status, "; authorization failed");
77 toplevel = XtInitialize("toplevel", "Moira", NULL, 0,
80 bboard = XtCreateManagedWidget( "bboard",
81 xmBulletinBoardWidgetClass,
83 menuwidget = BuildMenuTree(bboard, &MenuRoot);
84 SetupLogWidget(bboard);
86 XtRealizeWidget(toplevel);
88 set_com_err_hook(popup_error_hook);
89 mr_set_alternate_input(ConnectionNumber(XtDisplay(toplevel)),
95 int MoiraQuery(query, argc, argv, callback, data)
104 MakeWatchCursor(toplevel);
105 status = mr_query(query, argc, argv, callback, data);
106 if (status != MR_ABORTED && status != MR_NOT_CONNECTED) {
107 MakeNormalCursor(toplevel);
110 status = mr_connect(moira_server);
112 com_err(program_name, status, " while re-connecting to server %s",
114 MakeNormalCursor(toplevel);
117 status = mr_auth("mmoira");
119 com_err(program_name, status, " while re-authenticating to server %s",
122 MakeNormalCursor(toplevel);
125 status = mr_query(query, argc, argv, callback, data);
126 MakeNormalCursor(toplevel);
137 w = CreateForm(toplevel, spec);
142 void popup_error_hook(who, code, fmt, arg1, arg2, arg3, arg4, arg5)
146 caddr_t arg1, arg2, arg3, arg4, arg5;
148 char buf[BUFSIZ], *cp;
150 (void) strcpy(buf, who);
151 for (cp = buf; *cp; cp++);
155 (void) strcpy(cp, error_message(code));
159 sprintf(cp, fmt, arg1, arg2, arg3, arg4, arg5);
168 XtAppNextEvent(_XtDefaultAppContext(), &event);
169 XtDispatchEvent(&event);