10 |
|
* Jan 1990 |
11 |
|
*/ |
12 |
|
|
13 |
< |
#include <stdio.h> |
14 |
< |
#include <math.h> |
13 |
> |
#include "standard.h" |
14 |
|
#include <sys/ioctl.h> |
16 |
– |
#include <fcntl.h> |
15 |
|
#ifdef sparc |
16 |
|
#include <sys/conf.h> |
17 |
|
#include <sys/file.h> |
112 |
|
/* open display server */ |
113 |
|
ourdisplay = XOpenDisplay(NULL); |
114 |
|
if (ourdisplay == NULL) { |
115 |
< |
stderr_v("cannot open X-windows; DISPLAY variable set?\n"); |
115 |
> |
eputs("cannot open X-windows; DISPLAY variable set?\n"); |
116 |
|
return(NULL); |
117 |
|
} |
118 |
|
/* find a usable visual */ |
127 |
|
ourvinfo.blue_mask ; |
128 |
|
} else { |
129 |
|
if (nplanes < 4) { |
130 |
< |
stderr_v("not enough colors\n"); |
130 |
> |
eputs("not enough colors\n"); |
131 |
|
return(NULL); |
132 |
|
} |
133 |
|
if (!XMatchVisualInfo(ourdisplay,ourscreen, |
134 |
|
nplanes,PseudoColor,&ourvinfo) && |
135 |
|
!XMatchVisualInfo(ourdisplay,ourscreen, |
136 |
|
nplanes,GrayScale,&ourvinfo)) { |
137 |
< |
stderr_v("unsupported visual type\n"); |
137 |
> |
eputs("unsupported visual type\n"); |
138 |
|
return(NULL); |
139 |
|
} |
140 |
|
ourblack = BlackPixel(ourdisplay,ourscreen); |
152 |
|
else /* "x11d" */ { |
153 |
|
comheight = 0; |
154 |
|
#ifndef FNDELAY |
155 |
< |
stderr_v("warning: x11d driver not fully functional on this machine\n"); |
155 |
> |
eputs("warning: x11d driver not fully functional on this machine\n"); |
156 |
|
#endif |
157 |
|
} |
158 |
|
/* open window */ |
167 |
|
BORWIDTH, ourvinfo.depth, InputOutput, ourvinfo.visual, |
168 |
|
CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr); |
169 |
|
if (gwind == 0) { |
170 |
< |
stderr_v("cannot create window\n"); |
170 |
> |
eputs("cannot create window\n"); |
171 |
|
return(NULL); |
172 |
|
} |
173 |
|
XStoreName(ourdisplay, gwind, id); |
196 |
|
if (comheight) { |
197 |
|
x11_driver.comin = x11_comin; |
198 |
|
x11_driver.comout = x11_comout; |
199 |
< |
cmdvec = x11_comout; |
200 |
< |
if (wrnvec != NULL) |
201 |
< |
wrnvec = x11_errout; |
199 |
> |
erract[COMMAND].pf = x11_comout; |
200 |
> |
if (erract[WARNING].pf != NULL) |
201 |
> |
erract[WARNING].pf = x11_errout; |
202 |
|
inpcheck = IC_X11; |
203 |
|
} else { |
204 |
|
x11_driver.comin = std_comin; |
205 |
|
x11_driver.comout = std_comout; |
206 |
< |
cmdvec = std_comout; |
206 |
> |
erract[COMMAND].pf = std_comout; |
207 |
|
inpcheck = IC_IOCTL; |
208 |
|
} |
209 |
|
return(&x11_driver); |
213 |
|
static |
214 |
|
x11_close() /* close our display */ |
215 |
|
{ |
216 |
< |
cmdvec = NULL; /* reset error vectors */ |
217 |
< |
if (wrnvec != NULL) |
218 |
< |
wrnvec = stderr_v; |
216 |
> |
erract[COMMAND].pf = NULL; /* reset error vectors */ |
217 |
> |
if (erract[WARNING].pf != NULL) |
218 |
> |
erract[WARNING].pf = wputs; |
219 |
|
if (ourdisplay == NULL) |
220 |
|
return; |
221 |
|
if (comline != NULL) { |
256 |
|
/* reinitialize color table */ |
257 |
|
if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale) |
258 |
|
if (getpixels() == 0) |
259 |
< |
stderr_v("cannot allocate colors\n"); |
259 |
> |
eputs("cannot allocate colors\n"); |
260 |
|
else |
261 |
|
new_ctab(ncolors); |
262 |
|
/* get new command line */ |
266 |
|
comline = xt_open(ourdisplay, gwind, 0, gheight, gwidth, |
267 |
|
comheight, 0, ourblack, ourwhite, COMFN); |
268 |
|
if (comline == NULL) { |
269 |
< |
stderr_v("cannot open command line window\n"); |
269 |
> |
eputs("cannot open command line window\n"); |
270 |
|
quit(1); |
271 |
|
} |
272 |
|
XSelectInput(ourdisplay, comline->w, ExposureMask); |
316 |
|
if (1) { |
317 |
|
#endif |
318 |
|
if (fcntl(fileno(stdin), F_SETFL, FNDELAY) < 0) { |
319 |
< |
stderr_v("cannot change input mode\n"); |
319 |
> |
eputs("cannot change input mode\n"); |
320 |
|
quit(1); |
321 |
|
} |
322 |
|
inpcheck = IC_READ; |
354 |
|
x11_comout(outp) /* output a string to command line */ |
355 |
|
char *outp; |
356 |
|
{ |
357 |
< |
if (comline == NULL) |
357 |
> |
if (comline == NULL || outp == NULL || !outp[0]) |
358 |
|
return; |
359 |
|
xt_puts(outp, comline); |
360 |
|
if (outp[strlen(outp)-1] == '\n') |
366 |
|
x11_errout(msg) /* output an error message */ |
367 |
|
char *msg; |
368 |
|
{ |
369 |
< |
stderr_v(msg); /* send to stderr also! */ |
369 |
> |
eputs(msg); /* send to stderr also! */ |
370 |
|
x11_comout(msg); |
371 |
|
} |
372 |
|
|
386 |
|
#ifdef FNDELAY |
387 |
|
if (inpcheck == IC_READ) { /* turn off FNDELAY */ |
388 |
|
if (fcntl(fileno(stdin), F_SETFL, 0) < 0) { |
389 |
< |
stderr_v("cannot change input mode\n"); |
389 |
> |
eputs("cannot change input mode\n"); |
390 |
|
quit(1); |
391 |
|
} |
392 |
|
inpcheck = IC_IOCTL; |
567 |
|
if (ourvinfo.class == PseudoColor || |
568 |
|
ourvinfo.class == GrayScale) |
569 |
|
if (getpixels() == 0) |
570 |
< |
stderr_v("cannot allocate colors\n"); |
570 |
> |
eputs("cannot allocate colors\n"); |
571 |
|
else |
572 |
|
new_ctab(ncolors); |
573 |
|
mapped = 1; |