annotate lcdemu/main.c @ 903:312778104f54

lcdemu started, compiles and runs w/o actual functionality
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 07 Sep 2015 08:34:37 +0000
parents
children 69623c4cbf6c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
903
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * LCDemu main module
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 */
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/errno.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <X11/Xlib.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 #include <X11/Xresource.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 #include <X11/Xutil.h>
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "globals.h"
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 main(argc, argv)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 char **argv;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 XrmInitialize();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 process_cmdline(argc, argv);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 open_display();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 load_resources();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 create_our_window();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 set_initial_window_title();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 set_initial_icon_name();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 create_mainwin_gc();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 XMapWindow(mydisplay, mainwindow);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 XFlush(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 mainloop();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 /* NOTREACHED */
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 process_cmdline(argc, argv)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 char **argv;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 register char **ap, *opt;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 char *rhost, *ruser;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 int len;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 if (argc < 1) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 fprintf(stderr, "fc-lcdemu: invalid invokation\n");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 opt = rindex(argv[0], '/');
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 if (opt)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 progbasename = opt + 1;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 else
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 progbasename = argv[0];
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 proginstancename = progbasename;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 for (ap = argv+1; *ap; ) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 if (**ap == '-')
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 opt = *ap++;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 else
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 break;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 if (!strcmp(opt, "-display")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 if (!*ap) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 argreq: fprintf(stderr, "%s: %s requires an argument\n",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 progbasename, opt);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 mydisplayname = *ap++;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 if (!strcmp(opt, "-name")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 proginstancename = *ap++;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 if (!strcmp(opt, "-geometry") || !strcmp(opt, "-geom")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 XrmPutStringResource(&xrmdb_cmdline, "LCDemu.geometry",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 if (!strcmp(opt, "-iconic")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 XrmPutStringResource(&xrmdb_cmdline, "LCDemu.iconic",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 "on");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 if (!strcmp(opt, "-title")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 XrmPutStringResource(&xrmdb_cmdline, "LCDemu.title",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 if (!strcmp(opt, "-borderwidth") || !strcmp(opt, "-bw")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
92 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 XrmPutStringResource(&xrmdb_cmdline, "*borderWidth",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
95 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
96 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
97 if (!strcmp(opt, "-bordercolor") || !strcmp(opt, "-bd")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
98 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
99 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
100 XrmPutStringResource(&xrmdb_cmdline, "*borderColor",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
101 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
102 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
103 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
104 if (!strcmp(opt, "-xrm")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
105 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
106 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
107 XrmPutLineResource(&xrmdb_cmdline, *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
108 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
109 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
110 fprintf(stderr, "%s: %s: unrecognized option\n", progbasename,
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
111 opt);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
112 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
113 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
114 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
115
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
116 open_display()
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
117 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
118 if (!mydisplayname)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
119 mydisplayname = getenv("DISPLAY");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
120 if (!mydisplayname) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
121 fprintf(stderr, "%s: no X display available\n", progbasename);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
122 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
123 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
124 mydisplay = XOpenDisplay(mydisplayname);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
125 if (!mydisplay) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
126 fprintf(stderr, "%s: unable to open display %s\n", progbasename,
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
127 mydisplayname);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
128 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
129 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
130 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
131
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
132 mainloop()
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
133 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
134 register int i, cc;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
135 XEvent event;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
136 fd_set readfds;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
137 int maxfd;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
138 char buf[1024];
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
139
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
140 maxfd = ConnectionNumber(mydisplay) + 1;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
141 for (;;) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
142 cc = XPending(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
143 for (i = 0; i < cc; i++)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
144 XNextEvent(mydisplay, &event);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
145 XFlush(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
146 FD_ZERO(&readfds);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
147 FD_SET(0, &readfds);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
148 FD_SET(ConnectionNumber(mydisplay), &readfds);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
149 i = select(maxfd, &readfds, NULL, NULL, NULL);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
150 if (i < 0) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
151 if (errno == EINTR)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
152 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
153 perror("select");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
154 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
155 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
156 if (FD_ISSET(0, &readfds)) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
157 cc = read(0, buf, sizeof buf);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
158 if (cc > 0)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
159 input_on_stdin(buf, cc);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
160 else
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
161 exit(0);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
162 XFlush(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
163 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
164 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
165 }