-
Notifications
You must be signed in to change notification settings - Fork 0
/
thebarber.c
73 lines (53 loc) · 1.38 KB
/
thebarber.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Command.h>
#define callbackfn(xray) void xray (Widget w, XtPointer client, XtPointer call)
callbackfn( barber_callback );
char *globaluselesspointer;
int main(int argc, char **argv) {
/* items referred to by these names vary in function main */
Widget toplevel, barber_button;
auto int user_error=0;
/* */
/* user error check */
if(argc < 3) {
/* the user had a problem entering the command line */
printf("Problem running the barber. Recompile. Running anyway.");
user_error = 1;
}
/*
mental note: argv[1] is button blaspheme
argv[2] is system command
*/
toplevel = XtInitialize(
argv[0],
"thebarber",
NULL,
0,
&argc,
argv
);
if( user_error == 0 ) {
/* assume the user knew what he was entering */
globaluselesspointer = argv[2];
} else {
/* assume user wants to run more copies of the barber */
globaluselesspointer = argv[0];
}
barber_button = XtVaCreateManagedWidget (
"I AM THE BARBER",
commandWidgetClass,
toplevel,
XtNlabel, argv[1],
NULL,
0
);
/* end of useless definitions */
XtAddCallback(barber_button, XtNcallback, barber_callback, NULL);
XtRealizeWidget(toplevel);
XtMainLoop();
}
callbackfn( barber_callback )
{
system(globaluselesspointer); /* god damn you! */
}