home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume16 / ecu3 / part24 < prev    next >
Encoding:
Internet Message Format  |  1991-01-06  |  50.5 KB

  1. From: wht@n4hgf.uucp (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v16i048:  ECU async comm package rev 3.0, Part24/35
  4. Message-ID: <1991Jan6.052555.28540@sparky.IMD.Sterling.COM>
  5. Date: 6 Jan 91 05:25:55 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 7dc21ded 08c0037c eba5f808 422f2ad4
  8.  
  9. Submitted-by: wht@n4hgf.uucp (Warren Tucker)
  10. Posting-number: Volume 16, Issue 48
  11. Archive-name: ecu3/part24
  12.  
  13. ---- Cut Here and feed the following to sh ----
  14. #!/bin/sh
  15. # This is part 24 of ecu3
  16. if touch 2>&1 | fgrep 'amc' > /dev/null
  17.  then TOUCH=touch
  18.  else TOUCH=true
  19. fi
  20. # ============= sea/scurses.c ==============
  21. if test ! -d 'sea'; then
  22.     echo 'x - creating directory sea'
  23.     mkdir 'sea'
  24. fi
  25. echo 'x - extracting sea/scurses.c (Text)'
  26. sed 's/^X//' << 'SHAR_EOF' > 'sea/scurses.c' &&
  27. X/*+-------------------------------------------------------------------------
  28. X    scurses.c -- ecu file transfer program curses interface
  29. X
  30. X  000000000011111111112222222222333333333344444444445555555550
  31. X  012345678901234567890123456789012345678901234567890123456789
  32. X00.----------------------------------------------------------.
  33. X01|  SEAlink_6____  _39____________________________________  |
  34. X02|  File ### of ###: _38__________________________________  |
  35. X03|  File position:  _8______ length: _8______               |
  36. X04|  _55____________________________________________________ | transaction
  37. X05|  _55____________________________________________________ | last rx/tx hdr
  38. X06|  Comm I/O: rx _8______  tx _8______ bytes                |
  39. X07|  Baud rate: _5___ BINARY blklen: _____ comm mode: CBREAK |
  40. X08|  Time started: session: HH:MM:SS  this file: HH:MM:SS    |
  41. X09|                elpased: HH:MM:SS       time: HH:MM:SS    |
  42. X10|  Error counts: this file:  _4__  total: _6____           |
  43. X11|  _55____________________________________________________ |  err str
  44. X12|  _55____________________________________________________ |  comment str
  45. X13|  _55____________________________________________________ |  remote info
  46. X14`----------------------------------------------------------'
  47. X
  48. X  Defined functions:
  49. X    clear_area(win,row,col,len)
  50. X    clear_area_char(win,row,col,len,fillchar)
  51. X    get_elapsed_time(elapsed_seconds)
  52. X    get_tod(type,tod)
  53. X    report_error_count()
  54. X    report_file_byte_io(count)
  55. X    report_file_close()
  56. X    report_file_open_length(length)
  57. X    report_file_open_tod()
  58. X    report_file_rcv_started(filename,length,last_mod_time)
  59. X    report_file_send_open(filename,filestat)
  60. X    report_init(title)
  61. X    report_last_rxhdr(rptstr,error_flag)
  62. X    report_last_txhdr(rptstr,error_flag)
  63. X    report_line(baud_rate,mode)
  64. X    report_protocol_crc_type(str)
  65. X    report_rx_ind(status)
  66. X    report_rx_tx_count()
  67. X    report_rxpos(rxpos)
  68. X    report_str(rptstr,error_flag)
  69. X    report_top_line(topstr)
  70. X    report_transaction(str)
  71. X    report_tx_ind(status)
  72. X    report_txpos(txpos)
  73. X    report_uninit()
  74. X
  75. X------------------------------------------------------------------------*/
  76. X/*+:EDITS:*/
  77. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  78. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  79. X
  80. X#include <curses.h>
  81. X#include <sys/types.h>
  82. X#include <sys/stat.h>
  83. X#include <ctype.h>
  84. X#include <signal.h>
  85. X#include <time.h>
  86. X#include <sys/timeb.h>
  87. X#include <sys/machdep.h>
  88. X
  89. X#include "../pc_scr.h"
  90. X#include "lint_args.h"
  91. X
  92. Xlong time();
  93. Xextern char *tzname[];
  94. Xstruct tm *localtime();
  95. X
  96. X
  97. X#define WIN_LINES    15
  98. X#define WIN_COLS    60
  99. X#define WIN_TOPY    2
  100. X#define WIN_LEFTX    8
  101. X
  102. Xextern char curr_dir[];
  103. Xextern char s128[];
  104. Xextern int Filcnt;
  105. Xextern int Restricted;
  106. Xextern int sending_flag;    /* send == 1, receive == 0 */
  107. Xextern int npaths;
  108. Xextern long rxpos;
  109. Xextern int log_packets;
  110. X
  111. XWINDOW    *win;
  112. Xint (*original_sigint_handler)();
  113. Xint (*original_sigquit_handler)();
  114. Xint (*original_sigterm_handler)();
  115. Xint curses_installed = 0;        /* curses not yet active */
  116. Xint this_file_errors = 0;
  117. Xint total_errors = 0;
  118. Xlong current_seconds;
  119. Xlong start_seconds;
  120. Xlong elapsed_seconds;
  121. Xunsigned long total_data_chars_xfered = 0L;
  122. X
  123. Xunsigned char sTL = at_TL;
  124. Xunsigned char sTR = at_TR;
  125. Xunsigned char sBL = at_BL;
  126. Xunsigned char sBR = at_BR;
  127. Xunsigned char sLT = at_LT;
  128. Xunsigned char sRT = at_RT;
  129. Xunsigned char sVR = at_VR;
  130. Xunsigned char sHR = at_HR;
  131. X
  132. Xchar *win_template[] =
  133. X{
  134. X/*00000000001111111111222222222233333333334444444444555555555 */
  135. X/*01234567890123456789012345678901234567890123456789012345678 */
  136. X/*.----------------------------------------------------------. */
  137. X  "  SEAlink                                                 ",    /* 1 */
  138. X  "  File ### of ###: _____________________________________  ",    /* 2 */
  139. X  "  File position:  ________ length: ________               ",    /* 3 */
  140. X  "                                                          ",    /* 4 */
  141. X  "  tx: ______________________  rx: ______________________  ",    /* 5 */
  142. X  "  Comm I/O: rx ________  tx ________ bytes                ",    /* 6 */
  143. X  "  Baud rate: _____ BINARY blklen: 128   comm mode: ______ ",    /* 7 */
  144. X  "  Time started: session: --:--:--  this file: --:--:--    ",    /* 8 */
  145. X  "                elapsed: --:--:--    current: --:--:--    ",    /* 9 */
  146. X  "  Error counts: this file:  ____  total: ______           ",    /* 10 */
  147. X  "                                                          ",    /* 11 */
  148. X  "                                                          ",    /* 12 */
  149. X  "                                                          ",    /* 13 */
  150. X/*`----------------------------------------------------------' */
  151. X(char *)0
  152. X};
  153. X
  154. X/*+-----------------------------------------------------------------------
  155. X    char *get_elapsed_time(elapsed_seconds)
  156. X    hh:mm:ss returned
  157. X  static string address is returned
  158. X------------------------------------------------------------------------*/
  159. Xchar *get_elapsed_time(elapsed_seconds)
  160. Xlong elapsed_seconds;
  161. X{
  162. X    static char elapsed_time_str[10];
  163. X    long hh,mm,ss;
  164. X
  165. X    hh = elapsed_seconds / 3600;
  166. X    elapsed_seconds -= hh * 3600;
  167. X    mm = elapsed_seconds / 60L;
  168. X    elapsed_seconds -= mm * 60L;
  169. X    ss = elapsed_seconds;
  170. X
  171. X    sprintf(elapsed_time_str,"%02ld:%02ld:%02ld",hh,mm,ss);
  172. X    return(elapsed_time_str);
  173. X}    /* end of get_elapsed_time */
  174. X
  175. X/*+-----------------------------------------------------------------------
  176. X    char *get_tod(type,tod)
  177. X
  178. X  time of day types:
  179. X    0        hh:mm
  180. X    1        hh:mm:ss
  181. X    2        mm-dd-yyyy hh:mm
  182. X
  183. X  static string address is returned
  184. X  if tod != (char *)0, time is returned there too
  185. X------------------------------------------------------------------------*/
  186. Xchar *
  187. Xget_tod(type,tod)
  188. Xint type;
  189. Xchar *tod;
  190. X{
  191. X    long cur_time = 0;
  192. X    struct tm *lt;            /* local time */
  193. X    static char tod_str[32];
  194. X    struct timeb tp;
  195. X
  196. X    cur_time = time((long *)0);
  197. X    lt = localtime(&cur_time);
  198. X#if defined(M_XENIX) && defined(MESSED_UP_DST)
  199. X    ftime(&tp);                /* localtime() does not know about DST */
  200. X    if(tp.dstflag)            /* so we adjust with ftime, which does know */
  201. X    {
  202. X        cur_time += 3600L;    /* problem in BSD too, but no ftime there */
  203. X        lt = localtime(&cur_time);
  204. X        cur_time -= 3600L;
  205. X    }
  206. X#endif
  207. X
  208. X    switch(type)
  209. X    {
  210. X    case 0:
  211. X        sprintf(tod_str,"%02d:%02d",lt->tm_hour,lt->tm_min);
  212. X        break;
  213. X
  214. X    default:
  215. X    case 1:
  216. X        sprintf(tod_str,"%02d:%02d:%02d",lt->tm_hour,lt->tm_min,lt->tm_sec);
  217. X        break;
  218. X
  219. X    case 2:
  220. X        sprintf(tod_str,"%02d-%02d-%04d %02d:%02d",
  221. X            lt->tm_mon + 1,lt->tm_mday,lt->tm_year + 1900,
  222. X            lt->tm_hour,lt->tm_min);
  223. X        break;
  224. X    }
  225. X
  226. X    if(tod != (char *)0)
  227. X        strcpy(tod,tod_str);
  228. X
  229. X    return(tod_str);
  230. X}    /* end of get_tod */
  231. X
  232. X/*+-------------------------------------------------------------------------
  233. X    clear_area(win,row,col,len)
  234. X--------------------------------------------------------------------------*/
  235. Xclear_area(win,row,col,len)
  236. XWINDOW    *win;
  237. Xint row;
  238. Xint col;
  239. Xint len;
  240. X{
  241. X    wmove(win,row,col);
  242. X    while(len-- > 0)
  243. X        waddch(win,' ');
  244. X    wmove(win,row,col);
  245. X
  246. X}    /* end of clear_area */
  247. X
  248. X/*+-------------------------------------------------------------------------
  249. X    clear_area_char(win,row,col,len,fillchar)
  250. X--------------------------------------------------------------------------*/
  251. Xclear_area_char(win,row,col,len,fillchar)
  252. XWINDOW    *win;
  253. Xint row;
  254. Xint col;
  255. Xint len;
  256. Xchar fillchar;
  257. X{
  258. X    wmove(win,row,col);
  259. X    while(len-- > 0)
  260. X        waddch(win,fillchar);
  261. X    wmove(win,row,col);
  262. X
  263. X}    /* end of clear_area_char */
  264. X
  265. X/*+-------------------------------------------------------------------------
  266. X    report_top_line(topstr)
  267. X   top line: row 1 col 18 length 39
  268. X--------------------------------------------------------------------------*/
  269. Xvoid
  270. Xreport_top_line(topstr)
  271. Xchar *topstr;
  272. X{
  273. Xchar s42[42];
  274. X    clear_area(win,1,18,39);
  275. X    if(strlen(topstr) < 39)
  276. X        waddstr(win,topstr);
  277. X    else
  278. X    {
  279. X        strncpy(s42,topstr,39);
  280. X        s42[39] = 0;
  281. X        waddstr(win,s42);
  282. X    }
  283. X}    /* end of report_top_line */
  284. X
  285. X/*+-------------------------------------------------------------------------
  286. X    report_protocol_crc_type(str)
  287. X
  288. X  protocol crc type:  row 1 col 10 length 6
  289. X--------------------------------------------------------------------------*/
  290. Xreport_protocol_crc_type(str)
  291. Xregister char *str;
  292. X{
  293. Xchar s8[8];
  294. X
  295. X    if(strlen(str) > 6)
  296. X    {
  297. X        strncpy(s8,str,6);
  298. X        s8[6] = 0;
  299. X        str = s8;
  300. X    }
  301. X    clear_area(win,1,10,6);
  302. X    waddstr(win,str);
  303. X    wrefresh(win);
  304. X    if(log_packets)
  305. X    {
  306. X        write(log_packets,"chk:  ",6);
  307. X        write(log_packets,str,strlen(str));
  308. X        write(log_packets,"\n",1);
  309. X    }
  310. X
  311. X}    /* end of report_protocol_crc_type */
  312. X
  313. X/*+-------------------------------------------------------------------------
  314. X    report_uninit()
  315. X--------------------------------------------------------------------------*/
  316. Xvoid
  317. Xreport_uninit()
  318. X{
  319. Xfloat total = (float)total_data_chars_xfered;
  320. X
  321. X    if(curses_installed)
  322. X    {
  323. X        if((total_data_chars_xfered != 0L) && (elapsed_seconds != 0L))
  324. X        {
  325. X            sprintf(s128,"Data xfer rate ~= %6.0f chars/sec",
  326. X                total / (float)elapsed_seconds);
  327. X            if(log_packets)
  328. X            {
  329. X                write(log_packets,"info: ",6);
  330. X                write(log_packets,s128,strlen(s128));
  331. X                write(log_packets,"\n",1);
  332. X            }
  333. X            report_top_line(s128);
  334. X        }
  335. X        report_file_byte_io(0L);
  336. X        report_rx_tx_count();
  337. X        wmove(win,WIN_LINES - 1,WIN_COLS - 1);
  338. X        wrefresh(win);
  339. X        endwin();
  340. X        fprintf(stderr,"\r\n\r\n\r\n");
  341. X        fflush(stderr);
  342. X        curses_installed = 0;
  343. X    }
  344. X
  345. X}    /* end of report_uninit */
  346. X
  347. X/*+-------------------------------------------------------------------------
  348. X    report_init(title)
  349. X--------------------------------------------------------------------------*/
  350. Xvoid
  351. Xreport_init(title)
  352. Xchar *title;
  353. X{
  354. Xregister int itmp;
  355. Xregister char *cptr;
  356. Xint monitor_type;
  357. Xchar buf[48];
  358. X
  359. X    if(curses_installed)
  360. X        return;
  361. X
  362. X    initscr();
  363. X    crmode();
  364. X    noecho();
  365. X    nonl();
  366. X    clear();
  367. X    curses_installed = 1;
  368. X    win = newwin(WIN_LINES,WIN_COLS,WIN_TOPY,WIN_LEFTX);
  369. X    box(win,sVR,sHR);
  370. X    wmove(win,0,0); waddch(win,sTL);
  371. X    wmove(win,win->_maxy - 1,0); waddch(win,sBL);
  372. X    wmove(win,win->_maxy - 1,win->_maxx - 1); waddch(win,sBR);
  373. X    wmove(win,0,win->_maxx - 1); waddch(win,sTR);
  374. X    wmove(win,0,2);
  375. X    wstandout(win);
  376. X    waddch(win,'[');
  377. X    waddch(win,' ');
  378. X    waddstr(win,title);
  379. X    waddch(win,' ');
  380. X    waddch(win,']');
  381. X    wstandend(win);
  382. X    waddch(win,sHR);
  383. X    waddch(win,sHR);
  384. X    waddstr(win," dir: ");
  385. X    waddstr(win,curr_dir);
  386. X    waddch(win,' ');
  387. X
  388. X    itmp = 0;
  389. X    while(1)
  390. X    {
  391. X        if(win_template[itmp] == (char *)0)
  392. X            break;
  393. X        wmove(win,itmp + 1,1);
  394. X        waddstr(win,win_template[itmp++]);
  395. X    }
  396. X    if(sending_flag)
  397. X    {
  398. X        clear_area(win,2,15,3);
  399. X        sprintf(s128,"%3d",npaths);
  400. X        waddstr(win,s128);
  401. X#if defined(FORK_DEBUG)
  402. X        sprintf(s128,"ecusz pid %d",getpid());
  403. X#endif
  404. X    }
  405. X    else    /* ecurz */
  406. X    {
  407. X        clear_area(win,2,11,8);    /* clear "of ###" */
  408. X        waddstr(win,":");
  409. X#if defined(FORK_DEBUG)
  410. X        sprintf(s128,"ecurz pid %d",getpid());
  411. X#endif
  412. X    }
  413. X
  414. X#if defined(FORK_DEBUG)
  415. X    ecu_log_event(getppid(),s128);
  416. X#endif
  417. X
  418. X    clear_area(win,1,11,47);
  419. X    report_error_count();
  420. X    clear_area(win,8,26,8);        /* starting time */
  421. X    waddstr(win,get_tod(1,(char *)0));
  422. X    start_seconds = time((long *)0);
  423. X    current_seconds = start_seconds;
  424. X
  425. X    if(ioctl(0,CONS_GET,&monitor_type) < 0)    /* not multiscreen */
  426. X    {
  427. X        sTL = vanilla_TL;
  428. X        sTR = vanilla_TR;
  429. X        sBL = vanilla_BL;
  430. X        sBR = vanilla_BR;
  431. X        sLT = vanilla_LT;
  432. X        sRT = vanilla_RT;
  433. X        sVR = vanilla_VR;
  434. X        sHR = vanilla_HR;
  435. X    }
  436. X
  437. X    wrefresh(win);
  438. X
  439. X}    /* end of report_init */
  440. X
  441. X/*+-------------------------------------------------------------------------
  442. X    report_rx_ind(status)
  443. X--------------------------------------------------------------------------*/
  444. Xvoid
  445. Xreport_rx_ind(status)
  446. Xint status;
  447. X{
  448. X    wmove(win,1,54);
  449. X    waddch(win,(status) ? 'R' : ' ');
  450. X    wmove(win,1,54);
  451. X    wrefresh(win);
  452. X}    /* end of report_rx_ind */
  453. X
  454. X/*+-------------------------------------------------------------------------
  455. X    report_tx_ind(status)
  456. X--------------------------------------------------------------------------*/
  457. Xvoid
  458. Xreport_tx_ind(status)
  459. Xint status;
  460. X{
  461. X    wmove(win,1,56);
  462. X    waddch(win,(status) ? 'T' : ' ');
  463. X    wmove(win,1,56);
  464. X    wrefresh(win);
  465. X}    /* end of report_tx_ind */
  466. X
  467. X/*+-------------------------------------------------------------------------
  468. X    report_rx_tx_count()
  469. X
  470. X  rx char count: row 6 col 16 length 8 unsigned long
  471. X  tx char count: row 6 col 29 length 8 unsigned long
  472. X  now time of day: row 1 col 50 length 8 hh:mm:ss
  473. X  This procedure may be counted upon to perform wrefresh(win)
  474. X
  475. Xelapsed time row 9 col 26 length 8
  476. Xcurrent tod row 9 col 47 length 8
  477. X--------------------------------------------------------------------------*/
  478. Xreport_rx_tx_count()
  479. X{
  480. X    extern unsigned long rx_char_count;
  481. X    extern unsigned long tx_char_count;
  482. X
  483. X    register char *cptr;
  484. X
  485. X    sprintf(s128,"%8ld",rx_char_count);
  486. X    wmove(win,6,16);
  487. X    waddstr(win,s128);
  488. X    sprintf(s128,"%8ld",tx_char_count);
  489. X    wmove(win,6,29);
  490. X    waddstr(win,s128);
  491. X
  492. X    /* now time of day */
  493. X    clear_area(win,9,47,8);
  494. X    cptr = get_tod(1,(char *)0);
  495. X    waddstr(win,cptr);
  496. X    current_seconds = time((long *)0);
  497. X    elapsed_seconds = current_seconds - start_seconds;
  498. X    cptr = get_elapsed_time(elapsed_seconds);
  499. X    clear_area(win,9,26,8);
  500. X    waddstr(win,cptr);
  501. X    wrefresh(win);        /* calling procs expect this to occur always */
  502. X
  503. X}    /* end of report_rx_tx_count */
  504. X
  505. X/*+-------------------------------------------------------------------------
  506. X    report_line(baud_rate,mode)
  507. X--------------------------------------------------------------------------*/
  508. Xvoid
  509. Xreport_line(baud_rate,mode)
  510. Xunsigned baud_rate;
  511. Xchar *mode;
  512. X{
  513. Xchar s16[16];
  514. X    wmove(win,7,14);
  515. X    sprintf(s16,"%5u",baud_rate);
  516. X    waddstr(win,s16);
  517. X    clear_area(win,7,52,6);
  518. X    waddstr(win,mode);
  519. X    wrefresh(win);
  520. X}    /* end of report_line */
  521. X
  522. X/*+-------------------------------------------------------------------------
  523. X    report_rxpos(rxpos) row 3 col 19 len 8
  524. X--------------------------------------------------------------------------*/
  525. Xvoid
  526. Xreport_rxpos(rxpos)
  527. Xlong rxpos;
  528. X{
  529. Xchar tmp[16];
  530. Xchar refr;
  531. X
  532. X    if(rdchk(0))
  533. X    {
  534. X        read(0,&refr,1);
  535. X        if(refr == 0x0C || refr == 0x012)    /* ^L or ^R */
  536. X        {
  537. X            write(2,"\033[2J",4);
  538. X            nap((long)60);
  539. X            touchwin(stdscr);
  540. X            wrefresh(stdscr);
  541. X            touchwin(win);
  542. X            wrefresh(win);
  543. X        }
  544. X    }
  545. X
  546. X    if((rxpos > 99999999L) || (rxpos < 0L))
  547. X        return;
  548. X
  549. X    sprintf(tmp,"%8lu",rxpos);
  550. X    wmove(win,3,19);
  551. X    waddstr(win,tmp);
  552. X    wrefresh(win);
  553. X    report_rx_tx_count();    /* which will do a refresh */
  554. X}    /* end of report_rxpos */
  555. X
  556. X/*+-------------------------------------------------------------------------
  557. X    report_txpos(txpos)
  558. X--------------------------------------------------------------------------*/
  559. Xvoid
  560. Xreport_txpos(txpos)
  561. Xlong txpos;
  562. X{
  563. X    report_rxpos(txpos);
  564. X}    /* end of report_txpos */
  565. X
  566. X/*+-------------------------------------------------------------------------
  567. X    report_error_count()
  568. X    DOES NOT PERFORM A REFRESH CYCLE
  569. X  this file: row 10 col 29 len 4
  570. X  total:     row 10 col 42 len 6
  571. X--------------------------------------------------------------------------*/
  572. Xreport_error_count()
  573. X{
  574. X    char tmp[16];
  575. X
  576. X    clear_area(win,10,29,4);
  577. X    sprintf(tmp,"%4d",this_file_errors);
  578. X    waddstr(win,tmp);
  579. X
  580. X    clear_area(win,10,42,6);
  581. X    sprintf(tmp,"%6d",total_errors);
  582. X    waddstr(win,tmp);
  583. X    wrefresh(win);
  584. X
  585. X}    /* end of report_error_count */
  586. X
  587. X/*+-------------------------------------------------------------------------
  588. X    report_last_txhdr(rptstr,error_flag)
  589. X    5,7,22
  590. X--------------------------------------------------------------------------*/
  591. Xvoid
  592. Xreport_last_txhdr(rptstr,error_flag)
  593. Xregister char *rptstr;
  594. Xint error_flag;
  595. X{
  596. Xchar s24[24];
  597. X
  598. X    if(log_packets)
  599. X    {
  600. X        write(log_packets,"tx:   ",6);
  601. X        write(log_packets,rptstr,strlen(rptstr));
  602. X        write(log_packets,"\n",1);
  603. X    }
  604. X
  605. X    if(strlen(rptstr) > 22)
  606. X    {
  607. X        strncpy(s24,rptstr,22);
  608. X        s24[23] = 0;
  609. X        rptstr = s24;
  610. X    }
  611. X    clear_area(win,5,7,22);
  612. X    waddstr(win,rptstr);
  613. X    wrefresh(win);
  614. X
  615. X    if(error_flag)
  616. X    {
  617. X        ++this_file_errors;
  618. X        ++total_errors;
  619. X        report_error_count();
  620. X    }
  621. X}    /* end of report_last_txhdr */
  622. X
  623. X/*+-------------------------------------------------------------------------
  624. X    report_last_rxhdr(rptstr,error_flag)
  625. X    5,35,22
  626. X--------------------------------------------------------------------------*/
  627. Xvoid
  628. Xreport_last_rxhdr(rptstr,error_flag)
  629. Xregister char *rptstr;
  630. Xint error_flag;
  631. X{
  632. Xchar s24[24];
  633. Xextern int log_packets;
  634. X
  635. X    if(log_packets)
  636. X    {
  637. X        write(log_packets,"rx: ",4);
  638. X        write(log_packets,(error_flag) ? "E " : "  ",2);
  639. X        write(log_packets,rptstr,strlen(rptstr));
  640. X        write(log_packets,"\n",1);
  641. X    }
  642. X
  643. X    if(strlen(rptstr) > 22)
  644. X    {
  645. X        strncpy(s24,rptstr,22);
  646. X        s24[23] = 0;
  647. X        rptstr = s24;
  648. X    }
  649. X    clear_area(win,5,35,22);
  650. X    waddstr(win,rptstr);
  651. X    wrefresh(win);
  652. X
  653. X    if(error_flag)
  654. X    {
  655. X        ++this_file_errors;
  656. X        ++total_errors;
  657. X        report_error_count();
  658. X    }
  659. X
  660. X}    /* end of report_last_rxhdr */
  661. X
  662. X/*+-------------------------------------------------------------------------
  663. X    report_str(rptstr,error_flag) row 11/12 col 3 len 55
  664. X
  665. X  error_flag == 0 for status/progress message
  666. X             == 1 for bump error count, unless rptstr is null
  667. X                  in which case, merely clear error string area
  668. X             == 2 write string on bottom line (not an error)
  669. X             == 3 write string on transaction line (not an error)
  670. X             == -1 use error line but do not bump error count
  671. X--------------------------------------------------------------------------*/
  672. Xvoid
  673. Xreport_str(rptstr,error_flag)
  674. Xregister char *rptstr;
  675. Xint error_flag;
  676. X{
  677. Xchar s60[60];
  678. Xextern int log_packets;
  679. X
  680. X    if(strlen(rptstr) > 55)
  681. X    {
  682. X        strncpy(s60,rptstr,55);
  683. X        s60[56] = 0;
  684. X        rptstr = s60;
  685. X    }
  686. X
  687. X    switch(error_flag)
  688. X    {
  689. X        case 0:
  690. X            clear_area(win,12,3,55);
  691. X            break;
  692. X        case 1:
  693. X            ++this_file_errors;
  694. X            ++total_errors;
  695. X            report_error_count();
  696. X        case -1:
  697. X            clear_area(win,11,3,55);
  698. X            break;
  699. X        case 2:
  700. X            clear_area(win,13,3,55);
  701. X            break;
  702. X        case 3:
  703. X            clear_area(win,4,3,55);
  704. X            break;
  705. X    }
  706. X
  707. X    waddstr(win,rptstr);
  708. X    wrefresh(win);
  709. X
  710. X    if(log_packets)
  711. X    {
  712. X        write(log_packets,"info: ",6);
  713. X        sprintf(s60,"%2d ",error_flag);
  714. X        write(log_packets,s60,3);
  715. X        write(log_packets,rptstr,strlen(rptstr));
  716. X        write(log_packets,"\n",1);
  717. X    }
  718. X
  719. X}    /* end of report_str */
  720. X
  721. X/*+-------------------------------------------------------------------------
  722. X    report_transaction()
  723. X--------------------------------------------------------------------------*/
  724. Xvoid
  725. Xreport_transaction(str)
  726. Xchar *str;
  727. X{
  728. X    report_str(str,3);
  729. X}    /* end of report_transaction */
  730. X
  731. X/*+-------------------------------------------------------------------------
  732. X    report_file_open_tod() -- time of start of this file
  733. X
  734. X  this file open time: row 8 col 47 length 8
  735. X--------------------------------------------------------------------------*/
  736. Xvoid
  737. Xreport_file_open_tod()
  738. X{
  739. X    clear_area(win,8,47,8);
  740. X    waddstr(win,get_tod(1,(char *)0));
  741. X    wrefresh(win);
  742. X}    /* end of report_file_open_tod */
  743. X
  744. X/*+-------------------------------------------------------------------------
  745. X    report_file_open_length(long_length)
  746. X  length:   row 3 col 36 len  8
  747. X--------------------------------------------------------------------------*/
  748. Xreport_file_open_length(length)
  749. Xlong length;
  750. X{
  751. X    clear_area(win,3,36,8);
  752. X    if(length <= 0)
  753. X        waddstr(win,"unknown");
  754. X    else
  755. X    {
  756. X        sprintf(s128,"%8lu",length);
  757. X        waddstr(win,s128);
  758. X    }
  759. X    wrefresh(win);
  760. X}    /* end of report_file_open_length */
  761. X
  762. X/*+-------------------------------------------------------------------------
  763. X    report_file_send_open(filename,filestat)
  764. X
  765. X  filename: row 2 col 20 len 38
  766. X  number:   row 2 col 8 len 3
  767. X  length:   row 3 col 36 len  8
  768. X  mode:     row 3 col 46 len 10
  769. X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
  770. X--------------------------------------------------------------------------*/
  771. Xvoid
  772. Xreport_file_send_open(filename,filestat)
  773. Xchar *filename;
  774. Xstruct stat *filestat;
  775. X{
  776. Xchar s50[50];
  777. Xregister char *cptr = filename;
  778. Xchar s256[256];
  779. X
  780. X    if(log_packets)
  781. X    {
  782. X        write(log_packets,"file: ",6);
  783. X        write(log_packets,filename,strlen(filename));
  784. X        write(log_packets,"\n",1);
  785. X    }
  786. X
  787. X    /* number */
  788. X    clear_area(win,2,8,3);
  789. X    sprintf(s50,"%3d",Filcnt);
  790. X    waddstr(win,s50);
  791. X
  792. X    /* filename */
  793. X    if(strlen(filename) > 38)
  794. X    {
  795. X        strncpy(s50,filename,38);
  796. X        s50[39] = 0;
  797. X        cptr = s50;
  798. X    }
  799. X    clear_area(win,2,20,38);
  800. X    waddstr(win,cptr);
  801. X
  802. X#if defined(LOG_XFER)
  803. X    sprintf(s256,"sending %s",filename);
  804. X    ecu_log_event(getppid(),s256);
  805. X#endif
  806. X
  807. X    /* length */
  808. X    report_file_open_length(filestat->st_size);
  809. X
  810. X    /* time of start of this file */
  811. X    report_file_open_tod();
  812. X
  813. X    this_file_errors = 0;
  814. X    report_error_count();
  815. X}    /* end of report_file_send_open */
  816. X
  817. X/*+-------------------------------------------------------------------------
  818. X    report_file_rcv_started(filename,length,last_mod_time)
  819. X
  820. X  filename: row 2 col 7 len 50
  821. X  length:   row 3 col 36 len  8 if not xmodem
  822. X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
  823. X--------------------------------------------------------------------------*/
  824. Xreport_file_rcv_started(filename,length,last_mod_time)
  825. Xchar *filename;
  826. Xlong length;                    /* if < 0, "UNKNOWN" */
  827. Xlong last_mod_time;            /* not currently displayed */
  828. X{
  829. Xregister char *cptr;
  830. Xchar s50[50];
  831. Xchar s256[256];
  832. X
  833. X    if(log_packets)
  834. X    {
  835. X        write(log_packets,"file: ",6);
  836. X        write(log_packets,filename,strlen(filename));
  837. X        write(log_packets,"\n",1);
  838. X    }
  839. X
  840. X    /* filename */
  841. X    if(strlen(filename) > 38)
  842. X    {
  843. X        strncpy(s50,filename,38);
  844. X        s50[39] = 0;
  845. X        cptr = s50;
  846. X    }
  847. X    else
  848. X        cptr = filename;
  849. X
  850. X#if defined(LOG_XFER)
  851. X    sprintf(s256,"receiving %s",filename);
  852. X    ecu_log_event(getppid(),s256);
  853. X#endif
  854. X
  855. X    clear_area(win,2,20,38);
  856. X    waddstr(win,cptr);
  857. X
  858. X    /* file number */
  859. X    clear_area(win,2,8,3);
  860. X    sprintf(s50,"%3d",Filcnt);    /* rz uses as file number 1-n */
  861. X    waddstr(win,s50);
  862. X
  863. X/* if remote sender provides a file count, display it */
  864. X    if(npaths)
  865. X    {
  866. X        clear_area(win,2,12,7);    /* clear "of ###" */
  867. X        sprintf(s50,"of %3d:",npaths);
  868. X        waddstr(win,s50);
  869. X    }
  870. X
  871. X    /* length */
  872. X    report_file_open_length(length);
  873. X
  874. X    /* time of start of this file */
  875. X    report_file_open_tod();
  876. X
  877. X    this_file_errors = 0;
  878. X    report_error_count();
  879. X}    /* end of report_file_rcv_started */
  880. X
  881. X/*+-------------------------------------------------------------------------
  882. X    report_file_close()
  883. X--------------------------------------------------------------------------*/
  884. Xvoid report_file_close()
  885. X{
  886. X    report_str("End of file",0);
  887. X    wrefresh(win);
  888. X
  889. X}    /* end of report_file_close */
  890. X
  891. X/*+-------------------------------------------------------------------------
  892. X    report_file_byte_io(count)
  893. X--------------------------------------------------------------------------*/
  894. Xreport_file_byte_io(count)
  895. Xlong count;
  896. X{
  897. X
  898. X    total_data_chars_xfered += (long)count;
  899. X    if(total_data_chars_xfered)
  900. X    {
  901. X        sprintf(s128,"Total file bytes transferred: %lu",
  902. X            total_data_chars_xfered);
  903. X        report_str(s128,-1);
  904. X    }
  905. X
  906. X}    /* end of report_file_byte_io */
  907. X
  908. X/* end of scurses.c */
  909. X/* vi: set tabstop=4 shiftwidth=4: */
  910. SHAR_EOF
  911. $TOUCH -am 1208015790 'sea/scurses.c' &&
  912. chmod 0644 sea/scurses.c ||
  913. echo 'restore of sea/scurses.c failed'
  914. Wc_c="`wc -c < 'sea/scurses.c'`"
  915. test 22139 -eq "$Wc_c" ||
  916.     echo 'sea/scurses.c: original size 22139, current size' "$Wc_c"
  917. # ============= sea/sealink.doc ==============
  918. echo 'x - extracting sea/sealink.doc (Text)'
  919. sed 's/^X//' << 'SHAR_EOF' > 'sea/sealink.doc' &&
  920. X                                     SEALINK
  921. X
  922. X                             File Transfer Protocol
  923. X
  924. X                                 9 February 1987
  925. X
  926. X
  927. X
  928. X          (C) COPYRIGHT 1986,87 by System Enhancement Associates, Inc.
  929. X
  930. X
  931. X
  932. X     This document describes briefly the  SEAlink  file  transfer  protocol
  933. X     developers' package.  SEAlink is a sliding  window  protocol  that  is
  934. X     fully  backwards compatible with XMODEM in all tested implementations.
  935. X
  936. X     The intent of SEAlink is to provide a file transfer protocol that does
  937. X     not  suffer  from  propagation  delays,  such  as  are  introduced  by
  938. X     satellite relays or packet switched  networks.  Actual  tests  of  the
  939. X     enclosed  routines  has  shown  that  SEAlink  is capable of virtually
  940. X     eliminating propagation delays and turnaround delays.  File  transfers
  941. X     between New Jersey and Hawaii,  which normally suffer a degradation of
  942. X     50% or more  due  to  satellite  relays,  proceed  as  fast  as  local
  943. X     transfers.  Even transfers within the local exchange are speeded up by
  944. X     up to 20% at 2400 baud by the elimination of turnaround delays.  Large
  945. X     volume  tests  show  that SEAlink is capable of coming to within 2% of
  946. X     the theoretical minimum time for data transfer.
  947. X
  948. X
  949. X
  950. X     The developers' package contains the following files:
  951. X
  952. X         SEALINK.DOC    This document.
  953. X         SEALINK.C      A set of C routines for implementing SEAlink.
  954. X         CLINK.EXE      A sample TTY program that implements SEAlink.
  955. X
  956. X
  957. X
  958. X     You are granted a license to use this code in your  programs,  and  to
  959. X     adapt  it to your particular situation and needs,  subject only to the
  960. X     following conditions:
  961. X
  962. X     1) You must refer to it as the SEAlink protocol,  and  you  must  give
  963. X        credit to System Enhancement Associates.
  964. X
  965. X     2) If  you  modify  it in such a way that your version cannot converse
  966. X        with the original code as supplied by us,  then you should refer to
  967. X        it as "SEAlink derived",  or as a "variation of SEAlink",  or words
  968. X        to that effect.
  969. X
  970. X     In short,  we're not asking for any money,  but we'd like to get  some
  971. X     credit for our work.
  972. X
  973. X
  974. X     This  document  is  not  meant  to  be  a  rigorous  definition of the
  975. X     protocol.  The code provided should serve to document the details  and
  976. X     fine  points  of  implementing SEAlink.  We will,  however,  present a
  977. X     brief synopsis of how SEAlink adds sliding windows to XMODEM,  and why
  978. X     XMODEM doesn't mind.
  979. X
  980. X     First of all,  SEAlink adds a block number to the ACK and NAK used  in
  981. X     XMODEM.(1)  We  thus  create  "ACK/NAK  packets",  with  the following
  982. X     structure:
  983. X
  984. X         Byte 0:   ACK, NAK, or C
  985. X         Byte 1:   Block number
  986. X         Byte 2:   One's compliment of block number
  987. X
  988. X     This is identical in form to the first three bytes of a  data  packet,
  989. X     except that the SOH has been replaced with an ACK or NAK.(2)
  990. X
  991. X     From the receiver's point of view,  it does not matter if  the  trans-
  992. X     mitter  is using sliding window or not.  The receiver simply sends ACK
  993. X     and NAK packets as appropriate.  Any XMODEM driver tested to date will
  994. X     simply ignore this excess data behind the ACK or NAK.
  995. X
  996. X     From the transmitter's point of view,  it just barely matters  if  the
  997. X     receiver can handle sliding window.  The transmitter always acts as if
  998. X     it  is  sending sliding window,  but varies the window size.  If it is
  999. X     seeing valid block numbers and check values behind the  received  ACKs
  1000. X     and NAKs,  it sets the window size to six blocks.  Otherwise,  it sets
  1001. X     the  window  size  to  one  block.  The  result is that it only "sends
  1002. X     ahead" if the receiver can handle it.
  1003. X
  1004. X     It  should  be  a fairly simple matter to apply the underlying SEAlink
  1005. X     logic to almost any variant of XMODEM.
  1006. X
  1007. X
  1008. X     The  SEAlink  routines  provided  in  this package are also capable of
  1009. X     passing system dependent information,  such as true file size and time
  1010. X     of  last modification.  This data is passed in a special header block.
  1011. X     The header block looks exactly like any other block, except that it is
  1012. X     block number zero.
  1013. X
  1014. X     This is still backwards compatible with XMODEM,  as a SEAlink receiver
  1015. X     does  not  mind if block zero is missing,  and any XMODEM receiver yet
  1016. X     tested will regard block zero as a duplicate block and ACK it.
  1017. X
  1018. X     The data portion of block zero contains the following fields:
  1019. X
  1020. X
  1021. X         Offset    Size      Contents
  1022. X         ======    ====      ========
  1023. X
  1024. X            0        4       Original file length.
  1025. X            4        4       Date  and  time  file  was  last mofified,  in
  1026. X                             seconds since 1979.
  1027. X            8       17       Original  file  name,  as  a  null  terminated
  1028. X                             string.
  1029. X           25       15       Name  of  transmitting  program,   as  a  null
  1030. X                             terminated string.
  1031. X           40       88       Null filler and expansion area.
  1032. X
  1033. X
  1034. X     (1) XMODEM/CRC uses a "C" in place of  a  NAK  to  indicate  CRC  error
  1035. X         detection.  SEAlink  follows  this convention,  and supports either
  1036. X         checksum or CRC.  For brevity,  this document will use the term NAK
  1037. X         to mean either a true NAK (hex 15) or a C (hex 43).
  1038. X     (2) See previous footnote.
  1039. X
  1040. X     Any field which the transmitter cannot support should be  set  to  all
  1041. X     zeros.  Conversly,  the  receiver  should ignore any null fields.  The
  1042. X     receiver may ignore any field which he cannot support.
  1043. X
  1044. X
  1045. X
  1046. X     The  routines  enclosed  in  this package should be reasonably easy to
  1047. X     implement in your application.  We have attempted to exclude  compiler
  1048. X     dependent and system dependent logic from these routines.
  1049. X
  1050. X
  1051. X     You will need to alter our references to our communications driver  to
  1052. X     conform  to  your  own driver.  The communications related routines we
  1053. X     use are:
  1054. X
  1055. X         com_putc(c)         Output character c to comm port.
  1056. X
  1057. X         int com_getc(t)     Get character from comm port within  t  tenths
  1058. X                             of   a  second.   Return  EOF  if  time  limit
  1059. X                             expires.
  1060. X
  1061. X         com_dump()          Discard any pending output without sending it.
  1062. X
  1063. X
  1064. X     In  addition,  we  use  the  following  routines for controlling timed
  1065. X     loops:
  1066. X
  1067. X         long timerset(t)    Set a timer.  Returns a timer value which will
  1068. X                             expire in t tenths of a second.
  1069. X
  1070. X         int timeup(z)       Check a timer.  Returns true if  timer  z  has
  1071. X                             expired yet, or false otherwise.
  1072. X
  1073. X
  1074. X     These routines also make reference to the following functions for
  1075. X     system dependent information, which is optional:
  1076. X
  1077. X         filestat(name,&fs)  Read directory entry for  a  file  and  return
  1078. X                             system dependent information.
  1079. X
  1080. X         setstamp(f,dtg)     Set a file's date/time of last modification.
  1081. X
  1082. X
  1083. X
  1084. X
  1085. X     The SEAlink  implementation  provided  in  this  package  is  used  by
  1086. X     invoking the two primary routines:
  1087. X
  1088. X
  1089. X         int xmtfile(name)             /* transmit a file */
  1090. X         char *name;                   /* name of file to transmit */
  1091. X
  1092. X     This  routine is used to send a file.  One file is sent at a time.  If
  1093. X     the  name  is blank (name is null or *name points to a null),  then an
  1094. X     end of transmission marker is sent.
  1095. X
  1096. X     This routine returns a one if the file is successfully transmitted, or
  1097. X     a zero if a fatal error occurs.
  1098. X
  1099. X
  1100. X         char *rcvfile(name)           /* receive a file */
  1101. X         char *name;                   /* name of file (optional) */
  1102. X
  1103. X     This routine is used to receive a file.  One file is  received.  If  a
  1104. X     name is specified for the file,  then that name WILL be used,  and any
  1105. X     name  sent  by  the transmitter will be ignored.  If the name is blank
  1106. X     (name is null or *name points to a null),  then the  transmitter  must
  1107. X     provide a name for the file.
  1108. X
  1109. X     This routine returns a pointer to  the  name  of  the  file  that  was
  1110. X     received.  If the file transfer is not successful, then a null pointer
  1111. X     is returned.
  1112. X
  1113. X     The  pointer  returned  by  rcvfile()  points to a static data buffer.
  1114. X     This does not have to be freed (and should not be),  but  it  will  be
  1115. X     overwritten the next time rcvfile() is called.
  1116. X
  1117. X     The  rcvfile()  function  works  on a temporary file whose name is the
  1118. X     same as the final file,  but with a dash ("-") added at the beginning.
  1119. X     If  a  file  transfer  is  aborted,  then  this temporary file will be
  1120. X     retained.  An aborted file transfer will not harm a pre-existing  file
  1121. X     of the same name.
  1122. X
  1123. X
  1124. X
  1125. X     These  routines  can  be  used  for  either  single  or  multiple file
  1126. X     transfers.
  1127. X
  1128. X     To  send  multiple  files,  send  each  file one by one until either a
  1129. X     transmit fails or all files are sent.  If all  files  are  sent,  then
  1130. X     signal the end by calling xmtfile() with a null pointer.
  1131. X
  1132. X     To receive multiple files,  call rcvfile() repeatedly until it returns
  1133. X     a null pointer.
  1134. X
  1135. X
  1136. X
  1137. X     This  package includes a demonstration program named CLINK (pronounced
  1138. X     "clink"),  which is a  simple  TTY  program  for  doing  SEAlink  file
  1139. X     transfers.  CLINK  does  not  perform  any  sort of terminal emulation
  1140. X     whatsoever.  However,  she will make use of the ANSI.SYS screen driver
  1141. X     if you have it installed.
  1142. X
  1143. X
  1144. X     CLINK may be used in either of two ways: interactive mode or command
  1145. X     mode.
  1146. X
  1147. X     To use CLINK in the interactive mode, give the command "CLINK" with no
  1148. X     arguments.  Press  the  "ESCape"  key to give a command to CLINK.  The
  1149. X     command "?" (question mark) instructs CLINK to tell you what  commands
  1150. X     she understands.
  1151. X
  1152. X     To  use  CLINK  in the command mode,  give the command "CLINK" with an
  1153. X     argument.  There are three arguments you can give CLINK in the command
  1154. X     mode.  These are:
  1155. X
  1156. X      1) Receive files;  Do this with a command of the form:
  1157. X
  1158. X              CLINK R
  1159. X
  1160. X         CLINK  will  attempt  to receive one or more files from COM1,  and
  1161. X         will terminate as soon as all files  are  received,  or  when  the
  1162. X         transfer aborts.
  1163. X
  1164. X      2) Transmit files; Do this with a command of the form:
  1165. X
  1166. X              CLINK T <filename> ...
  1167. X
  1168. X         CLINK  will  attempt  to transmit the listed files over COM1,  and
  1169. X         will terminate as soon as all files are sent,  or the transfer  is
  1170. X         aborted.  <filename> may be one or more file names with or without
  1171. X         drive and path specifiers.  Wildcards may be used.
  1172. X
  1173. X      3) Give help;  If you type:
  1174. X
  1175. X              CLINK ?
  1176. X
  1177. X         or any invalid command,  CLINK will display a  brief  reminder  of
  1178. X         what arguments she understands in command mode.
  1179. X
  1180. X     In all cases, CLINK in the command mode will not alter the serial port
  1181. X     other than to set eight data bits,  one stop bit,  and no parity.  Any
  1182. X     previously installed serial drivers will be  replaced,  and  the  baud
  1183. X     rate will not be changed.
  1184. X
  1185. X
  1186. X
  1187. X     CLINK comes with her own serial driver built in for the IBM PC  family
  1188. X     and true compatibles,  but she is capable of using any standard FOSSIL
  1189. X     driver.
  1190. X
  1191. SHAR_EOF
  1192. $TOUCH -am 1114021689 'sea/sealink.doc' &&
  1193. chmod 0644 sea/sealink.doc ||
  1194. echo 'restore of sea/sealink.doc failed'
  1195. Wc_c="`wc -c < 'sea/sealink.doc'`"
  1196. test 11247 -eq "$Wc_c" ||
  1197.     echo 'sea/sealink.doc: original size 11247, current size' "$Wc_c"
  1198. # ============= sea/sealink.imp ==============
  1199. echo 'x - extracting sea/sealink.imp (Text)'
  1200. sed 's/^X//' << 'SHAR_EOF' > 'sea/sealink.imp' &&
  1201. X    SEAlink - Sliding window file transfer protocol
  1202. X
  1203. X    XENIX System V version by Scott Reynolds
  1204. X    additional XENIX modifications by Sanford Zelkovitz, without whose help
  1205. X    this couldn't have been accomplished
  1206. X
  1207. X    Based on:
  1208. X
  1209. X    MS-DOS Version 1.16, created on 01/15/87 at 01:40:52
  1210. X(C) COPYRIGHT 1986,87 by System Enhancement Associates; ALL RIGHTS RESERVED
  1211. X    By:  Thom Henderson
  1212. X
  1213. X    Description:
  1214. X
  1215. X    This file contains a set of routines to illustrate the SEAlink
  1216. X    sliding window file transfer protocol.  SEAlink is fully backward
  1217. X    compatible to XMODEM, and can be easily adapted to most XMODEM
  1218. X    variants.
  1219. X
  1220. X    The intent of SEAlink is to provide a file transfer protocol that
  1221. X    does not suffer from propagation delays, such as are introduced
  1222. X    by satellite relays or packet switched networks.
  1223. X
  1224. X    Instructions:
  1225. X
  1226. X    Two routines are provided to implement SEAlink file transfers.
  1227. X
  1228. X    int xmtfile(name)        /+ transmit a file +/
  1229. X    char *name;            /+ name of file to transmit +/
  1230. X
  1231. X    This routine is used to send a file.  One file is sent at a time.
  1232. X    If the name is blank (name is null or *name points to a null),
  1233. X    then only an end of transmission marker is sent.
  1234. X
  1235. X    This routine returns a one if the file is successfully
  1236. X    transmitted, or a zero if a fatal error occurs.
  1237. X
  1238. X    char *rcvfile(name)        /+ receive a file +/
  1239. X    char *name;            /+ name of file (optional) +/
  1240. X
  1241. X    This routine is used to receive a file.  One file is received.
  1242. X    The name, if given, takes precedence and will be the name of
  1243. X    the resulting file.  If the name is blank (name is null or *name
  1244. X    points to a null), then the name given by the transmitter is used.
  1245. X    If the transmitter does not give a name, then the file transfer
  1246. X    is aborted.
  1247. X
  1248. X    This routine returns a pointer to the name of the file that
  1249. X    was received.  If the file transfer is not successful, then
  1250. X    a null pointer is returned.
  1251. X
  1252. X    The pointer returned by rcvfile() points to a static data buffer.
  1253. X    This does not have to be freed (and should not be), but it will
  1254. X    be overwritten the next time rcvfile() is called.
  1255. X
  1256. X    The rcvfile() function works on a temporary file whose name is
  1257. X    the same as the final file, but with a period (".") added at the
  1258. X    beginning.  If a file transfer is aborted, then this temporary
  1259. X    file will be retained.  An aborted file transfer will not harm
  1260. X    a pre-existing file of the same name.
  1261. X
  1262. X    Programming notes:
  1263. X
  1264. X    These routines can be used for either single or multiple file
  1265. X    transfers.
  1266. X
  1267. X    To send multiple files, send each one one at a time until either
  1268. X    a transmit fails or all files are sent.  If all files are sent,
  1269. X    then signal the end by calling xmtfile() with a null pointer.
  1270. X
  1271. X    To receive multiple files, call rcvfile() repeatedly until it
  1272. X    returns a null pointer.
  1273. X
  1274. X    These routines pass a "block zero", which contains information
  1275. X    about the original file name, size, and date/time of last
  1276. X    modification.  If you cannot implement block zero, then you can
  1277. X    leave it out.  If you cannot set any given field in block zero
  1278. X    when transmitting, then you should leave it set to zeros.  If you
  1279. X    cannot use any given field of block zero when receiving, then
  1280. X    you should ignore it.
  1281. X
  1282. X    These routines are fully compatible with XMODEM, including the
  1283. X    original checksum method and later CRC adaptations.  It can be
  1284. X    easily adapted to Modem7 protocol by adding a Modem7 filename
  1285. X    transfer shell, though we do not recommend it.  The underlying
  1286. X    logic, of course, can be adapted to almost any variant of XMODEM.
  1287. X
  1288. X    License:
  1289. X
  1290. X    You are granted a license to use this code in your programs, and
  1291. X    to adapt it to your particular situation and needs, subject only
  1292. X    to the following conditions:
  1293. X
  1294. X    1)   You must refer to it as the SEAlink protocol, and you must
  1295. X         give credit to System Enhancement Associates.
  1296. X
  1297. X    2)   If you modify it in such a way that your version cannot
  1298. X         converse with the original code as supplied by us, then
  1299. X         you should refer to it as "SEAlink derived", or as a
  1300. X         "variation of SEAlink", or words to that effect.
  1301. X
  1302. X    In short, we're not asking for any money, but we'd like to
  1303. X    get some credit for our work.
  1304. X
  1305. X    Language:
  1306. X
  1307. X    Computer Innovations C86
  1308. X    Adapted for IBM PC XENIX 2.00.2 C using UNIX System V compatible calls
  1309. X
  1310. X    Notes on XENIX modifications:
  1311. X
  1312. X    The com_getc() routine has a minimum delay of .1 seconds, due
  1313. X    to the nature of the read() system call.  Attempts to eliminate
  1314. X    this delay have proven more costly than leaving it in.
  1315. X
  1316. X    CRC maintenance functions were added to the original code, as
  1317. X    they are not library calls under XENIX.
  1318. X
  1319. X    All output is performed through file descriptor 0, and is done
  1320. X    in blocks using the write() system call rather than individual
  1321. X    character writes.  File descriptor 1 may be selected by invoking
  1322. X    the program with a "-1" argument.
  1323. X
  1324. X    Most low level routines utilize register class variables to
  1325. X    decrease overhead and improve overall system response slightly.
  1326. X
  1327. X    A rudimentary command line processor was added to the original
  1328. X    routines to drive the transmitter and receiver.  The two
  1329. X    options, "s" and "r", are for sending and receiving respectively.
  1330. X
  1331. X    When invoked without proper arguments the program will display
  1332. X    a short message including usage notes.
  1333. X
  1334. X    -- Scott Reynolds, Sysop U.S.S. Enterprise BBS, (906)228-9460
  1335. SHAR_EOF
  1336. $TOUCH -am 0917230787 'sea/sealink.imp' &&
  1337. chmod 0644 sea/sealink.imp ||
  1338. echo 'restore of sea/sealink.imp failed'
  1339. Wc_c="`wc -c < 'sea/sealink.imp'`"
  1340. test 5213 -eq "$Wc_c" ||
  1341.     echo 'sea/sealink.imp: original size 5213, current size' "$Wc_c"
  1342. # ============= gendial/Makefile ==============
  1343. if test ! -d 'gendial'; then
  1344.     echo 'x - creating directory gendial'
  1345.     mkdir 'gendial'
  1346. fi
  1347. echo 'x - extracting gendial/Makefile (Text)'
  1348. sed 's/^X//' << 'SHAR_EOF' > 'gendial/Makefile' &&
  1349. X#  CHK=0xE274
  1350. X#
  1351. X# uucp dialer makefile
  1352. X#
  1353. X#+:EDITS:*/
  1354. X#:11-29-1990-18:09-wht@n4hgf-add dialgMPAD
  1355. X#:07-19-1990-17:12-root@n4hgf-add gendial/dialgT2500
  1356. X
  1357. XLDFLAGS = -s -i
  1358. XCFLAGS  = -Octl -DHDUU
  1359. X
  1360. XEXES   = dialgT2500 dialgT1000
  1361. XOBJS    =
  1362. XLIBS    = -lx
  1363. X
  1364. X.SUFFIXES:
  1365. X.SUFFIXES: .c .o .h
  1366. X
  1367. X.c.o:; cc -c $(CFLAGS) $*.c
  1368. X
  1369. Xall: dialgT2500
  1370. X#all:    $(EXES)
  1371. X
  1372. XdialgMC9624: gendial.o dceMC9624.o
  1373. X    cc $(CFLAGS) gendial.o dceMC9624.o $(LIBS) -o $@
  1374. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1375. X
  1376. XdialgTBPlus: gendial.o dceTBPlus.o
  1377. X    cc $(CFLAGS) gendial.o dceTBPlus.o $(LIBS) -o $@
  1378. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1379. X
  1380. XdialgMPAD: gendial.o dceMPAD.o
  1381. X    cc $(CFLAGS) gendial.o dceMPAD.o $(LIBS) -o $@
  1382. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1383. X
  1384. XdialgT2500: gendial.o dceT2500.o
  1385. X    cc $(CFLAGS) gendial.o dceT2500.o $(LIBS) -o $@
  1386. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1387. X
  1388. XdialgT1000: gendial.o dceT1000.o
  1389. X    cc $(CFLAGS) gendial.o dceT1000.o $(LIBS) -o $@
  1390. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1391. X
  1392. X# provide for standard SCO dialers
  1393. XdialHA12: dialHA12.c
  1394. X    cc $(CFLAGS) dialHA12.c $(LIBS) -o $@
  1395. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1396. X
  1397. XdialHA24: dialHA24.c
  1398. X    cc $(CFLAGS) dialHA24.c $(LIBS) -o $@
  1399. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1400. X
  1401. XdialMUL: dialMUL.c
  1402. X    cc $(CFLAGS) dialMUL.c $(LIBS) -o $@
  1403. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1404. X
  1405. XdialTBIT: dialTBIT.c
  1406. X    cc $(CFLAGS) dialTBIT.c $(LIBS) -o $@
  1407. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1408. X
  1409. XdialT2500: dialT2500.c
  1410. X    cc $(CFLAGS) dialT2500.c $(LIBS) -o $@
  1411. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1412. X
  1413. XdialVA3450: dialVA3450.c
  1414. X    cc $(CFLAGS) dialVA3450.c $(LIBS) -o $@
  1415. X    chown uucp $@; chgrp uucp $@; chmod 711 $@
  1416. X
  1417. Xgendial.o: dialer.h
  1418. XdceT2500.o: dialer.h
  1419. XdceMC9624.o: dialer.h
  1420. SHAR_EOF
  1421. $TOUCH -am 1129180990 'gendial/Makefile' &&
  1422. chmod 0644 gendial/Makefile ||
  1423. echo 'restore of gendial/Makefile failed'
  1424. Wc_c="`wc -c < 'gendial/Makefile'`"
  1425. test 1713 -eq "$Wc_c" ||
  1426.     echo 'gendial/Makefile: original size 1713, current size' "$Wc_c"
  1427. # ============= gendial/dialer.h ==============
  1428. echo 'x - extracting gendial/dialer.h (Text)'
  1429. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dialer.h' &&
  1430. X/*+-------------------------------------------------------------------------
  1431. X    dialer.h - SCO UUCP generic dialer program definitions
  1432. X    wht%n4hgf.uucp@emory.mathcs.emory.edu -or- emory!n4hgf!wht
  1433. X--------------------------------------------------------------------------*/
  1434. X/*+:EDITS:*/
  1435. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1436. X
  1437. X#include <stdio.h>
  1438. X#include <ctype.h>
  1439. X#include <errno.h>
  1440. X#include <fcntl.h>
  1441. X#include <setjmp.h>
  1442. X#include <signal.h>
  1443. X#include <sys/types.h>
  1444. X#include <sys/errno.h>
  1445. X#include <sys/ioctl.h>
  1446. X#include <sys/stat.h>
  1447. X#include <termio.h>
  1448. X#include <time.h>
  1449. X#include <pwd.h>
  1450. X
  1451. X#define ff fprintf
  1452. X#define se stderr
  1453. X
  1454. Xchar *strdup();
  1455. Xchar *strchr();
  1456. Xchar *strrchr();
  1457. Xstruct passwd *getpwnam();
  1458. X
  1459. Xextern int errno;
  1460. Xextern char *sys_errlist[];
  1461. X
  1462. Xextern int gargc;                    /* global copy of main's argv */
  1463. Xextern char **gargv;                /* global copy of main's argv */
  1464. Xextern char *dce_name;                /* full pathname of ACU device */
  1465. Xextern char *telno;                    /* phone number if dial type request */
  1466. Xextern struct termio dce_termio;    /* last termio for device */
  1467. Xextern int Debug;                    /* set per -x flag */
  1468. Xextern int dialing;                    /* set while dialing in progress */
  1469. Xextern int fddce;                    /* file descriptor for dce_name */
  1470. Xextern int DialerExitCode;             /* return code */
  1471. Xextern int status;                    /* set on errors */
  1472. Xextern int hangup_flag;                /* set when DCE being hung up */
  1473. Xextern int hiCBAUD;                    /* highest permissible baud rate */
  1474. Xextern int loCBAUD;                    /* lowest permissible baud rate */
  1475. Xextern int uid;                        /* user id of executor */
  1476. Xextern int uid_uucp;                /* user id of uucp */
  1477. Xextern int secure;                    /* non-zero to suppress display of secure
  1478. X                                     * DCE traffic
  1479. X                                     */
  1480. X
  1481. Xunsigned char dialer_codes[26];    /* A-Z embedded phone number codes */
  1482. X/* return codes: these are set up so that an abort signal at any time can */
  1483. X/* set the fail bit and return to the caller with the correct status */
  1484. X#define    SUCCESS        0
  1485. X#define    RC_FAIL        0x80    /* 1 = failed to connect */
  1486. X#define    RC_ENABLED    0x10    /* enabled flag: 1 = ungetty -r required to
  1487. X                             * restore the line
  1488. X                             */
  1489. X#define    RC_BAUD        0x0f    /* CBAUD connected at (0=same as dialed speed) */
  1490. X
  1491. X/* DCE result device independent flag */
  1492. X#define    rfNumeric    0x40000000
  1493. X
  1494. X/* program exit codes */
  1495. X#define    RCE_NULL    0    /* general purpose or unknown error code */
  1496. X#define    RCE_INUSE    1    /* line in use */
  1497. X#define    RCE_SIG        2    /* signal aborted dialer */
  1498. X#define    RCE_ARGS    3    /* invalid arguments */
  1499. X#define    RCE_PHNO    4    /* invalid phone number */
  1500. X#define    RCE_SPEED    5    /* invalid baud rate -or- bad connect baud */
  1501. X#define    RCE_OPEN    6    /* can't open line */
  1502. X#define    RCE_IOCTL    7    /* ioctl error */
  1503. X#define    RCE_TIMOUT    8    /* timeout */
  1504. X#define    RCE_NOTONE    9    /* no dial tone */
  1505. X#define    RCE_HANGUP    10    /* hangup failed */
  1506. X#define RCE_NORESP    11    /* Modem didn't respond. */
  1507. X#define    RCE_BUSY    13    /* phone is busy */
  1508. X#define    RCE_NOCARR    14    /* no carrier */
  1509. X#define    RCE_ANSWER    15    /* no answer */
  1510. X
  1511. X/* ungetty return codes */
  1512. X#define    UG_NOTENAB    0
  1513. X#define    UG_ENAB        1
  1514. X#define    UG_RESTART    1
  1515. X#define    UG_FAIL        2
  1516. X
  1517. X/* size for various buffers */
  1518. X#define MAXLINE        80
  1519. X
  1520. X/* How many errors allowed before call retry fails */
  1521. X#define    DIAL_ERRORS_MAX    4
  1522. X
  1523. X/* DCE message to code mapping struct ... array DCE_results of these
  1524. X * must be terminated with { (char *)0,0 } */
  1525. Xtypedef struct dce_result
  1526. X{
  1527. X    char *result;
  1528. X    long code;
  1529. X} DCE_RESULT;
  1530. X
  1531. X#define DEBUG(level,fmt,arg) if (Debug >= level) fprintf(stderr,fmt,arg)
  1532. X#if !defined(DBG)
  1533. X#define    DBG    0
  1534. X#endif
  1535. X
  1536. X/*
  1537. X * what the hell does __STDC__ mean in reality?  An __STDC__ compiler is
  1538. X * more nouveau than an older one.  ANSI C (or 'D') just stirred new
  1539. X * food for "standard" readers who went off and did what they wanted
  1540. X * to do.  We use __STDC__ to decide between two opinions of
  1541. X * what constitute "ANSI prototypes."  As of this writing, __STDC__ is
  1542. X * defined by the UNIX (MSC 5) compiler and not by the XENIX (MSC 4)
  1543. X * compiler.
  1544. X */
  1545. X#ifdef __STDC__
  1546. Xextern  int DCE_baud_to_CBAUD(unsigned int baud);
  1547. Xextern  void DCE_hangup(void );
  1548. Xextern  int DCE_dial(char *telno);
  1549. Xextern  void DCE_abort(int sig);
  1550. Xextern  void DCE_exit(int exitcode);
  1551. Xextern  int DCE_argv_hook(int argc,char * *argv,int optind,int unrecognized_switches);
  1552. Xextern  int get_uucp_uid(void );
  1553. Xextern  int instr(char *s1,char *s2);
  1554. Xextern  void translate(char *ttab,char *str);
  1555. Xextern  int decode_phone_number(char *userphno,char *result,int resultlen);
  1556. Xextern  char *make_printable(unsigned char ch);
  1557. Xextern  char *RCE_text(int value);
  1558. Xextern  void myexit(int code);
  1559. Xextern  int dial_abort(int sig);
  1560. Xextern  void cleanup(int stat);
  1561. Xextern  int SIGALRM_abort(int sig);
  1562. Xextern  int SIGALRM_alert(int sig);
  1563. Xextern  long _lread(int rtime,int error_ok);
  1564. Xextern  long lread_ignore(int rtime);
  1565. Xextern  long lread(int rtime);
  1566. Xextern  int lflush(void );
  1567. Xextern  void _lputc(char lchar);
  1568. Xextern  void _lputc_paced(long pace_msec,char lchar);
  1569. Xextern  void _lputs(char *string);
  1570. Xextern  void _lputs_paced(long pace_msec,char *string);
  1571. Xextern  int lwrite(char *str);
  1572. Xextern  int ltoggleDTR(long msec);
  1573. Xextern  int call_ungetty(char call_type);
  1574. Xextern  void display_termio(struct termio *ttt,char *text);
  1575. Xextern  int open_dce(void );
  1576. Xextern  int main(int argc,char * *argv);
  1577. X#else
  1578. Xextern  int DCE_baud_to_CBAUD(unsigned int baud);
  1579. Xextern  void DCE_hangup(void );
  1580. Xextern  int DCE_dial(char *telno);
  1581. Xextern  void DCE_abort(int sig);
  1582. Xextern  void DCE_exit(int exitcode);
  1583. Xextern  int DCE_argv_hook(int argc,char * *argv,int optind,int unrecognized_switches);
  1584. Xextern  int get_uucp_uid(void );
  1585. Xextern  int instr(char *s1,char *s2);
  1586. Xextern  void translate(char *ttab,char *str);
  1587. Xextern  int decode_phone_number(char *userphno,char *result,int resultlen);
  1588. Xextern  char *make_printable(unsigned char ch);
  1589. Xextern  char *RCE_text(int value);
  1590. Xextern  void myexit(int code);
  1591. Xextern  int dial_abort(int sig);
  1592. Xextern  void cleanup(int stat);
  1593. Xextern  int SIGALRM_abort(int sig);
  1594. Xextern  int SIGALRM_alert(int sig);
  1595. Xextern  long _lread(int rtime,int error_ok);
  1596. Xextern  long lread_ignore(int rtime);
  1597. Xextern  long lread(int rtime);
  1598. Xextern  int lflush(void );
  1599. Xextern  void _lputc(char lchar);
  1600. Xextern  void _lputc_paced(long pace_msec,char lchar);
  1601. Xextern  void _lputs(char *string);
  1602. Xextern  void _lputs_paced(long pace_msec,char *string);
  1603. Xextern  int lwrite(char *str);
  1604. Xextern  int ltoggleDTR(long msec);
  1605. Xextern  int call_ungetty(char call_type);
  1606. Xextern  void display_termio(struct termio *ttt,char *text);
  1607. Xextern  int open_dce(void );
  1608. Xextern  int main(int argc,char * *argv);
  1609. X#endif
  1610. X
  1611. X/* vi: set tabstop=4 shiftwidth=4: */
  1612. X/* end of dialer.h */
  1613. SHAR_EOF
  1614. $TOUCH -am 0919224990 'gendial/dialer.h' &&
  1615. chmod 0644 gendial/dialer.h ||
  1616. echo 'restore of gendial/dialer.h failed'
  1617. Wc_c="`wc -c < 'gendial/dialer.h'`"
  1618. test 6539 -eq "$Wc_c" ||
  1619.     echo 'gendial/dialer.h: original size 6539, current size' "$Wc_c"
  1620. true || echo 'restore of gendial/gendial.c failed'
  1621. echo End of part 24, continue with part 25
  1622. exit 0
  1623. --------------------------------------------------------------------
  1624. Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  1625. Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  1626.  
  1627. exit 0 # Just in case...
  1628. -- 
  1629. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1630. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1631. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1632. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1633.