]>
Commit | Line | Data |
---|---|---|
c4095074 | 1 | /* $Header$ |
2 | * | |
3 | * Copyright 1991 by the Massachusetts Institute of Technology. | |
4 | * | |
5 | * For further information on copyright and distribution | |
6 | * see the file mit-copyright.h | |
7 | */ | |
8 | ||
9 | #include <mit-copyright.h> | |
10 | #include <stdio.h> | |
11 | #include <moira.h> | |
12 | #include <Xm/PushB.h> | |
13 | #include <Xm/BulletinB.h> | |
14 | #include "mmoira.h" | |
15 | ||
16 | extern MenuItem MenuRoot; | |
17 | ||
892c98b2 | 18 | Widget CreateMenu(), CreateForm(); |
c4095074 | 19 | Widget BuildMenuTree(); |
892c98b2 | 20 | void popup_error_hook(); |
c4095074 | 21 | |
22 | Widget toplevel; | |
23 | char *user, *program_name, *moira_server; | |
24 | ||
25 | main(argc, argv) | |
26 | int argc; | |
27 | char *argv[]; | |
28 | { | |
892c98b2 | 29 | Widget button, bboard, menuwidget; |
c4095074 | 30 | int n; |
31 | ||
32 | user = "mar"; | |
33 | program_name = argv[0]; | |
34 | moira_server = ""; | |
35 | ||
36 | mr_connect(moira_server); | |
37 | mr_auth("mmoira"); | |
38 | ||
39 | toplevel = XtInitialize("toplevel", "Moira", NULL, 0, | |
40 | &argc, argv); | |
41 | ||
42 | bboard = XtCreateManagedWidget( "bboard", | |
43 | xmBulletinBoardWidgetClass, | |
44 | toplevel, NULL, 0); | |
c4095074 | 45 | menuwidget = BuildMenuTree(bboard, &MenuRoot); |
892c98b2 | 46 | SetupLogWidget(bboard); |
c4095074 | 47 | |
48 | XtRealizeWidget(toplevel); | |
49 | ||
892c98b2 | 50 | set_com_err_hook(popup_error_hook); |
c4095074 | 51 | XtMainLoop(); |
52 | } | |
53 | ||
c4095074 | 54 | |
55 | int MoiraQuery(query, argc, argv, callback, data) | |
56 | char *query; | |
57 | int argc; | |
58 | char **argv; | |
59 | int (*callback)(); | |
60 | caddr_t data; | |
61 | { | |
62 | int status; | |
63 | ||
892c98b2 | 64 | MakeWatchCursor(); |
c4095074 | 65 | status = mr_query(query, argc, argv, callback, data); |
892c98b2 | 66 | if (status != MR_ABORTED && status != MR_NOT_CONNECTED) { |
67 | MakeNormalCursor(); | |
68 | return(status); | |
69 | } | |
c4095074 | 70 | status = mr_connect(moira_server); |
71 | if (status) { | |
72 | com_err(program_name, status, " while re-connecting to server %s", | |
73 | moira_server); | |
892c98b2 | 74 | MakeNormalCursor(); |
c4095074 | 75 | return(MR_ABORTED); |
76 | } | |
77 | status = mr_auth("mmoira"); | |
78 | if (status) { | |
79 | com_err(program_name, status, " while re-authenticating to server %s", | |
80 | moira_server); | |
81 | mr_disconnect(); | |
892c98b2 | 82 | MakeNormalCursor(); |
c4095074 | 83 | return(MR_ABORTED); |
84 | } | |
85 | status = mr_query(query, argc, argv, callback, data); | |
892c98b2 | 86 | MakeNormalCursor(); |
c4095074 | 87 | return(status); |
88 | ||
89 | } | |
892c98b2 | 90 | |
91 | ||
92 | DisplayForm(spec) | |
93 | EntryForm *spec; | |
94 | { | |
95 | Widget w; | |
96 | ||
97 | w = CreateForm(toplevel, spec); | |
98 | XtManageChild(w); | |
99 | } | |
100 | ||
101 | ||
102 | void popup_error_hook(who, code, fmt, arg1, arg2, arg3, arg4, arg5) | |
103 | char *who; | |
104 | long code; | |
105 | char *fmt; | |
106 | caddr_t arg1, arg2, arg3, arg4, arg5; | |
107 | { | |
108 | char buf[BUFSIZ], *cp; | |
109 | ||
110 | (void) strcpy(buf, who); | |
111 | for (cp = buf; *cp; cp++); | |
112 | *cp++ = ':'; | |
113 | *cp++ = ' '; | |
114 | if (code) { | |
115 | (void) strcpy(cp, error_message(code)); | |
116 | while (*cp) | |
117 | cp++; | |
118 | } | |
119 | sprintf(cp, fmt, arg1, arg2, arg3, arg4, arg5); | |
120 | display_error(buf); | |
121 | } |