home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / ecu / part06 < prev    next >
Encoding:
Internet Message Format  |  1994-05-23  |  64.3 KB

  1. From: wht@n4hgf.atl.ga.us (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v42i104:  ecu - ECU Asynchronous Communications v3.30, Part06/37
  4. Date: 23 May 1994 14:22:16 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2rqvp8$dk2@sparky.sterling.com>
  9. X-Md4-Signature: fa1f5007485453d10f51bd1737c2e462
  10.  
  11. Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
  12. Posting-number: Volume 42, Issue 104
  13. Archive-name: ecu/part06
  14. Environment: SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2
  15. Supersedes: ecu: Volume 32, Issue 36-75
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  ecu330/ecufkey.c ecu330/z/zcurses.c
  22. # Wrapped by kent@sparky on Mon May 23 13:40:47 1994
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 6 (of 37)."'
  26. if test -f 'ecu330/ecufkey.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'ecu330/ecufkey.c'\"
  28. else
  29.   echo shar: Extracting \"'ecu330/ecufkey.c'\" \(16642 characters\)
  30.   sed "s/^X//" >'ecu330/ecufkey.c' <<'END_OF_FILE'
  31. X/*+-----------------------------------------------------------------
  32. X    ecufkey.c -- function key definition
  33. X    wht@n4hgf.atl.ga.us
  34. X
  35. X  Defined functions:
  36. X    ffso(str)
  37. X    idke_to_xf(ikde)
  38. X    kde_fgets(buf,bufsize,fp)
  39. X    kde_name_to_ikde(keystr)
  40. X    kde_text(ikde)
  41. X    keyset_define_key(bufptr)
  42. X    keyset_display()
  43. X    keyset_idstr(ikde)
  44. X    keyset_init()
  45. X    keyset_read(name)
  46. X    xf_text(xf)
  47. X    xf_to_ikde(xf)
  48. X
  49. X------------------------------------------------------------------*/
  50. X/*+:EDITS:*/
  51. X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  52. X/*:01-30-1993-12:17-wht@n4hgf-remove gcc < 1.40 bug workaround */
  53. X/*:01-11-1993-15:42-wht@n4hgf-declare skip_ld_break */
  54. X/*:01-01-1993-12:52-wht@n4hgf-add procedure binding for function keys */
  55. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  56. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  57. X/*:04-17-1992-16:29-wht@n4hgf-initialize keyset to SCO "ANSI" send strings */
  58. X/*:09-01-1991-05:16-wht@n4hgf2-allow comments and whitespace after names */
  59. X/*:08-31-1991-13:21-wht@n4hgf2-look for keys file in ECULIBDIR */
  60. X/*:08-16-1991-00:11-wht@n4hgf-keyset_init loads default keyset if found */
  61. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  62. X/*:07-12-1991-13:57-wht@n4hgf-GCC140 fix update */
  63. X/*:05-21-1991-00:45-wht@n4hgf-added -3 error code to keyset_read */
  64. X/*:05-21-1991-00:37-wht@n4hgf-improve fkey load error detection */
  65. X/*:05-16-1991-15:05-wht@n4hgf-gcc binary exploded in keyset_display */
  66. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  67. X
  68. X#include "ecu.h"
  69. X#include "ecukey.h"
  70. X#include "ecufkey.h"
  71. X#include "ecuxkey.h"
  72. X#include "ecufork.h"
  73. X
  74. Xchar *str_token();
  75. Xchar *skip_ld_break();
  76. X
  77. Xextern char kbdintr;         /* current input INTR */
  78. Xextern char curr_dir[CURR_DIRSIZ];    /* current working key defns */
  79. X
  80. XKDE keyset_table[KDE_COUNT];
  81. Xchar keyset_name[256] = "";
  82. X
  83. XKDEMAP kdemap[] =
  84. X{
  85. X    {XFcurup, IKDE_CUU, "CUU", "\033[A"},
  86. X    {XFcurdn, IKDE_CUD, "CUD", "\033[B"},
  87. X    {XFcurrt, IKDE_CUR, "CUR", "\033[C"},
  88. X    {XFcurlf, IKDE_CUL, "CUL", "\033[D"},
  89. X    {XFcur5, IKDE_CU5, "CU5", "\033[E"},
  90. X    {XFend, IKDE_END, "End", "\033[F"},
  91. X    {XFpgdn, IKDE_PGDN, "PgDn", "\033[G"},
  92. X    {XFhome, IKDE_HOME, "Home", "\033[H"},
  93. X    {XFpgup, IKDE_PGUP, "PgUp", "\033[I"},
  94. X    {XFins, IKDE_INS, "Ins", "\033[L"},
  95. X    {XF1, IKDE_F1, "F1", "\033[M"},
  96. X    {XF2, IKDE_F2, "F2", "\033[N"},
  97. X    {XF3, IKDE_F3, "F3", "\033[O"},
  98. X    {XF4, IKDE_F4, "F4", "\033[P"},
  99. X    {XF5, IKDE_F5, "F5", "\033[Q"},
  100. X    {XF6, IKDE_F6, "F6", "\033[R"},
  101. X    {XF7, IKDE_F7, "F7", "\033[S"},
  102. X    {XF8, IKDE_F8, "F8", "\033[T"},
  103. X    {XF9, IKDE_F9, "F9", "\033[U"},
  104. X    {XF10, IKDE_F10, "F10", "\033[V"},
  105. X    {XF11, IKDE_F11, "F11", "\033[W"},
  106. X    {XF12, IKDE_F12, "F12", "\033[X"},
  107. X    {XFbktab, IKDE_BKTAB, "BkTab", "\033[Z"},
  108. X    {255, IKDE_InitStr, "IS", ""},
  109. X    {0, 0, "", ""}
  110. X};
  111. X
  112. X/*+-------------------------------------------------------------------------
  113. X    keyset_init()
  114. X--------------------------------------------------------------------------*/
  115. Xvoid
  116. Xkeyset_init()
  117. X{
  118. X    register itmp;
  119. X    register KDE *tkde;
  120. X    register KDEMAP *kmap;
  121. X
  122. X    for (itmp = 0; itmp < KDE_COUNT; itmp++)
  123. X    {
  124. X        tkde = &keyset_table[itmp];
  125. X        tkde->logical[0] = 0;
  126. X        tkde->ikde = (uchar) itmp;
  127. X    }
  128. X
  129. X    kmap = kdemap;
  130. X    while (kmap->xf)
  131. X    {
  132. X        if (kmap->ikde <= IKDE_lastKey)
  133. X        {
  134. X            tkde = &keyset_table[kmap->ikde];
  135. X            sprintf(tkde->logical, "SCO %s", kmap->name);
  136. X            strcpy(tkde->str, kmap->init);
  137. X            tkde->count = strlen(tkde->str);
  138. X        }
  139. X        kmap++;
  140. X    }
  141. X
  142. X    keyset_name[0] = 0;
  143. X
  144. X    tkde = &keyset_table[IKDE_BKTAB];
  145. X    strcpy(tkde->logical, "redisplay");
  146. X    tkde->count = KACT_REDISPLAY;
  147. X
  148. X    tkde = &keyset_table[IKDE_HOME];
  149. X    strcpy(tkde->logical, "ecu cmd");
  150. X    tkde->count = KACT_COMMAND;
  151. X
  152. X    tkde = &keyset_table[IKDE_INS];
  153. X    strcpy(tkde->logical, "local shell");
  154. X    tkde->count = KACT_LOCAL_SHELL;
  155. X
  156. X    tkde = &keyset_table[IKDE_CU5];
  157. X    strcpy(tkde->logical, "screen dump");
  158. X    tkde->str[0] = 0x7F;     /* this key is intercepted by kbd read
  159. X                              * routine */
  160. X    tkde->count = 0;
  161. X
  162. X}                             /* end of keyset_init */
  163. X
  164. X/*+-------------------------------------------------------------------------
  165. X    kde_fgets(buf,bufsize,fp) - read and evaluate key file line
  166. X
  167. XReturns:
  168. X    KDETYPE_COMMENT     comment or blank line (null, all blank or "#"
  169. X                        as non-blank)
  170. X    KDETYPE_NAME        "name" (non "#\t " in column 1)
  171. X    KDETYPE_ENTRY       "entry" ("\t " in column 1)
  172. X    KDETYPE_EOF         end of file
  173. X--------------------------------------------------------------------------*/
  174. Xint
  175. Xkde_fgets(buf, bufsize, fp)
  176. Xchar *buf;
  177. Xint bufsize;
  178. XFILE *fp;
  179. X{
  180. X    register itmp;
  181. X    register char *cptr;
  182. X
  183. X    if (!fgets(buf, bufsize, fp))
  184. X    {
  185. X        return (KDETYPE_EOF);
  186. X    }
  187. X
  188. X    if (!(itmp = strlen(buf)))
  189. X        return (KDETYPE_COMMENT);
  190. X    if (buf[itmp - 1] == NL)
  191. X    {
  192. X        buf[itmp - 1] = 0;
  193. X        itmp--;
  194. X    }
  195. X    if (!itmp)
  196. X        return (KDETYPE_COMMENT);
  197. X
  198. X    cptr = buf;
  199. X    itmp = (strchr(" \t", *cptr)) ? KDETYPE_ENTRY : KDETYPE_NAME;
  200. X    while (*cptr && ((*cptr == SPACE) || (*cptr == TAB)))
  201. X        cptr++;
  202. X
  203. X    if (!*cptr || (*cptr == '#'))
  204. X        return (KDETYPE_COMMENT);
  205. X
  206. X    return (itmp);
  207. X
  208. X}                             /* end of kde_fgets */
  209. X
  210. X/*+-------------------------------------------------------------------------
  211. X    kde_name_to_ikde(keystr)
  212. X--------------------------------------------------------------------------*/
  213. Xint
  214. Xkde_name_to_ikde(keystr)
  215. Xchar *keystr;
  216. X{
  217. X    KDEMAP *kmap = kdemap;
  218. X
  219. X    while (kmap->xf != 0)
  220. X    {
  221. X        if (!strcmpi(kmap->name, keystr))
  222. X            return ((int)kmap->ikde);
  223. X        kmap++;
  224. X    }
  225. X    return (-1);
  226. X}                             /* end of kde_name_to_ikde */
  227. X
  228. X/*+-------------------------------------------------------------------------
  229. X    keyset_idstr(ikde)
  230. X--------------------------------------------------------------------------*/
  231. Xchar *
  232. Xkeyset_idstr(ikde)
  233. Xint ikde;
  234. X{
  235. X    KDEMAP *kmap = kdemap;
  236. X
  237. X    while (kmap->xf)
  238. X    {
  239. X        if ((int)kmap->ikde == ikde)
  240. X            return (kmap->name);
  241. X        kmap++;
  242. X    }
  243. X    return ((char *)0);
  244. X}                             /* end of keyset_idstr */
  245. X
  246. X/*+-------------------------------------------------------------------------
  247. X    xf_to_ikde(xf)
  248. X--------------------------------------------------------------------------*/
  249. Xint
  250. Xxf_to_ikde(xf)
  251. Xuchar xf;
  252. X{
  253. X    KDEMAP *kmap = kdemap;
  254. X
  255. X    while (kmap->xf)
  256. X    {
  257. X        if (kmap->xf == xf)
  258. X            return ((int)kmap->ikde & 0xFF);
  259. X        kmap++;
  260. X    }
  261. X    return (-1);
  262. X}                             /* end of xf_to_ikde */
  263. X
  264. X/*+-------------------------------------------------------------------------
  265. X    ikde_to_xf(ikde)
  266. X--------------------------------------------------------------------------*/
  267. Xint
  268. Xikde_to_xf(ikde)
  269. Xuchar ikde;
  270. X{
  271. X    KDEMAP *kmap = kdemap;
  272. X
  273. X    while (kmap->xf)
  274. X    {
  275. X        if (kmap->ikde == ikde)
  276. X            return ((int)kmap->xf & 0xFF);
  277. X        kmap++;
  278. X    }
  279. X    return (-1);
  280. X}                             /* end of ikde_to_xf */
  281. X
  282. X/*+-------------------------------------------------------------------------
  283. X    kde_text(ikde) - ikde value to text
  284. X--------------------------------------------------------------------------*/
  285. Xchar *
  286. Xkde_text(ikde)
  287. Xint ikde;
  288. X{
  289. X    KDEMAP *kmap = kdemap;
  290. X
  291. X    while (kmap->xf)
  292. X    {
  293. X        if (kmap->ikde == (char)ikde)
  294. X            return (kmap->name);
  295. X        kmap++;
  296. X    }
  297. X    return ("??");
  298. X}                             /* end of xf_to_ikde */
  299. X
  300. X/*+-------------------------------------------------------------------------
  301. X    xf_text(xf) - XFkey to text
  302. X--------------------------------------------------------------------------*/
  303. Xchar *
  304. Xxf_text(xf)
  305. Xuchar xf;
  306. X{
  307. X    static char sc8[8];
  308. X
  309. X    switch (xf)
  310. X    {
  311. X        case XFcurup:
  312. X            return ("CUU");
  313. X        case XFcurdn:
  314. X            return ("CUD");
  315. X        case XFcurrt:
  316. X            return ("CUR");
  317. X        case XFcurlf:
  318. X            return ("CUL");
  319. X        case XFcur5:
  320. X            return ("CU5");
  321. X        case XFend:
  322. X            return ("End");
  323. X        case XFpgdn:
  324. X            return ("PgDn");
  325. X        case XFhome:
  326. X            return ("Home");
  327. X        case XFpgup:
  328. X            return ("PgUp");
  329. X        case XFins:
  330. X            return ("Ins");
  331. X        case XF1:
  332. X            return ("F1");
  333. X        case XF2:
  334. X            return ("F2");
  335. X        case XF3:
  336. X            return ("F3");
  337. X        case XF4:
  338. X            return ("F4");
  339. X        case XF5:
  340. X            return ("F5");
  341. X        case XF6:
  342. X            return ("F6");
  343. X        case XF7:
  344. X            return ("F7");
  345. X        case XF8:
  346. X            return ("F8");
  347. X        case XF9:
  348. X            return ("F9");
  349. X        case XF10:
  350. X            return ("F10");
  351. X        case XF11:
  352. X            return ("F11");
  353. X        case XF12:
  354. X            return ("F12");
  355. X        case XFbktab:
  356. X            return ("BkTab");
  357. X    }
  358. X
  359. X    if ((xf >= XF_ALTA) && (xf <= XF_ALTZ))
  360. X    {
  361. X        sprintf(sc8, "Alt-%c", 'a' + xf - XF_ALTA);
  362. X        return (sc8);
  363. X    }
  364. X    sprintf(sc8, "XF_%02x\n", xf);
  365. X    return (sc8);
  366. X}                             /* end of xf_text */
  367. X
  368. X/*+-------------------------------------------------------------------------
  369. X    keyset_define_key(bufptr)
  370. X
  371. Xreturn 0 if no error, -1 if error
  372. X--------------------------------------------------------------------------*/
  373. Xint
  374. Xkeyset_define_key(bufptr)
  375. Xchar *bufptr;
  376. X{
  377. X    register itmp;
  378. X    register token_number;
  379. X    register KDE *tkde = (KDE *) 0;
  380. X    int ikde = 0;
  381. X    char token_separator[8];
  382. X    char *token;
  383. X    char *syntax = "syntax error in key definition: %s\n";
  384. X
  385. X    if ((itmp = strlen(bufptr)) && (bufptr[itmp - 1] == NL))
  386. X        bufptr[--itmp] = 0;     /* strip trailing NL */
  387. X    if (!itmp)
  388. X        return (0);
  389. X
  390. X    if ((*bufptr != SPACE) && (*bufptr != TAB))    /* if no leading space */
  391. X        return (0);
  392. X
  393. X    while ((*bufptr == SPACE) || (*bufptr == TAB))    /* strip lding sp/tab */
  394. X        bufptr++;
  395. X
  396. X    token_number = 0;
  397. X    strcpy(token_separator, ":");
  398. X    while (token = str_token(bufptr, token_separator))
  399. X    {
  400. X        bufptr = (char *)0;     /* further calls to str_token need NULL */
  401. X        switch (token_number)
  402. X        {
  403. X            case 0:         /* first field is key identifier */
  404. X                if ((ikde = kde_name_to_ikde(token)) < 0)
  405. X                {
  406. X                    pprintf(syntax, keyset_name);
  407. X                    pprintf("  %s is not a legal key identifier\n", token);
  408. X                    return (-1);
  409. X                }
  410. X                if (ikde == IKDE_HOME)
  411. X                {
  412. X                    pprintf(syntax, keyset_name);
  413. X                    pprintf("  HOME cannot be redefined!\n");
  414. X                    return (-1);
  415. X                }
  416. X                if (ikde == IKDE_CU5)
  417. X                {
  418. X                    pprintf(syntax, keyset_name);
  419. X                    pprintf("  CUR5 cannot be redefined!\n");
  420. X                    return (-1);
  421. X                }
  422. X                if (ikde == IKDE_BKTAB)
  423. X                {
  424. X                    pprintf(syntax, keyset_name);
  425. X                    pprintf("  BkTab cannot be redefined!\n");
  426. X                    return (-1);
  427. X                }
  428. X                tkde = &keyset_table[ikde];
  429. X                tkde->logical[0] = 0;
  430. X                tkde->count = 0;
  431. X                break;
  432. X
  433. X            case 1:         /* second field is logical key name */
  434. X                strncpy(tkde->logical, token, sizeof(tkde->logical));
  435. X                tkde->logical[sizeof(tkde->logical) - 1] = 0;
  436. X                strcpy(token_separator, " \t");    /* whitespace is tok sep
  437. X                                                 * now */
  438. X                break;
  439. X
  440. X            case 2:
  441. X                if (!strcmp(token, "proc"))
  442. X                {
  443. X                    token = skip_ld_break(token + 5);
  444. X                    strncpy(tkde->str, token, sizeof(tkde->str));
  445. X                    tkde->str[sizeof(tkde->str) - 1] = 0;
  446. X                    tkde->count = KACT_PROC;
  447. X                    return (0);    /* <<=========================== */
  448. X                }
  449. X            default:         /* third and subsequent to define key */
  450. X                if (!strlen(token))
  451. X                    continue;
  452. X                if (tkde->count == sizeof(tkde->str))
  453. X                {
  454. X                    pprintf(syntax, keyset_name);
  455. X                    pprintf("  %s: output count too long",
  456. X                        keyset_idstr(ikde));
  457. X                    return (-1);
  458. X                }
  459. X                if ((itmp = ascii_to_hex(token)) < 0)
  460. X                {
  461. X                    pprintf(syntax, keyset_name);
  462. X                    pprintf("  %s: '%s' invalid code\n",
  463. X                        keyset_idstr(ikde), token);
  464. X                    return (0);
  465. X                }
  466. X                tkde->str[tkde->count] = itmp;
  467. X                tkde->count++;
  468. X                break;
  469. X        }                     /* end of switch(token_number) */
  470. X        token_number++;
  471. X    }                         /* end while not end of record */
  472. X
  473. X    return (0);
  474. X
  475. X}                             /* end of keyset_define_key */
  476. X
  477. X/*+-------------------------------------------------------------------------
  478. X    keyset_read(name)
  479. Xreturns 0 on success, -1 if no .ecu/keys, -2 if no 'name', -3 if error
  480. X--------------------------------------------------------------------------*/
  481. Xint
  482. Xkeyset_read(name)
  483. Xchar *name;
  484. X{
  485. X    int itmp;
  486. X    int ikde;
  487. X    char ecukeys_name[128];
  488. X    char s128[128];
  489. X    FILE *fp_keys;
  490. X
  491. X    get_home_dir(ecukeys_name);
  492. X    strcat(ecukeys_name, "/.ecu/keys");    /* someone may core dump here one
  493. X                                         * day */
  494. X
  495. X    if (!(fp_keys = fopen(ecukeys_name, "r")))
  496. X    {
  497. X        strcpy(ecukeys_name, eculibdir);
  498. X        strcat(ecukeys_name, "/keys");
  499. X        if (!(fp_keys = fopen(ecukeys_name, "r")))
  500. X            return (-1);
  501. X    }
  502. X
  503. X/* find keyset name */
  504. X    itmp = 0;
  505. X    while ((ikde = kde_fgets(s128, sizeof(s128), fp_keys)) != KDETYPE_EOF)
  506. X    {
  507. X        if ((ikde == KDETYPE_NAME) && !strcmp(s128, name))
  508. X        {
  509. X            itmp = 1;         /* success */
  510. X            break;
  511. X        }
  512. X    }
  513. X    if (!itmp)                 /* find match? */
  514. X    {
  515. X        fclose(fp_keys);     /* nope */
  516. X        return (-2);
  517. X    }
  518. X
  519. X/*
  520. X * read past any other keyset names matching this set
  521. X * process 1st line of definition when found
  522. X */
  523. X    memset(s128, 0, sizeof(s128));
  524. X    while ((ikde = kde_fgets(s128, sizeof(s128), fp_keys)) != KDETYPE_EOF)
  525. X    {
  526. X        if (ikde == KDETYPE_ENTRY)
  527. X        {
  528. X            if (keyset_define_key(s128) < 0)
  529. X            {
  530. X                fclose(fp_keys);
  531. X                keyset_init();
  532. X                return (-3);
  533. X            }
  534. X            break;
  535. X        }
  536. X        memset(s128, 0, sizeof(s128));
  537. X    }
  538. X
  539. X/*
  540. X * read rest of definition
  541. X */
  542. X    while ((ikde = kde_fgets(s128, sizeof(s128), fp_keys)) != KDETYPE_EOF)
  543. X    {
  544. X        switch (ikde)
  545. X        {
  546. X            case KDETYPE_COMMENT:
  547. X                continue;
  548. X            case KDETYPE_ENTRY:
  549. X                if (keyset_define_key(s128) < 0)
  550. X                {
  551. X                    fclose(fp_keys);
  552. X                    keyset_init();
  553. X                    return (-3);
  554. X                }
  555. X                break;
  556. X            default:
  557. X                goto DONE;
  558. X        }
  559. X    }
  560. X
  561. X  DONE:
  562. X    strncpy(keyset_name, name, sizeof(keyset_name));
  563. X    keyset_name[sizeof(keyset_name) - 1] = 0;
  564. X    fclose(fp_keys);
  565. X    return (0);
  566. X}                             /* end of keyset_read */
  567. X
  568. X/*+-------------------------------------------------------------------------
  569. X    ffso(str)
  570. X--------------------------------------------------------------------------*/
  571. Xvoid
  572. Xffso(str)
  573. Xchar *str;
  574. X{
  575. X    tcap_stand_out();
  576. X    fputs(str, se);
  577. X    tcap_stand_end();
  578. X}                             /* end of ffso */
  579. X
  580. X/*+-------------------------------------------------------------------------
  581. X    keyset_display()
  582. X
  583. X F1  xxxxx  F2   xxxxx   HOME xxxxx  PGUP xxxxx
  584. X F3  xxxxx  F4   xxxxx   END  xxxxx  PGDN xxxxx
  585. X F5  xxxxx  F6   xxxxx   INS  xxxxx  CUR5 xxxxx
  586. X F7  xxxxx  F8   xxxxx   BkTab xxxxx
  587. X F9  xxxxx  F10  xxxxx   CUR^ xxxxx  CUR> xxxxx
  588. X F11 xxxxx  F12  xxxxx   CUR< xxxxx  CURv xxxxx
  589. X--------------------------------------------------------------------------*/
  590. Xvoid
  591. Xkeyset_display()
  592. X{
  593. X    int itmp;
  594. X    int itmp2;
  595. X    int clen1 = 0;
  596. X    char cfmt1[32];
  597. X    int clen2 = 0;
  598. X    char cfmt2[32];
  599. X    int clen3 = 0;
  600. X    char cfmt3[32];
  601. X    char cfmt4[32];
  602. X    KDE *tkde;
  603. X
  604. X    if (!keyset_name[0])
  605. X        keyset_init();
  606. X
  607. X    for (itmp = 0; itmp < KDE_COUNT; itmp++)
  608. X    {
  609. X        tkde = &keyset_table[itmp];
  610. X        itmp2 = strlen(tkde->logical);
  611. X        switch (itmp)
  612. X        {
  613. X            case IKDE_F1:
  614. X            case IKDE_F3:
  615. X            case IKDE_F5:
  616. X            case IKDE_F7:
  617. X            case IKDE_F9:
  618. X            case IKDE_F11:
  619. X                if (clen1 < itmp2)
  620. X                    clen1 = itmp2;
  621. X                break;
  622. X
  623. X            case IKDE_F2:
  624. X            case IKDE_F4:
  625. X            case IKDE_F6:
  626. X            case IKDE_F8:
  627. X            case IKDE_F10:
  628. X            case IKDE_F12:
  629. X                if (clen2 < itmp2)
  630. X                    clen2 = itmp2;
  631. X                break;
  632. X
  633. X            case IKDE_HOME:
  634. X            case IKDE_END:
  635. X            case IKDE_INS:
  636. X            case IKDE_CUU:
  637. X            case IKDE_CUL:
  638. X                if (clen3 < itmp2)
  639. X                    clen3 = itmp2;
  640. X                break;
  641. X
  642. X            case IKDE_InitStr:    /* initialization string excluded */
  643. X                break;
  644. X        }
  645. X    }
  646. X    sprintf(cfmt1, " %%-%d.%ds", clen1, clen1);
  647. X    sprintf(cfmt2, " %%-%d.%ds", clen2, clen2);
  648. X    sprintf(cfmt3, " %%-%d.%ds", clen3, clen3);
  649. X    strcpy(cfmt4, " %s");
  650. X    ff(se, "   key definition: %s\r\n\r\n", keyset_name);
  651. X
  652. X    ffso(" F1  ");
  653. X    ff(se, cfmt1, keyset_table[IKDE_F1].logical);
  654. X    fputs("  ", se);
  655. X    ffso(" F2  ");
  656. X    ff(se, cfmt2, keyset_table[IKDE_F2].logical);
  657. X    fputs("  ", se);
  658. X    ffso(" Home ");
  659. X    ff(se, cfmt3, keyset_table[IKDE_HOME].logical);
  660. X    fputs("  ", se);
  661. X    ffso(" PgUp ");
  662. X    ff(se, cfmt4, keyset_table[IKDE_PGUP].logical);
  663. X    fputs("\r\n", se);
  664. X
  665. X    ffso(" F3  ");
  666. X    ff(se, cfmt1, keyset_table[IKDE_F3].logical);
  667. X    fputs("  ", se);
  668. X    ffso(" F4  ");
  669. X    ff(se, cfmt2, keyset_table[IKDE_F4].logical);
  670. X    fputs("  ", se);
  671. X    ffso(" End  ");
  672. X    ff(se, cfmt3, keyset_table[IKDE_END].logical);
  673. X    fputs("  ", se);
  674. X    ffso(" PgDn ");
  675. X    ff(se, cfmt4, keyset_table[IKDE_PGDN].logical);
  676. X    fputs("\r\n", se);
  677. X
  678. X    ffso(" F5  ");
  679. X    ff(se, cfmt1, keyset_table[IKDE_F5].logical);
  680. X    fputs("  ", se);
  681. X    ffso(" F6  ");
  682. X    ff(se, cfmt2, keyset_table[IKDE_F6].logical);
  683. X    fputs("  ", se);
  684. X    ffso(" Ins  ");
  685. X    ff(se, cfmt3, keyset_table[IKDE_INS].logical);
  686. X    fputs("  ", se);
  687. X    ffso(" CUR5 ");
  688. X    ff(se, cfmt4, keyset_table[IKDE_CU5].logical);
  689. X    fputs("\r\n", se);
  690. X
  691. X    ffso(" F7  ");
  692. X    ff(se, cfmt1, keyset_table[IKDE_F7].logical);
  693. X    fputs("  ", se);
  694. X    ffso(" F8  ");
  695. X    ff(se, cfmt2, keyset_table[IKDE_F8].logical);
  696. X    fputs("  ", se);
  697. X    ffso(" BkTab");
  698. X    ff(se, cfmt3, keyset_table[IKDE_BKTAB].logical);
  699. X    fputs("\r\n", se);
  700. X
  701. X    ffso(" F9  ");
  702. X    ff(se, cfmt1, keyset_table[IKDE_F9].logical);
  703. X    fputs("  ", se);
  704. X    ffso(" F10 ");
  705. X    ff(se, cfmt2, keyset_table[IKDE_F10].logical);
  706. X    fputs("  ", se);
  707. X    ffso(" CUR^ ");
  708. X    ff(se, cfmt3, keyset_table[IKDE_CUU].logical);
  709. X    fputs("  ", se);
  710. X    ffso(" CUR> ");
  711. X    ff(se, cfmt4, keyset_table[IKDE_CUR].logical);
  712. X    fputs("\r\n", se);
  713. X
  714. X    ffso(" F11 ");
  715. X    ff(se, cfmt1, keyset_table[IKDE_F11].logical);
  716. X    fputs("  ", se);
  717. X    ffso(" F12 ");
  718. X    ff(se, cfmt2, keyset_table[IKDE_F12].logical);
  719. X    fputs("  ", se);
  720. X    ffso(" CUR< ");
  721. X    ff(se, cfmt3, keyset_table[IKDE_CUL].logical);
  722. X    fputs("  ", se);
  723. X    ffso(" CURv ");
  724. X    ff(se, cfmt4, keyset_table[IKDE_CUD].logical);
  725. X    fputs("\r\n\r\n", se);
  726. X
  727. X}                             /* end of keyset_display */
  728. X
  729. X/* end of ecufkey.c */
  730. X/* vi: set tabstop=4 shiftwidth=4: */
  731. END_OF_FILE
  732.   if test 16642 -ne `wc -c <'ecu330/ecufkey.c'`; then
  733.     echo shar: \"'ecu330/ecufkey.c'\" unpacked with wrong size!
  734.   fi
  735.   # end of 'ecu330/ecufkey.c'
  736. fi
  737. if test -f 'ecu330/z/zcurses.c' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'ecu330/z/zcurses.c'\"
  739. else
  740.   echo shar: Extracting \"'ecu330/z/zcurses.c'\" \(44210 characters\)
  741.   sed "s/^X//" >'ecu330/z/zcurses.c' <<'END_OF_FILE'
  742. X/*+-------------------------------------------------------------------------
  743. X    zcurses.c -- ecu file transfer program curses interface
  744. X
  745. X  000000000011111111112222222222333333333344444444445555555550
  746. X  012345678901234567890123456789012345678901234567890123456789
  747. X00.-[ prog+rev ]-- <dir> ------------------------------------.
  748. X01|  ZMODEM_6____  _40_____________________________________  |
  749. X02|  File ### of ###: _38__________________________________  |
  750. X03|  File position:  _8______ length: _8______  -rwxrwxrwx   |
  751. X04|  _55____________________________________________________ | transaction
  752. X05|  _55____________________________________________________ | last rx/tx hdr
  753. X06|  Comm I/O: rx _8______  tx _8______ bytes                |
  754. X07|  Baud rate: _5___ BINARY blklen: _____ comm mode: RAW-g  |
  755. X08|  Time:    started: __:__:__ this file: __:__:__ window:  |
  756. X09|  __:__:__ elapsed: __:__:__            __:__:__ ________ |
  757. X10|  Errors: this file: _3_ total: _4__ files skipped: _3_   |
  758. X11|  _55____________________________________________________ |  err str
  759. X12|  _55____________________________________________________ |  comment str
  760. X13|  _55____________________________________________________ |  remote info
  761. X14`----------------------------------------------------------'
  762. X
  763. X14|  FE ___ OE ___ rcvd ________ xmtd ________ RTS _ CTS _      FASI
  764. X15|  flow xmtr CTS ____ XOFF ____ rcvr RTS ____ XOFF ____
  765. X16|  queues: xmtr _____ of _____  rcvr _____ of _____
  766. X
  767. X14|  Output queue depth  ______  RTS _  CTS _                   sun
  768. X15|  Input queue depth   ______  Input queue avail ______
  769. X
  770. X
  771. X  Defined functions:
  772. X    clear_area(w,row,col,len)
  773. X    clear_area_char(w,row,col,len,fillchar)
  774. X    determine_output_mode()
  775. X    dumbtty_newline()
  776. X    get_elapsed_time(elapsed_secs)
  777. X    get_tod(type,tod)
  778. X    mode_map(file_mode,mode_str)
  779. X    report_comm_baud_rate(baud_rate)
  780. X    report_error_count()
  781. X    report_file_byte_io(count)
  782. X    report_file_close(skipped)
  783. X    report_file_open_length(length)
  784. X    report_file_open_mode(file_mode)
  785. X    report_file_open_tod()
  786. X    report_file_rcv_started(filename,length,last_mod_time,file_mode)
  787. X    report_file_send_open(filename,filestat)
  788. X    report_file_xfer_rate(text,count,final)
  789. X    report_init(title)
  790. X    report_last_rxhdr(rptstr,error_flag)
  791. X    report_last_txhdr(rptstr,error_flag)
  792. X    report_mode(comm_mode)
  793. X    report_protocol_crc_type(str)
  794. X    report_protocol_type(str)
  795. X    report_rx_ind(status)
  796. X    report_rx_tx_count()
  797. X    report_rxblklen(blklen)
  798. X    report_rxpos(pos)
  799. X    report_str(rptstr,error_flag)
  800. X    report_top_line(topstr)
  801. X    report_transaction(str)
  802. X    report_transfer_progress(filepos,initfpos)
  803. X    report_tx_ind(status)
  804. X    report_txblklen(blklen)
  805. X    report_txpos(pos)
  806. X    report_uninit(sig)
  807. X    report_window()
  808. X    report_xfer_mode(str)
  809. X    vanilla_ruling()
  810. X
  811. X------------------------------------------------------------------------*/
  812. X/*+:EDITS:*/
  813. X/*:05-04-1994-04:40-wht@n4hgf-ECU release 3.30 */
  814. X/*:01-16-1994-15:46-wht@n4hgf-use ecumachdep.h */
  815. X/*:12-02-1993-14:05-Robert_Broughton@mindlink.bc.c-LINUX patches */
  816. X/*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
  817. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  818. X/*:02-09-1992-16:08-root@n4hgf-ruling characters only on  SCO (tcap curses) */
  819. X/*:01-05-1992-17:27-wht@n4hgf-properly display progress for resumed transfers */
  820. X/*:09-02-1991-01:12-wht@n4hgf2-show sun driver information */
  821. X/*:08-28-1991-14:08-wht@n4hgf2-SVR4 cleanup by aega84!lh */
  822. X/*:08-23-1991-18:33-wht@n4hgf2-disable force no curses for tty vs. line speed */
  823. X/*:08-21-1991-06:23-wht@n4hgf-sun porting */
  824. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  825. X/*:06-15-1991-05:47-root@n4hgf-report per-file xfer rate */
  826. X/*:05-25-1991-14:51-wht@n4hgf-FAS/i display */
  827. X/*:04-24-1991-01:22-wht@n4hgf-handle dumbtty and single file xfer >= 1 hour */
  828. X/*:02-03-1991-17:27-wht@n4hgf-show elapsed time during no curses xfer */
  829. X/*:01-04-1991-15:54-wht@n4hgf-dumbtty per-file xfer rate was wrong */
  830. X/*:12-18-1990-21:26-wht@n4hgf-better output control */
  831. X/*:12-04-1990-04:07-wht@n4hgf-handle slow terminal using faster line */
  832. X/*:12-04-1990-03:04-wht@n4hgf-choose ruling chars based on multiscreen or not */
  833. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  834. X/*:08-14-1990-20:41-wht@n4hgf-ecu3.00-flush old edit history */
  835. X
  836. X#include "../ecucurses.h"
  837. X#include "../ecu_types.h"
  838. X#include "../ecu_stat.h"
  839. X#include "../ecu_time.h"
  840. X#include <ctype.h>
  841. X#include <signal.h>
  842. X
  843. X#include "../ecumachdep.h"
  844. X#include "../pc_scr.h"
  845. X
  846. X#if defined(FASI)
  847. X#include <local/fas.h>
  848. X#endif /* FASI */
  849. X
  850. Xlong time();
  851. Xvoid report_error_count();
  852. Xextern char *tzname[];
  853. Xstruct tm *localtime();
  854. X
  855. X#ifdef LINUX
  856. Xtypedef chtype Chtype;
  857. X
  858. X#else
  859. Xtypedef unsigned char Chtype;
  860. X
  861. X#endif
  862. X
  863. XChtype sTL = at_TL;
  864. XChtype sTR = at_TR;
  865. XChtype sBL = at_BL;
  866. XChtype sBR = at_BR;
  867. XChtype sLT = at_LT;
  868. XChtype sRT = at_RT;
  869. XChtype sVR = at_VR;
  870. XChtype sHR = at_HR;
  871. X
  872. X#if defined(FASI)
  873. X#define WIN_LINES    18
  874. X#else
  875. X#if defined(sun) && !defined (SVR4)
  876. X#define WIN_LINES    17
  877. X#else
  878. X#define WIN_LINES    15
  879. X#endif /* sun */
  880. X#endif /* FASI */
  881. X
  882. X#define WIN_COLS    60
  883. X#define WIN_TOPY    2
  884. X#define WIN_LEFTX    8
  885. X
  886. Xextern char curr_dir[];
  887. Xextern char *bottom_label;
  888. Xextern int Filcnt;
  889. Xextern int ecusz_flag;         /* ecusz == 1, ecurz == 0 */
  890. Xextern int force_dumbtty;
  891. Xextern int skip_count;
  892. Xextern int npats;
  893. Xextern int iofd;
  894. Xextern long rxpos;
  895. Xextern int log_packets;
  896. Xextern long Txpos;
  897. Xextern long Rxpos;
  898. Xextern long initial_filepos;
  899. X
  900. XWINDOW *win;
  901. Xint (*original_sigint_handler) ();
  902. Xint (*original_sigquit_handler) ();
  903. Xint (*original_sigterm_handler) ();
  904. Xint report_init_complete;
  905. Xint report_verbosity;
  906. Xint dumbtty;
  907. Xint dumbtty_pos;
  908. Xint this_file_errors;
  909. Xlong this_file_xfer_count;
  910. Xint total_errors;
  911. Xint show_window;
  912. Xlong current_seconds;
  913. Xlong start_seconds;
  914. Xlong this_file_start_seconds;
  915. Xlong elapsed_seconds;
  916. Xunsigned long total_data_bytes_xfered;
  917. Xunsigned int zcurses_baud_rate;
  918. Xchar s128[128];
  919. X
  920. X#if defined(FASI)
  921. Xstruct fas_info fip_start;
  922. X
  923. X#endif /* FASI */
  924. X
  925. Xchar *win_template[] =
  926. X{
  927. X/*00000000001111111111222222222233333333334444444444555555555 */
  928. X/*01234567890123456789012345678901234567890123456789012345678 */
  929. X/*.----------------------------------------------------------. */
  930. X    "                                                          ",    /* 1 */
  931. X    "  File ### of ###: _____________________________________  ",    /* 2 */
  932. X    "  File position:  ________ length: ________               ",    /* 3 */
  933. X    "                                                          ",    /* 4 */
  934. X    "  tx: ______________________  rx: ______________________  ",    /* 5 */
  935. X    "  Comm I/O: rx ________  tx ________ bytes                ",    /* 6 */
  936. X    "  Baud rate: _____ ______ blklen: _____ comm mode: ______ ",    /* 7 */
  937. X    "  Time:    started: __:__:__ this file: __:__:__          ",    /* 8 */
  938. X    "  __:__:__ elapsed: __:__:__            __:__:__          ",    /* 9 */
  939. X    "  Errors: this file: ___ total: ____ files skipped: ___   ",    /* 10 */
  940. X    "                                                          ",    /* 11 */
  941. X    "                                                          ",    /* 12 */
  942. X    "                                                          ",    /* 13 */
  943. X#if defined(FASI)
  944. X    "  FE ___ OE ___ rcvd ________ xmtd ________ RTS _ CTS _   ",
  945. X    "  flow xmtr CTS ____ XOFF ____ rcvr RTS ____ XOFF ____    ",
  946. X    "  queues: xmtr _____ of _____  rcvr _____ of _____        ",
  947. X#endif /* FASI */
  948. X#if defined(sun)
  949. X    "  Output queue depth  ______  RTS _  CTS _                ",
  950. X    "  Input queue depth   ______  Input queue avail ______    ",
  951. X#endif
  952. X/*`----------------------------------------------------------' */
  953. X    (char *)0
  954. X};
  955. X
  956. X/*+-------------------------------------------------------------------------
  957. X    vanilla_ruling() - use ordinary ruling characters
  958. X--------------------------------------------------------------------------*/
  959. Xvoid
  960. Xvanilla_ruling()
  961. X{
  962. X    sTL = vanilla_TL;
  963. X    sTR = vanilla_TR;
  964. X    sBL = vanilla_BL;
  965. X    sBR = vanilla_BR;
  966. X    sLT = vanilla_LT;
  967. X    sRT = vanilla_RT;
  968. X    sVR = vanilla_VR;
  969. X    sHR = vanilla_HR;
  970. X
  971. X}                             /* end of vanilla_ruling */
  972. X
  973. X/*+-----------------------------------------------------------------------
  974. X    char *get_elapsed_time(elapsed_secs)
  975. X    hh:mm:ss returned
  976. X  static string address is returned
  977. X------------------------------------------------------------------------*/
  978. Xchar *
  979. Xget_elapsed_time(elapsed_secs)
  980. Xlong elapsed_secs;
  981. X{
  982. X    static char elapsed_time_str[10];
  983. X    long hh, mm, ss;
  984. X
  985. X    hh = elapsed_secs / 3600;
  986. X    elapsed_secs -= hh * 3600;
  987. X    mm = elapsed_secs / 60L;
  988. X    elapsed_secs -= mm * 60L;
  989. X    ss = elapsed_secs;
  990. X
  991. X    sprintf(elapsed_time_str, "%02ld:%02ld:%02ld", hh, mm, ss);
  992. X    return (elapsed_time_str);
  993. X}                             /* end of get_elapsed_time */
  994. X
  995. X/*+-----------------------------------------------------------------------
  996. X    char *get_tod(type,tod)
  997. X
  998. X  time of day types:
  999. X    0        hh:mm
  1000. X    1        hh:mm:ss
  1001. X    2        mm-dd-yyyy hh:mm
  1002. X
  1003. X  static string address is returned
  1004. X  if tod != (char *)0, time is returned there too
  1005. X------------------------------------------------------------------------*/
  1006. Xchar *
  1007. Xget_tod(type, tod)
  1008. Xint type;
  1009. Xchar *tod;
  1010. X{
  1011. X    static char tod_str[32];
  1012. X    long cur_time = time((long *)0);
  1013. X    struct tm *lt = localtime(&cur_time);
  1014. X
  1015. X    switch (type)
  1016. X    {
  1017. X        case 0:
  1018. X            sprintf(tod_str, "%02d:%02d", lt->tm_hour, lt->tm_min);
  1019. X            break;
  1020. X
  1021. X        default:
  1022. X        case 1:
  1023. X            sprintf(tod_str, "%02d:%02d:%02d",
  1024. X                lt->tm_hour, lt->tm_min, lt->tm_sec);
  1025. X            break;
  1026. X
  1027. X        case 2:
  1028. X            sprintf(tod_str, "%02d-%02d-%04d %02d:%02d",
  1029. X                lt->tm_mon + 1, lt->tm_mday, lt->tm_year + 1900,
  1030. X                lt->tm_hour, lt->tm_min);
  1031. X            break;
  1032. X    }
  1033. X
  1034. X    if (tod != (char *)0)
  1035. X        strcpy(tod, tod_str);
  1036. X
  1037. X    return (tod_str);
  1038. X}                             /* end of get_tod */
  1039. X
  1040. X/*+-----------------------------------------------------------------------
  1041. X    mode_map(file_mode,mode_str)    build drwxrwxrwx string
  1042. X------------------------------------------------------------------------*/
  1043. Xchar *
  1044. Xmode_map(file_mode, mode_str)
  1045. Xunsigned short file_mode;
  1046. Xchar *mode_str;
  1047. X{
  1048. X    register unsigned ftype = file_mode & S_IFMT;
  1049. X    register char *rtn;
  1050. X    static char result[12];
  1051. X
  1052. X    rtn = (mode_str == (char *)0) ? result : mode_str;
  1053. X
  1054. X    /* drwxrwxrwx */
  1055. X    /* 0123456789 */
  1056. X    strcpy(rtn, "----------");
  1057. X
  1058. X    switch (ftype)
  1059. X    {
  1060. X        case S_IFIFO:
  1061. X            *rtn = 'p';
  1062. X            break;             /* FIFO (named pipe) */
  1063. X        case S_IFDIR:
  1064. X            *rtn = 'd';
  1065. X            break;             /* directory */
  1066. X        case S_IFCHR:
  1067. X            *rtn = 'c';
  1068. X            break;             /* character special */
  1069. X        case S_IFBLK:
  1070. X            *rtn = 'b';
  1071. X            break;             /* block special */
  1072. X        case S_IFREG:
  1073. X            *rtn = '-';
  1074. X            break;             /* regular */
  1075. X
  1076. X#if defined(S_IFLNK)
  1077. X        case S_IFLNK:
  1078. X            *rtn = 'l';
  1079. X            break;             /* symbolic link */
  1080. X#endif
  1081. X#if defined(S_IFSOCK)
  1082. X        case S_IFSOCK:
  1083. X            *rtn = 's';
  1084. X            break;             /* socket */
  1085. X#endif
  1086. X
  1087. X#if defined(S_IFNAM)
  1088. X        case S_IFNAM:         /* name space entry */
  1089. X#if defined(S_IFNAM)
  1090. X            if (file_mode & S_INSEM)    /* semaphore */
  1091. X            {
  1092. X                *rtn = 's';
  1093. X                break;
  1094. X            }
  1095. X#endif
  1096. X#if defined(S_INSHD)
  1097. X            if (file_mode & S_INSHD)    /* shared memory */
  1098. X            {
  1099. X                *rtn = 'm';
  1100. X                break;
  1101. X            }
  1102. X            break;
  1103. X#endif
  1104. X#endif
  1105. X
  1106. X        default:
  1107. X            *rtn = '?';
  1108. X            break;             /* ??? */
  1109. X    }
  1110. X
  1111. X    if (file_mode & 000400)
  1112. X        *(rtn + 1) = 'r';
  1113. X    if (file_mode & 000200)
  1114. X        *(rtn + 2) = 'w';
  1115. X    if (file_mode & 000100)
  1116. X        *(rtn + 3) = 'x';
  1117. X    if (file_mode & 004000)
  1118. X        *(rtn + 3) = 's';
  1119. X    if (file_mode & 000040)
  1120. X        *(rtn + 4) = 'r';
  1121. X    if (file_mode & 000020)
  1122. X        *(rtn + 5) = 'w';
  1123. X    if (file_mode & 000010)
  1124. X        *(rtn + 6) = 'x';
  1125. X    if (file_mode & 002000)
  1126. X        *(rtn + 6) = 's';
  1127. X    if (file_mode & 000004)
  1128. X        *(rtn + 7) = 'r';
  1129. X    if (file_mode & 000002)
  1130. X        *(rtn + 8) = 'w';
  1131. X    if (file_mode & 000001)
  1132. X        *(rtn + 9) = 'x';
  1133. X    if (file_mode & 001000)
  1134. X        *(rtn + 9) = 't';
  1135. X
  1136. X    return (rtn);
  1137. X
  1138. X}                             /* end of mode_map */
  1139. X
  1140. X/*+-------------------------------------------------------------------------
  1141. X    dumbtty_newline()
  1142. X--------------------------------------------------------------------------*/
  1143. Xvoid
  1144. Xdumbtty_newline()
  1145. X{
  1146. X    if (dumbtty_pos)
  1147. X        printf("\r\n");
  1148. X    dumbtty_pos = 0;
  1149. X
  1150. X}                             /* end of dumbtty_newline */
  1151. X
  1152. X/*+-------------------------------------------------------------------------
  1153. X    clear_area(w,row,col,len)
  1154. X--------------------------------------------------------------------------*/
  1155. Xclear_area(w, row, col, len)
  1156. XWINDOW *w;
  1157. Xint row;
  1158. Xint col;
  1159. Xint len;
  1160. X{
  1161. X    if (dumbtty)
  1162. X        return;
  1163. X    wmove(w, row, col);
  1164. X    while (len-- > 0)
  1165. X        waddch(w, ' ');
  1166. X    wmove(w, row, col);
  1167. X
  1168. X}                             /* end of clear_area */
  1169. X
  1170. X/*+-------------------------------------------------------------------------
  1171. X    clear_area_char(w,row,col,len,fillchar)
  1172. X--------------------------------------------------------------------------*/
  1173. Xclear_area_char(w, row, col, len, fillchar)
  1174. XWINDOW *w;
  1175. Xint row;
  1176. Xint col;
  1177. Xint len;
  1178. Xchar fillchar;
  1179. X{
  1180. X    if (dumbtty)
  1181. X        return;
  1182. X    wmove(w, row, col);
  1183. X    while (len-- > 0)
  1184. X        waddch(w, fillchar);
  1185. X    wmove(w, row, col);
  1186. X
  1187. X}                             /* end of clear_area_char */
  1188. X
  1189. X/*+-------------------------------------------------------------------------
  1190. X    report_top_line(topstr)
  1191. X   top line: row 1 col 17 length 42
  1192. X--------------------------------------------------------------------------*/
  1193. Xvoid
  1194. Xreport_top_line(topstr)
  1195. Xchar *topstr;
  1196. X{
  1197. X    char s42[42];
  1198. X
  1199. X    if (dumbtty)
  1200. X    {
  1201. X        dumbtty_newline();
  1202. X        dumbtty_pos = printf("%s", topstr);
  1203. X        fflush(stdout);
  1204. X        return;
  1205. X    }
  1206. X
  1207. X    clear_area(win, 1, 17, 42);
  1208. X    if (strlen(topstr) < 40)
  1209. X        waddstr(win, topstr);
  1210. X    else
  1211. X    {
  1212. X        strncpy(s42, topstr, 40);
  1213. X        s42[40] = 0;
  1214. X        waddstr(win, s42);
  1215. X    }
  1216. X}                             /* end of report_top_line */
  1217. X
  1218. X/*+-------------------------------------------------------------------------
  1219. X    report_xfer_mode(modestr)  BINARY/ASCII
  1220. X   protocol xfer type: row 7 col 20 length 6
  1221. X--------------------------------------------------------------------------*/
  1222. Xreport_xfer_mode(str)
  1223. Xchar *str;
  1224. X{
  1225. X    char s10[10];
  1226. X
  1227. X    if (dumbtty)
  1228. X        return;
  1229. X    if (strlen(str) > 6)
  1230. X    {
  1231. X        strncpy(s10, str, 6);
  1232. X        s10[7] = 0;
  1233. X        str = s10;
  1234. X    }
  1235. X    clear_area(win, 7, 20, 6);
  1236. X    waddstr(win, str);
  1237. X    wrefresh(win);
  1238. X
  1239. X}                             /* end of report_xfer_mode */
  1240. X
  1241. X/*+-------------------------------------------------------------------------
  1242. X    report_protocol_type(str)
  1243. X
  1244. X  protocol type:  row 1 col 3 length 6 string
  1245. X--------------------------------------------------------------------------*/
  1246. Xreport_protocol_type(str)
  1247. Xregister char *str;
  1248. X{
  1249. X    char s10[10];
  1250. X
  1251. X    if (dumbtty)
  1252. X    {
  1253. X        return;
  1254. X    }
  1255. X
  1256. X    if (strlen(str) > 6)
  1257. X    {
  1258. X        strncpy(s10, str, 6);
  1259. X        s10[7] = 0;
  1260. X        str = s10;
  1261. X    }
  1262. X    clear_area(win, 1, 3, 6);
  1263. X    waddstr(win, str);
  1264. X    wrefresh(win);
  1265. X
  1266. X}                             /* end of report_protocol_type */
  1267. X
  1268. X/*+-------------------------------------------------------------------------
  1269. X    report_protocol_crc_type(str)
  1270. X
  1271. X  protocol crc type:  row 1 col 9 length 6
  1272. X--------------------------------------------------------------------------*/
  1273. Xreport_protocol_crc_type(str)
  1274. Xregister char *str;
  1275. X{
  1276. X    char s8[8];
  1277. X
  1278. X    if (dumbtty)
  1279. X    {
  1280. X        return;
  1281. X    }
  1282. X
  1283. X    if (strlen(str) > 6)
  1284. X    {
  1285. X        strncpy(s8, str, 6);
  1286. X        s8[7] = 0;
  1287. X        str = s8;
  1288. X    }
  1289. X    clear_area(win, 1, 9, 6);
  1290. X    waddstr(win, str);
  1291. X    wrefresh(win);
  1292. X
  1293. X}                             /* end of report_protocol_crc_type */
  1294. X
  1295. X/*+-------------------------------------------------------------------------
  1296. X    report_uninit(sig)
  1297. X--------------------------------------------------------------------------*/
  1298. Xvoid
  1299. Xreport_uninit(sig)
  1300. Xint sig;                     /* if -1, called by normal code, else kill()
  1301. X                              * value */
  1302. X{
  1303. X    float rate = 0.0;
  1304. X    float eff = 0.0;
  1305. X
  1306. X    if (report_init_complete)
  1307. X    {
  1308. X        current_seconds = time((long *)0);
  1309. X        elapsed_seconds = current_seconds - start_seconds;
  1310. X        if (elapsed_seconds && (zcurses_baud_rate > 50))
  1311. X        {
  1312. X            rate = (float)total_data_bytes_xfered /
  1313. X                (float)elapsed_seconds;
  1314. X            if (zcurses_baud_rate)
  1315. X                eff = 100.0 * (rate / ((float)zcurses_baud_rate / 10.0));
  1316. X        }
  1317. X        if (rate > 0.01)
  1318. X        {
  1319. X            sprintf(s128, "XFERINFO transaction rate ~= %.0f ch/sec (%.0f%%)",
  1320. X                rate, (eff > 0.5) ? eff : 0.0);
  1321. X            if (log_packets)
  1322. X            {
  1323. X                write(log_packets, "info: ", 6);
  1324. X                write(log_packets, s128, strlen(s128));
  1325. X                write(log_packets, "\n", 1);
  1326. X            }
  1327. X            report_top_line(s128 + 9);
  1328. X#if defined(WHT)
  1329. X            ecu_log_event(getppid(), s128);
  1330. X#endif
  1331. X        }
  1332. X        if (dumbtty)
  1333. X            dumbtty_newline();
  1334. X        else
  1335. X        {
  1336. X            report_file_byte_io(0L);
  1337. X            report_rx_tx_count();
  1338. X            wmove(win, WIN_LINES - 1, WIN_COLS - 1);
  1339. X            wrefresh(win);
  1340. X            endwin();
  1341. X            fprintf(stderr, "\r\n\r\n\r\n");
  1342. X            fflush(stderr);
  1343. X        }
  1344. X        report_init_complete = 0;
  1345. X    }
  1346. X
  1347. X}                             /* end of report_uninit */
  1348. X
  1349. X/*+-------------------------------------------------------------------------
  1350. X    determine_output_mode()
  1351. X--------------------------------------------------------------------------*/
  1352. Xint
  1353. Xdetermine_output_mode()
  1354. X{
  1355. X#if defined(CONS_GET)
  1356. X    int monitor_type;
  1357. X
  1358. X#endif
  1359. X    struct stat dn;
  1360. X    struct stat tty_stat;
  1361. X
  1362. X#ifdef NO_PTY_CURSES
  1363. X    struct stat pty_stat;
  1364. X
  1365. X#endif
  1366. X
  1367. X    if (force_dumbtty)
  1368. X    {
  1369. X        dumbtty = 1;
  1370. X        report_verbosity = 1;
  1371. X        report_init_complete = 1;
  1372. X        return (1);
  1373. X    }
  1374. X
  1375. X#ifndef M_SYSV                 /* these are always set thus for non-SCO */
  1376. X    vanilla_ruling();
  1377. X#endif
  1378. X
  1379. X#if defined(CONS_GET)
  1380. X    if (ioctl(0, CONS_GET, &monitor_type) < 0)    /* not multiscreen */
  1381. X    {
  1382. X#endif
  1383. X
  1384. X#ifdef M_SYSV                 /* SCO non AT console */
  1385. X        vanilla_ruling();
  1386. X#endif
  1387. X#ifdef LINUX
  1388. X        sTL = ACS_ULCORNER;
  1389. X        sTR = ACS_URCORNER;
  1390. X        sBL = ACS_LLCORNER;
  1391. X        sBR = ACS_LRCORNER;
  1392. X        sLT = ACS_LTEE;
  1393. X        sRT = ACS_RTEE;
  1394. X        sVR = ACS_VLINE;
  1395. X        sHR = ACS_HLINE;
  1396. X#endif
  1397. X
  1398. X        /*
  1399. X         * if tty (console) is not character special, only report basic
  1400. X         * progress
  1401. X         */
  1402. X        memset((char *)&dn, 0, sizeof(dn));
  1403. X        stat("/dev/null", &dn);
  1404. X        if (fstat(0, &tty_stat) ||
  1405. X            ((tty_stat.st_mode & S_IFMT) != S_IFCHR) ||
  1406. X            (dn.st_rdev == tty_stat.st_rdev))
  1407. X        {
  1408. X#ifndef LINUX
  1409. X            dumbtty = 1;
  1410. X#endif
  1411. X            report_verbosity = 0;
  1412. X            report_init_complete = 1;
  1413. X            return (1);
  1414. X        }
  1415. X
  1416. X#ifdef NO_PTY_CURSES
  1417. X
  1418. X        /*
  1419. X         * if pty (must be xterm), send clear screen and no curses
  1420. X         */
  1421. X        if (!stat("/dev/ttyp0", &pty_stat) &&
  1422. X            (pty_stat.st_rdev & 0xFF00) == (tty_stat.st_rdev & 0xFF00))
  1423. X        {
  1424. X            static char ff[] = "\033[H\0332J\r\n";
  1425. X
  1426. X            write(2, ff, strlen(ff));
  1427. X            dumbtty = 1;
  1428. X            report_verbosity = 1;
  1429. X            report_init_complete = 1;
  1430. X            return (1);
  1431. X        }
  1432. X#endif
  1433. X
  1434. X        /*
  1435. X         * if non-multiscreen tty baud rate not at least that of the
  1436. X         * attached line, use no curses, but do be a bit more verbose than
  1437. X         * if tty not char special
  1438. X         */
  1439. X#ifdef TTY_VS_LINE_SPEED_NO_CURSES
  1440. X        test_tty_and_line_baud();
  1441. X#endif
  1442. X
  1443. X#if defined(CONS_GET)
  1444. X    }
  1445. X#endif
  1446. X
  1447. X    return (dumbtty);
  1448. X
  1449. X}                             /* end of determine_output_mode */
  1450. X
  1451. X/*+-------------------------------------------------------------------------
  1452. X    report_init(title)
  1453. X  "top line": row 1 col 11 len 21
  1454. X  file quan:  row 2 col 15 len  3
  1455. X              row 2 col 12 len  7 clear "of ###"
  1456. X  start time: row 8 col 21 len  8
  1457. X  "window:"   row 8 col 50 len  7
  1458. X--------------------------------------------------------------------------*/
  1459. Xvoid
  1460. Xreport_init(title)
  1461. Xchar *title;
  1462. X{
  1463. X    register int itmp;
  1464. X
  1465. X    if (report_init_complete)
  1466. X        return;
  1467. X
  1468. X    start_seconds = time((long *)0);
  1469. X    current_seconds = start_seconds;
  1470. X
  1471. X    if (dumbtty)
  1472. X        return;
  1473. X
  1474. X#if defined(FASI)
  1475. X    (void)ioctl(iofd, FASIC_SIP, &fip_start);
  1476. X#endif /* FASI */
  1477. X
  1478. X    if (!initscr())
  1479. X        exit(254);
  1480. X    if (!stdscr)
  1481. X        exit(254);
  1482. X    crmode();
  1483. X    noecho();
  1484. X    nonl();
  1485. X    clear();
  1486. X    report_init_complete = 1;
  1487. X    win = newwin(WIN_LINES, WIN_COLS, WIN_TOPY, WIN_LEFTX);
  1488. X    box(win, sVR, sHR);
  1489. X#if !defined(SVR4) && !defined(LINUX)
  1490. X    wmove(win, 0, 0);
  1491. X    waddch(win, sTL);
  1492. X    wmove(win, win->_maxy - 1, 0);
  1493. X    waddch(win, sBL);
  1494. X    wmove(win, win->_maxy - 1, win->_maxx - 1);
  1495. X    waddch(win, sBR);
  1496. X    wmove(win, 0, win->_maxx - 1);
  1497. X    waddch(win, sTR);
  1498. X#endif
  1499. X    wmove(win, 0, 2);
  1500. X    wstandout(win);
  1501. X    waddch(win, '[');
  1502. X    waddch(win, ' ');
  1503. X    strcpy(s128, title);
  1504. X    waddstr(win, s128);
  1505. X    waddch(win, ' ');
  1506. X    waddch(win, ']');
  1507. X    wstandend(win);
  1508. X#ifdef SVR4
  1509. X    whline(win, (unsigned long)(sHR & 0x00ff), 2);
  1510. X    wmove(win, 0, 8 + strlen(title));
  1511. X#else
  1512. X#ifdef LINUX
  1513. X    whline(win, sHR, 2);
  1514. X    wmove(win, 0, 8 + strlen(title));
  1515. X#else
  1516. X    waddch(win, sHR);
  1517. X    waddch(win, sHR);
  1518. X#endif
  1519. X#endif
  1520. X    waddch(win, ' ');
  1521. X    itmp = WIN_COLS - 2 - 7 - strlen(title);
  1522. X    curr_dir[itmp] = 0;
  1523. X    waddstr(win, curr_dir);
  1524. X    waddch(win, ' ');
  1525. X    if (bottom_label)
  1526. X    {
  1527. X        strncpy(s128, bottom_label, WIN_COLS - 6);
  1528. X        s128[WIN_COLS - 6] = 0;
  1529. X        wmove(win, WIN_LINES - 1, 2);
  1530. X        waddch(win, ' ');
  1531. X        waddstr(win, s128);
  1532. X        waddch(win, ' ');
  1533. X    }
  1534. X
  1535. X    itmp = 0;
  1536. X    while (1)
  1537. X    {
  1538. X        if (win_template[itmp] == (char *)0)
  1539. X            break;
  1540. X        wmove(win, itmp + 1, 1);
  1541. X        waddstr(win, win_template[itmp++]);
  1542. X    }
  1543. X    if (ecusz_flag)
  1544. X    {
  1545. X        clear_area(win, 2, 15, 3);
  1546. X        sprintf(s128, "%-3d", npats);
  1547. X        waddstr(win, s128);
  1548. X#if defined(FORK_DEBUG)
  1549. X        sprintf(s128, "DEBUG ecusz pid %d", getpid());
  1550. X#endif
  1551. X    }
  1552. X    else
  1553. X        /* ecurz */
  1554. X    {
  1555. X        clear_area(win, 2, 11, 8);    /* clear "of ###" */
  1556. X        waddstr(win, ":");
  1557. X#if defined(FORK_DEBUG)
  1558. X        sprintf(s128, "DEBUG ecurz pid %d", getpid());
  1559. X#endif
  1560. X    }
  1561. X
  1562. X#if defined(FORK_DEBUG)
  1563. X    ecu_log_event(getppid(), s128);
  1564. X#endif
  1565. X
  1566. X    clear_area(win, 1, 11, 21);
  1567. X    report_error_count();
  1568. X    clear_area(win, 8, 21, 8);    /* starting time */
  1569. X    waddstr(win, get_tod(1, (char *)0));
  1570. X
  1571. X    if (show_window)
  1572. X    {
  1573. X        wmove(win, 8, 50);
  1574. X        waddstr(win, "window:");
  1575. X        wmove(win, 9, 50);
  1576. X        waddstr(win, "+0");
  1577. X    }
  1578. X
  1579. X    wrefresh(win);
  1580. X
  1581. X}                             /* end of report_init */
  1582. X
  1583. X/*+-------------------------------------------------------------------------
  1584. X    report_rx_ind(status)
  1585. X--------------------------------------------------------------------------*/
  1586. Xvoid
  1587. Xreport_rx_ind(status)
  1588. Xint status;
  1589. X{
  1590. X    char *cptr;
  1591. X
  1592. X    if (dumbtty)
  1593. X    {
  1594. X        if (report_verbosity && status)
  1595. X        {
  1596. X            printf("R");
  1597. X            if (++dumbtty_pos > 75)
  1598. X            {
  1599. X                dumbtty_newline();
  1600. X                current_seconds = time((long *)0);
  1601. X                elapsed_seconds = current_seconds - this_file_start_seconds;
  1602. X                cptr = get_elapsed_time(elapsed_seconds);
  1603. X                dumbtty_pos = printf("%s elapsed ", cptr +
  1604. X                    ((elapsed_seconds < 3600L) ? 3 : 0));
  1605. X            }
  1606. X            fflush(stdout);
  1607. X        }
  1608. X        return;
  1609. X    }
  1610. X    wmove(win, 1, 54);
  1611. X    waddch(win, (status) ? 'R' : ' ');
  1612. X    wmove(win, 1, 54);
  1613. X    wrefresh(win);
  1614. X}                             /* end of report_rx_ind */
  1615. X
  1616. X/*+-------------------------------------------------------------------------
  1617. X    report_tx_ind(status)
  1618. X--------------------------------------------------------------------------*/
  1619. Xvoid
  1620. Xreport_tx_ind(status)
  1621. Xint status;
  1622. X{
  1623. X    char *cptr;
  1624. X
  1625. X    if (dumbtty)
  1626. X    {
  1627. X        if (report_verbosity && status)
  1628. X        {
  1629. X            printf("T");
  1630. X            if (++dumbtty_pos > 75)
  1631. X            {
  1632. X                dumbtty_newline();
  1633. X                dumbtty_newline();
  1634. X                current_seconds = time((long *)0);
  1635. X                elapsed_seconds = current_seconds - this_file_start_seconds;
  1636. X                cptr = get_elapsed_time(elapsed_seconds);
  1637. X                dumbtty_pos = printf("%s elapsed ", cptr +
  1638. X                    ((elapsed_seconds < 3600L) ? 3 : 0));
  1639. X            }
  1640. X            fflush(stdout);
  1641. X        }
  1642. X        return;
  1643. X    }
  1644. X    wmove(win, 1, 56);
  1645. X    waddch(win, (status) ? 'T' : ' ');
  1646. X    wmove(win, 1, 56);
  1647. X    wrefresh(win);
  1648. X}                             /* end of report_tx_ind */
  1649. X
  1650. X/*+-------------------------------------------------------------------------
  1651. X    report_window() - if enable, show open widow size
  1652. X--------------------------------------------------------------------------*/
  1653. Xvoid
  1654. Xreport_window()
  1655. X{
  1656. X    if (show_window && !dumbtty)
  1657. X    {
  1658. X        long ltmp;
  1659. X
  1660. X        wmove(win, 9, 50);
  1661. X        if ((ltmp = (Txpos - Rxpos)) > 999999L)
  1662. X            waddstr(win, ">+999999");
  1663. X        else if (ltmp < -999999L)
  1664. X            ;
  1665. X        else
  1666. X        {
  1667. X            sprintf(s128, "%+-8ld", ltmp);
  1668. X            waddstr(win, s128);
  1669. X            if (log_packets)
  1670. X            {
  1671. X                write(log_packets, "window: ", 8);
  1672. X                write(log_packets, s128, strlen(s128));
  1673. X                write(log_packets, "\n", 1);
  1674. X            }
  1675. X        }
  1676. X    }
  1677. X}                             /* end of report_window */
  1678. X
  1679. X/*+-------------------------------------------------------------------------
  1680. X    report_rx_tx_count()
  1681. X
  1682. X  This function may be counted upon to perform wrefresh(win)
  1683. X
  1684. X  rx char count:          row  6 col 16 len 8 unsigned long
  1685. X  tx char count:          row  6 col 29 len 8 unsigned long
  1686. X  session elapsed time:   row  9 col 21 len 8
  1687. X  this file elapsed time: row  9 col 41 len 8
  1688. X  current tod:            row  9 col  3 len 8
  1689. X  window:                 row  9 col 50 len 8
  1690. X
  1691. XIf FASI,
  1692. X  FE:                     row 14 col  6 len 4
  1693. X  OE:                     row 14 col 13 len 4
  1694. X  rcvd count:             row 14 col 22 len 8 unsigned long
  1695. X  xmtd count:             row 14 col 36 len 8 unsigned long
  1696. X  RTS status:             row 14 col 48 len 1
  1697. X  CTS status:             row 14 col 55 len 1
  1698. X  xmtr CTS count:         row 15 col 18 len 4
  1699. X  xmtr XOFF count:        row 15 col 28 len 4
  1700. X  rcvr CTS count:         row 15 col 42 len 4
  1701. X  rcvr XOFF count:        row 15 col 52 len 4
  1702. X  xmtr queue depth        row 16 col 16 len 5
  1703. X  xmtr queue size         row 16 col 25 len 5 (one time)
  1704. X  rcvr queue depth        row 16 col 37 len 5
  1705. X  rcvr queue size         row 16 col 46 len 5 (one time)
  1706. X
  1707. XIf sun, && !defined (SVR4)
  1708. X  output queue depth      row 14 col 23 len 6
  1709. X  RTS status              row 14 col 35 len 1
  1710. X  CTS status              row 14 col 42 len 1
  1711. X  input queue depth       row 15 col 23 len 6
  1712. X  input queue avail       row 15 col 49 len 6
  1713. X--------------------------------------------------------------------------*/
  1714. Xreport_rx_tx_count()
  1715. X{
  1716. X    extern unsigned long rx_char_count;
  1717. X    extern unsigned long tx_char_count;
  1718. X
  1719. X#if defined(FASI)
  1720. X    unsigned long ltmp;
  1721. X    struct fas_info now;
  1722. X
  1723. X#endif /* FASI */
  1724. X#if defined(sun) && !defined (SVR4)
  1725. X    uint output_queue;
  1726. X    uint input_avail;
  1727. X    uint input_size;
  1728. X    uint modem_lines;
  1729. X
  1730. X#endif
  1731. X
  1732. X    register char *cptr;
  1733. X
  1734. X    if (dumbtty)
  1735. X    {
  1736. X        return;
  1737. X    }
  1738. X
  1739. X    sprintf(s128, "%-8ld", rx_char_count);
  1740. X    wmove(win, 6, 16);
  1741. X    waddstr(win, s128);
  1742. X    sprintf(s128, "%-8ld", tx_char_count);
  1743. X    wmove(win, 6, 29);
  1744. X    waddstr(win, s128);
  1745. X
  1746. X    /* now time of day */
  1747. X    wmove(win, 9, 3);
  1748. X    cptr = get_tod(1, (char *)0);
  1749. X    waddstr(win, cptr);
  1750. X    current_seconds = time((long *)0);
  1751. X    elapsed_seconds = current_seconds - start_seconds;
  1752. X    cptr = get_elapsed_time(elapsed_seconds);
  1753. X    wmove(win, 9, 21);
  1754. X    waddstr(win, cptr);
  1755. X    if (this_file_start_seconds)
  1756. X        elapsed_seconds = current_seconds - this_file_start_seconds;
  1757. X    else
  1758. X        elapsed_seconds = 0;
  1759. X    cptr = get_elapsed_time(elapsed_seconds);
  1760. X    wmove(win, 9, 41);
  1761. X    waddstr(win, cptr);
  1762. X
  1763. X#if defined(FASI)
  1764. X    if (!ioctl(iofd, FASIC_SIP, &now))
  1765. X    {
  1766. X        static int statics = 0;    /* one time display flag */
  1767. X        if ((ltmp = now.framing_errors - fip_start.framing_errors) > 999L)
  1768. X            ltmp = 999L;
  1769. X        sprintf(s128, "%-3lu", ltmp);
  1770. X        wmove(win, 14, 6);
  1771. X        waddstr(win, s128);
  1772. X
  1773. X        if ((ltmp = now.overrun_errors - fip_start.overrun_errors) > 999L)
  1774. X            ltmp = 999L;
  1775. X        sprintf(s128, "%-3lu", ltmp);
  1776. X        wmove(win, 14, 13);
  1777. X        waddstr(win, s128);
  1778. X
  1779. X        ltmp = now.characters_received - fip_start.characters_received;
  1780. X        sprintf(s128, "%-8lu", ltmp);
  1781. X        wmove(win, 14, 22);
  1782. X        waddstr(win, s128);
  1783. X
  1784. X        ltmp = now.characters_transmitted - fip_start.characters_transmitted;
  1785. X        sprintf(s128, "%-8lu", ltmp);
  1786. X        wmove(win, 14, 36);
  1787. X        waddstr(win, s128);
  1788. X
  1789. X        wmove(win, 14, 49);
  1790. X        waddch(win, (now.mcr & MC_SET_RTS) ? 'T' : 'F');
  1791. X
  1792. X        wmove(win, 14, 55);
  1793. X        waddch(win, (now.msr & MS_CTS_PRESENT) ? 'T' : 'F');
  1794. X
  1795. X        ltmp = now.xmtr_hw_flow_count - fip_start.xmtr_hw_flow_count;
  1796. X        if (ltmp > 9999L)
  1797. X            ltmp = 9999L;
  1798. X        sprintf(s128, "%-4lu", ltmp);
  1799. X        wmove(win, 15, 17);
  1800. X        waddstr(win, s128);
  1801. X
  1802. X        ltmp = now.xmtr_sw_flow_count - fip_start.xmtr_sw_flow_count;
  1803. X        if (ltmp > 9999L)
  1804. X            ltmp = 9999L;
  1805. X        sprintf(s128, "%-4lu", ltmp);
  1806. X        wmove(win, 15, 27);
  1807. X        waddstr(win, s128);
  1808. X
  1809. X        ltmp = now.rcvr_hw_flow_count - fip_start.rcvr_hw_flow_count;
  1810. X        if (ltmp > 9999L)
  1811. X            ltmp = 9999L;
  1812. X        sprintf(s128, "%-4lu", ltmp);
  1813. X        wmove(win, 15, 41);
  1814. X        waddstr(win, s128);
  1815. X
  1816. X        ltmp = now.rcvr_sw_flow_count - fip_start.rcvr_sw_flow_count;
  1817. X        if (ltmp > 9999L)
  1818. X            ltmp = 9999L;
  1819. X        sprintf(s128, "%-4lu", ltmp);
  1820. X        wmove(win, 15, 51);
  1821. X        waddstr(win, s128);
  1822. X
  1823. X        if (now.xmit_ring_cnt > 99999)
  1824. X            now.xmit_ring_cnt = 99999;
  1825. X        sprintf(s128, "%-5u", now.xmit_ring_cnt);
  1826. X        wmove(win, 16, 16);
  1827. X        waddstr(win, s128);
  1828. X
  1829. X        if (now.recv_ring_cnt > 99999)
  1830. X            now.recv_ring_cnt = 99999;
  1831. X        sprintf(s128, "%-5u", now.recv_ring_cnt);
  1832. X        wmove(win, 16, 37);
  1833. X        waddstr(win, s128);
  1834. X
  1835. X        if (!statics)
  1836. X        {
  1837. X            statics = 1;
  1838. X            ltmp = XMIT_BUFF_SIZE;
  1839. X            if (ltmp > 99999)
  1840. X                ltmp = 99999;
  1841. X            sprintf(s128, "%-5lu", ltmp);
  1842. X            wmove(win, 16, 25);
  1843. X            waddstr(win, s128);
  1844. X
  1845. X            ltmp = RECV_BUFF_SIZE;
  1846. X            if (ltmp > 99999)
  1847. X                ltmp = 99999;
  1848. X            sprintf(s128, "%-5lu", ltmp);
  1849. X            wmove(win, 16, 46);
  1850. X            waddstr(win, s128);
  1851. X        }
  1852. X    }
  1853. X#endif /* FASI */
  1854. X
  1855. X#if defined(sun) && !defined (SVR4)
  1856. X    output_queue = 0;
  1857. X    ioctl(iofd, TIOCOUTQ, (int *)&output_queue);
  1858. X    if (output_queue > 999999)
  1859. X        output_queue = 999999;
  1860. X    sprintf(s128, "%6u", output_queue);
  1861. X    wmove(win, 14, 23);
  1862. X    waddstr(win, s128);
  1863. X
  1864. X    modem_lines = 0;
  1865. X    ioctl(iofd, TIOCMGET, (int *)&modem_lines);
  1866. X    wmove(win, 14, 35);
  1867. X    waddch(win, (modem_lines & TIOCM_RTS) ? 'T' : 'F');
  1868. X    wmove(win, 14, 42);
  1869. X    waddch(win, (modem_lines & TIOCM_CTS) ? 'T' : 'F');
  1870. X
  1871. X    input_size = 0;
  1872. X    input_avail = 0;
  1873. X    ioctl(iofd, TIOCISPACE, (int *)&input_avail);
  1874. X    ioctl(iofd, TIOCISIZE, (int *)&input_size);
  1875. X    if (input_size > 999999)
  1876. X        input_size = 999999;
  1877. X    if (input_avail > 999999)
  1878. X        input_avail = 999999;
  1879. X    sprintf(s128, "%6u", input_size - input_avail);
  1880. X    wmove(win, 15, 23);
  1881. X    waddstr(win, s128);
  1882. X    sprintf(s128, "%6u", input_avail);
  1883. X    wmove(win, 15, 49);
  1884. X    waddstr(win, s128);
  1885. X#endif
  1886. X
  1887. X    report_window();
  1888. X
  1889. X    wrefresh(win);             /* calling procs expect this to occur always */
  1890. X
  1891. X}                             /* end of report_rx_tx_count */
  1892. X
  1893. X/*+-------------------------------------------------------------------------
  1894. X    report_mode(comm_mode)
  1895. X
  1896. X comm mode row 7 col 52 length 6
  1897. X   3: save old tty stat, set raw mode with flow control
  1898. X   2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
  1899. X   1: save old tty stat, set raw mode
  1900. X   0: restore original tty mode
  1901. X--------------------------------------------------------------------------*/
  1902. Xvoid
  1903. Xreport_mode(comm_mode)
  1904. Xint comm_mode;
  1905. X{
  1906. X    char *cptr;
  1907. X    char tmp[8];
  1908. X
  1909. X    if (dumbtty)
  1910. X    {
  1911. X        return;
  1912. X    }
  1913. X
  1914. X    clear_area(win, 7, 52, 6);
  1915. X    switch (comm_mode)
  1916. X    {
  1917. X        case 0:
  1918. X            cptr = "NORMAL";
  1919. X            break;
  1920. X        case 1:
  1921. X            cptr = "RAW";
  1922. X            break;
  1923. X        case 2:
  1924. X            cptr = "RAW-g";
  1925. X            break;
  1926. X        case 3:
  1927. X            cptr = "RAW-f";
  1928. X            break;
  1929. X        default:
  1930. X            sprintf(tmp, "%5u", comm_mode);
  1931. X            cptr = tmp;
  1932. X    }
  1933. X    waddstr(win, cptr);
  1934. X    wrefresh(win);
  1935. X    if (log_packets)
  1936. X    {
  1937. X        write(log_packets, "comm_mode: ", 6);
  1938. X        write(log_packets, cptr, strlen(cptr));
  1939. X        write(log_packets, "\n", 1);
  1940. X    }
  1941. X
  1942. X}                             /* end of report_mode */
  1943. X
  1944. X/*+-------------------------------------------------------------------------
  1945. X    report_rxblklen(blklen)
  1946. Xrow 7 col 35 5 chars
  1947. X--------------------------------------------------------------------------*/
  1948. Xvoid
  1949. Xreport_rxblklen(blklen)
  1950. Xint blklen;
  1951. X{
  1952. X    char tmp[10];
  1953. X
  1954. X    if (dumbtty)
  1955. X    {
  1956. X        return;
  1957. X    }
  1958. X
  1959. X    sprintf(tmp, "%-5u", blklen);
  1960. X    clear_area(win, 7, 35, 5);
  1961. X    waddstr(win, tmp);
  1962. X    wrefresh(win);
  1963. X}                             /* end of report_rxblklen */
  1964. X
  1965. X/*+-------------------------------------------------------------------------
  1966. X    report_txblklen(blklen)
  1967. Xrow 7 col 35 5 chars
  1968. X--------------------------------------------------------------------------*/
  1969. Xvoid
  1970. Xreport_txblklen(blklen)
  1971. Xint blklen;
  1972. X{
  1973. X    if (dumbtty)
  1974. X    {
  1975. X        return;
  1976. X    }
  1977. X
  1978. X    report_rxblklen(blklen);
  1979. X}                             /* end of report_txblklen */
  1980. X
  1981. X/*+-------------------------------------------------------------------------
  1982. X    report_file_xfer_rate(text,count,final)
  1983. X--------------------------------------------------------------------------*/
  1984. Xvoid
  1985. Xreport_file_xfer_rate(text, count, final)
  1986. Xchar *text;
  1987. Xlong count;
  1988. Xint final;
  1989. X{
  1990. X    float rate = 0.0;
  1991. X    float efficiency = 0.0;
  1992. X    static long last_report = 0L;
  1993. X
  1994. X    current_seconds = time((long *)0);
  1995. X
  1996. X    if (!final && (current_seconds < (last_report + 5L)))
  1997. X        return;
  1998. X    last_report = current_seconds;
  1999. X
  2000. X    elapsed_seconds = current_seconds - this_file_start_seconds;
  2001. X
  2002. X    if (count && (elapsed_seconds > 0) && zcurses_baud_rate)
  2003. X    {
  2004. X        rate = (float)count / (float)elapsed_seconds;
  2005. X        efficiency = 100.0 * (rate / ((float)zcurses_baud_rate / 10.0));
  2006. X    }
  2007. X
  2008. X    if (efficiency > 120.0)     /* interim hack for ecusz -r */
  2009. X        return;
  2010. X
  2011. X    if (rate > 0.01)
  2012. X    {
  2013. X        if (efficiency < 0.5)
  2014. X            sprintf(s128, "XFERINFO %s rate ~= %.0f ch/sec", text, rate);
  2015. X        else
  2016. X        {
  2017. X            sprintf(s128, "XFERINFO %s rate ~= %.0f ch/sec (%.0lf%%)",
  2018. X                text, rate, efficiency);
  2019. X        }
  2020. X        if (!dumbtty)
  2021. X            report_top_line(s128 + 9);
  2022. X#if defined(WHT)
  2023. X        if (final)
  2024. X            ecu_log_event(getppid(), s128);
  2025. X#endif
  2026. X    }
  2027. X
  2028. X}                             /* end of report_file_xfer_rate */
  2029. X
  2030. X/*+-------------------------------------------------------------------------
  2031. X    report_transfer_progress(filepos,initfpos)
  2032. X--------------------------------------------------------------------------*/
  2033. Xvoid
  2034. Xreport_transfer_progress(filepos, initfpos)
  2035. Xlong filepos;
  2036. Xlong initfpos;
  2037. X{
  2038. X    char refr;
  2039. X
  2040. X    if (dumbtty)
  2041. X        return;
  2042. X
  2043. X    if (rdchk(0))
  2044. X    {
  2045. X        read(0, &refr, 1);
  2046. X        if (refr == 0x0C || refr == 0x012)    /* ^L or ^R */
  2047. X        {
  2048. X            touchwin(stdscr);
  2049. X            wrefresh(stdscr);
  2050. X            touchwin(win);
  2051. X            wrefresh(win);
  2052. X        }
  2053. X    }
  2054. X
  2055. X    if ((filepos > 99999999L) || (filepos < 0L))
  2056. X        return;
  2057. X
  2058. X    sprintf(s128, "%-8lu", filepos);
  2059. X    wmove(win, 3, 19);
  2060. X    waddstr(win, s128);
  2061. X    report_file_xfer_rate("data", filepos - initfpos, 0);
  2062. X    report_rx_tx_count();     /* which will do a refresh */
  2063. X
  2064. X}                             /* end of report_transfer_progress */
  2065. X
  2066. X/*+-------------------------------------------------------------------------
  2067. X    report_rxpos(pos) - report received file progress
  2068. X--------------------------------------------------------------------------*/
  2069. Xvoid
  2070. Xreport_rxpos(pos)
  2071. Xlong pos;
  2072. X{
  2073. X
  2074. X    if (dumbtty)
  2075. X        return;
  2076. X    report_transfer_progress(pos, initial_filepos);
  2077. X
  2078. X}                             /* end of report_rxpos */
  2079. X
  2080. X/*+-------------------------------------------------------------------------
  2081. X    report_txpos(pos) - report transmitted file progress
  2082. X--------------------------------------------------------------------------*/
  2083. Xvoid
  2084. Xreport_txpos(pos)
  2085. Xlong pos;
  2086. X{
  2087. X
  2088. X    if (dumbtty)
  2089. X        return;
  2090. X    report_transfer_progress(pos, initial_filepos);
  2091. X
  2092. X}                             /* end of report_txpos */
  2093. X
  2094. X/*+-------------------------------------------------------------------------
  2095. X    report_error_count()
  2096. X
  2097. X  this file: row 10 col 22 len 3
  2098. X  total:     row 10 col 33 len 4
  2099. X  skipped:   row 10 col 53 len 3
  2100. X--------------------------------------------------------------------------*/
  2101. Xvoid
  2102. Xreport_error_count()
  2103. X{
  2104. X    char tmp[16];
  2105. X
  2106. X    if (dumbtty)
  2107. X    {
  2108. X        return;
  2109. X    }
  2110. X
  2111. X    wmove(win, 10, 22);
  2112. X    sprintf(tmp, "%-3d", this_file_errors);
  2113. X    if (this_file_errors)
  2114. X        wstandout(win);
  2115. X    waddstr(win, tmp);
  2116. X    if (this_file_errors)
  2117. X        wstandend(win);
  2118. X
  2119. X    wmove(win, 10, 33);
  2120. X    sprintf(tmp, "%-4d", total_errors);
  2121. X    if (total_errors)
  2122. X        wstandout(win);
  2123. X    waddstr(win, tmp);
  2124. X    if (total_errors)
  2125. X        wstandend(win);
  2126. X
  2127. X    wmove(win, 10, 53);
  2128. X    sprintf(tmp, "%-3d", skip_count);
  2129. X    waddstr(win, tmp);
  2130. X    wrefresh(win);
  2131. X
  2132. X}                             /* end of report_error_count */
  2133. X
  2134. X/*+-------------------------------------------------------------------------
  2135. X    report_last_txhdr(rptstr,error_flag)
  2136. X    5,7,22
  2137. X--------------------------------------------------------------------------*/
  2138. Xvoid
  2139. Xreport_last_txhdr(rptstr, error_flag)
  2140. Xregister char *rptstr;
  2141. Xint error_flag;
  2142. X{
  2143. X    char s24[24];
  2144. X
  2145. X    if (log_packets)
  2146. X    {
  2147. X        write(log_packets, "tx:   ", 6);
  2148. X        write(log_packets, rptstr, strlen(rptstr));
  2149. X        write(log_packets, "\n", 1);
  2150. X    }
  2151. X
  2152. X    if (dumbtty)
  2153. X    {
  2154. X        if (error_flag)
  2155. X        {
  2156. X            dumbtty_newline();
  2157. X            dumbtty_pos = printf("%s ", rptstr);
  2158. X            ++this_file_errors;
  2159. X            ++total_errors;
  2160. X        }
  2161. X        return;
  2162. X    }
  2163. X
  2164. X    if (strlen(rptstr) > 22)
  2165. X    {
  2166. X        strncpy(s24, rptstr, 22);
  2167. X        s24[23] = 0;
  2168. X        rptstr = s24;
  2169. X    }
  2170. X    clear_area(win, 5, 7, 22);
  2171. X    waddstr(win, rptstr);
  2172. X
  2173. X    if (error_flag)
  2174. X    {
  2175. X        ++this_file_errors;
  2176. X        ++total_errors;
  2177. X        report_error_count();
  2178. X    }
  2179. X#if 0
  2180. X    else
  2181. X        wrefresh(win);
  2182. X#endif
  2183. X
  2184. X}                             /* end of report_last_txhdr */
  2185. X
  2186. X/*+-------------------------------------------------------------------------
  2187. X    report_last_rxhdr(rptstr,error_flag)
  2188. X    5,35,22
  2189. X--------------------------------------------------------------------------*/
  2190. Xvoid
  2191. Xreport_last_rxhdr(rptstr, error_flag)
  2192. Xregister char *rptstr;
  2193. Xint error_flag;
  2194. X{
  2195. X    char s24[24];
  2196. X    extern int log_packets;
  2197. X
  2198. X    if (log_packets)
  2199. X    {
  2200. X        write(log_packets, "rx:   ", 6);
  2201. X        write(log_packets, rptstr, strlen(rptstr));
  2202. X        write(log_packets, "\n", 1);
  2203. X    }
  2204. X
  2205. X    if (dumbtty)
  2206. X    {
  2207. X        if (error_flag)
  2208. X        {
  2209. X            dumbtty_newline();
  2210. X            dumbtty_pos = printf("%s ", rptstr);
  2211. X            ++this_file_errors;
  2212. X            ++total_errors;
  2213. X        }
  2214. X        return;
  2215. X    }
  2216. X
  2217. X    if (strlen(rptstr) > 22)
  2218. X    {
  2219. X        strncpy(s24, rptstr, 22);
  2220. X        s24[23] = 0;
  2221. X        rptstr = s24;
  2222. X    }
  2223. X    clear_area(win, 5, 35, 22);
  2224. X    waddstr(win, rptstr);
  2225. X
  2226. X    report_window();
  2227. X    if (error_flag)
  2228. X    {
  2229. X        ++this_file_errors;
  2230. X        ++total_errors;
  2231. X        report_error_count();
  2232. X    }
  2233. X#if 0
  2234. X    else
  2235. X        wrefresh(win);
  2236. X#endif
  2237. X
  2238. X}                             /* end of report_last_rxhdr */
  2239. X
  2240. X/*+-------------------------------------------------------------------------
  2241. X    report_str(rptstr,error_flag) row 11/12 col 3 len 55
  2242. X
  2243. X  error_flag == 0 for status/progress message
  2244. X             == 1 for bump error count, unless rptstr is null
  2245. X                  in which case, merely clear error string area
  2246. X             == 2 write string on bottom line (not an error)
  2247. X             == 3 write string on transaction line (not an error)
  2248. X             == -1 use error line but do not bump error count
  2249. X--------------------------------------------------------------------------*/
  2250. Xvoid
  2251. Xreport_str(rptstr, error_flag)
  2252. Xregister char *rptstr;
  2253. Xint error_flag;
  2254. X{
  2255. X    char s60[60];
  2256. X    extern int log_packets;
  2257. X
  2258. X    if (log_packets)
  2259. X    {
  2260. X        sprintf(s60, "rpt %d:", error_flag);
  2261. X        write(log_packets, s60, strlen(s60));
  2262. X        write(log_packets, rptstr, strlen(rptstr));
  2263. X        write(log_packets, "\n", 1);
  2264. X    }
  2265. X
  2266. X    if (dumbtty)
  2267. X    {
  2268. X        if (!strlen(rptstr))
  2269. X            return;
  2270. X        switch (error_flag)
  2271. X        {
  2272. X            case 0:
  2273. X                break;
  2274. X            case 1:
  2275. X                this_file_errors++;
  2276. X                total_errors++;
  2277. X            case -1:
  2278. X            case 2:
  2279. X            case 3:
  2280. X                dumbtty_newline();
  2281. X                dumbtty_pos = printf("%s ", rptstr);
  2282. X                fflush(stdout);
  2283. X        }
  2284. X        return;
  2285. X    }
  2286. X
  2287. X    if (strlen(rptstr) > 55)
  2288. X    {
  2289. X        strncpy(s60, rptstr, 55);
  2290. X        s60[55] = 0;
  2291. X        rptstr = s60;
  2292. X    }
  2293. X
  2294. X    switch (error_flag)
  2295. X    {
  2296. X        case 0:
  2297. X            clear_area(win, 12, 3, 55);
  2298. X            break;
  2299. X        case 1:
  2300. X            this_file_errors++;
  2301. X            total_errors++;
  2302. X            report_error_count();
  2303. X        case -1:
  2304. X            clear_area(win, 11, 3, 55);
  2305. X            break;
  2306. X        case 2:
  2307. X            clear_area(win, 13, 3, 55);
  2308. X            break;
  2309. X        case 3:
  2310. X            clear_area(win, 4, 3, 55);
  2311. X            break;
  2312. X    }
  2313. X
  2314. X    waddstr(win, rptstr);
  2315. X    wrefresh(win);
  2316. X
  2317. X}                             /* end of report_str */
  2318. X
  2319. X/*+-------------------------------------------------------------------------
  2320. X    report_transaction()
  2321. X--------------------------------------------------------------------------*/
  2322. Xvoid
  2323. Xreport_transaction(str)
  2324. Xchar *str;
  2325. X{
  2326. X    report_str(str, 3);
  2327. X}                             /* end of report_transaction */
  2328. X
  2329. X/*+-------------------------------------------------------------------------
  2330. X    report_file_open_tod() -- time of start of this file
  2331. X
  2332. X  this file open time: row 8 col 41 length 8
  2333. X--------------------------------------------------------------------------*/
  2334. Xvoid
  2335. Xreport_file_open_tod()
  2336. X{
  2337. X    if (dumbtty)
  2338. X        return;
  2339. X    clear_area(win, 8, 41, 8);
  2340. X    waddstr(win, get_tod(1, (char *)0));
  2341. X    wrefresh(win);
  2342. X}                             /* end of report_file_open_tod */
  2343. X
  2344. X/*+-------------------------------------------------------------------------
  2345. X    report_file_open_mode(file_mode)
  2346. X  mode map: row 4 col 46 len 10
  2347. X--------------------------------------------------------------------------*/
  2348. Xreport_file_open_mode(file_mode)
  2349. Xunsigned short file_mode;
  2350. X{
  2351. X    if (dumbtty)
  2352. X        return;
  2353. X    clear_area(win, 3, 46, 10);
  2354. X    waddstr(win, mode_map(file_mode, (char *)0));
  2355. X    wrefresh(win);
  2356. X}                             /* end of report_file_open_mode */
  2357. X
  2358. X/*+-------------------------------------------------------------------------
  2359. X    report_file_open_length(long_length)
  2360. X  length:   row 3 col 36 len  8
  2361. X--------------------------------------------------------------------------*/
  2362. Xreport_file_open_length(length)
  2363. Xlong length;
  2364. X{
  2365. X    if (dumbtty)
  2366. X        return;
  2367. X    clear_area(win, 3, 36, 8);
  2368. X    if (length <= 0)
  2369. X        waddstr(win, "unknown");
  2370. X    else
  2371. X    {
  2372. X        sprintf(s128, "%-8lu", length);
  2373. X        waddstr(win, s128);
  2374. X    }
  2375. X    wrefresh(win);
  2376. X}                             /* end of report_file_open_length */
  2377. X
  2378. X/*+-------------------------------------------------------------------------
  2379. X    report_file_send_open(filename,filestat)
  2380. X
  2381. X  filename: row 2 col 20 len 38
  2382. X  number:   row 2 col 8 len 3
  2383. X  length:   row 3 col 36 len  8
  2384. X  mode:     row 3 col 46 len 10
  2385. X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
  2386. X--------------------------------------------------------------------------*/
  2387. Xvoid
  2388. Xreport_file_send_open(filename, filestat)
  2389. Xchar *filename;
  2390. Xstruct stat *filestat;
  2391. X{
  2392. X    char s50[50];
  2393. X    register char *cptr = filename;
  2394. X
  2395. X    if (log_packets)
  2396. X    {
  2397. X        write(log_packets, "file: ", 6);
  2398. X        write(log_packets, filename, strlen(filename));
  2399. X        write(log_packets, "\n", 1);
  2400. X    }
  2401. X
  2402. X    this_file_start_seconds = time((long *)0);
  2403. X    this_file_xfer_count = 0;
  2404. X
  2405. X    if (dumbtty)
  2406. X    {
  2407. X        dumbtty_newline();
  2408. X        dumbtty_pos = printf("Sending '%s' ", filename);
  2409. X        fflush(stdout);
  2410. X        return;
  2411. X    }
  2412. X
  2413. X    /* number */
  2414. X    clear_area(win, 2, 8, 3);
  2415. X    sprintf(s50, "%-3d", Filcnt);
  2416. X    waddstr(win, s50);
  2417. X
  2418. X    /* filename */
  2419. X    if (strlen(filename) > 38)
  2420. X    {
  2421. X        strncpy(s50, filename, 38);
  2422. X        s50[39] = 0;
  2423. X        cptr = s50;
  2424. X    }
  2425. X    clear_area(win, 2, 20, 38);
  2426. X    waddstr(win, cptr);
  2427. X
  2428. X    /* length */
  2429. X    report_file_open_length(filestat->st_size);
  2430. X
  2431. X    /* mode */
  2432. X    report_file_open_mode(filestat->st_mode);
  2433. X
  2434. X    /* time of start of this file */
  2435. X    report_file_open_tod();
  2436. X
  2437. X    this_file_errors = 0;
  2438. X    report_error_count();
  2439. X}                             /* end of report_file_send_open */
  2440. X
  2441. X/*+-------------------------------------------------------------------------
  2442. X    report_file_rcv_started(filename,length,last_mod_time,file_mode)
  2443. X
  2444. X  filenumber: row 2 col  8 len  3
  2445. X              row 2 col 12 len  7 clear "of ###"
  2446. X  filename:   row 2 col 20 len 38
  2447. X--------------------------------------------------------------------------*/
  2448. Xreport_file_rcv_started(filename, length, last_mod_time, file_mode)
  2449. Xchar *filename;
  2450. Xlong length;                 /* if < 0, "UNKNOWN" */
  2451. Xlong last_mod_time;             /* not currently displayed */
  2452. Xunsigned short file_mode;     /* UNIX file modifier or zero */
  2453. X{
  2454. X    register char *cptr;
  2455. X    char s50[50];
  2456. X
  2457. X    if (log_packets)
  2458. X    {
  2459. X        write(log_packets, "file: ", 6);
  2460. X        write(log_packets, filename, strlen(filename));
  2461. X        write(log_packets, "\n", 1);
  2462. X    }
  2463. X
  2464. X    this_file_start_seconds = time((long *)0);
  2465. X    this_file_xfer_count = 0;
  2466. X
  2467. X    if (dumbtty)
  2468. X    {
  2469. X        dumbtty_newline();
  2470. X        dumbtty_pos = printf("Receiving '%s' ", filename) - 2;
  2471. X        fflush(stdout);
  2472. X        return;
  2473. X    }
  2474. X
  2475. X    /* filename */
  2476. X    if (strlen(filename) > 38)
  2477. X    {
  2478. X        strncpy(s50, filename, 38);
  2479. X        s50[39] = 0;
  2480. X        cptr = s50;
  2481. X    }
  2482. X    else
  2483. X        cptr = filename;
  2484. X
  2485. X    clear_area(win, 2, 20, 38);
  2486. X    waddstr(win, cptr);
  2487. X
  2488. X    /* file number */
  2489. X    clear_area(win, 2, 8, 3);
  2490. X    Filcnt++;
  2491. X    sprintf(s50, "%-3d", Filcnt);    /* rz uses as file number 1-n */
  2492. X    waddstr(win, s50);
  2493. X
  2494. X/* if remote sender provides a file count, display it */
  2495. X    if (npats)
  2496. X    {
  2497. X        clear_area(win, 2, 12, 7);    /* clear "of ###" */
  2498. X        sprintf(s50, "of %3d:", npats);
  2499. X        waddstr(win, s50);
  2500. X    }
  2501. X
  2502. X    /* length */
  2503. X    report_file_open_length(length);
  2504. X
  2505. X    /* mode */
  2506. X    report_file_open_mode(file_mode);
  2507. X
  2508. X    /* time of start of this file */
  2509. X    report_file_open_tod();
  2510. X
  2511. X    this_file_errors = 0;
  2512. X    report_error_count();
  2513. X}                             /* end of report_file_rcv_started */
  2514. X
  2515. X/*+-------------------------------------------------------------------------
  2516. X    report_file_close(skipped)
  2517. X--------------------------------------------------------------------------*/
  2518. Xvoid
  2519. Xreport_file_close(skipped)
  2520. Xint skipped;
  2521. X{
  2522. X    if (dumbtty)
  2523. X    {
  2524. X        dumbtty_newline();
  2525. X        dumbtty_pos +=
  2526. X            printf("Transfer time was %s", get_elapsed_time(elapsed_seconds));
  2527. X        dumbtty_newline();
  2528. X        if (s128[0])
  2529. X        {
  2530. X            dumbtty_pos += strlen(s128 + 9);
  2531. X            fputs(s128 + 9, stdout);
  2532. X            dumbtty_newline();
  2533. X        }
  2534. X        if (this_file_errors)
  2535. X        {
  2536. X            dumbtty_pos +=
  2537. X                printf("Errors for this file were %d", this_file_errors);
  2538. X            dumbtty_newline();
  2539. X        }
  2540. X        return;
  2541. X    }
  2542. X
  2543. X    if (show_window)
  2544. X    {
  2545. X        clear_area(win, 9, 50, 8);
  2546. X        waddstr(win, "+0");
  2547. X        Txpos = 0;
  2548. X        Rxpos = 0;
  2549. X    }
  2550. X
  2551. X    report_str("End of file", 0);
  2552. X    if (!skipped)
  2553. X    {
  2554. X        report_file_xfer_rate("last file",
  2555. X            this_file_xfer_count - initial_filepos, 1);
  2556. X    }
  2557. X    wrefresh(win);
  2558. X    this_file_start_seconds = 0;
  2559. X
  2560. X}                             /* end of report_file_close */
  2561. X
  2562. X/*+-------------------------------------------------------------------------
  2563. X    report_comm_baud_rate(baud_rate)
  2564. X
  2565. X baud rate: row 7 col 14 length 5
  2566. X--------------------------------------------------------------------------*/
  2567. Xreport_comm_baud_rate(baud_rate)
  2568. Xunsigned int baud_rate;
  2569. X{
  2570. X    char tstr8[8];
  2571. X
  2572. X    zcurses_baud_rate = baud_rate;
  2573. X
  2574. X    if (dumbtty)
  2575. X    {
  2576. X        return;
  2577. X    }
  2578. X
  2579. X    clear_area(win, 7, 14, 5);
  2580. X    if (baud_rate == 0)
  2581. X        waddstr(win, "?");
  2582. X    else
  2583. X    {
  2584. X        sprintf(tstr8, "%-5u", baud_rate);
  2585. X        waddstr(win, tstr8);
  2586. X    }
  2587. X    wrefresh(win);
  2588. X
  2589. X}                             /* end of report_comm_baud_rate */
  2590. X
  2591. X/*+-------------------------------------------------------------------------
  2592. X    report_file_byte_io(count)
  2593. X--------------------------------------------------------------------------*/
  2594. Xreport_file_byte_io(count)
  2595. Xlong count;
  2596. X{
  2597. X
  2598. X    this_file_xfer_count = count;
  2599. X    total_data_bytes_xfered += count;
  2600. X
  2601. X    if (dumbtty)
  2602. X    {
  2603. X        if (count)
  2604. X        {
  2605. X            dumbtty_newline();
  2606. X            printf("Transferred %ld bytes for this file\n", count);
  2607. X            dumbtty_newline();
  2608. X        }
  2609. X        return;
  2610. X    }
  2611. X
  2612. X    if (total_data_bytes_xfered)
  2613. X    {
  2614. X        sprintf(s128, "Total file bytes transferred: %ld",
  2615. X            total_data_bytes_xfered);
  2616. X        report_str(s128, -1);
  2617. X    }
  2618. X
  2619. X}                             /* end of report_file_byte_io */
  2620. X
  2621. X/* end of zcurses.c */
  2622. X/* vi: set tabstop=4 shiftwidth=4: */
  2623. END_OF_FILE
  2624.   if test 44210 -ne `wc -c <'ecu330/z/zcurses.c'`; then
  2625.     echo shar: \"'ecu330/z/zcurses.c'\" unpacked with wrong size!
  2626.   fi
  2627.   # end of 'ecu330/z/zcurses.c'
  2628. fi
  2629. echo shar: End of archive 6 \(of 37\).
  2630. cp /dev/null ark6isdone
  2631. MISSING=""
  2632. 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
  2633.     if test ! -f ark${I}isdone ; then
  2634.     MISSING="${MISSING} ${I}"
  2635.     fi
  2636. done
  2637. if test "${MISSING}" = "" ; then
  2638.     echo You have unpacked all 37 archives.
  2639.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2640. else
  2641.     echo You still must unpack the following archives:
  2642.     echo "        " ${MISSING}
  2643. fi
  2644. exit 0
  2645. exit 0 # Just in case...
  2646.