annotate lcdemu/main.c @ 911:42719fa3e6af

etmsync: memory read implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Tue, 08 Sep 2015 07:52:29 +0000
parents 69623c4cbf6c
children
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();
906
69623c4cbf6c lcdemu: image conversion implemented for X11 depth 24
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 903
diff changeset
22 init_image_conversion();
903
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 load_resources();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 create_our_window();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 set_initial_window_title();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 set_initial_icon_name();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 create_mainwin_gc();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 XMapWindow(mydisplay, mainwindow);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 XFlush(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 mainloop();
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 /* NOTREACHED */
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
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 process_cmdline(argc, argv)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 char **argv;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 register char **ap, *opt;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 char *rhost, *ruser;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 int len;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 if (argc < 1) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 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
44 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 opt = rindex(argv[0], '/');
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 if (opt)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 progbasename = opt + 1;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 else
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 progbasename = argv[0];
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 proginstancename = progbasename;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 for (ap = argv+1; *ap; ) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 if (**ap == '-')
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 opt = *ap++;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 else
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 break;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 if (!strcmp(opt, "-display")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 if (!*ap) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 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
60 progbasename, opt);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 mydisplayname = *ap++;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 if (!strcmp(opt, "-name")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 proginstancename = *ap++;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 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
73 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 XrmPutStringResource(&xrmdb_cmdline, "LCDemu.geometry",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 if (!strcmp(opt, "-iconic")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 XrmPutStringResource(&xrmdb_cmdline, "LCDemu.iconic",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 "on");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 if (!strcmp(opt, "-title")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 XrmPutStringResource(&xrmdb_cmdline, "LCDemu.title",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 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
92 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 XrmPutStringResource(&xrmdb_cmdline, "*borderWidth",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
95 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
96 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
97 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
98 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
99 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
100 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
101 XrmPutStringResource(&xrmdb_cmdline, "*borderColor",
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
102 *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
103 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
104 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
105 if (!strcmp(opt, "-xrm")) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
106 if (!*ap)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
107 goto argreq;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
108 XrmPutLineResource(&xrmdb_cmdline, *ap++);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
109 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
110 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
111 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
112 opt);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
113 exit(1);
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
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
117 open_display()
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
118 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
119 if (!mydisplayname)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
120 mydisplayname = getenv("DISPLAY");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
121 if (!mydisplayname) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
122 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
123 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
124 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
125 mydisplay = XOpenDisplay(mydisplayname);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
126 if (!mydisplay) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
127 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
128 mydisplayname);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
129 exit(1);
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
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
133 mainloop()
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
134 {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
135 register int i, cc;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
136 XEvent event;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
137 fd_set readfds;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
138 int maxfd;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
139 char buf[1024];
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
140
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
141 maxfd = ConnectionNumber(mydisplay) + 1;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
142 for (;;) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
143 cc = XPending(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
144 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
145 XNextEvent(mydisplay, &event);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
146 XFlush(mydisplay);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
147 FD_ZERO(&readfds);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
148 FD_SET(0, &readfds);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
149 FD_SET(ConnectionNumber(mydisplay), &readfds);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
150 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
151 if (i < 0) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
152 if (errno == EINTR)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
153 continue;
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
154 perror("select");
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
155 exit(1);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
156 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
157 if (FD_ISSET(0, &readfds)) {
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
158 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
159 if (cc > 0)
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
160 input_on_stdin(buf, cc);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
161 else
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
162 exit(0);
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
163 XFlush(mydisplay);
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 }
312778104f54 lcdemu started, compiles and runs w/o actual functionality
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
166 }