home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume32 / ecu / part10 < prev    next >
Text File  |  1992-09-14  |  58KB  |  2,345 lines

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