home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume21
/
ecu
/
part08
< prev
next >
Wrap
Text File
|
1991-08-05
|
55KB
|
2,152 lines
Newsgroups: comp.sources.misc
From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
Subject: v21i060: ecu - ECU async comm package rev 3.10, Part08/37
Message-ID: <1991Aug3.033806.28412@sparky.IMD.Sterling.COM>
X-Md4-Signature: 6557e4b0a5675290240c8313ff7925ce
Date: Sat, 3 Aug 1991 03:38:06 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
Posting-number: Volume 21, Issue 60
Archive-name: ecu/part08
Supersedes: ecu3: Volume 16, Issue 25-59
Environment: SCO, XENIX, ISC
---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is ecu310.08 (part 8 of ecu310)
# do not concatenate these parts, unpack them in order with /bin/sh
# file ecuphone.c continued
#
if touch 2>&1 | fgrep 'amc' > /dev/null
then TOUCH=touch
else TOUCH=true
fi
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 8; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping ecuphone.c'
else
echo 'x - continuing file ecuphone.c'
sed 's/^X//' << 'SHAR_EOF' >> 'ecuphone.c' &&
X case 'c': pde_cmd_change_dir(); break;
X
X case 'w': pde_cmd_set_wait(); break;
X
X case CRET:
X case NL:
X cmd = NL;
X if(!check_curr_pde())
X break;
X pde_list_save_if_dirty();
X windows_end(dirw);
X dirw = (WINDOW *)0;
X scrw = (WINDOW *)0;
X pde_dial_cycle();
X done = 1;
X if(rcvr_was_active)
X start_rcvr_process(1);
X break;
X
X case ESC:
X case CTL_C:
X cmd = 'q';
X case 'q':
X done = 1;
X continue;
X
X case '/':
X case 'f': pde_cmd_find(); break;
X
X case 'r': pde_cmd_remove(); break;
X case 'o': pde_cmd_remove_oops(); break;
X
X case 'a': pde_cmd_add((PDE *)0); break;
X
X case 'e': pde_add_or_edit(curr_pde,1); break;
X
X case CTL_L:
X case CTL_R:
X touchwin(stdscr);
X wrefresh(stdscr);
X touchwin(dirw);
X wrefresh(dirw);
X touchwin(scrw);
X wrefresh(scrw);
X break;
X
X default:
X sprintf(s80,"invalid command: %s",
X (cmd < 0x80) ? make_char_graphic(cmd,0) : "?");
X ring_bell();
X dirw_bot_msg(s80);
X break;
X }
X }
X sigint = 0;
X if(cmd == NL)
X return;
X
X pde_list_save_if_dirty();
X windows_end(dirw);
X dirw = (WINDOW *)0;
X scrw = (WINDOW *)0;
X redisplay_rcvr_screen();
X if(rcvr_was_active)
X start_rcvr_process(0);
X} /* end of pde_list_manager */
X
X/*+-------------------------------------------------------------------------
X copy_pde_to_lvar(tpde)
X
Xif changing line, close old line and open new one
Xif cannot change line, return 1, else 0
X--------------------------------------------------------------------------*/
Xint
Xcopy_pde_to_lvar(tpde)
Xregister PDE *tpde;
X{
Xint reopen = 0;
Xint lerr;
X
X if((tpde->tty[0] == '=') || (tpde->tty[0] == '/')) /* Devices device type */
X {
X if(choose_device(tpde->tty,tpde->baud))
X {
X sprintf(errmsg,"no idle line matches type '%s'",tpde->tty);
X return(1);
X }
X }
X else if(tpde->tty[0])
X {
X if(shm->Lline[0] && shm->Lline[8] && strcmp(tpde->tty,shm->Lline + 8))
X {
X reopen = 1;
X shm->Lmodem_already_init = 0;
X lclose();
X }
X strcpy(shm->Lline,"/dev/tty");
X strcat(shm->Lline,tpde->tty);
X }
X else /* "Any" */
X choose_line(tpde->baud);
X
X if(shm->Liofd < 0)
X reopen = 1;
X strcpy(shm->Llogical,tpde->logical);
X strcpy(shm->Ldescr,tpde->descr);
X strcpy(shm->Ltelno,tpde->telno);
X Ldial_debug_level = tpde->debug_level;
X if(!shm->Ldescr[0])
X strcpy(shm->Ldescr,shm->Llogical);
X shm->Lparity = tpde->parity;
X if(shm->Lbaud != tpde->baud)
X shm->Lmodem_already_init = 0;
X shm->Lbaud =tpde->baud;
X if(reopen)
X {
X if(lerr = lopen())
X {
X tcap_curbotleft();
X pprintf("%s: %s\n",shm->Lline,lopen_err_text(lerr));
X termecu(TERMECU_LINE_OPEN_ERROR);
X }
X }
X else
X {
X lset_baud_rate(1);
X lset_parity(1);
X }
X return(0);
X
X} /* end of copy_pde_to_lvar */
X
X/*+-----------------------------------------------------------------------
X lookup_logical_telno()
X
XA logical telephone number is either a symbolic identifer
Xor an actual telephone number. A symbolic identifer is a string
Xwhose initial character is a letter.
XAn actual telephone number begins with a numeral.
X
XThis function converts a logical telephone number
Xto a telephone number (suitable for dialing by a Hayes or
Xcompatible modem). It is called by command line processing
Xwhen 'ecu logical-name' is specified or in response to
Xa %dial logical-name. It is not used by the curses directory
Xmanager.
X
XIf the first character of 'shm->Llogical' is a digit, the entire
Xinput string is copied to 'shm->Ltelno'. If 'shm->Llogical' has a
Xnon-numeric first character, then the user's home directory is
Xsearched for the file .ecu/phone (~/.ecu/phone). The file is a series
Xof records terminated with a newline. Each record has two or three
Xfields separated by colons. The first field is the logical telephone
Xnumber and the second field is the telephone number. The third
X(optional) field contains a string to further identify the telephone
Xnumber being called.
X
XCASE IS INSIGNIFICANT in logical entry names for this procedure
X
XThe function returns one of the following:
X
X 1 if no error occurs
X 0 if not numeric phone number and logical string not found in file.
X
X------------------------------------------------------------------------*/
Xlookup_logical_telno()
X{
Xregister PDE *tpde;
X
X/* if literal phone number, return it immediately */
X Ldial_debug_level = 0;
X if(isdigit(shm->Llogical[0]))
X {
X strcpy(shm->Ltelno,shm->Llogical);
X strcpy(shm->Ldescr,"<telephone number>");
X return(1);
X }
X
X/* if logical phone number */
X if(!pde_list_quan)
X {
X if(pde_list_read())
X {
XNO_DIR:
X strcpy(errmsg,"phone directory empty");
X return(0);
X
X }
X if(!pde_list_quan)
X goto NO_DIR;
X }
X
X if(tpde = pde_list_search(shm->Llogical,0)) /* inexact search */
X return(!copy_pde_to_lvar(tpde));
X
X shm->Lrname[0] = 0;
X shm->Ltelno[0] = 0;
X shm->Ldescr[0] = 0;
X strcpy(errmsg,"entry not found in directory");
X return(0);
X
X} /* end of lookup_logical_telno */
X
X/* end of ecuphone.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
echo 'File ecuphone.c is complete' &&
$TOUCH -am 0725125691 'ecuphone.c' &&
chmod 0644 ecuphone.c ||
echo 'restore of ecuphone.c failed'
Wc_c="`wc -c < 'ecuphone.c'`"
test 51343 -eq "$Wc_c" ||
echo 'ecuphone.c: original size 51343, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecuphrase.c ==============
if test -f 'ecuphrase.c' -a X"$1" != X"-c"; then
echo 'x - skipping ecuphrase.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecuphrase.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecuphrase.c' &&
X/*+-----------------------------------------------------------------
X ecuphrases.c - %# phrase management
X wht@n4hgf.Mt-Park.GA.US
X
X Defined functions:
X phrase_help()
X phrases(nargc,nargv)
X read_phrases()
X
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X
X#define P_N_QUAN 23
Xchar *phrases_string[P_N_QUAN];
Xchar *phrases_label[P_N_QUAN];
Xint phrases_count = 0;
Xint phrases_resident = 0;
X
X/*+-----------------------------------------------------------------------
X read_phrases()
X------------------------------------------------------------------------*/
Xvoid
Xread_phrases()
X{
Xregister char *phrases_str;
Xchar phrases_buf[256];
Xchar phrases_buf_copy[256];
Xchar *phrases_lbl;
XFILE *fd_phrase;
X
X if(phrases_resident)
X {
X while(phrases_count)
X free(phrases_string[--phrases_count]);
X phrases_resident = 0;
X }
X
X get_home_dir(phrases_buf);
X strcat(phrases_buf,"/.ecu/phrases");
X
X if( (fd_phrase = fopen(phrases_buf,"r")) == NULL)
X {
X ff(se,"\r\n");
X perror(phrases_buf);
X ff(se,"\r\n");
X ff(se,"... no phrases resident\r\n");
X return;
X }
X
X/* we have an open .ecu/phrase file */
X phrases_count = 0;
X while(fgets(phrases_buf,sizeof(phrases_buf),fd_phrase) != NULL)
X {
X phrases_buf[strlen(phrases_buf) - 1] = 0;
X if(strlen(phrases_buf) == 0)
X continue;
X
X if(phrases_count == P_N_QUAN)
X {
X ff(se,"\r\nMaximum number of phrases %d exceeded\r\n",P_N_QUAN);
X ff(se,"rest of file ignored, starting with the following:\r\n");
X ff(se,"--> %s\r\n\r\n",phrases_buf);
X phrases_resident = 1;
X fclose(fd_phrase);
X return;
X }
X strcpy(phrases_buf_copy,phrases_buf);
X phrases_lbl = phrases_buf_copy;
X for(phrases_str = phrases_buf_copy; *phrases_str; phrases_str++)
X {
X if(*phrases_str == ':')
X {
X *phrases_str++ = 0;
X break;
X }
X if(*phrases_str == 0)
X {
X ff(se,"invalid entry `%s'\n",phrases_buf);
X continue;
X }
X }
X
X if(!(phrases_string[phrases_count] = malloc(strlen(phrases_str)+2)) ||
X !(phrases_label[phrases_count] = malloc(strlen(phrases_lbl)+2)))
X {
X ff(se,"\r\nNo more memory for phrases\r\n");
X ff(se,"rest of file ignored, starting with the following:\r\n");
X ff(se,"--> %s\r\n\r\n",phrases_buf);
X phrases_resident = 1;
X fclose(fd_phrase);
X if(phrases_string[phrases_count])
X free(phrases_string[phrases_count]);
X return;
X }
X strcpy(phrases_string[phrases_count],phrases_str);
X strcpy(phrases_label[phrases_count],phrases_lbl);
X phrases_count++;
X } /* while records left to read */
X
X fclose(fd_phrase);
X phrases_resident = 1;
X} /* end of read_phrases */
X
X/*+-------------------------------------------------------------------------
X phrases(nargc,nargv)
X--------------------------------------------------------------------------*/
Xphrases(nargc,nargv)
Xint nargc;
Xchar **nargv;
X{
Xregister itmp;
Xregister ichar;
Xregister char *cptr;
Xint old_ttymode = get_ttymode();
Xextern char *phrases_string[];
Xextern int phrases_count;
Xextern int phrases_resident;
Xextern int sigint;
Xextern int icmd_prompt_len;
X
X for(itmp = icmd_prompt_len + strlen(nargv[0]); itmp; itmp--)
X fputs("\b \b",se);
X
X itmp = atoi(nargv[0]);
X
X if(itmp == 0)
X {
X ff(se,"\r\n");
X read_phrases();
X if(!phrases_count)
X return(0);
X tcap_stand_out();
X ff(se,
X" # | mnemonic | phrase ");
X tcap_stand_end();
X ff(se,"\r\n");
X for(itmp = 0; itmp < phrases_count; itmp++)
X ff(se,"%2d | %12s | %s\r\n",itmp + 1,phrases_label[itmp],
X phrases_string[itmp]);
X return(0);
X }
X else
X if(phrases_resident == 0)
X read_phrases();
X
X if(itmp > phrases_count)
X {
X ff(se," unknown: %d\r\n",itmp);
X return(-1);
X }
X else
X {
X cptr = phrases_string[itmp - 1];
X ttymode(2);
X while(*cptr)
X {
X if(sigint)
X break;
X
X switch(ichar = *cptr++)
X {
X case '^':
X ichar = *cptr++;
X if((ichar >= '@') && (ichar <= '_'))
X lputc_paced(0,ichar & 0x1F);
X else if(ichar == '?')
X lputc_paced(0,0x7F);
X else
X {
X switch(ichar)
X {
X case 0:
X goto NULL_FOUND;
X case 'r':
X lputc_paced(0,'\r');
X break;
X case 'n':
X lputc_paced(0,'\n');
X break;
X case 't':
X lputc_paced(0,'\t');
X break;
X case '^':
X lputc_paced(0,'^');
X break;
X case 'p':
X itmp = atoi(cptr);
X while((*cptr >= '0') && (*cptr <= '9'))
X cptr++;
X if(*cptr == '.')
X cptr++;
X if(!itmp)
X itmp = 1;
X nap((long)itmp * 100L);
X break;
X case 'a':
X itmp = atoi(cptr);
X while((*cptr >= '0') && (*cptr <= '9'))
X cptr++;
X if(*cptr == '.')
X cptr++;
X if(itmp < nargc)
X {
X lputs_paced(0,nargv[itmp]);
X itmp = strlen(nargv[itmp]);
X }
X break;
X }
X }
X break;
X default:
X lputc_paced(0,ichar);
X }
X }
X
XNULL_FOUND:
X if(sigint)
X {
X sigint = 0;
X ff(se,"\r\n--> interrupted\r\n");
X }
X
X }
X
X ttymode(old_ttymode);
X return(0);
X
X} /* end of phrases */
X
X
X/*+-------------------------------------------------------------------------
X phrase_help()
X--------------------------------------------------------------------------*/
Xvoid
Xphrase_help()
X{
X ff(se,"^r == \\r ^n == \\n ^t == \\t ^^ == '^'\r\n");
X ff(se,"^p#. pause # secs\r\n");
X ff(se,"^a#. arg number # of %%# invocation\r\n");
X} /* end of phrase_help */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125691 'ecuphrase.c' &&
chmod 0644 ecuphrase.c ||
echo 'restore of ecuphrase.c failed'
Wc_c="`wc -c < 'ecuphrase.c'`"
test 5615 -eq "$Wc_c" ||
echo 'ecuphrase.c: original size 5615, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecurcvr.c ==============
if test -f 'ecurcvr.c' -a X"$1" != X"-c"; then
echo 'x - skipping ecurcvr.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecurcvr.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecurcvr.c' &&
X#define DEFENSIVE /* lots of changes this rev: defining this
X * will make for screwed up screen image
X * but no core dump if nassssty bugs show up
X */
X/* #define ANSI_DEBUG */ /* debug ansi */
X/* #define ANSI_DEBUG_2 */ /* debug ansi intensive output */
X/* #define ANSI_DEBUG_3 */ /* debug ansi selected output */
X/* #define ANSI_DEBUG_NOBUF */ /* unbufferred logging */
X/* #define ANSI_DEBUG_LOGFILE "/dev/tty2h" */
X/* #define DEBUG_CURSOR */
X/*+-------------------------------------------------------------------------
X ecurcvr.c - rcvr process + ANSI filter + non-ANSI<->ANSI hoop jumping
X wht@n4hgf.Mt-Park.GA.US
X
X Defined functions:
X accumulate_ansi_sequence(rchar)
X ansi_CNL()
X ansi_CPL()
X ansi_CUB()
X ansi_CUD()
X ansi_CUF()
X ansi_CUP()
X ansi_CUU()
X ansi_DCH()
X ansi_DL()
X ansi_DSR()
X ansi_ECH()
X ansi_ED()
X ansi_EL()
X ansi_HPA()
X ansi_ICH()
X ansi_IL()
X ansi_SD()
X ansi_SGR()
X ansi_SU()
X ansi_VPA()
X is_ansi_terminator(rchar)
X lgetc_rcvr()
X process_ansi_sequence()
X process_rcvd_char(rchar)
X rcvd_ESC()
X rcvr()
X rcvr_log_open()
X redisplay_rcvr_screen()
X saved_cursor_restore_cursor()
X saved_cursor_save_cursor()
X spaces(buf,buflen)
X spaces_trap(code,buf,buflen)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
X/*:07-05-1991-06:13-wht@n4hgf-SD was in baaaaadd shape */
X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
X/*:12-26-1990-14:32-wht@n4hgf-use memset in spaces() */
X/*:12-21-1990-21:06-wht@n4hgf-CUF and CUB set non-ansi cursor incorrectly */
X/*:12-20-1990-16:27-wht@n4hgf-had SU and SD swapped */
X/*:11-30-1990-18:39-wht@n4hgf-non-ansi console rcvr appears to be working */
X/*:11-28-1990-14:13-wht@n4hgf-start non-ansi console support */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecukey.h"
X
Xextern int errno;
Xextern char rcvr_log_file[]; /* if rcvr_log!= 0,log filename */
Xextern int rcvr_log; /* rcvr log active if != 0 */
Xextern FILE *rcvr_log_fp; /* rcvr log file */
Xextern int rcvr_log_raw; /* if true, log all, else filter ctl chrs */
Xextern int rcvr_log_append; /* if true, append, else scratch */
Xextern int rcvr_log_flusheach; /* if true, flush log on each char */
Xextern int rcvr_log_gen_title;
X
Xextern int want_bell_notify;
Xextern uint tcap_LINES; /* terminal line quantity - see ecutcap.c */
Xextern uint tcap_COLS; /* terminal column quantity - see ecutcap.c */
Xextern uint LINESxCOLS;
Xextern int tty_is_ansi; /* true if TERM contains "ansi" */
X
Xstatic char esc = ESC;
X#define MAX_ANSI_LEN 30 /* generous */
Xchar ansibuf[MAX_ANSI_LEN];
Xchar *ansi;
Xint ansilen = 0;
Xint in_ansi_accumulation = 0;
X
Xint saved_cursor_y;
Xint saved_cursor_x;
X
X#define RCVR_RDQUAN 250
Xchar lgetc_buf[RCVR_RDQUAN];
Xchar *lgetc_ptr;
Xextern int lgetc_count;
Xint vmin; /* quick copy of current vmin value */
X
X#ifdef ANSI_DEBUG
XFILE *wfp = (FILE *)0;
X#endif
X
Xextern int tty_is_multiscreen;
Xuchar non_multiscreen_hi_map[128] =
X{
X/*80*/ 'c','u','e','a','a','a','a','c', /* the main purpose of this ... */
X/*88*/ 'e','e','e','i','i','i','a','a', /* ... is to map ruling ... */
X/*90*/ 'e','e','a','a','a','o','u','u', /* ... characters, but as ...*/
X/*98*/ 'y','o','u','X','#','Y','P','f', /* ... a side effect, also map ... */
X/*A0*/ 'a','i','o','u','n','n','a','o', /* ... others to reasonable, ... */
X/*A8*/ '?','-','-','%','%','|','<','>', /* ... near, amusing, or random ... */
X/*B0*/ '#','#','#','|','+','+','+','.', /* ... printing characters as well */
X/*B8*/ '.','+','|','.','\'','\'','\'','.',
X/*C0*/ '`','+','+','+','-','+','+','+',
X/*C8*/ '`','.','+','+','+','=','+','+',
X/*D0*/ '+','+','+','`','`','.','.','+',
X/*D8*/ '+','\'','.','#','_','|','|','-',
X/*E0*/ 'a','b','F','T','E','o','u','t',
X/*E8*/ 'I','0','O','o','o','o','e','n',
X/*F0*/ '=','+','>','<','f','j','%','=',
X/*F8*/ 'o','.','.','V','n','2','*',' '
X};
X
X/*+-------------------------------------------------------------------------
X redisplay_rcvr_screen() - redisplay logical receiver screen
XAs of writing, this function is called only by the XMTR process
X--------------------------------------------------------------------------*/
Xvoid
Xredisplay_rcvr_screen()
X{
Xregister uint y;
Xextern int tty_not_char_special;
X
X
X if(tty_not_char_special)
X return;
X
X setcolor(colors_current);
X tcap_stand_end();
X for(y = 0; y < tcap_LINES; y++)
X {
X tcap_cursor(y,0);
X fwrite(&shm->screen[y][0],
X ((y != tcap_LINES - 1) ? tcap_COLS : tcap_COLS - 1),1,se);
X }
X tcap_eeol();
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X
X} /* end of redisplay_rcvr_screen */
X
X#ifdef DEBUG_CURSOR
Xvoid
Xspaces_trap(code,buf,buflen)
Xint code;
Xregister uchar *buf;
Xregister uint buflen;
X{
Xchar *xyz = (char *)0x90000000;
X ff(se,"rcvr 'spaces trap' code %d: cursor x,y=%d,%d\r\n",
X code,
X shm->cursor_y,shm->cursor_x);
X ff(se,"buf=%08lx len=%08lx offs=%08lx\r\n",buf,buflen,
X (ulong)buf - (ulong)shm->screen);
X *xyz = 0;
X abort();
X}
X#endif
X
X/*+-------------------------------------------------------------------------
X spaces(buf,buflen) - fill with spaces
X--------------------------------------------------------------------------*/
Xvoid
Xspaces(buf,buflen)
Xregister uchar *buf;
Xuint buflen;
X{
X#ifdef DEBUG_CURSOR
X if((ulong)buf > (((ulong)shm->screen) + LINESxCOLS))
X spaces_trap(1,buf,buflen);
X if((ulong)buf < (ulong)shm->screen)
X spaces_trap(2,buf,buflen);
X if((ulong)(buf + buflen) > (((ulong)shm->screen) + LINESxCOLS))
X spaces_trap(3,buf,buflen);
X if((ulong)(buf + buflen) < (ulong)shm->screen)
X spaces_trap(4,buf,buflen);
X#endif
X
X if(!buflen)
X return;
X
X#ifdef DEFENSIVE
X if((ulong)buf < (ulong)shm->screen)
X return;
X if((ulong)(buf + buflen) > (((ulong)shm->screen) + LINESxCOLS))
X return;
X#endif
X
X memset(buf,SPACE,buflen);
X
X} /* end of spaces */
X
X/*+-------------------------------------------------------------------------
X lgetc_rcvr() - rcvr version of get char from line
X--------------------------------------------------------------------------*/
Xint
Xlgetc_rcvr()
X{
Xextern int errno;
Xchar char_rtnd;
X
X if(!lgetc_count)
X {
X if(vmin == 1)
X {
X char_rtnd = lgetc_xmtr();
X return(char_rtnd);
X }
X lgetc_ptr = lgetc_buf;
XREAD_AGAIN:
X errno = 0;
X if((lgetc_count =
X read(shm->Liofd,lgetc_buf,RCVR_RDQUAN)) < 0)
X {
X if(errno == EINTR) /* if signal interrupted, ... */
X goto READ_AGAIN;
X termecu(TERMECU_LINE_READ_ERROR);
X }
X shm->rcvd_chars += lgetc_count;
X shm->rcvd_chars_this_connect += lgetc_count;
X
X }
X if(!lgetc_count)
X goto READ_AGAIN;
X
X lgetc_count--;
X return(*lgetc_ptr++);
X} /* end of lgetc_rcvr */
X
X/*+-------------------------------------------------------------------------
X ansi_SGR() - Set Graphics Rendition
X
XThe DOS ANSI world expects to be able to be able to chain 0,1 and
X3x,4x params together with semicolons.
X
X Supported modifiers for non-ansi terminals
X 0 normal
X 1 bold
X 4 underscore
X 5 blink
X 7 reverse video
X--------------------------------------------------------------------------*/
Xvoid
Xansi_SGR()
X{
Xregister itmp;
Xregister char *cptr;
Xchar SGRstr[MAX_ANSI_LEN];
Xchar *token;
Xchar *str_token();
X
X if(!tty_is_ansi)
X {
X ansibuf[ansilen - 1] = 0; /* get rid of 'm' */
X cptr = ansibuf + 1; /* get rid of '[' */
X if(!strlen(cptr))
X goto SGR_0;
X while(token = str_token(cptr,";"))
X {
X cptr = (char *)0; /* further calls to str_token need NULL */
X switch(atoi(token))
X {
X case 0: /* normal */
XSGR_0:
X tcap_stand_end();
X tcap_blink_off();
X tcap_underscore_off();
X tcap_bold_off();
X break;
X case 1: /* bold */
X tcap_bold_on();
X break;
X case 4: /* underscore */
X tcap_underscore_on();
X break;
X case 5: /* blink */
X tcap_blink_on();
X break;
X case 7: /* reverse video */
X tcap_stand_out();
X break;
X default:
X break;
X }
X }
X return;
X }
X
X if(ansilen <= 3) /* 'ESC[<0-9>m' and 'ESC[m' - quickly handled */
X {
X write(TTYERR,&esc,1);
X write(TTYERR,ansibuf,ansilen);
X return;
X }
X
X/* check XENIX 'ESC[<2,3,7>m' extensions */
X switch(itmp = atoi(ansibuf + 1))
X {
X case 7: /* XENIX 'ESC[7;<0-15>;<0-15>m' set fore/background color */
X itmp = atoi(ansibuf + 3); /* second parameter */
X if(itmp > 15) /* not XENIX extension */
X break;
X /* fall through */
X case 2: /* XENIX 'ESC[2;<0-15>;<0-15>m' set fore/background color */
X case 3: /* XENIX 'ESC[3;<0-1>m' color only set/clear blink */
X write(TTYERR,&esc,1);
X write(TTYERR,ansibuf,ansilen);
X return;
X default:
X break;
X }
X
X/* not XENIX extension */
X ansibuf[ansilen - 1] = 0; /* get rid of 'm' */
X cptr = ansibuf + 1; /* get rid of '[' */
X
X while(token = str_token(cptr,";"))
X {
X cptr = (char *)0; /* further calls to str_token need NULL */
X sprintf(SGRstr,"\033[%sm",token);
X write(TTYERR,SGRstr,strlen(SGRstr));
X }
X
X} /* end of ansi_SGR */
X
X/*+-------------------------------------------------------------------------
X ansi_CUP() - cursor position (also HVP horiz/vertical position)
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUP()
X{
Xregister uint param_count = 0;
Xchar ansicopy[MAX_ANSI_LEN];
Xregister char *cptr = ansicopy;
Xregister char *token;
Xchar *str_token();
X
X strcpy(cptr,ansibuf + 1);
X *(cptr + ansilen - 2) = 0;
X
X while(token = str_token(cptr,";"))
X {
X cptr = (char *)0; /* further calls to str_token need NULL */
X switch(++param_count)
X {
X case 1: shm->cursor_y = atoi(token) - 1; break;
X case 2: shm->cursor_x = atoi(token) - 1; break;
X }
X }
X switch(param_count)
X {
X case 0:
X shm->cursor_y = 0;
X case 1:
X shm->cursor_x = 0;
X }
X if(shm->cursor_x >= tcap_COLS)
X shm->cursor_x = 0;
X if(shm->cursor_y >= tcap_LINES)
X shm->cursor_y = 0;
X
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X
X} /* end of ansi_CUP */
X
X/*+-------------------------------------------------------------------------
X ansi_CUU() - cursor up
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUU()
X{
Xregister uint count;
Xregister uint y;
X
X if(ansilen == 2) /* no param */
X count = 1;
X else
X count = atoi(ansibuf + 1);
X
X y = shm->cursor_y - count;
X if(y >= tcap_LINES) /* unsigned comparison */
X y = 0;
X
X if(y != shm->cursor_y)
X {
X shm->cursor_y = y;
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X
X} /* end of ansi_CUU */
X
X/*+-------------------------------------------------------------------------
X ansi_CUD() - cursor down (also VPR vertical position relative)
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUD()
X{
Xregister uint count;
Xregister uint y;
X
X if(ansilen == 2) /* no param */
X count = 1;
X else
X count = atoi(ansibuf + 1);
X
X y = shm->cursor_y + count;
X if(y >= tcap_LINES)
X y = tcap_LINES - 1;
X
X if(y != shm->cursor_y)
X {
X shm->cursor_y = y;
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X
X} /* end of ansi_CUD */
X
X/*+-------------------------------------------------------------------------
X ansi_CUF() - cursor forward (also HPR horizontal position relative)
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUF()
X{
Xregister uint count;
Xregister uint x;
X
X if(ansilen == 2) /* no param */
X count = 1;
X else
X count = atoi(ansibuf + 1);
X
X x = shm->cursor_x + count;
X if(x >= tcap_COLS)
X x = tcap_COLS - 1;
X
X if(x != shm->cursor_x)
X {
X shm->cursor_x = x;
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X
X} /* end of ansi_CUF */
X
X/*+-------------------------------------------------------------------------
X ansi_CUB() - cursor forward
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUB()
X{
Xregister uint count;
Xregister uint x;
X
X if(ansilen == 2) /* no param */
X count = 1;
X else
X count = atoi(ansibuf + 1);
X
X x = shm->cursor_x - count;
X if(x >= tcap_COLS) /* unsigned comparison */
X x = 0;
X
X if(x != shm->cursor_x)
X {
X shm->cursor_x = x;
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X
X} /* end of ansi_CUB */
X
X/*+-------------------------------------------------------------------------
X ansi_DSR() - device status report
X--------------------------------------------------------------------------*/
Xvoid
Xansi_DSR()
X{
Xchar response[MAX_ANSI_LEN];
X
X sprintf(response,"\033[%d;%dR",shm->cursor_y + 1,shm->cursor_x + 1);
X write(shm->Liofd,response,strlen(response));
X
X} /* end of ansi_DSR */
X
X/*+-------------------------------------------------------------------------
X ansi_ED() - erase in display
X--------------------------------------------------------------------------*/
Xvoid
Xansi_ED()
X{
Xregister uint param;
Xint y;
X
X if(ansilen == 2) /* no param */
X param = 0;
X else
X param = atoi(ansibuf + 1);
X
X switch(param)
X {
X case 0: /* erase to end of display */
X spaces(&shm->screen[shm->cursor_y][shm->cursor_x],
X LINESxCOLS - ((shm->cursor_y * tcap_COLS) + shm->cursor_x));
X if(!tty_is_ansi)
X tcap_eeod();
X break;
X case 1: /* erase from beginning of display */
X spaces((char *)shm->screen,(shm->cursor_y * tcap_COLS) +
X shm->cursor_x);
X if(!tty_is_ansi)
X {
X for(y = 0; y < shm->cursor_y - 1; y++)
X {
X tcap_cursor(y,0);
X tcap_eeol();
X }
X if(shm->cursor_x)
X {
X tcap_cursor(shm->cursor_y,0);
X tcap_clear_area_char(shm->cursor_x,' ');
X }
X else
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X break;
X case 2: /* clear display */
X shm->cursor_y = 0;
X shm->cursor_x = 0;
X spaces((char *)shm->screen,LINESxCOLS);
X if(!tty_is_ansi)
X {
X tcap_clear_screen();
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X break;
X }
X
X} /* end of ansi_ED */
X
X/*+-------------------------------------------------------------------------
X ansi_EL() - erase in line
X--------------------------------------------------------------------------*/
Xvoid
Xansi_EL()
X{
Xregister uint param;
Xchar cr = CRET;
X
X if(ansilen == 2) /* no param */
X param = 0;
X else
X param = atoi(ansibuf + 1);
X
X switch(param)
X {
X case 2: /* clear line */
X shm->cursor_x = 0;
X if(!tty_is_ansi)
X write(TTYERR,&cr,1);
X /* fall thru */
X case 0: /* erase to end of line */
X spaces(&shm->screen[shm->cursor_y][shm->cursor_x],
X tcap_COLS - shm->cursor_x);
X if(!tty_is_ansi)
X tcap_eeol();
X break;
X case 1: /* erase from beginning of line */
X spaces(&shm->screen[shm->cursor_y][0],shm->cursor_x);
X if(!tty_is_ansi && shm->cursor_x)
X {
X write(TTYERR,&cr,1);
X tcap_clear_area_char(shm->cursor_x,' ');
X }
X break;
X }
X
X} /* end of ansi_EL */
X
X/*+-------------------------------------------------------------------------
X ansi_ECH() - erase characters
X--------------------------------------------------------------------------*/
Xvoid
Xansi_ECH()
X{
Xregister uint param;
Xregister uint screen_pos;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if((shm->cursor_x + param) >= tcap_COLS)
X return;
X
X screen_pos = (shm->cursor_y * tcap_COLS) + shm->cursor_x;
X mem_cpy((char *)shm->screen + screen_pos,
X (char *)shm->screen + screen_pos + param,param);
X spaces((char *)shm->screen + ((shm->cursor_y + 1) * tcap_COLS) -
X param,param);
X
X if(!tty_is_ansi)
X tcap_delete_chars(param);
X
X} /* end of ansi_ECH */
X
X/*+-------------------------------------------------------------------------
X ansi_SU() - scroll up (new blank lines at the bottom)
X--------------------------------------------------------------------------*/
Xvoid
Xansi_SU()
X{
Xregister uint param;
Xregister uint count;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param > tcap_LINES)
X param = tcap_LINES;
X if(!param)
X return;
X
X#ifdef ANSI_DEBUG_3
X if(wfp)
X fprintf(wfp,"SU: param=%u y,x=%d,%d\n",param,
X shm->cursor_y,shm->cursor_x);
X#endif
X
X count = tcap_COLS * param;
X mem_cpy((char *)shm->screen,(char *)shm->screen + count,
X LINESxCOLS - count);
X spaces((char *)shm->screen + LINESxCOLS - count,count);
X
X if(!tty_is_ansi)
X {
X tcap_cursor(tcap_LINES - 1,0);
X while(param--)
X ff(se,"\r\n");
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X
X} /* end of ansi_SU */
X
X/*+-------------------------------------------------------------------------
X ansi_SD() - scroll down (new blank lines at the top)
X--------------------------------------------------------------------------*/
Xvoid
Xansi_SD()
X{
Xregister uint param;
Xregister uint count;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param > tcap_LINES)
X param = tcap_LINES;
X if(!param)
X return;
X
X#ifdef ANSI_DEBUG_3
X if(wfp)
X fprintf(wfp,"SD: param=%u y,x=%d,%d\n",param,
X shm->cursor_y,shm->cursor_x);
X#endif
X
X count = tcap_COLS * param;
X mem_cpy((char *)shm->screen,(char *)shm->screen + count,
X LINESxCOLS - count);
X spaces((char *)shm->screen + LINESxCOLS - count,count);
X
X if(!tty_is_ansi)
X {
X tcap_cursor(0,0);
X tcap_insert_lines(count);
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X }
X
X} /* end of ansi_SD */
X
X/*+-------------------------------------------------------------------------
X ansi_HPA() - horizontal position absolute
X--------------------------------------------------------------------------*/
Xvoid
Xansi_HPA()
X{
Xregister uint param;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param >= tcap_LINES)
X return;
X
X if((unsigned)(shm->cursor_x = param) >= (unsigned)tcap_COLS)
X shm->cursor_x = tcap_COLS - 1;
X
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X
X} /* end of ansi_HPA */
X
X/*+-------------------------------------------------------------------------
X ansi_VPA() - vertical position absolute
X--------------------------------------------------------------------------*/
Xvoid
Xansi_VPA()
X{
Xregister uint param;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param >= tcap_COLS)
X return;
X
X if((unsigned)(shm->cursor_y = param) >= (unsigned)tcap_LINES)
X shm->cursor_y = tcap_LINES - 1;
X
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X
X} /* end of ansi_VPA */
X
X/*+-------------------------------------------------------------------------
X ansi_IL() - insert lines
X--------------------------------------------------------------------------*/
Xvoid
Xansi_IL()
X{
Xregister uint param;
Xregister uint count;
Xregister uint screen_pos;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if((shm->cursor_y + param) >= tcap_LINES)
X return;
X
X count = tcap_COLS * param;
X screen_pos = shm->cursor_y * tcap_COLS;
X mem_cpy((char *)shm->screen + screen_pos + count,
X (char *)shm->screen + screen_pos,
X LINESxCOLS - screen_pos - count);
X spaces((char *)shm->screen + screen_pos,count);
X
X if(!tty_is_ansi)
X tcap_insert_lines(param);
X
X} /* end of ansi_IL */
X
X/*+-------------------------------------------------------------------------
X ansi_ICH() - insert characters
X--------------------------------------------------------------------------*/
Xvoid
Xansi_ICH()
X{
Xregister uint param;
Xregister uint count;
Xregister uint screen_pos;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param > tcap_COLS - shm->cursor_x)
X param = tcap_COLS - shm->cursor_x;
X
X if(!param)
X return;
X
X screen_pos = (shm->cursor_y * tcap_COLS) + shm->cursor_x;
X count = tcap_COLS - shm->cursor_x - param;
X mem_cpy((char *)shm->screen + screen_pos + param,
X (char *)shm->screen + screen_pos,count);
X spaces((char *)shm->screen + screen_pos,param);
X
X if(!tty_is_ansi)
X tcap_insert_chars(param);
X
X} /* end of ansi_ICH */
X
X/*+-------------------------------------------------------------------------
X ansi_DL() - delete lines
X--------------------------------------------------------------------------*/
Xvoid
Xansi_DL()
X{
Xregister uint param;
Xregister uint count;
Xregister uint screen_pos;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param > (tcap_LINES - shm->cursor_y))
X param = tcap_LINES - shm->cursor_y;
X
X if(!param)
X return;
X
X count = tcap_COLS * param;
X screen_pos = shm->cursor_y * tcap_COLS;
X mem_cpy((char *)shm->screen + screen_pos,
X (char *)shm->screen + screen_pos + count,
X LINESxCOLS - screen_pos - count);
X spaces((char *)shm->screen + LINESxCOLS - count,count);
X
X if(!tty_is_ansi)
X tcap_delete_lines(param);
X
X} /* end of ansi_DL */
X
X/*+-------------------------------------------------------------------------
X ansi_DCH() - delete characters
X--------------------------------------------------------------------------*/
Xvoid
Xansi_DCH()
X{
Xregister uint param;
Xregister uint count;
Xregister uint screen_pos;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if(param > tcap_COLS - shm->cursor_x)
X param = tcap_COLS - shm->cursor_x;
X
X if(!param)
X return;
X
X screen_pos = (shm->cursor_y * tcap_COLS) + shm->cursor_x;
X count = tcap_COLS - shm->cursor_x - param;
X mem_cpy((char *)shm->screen + screen_pos,
X (char *)shm->screen + screen_pos + param,count);
X screen_pos = ((shm->cursor_y + 1) * tcap_COLS) - param;
X spaces((char *)shm->screen + screen_pos,param);
X
X if(!tty_is_ansi)
X tcap_delete_chars(param);
X
X} /* end of ansi_DCH */
X
X/*+-------------------------------------------------------------------------
X ansi_CPL() - cursor to previous line
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CPL()
X{
Xregister uint param;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if((shm->cursor_y -= param) >= tcap_LINES) /* unsigned comparison */
X shm->cursor_y = 0;
X shm->cursor_x = 0;
X
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X
X} /* end of ansi_CPL */
X
X/*+-------------------------------------------------------------------------
X ansi_CNL() - cursor to next line
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CNL()
X{
Xregister uint param;
X
X if(ansilen == 2) /* no param */
X param = 1;
X else
X param = atoi(ansibuf + 1);
X
X if((shm->cursor_y += param) >= tcap_LINES)
X shm->cursor_y = tcap_LINES - 1;
X shm->cursor_x = 0;
X
X if(!tty_is_ansi)
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X
X} /* end of ansi_CNL */
X
X/*+-------------------------------------------------------------------------
X saved_cursor_save_cursor() - nice but unfortunate IBM extension
X
XI can't find this used anywhere but in the DOS world. Supporting this
Xpair of sequences is what started this whole complex mess.
X--------------------------------------------------------------------------*/
Xvoid
Xsaved_cursor_save_cursor()
X{
X saved_cursor_y = shm->cursor_y;
X saved_cursor_x = shm->cursor_x;
X} /* end of saved_cursor_save_cursor */
X
X/*+-------------------------------------------------------------------------
X saved_cursor_restore_cursor() - nice but unfortunate IBM extension
X
XI can't find this used anywhere but in the DOS world. Supporting this
Xpair of sequences is what started this whole complex mess.
X--------------------------------------------------------------------------*/
Xvoid
Xsaved_cursor_restore_cursor()
X{
X shm->cursor_y = saved_cursor_y;
X shm->cursor_x = saved_cursor_x;
X tcap_cursor(shm->cursor_y,shm->cursor_x);
X} /* end of saved_cursor_restore_cursor */
X
X/*+-------------------------------------------------------------------------
X rcvd_ESC() - ESC seen-prepare to accumulate ansi sequence
X--------------------------------------------------------------------------*/
Xvoid
Xrcvd_ESC()
X{
X#ifdef ANSI_DEBUG
X if(wfp)
X fprintf(wfp,"ESC ");
X#endif
X
X ansi = ansibuf;
X ansilen = 0;
X in_ansi_accumulation = 1;
X
X} /* end of rcvd_ESC */
X
X/*+-------------------------------------------------------------------------
X is_ansi_terminator(rchar) - is character terminator for ansi sequence?
X--------------------------------------------------------------------------*/
Xint
Xis_ansi_terminator(rchar)
Xregister uint rchar;
X{
X return(isalpha(rchar) || (rchar == '@'));
X} /* end of is_ansi_terminator */
X
X/*+-------------------------------------------------------------------------
X accumulate_ansi_sequence(rchar)
X--------------------------------------------------------------------------*/
Xvoid
Xaccumulate_ansi_sequence(rchar)
Xuint rchar;
X{
X if(ansilen == (MAX_ANSI_LEN - 2))
X {
X in_ansi_accumulation = 0;
X return;
X }
X
X#ifdef ANSI_DEBUG_2
X if(wfp)
X {
X fprintf(wfp,"\naas: %02x %c ansilen=%d",
X rchar,(rchar & 0x7F < SPACE) ? '.' : (rchar & 0x7F),ansilen);
X }
X#endif
X
X *ansi++ = (uchar)rchar;
X *ansi = 0;
X ansilen++;
X
X} /* end of accumulate_ansi_sequence */
X
X/*+-------------------------------------------------------------------------
X process_ansi_sequence() - a full ansi sequence is to be decoded
X--------------------------------------------------------------------------*/
Xvoid
Xprocess_ansi_sequence()
X{
Xregister itmp;
X
X#ifdef ANSI_DEBUG
X if(wfp)
X fprintf(wfp,"\npas: len=%d '%s' y,x=%d,%d\n",ansilen,ansibuf,
X shm->cursor_y,shm->cursor_x);
X#endif
X
X if(!in_ansi_accumulation)
X return;
X in_ansi_accumulation = 0;
X
X itmp = 1; /* assume write needed */
X if((ansilen > 1) && (ansibuf[1] == '='))
X ;
X else switch(ansibuf[ansilen - 1])
X {
X case '@': ansi_ICH(); break;
X case 'A': ansi_CUU(); break;
X case 'B': ansi_CUD(); break;
X case 'C': ansi_CUF(); break;
X case 'D': ansi_CUB(); break;
X case 'E': ansi_CNL(); break;
X case 'F': ansi_CPL(); break;
X case 'H': ansi_CUP(); break;
X case 'J': ansi_ED(); break;
X case 'K': ansi_EL(); break;
X case 'L': ansi_IL(); break;
X case 'M': ansi_DL(); break;
X case 'P': ansi_DCH(); break;
X case 'S': ansi_SU(); break;
X case 'T': ansi_SD(); break;
X case 'X': ansi_ECH(); break;
X case '`': ansi_HPA(); break;
X case 'a': ansi_CUF(); break; /* HPR */
X case 'd': ansi_VPA(); break;
X case 'e': ansi_CUD(); break; /* VPR */
X case 'f': ansi_CUP(); break; /* HVP */
X case 'm': ansi_SGR(); itmp = 0; break;
X case 'n': ansi_DSR(); itmp = 0; break;
X case 's': saved_cursor_save_cursor(); itmp = 0; break;
X case 'u': saved_cursor_restore_cursor(); itmp = 0; break;
X#ifdef FUTURES
X case 'h': ansi_SM(); break; /* Set Mode: SCO: lock keyboard
X * MSDOS: host of shit */
X case 'i': ansi_MC(); break; /* Media Copy: send screen to line */
X case 'l': ansi_RM(); break; /* Reset Mode: SCO: unlock keyboard
X * MSDOS: host of shit */
X#endif /* FUTURES */
X default:
X break;
X }
X
X/* if proper ansi console and indicated, write the buffer to the screen */
X if(tty_is_ansi && itmp)
X {
X write(TTYERR,&esc,1);
X write(TTYERR,ansibuf,ansilen);
X }
X
X#ifdef ANSI_DEBUG
X if(wfp)
X fprintf(wfp,"pas: new cursor y,x=%d,%d\n",shm->cursor_y,shm->cursor_x);
X#endif
X} /* end of process_ansi_sequence */
X
X/*+-------------------------------------------------------------------------
X rcvr_log_open()
X--------------------------------------------------------------------------*/
Xvoid
Xrcvr_log_open()
X{
X
X if(rcvr_log) /* if xmtr set us up for logging */
X {
X rcvr_log_fp = fopen(rcvr_log_file,rcvr_log_append ? "a" : "w");
X rcvr_log_append = 1; /* until next %log -s */
X if(!rcvr_log_fp)
X {
X ff(se,"ecu RCVR: Could not open log file: %s\r\n",rcvr_log_file);
X ff(se,"recording aborted.\r\n");
X rcvr_log = 0;
X }
X else if(!rcvr_log_raw && rcvr_log_gen_title)
X {
X char tstr[80];
X get_tod(2,tstr);
X fprintf(rcvr_log_fp,"\n====> %s (%s, %s, %s) %s\n\n",
X shm->Lrname,shm->Llogical,
X shm->Ldescr,(shm->Ltelno[0]) ? shm->Ltelno : "NONE",tstr);
X }
X rcvr_log_gen_title = 0;
X }
X} /* end of rcvr_log_open */
X
X/*+-------------------------------------------------------------------------
X process_rcvd_char(rchar)
X--------------------------------------------------------------------------*/
Xint
Xprocess_rcvd_char(rchar)
Xregister uint rchar;
X{
Xregister itmp;
X
X if(shm->Lparity)
X rchar &= 0x7F;
X
X if(want_bell_notify == 2)
X {
X shmr_set_xmtr_bn_1();
X want_bell_notify = 1;
X bell_notify(XBELL_3T);
X }
X else if(rchar == 7)
X {
X bell_notify(XBELL_ATTENTION);
X return(0);
X }
X
X if(rchar == ESC)
X {
X rcvd_ESC();
X return(1);
X }
X else if(in_ansi_accumulation)
X {
X accumulate_ansi_sequence(rchar);
X if(is_ansi_terminator(rchar))
X process_ansi_sequence();
X return(1);
X }
X
X#ifdef TANDEM_ENQ_ACK /* for my friend John Dashner at Tandem */
X if(rchar == ENQ)
X {
X lputc(ACK);
X return(0);
X }
X#endif
X
X if(rchar < SPACE)
X {
X switch(rchar)
X {
X case CTL_L:
X spaces((char *)shm->screen,LINESxCOLS);
X shm->cursor_y = 0;
X shm->cursor_x = 0;
X break;
X
X case BS:
X if(shm->cursor_x)
X shm->cursor_x--;
X break;
X
X case NL:
X if(shm->cursor_y != tcap_LINES - 1)
X shm->cursor_y++;
X else
X {
X mem_cpy((char *)shm->screen,(char *)shm->screen + tcap_COLS,
X LINESxCOLS - tcap_COLS);
X spaces(&shm->screen[shm->cursor_y][0],tcap_COLS);
X }
X break;
X
X case CRET:
X shm->cursor_x = 0;
X break;
X
X case TAB:
X itmp = 8 - (shm->cursor_x % 8);
X shm->cursor_x += itmp;
X if(shm->cursor_x >= tcap_COLS)
X {
X shm->cursor_x = 0;
X if(++shm->cursor_y >= tcap_LINES)
X shm->cursor_y = tcap_LINES - 1;
X }
X#ifdef old
X else
X#endif
X spaces(&shm->screen[shm->cursor_y][shm->cursor_x],itmp);
X break;
X }
X }
X else
X {
X shm->screen[shm->cursor_y][shm->cursor_x++] = (uchar)rchar;
X if(shm->cursor_x >= tcap_COLS)
X {
X shm->cursor_x = 0;
X if(shm->cursor_y != tcap_LINES - 1)
X shm->cursor_y++;
X else
X {
X mem_cpy((char *)shm->screen,(char *)shm->screen + tcap_COLS,
X LINESxCOLS - tcap_COLS);
X spaces(&shm->screen[shm->cursor_y][shm->cursor_x],tcap_COLS);
X }
X }
X }
X
X#ifdef ANSI_DEBUG_2
X if(wfp)
X {
X if((rchar & 0x7F) == NL)
X fputs("\n",wfp);
X else
X fputc(((rchar & 0x7F) < SPACE) ? '.' : (rchar & 0x7F),wfp);
X }
X#endif
X
X if(rcvr_log && rcvr_log_fp)
X {
X /* if raw mode or character not excluded from "cooked" logging */
X if(rcvr_log_raw || ((rchar >= SPACE) && (rchar <= '~')) ||
X (rchar == NL) || (rchar == TAB))
X {
X LOGPUTC(rchar,rcvr_log_fp);
X }
X /* back if log file if not raw and char is backspace */
X else if(!rcvr_log_raw && (rchar == BS))
X {
X long logpos = 0;
X if(logpos = ftell(rcvr_log_fp))
X fseek(rcvr_log_fp,logpos - 1,0);
X }
X
X if(rcvr_log_flusheach)
X fflush(rcvr_log_fp);
X }
X return(0);
X
X} /* end of process_rcvd_char */
X
X/*+-----------------------------------------------------------------------
X rcvr() - copy characters from remote line to so (fd == 1)
X------------------------------------------------------------------------*/
Xvoid
Xrcvr()
X{
Xuchar rchar;
Xuchar nlchar = NL;
X
X#ifdef ANSI_DEBUG
Xchar s80[80];
X wfp = fopen(ANSI_DEBUG_LOGFILE,"a");
X if(ulindex(ANSI_DEBUG_LOGFILE,"/dev/tty") != -1)
X {
X sprintf(s80,"stty opost ocrnl < %s",ANSI_DEBUG_LOGFILE);
X system(s80);
X }
X fprintf(wfp,"***************\n");
X#ifdef ANSI_DEBUG_NOBUF
X setbuf(wfp,NULL);
X#endif /* ANSI_DEBUG_NOBUF */
X#endif /* ANSI_DEBUG */
X
X lgetc_count = 0;
X in_ansi_accumulation = 0;
X ansi = ansibuf;
X ansilen = 0;
X
X/* yetch - magic number gretching for lines and columns */
X if(!tcap_LINES || !tcap_COLS)
X {
X tcap_LINES = 25;
X tcap_COLS = 80;
X }
X if(tcap_LINES > 43)
X tcap_LINES = 43;
X if(tcap_COLS > 80)
X tcap_COLS = 80;
X LINESxCOLS = tcap_LINES * tcap_COLS;
X
X rcvr_signals();
X rcvr_log_open();
X
X saved_cursor_y = shm->cursor_y;
X saved_cursor_x = shm->cursor_x;
X
X/* receive loop - keep tight as possible! */
X if(tty_is_multiscreen)
X {
X while(1)
X {
X rchar = lgetc_rcvr();
X
X if(process_rcvd_char(rchar))
X continue;
X
X write(TTYERR,(char *)&rchar,1);
X
X if(shm->Ladd_nl_incoming && (rchar == CRET))
X write(TTYERR,(char *)&nlchar,1);
X }
X }
X else
X {
X while(1)
X {
X rchar = lgetc_rcvr();
X
X if(rchar >= 0x80)
X rchar = non_multiscreen_hi_map[rchar - 0x80];
X
X if(process_rcvd_char(rchar))
X continue;
X
X write(TTYERR,(char *)&rchar,1);
X
X if(shm->Ladd_nl_incoming && (rchar == CRET))
X write(TTYERR,(char *)&nlchar,1);
X }
X }
X} /* end of rcvr */
X
X/* end of ecurcvr.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125691 'ecurcvr.c' &&
chmod 0644 ecurcvr.c ||
echo 'restore of ecurcvr.c failed'
Wc_c="`wc -c < 'ecurcvr.c'`"
test 31860 -eq "$Wc_c" ||
echo 'ecurcvr.c: original size 31860, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecuscrdump.c ==============
if test -f 'ecuscrdump.c' -a X"$1" != X"-c"; then
echo 'x - skipping ecuscrdump.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecuscrdump.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecuscrdump.c' &&
X#define MULTISCREEN_DUMP_BUG
X/*+-------------------------------------------------------------------------
X ecuscrdump.c - screen dump
X wht@n4hgf.Mt-Park.GA.US
X
X Defined functions:
X screen_dump(scrfile)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
X/*:12-21-1990-17:27-wht@n4hgf-non-ansi considerations */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecukey.h"
X#include "pc_scr.h"
X
Xextern char curr_dir[CURR_DIRSIZ]; /* current working directory */
Xextern int rcvr_pid;
Xextern uint tcap_LINES;
Xextern uint tcap_COLS;
Xextern struct termio tty_termio_at_entry;
Xextern int tty_not_char_special;
Xextern int tty_is_multiscreen;
X
Xchar screen_dump_file_name[256];
X
X/*+-------------------------------------------------------------------------
X screen_dump(scrfile) - dump physical display contents
Xunless stdin is non-multiscreen and/or /dev/null, in which case,
Xdump rcvr virtual screen
Xif scrfile == NULL, default to ~/.ecu/screen.dump
X--------------------------------------------------------------------------*/
Xvoid
Xscreen_dump(scrfile)
Xchar *scrfile;
X{
Xuchar s133[133];
Xuchar schar;
Xregister uchar *cptr = s133;
Xuchar *sptr = (uchar *)shm->screen;
Xint srow = 0;
Xint scol = 0;
XFILE *fp;
Xstruct termio dump_tty_termio_at_entry;
Xstruct termio dump_tty_termio_current;
Xint rcvr_alive = (rcvr_pid > 0);
Xint use_ansi_MC = !(!tty_is_multiscreen || tty_not_char_special);
Xuint lines_left = tcap_LINES;
X
X if(rcvr_alive)
X kill_rcvr_process(SIGUSR1);
X
X if(use_ansi_MC)
X {
X /* save keyboard termio at entry */
X ioctl(TTYIN,TCGETA,(char *)&dump_tty_termio_at_entry);
X
X /* set keyboard to termio status at staart of execution of program
X * plus a few mods
X */
X
X dump_tty_termio_current = tty_termio_at_entry;
X dump_tty_termio_current.c_cflag &= ~(PARENB | PARODD);
X dump_tty_termio_current.c_cflag |= CS8;
X dump_tty_termio_current.c_iflag &= ~(ISTRIP);
X dump_tty_termio_current.c_lflag &= ~(ICANON | ISIG | ECHO);
X ioctl(TTYIN,TCSETAW,(char *) &dump_tty_termio_current);
X ttyflush(2);
X }
X
X if(scrfile)
X fp = fopen(scrfile,"a");
X else
X {
X get_home_dir(s133);
X strcat((char *)s133,"/.ecu/screen.dump");
X fp = fopen((char *)s133,"a");
X }
X if(!fp)
X {
X#if defined(MORSE)
X xbell(XBELL_DONE,1);
X#else
X ring_bell();
X nap(50L);
X ring_bell();
X#endif
X return;
X }
X
X get_tod(2,s133);
X fprintf(fp,"==> %s: %s (phone %s)\n",
X s133,shm->Ldescr,(shm->Ltelno[0]) ? shm->Ltelno : "NONE");
X
X if(use_ansi_MC)
X write(1,"\033[2i",4); /* spill your guts, screen */
X
X while(1)
X {
X if(use_ansi_MC)
X {
X if(!rdchk(0))
X {
X nap(hzmsec * 3);
X if(!rdchk(0))
X break;
X }
X read(0,(char *)&schar,1);
X if(!lines_left)
X continue;
X }
X else
X {
X if(srow == tcap_LINES)
X break;
X if(scol == tcap_COLS)
X {
X scol = 0;
X srow++;
X schar = NL;
X }
X else
X {
X schar = *sptr++;
X scol++;
X }
X }
X
X if((schar > 0x7E) || (schar < 0x20))
X {
X switch(schar)
X {
X case NL:
X while((cptr > s133) && (*(cptr - 1) == ' '))
X cptr--;
X *cptr++ = 0x0A;
X *cptr = 0;
X fputs((char *)s133,fp);
X cptr = s133;
X *cptr = 0;
X --lines_left;
X continue;
X
X case at_TL:
X schar = vanilla_TL;
X break;
X case at_TR:
X schar = vanilla_TR;
X break;
X case at_BL:
X schar = vanilla_BL;
X break;
X case at_BR:
X schar = vanilla_BR;
X break;
X case at_LT: /* left hand T */
X schar = vanilla_LT;
X break;
X case at_RT: /* right hand T */
X schar = vanilla_RT;
X break;
X case at_VR: /* vertical rule */
X schar = vanilla_VR;
X break;
X case at_HR: /* horizontal rule */
X schar = vanilla_HR;
X break;
X default:
X schar = ' ';
X }
X }
X *cptr++ = schar;
X }
X
X if(use_ansi_MC)
X {
X /* restore keyboard termio at entry */
X ioctl(TTYIN,TCSETAW,(char *)&dump_tty_termio_at_entry);
X ttyflush(2);
X#if defined(MULTISCREEN_DUMP_BUG)
X /*
X * bug in 2.3.1 sco video driver leaves "ESC[2" active;
X * use "l" (unlock tty) a noop
X */
X fputs("l",stdout);
X#endif /* MULTISCREEN_DUMP_BUG */
X }
X
X fclose(fp);
X
X#if defined(MORSE)
X xbell(XBELL_DONE,1);
X#else
X ring_bell();
X#endif
X
X if(rcvr_alive)
X start_rcvr_process(0);
X
X} /* end of screen_dump */
SHAR_EOF
$TOUCH -am 0725125691 'ecuscrdump.c' &&
chmod 0644 ecuscrdump.c ||
echo 'restore of ecuscrdump.c failed'
Wc_c="`wc -c < 'ecuscrdump.c'`"
test 4313 -eq "$Wc_c" ||
echo 'ecuscrdump.c: original size 4313, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecusetup.c ==============
if test -f 'ecusetup.c' -a X"$1" != X"-c"; then
echo 'x - skipping ecusetup.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecusetup.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecusetup.c' &&
X/*+-------------------------------------------------------------------------
X ecusetup.c -- ecu visual "argv"
X wht@n4hgf.Mt-Park.GA.US
X
X 0000000000111111111122222222223333333333444444444455555555556666
X 0123456789012345678901234567890123456789012345678901234567890123
X00.--[ ecu rev ]-------------------------------------------------.
X01| |
X02| Name/phone number to call: ..................... |
X03| Telephone .................... |
X04| Description ........................................ |
X05| |
X06| tty: /dev/tty..... (opened) |
X07| |
X08| duplex: . baud: ..... parity: . (data bits .) |
X09| add NL to transmitted CR: . |
X10| add NL to received CR: . |
X11| |
X12| |
X13| TAB:next ^B:prev END:proceed ^D:phone dir ESC:quit ecu |
X14`--------------------------------------------------------------'
X
X Defined functions:
X setup_display_baud()
X setup_display_name()
X setup_display_screen(write_lits)
X setup_display_single_char()
X setup_display_tty()
X setup_line_open()
X setup_open_status()
X setup_screen(argv_logical)
X setw_bot_msg(msg)
X setw_get_single(nondelim_list)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
X/*:06-05-1991-18:07-wht@n4hgf-rework */
X/*:04-27-1991-01:52-wht@n4hgf-overhaul revision numbers */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecucurses.h"
X#include "patchlevel.h"
SHAR_EOF
true || echo 'restore of ecusetup.c failed'
fi
echo 'End of ecu310 part 8'
echo 'File ecusetup.c is continued in part 9'
echo 9 > _shar_seq_.tmp
exit 0
--------------------------------------------------------------------
Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
Hacker Extraordinaire d' async PADs, pods, proteins and protocols
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.