home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
pc
/
source
/
termcap.zoo
/
termcap.2
< prev
next >
Wrap
Text File
|
1990-04-04
|
50KB
|
2,251 lines
#!/bin/sh
# this is part.02 (part 2 of tinfo)
# do not concatenate these parts, unpack them in order with /bin/sh
# file tty.c continued
#
touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
if [ -s /tmp/s3_touch$$ ]
then
TOUCH=can
else
TOUCH=cannot
fi
rm -f /tmp/s3_touch$$
CurArch=2
if test ! -r s3_seq_.tmp
then echo "Please unpack part 1 first!"
exit 1; fi
( read Scheck
case "$Scheck" in
"$CurArch") exit 0 ;;
*)
echo "Please unpack part $Scheck next!"
exit 1 ;;
esac
) < s3_seq_.tmp || exit 1
echo "x - Continuing file tty.c"
sed 's/^X//' << 'SHAR_EOF' >> tty.c
X
Xint reset_prog_mode() {
X if (ioctl(cur_term->fd, TIOCSETP, &cur_term->prog_mode.v6) < 0)
X return ERR;
X#ifdef TIOCGETC
X if (ioctl(cur_term->fd, TIOCSETC, &cur_term->prog_mode.v7) < 0)
X return ERR;
X#endif
X#ifdef TIOCLGET
X if (ioctl(cur_term->fd, TIOCLSET, &cur_term->prog_mode.bsd) < 0)
X return ERR;
X#endif
X#ifdef TIOCGLTC
X if (ioctl(cur_term->fd, TIOCSLTC, &cur_term->prog_mode.bsd_new) < 0)
X return ERR;
X#endif
X return OK;
X}
X
Xint _init_tty() {
X cur_term->true_lines = lines;
X cur_term->true_columns = columns;
X if (pad_char == NULL)
X cur_term->padch = '\000';
X else
X cur_term->padch = pad_char[0];
X if (def_shell_mode() == ERR)
X return ERR;
X if (def_prog_mode() == ERR)
X return ERR;
X#ifndef TIOCGETC
X cur_term->xon = xon_xoff && (xon_character == NULL
X || xon_character[0] == '\023')
X && (xoff_character == NULL
X || xoff_character[0] == '\021');
X#else
X if (xon_xoff) {
X if (xon_character != NULL) {
X cur_term->prog_mode.v7.t_startc = xon_character[0];
X if (ioctl(cur_term->fd, TIOCSETC, &cur_term->prog_mode.v7) < 0)
X return ERR;
X }
X if (xoff_character != NULL) {
X cur_term->prog_mode.v7.t_stopc = xoff_character[0];
X if (ioctl(cur_term->fd, TIOCSETC,
X &cur_term->prog_mode.v7) < 0)
X return ERR;
X }
X }
X cur_term->xon = xon_xoff;
X#endif
X#ifdef USE_WINSZ
X#ifdef TIOCGWINSZ
X if (cur_term->prog_mode.bsd_winsz.ws_row != 0
X && cur_term->prog_mode.bsd_winsz.ws_col != 0) {
X lines = cur_term->prog_mode.bsd_winsz.ws_row;
X columns = cur_term->prog_mode.bsd_winsz.ws_col;
X }
X#endif
X#endif
X return OK;
X}
X
X#else
X
Xint _lit_output() {
X return 0;
X}
X
Xvoid _norm_output() {
X return;
X}
X
X_check_tty() {
X return OK;
X}
X
Xdef_prog_mode() {
X return OK;
X}
X
Xreset_prog_mode() {
X return OK;
X}
X
Xdef_shell_mode() {
X return OK;
X}
X
Xreset_shell_mode() {
X return OK;
X}
X
X_init_tty() {
X cur_term->pad = 1
X cur_term->padch = 0;
X cur_term->baudrate = 1200;
X cur_term->xon = 0;
X cur_term->termcap = 0;
X cur_term->true_lines = lines;
X cur_term->true_columns = columns;
X}
X
X#endif
X
X#endif
X
SHAR_EOF
echo "File tty.c is complete"
chmod 0644 tty.c || echo "restore of tty.c fails"
case $TOUCH in
can)
touch -am 0402044690 tty.c
;;
esac
set `wc -c tty.c`;Wc_c=$1
case "$Wc_c" in
"7042") ;;
*) echo original size 7042, current size $Wc_c ;;
esac
# ============= tparm.c ==============
echo "x - extracting tparm.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > tparm.c &&
X/*
X * tparm.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/22 03:43:34
X *
X */
X
X#include "defs.h"
X#include "term.h"
X
X#include <ctype.h>
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) tparm.c 1.1";
X#endif
X#ifndef MAX_PUSHED
X#define MAX_PUSHED 32
X#endif
X
X#define ARG 1
X#define NUM 2
X
X#define INTEGER 1
X#define STRING 2
X
Xtypedef struct stack_str {
X int type;
X int argnum;
X int value;
X} stack;
X
Xstatic stack S[MAX_PUSHED];
Xstatic stack vars['z'-'a'+1];
Xstatic int pos = 0;
X
Xstatic struct arg_str {
X int type;
X int integer;
X char *string;
X} arg_list[10];
X
Xstatic int argcnt;
X
Xstatic va_list tparm_args;
X
Xstatic int pusharg(arg)
Xint arg; {
X if (pos == MAX_PUSHED)
X return 1;
X S[pos].type = ARG;
X S[pos++].argnum = arg;
X return 0;
X}
X
Xstatic int pushnum(num)
Xint num; {
X if (pos == MAX_PUSHED)
X return 1;
X S[pos].type = NUM;
X S[pos++].value = num;
X return 0;
X}
X
X/* VARARGS2 */
Xstatic int getarg(argnum, type, p)
Xint argnum, type;
Xanyptr p; {
X while (argcnt < argnum) {
X arg_list[argcnt].type = INTEGER;
X arg_list[argcnt++].integer = (int) va_arg(tparm_args, int);
X }
X if (argcnt > argnum) {
X if (arg_list[argnum].type != type)
X return 1;
X else if (type == STRING)
X *(char **)p = arg_list[argnum].string;
X else
X *(int *)p = arg_list[argnum].integer;
X } else {
X arg_list[argcnt].type = type;
X if (type == STRING)
X *(char **)p = arg_list[argcnt++].string
X = (char *) va_arg(tparm_args, char *);
X else
X *(int *)p = arg_list[argcnt++].integer = (int) va_arg(tparm_args, int);
X }
X return 0;
X}
X
X
Xstatic int popstring(str)
Xchar **str; {
X if (pos-- == 0)
X return 1;
X if (S[pos].type != ARG)
X return 1;
X return(getarg(S[pos].argnum, STRING, (anyptr) str));
X}
X
Xstatic int popnum(num)
Xint *num; {
X if (pos-- == 0)
X return 1;
X switch (S[pos].type) {
X case ARG:
X return (getarg(S[pos].argnum, INTEGER, (anyptr) num));
X case NUM:
X *num = S[pos].value;
X return 0;
X }
X return 1;
X}
X
Xstatic int cvtchar(sp, c)
Xregister char *sp, *c; {
X switch(*sp) {
X case '\\':
X switch(*++sp) {
X case '\'':
X case '$':
X case '\\':
X case '%':
X *c = *sp;
X return 2;
X case '\0':
X *c = '\\';
X return 1;
X case '0':
X if (sp[1] == '0' && sp[2] == '0') {
X *c = '\0';
X return 4;
X }
X *c = '\200'; /* '\0' ???? */
X return 2;
X default:
X *c = *sp;
X return 2;
X }
X default:
X *c = *sp;
X return 1;
X }
X}
X
Xstatic int termcap;
X
X/* sigh... this has got to be the ugliest code I've ever written.
X Trying to handle everything has its cost, I guess.
X
X It actually isn't to hard to figure out if a given % code is supposed
X to be interpeted with its termcap or terminfo meaning since almost
X all terminfo codes are invalid unless something has been pushed on
X the stack and termcap strings will never push things on the stack
X (%p isn't used by termcap). So where we have a choice we make the
X decision by wether or not somthing has been pushed on the stack.
X The static variable termcap keeps track of this; it starts out set
X to 1 and is incremented as each argument processed by a termcap % code,
X however if something is pushed on the stack it's set to 0 and the
X rest of the % codes are interpeted as terminfo % codes. Another way
X of putting it is that if termcap equals one we haven't decided either
X way yet, if it equals zero we're looking for terminfo codes, and if
X its greater than 1 we're looking for termcap codes.
X
X Terminfo % codes:
X
X %% output a '%'
X %[[:][-+# ][width][.precision]][doxXs]
X output pop according to the printf format
X %c output pop as a char
X %'c' push character constant c.
X %{n} push decimal constant n.
X %p[1-9] push paramter [1-9]
X %g[a-z] push variable [a-z]
X %P[a-z] put pop in variable [a-z]
X %l push the length of pop (a string)
X %+ add pop to pop and push the result
X %- subtract pop from pop and push the result
X %* multiply pop and pop and push the result
X %& bitwise and pop and pop and push the result
X %| bitwise or pop and pop and push the result
X %^ bitwise xor pop and pop and push the result
X %~ push the bitwise not of pop
X %= compare if pop and pop are equal and push the result
X %> compare if pop is less than pop and push the result
X %< compare if pop is greater than pop and push the result
X %A logical and pop and pop and push the result
X %O logical or pop and pop and push the result
X %! push the logical not of pop
X %? condition %t if_true [%e if_false] %;
X if condtion evaulates as true then evaluate if_true,
X else evaluate if_false. elseif's can be done:
X%? cond %t true [%e cond2 %t true2] ... [%e condN %t trueN] [%e false] %;
X %i add one to parameters 1 and 2. (ANSI)
X
X Termcap Codes:
X
X %% output a %
X %. output parameter as a character
X %d output parameter as a decimal number
X %2 output parameter in printf format %02d
X %3 output parameter in printf format %03d
X %+x add the character x to parameter and output it as a character
X(UW) %-x subtract parameter FROM the character x and output it as a char
X(UW) %ax add the character x to parameter
X(GNU) %a[+*-/=][cp]x
X GNU arithmetic.
X(UW) %sx subtract parameter FROM the character x
X %>xy if parameter > character x then add character y to parameter
X %B convert to BCD (parameter = (parameter/10)*16 + parameter%16)
X %D Delta Data encode (parameter = parameter - 2*(paramter%16))
X %i increment the first two parameters by one
X %n xor the first two parameters by 0140
X(GNU) %m xor the first two parameters by 0177
X %r swap the first two parameters
X(GNU) %b backup to previous parameter
X(GNU) %f skip this parameter
X
X Note the two definitions of %a, the GNU defintion is used if the characters
X after the 'a' are valid, otherwise the UW definition is used.
X
X (GNU) used by GNU Emacs termcap libraries
X (UW) used by the University of Waterloo (MFCF) termcap libraries
X
X*/
X
X#ifdef lint
X/* VARARGS1 */
Xchar *tparm(str)
Xchar *str; {
X#else /* lint */
X#ifdef USE_STDARG
X#ifdef USE_PROTOTYPES
Xchar *tparm(char *str, ...) {
X#else /* USE_PROTOTYPES */
Xchar *tparm(str)
Xchar *str; {
X#endif /* USE_PROTOTYPES */
X#else /* USE_STDARG */
Xchar *tparm(va_alist)
Xva_dcl {
X char *str;
X#endif
X#endif
X static char OOPS[] = "OOPS";
X static char buf[MAX_LINE];
X register char *sp, *dp;
X register char *fmt;
X char conv_char;
X char scan_for;
X int scan_depth, if_depth;
X static int i, j;
X static char *s, c;
X char fmt_buf[MAX_LINE];
X char sbuf[MAX_LINE];
X
X#ifdef lint
X scan_depth = 0;
X#else
X#ifdef USE_STDARG
X va_start(tparm_args, str);
X#else
X va_start(tparm_args);
X str = (char *) va_arg(tparm_args, char *);
X#endif
X#endif
X
X sp = str;
X dp = buf;
X scan_for = 0;
X if_depth = 0;
X argcnt = 0;
X pos = 0;
X termcap = 1;
X while(*sp != '\0') {
X switch(*sp) {
X case '\\':
X if (scan_for) {
X if (*++sp != '\0')
X sp++;
X break;
X }
X *dp++ = *sp++;
X if (*sp != '\0')
X *dp++ = *sp++;
X break;
X case '%':
X sp++;
X if (scan_for) {
X if (*sp == scan_for && if_depth == scan_depth) {
X if (scan_for == ';')
X if_depth--;
X scan_for = 0;
X } else if (*sp == '?')
X if_depth++;
X else if (*sp == ';') {
X if (if_depth == 0)
X return OOPS;
X else
X if_depth--;
X }
X sp++;
X break;
X }
X fmt = NULL;
X switch(*sp) {
X case '%':
X *dp++ = *sp++;
X break;
X case '+':
X if (!termcap) {
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i += j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X }
X ;/* FALLTHROUGH */
X case 'C':
X if (*sp == 'C') {
X if (getarg(termcap - 1, INTEGER, &i))
X return OOPS;
X if (i >= 96) {
X i /= 96;
X if (i == '$')
X *dp++ = '\\';
X *dp++ = i;
X }
X }
X fmt = "%c";
X /* FALLTHROUGH */
X case 'a':
X if (!termcap)
X return OOPS;
X if (getarg(termcap - 1, INTEGER, (anyptr) &i))
X return OOPS;
X if (*++sp == '\0')
X return OOPS;
X if ((sp[1] == 'p' || sp[1] == 'c')
X && sp[2] != '\0' && fmt == NULL) {
X /* GNU aritmitic parameter, what they
X realy need is terminfo. */
X int val, lc;
X if (sp[1] == 'p'
X && getarg(termcap - 1 + sp[2] - '@',
X INTEGER, (anyptr) &val))
X return OOPS;
X if (sp[1] == 'c') {
X lc = cvtchar(sp + 2, &c) + 2;
X /* Mask out 8th bit so \200 can be
X used for \0 as per GNU doc's */
X val = c & 0177;
X } else
X lc = 2;
X switch(sp[0]) {
X case '=':
X break;
X case '+':
X val = i + val;
X break;
X case '-':
X val = i - val;
X break;
X case '*':
X val = i * val;
X break;
X case '/':
X val = i / val;
X break;
X default:
X /* Not really GNU's %a after all... */
X lc = cvtchar(sp, &c);
X val = c + i;
X break;
X }
X arg_list[termcap - 1].integer = val;
X sp += lc;
X break;
X }
X sp += cvtchar(sp, &c);
X arg_list[termcap - 1].integer = c + i;
X if (fmt == NULL)
X break;
X sp--;
X /* FALLTHROUGH */
X case '-':
X if (!termcap) {
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i -= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X }
X fmt = "%c";
X /* FALLTHROUGH */
X case 's':
X if (termcap && (fmt == NULL || *sp == '-')) {
X if (getarg(termcap - 1, INTEGER, &i))
X return OOPS;
X if (*++sp == '\0')
X return OOPS;
X sp += cvtchar(sp, &c);
X arg_list[termcap - 1].integer = c - i;
X if (fmt == NULL)
X break;
X sp--;
X }
X if (!termcap)
X return OOPS;
X ;/* FALLTHROUGH */
X case '.':
X if (termcap && fmt == NULL)
X fmt = "%c";
X ;/* FALLTHROUGH */
X case 'd':
X if (termcap && fmt == NULL)
X fmt = "%d";
X ;/* FALLTHROUGH */
X case '2':
X if (termcap && fmt == NULL)
X fmt = "%02d";
X ;/* FALLTHROUGH */
X case '3':
X if (termcap && fmt == NULL)
X fmt = "%03d";
X ;/* FALLTHROUGH */
X case ':': case ' ': case '#': case 'u':
X case 'x': case 'X': case 'o': case 'c':
X case '0': case '1': case '4': case '5':
X case '6': case '7': case '8': case '9':
X if (fmt == NULL) {
X if (termcap)
X return OOPS;
X if (*sp == ':')
X sp++;
X fmt = fmt_buf;
X *fmt++ = '%';
X while(*sp != 's' && *sp != 'x' && *sp != 'X' && *sp != 'd' && *sp != 'o' && *sp != 'c' && *sp != 'u') {
X if (*sp == '\0')
X return OOPS;
X *fmt++ = *sp++;
X }
X *fmt++ = *sp;
X *fmt = '\0';
X fmt = fmt_buf;
X }
X conv_char = fmt[strlen(fmt - 1)];
X if (conv_char == 's') {
X if (popstring(&s))
X return OOPS;
X sprintf(sbuf, fmt, s);
X } else {
X if (termcap) {
X if (getarg(termcap++ - 1,
X INTEGER, &i))
X return OOPS;
X } else
X if (popnum(&i))
X return OOPS;
X if (i == 0 && conv_char == 'c')
X strcpy(sbuf, "\000");
X else
X sprintf(sbuf, fmt, i);
X }
X sp++;
X fmt = sbuf;
X while(*fmt != '\0') {
X if (*fmt == '$')
X *dp++ = '\\';
X *dp++ = *fmt++;
X }
X break;
X case 'r':
X if (!termcap || getarg(1, INTEGER, &i))
X return OOPS;
X arg_list[1].integer = arg_list[0].integer;
X arg_list[0].integer = i;
X sp++;
X break;
X case 'i':
X if (getarg(1, INTEGER, &i)
X || arg_list[0].type != INTEGER)
X return OOPS;
X arg_list[1].integer++;
X arg_list[0].integer++;
X sp++;
X break;
X case 'n':
X if (!termcap || getarg(1, INTEGER, &i))
X return OOPS;
X arg_list[0].integer ^= 0140;
X arg_list[1].integer ^= 0140;
X sp++;
X break;
X case '>':
X if (!termcap) {
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i = (i > j);
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X }
X if (getarg(termcap-1, INTEGER, &i))
X return OOPS;
X sp += cvtchar(sp, &c);
X if (i > c) {
X sp += cvtchar(sp, &c);
X arg_list[termcap-1].integer += c;
X } else
X sp += cvtchar(sp, &c);
X sp++;
X break;
X case 'B':
X if (!termcap || getarg(termcap-1, INTEGER, &i))
X return OOPS;
X arg_list[termcap-1].integer = 16*(i/10)+i%10;
X sp++;
X break;
X case 'D':
X if (!termcap || getarg(termcap-1, INTEGER, &i))
X return OOPS;
X arg_list[termcap-1].integer = i - 2 * (i % 16);
X sp++;
X break;
X case 'p':
X if (termcap > 1)
X return OOPS;
X if (*++sp == '\0')
X return OOPS;
X if (*sp == '0')
X i = 9;
X else
X i = *sp - '1';
X if (i < 0 || i > 9)
X return OOPS;
X if (pusharg(i))
X return OOPS;
X termcap = 0;
X sp++;
X break;
X case 'P':
X if (termcap || *++sp == '\0')
X return OOPS;
X i = *sp++ - 'a';
X if (i < 0 || i > 25)
X return OOPS;
X if (pos-- == 0)
X return OOPS;
X switch(vars[i].type = S[pos].type) {
X case ARG:
X vars[i].argnum = S[pos].argnum;
X break;
X case NUM:
X vars[i].value = S[pos].value;
X break;
X }
X break;
X case 'g':
X if (termcap || *++sp == '\0')
X return OOPS;
X i = *sp++ - 'a';
X if (i < 0 || i > 25)
X return OOPS;
X switch(vars[i].type) {
X case ARG:
X if (pusharg(vars[i].argnum))
X return OOPS;
X break;
X case NUM:
X if (pushnum(vars[i].value))
X return OOPS;
X break;
X }
X break;
X case '\'':
X if (termcap > 1)
X return OOPS;
X if (*++sp == '\0')
X return OOPS;
X sp += cvtchar(sp, &c);
X if (pushnum(c) || *sp++ != '\'')
X return OOPS;
X termcap = 0;
X break;
X case '{':
X if (termcap > 1)
X return OOPS;
X i = 0;
X sp++;
X while(isdigit(*sp))
X i = 10 * i + *sp++ - '0';
X if (*sp++ != '}' || pushnum(i))
X return OOPS;
X termcap = 0;
X break;
X case 'l':
X if (termcap || popstring(&s))
X return OOPS;
X i = strlen(s);
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '*':
X if (termcap || popnum(&j) || popnum(&i))
X return OOPS;
X i *= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '/':
X if (termcap || popnum(&j) || popnum(&i))
X return OOPS;
X i /= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case 'm':
X if (termcap) {
X if (getarg(1, INTEGER, &i))
X return OOPS;
X arg_list[0].integer ^= 0177;
X arg_list[1].integer ^= 0177;
X sp++;
X break;
X }
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i %= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '&':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i &= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '|':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i |= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '^':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i ^= j;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '=':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i = (i == j);
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '<':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i = (i < j);
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case 'A':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i = (i && j);
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case 'O':
X if (popnum(&j) || popnum(&i))
X return OOPS;
X i = (i || j);
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '!':
X if (popnum(&i))
X return OOPS;
X i = !i;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '~':
X if (popnum(&i))
X return OOPS;
X i = ~i;
X if (pushnum(i))
X return OOPS;
X sp++;
X break;
X case '?':
X if (termcap > 1)
X return OOPS;
X termcap = 0;
X if_depth++;
X sp++;
X break;
X case 't':
X if (popnum(&i) || if_depth == 0)
X return OOPS;
X if (!i) {
X scan_for = 'e';
X scan_depth = if_depth;
X }
X sp++;
X break;
X case 'e':
X if (if_depth == 0)
X return OOPS;
X scan_for = ';';
X scan_depth = if_depth;
X sp++;
X break;
X case ';':
X if (if_depth-- == 0)
X return OOPS;
X sp++;
X break;
X case 'b':
X if (--termcap < 1)
X return OOPS;
X sp++;
X break;
X case 'f':
X if (!termcap++)
X return OOPS;
X sp++;
X break;
X }
X break;
X default:
X if (scan_for)
X sp++;
X else
X *dp++ = *sp++;
X break;
X }
X }
X va_end(tparm_args);
X *dp = '\0';
X return buf;
X}
X
X#ifdef TEST
X
Xvoid putch(c)
Xint c; {
X c &= 0xff;
X if (c > 127 || c < 0) {
X printf("\\%03o", c);
X } else if (c < 32) {
X printf("^%c", c + '@');
X } else if (c == 127) {
X printf("^?");
X } else {
X putchar(c);
X }
X}
X
Xchar line[MAX_LINE];
X
Xint main(argc, argv)
Xint argc;
Xchar **argv; {
X register char *sp;
X putchar('\n');
X
X while(gets(line) != NULL) {
X sp = tparm(line, 1, -2, 30, 0, "bob was here");
X while(*sp)
X putch(*sp++);
X putchar('\n');
X }
X return 0;
X}
X#endif
SHAR_EOF
chmod 0644 tparm.c || echo "restore of tparm.c fails"
case $TOUCH in
can)
touch -am 0402044690 tparm.c
;;
esac
set `wc -c tparm.c`;Wc_c=$1
case "$Wc_c" in
"16585") ;;
*) echo original size 16585, current size $Wc_c ;;
esac
# ============= tiget.c ==============
echo "x - extracting tiget.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > tiget.c &&
X/*
X * tiget.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/22 03:43:36
X *
X * The various tiget terminfo functions.
X */
X
X#include "defs.h"
X#include "term.h"
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) tiget.c 1.1";
X#endif
Xextern char **_sboolnames[], **_snumnames[], **_sstrnames[];
X
Xextern int _compar();
X
Xstatic char **p2p2c;
X
Xint tigetnum(cap)
Xchar *cap; {
X register char ***match;
X p2p2c = ∩
X match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _snumnames,
X NUM_OF_NUMS, sizeof(char **), _compar);
X if (match == NULL)
X return -2;
X return cur_term->nums[*match - numnames];
X}
X
Xint tigetflag(cap)
Xchar *cap; {
X register char ***match;
X p2p2c = ∩
X match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sboolnames,
X NUM_OF_BOOLS, sizeof(char **), _compar);
X if (match == NULL)
X return -1;
X return cur_term->bools[*match - boolnames];
X}
X
Xchar *tigetstr(cap)
Xchar *cap; {
X register char ***match;
X p2p2c = ∩
X match = (char ***) bsearch((anyptr) &p2p2c, (anyptr) _sstrnames,
X NUM_OF_STRS, sizeof(char **), _compar);
X if (match == NULL)
X return (char *) -1;
X return cur_term->strs[*match - strnames];
X}
X
X
SHAR_EOF
chmod 0644 tiget.c || echo "restore of tiget.c fails"
case $TOUCH in
can)
touch -am 0402044690 tiget.c
;;
esac
set `wc -c tiget.c`;Wc_c=$1
case "$Wc_c" in
"1141") ;;
*) echo original size 1141, current size $Wc_c ;;
esac
# ============= tgoto.c ==============
echo "x - extracting tgoto.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > tgoto.c &&
X/*
X * tgoto.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/22 03:43:36
X *
X * A few kludged attempts to worry outputing ^D's and NL's...
X * My advice is to get a decent terminal.
X *
X */
X
X#include "defs.h"
X#include "term.h"
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) tgoto.c 1.1";
X#endif
X#ifdef USE_LITOUT_KLUDGE
X
X/*
X * This kludge works by telling tputs to switch the tty driver to
X * "literal output" when printing the string so we don't have worry
X * about newlines and EOTs. The problem is that ioctls used to
X * switch modes might flush buffers and cause other problems.
X */
X
X
Xchar *tgoto(str, x, y)
Xchar *str;
Xint x,y; {
X register char *sp;
X
X static char buf[MAX_LINE] = {'\\', '@'};
X
X sp = str = tparm(str, y, x);
X
X while (*sp != '\0') {
X if (*sp == '\004' || *sp == '\n') {
X strncpy(buf + 2, str, MAX_LINE - 2);
X buf[MAX_LINE - 2] = '\0';
X return buf;
X }
X sp++;
X }
X return sp;
X}
X#else
X
X#ifdef USE_UPBC_KLUDGE
X
X#ifdef USE_EXTERN_UPBC
Xextern char *BC, *UP;
X#else
X#define BC cursor_left
X#define UP cursor_right
X#endif
X
X#ifdef __GNUC__
X__inline__
X#endif
Xstatic int checkit(s)
Xregister char *s; {
X while(*s != '\0') {
X if (*s == '\004' || *s == '\n')
X return 1;
X s++;
X }
X return 0;
X}
X
X/*
X * Major kludge, basically we just changing the parmeters until we get
X * a string that doesn't contain a newline or EOT.
X */
X
Xchar *tgoto(str, x, y)
Xchar *str;
Xint x,y; {
X static char buf[MAX_LINE];
X register char *orig, *s;
X int l;
X
X orig = tparm(str, y, x);
X
X if (!checkit(orig))
X return orig;
X
X s = tparm(str, y + 1, x);
X
X if (!checkit(s)) {
X if (BC == NULL)
X return s;
X l = strlen(s);
X strncpy(buf, s, MAX_LINE - 1);
X if (l < MAX_LINE - 1)
X strncpy(buf + l, BC, MAX_LINE - 1 - l);
X return s;
X }
X
X s = tparm(str, y, x + 1);
X
X if (!checkit(s)) {
X if (UP == NULL)
X return s;
X l = strlen(s);
X strncpy(buf, s, MAX_LINE - 1);
X if (l < MAX_LINE - 1)
X strncpy(buf + l, UP, MAX_LINE - 1 - l);
X return s;
X }
X
X s = tparm(str, y + 1, x + 1);
X
X if (!checkit(s)) {
X if (UP == NULL || BC == NULL)
X return s;
X l = strlen(s);
X strncpy(buf, s, MAX_LINE - 1);
X if (l < MAX_LINE - 1)
X strncpy(buf + l, UP, MAX_LINE - 1 - l);
X l += strlen(UP);
X if (l < MAX_LINE - 1)
X strncpy(buf + l, BC, MAX_LINE - 1 - l);
X return s;
X }
X
X return orig;
X}
X
X#else
X
X/* the simple tgoto, don't worry about any of this newline/EOT crap */
X
Xchar *tgoto(str, x, y)
Xchar *str;
Xint x,y; {
X return tparm(str, y, x);
X}
X
X#endif
X
X#endif
SHAR_EOF
chmod 0644 tgoto.c || echo "restore of tgoto.c fails"
case $TOUCH in
can)
touch -am 0402044690 tgoto.c
;;
esac
set `wc -c tgoto.c`;Wc_c=$1
case "$Wc_c" in
"2435") ;;
*) echo original size 2435, current size $Wc_c ;;
esac
# ============= buildpath.c ==============
echo "x - extracting buildpath.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > buildpath.c &&
X/*
X * buildpath.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/22 03:43:37
X *
X * _buildpath builds a list of file names and terminal descriprions extracted
X * from its arguments. It returns a pointer to a structure that is used by
X * other routines as the list of file names to search for terminal
X * descriptions. It is passed a variable number of arguments consisting
X * of file name and type pairs. The file name can actually be a list of
X * file names seperated by spaces and any environment variables specified
X * by a dollar sign ($) followed by its name are substituted in. A type
X * of 1 indicates that the file name may actually be termcap description
X * and a type of 2 indicates it may be a terminfo description. A type of 0
X * indicates that the file name can only be a file name (or list of them).
X *
X */
X
X#include "defs.h"
X
X#include <ctype.h>
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) buildpath.c 1.1";
X#endif
X/* more memory is allocated for file names every HUNK file names */
X#define HUNK 32
X
X/* characters that seperate file names in a list */
X#define SEPERATORS " :"
X
Xstatic struct term_path *path = NULL; /* the list of files */
Xstatic int files = 0; /* # of files in the list */
Xstatic int size = 0; /* # of files there is space for */
X
X/* add a file name, type pair to the list */
Xstatic int addfile(file, type)
Xchar *file;
Xint type; {
X int l;
X char *s, *getenv();
X
X if (file == NULL) {
X if (type != -1)
X return -1;
X } else if (file[0] == '\0')
X return -1;
X
X#ifdef DEBUG
X if (file != NULL)
X printf("addfile: %s\n", file);
X#endif
X
X if (files >= size) {
X size += HUNK;
X if (path == NULL)
X path = (struct term_path *)
X malloc(size * sizeof(struct term_path));
X else
X path = (struct term_path *)
X realloc(path, size * sizeof(struct term_path));
X if (path == NULL)
X return 0;
X }
X if (file == NULL) {
X path[files].file = file;
X } else {
X l = strlen(file) + 1;
X s = (char *) malloc(l * sizeof(char));
X if (s == NULL)
X return 0;
X path[files].file = strcpy(s, file);
X }
X path[files].type = type;
X
X return ++files;
X}
X
X/* deallocate space used by the path list */
Xvoid _delpath(ppath)
Xstruct term_path *ppath; {
X struct term_path *p;
X
X p = ppath;
X while(p->file != NULL) {
X free(p->file);
X p++;
X }
X
X free(ppath);
X}
X
X/* build a list of paths. see above */
X#ifdef lint
X/*VARARGS2*/
Xstruct term_path *_buildpath(file, type)
Xchar *file;
Xint type;
X#else
X#ifdef USE_STDARG
X#ifdef USE_PROTOTYPES
Xstruct term_path *_buildpath(char *file, int type, ...)
X#else
Xstruct term_path *_buildpath(file, type)
Xchar *file;
Xint type;
X#endif /* USE_PROTOTYPES */
X#else /* USE_STDARG */
Xstruct term_path *_buildpath(va_alist)
Xva_dcl
X#endif /* USE_STDARG */
X#endif /* lint */
X{
X#ifndef lint
X#ifndef USE_STDARG
X char *file;
X int type;
X#endif
X#endif
X va_list ap;
X register char *s, *d, *e;
X char line[MAX_BUF+1];
X char name[MAX_NAME+1];
X int i,j;
X
X size = 0;
X files = 0;
X path = NULL;
X
X#ifdef lint
X ap = NULL;
X#else
X#ifdef USE_STDARG
X va_start(ap, type);
X#else
X va_start(ap);
X file = va_arg(ap, char *);
X type = va_arg(ap, int);
X#endif
X#endif
X
X while (type >= 0 && type <= 2) {
X s = file;
X d = line;
X i = 0;
X while(*s != '\0') {
X if (*s == '$') {
X s++;
X j = 0;
X while(*s != '\0' && (*s == '_' || isalnum(*s)))
X if (j < MAX_NAME) {
X name[j] = *s++;
X j++;
X } else
X break;
X name[j] = '\0';
X e = getenv(name);
X if (e != NULL) {
X while(*e != '\0') {
X if (i < MAX_BUF) {
X *d++ = *e++;
X i++;
X } else
X break;
X }
X } else if (*s == '/')
X s++;
X } else {
X if (i < MAX_BUF) {
X *d++ = *s++;
X i++;
X } else
X break;
X }
X }
X *d = '\0';
X if (type == 0 || line[0] == '/') {
X s = strtok(line, SEPERATORS);
X while(s != NULL) {
X if (addfile(s, 0) == 0)
X return NULL;
X s = strtok(NULL, SEPERATORS);
X }
X } else
X if (addfile(line, type) == 0)
X return NULL;
X file = va_arg(ap, char *);
X type = va_arg(ap, int);
X }
X addfile(NULL, -1);
X return path;
X}
SHAR_EOF
chmod 0644 buildpath.c || echo "restore of buildpath.c fails"
case $TOUCH in
can)
touch -am 0402044690 buildpath.c
;;
esac
set `wc -c buildpath.c`;Wc_c=$1
case "$Wc_c" in
"3998") ;;
*) echo original size 3998, current size $Wc_c ;;
esac
# ============= tcapconv.c ==============
echo "x - extracting tcapconv.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > tcapconv.c &&
X/*
X * tcapconv.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/27 18:29:29
X *
X */
X
X#include "defs.h"
X#define SINGLE
X#include "term.h"
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) tcapconv.c 1.2";
X#endif
Xextern char **_sstrcodes[], **_sstrnames[];
X
Xstatic char *C_CR = "\r";
Xstatic char *C_LF = "\n";
Xstatic char *C_BS = "\b";
Xstatic char *C_FF = "\f";
Xstatic char *C_HT = "\t";
Xstatic char *C_VT = "\013";
Xstatic char *C_NL = "\r\n";
X
X#define DEF(s) ((s) != (char *) -1 && (s) != NULL)
X#define NOTSET(s) ((s) == (char *) -1)
X
X/*
X * This routine fills in caps that either had defaults under termcap or
X * can be manufactured from obsolete termcap capabilities.
X */
X
Xvoid _tcapdefault() {
X char buf[MAX_LINE * 2 + 2];
X
X if (NOTSET(carriage_return)) {
X if (carriage_return_delay > 0) {
X sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
X carriage_return = _addstr(buf);
X } else
X carriage_return = _addstr(C_CR);
X }
X if (NOTSET(cursor_left)) {
X if (backspace_delay > 0) {
X sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
X cursor_left = _addstr(buf);
X } else if (backspaces_with_bs == 1)
X cursor_left = _addstr(C_BS);
X else if (DEF(backspace_if_not_bs))
X cursor_left = _addstr(backspace_if_not_bs);
X }
X/* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
X if (NOTSET(cursor_down)) {
X if (DEF(linefeed_if_not_lf))
X cursor_down = _addstr(linefeed_if_not_lf);
X else if (linefeed_is_newline != 1) {
X if (new_line_delay > 0) {
X sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
X cursor_down = _addstr(buf);
X } else
X cursor_down = _addstr(C_LF);
X }
X }
X if (NOTSET(scroll_forward) && crt_without_scrolling != 1) {
X if (DEF(linefeed_if_not_lf))
X cursor_down = _addstr(linefeed_if_not_lf);
X else if (linefeed_is_newline != 1) {
X if (new_line_delay > 0) {
X sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
X scroll_forward = _addstr(buf);
X } else
X scroll_forward = _addstr(C_LF);
X }
X }
X if (NOTSET(newline)) {
X if (linefeed_is_newline == 1) {
X if (new_line_delay > 0) {
X sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
X newline = _addstr(buf);
X } else
X newline = _addstr(C_LF);
X } else if (DEF(carriage_return) && DEF(scroll_forward)) {
X strncpy(buf, carriage_return, MAX_LINE-2);
X buf[MAX_LINE-1] = '\0';
X strncat(buf, scroll_forward, MAX_LINE-strlen(buf)-1);
X buf[MAX_LINE] = '\0';
X newline = _addstr(buf);
X } else if (DEF(carriage_return) && DEF(cursor_down)) {
X strncpy(buf, carriage_return, MAX_LINE-2);
X buf[MAX_LINE-1] = '\0';
X strncat(buf, cursor_down, MAX_LINE-strlen(buf)-1);
X buf[MAX_LINE] = '\0';
X newline = _addstr(buf);
X }
X }
X
X/*
X * We wait until know to decide if we've got a working cr because even
X * one that doesn't work can be used for newline. Unfortunately the
X * space allocated for it is wasted.
X */
X if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
X carriage_return = NULL;
X
X/*
X * supposedly most termcap entries have ta now and '\t' is no longer a
X * default, but it doesn't seem to be true...
X */
X if (NOTSET(tab)) {
X if (horizontal_tab_delay > 0) {
X sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
X tab = _addstr(buf);
X } else
X tab = _addstr(C_HT);
X }
X#if 0
X/* probably not needed and might confuse some programmes */
X if (NOTSET(form_feed)) {
X if (form_feed_delay > 0) {
X sprintf(buf, "%s$<%d>", C_FF, form_feed_delay);
X form_feed = _addstr(buf);
X } else
X form_feed = _addstr(C_FF);
X }
X#endif
X if (init_tabs == -1 && has_hardware_tabs == 1)
X init_tabs = 8;
X
X if (NOTSET(key_backspace))
X key_backspace = _addstr(C_BS);
X if (NOTSET(key_left))
X key_left = _addstr(C_BS);
X if (NOTSET(key_down))
X key_down = _addstr(C_LF);
X}
X
Xvoid _tcapconv() {
X char buf[MAX_LINE+1];
X
X if (GNU_tab_width > 0 && init_tabs == -1)
X init_tabs = GNU_tab_width;
X
X if (GNU_has_meta_key == 1 && has_meta_key == -1)
X has_meta_key = 1;
X
X/*
X * this is some what a kludge, but should work unless someone breaks
X * conventions.
X */
X if (DEF(other_non_function_keys)) {
X register char *s;
X static char *o;
X static char **p2p2c = &o;
X static char name[MAX_NAME] = "k";
X static char *P2C = name;
X static char **P2P2C = &P2C;
X char *str;
X register char ***match;
X
X s = strcpy(buf, other_non_function_keys);
X while(*s != '\0') {
X o = s;
X#ifdef lint
X p2p2c = &o;
X#endif
X while(*s != ',' && *s != '\0')
X s++;
X if (*s != '\0')
X *s++ = '\0';
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _sstrcodes,
X NUM_OF_STRS,
X sizeof(p2p2c),
X _compar);
X if (match == NULL)
X continue;
X str = _term_buf.strs[*match - strcodes];
X if (!DEF(str))
X continue;
X strncpy(name + 1, strnames[*match - strcodes],
X MAX_NAME - 2);
X match = (char ***) bsearch((anyptr) &P2P2C,
X (anyptr) _sstrnames,
X NUM_OF_STRS,
X sizeof(p2p2c),
X _compar);
X if (match == NULL)
X continue;
X if (!NOTSET(_term_buf.strs[*match - strnames]))
X continue;
X _term_buf.strs[*match - strnames] = _addstr(str);
X }
X }
X}
SHAR_EOF
chmod 0644 tcapconv.c || echo "restore of tcapconv.c fails"
case $TOUCH in
can)
touch -am 0402044690 tcapconv.c
;;
esac
set `wc -c tcapconv.c`;Wc_c=$1
case "$Wc_c" in
"5023") ;;
*) echo original size 5023, current size $Wc_c ;;
esac
# ============= qsort.c ==============
echo "x - extracting qsort.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > qsort.c &&
X/*
X * qsort.c
X *
X * This came from the GNU Emacs (18.55) tape.
X * Modified by Ross Ridge for use in this package
X * 90/03/27 18:29:41
X *
X */
X
X#include "defs.h"
X
X#ifdef USE_MYQSORT
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) qsort.c 1.2";
X#endif
X/*
X * qsort.c:
X * Our own version of the system qsort routine which is faster by an average
X * of 25%, with lows and highs of 10% and 50%.
X * The THRESHold below is the insertion sort threshold, and has been adjusted
X * for records of size 48 bytes.
X * The MTHREShold is where we stop finding a better median.
X */
X
X#define THRESH 4 /* threshold for insertion */
X
X#define MTHRESH 6 /* threshold for median */
X
X
X
Xstatic int qsz; /* size of each record */
X#ifdef USE_PROTOTYPES
Xstatic int (*qcmp)(anyptr,anyptr); /* the comparison routine */
X#else
Xstatic int (*qcmp)(); /* the comparison routine */
X#endif
X
Xstatic int thresh; /* THRESHold in chars */
Xstatic int mthresh; /* MTHRESHold in chars */
X
X/*
X * qsort:
X * First, set up some global parameters for qst to share. Then, quicksort
X * with qst(), and then a cleanup insertion sort ourselves. Sound simple?
X * It's not...
X */
Xvoid
Xqsort (base, n, size, compar)
X anyptr base;
X unsigned n;
X size_t size;
X#ifdef USE_PROTOTYPES
X int (*compar)(anyptr, anyptr);
X#else
X int (*compar)();
X#endif
X{
X register char *i, *j, *lo, *hi, *min;
X register int c;
X char *max;
X
X if (n <= 1) return;
X qsz = size / sizeof(char); /* of course if sizeof(char) aint one it had
X better be an even divisor of size */
X qcmp = compar;
X thresh = qsz*THRESH;
X mthresh = qsz*MTHRESH;
X max = (char *)base + n*qsz;
X if (n >= THRESH)
X {
X qst ((char *)base, max);
X hi = (char *)base + thresh;
X }
X else
X {
X hi = max;
X }
X /*
X * First put smallest element, which must be in the first THRESH, in
X * the first position as a sentinel. This is done just by searching
X * the first THRESH elements (or the first n if n < THRESH), finding
X * the min, and swapping it into the first position.
X */
X for (j = lo = (char *)base; (lo += qsz) < hi; )
X {
X if ((*qcmp) ((anyptr)j, (anyptr)lo) > 0)
X j = lo;
X }
X if (j != (char *)base)
X { /* swap j into place */
X for (i = (char *)base, hi = (char *)base + qsz; i < hi;)
X {
X c = *j;
X *j++ = *i;
X *i++ = c;
X }
X }
X /*
X * With our sentinel in place, we now run the following hyper-fast
X * insertion sort. For each remaining element, min, from [1] to [n-1],
X * set hi to the index of the element AFTER which this one goes.
X * Then, do the standard insertion sort shift on a character at a time
X * basis for each element in the frob.
X */
X for (min = (char *)base; (hi = min += qsz) < max;)
X {
X while ( (*qcmp) ((anyptr)(hi -= qsz), (anyptr) min) > 0);
X if ((hi += qsz) != min)
X {
X for (lo = min + qsz; --lo >= min;)
X {
X c = *lo;
X for (i = j = lo; (j -= qsz) >= hi; i = j)
X *i = *j;
X *i = c;
X }
X }
X }
X}
X
X/*
X * qst:
X * Do a quicksort
X * First, find the median element, and put that one in the first place as the
X * discriminator. (This "median" is just the median of the first, last and
X * middle elements). (Using this median instead of the first element is a big
X * win). Then, the usual partitioning/swapping, followed by moving the
X * discriminator into the right place. Then, figure out the sizes of the two
X * partions, do the smaller one recursively and the larger one via a repeat of
X * this code. Stopping when there are less than THRESH elements in a partition
X * and cleaning up with an insertion sort (in our caller) is a huge win.
X * All data swaps are done in-line, which is space-losing but time-saving.
X * (And there are only three places where this is done).
X */
Xstatic int
Xqst (base, max)
X char *base, char *max;
X{
X register char *i, *j, *jj, *mid;
X register int ii, c;
X char *tmp;
X int lo, hi;
X
X lo = max - base; /* number of elements as chars */
X do
X {
X /*
X * At the top here, lo is the number of characters of elements in the
X * current partition. (Which should be max - base).
X * Find the median of the first, last, and middle element and make that the
X * middle element. Set j to largest of first and middle. If max is larger
X * than that guy, then it's that guy, else compare max with loser of first
X * and take larger. Things are set up to prefer the middle, then the first
X * in case of ties.
X */
X mid = i = base + qsz * ((lo/qsz) >> 1);
X if (lo >= mthresh)
X {
X j = ((*qcmp) ((anyptr)(jj = base), (anyptr)i) > 0 ? jj : i);
X if ((*qcmp) ((anyptr)j, (anyptr)(tmp = max - qsz)) > 0)
X {
X j = (j == jj ? i : jj); /* switch to first loser */
X if ((*qcmp) ((anyptr)j, (anyptr)tmp) < 0)
X j = tmp;
X }
X if (j != i)
X {
X ii = qsz;
X do
X {
X c = *i;
X *i++ = *j;
X *j++ = c;
X }
X while( --ii );
X }
X }
X /*
X * Semi-standard quicksort partitioning/swapping
X */
X for (i = base, j = max - qsz; ;)
X {
X while (i < mid && (*qcmp) ((anyptr)i, (anyptr)mid) <= 0)
X i += qsz;
X while (j > mid)
X {
X if ((*qcmp) ((anyptr)mid, (anyptr)j) <= 0)
X {
X j -= qsz;
X continue;
X }
X tmp = i + qsz; /* value of i after swap */
X if (i == mid)
X { /* j <-> mid, new mid is j */
X mid = jj = j;
X }
X else
X { /* i <-> j */
X jj = j;
X j -= qsz;
X }
X goto swap;
X }
X if (i == mid)
X {
X break;
X }
X else
X { /* i <-> mid, new mid is i */
X jj = mid;
X tmp = mid = i; /* value of i after swap */
X j -= qsz;
X }
X swap:
X ii = qsz;
X do
X {
X c = *i;
X *i++ = *jj;
X *jj++ = c;
X }
X while (--ii);
X i = tmp;
X }
X /*
X * Look at sizes of the two partitions, do the smaller one first by
X * recursion, then do the larger one by making sure lo is its size,
X * base and max are update correctly, and branching back.
X * But only repeat (recursively or by branching) if the partition is
X * of at least size THRESH.
X */
X i = (j = mid) + qsz;
X if ((lo = j - base) <= (hi = max - i))
X {
X if (lo >= thresh)
X qst (base, j);
X base = i;
X lo = hi;
X }
X else
X {
X if (hi >= thresh)
X qst (i, max);
X max = j;
X }
X }
X while (lo >= thresh);
X}
X
X
X
X#endif
SHAR_EOF
chmod 0644 qsort.c || echo "restore of qsort.c fails"
case $TOUCH in
can)
touch -am 0402044690 qsort.c
;;
esac
set `wc -c qsort.c`;Wc_c=$1
case "$Wc_c" in
"6363") ;;
*) echo original size 6363, current size $Wc_c ;;
esac
# ============= gettcap.c ==============
echo "x - extracting gettcap.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > gettcap.c &&
X/*
X * gettcap.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/27 18:29:34
X *
X */
X
X#include "defs.h"
X#include "term.h"
X
X#include <ctype.h>
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) gettcap.c 1.3";
X#endif
Xextern char **_sboolnames[], **_sboolcodes[], **_sboolfnames[];
Xextern char **_snumnames[], **_snumcodes[], **_snumfnames[];
Xextern char **_sstrnames[], **_sstrcodes[], **_sstrfnames[];
X
Xint _gettcap(sp, cur, path)
Xregister char *sp;
XTERMINAL *cur;
Xstruct term_path *path; {
X static char name[MAX_NAME];
X static char entry[MAX_LINE];
X register char *dp;
X register TERMINAL *ct = cur;
X register char ***match;
X int i, pad, fract, mul;
X char c, flag;
X static char *p2c = name;
X static char **p2p2c = &p2c;
X
X dp = entry;
X while(*sp != ':' && *sp != '\0')
X *dp++ = *sp++;
X if (ct->name_all == NULL) {
X *dp = '\0';
X if ((ct->name_all = _addstr(entry)) == NULL)
X return 1;
X while(dp > entry && *--dp != '|');
X ct->name_long = ct->name_all + (dp - entry) + 1;
X }
X
X while(*sp != '\0') {
X while(*sp == ':')
X sp++;
X while(isspace(*sp))
X sp++;
X if (*sp == ':')
X continue;
X if (*sp == '\0')
X break;
X dp = name;
X while (*sp != ':' && *sp != '#' && *sp != '=' &&
X !isspace(*sp) && *sp != '\0')
X *dp++ = *sp++;
X *dp = '\0';
X#ifdef DEBUG
X printf(" %s", name);
X#endif
X switch(*sp) {
X case '=':
X#ifdef DEBUG
X putchar('$');
X#endif
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _sstrcodes,
X NUM_OF_STRS,
X sizeof(p2p2c), _compar);
X if (match != NULL)
X flag = _strflags[*match - strcodes];
X else
X flag = 'K';
X dp = entry;
X fract = pad = 0;
X sp++;
X if (isdigit(*sp) && flag != 'K') {
X pad = *sp++ - '0';
X while(isdigit(*sp))
X pad = pad * 10 + (*sp++ - '0');
X if (*sp == '.' && isdigit(sp[1])) {
X sp++;
X fract = (*sp++ - '0');
X }
X if (*sp == '*') {
X mul = 1;
X sp++;
X } else
X mul = 0;
X
X }
X while(*sp != '\0' && *sp != ':') {
X switch(*sp) {
X case '\\':
X switch(*++sp) {
X case 'e':
X case 'E': *dp++ = '\033'; break;
X case 'l': *dp++ = '\012'; break;
X case 'n': *dp++ = '\n'; break;
X case 'r': *dp++ = '\r'; break;
X case 't': *dp++ = '\t'; break;
X case 'b': *dp++ = '\b'; break;
X case 'f': *dp++ = '\f'; break;
X case 's': *dp++ = ' '; break;
X
X case '^':
X case '\\':
X case ',':
X case ':':
X *dp++ = *sp;
X break;
X
X case '0':
X if (!isdigit(*(sp + 1))) {
X *dp++ = '\200';
X break;
X }
X ;/* FALLTHROUGH */
X case '1':
X case '2':
X case '3':
X case '4':
X case '5':
X case '6':
X case '7':
X c = *sp - '0';
X if (sp[1] >= '0'
X && sp[1] <= '8')
X c = c * 8
X + (*++sp - '0');
X if (sp[1] >= '0'
X && sp[1] <= '8')
X c = c * 8
X + (*++sp - '0');
X switch((char)c) {
X case 0:
X if (flag == 'K')
X *dp++ = '\200';
X else {
X *dp++ = '\\';
X *dp++ = '0';
X *dp++ = '0';
X *dp++ = '0';
X }
X break;
X case '$':
X case '\'':
X case '\\':
X if (flag != 'K')
X *dp++ = '\\';
X /* FALLTHROUGH */
X default:
X if (flag == 'G'
X && c == '%')
X *dp++ = '\\';
X *dp++ = c;
X break;
X }
X break;
X default:
X *dp++ = '\\';
X *dp++ = *sp;
X break;
X }
X sp++;
X break;
X case '^':
X if (*++sp >= 'A' && *sp <= '_') {
X *dp++ = *sp++ - '@';
X } else if (*sp >= 'a' && *sp <= 'z') {
X *dp++ = *sp++ - 'a' + 1;
X } else if (*sp == '@') {
X if (flag == 'K')
X *dp++ = '\200';
X else {
X *dp++ = '\\';
X *dp++ = '0';
X *dp++ = '0';
X *dp++ = '0';
X }
X sp++;
X } else
X *dp++ = '^';
X break;
X case '$':
X if (flag != 'K')
X *dp++ = '\\';
X /* FALLTHROUGH */
X default:
X *dp++ = *sp++;
X break;
X }
X }
X if (pad != 0 || fract != 0) {
X if (fract == 0)
X sprintf(dp, "$<%d", pad);
X else
X sprintf(dp, "$<%d.%d", pad, fract);
X dp += strlen(dp);
X if (mul)
X *dp++ = '*';
X *dp++ = '>';
X }
X *dp++ = '\0';
X if(name[0] == 't' && name[1] == 'c' && name[2] == '\0'){
X if (_getother(entry, path, ct))
X return 1;
X break;
X }
X if (match == NULL)
X break;
X if (ct->strs[*match - strcodes] != (char *) -1)
X break;
X if ((ct->strs[*match - strcodes] = _addstr(entry))
X == NULL)
X return 1;
X break;
X case '#':
X#ifdef DEBUG
X putchar('#');
X#endif
X i = atoi(++sp);
X while(*sp != '\0' && *sp++ != ':');
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _snumcodes,
X NUM_OF_NUMS, sizeof(p2p2c),
X _compar);
X if (match == NULL)
X break;
X if (ct->nums[*match - numcodes] != -2)
X break;
X ct->nums[*match - numcodes] = i;
X break;
X default:
X while(*sp != '\0' && *sp++ != ':');
X if (*(dp - 1) == '@') {
X#ifdef DEBUG
X putchar('@');
X#endif
X *(dp - 1) = '\0';
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _sboolcodes,
X NUM_OF_BOOLS,
X sizeof(p2p2c),
X _compar);
X if (match != NULL) {
X#ifdef DEBUG
X putchar('!');
X#endif
X if (ct->bools[*match-boolcodes] == -1)
X ct->bools[*match-boolcodes] = 0;
X break;
X }
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _snumcodes,
X NUM_OF_NUMS,
X sizeof(p2p2c),
X _compar);
X if (match != NULL) {
X#ifdef DEBUG
X putchar('#');
X#endif
X if (ct->nums[*match-numcodes] == -2)
X ct->nums[*match-numcodes] = -1;
X break;
X }
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _sstrcodes,
X NUM_OF_STRS,
X sizeof(p2p2c),
X _compar);
X if (match != NULL) {
X#ifdef DEBUG
X putchar('$');
X#endif
X if (ct->strs[*match-strcodes]
X == (char *) -1)
X ct->strs[*match-strcodes]
X = NULL;
X break;
X }
X break;
X }
X#ifdef DEBUG
X putchar('!');
X#endif
X match = (char ***) bsearch((anyptr) &p2p2c,
X (anyptr) _sboolcodes,
X NUM_OF_BOOLS, sizeof(p2p2c),
X _compar);
X if (match == NULL)
X break;
X if (ct->bools[*match - boolcodes] != -1)
X break;
X ct->bools[*match - boolcodes] = 1;
X }
X }
X return 0;
X}
SHAR_EOF
chmod 0644 gettcap.c || echo "restore of gettcap.c fails"
case $TOUCH in
can)
touch -am 0402044690 gettcap.c
;;
esac
set `wc -c gettcap.c`;Wc_c=$1
case "$Wc_c" in
"6271") ;;
*) echo original size 6271, current size $Wc_c ;;
esac
# ============= gettinfo.c ==============
echo "x - extracting gettinfo.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > gettinfo.c &&
X/*
X * gettinfo.c
X *
X * By Ross Ridge
X * Public Domain
X * 90/03/27 18:29:31
X *
X */
X
X#include "defs.h"
X#include "term.h"
X
X#include <ctype.h>
X
X#ifdef USE_SCCS_IDS
Xstatic char SCCSid[] = "@(#) gettinfo.c 1.2";
X#endif
Xextern char **_sboolnames[], **_sboolcodes[], **_sboolfnames[];
Xextern char **_snumnames[], **_snumcodes[], **_snumfnames[];
Xextern char **_sstrnames[], **_sstrcodes[], **_sstrfnames[];
X
Xint _gettinfo(sp, cur, path)
Xregister char *sp;
Xstruct term_path *path;
XTERMINAL *cur; {
X static char name[MAX_NAME];
X static char entry[MAX_LINE];
X register char *dp;
X register TERMINAL *ct = cur;
X register char ***match;
X int i, base;
X char c, flag;
X static char *p2c = name;
X static char **p2p2c = &p2c;
X
X dp = entry;
X while(*sp != ',' && *sp != '\0')
X *dp++ = *sp++;
X if (ct->name_all == NULL) {
SHAR_EOF
echo "End of tinfo part 2"
echo "File gettinfo.c is continued in part 3"
echo "3" > s3_seq_.tmp
exit 0
--
Ross Ridge //
"The Great HTMU" [oo]
ross@contact.uucp -()-
ross@watcsc.waterloo.edu //