home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / termcap.zoo / termcap.2 < prev    next >
Text File  |  1990-04-04  |  50KB  |  2,251 lines

  1. #!/bin/sh
  2. # this is part.02 (part 2 of tinfo)
  3. # do not concatenate these parts, unpack them in order with /bin/sh
  4. # file tty.c continued
  5. #
  6. touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
  7. if [ -s /tmp/s3_touch$$ ]
  8. then
  9.     TOUCH=can
  10. else
  11.     TOUCH=cannot
  12. fi
  13. rm -f /tmp/s3_touch$$
  14. CurArch=2
  15. if test ! -r s3_seq_.tmp
  16. then echo "Please unpack part 1 first!"
  17.      exit 1; fi
  18. ( read Scheck
  19.   case "$Scheck" in
  20.   "$CurArch") exit 0 ;;
  21.   *)
  22.        echo "Please unpack part $Scheck next!"
  23.        exit 1 ;;
  24.   esac
  25. ) < s3_seq_.tmp || exit 1
  26. echo "x - Continuing file tty.c"
  27. sed 's/^X//' << 'SHAR_EOF' >> tty.c
  28. X
  29. Xint reset_prog_mode() {
  30. X    if (ioctl(cur_term->fd, TIOCSETP, &cur_term->prog_mode.v6) < 0)
  31. X        return ERR;
  32. X#ifdef TIOCGETC
  33. X    if (ioctl(cur_term->fd, TIOCSETC, &cur_term->prog_mode.v7) < 0)
  34. X        return ERR;
  35. X#endif
  36. X#ifdef TIOCLGET
  37. X    if (ioctl(cur_term->fd, TIOCLSET, &cur_term->prog_mode.bsd) < 0)
  38. X        return ERR;
  39. X#endif
  40. X#ifdef TIOCGLTC
  41. X    if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->prog_mode.bsd_new) < 0)
  42. X        return ERR;
  43. X#endif
  44. X    return OK;
  45. X}
  46. X
  47. Xint _init_tty() {
  48. X    cur_term->true_lines = lines;
  49. X    cur_term->true_columns = columns;
  50. X    if (pad_char == NULL)
  51. X        cur_term->padch = '\000';
  52. X    else
  53. X        cur_term->padch = pad_char[0];
  54. X    if (def_shell_mode() == ERR)
  55. X        return ERR;
  56. X    if (def_prog_mode() == ERR)
  57. X        return ERR;
  58. X#ifndef TIOCGETC
  59. X    cur_term->xon = xon_xoff && (xon_character == NULL
  60. X                     || xon_character[0] == '\023')
  61. X                && (xoff_character == NULL
  62. X                || xoff_character[0] == '\021');
  63. X#else
  64. X    if (xon_xoff) {
  65. X        if (xon_character != NULL) {
  66. X            cur_term->prog_mode.v7.t_startc = xon_character[0];
  67. X            if (ioctl(cur_term->fd, TIOCSETC, &cur_term->prog_mode.v7) < 0)
  68. X                return ERR;
  69. X        }
  70. X        if (xoff_character != NULL) {
  71. X            cur_term->prog_mode.v7.t_stopc = xoff_character[0];
  72. X            if (ioctl(cur_term->fd, TIOCSETC,
  73. X                      &cur_term->prog_mode.v7) < 0)
  74. X                return ERR;
  75. X        }
  76. X    }
  77. X    cur_term->xon = xon_xoff;
  78. X#endif
  79. X#ifdef USE_WINSZ
  80. X#ifdef TIOCGWINSZ
  81. X    if (cur_term->prog_mode.bsd_winsz.ws_row != 0
  82. X        && cur_term->prog_mode.bsd_winsz.ws_col != 0) {
  83. X        lines = cur_term->prog_mode.bsd_winsz.ws_row;
  84. X        columns = cur_term->prog_mode.bsd_winsz.ws_col;
  85. X    }
  86. X#endif
  87. X#endif
  88. X    return OK;
  89. X}
  90. X
  91. X#else
  92. X
  93. Xint _lit_output() {
  94. X    return 0;
  95. X}
  96. X
  97. Xvoid _norm_output() {
  98. X    return;
  99. X}
  100. X
  101. X_check_tty() {
  102. X    return OK;
  103. X}
  104. X
  105. Xdef_prog_mode() {
  106. X    return OK;
  107. X}
  108. X
  109. Xreset_prog_mode() {
  110. X    return OK;
  111. X}
  112. X
  113. Xdef_shell_mode() {
  114. X    return OK;
  115. X}
  116. X
  117. Xreset_shell_mode() {
  118. X    return OK;
  119. X}
  120. X
  121. X_init_tty() {
  122. X    cur_term->pad = 1
  123. X    cur_term->padch = 0;
  124. X    cur_term->baudrate = 1200;
  125. X    cur_term->xon = 0;
  126. X    cur_term->termcap = 0;
  127. X    cur_term->true_lines = lines;
  128. X    cur_term->true_columns = columns;
  129. X}
  130. X
  131. X#endif
  132. X
  133. X#endif
  134. X
  135. SHAR_EOF
  136. echo "File tty.c is complete"
  137. chmod 0644 tty.c || echo "restore of tty.c fails"
  138. case $TOUCH in
  139. can)
  140.     touch -am 0402044690 tty.c
  141.     ;;
  142. esac
  143. set `wc -c tty.c`;Wc_c=$1
  144. case "$Wc_c" in
  145. "7042") ;;
  146. *) echo original size 7042, current size $Wc_c ;;
  147. esac
  148. # ============= tparm.c ==============
  149. echo "x - extracting tparm.c (Text)"
  150. sed 's/^X//' << 'SHAR_EOF' > tparm.c &&
  151. X/*
  152. X * tparm.c
  153. X *
  154. X * By Ross Ridge
  155. X * Public Domain
  156. X * 90/03/22 03:43:34
  157. X *
  158. X */
  159. X
  160. X#include "defs.h"
  161. X#include "term.h"
  162. X
  163. X#include <ctype.h>
  164. X
  165. X#ifdef USE_SCCS_IDS
  166. Xstatic char SCCSid[] = "@(#) tparm.c 1.1";
  167. X#endif
  168. X#ifndef MAX_PUSHED
  169. X#define MAX_PUSHED    32
  170. X#endif
  171. X
  172. X#define ARG    1
  173. X#define NUM    2
  174. X
  175. X#define INTEGER    1
  176. X#define STRING    2
  177. X
  178. Xtypedef struct stack_str {
  179. X    int    type;
  180. X    int    argnum;
  181. X    int    value;
  182. X} stack;
  183. X
  184. Xstatic stack S[MAX_PUSHED];
  185. Xstatic stack vars['z'-'a'+1];
  186. Xstatic int pos = 0;
  187. X
  188. Xstatic struct arg_str {
  189. X    int type;
  190. X    int    integer;
  191. X    char    *string;
  192. X} arg_list[10];
  193. X
  194. Xstatic int argcnt;
  195. X
  196. Xstatic va_list tparm_args;
  197. X
  198. Xstatic int pusharg(arg)
  199. Xint arg; {
  200. X    if (pos == MAX_PUSHED)
  201. X        return 1;
  202. X    S[pos].type = ARG;
  203. X    S[pos++].argnum = arg;
  204. X    return 0;
  205. X}
  206. X
  207. Xstatic int pushnum(num)
  208. Xint num; {
  209. X    if (pos == MAX_PUSHED)
  210. X        return 1;
  211. X    S[pos].type = NUM;
  212. X    S[pos++].value = num;
  213. X    return 0;
  214. X}
  215. X
  216. X/* VARARGS2 */
  217. Xstatic int getarg(argnum, type, p)
  218. Xint argnum, type;
  219. Xanyptr p; {
  220. X    while (argcnt < argnum) {
  221. X        arg_list[argcnt].type = INTEGER;
  222. X        arg_list[argcnt++].integer = (int) va_arg(tparm_args, int);
  223. X    }
  224. X    if (argcnt > argnum) {
  225. X        if (arg_list[argnum].type != type)
  226. X            return 1;
  227. X        else if (type == STRING)
  228. X            *(char **)p = arg_list[argnum].string;
  229. X        else 
  230. X            *(int *)p = arg_list[argnum].integer;
  231. X    } else {
  232. X        arg_list[argcnt].type = type;
  233. X        if (type == STRING)
  234. X            *(char **)p = arg_list[argcnt++].string
  235. X                = (char *) va_arg(tparm_args, char *);
  236. X        else
  237. X            *(int *)p = arg_list[argcnt++].integer = (int) va_arg(tparm_args, int);
  238. X    }
  239. X    return 0;
  240. X}
  241. X
  242. X
  243. Xstatic int popstring(str)
  244. Xchar **str; {
  245. X    if (pos-- == 0)
  246. X        return 1;
  247. X    if (S[pos].type != ARG)
  248. X        return 1;
  249. X    return(getarg(S[pos].argnum, STRING, (anyptr) str));
  250. X}
  251. X
  252. Xstatic int popnum(num)
  253. Xint *num; {
  254. X    if (pos-- == 0)
  255. X        return 1;
  256. X    switch (S[pos].type) {
  257. X    case ARG:
  258. X        return (getarg(S[pos].argnum, INTEGER, (anyptr) num));
  259. X    case NUM:
  260. X        *num = S[pos].value;
  261. X        return 0;
  262. X    }
  263. X    return 1;
  264. X}
  265. X
  266. Xstatic int cvtchar(sp, c)
  267. Xregister char *sp, *c; {
  268. X    switch(*sp) {
  269. X    case '\\':
  270. X        switch(*++sp) {
  271. X        case '\'':
  272. X        case '$':
  273. X        case '\\':
  274. X        case '%':
  275. X            *c = *sp;
  276. X            return 2;
  277. X        case '\0':
  278. X            *c = '\\';
  279. X            return 1;
  280. X        case '0':
  281. X            if (sp[1] == '0' && sp[2] == '0') {
  282. X                *c = '\0';
  283. X                return 4;
  284. X            }
  285. X            *c = '\200'; /* '\0' ???? */
  286. X            return 2;
  287. X        default:
  288. X            *c = *sp;
  289. X            return 2;
  290. X        }
  291. X    default:
  292. X        *c = *sp;
  293. X        return 1;
  294. X    }
  295. X}
  296. X
  297. Xstatic int termcap;
  298. X
  299. X/* sigh... this has got to be the ugliest code I've ever written.
  300. X   Trying to handle everything has its cost, I guess.
  301. X
  302. X   It actually isn't to hard to figure out if a given % code is supposed
  303. X   to be interpeted with its termcap or terminfo meaning since almost
  304. X   all terminfo codes are invalid unless something has been pushed on
  305. X   the stack and termcap strings will never push things on the stack
  306. X   (%p isn't used by termcap). So where we have a choice we make the
  307. X   decision by wether or not somthing has been pushed on the stack.
  308. X   The static variable termcap keeps track of this; it starts out set
  309. X   to 1 and is incremented as each argument processed by a termcap % code,
  310. X   however if something is pushed on the stack it's set to 0 and the
  311. X   rest of the % codes are interpeted as terminfo % codes. Another way
  312. X   of putting it is that if termcap equals one we haven't decided either
  313. X   way yet, if it equals zero we're looking for terminfo codes, and if
  314. X   its greater than 1 we're looking for termcap codes.
  315. X
  316. X   Terminfo % codes:
  317. X
  318. X    %%    output a '%'
  319. X    %[[:][-+# ][width][.precision]][doxXs]
  320. X        output pop according to the printf format
  321. X    %c    output pop as a char
  322. X    %'c'    push character constant c.
  323. X    %{n}    push decimal constant n.
  324. X    %p[1-9] push paramter [1-9]
  325. X    %g[a-z] push variable [a-z]
  326. X    %P[a-z] put pop in variable [a-z]
  327. X    %l    push the length of pop (a string)
  328. X    %+    add pop to pop and push the result
  329. X    %-    subtract pop from pop and push the result
  330. X    %*    multiply pop and pop and push the result
  331. X    %&    bitwise and pop and pop and push the result
  332. X    %|    bitwise or pop and pop and push the result
  333. X    %^    bitwise xor pop and pop and push the result
  334. X    %~    push the bitwise not of pop
  335. X    %=    compare if pop and pop are equal and push the result
  336. X    %>    compare if pop is less than pop and push the result
  337. X    %<    compare if pop is greater than pop and push the result
  338. X    %A    logical and pop and pop and push the result
  339. X    %O    logical or pop and pop and push the result
  340. X    %!    push the logical not of pop
  341. X    %? condition %t if_true [%e if_false] %;
  342. X        if condtion evaulates as true then evaluate if_true,
  343. X        else evaluate if_false. elseif's can be done:
  344. X%? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %;
  345. X    %i    add one to parameters 1 and 2. (ANSI)
  346. X
  347. X  Termcap Codes:
  348. X
  349. X    %%    output a %
  350. X    %.    output parameter as a character
  351. X    %d    output parameter as a decimal number
  352. X    %2    output parameter in printf format %02d
  353. X    %3    output parameter in printf format %03d
  354. X    %+x    add the character x to parameter and output it as a character
  355. X(UW)    %-x    subtract parameter FROM the character x and output it as a char
  356. X(UW)    %ax    add the character x to parameter
  357. X(GNU)    %a[+*-/=][cp]x
  358. X        GNU arithmetic. 
  359. X(UW)    %sx    subtract parameter FROM the character x
  360. X    %>xy    if parameter > character x then add character y to parameter
  361. X    %B    convert to BCD (parameter = (parameter/10)*16 + parameter%16)
  362. X    %D    Delta Data encode (parameter = parameter - 2*(paramter%16))
  363. X    %i    increment the first two parameters by one
  364. X    %n    xor the first two parameters by 0140
  365. X(GNU)    %m    xor the first two parameters by 0177
  366. X    %r    swap the first two parameters
  367. X(GNU)    %b    backup to previous parameter
  368. X(GNU)    %f    skip this parameter
  369. X
  370. X  Note the two definitions of %a, the GNU defintion is used if the characters
  371. X  after the 'a' are valid, otherwise the UW definition is used.
  372. X
  373. X  (GNU) used by GNU Emacs termcap libraries
  374. X  (UW) used by the University of Waterloo (MFCF) termcap libraries
  375. X
  376. X*/
  377. X
  378. X#ifdef lint
  379. X/* VARARGS1 */
  380. Xchar *tparm(str)
  381. Xchar *str; {
  382. X#else /* lint */
  383. X#ifdef USE_STDARG
  384. X#ifdef USE_PROTOTYPES
  385. Xchar *tparm(char *str, ...) {
  386. X#else /* USE_PROTOTYPES */
  387. Xchar *tparm(str)
  388. Xchar *str; {
  389. X#endif /* USE_PROTOTYPES */
  390. X#else /* USE_STDARG */
  391. Xchar *tparm(va_alist)
  392. Xva_dcl {
  393. X    char *str;
  394. X#endif
  395. X#endif
  396. X    static char OOPS[] = "OOPS";
  397. X    static char buf[MAX_LINE];
  398. X    register char *sp, *dp;
  399. X    register char *fmt;
  400. X    char conv_char;
  401. X    char scan_for;
  402. X    int scan_depth, if_depth;
  403. X    static int i, j;
  404. X    static char *s, c;
  405. X    char fmt_buf[MAX_LINE];
  406. X    char sbuf[MAX_LINE];
  407. X
  408. X#ifdef lint
  409. X    scan_depth = 0;
  410. X#else
  411. X#ifdef USE_STDARG
  412. X    va_start(tparm_args, str);
  413. X#else
  414. X    va_start(tparm_args);
  415. X    str = (char *) va_arg(tparm_args, char *);
  416. X#endif
  417. X#endif
  418. X
  419. X    sp = str;
  420. X    dp = buf;
  421. X    scan_for = 0;
  422. X    if_depth = 0;
  423. X    argcnt = 0;
  424. X    pos = 0;
  425. X    termcap = 1;
  426. X    while(*sp != '\0') {
  427. X        switch(*sp) {
  428. X        case '\\':
  429. X            if (scan_for) {
  430. X                if (*++sp != '\0')
  431. X                    sp++;
  432. X                break;
  433. X            }
  434. X            *dp++ = *sp++;
  435. X            if (*sp != '\0')
  436. X                *dp++ = *sp++;
  437. X            break;
  438. X        case '%':
  439. X            sp++;
  440. X            if (scan_for) {
  441. X                if (*sp == scan_for && if_depth == scan_depth) {
  442. X                    if (scan_for == ';')
  443. X                        if_depth--;
  444. X                    scan_for = 0;
  445. X                } else if (*sp == '?')
  446. X                    if_depth++;
  447. X                else if (*sp == ';') {
  448. X                    if (if_depth == 0)
  449. X                        return OOPS;
  450. X                    else
  451. X                        if_depth--;
  452. X                }
  453. X                sp++;
  454. X                break;
  455. X            }
  456. X            fmt = NULL;
  457. X            switch(*sp) {
  458. X            case '%':
  459. X                *dp++ = *sp++;
  460. X                break;
  461. X            case '+':
  462. X                if (!termcap) {
  463. X                    if (popnum(&j) || popnum(&i))
  464. X                        return OOPS;
  465. X                    i += j;
  466. X                    if (pushnum(i))
  467. X                        return OOPS;
  468. X                    sp++;
  469. X                    break;
  470. X                }
  471. X                ;/* FALLTHROUGH */
  472. X            case 'C':
  473. X                if (*sp == 'C') { 
  474. X                    if (getarg(termcap - 1, INTEGER, &i))
  475. X                        return OOPS;
  476. X                    if (i >= 96) {
  477. X                        i /= 96;
  478. X                        if (i == '$')
  479. X                            *dp++ = '\\';
  480. X                        *dp++ = i;
  481. X                    }
  482. X                }
  483. X                fmt = "%c";
  484. X                /* FALLTHROUGH */
  485. X            case 'a':
  486. X                if (!termcap)
  487. X                    return OOPS;
  488. X                if (getarg(termcap - 1, INTEGER, (anyptr) &i))
  489. X                    return OOPS;
  490. X                if (*++sp == '\0')
  491. X                    return OOPS;
  492. X                if ((sp[1] == 'p' || sp[1] == 'c')
  493. X                        && sp[2] != '\0' && fmt == NULL) {
  494. X                    /* GNU aritmitic parameter, what they
  495. X                       realy need is terminfo.          */
  496. X                    int val, lc;
  497. X                    if (sp[1] == 'p'
  498. X                        && getarg(termcap - 1 + sp[2] - '@',
  499. X                              INTEGER, (anyptr) &val))
  500. X                        return OOPS;
  501. X                    if (sp[1] == 'c') {
  502. X                        lc = cvtchar(sp + 2, &c) + 2;
  503. X                    /* Mask out 8th bit so \200 can be
  504. X                       used for \0 as per GNU doc's    */
  505. X                        val = c & 0177;
  506. X                    } else
  507. X                        lc = 2;
  508. X                    switch(sp[0]) {
  509. X                    case '=':
  510. X                        break;
  511. X                    case '+':
  512. X                        val = i + val;
  513. X                        break;
  514. X                    case '-':
  515. X                        val = i - val;
  516. X                        break;
  517. X                    case '*':
  518. X                        val = i * val;
  519. X                        break;
  520. X                    case '/':
  521. X                        val = i / val;
  522. X                        break;
  523. X                    default:
  524. X                    /* Not really GNU's %a after all... */
  525. X                        lc = cvtchar(sp, &c);
  526. X                        val = c + i;
  527. X                        break;
  528. X                    }
  529. X                    arg_list[termcap - 1].integer = val;
  530. X                    sp += lc;
  531. X                    break;
  532. X                }
  533. X                sp += cvtchar(sp, &c);
  534. X                arg_list[termcap - 1].integer = c + i;
  535. X                if (fmt == NULL)
  536. X                    break;
  537. X                sp--;
  538. X                /* FALLTHROUGH */
  539. X            case '-':
  540. X                if (!termcap) {
  541. X                    if (popnum(&j) || popnum(&i))
  542. X                        return OOPS;
  543. X                    i -= j;
  544. X                    if (pushnum(i))
  545. X                        return OOPS;
  546. X                    sp++;
  547. X                    break;
  548. X                }
  549. X                fmt = "%c";
  550. X                /* FALLTHROUGH */
  551. X            case 's':
  552. X                if (termcap && (fmt == NULL || *sp == '-')) {
  553. X                    if (getarg(termcap - 1, INTEGER, &i))
  554. X                        return OOPS;
  555. X                    if (*++sp == '\0')
  556. X                        return OOPS;
  557. X                    sp += cvtchar(sp, &c);
  558. X                    arg_list[termcap - 1].integer = c - i;
  559. X                    if (fmt == NULL)
  560. X                        break;
  561. X                    sp--;
  562. X                }
  563. X                if (!termcap)
  564. X                    return OOPS;
  565. X                ;/* FALLTHROUGH */
  566. X            case '.':
  567. X                if (termcap && fmt == NULL) 
  568. X                    fmt = "%c";
  569. X                ;/* FALLTHROUGH */
  570. X            case 'd':
  571. X                if (termcap && fmt == NULL) 
  572. X                    fmt = "%d";
  573. X                ;/* FALLTHROUGH */
  574. X            case '2':
  575. X                if (termcap && fmt == NULL)
  576. X                    fmt = "%02d";
  577. X                ;/* FALLTHROUGH */
  578. X            case '3':
  579. X                if (termcap && fmt == NULL) 
  580. X                    fmt = "%03d";
  581. X                ;/* FALLTHROUGH */
  582. X            case ':': case ' ': case '#': case 'u':
  583. X            case 'x': case 'X': case 'o': case 'c':
  584. X            case '0': case '1': case '4': case '5':
  585. X            case '6': case '7': case '8': case '9':
  586. X                if (fmt == NULL) {
  587. X                    if (termcap)
  588. X                        return OOPS;
  589. X                    if (*sp == ':')
  590. X                        sp++;
  591. X                    fmt = fmt_buf;
  592. X                    *fmt++ = '%';
  593. X                    while(*sp != 's' && *sp != 'x' && *sp != 'X' && *sp != 'd' && *sp != 'o' && *sp != 'c' && *sp != 'u') {
  594. X                        if (*sp == '\0')
  595. X                            return OOPS;
  596. X                        *fmt++ = *sp++;
  597. X                    }
  598. X                    *fmt++ = *sp;
  599. X                    *fmt = '\0';
  600. X                    fmt = fmt_buf;
  601. X                }
  602. X                conv_char = fmt[strlen(fmt - 1)];
  603. X                if (conv_char == 's') {
  604. X                    if (popstring(&s))
  605. X                        return OOPS;
  606. X                    sprintf(sbuf, fmt, s);
  607. X                } else {
  608. X                    if (termcap) {
  609. X                        if (getarg(termcap++ - 1,
  610. X                               INTEGER, &i))
  611. X                            return OOPS;
  612. X                    } else
  613. X                        if (popnum(&i))
  614. X                            return OOPS;
  615. X                    if (i == 0 && conv_char == 'c')
  616. X                        strcpy(sbuf, "\000");
  617. X                    else
  618. X                        sprintf(sbuf, fmt, i);
  619. X                }
  620. X                sp++;
  621. X                fmt = sbuf;
  622. X                while(*fmt != '\0') {
  623. X                    if (*fmt == '$') 
  624. X                        *dp++ = '\\';
  625. X                    *dp++ = *fmt++;
  626. X                }
  627. X                break;
  628. X            case 'r':
  629. X                if (!termcap || getarg(1, INTEGER, &i))
  630. X                    return OOPS;
  631. X                arg_list[1].integer = arg_list[0].integer;
  632. X                arg_list[0].integer = i;
  633. X                sp++;
  634. X                break;
  635. X            case 'i':
  636. X                if (getarg(1, INTEGER, &i)
  637. X                    || arg_list[0].type != INTEGER)
  638. X                    return OOPS;
  639. X                arg_list[1].integer++;
  640. X                arg_list[0].integer++;
  641. X                sp++;
  642. X                break;
  643. X            case 'n':
  644. X                if (!termcap || getarg(1, INTEGER, &i))
  645. X                    return OOPS;
  646. X                arg_list[0].integer ^= 0140;
  647. X                arg_list[1].integer ^= 0140;
  648. X                sp++;
  649. X                break;
  650. X            case '>':
  651. X                if (!termcap) {
  652. X                    if (popnum(&j) || popnum(&i))
  653. X                        return OOPS;
  654. X                    i = (i > j);
  655. X                    if (pushnum(i))
  656. X                        return OOPS;
  657. X                    sp++;
  658. X                    break;
  659. X                }
  660. X                if (getarg(termcap-1, INTEGER, &i))
  661. X                    return OOPS;
  662. X                sp += cvtchar(sp, &c);
  663. X                if (i > c) {
  664. X                    sp += cvtchar(sp, &c);
  665. X                    arg_list[termcap-1].integer += c;
  666. X                } else
  667. X                    sp += cvtchar(sp, &c);
  668. X                sp++;
  669. X                break;
  670. X            case 'B':
  671. X                if (!termcap || getarg(termcap-1, INTEGER, &i))
  672. X                    return OOPS;
  673. X                arg_list[termcap-1].integer = 16*(i/10)+i%10;
  674. X                sp++;
  675. X                break;
  676. X            case 'D':
  677. X                if (!termcap || getarg(termcap-1, INTEGER, &i))
  678. X                    return OOPS;
  679. X                arg_list[termcap-1].integer = i - 2 * (i % 16);
  680. X                sp++;
  681. X                break;
  682. X            case 'p':
  683. X                if (termcap > 1)
  684. X                    return OOPS;
  685. X                if (*++sp == '\0')
  686. X                    return OOPS;
  687. X                if (*sp == '0')
  688. X                    i = 9;
  689. X                else
  690. X                    i = *sp - '1';
  691. X                if (i < 0 || i > 9)
  692. X                    return OOPS;
  693. X                if (pusharg(i))
  694. X                    return OOPS;
  695. X                termcap = 0;
  696. X                sp++;
  697. X                break;
  698. X            case 'P':
  699. X                if (termcap || *++sp == '\0')
  700. X                    return OOPS;
  701. X                i = *sp++ - 'a';
  702. X                if (i < 0 || i > 25)
  703. X                    return OOPS;
  704. X                if (pos-- == 0)
  705. X                    return OOPS;
  706. X                switch(vars[i].type = S[pos].type) {
  707. X                case ARG:
  708. X                    vars[i].argnum = S[pos].argnum;
  709. X                    break;
  710. X                case NUM:
  711. X                    vars[i].value = S[pos].value;
  712. X                    break;
  713. X                }
  714. X                break;
  715. X            case 'g':
  716. X                if (termcap || *++sp == '\0')
  717. X                    return OOPS;
  718. X                i = *sp++ - 'a';
  719. X                if (i < 0 || i > 25)
  720. X                    return OOPS;
  721. X                switch(vars[i].type) {
  722. X                case ARG:
  723. X                    if (pusharg(vars[i].argnum))
  724. X                        return OOPS;
  725. X                    break;
  726. X                case NUM:
  727. X                    if (pushnum(vars[i].value))
  728. X                        return OOPS;
  729. X                    break;
  730. X                }
  731. X                break;
  732. X            case '\'':
  733. X                if (termcap > 1)
  734. X                    return OOPS;
  735. X                if (*++sp == '\0')
  736. X                    return OOPS;
  737. X                sp += cvtchar(sp, &c);
  738. X                if (pushnum(c) || *sp++ != '\'')
  739. X                    return OOPS;
  740. X                termcap = 0;
  741. X                break;
  742. X            case '{':
  743. X                if (termcap > 1)
  744. X                    return OOPS;
  745. X                i = 0;
  746. X                sp++;
  747. X                while(isdigit(*sp))
  748. X                    i = 10 * i + *sp++ - '0';
  749. X                if (*sp++ != '}' || pushnum(i))
  750. X                    return OOPS;
  751. X                termcap = 0;
  752. X                break;
  753. X            case 'l':
  754. X                if (termcap || popstring(&s))
  755. X                    return OOPS;
  756. X                i = strlen(s);
  757. X                if (pushnum(i))
  758. X                    return OOPS;
  759. X                sp++;
  760. X                break;
  761. X            case '*':
  762. X                if (termcap || popnum(&j) || popnum(&i))
  763. X                    return OOPS;
  764. X                i *= j;
  765. X                if (pushnum(i))
  766. X                    return OOPS;
  767. X                sp++;
  768. X                break;
  769. X            case '/':
  770. X                if (termcap || popnum(&j) || popnum(&i))
  771. X                    return OOPS;
  772. X                i /= j;
  773. X                if (pushnum(i))
  774. X                    return OOPS;
  775. X                sp++;
  776. X                break;
  777. X            case 'm':
  778. X                if (termcap) {
  779. X                    if (getarg(1, INTEGER, &i))
  780. X                        return OOPS;
  781. X                    arg_list[0].integer ^= 0177;
  782. X                    arg_list[1].integer ^= 0177;
  783. X                    sp++;
  784. X                    break;
  785. X                }
  786. X                if (popnum(&j) || popnum(&i))
  787. X                    return OOPS;
  788. X                i %= j;
  789. X                if (pushnum(i))
  790. X                    return OOPS;
  791. X                sp++;
  792. X                break;
  793. X            case '&':
  794. X                if (popnum(&j) || popnum(&i))
  795. X                    return OOPS;
  796. X                i &= j;
  797. X                if (pushnum(i))
  798. X                    return OOPS;
  799. X                sp++;
  800. X                break;
  801. X            case '|':
  802. X                if (popnum(&j) || popnum(&i))
  803. X                    return OOPS;
  804. X                i |= j;
  805. X                if (pushnum(i))
  806. X                    return OOPS;
  807. X                sp++;
  808. X                break;
  809. X            case '^':
  810. X                if (popnum(&j) || popnum(&i))
  811. X                    return OOPS;
  812. X                i ^= j;
  813. X                if (pushnum(i))
  814. X                    return OOPS;
  815. X                sp++;
  816. X                break;
  817. X            case '=':
  818. X                if (popnum(&j) || popnum(&i))
  819. X                    return OOPS;
  820. X                i = (i == j);
  821. X                if (pushnum(i))
  822. X                    return OOPS;
  823. X                sp++;
  824. X                break;
  825. X            case '<':
  826. X                if (popnum(&j) || popnum(&i))
  827. X                    return OOPS;
  828. X                i = (i < j);
  829. X                if (pushnum(i))
  830. X                    return OOPS;
  831. X                sp++;
  832. X                break;
  833. X            case 'A':
  834. X                if (popnum(&j) || popnum(&i))
  835. X                    return OOPS;
  836. X                i = (i && j);
  837. X                if (pushnum(i))
  838. X                    return OOPS;
  839. X                sp++;
  840. X                break;
  841. X            case 'O':
  842. X                if (popnum(&j) || popnum(&i))
  843. X                    return OOPS;
  844. X                i = (i || j);
  845. X                if (pushnum(i))
  846. X                    return OOPS;
  847. X                sp++;
  848. X                break;
  849. X            case '!':
  850. X                if (popnum(&i))
  851. X                    return OOPS;
  852. X                i = !i;
  853. X                if (pushnum(i))
  854. X                    return OOPS;
  855. X                sp++;
  856. X                break;
  857. X            case '~':
  858. X                if (popnum(&i))
  859. X                    return OOPS;
  860. X                i = ~i;
  861. X                if (pushnum(i))
  862. X                    return OOPS;
  863. X                sp++;
  864. X                break;
  865. X            case '?':
  866. X                if (termcap > 1)
  867. X                    return OOPS;
  868. X                termcap = 0;
  869. X                if_depth++;
  870. X                sp++;
  871. X                break;
  872. X            case 't':
  873. X                if (popnum(&i) || if_depth == 0)
  874. X                    return OOPS;
  875. X                if (!i) {
  876. X                    scan_for = 'e';
  877. X                    scan_depth = if_depth;
  878. X                }
  879. X                sp++;
  880. X                break;
  881. X            case 'e':
  882. X                if (if_depth == 0)
  883. X                    return OOPS;
  884. X                scan_for = ';';
  885. X                scan_depth = if_depth;
  886. X                sp++;
  887. X                break;
  888. X            case ';':
  889. X                if (if_depth-- == 0)
  890. X                    return OOPS;
  891. X                sp++;
  892. X                break;
  893. X            case 'b':
  894. X                if (--termcap < 1)
  895. X                    return OOPS;
  896. X                sp++;
  897. X                break;
  898. X            case 'f':
  899. X                if (!termcap++)
  900. X                    return OOPS;
  901. X                sp++;
  902. X                break;
  903. X            }
  904. X            break;
  905. X        default:
  906. X            if (scan_for)
  907. X                sp++;
  908. X            else
  909. X                *dp++ = *sp++;
  910. X            break;
  911. X        }
  912. X    }
  913. X    va_end(tparm_args);
  914. X    *dp = '\0';
  915. X    return buf;
  916. X}
  917. X
  918. X#ifdef TEST
  919. X
  920. Xvoid putch(c)
  921. Xint c; {
  922. X    c &= 0xff;
  923. X    if (c > 127 || c < 0) {
  924. X        printf("\\%03o", c);
  925. X    } else if (c < 32) {
  926. X        printf("^%c", c + '@');
  927. X    } else if (c == 127) {
  928. X        printf("^?");
  929. X    } else {
  930. X        putchar(c);
  931. X    }
  932. X}
  933. X
  934. Xchar line[MAX_LINE];
  935. X
  936. Xint main(argc, argv)
  937. Xint argc;
  938. Xchar **argv; {
  939. X    register char *sp;
  940. X    putchar('\n');
  941. X
  942. X    while(gets(line) != NULL) {
  943. X        sp = tparm(line, 1, -2, 30, 0, "bob was here");
  944. X        while(*sp)
  945. X            putch(*sp++);
  946. X        putchar('\n');
  947. X    }
  948. X    return 0;
  949. X}
  950. X#endif
  951. SHAR_EOF
  952. chmod 0644 tparm.c || echo "restore of tparm.c fails"
  953. case $TOUCH in
  954. can)
  955.     touch -am 0402044690 tparm.c
  956.     ;;
  957. esac
  958. set `wc -c tparm.c`;Wc_c=$1
  959. case "$Wc_c" in
  960. "16585") ;;
  961. *) echo original size 16585, current size $Wc_c ;;
  962. esac
  963. # ============= tiget.c ==============
  964. echo "x - extracting tiget.c (Text)"
  965. sed 's/^X//' << 'SHAR_EOF' > tiget.c &&
  966. X/*
  967. X * tiget.c
  968. X *
  969. X * By Ross Ridge
  970. X * Public Domain
  971. X * 90/03/22 03:43:36
  972. X *
  973. X * The various tiget terminfo functions.
  974. X */
  975. X
  976. X#include "defs.h"
  977. X#include "term.h"
  978. X
  979. X#ifdef USE_SCCS_IDS
  980. Xstatic char SCCSid[] = "@(#) tiget.c 1.1";
  981. X#endif
  982. Xextern char **_sboolnames[], **_snumnames[], **_sstrnames[];
  983. X
  984. Xextern int _compar();
  985. X
  986. Xstatic char **p2p2c;
  987. X
  988. Xint tigetnum(cap)
  989. Xchar *cap; {
  990. X    register char ***match;
  991. X    p2p2c = ∩
  992. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumnames,
  993. X                   NUM_OF_NUMS, sizeof(char **), _compar);
  994. X    if (match == NULL)
  995. X        return -2;
  996. X    return cur_term->nums[*match - numnames];
  997. X}
  998. X
  999. Xint tigetflag(cap)
  1000. Xchar *cap; {
  1001. X    register char ***match;
  1002. X    p2p2c = ∩
  1003. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolnames,
  1004. X                   NUM_OF_BOOLS, sizeof(char **), _compar);
  1005. X    if (match == NULL)
  1006. X        return -1;
  1007. X    return cur_term->bools[*match - boolnames];
  1008. X}
  1009. X
  1010. Xchar *tigetstr(cap)
  1011. Xchar *cap; {
  1012. X    register char ***match;
  1013. X    p2p2c = ∩
  1014. X    match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrnames,
  1015. X                   NUM_OF_STRS, sizeof(char **), _compar);
  1016. X    if (match == NULL)
  1017. X        return (char *) -1;
  1018. X    return cur_term->strs[*match - strnames];
  1019. X}
  1020. X
  1021. X
  1022. SHAR_EOF
  1023. chmod 0644 tiget.c || echo "restore of tiget.c fails"
  1024. case $TOUCH in
  1025. can)
  1026.     touch -am 0402044690 tiget.c
  1027.     ;;
  1028. esac
  1029. set `wc -c tiget.c`;Wc_c=$1
  1030. case "$Wc_c" in
  1031. "1141") ;;
  1032. *) echo original size 1141, current size $Wc_c ;;
  1033. esac
  1034. # ============= tgoto.c ==============
  1035. echo "x - extracting tgoto.c (Text)"
  1036. sed 's/^X//' << 'SHAR_EOF' > tgoto.c &&
  1037. X/*
  1038. X * tgoto.c
  1039. X *
  1040. X * By Ross Ridge
  1041. X * Public Domain
  1042. X * 90/03/22 03:43:36
  1043. X *
  1044. X * A few kludged attempts to worry outputing ^D's and NL's...
  1045. X * My advice is to get a decent terminal.
  1046. X *
  1047. X */
  1048. X
  1049. X#include "defs.h"
  1050. X#include "term.h"
  1051. X
  1052. X#ifdef USE_SCCS_IDS
  1053. Xstatic char SCCSid[] = "@(#) tgoto.c 1.1";
  1054. X#endif
  1055. X#ifdef USE_LITOUT_KLUDGE
  1056. X
  1057. X/*
  1058. X * This kludge works by telling tputs to switch the tty driver to
  1059. X * "literal output" when printing the string so we don't have worry
  1060. X * about newlines and EOTs. The problem is that ioctls used to
  1061. X * switch modes might flush buffers and cause other problems.
  1062. X */
  1063. X
  1064. X
  1065. Xchar *tgoto(str, x, y)
  1066. Xchar *str;
  1067. Xint x,y; {
  1068. X    register char *sp;
  1069. X    
  1070. X    static char buf[MAX_LINE] = {'\\', '@'};
  1071. X
  1072. X    sp = str = tparm(str, y, x);
  1073. X
  1074. X    while (*sp != '\0') {
  1075. X        if (*sp == '\004' || *sp == '\n') {
  1076. X            strncpy(buf + 2, str, MAX_LINE - 2);
  1077. X            buf[MAX_LINE - 2] = '\0';
  1078. X            return buf;
  1079. X        }
  1080. X        sp++;
  1081. X    }
  1082. X    return sp;
  1083. X}
  1084. X#else
  1085. X
  1086. X#ifdef USE_UPBC_KLUDGE
  1087. X
  1088. X#ifdef USE_EXTERN_UPBC
  1089. Xextern char *BC, *UP;
  1090. X#else
  1091. X#define BC    cursor_left
  1092. X#define UP    cursor_right
  1093. X#endif
  1094. X
  1095. X#ifdef __GNUC__
  1096. X__inline__
  1097. X#endif
  1098. Xstatic int checkit(s)
  1099. Xregister char *s; {
  1100. X    while(*s != '\0') {
  1101. X        if (*s == '\004' || *s == '\n')
  1102. X            return 1;
  1103. X        s++;
  1104. X    }
  1105. X    return 0;
  1106. X}
  1107. X
  1108. X/*
  1109. X * Major kludge, basically we just changing the parmeters until we get
  1110. X * a string that doesn't contain a newline or EOT.
  1111. X */
  1112. X
  1113. Xchar *tgoto(str, x, y)
  1114. Xchar *str;
  1115. Xint x,y; {
  1116. X    static char buf[MAX_LINE];
  1117. X    register char *orig, *s;
  1118. X    int l;
  1119. X
  1120. X    orig = tparm(str, y, x);
  1121. X
  1122. X    if (!checkit(orig))
  1123. X        return orig;
  1124. X
  1125. X    s = tparm(str, y + 1, x);
  1126. X
  1127. X    if (!checkit(s)) {
  1128. X        if (BC == NULL)
  1129. X            return s;
  1130. X        l = strlen(s);
  1131. X        strncpy(buf, s, MAX_LINE - 1);
  1132. X        if (l < MAX_LINE - 1)
  1133. X            strncpy(buf + l, BC, MAX_LINE - 1 - l);
  1134. X        return s;
  1135. X    }
  1136. X
  1137. X    s = tparm(str, y, x + 1);
  1138. X
  1139. X    if (!checkit(s)) {
  1140. X        if (UP == NULL)
  1141. X            return s;
  1142. X        l = strlen(s);
  1143. X        strncpy(buf, s, MAX_LINE - 1);
  1144. X        if (l < MAX_LINE - 1)
  1145. X            strncpy(buf + l, UP, MAX_LINE - 1 - l);
  1146. X        return s;
  1147. X    }
  1148. X
  1149. X    s = tparm(str, y + 1, x + 1);
  1150. X
  1151. X    if (!checkit(s)) {
  1152. X        if (UP == NULL || BC == NULL)
  1153. X            return s;
  1154. X        l = strlen(s);
  1155. X        strncpy(buf, s, MAX_LINE - 1);
  1156. X        if (l < MAX_LINE - 1)
  1157. X            strncpy(buf + l, UP, MAX_LINE - 1 - l);
  1158. X        l += strlen(UP);
  1159. X        if (l < MAX_LINE - 1)
  1160. X            strncpy(buf + l, BC, MAX_LINE - 1 - l);
  1161. X        return s;
  1162. X    }
  1163. X
  1164. X    return orig;
  1165. X}
  1166. X
  1167. X#else
  1168. X
  1169. X/* the simple tgoto, don't worry about any of this newline/EOT crap */
  1170. X
  1171. Xchar *tgoto(str, x, y)
  1172. Xchar *str;
  1173. Xint x,y; {
  1174. X    return tparm(str, y, x);
  1175. X}
  1176. X
  1177. X#endif
  1178. X
  1179. X#endif
  1180. SHAR_EOF
  1181. chmod 0644 tgoto.c || echo "restore of tgoto.c fails"
  1182. case $TOUCH in
  1183. can)
  1184.     touch -am 0402044690 tgoto.c
  1185.     ;;
  1186. esac
  1187. set `wc -c tgoto.c`;Wc_c=$1
  1188. case "$Wc_c" in
  1189. "2435") ;;
  1190. *) echo original size 2435, current size $Wc_c ;;
  1191. esac
  1192. # ============= buildpath.c ==============
  1193. echo "x - extracting buildpath.c (Text)"
  1194. sed 's/^X//' << 'SHAR_EOF' > buildpath.c &&
  1195. X/*
  1196. X * buildpath.c
  1197. X * 
  1198. X * By Ross Ridge
  1199. X * Public Domain
  1200. X * 90/03/22 03:43:37
  1201. X *
  1202. X * _buildpath builds a list of file names and terminal descriprions extracted
  1203. X * from its arguments. It returns a pointer to a structure that is used by
  1204. X * other routines as the list of file names to search for terminal
  1205. X * descriptions.  It is passed a variable number of arguments consisting
  1206. X * of file name and type pairs. The file name can actually be a list of 
  1207. X * file names seperated by spaces and any environment variables specified
  1208. X * by a dollar sign ($) followed by its name are substituted in. A type
  1209. X * of 1 indicates that the file name may actually be termcap description
  1210. X * and a type of 2 indicates it may be a terminfo description. A type of 0
  1211. X * indicates that the file name can only be a file name (or list of them).
  1212. X *
  1213. X */
  1214. X
  1215. X#include "defs.h"
  1216. X
  1217. X#include <ctype.h>
  1218. X
  1219. X#ifdef USE_SCCS_IDS
  1220. Xstatic char SCCSid[] = "@(#) buildpath.c 1.1";
  1221. X#endif
  1222. X/* more memory is allocated for file names every HUNK file names */
  1223. X#define HUNK 32    
  1224. X
  1225. X/* characters that seperate file names in a list */
  1226. X#define SEPERATORS " :"
  1227. X
  1228. Xstatic struct term_path *path = NULL;    /* the list of files */
  1229. Xstatic int files = 0;            /* # of files in the list */
  1230. Xstatic int size = 0;            /* # of files there is space for */
  1231. X
  1232. X/* add a file name, type pair to the list */
  1233. Xstatic int addfile(file, type)
  1234. Xchar *file;
  1235. Xint type; {
  1236. X    int l;
  1237. X    char *s, *getenv();
  1238. X
  1239. X    if (file == NULL) {
  1240. X        if (type != -1)
  1241. X            return -1;
  1242. X    } else if (file[0] == '\0')
  1243. X        return -1;
  1244. X
  1245. X#ifdef DEBUG
  1246. X    if (file != NULL)
  1247. X        printf("addfile: %s\n", file);
  1248. X#endif
  1249. X
  1250. X    if (files >= size) {
  1251. X        size += HUNK;
  1252. X        if (path == NULL)
  1253. X            path = (struct term_path *) 
  1254. X                malloc(size * sizeof(struct term_path));
  1255. X        else
  1256. X            path = (struct term_path *)
  1257. X                realloc(path, size * sizeof(struct term_path));
  1258. X        if (path == NULL)
  1259. X            return 0;
  1260. X    }
  1261. X    if (file == NULL) {
  1262. X        path[files].file = file;
  1263. X    } else {
  1264. X        l = strlen(file) + 1;
  1265. X        s = (char *) malloc(l * sizeof(char));
  1266. X        if (s == NULL)
  1267. X            return 0;
  1268. X        path[files].file = strcpy(s, file);
  1269. X    }
  1270. X    path[files].type = type;
  1271. X    
  1272. X    return ++files;
  1273. X}
  1274. X
  1275. X/* deallocate space used by the path list */
  1276. Xvoid _delpath(ppath)
  1277. Xstruct term_path *ppath; {
  1278. X    struct term_path *p;
  1279. X
  1280. X    p = ppath;
  1281. X    while(p->file != NULL) {
  1282. X        free(p->file);
  1283. X        p++;
  1284. X    }
  1285. X
  1286. X    free(ppath);
  1287. X}
  1288. X
  1289. X/* build a list of paths. see above */
  1290. X#ifdef lint
  1291. X/*VARARGS2*/
  1292. Xstruct term_path *_buildpath(file, type)
  1293. Xchar *file;
  1294. Xint type;
  1295. X#else
  1296. X#ifdef USE_STDARG
  1297. X#ifdef USE_PROTOTYPES
  1298. Xstruct term_path *_buildpath(char *file, int type, ...)
  1299. X#else
  1300. Xstruct term_path *_buildpath(file, type)
  1301. Xchar *file;
  1302. Xint type;
  1303. X#endif /* USE_PROTOTYPES */
  1304. X#else /* USE_STDARG */
  1305. Xstruct term_path *_buildpath(va_alist)
  1306. Xva_dcl
  1307. X#endif /* USE_STDARG */
  1308. X#endif /* lint */
  1309. X{
  1310. X#ifndef lint
  1311. X#ifndef USE_STDARG
  1312. X    char *file;
  1313. X    int type;
  1314. X#endif
  1315. X#endif
  1316. X    va_list ap;
  1317. X    register char *s, *d, *e;
  1318. X    char line[MAX_BUF+1];
  1319. X    char name[MAX_NAME+1];
  1320. X    int i,j;
  1321. X
  1322. X    size = 0;
  1323. X    files = 0;
  1324. X    path = NULL;
  1325. X
  1326. X#ifdef lint
  1327. X    ap = NULL;
  1328. X#else
  1329. X#ifdef USE_STDARG
  1330. X    va_start(ap, type);
  1331. X#else
  1332. X    va_start(ap);
  1333. X    file = va_arg(ap, char *);
  1334. X    type = va_arg(ap, int);
  1335. X#endif
  1336. X#endif
  1337. X
  1338. X    while (type >= 0 && type <= 2) {
  1339. X        s = file;
  1340. X        d = line;
  1341. X        i = 0;
  1342. X        while(*s != '\0') {
  1343. X            if (*s == '$') {
  1344. X                s++;
  1345. X                j = 0;
  1346. X                while(*s != '\0' && (*s == '_' || isalnum(*s))) 
  1347. X                    if (j < MAX_NAME) {
  1348. X                        name[j] = *s++;
  1349. X                        j++;
  1350. X                    } else
  1351. X                        break;
  1352. X                name[j] = '\0';
  1353. X                e = getenv(name);
  1354. X                if (e != NULL) {
  1355. X                    while(*e != '\0') {
  1356. X                        if (i < MAX_BUF) {
  1357. X                            *d++ = *e++;
  1358. X                            i++;
  1359. X                        } else
  1360. X                            break;
  1361. X                    }
  1362. X                } else if (*s == '/') 
  1363. X                    s++;
  1364. X            } else {
  1365. X                if (i < MAX_BUF) {
  1366. X                    *d++ = *s++;
  1367. X                    i++;
  1368. X                } else
  1369. X                    break;
  1370. X            }
  1371. X        }
  1372. X        *d = '\0';
  1373. X        if (type == 0 || line[0] == '/') {
  1374. X            s = strtok(line, SEPERATORS);
  1375. X            while(s != NULL) {
  1376. X                if (addfile(s, 0) == 0)
  1377. X                    return NULL;
  1378. X                s = strtok(NULL, SEPERATORS);
  1379. X            }
  1380. X        } else 
  1381. X            if (addfile(line, type) == 0)
  1382. X                return NULL;
  1383. X        file = va_arg(ap, char *);
  1384. X        type = va_arg(ap, int);
  1385. X    }
  1386. X    addfile(NULL, -1);
  1387. X    return path;
  1388. X}
  1389. SHAR_EOF
  1390. chmod 0644 buildpath.c || echo "restore of buildpath.c fails"
  1391. case $TOUCH in
  1392. can)
  1393.     touch -am 0402044690 buildpath.c
  1394.     ;;
  1395. esac
  1396. set `wc -c buildpath.c`;Wc_c=$1
  1397. case "$Wc_c" in
  1398. "3998") ;;
  1399. *) echo original size 3998, current size $Wc_c ;;
  1400. esac
  1401. # ============= tcapconv.c ==============
  1402. echo "x - extracting tcapconv.c (Text)"
  1403. sed 's/^X//' << 'SHAR_EOF' > tcapconv.c &&
  1404. X/*
  1405. X * tcapconv.c
  1406. X *
  1407. X * By Ross Ridge
  1408. X * Public Domain
  1409. X * 90/03/27 18:29:29
  1410. X *
  1411. X */
  1412. X
  1413. X#include "defs.h"
  1414. X#define SINGLE
  1415. X#include "term.h"
  1416. X
  1417. X#ifdef USE_SCCS_IDS
  1418. Xstatic char SCCSid[] = "@(#) tcapconv.c 1.2";
  1419. X#endif
  1420. Xextern char **_sstrcodes[], **_sstrnames[];
  1421. X
  1422. Xstatic char *C_CR = "\r";
  1423. Xstatic char *C_LF = "\n";
  1424. Xstatic char *C_BS = "\b";
  1425. Xstatic char *C_FF = "\f";
  1426. Xstatic char *C_HT = "\t";
  1427. Xstatic char *C_VT = "\013";
  1428. Xstatic char *C_NL = "\r\n";
  1429. X
  1430. X#define DEF(s) ((s) != (char *) -1 && (s) != NULL)
  1431. X#define NOTSET(s) ((s) == (char *) -1)
  1432. X
  1433. X/*
  1434. X * This routine fills in caps that either had defaults under termcap or
  1435. X * can be manufactured from obsolete termcap capabilities. 
  1436. X */
  1437. X
  1438. Xvoid _tcapdefault() {
  1439. X    char buf[MAX_LINE * 2 + 2];
  1440. X
  1441. X    if (NOTSET(carriage_return)) {
  1442. X        if (carriage_return_delay > 0) {
  1443. X            sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
  1444. X            carriage_return = _addstr(buf);
  1445. X        } else
  1446. X            carriage_return = _addstr(C_CR);
  1447. X    }
  1448. X    if (NOTSET(cursor_left)) {
  1449. X        if (backspace_delay > 0) {
  1450. X            sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
  1451. X            cursor_left = _addstr(buf);
  1452. X        } else if (backspaces_with_bs == 1)
  1453. X            cursor_left = _addstr(C_BS);
  1454. X        else if (DEF(backspace_if_not_bs))
  1455. X            cursor_left = _addstr(backspace_if_not_bs);
  1456. X    }
  1457. X/* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
  1458. X    if (NOTSET(cursor_down)) {
  1459. X        if (DEF(linefeed_if_not_lf)) 
  1460. X            cursor_down = _addstr(linefeed_if_not_lf);
  1461. X        else if (linefeed_is_newline != 1) {
  1462. X            if (new_line_delay > 0) {
  1463. X                sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
  1464. X                cursor_down = _addstr(buf);
  1465. X            } else
  1466. X                cursor_down = _addstr(C_LF);
  1467. X        }
  1468. X    }
  1469. X    if (NOTSET(scroll_forward) && crt_without_scrolling != 1) {
  1470. X        if (DEF(linefeed_if_not_lf)) 
  1471. X            cursor_down = _addstr(linefeed_if_not_lf);
  1472. X        else if (linefeed_is_newline != 1) {
  1473. X            if (new_line_delay > 0) {
  1474. X                sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
  1475. X                scroll_forward = _addstr(buf);
  1476. X            } else
  1477. X                scroll_forward = _addstr(C_LF);
  1478. X        }
  1479. X    }
  1480. X    if (NOTSET(newline)) {
  1481. X        if (linefeed_is_newline == 1) {
  1482. X            if (new_line_delay > 0) {
  1483. X                sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
  1484. X                newline = _addstr(buf);
  1485. X            } else
  1486. X                newline = _addstr(C_LF);
  1487. X        } else if (DEF(carriage_return) && DEF(scroll_forward)) {
  1488. X            strncpy(buf, carriage_return, MAX_LINE-2);
  1489. X            buf[MAX_LINE-1] = '\0';
  1490. X            strncat(buf, scroll_forward, MAX_LINE-strlen(buf)-1);
  1491. X            buf[MAX_LINE] = '\0';
  1492. X            newline = _addstr(buf);
  1493. X        } else if (DEF(carriage_return) && DEF(cursor_down)) {
  1494. X            strncpy(buf, carriage_return, MAX_LINE-2);
  1495. X            buf[MAX_LINE-1] = '\0';
  1496. X            strncat(buf, cursor_down, MAX_LINE-strlen(buf)-1);
  1497. X            buf[MAX_LINE] = '\0';
  1498. X            newline = _addstr(buf);
  1499. X        }
  1500. X    }
  1501. X
  1502. X/*
  1503. X * We wait until know to decide if we've got a working cr because even
  1504. X * one that doesn't work can be used for newline. Unfortunately the
  1505. X * space allocated for it is wasted.
  1506. X */
  1507. X    if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
  1508. X        carriage_return = NULL;
  1509. X
  1510. X/*
  1511. X * supposedly most termcap entries have ta now and '\t' is no longer a
  1512. X * default, but it doesn't seem to be true...
  1513. X */
  1514. X    if (NOTSET(tab)) {
  1515. X        if (horizontal_tab_delay > 0) {
  1516. X            sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
  1517. X            tab = _addstr(buf);
  1518. X        } else
  1519. X            tab = _addstr(C_HT);
  1520. X    }
  1521. X#if 0
  1522. X/* probably not needed and might confuse some programmes */
  1523. X    if (NOTSET(form_feed)) {
  1524. X        if (form_feed_delay > 0) {
  1525. X            sprintf(buf, "%s$<%d>", C_FF, form_feed_delay);
  1526. X            form_feed = _addstr(buf);
  1527. X        } else
  1528. X            form_feed = _addstr(C_FF);
  1529. X    }
  1530. X#endif
  1531. X    if (init_tabs == -1 && has_hardware_tabs == 1)
  1532. X        init_tabs = 8;
  1533. X
  1534. X    if (NOTSET(key_backspace))
  1535. X        key_backspace = _addstr(C_BS);
  1536. X    if (NOTSET(key_left))
  1537. X        key_left = _addstr(C_BS);
  1538. X    if (NOTSET(key_down))
  1539. X        key_down = _addstr(C_LF);
  1540. X}
  1541. X
  1542. Xvoid _tcapconv() {
  1543. X    char buf[MAX_LINE+1];
  1544. X
  1545. X    if (GNU_tab_width > 0 && init_tabs == -1)
  1546. X        init_tabs = GNU_tab_width;
  1547. X
  1548. X    if (GNU_has_meta_key == 1 && has_meta_key == -1)
  1549. X        has_meta_key = 1;
  1550. X
  1551. X/*
  1552. X * this is some what a kludge, but should work unless someone breaks
  1553. X * conventions.
  1554. X */
  1555. X    if (DEF(other_non_function_keys)) {
  1556. X        register char *s;
  1557. X        static char *o;
  1558. X        static char **p2p2c = &o;
  1559. X        static char name[MAX_NAME] = "k";
  1560. X        static char *P2C = name;
  1561. X        static char **P2P2C = &P2C;
  1562. X        char *str;
  1563. X        register char ***match;
  1564. X
  1565. X        s = strcpy(buf, other_non_function_keys);
  1566. X        while(*s != '\0') {
  1567. X            o = s;
  1568. X#ifdef lint
  1569. X            p2p2c = &o;
  1570. X#endif
  1571. X            while(*s != ',' && *s != '\0')
  1572. X                s++;
  1573. X            if (*s != '\0')
  1574. X                *s++ = '\0';
  1575. X            match = (char ***) bsearch((anyptr) &p2p2c,
  1576. X                           (anyptr) _sstrcodes,
  1577. X                           NUM_OF_STRS,
  1578. X                           sizeof(p2p2c),
  1579. X                           _compar);
  1580. X            if (match == NULL)
  1581. X                continue;
  1582. X            str = _term_buf.strs[*match - strcodes];
  1583. X            if (!DEF(str))
  1584. X                continue;
  1585. X            strncpy(name + 1, strnames[*match - strcodes],
  1586. X                MAX_NAME - 2);
  1587. X            match = (char ***) bsearch((anyptr) &P2P2C,
  1588. X                           (anyptr) _sstrnames,
  1589. X                           NUM_OF_STRS,
  1590. X                           sizeof(p2p2c),
  1591. X                           _compar);
  1592. X            if (match == NULL)
  1593. X                continue;
  1594. X            if (!NOTSET(_term_buf.strs[*match - strnames]))
  1595. X                continue;
  1596. X            _term_buf.strs[*match - strnames] = _addstr(str);
  1597. X        }
  1598. X    }
  1599. X}
  1600. SHAR_EOF
  1601. chmod 0644 tcapconv.c || echo "restore of tcapconv.c fails"
  1602. case $TOUCH in
  1603. can)
  1604.     touch -am 0402044690 tcapconv.c
  1605.     ;;
  1606. esac
  1607. set `wc -c tcapconv.c`;Wc_c=$1
  1608. case "$Wc_c" in
  1609. "5023") ;;
  1610. *) echo original size 5023, current size $Wc_c ;;
  1611. esac
  1612. # ============= qsort.c ==============
  1613. echo "x - extracting qsort.c (Text)"
  1614. sed 's/^X//' << 'SHAR_EOF' > qsort.c &&
  1615. X/*
  1616. X * qsort.c
  1617. X *
  1618. X * This came from the GNU Emacs (18.55) tape.
  1619. X * Modified by Ross Ridge for use in this package
  1620. X * 90/03/27 18:29:41
  1621. X *
  1622. X */
  1623. X
  1624. X#include "defs.h"
  1625. X
  1626. X#ifdef USE_MYQSORT
  1627. X
  1628. X#ifdef USE_SCCS_IDS
  1629. Xstatic char SCCSid[] = "@(#) qsort.c 1.2";
  1630. X#endif
  1631. X/*
  1632. X * qsort.c:
  1633. X * Our own version of the system qsort routine which is faster by an average
  1634. X * of 25%, with lows and highs of 10% and 50%.
  1635. X * The THRESHold below is the insertion sort threshold, and has been adjusted
  1636. X * for records of size 48 bytes.
  1637. X * The MTHREShold is where we stop finding a better median.
  1638. X */
  1639. X
  1640. X#define        THRESH        4        /* threshold for insertion */
  1641. X
  1642. X#define        MTHRESH        6        /* threshold for median */
  1643. X
  1644. X
  1645. X
  1646. Xstatic  int        qsz;            /* size of each record */
  1647. X#ifdef USE_PROTOTYPES
  1648. Xstatic  int        (*qcmp)(anyptr,anyptr);    /* the comparison routine */
  1649. X#else
  1650. Xstatic  int        (*qcmp)();        /* the comparison routine */
  1651. X#endif
  1652. X
  1653. Xstatic  int        thresh;            /* THRESHold in chars */
  1654. Xstatic  int        mthresh;        /* MTHRESHold in chars */
  1655. X
  1656. X/*
  1657. X * qsort:
  1658. X * First, set up some global parameters for qst to share.  Then, quicksort
  1659. X * with qst(), and then a cleanup insertion sort ourselves.  Sound simple?
  1660. X * It's not...
  1661. X */
  1662. Xvoid
  1663. Xqsort (base, n, size, compar)
  1664. X     anyptr base;
  1665. X     unsigned n;
  1666. X     size_t size;
  1667. X#ifdef USE_PROTOTYPES
  1668. X     int (*compar)(anyptr, anyptr);
  1669. X#else
  1670. X     int (*compar)();
  1671. X#endif
  1672. X{
  1673. X  register char *i, *j, *lo, *hi, *min;
  1674. X  register int c;
  1675. X  char *max;
  1676. X
  1677. X  if (n <= 1)  return;
  1678. X  qsz = size / sizeof(char); /* of course if sizeof(char) aint one it had
  1679. X                better be an even divisor of size      */
  1680. X  qcmp = compar;
  1681. X  thresh = qsz*THRESH;
  1682. X  mthresh = qsz*MTHRESH;
  1683. X  max = (char *)base + n*qsz;
  1684. X  if (n >= THRESH)
  1685. X    {
  1686. X      qst ((char *)base, max);
  1687. X      hi = (char *)base + thresh;
  1688. X    }
  1689. X  else
  1690. X    {
  1691. X      hi = max;
  1692. X    }
  1693. X  /*
  1694. X   * First put smallest element, which must be in the first THRESH, in
  1695. X   * the first position as a sentinel.  This is done just by searching
  1696. X   * the first THRESH elements (or the first n if n < THRESH), finding
  1697. X   * the min, and swapping it into the first position.
  1698. X   */
  1699. X  for (j = lo = (char *)base; (lo += qsz) < hi; )
  1700. X    {
  1701. X      if ((*qcmp) ((anyptr)j, (anyptr)lo) > 0)
  1702. X    j = lo;
  1703. X    }
  1704. X  if (j != (char *)base)
  1705. X    {            /* swap j into place */
  1706. X      for (i = (char *)base, hi = (char *)base + qsz; i < hi;)
  1707. X    {
  1708. X      c = *j;
  1709. X      *j++ = *i;
  1710. X      *i++ = c;
  1711. X    }
  1712. X    }
  1713. X  /*
  1714. X   * With our sentinel in place, we now run the following hyper-fast
  1715. X   * insertion sort.  For each remaining element, min, from [1] to [n-1],
  1716. X   * set hi to the index of the element AFTER which this one goes.
  1717. X   * Then, do the standard insertion sort shift on a character at a time
  1718. X   * basis for each element in the frob.
  1719. X   */
  1720. X  for (min = (char *)base; (hi = min += qsz) < max;)
  1721. X    {
  1722. X      while ( (*qcmp) ((anyptr)(hi -= qsz), (anyptr) min) > 0);
  1723. X      if ((hi += qsz) != min)
  1724. X    {
  1725. X      for (lo = min + qsz; --lo >= min;)
  1726. X        {
  1727. X          c = *lo;
  1728. X          for (i = j = lo; (j -= qsz) >= hi; i = j)
  1729. X        *i = *j;
  1730. X          *i = c;
  1731. X        }
  1732. X    }
  1733. X    }
  1734. X}
  1735. X
  1736. X/*
  1737. X * qst:
  1738. X * Do a quicksort
  1739. X * First, find the median element, and put that one in the first place as the
  1740. X * discriminator.  (This "median" is just the median of the first, last and
  1741. X * middle elements).  (Using this median instead of the first element is a big
  1742. X * win).  Then, the usual partitioning/swapping, followed by moving the
  1743. X * discriminator into the right place.  Then, figure out the sizes of the two
  1744. X * partions, do the smaller one recursively and the larger one via a repeat of
  1745. X * this code.  Stopping when there are less than THRESH elements in a partition
  1746. X * and cleaning up with an insertion sort (in our caller) is a huge win.
  1747. X * All data swaps are done in-line, which is space-losing but time-saving.
  1748. X * (And there are only three places where this is done).
  1749. X */
  1750. Xstatic int
  1751. Xqst (base, max)
  1752. X     char *base, char *max;
  1753. X{
  1754. X  register char *i, *j, *jj, *mid;
  1755. X  register int ii, c;
  1756. X  char *tmp;
  1757. X  int lo, hi;
  1758. X
  1759. X  lo = max - base;    /* number of elements as chars */
  1760. X  do
  1761. X    {
  1762. X      /*
  1763. X       * At the top here, lo is the number of characters of elements in the
  1764. X       * current partition.  (Which should be max - base).
  1765. X       * Find the median of the first, last, and middle element and make that the
  1766. X       * middle element.  Set j to largest of first and middle.  If max is larger
  1767. X       * than that guy, then it's that guy, else compare max with loser of first
  1768. X       * and take larger.  Things are set up to prefer the middle, then the first
  1769. X       * in case of ties.
  1770. X       */
  1771. X      mid = i = base + qsz * ((lo/qsz) >> 1);
  1772. X      if (lo >= mthresh)
  1773. X    {
  1774. X      j = ((*qcmp) ((anyptr)(jj = base), (anyptr)i) > 0 ? jj : i);
  1775. X      if ((*qcmp) ((anyptr)j, (anyptr)(tmp = max - qsz)) > 0)
  1776. X        {
  1777. X          j = (j == jj ? i : jj);    /* switch to first loser */
  1778. X          if ((*qcmp) ((anyptr)j, (anyptr)tmp) < 0)
  1779. X        j = tmp;
  1780. X        }
  1781. X      if (j != i)
  1782. X        {
  1783. X          ii = qsz;
  1784. X          do
  1785. X        {
  1786. X          c = *i;
  1787. X          *i++ = *j;
  1788. X          *j++ = c;
  1789. X        }
  1790. X          while(  --ii  );
  1791. X        }
  1792. X    }
  1793. X      /*
  1794. X       * Semi-standard quicksort partitioning/swapping
  1795. X       */
  1796. X      for (i = base, j = max - qsz; ;)
  1797. X    {
  1798. X      while (i < mid && (*qcmp) ((anyptr)i, (anyptr)mid) <= 0)
  1799. X        i += qsz;
  1800. X      while (j > mid)
  1801. X        {
  1802. X          if ((*qcmp) ((anyptr)mid, (anyptr)j) <= 0)
  1803. X        {
  1804. X          j -= qsz;
  1805. X          continue;
  1806. X        }
  1807. X          tmp = i + qsz;        /* value of i after swap */
  1808. X          if (i == mid)
  1809. X        {    /* j <-> mid, new mid is j */
  1810. X          mid = jj = j;
  1811. X        }
  1812. X          else
  1813. X        {            /* i <-> j */
  1814. X          jj = j;
  1815. X          j -= qsz;
  1816. X        }
  1817. X          goto  swap;
  1818. X        }
  1819. X      if (i == mid)
  1820. X        {
  1821. X          break;
  1822. X        }
  1823. X      else
  1824. X        {                /* i <-> mid, new mid is i */
  1825. X          jj = mid;
  1826. X          tmp = mid = i;        /* value of i after swap */
  1827. X          j -= qsz;
  1828. X        }
  1829. X    swap:
  1830. X      ii = qsz;
  1831. X      do
  1832. X        {
  1833. X          c = *i;
  1834. X          *i++ = *jj;
  1835. X          *jj++ = c;
  1836. X        }
  1837. X      while (--ii);
  1838. X      i = tmp;
  1839. X    }
  1840. X      /*
  1841. X       * Look at sizes of the two partitions, do the smaller one first by
  1842. X       * recursion, then do the larger one by making sure lo is its size,
  1843. X       * base and max are update correctly, and branching back.
  1844. X       * But only repeat (recursively or by branching) if the partition is
  1845. X       * of at least size THRESH.
  1846. X       */
  1847. X      i = (j = mid) + qsz;
  1848. X      if ((lo = j - base) <= (hi = max - i))
  1849. X    {
  1850. X      if (lo >= thresh)
  1851. X        qst (base, j);
  1852. X      base = i;
  1853. X      lo = hi;
  1854. X    }
  1855. X      else
  1856. X    {
  1857. X      if (hi >= thresh)
  1858. X        qst (i, max);
  1859. X      max = j;
  1860. X    }
  1861. X    }
  1862. X  while (lo >= thresh);
  1863. X}
  1864. X
  1865. X
  1866. X
  1867. X#endif
  1868. SHAR_EOF
  1869. chmod 0644 qsort.c || echo "restore of qsort.c fails"
  1870. case $TOUCH in
  1871. can)
  1872.     touch -am 0402044690 qsort.c
  1873.     ;;
  1874. esac
  1875. set `wc -c qsort.c`;Wc_c=$1
  1876. case "$Wc_c" in
  1877. "6363") ;;
  1878. *) echo original size 6363, current size $Wc_c ;;
  1879. esac
  1880. # ============= gettcap.c ==============
  1881. echo "x - extracting gettcap.c (Text)"
  1882. sed 's/^X//' << 'SHAR_EOF' > gettcap.c &&
  1883. X/*
  1884. X * gettcap.c
  1885. X *
  1886. X * By Ross Ridge
  1887. X * Public Domain
  1888. X * 90/03/27 18:29:34
  1889. X *
  1890. X */
  1891. X
  1892. X#include "defs.h"
  1893. X#include "term.h"
  1894. X
  1895. X#include <ctype.h>
  1896. X
  1897. X#ifdef USE_SCCS_IDS
  1898. Xstatic char SCCSid[] = "@(#) gettcap.c 1.3";
  1899. X#endif
  1900. Xextern char **_sboolnames[], **_sboolcodes[], **_sboolfnames[];
  1901. Xextern char **_snumnames[], **_snumcodes[], **_snumfnames[];
  1902. Xextern char **_sstrnames[], **_sstrcodes[], **_sstrfnames[];
  1903. X
  1904. Xint _gettcap(sp, cur, path)
  1905. Xregister char *sp;
  1906. XTERMINAL *cur;
  1907. Xstruct term_path *path; {
  1908. X    static char name[MAX_NAME];
  1909. X    static char entry[MAX_LINE];
  1910. X    register char *dp;
  1911. X    register TERMINAL *ct = cur;
  1912. X    register char ***match;
  1913. X    int i, pad, fract, mul;
  1914. X    char c, flag;
  1915. X    static char *p2c = name;
  1916. X    static char **p2p2c = &p2c;
  1917. X
  1918. X    dp = entry;
  1919. X    while(*sp != ':' && *sp != '\0')
  1920. X        *dp++ = *sp++;
  1921. X    if (ct->name_all == NULL) {
  1922. X        *dp = '\0';
  1923. X        if ((ct->name_all = _addstr(entry)) == NULL)
  1924. X            return 1;
  1925. X        while(dp > entry && *--dp != '|');
  1926. X        ct->name_long = ct->name_all + (dp - entry) + 1;
  1927. X    }
  1928. X
  1929. X     while(*sp != '\0') {
  1930. X        while(*sp == ':')
  1931. X            sp++;
  1932. X        while(isspace(*sp))
  1933. X            sp++;
  1934. X        if (*sp == ':')
  1935. X            continue;
  1936. X        if (*sp == '\0')
  1937. X            break;
  1938. X        dp = name;
  1939. X        while (*sp != ':' && *sp != '#' && *sp != '=' &&
  1940. X               !isspace(*sp) && *sp != '\0')
  1941. X            *dp++ = *sp++;
  1942. X        *dp = '\0';
  1943. X#ifdef DEBUG
  1944. X        printf(" %s", name);
  1945. X#endif
  1946. X        switch(*sp) {
  1947. X        case '=':
  1948. X#ifdef DEBUG
  1949. X            putchar('$');
  1950. X#endif
  1951. X            match = (char ***) bsearch((anyptr) &p2p2c,
  1952. X                           (anyptr) _sstrcodes,
  1953. X                           NUM_OF_STRS,
  1954. X                           sizeof(p2p2c), _compar);
  1955. X            if (match != NULL)
  1956. X                flag = _strflags[*match - strcodes];
  1957. X            else
  1958. X                flag = 'K';
  1959. X            dp = entry;
  1960. X            fract = pad = 0;
  1961. X            sp++;
  1962. X            if (isdigit(*sp) && flag != 'K') {
  1963. X                pad = *sp++ - '0';
  1964. X                while(isdigit(*sp))
  1965. X                    pad = pad * 10 + (*sp++ - '0');
  1966. X                if (*sp == '.' && isdigit(sp[1])) {
  1967. X                    sp++;
  1968. X                    fract = (*sp++ - '0');
  1969. X                }
  1970. X                if (*sp == '*') {
  1971. X                    mul = 1;
  1972. X                    sp++;
  1973. X                } else
  1974. X                    mul = 0;
  1975. X    
  1976. X            }
  1977. X            while(*sp != '\0' && *sp != ':') {
  1978. X                switch(*sp) {
  1979. X                case '\\':
  1980. X                    switch(*++sp) {
  1981. X                    case 'e':
  1982. X                    case 'E': *dp++ = '\033'; break;
  1983. X                    case 'l': *dp++ = '\012'; break;
  1984. X                    case 'n': *dp++ = '\n'; break;
  1985. X                    case 'r': *dp++ = '\r'; break;
  1986. X                    case 't': *dp++ = '\t'; break;
  1987. X                    case 'b': *dp++ = '\b'; break;
  1988. X                    case 'f': *dp++ = '\f'; break;
  1989. X                    case 's': *dp++ = ' '; break;
  1990. X
  1991. X                    case '^': 
  1992. X                    case '\\':
  1993. X                    case ',':
  1994. X                    case ':':
  1995. X                        *dp++ = *sp;
  1996. X                        break;
  1997. X
  1998. X                    case '0':
  1999. X                        if (!isdigit(*(sp + 1))) {
  2000. X                            *dp++ = '\200';
  2001. X                            break;
  2002. X                        }
  2003. X                        ;/* FALLTHROUGH */
  2004. X                    case '1':
  2005. X                    case '2':
  2006. X                    case '3':
  2007. X                    case '4':
  2008. X                    case '5':
  2009. X                    case '6':
  2010. X                    case '7':
  2011. X                        c = *sp - '0';
  2012. X                        if (sp[1] >= '0'
  2013. X                            && sp[1] <= '8')
  2014. X                            c = c * 8
  2015. X                                + (*++sp - '0');
  2016. X                        if (sp[1] >= '0'
  2017. X                            && sp[1] <= '8')
  2018. X                            c = c * 8
  2019. X                                + (*++sp - '0');
  2020. X                        switch((char)c) {
  2021. X                        case 0:
  2022. X                            if (flag == 'K')
  2023. X                                *dp++ = '\200';
  2024. X                            else {
  2025. X                                *dp++ = '\\';
  2026. X                                *dp++ = '0';
  2027. X                                *dp++ = '0';
  2028. X                                *dp++ = '0';
  2029. X                            }
  2030. X                            break;
  2031. X                        case '$':
  2032. X                        case '\'':
  2033. X                        case '\\':
  2034. X                            if (flag != 'K')
  2035. X                                *dp++ = '\\';
  2036. X                            /* FALLTHROUGH */
  2037. X                        default:
  2038. X                            if (flag == 'G'
  2039. X                                && c == '%')
  2040. X                                *dp++ = '\\';
  2041. X                            *dp++ = c;
  2042. X                            break;
  2043. X                        }
  2044. X                        break;
  2045. X                    default:
  2046. X                        *dp++ = '\\';
  2047. X                        *dp++ = *sp;
  2048. X                        break;
  2049. X                    }
  2050. X                    sp++;
  2051. X                    break;
  2052. X                case '^':
  2053. X                    if (*++sp >= 'A' && *sp <= '_') {
  2054. X                        *dp++ = *sp++ - '@';
  2055. X                    } else if (*sp >= 'a' && *sp <= 'z') {
  2056. X                        *dp++ = *sp++ - 'a' + 1;
  2057. X                    } else if (*sp == '@') {
  2058. X                        if (flag == 'K')
  2059. X                            *dp++ = '\200';
  2060. X                        else {
  2061. X                            *dp++ = '\\';
  2062. X                            *dp++ = '0';
  2063. X                            *dp++ = '0';
  2064. X                            *dp++ = '0';
  2065. X                        }
  2066. X                        sp++;
  2067. X                    } else 
  2068. X                        *dp++ = '^';
  2069. X                    break;
  2070. X                case '$':
  2071. X                    if (flag != 'K')
  2072. X                        *dp++ = '\\';
  2073. X                    /* FALLTHROUGH */
  2074. X                default:
  2075. X                    *dp++ = *sp++;
  2076. X                    break;
  2077. X                }
  2078. X            }
  2079. X            if (pad != 0 || fract != 0) {
  2080. X                if (fract == 0)
  2081. X                    sprintf(dp, "$<%d", pad);
  2082. X                else
  2083. X                    sprintf(dp, "$<%d.%d", pad, fract);
  2084. X                dp += strlen(dp);
  2085. X                if (mul) 
  2086. X                    *dp++ = '*';
  2087. X                *dp++ = '>';
  2088. X            }
  2089. X            *dp++ = '\0';
  2090. X            if(name[0] == 't' && name[1] == 'c' && name[2] == '\0'){
  2091. X                if (_getother(entry, path, ct))
  2092. X                    return 1;
  2093. X                break;
  2094. X            }
  2095. X            if (match == NULL)
  2096. X                break;
  2097. X            if (ct->strs[*match - strcodes] != (char *) -1)
  2098. X                break;
  2099. X            if ((ct->strs[*match - strcodes] = _addstr(entry))
  2100. X                == NULL)
  2101. X                return 1;
  2102. X            break;    
  2103. X        case '#':
  2104. X#ifdef DEBUG
  2105. X            putchar('#');
  2106. X#endif
  2107. X            i = atoi(++sp);
  2108. X            while(*sp != '\0' && *sp++ != ':');
  2109. X            match = (char ***) bsearch((anyptr) &p2p2c,
  2110. X                           (anyptr) _snumcodes,
  2111. X                           NUM_OF_NUMS, sizeof(p2p2c),
  2112. X                           _compar);
  2113. X            if (match == NULL)
  2114. X                break;
  2115. X            if (ct->nums[*match - numcodes] != -2)
  2116. X                break;
  2117. X            ct->nums[*match - numcodes] = i;
  2118. X            break;
  2119. X        default:
  2120. X            while(*sp != '\0' && *sp++ != ':');
  2121. X            if (*(dp - 1) == '@') {
  2122. X#ifdef DEBUG
  2123. X                putchar('@');
  2124. X#endif
  2125. X                *(dp - 1) = '\0';
  2126. X                match = (char ***) bsearch((anyptr) &p2p2c,
  2127. X                               (anyptr) _sboolcodes,
  2128. X                               NUM_OF_BOOLS,
  2129. X                               sizeof(p2p2c),
  2130. X                               _compar);
  2131. X                if (match != NULL) {
  2132. X#ifdef DEBUG
  2133. X                    putchar('!');
  2134. X#endif
  2135. X                    if (ct->bools[*match-boolcodes] == -1)
  2136. X                        ct->bools[*match-boolcodes] = 0;
  2137. X                    break;
  2138. X                }
  2139. X                match = (char ***) bsearch((anyptr) &p2p2c,
  2140. X                               (anyptr) _snumcodes,
  2141. X                               NUM_OF_NUMS,
  2142. X                               sizeof(p2p2c),
  2143. X                               _compar);
  2144. X                if (match != NULL) {
  2145. X#ifdef DEBUG
  2146. X                    putchar('#');
  2147. X#endif
  2148. X                    if (ct->nums[*match-numcodes] == -2)
  2149. X                        ct->nums[*match-numcodes] = -1;
  2150. X                    break;
  2151. X                }
  2152. X                match = (char ***) bsearch((anyptr) &p2p2c,
  2153. X                               (anyptr) _sstrcodes,
  2154. X                               NUM_OF_STRS,
  2155. X                               sizeof(p2p2c),
  2156. X                               _compar);
  2157. X                if (match != NULL) {
  2158. X#ifdef DEBUG
  2159. X                    putchar('$');
  2160. X#endif
  2161. X                    if (ct->strs[*match-strcodes]
  2162. X                        == (char *) -1)
  2163. X                        ct->strs[*match-strcodes]
  2164. X                            = NULL;
  2165. X                    break;
  2166. X                }
  2167. X                break;
  2168. X            }
  2169. X#ifdef DEBUG
  2170. X            putchar('!');
  2171. X#endif
  2172. X            match = (char ***) bsearch((anyptr) &p2p2c,
  2173. X                           (anyptr) _sboolcodes,
  2174. X                           NUM_OF_BOOLS, sizeof(p2p2c),
  2175. X                           _compar);
  2176. X            if (match == NULL)
  2177. X                break;
  2178. X            if (ct->bools[*match - boolcodes] != -1)
  2179. X                break;
  2180. X            ct->bools[*match - boolcodes] = 1;
  2181. X        }
  2182. X    }
  2183. X    return 0;
  2184. X}
  2185. SHAR_EOF
  2186. chmod 0644 gettcap.c || echo "restore of gettcap.c fails"
  2187. case $TOUCH in
  2188. can)
  2189.     touch -am 0402044690 gettcap.c
  2190.     ;;
  2191. esac
  2192. set `wc -c gettcap.c`;Wc_c=$1
  2193. case "$Wc_c" in
  2194. "6271") ;;
  2195. *) echo original size 6271, current size $Wc_c ;;
  2196. esac
  2197. # ============= gettinfo.c ==============
  2198. echo "x - extracting gettinfo.c (Text)"
  2199. sed 's/^X//' << 'SHAR_EOF' > gettinfo.c &&
  2200. X/*
  2201. X * gettinfo.c
  2202. X *
  2203. X * By Ross Ridge
  2204. X * Public Domain
  2205. X * 90/03/27 18:29:31
  2206. X *
  2207. X */
  2208. X
  2209. X#include "defs.h"
  2210. X#include "term.h"
  2211. X
  2212. X#include <ctype.h>
  2213. X
  2214. X#ifdef USE_SCCS_IDS
  2215. Xstatic char SCCSid[] = "@(#) gettinfo.c 1.2";
  2216. X#endif
  2217. Xextern char **_sboolnames[], **_sboolcodes[], **_sboolfnames[];
  2218. Xextern char **_snumnames[], **_snumcodes[], **_snumfnames[];
  2219. Xextern char **_sstrnames[], **_sstrcodes[], **_sstrfnames[];
  2220. X
  2221. Xint _gettinfo(sp, cur, path)
  2222. Xregister char *sp;
  2223. Xstruct term_path *path;
  2224. XTERMINAL *cur; {
  2225. X    static char name[MAX_NAME];
  2226. X    static char entry[MAX_LINE];
  2227. X    register char *dp;
  2228. X    register TERMINAL *ct = cur;
  2229. X    register char ***match;
  2230. X    int i, base;
  2231. X    char c, flag;
  2232. X    static char *p2c = name;
  2233. X    static char **p2p2c = &p2c;
  2234. X
  2235. X    dp = entry;
  2236. X    while(*sp != ',' && *sp != '\0')
  2237. X        *dp++ = *sp++;
  2238. X    if (ct->name_all == NULL) {
  2239. SHAR_EOF
  2240. echo "End of tinfo part 2"
  2241. echo "File gettinfo.c is continued in part 3"
  2242. echo "3" > s3_seq_.tmp
  2243. exit 0
  2244. -- 
  2245. Ross Ridge                                 //
  2246. "The Great HTMU"                            [oo]
  2247. ross@contact.uucp                            -()-
  2248. ross@watcsc.waterloo.edu                         //
  2249.  
  2250.  
  2251.