home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / misc / 3937 < prev    next >
Encoding:
Text File  |  1992-09-13  |  57.1 KB  |  2,351 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  4. Subject:  v32i045:  ecu - ECU Asynchronous Communications v3.20, Part10/40
  5. Message-ID: <1992Sep13.153236.5127@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 3c97a0b3684e75e7059e730ca5fbb547
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v32i036=ecu.141245@sparky.IMD.Sterling.COM>
  11. Date: Sun, 13 Sep 1992 15:32:36 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 2336
  14.  
  15. Submitted-by: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  16. Posting-number: Volume 32, Issue 45
  17. Archive-name: ecu/part10
  18. Environment: SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses
  19. Supersedes: ecu: Volume 21, Issue 53-89
  20.  
  21. ---- Cut Here and feed the following to sh ----
  22. #!/bin/sh
  23. # this is ecu320.10 (part 10 of ecu320)
  24. # do not concatenate these parts, unpack them in order with /bin/sh
  25. # file ecupde.c continued
  26. #
  27. if test ! -r _shar_seq_.tmp; then
  28.     echo 'Please unpack part 1 first!'
  29.     exit 1
  30. fi
  31. (read Scheck
  32.  if test "$Scheck" != 10; then
  33.     echo Please unpack part "$Scheck" next!
  34.     exit 1
  35.  else
  36.     exit 0
  37.  fi
  38. ) < _shar_seq_.tmp || exit 1
  39. if test ! -f _shar_wnt_.tmp; then
  40.     echo 'x - still skipping ecupde.c'
  41. else
  42. echo 'x - continuing file ecupde.c'
  43. sed 's/^X//' << 'SHAR_EOF' >> 'ecupde.c' &&
  44. X    if(shm->Lbaud != tpde->baud)
  45. X        shm->Lmodem_already_init = 0;
  46. X    Ldial_debug_level = tpde->debug_level;
  47. X    /* tpde->dcdwatch is explicitly unused here; must defer until connect  */
  48. X
  49. X    if(!trial)
  50. X    {
  51. X        if(reopen)
  52. X        {
  53. X            if(lerr = lopen())
  54. X            {
  55. X                tcap_curbotleft();
  56. X                pprintf("%s: %s\n",shm->Lline,linst_err_text(lerr));
  57. X                termecu(TERMECU_LINE_OPEN_ERROR);
  58. X            }
  59. X        }
  60. X        else
  61. X        {
  62. X            lset_baud_rate(1);
  63. X            lset_parity(1);
  64. X        }
  65. X    }
  66. X    return(0);
  67. X
  68. X}    /* end of copy_pde_to_Lvariables */
  69. X
  70. X/*+-----------------------------------------------------------------------
  71. X    logical_telno_to_pde() - logical dial string to dialing info (PDE)
  72. X
  73. X    NOT USED BY THE CURSES DIRECTORY MANAGER
  74. X
  75. XA logical telephone number is one of:
  76. X1. null,
  77. X2. a symbolic identifer, or
  78. X3. an actual telephone number.  
  79. X
  80. XA symbolic identifer is a string whose initial character is a
  81. Xletter.  An actual telephone number begins with a numeral.
  82. X
  83. XThis function converts a logical telephone number to a dialing
  84. Xentry (PDE) from the directory or a constructed static one.  It
  85. Xis called by command line processing when 'ecu logical-name' is
  86. Xspecified or in response to a %dial logical-name.
  87. X
  88. XThe function returns one of the following:
  89. X
  90. X  directory or static PDE        if no error occurs
  91. X  (PDE *)0                        if not numeric phone number
  92. X                                and logical string not found in directory;
  93. X                                global char[] errmsg has been plugged with
  94. X                                error message
  95. X
  96. X------------------------------------------------------------------------*/
  97. XPDE *
  98. Xlogical_telno_to_pde(logical)
  99. Xchar *logical;
  100. X{
  101. X    static PDE literal_number_pde;
  102. X    register PDE *tpde = 0;
  103. X    extern int phdir_list_quan;
  104. X
  105. X#ifdef CHOOSE_DEBUG
  106. X    char s80[80];
  107. X    sprintf(s80,"logical_telno_to_pde(logical='%s')",logical);
  108. X    ecu_log_event((int)xmtr_pid,s80);
  109. X#endif
  110. X
  111. X/*
  112. X * if literal phone number, return homemade, static "PDE"
  113. X * with most stuff dummied up with the status quo
  114. X */
  115. X    if(isdigit(*logical))
  116. X    {
  117. X        tpde = &literal_number_pde;
  118. X        memset((char *)tpde,0,sizeof(PDE));
  119. X        tpde->baud = shm->Lbaud;
  120. X        tpde->parity = shm->Lparity;
  121. X        strncpy(tpde->logical,logical,DESTREF_LEN);
  122. X        tpde->logical[DESTREF_LEN] = 0;
  123. X        strncpy(tpde->telno,logical,DESTREF_LEN);
  124. X        tpde->telno[DESTREF_LEN] = 0;
  125. X        strncpy(tpde->tty,shm->Lline + 5,PDE_TTY_LEN);
  126. X        tpde->tty[PDE_TTY_LEN] = 0;
  127. X        if((strlen(logical) + 8) <= PDE_DESCR_LEN)
  128. X            sprintf(tpde->descr,"<telno %s>",logical);
  129. X        else
  130. X            strcpy(tpde->descr,"<telno>");
  131. X        tpde->dcdwatch = 'n';
  132. X        goto RETURN;
  133. X    }
  134. X
  135. X/*
  136. X * if empty phone number, return homemade, static "PDE"
  137. X * with most stuff dummied up with the status quo
  138. X */
  139. X    if(!*logical)
  140. X    {
  141. X        tpde = &literal_number_pde;
  142. X        memset((char *)tpde,0,sizeof(PDE));
  143. X        tpde->baud = shm->Lbaud;
  144. X        tpde->parity = shm->Lparity;
  145. X        strcpy(tpde->tty,shm->Lline + 5);
  146. X        if(!tpde->tty[0])
  147. X            strcpy(tpde->tty,default_tty + 5);
  148. X        strcpy(tpde->descr,"<direct connect>");
  149. X        tpde->dcdwatch = 'n';
  150. X        goto RETURN;
  151. X    }
  152. X
  153. X    /*
  154. X     * read directory if necessary
  155. X     */
  156. X    if(!phdir_list_quan)
  157. X    {
  158. X        if(phdir_list_read() && !phdir_list_quan)
  159. X        {    /* if still no good, ... */
  160. X            strcpy(errmsg,"phone directory empty");
  161. X            tpde = 0;
  162. X            goto RETURN;
  163. X        }
  164. X    }
  165. X
  166. X    /*
  167. X     * now, look up the entry
  168. X     */
  169. X    if(tpde = phdir_list_search(logical,0))
  170. X        goto RETURN;
  171. X
  172. X    /*
  173. X     * whoops ... not found
  174. X     */
  175. X    shm->Lrname[0] = 0;
  176. X    shm->Ltelno[0] = 0;
  177. X    shm->Ldescr[0] = 0;
  178. X    strcpy(errmsg,"entry not found in directory");
  179. X    tpde = 0;
  180. X
  181. XRETURN:
  182. X
  183. X#ifdef CHOOSE_DEBUG
  184. X    sprintf(s80,"logical_telno_to_pde %s%s",
  185. X        (tpde) ? "chosen tty=" : "no tty chosen",
  186. X        (tpde) ? tpde->tty : "");
  187. X    ecu_log_event((int)xmtr_pid,s80);
  188. X#endif
  189. X
  190. X    return(tpde);
  191. X
  192. X}    /* end of logical_telno_to_pde */
  193. X
  194. X/*+-------------------------------------------------------------------------
  195. X    call_logical_telno(logical) - call a logical or literal telephone number
  196. X
  197. X-1 if no such entry or pde_dial() status
  198. X--------------------------------------------------------------------------*/
  199. Xint
  200. Xcall_logical_telno(logical)
  201. Xchar *logical;
  202. X{
  203. X    int ret;
  204. X    PDE *tpde;
  205. X
  206. X    if(tpde = logical_telno_to_pde(logical))
  207. X        ret = pde_dial(tpde);
  208. X    else
  209. X    {
  210. X        pprintf("%s: %s\n",logical,errmsg);
  211. X        ret = eFATAL_ALREADY;
  212. X    }
  213. X
  214. X    return(ret);
  215. X
  216. X}    /* end of call_logical_telno */
  217. X
  218. X/* vi: set tabstop=4 shiftwidth=4: */
  219. X/* end of ecupde.c */
  220. SHAR_EOF
  221. echo 'File ecupde.c is complete' &&
  222. chmod 0644 ecupde.c ||
  223. echo 'restore of ecupde.c failed'
  224. Wc_c="`wc -c < 'ecupde.c'`"
  225. test 16547 -eq "$Wc_c" ||
  226.     echo 'ecupde.c: original size 16547, current size' "$Wc_c"
  227. rm -f _shar_wnt_.tmp
  228. fi
  229. # ============= ecupde.h ==============
  230. if test -f 'ecupde.h' -a X"$1" != X"-c"; then
  231.     echo 'x - skipping ecupde.h (File already exists)'
  232.     rm -f _shar_wnt_.tmp
  233. else
  234. > _shar_wnt_.tmp
  235. echo 'x - extracting ecupde.h (Text)'
  236. sed 's/^X//' << 'SHAR_EOF' > 'ecupde.h' &&
  237. X/*+-----------------------------------------------------------------------
  238. X    ecupde.h - phone directory entry definition
  239. X    wht@n4hgf.Mt-Park.GA.US
  240. X------------------------------------------------------------------------*/
  241. X/*+:EDITS:*/
  242. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  243. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  244. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  245. X/*:11-28-1991-14:56-wht@n4hgf-add dcdwatch */
  246. X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
  247. X/*:06-01-1991-23:53-wht@n4hgf-use PDE_..._LEN identifiers */
  248. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  249. X
  250. X#ifndef _ecupde_h
  251. X#define _ecupde_h
  252. X
  253. X#define PDE_TTY_LEN            15
  254. X#define PDE_DESCR_LEN        40
  255. X
  256. X#ifdef futures
  257. X#define PDE_FC_NONE            0    /* no FAS: none   FAS: RTS/CTS */
  258. X#define PDE_FC_XON_XOFF        1    /* XON/XOFF */
  259. X#define PDE_FC_RTS_CTS        2    /* no FAS: SCO RTS/CTS */
  260. X#endif
  261. X
  262. Xtypedef struct phone_directory_entry
  263. X{
  264. X    struct phone_directory_entry *next;
  265. X    struct phone_directory_entry *prev;
  266. X    uint baud;                
  267. X    short parity;                        /* 0,'e','o', maybe 'm','s' */
  268. X    ushort redial;                        /* if non-zero, marked for redial */
  269. X    char logical[DESTREF_LEN + 1];    /* logical name of remote */
  270. X    char telno[DESTREF_LEN + 1];        /* telno for remote or null */
  271. X    char tty[PDE_TTY_LEN + 1];            /* ttyname for access */
  272. X    char descr[PDE_DESCR_LEN + 1];        /* description of remote */
  273. X#ifdef futures
  274. X    uint zwindw_size;                    /* default ZMODEM window size */
  275. X    uchar flow_control;                    /* PDE_FC_... flow control */
  276. X#endif
  277. X    uchar debug_level;                    /* -x debug level for dialer */
  278. X    uchar dcdwatch;            /*
  279. X                             * how to set shm->Ldcdwatch on successful connect
  280. X                             * '0': off
  281. X                             * '1': on
  282. X                             * 't': terminate
  283. X                             * 'n': no change
  284. X                             */
  285. X}    PDE;
  286. X
  287. X#endif /* _ecupde_h */
  288. X
  289. X/* vi: set tabstop=4 shiftwidth=4: */
  290. X/* end of ecupde.h */
  291. SHAR_EOF
  292. chmod 0644 ecupde.h ||
  293. echo 'restore of ecupde.h failed'
  294. Wc_c="`wc -c < 'ecupde.h'`"
  295. test 1832 -eq "$Wc_c" ||
  296.     echo 'ecupde.h: original size 1832, current size' "$Wc_c"
  297. rm -f _shar_wnt_.tmp
  298. fi
  299. # ============= ecuphdir.c ==============
  300. if test -f 'ecuphdir.c' -a X"$1" != X"-c"; then
  301.     echo 'x - skipping ecuphdir.c (File already exists)'
  302.     rm -f _shar_wnt_.tmp
  303. else
  304. > _shar_wnt_.tmp
  305. echo 'x - extracting ecuphdir.c (Text)'
  306. sed 's/^X//' << 'SHAR_EOF' > 'ecuphdir.c' &&
  307. X/*+-------------------------------------------------------------------------
  308. X    ecuphone.c -- visual phone dialer/directory editor
  309. X    wht@n4hgf.Mt-Park.GA.US
  310. X
  311. X  .---[ title ]------------modified-.<-- dirw "top line"
  312. X  |   stand out mode                |<-- dirw "header line"
  313. X  |                                 |<-- scrw first line
  314. X  |                                 |
  315. X  |                                 |
  316. X  |                                 |
  317. X  |                                 |<-- scrw last line
  318. X  +---------------------------------+<-- dirw bottom separator line
  319. X  |                                 |<-- dirw extra cmd prompt line
  320. X  |   stand out mode                |<-- dirw "cmd line"
  321. X  `---------------------------------'<-- dirw bottom line
  322. X
  323. X  00000000001111111111222222222233333333334444444444555555555566
  324. X  01234567890123456789012345678901234567890123456789012345678901
  325. X 0.--[ entry nnnnn ]-------------------------------------------.
  326. X 1|                                                            |
  327. X 2| telephone number  ___________________                      |
  328. X 3| device            __________                               |
  329. X 4| baud rate         _____                                    |
  330. X 5| parity            _                                        |
  331. X 6| description       ________________________________________ |
  332. X 7| debug level       _  (dialer -x value 0-9)                 |
  333. X 8| DCD watch         _                                        |
  334. X 9|                                                            |
  335. X10| <prompt>                                                   |
  336. X11| <control key description>                                  |
  337. X12`------------------------------------------------------------'
  338. X
  339. X  Defined functions:
  340. X    check_curr_pde()
  341. X    dirw_bot_msg(msg)
  342. X    dirw_cmd_line_setup(prompt1,prompt2)
  343. X    dirw_display()
  344. X    dirw_display_config()
  345. X    dirw_display_phonedir_name()
  346. X    dirw_get_cmd()
  347. X    phdir_add_or_edit(tpde,edit)
  348. X    phdir_add_or_edit_read(prompt,edit,y,buf,bufmax,delim)
  349. X    phdir_cmd_add(tpde)
  350. X    phdir_cmd_change_dir()
  351. X    phdir_cmd_down()
  352. X    phdir_cmd_find()
  353. X    phdir_cmd_mark(tpde)
  354. X    phdir_cmd_remove()
  355. X    phdir_cmd_remove_oops()
  356. X    phdir_cmd_save()
  357. X    phdir_cmd_set_wait()
  358. X    phdir_cmd_unmark(tpde)
  359. X    phdir_cmd_unmark_all()
  360. X    phdir_cmd_up()
  361. X    phdir_dial_cycle()
  362. X    phdir_display(line,tpde,stand_out)
  363. X    phdir_display_logical(line,tpde,stand_out)
  364. X    phdir_list_add(tpde)
  365. X    phdir_list_erase()
  366. X    phdir_list_remove(tpde)
  367. X    phdir_list_save_if_dirty()
  368. X    phdir_list_search(logical,exact_flag)
  369. X    phdir_list_set_dirty(flag)
  370. X    phdir_manager()
  371. X    scrw_fill(tpde,curr_pde_line)
  372. X    scrw_fill_at(line_num,tpde,curr_pde_line)
  373. X    want_pd_create(name)
  374. X
  375. X--------------------------------------------------------------------------*/
  376. X/*+:EDITS:*/
  377. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  378. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  379. X/*:05-17-1992-18:29-wht@n4hgf-pde add now cycles thru fields til END */
  380. X/*:11-28-1991-14:32-wht@n4hgf-add dcdwatch option */
  381. X/*:11-20-1991-05:19-wht@n4hgf-improve "Any" line handling on add or edit */
  382. X/*:08-28-1991-15:15-wht@n4hgf2-fix bad structure in phdir_add_or_edit_read */
  383. X/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
  384. X/*:08-15-1991-18:13-wht@n4hgf-do not allow edit of non-existent entry */
  385. X/*:08-11-1991-19:56-wht@n4hgf-soup up tty name for ISC vs. SCO */
  386. X/*:08-07-1991-13:48-root@n4hgf-w subcommand was not asking both questions */
  387. X/*:08-01-1991-03:52-wht@n4hgf-when editing string, set cursor to end */
  388. X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
  389. X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
  390. X/*:07-12-1991-15:37-wht@n4hgf-fix core dump when creating phone from setup */
  391. X/*:06-09-1991-16:54-jjb-want_pd_create sneak path when not in curses */
  392. X/*:06-02-1991-19:43-wht@n4hgf-add dial debug level */
  393. X/*:06-02-1991-17:29-wht@n4hgf-move hdb_choose_Any to hdbintf.c */
  394. X/*:06-01-1991-23:53-wht@n4hgf-use PDE_..._LEN identifiers */
  395. X/*:04-03-1991-14:47-wht@n4hgf-must refresh both windows in terminfo curses */
  396. X/*:03-18-1991-21:39-wht@n4hgf-add wrefresh of scrw in up/down */
  397. X/*:02-05-1991-14:51-wht@n4hgf-calloc PDE instead of malloc */
  398. X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
  399. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  400. X
  401. X#include "ecucurses.h"
  402. X
  403. X#define STDIO_H_INCLUDED
  404. X#define OMIT_TERMIO_REFERENCES
  405. X#include "ecu.h"
  406. X#include "pc_scr.h"
  407. X
  408. X#include "ecupde.h"
  409. X#include "ecukey.h"
  410. X#include "ecuxkey.h"
  411. X#include "esd.h"
  412. X#include "var.h"
  413. X
  414. Xchar *find_procedure();
  415. Xchar *make_char_graphic();
  416. Xchar *linst_err_text();
  417. XWINDOW *window_create();
  418. X
  419. Xvoid dirw_bot_msg();
  420. Xvoid dirw_display_phonedir_name();
  421. Xvoid dirw_cmd_line_setup();
  422. X
  423. X/* window definitions */
  424. X#define DIRW_LINES        (LINES - 1)
  425. X#define DIRW_COLS        (80)
  426. X#define DIRW_TOP_LINES    2
  427. X#define DIRW_BOT_LINES    4
  428. X#define DIRW_CMD_LINE    (DIRW_LINES - 2)
  429. X#define SCRW_LINES        (DIRW_LINES - DIRW_TOP_LINES - DIRW_BOT_LINES)
  430. X#define SCRW_COLS        (DIRW_COLS)
  431. X#define SCRW_TLY        (DIRW_TOP_LINES)
  432. X#define SCRW_TLX        0
  433. X#define PDE_ITEM_COUNT    (7)
  434. X#define ADDW_LINES        (PDE_ITEM_COUNT + 6)
  435. X#define ADDW_COLS        (62)
  436. X#define ADDW_TLY        (SCRW_TLY + 1)
  437. X#define ADDW_TLX        (4)
  438. X
  439. Xextern int errno;
  440. X
  441. Xextern int windows_active;
  442. Xextern char errmsg[];
  443. Xextern char kbdintr;
  444. Xextern char phonedir_name[];        /* phone directory name */
  445. Xextern char *phonedir_trigger;
  446. X
  447. XWINDOW *dirw = (WINDOW *)0;
  448. XWINDOW *scrw = (WINDOW *)0;
  449. XWINDOW *addw = (WINDOW *)0;
  450. X
  451. XPDE *phdir_list_head = (PDE *)0;    /* pointer to first pde in linked list */
  452. XPDE *curr_pde = (PDE *)0;        /* current pde */
  453. XPDE *remove_pde = (PDE *)0;        /* if non-zero, pde just removed */
  454. Xint remove_dirty_flag;            /* phdir_list_dirty at remove time */
  455. Xint phdir_list_quan = 0;            /* count of items in list now */
  456. Xint phdir_list_dirty = 0;            /* phdir_list modified but not saved */
  457. Xint pde_marked_for_redial_count = 0;
  458. Xint scrw_curr_pde_line;            /* scrw line curr_pde is on */
  459. Xint phonedir_name_x;            /* position for phonedir name on screen */
  460. X
  461. X
  462. X#define NAP_DECISEC_SINGLE_MIN         10
  463. X#define NAP_DECISEC_MULTIPLE_MIN       10
  464. Xint nap_decisec_single   = 150;
  465. Xint nap_decisec_multiple = 50;
  466. X
  467. X/*+-------------------------------------------------------------------------
  468. X    phdir_list_erase()
  469. X--------------------------------------------------------------------------*/
  470. Xvoid
  471. Xphdir_list_erase()
  472. X{
  473. X    register PDE *pde = phdir_list_head;
  474. X    register PDE *next;
  475. X
  476. X    while(pde)
  477. X    {
  478. X        next = pde->next;
  479. X        free((char *)pde);
  480. X        pde = next;
  481. X    }
  482. X    phdir_list_head = (PDE *)0;
  483. X    phdir_list_quan = 0;
  484. X    curr_pde = (PDE *)0;
  485. X    remove_pde = (PDE *)0;
  486. X    pde_marked_for_redial_count = 0;
  487. X
  488. X}    /* end of phdir_list_erase */
  489. X
  490. X/*+-------------------------------------------------------------------------
  491. X    phdir_list_set_dirty(flag)
  492. X0: clean, 1 dirty, -1 do not modify;update screen only
  493. X--------------------------------------------------------------------------*/
  494. Xvoid
  495. Xphdir_list_set_dirty(flag)
  496. Xint flag;
  497. X{
  498. X    register itmp;
  499. X    if(flag != phdir_list_dirty)
  500. X    {
  501. X        if(flag != -1)
  502. X            phdir_list_dirty = flag;
  503. X        wmove(dirw,0,DIRW_COLS - 14);
  504. X        if(phdir_list_dirty)
  505. X            waddstr(dirw," modified ");
  506. X        else
  507. X        {
  508. X            itmp = 10;
  509. X#if defined(SVR4)
  510. X            whline(dirw, (unsigned long)(sHR & 0x00ff), itmp);
  511. X#else
  512. X            while(itmp--)
  513. X                waddch(dirw,(unsigned)sHR);
  514. X#endif
  515. X        }
  516. X        wrefresh(dirw);
  517. X    }
  518. X}    /* end of phdir_list_set_dirty */
  519. X
  520. X/*+-------------------------------------------------------------------------
  521. X    phdir_list_add(tpde) -- add to linked list
  522. X--------------------------------------------------------------------------*/
  523. Xvoid
  524. Xphdir_list_add(tpde)
  525. XPDE *tpde;
  526. X{
  527. X    register PDE *this = tpde;
  528. X    register PDE *prev;
  529. X    register PDE *next;
  530. X
  531. X/* if empty, init list with this one and quit */
  532. X    if(phdir_list_head == (PDE *)0)
  533. X    {
  534. X        phdir_list_head = this;
  535. X        this->prev = (PDE *)0;
  536. X        this->next = (PDE *)0;
  537. X        phdir_list_quan++;
  538. X        return;
  539. X    }
  540. X
  541. X/* list not empty */
  542. X    prev = (PDE *)0;        /* no previous yet */
  543. X    next = phdir_list_head;    /* init next to top of list */
  544. X
  545. X    while(strcmp(next->logical,this->logical) < 0)
  546. X    {
  547. X        prev = next;
  548. X        next = prev->next;
  549. X        if(next == (PDE *)0)
  550. X            break;
  551. X    }
  552. X
  553. X    if(prev)        /* if non-zero, we will not update the list head */
  554. X    {
  555. X        this->next = prev->next;
  556. X        this->prev = prev;
  557. X        prev->next = this;
  558. X        if(next)
  559. X            next->prev = this;
  560. X    }
  561. X    else    /* 'this' is to become the new list head (1st element) */
  562. X    {
  563. X        this->next = next;
  564. X        this->prev = (PDE *)0;
  565. X        if(next)
  566. X            next->prev = this;
  567. X        phdir_list_head = this;
  568. X    }
  569. X    phdir_list_quan++;
  570. X
  571. X}    /* end of pde_add */
  572. X
  573. X/*+-------------------------------------------------------------------------
  574. X    phdir_list_remove(tpde) -- remove from linked list
  575. X--------------------------------------------------------------------------*/
  576. Xvoid
  577. Xphdir_list_remove(tpde)
  578. Xregister PDE *tpde;
  579. X{
  580. X    register PDE *prev;
  581. X    register PDE *next;
  582. X
  583. X    prev = (PDE *)0;    /* there is no previous now */
  584. X
  585. X    if((next = phdir_list_head) == (PDE *)0)    /* if empty list */
  586. X        return;
  587. X
  588. X    while(next != tpde)
  589. X    {
  590. X        prev = next;
  591. X        next = prev->next;
  592. X        if(next == (PDE *)0)
  593. X            return;
  594. X    }
  595. X
  596. X/* take care of "current pde" */
  597. X    if(tpde == curr_pde)
  598. X    {
  599. X        if(tpde->next)
  600. X            curr_pde = tpde->next;
  601. X        else if(tpde->prev)
  602. X            curr_pde = tpde->prev;
  603. X        else
  604. X            curr_pde = (PDE *)0;
  605. X    }
  606. X
  607. X/* marked? */
  608. X    if(tpde->redial)
  609. X    {
  610. X        tpde->redial = 0;
  611. X        pde_marked_for_redial_count--;
  612. X    }
  613. X
  614. X/* unlink */
  615. X
  616. X    if(prev)        /* if non-zero, we will not update the list head */
  617. X    {
  618. X        prev->next = tpde->next;
  619. X        if(tpde->next)
  620. X            (tpde->next)->prev = prev;
  621. X    }
  622. X    else
  623. X    {
  624. X        phdir_list_head = tpde->next;
  625. X        if(tpde->next)
  626. X            (tpde->next)->prev = (PDE *)0;
  627. X    }
  628. X
  629. X    tpde->next = (PDE *)0;
  630. X    tpde->prev = (PDE *)0;
  631. X
  632. X    phdir_list_quan--;
  633. X}    /* end of phdir_list_remove */
  634. X
  635. X/*+-----------------------------------------------------------------------
  636. X    PDE *phdir_list_search(logical,exact_flag)
  637. X------------------------------------------------------------------------*/
  638. XPDE *
  639. Xphdir_list_search(logical,exact_flag)
  640. Xchar *logical;
  641. Xint exact_flag;
  642. X{
  643. X    register PDE *tpde;
  644. X
  645. X    if(!phdir_list_quan)
  646. X    {
  647. X        if(phdir_list_read())
  648. X            return((PDE *)0);
  649. X    }
  650. X
  651. X    if(!logical || !*logical)
  652. X        return((PDE *)0);
  653. X
  654. X    tpde = phdir_list_head;
  655. X    while(tpde)
  656. X    {
  657. X        /* only first few chars necessary for match with ulcmpb */
  658. X        if(exact_flag)
  659. X        {
  660. X            if(strcmp(tpde->logical,logical) == 0)
  661. X                return(tpde);
  662. X        }
  663. X        else
  664. X        {
  665. X            if(ulcmpb(tpde->logical,logical) < 0)
  666. X                return(tpde);
  667. X        }
  668. X        tpde = tpde->next;
  669. X    }
  670. X    if(!tpde)
  671. X        sprintf(errmsg,"'%s' not found",logical);
  672. X    return(tpde);
  673. X
  674. X}    /* end of phdir_list_search */
  675. X
  676. X/*+-------------------------------------------------------------------------
  677. X    want_pd_create(name)
  678. X--------------------------------------------------------------------------*/
  679. Xint
  680. Xwant_pd_create(name)
  681. Xchar *name;
  682. X{
  683. X    uchar uctmp = 255;
  684. X
  685. X    if(!dirw)
  686. X        return(1);
  687. X
  688. X#ifdef COMPILER_BUG_FIXED
  689. X    dirw_bot_msg("type 'y' or 'n'");
  690. X    while(uctmp == 255)
  691. X    {
  692. X        ring_bell();
  693. X        dirw_cmd_line_setup(name,"does not exist: create?");
  694. X        uctmp = ttygetc(0);
  695. X        if(isupper(uctmp))
  696. X            uctmp = tolower(uctmp);
  697. X        switch(uctmp)
  698. X        {
  699. X            case 'y': uctmp = 1; break;
  700. X            case 'n': uctmp = 0; break;
  701. X            default: uctmp = 255; break;        
  702. X        }
  703. X    }
  704. X    dirw_bot_msg("");
  705. X    return((int)uctmp);
  706. X
  707. X#else
  708. X
  709. XKROCK:
  710. X    dirw_bot_msg("type 'y' or 'n'");
  711. X    ring_bell();
  712. X    dirw_cmd_line_setup(name,"does not exist: create?");
  713. X    uctmp = ttygetc(0);
  714. X    dirw_bot_msg("");
  715. X    if(isupper(uctmp))
  716. X        uctmp = tolower(uctmp);
  717. X    switch(uctmp)
  718. X    {
  719. X        case 'y': return(1);
  720. X        case 'n': return(0);
  721. X    }
  722. X    goto KROCK;
  723. X#endif
  724. X}    /* end of want_pd_create */
  725. X
  726. X/*+-------------------------------------------------------------------------
  727. X    dirw_display_phonedir_name()
  728. X--------------------------------------------------------------------------*/
  729. Xvoid
  730. Xdirw_display_phonedir_name()
  731. X{
  732. X    register itmp,x;
  733. X    char s80[80];
  734. X
  735. X    if(!dirw || !phonedir_name[0])
  736. X        return;
  737. X
  738. X    wmove(dirw,0,phonedir_name_x);
  739. X    waddch(dirw,' ');
  740. X    strncpy(s80,phonedir_name,itmp = DIRW_COLS - phonedir_name_x - 5);
  741. X    s80[itmp] = 0;
  742. X    waddstr(dirw,s80);
  743. X    waddch(dirw,' ');
  744. X    getyx(dirw,itmp,x);
  745. X
  746. X#if defined(SVR4)
  747. X    whline(dirw, (unsigned long)(sHR & 0x00ff), DIRW_COLS - 1 - x);
  748. X#else
  749. X    while(x < DIRW_COLS - 1)
  750. X    {
  751. X        waddch(dirw,sHR);
  752. X        x++;
  753. X    }
  754. X#endif
  755. X}    /* end of dirw_display_phonedir_name */
  756. X
  757. X/*+-------------------------------------------------------------------------
  758. X    dirw_display_config()
  759. X--------------------------------------------------------------------------*/
  760. Xvoid
  761. Xdirw_display_config()
  762. X{
  763. X    register y,x;
  764. X
  765. X    if(!dirw)
  766. X        return;
  767. X
  768. X#if defined(SVR4)
  769. X    wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,1);
  770. X    whline(dirw, (unsigned long)(sHR & 0x00ff), DIRW_COLS - 2);
  771. X#else
  772. X    wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,0);
  773. X    waddch(dirw,sLT);
  774. X    getyx(dirw,y,x);
  775. X    while(x++ < (DIRW_COLS - 1))
  776. X        waddch(dirw,sHR);
  777. X    waddch(dirw,sRT);
  778. X#endif
  779. X
  780. X    if(pde_marked_for_redial_count)
  781. X    {
  782. X        wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,2);
  783. X        wstandout(dirw);
  784. X        wprintw(dirw," REDIAL CYCLE  wait: single=%d multiple=%d ",
  785. X            nap_decisec_single / 10,nap_decisec_multiple / 10);
  786. X
  787. X        wmove(dirw,DIRW_LINES - DIRW_BOT_LINES,56);
  788. X        wprintw(dirw," %2d marked entr%s ",
  789. X            pde_marked_for_redial_count,
  790. X            (pde_marked_for_redial_count == 1) ? "y" : "ies");
  791. X        wstandend(dirw);
  792. X    }
  793. X}    /* end of dirw_display_config */
  794. X
  795. X/*+-----------------------------------------------------------------------
  796. X    dirw_display()
  797. X00000000001111111111222222222233333333334444444444555555555566666666667777777777
  798. X01234567890123456789012345678901234567890123456789012345678901234567890123456789
  799. X| entry name | telephone number | tty | baud P | description                   |
  800. X| 0123456789 | 0123456789012345 | 01  | baud P | 01234567890123456789012345678 |
  801. X------------------------------------------------------------------------*/
  802. Xvoid
  803. Xdirw_display()
  804. X{
  805. X    if(!dirw)
  806. X        return;
  807. X    wmove(dirw,1,1);
  808. X    wstandout(dirw);
  809. X
  810. X#if defined(SVR4)
  811. X    waddstr(dirw,
  812. X" entry name | telephone number | tty | baud P | description                   "
  813. X        );
  814. X#else
  815. X    waddstr(dirw," entry name ");
  816. X    waddch(dirw,(unsigned)sVR);
  817. X    waddstr(dirw," telephone number ");
  818. X    waddch(dirw,(unsigned)sVR);
  819. X    waddstr(dirw," tty ");
  820. X    waddch(dirw,(unsigned)sVR);
  821. X    waddstr(dirw," baud P ");
  822. X    waddch(dirw,(unsigned)sVR);
  823. X    waddstr(dirw," description                   ");
  824. X#endif
  825. X
  826. X    wstandend(dirw);
  827. X    dirw_display_phonedir_name();
  828. X    dirw_display_config();
  829. X#if 0
  830. X    touchwin(stdscr);
  831. X    wrefresh(stdscr);
  832. X#endif
  833. X    wrefresh(dirw);
  834. X
  835. X}    /* end of dirw_display */
  836. X
  837. X/*+-------------------------------------------------------------------------
  838. X    dirw_bot_msg(msg)
  839. X--------------------------------------------------------------------------*/
  840. Xvoid
  841. Xdirw_bot_msg(msg)
  842. Xchar *msg;
  843. X{
  844. X    register itmp;
  845. X    register itmp2;
  846. X    static last_msglen = 0;
  847. X#define DIRW_BOT_LINE_TLX 2
  848. X#define DIRW_BOT_LINE_MAX_MSGLEN    (DIRW_COLS - DIRW_BOT_LINE_TLX - 8)
  849. X    char msg2[80];
  850. X
  851. X    if(!dirw || (!last_msglen && !strlen(msg)))
  852. X        return;
  853. X
  854. X    wmove(dirw,DIRW_LINES - 1,DIRW_BOT_LINE_TLX);
  855. X
  856. X    if((itmp = strlen(msg)) == 0)
  857. X    {
  858. X        itmp2 = last_msglen + 2;
  859. X
  860. X#if defined(SVR4)
  861. X        whline(dirw, (unsigned long)(sHR & 0x00ff), itmp2);
  862. X#else
  863. X        for(itmp = 0; itmp < itmp2; itmp++)
  864. X            waddch(dirw,(unsigned)sHR);
  865. X#endif
  866. X
  867. X        last_msglen = 0;
  868. X    }
  869. X    else
  870. X    {
  871. X        waddch(dirw,' ');
  872. X        if(itmp > DIRW_BOT_LINE_MAX_MSGLEN)
  873. X        {
  874. X            strncpy(msg2,msg,DIRW_BOT_LINE_MAX_MSGLEN);
  875. X            msg2[DIRW_BOT_LINE_MAX_MSGLEN + 1] = 0;
  876. X            waddstr(dirw,msg2);
  877. X            itmp = strlen(msg2);
  878. X        }
  879. X        else
  880. X        {
  881. X            waddstr(dirw,msg);
  882. X            itmp = strlen(msg);
  883. X        }
  884. X        waddch(dirw,' ');
  885. X        if((itmp2 = last_msglen - itmp) > 0)
  886. X        {
  887. X#if defined(SVR4)
  888. X            whline(dirw, (unsigned long)(sHR & 0x00ff), itmp2);
  889. X#else
  890. X            while(itmp2--)
  891. X                waddch(dirw,(unsigned)sHR);
  892. X#endif
  893. X        }
  894. X        last_msglen = itmp;        /* remember last message length */
  895. X    }
  896. X    wrefresh(dirw);
  897. X}    /* end of dirw_bot_msg */
  898. X
  899. X/*+-------------------------------------------------------------------------
  900. X    phdir_display_logical(line,tpde,stand_out)
  901. X--------------------------------------------------------------------------*/
  902. Xvoid
  903. Xphdir_display_logical(line,tpde,stand_out)
  904. Xint line;
  905. XPDE *tpde;
  906. Xint stand_out;
  907. X{
  908. X
  909. X    wmove(scrw,line,0);
  910. X#if defined(SVR4)
  911. X    wvline(scrw, (unsigned long)(sVR & 0x00ff), 1);
  912. X    wmove(scrw,line,1);
  913. X#else
  914. X    waddch(scrw,(unsigned)sVR);
  915. X#endif
  916. X
  917. X    if(tpde->redial)
  918. X    {
  919. X        wstandout(scrw);
  920. X        waddch(scrw,'>');
  921. X        wstandend(scrw);
  922. X    }
  923. X    else
  924. X        waddch(scrw,' ');
  925. X
  926. X    if(stand_out)
  927. X        wstandout(scrw);
  928. X    wprintw(scrw,"%-10.10s",tpde->logical);
  929. X    if(stand_out)
  930. X        wstandend(scrw);
  931. X
  932. X}    /* end of phdir_display_logical */
  933. X
  934. X/*+-----------------------------------------------------------------------
  935. X    phdir_display(win,line,tpde,stand_out)
  936. X00000000001111111111222222222233333333334444444444555555555566666666667777777777
  937. X01234567890123456789012345678901234567890123456789012345678901234567890123456789
  938. X| entry name | telephone number | tty | baud P | description                   |
  939. X| 0123456789 | 0123456789012345 | 01  | baud P | 01234567890123456789012345678 |
  940. X--------------------------------------------------------------------------*/
  941. Xphdir_display(line,tpde,stand_out)
  942. Xint line;
  943. XPDE *tpde;
  944. Xint stand_out;
  945. X{
  946. X
  947. X    phdir_display_logical(line,tpde,stand_out);
  948. X    waddch(scrw,' ');
  949. X#if defined(SVR4)
  950. X    wmove(scrw, line, 13);
  951. X    waddch(scrw,'|');
  952. X#else
  953. X    waddch(scrw,(unsigned)sVR);
  954. X#endif
  955. X    waddch(scrw,' ');
  956. X#if defined(SVR4)
  957. X    wprintw(scrw,"%-16.16s |",tpde->telno);
  958. X    if(tpde->tty[0])
  959. X        wprintw(scrw,"%-5.5s|",tpde->tty);
  960. X    else
  961. X        waddstr(scrw,"Any  |");
  962. X    wprintw(scrw,"%5u %c | ",tpde->baud,
  963. X        (tpde->parity) ? to_upper(tpde->parity) : 'N');
  964. X    wprintw(scrw,"%-29.29s",tpde->descr);
  965. X#else
  966. X    wprintw(scrw,"%-16.16s ",tpde->telno);
  967. X    waddch(scrw,(unsigned)sVR);
  968. X    if(tpde->tty[0])
  969. X        wprintw(scrw,"%-5.5s",tpde->tty);
  970. X    else
  971. X        waddstr(scrw,"Any  ");
  972. X    waddch(scrw,(unsigned)sVR);
  973. X    wprintw(scrw,"%5u %c ",tpde->baud,
  974. X        (tpde->parity) ? to_upper(tpde->parity) : 'N');
  975. X    waddch(scrw,(unsigned)sVR);
  976. X    wprintw(scrw," %-29.29s ",tpde->descr);
  977. X    waddch(scrw,(unsigned)sVR);
  978. X#endif
  979. X    return(0);
  980. X
  981. X}    /* end of phdir_display */
  982. X
  983. X/*+-----------------------------------------------------------------------
  984. X    scrw_fill(first_pde,curr_pde_line)
  985. X------------------------------------------------------------------------*/
  986. Xvoid
  987. Xscrw_fill(tpde,curr_pde_line)
  988. Xregister PDE *tpde;
  989. Xint *curr_pde_line;
  990. X{
  991. X    register line;
  992. X    register is_curr_pde;
  993. X
  994. X    *curr_pde_line = -1;
  995. X    for(line = 0; line < SCRW_LINES; line++)
  996. X    {
  997. X        if(tpde)
  998. X        {
  999. X            if(is_curr_pde = (tpde == curr_pde))
  1000. X                *curr_pde_line = line;
  1001. X            phdir_display(line,tpde,is_curr_pde);
  1002. X            tpde = tpde->next;
  1003. X        }
  1004. X        else
  1005. X        {
  1006. X            wmove(scrw,line,0);
  1007. X#if defined(SVR4)
  1008. X            wvline(scrw, (unsigned long)(sVR & 0x00ff), 1);
  1009. X            wmove(scrw,line,1);
  1010. X#else
  1011. X            waddch(scrw,(unsigned)sVR);
  1012. X#endif
  1013. X            wclrtoeol(scrw);
  1014. X            wmove(scrw,line,SCRW_COLS - 1);
  1015. X#if defined(SVR4)
  1016. X            wvline(scrw, (unsigned long)(sVR & 0x00ff), 1);
  1017. X#else
  1018. X            waddch(scrw,(unsigned)sVR);
  1019. X#endif
  1020. X        }
  1021. X    }
  1022. X    wrefresh(scrw);
  1023. X
  1024. X}    /* end of scrw_fill */
  1025. X
  1026. X/*+-------------------------------------------------------------------------
  1027. X    scrw_fill_at(line_num,first_pde,curr_pde_line)
  1028. X--------------------------------------------------------------------------*/
  1029. Xvoid
  1030. Xscrw_fill_at(line_num,tpde,curr_pde_line)
  1031. Xint line_num;
  1032. Xregister PDE *tpde;
  1033. Xint *curr_pde_line;
  1034. X{
  1035. X    register itmp;
  1036. X
  1037. X    if(!tpde)
  1038. X    {
  1039. X        scrw_fill(tpde,curr_pde_line);
  1040. X        return;
  1041. X    }
  1042. X    for(itmp = 0; itmp < line_num; itmp++)
  1043. X    {
  1044. X        if(!tpde->prev)
  1045. X            break;
  1046. X        tpde = tpde->prev;
  1047. X    }
  1048. X
  1049. X    scrw_fill(tpde,curr_pde_line);
  1050. X
  1051. X}    /* end of scrw_fill_at */
  1052. X
  1053. X/*+-------------------------------------------------------------------------
  1054. X    dirw_cmd_line_setup(prompt1,prompt2)
  1055. X--------------------------------------------------------------------------*/
  1056. Xvoid
  1057. Xdirw_cmd_line_setup(prompt1,prompt2)
  1058. Xchar *prompt1;
  1059. Xchar *prompt2;
  1060. X{
  1061. X    register icol;
  1062. X    int y;
  1063. X    int x;
  1064. X    char *cptr;
  1065. X    int standout_mode;
  1066. X
  1067. X    wmove(dirw,DIRW_CMD_LINE - 1,1);
  1068. X    wstandend(dirw);
  1069. X    standout_mode = 0;
  1070. X    waddch(dirw,' ');
  1071. X    cptr = prompt1;
  1072. X    while(*cptr)
  1073. X    {
  1074. X        if(*cptr == '~')
  1075. X        {
  1076. X            if(standout_mode)
  1077. X                wstandend(dirw);
  1078. X            else
  1079. X                wstandout(dirw);
  1080. X            standout_mode = !standout_mode;
  1081. X            cptr++;
  1082. X        }
  1083. X        else
  1084. X            waddch(dirw,*cptr++);
  1085. X    }
  1086. X    wstandend(dirw);
  1087. X    standout_mode = 0;
  1088. X
  1089. X    waddch(dirw,' ');
  1090. X    getyx(dirw,y,x);
  1091. X    for(icol = x; icol < DIRW_COLS - 1; icol++)
  1092. X        waddch(dirw,' ');
  1093. X
  1094. X    wmove(dirw,DIRW_CMD_LINE,1);
  1095. X    waddch(dirw,' ');
  1096. X    cptr = prompt2;
  1097. X    while(*cptr)
  1098. X    {
  1099. X        if(*cptr == '~')
  1100. X        {
  1101. X            if(standout_mode)
  1102. X                wstandend(dirw);
  1103. X            else
  1104. X                wstandout(dirw);
  1105. X            standout_mode = !standout_mode;
  1106. X            cptr++;
  1107. X        }
  1108. X        else
  1109. X            waddch(dirw,*cptr++);
  1110. X    }
  1111. X    wstandend(dirw);
  1112. X    waddch(dirw,' ');
  1113. X    getyx(dirw,y,x);
  1114. X    for(icol = x; icol < DIRW_COLS - 1; icol++)
  1115. X        waddch(dirw,' ');
  1116. X    wmove(dirw,y,x);
  1117. X    wrefresh(scrw);
  1118. X    wrefresh(dirw);
  1119. X}    /* end of dirw_cmd_line_setup */
  1120. X
  1121. X/*+-------------------------------------------------------------------------
  1122. X    dirw_get_cmd()
  1123. X--------------------------------------------------------------------------*/
  1124. Xuchar
  1125. Xdirw_get_cmd()
  1126. X{
  1127. X    register uchar cmd;
  1128. X    char setupline1[128];    /* yetch ... avoid source line > 80 chars */
  1129. X    char *setupline1_1 = "~d~own ~u~p ~e~dit ~a~dd ~r~emove ~s~ave ~f~ind ";
  1130. X    char *setupline1_2 = "~c~hange dial dir ~ENTER~:dial ~ESC,q~uit";
  1131. X
  1132. X    strcpy(setupline1,setupline1_1);
  1133. X    strcat(setupline1,setupline1_2);
  1134. X
  1135. X    dirw_cmd_line_setup(
  1136. X        setupline1,
  1137. X        "redial: ~m~ark un~M~ark ~U~nmark all ~w~ait between dial");
  1138. X    cmd = ttygetc(1);
  1139. X    dirw_bot_msg("");
  1140. X    return(cmd);
  1141. X
  1142. X}    /* end of dirw_get_cmd */
  1143. X
  1144. X/*+-------------------------------------------------------------------------
  1145. X    phdir_cmd_save()
  1146. X--------------------------------------------------------------------------*/
  1147. Xvoid
  1148. Xphdir_cmd_save()
  1149. X{
  1150. X    FILE *fpold;
  1151. X    FILE *fpnew;
  1152. X    PDE *tpde;
  1153. X    char *cptr;
  1154. X    char phonedir_ntmp[256];        /* temp phone directory name */
  1155. X    char iobuf[128];
  1156. X    int count = 0;
  1157. X
  1158. X    if(!phdir_list_dirty)
  1159. X    {
  1160. X        dirw_bot_msg("directory has not been modified");
  1161. X        return;
  1162. X    }
  1163. X
  1164. X    strcpy(phonedir_ntmp,phonedir_name);
  1165. X    strcat(phonedir_ntmp,".t");
  1166. X
  1167. X    if(!(fpnew = fopen(phonedir_ntmp,"w")))    /* open old file */
  1168. X    {
  1169. X        sprintf(iobuf,"cannot open %s",phonedir_ntmp);
  1170. X        dirw_bot_msg(iobuf);
  1171. X        return;
  1172. X    }
  1173. X
  1174. X/* write trigger */
  1175. X    fputs(phonedir_trigger,fpnew);
  1176. X
  1177. X/* retain commented entries */
  1178. X    if((fpold = fopen(phonedir_name,"r")))    /* open old file */
  1179. X    {
  1180. X        while(fgets(iobuf,sizeof(iobuf),fpold))
  1181. X        {
  1182. X            if((iobuf[0] == '#') && strcmp(iobuf,phonedir_trigger))
  1183. X                fputs(iobuf,fpnew);
  1184. X        }
  1185. X        fclose(fpold);
  1186. X    }
  1187. X
  1188. X/* write new entries */
  1189. X    tpde = phdir_list_head;
  1190. X    while(tpde)
  1191. X    {
  1192. X        cptr = tpde->descr;
  1193. X        while(*cptr)            /* cannot have ':' in description */
  1194. X        {                        /* should have picked another separator, ... */
  1195. X            if(*cptr == ':')    /* ... but compatibility is important */
  1196. X                *cptr = '-';
  1197. X            cptr++;
  1198. X        }
  1199. X        sprintf(iobuf,"%d",count+1);
  1200. X        dirw_bot_msg(iobuf);
  1201. X        sprintf(iobuf,"%s:%s:%s:%u:%c:%s:%d:%c\n",tpde->logical,tpde->telno,
  1202. X            tpde->tty,tpde->baud,
  1203. X            (tpde->parity) ? to_upper(tpde->parity) : 'N',
  1204. X            tpde->descr,tpde->debug_level,to_upper(tpde->dcdwatch));
  1205. X        fputs(iobuf,fpnew);
  1206. X        tpde = tpde->next;
  1207. X        count++;
  1208. X    }
  1209. X
  1210. X    fclose(fpnew);
  1211. X    unlink(phonedir_name);
  1212. X    rename(phonedir_ntmp,phonedir_name);
  1213. X    sprintf(iobuf,"saved %d entries",count);
  1214. X    dirw_bot_msg(iobuf);
  1215. X    phdir_list_set_dirty(0);
  1216. X
  1217. X}    /* end of phdir_cmd_save */
  1218. X
  1219. X/*+-------------------------------------------------------------------------
  1220. X    phdir_list_save_if_dirty()
  1221. X--------------------------------------------------------------------------*/
  1222. Xvoid
  1223. Xphdir_list_save_if_dirty()
  1224. X{
  1225. X    uint cmd = 0;
  1226. X
  1227. X    if(phdir_list_dirty)
  1228. X    {
  1229. X        dirw_bot_msg("type 'y' or 'n'");
  1230. X        while(!cmd)
  1231. X        {
  1232. X            ring_bell();
  1233. X            dirw_cmd_line_setup("","current directory modified: save?");
  1234. X            cmd = ttygetc(0);
  1235. X            if(isupper(cmd))
  1236. X                cmd = tolower(cmd);
  1237. X            switch(cmd)
  1238. X            {
  1239. X                case 'y': phdir_cmd_save(); break;
  1240. X                case 'n': break;
  1241. X                default:
  1242. X                    cmd = 0;
  1243. X                    break;        
  1244. X            }
  1245. X        }
  1246. X        dirw_bot_msg("");
  1247. X    }
  1248. X}    /* end of phdir_list_save_if_dirty */
  1249. X
  1250. X/*+-------------------------------------------------------------------------
  1251. X    phdir_cmd_up()
  1252. X--------------------------------------------------------------------------*/
  1253. Xvoid
  1254. Xphdir_cmd_up()
  1255. X{
  1256. X    register PDE *tpde;
  1257. X
  1258. X    if((!curr_pde) || (curr_pde->prev == (PDE *)0))
  1259. X    {
  1260. X        ring_bell();
  1261. X        return;
  1262. X    }
  1263. X    if(scrw_curr_pde_line)
  1264. X    {
  1265. X        phdir_display_logical(scrw_curr_pde_line,curr_pde,0);
  1266. X        scrw_curr_pde_line--;
  1267. X        curr_pde = curr_pde->prev;
  1268. X        phdir_display_logical(scrw_curr_pde_line,curr_pde,1);
  1269. X    }
  1270. X    else
  1271. X    {
  1272. X        tpde = curr_pde;
  1273. X        curr_pde = curr_pde->prev;
  1274. X        scrw_fill_at(10,tpde,&scrw_curr_pde_line);
  1275. X    }
  1276. X
  1277. X}    /* end of phdir_cmd_up */
  1278. X
  1279. X/*+-------------------------------------------------------------------------
  1280. X    phdir_cmd_down()
  1281. X--------------------------------------------------------------------------*/
  1282. Xvoid
  1283. Xphdir_cmd_down()
  1284. X{
  1285. X    register PDE *tpde;
  1286. X
  1287. X    if((!curr_pde) || (curr_pde->next == (PDE *)0))
  1288. X    {
  1289. X        ring_bell();
  1290. X        return;
  1291. X    }
  1292. X    if(scrw_curr_pde_line < (SCRW_LINES - 1))
  1293. X    {
  1294. X        phdir_display_logical(scrw_curr_pde_line,curr_pde,0);
  1295. X        scrw_curr_pde_line++;
  1296. X        curr_pde = curr_pde->next;
  1297. X        phdir_display_logical(scrw_curr_pde_line,curr_pde,1);
  1298. X    }
  1299. X    else
  1300. X    {
  1301. X        tpde = curr_pde;
  1302. X        curr_pde = curr_pde->next;
  1303. X        scrw_fill_at(SCRW_LINES - 10,tpde,&scrw_curr_pde_line);
  1304. X    }
  1305. X
  1306. X}    /* end of phdir_cmd_down */
  1307. X
  1308. X/*+-------------------------------------------------------------------------
  1309. X    check_curr_pde() -- return 1 if there is a current pde, else 0
  1310. X--------------------------------------------------------------------------*/
  1311. Xcheck_curr_pde()
  1312. X{
  1313. X    if(!curr_pde)
  1314. X    {
  1315. X        dirw_bot_msg("no directory entry selected");
  1316. X        return(0);
  1317. X    }
  1318. X    return(1);
  1319. X}    /* end of check_curr_pde */
  1320. X
  1321. X/*+-------------------------------------------------------------------------
  1322. X    phdir_add_or_edit_read(prompt,edit,y,buf,bufmax,delim)
  1323. X
  1324. XThere are numerous theoretcally possible string overflow possibilities
  1325. Xin here, but no practical string will be long enough
  1326. X--------------------------------------------------------------------------*/
  1327. Xvoid
  1328. Xphdir_add_or_edit_read(prompt,edit,y,buf,bufmax,delim)
  1329. Xchar *prompt;
  1330. Xint edit;
  1331. Xint y;
  1332. Xchar *buf;
  1333. Xint bufmax;
  1334. Xuchar *delim;
  1335. X{
  1336. X    int wgpos = -1;
  1337. X    char s80[80];
  1338. X    int done = 0;
  1339. X
  1340. X    if(!check_curr_pde())
  1341. X        return;
  1342. X
  1343. X    wmove(addw,PDE_ITEM_COUNT + 3,2);
  1344. X    waddstr(addw,prompt);
  1345. X
  1346. X    wstandout(addw);
  1347. X    if(edit)
  1348. X        strcpy(s80,buf);
  1349. X
  1350. X    do
  1351. X    {
  1352. X        (void)wingets(addw,y,20,s80,bufmax,delim,edit,&wgpos);
  1353. X        wstandend(addw);
  1354. X        clear_area(addw,y,20,bufmax);
  1355. X        edit = 1;        /* if we come back again, edit string */
  1356. X
  1357. X        switch(*((uchar *)delim))
  1358. X        {
  1359. X            case ESC:
  1360. X                waddstr(addw,buf);
  1361. X                done = 1;
  1362. X                break;
  1363. X
  1364. X            case TAB:
  1365. X            case NL:
  1366. X            case XFcurdn:
  1367. X                *delim = NL;
  1368. X            case XFend:
  1369. X                strcpy(buf,s80);
  1370. X                waddstr(addw,buf);
  1371. X                done = 1;
  1372. X                break;
  1373. X
  1374. X            case CTL_U:
  1375. X                s80[0] = 0;
  1376. X                break;
  1377. X
  1378. X            case CTL_B:
  1379. X            case XFcurup:
  1380. X                strcpy(buf,s80);
  1381. X                waddstr(addw,buf);
  1382. X                *delim = CTL_B;
  1383. X                done = 1;
  1384. X                break;
  1385. X
  1386. X            default:
  1387. X                ring_bell();
  1388. X                break;
  1389. X        }
  1390. X    } while(!done);
  1391. X
  1392. X    clear_area(addw,PDE_ITEM_COUNT + 3,2,strlen(prompt));
  1393. X
  1394. X}    /* end of phdir_add_or_edit_read */
  1395. X
  1396. X/*+-------------------------------------------------------------------------
  1397. X    phdir_add_or_edit(tpde,edit)
  1398. X--------------------------------------------------------------------------*/
  1399. Xint
  1400. Xphdir_add_or_edit(tpde,edit)
  1401. Xregister PDE *tpde;
  1402. Xint edit;
  1403. X{
  1404. X    int input_state = 0;
  1405. X    int changed = 0;
  1406. X    int done = 0;
  1407. X    int aborted = 0;
  1408. X    int itmp;
  1409. X    int wgedit = 0;
  1410. X    int wgpos = -1;
  1411. X    char s64[64];
  1412. X    uchar delim = 0;
  1413. X    int y,x;
  1414. X    PDE *old_curr_pde = (PDE *)0;
  1415. X    uint baud;
  1416. X    char cmpbuf[128];
  1417. X    char *emsg = (char *)0;
  1418. X
  1419. X    if(!edit)
  1420. X    {
  1421. X        dirw_bot_msg("ESC: abort  ^U: erase input");
  1422. X        dirw_cmd_line_setup(
  1423. X            "Only the 1st 10 characters appear in the table",
  1424. X            "Enter new directory entry name: ");
  1425. X        getyx(dirw,y,x);
  1426. X        wstandout(dirw);
  1427. X        while((delim != ESC) && (delim != NL))
  1428. X        {
  1429. X            (void)wingets(dirw,y,x,tpde->logical,DESTREF_LEN+1,&delim,
  1430. X                wgedit,&wgpos);
  1431. X            wgedit = 1;
  1432. X        }
  1433. X        wstandend(dirw);
  1434. X        dirw_bot_msg("");
  1435. X        if((!strlen(tpde->logical)) || (delim == ESC))
  1436. X        {
  1437. X            dirw_bot_msg("add aborted");
  1438. X            return(0);
  1439. X        }
  1440. X    
  1441. X        if(!isalpha(tpde->logical[0]))
  1442. X        {
  1443. X            dirw_bot_msg("first character must be alphabetic");
  1444. X            return(0);
  1445. X        }
  1446. X
  1447. X        if(phdir_list_search(tpde->logical,1))
  1448. X        {
  1449. X            sprintf(s64,"'%s' is already in the directory",tpde->logical);
  1450. X            ring_bell();
  1451. X            dirw_bot_msg(s64);
  1452. X            return(0);
  1453. X        }
  1454. X
  1455. X        tpde->descr[0] = 0;
  1456. X        tpde->telno[0] = 0;
  1457. X        tpde->tty[0] = 0;
  1458. X        tpde->parity = 0;
  1459. X        tpde->baud = DEFAULT_BAUD_RATE;
  1460. X        tpde->debug_level = 0;
  1461. X        tpde->dcdwatch = 'n';        /* do not modify shm->Ldcdwatch */
  1462. X    
  1463. X        phdir_list_add(tpde);
  1464. X        old_curr_pde = curr_pde;
  1465. X        curr_pde = tpde;
  1466. X        scrw_fill_at(SCRW_LINES / 2,tpde,&scrw_curr_pde_line);
  1467. X        tpde = curr_pde;
  1468. X    }    /* end of add code */
  1469. X
  1470. X    dirw_cmd_line_setup("","");
  1471. X
  1472. X    /*
  1473. X     * get a new window
  1474. X     */
  1475. X    sprintf(s64,"entry: %s",tpde->logical);
  1476. X    addw = window_create(s64,3,ADDW_TLY,ADDW_TLX,ADDW_LINES,ADDW_COLS);
  1477. X
  1478. X    wmove(addw,2,2);  waddstr(addw,"telephone number");
  1479. X    wmove(addw,3,2);  waddstr(addw,"device");
  1480. X    wmove(addw,4,2);  waddstr(addw,"baud rate");
  1481. X    wmove(addw,5,2);  waddstr(addw,"parity");
  1482. X    wmove(addw,6,2);  waddstr(addw,"description");
  1483. X    wmove(addw,7,2);  waddstr(addw,"debug level");
  1484. X    wmove(addw,7,23); waddstr(addw,"(dialer -x value 0-9)");
  1485. X    wmove(addw,8,2);  waddstr(addw,"DCD watch");
  1486. X
  1487. X    wmove(addw,2,20); waddstr(addw,tpde->telno);
  1488. X    wmove(addw,3,20); waddstr(addw,(tpde->tty[0]) ? tpde->tty : "Any");
  1489. X    sprintf(s64,"%-5u",tpde->baud);
  1490. X    wmove(addw,4,20); waddstr(addw,s64);
  1491. X    s64[0] = (tpde->parity) ? to_upper((char)tpde->parity) : 'N';
  1492. X    s64[1] = 0;
  1493. X    wmove(addw,5,20); waddstr(addw,s64);
  1494. X    wmove(addw,6,20); waddstr(addw,tpde->descr);
  1495. X    sprintf(s64,"%u",tpde->debug_level);
  1496. X    wmove(addw,7,20); waddstr(addw,s64);
  1497. X    wmove(addw,8,20); waddch(addw,tpde->dcdwatch);
  1498. X
  1499. X    wmove(addw,PDE_ITEM_COUNT + 4,2);
  1500. X    if(edit)
  1501. X        waddstr(addw,"ESC: exit  END: accept  ^U: erase ^B: back  TAB: fwd");
  1502. X    else
  1503. X        waddstr(addw,"ESC: cancel  END: accept  ^U: erase field  ^B: back up");
  1504. X    wrefresh(addw);
  1505. X
  1506. X/* add/edit common */
  1507. X    while(!done)
  1508. X    {
  1509. X        changed = 0;
  1510. X        switch(input_state)
  1511. X        {
  1512. X            case 0:
  1513. X                if(edit)
  1514. X                    strcpy(s64,tpde->telno);
  1515. X                phdir_add_or_edit_read("Enter telephone number",
  1516. X                    edit,input_state + 2,tpde->telno,DESTREF_LEN+1,&delim);
  1517. X                if(edit && strcmp(tpde->telno,s64))
  1518. X                    changed = 1;
  1519. X                break;
  1520. X
  1521. X            case 1:
  1522. X                if(!tpde->tty[0])
  1523. X                    strcpy(tpde->tty,"Any");
  1524. X                if(edit)
  1525. X                    strcpy(s64,tpde->tty);
  1526. XCASE_1_AGAIN:
  1527. X                phdir_add_or_edit_read( (emsg) ? emsg :
  1528. X                    "Enter tty (e.g. 1a), Any or [=/]Devices-type",
  1529. X                    edit,input_state + 2,s64,PDE_TTY_LEN+1,&delim);
  1530. X                if((delim != ESC) && (s64[0] == '/') &&
  1531. X                    regexp_compile(s64 + 1,cmpbuf,sizeof(cmpbuf),&emsg))
  1532. X                {
  1533. X                    ring_bell();
  1534. X                    goto CASE_1_AGAIN;
  1535. X                }
  1536. X                emsg = (char *)0;
  1537. X                if(!strlen(s64) || !strcmpi(s64,"any"))
  1538. X                {
  1539. X                    strcpy(s64,"Any");
  1540. X                    clear_area(addw,input_state + 2,20,PDE_TTY_LEN+1);
  1541. X                    waddstr(addw,s64);
  1542. X                }
  1543. X                if(edit)
  1544. X                    changed = !!strcmp(tpde->tty,s64);
  1545. X                if(!strcmpi(s64,"any"))
  1546. X                    tpde->tty[0] = 0;
  1547. X                else
  1548. X                    strcpy(tpde->tty,s64);
  1549. X                break;
  1550. X
  1551. X            case 2:
  1552. X                sprintf(s64,"%u",tpde->baud);
  1553. X                phdir_add_or_edit_read(
  1554. X                "Enter rate (110,300,600,1200,2400,4800,9600,19200,38400)",
  1555. X                    1,input_state + 2,s64,5+1,&delim);
  1556. X                if(valid_baud_rate(baud = atoi(s64)) < 0)
  1557. X                {
  1558. X                    ring_bell();
  1559. X                    continue;
  1560. X                }
  1561. X                if(edit && (tpde->baud != baud ))
  1562. X                    changed = 1;
  1563. X                tpde->baud = baud;
  1564. X                break;
  1565. X
  1566. X            case 3:
  1567. X                sprintf(s64,"%c",(tpde->parity) ? tpde->parity : 'N');
  1568. X                phdir_add_or_edit_read("Enter parity (n,o,e)",
  1569. X                    1,input_state + 2,s64,1+1,&delim);
  1570. X                switch(s64[0] = to_lower(s64[0]))
  1571. X                {
  1572. X                    case 'n':
  1573. X                        s64[0] = 0;
  1574. X                    case 'o':
  1575. X                    case 'e':
  1576. X                        if(edit && (tpde->parity != s64[0]))
  1577. X                            changed = 1;
  1578. X                        tpde->parity = s64[0];
  1579. X                        break;
  1580. X                    default:
  1581. X                        ring_bell();
  1582. X                        continue;
  1583. X                }
  1584. X                break;
  1585. X
  1586. X            case 4:
  1587. X                if(edit)
  1588. X                    strcpy(s64,tpde->descr);
  1589. X                phdir_add_or_edit_read("Enter description",
  1590. X                    edit,input_state + 2,tpde->descr,PDE_DESCR_LEN+1,&delim);
  1591. X                if(edit && strcmp(tpde->descr,s64))
  1592. X                    changed = 1;
  1593. X                break;
  1594. X
  1595. X            case 5:
  1596. X                sprintf(s64,"%u",tpde->debug_level);
  1597. X                phdir_add_or_edit_read("Enter dialer debug level (0-9)",
  1598. X                    1,input_state + 2,s64,1+1,&delim);
  1599. X                if(!isdigit(s64[0]))
  1600. X                {
  1601. X                    ring_bell();
  1602. X                    continue;
  1603. X                }
  1604. X                itmp = atoi(s64);
  1605. X                if(edit && (itmp != tpde->debug_level))
  1606. X                    changed = 1;
  1607. X                tpde->debug_level = itmp;
  1608. X                break;
  1609. X
  1610. X            case 6:
  1611. X                sprintf(s64,"%c",tpde->dcdwatch);
  1612. X                phdir_add_or_edit_read(
  1613. X                    "0=off,1=on,t=terminate ecu on carrier loss,n=no change",
  1614. X                    1,input_state + 2,s64,1+1,&delim);
  1615. X                switch(s64[0] = to_lower(s64[0]))
  1616. X                {
  1617. X                    case '0':
  1618. X                    case '1':
  1619. X                    case 't':
  1620. X                    case 'n':
  1621. X                        break;
  1622. X                    default:
  1623. X                        ring_bell();
  1624. X                        continue;
  1625. X                }
  1626. X                if(edit && ((uchar)s64[0] != tpde->dcdwatch))
  1627. X                    changed = 1;
  1628. X                tpde->dcdwatch = s64[0];
  1629. X                break;
  1630. X        }
  1631. X
  1632. X        switch(delim) /* process delimiter */
  1633. X        {
  1634. X            case CTL_L:
  1635. X            case CTL_R:
  1636. X                touchwin(stdscr);
  1637. X                wrefresh(stdscr);
  1638. X                touchwin(dirw);
  1639. X                wrefresh(dirw);
  1640. X                touchwin(scrw);
  1641. X                wrefresh(scrw);
  1642. X                break;
  1643. X
  1644. X            case CTL_B:
  1645. X                if(input_state)
  1646. X                    input_state--;
  1647. X                else
  1648. X                    input_state = 6;
  1649. X                break;
  1650. X
  1651. X            case ESC:
  1652. X                if(edit)
  1653. X                {
  1654. X                    dirw_bot_msg("edit exit");
  1655. X                    done = 1;
  1656. X                }
  1657. X                else
  1658. X                {
  1659. X                    phdir_list_remove(tpde);
  1660. X                    if(old_curr_pde)
  1661. X                        curr_pde = old_curr_pde;
  1662. X                    else
  1663. X                    {
  1664. X                        pputs("\nphdir_add_or_edit logic error\n");
  1665. X                        termecu(TERMECU_XMTR_FATAL_ERROR);
  1666. X                    }
  1667. X                    dirw_bot_msg("add aborted");
  1668. X                    aborted = 1;
  1669. X                    done = 1;
  1670. X                }
  1671. X                break;
  1672. X
  1673. X            case XFend:
  1674. X                done = 1;
  1675. X            case NL:
  1676. X                if(edit && changed)
  1677. X                    phdir_list_set_dirty(1);
  1678. X                input_state++;
  1679. X                input_state %= PDE_ITEM_COUNT;
  1680. X                break;
  1681. X
  1682. X            default:
  1683. X                ring_bell();
  1684. X                break;
  1685. X
  1686. X        }
  1687. X    }
  1688. X
  1689. X    delwin(addw);
  1690. X    addw = (WINDOW *)0;
  1691. X    touchwin(scrw);
  1692. X    if(aborted)
  1693. X    {
  1694. X        scrw_fill_at(scrw_curr_pde_line + 1,curr_pde,
  1695. X            &scrw_curr_pde_line);
  1696. X    }
  1697. X    else
  1698. X        phdir_display(scrw_curr_pde_line,tpde,1);
  1699. X    return(!aborted);
  1700. X
  1701. X}    /* end of phdir_add_or_edit */
  1702. X
  1703. X/*+-------------------------------------------------------------------------
  1704. X    phdir_cmd_add(tpde)
  1705. Xif tpde != 0, it is an already valid pde that is to be added
  1706. Xelse if == 0, interactive add
  1707. X--------------------------------------------------------------------------*/
  1708. Xvoid
  1709. Xphdir_cmd_add(tpde)
  1710. Xregister PDE *tpde;
  1711. X{
  1712. X
  1713. X    if(tpde)
  1714. X    {
  1715. X        phdir_list_add(tpde);
  1716. X    }
  1717. X    else
  1718. X    {
  1719. X        if(!(tpde = (PDE *)calloc(1,sizeof(PDE ))))
  1720. X        {
  1721. X            dirw_bot_msg("Out of memory -- cannot add new entry");
  1722. X            return;
  1723. X        }
  1724. X        if(!phdir_add_or_edit(tpde,0))    /* routine will add to list ... */
  1725. X        {                                /* ... if good return */
  1726. X            free((char *)tpde);
  1727. X            return;
  1728. X        }
  1729. X    }
  1730. X    phdir_list_set_dirty(1);
  1731. X
  1732. X    curr_pde = tpde;
  1733. X    scrw_fill_at(SCRW_LINES / 2,curr_pde,&scrw_curr_pde_line);
  1734. X
  1735. X}    /* end of phdir_cmd_add */
  1736. X
  1737. X/*+-------------------------------------------------------------------------
  1738. X    phdir_cmd_mark(tpde) - mark for redial
  1739. X--------------------------------------------------------------------------*/
  1740. Xvoid
  1741. Xphdir_cmd_mark(tpde)
  1742. Xregister PDE *tpde;
  1743. X{
  1744. X
  1745. X    if(!tpde)
  1746. X        return;
  1747. X    if(!tpde->redial)
  1748. X    {
  1749. X        tpde->redial = 1;
  1750. X        if(tpde == curr_pde)
  1751. X            phdir_display_logical(scrw_curr_pde_line,curr_pde,1);
  1752. X        pde_marked_for_redial_count++;
  1753. X        dirw_display_config();
  1754. X    }
  1755. X
  1756. X}    /* end of phdir_cmd_mark */
  1757. X
  1758. X/*+-------------------------------------------------------------------------
  1759. X    phdir_cmd_unmark(tpde) - unmark for redial
  1760. X--------------------------------------------------------------------------*/
  1761. Xvoid
  1762. Xphdir_cmd_unmark(tpde)
  1763. Xregister PDE *tpde;
  1764. X{
  1765. X
  1766. X    if(!tpde)
  1767. X        return;
  1768. X    if(tpde->redial)
  1769. X    {
  1770. X        tpde->redial = 0;
  1771. X        if(tpde == curr_pde)
  1772. X            phdir_display_logical(scrw_curr_pde_line,curr_pde,1);
  1773. X        pde_marked_for_redial_count--;
  1774. X        dirw_display_config();
  1775. X    }
  1776. X
  1777. X}    /* end of phdir_cmd_unmark */
  1778. X
  1779. X/*+-------------------------------------------------------------------------
  1780. X    phdir_cmd_unmark_all() - unmark for redial all PDEs
  1781. X--------------------------------------------------------------------------*/
  1782. Xvoid
  1783. Xphdir_cmd_unmark_all()
  1784. X{
  1785. X    register PDE *tpde;
  1786. X    register y;
  1787. X
  1788. X    tpde = phdir_list_head;
  1789. X    while(tpde)
  1790. X    {
  1791. X        tpde->redial = 0;
  1792. X        tpde = tpde->next;
  1793. X    }
  1794. X
  1795. X    for(y = 0; y < SCRW_LINES; y++)
  1796. X    {
  1797. X        wmove(scrw,y,1);
  1798. X        waddch(scrw,' ');
  1799. X    }
  1800. X    pde_marked_for_redial_count = 0;
  1801. X    dirw_display_config();
  1802. X
  1803. X}    /* end of phdir_cmd_unmark_all */
  1804. X
  1805. X/*+-------------------------------------------------------------------------
  1806. X    phdir_cmd_remove_oops()
  1807. X--------------------------------------------------------------------------*/
  1808. Xvoid
  1809. Xphdir_cmd_remove_oops()
  1810. X{
  1811. X    if(!remove_pde)
  1812. X    {
  1813. X        dirw_bot_msg("no removed entry to restore");
  1814. X        return;
  1815. X    }
  1816. X    phdir_cmd_add(remove_pde);
  1817. X    phdir_list_set_dirty(remove_dirty_flag);
  1818. X    remove_pde = (PDE *)0;
  1819. X}    /* end of phdir_cmd_remove_oops */
  1820. X
  1821. X/*+-------------------------------------------------------------------------
  1822. X    phdir_cmd_remove()
  1823. X--------------------------------------------------------------------------*/
  1824. Xvoid
  1825. Xphdir_cmd_remove()
  1826. X{
  1827. X    char s80[80];
  1828. X
  1829. X    if(!check_curr_pde())
  1830. X        return;
  1831. X
  1832. X    remove_pde = curr_pde;
  1833. X    remove_dirty_flag = phdir_list_dirty;
  1834. X    phdir_list_remove(curr_pde);
  1835. X    phdir_list_set_dirty(1);
  1836. X
  1837. X    if(phdir_list_quan)
  1838. X        scrw_fill_at(scrw_curr_pde_line + 1,curr_pde,&scrw_curr_pde_line);
  1839. X    else
  1840. X        scrw_fill((PDE *)0,&scrw_curr_pde_line);
  1841. X
  1842. X    ring_bell();
  1843. X    sprintf(s80,"if you did not mean to to remove '%s', press 'o' (oops) NOW!",
  1844. X            remove_pde->logical);
  1845. X    dirw_bot_msg(s80);
  1846. X
  1847. X}    /* end of phdir_cmd_remove */
  1848. X
  1849. X/*+-------------------------------------------------------------------------
  1850. X    phdir_cmd_find()
  1851. X--------------------------------------------------------------------------*/
  1852. Xvoid
  1853. Xphdir_cmd_find()
  1854. X{
  1855. X    register PDE *tpde;
  1856. X    char findname[12];
  1857. X    uchar delim = 0;
  1858. X    int y,x;
  1859. X    int wgedit = 0;
  1860. X    int wgpos = -1;
  1861. X
  1862. X    dirw_bot_msg("ESC: abort  ^U: erase input");
  1863. X    dirw_cmd_line_setup("","Directory entry name to find: ");
  1864. X    getyx(dirw,y,x);
  1865. X    wstandout(dirw);
  1866. X    while((delim != ESC) && (delim != NL))
  1867. X    {
  1868. X        (void)wingets(dirw,y,x,findname,DESTREF_LEN+1,&delim,
  1869. X            wgedit,&wgpos);
  1870. X        wgedit = 1;
  1871. X    }
  1872. X    wstandend(dirw);
  1873. X    dirw_bot_msg("");
  1874. X    if((!strlen(findname)) || (delim == ESC))
  1875. X        return;
  1876. X
  1877. X    if(! (tpde = phdir_list_search(findname,0)))
  1878. X    {
  1879. X        dirw_bot_msg(errmsg);
  1880. X        return;
  1881. X    }
  1882. X    curr_pde = tpde;
  1883. X    scrw_fill_at(SCRW_LINES / 2,tpde,&scrw_curr_pde_line);
  1884. X
  1885. X}    /* end of phdir_cmd_find */
  1886. X
  1887. X/*+-------------------------------------------------------------------------
  1888. X    phdir_cmd_change_dir()
  1889. X--------------------------------------------------------------------------*/
  1890. Xvoid
  1891. Xphdir_cmd_change_dir()
  1892. X{
  1893. X    int itmp;
  1894. X    char newdirname[256];
  1895. X    char buf[256];
  1896. X    uchar delim = 0;
  1897. X    int y,x;
  1898. X    int wgedit = 0;
  1899. X    int wgpos = -1;
  1900. X    char *expcmd;
  1901. X    extern char errmsg[];
  1902. X
  1903. X    phdir_list_save_if_dirty();
  1904. X    dirw_bot_msg("ESC: abort  ^U: erase input");
  1905. X    dirw_cmd_line_setup(" Enter new directory name:","");
  1906. X    getyx(dirw,y,x);
  1907. X    wstandout(dirw);
  1908. X    while((delim != ESC) && (delim != NL))
  1909. X    {
  1910. X        (void)wingets(dirw,y,x,buf,70+1,&delim,
  1911. X            wgedit,&wgpos);
  1912. X        wgedit = 1;
  1913. X    }
  1914. X    wstandend(dirw);
  1915. X    dirw_bot_msg("");
  1916. X    if((!strlen(buf)) || (delim == ESC))
  1917. X        return;
  1918. X
  1919. X    if((buf[0] == '~') || (buf[0] == '.') || (buf[0] == '/'))
  1920. X        strcpy(newdirname,buf);
  1921. X    else
  1922. X    {
  1923. X        get_curr_dir(newdirname,sizeof(newdirname));
  1924. X        strcat(newdirname,"/");
  1925. X        strcat(newdirname,buf);
  1926. X    }
  1927. X    if(find_shell_chars(newdirname))
  1928. X    {
  1929. X        if(expand_wildcard_list(newdirname,&expcmd))
  1930. X        {
  1931. X            dirw_bot_msg(expcmd);
  1932. X            ring_bell();
  1933. X            return;
  1934. X        }
  1935. X        strncpy(newdirname,expcmd,sizeof(newdirname) - 1);
  1936. X        newdirname[sizeof(newdirname) - 1] = 0;
  1937. X        free(expcmd);
  1938. X    }
  1939. X
  1940. X    if(access(newdirname,4))
  1941. X    {
  1942. X        if(errno == ENOENT)
  1943. X        {
  1944. X            if(!want_pd_create(newdirname))
  1945. X            {
  1946. X                dirw_bot_msg("non-existent file not created");
  1947. X                return;
  1948. X            }
  1949. X            if((itmp = open(newdirname,O_RDWR | O_CREAT | O_TRUNC,0600)) >= 0)
  1950. X            {
  1951. X                write(itmp,phonedir_trigger,strlen(phonedir_trigger));
  1952. X                close(itmp);
  1953. X                dirw_bot_msg("created new (empty) directory file");
  1954. X                ring_bell();
  1955. X                Nap(1000L);
  1956. X                goto READ_LIST;
  1957. X            }
  1958. X            if(errno == ENOENT)
  1959. X            {
  1960. X                dirw_bot_msg("directory does not exist");
  1961. X                ring_bell();
  1962. X                return;
  1963. X            }
  1964. X        }
  1965. X        dirw_bot_msg(errno_text(errno));
  1966. X        ring_bell();
  1967. X        return;
  1968. X    }
  1969. X
  1970. XREAD_LIST:
  1971. X    strcpy(phonedir_name,newdirname);
  1972. X    if(phdir_list_read())
  1973. X    {
  1974. X        dirw_bot_msg(errmsg);
  1975. X        return;
  1976. X    }
  1977. X    curr_pde = phdir_list_head;
  1978. X    scrw_fill(curr_pde,&scrw_curr_pde_line);
  1979. X    if(!phdir_list_quan)
  1980. X    {
  1981. X        dirw_bot_msg("directory empty");
  1982. X        return;
  1983. X    }
  1984. X
  1985. X}    /* end of phdir_cmd_change_dir */
  1986. X
  1987. X/*+-------------------------------------------------------------------------
  1988. X    phdir_dial_cycle() - dial single destination or cycle through list
  1989. Xreturn 1 if connect occurs, 0 if cycle expires or interrupted
  1990. X--------------------------------------------------------------------------*/
  1991. Xint
  1992. Xphdir_dial_cycle()
  1993. X{
  1994. X    register PDE *tpde = phdir_list_head;
  1995. X    uint ans;
  1996. X    int nap_decisec;
  1997. X    int rtn = 0;
  1998. X    int restart_rcvr = need_rcvr_restart();
  1999. X
  2000. X    if(!tpde || !phdir_list_quan)
  2001. X    {
  2002. X        ring_bell();
  2003. X        return(0);
  2004. X    }
  2005. X
  2006. X    if(!pde_marked_for_redial_count)
  2007. X    {
  2008. X        pde_dial(curr_pde);
  2009. X        return(!(int)iv[0]);
  2010. X    }
  2011. X
  2012. X    kill_rcvr_process(SIGUSR1);
  2013. X
  2014. X    ff(se,"\r\nbeginning cycle through %d marked redial entr%s\r\n",
  2015. X        pde_marked_for_redial_count,
  2016. X        (pde_marked_for_redial_count > 1) ? "ies" : "y");
  2017. X
  2018. X    while(1)    /* forever until a connect or interrupt */
  2019. X    {
  2020. X        if(tpde->redial)
  2021. X        {
  2022. X            pde_dial(tpde);
  2023. X            switch((int)iv[0])
  2024. X            {
  2025. X                case 0:        /* CONNECTED */
  2026. X                    tpde->redial = 0;
  2027. X                    pde_marked_for_redial_count--;
  2028. X                    bell_notify(XBELL_C);
  2029. X                    rtn = 1;
  2030. X                    goto RETURN;
  2031. X                case 2:        /* INTERRUPTED */
  2032. X                    ff(se,"\r\ndial interrupted: abort cycle (y,n)?  ");
  2033. X                    sigint = 0;
  2034. X                    ans = 0;
  2035. X                    while(ans == 0)
  2036. X                    {
  2037. X                        switch(ans = to_lower(ttygetc(1)))
  2038. X                        {
  2039. X                            case 'y':
  2040. X                                ff(se,"YES\r\n");
  2041. X                                goto ABORT_CYCLE;
  2042. X                            case 'n':
  2043. X                                ff(se,"NO\r\n");
  2044. X                                break;
  2045. X                            default: 
  2046. X                                ring_bell();
  2047. X                                ans = 0;
  2048. X                        }
  2049. X                    }
  2050. X                    break;
  2051. X                case 1:        /* FAILED TO CONNECT */
  2052. X                case 3:        /* MODEM ERROR */
  2053. X                default:
  2054. X                    if(pde_marked_for_redial_count == 1)
  2055. X                        nap_decisec = nap_decisec_single;
  2056. X                    else
  2057. X                        nap_decisec = nap_decisec_multiple;
  2058. X                    ff(se,
  2059. X                    "waiting %d seconds ... 'c' to cycle, %s to abort\r\n",
  2060. X                        nap_decisec/10,
  2061. X                        (kbdintr == DEL) ?"DEL":make_char_graphic(kbdintr,0));
  2062. X                    while(nap_decisec--)
  2063. X                    {
  2064. X                        Nap(100L);
  2065. X                        if(ttyrdchk())
  2066. X                        {
  2067. X                            ans = to_lower(ttygetc(1));
  2068. X                            ttyflush(0);
  2069. X                            if(ans == 'c')
  2070. X                                goto CONTINUE_CYCLE;
  2071. X                            else if(ans == kbdintr)
  2072. X                                goto ABORT_CYCLE;
  2073. X                            else
  2074. X                                ring_bell();
  2075. X                        }
  2076. X                        if(sigint)
  2077. X                            goto ABORT_CYCLE;
  2078. X                    }
  2079. X                    break;
  2080. X            }
  2081. X        }
  2082. XCONTINUE_CYCLE:
  2083. X        tpde = tpde->next;
  2084. X        if(!tpde)
  2085. X            tpde = phdir_list_head;
  2086. X    }
  2087. X
  2088. XABORT_CYCLE:
  2089. X    sigint = 0;
  2090. X    ff(se,"redial cycle ABORTED\r\n");
  2091. X
  2092. XRETURN:
  2093. X    if(restart_rcvr)
  2094. X        start_rcvr_process(1);
  2095. X
  2096. X    return(rtn);
  2097. X
  2098. X}    /* end of phdir_dial_cycle */
  2099. X
  2100. X/*+-------------------------------------------------------------------------
  2101. X    phdir_cmd_set_wait()
  2102. X--------------------------------------------------------------------------*/
  2103. Xvoid
  2104. Xphdir_cmd_set_wait()
  2105. X{
  2106. X    char buf[64];
  2107. X    uchar delim = 0;
  2108. X    int y,x;
  2109. X    int wgpos = -1;
  2110. X
  2111. X    dirw_bot_msg("ESC: abort  ^U: erase input");
  2112. X    sprintf(buf,"(Must be greater than or equal to %d seconds)",
  2113. X        NAP_DECISEC_SINGLE_MIN / 10);
  2114. X    dirw_cmd_line_setup(buf,"Wait between dials when one entry marked:");
  2115. X    getyx(dirw,y,x);
  2116. X    sprintf(buf,"%d",nap_decisec_single / 10);
  2117. X    wstandout(dirw);
  2118. X    wgpos = strlen(buf);
  2119. X    while((delim != ESC) && (delim != NL))
  2120. X        (void)wingets(dirw,y,x,buf,3+1,&delim,1,&wgpos);
  2121. X    wstandend(dirw);
  2122. X    if((!strlen(buf)) || (delim == ESC))
  2123. X    {
  2124. X        dirw_bot_msg("");
  2125. X        return;
  2126. X    }
  2127. X    nap_decisec_single = 0;
  2128. X    sscanf(buf,"%d",&nap_decisec_single);
  2129. X    nap_decisec_single *= 10;
  2130. X    if(nap_decisec_single <  NAP_DECISEC_SINGLE_MIN)
  2131. X        nap_decisec_single = NAP_DECISEC_SINGLE_MIN;
  2132. X    dirw_display_config();
  2133. X
  2134. X    sprintf(buf,"(Must be greater than or equal to %d seconds)",
  2135. X        NAP_DECISEC_MULTIPLE_MIN / 10);
  2136. X    dirw_cmd_line_setup(buf,"Wait between dials when multiple entries marked:");
  2137. X    getyx(dirw,y,x);
  2138. X    sprintf(buf,"%d",nap_decisec_multiple / 10);
  2139. X    wstandout(dirw);
  2140. X    wgpos = strlen(buf);
  2141. X    delim = 0;
  2142. X    while((delim != ESC) && (delim != NL))
  2143. X        (void)wingets(dirw,y,x,buf,3+1,&delim,1,&wgpos);
  2144. X    wstandend(dirw);
  2145. X    if((!strlen(buf)) || (delim == ESC))
  2146. X    {
  2147. X        dirw_bot_msg("");
  2148. X        return;
  2149. X    }
  2150. X    nap_decisec_multiple = 0;
  2151. X    sscanf(buf,"%d",&nap_decisec_multiple);
  2152. X    nap_decisec_multiple *= 10;
  2153. X    if(nap_decisec_multiple <  NAP_DECISEC_MULTIPLE_MIN)
  2154. X        nap_decisec_multiple = NAP_DECISEC_MULTIPLE_MIN;
  2155. X    dirw_display_config();
  2156. X
  2157. X    dirw_bot_msg("");
  2158. X
  2159. X}    /* end of phdir_cmd_set_wait */
  2160. X
  2161. X/*+-------------------------------------------------------------------------
  2162. X    phdir_manager()
  2163. X--------------------------------------------------------------------------*/
  2164. Xvoid
  2165. Xphdir_manager()
  2166. X{
  2167. X    register uchar cmd = 0;
  2168. X    int done;
  2169. X    char s80[80];
  2170. X    int restart_rcvr = need_rcvr_restart();
  2171. X
  2172. X    kill_rcvr_process(SIGUSR1);
  2173. X
  2174. X    windows_start();
  2175. X    dirw = window_create("dialing directory",3,0,0,DIRW_LINES,DIRW_COLS);
  2176. X    phonedir_name_x = 26;    /* must be set before calling dirw_display */
  2177. X    dirw_display();
  2178. X
  2179. X    scrw = subwin(dirw,SCRW_LINES,SCRW_COLS,SCRW_TLY,SCRW_TLX);
  2180. X    scrollok(scrw,0);
  2181. X    if(!phdir_list_quan)
  2182. X    {
  2183. X        if(phdir_list_read())
  2184. X            dirw_bot_msg(errmsg);
  2185. X        else if(!phdir_list_quan)
  2186. X            dirw_bot_msg("directory empty");
  2187. X    }
  2188. X
  2189. X    if(phdir_list_quan)
  2190. X    {
  2191. X        if(curr_pde)
  2192. X            scrw_fill_at(scrw_curr_pde_line,curr_pde,&scrw_curr_pde_line);
  2193. X        else
  2194. X        {
  2195. X            curr_pde = phdir_list_head;
  2196. X            scrw_fill(curr_pde,&scrw_curr_pde_line);
  2197. X        }
  2198. X    }
  2199. X
  2200. X    phdir_list_set_dirty(-1);
  2201. X
  2202. X    done = 0;
  2203. X    while(!done)
  2204. X    {
  2205. X        cmd = dirw_get_cmd();
  2206. X        if((cmd != 'o') && (remove_pde))
  2207. X        {
  2208. X            free((char *)remove_pde);
  2209. X            remove_pde = (PDE *)0;
  2210. X        }
  2211. X
  2212. X        switch(cmd)
  2213. X        {
  2214. X            case XFcurdn:
  2215. X            case 'd':
  2216. X            case 'j': phdir_cmd_down(); break;
  2217. X
  2218. X            case XFcurup:
  2219. X            case 'u':
  2220. X            case 'k': phdir_cmd_up(); break;
  2221. X
  2222. X            case 's': phdir_cmd_save(); break;
  2223. X
  2224. X            case 'm': phdir_cmd_mark(curr_pde); break;
  2225. X            case 'M': phdir_cmd_unmark(curr_pde); break;
  2226. X            case 'U': phdir_cmd_unmark_all(); break;
  2227. X            case 'c': phdir_cmd_change_dir(); break;
  2228. X
  2229. X            case 'w': phdir_cmd_set_wait(); break;
  2230. X
  2231. X            case CRET:
  2232. X            case NL:
  2233. X            case XFend:
  2234. X                cmd = NL;
  2235. X                if(!check_curr_pde())
  2236. X                    break;
  2237. X                phdir_list_save_if_dirty();
  2238. X                wrefresh(dirw);
  2239. X                delwin(scrw);
  2240. X                delwin(dirw);
  2241. X                windows_end(1);
  2242. X                dirw = (WINDOW *)0;
  2243. X                scrw = (WINDOW *)0;
  2244. X                phdir_dial_cycle();
  2245. X                done = 1;
  2246. X                if(restart_rcvr)
  2247. X                    start_rcvr_process(1);
  2248. X                break;
  2249. X
  2250. X            case ESC:
  2251. X            case CTL_C:
  2252. X                cmd = 'q';
  2253. X            case 'q':
  2254. X                done = 1;
  2255. X                continue;
  2256. X
  2257. X            case '/':
  2258. X            case 'f': phdir_cmd_find(); break;
  2259. X
  2260. X            case 'r': phdir_cmd_remove(); break;
  2261. X            case 'o': phdir_cmd_remove_oops(); break;
  2262. X
  2263. X            case 'a': phdir_cmd_add((PDE *)0); break;
  2264. X
  2265. X            case 'e': phdir_add_or_edit(curr_pde,1); break;
  2266. X
  2267. X            case CTL_L:
  2268. X            case CTL_R:
  2269. X                touchwin(stdscr);
  2270. X                wrefresh(stdscr);
  2271. X                touchwin(dirw);
  2272. X                wrefresh(dirw);
  2273. X                touchwin(scrw);
  2274. X                wrefresh(scrw);
  2275. X                break;
  2276. X
  2277. X            default:
  2278. X                sprintf(s80,"invalid command: %s",
  2279. X                    (cmd < 0x80) ? make_char_graphic(cmd,0) : "?");
  2280. X                ring_bell();
  2281. X                dirw_bot_msg(s80);
  2282. X                break;
  2283. X        }
  2284. X    }
  2285. X    sigint = 0;
  2286. X    if(cmd == NL)
  2287. X        return;
  2288. X
  2289. X    phdir_list_save_if_dirty();
  2290. X    wrefresh(dirw);
  2291. X    delwin(scrw);
  2292. X    delwin(dirw);
  2293. X    windows_end(0);
  2294. X    dirw = (WINDOW *)0;
  2295. X    scrw = (WINDOW *)0;
  2296. X    redisplay_rcvr_screen();
  2297. X
  2298. X    if(restart_rcvr)
  2299. X        start_rcvr_process(0);
  2300. X
  2301. X}    /* end of phdir_manager */
  2302. X
  2303. X/* end of ecuphone.c */
  2304. X/* vi: set tabstop=4 shiftwidth=4: */
  2305. SHAR_EOF
  2306. chmod 0644 ecuphdir.c ||
  2307. echo 'restore of ecuphdir.c failed'
  2308. Wc_c="`wc -c < 'ecuphdir.c'`"
  2309. test 46641 -eq "$Wc_c" ||
  2310.     echo 'ecuphdir.c: original size 46641, current size' "$Wc_c"
  2311. rm -f _shar_wnt_.tmp
  2312. fi
  2313. # ============= ecuphrase.c ==============
  2314. if test -f 'ecuphrase.c' -a X"$1" != X"-c"; then
  2315.     echo 'x - skipping ecuphrase.c (File already exists)'
  2316.     rm -f _shar_wnt_.tmp
  2317. else
  2318. > _shar_wnt_.tmp
  2319. echo 'x - extracting ecuphrase.c (Text)'
  2320. sed 's/^X//' << 'SHAR_EOF' > 'ecuphrase.c' &&
  2321. X/*+-----------------------------------------------------------------
  2322. X    ecuphrases.c - %# phrase management
  2323. X    wht@n4hgf.Mt-Park.GA.US
  2324. X
  2325. X  Defined functions:
  2326. X    phrase_help()
  2327. X    phrases(nargc,nargv)
  2328. X    read_phrases()
  2329. X
  2330. X------------------------------------------------------------------------*/
  2331. X/*+:EDITS:*/
  2332. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  2333. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  2334. X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
  2335. X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
  2336. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  2337. X
  2338. X#include "ecu.h"
  2339. X
  2340. X#define P_N_QUAN    23
  2341. Xchar *phrases_string[P_N_QUAN];
  2342. SHAR_EOF
  2343. true || echo 'restore of ecuphrase.c failed'
  2344. fi
  2345. echo 'End of ecu320 part 10'
  2346. echo 'File ecuphrase.c is continued in part 11'
  2347. echo 11 > _shar_seq_.tmp
  2348. exit 0
  2349.  
  2350. exit 0 # Just in case...
  2351.