home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / vms / 12934 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  32.7 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!mp.cs.niu.edu!fnnews!SNYDER
  2. From: SNYDER@d0sb10.fnal.gov
  3. Newsgroups: comp.os.vms
  4. Subject: Re: GNUPLOT_X11 for VMS???
  5. Message-ID: <SNYDER.92Jul29220321@d0sb10.fnal.gov>
  6. Date: 30 Jul 92 04:03:20 GMT
  7. References: <1992Jul29.183132.1@cstp.umkc.edu>
  8. Sender: news@fnnews.fnal.gov
  9. Organization: Fermilab
  10. Lines: 1111
  11. Nntp-Posting-Host: d0sb10.fnal.gov
  12. In-reply-to: mckeever@cstp.umkc.edu's message of 30 Jul 92 00:31:32 GMT
  13.  
  14. In article <1992Jul29.183132.1@cstp.umkc.edu> mckeever@cstp.umkc.edu writes:
  15. >...  Has some kind soul who knows what they are doing with X11 and
  16. >C already got GNUPLOT_X11 running on a VMS machine?  And are you willing to
  17. >share?
  18.  
  19.  
  20. I hacked this up last week for gnuplot 3.2.  You should include `x11-vms.trm'
  21. instead of `x11.trm' in term.c.  Compile and link gnuplot and gnuplot_x11,
  22. and define the logical `gnuplot_dir' to point to the directory where gnuplot_x11.exe
  23. is located.  Then you should be set!
  24.  
  25. Caveat:  I've only tried to compile this with gcc.  I don't think there's anything
  26. which would cause problems for vaxc, though you may have to diddle
  27. some header files.
  28.  
  29. scott snyder
  30. snyder@d0sb10.fnal.gov
  31.  
  32.  
  33. $! ------------------ CUT HERE -----------------------
  34. $ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
  35. $!
  36. $! This archive created by VMS_SHARE Version 7.2-010  25-Jun-1992
  37. $!   On 29-JUL-1992 21:51:55.66   By user SNYDER 
  38. $!
  39. $! This VMS_SHARE Written by:
  40. $!    Andy Harper, Kings College London UK
  41. $!
  42. $! Acknowledgements to:
  43. $!    James Gray       - Original VMS_SHARE
  44. $!    Michael Bednarek - Original Concept and implementation
  45. $!
  46. $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
  47. $! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
  48. $!
  49. $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
  50. $!       1. GNUPLOT_X11.C;7
  51. $!       2. X11-VMS.TRM;5
  52. $!
  53. $set="set"
  54. $set symbol/scope=(nolocal,noglobal)
  55. $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
  56. $e="write sys$error  ""%UNPACK"", "
  57. $w="write sys$output ""%UNPACK"", "
  58. $ if f$trnlnm("SHARE_LOG") then $ w = "!"
  59. $ ve=f$getsyi("version")
  60. $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
  61. $ e "-E-OLDVER, Must run at least VMS 4.4"
  62. $ v=f$verify(v)
  63. $ exit 44
  64. $UNPACK: SUBROUTINE ! P1=filename, P2=checksum
  65. $ x = P1 - f$parse(P1,,,"version")
  66. $ y = f$search(x)
  67. $ if y .eqs. "" then $ goto file_absent
  68. $ x = f$integer(f$parse(P1,,,"version")-";")
  69. $ y = f$integer(f$parse(y,,,"version")-";")
  70. $ if x .gt. y then $ goto file_absent
  71. $ if f$mode() .eqs. "INTERACTIVE" then $ goto file_interactive
  72. $ if x .eq. y then e "-W-EXISTS, File ''P1' exists. Skipped."
  73. $ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists. Skipped."
  74. $file_delete:
  75. $ delete 'f'*
  76. $ exit
  77. $file_interactive:
  78. $ if x .eq. y then e "-W-EXISTS, File ''P1' exists."
  79. $ if x .ne. y then e "-W-NEWERVERSION, of File ''P1' exists."
  80. $ read/error=file_delete/end=file_delete-
  81.   /prompt="Create new version [y/n]: " -
  82.   sys$command x
  83. $ if .not. x then $ e "-W-SKIPPED, File ''P1' skipped."
  84. $ if .not. x then $ goto file_delete
  85. $ P1 = P1 - f$parse(P1,,,"version")
  86. $file_absent:
  87. $ if f$parse(P1) .nes. "" then $ goto dirok
  88. $ dn=f$parse(P1,,,"DIRECTORY")
  89. $ w "-I-CREDIR, Creating directory ''dn'."
  90. $ create/dir 'dn'
  91. $ if $status then $ goto dirok
  92. $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
  93. $ delete 'f'*
  94. $ exit
  95. $dirok:
  96. $ w "-I-PROCESS, Processing file ''P1'."
  97. $ if .not. f$verify() then $ define/user sys$output nl:
  98. $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
  99. PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
  100. SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
  101. CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
  102. LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
  103. BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
  104. IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
  105. MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
  106. ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
  107. 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
  108. POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
  109. ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
  110. COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
  111. "output_file"));ENDPROCEDURE;Unpacker;QUIT;
  112. $ delete/nolog 'f'*
  113. $ CHECKSUM 'P1'
  114. $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
  115. $ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
  116. $ ENDSUBROUTINE
  117. $START:
  118. $ create 'f'
  119. X#ifndef lint
  120. Xstatic char *RCSid = "$Id: gnuplot_x11.c,v 3.26 92/03/24 22:35:52 woo Exp Lo
  121. Vcker: woo $";
  122. X#endif
  123. X
  124. X/*--------------------------------------------------------------------------
  125. V---
  126. X *   gnuplot_x11 - X11 outboard terminal driver for gnuplot 3
  127. X *
  128. X *   Requires installation of companion inboard x11 driver in gnuplot/term.c
  129. X *
  130. X *   Acknowledgements:`20
  131. X *      Chris Peterson (MIT)
  132. X *      Dana Chee (Bellcore)`20
  133. X *      Arthur Smith (Cornell)
  134. X *      Hendri Hondorp (University of Twente, The Netherlands)
  135. X *      Bill Kucharski (Solbourne)
  136. X *      Charlie Kline (University of Illinois)
  137. X *      O'Reilly & Associates: X Window System - Volumes 1 & 2
  138. X *
  139. X * vms stuff - sss
  140. X *
  141. X *   This code is provided as is and with no warranties of any kind.
  142. X *      `20
  143. X *   Ed Kubaitis (ejk@uiuc.edu)
  144. X *   Computing & Communications Services Office`20
  145. X *   University of Illinois, Urbana
  146. X *--------------------------------------------------------------------------
  147. V-*/
  148. X
  149. X#include <X11/Xos.h>
  150. X#include <X11/Xlib.h>
  151. X#include <X11/Xutil.h>
  152. X#include <X11/Xatom.h>
  153. X#include <X11/Xresource.h>
  154. X`20
  155. X#include <stdio.h>
  156. X#include <signal.h>
  157. X
  158. X#ifndef VMS
  159. X#ifndef FD_SET
  160. X#ifndef OLD_SELECT
  161. X#include <sys/select.h>
  162. X#else   /* OLD_SELECT */
  163. X#define FD_SET(n, p)    ((p)->fds_bits`5B0`5D `7C= (1 << ((n) % 32)))
  164. X#define FD_CLR(n, p)    ((p)->fds_bits`5B0`5D &= `7E(1 << ((n) % 32)))
  165. X#define FD_ISSET(n, p)  ((p)->fds_bits`5B0`5D & (1 << ((n) % 32)))
  166. X#define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
  167. X#endif  /* OLD_SELECT */
  168. X#endif  /* FD_SET */
  169. X#endif  /* VMS */
  170. X
  171. X#include <errno.h>
  172. Xextern int errno;
  173. X
  174. X#define FallbackFont "fixed"
  175. X#define Ncolors 13
  176. Xunsigned long colors`5BNcolors`5D;
  177. X
  178. Xchar dashes`5B10`5D`5B5`5D = `7B `7B0`7D, `7B1,6,0`7D,`20
  179. X   `7B0`7D, `7B4,2,0`7D, `7B1,3,0`7D, `7B4,4,0`7D, `7B1,5,0`7D, `7B4,4,4,1,0
  180. V`7D, `7B4,2,0`7D, `7B1,3,0`7D
  181. X   `7D;
  182. X
  183. XDisplay *dpy; int scr; Window win, root;
  184. XVisual *vis; GC gc = (GC)0; Pixmap pixmap; XFontStruct *font;
  185. Xunsigned int W = 640, H = 450; int D, gX = 100, gY = 100;
  186. X
  187. XBool Mono = 0, Gray = 0, Rv = 0, Clear = 0;
  188. Xchar Name`5B64`5D = "gnuplot";
  189. Xchar Class`5B64`5D = "Gnuplot";
  190. X
  191. Xint cx=0, cy=0, vchar, nc = 0, ncalloc = 0;
  192. Xdouble xscale, yscale;
  193. X#define X(x) (int) (x * xscale)
  194. X#define Y(y) (int) ((4095-y) * yscale)
  195. Xenum JUSTIFY `7B LEFT, CENTRE, RIGHT `7D jmode;
  196. X
  197. X#define Nbuf 1024
  198. Xchar buf`5BNbuf`5D, **commands = (char **)0;
  199. X
  200. X#ifndef VMS
  201. XFILE *X11_ipc = stdin;
  202. Xchar X11_ipcpath`5B32`5D;
  203. X#endif
  204. X
  205. X
  206. X#ifdef VMS
  207. X
  208. XFILE *X11_ipc;
  209. X
  210. X#include <descrip.h>
  211. X#include <iodef.h>
  212. X#include <ssdef.h>
  213. X
  214. X/* channel to read from */
  215. Xshort vms_input_chan;
  216. X
  217. X/* event flag used to signal completion of the read.
  218. X   the flag must be in cluster 0, so $get_ef is kinda useless... */
  219. Xconst int vms_input_efn = 4;
  220. X
  221. X/* flag set when we reach eof on the input channel */
  222. Xint vms_input_eof = 0;
  223. X
  224. X/* an iosb for the read */
  225. Xstruct vms_iosb
  226. X`7B
  227. X  short status;
  228. X  short size;
  229. X  int   dum;
  230. X`7D vms_input_iosb;
  231. X
  232. X/* input buffer for read.
  233. X   the length of this buffer is limited by the size of the mailbox
  234. X   created in x11_vms.trm. */
  235. Xchar vms_input_buf`5B160`5D;
  236. X
  237. X/* check a vms return status and signal if there was an error */
  238. Xstatic int erck(int stat)
  239. X`7B
  240. X  if ((stat&1) == 0) lib$signal(stat);
  241. X  return stat;
  242. X`7D
  243. X
  244. X
  245. X/* start a read on the input channel into VMS_INPUT_BUF.
  246. X   event flag VMS_INPUT_EFN will be set when the read completes. */
  247. X
  248. Xvoid start_vms_input(void)
  249. X`7B
  250. X  erck( sys$qio(vms_input_efn, vms_input_chan, IO$_READVBLK, &vms_input_iosb
  251. V,
  252. X`09`090, 0, vms_input_buf, sizeof(vms_input_buf)-1,
  253. X`09`090, 0, 0, 0) );
  254. X`7D
  255. X
  256. X
  257. X/* when exiting, close our input channel and commit suicide.
  258. X   the somewhat drastic step of $delprc is taken to try to avoid the
  259. X   possibility of stranded processes. */
  260. X
  261. Xvoid vms_exit()
  262. X`7B
  263. X  erck( sys$dassgn(vms_input_chan) );
  264. X  erck( sys$delprc(0, 0) );
  265. X`7D
  266. X
  267. X
  268. X/* initialization: open a channel to sys$input, and start a read going on it
  269. V.
  270. X   also set up an exit handler which ensures that this process will die
  271. X   when this program exits. */
  272. X
  273. Xvoid vms_init(void)
  274. X`7B
  275. X  static int dum;
  276. X  static struct `7B
  277. X    int flink;
  278. X    void (*handler)();
  279. X    int count;
  280. X    int *condvalue;
  281. X  `7D exhblk = `7B0, vms_exit, 0, &dum`7D;
  282. X  $DESCRIPTOR(name_dsc, "SYS$INPUT");
  283. X
  284. X  erck( sys$assign(&name_dsc, &vms_input_chan, 0, 0) );
  285. X  start_vms_input();
  286. X  erck( sys$dclexh(&exhblk) );
  287. X`7D
  288. X
  289. X
  290. X/* this emulates fgets, but reads from our vms input channel instead of
  291. X   a C stream */
  292. X
  293. Xint vms_fgets(char *buf, int bufsiz, FILE *dum)
  294. X`7B
  295. X  int len;
  296. X
  297. X  /* if we've already hit eof, return 0 */
  298. X  if (vms_input_eof) return 0;
  299. X
  300. X  /* wait for the last read to complete */
  301. X  erck( sys$waitfr(vms_input_efn) );
  302. X
  303. X  /* if it returned eof status, return 0 and set the eof flag */
  304. X  if (vms_input_iosb.status == SS$_ENDOFFILE) `7B
  305. X    vms_input_eof = 1;
  306. X    return 0;
  307. X  `7D
  308. X  /* if it returned any other error, signal it */
  309. X  if ((vms_input_iosb.status & 1) == 0) lib$signal(vms_input_iosb.status);
  310. X
  311. X  /* copy the input buffer to the caller's buffer
  312. X     (or as much of it as will fit, anyway) */
  313. X
  314. X  len = vms_input_iosb.size;
  315. X  if (len > bufsiz-1) len = bufsiz-1;
  316. X  memcpy(buf, vms_input_buf, len);
  317. X  buf`5Blen`5D = '\0';
  318. X
  319. X  /* start another read on the channel */
  320. X  start_vms_input();
  321. X  return len;
  322. X`7D
  323. X
  324. X
  325. Xint gethostname (char *buf, int buflen)
  326. X`7B
  327. X  static char system_name_saved`5B32`5D;
  328. X  char *sp;
  329. X  extern char *getenv ();
  330. X  if ((sp = getenv ("SYS$NODE")) == 0)
  331. X    sp = "vax-vms";
  332. X
  333. X  /* vms likes to stick a leading underscore in front of the node
  334. X     name for some reason... */
  335. X  if (*sp == '_') ++sp;
  336. X  buf`5Bbuflen-1`5D = '\0';
  337. X  strncpy (buf, sp, buflen);
  338. X  if (strlen (sp) < buflen) buf`5Bstrlen (sp)`5D = '\0';
  339. X `20
  340. X  /* now hack off any trailing `60::' */
  341. X  `7B
  342. X    char *end;
  343. X   `20
  344. X    if ((end = index (buf, ':')) != 0)
  345. X      *end = '\0';
  346. X  `7D
  347. X  return 0;
  348. X`7D
  349. X
  350. X
  351. X/* define some macros to map the C input routines to our asynchronous
  352. X   vms input routines above */
  353. X
  354. X#define fgets vms_fgets
  355. X#ifdef feof
  356. X# undef feof
  357. X#endif
  358. X#define feof(dum) vms_input_eof
  359. X#ifdef ferror
  360. X# undef ferror
  361. X#endif
  362. X#define ferror(dum) 0
  363. X
  364. X#endif  /* VMS */
  365. X
  366. X/*--------------------------------------------------------------------------
  367. V---
  368. X *   main program`20
  369. X *--------------------------------------------------------------------------
  370. V-*/
  371. X
  372. Xmain(argc, argv) int argc; char *argv`5B`5D; `7B
  373. X#ifdef VMS
  374. X  vms_init ();
  375. X#endif
  376. X
  377. X   preset(argc, argv);
  378. X   mainloop();
  379. X   exit(0);
  380. X
  381. X   `7D
  382. X
  383. X/*--------------------------------------------------------------------------
  384. V---
  385. X *   mainloop - process X events and input from gnuplot
  386. X *
  387. X *   On systems with a fully implemented select(), select is used (without
  388. X *   timeout) to sense both input from the X server network connection and
  389. X *   pipe input from gnuplot. On platforms with an incomplete or faulty`20
  390. X *   select(), select (with timeout) is used for the server, and a temporary
  391. V`20
  392. X *   file rather than a pipe is used for gnuplot input.
  393. X *--------------------------------------------------------------------------
  394. V-*/
  395. X
  396. X#ifdef VMS
  397. X
  398. Xmainloop ()
  399. X`7B
  400. X  int ef_mask, stat, retval, rmask;
  401. X  XEvent xe;
  402. X
  403. X  ef_mask = 1 << vms_input_efn;
  404. X  while (1) `7B
  405. X    stat = XMultiplexInput (1, &dpy, ef_mask, 1000000, 0, &retval);
  406. X    while (XCheckMaskEvent (dpy, 0xffffffff, &xe)) `7B
  407. X      if (xe.type == ConfigureNotify) resize (&xe);
  408. X    `7D
  409. X    sys$readef (0, &rmask);
  410. X    if ((rmask & ef_mask) != 0) accept ();
  411. X  `7D
  412. X`7D
  413. X
  414. X#else /* not VMS */
  415. X
  416. Xmainloop() `7B
  417. X   int nf, nfds, cn = ConnectionNumber(dpy), in = fileno(X11_ipc);
  418. X   struct timeval timeout, *timer = (struct timeval *)0;
  419. X   fd_set rset, tset;
  420. X   unsigned long all = 0xffffffff;
  421. X   XEvent xe;
  422. X
  423. X   FD_ZERO(&rset);
  424. X   FD_SET(cn, &rset);
  425. X
  426. X#ifndef CRIPPLED_SELECT
  427. X   FD_SET(in, &rset);
  428. X   nfds = (cn > in) ? cn + 1 : in + 1;
  429. X#else  /* CRIPPLED_SELECT */
  430. X   timeout.tv_sec = 1;
  431. X   timeout.tv_usec = 0;
  432. X   timer = &timeout;
  433. X   sprintf(X11_ipcpath, "/tmp/Gnuplot_%d", getppid());
  434. X   nfds = cn + 1;
  435. X#endif /* CRIPPLED_SELECT */
  436. X
  437. X   while(1) `7B
  438. X      tset = rset;
  439. X      nf = select(nfds, &tset, (fd_set *)0, (fd_set *)0, timer);
  440. X      if (nf < 0) `7B
  441. X`09 if (errno == EINTR) continue;
  442. X`09 fprintf(stderr, "gnuplot: select failed. errno:%d\n", errno);
  443. X`09 exit(1);
  444. X`09 `7D
  445. X      nf > 0 && XNoOp(dpy);
  446. X      if (FD_ISSET(cn, &tset)) `7B
  447. X`09 while (XCheckMaskEvent(dpy, all, &xe)) `7B
  448. X`09    (xe.type == ConfigureNotify)  && resize(&xe);`20
  449. X`09    `7D
  450. X`09 `7D
  451. X#ifndef CRIPPLED_SELECT
  452. X      FD_ISSET(in, &tset) && accept();
  453. X#else  /* CRIPPLED_SELECT */
  454. X      if ((X11_ipc = fopen(X11_ipcpath, "r"))) `7B
  455. X`09 unlink(X11_ipcpath);
  456. X`09 accept();
  457. X`09 fclose(X11_ipc);
  458. X`09 `7D
  459. X#endif /* CRIPPLED_SELECT */
  460. X      `7D
  461. X   `7D
  462. X
  463. X#endif /* not VMS */
  464. X
  465. X/*--------------------------------------------------------------------------
  466. V---
  467. X *   accept - accept & record new plot from gnuplot inboard X11 driver
  468. X *--------------------------------------------------------------------------
  469. V-*/
  470. X
  471. Xaccept() `7B
  472. X
  473. X   while (fgets(buf, Nbuf, X11_ipc)) `7B
  474. X     if (*buf == 'G') `7B                           /* enter graphics mode *
  475. V/
  476. X`09 if (commands) `7B
  477. X`09    int n; for (n=0; n<nc; n++) free(commands`5Bn`5D);
  478. X`09    free(commands);
  479. X`09    `7D
  480. X`09 commands = (char **)0; nc = ncalloc = 0;
  481. X         `7D
  482. X      else if (*buf == 'E') `7B display(); break; `7D /* leave graphics mode
  483. V */
  484. X      else if (*buf == 'R') `7B exit(0); `7D          /* leave X11/x11 mode
  485. V  */
  486. X      else `7B                                      /* record command      *
  487. V/
  488. X`09 char *p;
  489. X`09 if (nc >= ncalloc) `7B
  490. X`09    ncalloc = ncalloc*2 + 1;
  491. X`09    commands = (commands)
  492. X`09       ? (char **)realloc(commands, ncalloc * sizeof(char *))
  493. X`09       : (char **)malloc(sizeof(char *));
  494. X`09    `7D
  495. X`09 p = (char *)malloc((unsigned)strlen(buf)+1);
  496. X`09 if (!commands `7C`7C !p) `7B
  497. X`09    fprintf(stderr, "gnuplot: can't get memory. X11 aborted.\n");
  498. X`09    exit(1);
  499. X`09    `7D
  500. X`09 commands`5Bnc++`5D = strcpy(p, buf);
  501. X`09 `7D
  502. X      `7D
  503. X   if (feof(X11_ipc) `7C`7C ferror(X11_ipc)) exit(1);
  504. X   `7D
  505. X
  506. X/*--------------------------------------------------------------------------
  507. V---
  508. X *   display - display last plot from gnuplot inboard X11 driver
  509. X *--------------------------------------------------------------------------
  510. V-*/
  511. X
  512. Xdisplay() `7B
  513. X   int n, x, y, sw, sl, lt, width, type;
  514. X   char *buf, *str;
  515. X
  516. X   if (!nc) return;
  517. X
  518. X   /* set scaling factor between internal driver & window geometry */
  519. X   xscale = (double)W / 4096.;  yscale = (double)H / 4096.; `20
  520. X
  521. X   /* create new pixmap & GC */
  522. X   if (gc) `7B XFreeGC(dpy, gc); XFreePixmap(dpy, pixmap); `7D
  523. X   pixmap = XCreatePixmap(dpy, root, W, H, D);
  524. X   gc = XCreateGC(dpy, pixmap, 0, (XGCValues *)0);
  525. X   XSetFont(dpy, gc, font->fid);
  526. X
  527. X   /* set pixmap background */
  528. X   XSetForeground(dpy, gc, colors`5B0`5D);
  529. X   XFillRectangle(dpy, pixmap, gc, 0, 0, W, H);
  530. X   XSetBackground(dpy, gc, colors`5B0`5D);
  531. X
  532. X   /* set new pixmap as window background */
  533. X   XSetWindowBackgroundPixmap(dpy, win, pixmap);
  534. X
  535. X   /* momentarily clear the window first if requested */
  536. X   if (Clear) `7B
  537. X      XClearWindow(dpy, win);
  538. X      XFlush(dpy);
  539. X      `7D
  540. X
  541. X   /* loop over accumulated commands from inboard driver */
  542. X   for (n=0; n<nc; n++) `7B
  543. X      buf = commands`5Bn`5D;
  544. X
  545. X      /*   X11_vector(x,y) - draw vector  */
  546. X      if (*buf == 'V') `7B`20
  547. X`09 sscanf(buf, "V%4d%4d", &x, &y); `20
  548. X`09 XDrawLine(dpy, pixmap, gc, X(cx), Y(cy), X(x), Y(y));
  549. X`09 cx = x; cy = y;
  550. X`09 `7D
  551. X
  552. X      /*   X11_move(x,y) - move  */
  553. X      else if (*buf == 'M')`20
  554. X`09 sscanf(buf, "M%4d%4d", &cx, &cy); `20
  555. X
  556. X      /*   X11_put_text(x,y,str) - draw text   */
  557. X      else if (*buf == 'T') `7B`20
  558. X`09 sscanf(buf, "T%4d%4d", &x, &y); `20
  559. X`09 str = buf + 9; sl = strlen(str) - 1;
  560. X`09 sw = XTextWidth(font, str, sl);
  561. X`09 switch(jmode) `7B
  562. X`09    case LEFT:   sw = 0;     break;
  563. X`09    case CENTRE: sw = -sw/2; break;
  564. X`09    case RIGHT:  sw = -sw;   break;
  565. X`09    `7D
  566. X`09 XSetForeground(dpy, gc, colors`5B2`5D);
  567. X`09 XDrawString(dpy, pixmap, gc, X(x)+sw, Y(y)+vchar/3, str, sl);
  568. X`09 XSetForeground(dpy, gc, colors`5Blt+3`5D);
  569. X`09 `7D
  570. X
  571. X      /*   X11_justify_text(mode) - set text justification mode  */
  572. X      else if (*buf == 'J')`20
  573. X`09 sscanf(buf, "J%4d", &jmode);
  574. X
  575. X      /*   X11_linetype(type) - set line type  */
  576. X      else if (*buf == 'L') `7B`20
  577. X`09 sscanf(buf, "L%4d", <);
  578. X`09 lt = (lt%8)+2;
  579. X`09 width = (lt == 0) ? 2 : 0;
  580. X`09 if (!Mono) `7B
  581. X`09    if (lt != 1)`20
  582. X`09       type = LineSolid;
  583. X`09    else `7B
  584. X`09       type = LineOnOffDash;
  585. X`09       XSetDashes(dpy, gc, 0, dashes`5Blt`5D, strlen(dashes`5Blt`5D));
  586. X`09       `7D
  587. X`09    XSetForeground(dpy, gc, colors`5Blt+3`5D);
  588. X`09    `7D
  589. X`09 else `7B
  590. X`09    type  = (lt == 0 `7C`7C lt == 2) ? LineSolid : LineOnOffDash;
  591. X`09    if (dashes`5Blt`5D`5B0`5D)
  592. X`09       XSetDashes(dpy, gc, 0, dashes`5Blt`5D, strlen(dashes`5Blt`5D));
  593. X`09    `7D
  594. X`09 XSetLineAttributes( dpy,gc, width, type, CapButt, JoinBevel);
  595. X`09 `7D
  596. X      `7D
  597. X
  598. X   /* trigger exposure of background pixmap */
  599. X   XClearWindow(dpy,win);
  600. X   XFlush(dpy);
  601. X   `7D
  602. X
  603. X/*--------------------------------------------------------------------------
  604. V---
  605. X *   resize - rescale last plot if window resized
  606. X *--------------------------------------------------------------------------
  607. V-*/
  608. X
  609. XBool init = True;
  610. X
  611. Xresize(xce) XConfigureEvent *xce; `7B
  612. X   if (!init `7C`7C xce->width != W `7C`7C xce->height != H) `7B
  613. X      W = xce->width; H = xce->height;
  614. X      display();
  615. X      init = True;
  616. X      `7D
  617. X   `7D
  618. X
  619. X
  620. X/*--------------------------------------------------------------------------
  621. V---
  622. X *   preset - determine options, open display, create window
  623. X *--------------------------------------------------------------------------
  624. V-*/
  625. X
  626. X#define On(v) ( !strcmp(v,"on") `7C`7C !strcmp(v,"true") `7C`7C \
  627. X`09`09!strcmp(v,"On") `7C`7C !strcmp(v,"True") )
  628. X
  629. X#define AppDefDir "/usr/lib/X11/app-defaults"
  630. X#ifndef MAXHOSTNAMELEN
  631. X#define MAXHOSTNAMELEN 64
  632. X#endif
  633. X
  634. Xstatic XrmDatabase dbCmd, dbApp, dbDef, dbEnv, db = (XrmDatabase)0;
  635. X
  636. Xchar *pr_GetR(), *getenv(), *type`5B20`5D;
  637. XXrmValue value;
  638. X
  639. X#define Nopt 25
  640. Xstatic XrmOptionDescRec options`5B`5D = `7B
  641. X   `7B"-mono",             ".mono",             XrmoptionNoArg,   "on" `7D,
  642. X   `7B"-gray",             ".gray",             XrmoptionNoArg,   "on" `7D,
  643. X   `7B"-clear",            ".clear",            XrmoptionNoArg,   "on" `7D,
  644. X   `7B"-display",          ".display",          XrmoptionSepArg,  NULL `7D,
  645. X   `7B"-name",             ".name",             XrmoptionSepArg,  NULL `7D,
  646. X   `7B"-geometry",         "*geometry",         XrmoptionSepArg,  NULL `7D,
  647. X   `7B"-background",       "*background",       XrmoptionSepArg,  NULL `7D,
  648. X   `7B"-bg",               "*background",       XrmoptionSepArg,  NULL `7D,
  649. X   `7B"-foreground",       "*foreground",       XrmoptionSepArg,  NULL `7D,
  650. X   `7B"-fg",               "*foreground",       XrmoptionSepArg,  NULL `7D,
  651. X   `7B"-bordercolor",      "*bordercolor",      XrmoptionSepArg,  NULL `7D,
  652. X   `7B"-bd",               "*bordercolor",      XrmoptionSepArg,  NULL `7D,
  653. X   `7B"-borderwidth",      ".borderwidth",      XrmoptionSepArg,  NULL `7D,
  654. X   `7B"-bw",               ".borderwidth",      XrmoptionSepArg,  NULL `7D,
  655. X   `7B"-font",             "*font",             XrmoptionSepArg,  NULL `7D,
  656. X   `7B"-fn",               "*font",             XrmoptionSepArg,  NULL `7D,
  657. X   `7B"-reverse",          "*reverseVideo",     XrmoptionNoArg,   "on" `7D,
  658. X   `7B"-rv",               "*reverseVideo",     XrmoptionNoArg,   "on" `7D,
  659. X   `7B"+rv",               "*reverseVideo",     XrmoptionNoArg,   "off"`7D,
  660. X   `7B"-iconic",           "*iconic",           XrmoptionNoArg,   "on" `7D,
  661. X   `7B"-synchronous",      "*synchronous",      XrmoptionNoArg,   "on" `7D,
  662. X   `7B"-xnllanguage",      "*xnllanguage",      XrmoptionSepArg,  NULL `7D,
  663. X   `7B"-selectionTimeout", "*selectionTimeout", XrmoptionSepArg,  NULL `7D,
  664. X   `7B"-title",            ".title",            XrmoptionSepArg,  NULL `7D,
  665. X   `7B"-xrm",              NULL,                XrmoptionResArg,  NULL `7D,
  666. X   `7D;
  667. X
  668. Xpreset(argc, argv) int argc; char *argv`5B`5D; `7B
  669. X   int Argc = argc; char **Argv = argv;
  670. X
  671. X   char *display = getenv("DISPLAY"),  *home = getenv("HOME");
  672. X   char *server_defaults, *env, buf`5B256`5D;
  673. X
  674. X   /*---set to ignore `5EC and `5EZ-----------------------------------------
  675. V-----*/
  676. X
  677. X   signal(SIGINT, SIG_IGN);
  678. X#ifdef SIGTSTP
  679. X   signal(SIGTSTP, SIG_IGN);
  680. X#endif
  681. X
  682. X   /*---prescan arguments for "-name"---------------------------------------
  683. V-*/
  684. X
  685. X   while(++Argv, --Argc > 0) `7B
  686. X      if (!strcmp(*Argv, "-name") && Argc > 1) `7B
  687. X`09 strncpy(Name, Argv`5B1`5D, 64);
  688. X`09 strncpy(Class, Argv`5B1`5D, 64);
  689. X`09 if (Class`5B0`5D >= 'a' && Class`5B0`5D <= 'z') Class`5B0`5D -= 0x20;
  690. X`09 `7D
  691. X      `7D
  692. X   Argc = argc; Argv = argv;
  693. X
  694. X   /*---parse command line--------------------------------------------------
  695. V-*/
  696. X
  697. X   XrmInitialize();
  698. X   XrmParseCommand(&dbCmd, options, Nopt, Name, &Argc, Argv);
  699. X   if (Argc > 1) `7B
  700. X      fprintf(stderr, "\ngnuplot: bad option: %s\n", Argv`5B1`5D);
  701. X      fprintf(stderr, "gnuplot: X11 aborted.\n");
  702. X      exit(1);
  703. X      `7D
  704. X   if (pr_GetR(dbCmd, ".display")) display = value.addr;
  705. X
  706. X   /*---open display--------------------------------------------------------
  707. V-*/
  708. X
  709. X   dpy = XOpenDisplay(display);`20
  710. X   if (!dpy) `7B
  711. X      fprintf(stderr, "\ngnuplot: unable to open display '%s'\n", display);
  712. X      fprintf(stderr, "gnuplot: X11 aborted.\n");
  713. X      exit(1);
  714. X      `7D
  715. X   scr = DefaultScreen(dpy);
  716. X   vis = DefaultVisual(dpy,scr);
  717. X   D = DefaultDepth(dpy,scr);
  718. X   root = DefaultRootWindow(dpy);
  719. X   server_defaults = XResourceManagerString(dpy);
  720. X
  721. X   /*---get application defaults--(subset of Xt processing)-----------------
  722. V-*/
  723. X
  724. X   sprintf(buf, "%s/%s", AppDefDir, "Gnuplot");
  725. X   dbApp = XrmGetFileDatabase(buf);
  726. X   XrmMergeDatabases(dbApp, &db);
  727. X
  728. X   /*---get server or `7E/.Xdefaults----------------------------------------
  729. V---*/
  730. X
  731. X   if (server_defaults)
  732. X      dbDef = XrmGetStringDatabase(server_defaults);
  733. X   else `7B
  734. X      sprintf(buf, "%s/.Xdefaults", home);
  735. X      dbDef = XrmGetFileDatabase(buf);
  736. X      `7D
  737. X   XrmMergeDatabases(dbDef, &db);
  738. X
  739. X   /*---get XENVIRONMENT or  `7E/.Xdefaults-hostname------------------------
  740. V---*/
  741. X
  742. X   if (env = getenv("XENVIRONMENT"))`20
  743. X      dbEnv = XrmGetFileDatabase(env);
  744. X   else `7B
  745. X      char *p, host`5BMAXHOSTNAMELEN`5D;
  746. X      if (gethostname(host, MAXHOSTNAMELEN) < 0) `7B
  747. X`09 fprintf(stderr, "gnuplot: gethostname failed. X11 aborted.\n");
  748. X`09 exit(1);
  749. X`09 `7D
  750. X      if (p = index(host, '.')) *p = '\0';
  751. X      sprintf(buf, "%s/.Xdefaults-%s", home, host);
  752. X      dbEnv = XrmGetFileDatabase(buf);
  753. X      `7D
  754. X   XrmMergeDatabases(dbEnv, &db);
  755. X
  756. X   /*---merge command line options------------------------------------------
  757. V-*/
  758. X
  759. X   XrmMergeDatabases(dbCmd, &db);
  760. X
  761. X   /*---determine geometry, font and colors---------------------------------
  762. V-*/
  763. X
  764. X   pr_geometry();
  765. X   pr_font();
  766. X   pr_color();
  767. X
  768. X   /*---create window-------------------------------------------------------
  769. V-*/
  770. X
  771. X   pr_window();
  772. X
  773. X   `7D`20
  774. X
  775. X/*--------------------------------------------------------------------------
  776. V---
  777. X *   pr_GetR - get resource from database using "-name" option (if any)
  778. X *--------------------------------------------------------------------------
  779. V-*/
  780. X
  781. Xchar *
  782. Xpr_GetR(db, resource) XrmDatabase db; char *resource; `7B
  783. X   char name`5B128`5D, class`5B128`5D, *rc;
  784. X
  785. X   strcpy(name, Name); strcat(name, resource);
  786. X   strcpy(class, Class); strcat(class, resource);
  787. X   rc = XrmGetResource(db, name, class, type, &value)
  788. X      ? (char *)value.addr`20
  789. X      : (char *)0;
  790. X   return(rc);
  791. X   `7D
  792. X
  793. X/*--------------------------------------------------------------------------
  794. V---
  795. X *   pr_color - determine color values
  796. X *--------------------------------------------------------------------------
  797. V-*/
  798. X
  799. Xchar color_keys`5BNcolors`5D`5B30`5D =   `7B`20
  800. X   "background", "bordercolor", "text", "border", "axis",`20
  801. X   "line1", "line2", "line3",  "line4",`20
  802. X   "line5", "line6", "line7",  "line8"`20
  803. X   `7D;
  804. Xchar color_values`5BNcolors`5D`5B30`5D = `7B`20
  805. X   "white", "black",  "black",  "black",  "black",`20
  806. X   "red",   "green",  "blue",   "magenta",`20
  807. X   "cyan",  "sienna", "orange", "coral"`20
  808. X   `7D;
  809. Xchar gray_values`5BNcolors`5D`5B30`5D = `7B`20
  810. X   "black",   "white",  "white",  "gray50", "gray50",
  811. X   "gray100", "gray60", "gray80", "gray40",`20
  812. X   "gray90",  "gray50", "gray70", "gray30"`20
  813. X   `7D;
  814. X
  815. Xpr_color() `7B
  816. X   unsigned long black = BlackPixel(dpy, scr), white = WhitePixel(dpy,scr);
  817. X   char option`5B20`5D, *v, *type = (Gray) ? "Gray" : "Color";
  818. X   XColor used, exact;
  819. X   Colormap cmap;
  820. X   int n;
  821. X
  822. X   pr_GetR(db, ".mono")         && On(value.addr) && Mono++;
  823. X   pr_GetR(db, ".gray")         && On(value.addr) && Gray++;
  824. X   pr_GetR(db, ".reverseVideo") && On(value.addr) && Rv++;
  825. X
  826. X   if (!Gray && (vis->class == GrayScale `7C`7C vis->class == StaticGray)) M
  827. Vono++;
  828. X
  829. X   if (!Mono) `7B
  830. X      cmap = DefaultColormap(dpy, scr);
  831. X      for (n=0; n<Ncolors; n++) `7B
  832. X`09 strcpy(option, ".");
  833. X`09 strcat(option, color_keys`5Bn`5D);
  834. X`09 (n > 1) && strcat(option, type);
  835. X`09 v = pr_GetR(db, option)`20
  836. X`09     ? value.addr
  837. X`09     : ((Gray) ? gray_values`5Bn`5D : color_values`5Bn`5D);
  838. X`09 if (XAllocNamedColor(dpy, cmap, v, &used, &exact))
  839. X`09    colors`5Bn`5D = used.pixel;
  840. X`09 else `7B
  841. X`09    fprintf(stderr, "\ngnuplot: can't allocate %s:%s\n", option, v);
  842. X`09    fprintf(stderr, "gnuplot: reverting to monochrome\n");
  843. X`09    Mono++; break;
  844. X`09    `7D
  845. X`09 `7D
  846. X      `7D
  847. X   if (Mono) `7B
  848. X      colors`5B0`5D = (Rv) ? black : white ;
  849. X      for (n=1; n<Ncolors; n++)  colors`5Bn`5D = (Rv) ? white : black;
  850. X      `7D
  851. X   `7D
  852. X
  853. X/*--------------------------------------------------------------------------
  854. V---
  855. X *   pr_font - determine font         `20
  856. X *--------------------------------------------------------------------------
  857. V-*/
  858. X
  859. Xpr_font() `7B
  860. X   char *fontname = pr_GetR(db, ".font");
  861. X
  862. X   if (!fontname) fontname = FallbackFont;
  863. X   font = XLoadQueryFont(dpy, fontname);
  864. X   if (!font) `7B
  865. X      fprintf(stderr, "\ngnuplot: can't load font '%s'\n", fontname);
  866. X      fprintf(stderr, "gnuplot: using font '%s' instead.\n", FallbackFont);
  867. X      font = XLoadQueryFont(dpy, FallbackFont);
  868. X      if (!font) `7B
  869. X`09 fprintf(stderr, "gnuplot: can't load font '%s'\n", FallbackFont);
  870. X`09 fprintf(stderr, "gnuplot: no useable font - X11 aborted.\n");
  871. X         exit(1);
  872. X`09 `7D
  873. X      `7D
  874. X   vchar = font->ascent + font->descent;
  875. X   `7D
  876. X
  877. X/*--------------------------------------------------------------------------
  878. V---
  879. X *   pr_geometry - determine window geometry     `20
  880. X *--------------------------------------------------------------------------
  881. V-*/
  882. X
  883. Xpr_geometry() `7B
  884. X   char *geometry = pr_GetR(db, ".geometry");
  885. X   int x, y, flags;
  886. X   unsigned int w, h;`20
  887. X
  888. X   if (geometry) `7B
  889. X      flags = XParseGeometry(geometry, &x, &y, &w, &h);
  890. X
  891. X      if (flags & WidthValue)  W = w;
  892. X      if (flags & HeightValue) H = h;
  893. X      if (flags & XValue) `7B
  894. X`09 if (flags & XNegative) x += DisplayWidth(dpy,scr);
  895. X`09 gX = x;
  896. X`09 `7D
  897. X      if (flags & YValue) `7B
  898. X`09 if (flags & YNegative) y += DisplayHeight(dpy,scr);
  899. X`09 gY = y;
  900. X`09 `7D
  901. X      `7D
  902. X   `7D
  903. X
  904. X/*--------------------------------------------------------------------------
  905. V---
  906. X *   pr_window - create window`20
  907. X *--------------------------------------------------------------------------
  908. V-*/
  909. X
  910. Xpr_window() `7B
  911. X   char *title =  pr_GetR(db, ".title");
  912. X   XSizeHints hints;
  913. X
  914. X   win = XCreateSimpleWindow(dpy, root, gX, gY, W, H, 2, colors`5B1`5D, colo
  915. Vrs`5B0`5D);
  916. X
  917. X   pr_GetR(db, ".clear") && On(value.addr) && Clear++;
  918. X
  919. X   hints.flags = PPosition;
  920. X   hints.x = gX; hints.y = gY;
  921. X   XSetNormalHints(dpy, win, &hints);
  922. X
  923. X   if (pr_GetR(db, ".iconic") && On(value.addr)) `7B
  924. X      XWMHints wmh;
  925. X
  926. X      wmh.flags = StateHint ;
  927. X      wmh.initial_state = IconicState;
  928. X      XSetWMHints(dpy, win, &wmh);
  929. X      `7D`20
  930. X
  931. X   XStoreName(dpy, win, ((title) ? title : Class));
  932. X
  933. X   XSelectInput(dpy, win, StructureNotifyMask);
  934. X   XMapWindow(dpy, win);
  935. X  `20
  936. X   `7D
  937. $ CALL UNPACK GNUPLOT_X11.C;7 1210028340
  938. $ create 'f'
  939. X/*
  940. X *    x11-vms.trm  --- inboard terminal driver for X11 (VMS version) - sss
  941. X */
  942. X
  943. X#define X11_XMAX 4096
  944. X#define X11_YMAX 4096
  945. X
  946. X/* approximations for typical font/screen sizes */
  947. X#define X11_VCHAR (X11_YMAX/25)`20
  948. X#define X11_HCHAR (X11_XMAX/100)`20
  949. X#define X11_VTIC (X11_YMAX/100)
  950. X#define X11_HTIC (X11_XMAX/150)
  951. X
  952. X#define X11_nopts 25
  953. Xchar X11_opts`5BX11_nopts`5D`5B20`5D = `7B
  954. X   "-mono", "-gray", "-clear",
  955. X   "-iconic", "-rv", "-reverse", "+rv", "-synchronous",`20
  956. X   "-display", "-geometry", "-bg", "-background", "-bd", "-bordercolor", "-b
  957. Vw",
  958. X   "-borderwidth", "-fg", "-foreground", "-fn", "-font", "-name",`20
  959. X   "-selectionTimeout", "-title", "-xnllanguage", "-xrm"`20
  960. X   `7D;
  961. Xint X11_optarg`5BX11_nopts`5D = `7B`20
  962. X   0, 0, 0,
  963. X   0, 0, 0, 0, 0,
  964. X   1, 1, 1, 1, 1, 1, 1,
  965. X   1, 1, 1, 1, 1, 1,`20
  966. X   1, 1, 1, 1
  967. X   `7D;
  968. X
  969. X/* command to start the outboard driver */
  970. Xchar X11_command`5B1024`5D= "mcr gnuplot_dir:gnuplot_x11 -name gnuplot";
  971. X
  972. X
  973. X/*   X11_args - scan gnuplot command line for standard X Toolkit options */
  974. X
  975. XX11_args(argc, argv) int argc; char *argv`5B`5D; `7B
  976. X   int nx11 = 0, n;
  977. X
  978. X   while(++argv, --argc > 0) `7B
  979. X      for (n=0; n<X11_nopts; n++) `7B
  980. X`09 if (!strcmp(*argv, X11_opts`5Bn`5D)) `7B
  981. X`09    strcat(X11_command, " ");
  982. X`09    strcat(X11_command, *argv);`20
  983. X`09    if (X11_optarg`5Bn`5D) `7B
  984. X`09       if (--argc <= 0) return(nx11);
  985. X`09       strcat(X11_command, " \"");
  986. X`09       strcat(X11_command, *++argv);`20
  987. X`09       strcat(X11_command, "\"");
  988. X`09       nx11++;
  989. X`09       `7D
  990. X`09    nx11++; break;
  991. X`09    `7D
  992. X`09 `7D
  993. X      if (n == X11_nopts) break;`20
  994. X      `7D
  995. X   return(nx11);
  996. X   `7D
  997. X
  998. X
  999. X#include <dvidef.h>
  1000. X#include <iodef.h>
  1001. X#include <descrip.h>
  1002. X#include <clidef.h>
  1003. X
  1004. X#define MSGSIZE 160
  1005. Xstatic int mbx_chan;
  1006. Xstatic int x11_on = 0;
  1007. X
  1008. Xint X11_reset ();
  1009. X
  1010. Xstatic int exh_retstat;
  1011. Xstatic struct `7B
  1012. X  int flink;
  1013. X  int (*handler)();
  1014. X  int count;
  1015. X  int *condvalue;
  1016. X`7D exhblk = `7B0, X11_reset, 0, &exh_retstat`7D;
  1017. X
  1018. Xint erck(int stat)
  1019. X`7B
  1020. X  if ((stat&1) == 0) lib$signal(stat);
  1021. X  return stat;
  1022. X`7D
  1023. X
  1024. Xvoid mbx_close(void)
  1025. X`7B
  1026. X  erck( sys$qio(0, mbx_chan, IO$_WRITEOF,
  1027. X`09`090, 0, 0, 0, 0, 0, 0, 0, 0) );
  1028. X  erck( sys$dassgn(mbx_chan) );
  1029. X`7D
  1030. X
  1031. Xvoid create_mbx (int *chan)
  1032. X`7B
  1033. X  erck( sys$crembx (0, chan, MSGSIZE, 2 * MSGSIZE, 0, 0, 0) );
  1034. X`7D
  1035. X
  1036. Xvoid vms_get_device_name(short chan, struct dsc$descriptor_s *dsc)
  1037. X`7B
  1038. X  int dum_DVI$_DEVNAM = DVI$_DEVNAM;
  1039. X
  1040. X  erck( lib$getdvi (&dum_DVI$_DEVNAM, &chan, 0, 0, dsc, &dsc->dsc$w_length)
  1041. V );
  1042. X`7D
  1043. X
  1044. XX11_init()`20
  1045. X`7B
  1046. X  int dum_CLI$M_NOWAIT = CLI$M_NOWAIT;
  1047. X  char inbuf`5B32`5D;
  1048. X  $DESCRIPTOR(indsc, inbuf);
  1049. X  $DESCRIPTOR(outdsc, "sys$output");
  1050. X  $DESCRIPTOR(cmddsc, "");
  1051. X  create_mbx(&mbx_chan);
  1052. X  vms_get_device_name(mbx_chan, &indsc);
  1053. X
  1054. X  cmddsc.dsc$w_length = strlen(X11_command);
  1055. X  cmddsc.dsc$a_pointer = X11_command;
  1056. X
  1057. X  erck( lib$spawn(&cmddsc, &indsc, &outdsc, &dum_CLI$M_NOWAIT) );
  1058. X
  1059. X  erck( sys$dclexh(&exhblk) );
  1060. X  x11_on = 1;
  1061. X`7D
  1062. X
  1063. Xvoid mbx_write(char *buf)
  1064. X`7B
  1065. X  erck( sys$qiow(0, mbx_chan, IO$_WRITEVBLK `7C IO$M_NOW,
  1066. X`09`09 0, 0, 0, buf, strlen(buf), 0, 0, 0, 0) );
  1067. X`7D
  1068. X
  1069. X
  1070. Xint X11_reset()
  1071. X`7B
  1072. X  if (x11_on) `7B
  1073. X    x11_on = 0;
  1074. X    erck( sys$canexh(&exhblk) );
  1075. X    mbx_write("R\n");
  1076. X    mbx_close();
  1077. X  `7D
  1078. X`7D
  1079. X
  1080. XX11_text() `7B mbx_write("E\n"); `7D
  1081. X
  1082. XX11_graphics() `7B mbx_write("G\n"); `7D
  1083. X
  1084. XX11_move(x,y) unsigned int x,y;
  1085. X`7B
  1086. X  char buf`5B12`5D;
  1087. X  sprintf(buf, "M%04d%04d\n", x, y);
  1088. X  mbx_write(buf);
  1089. X`7D
  1090. X
  1091. XX11_vector(x,y) unsigned int x,y;
  1092. X`7B
  1093. X  char buf`5B12`5D;
  1094. X  sprintf(buf, "V%04d%04d\n", x, y);
  1095. X  mbx_write(buf);
  1096. X`7D
  1097. X
  1098. XX11_linetype(lt) int lt;`20
  1099. X`7B
  1100. X  char buf`5B12`5D;
  1101. X  sprintf(buf, "L%04d\n", lt);
  1102. X  mbx_write(buf);
  1103. X`7D
  1104. X
  1105. XX11_put_text(x,y,str) unsigned int x,y; char str`5B`5D;
  1106. X`7B
  1107. X  extern void *malloc();
  1108. X  char *buf = (char *)malloc(strlen(str) + 12);
  1109. X  if (buf == NULL) abort();
  1110. X  sprintf(buf, "T%04d%04d%s\n", x, y, str);
  1111. X  mbx_write(buf);
  1112. X  free(buf);
  1113. X`7D
  1114. X
  1115. XX11_justify_text(mode) enum JUSTIFY mode;
  1116. X`7B
  1117. X  char buf`5B12`5D;
  1118. X  sprintf(buf, "J%04d\n", mode);
  1119. X  mbx_write(buf);
  1120. X  return(TRUE);
  1121. X`7D
  1122. $ CALL UNPACK X11-VMS.TRM;5 192512603
  1123. $ v=f$verify(v)
  1124. $ EXIT
  1125.