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

  1. From: wht@n4hgf.uucp (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v16i031:  ECU async comm package rev 3.0, Part07/35
  4. Message-ID: <1991Jan6.051918.27571@sparky.IMD.Sterling.COM>
  5. Date: 6 Jan 91 05:19:18 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 2283ab67 bede04c2 382a8656 6e76f3e9
  8.  
  9. Submitted-by: wht@n4hgf.uucp (Warren Tucker)
  10. Posting-number: Volume 16, Issue 31
  11. Archive-name: ecu3/part07
  12.  
  13. ---- Cut Here and feed the following to sh ----
  14. #!/bin/sh
  15. # This is part 07 of ecu3
  16. if touch 2>&1 | fgrep 'amc' > /dev/null
  17.  then TOUCH=touch
  18.  else TOUCH=true
  19. fi
  20. # ============= ecusetup.c ==============
  21. echo 'x - extracting ecusetup.c (Text)'
  22. sed 's/^X//' << 'SHAR_EOF' > 'ecusetup.c' &&
  23. X/*+-------------------------------------------------------------------------
  24. X    ecusetup.c -- ecu visual "argv"
  25. X    wht@n4hgf.Mt-Park.GA.US
  26. X
  27. X  0000000000111111111122222222223333333333444444444455555555556666
  28. X  0123456789012345678901234567890123456789012345678901234567890123
  29. X00.--[ ecu rev ]-------------------------------------------------.
  30. X01|                                                              |
  31. X02|  Name/phone number to call: ...................              |
  32. X03|  ...................        ................................ |
  33. X04|                                                              |
  34. X05|  tty: /dev/tty.....   (opened)                               | 
  35. X06|                                                              |
  36. X07|  duplex: .  baud: .....  parity: . (data bits .)             |
  37. X08|  Add NL to transmitted CR: .                                 |
  38. X09|  Add NL to received CR:    .                                 |
  39. X10|                                                              |
  40. X11|                                                              |
  41. X12|   TAB:next ^B:prev END:proceed ^D:phone dir  ESC:quit ecu    |
  42. X13`--------------------------------------------------------------'
  43. X
  44. X  Defined functions:
  45. X    setup_display_baud()
  46. X    setup_display_name()
  47. X    setup_display_screen(write_lits)
  48. X    setup_display_single_char()
  49. X    setup_display_tty()
  50. X    setup_line_open()
  51. X    setup_open_status()
  52. X    setup_screen(argv_logical)
  53. X    setw_bot_msg(msg)
  54. X    setw_get_single(nondelim_list)
  55. X
  56. X--------------------------------------------------------------------------*/
  57. X/*+:EDITS:*/
  58. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  59. X
  60. X#include <curses.h>
  61. X#include "patchlevel.h"
  62. X
  63. X#define STDIO_H_INCLUDED
  64. X#define OMIT_TERMIO_REFERENCES
  65. X#include "ecu.h"
  66. X#include "ecukey.h"
  67. X#include "ecuxkey.h"
  68. X#include "pc_scr.h"
  69. X
  70. X#define END        XFend
  71. X
  72. X#define SETW_LINES    14
  73. X#define SETW_COLS    64
  74. X#define SETW_TLY    1
  75. X#define SETW_TLX    ((80 - SETW_COLS) / 2)
  76. X
  77. X#define NAME_Y        2
  78. X#define NAME_X        30
  79. X#define NAME_LEN    19
  80. X#define NAME_LX        3
  81. X
  82. X#define TELNO_Y        3
  83. X#define TELNO_X        3
  84. X#define TELNO_LEN    19
  85. X
  86. X#define DESCR_Y        3
  87. X#define DESCR_X        30
  88. X#define DESCR_LEN    32
  89. X
  90. X#define TTY_Y        5
  91. X#define TTY_X        16
  92. X#define TTY_LEN        5
  93. X#define TTY_LX        3
  94. X
  95. X#define TTYOPN_LY    5
  96. X#define TTYOPN_LX    24
  97. X
  98. X#define DPX_Y        7
  99. X#define DPX_X        11
  100. X#define DPX_LX        3
  101. X
  102. X#define BAUD_Y        7
  103. X#define BAUD_X        20
  104. X#define BAUD_LEN    5
  105. X#define BAUD_LX        14
  106. X
  107. X#define PAR_Y        7
  108. X#define PAR_X        34
  109. X#define PAR_LX        27
  110. X
  111. X#define DB_Y        7
  112. X#define DB_X        48
  113. X#define DB_LX        37
  114. X#define DB_LX2        49
  115. X
  116. X#define XADDNL_Y    8
  117. X#define XADDNL_X    29
  118. X#define XADDNL_LX    3
  119. X
  120. X#define RADDNL_Y    9
  121. X#define RADDNL_X    29
  122. X#define RADDNL_LX    3
  123. X
  124. Xextern char *numeric_revision;    /* ecunumrev.c */
  125. Xextern char *revision_modifier; /* ecunumrev.c */
  126. Xextern int rcvr_pid;
  127. Xextern int interrupt;
  128. Xextern char errmsg[];
  129. X
  130. XWINDOW *setw;
  131. X
  132. X#define SETW_MSG_LEFTX 2
  133. X#define SETW_MSG_MAXLEN    (SETW_COLS - SETW_MSG_LEFTX - 8)
  134. X#define SETW_MSG_BOT_Y  (SETW_LINES - 1)
  135. X#define SETW_MSG_ERR_Y  (SETW_LINES - 3)
  136. X
  137. X/*+-------------------------------------------------------------------------
  138. X    setw_msg(msg,y,fillch)
  139. X--------------------------------------------------------------------------*/
  140. Xvoid
  141. Xsetw_msg(msg,y,fillch,last_msglen)
  142. Xchar *msg;
  143. Xint y;
  144. Xchar fillch;
  145. Xint *last_msglen;
  146. X{
  147. Xregister itmp;
  148. Xregister itmp2;
  149. Xchar msg2[80];
  150. X
  151. X    if(!*last_msglen && !strlen(msg))
  152. X        return;
  153. X
  154. X    wmove(setw,y,SETW_MSG_LEFTX);
  155. X
  156. X    if((itmp = strlen(msg)) == 0)
  157. X    {
  158. X        itmp2 = *last_msglen + 2;
  159. X        for(itmp = 0; itmp < itmp2; itmp++)
  160. X            waddch(setw,fillch & 0xFF);
  161. X        *last_msglen = 0;
  162. X    }
  163. X    else
  164. X    {
  165. X        waddch(setw,' ');
  166. X        if(itmp > SETW_MSG_MAXLEN)
  167. X        {
  168. X            strncpy(msg2,msg,SETW_MSG_MAXLEN);
  169. X            msg2[SETW_MSG_MAXLEN + 1] = 0;
  170. X            waddstr(setw,msg2);
  171. X            itmp = strlen(msg2);
  172. X        }
  173. X        else
  174. X        {
  175. X            waddstr(setw,msg);
  176. X            itmp = strlen(msg);
  177. X        }
  178. X        waddch(setw,' ');
  179. X        if((itmp2 = *last_msglen - itmp) > 0)
  180. X        {
  181. X            while(itmp2--)
  182. X                waddch(setw,fillch & 0xFF);
  183. X        }
  184. X        *last_msglen = itmp;        /* remember last message length */
  185. X    }
  186. X    wrefresh(setw);
  187. X}    /* end of setw_msg */
  188. X
  189. X/*+-------------------------------------------------------------------------
  190. X    setw_bot_msg(msg)
  191. X--------------------------------------------------------------------------*/
  192. Xvoid
  193. Xsetw_bot_msg(msg)
  194. Xchar *msg;
  195. X{
  196. Xstatic int last_msglen = 0;
  197. X
  198. X    setw_msg(msg,SETW_MSG_BOT_Y,sHR,&last_msglen);
  199. X}    /* end of setw_bot_msg */
  200. X
  201. X/*+-------------------------------------------------------------------------
  202. X    setw_err_msg(msg)
  203. X--------------------------------------------------------------------------*/
  204. Xvoid
  205. Xsetw_err_msg(msg)
  206. Xchar *msg;
  207. X{
  208. Xstatic int last_msglen = 0;
  209. X
  210. X    setw_msg(msg,SETW_MSG_ERR_Y,' ',&last_msglen);
  211. X}    /* end of setw_err_msg */
  212. X
  213. X/*+-------------------------------------------------------------------------
  214. X    setup_display_name()
  215. X--------------------------------------------------------------------------*/
  216. Xvoid
  217. Xsetup_display_name()
  218. X{
  219. X    clear_area(setw,NAME_Y,NAME_X,NAME_LEN);
  220. X    waddstr(setw,shm->Llogical);
  221. X
  222. X    clear_area(setw,TELNO_Y,TELNO_X,TELNO_LEN);
  223. X    clear_area(setw,DESCR_Y,DESCR_X,DESCR_LEN);
  224. X    if(strcmp(shm->Llogical,shm->Ldescr))
  225. X    {
  226. X        waddstr(setw,shm->Ldescr);
  227. X        wmove(setw,TELNO_Y,TELNO_X);
  228. X        waddstr(setw,shm->Ltelno);
  229. X    }
  230. X
  231. X}    /* end of setup_display_name */
  232. X
  233. X/*+-------------------------------------------------------------------------
  234. X    setup_display_tty()
  235. X000000000011111
  236. X012345678901234
  237. X/dev/ttyxxxxxx
  238. X--------------------------------------------------------------------------*/
  239. Xvoid
  240. Xsetup_display_tty()
  241. X{
  242. X    clear_area(setw,TTY_Y,TTY_X,TTY_LEN);
  243. X    waddstr(setw,&shm->Lline[8]);
  244. X}    /* end of setup_display_tty */
  245. X
  246. X/*+-------------------------------------------------------------------------
  247. X    setup_display_single_char()
  248. X--------------------------------------------------------------------------*/
  249. Xvoid
  250. Xsetup_display_single_char()
  251. X{
  252. X    wmove(setw,DPX_Y,DPX_X);
  253. X    waddch(setw,(shm->Lfull_duplex) ? 'F' : 'E');
  254. X    wmove(setw,PAR_Y,PAR_X);
  255. X    waddch(setw,(shm->Lparity) ? to_upper(shm->Lparity) : 'N');
  256. X    wmove(setw,DB_Y,DB_X);
  257. X    waddch(setw,(shm->Lparity) ? '7' : '8');
  258. X    wmove(setw,XADDNL_Y,XADDNL_X);
  259. X    waddch(setw,(shm->Ladd_nl_outgoing) ? 'Y' : 'N');
  260. X    wmove(setw,RADDNL_Y,RADDNL_X);
  261. X    waddch(setw,(shm->Ladd_nl_incoming) ? 'Y' : 'N');
  262. X
  263. X }    /* end of setup_display_single_char */
  264. X
  265. X/*+-------------------------------------------------------------------------
  266. X    setup_display_baud()
  267. X--------------------------------------------------------------------------*/
  268. Xvoid
  269. Xsetup_display_baud()
  270. X{
  271. Xchar s8[8];
  272. X    clear_area(setw,BAUD_Y,BAUD_X,BAUD_LEN);
  273. X    sprintf(s8,"%u",shm->Lbaud);
  274. X    waddstr(setw,s8);
  275. X
  276. X}    /* end of setup_display_baud */
  277. X
  278. X/*+-------------------------------------------------------------------------
  279. X    setup_display_screen(write_lits)
  280. X--------------------------------------------------------------------------*/
  281. Xvoid
  282. Xsetup_display_screen(write_lits)
  283. Xint write_lits;
  284. X{
  285. X    if(write_lits)
  286. X    {
  287. X        wmove(setw,NAME_Y,NAME_LX);
  288. X        waddstr(setw,"Name/phone number to call:");
  289. X        wmove(setw,TTY_Y,TTY_LX);
  290. X        waddstr(setw,"tty: /dev/tty");
  291. X        wmove(setw,DPX_Y,DPX_LX);
  292. X        waddstr(setw,"duplex:");
  293. X        wmove(setw,BAUD_Y,BAUD_LX);
  294. X        waddstr(setw,"baud:");
  295. X        wmove(setw,PAR_Y,PAR_LX);
  296. X        waddstr(setw,"parity:");
  297. X        wmove(setw,DB_Y,DB_LX);
  298. X        waddstr(setw,"(data bits");
  299. X        wmove(setw,DB_Y,DB_LX2);
  300. X        waddch(setw,')');
  301. X        wmove(setw,XADDNL_Y,XADDNL_LX);
  302. X        waddstr(setw,"Add NL to transmitted CR:");
  303. X        wmove(setw,RADDNL_Y,RADDNL_LX);
  304. X        waddstr(setw,"Add NL to received CR:");
  305. X        wmove(setw,SETW_LINES - 2,1);
  306. X        wstandout(setw);
  307. X        waddstr(setw,        /* kludge -- must change if setw width does */
  308. X            "   TAB:next ^B:prev END:proceed ^D:phone dir  ESC:quit ecu    ");
  309. X        wstandend(setw);
  310. X    }
  311. X    setup_display_name();
  312. X    setup_display_tty();
  313. X    setup_display_single_char();
  314. X    setup_display_baud();
  315. X    wrefresh(setw);
  316. X}    /* end of setup_display_screen */
  317. X
  318. X/*+-------------------------------------------------------------------------
  319. X    setup_open_status()
  320. X--------------------------------------------------------------------------*/
  321. Xvoid
  322. Xsetup_open_status()
  323. X{
  324. X    wmove(setw,TTYOPN_LY,TTYOPN_LX);
  325. X    if(shm->Liofd >= 0)
  326. X        waddstr(setw,"(opened)");
  327. X    else
  328. X        waddstr(setw,"        ");
  329. X    wrefresh(setw);
  330. X}    /* end of setup_open_status */
  331. X
  332. X/*+-------------------------------------------------------------------------
  333. X    setup_line_open()
  334. X--------------------------------------------------------------------------*/
  335. Xsetup_line_open()
  336. X{
  337. Xregister itmp;
  338. Xregister retries = 8;
  339. Xchar *lopen_err_text();
  340. Xchar *cptr;
  341. Xchar msg[80];
  342. X
  343. X    while(itmp = lopen())
  344. X    {
  345. X        if(retries)
  346. X        {
  347. X            if(!(itmp == LOPEN_ENABLED_IN_USE) &&
  348. X                !(itmp == LOPEN_DIALOUT_IN_USE))
  349. X            {
  350. X                retries = 1;
  351. X                goto FAIL;
  352. X            }
  353. X            sprintf(msg,"%s - waiting %d sec",lopen_err_text(itmp),retries);
  354. X            cptr = msg;
  355. X        }
  356. X        else
  357. X        {
  358. XFAIL:
  359. X            cptr = lopen_err_text(itmp);
  360. X            ring_bell();
  361. X        }
  362. X        setw_err_msg(cptr);
  363. X        if(!retries--)
  364. X            break;
  365. X        nap(1000L);
  366. X        setw_err_msg("");
  367. X    }
  368. X    setup_open_status();
  369. X    return(itmp);
  370. X
  371. X}    /* end of setup_line_open */
  372. X
  373. X/*+-------------------------------------------------------------------------
  374. X    setw_get_single(nondelim_list)
  375. Xassumes cursor is already positioned
  376. X--------------------------------------------------------------------------*/
  377. Xint
  378. Xsetw_get_single(nondelim_list)
  379. Xregister char *nondelim_list;
  380. X{
  381. Xregister uint itmp;
  382. Xstatic char setw_nondelim_list[] =
  383. X{
  384. X    CR,NL,CTL_B,CTL_D,TAB,ESC,CTL_L,CTL_R,END
  385. X};
  386. X
  387. X    itmp = winget_single(setw,nondelim_list,setw_nondelim_list);
  388. X    if( (itmp & 0xFF) == CR)
  389. X        itmp = NL | 0x1000;
  390. X    return(itmp);
  391. X}    /* end of setw_get_single */
  392. X
  393. X/*+-------------------------------------------------------------------------
  394. X    setup_screen(argv_logical)
  395. X--------------------------------------------------------------------------*/
  396. Xvoid
  397. Xsetup_screen(argv_logical)
  398. Xchar *argv_logical;
  399. X{
  400. Xregister itmp;
  401. Xregister input_state = 0;
  402. Xchar s64[64];
  403. Xint done = 0;
  404. Xuint baud;
  405. Xuchar delim;    /* important to be unsigned to avoid sign extension */
  406. XWINDOW *window_create();
  407. Xstatic char use_input_delim[] = {TAB,NL,END,CTL_D};
  408. X
  409. X    windows_start();
  410. X    sprintf(s64,"ecu %s.%02d%s",numeric_revision,PATCHLEVEL,revision_modifier);
  411. X    setw = window_create(s64,-3,SETW_TLY,SETW_TLX,SETW_LINES,SETW_COLS);
  412. X    setup_display_screen(1);
  413. X
  414. XREENTER_INPUT_LOOP:
  415. X    while(!done)
  416. X    {
  417. X        wrefresh(setw);
  418. X        switch(input_state)
  419. X        {
  420. X            case 0:
  421. XCASE_0:
  422. X                if(argv_logical)
  423. X                {
  424. X                    itmp = 0;    /* 'ecu -' means dont dial */
  425. X                    if(strcmp(argv_logical,"-"))    /* if not "-" */
  426. X                    {
  427. X                        strncpy(s64,argv_logical,NAME_LEN + 1);
  428. X                        s64[NAME_LEN + 1] = 0;
  429. X                        itmp = strlen(s64);
  430. X                    }
  431. X                    delim = END;
  432. X                }
  433. X                else
  434. X                {
  435. X                    setw_bot_msg(
  436. X                        "logical phone directory entry, phone number or empty");
  437. X                     itmp = wingets(setw,NAME_Y,NAME_X,s64,NAME_LEN + 1,&delim,
  438. X                        (shm->Llogical[0] != 0));
  439. X                    setw_err_msg("");
  440. X                }
  441. X                if(strchr(use_input_delim,delim) && strlen(s64))
  442. X                {
  443. X                    strcpy(shm->Llogical,s64);
  444. X                    if(shm->Llogical[0] && (lookup_logical_telno() == 0))
  445. X                    {
  446. X                        setw_err_msg(errmsg);
  447. X                        setup_display_screen(0);
  448. X                        ring_bell();
  449. X                        argv_logical = (char *)0;
  450. X                        goto CASE_0;
  451. X                    }
  452. X                    setup_display_screen(0);
  453. X                    break;
  454. X                }
  455. X                setup_display_name();
  456. X                break;
  457. X
  458. X            case 1:
  459. X                setw_bot_msg("comm line: i.e., 1a, 2a, 4a, 4b, 4c, 4d");
  460. X                setup_display_tty();
  461. X                strcpy(s64,&shm->Lline[8]);
  462. X                 itmp = wingets(setw,TTY_Y,TTY_X,s64,TTY_LEN + 1,&delim,1);
  463. X                setw_err_msg("");
  464. X                if(strchr(use_input_delim,delim) && strlen(s64))
  465. X                    strcpy(&shm->Lline[8],s64);
  466. X                setup_display_tty();
  467. X                break;
  468. X
  469. X            case 2:
  470. X                setw_bot_msg("duplex F:full H:half");
  471. X                wmove(setw,DPX_Y,DPX_X);
  472. X                wrefresh(setw);
  473. X                delim = NL;
  474. X                switch(itmp = setw_get_single("fh"))
  475. X                {
  476. X                    case 0:
  477. X                    case 1:
  478. X                        shm->Lfull_duplex = itmp;
  479. X                        break;
  480. X                    default:
  481. X                        delim = itmp & 0xFF;
  482. X                        break;
  483. X                }
  484. X                break;
  485. X
  486. X            case 3:        /* baud */
  487. X                setw_bot_msg(
  488. X                "rates: 110,300,600,1200,2400,4800,9600,19200,38400");
  489. XCASE_3:
  490. X                sprintf(s64,"%u",shm->Lbaud);
  491. X                 itmp = wingets(setw,BAUD_Y,BAUD_X,s64,BAUD_LEN + 1,&delim,1);
  492. X                if(strchr(use_input_delim,delim) && strlen(s64))
  493. X                {
  494. X                    if(valid_baud_rate(baud = atoi(s64)) < 0)
  495. X                    {
  496. X                        setup_display_baud();
  497. X                        ring_bell();
  498. X                        goto CASE_3;
  499. X                    }
  500. X                    shm->Lbaud = baud;
  501. X                }
  502. X                setup_display_baud();
  503. X                break;
  504. X
  505. X            case 4:
  506. X                setw_bot_msg("parity: N:none E:even O:odd");
  507. X                wmove(setw,PAR_Y,PAR_X);
  508. X                wrefresh(setw);
  509. X                delim = NL;
  510. X                switch(itmp = setw_get_single("neo"))
  511. X                {
  512. X                    case 0:    shm->Lparity = 0;   break;
  513. X                    case 1: shm->Lparity = 'e'; break;
  514. X                    case 2: shm->Lparity = 'o'; break;
  515. X                    default:
  516. X                        delim = itmp & 0xFF;
  517. X                        break;
  518. X                }
  519. X                wmove(setw,DB_Y,DB_X);
  520. X                waddch(setw,(shm->Lparity) ? '7' : '8');
  521. X                break;
  522. X
  523. X            case 5:
  524. X                setw_bot_msg("");
  525. X                wmove(setw,XADDNL_Y,XADDNL_X);
  526. X                wrefresh(setw);
  527. X                delim = NL;
  528. X                switch(itmp = setw_get_single("ny"))
  529. X                {
  530. X                    case 0:
  531. X                    case 1: shm->Ladd_nl_outgoing = itmp; break;
  532. X                    default: delim = itmp & 0xFF;
  533. X                }
  534. X                break;
  535. X
  536. X            case 6:
  537. X                setw_bot_msg("");
  538. X                wmove(setw,RADDNL_Y,RADDNL_X);
  539. X                wrefresh(setw);
  540. X                delim = NL;
  541. X                switch(itmp = setw_get_single("ny"))
  542. X                {
  543. X                    case 0:
  544. X                    case 1: shm->Ladd_nl_incoming = itmp; break;
  545. X                    default: delim = itmp & 0xFF; break;
  546. X                }
  547. X                break;
  548. X        }
  549. X
  550. X        if(argv_logical)
  551. X            break;
  552. X
  553. X        switch(delim)
  554. X        {
  555. X            case CTL_B:
  556. X                if(input_state)
  557. X                    input_state--;
  558. X                else
  559. X                    input_state = 6;
  560. X                break;
  561. X
  562. X            case TAB:
  563. X            case NL:
  564. X                input_state++;
  565. X                input_state %= 7;
  566. X                break;
  567. X
  568. X            case ESC:
  569. X                if(shm->Liofd >= 0)
  570. X                    lclose();
  571. X                setw_bot_msg("");
  572. X                setup_open_status();
  573. X                hangup(0);
  574. X                break;
  575. X
  576. X            case CTL_L:
  577. X            case CTL_R:
  578. X                tcap_clear_screen();
  579. X                touchwin(stdscr);
  580. X                wrefresh(stdscr);
  581. X                setup_display_screen(1);
  582. X                touchwin(setw);
  583. X                wrefresh(setw);
  584. X                break;
  585. X
  586. X            case END:
  587. X            case CTL_D:
  588. X                done = 1;
  589. X                break;
  590. X        }
  591. X    }
  592. X
  593. X    if(shm->Liofd < 0)
  594. X    {
  595. X        wmove(setw,TTY_Y,TTY_X);
  596. X        wrefresh(setw);
  597. X        if(setup_line_open())
  598. X        {
  599. X            done = 0;
  600. X            input_state = 1;
  601. X            argv_logical = (char *)0;
  602. X            goto REENTER_INPUT_LOOP;
  603. X        }
  604. X    }
  605. X
  606. X    wmove(setw,SETW_LINES - 2,1);
  607. X    wstandout(setw);
  608. X    waddstr(setw,        /* kludge -- must change if setw width does */
  609. X        "------- Press HOME then 'help' for further assistance --------");
  610. X    wstandend(setw);
  611. X    setw_bot_msg("");
  612. X    windows_end(setw);
  613. X    tcap_cursor(SETW_TLY + SETW_LINES + 2,0);
  614. X    if(delim == CTL_D)
  615. X    {
  616. X        rcvr_pid = -2;
  617. X        pde_list_manager();
  618. X    }
  619. X    else if(shm->Llogical[0])
  620. X    {
  621. X#ifdef AUTO_DIAL_PROC
  622. X        if(find_procedure(shm->Llogical))
  623. X        {
  624. X        char *pargv[2];
  625. X            pargv[0] = shm->Llogical;
  626. X            pargv[1] = "!INITIAL";
  627. X            rcvr_pid = 0;
  628. X            do_proc(2,pargv);
  629. X            interrupt = 0;
  630. X            start_rcvr_process(1);
  631. X        }
  632. X        else
  633. X        {
  634. X            rcvr_pid = -2;
  635. X            DCE_dial();
  636. X        }
  637. X#else
  638. X    rcvr_pid = -2;
  639. X    DCE_dial();
  640. X#endif
  641. X    }
  642. X    else
  643. X        start_rcvr_process(1);
  644. X
  645. X}    /* end of setup_screen */
  646. X
  647. X/* vi: set tabstop=4 shiftwidth=4: */
  648. SHAR_EOF
  649. $TOUCH -am 1224223390 'ecusetup.c' &&
  650. chmod 0644 ecusetup.c ||
  651. echo 'restore of ecusetup.c failed'
  652. Wc_c="`wc -c < 'ecusetup.c'`"
  653. test 14649 -eq "$Wc_c" ||
  654.     echo 'ecusetup.c: original size 14649, current size' "$Wc_c"
  655. # ============= ecushm.c ==============
  656. echo 'x - extracting ecushm.c (Text)'
  657. sed 's/^X//' << 'SHAR_EOF' > 'ecushm.c' &&
  658. X/*+-------------------------------------------------------------------------
  659. X    ecushm.c - shared memory handler for ecu xmtr/rcvr comm
  660. X    wht@n4hgf.Mt-Park.GA.US
  661. X
  662. X  Defined functions:
  663. X    shm_done()
  664. X    shm_init()
  665. X    shmr_process_rcvr_SIGUSR2()
  666. X    shmr_set_xmtr_bn_1()
  667. X    shmx_connect()
  668. X    shmx_make_rcvr_sleep(seconds)
  669. X    shmx_process_xmtr_SIGUSR2()
  670. X    shmx_rc_report(prcvd_chars,prcvd_chars_this_connect)
  671. X    shmx_set_rcvr_ansi(mode)
  672. X    shmx_set_rcvr_bn(bn_value)
  673. X    shmx_set_rcvr_log(logfilename,append_flag,raw_flag)
  674. X    shmx_set_rcvr_nl_control()
  675. X
  676. X--------------------------------------------------------------------------*/
  677. X/*+:EDITS:*/
  678. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  679. X
  680. X#include "ecu.h"
  681. X#include <sys/ipc.h>
  682. X#include <sys/shm.h>
  683. X
  684. X/* xmtr to rcvr cmds */
  685. X#define SHMX_MAKE_RCVR_SLEEP    1    /* sleep xi1=#seconds */
  686. X#define    SHMX_SET_RCVR_BN        2    /* set want_bell_notify xi1=value */
  687. X#define SHMX_SET_RCVR_LOG        3    /* log file manipulations
  688. X                                     * xi1=append, xi2=raw, xs1=name */
  689. X/* rcvr to xmtr cmds */
  690. X#define SHMR_SET_XMTR_BN1        1    /* set want_bell_notify to 1 */
  691. X
  692. Xextern int want_bell_notify;
  693. Xextern int rcvr_pid;
  694. Xextern int xmtr_pid;
  695. Xextern char rcvr_log_file[];    /* if rcvr_log!= 0,log filename */
  696. Xextern int rcvr_log;            /* rcvr log active if != 0 */
  697. Xextern FILE *rcvr_log_fp;        /* rcvr log file */
  698. Xextern int rcvr_log_raw;        /* if true, log all, else filter ctl chrs */
  699. Xextern int rcvr_log_flusheach;
  700. Xextern int rcvr_log_append;    /* if true, append, else scratch */
  701. Xextern int rcvr_log_gen_title;
  702. X
  703. XECU_SDS FAR *shm;                /* shared segment pointer */
  704. Xkey_t shm_key;
  705. Xint shm_shmid;
  706. X
  707. X/*+-------------------------------------------------------------------------
  708. X    shm_init()
  709. X  Called by parent process (xmtr) to initialize environment
  710. X--------------------------------------------------------------------------*/
  711. Xshm_init()
  712. X{
  713. Xchar FAR *shmat();
  714. Xuint save_LINESxCOLS;
  715. Xextern uint LINESxCOLS;
  716. X
  717. X    shm_key = 0xEC000000L | getpid();
  718. X
  719. X    if((shm_shmid = shmget(shm_key,sizeof(ECU_SDS),IPC_CREAT | 0600)) < 0)
  720. X    {
  721. X        perror("shmget");
  722. X        exit(11);
  723. X    }
  724. X
  725. X    if(((char FAR *)shm = shmat(shm_shmid,(char FAR *)0,0)) == (char FAR *)-1)
  726. X    {
  727. X        perror("shmat");
  728. X        exit(11);
  729. X    }
  730. X
  731. X    shm->xcmd = 0;    /* signal from xmtr to rcvr SIGUSR2 */
  732. X    shm->xi1 = 0;    /* parameters */
  733. X    shm->xi2 = 0;
  734. X    shm->xs1[0] = 0;
  735. X    shm->rcmd = 0;    /* signal from rcvr to xmtr SIGUSR2 */
  736. X    shm->ri1 = 0;    /* parameters */
  737. X    shm->ri2 = 0;
  738. X    shm->rs1[0] = 0;
  739. X    shm->rcvd_chars = 0L;
  740. X    shm->rcvd_chars_this_connect = 0L;
  741. X
  742. X    shm->cursor_y = 0;
  743. X    shm->cursor_x = 0;
  744. X    shm->friend_space[0] = 0;
  745. X    save_LINESxCOLS = LINESxCOLS;
  746. X    LINESxCOLS = sizeof(shm->screen);    /* avoid trap */
  747. X    spaces((char *)shm->screen,sizeof(shm->screen));
  748. X    LINESxCOLS = save_LINESxCOLS;
  749. X
  750. X    return(0);
  751. X
  752. X}    /* end of shm_init */
  753. X
  754. X/*+-------------------------------------------------------------------------
  755. X    shm_done() -- finished with shm -- clean up
  756. X--------------------------------------------------------------------------*/
  757. Xvoid
  758. Xshm_done()
  759. X{
  760. X    if(shmctl(shm_shmid,IPC_RMID,(struct shmid_ds *)0))
  761. X        perror("shmctl IPC_RMID");
  762. X}    /* end of shm_done */
  763. X
  764. X/*+-------------------------------------------------------------------------
  765. X    shmx_rc_report(prcvr_chars,prcvr_chars_this_connect)
  766. X xmtr calls to get rcvr stats
  767. X--------------------------------------------------------------------------*/
  768. Xshmx_rc_report(prcvd_chars,prcvd_chars_this_connect)
  769. Xlong *prcvd_chars;
  770. Xlong *prcvd_chars_this_connect;
  771. X{
  772. X    *prcvd_chars = shm->rcvd_chars;
  773. X    *prcvd_chars_this_connect = shm->rcvd_chars_this_connect;
  774. X}    /* end of shmx_rc_report */
  775. X
  776. X/*+-------------------------------------------------------------------------
  777. X    shmx_connect() -- xmtr calls when modem connects
  778. X--------------------------------------------------------------------------*/
  779. Xvoid
  780. Xshmx_connect()
  781. X{
  782. X    shm->rcvd_chars_this_connect = 0L;
  783. X}    /* end of shmx_connect */
  784. X
  785. X/*+-------------------------------------------------------------------------
  786. X    shmx_make_rcvr_sleep(seconds)
  787. X--------------------------------------------------------------------------*/
  788. Xvoid
  789. Xshmx_make_rcvr_sleep(seconds)
  790. Xint seconds;
  791. X{
  792. X    shm->xcmd = SHMX_MAKE_RCVR_SLEEP;
  793. X    shm->xi1 = seconds;
  794. X    kill_rcvr_process(SIGUSR2);
  795. X
  796. X}    /* end of shmx_make_rcvr_sleep */
  797. X
  798. X/*+-------------------------------------------------------------------------
  799. X    shmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each)
  800. X
  801. Xnull logfilename stops logging
  802. Xappend_flag says whether to open for write or append
  803. Xraw_flag says whether or not to filter non-printable chars or not
  804. X(NL not filtered)
  805. X--------------------------------------------------------------------------*/
  806. Xvoid
  807. Xshmx_set_rcvr_log(logfilename,append_flag,raw_flag,flush_each)
  808. Xchar *logfilename;
  809. Xint append_flag;
  810. Xint raw_flag;
  811. Xint flush_each;
  812. X{
  813. X    shm->xcmd = SHMX_SET_RCVR_LOG;
  814. X    shm->xi1 = append_flag;
  815. X    shm->xi2 = raw_flag;
  816. X    shm->xi3 = flush_each;
  817. X    strcpy(shm->xs1,logfilename);
  818. X    kill_rcvr_process(SIGUSR2);
  819. X}    /* end of shmx_set_rcvr_log */
  820. X
  821. X/*+-------------------------------------------------------------------------
  822. X    shmx_set_rcvr_bn(bn_value)
  823. X--------------------------------------------------------------------------*/
  824. Xvoid
  825. Xshmx_set_rcvr_bn(bn_value)
  826. Xint bn_value;
  827. X{
  828. X    shm->xcmd = SHMX_SET_RCVR_BN;
  829. X    shm->xi1 = bn_value;
  830. X    kill_rcvr_process(SIGUSR2);
  831. X
  832. X}    /* end of shmx_set_rcvr_bn */
  833. X
  834. X/*+-------------------------------------------------------------------------
  835. X    shmr_set_xmtr_bn_1()
  836. X--------------------------------------------------------------------------*/
  837. Xvoid
  838. Xshmr_set_xmtr_bn_1()
  839. X{
  840. X    shm->rcmd = SHMR_SET_XMTR_BN1;
  841. X    kill(xmtr_pid,SIGUSR2);
  842. X
  843. X}    /* end of shmr_set_xmtr_bn_1 */
  844. X
  845. X/*+-------------------------------------------------------------------------
  846. X    shmx_process_xmtr_SIGUSR2()
  847. X--------------------------------------------------------------------------*/
  848. Xvoid
  849. Xshmx_process_xmtr_SIGUSR2()
  850. X{
  851. Xregister rcmd;
  852. Xregister ri1,ri2;
  853. X
  854. X    rcmd = shm->rcmd;
  855. X    shm->rcmd = 0;
  856. X    ri1 = shm->ri1;
  857. X    ri2 = shm->ri2;
  858. X
  859. X    switch(rcmd)
  860. X    {
  861. X        case SHMR_SET_XMTR_BN1:
  862. X            want_bell_notify = 1;
  863. X            break;
  864. X    }
  865. X
  866. X}    /* end of shmx_process_xmtr_SIGUSR2 */
  867. X
  868. X/*+-------------------------------------------------------------------------
  869. X    shmr_process_rcvr_SIGUSR2()
  870. X--------------------------------------------------------------------------*/
  871. Xvoid
  872. Xshmr_process_rcvr_SIGUSR2()
  873. X{
  874. Xregister xcmd;
  875. Xregister xi1,xi2,xi3;
  876. Xchar xs1[SHM_STRLEN];
  877. X
  878. X    xcmd = shm->xcmd;
  879. X    shm->xcmd = 0;
  880. X    xi1 = shm->xi1;
  881. X    xi2 = shm->xi2;
  882. X    xi3 = shm->xi3;
  883. X    strcpy(xs1,shm->xs1);
  884. X
  885. X    switch(xcmd)
  886. X    {
  887. X        case SHMX_MAKE_RCVR_SLEEP:
  888. X            sleep(xi1);
  889. X            break;
  890. X
  891. X        case SHMX_SET_RCVR_BN:
  892. X            want_bell_notify = xi1;
  893. X            break;
  894. X
  895. X        case SHMX_SET_RCVR_LOG:
  896. X            if(rcvr_log)         /* if already logging */
  897. X            {
  898. X                if(!rcvr_log_raw)
  899. X                    putc('\n',rcvr_log_fp);
  900. X                fclose(rcvr_log_fp);
  901. X                rcvr_log = 0;
  902. X            }
  903. X            if(strlen(xs1) == 0)    /* if all we wanted was to stop log ... */
  904. X                break;                /* ... then quit */
  905. X            rcvr_log_gen_title = 1;
  906. X            rcvr_log = 1;
  907. X            rcvr_log_append = xi1;
  908. X            rcvr_log_raw = xi2;
  909. X            rcvr_log_flusheach = xi3;
  910. X            strcpy(rcvr_log_file,xs1);
  911. X            rcvr_log_open();
  912. X            break;
  913. X    }
  914. X
  915. X}    /* end of shmr_process_rcvr_SIGUSR2 */
  916. X
  917. X/* end of ecushm.c */
  918. X/* vi: set tabstop=4 shiftwidth=4: */
  919. SHAR_EOF
  920. $TOUCH -am 1224223390 'ecushm.c' &&
  921. chmod 0644 ecushm.c ||
  922. echo 'restore of ecushm.c failed'
  923. Wc_c="`wc -c < 'ecushm.c'`"
  924. test 7052 -eq "$Wc_c" ||
  925.     echo 'ecushm.c: original size 7052, current size' "$Wc_c"
  926. # ============= ecusighdl.c ==============
  927. echo 'x - extracting ecusighdl.c (Text)'
  928. sed 's/^X//' << 'SHAR_EOF' > 'ecusighdl.c' &&
  929. X/* #define RCVR_CLEAN_CORE_DUMP */
  930. X/*+-----------------------------------------------------------------------
  931. X    ecusighdl.c - xmtr/rcvr individual process signal handlers
  932. X    wht@n4hgf.Mt-Park.GA.US
  933. X
  934. X  Defined functions:
  935. X    child_signals()
  936. X    hangup(sig)
  937. X    kill_rcvr_process(sig)
  938. X    rcvr_SIGHUP_handler()
  939. X    rcvr_SIGINT_handler()
  940. X    rcvr_SIGTERM_handler()
  941. X    rcvr_SIGUSR1_handler()
  942. X    rcvr_SIGUSR2_handler()
  943. X    rcvr_common_signal_handler()
  944. X    rcvr_death_handler(sig)
  945. X    rcvr_signals()
  946. X    start_rcvr_process(notify_flag)
  947. X    xmtr_SIGHUP_handler(sig)
  948. X    xmtr_SIGINT_handler()
  949. X    xmtr_SIGTERM_handler(sig)
  950. X    xmtr_SIGUSR2_handler()
  951. X    xmtr_bsd4_SIGCHLD_handler()
  952. X    xmtr_signals()
  953. X    xmtr_SIGCLD_handler()
  954. X
  955. X------------------------------------------------------------------------*/
  956. X/*+:EDITS:*/
  957. X/*:12-18-1990-20:02-wht@n4hgf-add rcvr_death_handler */
  958. X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
  959. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  960. X
  961. X#include "ecu.h"
  962. X#include "ecufork.h"
  963. X
  964. Xextern int errno;
  965. Xextern int rcvr_pid;
  966. Xextern int xmtr_pid;
  967. Xextern int windows_active;
  968. Xextern int current_ttymode;
  969. Xextern char lopen_err_str[];
  970. Xextern int rcvr_log;
  971. Xextern FILE *rcvr_log_fp;
  972. Xextern char rcvr_log_file[];    /* if rcvr_log!= 0,log filename */
  973. Xextern int rcvr_log_append;
  974. X
  975. Xint interrupt = 0;            /* interrupt indicator */
  976. Xint proc_interrupt = 0;        /* procedure interrupt indicator */
  977. Xint last_child_wait_status = 0;
  978. Xint last_child_wait_pid = 0;
  979. Xint xmtr_killed_rcvr = 0;
  980. X
  981. Xchar *signal_name_text();
  982. X
  983. Xvoid hangup();
  984. Xvoid xmtr_signals();
  985. X
  986. Xvoid rcvr_SIGTERM_handler();
  987. Xvoid rcvr_SIGINT_handler();
  988. Xvoid rcvr_SIGUSR1_handler();
  989. Xvoid rcvr_SIGUSR2_handler();
  990. Xvoid rcvr_SIGHUP_handler();
  991. Xvoid xmtr_SIGINT_handler();
  992. Xvoid xmtr_SIGHUP_handler();
  993. Xvoid xmtr_SIGTERM_handler();
  994. Xvoid xmtr_SIGCLD_handler();
  995. Xvoid rcvr_common_signal_handler();
  996. Xvoid rcvr_death_handler();
  997. X
  998. X/*+-----------------------------------------------------------------------
  999. X    start_rcvr_process(notify_flag)
  1000. X------------------------------------------------------------------------*/
  1001. Xstart_rcvr_process(notify_flag)
  1002. Xint notify_flag;
  1003. X{
  1004. Xchar s40[40];
  1005. Xextern ulong colors_current;
  1006. Xulong colors_at_entry = colors_current;
  1007. X
  1008. X    fflush(so);
  1009. X    fflush(se);
  1010. X
  1011. X    if(rcvr_pid > 0)            /* if process already active,just ... */
  1012. X        return(rcvr_pid);        /* ... return the process id */
  1013. X
  1014. X    if(rcvr_log && rcvr_log_file[0] && rcvr_log_fp)
  1015. X    {
  1016. X        fclose(rcvr_log_fp);
  1017. X        rcvr_log_fp = NULL;
  1018. X    }
  1019. X
  1020. X    xmtr_killed_rcvr = 0;
  1021. X    rcvr_pid = smart_fork();
  1022. X    if(rcvr_pid == 0)        /* if we are the (spawned) rcvr process */
  1023. X    {
  1024. X        if(notify_flag)
  1025. X        {
  1026. X            setcolor(colors_notify);
  1027. X            fputs("[interactive mode]",se);
  1028. X            setcolor(colors_at_entry);
  1029. X            fputs("\r\n",se);
  1030. X        }
  1031. X
  1032. X        rcvr();    /* run until killed */
  1033. X        /*NOTREACHED*/
  1034. X    }
  1035. X    else if(rcvr_pid > 0)     /* we are the father (xmtr) process */
  1036. X    {
  1037. X#if defined(FORK_DEBUG)
  1038. X        sprintf(s40,"DEBUG rcvr pid %d",rcvr_pid);
  1039. X        ecu_log_event(getpid(),s40);        /* rcvr */
  1040. X#endif
  1041. X        if(rcvr_log)
  1042. X            rcvr_log_append = 1;    /* until next %log -s */
  1043. X        xmtr_signals();
  1044. X        return(rcvr_pid);
  1045. X    }
  1046. X    else
  1047. X    {
  1048. X        rcvr_pid = -1;        /* no receiver active */
  1049. X        ff(se,"\r\n\ncould not fork for receive\r\n");
  1050. X        hangup(HANGUP_NO_FORK_FOR_RCVR);
  1051. X        /*NOTREACHED*/
  1052. X    }
  1053. X}    /* end of start_rcvr_process */
  1054. X
  1055. X/*+-----------------------------------------------------------------------
  1056. X    kill_rcvr_process(sig) -- kill rcvr process with signal 'sig'
  1057. X------------------------------------------------------------------------*/
  1058. Xvoid
  1059. Xkill_rcvr_process(sig)
  1060. Xint sig;
  1061. X{
  1062. Xint wait_count = 70;
  1063. X
  1064. X    if(rcvr_pid > 0)        /* if we have forked a rcvr process */
  1065. X    {
  1066. X        xmtr_killed_rcvr = 1;
  1067. X        rcvr_log_fp = NULL;
  1068. X        xmtr_signals();
  1069. X        kill(rcvr_pid,sig);
  1070. X        if(sig != SIGUSR2)    /* rcvr does not die on SIGUSR2 */
  1071. X        {
  1072. X            errno = 0;
  1073. X            while(wait_count)
  1074. X            {
  1075. X                if(kill(rcvr_pid,0) && (errno == ESRCH))
  1076. X                    break;
  1077. X                errno = 0;
  1078. X                nap(40L);
  1079. X                wait_count--;
  1080. X            }
  1081. X            if(!wait_count)
  1082. X            {
  1083. X                while(!kill(rcvr_pid,SIGKILL))
  1084. X                {
  1085. X                    wait((int *)0);
  1086. X                    nap(40L);
  1087. X                }
  1088. X            }
  1089. X            rcvr_pid = -1;
  1090. X            if(rcvr_log && rcvr_log_file[0])
  1091. X                rcvr_log_fp = fopen(rcvr_log_file,"a");
  1092. X        }
  1093. X    }
  1094. X
  1095. X}    /* end of kill_rcvr_process */
  1096. X
  1097. X/*+-------------------------------------------------------------------------
  1098. X    hangup_code_text(code)
  1099. X--------------------------------------------------------------------------*/
  1100. Xchar *
  1101. Xhangup_code_text(code)
  1102. Xint code;
  1103. X{
  1104. Xstatic char errant[16];
  1105. Xchar *signal_name_text();
  1106. X
  1107. X    if((code >= HANGUP_SIG1) && (code <= HANGUP_SIGN))
  1108. X        return(signal_name_text(code));
  1109. X
  1110. X    switch(code)
  1111. X    {
  1112. X        case HANGUP_LINE_READ_ERROR: return("line read error");
  1113. X        case HANGUP_XMTR_WRITE_ERROR: return("line write error");
  1114. X        case HANGUP_XMTR_LOGIC_ERROR: return("XMTR LOGIC ERROR");
  1115. X        case HANGUP_RCVR_LOGIC_ERROR: return("RCVR LOGIC ERROR");
  1116. X        case HANGUP_BSD4_IOCTL: return("BSD4 ioctl error");
  1117. X        case HANGUP_SHM_ABL: return("SHM ABL error");
  1118. X        case HANGUP_SHM_RTL: return("SHM RTL error");
  1119. X        case HANGUP_NO_FORK_FOR_RCVR: return("can't fork for RCVR");
  1120. X        case HANGUP_TTYIN_READ_ERROR: return("keyboard read error");
  1121. X        case HANGUP_LINE_OPEN_ERROR: return("line open error");
  1122. X        case HANGUP_PWENT_ERROR: return("password entry error");
  1123. X        case HANGUP_USAGE: return("usage");
  1124. X        case HANGUP_INIT_PROC_ERROR: return("error during initial procedure");
  1125. X        case HANGUP_CONFIG_ERROR: return("configuration error");
  1126. X        default:
  1127. X            sprintf(errant,"code %u?",code);
  1128. X            return(errant);
  1129. X    }
  1130. X
  1131. X}    /* end of hangup_code_text */
  1132. X
  1133. X/*+-----------------------------------------------------------------------
  1134. X    hangup(sig) -- terminate program (with comm line cleanup)
  1135. X
  1136. X  close comm line
  1137. X  return any ungetty'd line
  1138. X  return user's console to normal status
  1139. X  unlink shm name
  1140. X  terminate program
  1141. X  see ecuhangup.h
  1142. X------------------------------------------------------------------------*/
  1143. Xvoid
  1144. Xhangup(sig)
  1145. Xint sig;
  1146. X{
  1147. Xint isig;
  1148. Xint save_errno = errno;
  1149. Xextern char initial_procedure[];
  1150. X
  1151. X    if(xmtr_pid == getpid())        /* if we are xmtr */
  1152. X    {
  1153. X        for(isig = 1; isig < NSIG; isig++)
  1154. X            signal(isig,SIG_IGN);
  1155. X        kill_rcvr_process(SIGUSR1);
  1156. X        if(shm)
  1157. X        {
  1158. X            if(shm->Lmodem_off_hook)
  1159. X                DCE_hangup();
  1160. X            if(shm->Liofd != -1)
  1161. X                lclose();            /* close line */
  1162. X        }
  1163. X
  1164. X        /* make SURE we release any line acquired from getty */
  1165. X        ungetty_return_line();    /* lclose() calls this via unlock_tty(),
  1166. X                                 * but ok to make sure
  1167. X                                 */
  1168. X
  1169. X        if(windows_active)
  1170. X            windows_end_signal();
  1171. X        tcap_curbotleft();
  1172. X        tcap_eeod();
  1173. X        ttymode(0);            /* normal tty status */
  1174. X        shm_done();
  1175. X        if(sig > NSIG)
  1176. X        {
  1177. X        char s64[64];
  1178. X            setcolor(colors_error);
  1179. X            if(sig == HANGUP_INIT_PROC_ERROR)
  1180. X                pprintf("initial procedure '%s' failed\n",initial_procedure);
  1181. X            else if((sig > HANGUP_INIT_PROC_ERROR) &&
  1182. X                    (sig <= HANGUP_INIT_PROC_ERROR + 32))
  1183. X            {
  1184. X                pprintf("procedure command: exit %d\n",
  1185. X                    sig - HANGUP_INIT_PROC_ERROR);
  1186. X            }
  1187. X            else
  1188. X            {
  1189. X                sprintf(s64,"## XMTR %s, errno = %d",hangup_code_text(sig),
  1190. X                    save_errno);
  1191. X                pputs(s64);
  1192. X                pputs("\n");
  1193. X                if(lopen_err_str[0])
  1194. X                {
  1195. X                    pputs(lopen_err_str);
  1196. X                    pputs("\n");
  1197. X                }
  1198. X                ecu_log_event(getpid(),s64);
  1199. X                errno = save_errno;
  1200. X                if(errno)
  1201. X                    pperror("errno may not apply, but");
  1202. X            }
  1203. X        }
  1204. X        setcolor(colors_normal);
  1205. X    }
  1206. X    else                            /* we are rcvr */
  1207. X    {
  1208. X        if(sig > NSIG)
  1209. X        {
  1210. X        char s64[64];
  1211. X            sprintf(s64,"## RCVR %s, errno = %d",hangup_code_text(sig),
  1212. X                save_errno);
  1213. X            setcolor(colors_error);
  1214. X            pputs(s64);
  1215. X            pputs("\n");
  1216. X            ecu_log_event(getpid(),s64);
  1217. X            errno = save_errno;
  1218. X            if(errno)
  1219. X                pperror("errno may not apply, but");
  1220. X        }
  1221. X        setcolor(colors_normal);
  1222. X        kill(xmtr_pid,SIGHUP);
  1223. X    }
  1224. X    exit(sig);
  1225. X    /*NOTREACHED*/
  1226. X
  1227. X}    /* end of hangup */
  1228. X
  1229. Xvoid
  1230. Xrcvr_common_signal_handler()
  1231. X{
  1232. Xextern int rcvr_log;
  1233. Xextern int rcvr_log_raw;
  1234. Xextern FILE *rcvr_log_fp;
  1235. X
  1236. X    if(rcvr_log)
  1237. X    {
  1238. X        if(!rcvr_log_raw)
  1239. X            fputs("\n",rcvr_log_fp);
  1240. X        fclose(rcvr_log_fp);
  1241. X    }
  1242. X
  1243. X    exit(0);
  1244. X}
  1245. Xvoid
  1246. Xrcvr_SIGTERM_handler()
  1247. X{
  1248. X    rcvr_common_signal_handler();
  1249. X}
  1250. Xvoid
  1251. Xrcvr_SIGINT_handler()
  1252. X{
  1253. X    signal(SIGINT,rcvr_SIGINT_handler);
  1254. X}
  1255. Xvoid
  1256. Xrcvr_SIGUSR1_handler()
  1257. X{
  1258. X    rcvr_common_signal_handler();
  1259. X}
  1260. Xvoid
  1261. Xrcvr_SIGUSR2_handler()
  1262. X{
  1263. X    signal(SIGUSR2,rcvr_SIGUSR2_handler);
  1264. X    shmr_process_rcvr_SIGUSR2();
  1265. X}
  1266. Xvoid
  1267. Xrcvr_SIGHUP_handler()
  1268. X{
  1269. X    rcvr_common_signal_handler();
  1270. X}
  1271. Xvoid
  1272. Xrcvr_death_handler(sig)
  1273. Xint sig;
  1274. X{
  1275. X    fprintf(stderr,"\r\nreceiver process caught signal %s\r\n",
  1276. X        signal_name_text(sig));
  1277. X    fprintf(stderr,"cursor y=%d x=%d\r\n",shm->cursor_y,shm->cursor_x);
  1278. X#ifdef SIGABRT
  1279. X    signal(SIGABRT,SIG_DFL);
  1280. X#else
  1281. X    signal(SIGIOT,SIG_IOT);
  1282. X#endif
  1283. X    abort();
  1284. X    _exit(-1);
  1285. X}
  1286. X/*+-------------------------------------------------------------------------
  1287. X    xmtr_SIGINT_handler()
  1288. X--------------------------------------------------------------------------*/
  1289. Xvoid
  1290. Xxmtr_SIGINT_handler()
  1291. X{
  1292. X    signal(SIGINT,xmtr_SIGINT_handler);
  1293. X    interrupt = 1;
  1294. X    proc_interrupt = 1;
  1295. X}    /* end of xmtr_SIGINT_handler */
  1296. X
  1297. Xvoid
  1298. Xxmtr_SIGHUP_handler(sig)
  1299. Xint sig;
  1300. X{
  1301. X    hangup(sig);
  1302. X}
  1303. Xvoid
  1304. Xxmtr_SIGTERM_handler(sig)
  1305. Xint sig;
  1306. X{
  1307. X    hangup(sig);
  1308. X}
  1309. X
  1310. Xvoid
  1311. Xxmtr_SIGUSR2_handler()
  1312. X{
  1313. X    signal(SIGUSR2,xmtr_SIGUSR2_handler);
  1314. X    shmx_process_xmtr_SIGUSR2();
  1315. X}
  1316. X
  1317. X/*+-------------------------------------------------------------------------
  1318. X    xmtr_SIGCLD_handler()
  1319. X--------------------------------------------------------------------------*/
  1320. Xvoid
  1321. Xxmtr_SIGCLD_handler()
  1322. X{
  1323. Xextern int xmtr_killed_rcvr;
  1324. X
  1325. XWAIT:
  1326. X    errno = 0;
  1327. X    if((last_child_wait_pid = wait(&last_child_wait_status)) < 0)
  1328. X    {
  1329. X        if(errno == EINTR)
  1330. X            goto WAIT;
  1331. X    }
  1332. X
  1333. X#if defined(FORK_DEBUG)
  1334. X    sprintf(s40,"DEBUG fork SIGCLD pid %d term %x",
  1335. X        last_child_wait_pid,last_child_wait_status);
  1336. X    ecu_log_event(getpid(),s40);        /* xmtr_SIGCLD_handler() */
  1337. X#endif
  1338. X
  1339. X    if((last_child_wait_pid  == rcvr_pid) && !xmtr_killed_rcvr)
  1340. X    {
  1341. X        fprintf(stderr,"\r\nECU receiver process died unexpectedly\r\n");
  1342. X        hangup(HANGUP_RCVR_LOGIC_ERROR);
  1343. X    }
  1344. X    signal(SIGCLD,xmtr_SIGCLD_handler);
  1345. X
  1346. X}    /* end of xmtr_SIGCLD_handler */
  1347. X
  1348. X/*+-------------------------------------------------------------------------
  1349. X    child_signals() - signal() calls for children processes
  1350. X--------------------------------------------------------------------------*/
  1351. Xvoid
  1352. Xchild_signals()
  1353. X{
  1354. X    signal(SIGHUP,SIG_DFL);
  1355. X    signal(SIGINT,SIG_DFL);
  1356. X    signal(SIGTERM,SIG_DFL);
  1357. X    signal(SIGQUIT,SIG_DFL);
  1358. X    signal(SIGUSR1,SIG_DFL);
  1359. X    signal(SIGUSR2,SIG_DFL);
  1360. X    signal(SIGCLD,SIG_DFL);
  1361. X
  1362. X}    /* end of child_signals */
  1363. X
  1364. X/*+-------------------------------------------------------------------------
  1365. X    xmtr_signals()
  1366. X--------------------------------------------------------------------------*/
  1367. Xvoid
  1368. Xxmtr_signals()
  1369. X{
  1370. X    signal(SIGHUP,xmtr_SIGHUP_handler);
  1371. X    signal(SIGQUIT,SIG_IGN);
  1372. X    signal(SIGINT,xmtr_SIGINT_handler);
  1373. X    signal(SIGTERM,xmtr_SIGTERM_handler);
  1374. X    signal(SIGCLD,xmtr_SIGCLD_handler);
  1375. X    signal(SIGUSR2,xmtr_SIGUSR2_handler);
  1376. X
  1377. X}    /* end of xmtr_signals */
  1378. X
  1379. X/*+-------------------------------------------------------------------------
  1380. X    rcvr_signals()
  1381. X--------------------------------------------------------------------------*/
  1382. Xvoid
  1383. Xrcvr_signals()
  1384. X{
  1385. X    signal(SIGHUP,rcvr_SIGHUP_handler);
  1386. X    signal(SIGQUIT,SIG_IGN);
  1387. X#ifdef RCVR_CLEAN_CORE_DUMP
  1388. X    signal(SIGILL,SIG_DFL);
  1389. X    signal(SIGTRAP,SIG_DFL);
  1390. X    signal(SIGIOT,SIG_DFL);
  1391. X    signal(SIGABRT,SIG_DFL);
  1392. X    signal(SIGEMT,SIG_DFL);
  1393. X    signal(SIGFPE,SIG_DFL);
  1394. X    signal(SIGBUS,SIG_DFL);
  1395. X    signal(SIGSEGV,SIG_DFL);
  1396. X#else
  1397. X#ifdef SIGILL
  1398. X    signal(SIGILL,rcvr_death_handler);
  1399. X#endif
  1400. X#ifdef SIGTRAP
  1401. X    signal(SIGTRAP,rcvr_death_handler);
  1402. X#endif
  1403. X#ifdef SIGIOT
  1404. X    signal(SIGIOT,rcvr_death_handler);
  1405. X#endif
  1406. X#ifdef SIGABRT
  1407. X    signal(SIGABRT,rcvr_death_handler);
  1408. X#endif
  1409. X#ifdef SIGEMT
  1410. X    signal(SIGEMT,rcvr_death_handler);
  1411. X#endif
  1412. X#ifdef SIGFPE
  1413. X    signal(SIGFPE,rcvr_death_handler);
  1414. X#endif
  1415. X#ifdef SIGBUS
  1416. X    signal(SIGBUS,rcvr_death_handler);
  1417. X#endif
  1418. X#ifdef SIGSEGV
  1419. X    signal(SIGSEGV,rcvr_death_handler);
  1420. X#endif
  1421. X#endif
  1422. X    signal(SIGTERM,rcvr_SIGTERM_handler);
  1423. X    signal(SIGINT,rcvr_SIGINT_handler);
  1424. X    signal(SIGUSR1,rcvr_SIGUSR1_handler);
  1425. X    signal(SIGUSR2,rcvr_SIGUSR2_handler);
  1426. X
  1427. X}    /* end of rcvr_signals */
  1428. X
  1429. X/* vi: set tabstop=4 shiftwidth=4: */
  1430. SHAR_EOF
  1431. $TOUCH -am 1224223390 'ecusighdl.c' &&
  1432. chmod 0644 ecusighdl.c ||
  1433. echo 'restore of ecusighdl.c failed'
  1434. Wc_c="`wc -c < 'ecusighdl.c'`"
  1435. test 11775 -eq "$Wc_c" ||
  1436.     echo 'ecusighdl.c: original size 11775, current size' "$Wc_c"
  1437. # ============= ecutcap.c ==============
  1438. echo 'x - extracting ecutcap.c (Text)'
  1439. sed 's/^X//' << 'SHAR_EOF' > 'ecutcap.c' &&
  1440. X/*+-------------------------------------------------------------------------
  1441. X    ecutcap.c -- termcap stuff
  1442. X    wht@n4hgf.Mt-Park.GA.US
  1443. X
  1444. X  Defined functions:
  1445. X    tcap_blink_off()
  1446. X    tcap_blink_on()
  1447. X    tcap_bold_off()
  1448. X    tcap_bold_on()
  1449. X    tcap_clear_screen()
  1450. X    tcap_curbotleft()
  1451. X    tcap_curleft(count)
  1452. X    tcap_cursor(y,x)
  1453. X    tcap_curright(count)
  1454. X    tcap_delete_chars(count)
  1455. X    tcap_delete_lines(count)
  1456. X    tcap_draw_box(y,x,height,width,title,title_x)
  1457. X    tcap_draw_box_primitive(y,x,height,width)
  1458. X    tcap_eeod()
  1459. X    tcap_eeol()
  1460. X    tcap_horiz_rule(count)
  1461. X    tcap_insert_lines(count)
  1462. X    tcap_putc_stderr(character)
  1463. X    tcap_init()
  1464. X    tcap_stand_end()
  1465. X    tcap_stand_out()
  1466. X    tcap_clear_area_char(count,clrch)
  1467. X    tcap_gets(buf,bufsize,delim,wait_for_key)
  1468. X    tcap_underscore_off()
  1469. X    tcap_underscore_on()
  1470. X    tcap_vbell()
  1471. X    tcap_vertical_rule(y,x,count)
  1472. X
  1473. X--------------------------------------------------------------------------*/
  1474. X/*+:EDITS:*/
  1475. X/*:11-28-1990-14:52-wht@n4hgf-tcap support for non-ansi console */
  1476. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1477. X
  1478. X#include "ecu.h"
  1479. X#include "ecukey.h"
  1480. X#include "pc_scr.h"
  1481. X
  1482. Xuint tcap_LINES;
  1483. Xuint tcap_COLS;
  1484. X
  1485. Xstatic char *tc_blink_on = "";
  1486. Xstatic char *tc_blink_off = "";
  1487. Xstatic char *tc_bold_on = "";
  1488. Xstatic char *tc_bold_off = "";
  1489. Xstatic char *tc_clear = "";
  1490. Xstatic char *tc_curleft = "";
  1491. Xstatic char *tc_curright = "";
  1492. Xstatic char *tc_delchar = "";
  1493. Xstatic char *tc_delline = "";
  1494. Xstatic char *tc_eeod = "";
  1495. Xstatic char *tc_eeol = "";
  1496. Xstatic char *tc_inschar = "";
  1497. Xstatic char *tc_insline = "";
  1498. Xstatic char *tc_move = "";
  1499. Xstatic char *tc_standout = "";
  1500. Xstatic char *tc_standend = "";
  1501. Xstatic char *tc_underscore_on = "";
  1502. Xstatic char *tc_underscore_off = "";
  1503. Xstatic char *tc_vbell = "";
  1504. Xstatic char tc_strbuf[384];
  1505. Xstatic int tc_standout_width;
  1506. X
  1507. Xchar *tgetstr();
  1508. Xchar *tgoto();
  1509. Xchar *getenv();
  1510. X
  1511. Xvoid tcap_cursor();
  1512. Xvoid tcap_stand_out();
  1513. Xvoid tcap_stand_end();
  1514. X
  1515. X/*+-------------------------------------------------------------------------
  1516. X    tcap_init() - get termcap variables
  1517. X--------------------------------------------------------------------------*/
  1518. Xvoid
  1519. Xtcap_init()
  1520. X{
  1521. Xchar termbuf[1024];
  1522. Xchar *cptr;
  1523. X
  1524. X    cptr = tc_strbuf;
  1525. X    if(tgetent(termbuf,getenv("TERM")) > 0)
  1526. X    {
  1527. X        tc_blink_on         = tgetstr("mb",&cptr);    /* "XENIX extension" */
  1528. X        tc_blink_off        = tgetstr("me",&cptr);    /* "XENIX extension" */
  1529. X        tc_clear            = tgetstr("cl",&cptr);
  1530. X        tc_curleft          = tgetstr("kl",&cptr);
  1531. X        tc_curright         = tgetstr("kr",&cptr);
  1532. X        tc_delchar          = tgetstr("dc",&cptr);
  1533. X        tc_delline          = tgetstr("dl",&cptr);
  1534. X        tc_eeod             = tgetstr("cd",&cptr);
  1535. X        tc_eeol             = tgetstr("ce",&cptr);
  1536. X        tc_inschar          = tgetstr("ic",&cptr);
  1537. X        tc_insline          = tgetstr("al",&cptr);
  1538. X        tc_move             = tgetstr("cm",&cptr);
  1539. X        tc_standout         = tgetstr("so",&cptr);
  1540. X        tc_standend         = tgetstr("se",&cptr);
  1541. X        tc_underscore_on    = tgetstr("us",&cptr);
  1542. X        tc_underscore_off   = tgetstr("ue",&cptr);
  1543. X        tc_vbell            = tgetstr("vb",&cptr);
  1544. X        tc_bold_on          = tc_standout;            /* for now */
  1545. X        tc_bold_off         = tc_standend;            /* for now */
  1546. X        if((tc_standout_width = tgetnum("sg")) < 0)
  1547. X            tc_standout_width = 0;
  1548. X        tcap_LINES = tgetnum("li");
  1549. X        tcap_COLS = tgetnum("co");
  1550. X    }
  1551. X
  1552. X}    /* end of tcap_init */
  1553. X
  1554. X/*+-------------------------------------------------------------------------
  1555. X    tcap_horiz_rule(count) - horizontal rule starting at current position
  1556. X--------------------------------------------------------------------------*/
  1557. Xvoid
  1558. Xtcap_horiz_rule(count)
  1559. Xregister count;
  1560. X{
  1561. X    while(count--)
  1562. X        fputc(sHR,se);
  1563. X}    /* end of tcap_horiz_rule */
  1564. X
  1565. X/*+-------------------------------------------------------------------------
  1566. X    tcap_vertical_rule(y,x,count) - vertical rule starting at y,x
  1567. X--------------------------------------------------------------------------*/
  1568. Xvoid
  1569. Xtcap_vertical_rule(y,x,count)
  1570. Xint y;
  1571. Xregister x;
  1572. Xregister count;
  1573. X{
  1574. X
  1575. X    while(count--)
  1576. X    {
  1577. X        tcap_cursor(y++,x);
  1578. X        fputc(sVR,se);
  1579. X    }
  1580. X        
  1581. X}    /* end of tcap_vertical_rule */
  1582. X
  1583. X/*+-------------------------------------------------------------------------
  1584. X    tcap_draw_box_primitive(y,x,height,width) - ruled box
  1585. X--------------------------------------------------------------------------*/
  1586. Xvoid
  1587. Xtcap_draw_box_primitive(y,x,height,width)
  1588. Xregister y;
  1589. Xint x;
  1590. Xint height;
  1591. Xint width;
  1592. X{
  1593. Xregister i;
  1594. X
  1595. X    tcap_cursor(y,x);
  1596. X    fputc(sTL,se);
  1597. X    if((i = width - 2) > 0)
  1598. X        tcap_horiz_rule(i);
  1599. X    fputc(sTR,se);
  1600. X    if((i = height - 2) > 0)
  1601. X    {
  1602. X        tcap_vertical_rule(y + 1,x + width - 1,i);
  1603. X        tcap_vertical_rule(y + 1,x,i);
  1604. X    }
  1605. X    tcap_cursor(y + height - 1,x);
  1606. X    fputc(sBL,se);
  1607. X    if((i = width - 2) > 0)
  1608. X        tcap_horiz_rule(i);
  1609. X    fputc(sBR,se);
  1610. X
  1611. X}    /* end of tcap_draw_box_primitive */
  1612. X
  1613. X/*+-------------------------------------------------------------------------
  1614. X    tcap_draw_box(y,x,height,width,title,title_x)
  1615. X--------------------------------------------------------------------------*/
  1616. Xvoid
  1617. Xtcap_draw_box(y,x,height,width,title,title_x)
  1618. Xchar *title;
  1619. X{
  1620. Xregister stand = (title_x < 0);
  1621. X
  1622. X    if(stand)
  1623. X        title_x = -title_x;
  1624. X
  1625. X    tcap_draw_box_primitive(y,x,height,width);
  1626. X    tcap_cursor(y,x + title_x);
  1627. X    fputc('[',se);
  1628. X    if(stand)
  1629. X        tcap_stand_out();
  1630. X    fprintf(so," %s ",title);
  1631. X    if(stand)
  1632. X        tcap_stand_end();
  1633. X    fputc(']',se);
  1634. X
  1635. X}    /* end of tcap_draw_box */
  1636. X
  1637. X/*+-------------------------------------------------------------------------
  1638. X    tcap_putc_stderr(character) - utility rotuine for tputs
  1639. X--------------------------------------------------------------------------*/
  1640. Xvoid
  1641. Xtcap_putc_stderr(character)
  1642. Xint character;
  1643. X{
  1644. X    fputc(character,se);
  1645. X}    /* end of tcap_putc_stderr */
  1646. X
  1647. X/*+-------------------------------------------------------------------------
  1648. X    tcap_cursor(y,x)
  1649. X--------------------------------------------------------------------------*/
  1650. Xvoid
  1651. Xtcap_cursor(y,x)
  1652. Xuint y;
  1653. Xuint x;
  1654. X{
  1655. X    if(y >= tcap_LINES)
  1656. X        y = tcap_LINES - 1;
  1657. X    if(x >= tcap_COLS)
  1658. X        x = tcap_COLS - 1;
  1659. X    tputs(tgoto(tc_move,x,y),1,tcap_putc_stderr);
  1660. X}    /* end of tcap_cursor */
  1661. X
  1662. X/*+-------------------------------------------------------------------------
  1663. X    tcap_curleft(count) - move cursor left
  1664. X--------------------------------------------------------------------------*/
  1665. Xvoid
  1666. Xtcap_curleft(count)
  1667. Xregister count;
  1668. X{
  1669. X    while(count--)
  1670. X        fputs(tc_curleft,se);
  1671. X}    /* end of tcap_curleft */
  1672. X
  1673. X/*+-------------------------------------------------------------------------
  1674. X    tcap_curright(count) - move cursor right
  1675. X--------------------------------------------------------------------------*/
  1676. Xvoid
  1677. Xtcap_curright(count)
  1678. Xregister count;
  1679. X{
  1680. X    while(count--)
  1681. X        fputs(tc_curright,se);
  1682. X}    /* end of tcap_curright */
  1683. X
  1684. X/*+-------------------------------------------------------------------------
  1685. X    tcap_curbotleft()
  1686. X--------------------------------------------------------------------------*/
  1687. Xvoid
  1688. Xtcap_curbotleft()
  1689. X{
  1690. X    tcap_cursor(tcap_LINES - 1,0);
  1691. X}    /* end of tcap_curbotleft */
  1692. X
  1693. X/*+-------------------------------------------------------------------------
  1694. X    tcap_insert_lines(count)
  1695. X--------------------------------------------------------------------------*/
  1696. Xvoid
  1697. Xtcap_insert_lines(count)
  1698. Xregister count;
  1699. X{
  1700. X    if(count && *tc_insline)
  1701. X    {
  1702. X        while(count--)
  1703. X            tputs(tc_insline,1,tcap_putc_stderr);
  1704. X    }
  1705. X}    /* end of tcap_insert_lines */
  1706. X
  1707. X/*+-------------------------------------------------------------------------
  1708. X    tcap_delete_lines(count)
  1709. X--------------------------------------------------------------------------*/
  1710. Xvoid
  1711. Xtcap_delete_lines(count)
  1712. Xregister count;
  1713. X{
  1714. X    if(count && *tc_delline)
  1715. X    {
  1716. X        while(count--)
  1717. X            tputs(tc_delline,1,tcap_putc_stderr);
  1718. X    }
  1719. X}    /* end of tcap_delete_lines */
  1720. X
  1721. X/*+-------------------------------------------------------------------------
  1722. X    tcap_insert_chars(count)
  1723. X--------------------------------------------------------------------------*/
  1724. Xvoid
  1725. Xtcap_insert_chars(count)
  1726. Xregister count;
  1727. X{
  1728. X    if(count && *tc_inschar)
  1729. X    {
  1730. X        while(count--)
  1731. X            tputs(tc_inschar,1,tcap_putc_stderr);
  1732. X    }
  1733. X}    /* end of tcap_insert_chars */
  1734. X
  1735. X/*+-------------------------------------------------------------------------
  1736. X    tcap_delete_chars(count)
  1737. X--------------------------------------------------------------------------*/
  1738. Xvoid
  1739. Xtcap_delete_chars(count)
  1740. Xregister count;
  1741. X{
  1742. X    if(count && *tc_delchar)
  1743. X    {
  1744. X        while(count--)
  1745. X            tputs(tc_delchar,1,tcap_putc_stderr);
  1746. X    }
  1747. X}    /* end of tcap_delete_chars */
  1748. X
  1749. X/*+-------------------------------------------------------------------------
  1750. X    tcap_vbell() - output visual bell
  1751. X--------------------------------------------------------------------------*/
  1752. Xvoid
  1753. Xtcap_vbell()
  1754. X{
  1755. X    if(*tc_vbell)
  1756. X        tputs(tc_vbell,1,tcap_putc_stderr);
  1757. X}    /* end of tcap_vbell */
  1758. X
  1759. X/*+-------------------------------------------------------------------------
  1760. X    tcap_clear_screen()
  1761. X--------------------------------------------------------------------------*/
  1762. Xvoid
  1763. Xtcap_clear_screen()
  1764. X{
  1765. X    if(*tc_clear)
  1766. X        tputs(tc_clear,1,tcap_putc_stderr);
  1767. X}    /* end of tcap_clear_screen */
  1768. X
  1769. X/*+-------------------------------------------------------------------------
  1770. X    tcap_eeol() - erase to end of line
  1771. X--------------------------------------------------------------------------*/
  1772. Xvoid
  1773. Xtcap_eeol()
  1774. X{
  1775. X    if(*tc_eeol)
  1776. X        tputs(tc_eeol,1,tcap_putc_stderr);
  1777. X}    /* end of tcap_eeol */
  1778. X
  1779. X/*+-------------------------------------------------------------------------
  1780. X    tcap_eeod() - erase to end of display
  1781. X--------------------------------------------------------------------------*/
  1782. Xvoid
  1783. Xtcap_eeod()
  1784. X{
  1785. X    if(*tc_eeod)
  1786. X        tputs(tc_eeod,1,tcap_putc_stderr);
  1787. X}    /* end of tcap_eeod */
  1788. X
  1789. X/*+-------------------------------------------------------------------------
  1790. X    tcap_stand_out()
  1791. X--------------------------------------------------------------------------*/
  1792. Xvoid
  1793. Xtcap_stand_out()
  1794. X{
  1795. X    if(*tc_standout) /*  && (tc_standout_width == 0)) */
  1796. X        tputs(tc_standout,1,tcap_putc_stderr);
  1797. X}    /* end of tcap_stand_out */
  1798. X
  1799. X/*+-------------------------------------------------------------------------
  1800. X    tcap_stand_end()
  1801. X--------------------------------------------------------------------------*/
  1802. Xvoid
  1803. Xtcap_stand_end()
  1804. X{
  1805. X    if(*tc_standend) /* && (tc_standout_width == 0)) */
  1806. X        tputs(tc_standend,1,tcap_putc_stderr);
  1807. X}    /* end of tcap_stand_end */
  1808. X
  1809. X/*+-------------------------------------------------------------------------
  1810. X    tcap_bold_on()
  1811. X--------------------------------------------------------------------------*/
  1812. Xvoid
  1813. Xtcap_bold_on()
  1814. X{
  1815. X    if(*tc_bold_on)
  1816. X        tputs(tc_bold_on,1,tcap_putc_stderr);
  1817. X    else if(*tc_standout) /*  && (tc_standout_width == 0)) */
  1818. X        tputs(tc_standout,1,tcap_putc_stderr);
  1819. X}    /* end of tcap_bold_on */
  1820. X
  1821. X/*+-------------------------------------------------------------------------
  1822. X    tcap_bold_off()
  1823. X--------------------------------------------------------------------------*/
  1824. Xvoid
  1825. Xtcap_bold_off()
  1826. X{
  1827. X    if(*tc_bold_off)
  1828. X        tputs(tc_bold_off,1,tcap_putc_stderr);
  1829. X    else if(*tc_standend) /* && (tc_standout_width == 0)) */
  1830. X        tputs(tc_standend,1,tcap_putc_stderr);
  1831. X}    /* end of tcap_bold_off */
  1832. X
  1833. X/*+-------------------------------------------------------------------------
  1834. X    tcap_underscore_on()
  1835. X--------------------------------------------------------------------------*/
  1836. Xvoid
  1837. Xtcap_underscore_on()
  1838. X{
  1839. X    if(*tc_underscore_on)
  1840. X        tputs(tc_underscore_on,1,tcap_putc_stderr);
  1841. X    else if(*tc_standout) /*  && (tc_standout_width == 0)) */
  1842. X        tputs(tc_standout,1,tcap_putc_stderr);
  1843. X}    /* end of tcap_underscore_on */
  1844. X
  1845. X/*+-------------------------------------------------------------------------
  1846. X    tcap_underscore_off()
  1847. X--------------------------------------------------------------------------*/
  1848. Xvoid
  1849. Xtcap_underscore_off()
  1850. X{
  1851. X    if(*tc_underscore_off)
  1852. X        tputs(tc_underscore_off,1,tcap_putc_stderr);
  1853. X    else if(*tc_standend) /* && (tc_standout_width == 0)) */
  1854. X        tputs(tc_standend,1,tcap_putc_stderr);
  1855. X}    /* end of tcap_underscore_off */
  1856. X
  1857. X/*+-------------------------------------------------------------------------
  1858. X    tcap_blink_on()
  1859. X--------------------------------------------------------------------------*/
  1860. Xvoid
  1861. Xtcap_blink_on()
  1862. X{
  1863. X    if(*tc_blink_on)
  1864. X        tputs(tc_blink_on,1,tcap_putc_stderr);
  1865. X    else if(*tc_standout) /*  && (tc_standout_width == 0)) */
  1866. X        tputs(tc_standout,1,tcap_putc_stderr);
  1867. X}    /* end of tcap_blink_on */
  1868. X
  1869. X/*+-------------------------------------------------------------------------
  1870. X    tcap_blink_off()
  1871. X--------------------------------------------------------------------------*/
  1872. Xvoid
  1873. Xtcap_blink_off()
  1874. X{
  1875. X    if(*tc_blink_off)
  1876. X        tputs(tc_blink_off,1,tcap_putc_stderr);
  1877. X    else if(*tc_standend) /* && (tc_standout_width == 0)) */
  1878. X        tputs(tc_standend,1,tcap_putc_stderr);
  1879. X}    /* end of tcap_blink_off */
  1880. X
  1881. X/*+-------------------------------------------------------------------------
  1882. X    tcap_clear_area_char(count,clrch)
  1883. X--------------------------------------------------------------------------*/
  1884. Xvoid
  1885. Xtcap_clear_area_char(count,clrch)
  1886. Xregister count;
  1887. Xregister clrch;
  1888. X{
  1889. Xregister itmp = count;
  1890. X    while(itmp--)
  1891. X        fputc(clrch,se);
  1892. X    itmp = count;
  1893. X    while(itmp--)
  1894. X        fputs(tc_curleft,se);
  1895. X
  1896. X}    /* end of tcap_clear_area_char */
  1897. X
  1898. X/*+-------------------------------------------------------------------------
  1899. X numchars = tcap_gets(buf,bufsize,&delim,wait_for_key)
  1900. X
  1901. XThis procedure reads a string and returns the number
  1902. Xof characters read.  -1 is returned if an abort is signaled by the
  1903. Xkeyboard user.
  1904. X--------------------------------------------------------------------------*/
  1905. Xint
  1906. Xtcap_gets(buf,bufsize,delim,wait_for_key)
  1907. Xchar *buf;
  1908. Xregister bufsize;    /* includes room for null..field is 1 less */
  1909. Xregister uchar *delim;
  1910. Xint wait_for_key;
  1911. X{
  1912. Xregister count;
  1913. Xregister itmp;
  1914. Xregister char *cptr = buf;
  1915. X
  1916. X    if(!wait_for_key)
  1917. X        tcap_clear_area_char(bufsize-1,'_');
  1918. X
  1919. X    count = 0;            /* no characters in string */
  1920. X    *cptr = 0;            /* start with null string */
  1921. X
  1922. X    while(1)
  1923. X    {
  1924. X        *delim = ttygetc(1);
  1925. X        if((*delim < 0x20) || (*delim >= 0x7F))
  1926. X        {
  1927. X            switch(*delim)
  1928. X            {
  1929. X                case CR:
  1930. X                    *delim = NL;
  1931. X                case NL:
  1932. X                    return(count);
  1933. X
  1934. X                case BS:
  1935. X                    if(count)
  1936. X                    {
  1937. X                        count--;
  1938. X                        *--cptr = 0;
  1939. X                        fputc(0x08,se);
  1940. X                        fputc('_',se);
  1941. X                        fputs(tc_curleft,se);
  1942. X                    }
  1943. X                    continue;
  1944. X
  1945. X                case ESC:
  1946. X                case CTL_U:
  1947. X                    itmp = count;
  1948. X                    while(itmp--)
  1949. X                    {
  1950. X                        *--cptr = 0;
  1951. X                        fputc(0x08,se);
  1952. X                    }
  1953. X                    itmp = count;
  1954. X                    while(itmp--)
  1955. X                        fputc('_',se);
  1956. X                    itmp = count;
  1957. X                    while(itmp--)
  1958. X                        fputs(tc_curleft,se);
  1959. X                    cptr = buf;
  1960. X                    count = 0;
  1961. X                    if(*delim == ESC)
  1962. X                        return(-1);
  1963. X                    continue;
  1964. X
  1965. X                default:
  1966. X                    return(-1);
  1967. X            }    /* end of switch(*delim) */
  1968. X            /*NOTREACHED*/
  1969. X        }        /* end of if read delimiter */
  1970. X
  1971. X        if(count == bufsize-1)
  1972. X            continue;
  1973. X        if(wait_for_key)
  1974. X        {
  1975. X            tcap_clear_area_char(bufsize-1,'_');
  1976. X            wait_for_key = 0;
  1977. X        }
  1978. X        fputc(*delim,se);
  1979. X        *cptr++ = *delim;
  1980. X        *cptr = 0;
  1981. X        count++;
  1982. X    }    /* end of while can get character */
  1983. X                    
  1984. X}    /* end of tcap_gets */
  1985. X
  1986. X
  1987. X/* end of ecutcap.c */
  1988. X/* vi: set tabstop=4 shiftwidth=4: */
  1989. SHAR_EOF
  1990. $TOUCH -am 1224223490 'ecutcap.c' &&
  1991. chmod 0644 ecutcap.c ||
  1992. echo 'restore of ecutcap.c failed'
  1993. Wc_c="`wc -c < 'ecutcap.c'`"
  1994. test 14554 -eq "$Wc_c" ||
  1995.     echo 'ecutcap.c: original size 14554, current size' "$Wc_c"
  1996. true || echo 'restore of ecutime.c failed'
  1997. echo End of part 7, continue with part 8
  1998. exit 0
  1999. --------------------------------------------------------------------
  2000. Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  2001. Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  2002.  
  2003. exit 0 # Just in case...
  2004. -- 
  2005. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2006. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2007. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2008. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2009.