home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / ecu / part27 < prev    next >
Encoding:
Text File  |  1992-09-13  |  57.0 KB  |  1,959 lines

  1. Newsgroups: comp.sources.misc
  2. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  3. Subject:  v32i062:  ecu - ECU Asynchronous Communications v3.20, Part27/40
  4. Message-ID: <1992Sep14.144840.22238@sparky.imd.sterling.com>
  5. X-Md4-Signature: 993df7828f781ca49290a84e9186045e
  6. Date: Mon, 14 Sep 1992 14:48:40 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  10. Posting-number: Volume 32, Issue 62
  11. Archive-name: ecu/part27
  12. Environment: SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses
  13. Supersedes: ecu: Volume 21, Issue 53-89
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. #!/bin/sh
  17. # this is ecu320.27 (part 27 of ecu320)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file sea/ecusea.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 27; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping sea/ecusea.c'
  35. else
  36. echo 'x - continuing file sea/ecusea.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'sea/ecusea.c' &&
  38. X    return(0);                          /* exit with bad status */
  39. X}    /* end of send_file */
  40. X
  41. X/*+-------------------------------------------------------------------------
  42. X    set_utime_1980(filename,secs_since_1980)
  43. X--------------------------------------------------------------------------*/
  44. Xvoid
  45. Xset_utime_1980(filename,secs_since_1980)
  46. Xchar *filename;                        /* file to set stamp on */
  47. Xlong secs_since_1980;
  48. X{
  49. Xtime_t times[2];
  50. Xtime_t time();
  51. X
  52. X    times[0] = time((long *) 0);                /* accessed */
  53. X    times[1] = secs_since_1980 + OFFSET_1980;    /* modified (convert time) */
  54. X    utime(filename,times);
  55. X}    /* end of set_utime_1980 */
  56. X
  57. X/*+-------------------------------------------------------------------------
  58. X    receive_block(buf) - get block from line
  59. Xreturn 0 if good chk/CRC, 1 if bad
  60. X--------------------------------------------------------------------------*/
  61. Xint
  62. Xreceive_block(buf)
  63. Xchar *buf;                /* data buffer */
  64. X{
  65. Xregister unsigned int rdchar;    
  66. Xregister unsigned short rUINT16 = 0;    /* calculated CRC or check value */
  67. Xint itmp;
  68. Xint timeout = no_ack_mode ? 200 : 5;    /* short block timeout */
  69. Xunsigned short rcvd_crc;                /* received CRC or check value */
  70. X
  71. X    itmp = 128;
  72. X    while(itmp--)
  73. X    {
  74. X        if((rdchar = lgetc_timeout(timeout)) == TIMEOUT)
  75. X            return(1);
  76. X        if(crc_in_use)
  77. X            rUINT16 = crc_update(rdchar,rUINT16);
  78. X        else
  79. X            rUINT16 += rdchar;
  80. X        *buf++ = rdchar;
  81. X    }
  82. X
  83. X    if(crc_in_use)
  84. X    {
  85. X        rUINT16 = crc_update(0,rUINT16);
  86. X        rUINT16 = crc_update(0,rUINT16);
  87. X        rdchar = lgetc_timeout(timeout);
  88. X        rcvd_crc = (rdchar << 8) | lgetc_timeout(timeout);
  89. X    }
  90. X    else 
  91. X    {
  92. X        rUINT16 &= 0xFF;
  93. X        rcvd_crc = lgetc_timeout(timeout) & 0xFF;
  94. X    }
  95. X
  96. X    if(rUINT16 != rcvd_crc)
  97. X    {
  98. X        sprintf(s128,"bad %s calc=%04x rcvd=%04x",
  99. X            crc_in_use ? "CRC" : "checksum",rcvd_crc,rUINT16);
  100. X        report_str(s128,-1);
  101. X    }
  102. X    return(rUINT16 != rcvd_crc);
  103. X}    /* end of receive_block */
  104. X
  105. X/*+-------------------------------------------------------------------------
  106. X    receive_file()
  107. X--------------------------------------------------------------------------*/
  108. Xchar *
  109. Xreceive_file()
  110. X{
  111. Xint rdchar;                    /* received character */
  112. Xint tries;                    /* retry counter */
  113. Xint blknum;                    /* desired block number */
  114. Xint inblk;                    /* this block number */
  115. XFILE *fp;
  116. Xchar buf[128];                /* data buffer */
  117. Xchar tmpname[100];            /* name of temporary file */
  118. Xstatic char outname[100];    /* name of final file */
  119. XBLK0 blk0;                    /* file header data storage */
  120. Xint endblk;                    /* block number of EOT, if known */
  121. Xlong left = 0;                /* bytes left to output */
  122. Xint itmp;                    /* index */
  123. Xint cnvrt;                    /* flag -- convert filename? */
  124. Xchar *onp;                    /* use to convert filename to l / rdchar */
  125. Xlong ftell();
  126. X
  127. X    *outname = '\0';        /* get name from transmitter */
  128. X    cnvrt = 1;        /* convert to local is necessary */
  129. X    sprintf(tmpname,"./SEA%05d.tmp",getpid());    /* use a unique temp filename */
  130. X
  131. X    if(!(fp = fopen(tmpname,"w")))
  132. X    {    /* open temporary file */
  133. X        sprintf(s128,"Cannot create temp file %s\n",tmpname);
  134. X        report_str(s128,0);
  135. X        xmit_cancel();
  136. X        return(NULL);
  137. X    }
  138. X
  139. X    blknum = 0;
  140. X    tries = -10;                /* kludge for first time around */
  141. X    crc_in_use = 1;                /* try for CRC error checking */
  142. X    error_count = 0;            /* no errors yet */
  143. X    endblk = 0;                    /* we don't know the size yet */
  144. X    no_ack_mode = 0;            /* we don't know about this yet */
  145. X    memset((char *)&blk0,0,sizeof(blk0));    /* or much of anything else */
  146. X    report_protocol_crc_type("/CRC16");
  147. X
  148. XSEND_NAK:                /* we got a bad block */
  149. X    if(blknum > 1)
  150. X    {
  151. X        error_count++;
  152. X        report_str("bad block",1);
  153. X    }
  154. X    if(++tries > 10)
  155. X        goto CANCEL_TRANSFER;
  156. X    if(tries == 0)            /* if CRC isn't going */
  157. X    {
  158. X        crc_in_use = 0;        /* then give checksum a try */
  159. X        report_protocol_crc_type("/CHK");
  160. X    }
  161. X
  162. X    xmit_nak(blknum);        /* send the NAK */
  163. X    if(no_ack_mode && error_count > 20)
  164. X    {    /* if no_ack_mode mode isn't working */
  165. X        no_ack_mode = 0;        /* then shut it off */
  166. X        report_str("Overdrive disengaged",0);
  167. X    }
  168. X
  169. XRECEIVE_NEXT_BLOCK:                /* start of "get a block" */
  170. X    report_rxpos(ftell(fp));
  171. X    while((rdchar = lgetc_timeout(30)) != TIMEOUT)
  172. X    {
  173. X        if(rdchar == CAN)
  174. X        {
  175. X            if((rdchar = lgetc_timeout(30)) == CAN)
  176. X            {
  177. X                xmit_cancel();
  178. X                return(NULL);
  179. X            }
  180. X            break;
  181. X        }
  182. X        if(rdchar == EOT)
  183. X        {
  184. X            if(!endblk || endblk == blknum)
  185. X                goto RECEIVE_EOT_SEEN;
  186. X        }
  187. X        else if(rdchar == SOH)
  188. X        {
  189. X            if((inblk = lgetc_timeout(5)) == TIMEOUT)
  190. X                goto SEND_NAK;
  191. X            if(lgetc_timeout(5) == (inblk ^ 0xFF))
  192. X            {
  193. X                sprintf(s128,"receiving %d",inblk);
  194. X                report_last_rxhdr(s128,0);
  195. X                goto GOT_START_OF_BLOCK;    /* we found a start */
  196. X            }
  197. X        }
  198. X    }
  199. X    goto SEND_NAK;
  200. X
  201. XGOT_START_OF_BLOCK:                /* start of block detected */
  202. X    rdchar = blknum & 0xFF;
  203. X    if(inblk == 0 && blknum <= 1)
  204. X    {    /* if this is the header */
  205. X        if(receive_block((char *)&blk0))
  206. X            goto SEND_NAK;        /* bad header block */
  207. X        else 
  208. X        {
  209. X            xmit_ack(inblk);    /* ack the header */
  210. X
  211. X#if defined(M_UNIX)
  212. X            if(fname_too_long(blk0.filename))
  213. X            {
  214. X                strcpy(s128,"truncated: ");
  215. X                strncat(s128,blk0.filename,sizeof(s128) - 12);
  216. X                report_str(s128,-1);
  217. X                strcpy(outname,fname_truncated());
  218. X            }
  219. X            else
  220. X#endif
  221. X                strcpy(outname,blk0.filename);
  222. X            report_file_rcv_started(outname,blk0.length,
  223. X                blk0.secs_since_1980 + OFFSET_1980);
  224. X            if(left = blk0.length)    /* length to transfer */
  225. X                endblk=(int)((left + 127L)/128L)+1;
  226. X            if(no_ack_mode != blk0.send_no_acks)
  227. X            {
  228. X                sprintf(s128,"Overdrive %sengaged",
  229. X                    (blk0.send_no_acks) ? "" : "dis");
  230. X                report_str(s128,0);
  231. X            }
  232. X            no_ack_mode = blk0.send_no_acks;
  233. X            blknum = 1;    /* now we want first data block */
  234. X            goto RECEIVE_NEXT_BLOCK;
  235. X        }
  236. X    }
  237. X
  238. X    if(inblk == rdchar)
  239. X    {            /* if this is the one we want */
  240. X        if(!receive_block(buf))
  241. X        {        /* else if we get it okay */
  242. X            if(!no_ack_mode)        /* if we're sending ACKs */
  243. X                xmit_ack(inblk);    /* then ACK the data */
  244. X            for(itmp = 0; itmp < 128; itmp++)
  245. X            {
  246. X                if(endblk)
  247. X                {    /* limit file size if known */
  248. X                    if(!left)
  249. X                        break;
  250. X                    left--;
  251. X                }
  252. X                if(fputc(buf[itmp],fp) == EOF)
  253. X                {
  254. X                    report_str("FILE WRITE ERROR",0);
  255. X                    goto CANCEL_TRANSFER;
  256. X                }
  257. X            }
  258. X            tries = 0;        /* reset try count */
  259. X            blknum++;        /* we want the next block */
  260. X            goto RECEIVE_NEXT_BLOCK;
  261. X        }
  262. X        goto SEND_NAK;        /* ask for a resend */
  263. X    }
  264. X
  265. X    if(inblk < rdchar || inblk > rdchar + 100)
  266. X    {    /* if resending what we have */
  267. X        receive_block(buf);            /* ignore it */
  268. X        xmit_ack(inblk);            /* but ack it */
  269. X    }
  270. X    goto RECEIVE_NEXT_BLOCK;        /* else if running ahead */
  271. X
  272. XRECEIVE_EOT_SEEN:
  273. X#ifdef NAKEOT
  274. X    xmit_nak(blknum);                /* NAK the EOT, make sure */
  275. X    if(lgetc_timeout(20) != EOT)    /* we're all done */
  276. X        goto SEND_NAK;
  277. X#endif /* NAKEOT */
  278. X    xmit_ack(blknum);                /* ACK it and clean up */
  279. X    report_last_rxhdr("EOT",0);
  280. X    if(blknum > 1)
  281. X    {                /* if we really got anything */
  282. X        fclose(fp);
  283. X        unlink(outname);        /* rename temp to proper name */
  284. X        for(onp = outname;cnvrt && *onp;onp++)
  285. X            /* find out if there's lower- */
  286. X            if(islower(*onp))    /* case letters filename */
  287. X                cnvrt = 0;    /*  there are, don't convert */
  288. X        if(cnvrt)            /* if there aren't, make all */
  289. X            for(onp = outname;*onp;onp++)    /* into uppercase */
  290. X                *onp = tolower(*onp);
  291. X        if(link(tmpname,outname) == 0)
  292. X            unlink(tmpname);
  293. X        if(blk0.secs_since_1980)        /* set stamp, if known */
  294. X            set_utime_1980(outname,blk0.secs_since_1980);
  295. X        return(outname);
  296. X    }
  297. X    else 
  298. X    {                /* else no real file */
  299. X        fclose(fp);
  300. X        unlink(tmpname);        /* discard empty file */
  301. X        report_str("end of transfer",0);
  302. X        rf_done = 1;
  303. X        return(NULL);
  304. X    }
  305. X
  306. XCANCEL_TRANSFER:
  307. X    fclose(fp);
  308. X    xmit_cancel();
  309. X    rf_done = 2;
  310. X    return(NULL);
  311. X}    /* end of receive_file */
  312. X
  313. X/*+-------------------------------------------------------------------------
  314. X    cancel_transaction(sig)
  315. X--------------------------------------------------------------------------*/
  316. XSIGTYPE
  317. Xcancel_transaction(sig)
  318. Xint sig;
  319. X{
  320. X    xmit_cancel();
  321. X    sprintf(s128,"signal %d ... exiting",sig);
  322. X    report_str(s128,1);
  323. X/*
  324. X    report_rx_ind(0);
  325. X    report_tx_ind(0);
  326. X*/
  327. X    report_uninit();
  328. X    if(sig == SIGQUIT)
  329. X        abort();
  330. X    exit(128+sig);
  331. X}    /* end of cancel_transaction */
  332. X
  333. X/*+-------------------------------------------------------------------------
  334. X    getspeed(code)
  335. X--------------------------------------------------------------------------*/
  336. Xstruct B_to_baud { unsigned baud; int B_code; };
  337. Xunsigned
  338. Xgetspeed(code)
  339. Xint code;
  340. X{
  341. Xregister itmp;
  342. Xstatic struct B_to_baud speeds[] = 
  343. X{
  344. X 50, B50, 75, B75, 110, B110, 300, B300, 600, B600, 1200, B1200,
  345. X 2400, B2400, 4800, B4800, 9600, B9600, 19200, EXTA, 38400, EXTB, 0
  346. X};
  347. X
  348. X    code &= CBAUD;
  349. X    for(itmp = 0; speeds[itmp].baud; itmp++)
  350. X        if(speeds[itmp].B_code == code)
  351. X            return(speeds[itmp].baud);
  352. X    return(38400);    /* Assume fifo if ioctl failed */
  353. X}    /* end of getspeed */
  354. X
  355. X/*+-------------------------------------------------------------------------
  356. X    main(argc,argv,envp)
  357. X--------------------------------------------------------------------------*/
  358. Xmain(argc,argv,envp)
  359. Xint argc;
  360. Xchar **argv;
  361. Xchar **envp;
  362. X{
  363. Xint ipaths;
  364. Xint ok = 0;
  365. X#define MAX_PATHS 512
  366. Xchar *paths[MAX_PATHS];
  367. Xchar **ppaths = paths;
  368. Xchar *cptr;
  369. Xchar **gargv = argv;
  370. Xint gargc = argc;
  371. X
  372. X    exit_code = 254;
  373. X    while(--argc)
  374. X    {
  375. X        cptr = *++argv;
  376. X        if(*cptr == '-')
  377. X        {
  378. X            cptr++;
  379. X            switch(*cptr++)
  380. X            {
  381. X            case ',':
  382. X                log_packets = 1;
  383. X                break;
  384. X            case '/':
  385. X                if(--argc < 1)
  386. X                    exit(255);
  387. X                strcpy(curr_dir,*++argv);
  388. X                break;
  389. X            case '.':
  390. X                if(--argc < 1)
  391. X                    exit(255);
  392. X                iofd = atoi(*++argv);
  393. X                break;
  394. X            case 'r':
  395. X                sending_flag = 0;
  396. X                break;
  397. X            case 's':
  398. X                sending_flag = 1;
  399. X            }
  400. X        }
  401. X        else if(argc > 0)
  402. X        {
  403. X            if(npaths < MAX_PATHS)
  404. X            {
  405. X                *ppaths++ = cptr;
  406. X                npaths++;
  407. X            }
  408. X            else
  409. X            {
  410. X                printf("too many filenames to send\n");
  411. X                exit(255);
  412. X            }
  413. X        }
  414. X    }
  415. X
  416. X    if(sending_flag == -1)
  417. X    {
  418. X        printf("no -r or -s\n");
  419. X        exit(255);
  420. X    }
  421. X
  422. X    if((npaths < 1) && sending_flag)
  423. X        exit(253);
  424. X
  425. X    if(npaths && !sending_flag)
  426. X        exit(255);
  427. X
  428. X    if(log_packets)
  429. X    {
  430. X        char log_packets_name[64];
  431. X        FILE *ftmp;
  432. X        int iargv;
  433. X        sprintf(log_packets_name,"/tmp/sea%05d.plog",getpid());
  434. X        unlink(log_packets_name);
  435. X        ftmp = fopen(log_packets_name,"w");
  436. X        fclose(ftmp);
  437. X        log_packets = open(log_packets_name,O_WRONLY,0644);
  438. X        if(log_packets < 0)
  439. X            log_packets = 0;
  440. X        else
  441. X        {
  442. X            write(log_packets,"exec: ",6);
  443. X            for(iargv = 0; iargv < gargc; iargv++)
  444. X            {
  445. X                write(log_packets,gargv[iargv],strlen(gargv[iargv]));
  446. X                write(log_packets," ",1);
  447. X            }
  448. X            write(log_packets,"\n",1);
  449. X        }
  450. X    }
  451. X
  452. X    sprintf(s128,"ecusea %s",revision);
  453. X    report_init(s128);
  454. X    report_top_line("System Enhancement Associates");
  455. X    signal(SIGHUP,cancel_transaction);
  456. X    signal(SIGQUIT,cancel_transaction);
  457. X    signal(SIGINT,cancel_transaction);
  458. X    signal(SIGTERM,cancel_transaction);
  459. X#if    defined(SIGSTOP)
  460. X    /*
  461. X     * call Roto-Rooter on POSIX plots
  462. X     */
  463. X    signal(SIGSTOP,SIG_IGN);
  464. X    signal(SIGTSTP,SIG_IGN);
  465. X    signal(SIGCONT,SIG_IGN);
  466. X    signal(SIGTTIN,SIG_IGN);
  467. X    signal(SIGTTOU,SIG_IGN);
  468. X#endif
  469. X
  470. X    ioctl(iofd,TCGETA,&tio0);
  471. X    tio = tio0;
  472. X
  473. X    tio.c_oflag = 0;
  474. X    tio.c_cflag &= ~PARENB;
  475. X    tio.c_cflag &= ~CSIZE;
  476. X    tio.c_cflag |= CS8;
  477. X
  478. X    /*
  479. X     * learn tick rate for various timers
  480. X     */
  481. X    init_Nap();
  482. X
  483. X    baud_rate = getspeed(tio.c_cflag);
  484. X    ioctl(iofd,TCSETA,&tio);
  485. X    report_line(baud_rate,"RAW");
  486. X
  487. X    switch(sending_flag)
  488. X    {
  489. X        case 0:                /* receive files */
  490. X            while(receive_file() != NULL)
  491. X                Nap(1000L);
  492. X            ok = (rf_done == 1);
  493. X            break;
  494. X
  495. X        case 1:                /* send files */
  496. X            ipaths = 0;
  497. X            while(ipaths < npaths)
  498. X            {
  499. X                if(!(ok = send_file(paths[ipaths])))
  500. X                    break;
  501. X                Nap(1000L);
  502. X                ipaths++;
  503. X            }
  504. X            if(ok)        /* no errors, send end marker */
  505. X                send_file("");
  506. X            report_str("end of transfer",0);
  507. X            break;
  508. X    }
  509. X
  510. X    ioctl(iofd,TCSETA,&tio0);
  511. X    report_line(baud_rate,"NORMAL");
  512. X    report_uninit();
  513. X    exit(ok ? 0 : exit_code);    /* and return error status */
  514. X
  515. X}    /* end of main */
  516. X
  517. SHAR_EOF
  518. echo 'File sea/ecusea.c is complete' &&
  519. chmod 0644 sea/ecusea.c ||
  520. echo 'restore of sea/ecusea.c failed'
  521. Wc_c="`wc -c < 'sea/ecusea.c'`"
  522. test 37329 -eq "$Wc_c" ||
  523.     echo 'sea/ecusea.c: original size 37329, current size' "$Wc_c"
  524. rm -f _shar_wnt_.tmp
  525. fi
  526. # ============= sea/scurses.c ==============
  527. if test -f 'sea/scurses.c' -a X"$1" != X"-c"; then
  528.     echo 'x - skipping sea/scurses.c (File already exists)'
  529.     rm -f _shar_wnt_.tmp
  530. else
  531. > _shar_wnt_.tmp
  532. echo 'x - extracting sea/scurses.c (Text)'
  533. sed 's/^X//' << 'SHAR_EOF' > 'sea/scurses.c' &&
  534. X/*+-------------------------------------------------------------------------
  535. X    scurses.c -- ecu file transfer program curses interface
  536. X
  537. X  000000000011111111112222222222333333333344444444445555555550
  538. X  012345678901234567890123456789012345678901234567890123456789
  539. X00.----------------------------------------------------------.
  540. X01|  SEAlink_6____  _39____________________________________  |
  541. X02|  File ### of ###: _38__________________________________  |
  542. X03|  File position:  _8______ length: _8______               |
  543. X04|  _55____________________________________________________ | transaction
  544. X05|  _55____________________________________________________ | last rx/tx hdr
  545. X06|  Comm I/O: rx _8______  tx _8______ bytes                |
  546. X07|  Baud rate: _5___ BINARY blklen: _____ comm mode: CBREAK |
  547. X08|  Time started: session: HH:MM:SS  this file: HH:MM:SS    |
  548. X09|                elpased: HH:MM:SS       time: HH:MM:SS    |
  549. X10|  Error counts: this file:  _4__  total: _6____           |
  550. X11|  _55____________________________________________________ |  err str
  551. X12|  _55____________________________________________________ |  comment str
  552. X13|  _55____________________________________________________ |  remote info
  553. X14`----------------------------------------------------------'
  554. X
  555. X  Defined functions:
  556. X    clear_area(w,row,col,len)
  557. X    clear_area_char(w,row,col,len,fillchar)
  558. X    get_elapsed_time(elapsed_secs)
  559. X    hhmmss(tod)
  560. X    report_error_count()
  561. X    report_file_byte_io(count)
  562. X    report_file_close()
  563. X    report_file_open_length(length)
  564. X    report_file_open_tod()
  565. X    report_file_rcv_started(filename,length,last_mod_time)
  566. X    report_file_send_open(filename,filestat)
  567. X    report_init(title)
  568. X    report_last_rxhdr(rptstr,error_flag)
  569. X    report_last_txhdr(rptstr,error_flag)
  570. X    report_line(baud_rate,mode)
  571. X    report_protocol_crc_type(str)
  572. X    report_rx_ind(status)
  573. X    report_rx_tx_count()
  574. X    report_rxpos(pos)
  575. X    report_str(rptstr,error_flag)
  576. X    report_top_line(topstr)
  577. X    report_transaction(str)
  578. X    report_tx_ind(status)
  579. X    report_txpos(pos)
  580. X    report_uninit()
  581. X    vanilla_ruling()
  582. X
  583. X------------------------------------------------------------------------*/
  584. X/*+:EDITS:*/
  585. X/*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
  586. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  587. X/*:04-24-1992-21:15-wht@n4hgf-sort out vannilla vs. at ruling */
  588. X/*:02-09-1992-16:08-root@n4hgf-ruling characters only on  SCO (tcap curses) */
  589. X/*:08-28-1991-14:08-wht@n4hgf2-SVR4 cleanup by aega84!lh */
  590. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  591. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  592. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  593. X
  594. X#include "../ecucurses.h"
  595. X#include "../ecu_types.h"
  596. X#include "../ecu_stat.h"
  597. X#include <ctype.h>
  598. X#include <signal.h>
  599. X#include <time.h>
  600. X#include <sys/timeb.h>
  601. X
  602. X#if defined(M_SYSV)
  603. X#   include <sys/machdep.h>
  604. X#else
  605. X#if defined(ISC) || defined(SVR4)
  606. X#  include <sys/at_ansi.h>
  607. X#  include <sys/kd.h>
  608. X#endif
  609. X#endif
  610. X
  611. X#include "../pc_scr.h"
  612. X
  613. X#ifdef USE_PROTOS
  614. X# include "protos.h"
  615. X#endif
  616. X
  617. Xlong time();
  618. Xextern char *tzname[];
  619. Xstruct tm *localtime();
  620. X
  621. X#define WIN_LINES    15
  622. X#define WIN_COLS    60
  623. X#define WIN_TOPY    2
  624. X#define WIN_LEFTX    8
  625. X
  626. Xextern char curr_dir[];
  627. Xextern char s128[];
  628. Xextern int Filcnt;
  629. Xextern int Restricted;
  630. Xextern int sending_flag;    /* send == 1, receive == 0 */
  631. Xextern int npaths;
  632. Xextern long rxpos;
  633. Xextern int log_packets;
  634. X
  635. XWINDOW    *win;
  636. Xint (*original_sigint_handler)();
  637. Xint (*original_sigquit_handler)();
  638. Xint (*original_sigterm_handler)();
  639. Xint curses_installed = 0;        /* curses not yet active */
  640. Xint this_file_errors = 0;
  641. Xint total_errors = 0;
  642. Xlong current_seconds;
  643. Xlong start_seconds;
  644. Xlong elapsed_seconds;
  645. Xunsigned long total_data_chars_xfered = 0L;
  646. X
  647. Xunsigned char sTL = at_TL;
  648. Xunsigned char sTR = at_TR;
  649. Xunsigned char sBL = at_BL;
  650. Xunsigned char sBR = at_BR;
  651. Xunsigned char sLT = at_LT;
  652. Xunsigned char sRT = at_RT;
  653. Xunsigned char sVR = at_VR;
  654. Xunsigned char sHR = at_HR;
  655. X
  656. Xchar *win_template[] =
  657. X{
  658. X/*00000000001111111111222222222233333333334444444444555555555 */
  659. X/*01234567890123456789012345678901234567890123456789012345678 */
  660. X/*.----------------------------------------------------------. */
  661. X  "  SEAlink                                                 ",    /* 1 */
  662. X  "  File ### of ###: _____________________________________  ",    /* 2 */
  663. X  "  File position:  ________ length: ________               ",    /* 3 */
  664. X  "                                                          ",    /* 4 */
  665. X  "  tx: ______________________  rx: ______________________  ",    /* 5 */
  666. X  "  Comm I/O: rx ________  tx ________ bytes                ",    /* 6 */
  667. X  "  Baud rate: _____ BINARY blklen: 128   comm mode: ______ ",    /* 7 */
  668. X  "  Time started: session: --:--:--  this file: --:--:--    ",    /* 8 */
  669. X  "                elapsed: --:--:--    current: --:--:--    ",    /* 9 */
  670. X  "  Error counts: this file:  ____  total: ______           ",    /* 10 */
  671. X  "                                                          ",    /* 11 */
  672. X  "                                                          ",    /* 12 */
  673. X  "                                                          ",    /* 13 */
  674. X/*`----------------------------------------------------------' */
  675. X(char *)0
  676. X};
  677. X
  678. X/*+-------------------------------------------------------------------------
  679. X    vanilla_ruling() - use ordinary ruling characters
  680. X--------------------------------------------------------------------------*/
  681. Xvoid
  682. Xvanilla_ruling()
  683. X{
  684. X    sTL = vanilla_TL;
  685. X    sTR = vanilla_TR;
  686. X    sBL = vanilla_BL;
  687. X    sBR = vanilla_BR;
  688. X    sLT = vanilla_LT;
  689. X    sRT = vanilla_RT;
  690. X    sVR = vanilla_VR;
  691. X    sHR = vanilla_HR;
  692. X
  693. X}    /* end of vanilla_ruling */
  694. X
  695. X/*+-----------------------------------------------------------------------
  696. X    char *get_elapsed_time(elapsed_secs)
  697. X    hh:mm:ss returned
  698. X  static string address is returned
  699. X------------------------------------------------------------------------*/
  700. Xchar *get_elapsed_time(elapsed_secs)
  701. Xlong elapsed_secs;
  702. X{
  703. X    static char elapsed_time_str[10];
  704. X    long hh,mm,ss;
  705. X
  706. X    hh = elapsed_secs / 3600;
  707. X    elapsed_secs -= hh * 3600;
  708. X    mm = elapsed_secs / 60L;
  709. X    elapsed_secs -= mm * 60L;
  710. X    ss = elapsed_secs;
  711. X
  712. X    sprintf(elapsed_time_str,"%02ld:%02ld:%02ld",hh,mm,ss);
  713. X    return(elapsed_time_str);
  714. X}    /* end of get_elapsed_time */
  715. X
  716. X/*+-----------------------------------------------------------------------
  717. X    char *hhmmss(tod) - get time of day in form "hh:mm:ss"
  718. X
  719. X  static string address is returned
  720. X  if tod != (char *)0, time is returned there too
  721. X------------------------------------------------------------------------*/
  722. Xchar *
  723. Xhhmmss(tod)
  724. Xchar *tod;
  725. X{
  726. X    long cur_time = 0;
  727. X    struct tm *lt;            /* local time */
  728. X    static char tod_str[32];
  729. X
  730. X    cur_time = time((long *)0);
  731. X    lt = localtime(&cur_time);
  732. X
  733. X    sprintf(tod_str,"%02d:%02d:%02d",lt->tm_hour,lt->tm_min,lt->tm_sec);
  734. X
  735. X    if(tod != (char *)0)
  736. X        strcpy(tod,tod_str);
  737. X
  738. X    return(tod_str);
  739. X
  740. X}    /* end of hhmmss */
  741. X
  742. X/*+-------------------------------------------------------------------------
  743. X    clear_area(w,row,col,len)
  744. X--------------------------------------------------------------------------*/
  745. Xclear_area(w,row,col,len)
  746. XWINDOW    *w;
  747. Xint row;
  748. Xint col;
  749. Xint len;
  750. X{
  751. X    wmove(w,row,col);
  752. X    while(len-- > 0)
  753. X        waddch(w,' ');
  754. X    wmove(w,row,col);
  755. X
  756. X}    /* end of clear_area */
  757. X
  758. X/*+-------------------------------------------------------------------------
  759. X    clear_area_char(w,row,col,len,fillchar)
  760. X--------------------------------------------------------------------------*/
  761. Xclear_area_char(w,row,col,len,fillchar)
  762. XWINDOW    *w;
  763. Xint row;
  764. Xint col;
  765. Xint len;
  766. Xchar fillchar;
  767. X{
  768. X    wmove(w,row,col);
  769. X    while(len-- > 0)
  770. X        waddch(w,fillchar);
  771. X    wmove(w,row,col);
  772. X
  773. X}    /* end of clear_area_char */
  774. X
  775. X/*+-------------------------------------------------------------------------
  776. X    report_top_line(topstr)
  777. X   top line: row 1 col 18 length 39
  778. X--------------------------------------------------------------------------*/
  779. Xvoid
  780. Xreport_top_line(topstr)
  781. Xchar *topstr;
  782. X{
  783. Xchar s42[42];
  784. X    clear_area(win,1,18,39);
  785. X    if(strlen(topstr) < 39)
  786. X        waddstr(win,topstr);
  787. X    else
  788. X    {
  789. X        strncpy(s42,topstr,39);
  790. X        s42[39] = 0;
  791. X        waddstr(win,s42);
  792. X    }
  793. X}    /* end of report_top_line */
  794. X
  795. X/*+-------------------------------------------------------------------------
  796. X    report_protocol_crc_type(str)
  797. X
  798. X  protocol crc type:  row 1 col 10 length 6
  799. X--------------------------------------------------------------------------*/
  800. Xreport_protocol_crc_type(str)
  801. Xregister char *str;
  802. X{
  803. Xchar s8[8];
  804. X
  805. X    if(strlen(str) > 6)
  806. X    {
  807. X        strncpy(s8,str,6);
  808. X        s8[6] = 0;
  809. X        str = s8;
  810. X    }
  811. X    clear_area(win,1,10,6);
  812. X    waddstr(win,str);
  813. X    wrefresh(win);
  814. X    if(log_packets)
  815. X    {
  816. X        write(log_packets,"chk:  ",6);
  817. X        write(log_packets,str,strlen(str));
  818. X        write(log_packets,"\n",1);
  819. X    }
  820. X
  821. X}    /* end of report_protocol_crc_type */
  822. X
  823. X/*+-------------------------------------------------------------------------
  824. X    report_error_count()
  825. X    DOES NOT PERFORM A REFRESH CYCLE
  826. X  this file: row 10 col 29 len 4
  827. X  total:     row 10 col 42 len 6
  828. X--------------------------------------------------------------------------*/
  829. Xvoid
  830. Xreport_error_count()
  831. X{
  832. X    char tmp[16];
  833. X
  834. X    clear_area(win,10,29,4);
  835. X    sprintf(tmp,"%4d",this_file_errors);
  836. X    waddstr(win,tmp);
  837. X
  838. X    clear_area(win,10,42,6);
  839. X    sprintf(tmp,"%6d",total_errors);
  840. X    waddstr(win,tmp);
  841. X    wrefresh(win);
  842. X
  843. X}    /* end of report_error_count */
  844. X
  845. X/*+-------------------------------------------------------------------------
  846. X    report_uninit()
  847. X--------------------------------------------------------------------------*/
  848. Xvoid
  849. Xreport_uninit()
  850. X{
  851. Xfloat total = (float)total_data_chars_xfered;
  852. X
  853. X    if(curses_installed)
  854. X    {
  855. X        if((total_data_chars_xfered != 0L) && (elapsed_seconds != 0L))
  856. X        {
  857. X            sprintf(s128,"Data xfer rate ~= %6.0f chars/sec",
  858. X                total / (float)elapsed_seconds);
  859. X            if(log_packets)
  860. X            {
  861. X                write(log_packets,"info: ",6);
  862. X                write(log_packets,s128,strlen(s128));
  863. X                write(log_packets,"\n",1);
  864. X            }
  865. X            report_top_line(s128);
  866. X        }
  867. X        report_file_byte_io(0L);
  868. X        report_rx_tx_count();
  869. X        wmove(win,WIN_LINES - 1,WIN_COLS - 1);
  870. X        wrefresh(win);
  871. X        endwin();
  872. X        fprintf(stderr,"\r\n\r\n\r\n");
  873. X        fflush(stderr);
  874. X        curses_installed = 0;
  875. X    }
  876. X
  877. X}    /* end of report_uninit */
  878. X
  879. X/*+-------------------------------------------------------------------------
  880. X    report_init(title)
  881. X--------------------------------------------------------------------------*/
  882. Xvoid
  883. Xreport_init(title)
  884. Xchar *title;
  885. X{
  886. Xregister int itmp;
  887. X#if defined(CONS_GET)
  888. Xint monitor_type;
  889. X#endif
  890. X
  891. X    if(curses_installed)
  892. X        return;
  893. X
  894. X#if defined(M_SYSV)
  895. X    if(ioctl(0,CONS_GET,&monitor_type) < 0)    /* not multiscreen */
  896. X#ifdef M_SYSV    /* SCO non AT console */
  897. X        vanilla_ruling();
  898. X#endif
  899. X#else
  900. X    vanilla_ruling();
  901. X#endif
  902. X
  903. X    initscr();
  904. X    crmode();
  905. X    noecho();
  906. X    nonl();
  907. X    clear();
  908. X    curses_installed = 1;
  909. X    win = newwin(WIN_LINES,WIN_COLS,WIN_TOPY,WIN_LEFTX);
  910. X    box(win,sVR,sHR);
  911. X#ifndef SVR4
  912. X    wmove(win,0,0); waddch(win,sTL);
  913. X    wmove(win,win->_maxy - 1,0); waddch(win,sBL);
  914. X    wmove(win,win->_maxy - 1,win->_maxx - 1); waddch(win,sBR);
  915. X    wmove(win,0,win->_maxx - 1); waddch(win,sTR);
  916. X#endif
  917. X    wmove(win,0,2);
  918. X    wstandout(win);
  919. X    waddch(win,'[');
  920. X    waddch(win,' ');
  921. X    waddstr(win,title);
  922. X    waddch(win,' ');
  923. X    waddch(win,']');
  924. X    wstandend(win);
  925. X#ifdef SVR4
  926. X    whline(win, (unsigned long)(sHR & 0x00ff), 2);
  927. X    wmove(win,0, 8 + strlen(title));
  928. X#else
  929. X    waddch(win,sHR);
  930. X    waddch(win,sHR);
  931. X#endif
  932. X    waddstr(win," dir: ");
  933. X    waddstr(win,curr_dir);
  934. X    waddch(win,' ');
  935. X
  936. X    itmp = 0;
  937. X    while(1)
  938. X    {
  939. X        if(win_template[itmp] == (char *)0)
  940. X            break;
  941. X        wmove(win,itmp + 1,1);
  942. X        waddstr(win,win_template[itmp++]);
  943. X    }
  944. X    if(sending_flag)
  945. X    {
  946. X        clear_area(win,2,15,3);
  947. X        sprintf(s128,"%3d",npaths);
  948. X        waddstr(win,s128);
  949. X    }
  950. X    else    /* ecurz */
  951. X    {
  952. X        clear_area(win,2,11,8);    /* clear "of ###" */
  953. X        waddstr(win,":");
  954. X    }
  955. X
  956. X    clear_area(win,1,11,47);
  957. X    report_error_count();
  958. X    clear_area(win,8,26,8);        /* starting time */
  959. X    waddstr(win,hhmmss((char *)0));
  960. X    start_seconds = time((long *)0);
  961. X    current_seconds = start_seconds;
  962. X
  963. X    wrefresh(win);
  964. X
  965. X}    /* end of report_init */
  966. X
  967. X/*+-------------------------------------------------------------------------
  968. X    report_rx_ind(status)
  969. X--------------------------------------------------------------------------*/
  970. Xvoid
  971. Xreport_rx_ind(status)
  972. Xint status;
  973. X{
  974. X    wmove(win,1,54);
  975. X    waddch(win,(status) ? 'R' : ' ');
  976. X    wmove(win,1,54);
  977. X    wrefresh(win);
  978. X}    /* end of report_rx_ind */
  979. X
  980. X/*+-------------------------------------------------------------------------
  981. X    report_tx_ind(status)
  982. X--------------------------------------------------------------------------*/
  983. Xvoid
  984. Xreport_tx_ind(status)
  985. Xint status;
  986. X{
  987. X    wmove(win,1,56);
  988. X    waddch(win,(status) ? 'T' : ' ');
  989. X    wmove(win,1,56);
  990. X    wrefresh(win);
  991. X}    /* end of report_tx_ind */
  992. X
  993. X/*+-------------------------------------------------------------------------
  994. X    report_rx_tx_count()
  995. X
  996. X  rx char count: row 6 col 16 length 8 unsigned long
  997. X  tx char count: row 6 col 29 length 8 unsigned long
  998. X  now time of day: row 1 col 50 length 8 hh:mm:ss
  999. X  This procedure may be counted upon to perform wrefresh(win)
  1000. X
  1001. Xelapsed time row 9 col 26 length 8
  1002. Xcurrent tod row 9 col 47 length 8
  1003. X--------------------------------------------------------------------------*/
  1004. Xreport_rx_tx_count()
  1005. X{
  1006. X    extern unsigned long rx_char_count;
  1007. X    extern unsigned long tx_char_count;
  1008. X
  1009. X    register char *cptr;
  1010. X
  1011. X    sprintf(s128,"%8ld",rx_char_count);
  1012. X    wmove(win,6,16);
  1013. X    waddstr(win,s128);
  1014. X    sprintf(s128,"%8ld",tx_char_count);
  1015. X    wmove(win,6,29);
  1016. X    waddstr(win,s128);
  1017. X
  1018. X    /* now time of day */
  1019. X    clear_area(win,9,47,8);
  1020. X    cptr = hhmmss((char *)0);
  1021. X    waddstr(win,cptr);
  1022. X    current_seconds = time((long *)0);
  1023. X    elapsed_seconds = current_seconds - start_seconds;
  1024. X    cptr = get_elapsed_time(elapsed_seconds);
  1025. X    clear_area(win,9,26,8);
  1026. X    waddstr(win,cptr);
  1027. X    wrefresh(win);        /* calling procs expect this to occur always */
  1028. X
  1029. X}    /* end of report_rx_tx_count */
  1030. X
  1031. X/*+-------------------------------------------------------------------------
  1032. X    report_line(baud_rate,mode)
  1033. X--------------------------------------------------------------------------*/
  1034. Xvoid
  1035. Xreport_line(baud_rate,mode)
  1036. Xunsigned baud_rate;
  1037. Xchar *mode;
  1038. X{
  1039. Xchar s16[16];
  1040. X    wmove(win,7,14);
  1041. X    sprintf(s16,"%5u",baud_rate);
  1042. X    waddstr(win,s16);
  1043. X    clear_area(win,7,52,6);
  1044. X    waddstr(win,mode);
  1045. X    wrefresh(win);
  1046. X}    /* end of report_line */
  1047. X
  1048. X/*+-------------------------------------------------------------------------
  1049. X    report_rxpos(pos) row 3 col 19 len 8
  1050. X--------------------------------------------------------------------------*/
  1051. Xvoid
  1052. Xreport_rxpos(pos)
  1053. Xlong pos;
  1054. X{
  1055. Xchar tmp[16];
  1056. Xchar refr;
  1057. X
  1058. X    if(rdchk(0))
  1059. X    {
  1060. X        read(0,&refr,1);
  1061. X        if(refr == 0x0C || refr == 0x012)    /* ^L or ^R */
  1062. X        {
  1063. X            write(2,"\033[2J",4);
  1064. X            Nap((long)60);
  1065. X            touchwin(stdscr);
  1066. X            wrefresh(stdscr);
  1067. X            touchwin(win);
  1068. X            wrefresh(win);
  1069. X        }
  1070. X    }
  1071. X
  1072. X    if((pos > 99999999L) || (pos < 0L))
  1073. X        return;
  1074. X
  1075. X    sprintf(tmp,"%8lu",pos);
  1076. X    wmove(win,3,19);
  1077. X    waddstr(win,tmp);
  1078. X    wrefresh(win);
  1079. X    report_rx_tx_count();    /* which will do a refresh */
  1080. X}    /* end of report_rxpos */
  1081. X
  1082. X/*+-------------------------------------------------------------------------
  1083. X    report_txpos(pos)
  1084. X--------------------------------------------------------------------------*/
  1085. Xvoid
  1086. Xreport_txpos(pos)
  1087. Xlong pos;
  1088. X{
  1089. X    report_rxpos(pos);
  1090. X}    /* end of report_txpos */
  1091. X
  1092. X/*+-------------------------------------------------------------------------
  1093. X    report_last_txhdr(rptstr,error_flag)
  1094. X    5,7,22
  1095. X--------------------------------------------------------------------------*/
  1096. Xvoid
  1097. Xreport_last_txhdr(rptstr,error_flag)
  1098. Xregister char *rptstr;
  1099. Xint error_flag;
  1100. X{
  1101. Xchar s24[24];
  1102. X
  1103. X    if(log_packets)
  1104. X    {
  1105. X        write(log_packets,"tx:   ",6);
  1106. X        write(log_packets,rptstr,strlen(rptstr));
  1107. X        write(log_packets,"\n",1);
  1108. X    }
  1109. X
  1110. X    if(strlen(rptstr) > 22)
  1111. X    {
  1112. X        strncpy(s24,rptstr,22);
  1113. X        s24[23] = 0;
  1114. X        rptstr = s24;
  1115. X    }
  1116. X    clear_area(win,5,7,22);
  1117. X    waddstr(win,rptstr);
  1118. X    wrefresh(win);
  1119. X
  1120. X    if(error_flag)
  1121. X    {
  1122. X        ++this_file_errors;
  1123. X        ++total_errors;
  1124. X        report_error_count();
  1125. X    }
  1126. X}    /* end of report_last_txhdr */
  1127. X
  1128. X/*+-------------------------------------------------------------------------
  1129. X    report_last_rxhdr(rptstr,error_flag)
  1130. X    5,35,22
  1131. X--------------------------------------------------------------------------*/
  1132. Xvoid
  1133. Xreport_last_rxhdr(rptstr,error_flag)
  1134. Xregister char *rptstr;
  1135. Xint error_flag;
  1136. X{
  1137. Xchar s24[24];
  1138. Xextern int log_packets;
  1139. X
  1140. X    if(log_packets)
  1141. X    {
  1142. X        write(log_packets,"rx: ",4);
  1143. X        write(log_packets,(error_flag) ? "E " : "  ",2);
  1144. X        write(log_packets,rptstr,strlen(rptstr));
  1145. X        write(log_packets,"\n",1);
  1146. X    }
  1147. X
  1148. X    if(strlen(rptstr) > 22)
  1149. X    {
  1150. X        strncpy(s24,rptstr,22);
  1151. X        s24[23] = 0;
  1152. X        rptstr = s24;
  1153. X    }
  1154. X    clear_area(win,5,35,22);
  1155. X    waddstr(win,rptstr);
  1156. X    wrefresh(win);
  1157. X
  1158. X    if(error_flag)
  1159. X    {
  1160. X        ++this_file_errors;
  1161. X        ++total_errors;
  1162. X        report_error_count();
  1163. X    }
  1164. X
  1165. X}    /* end of report_last_rxhdr */
  1166. X
  1167. X/*+-------------------------------------------------------------------------
  1168. X    report_str(rptstr,error_flag) row 11/12 col 3 len 55
  1169. X
  1170. X  error_flag == 0 for status/progress message
  1171. X             == 1 for bump error count, unless rptstr is null
  1172. X                  in which case, merely clear error string area
  1173. X             == 2 write string on bottom line (not an error)
  1174. X             == 3 write string on transaction line (not an error)
  1175. X             == -1 use error line but do not bump error count
  1176. X--------------------------------------------------------------------------*/
  1177. Xvoid
  1178. Xreport_str(rptstr,error_flag)
  1179. Xregister char *rptstr;
  1180. Xint error_flag;
  1181. X{
  1182. Xchar s60[60];
  1183. Xextern int log_packets;
  1184. X
  1185. X    if(strlen(rptstr) > 55)
  1186. X    {
  1187. X        strncpy(s60,rptstr,55);
  1188. X        s60[56] = 0;
  1189. X        rptstr = s60;
  1190. X    }
  1191. X
  1192. X    switch(error_flag)
  1193. X    {
  1194. X        case 0:
  1195. X            clear_area(win,12,3,55);
  1196. X            break;
  1197. X        case 1:
  1198. X            ++this_file_errors;
  1199. X            ++total_errors;
  1200. X            report_error_count();
  1201. X        case -1:
  1202. X            clear_area(win,11,3,55);
  1203. X            break;
  1204. X        case 2:
  1205. X            clear_area(win,13,3,55);
  1206. X            break;
  1207. X        case 3:
  1208. X            clear_area(win,4,3,55);
  1209. X            break;
  1210. X    }
  1211. X
  1212. X    waddstr(win,rptstr);
  1213. X    wrefresh(win);
  1214. X
  1215. X    if(log_packets)
  1216. X    {
  1217. X        write(log_packets,"info: ",6);
  1218. X        sprintf(s60,"%2d ",error_flag);
  1219. X        write(log_packets,s60,3);
  1220. X        write(log_packets,rptstr,strlen(rptstr));
  1221. X        write(log_packets,"\n",1);
  1222. X    }
  1223. X
  1224. X}    /* end of report_str */
  1225. X
  1226. X/*+-------------------------------------------------------------------------
  1227. X    report_transaction()
  1228. X--------------------------------------------------------------------------*/
  1229. Xvoid
  1230. Xreport_transaction(str)
  1231. Xchar *str;
  1232. X{
  1233. X    report_str(str,3);
  1234. X}    /* end of report_transaction */
  1235. X
  1236. X/*+-------------------------------------------------------------------------
  1237. X    report_file_open_tod() -- time of start of this file
  1238. X
  1239. X  this file open time: row 8 col 47 length 8
  1240. X--------------------------------------------------------------------------*/
  1241. Xvoid
  1242. Xreport_file_open_tod()
  1243. X{
  1244. X    clear_area(win,8,47,8);
  1245. X    waddstr(win,hhmmss((char *)0));
  1246. X    wrefresh(win);
  1247. X}    /* end of report_file_open_tod */
  1248. X
  1249. X/*+-------------------------------------------------------------------------
  1250. X    report_file_open_length(long_length)
  1251. X  length:   row 3 col 36 len  8
  1252. X--------------------------------------------------------------------------*/
  1253. Xreport_file_open_length(length)
  1254. Xlong length;
  1255. X{
  1256. X    clear_area(win,3,36,8);
  1257. X    if(length <= 0)
  1258. X        waddstr(win,"unknown");
  1259. X    else
  1260. X    {
  1261. X        sprintf(s128,"%8lu",length);
  1262. X        waddstr(win,s128);
  1263. X    }
  1264. X    wrefresh(win);
  1265. X}    /* end of report_file_open_length */
  1266. X
  1267. X/*+-------------------------------------------------------------------------
  1268. X    report_file_send_open(filename,filestat)
  1269. X
  1270. X  filename: row 2 col 20 len 38
  1271. X  number:   row 2 col 8 len 3
  1272. X  length:   row 3 col 36 len  8
  1273. X  mode:     row 3 col 46 len 10
  1274. X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
  1275. X--------------------------------------------------------------------------*/
  1276. Xvoid
  1277. Xreport_file_send_open(filename,filestat)
  1278. Xchar *filename;
  1279. Xstruct stat *filestat;
  1280. X{
  1281. Xchar s50[50];
  1282. Xregister char *cptr = filename;
  1283. X
  1284. X    if(log_packets)
  1285. X    {
  1286. X        write(log_packets,"file: ",6);
  1287. X        write(log_packets,filename,strlen(filename));
  1288. X        write(log_packets,"\n",1);
  1289. X    }
  1290. X
  1291. X    /* number */
  1292. X    clear_area(win,2,8,3);
  1293. X    sprintf(s50,"%3d",Filcnt);
  1294. X    waddstr(win,s50);
  1295. X
  1296. X    /* filename */
  1297. X    if(strlen(filename) > 38)
  1298. X    {
  1299. X        strncpy(s50,filename,38);
  1300. X        s50[39] = 0;
  1301. X        cptr = s50;
  1302. X    }
  1303. X    clear_area(win,2,20,38);
  1304. X    waddstr(win,cptr);
  1305. X
  1306. X#if defined(LOG_XFER)
  1307. X    sprintf(s128,"sending %s",filename);
  1308. X    ecu_log_event(getppid(),s128);
  1309. X#endif
  1310. X
  1311. X    /* length */
  1312. X    report_file_open_length(filestat->st_size);
  1313. X
  1314. X    /* time of start of this file */
  1315. X    report_file_open_tod();
  1316. X
  1317. X    this_file_errors = 0;
  1318. X    report_error_count();
  1319. X}    /* end of report_file_send_open */
  1320. X
  1321. X/*+-------------------------------------------------------------------------
  1322. X    report_file_rcv_started(filename,length,last_mod_time)
  1323. X
  1324. X  filename: row 2 col 7 len 50
  1325. X  length:   row 3 col 36 len  8 if not xmodem
  1326. X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
  1327. X--------------------------------------------------------------------------*/
  1328. Xreport_file_rcv_started(filename,length,last_mod_time)
  1329. Xchar *filename;
  1330. Xlong length;                    /* if < 0, "UNKNOWN" */
  1331. Xlong last_mod_time;            /* not currently displayed */
  1332. X{
  1333. Xregister char *cptr;
  1334. Xchar s50[50];
  1335. X
  1336. X    if(log_packets)
  1337. X    {
  1338. X        write(log_packets,"file: ",6);
  1339. X        write(log_packets,filename,strlen(filename));
  1340. X        write(log_packets,"\n",1);
  1341. X    }
  1342. X
  1343. X    /* filename */
  1344. X    if(strlen(filename) > 38)
  1345. X    {
  1346. X        strncpy(s50,filename,38);
  1347. X        s50[39] = 0;
  1348. X        cptr = s50;
  1349. X    }
  1350. X    else
  1351. X        cptr = filename;
  1352. X
  1353. X#if defined(LOG_XFER)
  1354. X    sprintf(s128,"receiving %s",filename);
  1355. X    ecu_log_event(getppid(),s128);
  1356. X#endif
  1357. X
  1358. X    clear_area(win,2,20,38);
  1359. X    waddstr(win,cptr);
  1360. X
  1361. X    /* file number */
  1362. X    clear_area(win,2,8,3);
  1363. X    sprintf(s50,"%3d",Filcnt);    /* rz uses as file number 1-n */
  1364. X    waddstr(win,s50);
  1365. X
  1366. X/* if remote sender provides a file count, display it */
  1367. X    if(npaths)
  1368. X    {
  1369. X        clear_area(win,2,12,7);    /* clear "of ###" */
  1370. X        sprintf(s50,"of %3d:",npaths);
  1371. X        waddstr(win,s50);
  1372. X    }
  1373. X
  1374. X    /* length */
  1375. X    report_file_open_length(length);
  1376. X
  1377. X    /* time of start of this file */
  1378. X    report_file_open_tod();
  1379. X
  1380. X    this_file_errors = 0;
  1381. X    report_error_count();
  1382. X}    /* end of report_file_rcv_started */
  1383. X
  1384. X/*+-------------------------------------------------------------------------
  1385. X    report_file_close()
  1386. X--------------------------------------------------------------------------*/
  1387. Xvoid report_file_close()
  1388. X{
  1389. X    report_str("End of file",0);
  1390. X    wrefresh(win);
  1391. X
  1392. X}    /* end of report_file_close */
  1393. X
  1394. X/*+-------------------------------------------------------------------------
  1395. X    report_file_byte_io(count)
  1396. X--------------------------------------------------------------------------*/
  1397. Xreport_file_byte_io(count)
  1398. Xlong count;
  1399. X{
  1400. X
  1401. X    total_data_chars_xfered += (long)count;
  1402. X    if(total_data_chars_xfered)
  1403. X    {
  1404. X        sprintf(s128,"Total file bytes transferred: %lu",
  1405. X            total_data_chars_xfered);
  1406. X        report_str(s128,-1);
  1407. X    }
  1408. X
  1409. X}    /* end of report_file_byte_io */
  1410. X
  1411. X/* end of scurses.c */
  1412. X/* vi: set tabstop=4 shiftwidth=4: */
  1413. SHAR_EOF
  1414. chmod 0644 sea/scurses.c ||
  1415. echo 'restore of sea/scurses.c failed'
  1416. Wc_c="`wc -c < 'sea/scurses.c'`"
  1417. test 22195 -eq "$Wc_c" ||
  1418.     echo 'sea/scurses.c: original size 22195, current size' "$Wc_c"
  1419. rm -f _shar_wnt_.tmp
  1420. fi
  1421. # ============= sea/sealink.doc ==============
  1422. if test -f 'sea/sealink.doc' -a X"$1" != X"-c"; then
  1423.     echo 'x - skipping sea/sealink.doc (File already exists)'
  1424.     rm -f _shar_wnt_.tmp
  1425. else
  1426. > _shar_wnt_.tmp
  1427. echo 'x - extracting sea/sealink.doc (Text)'
  1428. sed 's/^X//' << 'SHAR_EOF' > 'sea/sealink.doc' &&
  1429. X                                     SEALINK
  1430. X
  1431. X                             File Transfer Protocol
  1432. X
  1433. X                                 9 February 1987
  1434. X
  1435. X
  1436. X
  1437. X          (C) COPYRIGHT 1986,87 by System Enhancement Associates, Inc.
  1438. X
  1439. X
  1440. X
  1441. X     This document describes briefly the  SEAlink  file  transfer  protocol
  1442. X     developers' package.  SEAlink is a sliding  window  protocol  that  is
  1443. X     fully  backwards compatible with XMODEM in all tested implementations.
  1444. X
  1445. X     The intent of SEAlink is to provide a file transfer protocol that does
  1446. X     not  suffer  from  propagation  delays,  such  as  are  introduced  by
  1447. X     satellite relays or packet switched  networks.  Actual  tests  of  the
  1448. X     enclosed  routines  has  shown  that  SEAlink  is capable of virtually
  1449. X     eliminating propagation delays and turnaround delays.  File  transfers
  1450. X     between New Jersey and Hawaii,  which normally suffer a degradation of
  1451. X     50% or more  due  to  satellite  relays,  proceed  as  fast  as  local
  1452. X     transfers.  Even transfers within the local exchange are speeded up by
  1453. X     up to 20% at 2400 baud by the elimination of turnaround delays.  Large
  1454. X     volume  tests  show  that SEAlink is capable of coming to within 2% of
  1455. X     the theoretical minimum time for data transfer.
  1456. X
  1457. X
  1458. X
  1459. X     The developers' package contains the following files:
  1460. X
  1461. X         SEALINK.DOC    This document.
  1462. X         SEALINK.C      A set of C routines for implementing SEAlink.
  1463. X         CLINK.EXE      A sample TTY program that implements SEAlink.
  1464. X
  1465. X
  1466. X
  1467. X     You are granted a license to use this code in your  programs,  and  to
  1468. X     adapt  it to your particular situation and needs,  subject only to the
  1469. X     following conditions:
  1470. X
  1471. X     1) You must refer to it as the SEAlink protocol,  and  you  must  give
  1472. X        credit to System Enhancement Associates.
  1473. X
  1474. X     2) If  you  modify  it in such a way that your version cannot converse
  1475. X        with the original code as supplied by us,  then you should refer to
  1476. X        it as "SEAlink derived",  or as a "variation of SEAlink",  or words
  1477. X        to that effect.
  1478. X
  1479. X     In short,  we're not asking for any money,  but we'd like to get  some
  1480. X     credit for our work.
  1481. X
  1482. X
  1483. X     This  document  is  not  meant  to  be  a  rigorous  definition of the
  1484. X     protocol.  The code provided should serve to document the details  and
  1485. X     fine  points  of  implementing SEAlink.  We will,  however,  present a
  1486. X     brief synopsis of how SEAlink adds sliding windows to XMODEM,  and why
  1487. X     XMODEM doesn't mind.
  1488. X
  1489. X     First of all,  SEAlink adds a block number to the ACK and NAK used  in
  1490. X     XMODEM.(1)  We  thus  create  "ACK/NAK  packets",  with  the following
  1491. X     structure:
  1492. X
  1493. X         Byte 0:   ACK, NAK, or C
  1494. X         Byte 1:   Block number
  1495. X         Byte 2:   One's compliment of block number
  1496. X
  1497. X     This is identical in form to the first three bytes of a  data  packet,
  1498. X     except that the SOH has been replaced with an ACK or NAK.(2)
  1499. X
  1500. X     From the receiver's point of view,  it does not matter if  the  trans-
  1501. X     mitter  is using sliding window or not.  The receiver simply sends ACK
  1502. X     and NAK packets as appropriate.  Any XMODEM driver tested to date will
  1503. X     simply ignore this excess data behind the ACK or NAK.
  1504. X
  1505. X     From the transmitter's point of view,  it just barely matters  if  the
  1506. X     receiver can handle sliding window.  The transmitter always acts as if
  1507. X     it  is  sending sliding window,  but varies the window size.  If it is
  1508. X     seeing valid block numbers and check values behind the  received  ACKs
  1509. X     and NAKs,  it sets the window size to six blocks.  Otherwise,  it sets
  1510. X     the  window  size  to  one  block.  The  result is that it only "sends
  1511. X     ahead" if the receiver can handle it.
  1512. X
  1513. X     It  should  be  a fairly simple matter to apply the underlying SEAlink
  1514. X     logic to almost any variant of XMODEM.
  1515. X
  1516. X
  1517. X     The  SEAlink  routines  provided  in  this package are also capable of
  1518. X     passing system dependent information,  such as true file size and time
  1519. X     of  last modification.  This data is passed in a special header block.
  1520. X     The header block looks exactly like any other block, except that it is
  1521. X     block number zero.
  1522. X
  1523. X     This is still backwards compatible with XMODEM,  as a SEAlink receiver
  1524. X     does  not  mind if block zero is missing,  and any XMODEM receiver yet
  1525. X     tested will regard block zero as a duplicate block and ACK it.
  1526. X
  1527. X     The data portion of block zero contains the following fields:
  1528. X
  1529. X
  1530. X         Offset    Size      Contents
  1531. X         ======    ====      ========
  1532. X
  1533. X            0        4       Original file length.
  1534. X            4        4       Date  and  time  file  was  last mofified,  in
  1535. X                             seconds since 1979.
  1536. X            8       17       Original  file  name,  as  a  null  terminated
  1537. X                             string.
  1538. X           25       15       Name  of  transmitting  program,   as  a  null
  1539. X                             terminated string.
  1540. X           40       88       Null filler and expansion area.
  1541. X
  1542. X
  1543. X     (1) XMODEM/CRC uses a "C" in place of  a  NAK  to  indicate  CRC  error
  1544. X         detection.  SEAlink  follows  this convention,  and supports either
  1545. X         checksum or CRC.  For brevity,  this document will use the term NAK
  1546. X         to mean either a true NAK (hex 15) or a C (hex 43).
  1547. X     (2) See previous footnote.
  1548. X
  1549. X     Any field which the transmitter cannot support should be  set  to  all
  1550. X     zeros.  Conversly,  the  receiver  should ignore any null fields.  The
  1551. X     receiver may ignore any field which he cannot support.
  1552. X
  1553. X
  1554. X
  1555. X     The  routines  enclosed  in  this package should be reasonably easy to
  1556. X     implement in your application.  We have attempted to exclude  compiler
  1557. X     dependent and system dependent logic from these routines.
  1558. X
  1559. X
  1560. X     You will need to alter our references to our communications driver  to
  1561. X     conform  to  your  own driver.  The communications related routines we
  1562. X     use are:
  1563. X
  1564. X         com_putc(c)         Output character c to comm port.
  1565. X
  1566. X         int com_getc(t)     Get character from comm port within  t  tenths
  1567. X                             of   a  second.   Return  EOF  if  time  limit
  1568. X                             expires.
  1569. X
  1570. X         com_dump()          Discard any pending output without sending it.
  1571. X
  1572. X
  1573. X     In  addition,  we  use  the  following  routines for controlling timed
  1574. X     loops:
  1575. X
  1576. X         long timerset(t)    Set a timer.  Returns a timer value which will
  1577. X                             expire in t tenths of a second.
  1578. X
  1579. X         int timeup(z)       Check a timer.  Returns true if  timer  z  has
  1580. X                             expired yet, or false otherwise.
  1581. X
  1582. X
  1583. X     These routines also make reference to the following functions for
  1584. X     system dependent information, which is optional:
  1585. X
  1586. X         filestat(name,&fs)  Read directory entry for  a  file  and  return
  1587. X                             system dependent information.
  1588. X
  1589. X         setstamp(f,dtg)     Set a file's date/time of last modification.
  1590. X
  1591. X
  1592. X
  1593. X
  1594. X     The SEAlink  implementation  provided  in  this  package  is  used  by
  1595. X     invoking the two primary routines:
  1596. X
  1597. X
  1598. X         int xmtfile(name)             /* transmit a file */
  1599. X         char *name;                   /* name of file to transmit */
  1600. X
  1601. X     This  routine is used to send a file.  One file is sent at a time.  If
  1602. X     the  name  is blank (name is null or *name points to a null),  then an
  1603. X     end of transmission marker is sent.
  1604. X
  1605. X     This routine returns a one if the file is successfully transmitted, or
  1606. X     a zero if a fatal error occurs.
  1607. X
  1608. X
  1609. X         char *rcvfile(name)           /* receive a file */
  1610. X         char *name;                   /* name of file (optional) */
  1611. X
  1612. X     This routine is used to receive a file.  One file is  received.  If  a
  1613. X     name is specified for the file,  then that name WILL be used,  and any
  1614. X     name  sent  by  the transmitter will be ignored.  If the name is blank
  1615. X     (name is null or *name points to a null),  then the  transmitter  must
  1616. X     provide a name for the file.
  1617. X
  1618. X     This routine returns a pointer to  the  name  of  the  file  that  was
  1619. X     received.  If the file transfer is not successful, then a null pointer
  1620. X     is returned.
  1621. X
  1622. X     The  pointer  returned  by  rcvfile()  points to a static data buffer.
  1623. X     This does not have to be freed (and should not be),  but  it  will  be
  1624. X     overwritten the next time rcvfile() is called.
  1625. X
  1626. X     The  rcvfile()  function  works  on a temporary file whose name is the
  1627. X     same as the final file,  but with a dash ("-") added at the beginning.
  1628. X     If  a  file  transfer  is  aborted,  then  this temporary file will be
  1629. X     retained.  An aborted file transfer will not harm a pre-existing  file
  1630. X     of the same name.
  1631. X
  1632. X
  1633. X
  1634. X     These  routines  can  be  used  for  either  single  or  multiple file
  1635. X     transfers.
  1636. X
  1637. X     To  send  multiple  files,  send  each  file one by one until either a
  1638. X     transmit fails or all files are sent.  If all  files  are  sent,  then
  1639. X     signal the end by calling xmtfile() with a null pointer.
  1640. X
  1641. X     To receive multiple files,  call rcvfile() repeatedly until it returns
  1642. X     a null pointer.
  1643. X
  1644. X
  1645. X
  1646. X     This  package includes a demonstration program named CLINK (pronounced
  1647. X     "clink"),  which is a  simple  TTY  program  for  doing  SEAlink  file
  1648. X     transfers.  CLINK  does  not  perform  any  sort of terminal emulation
  1649. X     whatsoever.  However,  she will make use of the ANSI.SYS screen driver
  1650. X     if you have it installed.
  1651. X
  1652. X
  1653. X     CLINK may be used in either of two ways: interactive mode or command
  1654. X     mode.
  1655. X
  1656. X     To use CLINK in the interactive mode, give the command "CLINK" with no
  1657. X     arguments.  Press  the  "ESCape"  key to give a command to CLINK.  The
  1658. X     command "?" (question mark) instructs CLINK to tell you what  commands
  1659. X     she understands.
  1660. X
  1661. X     To  use  CLINK  in the command mode,  give the command "CLINK" with an
  1662. X     argument.  There are three arguments you can give CLINK in the command
  1663. X     mode.  These are:
  1664. X
  1665. X      1) Receive files;  Do this with a command of the form:
  1666. X
  1667. X              CLINK R
  1668. X
  1669. X         CLINK  will  attempt  to receive one or more files from COM1,  and
  1670. X         will terminate as soon as all files  are  received,  or  when  the
  1671. X         transfer aborts.
  1672. X
  1673. X      2) Transmit files; Do this with a command of the form:
  1674. X
  1675. X              CLINK T <filename> ...
  1676. X
  1677. X         CLINK  will  attempt  to transmit the listed files over COM1,  and
  1678. X         will terminate as soon as all files are sent,  or the transfer  is
  1679. X         aborted.  <filename> may be one or more file names with or without
  1680. X         drive and path specifiers.  Wildcards may be used.
  1681. X
  1682. X      3) Give help;  If you type:
  1683. X
  1684. X              CLINK ?
  1685. X
  1686. X         or any invalid command,  CLINK will display a  brief  reminder  of
  1687. X         what arguments she understands in command mode.
  1688. X
  1689. X     In all cases, CLINK in the command mode will not alter the serial port
  1690. X     other than to set eight data bits,  one stop bit,  and no parity.  Any
  1691. X     previously installed serial drivers will be  replaced,  and  the  baud
  1692. X     rate will not be changed.
  1693. X
  1694. X
  1695. X
  1696. X     CLINK comes with her own serial driver built in for the IBM PC  family
  1697. X     and true compatibles,  but she is capable of using any standard FOSSIL
  1698. X     driver.
  1699. X
  1700. SHAR_EOF
  1701. chmod 0644 sea/sealink.doc ||
  1702. echo 'restore of sea/sealink.doc failed'
  1703. Wc_c="`wc -c < 'sea/sealink.doc'`"
  1704. test 11247 -eq "$Wc_c" ||
  1705.     echo 'sea/sealink.doc: original size 11247, current size' "$Wc_c"
  1706. rm -f _shar_wnt_.tmp
  1707. fi
  1708. # ============= sea/sealink.imp ==============
  1709. if test -f 'sea/sealink.imp' -a X"$1" != X"-c"; then
  1710.     echo 'x - skipping sea/sealink.imp (File already exists)'
  1711.     rm -f _shar_wnt_.tmp
  1712. else
  1713. > _shar_wnt_.tmp
  1714. echo 'x - extracting sea/sealink.imp (Text)'
  1715. sed 's/^X//' << 'SHAR_EOF' > 'sea/sealink.imp' &&
  1716. X    SEAlink - Sliding window file transfer protocol
  1717. X
  1718. X    XENIX System V version by Scott Reynolds
  1719. X    additional XENIX modifications by Sanford Zelkovitz, without whose help
  1720. X    this couldn't have been accomplished
  1721. X
  1722. X    Based on:
  1723. X
  1724. X    MS-DOS Version 1.16, created on 01/15/87 at 01:40:52
  1725. X(C) COPYRIGHT 1986,87 by System Enhancement Associates; ALL RIGHTS RESERVED
  1726. X    By:  Thom Henderson
  1727. X
  1728. X    Description:
  1729. X
  1730. X    This file contains a set of routines to illustrate the SEAlink
  1731. X    sliding window file transfer protocol.  SEAlink is fully backward
  1732. X    compatible to XMODEM, and can be easily adapted to most XMODEM
  1733. X    variants.
  1734. X
  1735. X    The intent of SEAlink is to provide a file transfer protocol that
  1736. X    does not suffer from propagation delays, such as are introduced
  1737. X    by satellite relays or packet switched networks.
  1738. X
  1739. X    Instructions:
  1740. X
  1741. X    Two routines are provided to implement SEAlink file transfers.
  1742. X
  1743. X    int xmtfile(name)        /+ transmit a file +/
  1744. X    char *name;            /+ name of file to transmit +/
  1745. X
  1746. X    This routine is used to send a file.  One file is sent at a time.
  1747. X    If the name is blank (name is null or *name points to a null),
  1748. X    then only an end of transmission marker is sent.
  1749. X
  1750. X    This routine returns a one if the file is successfully
  1751. X    transmitted, or a zero if a fatal error occurs.
  1752. X
  1753. X    char *rcvfile(name)        /+ receive a file +/
  1754. X    char *name;            /+ name of file (optional) +/
  1755. X
  1756. X    This routine is used to receive a file.  One file is received.
  1757. X    The name, if given, takes precedence and will be the name of
  1758. X    the resulting file.  If the name is blank (name is null or *name
  1759. X    points to a null), then the name given by the transmitter is used.
  1760. X    If the transmitter does not give a name, then the file transfer
  1761. X    is aborted.
  1762. X
  1763. X    This routine returns a pointer to the name of the file that
  1764. X    was received.  If the file transfer is not successful, then
  1765. X    a null pointer is returned.
  1766. X
  1767. X    The pointer returned by rcvfile() points to a static data buffer.
  1768. X    This does not have to be freed (and should not be), but it will
  1769. X    be overwritten the next time rcvfile() is called.
  1770. X
  1771. X    The rcvfile() function works on a temporary file whose name is
  1772. X    the same as the final file, but with a period (".") added at the
  1773. X    beginning.  If a file transfer is aborted, then this temporary
  1774. X    file will be retained.  An aborted file transfer will not harm
  1775. X    a pre-existing file of the same name.
  1776. X
  1777. X    Programming notes:
  1778. X
  1779. X    These routines can be used for either single or multiple file
  1780. X    transfers.
  1781. X
  1782. X    To send multiple files, send each one one at a time until either
  1783. X    a transmit fails or all files are sent.  If all files are sent,
  1784. X    then signal the end by calling xmtfile() with a null pointer.
  1785. X
  1786. X    To receive multiple files, call rcvfile() repeatedly until it
  1787. X    returns a null pointer.
  1788. X
  1789. X    These routines pass a "block zero", which contains information
  1790. X    about the original file name, size, and date/time of last
  1791. X    modification.  If you cannot implement block zero, then you can
  1792. X    leave it out.  If you cannot set any given field in block zero
  1793. X    when transmitting, then you should leave it set to zeros.  If you
  1794. X    cannot use any given field of block zero when receiving, then
  1795. X    you should ignore it.
  1796. X
  1797. X    These routines are fully compatible with XMODEM, including the
  1798. X    original checksum method and later CRC adaptations.  It can be
  1799. X    easily adapted to Modem7 protocol by adding a Modem7 filename
  1800. X    transfer shell, though we do not recommend it.  The underlying
  1801. X    logic, of course, can be adapted to almost any variant of XMODEM.
  1802. X
  1803. X    License:
  1804. X
  1805. X    You are granted a license to use this code in your programs, and
  1806. X    to adapt it to your particular situation and needs, subject only
  1807. X    to the following conditions:
  1808. X
  1809. X    1)   You must refer to it as the SEAlink protocol, and you must
  1810. X         give credit to System Enhancement Associates.
  1811. X
  1812. X    2)   If you modify it in such a way that your version cannot
  1813. X         converse with the original code as supplied by us, then
  1814. X         you should refer to it as "SEAlink derived", or as a
  1815. X         "variation of SEAlink", or words to that effect.
  1816. X
  1817. X    In short, we're not asking for any money, but we'd like to
  1818. X    get some credit for our work.
  1819. X
  1820. X    Language:
  1821. X
  1822. X    Computer Innovations C86
  1823. X    Adapted for IBM PC XENIX 2.00.2 C using UNIX System V compatible calls
  1824. X
  1825. X    Notes on XENIX modifications:
  1826. X
  1827. X    The com_getc() routine has a minimum delay of .1 seconds, due
  1828. X    to the nature of the read() system call.  Attempts to eliminate
  1829. X    this delay have proven more costly than leaving it in.
  1830. X
  1831. X    CRC maintenance functions were added to the original code, as
  1832. X    they are not library calls under XENIX.
  1833. X
  1834. X    All output is performed through file descriptor 0, and is done
  1835. X    in blocks using the write() system call rather than individual
  1836. X    character writes.  File descriptor 1 may be selected by invoking
  1837. X    the program with a "-1" argument.
  1838. X
  1839. X    Most low level routines utilize register class variables to
  1840. X    decrease overhead and improve overall system response slightly.
  1841. X
  1842. X    A rudimentary command line processor was added to the original
  1843. X    routines to drive the transmitter and receiver.  The two
  1844. X    options, "s" and "r", are for sending and receiving respectively.
  1845. X
  1846. X    When invoked without proper arguments the program will display
  1847. X    a short message including usage notes.
  1848. X
  1849. X    -- Scott Reynolds, Sysop U.S.S. Enterprise BBS, (906)228-9460
  1850. SHAR_EOF
  1851. chmod 0644 sea/sealink.imp ||
  1852. echo 'restore of sea/sealink.imp failed'
  1853. Wc_c="`wc -c < 'sea/sealink.imp'`"
  1854. test 5213 -eq "$Wc_c" ||
  1855.     echo 'sea/sealink.imp: original size 5213, current size' "$Wc_c"
  1856. rm -f _shar_wnt_.tmp
  1857. fi
  1858. # ============= gendial/README ==============
  1859. if test -f 'gendial/README' -a X"$1" != X"-c"; then
  1860.     echo 'x - skipping gendial/README (File already exists)'
  1861.     rm -f _shar_wnt_.tmp
  1862. else
  1863. > _shar_wnt_.tmp
  1864. echo 'x - extracting gendial/README (Text)'
  1865. sed 's/^X//' << 'SHAR_EOF' > 'gendial/README' &&
  1866. XI have done at least rudimentary testing of each of these
  1867. Xdialers in an SCO XENIX or UNIX.  I have good faith in
  1868. Xthe HA24, USR24, MPAD, T2500 and MC9624 dialers.
  1869. XSome many things and ROMs have been called Trailblazer Plus
  1870. Xthat I juust dunno.
  1871. X
  1872. XdialgHA24       Hayes 2400
  1873. XdialgMC9624     Microcom AX/9624c
  1874. XdialgMPAD       AT&T Tridom VSAT modem emulation PAD
  1875. XdialgT2500      Telebit T2500
  1876. XdialgTBPlus     Telebit Trailblazer rom version 5.01
  1877. XdialgUSR24      US Robotic Courier 2400
  1878. SHAR_EOF
  1879. chmod 0644 gendial/README ||
  1880. echo 'restore of gendial/README failed'
  1881. Wc_c="`wc -c < 'gendial/README'`"
  1882. test 480 -eq "$Wc_c" ||
  1883.     echo 'gendial/README: original size 480, current size' "$Wc_c"
  1884. rm -f _shar_wnt_.tmp
  1885. fi
  1886. # ============= gendial/install_dialer ==============
  1887. if test -f 'gendial/install_dialer' -a X"$1" != X"-c"; then
  1888.     echo 'x - skipping gendial/install_dialer (File already exists)'
  1889.     rm -f _shar_wnt_.tmp
  1890. else
  1891. > _shar_wnt_.tmp
  1892. echo 'x - extracting gendial/install_dialer (Text)'
  1893. sed 's/^X//' << 'SHAR_EOF' > 'gendial/install_dialer' &&
  1894. X:
  1895. X#+----------------------------------------------------------
  1896. X# install_dialer -  ECU gendial modem dial installation
  1897. X# usage: install_dialer directory executeable 
  1898. X#+----------------------------------------------------------
  1899. X#+:EDITS:*/
  1900. X#:09-10-1992-13:59-wht@n4hgf-ECU release 3.20
  1901. X#:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA
  1902. X#:04-30-1991-16:07-root@n4hgf-add header and ls -l
  1903. X
  1904. Xlib="$1"
  1905. X
  1906. Xecho ''
  1907. Xwhile [ x$2 != x ]
  1908. Xdo
  1909. X    echo Installing dialer $2 in $lib
  1910. X    rm -f $lib/$2 $lib/$2~
  1911. X    if [ -f $lib/$2 ]; then mv $lib/$2 $lib/$2~; fi
  1912. X    cp $2 $lib/$2
  1913. X    strip $lib/$2
  1914. X    if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $lib/$2; fi
  1915. X    chown uucp $lib/$2; chgrp uucp $lib/$2; chmod 711 $lib/$2
  1916. X    ls -l $lib/$2
  1917. X    shift
  1918. X    echo ''
  1919. Xdone
  1920. X
  1921. SHAR_EOF
  1922. chmod 0755 gendial/install_dialer ||
  1923. echo 'restore of gendial/install_dialer failed'
  1924. Wc_c="`wc -c < 'gendial/install_dialer'`"
  1925. test 720 -eq "$Wc_c" ||
  1926.     echo 'gendial/install_dialer: original size 720, current size' "$Wc_c"
  1927. rm -f _shar_wnt_.tmp
  1928. fi
  1929. # ============= gendial/dceHA24.c ==============
  1930. if test -f 'gendial/dceHA24.c' -a X"$1" != X"-c"; then
  1931.     echo 'x - skipping gendial/dceHA24.c (File already exists)'
  1932.     rm -f _shar_wnt_.tmp
  1933. else
  1934. > _shar_wnt_.tmp
  1935. echo 'x - extracting gendial/dceHA24.c (Text)'
  1936. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dceHA24.c' &&
  1937. X/*+-------------------------------------------------------------------------
  1938. X    dceHA24.c - DCE-specific portion of generic SCO UUCP dialer
  1939. X    Driver for generic Hayes-style 2400 baud modem
  1940. X    wht@n4hgf.Mt-Park.GA.US
  1941. X
  1942. X Necessary DCE switch setting or other configuration:
  1943. X   enable onhook upon loss of DTR
  1944. X--------------------------------------------------------------------------*/
  1945. X/*+:EDITS:*/
  1946. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1947. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1948. X/*:02-02-1992-18:01-root@n4hgf-proper ordering of DCE_result entries */
  1949. X/*:01-26-1992-15:30-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
  1950. SHAR_EOF
  1951. true || echo 'restore of gendial/dceHA24.c failed'
  1952. fi
  1953. echo 'End of ecu320 part 27'
  1954. echo 'File gendial/dceHA24.c is continued in part 28'
  1955. echo 28 > _shar_seq_.tmp
  1956. exit 0
  1957.  
  1958. exit 0 # Just in case...
  1959.