home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume12 / ecu2.80 / part05 < prev    next >
Encoding:
Text File  |  1990-05-11  |  44.4 KB  |  1,873 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v12i058: ECU 2.80 part 05/29
  3. from: wht%n4hgf@gatech.edu (Warren Tucker)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 12, Issue 58
  7. Submitted-by: wht%n4hgf@gatech.edu (Warren Tucker)
  8. Archive-name: ecu2.80/part05
  9.  
  10. ---- Cut Here and unpack ----
  11. #!/bin/sh
  12. # This is part 05 of ecu280
  13. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  14.  then TOUCH=touch
  15.  else TOUCH=true
  16. fi
  17. # ============= ecuphone.c ==============
  18. echo "x - extracting ecuphone.c (Text)"
  19. sed 's/^X//' << 'SHAR_EOF' > ecuphone.c &&
  20. X/* CHK=0x4180 */
  21. X/*+-------------------------------------------------------------------------
  22. X    ecuphone.c -- visual phone dialer/directory editor
  23. X    wht%n4hgf@gatech.edu
  24. X
  25. X  .---[ title ]------------modified-.<-- dirw "top line"
  26. X  |   stand out mode                |<-- dirw "header line"
  27. X  |                                 |<-- scrw first line
  28. X  |                                 |
  29. X  |                                 |
  30. X  |                                 |
  31. X  |                                 |<-- scrw last line
  32. X  |   stand out mode                |<-- dirw "cmd line"
  33. X  `---------------------------------'<-- dirw bottom line
  34. X
  35. X  Defined functions:
  36. X    check_curr_pde()
  37. X    choose_line(baud)
  38. X    copy_pde_to_lvar(tpde)
  39. X    dirw_bot_msg(msg)
  40. X    dirw_cmd_line_setup(prompt)
  41. X    dirw_display_top()
  42. X    dirw_get_cmd(prompt)
  43. X    lookup_logical_telno()
  44. X    pde_add_or_edit(tpde,edit)
  45. X    pde_add_or_edit_read(prompt,edit,x,buf,max,delim)
  46. X    pde_cmd_add(tpde)
  47. X    pde_cmd_down()
  48. X    pde_cmd_dump_list()
  49. X    pde_cmd_find()
  50. X    pde_cmd_remove()
  51. X    pde_cmd_remove_oops()
  52. X    pde_cmd_save()
  53. X    pde_cmd_up()
  54. X    pde_display(line,tpde,stand_out)
  55. X    pde_display_logical(line,tpde,stand_out)
  56. X    pde_list_add(tpde)
  57. X    pde_list_erase()
  58. X    pde_list_manager()
  59. X    pde_list_read()
  60. X    pde_list_remove(tpde)
  61. X    pde_list_save_if_dirty()
  62. X    pde_list_search(logical,exact_flag)
  63. X    pde_list_set_dirty(flag)
  64. X    scrw_fill(tpde,curr_pde_line)
  65. X    scrw_fill_at(line_num,tpde,curr_pde_line)
  66. X
  67. X--------------------------------------------------------------------------*/
  68. X/*+:EDITS:*/
  69. X/*:05-07-1990-21:23-wht@n4hgf---- 2.80 --- */
  70. X/*:04-20-1990-17:58-wht@n4hgf-choose_line now only uses ACU lines */
  71. X/*:04-19-1990-03:07-wht@n4hgf-GCC run found unused vars -- rm them */
  72. X/*:04-16-1990-01:16-wht@n4hgf-modify for true field editing */
  73. X/*:04-15-1990-19:34-wht@n4hgf-add cursor up and down to motion choices */
  74. X/*:04-14-1990-14:47-wht@n4hgf-refresh dialing directory on no-dial exit */
  75. X/*:03-25-1990-14:11-wht@n4hgf------ x2.70 ------- */
  76. X/*:03-23-1990-14:51-wht@n4hgf-use strcmpi instead of ulcmpb */
  77. X/*:03-12-1990-04:29-wht@n4hgf-add Lrname */
  78. X/*:02-15-1990-15:48-wht-better diagnostic for LOPEN_LCKERR */
  79. X/*:11-24-1989-14:41-wht-UNIX tcap-curses blinks with high bits set on addch */
  80. X/*:11-23-1989-03:11-wht-conditional compile for M_XENIX or M_UNIX */
  81. X/*:10-23-1989-18:31-wht-was not calling enddvent if getdvbaud succeeded */
  82. X/*:10-15-1989-16:52-wht-fix bug on adding to empty directory */
  83. X/*:08-31-1989-12:37-wht-was not always setting brate/parity properly */
  84. X/*:07-03-1989-22:57-wht------ x2.00 ----- */
  85. X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */
  86. X
  87. X#include <curses.h>
  88. X#include "pc_scr.h"
  89. X
  90. X#define STDIO_H_INCLUDED
  91. X#define OMIT_TERMIO_REFERENCES
  92. X#include "ecu.h"
  93. X
  94. X#include "ecupde.h"
  95. X#include "ecukey.h"
  96. X#include "ecuxkey.h"
  97. X#include "ecuhangup.h"
  98. X#include "utmpstatus.h"
  99. X#include "dvent.h"
  100. X
  101. Xvoid dirw_bot_msg();
  102. X
  103. X#if defined(pyr)
  104. X#define strchr index
  105. X#define strrchr rindex
  106. X#endif
  107. X
  108. Xchar *strchr();
  109. Xchar *strrchr();
  110. X
  111. X/* window definitions */
  112. X#define DIRW_LINES        (LINES - 1)
  113. X#define DIRW_COLS        (COLS)
  114. X#define DIRW_COLS        (COLS)
  115. X#define DIRW_TOP_LINES    2
  116. X#define DIRW_BOT_LINES    2
  117. X#define DIRW_CMD_LINE    (DIRW_LINES - 2)
  118. X#define SCRW_LINES        (DIRW_LINES - DIRW_TOP_LINES - DIRW_BOT_LINES)
  119. X#define SCRW_COLS        (DIRW_COLS)
  120. X#define SCRW_TLY        (DIRW_TOP_LINES)
  121. X#define SCRW_TLX        0
  122. X
  123. Xextern int windows_active;
  124. Xextern int rcvr_pid;
  125. Xextern char errmsg[];
  126. Xextern int tcap_LINES;
  127. X
  128. XWINDOW *dirw;
  129. XWINDOW *scrw;
  130. X
  131. XPDE        *pde_list_head = (PDE *)0;    /* pointer to first pde in linked list */
  132. XPDE        *curr_pde = (PDE *)0;        /* current pde */
  133. XPDE        *remove_pde = (PDE *)0;        /* if non-zero, pde just removed */
  134. Xint remove_dirty_flag;            /* pde_list_dirty at remove time */
  135. Xint pde_list_quan = 0;            /* count of items in list now */
  136. Xint pde_list_dirty = 0;            /* pde_list modified but not saved */
  137. Xint scrw_curr_pde_line;            /* scrw line curr_pde is on */
  138. Xchar ecuphone_name[256];            /* phone directory name */
  139. X
  140. X/*+-------------------------------------------------------------------------
  141. X    pde_list_erase()
  142. X--------------------------------------------------------------------------*/
  143. Xvoid
  144. Xpde_list_erase()
  145. X{
  146. Xregister PDE *pde = pde_list_head;
  147. Xregister PDE *next;
  148. X
  149. X    while(pde)
  150. X    {
  151. X        next = pde->next;
  152. X        free((char *)pde);
  153. X        pde = next;
  154. X    }
  155. X    pde_list_head = (PDE *)0;
  156. X    pde_list_quan = 0;
  157. X}    /* end of pde_list_erase */
  158. X
  159. X/*+-------------------------------------------------------------------------
  160. X    pde_list_set_dirty(flag)
  161. X0: clean, 1 dirty, -1 do not modify;update screen only
  162. X--------------------------------------------------------------------------*/
  163. Xvoid
  164. Xpde_list_set_dirty(flag)
  165. Xint flag;
  166. X{
  167. Xregister itmp;
  168. X    if(flag != pde_list_dirty)
  169. X    {
  170. X        if(flag != -1)
  171. X            pde_list_dirty = flag;
  172. X        wmove(dirw,0,DIRW_COLS - 14);
  173. X        if(pde_list_dirty)
  174. X            waddstr(dirw," modified ");
  175. X        else
  176. X        {
  177. X            itmp = 10;
  178. X            while(itmp--)
  179. X                waddch(dirw,(unsigned)sHR);
  180. X        }
  181. X        wrefresh(dirw);
  182. X    }
  183. X}    /* end of pde_list_set_dirty */
  184. X
  185. X/*+-------------------------------------------------------------------------
  186. X    pde_list_add(tpde) -- add to linked list
  187. X--------------------------------------------------------------------------*/
  188. Xvoid
  189. Xpde_list_add(tpde)
  190. XPDE *tpde;
  191. X{
  192. Xregister PDE *this = tpde;
  193. Xregister PDE *prev;
  194. Xregister PDE *next;
  195. X
  196. X/* if empty, init list with this one and quit */
  197. X    if(pde_list_head == (PDE *)0)
  198. X    {
  199. X        pde_list_head = this;
  200. X        this->prev = (PDE *)0;
  201. X        this->next = (PDE *)0;
  202. X        pde_list_quan++;
  203. X        return;
  204. X    }
  205. X
  206. X/* list not empty */
  207. X    prev = (PDE *)0;        /* no previous yet */
  208. X    next = pde_list_head;    /* init next to top of list */
  209. X
  210. X    while(strcmp(next->logical,this->logical) < 0)
  211. X    {
  212. X        prev = next;
  213. X        next = prev->next;
  214. X        if(next == (PDE *)0)
  215. X            break;
  216. X    }
  217. X
  218. X    if(prev)        /* if non-zero, we will not update the list head */
  219. X    {
  220. X        this->next = prev->next;
  221. X        this->prev = prev;
  222. X        prev->next = this;
  223. X        if(next)
  224. X            next->prev = this;
  225. X    }
  226. X    else    /* 'this' is to become the new list head (1st element) */
  227. X    {
  228. X        this->next = next;
  229. X        this->prev = (PDE *)0;
  230. X        if(next)
  231. X            next->prev = this;
  232. X        pde_list_head = this;
  233. X    }
  234. X    pde_list_quan++;
  235. X
  236. X}    /* end of pde_add */
  237. X
  238. X/*+-------------------------------------------------------------------------
  239. X    pde_list_remove(tpde) -- add to linked list
  240. X--------------------------------------------------------------------------*/
  241. Xvoid
  242. Xpde_list_remove(tpde)
  243. Xregister PDE *tpde;
  244. X{
  245. Xregister PDE *prev;
  246. Xregister PDE *next;
  247. X
  248. X    prev = (PDE *)0;    /* there is no previous now */
  249. X
  250. X    if((next = pde_list_head) == (PDE *)0)    /* if empty list */
  251. X        return;
  252. X
  253. X    while(next != tpde)
  254. X    {
  255. X        prev = next;
  256. X        next = prev->next;
  257. X        if(next == (PDE *)0)
  258. X            return;
  259. X    }
  260. X
  261. X/* take care of "current pde" */
  262. X    if(tpde == curr_pde)
  263. X    {
  264. X        if(tpde->next)
  265. X            curr_pde = tpde->next;
  266. X        else if(tpde->prev)
  267. X            curr_pde = tpde->prev;
  268. X        else
  269. X            curr_pde = (PDE *)0;
  270. X    }
  271. X
  272. X/* unlink */
  273. X
  274. X    if(prev)        /* if non-zero, we will not update the list head */
  275. X    {
  276. X        prev->next = tpde->next;
  277. X        if(tpde->next)
  278. X            (tpde->next)->prev = prev;
  279. X    }
  280. X    else
  281. X    {
  282. X        pde_list_head = tpde->next;
  283. X        if(tpde->next)
  284. X            (tpde->next)->prev = (PDE *)0;
  285. X    }
  286. X
  287. X    tpde->next = (PDE *)0;
  288. X    tpde->prev = (PDE *)0;
  289. X
  290. X    pde_list_quan--;
  291. X}    /* end of pde_list_remove */
  292. X
  293. X/*+-----------------------------------------------------------------------
  294. X    PDE *pde_list_search(logical,exact_flag)
  295. X------------------------------------------------------------------------*/
  296. XPDE *
  297. Xpde_list_search(logical,exact_flag)
  298. Xchar *logical;
  299. Xint exact_flag;
  300. X{
  301. Xregister PDE *tpde;
  302. X
  303. X    if(!pde_list_quan)
  304. X    {
  305. X        if(pde_list_read())
  306. X            return((PDE *)0);
  307. X    }
  308. X
  309. X    tpde = pde_list_head;
  310. X    while(tpde)
  311. X    {
  312. X        /* only first few chars necessary for match with ulcmpb */
  313. X        if(exact_flag)
  314. X        {
  315. X            if(strcmp(tpde->logical,logical) == 0)
  316. X                return(tpde);
  317. X        }
  318. X        else
  319. X        {
  320. X            if(ulcmpb(tpde->logical,logical) < 0)
  321. X                return(tpde);
  322. X        }
  323. X        tpde = tpde->next;
  324. X    }
  325. X    if(!tpde)
  326. X        sprintf(errmsg,"'%s' not found",logical);
  327. X    return(tpde);
  328. X
  329. X}    /* end of pde_list_search */
  330. X
  331. X/*+-------------------------------------------------------------------------
  332. X    pde_cmd_dump_list()
  333. X--------------------------------------------------------------------------*/
  334. X#if defined(PDE_DEBUG)
  335. Xvoid
  336. Xpde_cmd_dump_list()
  337. X{
  338. Xregister PDE *tpde = pde_list_head;
  339. Xint count = 0;
  340. X
  341. X    curmove(LINES - 1,0);
  342. X    while(tpde)
  343. X    {
  344. X        ff(se,"p:%04x t:%04x n:%04x %c %s\r\n",
  345. X            tpde->prev,tpde,tpde->next,(tpde == curr_pde) ? '*' : ' ',
  346. X            tpde->logical);
  347. X        if((count++ % 15) == 14)
  348. X        {
  349. X            ff(se,"press return:  ");
  350. X            ttygetc(1);
  351. X            ff(se,"\r\n");
  352. X        }
  353. X        tpde = tpde->next;
  354. X    }
  355. X    ff(se,"press return:  ");
  356. X    ttygetc(1);
  357. X    touchwin(stdscr);
  358. X    touchwin(dirw);
  359. X    touchwin(scrw);
  360. X    wrefresh(stdscr);
  361. X    wrefresh(dirw);
  362. X    wrefresh(scrw);
  363. X
  364. X}    /* end of pde_cmd_dump_list */
  365. X#endif
  366. X
  367. X/*+-----------------------------------------------------------------------
  368. X    pde_list_read()
  369. Xsample .ecu/phone:
  370. X#tri2:426-0624:2400:E:Tridom Pyramid        comment
  371. Xarc:393-3083:2400:N:Atlanta Radio Club
  372. X
  373. Xreturn 0 if entire list read, else 1 if error (error msg in errmsg)
  374. X------------------------------------------------------------------------*/
  375. Xint
  376. Xpde_list_read()
  377. X{
  378. Xregister itmp;
  379. Xregister token_number;
  380. Xregister char *cptr;
  381. Xregister char *token;
  382. Xchar readpde_buf[128];
  383. XFILE *fp_phone;
  384. XPDE     *tpde;
  385. Xchar *str_token();
  386. X
  387. X    if(!ecuphone_name[0])
  388. X    {
  389. X        get_home_dir(ecuphone_name);
  390. X        strcat(ecuphone_name,"/.ecu/phone");
  391. X    }
  392. X
  393. X    if( (fp_phone = fopen(ecuphone_name,"r")) == NULL)
  394. X    {
  395. X        perror_errmsg(ecuphone_name);
  396. X        return(1);
  397. X    }
  398. X
  399. X/* we have an open .ecu/phone file */
  400. X    pde_list_erase();        /* clear any previous directory */
  401. X    while(fgets(readpde_buf,sizeof(readpde_buf),fp_phone) != NULL)
  402. X    {
  403. X        if(readpde_buf[0] == '#')        /* comment? */
  404. X            continue;
  405. X        if(itmp = strlen(readpde_buf))    /* itmp = len; if > 0 ... */
  406. X        {
  407. X            itmp--;
  408. X            readpde_buf[itmp] = 0;        /* ... strip trailing NL */
  409. X        }
  410. X        cptr = readpde_buf;                /* first call to str_token, -> buff */
  411. X        while((*cptr == 0x20) || (*cptr == TAB))
  412. X            cptr++;                        /* strip leading spaces */
  413. X        if(*cptr == 0)                    /* if line all blank, skip it */
  414. X            continue;
  415. X
  416. X        if(!(tpde = (PDE *)malloc(sizeof(PDE))))
  417. X        {
  418. X            fclose(fp_phone);
  419. X            strcpy(errmsg,"Out of memory reading phone list");
  420. X            return(1);
  421. X        }
  422. X
  423. X        tpde->descr[0] = 0;
  424. X        tpde->logical[0] = 0;
  425. X        tpde->telno[0] = 0;
  426. X        tpde->tty[0] = 0;
  427. X        tpde->parity = 0;
  428. X        tpde->baud = 2400;
  429. X        tpde->prev = (PDE *)0;
  430. X        tpde->next = (PDE *)0;
  431. X
  432. X        token_number = 0;
  433. X        while((token = str_token(cptr,":")) != NULL)
  434. X        {
  435. X            cptr = NULL;    /* further calls to str_token need NULL */
  436. X            switch(token_number++)
  437. X            {
  438. X                case 0:        /* first field is logical name */
  439. X                    strncpy(tpde->logical,token,sizeof(tpde->logical));
  440. X                    tpde->logical[sizeof(tpde->logical) - 1] = 0;
  441. X                    break;
  442. X                case 1:        /* second field is tpde->telno phone number */
  443. X                    strncpy(tpde->telno,token,sizeof(tpde->telno));
  444. X                    tpde->telno[sizeof(tpde->telno) - 1] = 0;
  445. X                    break;
  446. X                case 2:        /* third field is line */
  447. X                    strncpy(tpde->tty,token,sizeof(tpde->tty));
  448. X                    tpde->tty[sizeof(tpde->tty) - 1] = 0;
  449. X                    break;
  450. X                case 3:        /* fourth field is baud rate */
  451. X                    tpde->baud = atoi(token);
  452. X                    break;
  453. X                case 4:        /* fifth field is parity */
  454. X                    switch(itmp = to_lower(token[0]))
  455. X                    {
  456. X                        case 'o':
  457. X                        case 'e':
  458. X                        case 'm':
  459. X                        case 's':
  460. X                            tpde->parity = itmp;
  461. X                            break;
  462. X                        default:
  463. X                        case 'n':
  464. X                            tpde->parity = 0;
  465. X                            break;
  466. X                    }
  467. X                    break;
  468. X                default:
  469. X                    strncpy(tpde->descr,token,sizeof(tpde->descr));
  470. X                    tpde->descr[sizeof(tpde->descr) - 1] = 0;
  471. X                    break;
  472. X            }    /* end of switch(token_number) */
  473. X        }        /* end while not end of record */
  474. X
  475. X        pde_list_add(tpde);
  476. X
  477. X    }            /* while records left to ready */
  478. X
  479. X    fclose(fp_phone);
  480. X    return(0);
  481. X}    /* end of pde_list_read */
  482. X
  483. X/*+-----------------------------------------------------------------------
  484. X    dirw_display_top()
  485. X------------------------------------------------------------------------*/
  486. Xvoid
  487. Xdirw_display_top()
  488. X{
  489. X    wmove(dirw,1,1);
  490. X    wstandout(dirw);
  491. X    wprintw(dirw,
  492. X" entry name %c telephone number %c tty %c baud P %c description                   ",
  493. X        sVR,sVR,sVR,sVR);
  494. X    wstandend(dirw);
  495. X    wrefresh(dirw);
  496. X}    /* end of dirw_display_top() */
  497. X
  498. X/*+-------------------------------------------------------------------------
  499. X    dirw_bot_msg(msg)
  500. X--------------------------------------------------------------------------*/
  501. Xvoid
  502. Xdirw_bot_msg(msg)
  503. Xchar *msg;
  504. X{
  505. Xregister itmp;
  506. Xregister itmp2;
  507. Xstatic last_msglen = 0;
  508. X#define DIRW_BOT_LINE_TLX 2
  509. X#define DIRW_BOT_LINE_MAX_MSGLEN    (DIRW_COLS - DIRW_BOT_LINE_TLX - 8)
  510. Xchar msg2[80];
  511. X
  512. X    if(!last_msglen && !strlen(msg))
  513. X        return;
  514. X
  515. X    wmove(dirw,DIRW_LINES - 1,DIRW_BOT_LINE_TLX);
  516. X
  517. X    if((itmp = strlen(msg)) == 0)
  518. X    {
  519. X        itmp2 = last_msglen + 2;
  520. X        for(itmp = 0; itmp < itmp2; itmp++)
  521. X            waddch(dirw,(unsigned)sHR);
  522. X        last_msglen = 0;
  523. X    }
  524. X    else
  525. X    {
  526. X        waddch(dirw,' ');
  527. X        if(itmp > DIRW_BOT_LINE_MAX_MSGLEN)
  528. X        {
  529. X            strncpy(msg2,msg,DIRW_BOT_LINE_MAX_MSGLEN);
  530. X            msg2[DIRW_BOT_LINE_MAX_MSGLEN + 1] = 0;
  531. X            waddstr(dirw,msg2);
  532. X            itmp = strlen(msg2);
  533. X        }
  534. X        else
  535. X        {
  536. X            waddstr(dirw,msg);
  537. X            itmp = strlen(msg);
  538. X        }
  539. X        waddch(dirw,' ');
  540. X        if((itmp2 = last_msglen - itmp) > 0)
  541. X        {
  542. X            while(itmp2--)
  543. X                waddch(dirw,(unsigned)sHR);
  544. X        }
  545. X        last_msglen = itmp;        /* remember last message length */
  546. X    }
  547. X    wrefresh(dirw);
  548. X}    /* end of dirw_bot_msg */
  549. X
  550. X/*+-------------------------------------------------------------------------
  551. X    pde_display_logical(line,tpde,stand_out)
  552. X--------------------------------------------------------------------------*/
  553. Xvoid
  554. Xpde_display_logical(line,tpde,stand_out)
  555. Xint line;
  556. XPDE        *tpde;
  557. Xint stand_out;
  558. X{
  559. X    wmove(scrw,line,0);
  560. X    waddch(scrw,(unsigned)sVR);
  561. X
  562. X    if(stand_out)
  563. X        wstandout(scrw);
  564. X    wprintw(scrw," %-10.10s",tpde->logical);
  565. X    if(stand_out)
  566. X        wstandend(scrw);
  567. X
  568. X}    /* end of pde_display_logical */
  569. X
  570. X/*+-----------------------------------------------------------------------
  571. X    pde_display(win,line,tpde,stand_out)
  572. X00000000001111111111222222222233333333334444444444555555555566666666667777777777
  573. X01234567890123456789012345678901234567890123456789012345678901234567890123456789
  574. X| entry name | telephone number | tty | baud P | description                   |
  575. X| 0123456789 | 0123456789012345 | 01  | baud P | 01234567890123456789012345678 |
  576. X--------------------------------------------------------------------------*/
  577. Xpde_display(line,tpde,stand_out)
  578. Xint line;
  579. XPDE        *tpde;
  580. Xint stand_out;
  581. X{
  582. X
  583. X    pde_display_logical(line,tpde,stand_out);
  584. X    waddch(scrw,' ');
  585. X    waddch(scrw,(unsigned)sVR);
  586. X    waddch(scrw,' ');
  587. X    wprintw(scrw,"%-16.16s %c ",tpde->telno,sVR);
  588. X    if(tpde->tty[0])
  589. X        wprintw(scrw,"%-2.2s  %c",tpde->tty,sVR);
  590. X    else
  591. X        wprintw(scrw,"Any %c",sVR);
  592. X    wprintw(scrw,"%5u %c %c ",tpde->baud,
  593. X        (tpde->parity) ? to_upper(tpde->parity) : 'N',sVR);
  594. X    wprintw(scrw,"%-29.29s %c",tpde->descr,sVR);
  595. X    return(0);
  596. X
  597. X}    /* end of pde_display */
  598. X
  599. X/*+-----------------------------------------------------------------------
  600. X    scrw_fill(first_pde,curr_pde_line)
  601. X------------------------------------------------------------------------*/
  602. Xvoid
  603. Xscrw_fill(tpde,curr_pde_line)
  604. Xregister PDE *tpde;
  605. Xint *curr_pde_line;
  606. X{
  607. Xregister line;
  608. Xregister is_curr_pde;
  609. X
  610. X    *curr_pde_line = -1;
  611. X    for(line = 0; line < SCRW_LINES; line++)
  612. X    {
  613. X        if(tpde)
  614. X        {
  615. X            if(is_curr_pde = (tpde == curr_pde))
  616. X                *curr_pde_line = line;
  617. X            pde_display(line,tpde,(tpde == curr_pde));
  618. X            tpde = tpde->next;
  619. X        }
  620. X        else
  621. X        {
  622. X            wmove(scrw,line,0);
  623. X            waddch(scrw,(unsigned)sVR);
  624. X            wclrtoeol(scrw);
  625. X            wmove(scrw,line,SCRW_COLS - 1);
  626. X            waddch(scrw,(unsigned)sVR);
  627. X        }
  628. X    }
  629. X    wrefresh(scrw);
  630. X
  631. X}    /* end of scrw_fill */
  632. X
  633. X/*+-------------------------------------------------------------------------
  634. X    scrw_fill_at(line_num,first_pde,curr_pde_line)
  635. X--------------------------------------------------------------------------*/
  636. Xvoid
  637. Xscrw_fill_at(line_num,tpde,curr_pde_line)
  638. Xint line_num;
  639. Xregister PDE *tpde;
  640. Xint *curr_pde_line;
  641. X{
  642. Xregister itmp;
  643. X
  644. X    if(!tpde)
  645. X    {
  646. X        scrw_fill(tpde,curr_pde_line);
  647. X/*
  648. X        wclear(scrw);
  649. X        wrefresh(scrw);
  650. X*/
  651. X        return;
  652. X    }
  653. X    for(itmp = 0; itmp < line_num; itmp++)
  654. X    {
  655. X        if(!tpde->prev)
  656. X            break;
  657. X        tpde = tpde->prev;
  658. X    }
  659. X
  660. X    scrw_fill(tpde,curr_pde_line);
  661. X
  662. X}    /* end of scrw_fill_at */
  663. X
  664. X/*+-------------------------------------------------------------------------
  665. X    dirw_cmd_line_setup(prompt)
  666. X--------------------------------------------------------------------------*/
  667. Xvoid
  668. Xdirw_cmd_line_setup(prompt)
  669. Xchar *prompt;
  670. X{
  671. Xregister icol;
  672. Xint y;
  673. Xint x;
  674. X
  675. X    wmove(dirw,DIRW_CMD_LINE,1);
  676. X    wstandout(dirw);
  677. X    waddch(dirw,' ');
  678. X    waddstr(dirw,prompt);
  679. X    waddch(dirw,' ');
  680. X    getyx(dirw,y,x);
  681. X    for(icol = x; icol < DIRW_COLS - 1; icol++)
  682. X        waddch(dirw,' ');
  683. X    wmove(dirw,y,x);
  684. X    wstandend(dirw);
  685. X    wrefresh(dirw);
  686. X}    /* end of dirw_cmd_line_setup */
  687. X
  688. X/*+-------------------------------------------------------------------------
  689. X    dirw_get_cmd()
  690. X--------------------------------------------------------------------------*/
  691. Xuchar
  692. Xdirw_get_cmd(prompt)
  693. Xchar *prompt;
  694. X{
  695. Xregister uchar cmd;
  696. X
  697. X    dirw_cmd_line_setup(prompt);
  698. X    cmd = ttygetc(1);
  699. X    dirw_bot_msg("");
  700. X    return(cmd);
  701. X
  702. X}    /* end of dirw_get_cmd */
  703. X
  704. X/*+-------------------------------------------------------------------------
  705. X    pde_cmd_save()
  706. X--------------------------------------------------------------------------*/
  707. Xvoid
  708. Xpde_cmd_save()
  709. X{
  710. XFILE *fpold;
  711. XFILE *fpnew;
  712. XPDE        *tpde;
  713. Xchar ecuphone_ntmp[256];        /* temp phone directory name */
  714. Xchar iobuf[128];
  715. Xint count = 0;
  716. X
  717. X    if(!pde_list_dirty)
  718. X    {
  719. X        dirw_bot_msg("directory has not been modified");
  720. X        return;
  721. X    }
  722. X
  723. X    strcpy(ecuphone_ntmp,ecuphone_name);
  724. X    strcat(ecuphone_ntmp,".t");
  725. X
  726. X    if((fpnew = fopen(ecuphone_ntmp,"w")) == NULL)    /* open old file */
  727. X    {
  728. X        sprintf(iobuf,"cannot open %s",ecuphone_ntmp);
  729. X        dirw_bot_msg(iobuf);
  730. X        return;
  731. X    }
  732. X
  733. X/* retain commented entries */
  734. X    if((fpold = fopen(ecuphone_name,"r")) != NULL)    /* open old file */
  735. X    {
  736. X        while(fgets(iobuf,sizeof(iobuf),fpold) != NULL)
  737. X        {
  738. X            if(iobuf[0] == '#')
  739. X                fputs(iobuf,fpnew);
  740. X        }
  741. X        fclose(fpold);
  742. X    }
  743. X
  744. X/* write new entries */
  745. X    tpde = pde_list_head;
  746. X    while(tpde)
  747. X    {
  748. X        sprintf(iobuf,"%d",count+1);
  749. X        dirw_bot_msg(iobuf);
  750. X        sprintf(iobuf,"%s:%s:%s:%u:%c:%s\n",tpde->logical,tpde->telno,
  751. X            tpde->tty,tpde->baud,
  752. X            (tpde->parity) ? to_upper(tpde->parity) : 'N',
  753. X            tpde->descr);
  754. X        fputs(iobuf,fpnew);
  755. X        tpde = tpde->next;
  756. X        count++;
  757. X    }
  758. X
  759. X    fclose(fpnew);
  760. X    unlink(ecuphone_name);
  761. X    rename(ecuphone_ntmp,ecuphone_name);
  762. X    sprintf(iobuf,"saved %d entries",count);
  763. X    dirw_bot_msg(iobuf);
  764. X    pde_list_set_dirty(0);
  765. X
  766. X}    /* end of pde_cmd_save */
  767. X
  768. X/*+-------------------------------------------------------------------------
  769. X    pde_list_save_if_dirty()
  770. X--------------------------------------------------------------------------*/
  771. Xvoid
  772. Xpde_list_save_if_dirty()
  773. X{
  774. Xint cmd = 0;
  775. X
  776. X    if(pde_list_dirty)
  777. X    {
  778. X        while(!cmd)
  779. X        {
  780. X            ring_bell();
  781. X            cmd = dirw_get_cmd("directory modified: save?");
  782. X            if(isupper(cmd))
  783. X                cmd = tolower(cmd);
  784. X            switch(cmd)
  785. X            {
  786. X                case 'y': pde_cmd_save(); break;
  787. X                case 'n': break;
  788. X                default:
  789. X                    ring_bell();
  790. X                    cmd = 0;
  791. X                    break;        
  792. X            }
  793. X        }
  794. X    }
  795. X}    /* end of pde_list_save_if_dirty */
  796. X
  797. X/*+-------------------------------------------------------------------------
  798. X    pde_cmd_up()
  799. X--------------------------------------------------------------------------*/
  800. Xvoid
  801. Xpde_cmd_up()
  802. X{
  803. Xregister PDE *tpde;
  804. X
  805. X    if((!curr_pde) || (curr_pde->prev == (PDE *)0))
  806. X    {
  807. X        ring_bell();
  808. X        return;
  809. X    }
  810. X    if(scrw_curr_pde_line)
  811. X    {
  812. X        pde_display_logical(scrw_curr_pde_line,curr_pde,0);
  813. X        scrw_curr_pde_line--;
  814. X        curr_pde = curr_pde->prev;
  815. X        pde_display_logical(scrw_curr_pde_line,curr_pde,1);
  816. X    }
  817. X    else
  818. X    {
  819. X        tpde = curr_pde;
  820. X        curr_pde = curr_pde->prev;
  821. X        scrw_fill_at(10,tpde,&scrw_curr_pde_line);
  822. X    }
  823. X
  824. X}    /* end of pde_cmd_up */
  825. X
  826. X/*+-------------------------------------------------------------------------
  827. X    pde_cmd_down()
  828. X--------------------------------------------------------------------------*/
  829. Xvoid
  830. Xpde_cmd_down()
  831. X{
  832. Xregister itmp;
  833. Xregister PDE *tpde;
  834. X
  835. X    if((!curr_pde) || (curr_pde->next == (PDE *)0))
  836. X    {
  837. X        ring_bell();
  838. X        return;
  839. X    }
  840. X    if(scrw_curr_pde_line < (SCRW_LINES - 1))
  841. X    {
  842. X        pde_display_logical(scrw_curr_pde_line,curr_pde,0);
  843. X        scrw_curr_pde_line++;
  844. X        curr_pde = curr_pde->next;
  845. X        pde_display_logical(scrw_curr_pde_line,curr_pde,1);
  846. X    }
  847. X    else
  848. X    {
  849. X        tpde = curr_pde;
  850. X        curr_pde = curr_pde->next;
  851. X        scrw_fill_at(SCRW_LINES - 10,tpde,&scrw_curr_pde_line);
  852. X    }
  853. X
  854. X}    /* end of pde_cmd_down */
  855. X
  856. X/*+-------------------------------------------------------------------------
  857. X    check_curr_pde() -- return 1 if there is a current pde, else 0
  858. X--------------------------------------------------------------------------*/
  859. Xcheck_curr_pde()
  860. X{
  861. X    if(!curr_pde)
  862. X    {
  863. X        dirw_bot_msg("no directory entry selected");
  864. X        return(0);
  865. X    }
  866. X    return(1);
  867. X}    /* end of check_curr_pde */
  868. X
  869. X/*+-------------------------------------------------------------------------
  870. X    pde_add_or_edit_read(prompt,edit,x,buf,max,delim)
  871. Xmax must not wrap around to another line
  872. X--------------------------------------------------------------------------*/
  873. Xpde_add_or_edit_read(prompt,edit,x,buf,max,delim)
  874. Xchar *prompt;
  875. Xint edit;
  876. Xint x;
  877. Xchar *buf;
  878. Xint max;
  879. Xchar *delim;
  880. X{
  881. Xregister itmp;
  882. Xchar s82[82];
  883. X
  884. X    while(1)
  885. X    {
  886. X        dirw_cmd_line_setup(prompt);
  887. X        wstandout(scrw);
  888. X        if(edit)
  889. X            strcpy(s82,buf);
  890. X        itmp = wingets(scrw,scrw_curr_pde_line,x,s82,max,delim,edit);
  891. X        wstandend(scrw);
  892. X        
  893. X        switch(*delim)
  894. X        {
  895. X            case ESC:
  896. X                return;
  897. X
  898. X            case CR:
  899. X            case NL:
  900. X                if(edit && (itmp == 0))
  901. X                {
  902. X                    *delim = TAB;
  903. X                    return;
  904. X                }
  905. X                strcpy(buf,s82);
  906. X                return;
  907. X
  908. X            case CTL_B:
  909. X                *buf = 0;
  910. X                return;
  911. X
  912. X            case TAB:
  913. X                if(!edit)
  914. X                    continue;
  915. X                *buf = 0;
  916. X                return;
  917. X
  918. X            default:
  919. X                break;
  920. X        }
  921. X    }
  922. X}    /* end of pde_add_or_edit_read */
  923. X
  924. X/*+-------------------------------------------------------------------------
  925. X    pde_add_or_edit(tpde,edit)
  926. Xif called with edit == 1, tpde MUST == curr_pde !!!
  927. X00000000001111111111222222222233333333334444444444555555555566666666667777777777
  928. X01234567890123456789012345678901234567890123456789012345678901234567890123456789
  929. X| entry name | telephone number | tty | baud P | description                   |
  930. X| 0123456789 | 0123456789012345 | 01  | baud P | 01234567890123456789012345678 |
  931. X--------------------------------------------------------------------------*/
  932. Xint
  933. Xpde_add_or_edit(tpde,edit)
  934. Xregister PDE *tpde;
  935. Xint edit;
  936. X{
  937. Xregister itmp;
  938. Xint input_state = 0;
  939. Xint changed;
  940. Xchar s50[50];
  941. Xchar delim;
  942. Xint done = 0;
  943. Xint y,x;
  944. XPDE *old_curr_pde;
  945. Xuint baud;
  946. X
  947. X    if(!edit)
  948. X    {
  949. X        dirw_bot_msg("ESC: abort  ^U: erase input");
  950. X        dirw_cmd_line_setup("Enter new directory entry name: ");
  951. X        getyx(dirw,y,x);
  952. X        wstandout(dirw);
  953. X        wingets(dirw,y,x,tpde->logical,10+1,&delim,0);
  954. X        wstandend(dirw);
  955. X        if((!strlen(tpde->logical)) || (tpde->logical[0] == ESC))
  956. X        {
  957. X            dirw_bot_msg("add aborted");
  958. X            return(0);
  959. X        }
  960. X    
  961. X        if(!isalpha(tpde->logical[0]))
  962. X        {
  963. X            dirw_bot_msg("first character must be alphabetic");
  964. X            return(0);
  965. X        }
  966. X
  967. X        if(pde_list_search(tpde->logical,1))
  968. X        {
  969. X            sprintf(s50,"'%s' is already in the directory",tpde->logical);
  970. X            ring_bell();
  971. X            dirw_bot_msg(s50);
  972. X            return(0);
  973. X        }
  974. X
  975. X        tpde->descr[0] = 0;
  976. X        tpde->telno[0] = 0;
  977. X        tpde->tty[0] = 0;
  978. X        tpde->parity = '-';
  979. X        tpde->baud = 0;                
  980. X    
  981. X        pde_list_add(tpde);
  982. X        old_curr_pde = curr_pde;
  983. X        curr_pde = tpde;
  984. X        scrw_fill_at(SCRW_LINES / 2,tpde,&scrw_curr_pde_line);
  985. X        tpde = curr_pde;
  986. X    }    /* end of add code */
  987. X
  988. X    if(edit)
  989. X        dirw_bot_msg("ESC: exit  ^U: erase input  ^B: back  TAB: forward");
  990. X    else
  991. X        dirw_bot_msg("ESC: abort  ^U: erase input  ^B: back up");
  992. X
  993. X/* add/edit common */
  994. X    while(!done)
  995. X    {
  996. X        changed = 0;
  997. X        switch(input_state)
  998. X        {
  999. X            case 0:
  1000. X                if(edit)
  1001. X                    strcpy(s50,tpde->telno);
  1002. X                pde_add_or_edit_read("Enter telephone number",
  1003. X                    edit,15,tpde->telno,16+1,&delim);
  1004. X                if(edit && strcmp(tpde->telno,s50))
  1005. X                    changed = 1;
  1006. X                break;
  1007. X
  1008. X            case 1:
  1009. X                if(edit)
  1010. X                    strcpy(s50,(tpde->tty[0]) ? tpde->tty : "Any");
  1011. X                pde_add_or_edit_read("Enter tty identifier (i.e., 1a)",
  1012. X                    edit,34,s50,3+1,&delim);
  1013. X                if(edit && strcmp((tpde->tty[0]) ? tpde->tty : "Any",s50))
  1014. X                    changed = 1;
  1015. X                if(!strcmpi(s50,"any"))
  1016. X                    tpde->tty[0] = 0;
  1017. X                else
  1018. X                {
  1019. X                    strncpy(tpde->tty,s50,2);
  1020. X                    tpde->tty[2] = 0;
  1021. X                }
  1022. X                break;
  1023. X
  1024. X            case 2:
  1025. X                if(edit)
  1026. X                    sprintf(s50,"%u",tpde->baud);
  1027. X                pde_add_or_edit_read(
  1028. X                "Enter baud rate (110,300,600,1200,2400,4800,9600,19200,38400)",
  1029. X                    edit,39,s50,5+1,&delim);
  1030. X                if(valid_baud_rate(baud = atoi(s50)) < 0)
  1031. X                {
  1032. X                    ring_bell();
  1033. X                    continue;
  1034. X                }
  1035. X                if(edit && (tpde->baud != baud ))
  1036. X                    changed = 1;
  1037. X                tpde->baud = baud;
  1038. X                break;
  1039. X
  1040. X            case 3:
  1041. X                if(edit)
  1042. X                    sprintf(s50,"%c",(tpde->parity) ? tpde->parity : 'n');
  1043. X                pde_add_or_edit_read("Enter parity (n,o,e)",
  1044. X                    edit,45,s50,1+1,&delim);
  1045. X                switch(s50[0] = to_lower(s50[0]))
  1046. X                {
  1047. X                    case 'n':
  1048. X                        s50[0] = 0;
  1049. X                    case 'o':
  1050. X                    case 'e':
  1051. X                        if(edit && (tpde->parity != s50[0]))
  1052. X                            changed = 1;
  1053. X                        tpde->parity = s50[0];
  1054. X                        break;
  1055. X                    default:
  1056. X                        ring_bell();
  1057. X                        continue;
  1058. X                }
  1059. X                break;
  1060. X
  1061. X            case 4:
  1062. X                if(edit)
  1063. X                    strcpy(s50,tpde->descr);
  1064. X                pde_add_or_edit_read("Enter description",
  1065. X                    edit,49,tpde->descr,29+1,&delim);
  1066. X                if(edit && strcmp(tpde->descr,s50))
  1067. X                    changed = 1;
  1068. X                break;
  1069. X        }
  1070. X
  1071. X        pde_display(scrw_curr_pde_line,tpde,1);    /* regardless of delimiter */
  1072. X
  1073. X        switch(delim) /* process delimiter */
  1074. X        {
  1075. X            case CTL_L:
  1076. X            case CTL_R:
  1077. X                clear_screen();
  1078. X                touchwin(stdscr);
  1079. X                wrefresh(stdscr);
  1080. X                touchwin(dirw);
  1081. X                wrefresh(dirw);
  1082. X                touchwin(scrw);
  1083. X                wrefresh(scrw);
  1084. X                break;
  1085. X
  1086. X            case CTL_B:
  1087. X                if(input_state)
  1088. X                    input_state--;
  1089. X                break;
  1090. X
  1091. X            case TAB:
  1092. X                input_state++;
  1093. X                input_state %= 5;
  1094. X                break;
  1095. X
  1096. X            case ESC:
  1097. X                if(edit)
  1098. X                {
  1099. X                    dirw_bot_msg("edit finished");
  1100. X                    done = 1;
  1101. X                }
  1102. X                else
  1103. X                {
  1104. X                    pde_list_remove(tpde);
  1105. X                    curr_pde = old_curr_pde;
  1106. X                    scrw_fill_at(scrw_curr_pde_line + 1,curr_pde,
  1107. X                            &scrw_curr_pde_line);
  1108. X                    dirw_bot_msg("add aborted");
  1109. X                    return(0);
  1110. X                }
  1111. X                break;
  1112. X
  1113. X            case NL:
  1114. X                if(edit && changed)
  1115. X                    pde_list_set_dirty(1);
  1116. X                /* fall thru */
  1117. X            default:
  1118. X                if(!edit && (input_state == 4))
  1119. X                    done = 1;
  1120. X                else 
  1121. X                {
  1122. X                    input_state++;
  1123. X                    input_state %= 5;
  1124. X                }
  1125. X                break;
  1126. X        }
  1127. X    }
  1128. X    return(1);
  1129. X
  1130. X}    /* end of pde_add_or_edit */
  1131. X
  1132. X/*+-------------------------------------------------------------------------
  1133. X    pde_cmd_add(tpde)
  1134. Xif tpde != 0, it is an already valid pde that is to be added
  1135. Xelse if == 0, interactive add
  1136. X--------------------------------------------------------------------------*/
  1137. Xvoid
  1138. Xpde_cmd_add(tpde)
  1139. Xregister PDE *tpde;
  1140. X{
  1141. Xregister itmp;
  1142. X
  1143. X    if(tpde)
  1144. X    {
  1145. X        pde_list_add(tpde);
  1146. X    }
  1147. X    else
  1148. X    {
  1149. X        if(!(tpde = (PDE *)malloc(sizeof(PDE))))
  1150. X        {
  1151. X            dirw_bot_msg("Out of memory -- cannot add new entry");
  1152. X            return;
  1153. X        }
  1154. X        if(!pde_add_or_edit(tpde,0))    /* routine will add to list ... */
  1155. X        {                                /* ... if good return */
  1156. X            free((char *)tpde);
  1157. X            return;
  1158. X        }
  1159. X    }
  1160. X    pde_list_set_dirty(1);
  1161. X
  1162. X    curr_pde = tpde;
  1163. X    scrw_fill_at(SCRW_LINES / 2,curr_pde,&scrw_curr_pde_line);
  1164. X
  1165. X}    /* end of pde_cmd_add */
  1166. X
  1167. X/*+-------------------------------------------------------------------------
  1168. X    pde_cmd_remove_oops()
  1169. X--------------------------------------------------------------------------*/
  1170. Xvoid
  1171. Xpde_cmd_remove_oops()
  1172. X{
  1173. X    if(!remove_pde)
  1174. X    {
  1175. X        dirw_bot_msg("no removed entry to restore");
  1176. X        return;
  1177. X    }
  1178. X    pde_cmd_add(remove_pde);
  1179. X    pde_list_set_dirty(remove_dirty_flag);
  1180. X    remove_pde = (PDE *)0;
  1181. X}    /* end of pde_cmd_remove_oops */
  1182. X
  1183. X/*+-------------------------------------------------------------------------
  1184. X    pde_cmd_remove()
  1185. X--------------------------------------------------------------------------*/
  1186. Xvoid
  1187. Xpde_cmd_remove()
  1188. X{
  1189. Xregister itmp;
  1190. Xregister PDE *tpde;
  1191. Xchar s80[80];
  1192. X
  1193. X    if(!check_curr_pde())
  1194. X        return;
  1195. X
  1196. X    remove_pde = curr_pde;
  1197. X    remove_dirty_flag = pde_list_dirty;
  1198. X    pde_list_remove(curr_pde);
  1199. X    pde_list_set_dirty(1);
  1200. X
  1201. X    if(pde_list_quan)
  1202. X        scrw_fill_at(scrw_curr_pde_line + 1,curr_pde,&scrw_curr_pde_line);
  1203. X    else
  1204. X        scrw_fill((PDE *)0,&scrw_curr_pde_line);
  1205. X
  1206. X    ring_bell();
  1207. X    sprintf(s80,"if you did not mean to to remove '%s', press 'o' (oops) NOW!",
  1208. X            remove_pde->logical);
  1209. X    dirw_bot_msg(s80);
  1210. X
  1211. X}    /* end of pde_cmd_remove */
  1212. X
  1213. X/*+-------------------------------------------------------------------------
  1214. X    pde_cmd_find()
  1215. X--------------------------------------------------------------------------*/
  1216. Xvoid
  1217. Xpde_cmd_find()
  1218. X{
  1219. Xregister itmp;
  1220. Xregister PDE *tpde;
  1221. Xchar findname[12];
  1222. Xchar s50[50];
  1223. Xchar delim;
  1224. Xint y,x;
  1225. X
  1226. X    dirw_bot_msg("ESC: abort  ^U: erase input");
  1227. X    dirw_cmd_line_setup("Directory entry name to find: ");
  1228. X    getyx(dirw,y,x);
  1229. X    wstandout(dirw);
  1230. X    wingets(dirw,y,x,findname,10+1,&delim,0);
  1231. X    wstandend(dirw);
  1232. X    if((!strlen(findname)) || (delim == ESC))
  1233. X        return;
  1234. X
  1235. X    if(! (tpde = pde_list_search(findname,0)))
  1236. X    {
  1237. X        dirw_bot_msg(errmsg);
  1238. X        return;
  1239. X    }
  1240. X    curr_pde = tpde;
  1241. X    scrw_fill_at(SCRW_LINES / 2,tpde,&scrw_curr_pde_line);
  1242. X
  1243. X}    /* end of pde_cmd_find */
  1244. X
  1245. X/*+-------------------------------------------------------------------------
  1246. X    pde_list_manager()
  1247. X--------------------------------------------------------------------------*/
  1248. Xvoid
  1249. Xpde_list_manager()
  1250. X{
  1251. Xregister uchar cmd = 0;
  1252. Xint rcvr_active = (rcvr_pid > 0) || (rcvr_pid == -2);
  1253. Xint done;
  1254. Xchar s80[80];
  1255. XWINDOW *window_create();
  1256. Xchar *find_procedure();
  1257. Xextern int proc_level;
  1258. X
  1259. X    if(rcvr_active && (rcvr_pid != -2))
  1260. X        kill_rcvr_process(SIGUSR1);
  1261. X
  1262. X    windows_start();
  1263. X    dirw = window_create("dialing directory",3,0,0,DIRW_LINES,DIRW_COLS);
  1264. X    dirw_display_top();
  1265. X
  1266. X    scrw = subwin(dirw,SCRW_LINES,SCRW_COLS,SCRW_TLY,SCRW_TLX);
  1267. X    scrollok(scrw,0);
  1268. X    if(!pde_list_quan)
  1269. X    {
  1270. X        if(pde_list_read())
  1271. X            dirw_bot_msg(errmsg);
  1272. X        else if(!pde_list_quan)
  1273. X            dirw_bot_msg("directory empty");
  1274. X    }
  1275. X
  1276. X    if(pde_list_quan)
  1277. X    {
  1278. X        if(curr_pde)
  1279. X            scrw_fill_at(scrw_curr_pde_line,curr_pde,&scrw_curr_pde_line);
  1280. X        else
  1281. X        {
  1282. X            curr_pde = pde_list_head;
  1283. X            scrw_fill(curr_pde,&scrw_curr_pde_line);
  1284. X        }
  1285. X    }
  1286. X
  1287. X    pde_list_set_dirty(-1);
  1288. X
  1289. X    done = 0;
  1290. X    while(!done)
  1291. X    {
  1292. X        cmd = dirw_get_cmd(
  1293. X#if defined(M_XENIX) || defined(M_UNIX)
  1294. X    "d,j:down u,k:up e:edit a:add r:remove s:save f:find END:dial ESC,q:quit");
  1295. X#else
  1296. X    "d,j:down u,k:up e:edit a:add r:remove s:save f:find ^D:dial  ESC,q:quit");
  1297. X#endif
  1298. X        if((cmd != 'o') && (remove_pde))
  1299. X        {
  1300. X            free((char *)remove_pde);
  1301. X            remove_pde = (PDE *)0;
  1302. X        }
  1303. X
  1304. X        switch(cmd)
  1305. X        {
  1306. X            case XFcurdn:
  1307. X            case 'd':
  1308. X            case 'j': pde_cmd_down(); break;
  1309. X
  1310. X            case XFcurup:
  1311. X            case 'u':
  1312. X            case 'k': pde_cmd_up(); break;
  1313. X
  1314. X            case 's': pde_cmd_save(); break;
  1315. X
  1316. X            case CR:
  1317. X            case NL:
  1318. X            case XFend:
  1319. X                cmd = XFend;
  1320. X                if(!check_curr_pde())
  1321. X                    break;
  1322. X                pde_list_save_if_dirty();
  1323. X                windows_end(dirw);
  1324. X
  1325. X/* dont do this here
  1326. X                redisplay_rcvr_screen();
  1327. X*/
  1328. X
  1329. X                done = 1;
  1330. X#ifdef AUTO_DIAL_PROC
  1331. X                if(!proc_level && find_procedure(curr_pde->logical))
  1332. X                {
  1333. X                char *pargv[2];
  1334. X                    pargv[0] = curr_pde->logical;
  1335. X                    pargv[1] = "!MENU";
  1336. X                    rcvr_pid = 0;
  1337. X                    do_proc(2,pargv);
  1338. X                    start_rcvr_process(1);
  1339. X                }
  1340. X                else
  1341. X                {
  1342. X                    if(rcvr_active)
  1343. X                        rcvr_pid = -2;    /* hayes_dial shud start rcvr */
  1344. X                    hayes_dial_pde(curr_pde);
  1345. X                }
  1346. X#else
  1347. X                if(rcvr_active)
  1348. X                    rcvr_pid = -2;    /* hayes_dial shud start rcvr */
  1349. X                hayes_dial_pde(curr_pde);
  1350. X#endif
  1351. X                break;
  1352. X
  1353. X            case ESC:
  1354. X            case CTL_C:
  1355. X                cmd = 'q';
  1356. X            case 'q':
  1357. X                done = 1;
  1358. X                continue;
  1359. X
  1360. X            case 'f': pde_cmd_find(); break;
  1361. X
  1362. X            case 'r': pde_cmd_remove(); break;
  1363. X            case 'o': pde_cmd_remove_oops(); break;
  1364. X
  1365. X            case 'a': pde_cmd_add((PDE *)0); break;
  1366. X
  1367. X            case 'e': pde_add_or_edit(curr_pde,1); break;
  1368. X
  1369. X#if defined(PDE_DEBUG)
  1370. X            case CTL_BSLASH:    /* undocumented ^\ */
  1371. X                pde_cmd_dump_list(); break;
  1372. X#endif
  1373. X
  1374. X            case CTL_L:
  1375. X            case CTL_R:
  1376. X                touchwin(stdscr);
  1377. X                wrefresh(stdscr);
  1378. X                touchwin(dirw);
  1379. X                wrefresh(dirw);
  1380. X                touchwin(scrw);
  1381. X                wrefresh(scrw);
  1382. X                break;
  1383. X
  1384. X            default:
  1385. X                sprintf(s80,"illegal command: %c",
  1386. X                    (isprint(cmd)) ? cmd : '?');
  1387. X                dirw_bot_msg(s80);
  1388. X                break;
  1389. X        }
  1390. X    }
  1391. X    if(cmd == XFend)
  1392. X        return;
  1393. X    pde_list_save_if_dirty();
  1394. X    windows_end(dirw);
  1395. X
  1396. X    redisplay_rcvr_screen();
  1397. X
  1398. X    if(rcvr_active)
  1399. X        start_rcvr_process(0);
  1400. X}    /* end of pde_list_manager */
  1401. X
  1402. X/*+-------------------------------------------------------------------------
  1403. X    choose_line(baud) - user is dialing a remote and will take 'Any' line
  1404. X--------------------------------------------------------------------------*/
  1405. Xvoid
  1406. Xchoose_line(baud)
  1407. Xuint baud;
  1408. X{
  1409. Xstruct dvent *dve;
  1410. Xchar s32[32];
  1411. X
  1412. X/* check out current line choice */
  1413. X    if(access(shm->Lline,6))
  1414. X        goto GET_LINE_THAT_MATCHES_BAUD;
  1415. X    dve = getdvline(shm->Lline + 8);
  1416. X    enddvent();
  1417. X    if(!dve)    /* if no match in Devices, let ecu fend for itself */
  1418. X        return;
  1419. X
  1420. X/* if shm->Lline is open and baud rate ok, no further */
  1421. X    if(shm->Liofd > 0)
  1422. X    {
  1423. X        if((dve->low_baud <= baud) && (baud <= dve->high_baud))
  1424. X            return;
  1425. X        lclose();    /* won't do ... gotta find a new one */
  1426. X        goto GET_LINE_THAT_MATCHES_BAUD;
  1427. X    }
  1428. X
  1429. X    if(!shm->Lline[0])
  1430. X        memset(shm->Lline,0,sizeof(shm->Lline));
  1431. X
  1432. X/* see if shm->Lline in use by someone else; if not and baud rate ok, no further */
  1433. X    switch(utmp_status(shm->Lline))
  1434. X    {
  1435. X        case US_NOTFOUND:    /* not in utmp, or getty dead */
  1436. X            if(line_locked(shm->Lline))
  1437. X                goto GET_LINE_THAT_MATCHES_BAUD;
  1438. X        case US_LOGIN:        /* enabled for login, idle */
  1439. X            if((dve->low_baud <= baud) && (baud <= dve->high_baud))
  1440. X                return;
  1441. X    }
  1442. X
  1443. X/* we've got to pick a new line */
  1444. XGET_LINE_THAT_MATCHES_BAUD:
  1445. X
  1446. X    strcpy(s32,"/dev/tty");
  1447. X    while(1)
  1448. X    {
  1449. X        if(!(dve = getdvbaud(baud)))
  1450. X        {
  1451. X            enddvent();        /* no match ... */
  1452. X            return;            /* ... so let current shm->Lline fail */
  1453. X        }
  1454. X/* by now, we know shm->Lline wont work */
  1455. X        if(!strcmp(dve->line,shm->Lline + 5))
  1456. X            continue;
  1457. X/* if not acu, dont use it */
  1458. X        if(ulindex(dve->type,"ACU") < 0)
  1459. X            continue;
  1460. X        strcpy(&s32[8],dve->line + 3);    /* yeech ... make "/dev/ttyxx" */
  1461. X        switch(utmp_status(s32))
  1462. X        {
  1463. X            case US_NOTFOUND:    /* not in utmp, or getty dead */
  1464. X                if(line_locked(s32))
  1465. X                    continue;
  1466. X            case US_LOGIN:        /* enabled for login, idle */
  1467. X                strcpy(shm->Lline,s32);    /* @@@@@@@@@@@ MATCH @@@@@@@@@ */
  1468. X                shm->Lline[9] = to_lower(shm->Lline[9]);
  1469. X                enddvent();    
  1470. X                return;
  1471. X        }
  1472. X    }
  1473. X    /*NOTREACHED*/
  1474. X
  1475. X}    /* end of choose_line */
  1476. X
  1477. X/*+-------------------------------------------------------------------------
  1478. X    copy_pde_to_lvar(tpde)
  1479. X
  1480. Xif changing line, close old line and open new one
  1481. X--------------------------------------------------------------------------*/
  1482. Xvoid
  1483. Xcopy_pde_to_lvar(tpde)
  1484. Xregister PDE *tpde;
  1485. X{
  1486. Xint reopen = 0;
  1487. Xint lerr;
  1488. X
  1489. X    if(tpde->tty[0])
  1490. X    {
  1491. X        if(shm->Lline[0] && shm->Lline[8] && strcmp(tpde->tty,shm->Lline + 8))
  1492. X        {
  1493. X            reopen = 1;
  1494. X            shm->Lmodem_already_init = 0;
  1495. X            lclose();
  1496. X        }
  1497. X        strcpy(shm->Lline,"/dev/tty");
  1498. X        strcat(shm->Lline,tpde->tty);
  1499. X    }
  1500. X    else
  1501. X        choose_line(tpde->baud);
  1502. X
  1503. X    if(shm->Liofd < 0)
  1504. X        reopen = 1;
  1505. X    strcpy(shm->Llogical,tpde->logical);
  1506. X    strcpy(shm->Ldescr,tpde->descr);
  1507. X    strcpy(shm->Ltelno,tpde->telno);
  1508. X    if(!shm->Ldescr[0])
  1509. X        strcpy(shm->Ldescr,shm->Llogical);
  1510. X    shm->Lparity = tpde->parity;
  1511. X    if(shm->Lbaud != tpde->baud)
  1512. X        shm->Lmodem_already_init = 0;
  1513. X    shm->Lbaud =tpde->baud;    
  1514. X    if(reopen)
  1515. X    {
  1516. X        if(lerr = lopen())
  1517. X        {
  1518. X            curbotleft();
  1519. X            if(lerr == LOPEN_LCKERR || lerr == LOPEN_UNKPID)
  1520. X                pputs("port not available\n");
  1521. X            pprintf("%s: %s\n",shm->Lline,lopen_err_text(lerr));
  1522. X            hangup(HANGUP_LINE_OPEN_ERROR);
  1523. X        }
  1524. X    }
  1525. X    else
  1526. X    {
  1527. X        lset_baud_rate(1);
  1528. X        lset_parity(1);
  1529. X    }
  1530. X
  1531. X}    /* end of copy_pde_to_lvar */
  1532. X
  1533. X/*+-----------------------------------------------------------------------
  1534. X    lookup_logical_telno()
  1535. X
  1536. XA logical telephone number is either a symbolic identifer
  1537. Xor an lcb->telno telephone number.  A symbolic identifer is a string
  1538. Xwhose initial character is a letter.
  1539. XAn lcb->telno telephone number begins with a numeral.
  1540. X
  1541. XThis function converts a logical telephone number 
  1542. Xto a telephone number (suitable for dialing by a Hayes or
  1543. Xcompatible modem).  It is called by command line processing
  1544. Xwhen 'ecu logical-name' is specified or in response to
  1545. Xa %dial logical-name.  It is not used by the curses directory
  1546. Xmanager.
  1547. X
  1548. XIf the first character of 'shm->Llogical' is a digit, the entire
  1549. Xinput string is copied to 'shm->Ltelno'.  If 'shm->Llogical' has a 
  1550. Xnon-numeric first character, then the user's home directory is
  1551. Xsearched for the file .ecu/phone (~/.ecu/phone). The file is a series
  1552. Xof records terminated with a newline.  Each record has two or three
  1553. Xfields separated by colons.  The first field is the logical telephone
  1554. Xnumber and the second field is the telephone number.  The third
  1555. X(optional) field contains a string to further identify the telephone
  1556. Xnumber being called.
  1557. X
  1558. XCASE IS INSIGNIFICANT in logical entry names for this procedure
  1559. X
  1560. XThe function returns one of the following:
  1561. X
  1562. X  1        if no error occurs
  1563. X  0        if not numeric phone number and logical string not found in file.
  1564. X
  1565. X------------------------------------------------------------------------*/
  1566. Xlookup_logical_telno()
  1567. X{
  1568. Xregister PDE *tpde;
  1569. X
  1570. X    if(!pde_list_quan)
  1571. X    {
  1572. X        if(pde_list_read())
  1573. X            return(0);
  1574. X    }
  1575. X
  1576. X/* if literal phone number, return it immediately */
  1577. X
  1578. X    if(isdigit(shm->Llogical[0]))
  1579. X    {
  1580. X        strcpy(shm->Ltelno,shm->Llogical);
  1581. X        strcpy(shm->Ldescr,shm->Llogical);
  1582. X        return(1);
  1583. X    }
  1584. X
  1585. X/* if logical phone number */
  1586. X    if(tpde = pde_list_search(shm->Llogical,0))    /* inexact search */
  1587. X    {
  1588. X        copy_pde_to_lvar(tpde);
  1589. X        return(1);
  1590. X    }
  1591. X
  1592. X    shm->Llogical[0] = 0;
  1593. X    shm->Lrname[0] = 0;
  1594. X    shm->Ltelno[0] = 0;
  1595. X    shm->Ldescr[0] = 0;
  1596. X    return(0);
  1597. X
  1598. X}    /* end of lookup_logical_telno */
  1599. X
  1600. X/* end of ecuphone.c */
  1601. X/* vi: set tabstop=4 shiftwidth=4: */
  1602. SHAR_EOF
  1603. $TOUCH -am 0507233390 ecuphone.c &&
  1604. chmod 0644 ecuphone.c ||
  1605. echo "restore of ecuphone.c failed"
  1606. set `wc -c ecuphone.c`;Wc_c=$1
  1607. if test "$Wc_c" != "36781"; then
  1608.     echo original size 36781, current size $Wc_c
  1609. fi
  1610. # ============= ecuphrase.c ==============
  1611. echo "x - extracting ecuphrase.c (Text)"
  1612. sed 's/^X//' << 'SHAR_EOF' > ecuphrase.c &&
  1613. X/* CHK=0x62B9 */
  1614. X/*+-----------------------------------------------------------------
  1615. X    ecuphrases.c
  1616. X    wht%n4hgf@gatech.edu
  1617. X
  1618. X  Defined functions:
  1619. X    phrase_help()
  1620. X    phrases(nargc,nargv)
  1621. X    read_phrases()
  1622. X
  1623. X------------------------------------------------------------------------*/
  1624. X/*+:EDITS:*/
  1625. X/*:05-07-1990-21:23-wht@n4hgf---- 2.80 --- */
  1626. X/*:03-25-1990-14:11-wht@n4hgf------ x2.70 ------- */
  1627. X/*:10-15-1989-17:23-wht-dont show empty phrase list */
  1628. X/*:07-03-1989-22:57-wht------ x2.00 ----- */
  1629. X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */
  1630. X
  1631. X#include "ecu.h"
  1632. X
  1633. X#define P_N_QUAN    23
  1634. Xchar *phrases_string[P_N_QUAN];
  1635. Xchar *phrases_label[P_N_QUAN];
  1636. Xint phrases_count = 0;
  1637. Xint phrases_resident = 0;
  1638. X
  1639. X/*+-----------------------------------------------------------------------
  1640. X    read_phrases()
  1641. X------------------------------------------------------------------------*/
  1642. Xvoid
  1643. Xread_phrases()
  1644. X{
  1645. Xregister char *phrases_str;
  1646. Xchar phrases_buf[256];
  1647. Xchar phrases_buf_copy[256];
  1648. Xchar *phrases_lbl;
  1649. XFILE *fd_phrase;
  1650. X
  1651. X    if(phrases_resident)
  1652. X    {
  1653. X        while(phrases_count)
  1654. X            free(phrases_string[--phrases_count]);
  1655. X        phrases_resident = 0;
  1656. X    }
  1657. X
  1658. X    get_home_dir(phrases_buf);
  1659. X    strcat(phrases_buf,"/.ecu/phrases");
  1660. X
  1661. X    if( (fd_phrase = fopen(phrases_buf,"r")) == NULL)
  1662. X    {
  1663. X        ff(se,"\r\n");
  1664. X        perror(phrases_buf);
  1665. X        ff(se,"\r\n");
  1666. X        ff(se,"... no phrases resident\r\n");
  1667. X        return;
  1668. X    }
  1669. X
  1670. X/* we have an open .ecu/phrase file */
  1671. X    phrases_count = 0;
  1672. X    while(fgets(phrases_buf,sizeof(phrases_buf),fd_phrase) != NULL)
  1673. X    {
  1674. X        phrases_buf[strlen(phrases_buf) - 1] = 0;
  1675. X        if(strlen(phrases_buf) == 0)
  1676. X            continue;
  1677. X
  1678. X        if(phrases_count == P_N_QUAN)
  1679. X        {
  1680. X            ff(se,"\r\nMaximum number of phrases %d exceeded\r\n",P_N_QUAN);
  1681. X            ff(se,"rest of file ignored, starting with the following:\r\n");
  1682. X            ff(se,"--> %s\r\n\r\n",phrases_buf);
  1683. X            phrases_resident = 1;
  1684. X            fclose(fd_phrase);
  1685. X            return;
  1686. X        }
  1687. X        strcpy(phrases_buf_copy,phrases_buf);
  1688. X        phrases_lbl = phrases_buf_copy;
  1689. X        for(phrases_str = phrases_buf_copy; *phrases_str; phrases_str++)
  1690. X        {
  1691. X            if(*phrases_str == ':')
  1692. X            {
  1693. X                *phrases_str++ = 0;
  1694. X                break;
  1695. X            }
  1696. X            if(*phrases_str == 0)
  1697. X            {
  1698. X                ff(se,"invalid entry `%s'\n",phrases_buf);
  1699. X                continue;
  1700. X            }
  1701. X        }
  1702. X
  1703. X        if(!(phrases_string[phrases_count] = malloc(strlen(phrases_str)+2)) ||
  1704. X           !(phrases_label[phrases_count] = malloc(strlen(phrases_lbl)+2)))
  1705. X        {
  1706. X            ff(se,"\r\nNo more memory for phrases\r\n");
  1707. X            ff(se,"rest of file ignored, starting with the following:\r\n");
  1708. X            ff(se,"--> %s\r\n\r\n",phrases_buf);
  1709. X            phrases_resident = 1;
  1710. X            fclose(fd_phrase);
  1711. X            if(phrases_string[phrases_count])
  1712. X                free(phrases_string[phrases_count]);
  1713. X            return;
  1714. X        }
  1715. X        strcpy(phrases_string[phrases_count],phrases_str);
  1716. X        strcpy(phrases_label[phrases_count],phrases_lbl);
  1717. X        phrases_count++;
  1718. X    }            /* while records left to read */
  1719. X
  1720. X    fclose(fd_phrase);
  1721. X    phrases_resident = 1;
  1722. X}    /* end of read_phrases */
  1723. X
  1724. X/*+-------------------------------------------------------------------------
  1725. X    phrases(nargc,nargv)
  1726. X--------------------------------------------------------------------------*/
  1727. Xphrases(nargc,nargv)
  1728. Xint nargc;
  1729. Xchar **nargv;
  1730. X{
  1731. Xregister itmp;
  1732. Xregister ichar;
  1733. Xregister char *cptr;
  1734. Xint old_ttymode = get_ttymode();
  1735. Xextern char *phrases_string[]; 
  1736. Xextern int phrases_count;
  1737. Xextern int phrases_resident;
  1738. Xextern int interrupt;
  1739. Xextern int icmd_prompt_len;
  1740. X
  1741. X    for(itmp = icmd_prompt_len + strlen(nargv[0]); itmp; itmp--)
  1742. X        fputs("\b \b",se);
  1743. X
  1744. X    itmp = atoi(nargv[0]);
  1745. X
  1746. X    if(itmp == 0)
  1747. X    {
  1748. X        ff(se,"\r\n");
  1749. X        read_phrases();
  1750. X        if(!phrases_count)
  1751. X            return(0);
  1752. X        stand_out();
  1753. X        ff(se,
  1754. X" # |  mnemonic    |     phrase                                              ");
  1755. X        stand_end();
  1756. X        ff(se,"\r\n");
  1757. X        for(itmp = 0; itmp < phrases_count; itmp++)
  1758. X            ff(se,"%2d | %12s |  %s\r\n",itmp + 1,phrases_label[itmp],
  1759. X                        phrases_string[itmp]);
  1760. X        return(0);
  1761. X    }
  1762. X    else
  1763. X        if(phrases_resident == 0)
  1764. X            read_phrases();
  1765. X
  1766. X    if(itmp > phrases_count)
  1767. X    {
  1768. X        ff(se,"  unknown: %d\r\n",itmp);
  1769. X        return(-1);
  1770. X    }
  1771. X    else
  1772. X    {
  1773. X        cptr = phrases_string[itmp - 1];
  1774. X        ttymode(2);
  1775. X        while(*cptr)
  1776. X        {
  1777. X            if(interrupt)
  1778. X                break;
  1779. X
  1780. X            switch(ichar = *cptr++)
  1781. X            {
  1782. X                case '^':
  1783. X                    ichar = *cptr++;
  1784. X                    if((ichar >= '@') && (ichar <= '_'))
  1785. X                        lputc_paced(0,ichar & 0x1F);
  1786. X                    else if(ichar == '?')
  1787. X                        lputc_paced(0,0x7F);
  1788. X                    else
  1789. X                    {
  1790. X                        switch(ichar)
  1791. X                        {
  1792. X                            case 0:
  1793. X                                goto NULL_FOUND;
  1794. X                            case 'r':
  1795. X                                lputc_paced(0,'\r');
  1796. X                                break;
  1797. X                            case 'n':
  1798. X                                lputc_paced(0,'\n');
  1799. X                                break;
  1800. X                            case 't':
  1801. X                                lputc_paced(0,'\t');
  1802. X                                break;
  1803. X                            case '^':
  1804. X                                lputc_paced(0,'^'); 
  1805. X                                break;
  1806. X                            case 'p': 
  1807. X                                itmp = atoi(cptr);
  1808. X                                while((*cptr >= '0') && (*cptr <= '9'))
  1809. X                                    cptr++;
  1810. X                                if(*cptr == '.')
  1811. X                                    cptr++;
  1812. X                                if(!itmp)
  1813. X                                    itmp = 1;
  1814. X                                nap((long)itmp * 100L);
  1815. X                                break;
  1816. X                            case 'a':
  1817. X                                itmp = atoi(cptr);
  1818. X                                while((*cptr >= '0') && (*cptr <= '9'))
  1819. X                                    cptr++;
  1820. X                                if(*cptr == '.')
  1821. X                                    cptr++;
  1822. X                                if(itmp < nargc)
  1823. X                                {
  1824. X                                    lputs_paced(0,nargv[itmp]);
  1825. X                                    itmp = strlen(nargv[itmp]);
  1826. X                                }
  1827. X                                break;
  1828. X                        }
  1829. X                    }
  1830. X                    break;
  1831. X                default:
  1832. X                    lputc_paced(0,ichar);
  1833. X            }
  1834. X        }
  1835. X
  1836. XNULL_FOUND:
  1837. X        if(interrupt)
  1838. X        {
  1839. X            interrupt = 0;
  1840. X            ff(se,"\r\n--> interrupted\r\n");
  1841. X        }
  1842. X
  1843. X    }
  1844. X
  1845. X    ttymode(old_ttymode);
  1846. X    return(0);
  1847. X
  1848. X}    /* end of phrases */
  1849. X
  1850. X
  1851. X/*+-------------------------------------------------------------------------
  1852. X    phrase_help()
  1853. X--------------------------------------------------------------------------*/
  1854. Xvoid
  1855. Xphrase_help()
  1856. X{
  1857. X    ff(se,"^r == \\r    ^n == \\n   ^t == \\t  ^^ == '^'\r\n");
  1858. X    ff(se,"^p#.  pause # secs\r\n");
  1859. X    ff(se,"^a#.  arg number # of %%# invocation\r\n");
  1860. X}    /* end of phrase_help */
  1861. X/* vi: set tabstop=4 shiftwidth=4: */
  1862. SHAR_EOF
  1863. $TOUCH -am 0507233390 ecuphrase.c &&
  1864. chmod 0644 ecuphrase.c ||
  1865. echo "restore of ecuphrase.c failed"
  1866. set `wc -c ecuphrase.c`;Wc_c=$1
  1867. if test "$Wc_c" != "5689"; then
  1868.     echo original size 5689, current size $Wc_c
  1869. fi
  1870. echo "End of part 5, continue with part 6"
  1871. exit 0
  1872.  
  1873.