home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume1 / 8711 / microemacs-3.9 / 12 < prev    next >
Text File  |  1987-11-20  |  34KB  |  1,410 lines

  1. Article 89 of comp.sources.misc:
  2. Path: tut!osu-cis!cbosgd!mandrill!hal!ncoast!allbery
  3. From: nwd@j.cc.purdue.edu (Daniel Lawrence)
  4. Newsgroups: comp.sources.misc
  5. Subject: MicroEmacs 3.9 (Part 12 of 16)
  6. Message-ID: <5688@ncoast.UUCP>
  7. Date: 17 Nov 87 02:34:43 GMT
  8. Sender: allbery@ncoast.UUCP
  9. Lines: 1395
  10. Approved: allbery@ncoast.UUCP
  11. X-Archive: comp.sources.misc/microemacs-3.9/11
  12.  
  13. # This is a shar archive.
  14. # Remove everything above this line.
  15. # Run the file through sh, not csh.
  16. # (type `sh mes.12')
  17. # If you do not see the message
  18. #    `mes.12 completed!'
  19. # then the file was incomplete.
  20. echo extracting - tcap.c
  21. sed 's/^X//' > tcap.c << 'FRIDAY_NIGHT'
  22. X/*    tcap:    Unix V5, V7 and BS4.2 Termcap video driver
  23. X        for MicroEMACS
  24. X*/
  25. X
  26. X#define    termdef    1            /* don't define "term" external */
  27. X
  28. X#include <stdio.h>
  29. X#include    "estruct.h"
  30. X#include        "edef.h"
  31. X
  32. X#if TERMCAP
  33. X
  34. X#define    MARGIN    8
  35. X#define    SCRSIZ    64
  36. X#define    NPAUSE    10            /* # times thru update to pause */
  37. X#define BEL     0x07
  38. X#define ESC     0x1B
  39. X
  40. Xextern int      ttopen();
  41. Xextern int      ttgetc();
  42. Xextern int      ttputc();
  43. Xextern int    tgetnum();
  44. Xextern int      ttflush();
  45. Xextern int      ttclose();
  46. Xextern int    tcapkopen();
  47. Xextern int    tcapkclose();
  48. Xextern int      tcapmove();
  49. Xextern int      tcapeeol();
  50. Xextern int      tcapeeop();
  51. Xextern int      tcapbeep();
  52. Xextern int    tcaprev();
  53. Xextern int    tcapcres();
  54. Xextern int      tcapopen();
  55. Xextern int      tput();
  56. Xextern char     *tgoto();
  57. X#if    COLOR
  58. Xextern    int    tcapfcol();
  59. Xextern    int    tcapbcol();
  60. X#endif
  61. X
  62. X#define TCAPSLEN 315
  63. Xchar tcapbuf[TCAPSLEN];
  64. Xchar *UP, PC, *CM, *CE, *CL, *SO, *SE;
  65. X
  66. XTERM term = {
  67. X    NULL,    /* these four values are set dynamically at open time */
  68. X    NULL,
  69. X    NULL,
  70. X    NULL,
  71. X    MARGIN,
  72. X    SCRSIZ,
  73. X    NPAUSE,
  74. X        tcapopen,
  75. X        ttclose,
  76. X        tcapkopen,
  77. X        tcapkclose,
  78. X        ttgetc,
  79. X        ttputc,
  80. X        ttflush,
  81. X        tcapmove,
  82. X        tcapeeol,
  83. X        tcapeeop,
  84. X        tcapbeep,
  85. X        tcaprev,
  86. X        tcapcres
  87. X#if    COLOR
  88. X    , tcapfcol,
  89. X    tcapbcol
  90. X#endif
  91. X};
  92. X
  93. Xtcapopen()
  94. X
  95. X{
  96. X        char *getenv();
  97. X        char *t, *p, *tgetstr();
  98. X        char tcbuf[1024];
  99. X        char *tv_stype;
  100. X        char err_str[72];
  101. X
  102. X        if ((tv_stype = getenv("TERM")) == NULL)
  103. X        {
  104. X                puts("Environment variable TERM not defined!");
  105. X                exit(1);
  106. X        }
  107. X
  108. X        if ((tgetent(tcbuf, tv_stype)) != 1)
  109. X        {
  110. X                sprintf(err_str, "Unknown terminal type %s!", tv_stype);
  111. X                puts(err_str);
  112. X                exit(1);
  113. X        }
  114. X
  115. X       if ((term.t_nrow=(short)tgetnum("li")-1) == -1){
  116. X               puts("termcap entry incomplete (lines)");
  117. X               exit(1);
  118. X       }
  119. X    term.t_mrow =  term.t_nrow;
  120. X
  121. X       if ((term.t_ncol=(short)tgetnum("co")) == -1){
  122. X               puts("Termcap entry incomplete (columns)");
  123. X               exit(1);
  124. X       }
  125. X    term.t_mcol = term.t_ncol;
  126. X
  127. X        p = tcapbuf;
  128. X        t = tgetstr("pc", &p);
  129. X        if(t)
  130. X                PC = *t;
  131. X
  132. X        CL = tgetstr("cl", &p);
  133. X        CM = tgetstr("cm", &p);
  134. X        CE = tgetstr("ce", &p);
  135. X        UP = tgetstr("up", &p);
  136. X    SE = tgetstr("se", &p);
  137. X    SO = tgetstr("so", &p);
  138. X    if (SO != NULL)
  139. X        revexist = TRUE;
  140. X
  141. X        if(CL == NULL || CM == NULL || UP == NULL)
  142. X        {
  143. X                puts("Incomplete termcap entry\n");
  144. X                exit(1);
  145. X        }
  146. X
  147. X    if (CE == NULL)        /* will we be able to use clear to EOL? */
  148. X        eolexist = FALSE;
  149. X        
  150. X        if (p >= &tcapbuf[TCAPSLEN])
  151. X        {
  152. X                puts("Terminal description too big!\n");
  153. X                exit(1);
  154. X        }
  155. X        ttopen();
  156. X}
  157. X
  158. Xtcapkopen()
  159. X
  160. X{
  161. X    strcpy(sres, "NORMAL");
  162. X}
  163. X
  164. Xtcapkclose()
  165. X
  166. X{
  167. X}
  168. X
  169. Xtcapmove(row, col)
  170. Xregister int row, col;
  171. X{
  172. X        putpad(tgoto(CM, col, row));
  173. X}
  174. X
  175. Xtcapeeol()
  176. X{
  177. X        putpad(CE);
  178. X}
  179. X
  180. Xtcapeeop()
  181. X{
  182. X        putpad(CL);
  183. X}
  184. X
  185. Xtcaprev(state)        /* change reverse video status */
  186. X
  187. Xint state;        /* FALSE = normal video, TRUE = reverse video */
  188. X
  189. X{
  190. X    static int revstate = FALSE;
  191. X    if (state) {
  192. X        if (SO != NULL)
  193. X            putpad(SO);
  194. X    } else
  195. X        if (SE != NULL)
  196. X            putpad(SE);
  197. X}
  198. X
  199. Xtcapcres()    /* change screen resolution */
  200. X
  201. X{
  202. X    return(TRUE);
  203. X}
  204. X
  205. Xspal(dummy)    /* change palette string */
  206. X
  207. X{
  208. X    /*    Does nothing here    */
  209. X}
  210. X
  211. X#if    COLOR
  212. Xtcapfcol()    /* no colors here, ignore this */
  213. X{
  214. X}
  215. X
  216. Xtcapbcol()    /* no colors here, ignore this */
  217. X{
  218. X}
  219. X#endif
  220. X
  221. Xtcapbeep()
  222. X{
  223. X    ttputc(BEL);
  224. X}
  225. X
  226. Xputpad(str)
  227. Xchar    *str;
  228. X{
  229. X    tputs(str, 1, ttputc);
  230. X}
  231. X
  232. Xputnpad(str, n)
  233. Xchar    *str;
  234. X{
  235. X    tputs(str, n, ttputc);
  236. X}
  237. X
  238. X
  239. X#if    FLABEL
  240. Xfnclabel(f, n)        /* label a function key */
  241. X
  242. Xint f,n;    /* default flag, numeric argument [unused] */
  243. X
  244. X{
  245. X    /* on machines with no function keys...don't bother */
  246. X    return(TRUE);
  247. X}
  248. X#endif
  249. X#else
  250. X
  251. Xhello()
  252. X{
  253. X}
  254. X
  255. X#endif
  256. FRIDAY_NIGHT
  257. echo extracting - termio.c
  258. sed 's/^X//' > termio.c << 'FRIDAY_NIGHT'
  259. X/*
  260. X * The functions in this file negotiate with the operating system for
  261. X * characters, and write characters in a barely buffered fashion on the display.
  262. X * All operating systems.
  263. X */
  264. X#include        <stdio.h>
  265. X#include    "estruct.h"
  266. X#include        "edef.h"
  267. X
  268. X#if   MSDOS & TURBO
  269. X#include <conio.h>
  270. X#endif
  271. X
  272. X#if     AMIGA
  273. X#define NEW 1006L
  274. X#define AMG_MAXBUF      1024L
  275. Xstatic long terminal;
  276. Xstatic char     scrn_tmp[AMG_MAXBUF+1];
  277. Xstatic long     scrn_tmp_p = 0;
  278. X#endif
  279. X
  280. X#if     VMS
  281. X#include        <stsdef.h>
  282. X#include        <ssdef.h>
  283. X#include        <descrip.h>
  284. X#include        <iodef.h>
  285. X#include        <ttdef.h>
  286. X#include    <tt2def.h>
  287. X
  288. X#define NIBUF   128                     /* Input buffer size            */
  289. X#define NOBUF   1024                    /* MM says bug buffers win!     */
  290. X#define EFN     0                       /* Event flag                   */
  291. X
  292. Xchar    obuf[NOBUF];                    /* Output buffer                */
  293. Xint     nobuf;                  /* # of bytes in above    */
  294. Xchar    ibuf[NIBUF];                    /* Input buffer          */
  295. Xint     nibuf;                  /* # of bytes in above  */
  296. Xint     ibufi;                  /* Read index                   */
  297. Xint     oldmode[3];                     /* Old TTY mode bits            */
  298. Xint     newmode[3];                     /* New TTY mode bits            */
  299. Xshort   iochan;                  /* TTY I/O channel             */
  300. X#endif
  301. X
  302. X#if     CPM
  303. X#include        <bdos.h>
  304. X#endif
  305. X
  306. X#if     MSDOS & (LATTICE | MSC | TURBO | AZTEC | MWC86)
  307. Xunion REGS rg;        /* cpu register for use of DOS calls */
  308. Xint nxtchar = -1;    /* character held from type ahead    */
  309. X#endif
  310. X
  311. X#if RAINBOW
  312. X#include "rainbow.h"
  313. X#endif
  314. X
  315. X#if    USG            /* System V */
  316. X#include    <signal.h>
  317. X#include    <termio.h>
  318. X#include    <fcntl.h>
  319. Xint kbdflgs;            /* saved keyboard fd flags    */
  320. Xint kbdpoll;            /* in O_NDELAY mode            */
  321. Xint kbdqp;            /* there is a char in kbdq    */
  322. Xchar kbdq;            /* char we've already read    */
  323. Xstruct    termio    otermio;    /* original terminal characteristics */
  324. Xstruct    termio    ntermio;    /* charactoristics to use inside */
  325. X#endif
  326. X
  327. X#if V7 | BSD
  328. X#undef    CTRL
  329. X#include        <sgtty.h>        /* for stty/gtty functions */
  330. X#include    <signal.h>
  331. Xstruct  sgttyb  ostate;          /* saved tty state */
  332. Xstruct  sgttyb  nstate;          /* values for editor mode */
  333. Xstruct tchars    otchars;    /* Saved terminal special character set */
  334. Xstruct tchars    ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  335. X                /* A lot of nothing */
  336. X#if BSD
  337. X#include <sys/ioctl.h>        /* to get at the typeahead */
  338. Xextern    int rtfrmshell();    /* return from suspended shell */
  339. X#define    TBUFSIZ    128
  340. Xchar tobuf[TBUFSIZ];        /* terminal output buffer */
  341. X#endif
  342. X#endif
  343. X
  344. X/*
  345. X * This function is called once to set up the terminal device streams.
  346. X * On VMS, it translates TT until it finds the terminal, then assigns
  347. X * a channel to it and sets it raw. On CPM it is a no-op.
  348. X */
  349. Xttopen()
  350. X{
  351. X#if     AMIGA
  352. X    char oline[NSTRING];
  353. X#if    AZTEC
  354. X    extern    Enable_Abort;    /* Turn off ctrl-C interrupt */
  355. X
  356. X    Enable_Abort = 0;    /* for the Manx compiler */
  357. X#endif
  358. X    strcpy(oline, "RAW:0/0/640/200/");
  359. X    strcat(oline, PROGNAME);
  360. X    strcat(oline, " ");
  361. X    strcat(oline, VERSION);
  362. X    strcat(oline, "/Amiga");
  363. X        terminal = Open(oline, NEW);
  364. X#endif
  365. X#if     VMS
  366. X        struct  dsc$descriptor  idsc;
  367. X        struct  dsc$descriptor  odsc;
  368. X        char    oname[40];
  369. X        int     iosb[2];
  370. X        int     status;
  371. X
  372. X        odsc.dsc$a_pointer = "TT";
  373. X        odsc.dsc$w_length  = strlen(odsc.dsc$a_pointer);
  374. X        odsc.dsc$b_dtype        = DSC$K_DTYPE_T;
  375. X        odsc.dsc$b_class        = DSC$K_CLASS_S;
  376. X        idsc.dsc$b_dtype        = DSC$K_DTYPE_T;
  377. X        idsc.dsc$b_class        = DSC$K_CLASS_S;
  378. X        do {
  379. X                idsc.dsc$a_pointer = odsc.dsc$a_pointer;
  380. X                idsc.dsc$w_length  = odsc.dsc$w_length;
  381. X                odsc.dsc$a_pointer = &oname[0];
  382. X                odsc.dsc$w_length  = sizeof(oname);
  383. X                status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc);
  384. X                if (status!=SS$_NORMAL && status!=SS$_NOTRAN)
  385. X                        exit(status);
  386. X                if (oname[0] == 0x1B) {
  387. X                        odsc.dsc$a_pointer += 4;
  388. X                        odsc.dsc$w_length  -= 4;
  389. X                }
  390. X        } while (status == SS$_NORMAL);
  391. X        status = SYS$ASSIGN(&odsc, &iochan, 0, 0);
  392. X        if (status != SS$_NORMAL)
  393. X                exit(status);
  394. X        status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
  395. X                          oldmode, sizeof(oldmode), 0, 0, 0, 0);
  396. X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  397. X                exit(status);
  398. X        newmode[0] = oldmode[0];
  399. X        newmode[1] = oldmode[1] | TT$M_NOECHO;
  400. X        newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC);
  401. X        newmode[2] = oldmode[2] | TT2$M_PASTHRU;
  402. X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
  403. X                          newmode, sizeof(newmode), 0, 0, 0, 0);
  404. X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  405. X                exit(status);
  406. X        term.t_nrow = (newmode[1]>>24) - 1;
  407. X        term.t_ncol = newmode[0]>>16;
  408. X
  409. X#endif
  410. X#if     CPM
  411. X#endif
  412. X
  413. X#if     MSDOS & (HP150 == 0) & LATTICE
  414. X    /* kill the ctrl-break interupt */
  415. X    rg.h.ah = 0x33;        /* control-break check dos call */
  416. X    rg.h.al = 1;        /* set the current state */
  417. X    rg.h.dl = 0;        /* set it OFF */
  418. X    intdos(&rg, &rg);    /* go for it! */
  419. X#endif
  420. X
  421. X#if    USG
  422. X    ioctl(0, TCGETA, &otermio);    /* save old settings */
  423. X    ntermio.c_iflag = 0;        /* setup new settings */
  424. X    ntermio.c_oflag = 0;
  425. X    ntermio.c_cflag = otermio.c_cflag;
  426. X    ntermio.c_lflag = 0;
  427. X    ntermio.c_line = otermio.c_line;
  428. X    ntermio.c_cc[VMIN] = 1;
  429. X    ntermio.c_cc[VTIME] = 0;
  430. X    ioctl(0, TCSETA, &ntermio);    /* and activate them */
  431. X    kbdflgs = fcntl( 0, F_GETFL, 0 );
  432. X    kbdpoll = FALSE;
  433. X#endif
  434. X
  435. X#if     V7 | BSD
  436. X        gtty(0, &ostate);                       /* save old state */
  437. X        gtty(0, &nstate);                       /* get base of new state */
  438. X        nstate.sg_flags |= RAW;
  439. X        nstate.sg_flags &= ~(ECHO|CRMOD);       /* no echo for now... */
  440. X        stty(0, &nstate);                       /* set mode */
  441. X    ioctl(0, TIOCGETC, &otchars);        /* Save old characters */
  442. X    ioctl(0, TIOCSETC, &ntchars);        /* Place new character into K */
  443. X#if    BSD
  444. X    /* provide a smaller terminal output buffer so that
  445. X       the type ahead detection works better (more often) */
  446. X    setbuffer(stdout, &tobuf[0], TBUFSIZ);
  447. X    signal(SIGTSTP,SIG_DFL);    /* set signals so that we can */
  448. X    signal(SIGCONT,rtfrmshell);    /* suspend & restart emacs */
  449. X#endif
  450. X#endif
  451. X    /* on all screens we are not sure of the initial position
  452. X       of the cursor                    */
  453. X    ttrow = 999;
  454. X    ttcol = 999;
  455. X}
  456. X
  457. X/*
  458. X * This function gets called just before we go back home to the command
  459. X * interpreter. On VMS it puts the terminal back in a reasonable state.
  460. X * Another no-operation on CPM.
  461. X */
  462. Xttclose()
  463. X{
  464. X#if     AMIGA
  465. X#if    LATTICE
  466. X        amg_flush();
  467. X        Close(terminal);
  468. X#endif
  469. X#if    AZTEC
  470. X        amg_flush();
  471. X    Enable_Abort = 1;    /* Fix for Manx */
  472. X        Close(terminal);
  473. X#endif
  474. X#endif
  475. X
  476. X#if     VMS
  477. X        int     status;
  478. X        int     iosb[1];
  479. X
  480. X        ttflush();
  481. X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
  482. X                 oldmode, sizeof(oldmode), 0, 0, 0, 0);
  483. X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  484. X                exit(status);
  485. X        status = SYS$DASSGN(iochan);
  486. X        if (status != SS$_NORMAL)
  487. X                exit(status);
  488. X#endif
  489. X#if     CPM
  490. X#endif
  491. X#if     MSDOS & (HP150 == 0) & LATTICE
  492. X    /* restore the ctrl-break interupt */
  493. X    rg.h.ah = 0x33;        /* control-break check dos call */
  494. X    rg.h.al = 1;        /* set the current state */
  495. X    rg.h.dl = 1;        /* set it ON */
  496. X    intdos(&rg, &rg);    /* go for it! */
  497. X#endif
  498. X
  499. X#if    USG
  500. X    ioctl(0, TCSETA, &otermio);    /* restore terminal settings */
  501. X    fcntl(0, F_SETFL, kbdflgs);
  502. X#endif
  503. X
  504. X#if     V7 | BSD
  505. X        stty(0, &ostate);
  506. X    ioctl(0, TIOCSETC, &otchars);    /* Place old character into K */
  507. X#endif
  508. X}
  509. X
  510. X/*
  511. X * Write a character to the display. On VMS, terminal output is buffered, and
  512. X * we just put the characters in the big array, after checking for overflow.
  513. X * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on
  514. X * MS-DOS (use the very very raw console output routine).
  515. X */
  516. Xttputc(c)
  517. X#if     AMIGA
  518. X        char c;
  519. X#endif
  520. X{
  521. X#if     AMIGA
  522. X        scrn_tmp[scrn_tmp_p++] = c;
  523. X        if(scrn_tmp_p>=AMG_MAXBUF)
  524. X                amg_flush();
  525. X#endif
  526. X#if     VMS
  527. X        if (nobuf >= NOBUF)
  528. X                ttflush();
  529. X        obuf[nobuf++] = c;
  530. X#endif
  531. X
  532. X#if     CPM
  533. X        bios(BCONOUT, c, 0);
  534. X#endif
  535. X
  536. X#if     MSDOS & MWC86
  537. X        putcnb(c);
  538. X#endif
  539. X
  540. X#if    MSDOS & (LATTICE | AZTEC) & ~IBMPC
  541. X    bdos(6, c, 0);
  542. X#endif
  543. X
  544. X#if RAINBOW
  545. X        Put_Char(c);                    /* fast video */
  546. X#endif
  547. X
  548. X
  549. X#if     V7 | USG | BSD
  550. X        fputc(c, stdout);
  551. X#endif
  552. X}
  553. X
  554. X#if    AMIGA
  555. Xamg_flush()
  556. X{
  557. X        if(scrn_tmp_p)
  558. X                Write(terminal,scrn_tmp,scrn_tmp_p);
  559. X        scrn_tmp_p = 0;
  560. X}
  561. X#endif
  562. X
  563. X/*
  564. X * Flush terminal buffer. Does real work where the terminal output is buffered
  565. X * up. A no-operation on systems where byte at a time terminal I/O is done.
  566. X */
  567. Xttflush()
  568. X{
  569. X#if     AMIGA
  570. X        amg_flush();
  571. X#endif
  572. X#if     VMS
  573. X        int     status;
  574. X        int     iosb[2];
  575. X
  576. X        status = SS$_NORMAL;
  577. X        if (nobuf != 0) {
  578. X                status = SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT,
  579. X                         iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
  580. X                if (status == SS$_NORMAL)
  581. X                        status = iosb[0] & 0xFFFF;
  582. X                nobuf = 0;
  583. X        }
  584. X        return (status);
  585. X#endif
  586. X
  587. X#if     CPM
  588. X#endif
  589. X
  590. X#if     MSDOS
  591. X#endif
  592. X
  593. X#if     V7 | USG | BSD
  594. X        fflush(stdout);
  595. X#endif
  596. X}
  597. X
  598. X/*
  599. X * Read a character from the terminal, performing no editing and doing no echo
  600. X * at all. More complex in VMS that almost anyplace else, which figures. Very
  601. X * simple on CPM, because the system can do exactly what you want.
  602. X */
  603. Xttgetc()
  604. X{
  605. X#if     AMIGA
  606. X        char ch;
  607. X        amg_flush();
  608. X        Read(terminal, &ch, 1L);
  609. X        return(255 & (int)ch);
  610. X#endif
  611. X#if     VMS
  612. X        int     status;
  613. X        int     iosb[2];
  614. X        int     term[2];
  615. X
  616. X        while (ibufi >= nibuf) {
  617. X                ibufi = 0;
  618. X                term[0] = 0;
  619. X                term[1] = 0;
  620. X                status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED,
  621. X                         iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0);
  622. X                if (status != SS$_NORMAL)
  623. X                        exit(status);
  624. X                status = iosb[0] & 0xFFFF;
  625. X                if (status!=SS$_NORMAL && status!=SS$_TIMEOUT)
  626. X                        exit(status);
  627. X                nibuf = (iosb[0]>>16) + (iosb[1]>>16);
  628. X                if (nibuf == 0) {
  629. X                        status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
  630. X                                 iosb, 0, 0, ibuf, 1, 0, term, 0, 0);
  631. X                        if (status != SS$_NORMAL
  632. X                        || (status = (iosb[0]&0xFFFF)) != SS$_NORMAL)
  633. X                                exit(status);
  634. X                        nibuf = (iosb[0]>>16) + (iosb[1]>>16);
  635. X                }
  636. X        }
  637. X        return (ibuf[ibufi++] & 0xFF);    /* Allow multinational  */
  638. X#endif
  639. X
  640. X#if     CPM
  641. X        return (biosb(BCONIN, 0, 0));
  642. X#endif
  643. X
  644. X#if RAINBOW
  645. X        int Ch;
  646. X
  647. X        while ((Ch = Read_Keyboard()) < 0);
  648. X
  649. X        if ((Ch & Function_Key) == 0)
  650. X                if (!((Ch & 0xFF) == 015 || (Ch & 0xFF) == 0177))
  651. X                        Ch &= 0xFF;
  652. X
  653. X        return Ch;
  654. X#endif
  655. X
  656. X#if     MSDOS & MWC86
  657. X        return (getcnb());
  658. X#endif
  659. X
  660. X#if    MSDOS & (LATTICE | MSC | TURBO | AZTEC)
  661. X    int c;        /* character read */
  662. X
  663. X    /* if a char already is ready, return it */
  664. X    if (nxtchar >= 0) {
  665. X        c = nxtchar;
  666. X        nxtchar = -1;
  667. X        return(c);
  668. X    }
  669. X
  670. X    /* call the dos to get a char */
  671. X    rg.h.ah = 7;        /* dos Direct Console Input call */
  672. X    intdos(&rg, &rg);
  673. X    c = rg.h.al;        /* grab the char */
  674. X    return(c & 255);
  675. X#endif
  676. X
  677. X#if     V7 | BSD
  678. X        return(127 & fgetc(stdin));
  679. X#endif
  680. X
  681. X#if    USG
  682. X    if( kbdqp )
  683. X        kbdqp = FALSE;
  684. X    else
  685. X    {
  686. X        if( kbdpoll && fcntl( 0, F_SETFL, kbdflgs ) < 0 )
  687. X            return FALSE;
  688. X        kbdpoll = FALSE;
  689. X        while (read(0, &kbdq, 1) != 1)
  690. X            ;
  691. X    }
  692. X    return ( kbdq & 127 );
  693. X#endif
  694. X}
  695. X
  696. X#if    TYPEAH & (~ST520)
  697. X/* typahead:    Check to see if any characters are already in the
  698. X        keyboard buffer
  699. X*/
  700. X
  701. Xtypahead()
  702. X
  703. X{
  704. X#if    MSDOS & (MSC | TURBO)
  705. X    if (kbhit() != 0)
  706. X        return(TRUE);
  707. X    else
  708. X        return(FALSE);
  709. X#endif
  710. X
  711. X#if    MSDOS & (LATTICE | AZTEC | MWC86)
  712. X    int c;        /* character read */
  713. X    int flags;    /* cpu flags from dos call */
  714. X
  715. X    if (nxtchar >= 0)
  716. X        return(TRUE);
  717. X
  718. X    rg.h.ah = 6;    /* Direct Console I/O call */
  719. X    rg.h.dl = 255;    /*         does console input */
  720. X#if    LATTICE | AZTEC
  721. X    flags = intdos(&rg, &rg);
  722. X#else
  723. X    intcall(&rg, &rg, 0x21);
  724. X    flags = rg.x.flags;
  725. X#endif
  726. X    c = rg.h.al;    /* grab the character */
  727. X
  728. X    /* no character pending */
  729. X    if ((flags & 64) != 0)
  730. X        return(FALSE);
  731. X
  732. X    /* save the character and return true */
  733. X    nxtchar = c;
  734. X    return(TRUE);
  735. X#endif
  736. X
  737. X#if    BSD
  738. X    int x;    /* holds # of pending chars */
  739. X
  740. X    return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x);
  741. X#endif
  742. X
  743. X#if    USG
  744. X    if( !kbdqp )
  745. X    {
  746. X        if( !kbdpoll && fcntl( 0, F_SETFL, kbdflgs | O_NDELAY ) < 0 )
  747. X            return(FALSE);
  748. X        kbdqp = (1 == read( 0, &kbdq, 1 ));
  749. X    }
  750. X    return ( kbdqp );
  751. X#endif
  752. X    return(FALSE);
  753. X}
  754. X#endif
  755. X
  756. FRIDAY_NIGHT
  757. echo extracting - tipc.c
  758. sed 's/^X//' > tipc.c << 'FRIDAY_NIGHT'
  759. X/*
  760. X * The routines in this file provide support for the TI-PC and other
  761. X * compatible terminals. It goes directly to the graphics RAM to do
  762. X * screen output. It compiles into nothing if not a TI-PC driver
  763. X */
  764. X
  765. X#define termdef 1                       /* don't define "term" external */
  766. X
  767. X#include        <stdio.h>
  768. X#include        "estruct.h"
  769. X#include        "edef.h"
  770. X
  771. X#if     TIPC
  772. X
  773. X#define NROW    25                      /* Screen size.                 */
  774. X#define NCOL    80                      /* Edit if you want to.         */
  775. X#define MARGIN  8                       /* size of minimim margin and   */
  776. X#define SCRSIZ  64                      /* scroll size for extended lines */
  777. X#define NPAUSE  200                     /* # times thru update to pause */
  778. X#define BEL     0x07                    /* BEL character.               */
  779. X#define ESC     0x1B                    /* ESC character.               */
  780. X#define SPACE   32                      /* space character              */
  781. X#define SCADD   0xDE000L                /* address of screen RAM        */
  782. X
  783. X#define CHAR_ENABLE     0x08            /* TI attribute to show char    */
  784. X#define TI_REVERSE      0x10            /* TI attribute to reverse char */
  785. X#define BLACK   0+CHAR_ENABLE           /* TI attribute for Black       */
  786. X#define BLUE    1+CHAR_ENABLE           /* TI attribute for Blue        */
  787. X#define RED     2+CHAR_ENABLE           /* TI attribute for Red         */
  788. X#define MAGENTA 3+CHAR_ENABLE           /* TI attribute for Magenta     */
  789. X#define GREEN   4+CHAR_ENABLE           /* TI attribute for Green       */
  790. X#define CYAN    5+CHAR_ENABLE           /* TI attribute for Cyan        */
  791. X#define YELLOW  6+CHAR_ENABLE           /* TI attribute for Yellow      */
  792. X#define WHITE   7+CHAR_ENABLE           /* TI attribute for White       */
  793. X
  794. X
  795. Xextern  int     ttopen();               /* Forward references.          */
  796. Xextern  int     ttgetc();
  797. Xextern  int     ttputc();
  798. Xextern  int     ttflush();
  799. Xextern  int     ttclose();
  800. Xextern  int     timove();
  801. Xextern  int     tieeol();
  802. Xextern  int     tieeop();
  803. Xextern  int     tibeep();
  804. Xextern  int     tiopen();
  805. Xextern  int     tirev();
  806. Xextern    int    ticres();
  807. Xextern  int     ticlose();
  808. Xextern  int     tiputc();
  809. X
  810. X#if     COLOR
  811. Xextern  int     tifcol();
  812. Xextern  int     tibcol();
  813. X
  814. Xint     cfcolor = -1;           /* current forground color */
  815. Xint     cbcolor = -1;           /* current background color */
  816. Xint     ctrans[] =              /* ansi to ti color translation table */
  817. X        {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
  818. X#endif
  819. X
  820. X/*
  821. X * Standard terminal interface dispatch table. Most of the fields point into
  822. X * "termio" code.
  823. X */
  824. XTERM    term    = {
  825. X    NROW-1,
  826. X        NROW-1,
  827. X        NCOL,
  828. X        NCOL,
  829. X        MARGIN,
  830. X        SCRSIZ,
  831. X        NPAUSE,
  832. X        tiopen,
  833. X        ticlose,
  834. X        ttgetc,
  835. X        tiputc,
  836. X        ttflush,
  837. X        timove,
  838. X        tieeol,
  839. X        tieeop,
  840. X        tibeep,
  841. X        tirev,
  842. X        ticres
  843. X#if     COLOR
  844. X        , tifcol,
  845. X        tibcol
  846. X#endif
  847. X};
  848. X
  849. Xextern union REGS rg;
  850. X
  851. X#if     COLOR
  852. Xsetatt( attr )
  853. Xint attr;
  854. X{
  855. X        rg.h.ah = 0x16;         /* set the forground character attribute */
  856. X        rg.h.bl = attr;
  857. X        int86( 0x49, &rg, &rg );
  858. X}
  859. X
  860. Xtifcol(color)           /* set the current output color */
  861. X
  862. Xint color;      /* color to set */
  863. X
  864. X{
  865. X        cfcolor = ctrans[color];
  866. X        setatt ( cfcolor );
  867. X}
  868. X
  869. Xtibcol(color)           /* set the current background color */
  870. X
  871. Xint color;      /* color to set */
  872. X
  873. X{
  874. X        cbcolor = ctrans[color];
  875. X}
  876. X#endif
  877. X
  878. Xtimove(row, col)
  879. X{
  880. X        rg.h.ah = 2;            /* set cursor position function code */
  881. X        rg.h.dh = col;
  882. X        rg.h.dl = row;
  883. X        int86(0x49, &rg, &rg);
  884. X}
  885. X
  886. Xtieeol()        /* erase to the end of the line */
  887. X
  888. X{
  889. X        int ccol;       /* current column cursor lives */
  890. X        int crow;       /*         row  */
  891. X
  892. X        /* find the current cursor position */
  893. X        rg.h.ah = 3;            /* read cursor position function code */
  894. X        int86(0x49, &rg, &rg);
  895. X        ccol = rg.h.dh;         /* record current column */
  896. X        crow = rg.h.dl;         /* and row */
  897. X
  898. X        rg.h.ah = 0x09;         /* Write character at cursor position */
  899. X        rg.h.al = ' ';          /* Space */
  900. X        rg.h.bl = cfcolor;
  901. X        rg.x.cx = NCOL-ccol;    /* Number of characters to write */
  902. X        int86(0x49, &rg, &rg);
  903. X
  904. X}
  905. X
  906. Xtiputc(ch)      /* put a character at the current position in the
  907. X                   current colors */
  908. X
  909. Xint ch;
  910. X
  911. X{
  912. X        rg.h.ah = 0x0E;         /* write char to screen with current attrs */
  913. X        rg.h.al = ch;
  914. X        int86(0x49, &rg, &rg);
  915. X}
  916. X
  917. Xtieeop()                        /* Actually a clear screen */
  918. X{
  919. X
  920. X        rg.h.ah = 0x13;         /* Clear Text Screen and Home Cursor */
  921. X        int86(0x49, &rg, &rg);
  922. X}
  923. X
  924. Xtirev(state)            /* change reverse video state */
  925. X
  926. Xint state;      /* TRUE = reverse, FALSE = normal */
  927. X
  928. X{
  929. X        setatt( state ? cbcolor : cfcolor  );
  930. X}
  931. X
  932. Xticres()    /* change screen resolution */
  933. X
  934. X{
  935. X    return(TRUE);
  936. X}
  937. X
  938. Xspal()        /* change palette string */
  939. X
  940. X{
  941. X    /*    Does nothing here    */
  942. X}
  943. X
  944. Xtibeep()
  945. X{
  946. X        bdos(6, BEL, 0);
  947. X}
  948. X
  949. Xtiopen()
  950. X{
  951. X    strcpy(sres, "NORMAL");
  952. X        revexist = TRUE;
  953. X        ttopen();
  954. X}
  955. X
  956. Xticlose()
  957. X
  958. X{
  959. X#if     COLOR
  960. X        tifcol(7);
  961. X        tibcol(0);
  962. X#endif
  963. X        ttclose();
  964. X}
  965. X#else
  966. Xtihello()
  967. X{
  968. X}
  969. X#endif
  970. X
  971. FRIDAY_NIGHT
  972. echo extracting - vmsvt.c
  973. sed 's/^X//' > vmsvt.c << 'FRIDAY_NIGHT'
  974. X/*
  975. X *  Advanced VMS terminal driver
  976. X *
  977. X *  Knows about any terminal defined in SMGTERMS.TXT and TERMTABLE.TXT
  978. X *  located in SYS$SYSTEM.
  979. X *
  980. X *  Author:  Curtis Smith
  981. X *  Last Updated: 07/14/87
  982. X */
  983. X
  984. X#include    <stdio.h>        /* Standard I/O package        */
  985. X#include    "estruct.h"        /* Emacs' structures        */
  986. X#include    "edef.h"        /* Emacs' definitions        */
  987. X
  988. X#if    VMSVT
  989. X
  990. X#include     <descrip.h>        /* Descriptor definitions    */
  991. X
  992. X/*  These would normally come from iodef.h and ttdef.h  */
  993. X#define IO$_SENSEMODE    0x27        /* Sense mode of terminal    */
  994. X#define TT$_UNKNOWN    0x00        /* Unknown terminal        */
  995. X
  996. X/** Forward references **/
  997. Xint vmsopen(), ttclose(), vmskopen(), vmskclose(), ttgetc(), ttputc();
  998. Xint ttflush(), vmsmove(), vmseeol(), vmseeop(), vmsbeep(), vmsrev();
  999. Xint vmscres();
  1000. Xextern int eolexist, revexist;
  1001. Xextern char sres[];
  1002. X
  1003. X#if COLOR
  1004. Xint vmsfcol(), vmsbcol();
  1005. X#endif
  1006. X
  1007. X/** SMG stuff **/
  1008. Xstatic char * begin_reverse, * end_reverse, * erase_to_end_line;
  1009. Xstatic char * erase_whole_display;
  1010. Xstatic int termtype;
  1011. X
  1012. X#define SMG$K_BEGIN_REVERSE        0x1bf
  1013. X#define SMG$K_END_REVERSE        0x1d6
  1014. X#define SMG$K_SET_CURSOR_ABS        0x23a
  1015. X#define SMG$K_ERASE_WHOLE_DISPLAY    0x1da
  1016. X#define SMG$K_ERASE_TO_END_LINE        0x1d9
  1017. X
  1018. X
  1019. X/* Dispatch table. All hard fields just point into the terminal I/O code. */
  1020. XTERM    term    = {
  1021. X    24 - 1,                /* Max number of rows allowable */
  1022. X    /* Filled in */ - 1,        /* Current number of rows used    */
  1023. X    132,                /* Max number of columns    */
  1024. X    /* Filled in */ 0,        /* Current number of columns    */
  1025. X    64,                /* Min margin for extended lines*/
  1026. X    8,                /* Size of scroll region    */
  1027. X    100,                /* # times thru update to pause */
  1028. X    vmsopen,            /* Open terminal at the start    */
  1029. X    ttclose,            /* Close terminal at end    */
  1030. X    vmskopen,            /* Open keyboard        */
  1031. X    vmskclose,            /* Close keyboard        */
  1032. X    ttgetc,                /* Get character from keyboard    */
  1033. X    ttputc,                /* Put character to display    */
  1034. X    ttflush,            /* Flush output buffers        */
  1035. X    vmsmove,            /* Move cursor, origin 0    */
  1036. X    vmseeol,            /* Erase to end of line        */
  1037. X    vmseeop,            /* Erase to end of page        */
  1038. X    vmsbeep,            /* Beep                */
  1039. X    vmsrev,                /* Set reverse video state    */
  1040. X    vmscres                /* Change screen resolution    */
  1041. X#if    COLOR
  1042. X    , vmsfcol,            /* Set forground color        */
  1043. X    vmsbcol                /* Set background color        */
  1044. X#endif
  1045. X};
  1046. X
  1047. X/***
  1048. X *  ttputs  -  Send a string to ttputc
  1049. X *
  1050. X *  Nothing returned
  1051. X ***/
  1052. Xttputs(string)
  1053. Xchar * string;                /* String to write        */
  1054. X{
  1055. X    if (string)
  1056. X        while (*string != '\0')
  1057. X            ttputc(*string++);
  1058. X}
  1059. X
  1060. X
  1061. X/***
  1062. X *  vmsmove  -  Move the cursor (0 origin)
  1063. X *
  1064. X *  Nothing returned
  1065. X ***/
  1066. Xvmsmove(row, col)
  1067. Xint row;                /* Row position            */
  1068. Xint col;                /* Column position        */
  1069. X{
  1070. X    char buffer[32];
  1071. X    int ret_length;
  1072. X    static int request_code = SMG$K_SET_CURSOR_ABS;
  1073. X    static int max_buffer_length = sizeof(buffer);
  1074. X    static int arg_list[3] = { 2 };
  1075. X    register char * cp;
  1076. X    
  1077. X    register int i;
  1078. X
  1079. X    /* Set the arguments into the arg_list array
  1080. X     * SMG assumes the row/column positions are 1 based (boo!)
  1081. X     */
  1082. X    arg_list[1] = row + 1;
  1083. X    arg_list[2] = col + 1;
  1084. X
  1085. X    if ((smg$get_term_data(        /* Get terminal data        */
  1086. X        &termtype,        /* Terminal table address    */
  1087. X        &request_code,        /* Request code            */
  1088. X        &max_buffer_length,    /* Maximum buffer length    */
  1089. X        &ret_length,        /* Return length        */
  1090. X        buffer,            /* Capability data buffer    */
  1091. X        arg_list)        /* Argument list array        */
  1092. X
  1093. X    /* We'll know soon enough if this doesn't work        */
  1094. X            & 1) == 0) {
  1095. X                ttputs("OOPS");
  1096. X                return;
  1097. X            }
  1098. X
  1099. X    /* Send out resulting sequence                */
  1100. X    i = ret_length;
  1101. X    cp = buffer;
  1102. X    while (i-- > 0)
  1103. X        ttputc(*cp++);
  1104. X}
  1105. X
  1106. X
  1107. X/***
  1108. X *  vmsrev  -  Set the reverse video status
  1109. X *
  1110. X *  Nothing returned
  1111. X ***/
  1112. Xvmsrev(status)
  1113. Xint status;                /* TRUE if setting reverse    */
  1114. X{
  1115. X    if (status)
  1116. X        ttputs(begin_reverse);
  1117. X    else 
  1118. X        ttputs(end_reverse);
  1119. X}
  1120. X
  1121. X/***
  1122. X *  vmscres  -  Change screen resolution (which it doesn't)
  1123. X *
  1124. X *  Nothing returned
  1125. X ***/
  1126. Xvmscres()
  1127. X{
  1128. X    /* But it could.  For vt100/vt200s, one could switch from
  1129. X    80 and 132 columns modes */
  1130. X}
  1131. X
  1132. X
  1133. X#if    COLOR
  1134. X/***
  1135. X *  vmsfcol  -  Set the forground color (not implimented)
  1136. X *
  1137. X *  Nothing returned
  1138. X ***/
  1139. Xvmsfcol()
  1140. X{
  1141. X}
  1142. X
  1143. X/***
  1144. X *  vmsbcol  -  Set the background color (not implimented)
  1145. X *
  1146. X *  Nothing returned
  1147. X ***/
  1148. Xvmsbcol()
  1149. X{
  1150. X}
  1151. X#endif
  1152. X
  1153. X/***
  1154. X *  vmseeol  -  Erase to end of line
  1155. X *
  1156. X *  Nothing returned
  1157. X ***/
  1158. Xvmseeol()
  1159. X{
  1160. X    ttputs(erase_to_end_line);
  1161. X}
  1162. X
  1163. X
  1164. X/***
  1165. X *  vmseeop  -  Erase to end of page (clear screen)
  1166. X *
  1167. X *  Nothing returned
  1168. X ***/
  1169. Xvmseeop()
  1170. X{
  1171. X    ttputs(erase_whole_display);
  1172. X}
  1173. X
  1174. X
  1175. X/***
  1176. X *  vmsbeep  -  Ring the bell
  1177. X *
  1178. X *  Nothing returned
  1179. X ***/
  1180. Xvmsbeep()
  1181. X{
  1182. X    ttputc('\007');
  1183. X}
  1184. X
  1185. X
  1186. X/***
  1187. X *  vmsgetstr  -  Get an SMG string capability by name
  1188. X *
  1189. X *  Returns:    Escape sequence
  1190. X *        NULL    No escape sequence available
  1191. X ***/ 
  1192. Xchar * vmsgetstr(request_code)
  1193. Xint request_code;            /* Request code            */
  1194. X{
  1195. X    register char * result;
  1196. X    static char seq_storage[1024];
  1197. X    static char * buffer = seq_storage;
  1198. X    static int arg_list[2] = { 1, 1 };
  1199. X    int max_buffer_length, ret_length;
  1200. X
  1201. X    /*  Precompute buffer length */
  1202. X    
  1203. X    max_buffer_length = (seq_storage + sizeof(seq_storage)) - buffer;
  1204. X
  1205. X    /* Get terminal commands sequence from master table */
  1206. X
  1207. X    if ((smg$get_term_data(    /* Get terminal data        */
  1208. X        &termtype,    /* Terminal table address    */
  1209. X        &request_code,    /* Request code            */
  1210. X        &max_buffer_length,/* Maximum buffer length    */
  1211. X        &ret_length,    /* Return length        */
  1212. X        buffer,        /* Capability data buffer    */
  1213. X        arg_list)    /* Argument list array        */
  1214. X
  1215. X    /* If this doesn't work, try again with no arguments */
  1216. X    
  1217. X        & 1) == 0 && 
  1218. X
  1219. X        (smg$get_term_data(    /* Get terminal data        */
  1220. X            &termtype,    /* Terminal table address    */
  1221. X            &request_code,    /* Request code            */
  1222. X            &max_buffer_length,/* Maximum buffer length    */
  1223. X            &ret_length,    /* Return length        */
  1224. X            buffer)        /* Capability data buffer    */
  1225. X
  1226. X    /* Return NULL pointer if capability is not available */
  1227. X    
  1228. X            & 1) == 0)
  1229. X                return NULL;
  1230. X
  1231. X    /* Check for empty result */
  1232. X    if (ret_length == 0)
  1233. X        return NULL;
  1234. X    
  1235. X    /* Save current position so we can return it to caller */
  1236. X
  1237. X    result = buffer;
  1238. X
  1239. X    /* NIL terminate the sequence for return */
  1240. X    
  1241. X    buffer[ret_length] = 0;
  1242. X
  1243. X    /* Advance buffer */
  1244. X
  1245. X    buffer += ret_length + 1;
  1246. X
  1247. X    /* Return capability to user */
  1248. X    return result;
  1249. X}
  1250. X
  1251. X
  1252. X/** I/O information block definitions **/
  1253. Xstruct iosb {            /* I/O status block            */
  1254. X    short    i_cond;        /* Condition value            */
  1255. X    short    i_xfer;        /* Transfer count            */
  1256. X    long    i_info;        /* Device information            */
  1257. X};
  1258. Xstruct termchar {        /* Terminal characteristics        */
  1259. X    char    t_class;    /* Terminal class            */
  1260. X    char    t_type;        /* Terminal type            */
  1261. X    short    t_width;    /* Terminal width in characters        */
  1262. X    long    t_mandl;    /* Terminal's mode and length        */
  1263. X    long    t_extend;    /* Extended terminal characteristics    */
  1264. X};
  1265. Xstatic struct termchar tc;    /* Terminal characteristics        */
  1266. X
  1267. X/***
  1268. X *  vmsgtty - Get terminal type from system control block
  1269. X *
  1270. X *  Nothing returned
  1271. X ***/
  1272. Xvmsgtty()
  1273. X{
  1274. X    short fd;
  1275. X    int status;
  1276. X    struct iosb iostatus;
  1277. X    $DESCRIPTOR(devnam, "SYS$INPUT");
  1278. X
  1279. X    /* Assign input to a channel */
  1280. X    status = sys$assign(&devnam, &fd, 0, 0);
  1281. X    if ((status & 1) == 0)
  1282. X        exit (status);
  1283. X
  1284. X    /* Get terminal characteristics */
  1285. X    status = sys$qiow(        /* Queue and wait        */
  1286. X        0,            /* Wait on event flag zero    */
  1287. X        fd,            /* Channel to input terminal    */
  1288. X        IO$_SENSEMODE,        /* Get current characteristic    */
  1289. X        &iostatus,        /* Status after operation    */
  1290. X        0, 0,            /* No AST service        */
  1291. X        &tc,            /* Terminal characteristics buf */
  1292. X        sizeof(tc),        /* Size of the buffer        */
  1293. X        0, 0, 0, 0);        /* P3-P6 unused            */
  1294. X
  1295. X    /* De-assign the input device */
  1296. X    if ((sys$dassgn(fd) & 1) == 0)
  1297. X        exit(status);
  1298. X
  1299. X    /* Jump out if bad status */
  1300. X    if ((status & 1) == 0)
  1301. X        exit(status);
  1302. X    if ((iostatus.i_cond & 1) == 0)
  1303. X        exit(iostatus.i_cond);
  1304. X}
  1305. X
  1306. X
  1307. X/***
  1308. X *  vmsopen  -  Get terminal type and open terminal
  1309. X *
  1310. X *  Nothing returned
  1311. X ***/
  1312. Xvmsopen()
  1313. X{
  1314. X    /* Get terminal type */
  1315. X    vmsgtty();
  1316. X    if (tc.t_type == TT$_UNKNOWN) {
  1317. X        printf("Terminal type is unknown!\n");
  1318. X        printf("Try set your terminal type with SET TERMINAL/INQUIRE\n");
  1319. X        printf("Or get help on SET TERMINAL/DEVICE_TYPE\n");
  1320. X        exit(3);
  1321. X    }
  1322. X
  1323. X    /* Access the system terminal definition table for the        */
  1324. X    /* information of the terminal type returned by IO$_SENSEMODE    */
  1325. X    if ((smg$init_term_table_by_type(&tc.t_type, &termtype) & 1) == 0)
  1326. X        return -1;
  1327. X        
  1328. X    /* Set sizes */
  1329. X    term.t_nrow = ((unsigned int) tc.t_mandl >> 24) - 1;
  1330. X    term.t_ncol = tc.t_width;
  1331. X
  1332. X    /* Get some capabilities */
  1333. X    begin_reverse = vmsgetstr(SMG$K_BEGIN_REVERSE);
  1334. X    end_reverse = vmsgetstr(SMG$K_END_REVERSE);
  1335. X    revexist = begin_reverse != NULL && end_reverse != NULL;
  1336. X    erase_to_end_line = vmsgetstr(SMG$K_ERASE_TO_END_LINE);
  1337. X    eolexist = erase_to_end_line != NULL;
  1338. X    erase_whole_display = vmsgetstr(SMG$K_ERASE_WHOLE_DISPLAY);
  1339. X
  1340. X    /* Set resolution */
  1341. X    strcpy(sres, "NORMAL");
  1342. X
  1343. X    /* Open terminal I/O drivers */
  1344. X    ttopen();
  1345. X}
  1346. X
  1347. X
  1348. X/***
  1349. X *  vmskopen  -  Open keyboard (not used)
  1350. X *
  1351. X *  Nothing returned
  1352. X ***/
  1353. Xvmskopen()
  1354. X{
  1355. X}
  1356. X
  1357. X
  1358. X/***
  1359. X *  vmskclose  -  Close keyboard (not used)
  1360. X *
  1361. X *  Nothing returned
  1362. X ***/
  1363. Xvmskclose()
  1364. X{
  1365. X}
  1366. X
  1367. X
  1368. X/***
  1369. X *  fnclabel  -  Label function keys (not used)
  1370. X *
  1371. X *  Nothing returned
  1372. X ***/
  1373. X#if    FLABEL
  1374. Xfnclabel(f, n)        /* label a function key */
  1375. Xint f,n;    /* default flag, numeric argument [unused] */
  1376. X{
  1377. X    /* on machines with no function keys...don't bother */
  1378. X    return(TRUE);
  1379. X}
  1380. X#endif
  1381. X
  1382. X
  1383. X/***
  1384. X *  spal  -  Set palette type  (Are you kidding?)
  1385. X *
  1386. X *  Nothing returned
  1387. X ***/
  1388. Xspal()
  1389. X{
  1390. X}
  1391. X
  1392. X#else
  1393. X
  1394. X/***
  1395. X *  hellovms  -  Avoid error because of empty module
  1396. X *
  1397. X *  Nothing returned
  1398. X ***/
  1399. Xhellovms()
  1400. X{
  1401. X}
  1402. X
  1403. X#endif
  1404. FRIDAY_NIGHT
  1405. echo mes.12 completed!
  1406. # That's all folks!
  1407.  
  1408.  
  1409.