home *** CD-ROM | disk | FTP | other *** search
- From: wht@n4hgf.atl.ga.us (Warren Tucker)
- Newsgroups: comp.sources.misc
- Subject: v42i104: ecu - ECU Asynchronous Communications v3.30, Part06/37
- Date: 23 May 1994 14:22:16 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2rqvp8$dk2@sparky.sterling.com>
- X-Md4-Signature: fa1f5007485453d10f51bd1737c2e462
-
- Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
- Posting-number: Volume 42, Issue 104
- Archive-name: ecu/part06
- Environment: SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2
- Supersedes: ecu: Volume 32, Issue 36-75
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: ecu330/ecufkey.c ecu330/z/zcurses.c
- # Wrapped by kent@sparky on Mon May 23 13:40:47 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 6 (of 37)."'
- if test -f 'ecu330/ecufkey.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/ecufkey.c'\"
- else
- echo shar: Extracting \"'ecu330/ecufkey.c'\" \(16642 characters\)
- sed "s/^X//" >'ecu330/ecufkey.c' <<'END_OF_FILE'
- X/*+-----------------------------------------------------------------
- X ecufkey.c -- function key definition
- X wht@n4hgf.atl.ga.us
- X
- X Defined functions:
- X ffso(str)
- X idke_to_xf(ikde)
- X kde_fgets(buf,bufsize,fp)
- X kde_name_to_ikde(keystr)
- X kde_text(ikde)
- X keyset_define_key(bufptr)
- X keyset_display()
- X keyset_idstr(ikde)
- X keyset_init()
- X keyset_read(name)
- X xf_text(xf)
- X xf_to_ikde(xf)
- X
- X------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
- X/*:01-30-1993-12:17-wht@n4hgf-remove gcc < 1.40 bug workaround */
- X/*:01-11-1993-15:42-wht@n4hgf-declare skip_ld_break */
- X/*:01-01-1993-12:52-wht@n4hgf-add procedure binding for function keys */
- X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
- X/*:04-17-1992-16:29-wht@n4hgf-initialize keyset to SCO "ANSI" send strings */
- X/*:09-01-1991-05:16-wht@n4hgf2-allow comments and whitespace after names */
- X/*:08-31-1991-13:21-wht@n4hgf2-look for keys file in ECULIBDIR */
- X/*:08-16-1991-00:11-wht@n4hgf-keyset_init loads default keyset if found */
- X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
- X/*:07-12-1991-13:57-wht@n4hgf-GCC140 fix update */
- X/*:05-21-1991-00:45-wht@n4hgf-added -3 error code to keyset_read */
- X/*:05-21-1991-00:37-wht@n4hgf-improve fkey load error detection */
- X/*:05-16-1991-15:05-wht@n4hgf-gcc binary exploded in keyset_display */
- 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 "ecufkey.h"
- X#include "ecuxkey.h"
- X#include "ecufork.h"
- X
- Xchar *str_token();
- Xchar *skip_ld_break();
- X
- Xextern char kbdintr; /* current input INTR */
- Xextern char curr_dir[CURR_DIRSIZ]; /* current working key defns */
- X
- XKDE keyset_table[KDE_COUNT];
- Xchar keyset_name[256] = "";
- X
- XKDEMAP kdemap[] =
- X{
- X {XFcurup, IKDE_CUU, "CUU", "\033[A"},
- X {XFcurdn, IKDE_CUD, "CUD", "\033[B"},
- X {XFcurrt, IKDE_CUR, "CUR", "\033[C"},
- X {XFcurlf, IKDE_CUL, "CUL", "\033[D"},
- X {XFcur5, IKDE_CU5, "CU5", "\033[E"},
- X {XFend, IKDE_END, "End", "\033[F"},
- X {XFpgdn, IKDE_PGDN, "PgDn", "\033[G"},
- X {XFhome, IKDE_HOME, "Home", "\033[H"},
- X {XFpgup, IKDE_PGUP, "PgUp", "\033[I"},
- X {XFins, IKDE_INS, "Ins", "\033[L"},
- X {XF1, IKDE_F1, "F1", "\033[M"},
- X {XF2, IKDE_F2, "F2", "\033[N"},
- X {XF3, IKDE_F3, "F3", "\033[O"},
- X {XF4, IKDE_F4, "F4", "\033[P"},
- X {XF5, IKDE_F5, "F5", "\033[Q"},
- X {XF6, IKDE_F6, "F6", "\033[R"},
- X {XF7, IKDE_F7, "F7", "\033[S"},
- X {XF8, IKDE_F8, "F8", "\033[T"},
- X {XF9, IKDE_F9, "F9", "\033[U"},
- X {XF10, IKDE_F10, "F10", "\033[V"},
- X {XF11, IKDE_F11, "F11", "\033[W"},
- X {XF12, IKDE_F12, "F12", "\033[X"},
- X {XFbktab, IKDE_BKTAB, "BkTab", "\033[Z"},
- X {255, IKDE_InitStr, "IS", ""},
- X {0, 0, "", ""}
- X};
- X
- X/*+-------------------------------------------------------------------------
- X keyset_init()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xkeyset_init()
- X{
- X register itmp;
- X register KDE *tkde;
- X register KDEMAP *kmap;
- X
- X for (itmp = 0; itmp < KDE_COUNT; itmp++)
- X {
- X tkde = &keyset_table[itmp];
- X tkde->logical[0] = 0;
- X tkde->ikde = (uchar) itmp;
- X }
- X
- X kmap = kdemap;
- X while (kmap->xf)
- X {
- X if (kmap->ikde <= IKDE_lastKey)
- X {
- X tkde = &keyset_table[kmap->ikde];
- X sprintf(tkde->logical, "SCO %s", kmap->name);
- X strcpy(tkde->str, kmap->init);
- X tkde->count = strlen(tkde->str);
- X }
- X kmap++;
- X }
- X
- X keyset_name[0] = 0;
- X
- X tkde = &keyset_table[IKDE_BKTAB];
- X strcpy(tkde->logical, "redisplay");
- X tkde->count = KACT_REDISPLAY;
- X
- X tkde = &keyset_table[IKDE_HOME];
- X strcpy(tkde->logical, "ecu cmd");
- X tkde->count = KACT_COMMAND;
- X
- X tkde = &keyset_table[IKDE_INS];
- X strcpy(tkde->logical, "local shell");
- X tkde->count = KACT_LOCAL_SHELL;
- X
- X tkde = &keyset_table[IKDE_CU5];
- X strcpy(tkde->logical, "screen dump");
- X tkde->str[0] = 0x7F; /* this key is intercepted by kbd read
- X * routine */
- X tkde->count = 0;
- X
- X} /* end of keyset_init */
- X
- X/*+-------------------------------------------------------------------------
- X kde_fgets(buf,bufsize,fp) - read and evaluate key file line
- X
- XReturns:
- X KDETYPE_COMMENT comment or blank line (null, all blank or "#"
- X as non-blank)
- X KDETYPE_NAME "name" (non "#\t " in column 1)
- X KDETYPE_ENTRY "entry" ("\t " in column 1)
- X KDETYPE_EOF end of file
- X--------------------------------------------------------------------------*/
- Xint
- Xkde_fgets(buf, bufsize, fp)
- Xchar *buf;
- Xint bufsize;
- XFILE *fp;
- X{
- X register itmp;
- X register char *cptr;
- X
- X if (!fgets(buf, bufsize, fp))
- X {
- X return (KDETYPE_EOF);
- X }
- X
- X if (!(itmp = strlen(buf)))
- X return (KDETYPE_COMMENT);
- X if (buf[itmp - 1] == NL)
- X {
- X buf[itmp - 1] = 0;
- X itmp--;
- X }
- X if (!itmp)
- X return (KDETYPE_COMMENT);
- X
- X cptr = buf;
- X itmp = (strchr(" \t", *cptr)) ? KDETYPE_ENTRY : KDETYPE_NAME;
- X while (*cptr && ((*cptr == SPACE) || (*cptr == TAB)))
- X cptr++;
- X
- X if (!*cptr || (*cptr == '#'))
- X return (KDETYPE_COMMENT);
- X
- X return (itmp);
- X
- X} /* end of kde_fgets */
- X
- X/*+-------------------------------------------------------------------------
- X kde_name_to_ikde(keystr)
- X--------------------------------------------------------------------------*/
- Xint
- Xkde_name_to_ikde(keystr)
- Xchar *keystr;
- X{
- X KDEMAP *kmap = kdemap;
- X
- X while (kmap->xf != 0)
- X {
- X if (!strcmpi(kmap->name, keystr))
- X return ((int)kmap->ikde);
- X kmap++;
- X }
- X return (-1);
- X} /* end of kde_name_to_ikde */
- X
- X/*+-------------------------------------------------------------------------
- X keyset_idstr(ikde)
- X--------------------------------------------------------------------------*/
- Xchar *
- Xkeyset_idstr(ikde)
- Xint ikde;
- X{
- X KDEMAP *kmap = kdemap;
- X
- X while (kmap->xf)
- X {
- X if ((int)kmap->ikde == ikde)
- X return (kmap->name);
- X kmap++;
- X }
- X return ((char *)0);
- X} /* end of keyset_idstr */
- X
- X/*+-------------------------------------------------------------------------
- X xf_to_ikde(xf)
- X--------------------------------------------------------------------------*/
- Xint
- Xxf_to_ikde(xf)
- Xuchar xf;
- X{
- X KDEMAP *kmap = kdemap;
- X
- X while (kmap->xf)
- X {
- X if (kmap->xf == xf)
- X return ((int)kmap->ikde & 0xFF);
- X kmap++;
- X }
- X return (-1);
- X} /* end of xf_to_ikde */
- X
- X/*+-------------------------------------------------------------------------
- X ikde_to_xf(ikde)
- X--------------------------------------------------------------------------*/
- Xint
- Xikde_to_xf(ikde)
- Xuchar ikde;
- X{
- X KDEMAP *kmap = kdemap;
- X
- X while (kmap->xf)
- X {
- X if (kmap->ikde == ikde)
- X return ((int)kmap->xf & 0xFF);
- X kmap++;
- X }
- X return (-1);
- X} /* end of ikde_to_xf */
- X
- X/*+-------------------------------------------------------------------------
- X kde_text(ikde) - ikde value to text
- X--------------------------------------------------------------------------*/
- Xchar *
- Xkde_text(ikde)
- Xint ikde;
- X{
- X KDEMAP *kmap = kdemap;
- X
- X while (kmap->xf)
- X {
- X if (kmap->ikde == (char)ikde)
- X return (kmap->name);
- X kmap++;
- X }
- X return ("??");
- X} /* end of xf_to_ikde */
- X
- X/*+-------------------------------------------------------------------------
- X xf_text(xf) - XFkey to text
- X--------------------------------------------------------------------------*/
- Xchar *
- Xxf_text(xf)
- Xuchar xf;
- X{
- X static char sc8[8];
- X
- X switch (xf)
- X {
- X case XFcurup:
- X return ("CUU");
- X case XFcurdn:
- X return ("CUD");
- X case XFcurrt:
- X return ("CUR");
- X case XFcurlf:
- X return ("CUL");
- X case XFcur5:
- X return ("CU5");
- X case XFend:
- X return ("End");
- X case XFpgdn:
- X return ("PgDn");
- X case XFhome:
- X return ("Home");
- X case XFpgup:
- X return ("PgUp");
- X case XFins:
- X return ("Ins");
- X case XF1:
- X return ("F1");
- X case XF2:
- X return ("F2");
- X case XF3:
- X return ("F3");
- X case XF4:
- X return ("F4");
- X case XF5:
- X return ("F5");
- X case XF6:
- X return ("F6");
- X case XF7:
- X return ("F7");
- X case XF8:
- X return ("F8");
- X case XF9:
- X return ("F9");
- X case XF10:
- X return ("F10");
- X case XF11:
- X return ("F11");
- X case XF12:
- X return ("F12");
- X case XFbktab:
- X return ("BkTab");
- X }
- X
- X if ((xf >= XF_ALTA) && (xf <= XF_ALTZ))
- X {
- X sprintf(sc8, "Alt-%c", 'a' + xf - XF_ALTA);
- X return (sc8);
- X }
- X sprintf(sc8, "XF_%02x\n", xf);
- X return (sc8);
- X} /* end of xf_text */
- X
- X/*+-------------------------------------------------------------------------
- X keyset_define_key(bufptr)
- X
- Xreturn 0 if no error, -1 if error
- X--------------------------------------------------------------------------*/
- Xint
- Xkeyset_define_key(bufptr)
- Xchar *bufptr;
- X{
- X register itmp;
- X register token_number;
- X register KDE *tkde = (KDE *) 0;
- X int ikde = 0;
- X char token_separator[8];
- X char *token;
- X char *syntax = "syntax error in key definition: %s\n";
- X
- X if ((itmp = strlen(bufptr)) && (bufptr[itmp - 1] == NL))
- X bufptr[--itmp] = 0; /* strip trailing NL */
- X if (!itmp)
- X return (0);
- X
- X if ((*bufptr != SPACE) && (*bufptr != TAB)) /* if no leading space */
- X return (0);
- X
- X while ((*bufptr == SPACE) || (*bufptr == TAB)) /* strip lding sp/tab */
- X bufptr++;
- X
- X token_number = 0;
- X strcpy(token_separator, ":");
- X while (token = str_token(bufptr, token_separator))
- X {
- X bufptr = (char *)0; /* further calls to str_token need NULL */
- X switch (token_number)
- X {
- X case 0: /* first field is key identifier */
- X if ((ikde = kde_name_to_ikde(token)) < 0)
- X {
- X pprintf(syntax, keyset_name);
- X pprintf(" %s is not a legal key identifier\n", token);
- X return (-1);
- X }
- X if (ikde == IKDE_HOME)
- X {
- X pprintf(syntax, keyset_name);
- X pprintf(" HOME cannot be redefined!\n");
- X return (-1);
- X }
- X if (ikde == IKDE_CU5)
- X {
- X pprintf(syntax, keyset_name);
- X pprintf(" CUR5 cannot be redefined!\n");
- X return (-1);
- X }
- X if (ikde == IKDE_BKTAB)
- X {
- X pprintf(syntax, keyset_name);
- X pprintf(" BkTab cannot be redefined!\n");
- X return (-1);
- X }
- X tkde = &keyset_table[ikde];
- X tkde->logical[0] = 0;
- X tkde->count = 0;
- X break;
- X
- X case 1: /* second field is logical key name */
- X strncpy(tkde->logical, token, sizeof(tkde->logical));
- X tkde->logical[sizeof(tkde->logical) - 1] = 0;
- X strcpy(token_separator, " \t"); /* whitespace is tok sep
- X * now */
- X break;
- X
- X case 2:
- X if (!strcmp(token, "proc"))
- X {
- X token = skip_ld_break(token + 5);
- X strncpy(tkde->str, token, sizeof(tkde->str));
- X tkde->str[sizeof(tkde->str) - 1] = 0;
- X tkde->count = KACT_PROC;
- X return (0); /* <<=========================== */
- X }
- X default: /* third and subsequent to define key */
- X if (!strlen(token))
- X continue;
- X if (tkde->count == sizeof(tkde->str))
- X {
- X pprintf(syntax, keyset_name);
- X pprintf(" %s: output count too long",
- X keyset_idstr(ikde));
- X return (-1);
- X }
- X if ((itmp = ascii_to_hex(token)) < 0)
- X {
- X pprintf(syntax, keyset_name);
- X pprintf(" %s: '%s' invalid code\n",
- X keyset_idstr(ikde), token);
- X return (0);
- X }
- X tkde->str[tkde->count] = itmp;
- X tkde->count++;
- X break;
- X } /* end of switch(token_number) */
- X token_number++;
- X } /* end while not end of record */
- X
- X return (0);
- X
- X} /* end of keyset_define_key */
- X
- X/*+-------------------------------------------------------------------------
- X keyset_read(name)
- Xreturns 0 on success, -1 if no .ecu/keys, -2 if no 'name', -3 if error
- X--------------------------------------------------------------------------*/
- Xint
- Xkeyset_read(name)
- Xchar *name;
- X{
- X int itmp;
- X int ikde;
- X char ecukeys_name[128];
- X char s128[128];
- X FILE *fp_keys;
- X
- X get_home_dir(ecukeys_name);
- X strcat(ecukeys_name, "/.ecu/keys"); /* someone may core dump here one
- X * day */
- X
- X if (!(fp_keys = fopen(ecukeys_name, "r")))
- X {
- X strcpy(ecukeys_name, eculibdir);
- X strcat(ecukeys_name, "/keys");
- X if (!(fp_keys = fopen(ecukeys_name, "r")))
- X return (-1);
- X }
- X
- X/* find keyset name */
- X itmp = 0;
- X while ((ikde = kde_fgets(s128, sizeof(s128), fp_keys)) != KDETYPE_EOF)
- X {
- X if ((ikde == KDETYPE_NAME) && !strcmp(s128, name))
- X {
- X itmp = 1; /* success */
- X break;
- X }
- X }
- X if (!itmp) /* find match? */
- X {
- X fclose(fp_keys); /* nope */
- X return (-2);
- X }
- X
- X/*
- X * read past any other keyset names matching this set
- X * process 1st line of definition when found
- X */
- X memset(s128, 0, sizeof(s128));
- X while ((ikde = kde_fgets(s128, sizeof(s128), fp_keys)) != KDETYPE_EOF)
- X {
- X if (ikde == KDETYPE_ENTRY)
- X {
- X if (keyset_define_key(s128) < 0)
- X {
- X fclose(fp_keys);
- X keyset_init();
- X return (-3);
- X }
- X break;
- X }
- X memset(s128, 0, sizeof(s128));
- X }
- X
- X/*
- X * read rest of definition
- X */
- X while ((ikde = kde_fgets(s128, sizeof(s128), fp_keys)) != KDETYPE_EOF)
- X {
- X switch (ikde)
- X {
- X case KDETYPE_COMMENT:
- X continue;
- X case KDETYPE_ENTRY:
- X if (keyset_define_key(s128) < 0)
- X {
- X fclose(fp_keys);
- X keyset_init();
- X return (-3);
- X }
- X break;
- X default:
- X goto DONE;
- X }
- X }
- X
- X DONE:
- X strncpy(keyset_name, name, sizeof(keyset_name));
- X keyset_name[sizeof(keyset_name) - 1] = 0;
- X fclose(fp_keys);
- X return (0);
- X} /* end of keyset_read */
- X
- X/*+-------------------------------------------------------------------------
- X ffso(str)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xffso(str)
- Xchar *str;
- X{
- X tcap_stand_out();
- X fputs(str, se);
- X tcap_stand_end();
- X} /* end of ffso */
- X
- X/*+-------------------------------------------------------------------------
- X keyset_display()
- X
- X F1 xxxxx F2 xxxxx HOME xxxxx PGUP xxxxx
- X F3 xxxxx F4 xxxxx END xxxxx PGDN xxxxx
- X F5 xxxxx F6 xxxxx INS xxxxx CUR5 xxxxx
- X F7 xxxxx F8 xxxxx BkTab xxxxx
- X F9 xxxxx F10 xxxxx CUR^ xxxxx CUR> xxxxx
- X F11 xxxxx F12 xxxxx CUR< xxxxx CURv xxxxx
- X--------------------------------------------------------------------------*/
- Xvoid
- Xkeyset_display()
- X{
- X int itmp;
- X int itmp2;
- X int clen1 = 0;
- X char cfmt1[32];
- X int clen2 = 0;
- X char cfmt2[32];
- X int clen3 = 0;
- X char cfmt3[32];
- X char cfmt4[32];
- X KDE *tkde;
- X
- X if (!keyset_name[0])
- X keyset_init();
- X
- X for (itmp = 0; itmp < KDE_COUNT; itmp++)
- X {
- X tkde = &keyset_table[itmp];
- X itmp2 = strlen(tkde->logical);
- X switch (itmp)
- X {
- X case IKDE_F1:
- X case IKDE_F3:
- X case IKDE_F5:
- X case IKDE_F7:
- X case IKDE_F9:
- X case IKDE_F11:
- X if (clen1 < itmp2)
- X clen1 = itmp2;
- X break;
- X
- X case IKDE_F2:
- X case IKDE_F4:
- X case IKDE_F6:
- X case IKDE_F8:
- X case IKDE_F10:
- X case IKDE_F12:
- X if (clen2 < itmp2)
- X clen2 = itmp2;
- X break;
- X
- X case IKDE_HOME:
- X case IKDE_END:
- X case IKDE_INS:
- X case IKDE_CUU:
- X case IKDE_CUL:
- X if (clen3 < itmp2)
- X clen3 = itmp2;
- X break;
- X
- X case IKDE_InitStr: /* initialization string excluded */
- X break;
- X }
- X }
- X sprintf(cfmt1, " %%-%d.%ds", clen1, clen1);
- X sprintf(cfmt2, " %%-%d.%ds", clen2, clen2);
- X sprintf(cfmt3, " %%-%d.%ds", clen3, clen3);
- X strcpy(cfmt4, " %s");
- X ff(se, " key definition: %s\r\n\r\n", keyset_name);
- X
- X ffso(" F1 ");
- X ff(se, cfmt1, keyset_table[IKDE_F1].logical);
- X fputs(" ", se);
- X ffso(" F2 ");
- X ff(se, cfmt2, keyset_table[IKDE_F2].logical);
- X fputs(" ", se);
- X ffso(" Home ");
- X ff(se, cfmt3, keyset_table[IKDE_HOME].logical);
- X fputs(" ", se);
- X ffso(" PgUp ");
- X ff(se, cfmt4, keyset_table[IKDE_PGUP].logical);
- X fputs("\r\n", se);
- X
- X ffso(" F3 ");
- X ff(se, cfmt1, keyset_table[IKDE_F3].logical);
- X fputs(" ", se);
- X ffso(" F4 ");
- X ff(se, cfmt2, keyset_table[IKDE_F4].logical);
- X fputs(" ", se);
- X ffso(" End ");
- X ff(se, cfmt3, keyset_table[IKDE_END].logical);
- X fputs(" ", se);
- X ffso(" PgDn ");
- X ff(se, cfmt4, keyset_table[IKDE_PGDN].logical);
- X fputs("\r\n", se);
- X
- X ffso(" F5 ");
- X ff(se, cfmt1, keyset_table[IKDE_F5].logical);
- X fputs(" ", se);
- X ffso(" F6 ");
- X ff(se, cfmt2, keyset_table[IKDE_F6].logical);
- X fputs(" ", se);
- X ffso(" Ins ");
- X ff(se, cfmt3, keyset_table[IKDE_INS].logical);
- X fputs(" ", se);
- X ffso(" CUR5 ");
- X ff(se, cfmt4, keyset_table[IKDE_CU5].logical);
- X fputs("\r\n", se);
- X
- X ffso(" F7 ");
- X ff(se, cfmt1, keyset_table[IKDE_F7].logical);
- X fputs(" ", se);
- X ffso(" F8 ");
- X ff(se, cfmt2, keyset_table[IKDE_F8].logical);
- X fputs(" ", se);
- X ffso(" BkTab");
- X ff(se, cfmt3, keyset_table[IKDE_BKTAB].logical);
- X fputs("\r\n", se);
- X
- X ffso(" F9 ");
- X ff(se, cfmt1, keyset_table[IKDE_F9].logical);
- X fputs(" ", se);
- X ffso(" F10 ");
- X ff(se, cfmt2, keyset_table[IKDE_F10].logical);
- X fputs(" ", se);
- X ffso(" CUR^ ");
- X ff(se, cfmt3, keyset_table[IKDE_CUU].logical);
- X fputs(" ", se);
- X ffso(" CUR> ");
- X ff(se, cfmt4, keyset_table[IKDE_CUR].logical);
- X fputs("\r\n", se);
- X
- X ffso(" F11 ");
- X ff(se, cfmt1, keyset_table[IKDE_F11].logical);
- X fputs(" ", se);
- X ffso(" F12 ");
- X ff(se, cfmt2, keyset_table[IKDE_F12].logical);
- X fputs(" ", se);
- X ffso(" CUR< ");
- X ff(se, cfmt3, keyset_table[IKDE_CUL].logical);
- X fputs(" ", se);
- X ffso(" CURv ");
- X ff(se, cfmt4, keyset_table[IKDE_CUD].logical);
- X fputs("\r\n\r\n", se);
- X
- X} /* end of keyset_display */
- X
- X/* end of ecufkey.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 16642 -ne `wc -c <'ecu330/ecufkey.c'`; then
- echo shar: \"'ecu330/ecufkey.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/ecufkey.c'
- fi
- if test -f 'ecu330/z/zcurses.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ecu330/z/zcurses.c'\"
- else
- echo shar: Extracting \"'ecu330/z/zcurses.c'\" \(44210 characters\)
- sed "s/^X//" >'ecu330/z/zcurses.c' <<'END_OF_FILE'
- X/*+-------------------------------------------------------------------------
- X zcurses.c -- ecu file transfer program curses interface
- X
- X 000000000011111111112222222222333333333344444444445555555550
- X 012345678901234567890123456789012345678901234567890123456789
- X00.-[ prog+rev ]-- <dir> ------------------------------------.
- X01| ZMODEM_6____ _40_____________________________________ |
- X02| File ### of ###: _38__________________________________ |
- X03| File position: _8______ length: _8______ -rwxrwxrwx |
- X04| _55____________________________________________________ | transaction
- X05| _55____________________________________________________ | last rx/tx hdr
- X06| Comm I/O: rx _8______ tx _8______ bytes |
- X07| Baud rate: _5___ BINARY blklen: _____ comm mode: RAW-g |
- X08| Time: started: __:__:__ this file: __:__:__ window: |
- X09| __:__:__ elapsed: __:__:__ __:__:__ ________ |
- X10| Errors: this file: _3_ total: _4__ files skipped: _3_ |
- X11| _55____________________________________________________ | err str
- X12| _55____________________________________________________ | comment str
- X13| _55____________________________________________________ | remote info
- X14`----------------------------------------------------------'
- X
- X14| FE ___ OE ___ rcvd ________ xmtd ________ RTS _ CTS _ FASI
- X15| flow xmtr CTS ____ XOFF ____ rcvr RTS ____ XOFF ____
- X16| queues: xmtr _____ of _____ rcvr _____ of _____
- X
- X14| Output queue depth ______ RTS _ CTS _ sun
- X15| Input queue depth ______ Input queue avail ______
- X
- X
- X Defined functions:
- X clear_area(w,row,col,len)
- X clear_area_char(w,row,col,len,fillchar)
- X determine_output_mode()
- X dumbtty_newline()
- X get_elapsed_time(elapsed_secs)
- X get_tod(type,tod)
- X mode_map(file_mode,mode_str)
- X report_comm_baud_rate(baud_rate)
- X report_error_count()
- X report_file_byte_io(count)
- X report_file_close(skipped)
- X report_file_open_length(length)
- X report_file_open_mode(file_mode)
- X report_file_open_tod()
- X report_file_rcv_started(filename,length,last_mod_time,file_mode)
- X report_file_send_open(filename,filestat)
- X report_file_xfer_rate(text,count,final)
- X report_init(title)
- X report_last_rxhdr(rptstr,error_flag)
- X report_last_txhdr(rptstr,error_flag)
- X report_mode(comm_mode)
- X report_protocol_crc_type(str)
- X report_protocol_type(str)
- X report_rx_ind(status)
- X report_rx_tx_count()
- X report_rxblklen(blklen)
- X report_rxpos(pos)
- X report_str(rptstr,error_flag)
- X report_top_line(topstr)
- X report_transaction(str)
- X report_transfer_progress(filepos,initfpos)
- X report_tx_ind(status)
- X report_txblklen(blklen)
- X report_txpos(pos)
- X report_uninit(sig)
- X report_window()
- X report_xfer_mode(str)
- X vanilla_ruling()
- X
- X------------------------------------------------------------------------*/
- X/*+:EDITS:*/
- X/*:05-04-1994-04:40-wht@n4hgf-ECU release 3.30 */
- X/*:01-16-1994-15:46-wht@n4hgf-use ecumachdep.h */
- X/*:12-02-1993-14:05-Robert_Broughton@mindlink.bc.c-LINUX patches */
- X/*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
- X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
- X/*:02-09-1992-16:08-root@n4hgf-ruling characters only on SCO (tcap curses) */
- X/*:01-05-1992-17:27-wht@n4hgf-properly display progress for resumed transfers */
- X/*:09-02-1991-01:12-wht@n4hgf2-show sun driver information */
- X/*:08-28-1991-14:08-wht@n4hgf2-SVR4 cleanup by aega84!lh */
- X/*:08-23-1991-18:33-wht@n4hgf2-disable force no curses for tty vs. line speed */
- X/*:08-21-1991-06:23-wht@n4hgf-sun porting */
- X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
- X/*:06-15-1991-05:47-root@n4hgf-report per-file xfer rate */
- X/*:05-25-1991-14:51-wht@n4hgf-FAS/i display */
- X/*:04-24-1991-01:22-wht@n4hgf-handle dumbtty and single file xfer >= 1 hour */
- X/*:02-03-1991-17:27-wht@n4hgf-show elapsed time during no curses xfer */
- X/*:01-04-1991-15:54-wht@n4hgf-dumbtty per-file xfer rate was wrong */
- X/*:12-18-1990-21:26-wht@n4hgf-better output control */
- X/*:12-04-1990-04:07-wht@n4hgf-handle slow terminal using faster line */
- X/*:12-04-1990-03:04-wht@n4hgf-choose ruling chars based on multiscreen or not */
- X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
- X/*:08-14-1990-20:41-wht@n4hgf-ecu3.00-flush old edit history */
- X
- X#include "../ecucurses.h"
- X#include "../ecu_types.h"
- X#include "../ecu_stat.h"
- X#include "../ecu_time.h"
- X#include <ctype.h>
- X#include <signal.h>
- X
- X#include "../ecumachdep.h"
- X#include "../pc_scr.h"
- X
- X#if defined(FASI)
- X#include <local/fas.h>
- X#endif /* FASI */
- X
- Xlong time();
- Xvoid report_error_count();
- Xextern char *tzname[];
- Xstruct tm *localtime();
- X
- X#ifdef LINUX
- Xtypedef chtype Chtype;
- X
- X#else
- Xtypedef unsigned char Chtype;
- X
- X#endif
- X
- XChtype sTL = at_TL;
- XChtype sTR = at_TR;
- XChtype sBL = at_BL;
- XChtype sBR = at_BR;
- XChtype sLT = at_LT;
- XChtype sRT = at_RT;
- XChtype sVR = at_VR;
- XChtype sHR = at_HR;
- X
- X#if defined(FASI)
- X#define WIN_LINES 18
- X#else
- X#if defined(sun) && !defined (SVR4)
- X#define WIN_LINES 17
- X#else
- X#define WIN_LINES 15
- X#endif /* sun */
- X#endif /* FASI */
- X
- X#define WIN_COLS 60
- X#define WIN_TOPY 2
- X#define WIN_LEFTX 8
- X
- Xextern char curr_dir[];
- Xextern char *bottom_label;
- Xextern int Filcnt;
- Xextern int ecusz_flag; /* ecusz == 1, ecurz == 0 */
- Xextern int force_dumbtty;
- Xextern int skip_count;
- Xextern int npats;
- Xextern int iofd;
- Xextern long rxpos;
- Xextern int log_packets;
- Xextern long Txpos;
- Xextern long Rxpos;
- Xextern long initial_filepos;
- X
- XWINDOW *win;
- Xint (*original_sigint_handler) ();
- Xint (*original_sigquit_handler) ();
- Xint (*original_sigterm_handler) ();
- Xint report_init_complete;
- Xint report_verbosity;
- Xint dumbtty;
- Xint dumbtty_pos;
- Xint this_file_errors;
- Xlong this_file_xfer_count;
- Xint total_errors;
- Xint show_window;
- Xlong current_seconds;
- Xlong start_seconds;
- Xlong this_file_start_seconds;
- Xlong elapsed_seconds;
- Xunsigned long total_data_bytes_xfered;
- Xunsigned int zcurses_baud_rate;
- Xchar s128[128];
- X
- X#if defined(FASI)
- Xstruct fas_info fip_start;
- X
- X#endif /* FASI */
- X
- Xchar *win_template[] =
- X{
- X/*00000000001111111111222222222233333333334444444444555555555 */
- X/*01234567890123456789012345678901234567890123456789012345678 */
- X/*.----------------------------------------------------------. */
- X " ", /* 1 */
- X " File ### of ###: _____________________________________ ", /* 2 */
- X " File position: ________ length: ________ ", /* 3 */
- X " ", /* 4 */
- X " tx: ______________________ rx: ______________________ ", /* 5 */
- X " Comm I/O: rx ________ tx ________ bytes ", /* 6 */
- X " Baud rate: _____ ______ blklen: _____ comm mode: ______ ", /* 7 */
- X " Time: started: __:__:__ this file: __:__:__ ", /* 8 */
- X " __:__:__ elapsed: __:__:__ __:__:__ ", /* 9 */
- X " Errors: this file: ___ total: ____ files skipped: ___ ", /* 10 */
- X " ", /* 11 */
- X " ", /* 12 */
- X " ", /* 13 */
- X#if defined(FASI)
- X " FE ___ OE ___ rcvd ________ xmtd ________ RTS _ CTS _ ",
- X " flow xmtr CTS ____ XOFF ____ rcvr RTS ____ XOFF ____ ",
- X " queues: xmtr _____ of _____ rcvr _____ of _____ ",
- X#endif /* FASI */
- X#if defined(sun)
- X " Output queue depth ______ RTS _ CTS _ ",
- X " Input queue depth ______ Input queue avail ______ ",
- X#endif
- X/*`----------------------------------------------------------' */
- X (char *)0
- X};
- X
- X/*+-------------------------------------------------------------------------
- X vanilla_ruling() - use ordinary ruling characters
- X--------------------------------------------------------------------------*/
- Xvoid
- Xvanilla_ruling()
- X{
- X sTL = vanilla_TL;
- X sTR = vanilla_TR;
- X sBL = vanilla_BL;
- X sBR = vanilla_BR;
- X sLT = vanilla_LT;
- X sRT = vanilla_RT;
- X sVR = vanilla_VR;
- X sHR = vanilla_HR;
- X
- X} /* end of vanilla_ruling */
- X
- X/*+-----------------------------------------------------------------------
- X char *get_elapsed_time(elapsed_secs)
- X hh:mm:ss returned
- X static string address is returned
- X------------------------------------------------------------------------*/
- Xchar *
- Xget_elapsed_time(elapsed_secs)
- Xlong elapsed_secs;
- X{
- X static char elapsed_time_str[10];
- X long hh, mm, ss;
- X
- X hh = elapsed_secs / 3600;
- X elapsed_secs -= hh * 3600;
- X mm = elapsed_secs / 60L;
- X elapsed_secs -= mm * 60L;
- X ss = elapsed_secs;
- X
- X sprintf(elapsed_time_str, "%02ld:%02ld:%02ld", hh, mm, ss);
- X return (elapsed_time_str);
- X} /* end of get_elapsed_time */
- X
- X/*+-----------------------------------------------------------------------
- X char *get_tod(type,tod)
- X
- X time of day types:
- X 0 hh:mm
- X 1 hh:mm:ss
- X 2 mm-dd-yyyy hh:mm
- X
- X static string address is returned
- X if tod != (char *)0, time is returned there too
- X------------------------------------------------------------------------*/
- Xchar *
- Xget_tod(type, tod)
- Xint type;
- Xchar *tod;
- X{
- X static char tod_str[32];
- X long cur_time = time((long *)0);
- X struct tm *lt = localtime(&cur_time);
- X
- X switch (type)
- X {
- X case 0:
- X sprintf(tod_str, "%02d:%02d", lt->tm_hour, lt->tm_min);
- X break;
- X
- X default:
- X case 1:
- X sprintf(tod_str, "%02d:%02d:%02d",
- X lt->tm_hour, lt->tm_min, lt->tm_sec);
- X break;
- X
- X case 2:
- X sprintf(tod_str, "%02d-%02d-%04d %02d:%02d",
- X lt->tm_mon + 1, lt->tm_mday, lt->tm_year + 1900,
- X lt->tm_hour, lt->tm_min);
- X break;
- X }
- X
- X if (tod != (char *)0)
- X strcpy(tod, tod_str);
- X
- X return (tod_str);
- X} /* end of get_tod */
- X
- X/*+-----------------------------------------------------------------------
- X mode_map(file_mode,mode_str) build drwxrwxrwx string
- X------------------------------------------------------------------------*/
- Xchar *
- Xmode_map(file_mode, mode_str)
- Xunsigned short file_mode;
- Xchar *mode_str;
- X{
- X register unsigned ftype = file_mode & S_IFMT;
- X register char *rtn;
- X static char result[12];
- X
- X rtn = (mode_str == (char *)0) ? result : mode_str;
- X
- X /* drwxrwxrwx */
- X /* 0123456789 */
- X strcpy(rtn, "----------");
- X
- X switch (ftype)
- X {
- X case S_IFIFO:
- X *rtn = 'p';
- X break; /* FIFO (named pipe) */
- X case S_IFDIR:
- X *rtn = 'd';
- X break; /* directory */
- X case S_IFCHR:
- X *rtn = 'c';
- X break; /* character special */
- X case S_IFBLK:
- X *rtn = 'b';
- X break; /* block special */
- X case S_IFREG:
- X *rtn = '-';
- X break; /* regular */
- X
- X#if defined(S_IFLNK)
- X case S_IFLNK:
- X *rtn = 'l';
- X break; /* symbolic link */
- X#endif
- X#if defined(S_IFSOCK)
- X case S_IFSOCK:
- X *rtn = 's';
- X break; /* socket */
- X#endif
- X
- X#if defined(S_IFNAM)
- X case S_IFNAM: /* name space entry */
- X#if defined(S_IFNAM)
- X if (file_mode & S_INSEM) /* semaphore */
- X {
- X *rtn = 's';
- X break;
- X }
- X#endif
- X#if defined(S_INSHD)
- X if (file_mode & S_INSHD) /* shared memory */
- X {
- X *rtn = 'm';
- X break;
- X }
- X break;
- X#endif
- X#endif
- X
- X default:
- X *rtn = '?';
- X break; /* ??? */
- X }
- X
- X if (file_mode & 000400)
- X *(rtn + 1) = 'r';
- X if (file_mode & 000200)
- X *(rtn + 2) = 'w';
- X if (file_mode & 000100)
- X *(rtn + 3) = 'x';
- X if (file_mode & 004000)
- X *(rtn + 3) = 's';
- X if (file_mode & 000040)
- X *(rtn + 4) = 'r';
- X if (file_mode & 000020)
- X *(rtn + 5) = 'w';
- X if (file_mode & 000010)
- X *(rtn + 6) = 'x';
- X if (file_mode & 002000)
- X *(rtn + 6) = 's';
- X if (file_mode & 000004)
- X *(rtn + 7) = 'r';
- X if (file_mode & 000002)
- X *(rtn + 8) = 'w';
- X if (file_mode & 000001)
- X *(rtn + 9) = 'x';
- X if (file_mode & 001000)
- X *(rtn + 9) = 't';
- X
- X return (rtn);
- X
- X} /* end of mode_map */
- X
- X/*+-------------------------------------------------------------------------
- X dumbtty_newline()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xdumbtty_newline()
- X{
- X if (dumbtty_pos)
- X printf("\r\n");
- X dumbtty_pos = 0;
- X
- X} /* end of dumbtty_newline */
- X
- X/*+-------------------------------------------------------------------------
- X clear_area(w,row,col,len)
- X--------------------------------------------------------------------------*/
- Xclear_area(w, row, col, len)
- XWINDOW *w;
- Xint row;
- Xint col;
- Xint len;
- X{
- X if (dumbtty)
- X return;
- X wmove(w, row, col);
- X while (len-- > 0)
- X waddch(w, ' ');
- X wmove(w, row, col);
- X
- X} /* end of clear_area */
- X
- X/*+-------------------------------------------------------------------------
- X clear_area_char(w,row,col,len,fillchar)
- X--------------------------------------------------------------------------*/
- Xclear_area_char(w, row, col, len, fillchar)
- XWINDOW *w;
- Xint row;
- Xint col;
- Xint len;
- Xchar fillchar;
- X{
- X if (dumbtty)
- X return;
- X wmove(w, row, col);
- X while (len-- > 0)
- X waddch(w, fillchar);
- X wmove(w, row, col);
- X
- X} /* end of clear_area_char */
- X
- X/*+-------------------------------------------------------------------------
- X report_top_line(topstr)
- X top line: row 1 col 17 length 42
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_top_line(topstr)
- Xchar *topstr;
- X{
- X char s42[42];
- X
- X if (dumbtty)
- X {
- X dumbtty_newline();
- X dumbtty_pos = printf("%s", topstr);
- X fflush(stdout);
- X return;
- X }
- X
- X clear_area(win, 1, 17, 42);
- X if (strlen(topstr) < 40)
- X waddstr(win, topstr);
- X else
- X {
- X strncpy(s42, topstr, 40);
- X s42[40] = 0;
- X waddstr(win, s42);
- X }
- X} /* end of report_top_line */
- X
- X/*+-------------------------------------------------------------------------
- X report_xfer_mode(modestr) BINARY/ASCII
- X protocol xfer type: row 7 col 20 length 6
- X--------------------------------------------------------------------------*/
- Xreport_xfer_mode(str)
- Xchar *str;
- X{
- X char s10[10];
- X
- X if (dumbtty)
- X return;
- X if (strlen(str) > 6)
- X {
- X strncpy(s10, str, 6);
- X s10[7] = 0;
- X str = s10;
- X }
- X clear_area(win, 7, 20, 6);
- X waddstr(win, str);
- X wrefresh(win);
- X
- X} /* end of report_xfer_mode */
- X
- X/*+-------------------------------------------------------------------------
- X report_protocol_type(str)
- X
- X protocol type: row 1 col 3 length 6 string
- X--------------------------------------------------------------------------*/
- Xreport_protocol_type(str)
- Xregister char *str;
- X{
- X char s10[10];
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X if (strlen(str) > 6)
- X {
- X strncpy(s10, str, 6);
- X s10[7] = 0;
- X str = s10;
- X }
- X clear_area(win, 1, 3, 6);
- X waddstr(win, str);
- X wrefresh(win);
- X
- X} /* end of report_protocol_type */
- X
- X/*+-------------------------------------------------------------------------
- X report_protocol_crc_type(str)
- X
- X protocol crc type: row 1 col 9 length 6
- X--------------------------------------------------------------------------*/
- Xreport_protocol_crc_type(str)
- Xregister char *str;
- X{
- X char s8[8];
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X if (strlen(str) > 6)
- X {
- X strncpy(s8, str, 6);
- X s8[7] = 0;
- X str = s8;
- X }
- X clear_area(win, 1, 9, 6);
- X waddstr(win, str);
- X wrefresh(win);
- X
- X} /* end of report_protocol_crc_type */
- X
- X/*+-------------------------------------------------------------------------
- X report_uninit(sig)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_uninit(sig)
- Xint sig; /* if -1, called by normal code, else kill()
- X * value */
- X{
- X float rate = 0.0;
- X float eff = 0.0;
- X
- X if (report_init_complete)
- X {
- X current_seconds = time((long *)0);
- X elapsed_seconds = current_seconds - start_seconds;
- X if (elapsed_seconds && (zcurses_baud_rate > 50))
- X {
- X rate = (float)total_data_bytes_xfered /
- X (float)elapsed_seconds;
- X if (zcurses_baud_rate)
- X eff = 100.0 * (rate / ((float)zcurses_baud_rate / 10.0));
- X }
- X if (rate > 0.01)
- X {
- X sprintf(s128, "XFERINFO transaction rate ~= %.0f ch/sec (%.0f%%)",
- X rate, (eff > 0.5) ? eff : 0.0);
- X if (log_packets)
- X {
- X write(log_packets, "info: ", 6);
- X write(log_packets, s128, strlen(s128));
- X write(log_packets, "\n", 1);
- X }
- X report_top_line(s128 + 9);
- X#if defined(WHT)
- X ecu_log_event(getppid(), s128);
- X#endif
- X }
- X if (dumbtty)
- X dumbtty_newline();
- X else
- X {
- X report_file_byte_io(0L);
- X report_rx_tx_count();
- X wmove(win, WIN_LINES - 1, WIN_COLS - 1);
- X wrefresh(win);
- X endwin();
- X fprintf(stderr, "\r\n\r\n\r\n");
- X fflush(stderr);
- X }
- X report_init_complete = 0;
- X }
- X
- X} /* end of report_uninit */
- X
- X/*+-------------------------------------------------------------------------
- X determine_output_mode()
- X--------------------------------------------------------------------------*/
- Xint
- Xdetermine_output_mode()
- X{
- X#if defined(CONS_GET)
- X int monitor_type;
- X
- X#endif
- X struct stat dn;
- X struct stat tty_stat;
- X
- X#ifdef NO_PTY_CURSES
- X struct stat pty_stat;
- X
- X#endif
- X
- X if (force_dumbtty)
- X {
- X dumbtty = 1;
- X report_verbosity = 1;
- X report_init_complete = 1;
- X return (1);
- X }
- X
- X#ifndef M_SYSV /* these are always set thus for non-SCO */
- X vanilla_ruling();
- X#endif
- X
- X#if defined(CONS_GET)
- X if (ioctl(0, CONS_GET, &monitor_type) < 0) /* not multiscreen */
- X {
- X#endif
- X
- X#ifdef M_SYSV /* SCO non AT console */
- X vanilla_ruling();
- X#endif
- X#ifdef LINUX
- X sTL = ACS_ULCORNER;
- X sTR = ACS_URCORNER;
- X sBL = ACS_LLCORNER;
- X sBR = ACS_LRCORNER;
- X sLT = ACS_LTEE;
- X sRT = ACS_RTEE;
- X sVR = ACS_VLINE;
- X sHR = ACS_HLINE;
- X#endif
- X
- X /*
- X * if tty (console) is not character special, only report basic
- X * progress
- X */
- X memset((char *)&dn, 0, sizeof(dn));
- X stat("/dev/null", &dn);
- X if (fstat(0, &tty_stat) ||
- X ((tty_stat.st_mode & S_IFMT) != S_IFCHR) ||
- X (dn.st_rdev == tty_stat.st_rdev))
- X {
- X#ifndef LINUX
- X dumbtty = 1;
- X#endif
- X report_verbosity = 0;
- X report_init_complete = 1;
- X return (1);
- X }
- X
- X#ifdef NO_PTY_CURSES
- X
- X /*
- X * if pty (must be xterm), send clear screen and no curses
- X */
- X if (!stat("/dev/ttyp0", &pty_stat) &&
- X (pty_stat.st_rdev & 0xFF00) == (tty_stat.st_rdev & 0xFF00))
- X {
- X static char ff[] = "\033[H\0332J\r\n";
- X
- X write(2, ff, strlen(ff));
- X dumbtty = 1;
- X report_verbosity = 1;
- X report_init_complete = 1;
- X return (1);
- X }
- X#endif
- X
- X /*
- X * if non-multiscreen tty baud rate not at least that of the
- X * attached line, use no curses, but do be a bit more verbose than
- X * if tty not char special
- X */
- X#ifdef TTY_VS_LINE_SPEED_NO_CURSES
- X test_tty_and_line_baud();
- X#endif
- X
- X#if defined(CONS_GET)
- X }
- X#endif
- X
- X return (dumbtty);
- X
- X} /* end of determine_output_mode */
- X
- X/*+-------------------------------------------------------------------------
- X report_init(title)
- X "top line": row 1 col 11 len 21
- X file quan: row 2 col 15 len 3
- X row 2 col 12 len 7 clear "of ###"
- X start time: row 8 col 21 len 8
- X "window:" row 8 col 50 len 7
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_init(title)
- Xchar *title;
- X{
- X register int itmp;
- X
- X if (report_init_complete)
- X return;
- X
- X start_seconds = time((long *)0);
- X current_seconds = start_seconds;
- X
- X if (dumbtty)
- X return;
- X
- X#if defined(FASI)
- X (void)ioctl(iofd, FASIC_SIP, &fip_start);
- X#endif /* FASI */
- X
- X if (!initscr())
- X exit(254);
- X if (!stdscr)
- X exit(254);
- X crmode();
- X noecho();
- X nonl();
- X clear();
- X report_init_complete = 1;
- X win = newwin(WIN_LINES, WIN_COLS, WIN_TOPY, WIN_LEFTX);
- X box(win, sVR, sHR);
- X#if !defined(SVR4) && !defined(LINUX)
- X wmove(win, 0, 0);
- X waddch(win, sTL);
- X wmove(win, win->_maxy - 1, 0);
- X waddch(win, sBL);
- X wmove(win, win->_maxy - 1, win->_maxx - 1);
- X waddch(win, sBR);
- X wmove(win, 0, win->_maxx - 1);
- X waddch(win, sTR);
- X#endif
- X wmove(win, 0, 2);
- X wstandout(win);
- X waddch(win, '[');
- X waddch(win, ' ');
- X strcpy(s128, title);
- X waddstr(win, s128);
- X waddch(win, ' ');
- X waddch(win, ']');
- X wstandend(win);
- X#ifdef SVR4
- X whline(win, (unsigned long)(sHR & 0x00ff), 2);
- X wmove(win, 0, 8 + strlen(title));
- X#else
- X#ifdef LINUX
- X whline(win, sHR, 2);
- X wmove(win, 0, 8 + strlen(title));
- X#else
- X waddch(win, sHR);
- X waddch(win, sHR);
- X#endif
- X#endif
- X waddch(win, ' ');
- X itmp = WIN_COLS - 2 - 7 - strlen(title);
- X curr_dir[itmp] = 0;
- X waddstr(win, curr_dir);
- X waddch(win, ' ');
- X if (bottom_label)
- X {
- X strncpy(s128, bottom_label, WIN_COLS - 6);
- X s128[WIN_COLS - 6] = 0;
- X wmove(win, WIN_LINES - 1, 2);
- X waddch(win, ' ');
- X waddstr(win, s128);
- X waddch(win, ' ');
- X }
- X
- X itmp = 0;
- X while (1)
- X {
- X if (win_template[itmp] == (char *)0)
- X break;
- X wmove(win, itmp + 1, 1);
- X waddstr(win, win_template[itmp++]);
- X }
- X if (ecusz_flag)
- X {
- X clear_area(win, 2, 15, 3);
- X sprintf(s128, "%-3d", npats);
- X waddstr(win, s128);
- X#if defined(FORK_DEBUG)
- X sprintf(s128, "DEBUG ecusz pid %d", getpid());
- X#endif
- X }
- X else
- X /* ecurz */
- X {
- X clear_area(win, 2, 11, 8); /* clear "of ###" */
- X waddstr(win, ":");
- X#if defined(FORK_DEBUG)
- X sprintf(s128, "DEBUG ecurz pid %d", getpid());
- X#endif
- X }
- X
- X#if defined(FORK_DEBUG)
- X ecu_log_event(getppid(), s128);
- X#endif
- X
- X clear_area(win, 1, 11, 21);
- X report_error_count();
- X clear_area(win, 8, 21, 8); /* starting time */
- X waddstr(win, get_tod(1, (char *)0));
- X
- X if (show_window)
- X {
- X wmove(win, 8, 50);
- X waddstr(win, "window:");
- X wmove(win, 9, 50);
- X waddstr(win, "+0");
- X }
- X
- X wrefresh(win);
- X
- X} /* end of report_init */
- X
- X/*+-------------------------------------------------------------------------
- X report_rx_ind(status)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_rx_ind(status)
- Xint status;
- X{
- X char *cptr;
- X
- X if (dumbtty)
- X {
- X if (report_verbosity && status)
- X {
- X printf("R");
- X if (++dumbtty_pos > 75)
- X {
- X dumbtty_newline();
- X current_seconds = time((long *)0);
- X elapsed_seconds = current_seconds - this_file_start_seconds;
- X cptr = get_elapsed_time(elapsed_seconds);
- X dumbtty_pos = printf("%s elapsed ", cptr +
- X ((elapsed_seconds < 3600L) ? 3 : 0));
- X }
- X fflush(stdout);
- X }
- X return;
- X }
- X wmove(win, 1, 54);
- X waddch(win, (status) ? 'R' : ' ');
- X wmove(win, 1, 54);
- X wrefresh(win);
- X} /* end of report_rx_ind */
- X
- X/*+-------------------------------------------------------------------------
- X report_tx_ind(status)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_tx_ind(status)
- Xint status;
- X{
- X char *cptr;
- X
- X if (dumbtty)
- X {
- X if (report_verbosity && status)
- X {
- X printf("T");
- X if (++dumbtty_pos > 75)
- X {
- X dumbtty_newline();
- X dumbtty_newline();
- X current_seconds = time((long *)0);
- X elapsed_seconds = current_seconds - this_file_start_seconds;
- X cptr = get_elapsed_time(elapsed_seconds);
- X dumbtty_pos = printf("%s elapsed ", cptr +
- X ((elapsed_seconds < 3600L) ? 3 : 0));
- X }
- X fflush(stdout);
- X }
- X return;
- X }
- X wmove(win, 1, 56);
- X waddch(win, (status) ? 'T' : ' ');
- X wmove(win, 1, 56);
- X wrefresh(win);
- X} /* end of report_tx_ind */
- X
- X/*+-------------------------------------------------------------------------
- X report_window() - if enable, show open widow size
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_window()
- X{
- X if (show_window && !dumbtty)
- X {
- X long ltmp;
- X
- X wmove(win, 9, 50);
- X if ((ltmp = (Txpos - Rxpos)) > 999999L)
- X waddstr(win, ">+999999");
- X else if (ltmp < -999999L)
- X ;
- X else
- X {
- X sprintf(s128, "%+-8ld", ltmp);
- X waddstr(win, s128);
- X if (log_packets)
- X {
- X write(log_packets, "window: ", 8);
- X write(log_packets, s128, strlen(s128));
- X write(log_packets, "\n", 1);
- X }
- X }
- X }
- X} /* end of report_window */
- X
- X/*+-------------------------------------------------------------------------
- X report_rx_tx_count()
- X
- X This function may be counted upon to perform wrefresh(win)
- X
- X rx char count: row 6 col 16 len 8 unsigned long
- X tx char count: row 6 col 29 len 8 unsigned long
- X session elapsed time: row 9 col 21 len 8
- X this file elapsed time: row 9 col 41 len 8
- X current tod: row 9 col 3 len 8
- X window: row 9 col 50 len 8
- X
- XIf FASI,
- X FE: row 14 col 6 len 4
- X OE: row 14 col 13 len 4
- X rcvd count: row 14 col 22 len 8 unsigned long
- X xmtd count: row 14 col 36 len 8 unsigned long
- X RTS status: row 14 col 48 len 1
- X CTS status: row 14 col 55 len 1
- X xmtr CTS count: row 15 col 18 len 4
- X xmtr XOFF count: row 15 col 28 len 4
- X rcvr CTS count: row 15 col 42 len 4
- X rcvr XOFF count: row 15 col 52 len 4
- X xmtr queue depth row 16 col 16 len 5
- X xmtr queue size row 16 col 25 len 5 (one time)
- X rcvr queue depth row 16 col 37 len 5
- X rcvr queue size row 16 col 46 len 5 (one time)
- X
- XIf sun, && !defined (SVR4)
- X output queue depth row 14 col 23 len 6
- X RTS status row 14 col 35 len 1
- X CTS status row 14 col 42 len 1
- X input queue depth row 15 col 23 len 6
- X input queue avail row 15 col 49 len 6
- X--------------------------------------------------------------------------*/
- Xreport_rx_tx_count()
- X{
- X extern unsigned long rx_char_count;
- X extern unsigned long tx_char_count;
- X
- X#if defined(FASI)
- X unsigned long ltmp;
- X struct fas_info now;
- X
- X#endif /* FASI */
- X#if defined(sun) && !defined (SVR4)
- X uint output_queue;
- X uint input_avail;
- X uint input_size;
- X uint modem_lines;
- X
- X#endif
- X
- X register char *cptr;
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X sprintf(s128, "%-8ld", rx_char_count);
- X wmove(win, 6, 16);
- X waddstr(win, s128);
- X sprintf(s128, "%-8ld", tx_char_count);
- X wmove(win, 6, 29);
- X waddstr(win, s128);
- X
- X /* now time of day */
- X wmove(win, 9, 3);
- X cptr = get_tod(1, (char *)0);
- X waddstr(win, cptr);
- X current_seconds = time((long *)0);
- X elapsed_seconds = current_seconds - start_seconds;
- X cptr = get_elapsed_time(elapsed_seconds);
- X wmove(win, 9, 21);
- X waddstr(win, cptr);
- X if (this_file_start_seconds)
- X elapsed_seconds = current_seconds - this_file_start_seconds;
- X else
- X elapsed_seconds = 0;
- X cptr = get_elapsed_time(elapsed_seconds);
- X wmove(win, 9, 41);
- X waddstr(win, cptr);
- X
- X#if defined(FASI)
- X if (!ioctl(iofd, FASIC_SIP, &now))
- X {
- X static int statics = 0; /* one time display flag */
- X if ((ltmp = now.framing_errors - fip_start.framing_errors) > 999L)
- X ltmp = 999L;
- X sprintf(s128, "%-3lu", ltmp);
- X wmove(win, 14, 6);
- X waddstr(win, s128);
- X
- X if ((ltmp = now.overrun_errors - fip_start.overrun_errors) > 999L)
- X ltmp = 999L;
- X sprintf(s128, "%-3lu", ltmp);
- X wmove(win, 14, 13);
- X waddstr(win, s128);
- X
- X ltmp = now.characters_received - fip_start.characters_received;
- X sprintf(s128, "%-8lu", ltmp);
- X wmove(win, 14, 22);
- X waddstr(win, s128);
- X
- X ltmp = now.characters_transmitted - fip_start.characters_transmitted;
- X sprintf(s128, "%-8lu", ltmp);
- X wmove(win, 14, 36);
- X waddstr(win, s128);
- X
- X wmove(win, 14, 49);
- X waddch(win, (now.mcr & MC_SET_RTS) ? 'T' : 'F');
- X
- X wmove(win, 14, 55);
- X waddch(win, (now.msr & MS_CTS_PRESENT) ? 'T' : 'F');
- X
- X ltmp = now.xmtr_hw_flow_count - fip_start.xmtr_hw_flow_count;
- X if (ltmp > 9999L)
- X ltmp = 9999L;
- X sprintf(s128, "%-4lu", ltmp);
- X wmove(win, 15, 17);
- X waddstr(win, s128);
- X
- X ltmp = now.xmtr_sw_flow_count - fip_start.xmtr_sw_flow_count;
- X if (ltmp > 9999L)
- X ltmp = 9999L;
- X sprintf(s128, "%-4lu", ltmp);
- X wmove(win, 15, 27);
- X waddstr(win, s128);
- X
- X ltmp = now.rcvr_hw_flow_count - fip_start.rcvr_hw_flow_count;
- X if (ltmp > 9999L)
- X ltmp = 9999L;
- X sprintf(s128, "%-4lu", ltmp);
- X wmove(win, 15, 41);
- X waddstr(win, s128);
- X
- X ltmp = now.rcvr_sw_flow_count - fip_start.rcvr_sw_flow_count;
- X if (ltmp > 9999L)
- X ltmp = 9999L;
- X sprintf(s128, "%-4lu", ltmp);
- X wmove(win, 15, 51);
- X waddstr(win, s128);
- X
- X if (now.xmit_ring_cnt > 99999)
- X now.xmit_ring_cnt = 99999;
- X sprintf(s128, "%-5u", now.xmit_ring_cnt);
- X wmove(win, 16, 16);
- X waddstr(win, s128);
- X
- X if (now.recv_ring_cnt > 99999)
- X now.recv_ring_cnt = 99999;
- X sprintf(s128, "%-5u", now.recv_ring_cnt);
- X wmove(win, 16, 37);
- X waddstr(win, s128);
- X
- X if (!statics)
- X {
- X statics = 1;
- X ltmp = XMIT_BUFF_SIZE;
- X if (ltmp > 99999)
- X ltmp = 99999;
- X sprintf(s128, "%-5lu", ltmp);
- X wmove(win, 16, 25);
- X waddstr(win, s128);
- X
- X ltmp = RECV_BUFF_SIZE;
- X if (ltmp > 99999)
- X ltmp = 99999;
- X sprintf(s128, "%-5lu", ltmp);
- X wmove(win, 16, 46);
- X waddstr(win, s128);
- X }
- X }
- X#endif /* FASI */
- X
- X#if defined(sun) && !defined (SVR4)
- X output_queue = 0;
- X ioctl(iofd, TIOCOUTQ, (int *)&output_queue);
- X if (output_queue > 999999)
- X output_queue = 999999;
- X sprintf(s128, "%6u", output_queue);
- X wmove(win, 14, 23);
- X waddstr(win, s128);
- X
- X modem_lines = 0;
- X ioctl(iofd, TIOCMGET, (int *)&modem_lines);
- X wmove(win, 14, 35);
- X waddch(win, (modem_lines & TIOCM_RTS) ? 'T' : 'F');
- X wmove(win, 14, 42);
- X waddch(win, (modem_lines & TIOCM_CTS) ? 'T' : 'F');
- X
- X input_size = 0;
- X input_avail = 0;
- X ioctl(iofd, TIOCISPACE, (int *)&input_avail);
- X ioctl(iofd, TIOCISIZE, (int *)&input_size);
- X if (input_size > 999999)
- X input_size = 999999;
- X if (input_avail > 999999)
- X input_avail = 999999;
- X sprintf(s128, "%6u", input_size - input_avail);
- X wmove(win, 15, 23);
- X waddstr(win, s128);
- X sprintf(s128, "%6u", input_avail);
- X wmove(win, 15, 49);
- X waddstr(win, s128);
- X#endif
- X
- X report_window();
- X
- X wrefresh(win); /* calling procs expect this to occur always */
- X
- X} /* end of report_rx_tx_count */
- X
- X/*+-------------------------------------------------------------------------
- X report_mode(comm_mode)
- X
- X comm mode row 7 col 52 length 6
- X 3: save old tty stat, set raw mode with flow control
- X 2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
- X 1: save old tty stat, set raw mode
- X 0: restore original tty mode
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_mode(comm_mode)
- Xint comm_mode;
- X{
- X char *cptr;
- X char tmp[8];
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X clear_area(win, 7, 52, 6);
- X switch (comm_mode)
- X {
- X case 0:
- X cptr = "NORMAL";
- X break;
- X case 1:
- X cptr = "RAW";
- X break;
- X case 2:
- X cptr = "RAW-g";
- X break;
- X case 3:
- X cptr = "RAW-f";
- X break;
- X default:
- X sprintf(tmp, "%5u", comm_mode);
- X cptr = tmp;
- X }
- X waddstr(win, cptr);
- X wrefresh(win);
- X if (log_packets)
- X {
- X write(log_packets, "comm_mode: ", 6);
- X write(log_packets, cptr, strlen(cptr));
- X write(log_packets, "\n", 1);
- X }
- X
- X} /* end of report_mode */
- X
- X/*+-------------------------------------------------------------------------
- X report_rxblklen(blklen)
- Xrow 7 col 35 5 chars
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_rxblklen(blklen)
- Xint blklen;
- X{
- X char tmp[10];
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X sprintf(tmp, "%-5u", blklen);
- X clear_area(win, 7, 35, 5);
- X waddstr(win, tmp);
- X wrefresh(win);
- X} /* end of report_rxblklen */
- X
- X/*+-------------------------------------------------------------------------
- X report_txblklen(blklen)
- Xrow 7 col 35 5 chars
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_txblklen(blklen)
- Xint blklen;
- X{
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X report_rxblklen(blklen);
- X} /* end of report_txblklen */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_xfer_rate(text,count,final)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_file_xfer_rate(text, count, final)
- Xchar *text;
- Xlong count;
- Xint final;
- X{
- X float rate = 0.0;
- X float efficiency = 0.0;
- X static long last_report = 0L;
- X
- X current_seconds = time((long *)0);
- X
- X if (!final && (current_seconds < (last_report + 5L)))
- X return;
- X last_report = current_seconds;
- X
- X elapsed_seconds = current_seconds - this_file_start_seconds;
- X
- X if (count && (elapsed_seconds > 0) && zcurses_baud_rate)
- X {
- X rate = (float)count / (float)elapsed_seconds;
- X efficiency = 100.0 * (rate / ((float)zcurses_baud_rate / 10.0));
- X }
- X
- X if (efficiency > 120.0) /* interim hack for ecusz -r */
- X return;
- X
- X if (rate > 0.01)
- X {
- X if (efficiency < 0.5)
- X sprintf(s128, "XFERINFO %s rate ~= %.0f ch/sec", text, rate);
- X else
- X {
- X sprintf(s128, "XFERINFO %s rate ~= %.0f ch/sec (%.0lf%%)",
- X text, rate, efficiency);
- X }
- X if (!dumbtty)
- X report_top_line(s128 + 9);
- X#if defined(WHT)
- X if (final)
- X ecu_log_event(getppid(), s128);
- X#endif
- X }
- X
- X} /* end of report_file_xfer_rate */
- X
- X/*+-------------------------------------------------------------------------
- X report_transfer_progress(filepos,initfpos)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_transfer_progress(filepos, initfpos)
- Xlong filepos;
- Xlong initfpos;
- X{
- X char refr;
- X
- X if (dumbtty)
- X return;
- X
- X if (rdchk(0))
- X {
- X read(0, &refr, 1);
- X if (refr == 0x0C || refr == 0x012) /* ^L or ^R */
- X {
- X touchwin(stdscr);
- X wrefresh(stdscr);
- X touchwin(win);
- X wrefresh(win);
- X }
- X }
- X
- X if ((filepos > 99999999L) || (filepos < 0L))
- X return;
- X
- X sprintf(s128, "%-8lu", filepos);
- X wmove(win, 3, 19);
- X waddstr(win, s128);
- X report_file_xfer_rate("data", filepos - initfpos, 0);
- X report_rx_tx_count(); /* which will do a refresh */
- X
- X} /* end of report_transfer_progress */
- X
- X/*+-------------------------------------------------------------------------
- X report_rxpos(pos) - report received file progress
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_rxpos(pos)
- Xlong pos;
- X{
- X
- X if (dumbtty)
- X return;
- X report_transfer_progress(pos, initial_filepos);
- X
- X} /* end of report_rxpos */
- X
- X/*+-------------------------------------------------------------------------
- X report_txpos(pos) - report transmitted file progress
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_txpos(pos)
- Xlong pos;
- X{
- X
- X if (dumbtty)
- X return;
- X report_transfer_progress(pos, initial_filepos);
- X
- X} /* end of report_txpos */
- X
- X/*+-------------------------------------------------------------------------
- X report_error_count()
- X
- X this file: row 10 col 22 len 3
- X total: row 10 col 33 len 4
- X skipped: row 10 col 53 len 3
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_error_count()
- X{
- X char tmp[16];
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X wmove(win, 10, 22);
- X sprintf(tmp, "%-3d", this_file_errors);
- X if (this_file_errors)
- X wstandout(win);
- X waddstr(win, tmp);
- X if (this_file_errors)
- X wstandend(win);
- X
- X wmove(win, 10, 33);
- X sprintf(tmp, "%-4d", total_errors);
- X if (total_errors)
- X wstandout(win);
- X waddstr(win, tmp);
- X if (total_errors)
- X wstandend(win);
- X
- X wmove(win, 10, 53);
- X sprintf(tmp, "%-3d", skip_count);
- X waddstr(win, tmp);
- X wrefresh(win);
- X
- X} /* end of report_error_count */
- X
- X/*+-------------------------------------------------------------------------
- X report_last_txhdr(rptstr,error_flag)
- X 5,7,22
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_last_txhdr(rptstr, error_flag)
- Xregister char *rptstr;
- Xint error_flag;
- X{
- X char s24[24];
- X
- X if (log_packets)
- X {
- X write(log_packets, "tx: ", 6);
- X write(log_packets, rptstr, strlen(rptstr));
- X write(log_packets, "\n", 1);
- X }
- X
- X if (dumbtty)
- X {
- X if (error_flag)
- X {
- X dumbtty_newline();
- X dumbtty_pos = printf("%s ", rptstr);
- X ++this_file_errors;
- X ++total_errors;
- X }
- X return;
- X }
- X
- X if (strlen(rptstr) > 22)
- X {
- X strncpy(s24, rptstr, 22);
- X s24[23] = 0;
- X rptstr = s24;
- X }
- X clear_area(win, 5, 7, 22);
- X waddstr(win, rptstr);
- X
- X if (error_flag)
- X {
- X ++this_file_errors;
- X ++total_errors;
- X report_error_count();
- X }
- X#if 0
- X else
- X wrefresh(win);
- X#endif
- X
- X} /* end of report_last_txhdr */
- X
- X/*+-------------------------------------------------------------------------
- X report_last_rxhdr(rptstr,error_flag)
- X 5,35,22
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_last_rxhdr(rptstr, error_flag)
- Xregister char *rptstr;
- Xint error_flag;
- X{
- X char s24[24];
- X extern int log_packets;
- X
- X if (log_packets)
- X {
- X write(log_packets, "rx: ", 6);
- X write(log_packets, rptstr, strlen(rptstr));
- X write(log_packets, "\n", 1);
- X }
- X
- X if (dumbtty)
- X {
- X if (error_flag)
- X {
- X dumbtty_newline();
- X dumbtty_pos = printf("%s ", rptstr);
- X ++this_file_errors;
- X ++total_errors;
- X }
- X return;
- X }
- X
- X if (strlen(rptstr) > 22)
- X {
- X strncpy(s24, rptstr, 22);
- X s24[23] = 0;
- X rptstr = s24;
- X }
- X clear_area(win, 5, 35, 22);
- X waddstr(win, rptstr);
- X
- X report_window();
- X if (error_flag)
- X {
- X ++this_file_errors;
- X ++total_errors;
- X report_error_count();
- X }
- X#if 0
- X else
- X wrefresh(win);
- X#endif
- X
- X} /* end of report_last_rxhdr */
- X
- X/*+-------------------------------------------------------------------------
- X report_str(rptstr,error_flag) row 11/12 col 3 len 55
- X
- X error_flag == 0 for status/progress message
- X == 1 for bump error count, unless rptstr is null
- X in which case, merely clear error string area
- X == 2 write string on bottom line (not an error)
- X == 3 write string on transaction line (not an error)
- X == -1 use error line but do not bump error count
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_str(rptstr, error_flag)
- Xregister char *rptstr;
- Xint error_flag;
- X{
- X char s60[60];
- X extern int log_packets;
- X
- X if (log_packets)
- X {
- X sprintf(s60, "rpt %d:", error_flag);
- X write(log_packets, s60, strlen(s60));
- X write(log_packets, rptstr, strlen(rptstr));
- X write(log_packets, "\n", 1);
- X }
- X
- X if (dumbtty)
- X {
- X if (!strlen(rptstr))
- X return;
- X switch (error_flag)
- X {
- X case 0:
- X break;
- X case 1:
- X this_file_errors++;
- X total_errors++;
- X case -1:
- X case 2:
- X case 3:
- X dumbtty_newline();
- X dumbtty_pos = printf("%s ", rptstr);
- X fflush(stdout);
- X }
- X return;
- X }
- X
- X if (strlen(rptstr) > 55)
- X {
- X strncpy(s60, rptstr, 55);
- X s60[55] = 0;
- X rptstr = s60;
- X }
- X
- X switch (error_flag)
- X {
- X case 0:
- X clear_area(win, 12, 3, 55);
- X break;
- X case 1:
- X this_file_errors++;
- X total_errors++;
- X report_error_count();
- X case -1:
- X clear_area(win, 11, 3, 55);
- X break;
- X case 2:
- X clear_area(win, 13, 3, 55);
- X break;
- X case 3:
- X clear_area(win, 4, 3, 55);
- X break;
- X }
- X
- X waddstr(win, rptstr);
- X wrefresh(win);
- X
- X} /* end of report_str */
- X
- X/*+-------------------------------------------------------------------------
- X report_transaction()
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_transaction(str)
- Xchar *str;
- X{
- X report_str(str, 3);
- X} /* end of report_transaction */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_open_tod() -- time of start of this file
- X
- X this file open time: row 8 col 41 length 8
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_file_open_tod()
- X{
- X if (dumbtty)
- X return;
- X clear_area(win, 8, 41, 8);
- X waddstr(win, get_tod(1, (char *)0));
- X wrefresh(win);
- X} /* end of report_file_open_tod */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_open_mode(file_mode)
- X mode map: row 4 col 46 len 10
- X--------------------------------------------------------------------------*/
- Xreport_file_open_mode(file_mode)
- Xunsigned short file_mode;
- X{
- X if (dumbtty)
- X return;
- X clear_area(win, 3, 46, 10);
- X waddstr(win, mode_map(file_mode, (char *)0));
- X wrefresh(win);
- X} /* end of report_file_open_mode */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_open_length(long_length)
- X length: row 3 col 36 len 8
- X--------------------------------------------------------------------------*/
- Xreport_file_open_length(length)
- Xlong length;
- X{
- X if (dumbtty)
- X return;
- X clear_area(win, 3, 36, 8);
- X if (length <= 0)
- X waddstr(win, "unknown");
- X else
- X {
- X sprintf(s128, "%-8lu", length);
- X waddstr(win, s128);
- X }
- X wrefresh(win);
- X} /* end of report_file_open_length */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_send_open(filename,filestat)
- X
- X filename: row 2 col 20 len 38
- X number: row 2 col 8 len 3
- X length: row 3 col 36 len 8
- X mode: row 3 col 46 len 10
- X time of start of this file: row 4 col 47 length 8 hh:mm:ss
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_file_send_open(filename, filestat)
- Xchar *filename;
- Xstruct stat *filestat;
- X{
- X char s50[50];
- X register char *cptr = filename;
- X
- X if (log_packets)
- X {
- X write(log_packets, "file: ", 6);
- X write(log_packets, filename, strlen(filename));
- X write(log_packets, "\n", 1);
- X }
- X
- X this_file_start_seconds = time((long *)0);
- X this_file_xfer_count = 0;
- X
- X if (dumbtty)
- X {
- X dumbtty_newline();
- X dumbtty_pos = printf("Sending '%s' ", filename);
- X fflush(stdout);
- X return;
- X }
- X
- X /* number */
- X clear_area(win, 2, 8, 3);
- X sprintf(s50, "%-3d", Filcnt);
- X waddstr(win, s50);
- X
- X /* filename */
- X if (strlen(filename) > 38)
- X {
- X strncpy(s50, filename, 38);
- X s50[39] = 0;
- X cptr = s50;
- X }
- X clear_area(win, 2, 20, 38);
- X waddstr(win, cptr);
- X
- X /* length */
- X report_file_open_length(filestat->st_size);
- X
- X /* mode */
- X report_file_open_mode(filestat->st_mode);
- X
- X /* time of start of this file */
- X report_file_open_tod();
- X
- X this_file_errors = 0;
- X report_error_count();
- X} /* end of report_file_send_open */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_rcv_started(filename,length,last_mod_time,file_mode)
- X
- X filenumber: row 2 col 8 len 3
- X row 2 col 12 len 7 clear "of ###"
- X filename: row 2 col 20 len 38
- X--------------------------------------------------------------------------*/
- Xreport_file_rcv_started(filename, length, last_mod_time, file_mode)
- Xchar *filename;
- Xlong length; /* if < 0, "UNKNOWN" */
- Xlong last_mod_time; /* not currently displayed */
- Xunsigned short file_mode; /* UNIX file modifier or zero */
- X{
- X register char *cptr;
- X char s50[50];
- X
- X if (log_packets)
- X {
- X write(log_packets, "file: ", 6);
- X write(log_packets, filename, strlen(filename));
- X write(log_packets, "\n", 1);
- X }
- X
- X this_file_start_seconds = time((long *)0);
- X this_file_xfer_count = 0;
- X
- X if (dumbtty)
- X {
- X dumbtty_newline();
- X dumbtty_pos = printf("Receiving '%s' ", filename) - 2;
- X fflush(stdout);
- X return;
- X }
- X
- X /* filename */
- X if (strlen(filename) > 38)
- X {
- X strncpy(s50, filename, 38);
- X s50[39] = 0;
- X cptr = s50;
- X }
- X else
- X cptr = filename;
- X
- X clear_area(win, 2, 20, 38);
- X waddstr(win, cptr);
- X
- X /* file number */
- X clear_area(win, 2, 8, 3);
- X Filcnt++;
- X sprintf(s50, "%-3d", Filcnt); /* rz uses as file number 1-n */
- X waddstr(win, s50);
- X
- X/* if remote sender provides a file count, display it */
- X if (npats)
- X {
- X clear_area(win, 2, 12, 7); /* clear "of ###" */
- X sprintf(s50, "of %3d:", npats);
- X waddstr(win, s50);
- X }
- X
- X /* length */
- X report_file_open_length(length);
- X
- X /* mode */
- X report_file_open_mode(file_mode);
- X
- X /* time of start of this file */
- X report_file_open_tod();
- X
- X this_file_errors = 0;
- X report_error_count();
- X} /* end of report_file_rcv_started */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_close(skipped)
- X--------------------------------------------------------------------------*/
- Xvoid
- Xreport_file_close(skipped)
- Xint skipped;
- X{
- X if (dumbtty)
- X {
- X dumbtty_newline();
- X dumbtty_pos +=
- X printf("Transfer time was %s", get_elapsed_time(elapsed_seconds));
- X dumbtty_newline();
- X if (s128[0])
- X {
- X dumbtty_pos += strlen(s128 + 9);
- X fputs(s128 + 9, stdout);
- X dumbtty_newline();
- X }
- X if (this_file_errors)
- X {
- X dumbtty_pos +=
- X printf("Errors for this file were %d", this_file_errors);
- X dumbtty_newline();
- X }
- X return;
- X }
- X
- X if (show_window)
- X {
- X clear_area(win, 9, 50, 8);
- X waddstr(win, "+0");
- X Txpos = 0;
- X Rxpos = 0;
- X }
- X
- X report_str("End of file", 0);
- X if (!skipped)
- X {
- X report_file_xfer_rate("last file",
- X this_file_xfer_count - initial_filepos, 1);
- X }
- X wrefresh(win);
- X this_file_start_seconds = 0;
- X
- X} /* end of report_file_close */
- X
- X/*+-------------------------------------------------------------------------
- X report_comm_baud_rate(baud_rate)
- X
- X baud rate: row 7 col 14 length 5
- X--------------------------------------------------------------------------*/
- Xreport_comm_baud_rate(baud_rate)
- Xunsigned int baud_rate;
- X{
- X char tstr8[8];
- X
- X zcurses_baud_rate = baud_rate;
- X
- X if (dumbtty)
- X {
- X return;
- X }
- X
- X clear_area(win, 7, 14, 5);
- X if (baud_rate == 0)
- X waddstr(win, "?");
- X else
- X {
- X sprintf(tstr8, "%-5u", baud_rate);
- X waddstr(win, tstr8);
- X }
- X wrefresh(win);
- X
- X} /* end of report_comm_baud_rate */
- X
- X/*+-------------------------------------------------------------------------
- X report_file_byte_io(count)
- X--------------------------------------------------------------------------*/
- Xreport_file_byte_io(count)
- Xlong count;
- X{
- X
- X this_file_xfer_count = count;
- X total_data_bytes_xfered += count;
- X
- X if (dumbtty)
- X {
- X if (count)
- X {
- X dumbtty_newline();
- X printf("Transferred %ld bytes for this file\n", count);
- X dumbtty_newline();
- X }
- X return;
- X }
- X
- X if (total_data_bytes_xfered)
- X {
- X sprintf(s128, "Total file bytes transferred: %ld",
- X total_data_bytes_xfered);
- X report_str(s128, -1);
- X }
- X
- X} /* end of report_file_byte_io */
- X
- X/* end of zcurses.c */
- X/* vi: set tabstop=4 shiftwidth=4: */
- END_OF_FILE
- if test 44210 -ne `wc -c <'ecu330/z/zcurses.c'`; then
- echo shar: \"'ecu330/z/zcurses.c'\" unpacked with wrong size!
- fi
- # end of 'ecu330/z/zcurses.c'
- fi
- echo shar: End of archive 6 \(of 37\).
- cp /dev/null ark6isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 37 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-