-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecuphdir.c
2505 lines (2257 loc) · 58 KB
/
ecuphdir.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*+-------------------------------------------------------------------------
ecuphdir.c -- visual phone dialer/directory editor
.---[ title ]------------modified-.<-- dirw "top line"
| stand out mode |<-- dirw "header line"
| |<-- scrw first line
| |
| |
| |
| |<-- scrw last line
+---------------------------------+<-- dirw bottom separator line
| |<-- dirw extra cmd prompt line
| stand out mode |<-- dirw "cmd line"
`---------------------------------'<-- dirw bottom line
000000000011111111112222222222333333333344444444445555555555666666666671
012345678901234567890123456789012345678901234567890123456789012345678901
0.--[ entry nnnnn ]-----------------------------------------------------.
1| |
2| telephone number ___________________ |
3| device __________ |
4| bit rate _____ |
5| parity _ |
6| description ________________________________________ |
7| debug level _ (dialer -x value 0-9) |
8| DCD watch _ |
9| RTS/CTS flow ctl _ (0=off,7=best,n=no change) |
10| |
-2| <prompt> |
-1| <control key description> |
n`----------------------------------------------------------------------'
Defined functions:
check_curr_pde()
dirw_bot_msg(msg)
dirw_cmd_line_setup(prompt1, prompt2)
dirw_display()
dirw_display_config()
dirw_display_phonedir_name()
dirw_get_cmd()
field_colon_protect(fieldstr)
field_colon_restore(fieldstr)
phdir_add_or_edit(tpde, edit)
phdir_add_or_edit_read(prompt, y, buf, bufmax, delim)
phdir_cmd_add(tpde)
phdir_cmd_change_dir()
phdir_cmd_down()
phdir_cmd_find()
phdir_cmd_mark(tpde)
phdir_cmd_pgdn()
phdir_cmd_pgup()
phdir_cmd_remove()
phdir_cmd_remove_oops()
phdir_cmd_save()
phdir_cmd_set_wait()
phdir_cmd_unmark(tpde)
phdir_cmd_unmark_all()
phdir_cmd_up()
phdir_dial_cycle()
phdir_display(line, tpde, stand_out)
phdir_display_logical(line, tpde, stand_out)
phdir_list_add(tpde)
phdir_list_erase()
phdir_list_read()
phdir_list_remove(tpde)
phdir_list_save_if_dirty()
phdir_list_search(logical, exact_flag)
phdir_list_set_dirty(flag)
phdir_manager()
scrw_fill(tpde, curr_pde_line)
scrw_fill_at(line_num, tpde, curr_pde_line)
want_pd_create(name)
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:04-26-2000-11:15-wht@bob-RELEASE 4.42 */
/*:11-16-1997-22:15-wht@kepler-regexp_compile changed shape */
/*:03-16-1997-03:[email protected] boxes for curses under SCO */
/*:02-09-1997-19:37-wht@yuriatin-mv find_procedure defn to ecu.h */
/*:01-24-1997-02:37-wht@yuriatin-SOURCE RELEASE 4.00 */
/*:09-16-1996-05:21-wht@yuriatin-protect colons in phdir entries */
/*:09-11-1996-20:[email protected] telnet,curses,structural overhaul */
/*:09-09-1996-03:16-wht@yuriatin-CFG_TelnetOption sizing */
/*:08-22-1996-15:27-wht@fep-better add_or_edit abort on ESC */
/*:08-20-1996-12:39-wht@kepler-locale/ctype fixes from [email protected] */
/*:07-24-1996-21:37-wht@n4hgf-no more wvline/whline */
/*:12-06-1995-13:30-wht@n4hgf-termecu w/errno -1 consideration */
/*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
/*:11-14-1995-10:[email protected] control point: SOCKETS */
/*:10-14-1995-23:17-wht@kepler-widen addw for baud string under Linux/BSD */
/*:10-14-1995-16:29-wht@kepler-use valid_baud_string */
/*:09-17-1995-16:35-wht@kepler-dcdw==1 does not work under Linux */
/*:05-11-1995-15:55-wht@n4hgf-ck_sigint fools optimizing compilers */
/*:05-11-1995-15:00-wht@n4hgf-^F and ^B vi-isms for page down and up */
/*:03-12-1995-02:28-wht@kepler-properly mark dirty on any edited existing pde */
/*:03-12-1995-01:54-wht@kepler-prevent clobber of reentered field during add */
/*:03-12-1995-01:03-wht@kepler-use ECU_MAXPN and clean up get_curr_dir */
/*:01-12-1995-15:19-wht@n4hgf-apply Andrew Chernov 8-bit clean+FreeBSD patch */
/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
/*:11-17-1993-10:58-wht@n4hgf-ask for 'tty1a' not '1a' in case 1 */
/*:08-17-1993-14:00-wht@n4hgf-with new wingets, skip standout in phdir edit */
/*:05-29-1993-20:21-wht@n4hgf-change linst_err_text to LINST_text */
/*:03-01-1993-03:28-wht@n4hgf-add PgUP and PgDn */
/*:01-11-1993-16:05-wht@n4hgf-improve error checking + bell on error */
/*:12-04-1992-20:43-wht@n4hgf-fix logic error test */
/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
/*:05-17-1992-18:29-wht@n4hgf-pde add now cycles thru fields til END */
/*:11-28-1991-14:32-wht@n4hgf-add dcdwatch option */
/*:11-20-1991-05:19-wht@n4hgf-improve "Any" line handling on add or edit */
/*:08-28-1991-15:15-wht@n4hgf2-fix bad structure in phdir_add_or_edit_read */
/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
/*:08-15-1991-18:13-wht@n4hgf-do not allow edit of non-existent entry */
/*:08-11-1991-19:56-wht@n4hgf-soup up tty name for ISC vs. SCO */
/*:08-07-1991-13:48-root@n4hgf-w subcommand was not asking both questions */
/*:08-01-1991-03:52-wht@n4hgf-when editing string, set cursor to end */
/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
/*:07-12-1991-15:37-wht@n4hgf-fix core dump when creating phone from setup */
/*:06-09-1991-16:54-jjb-want_pd_create sneak path when not in curses */
/*:06-02-1991-19:43-wht@n4hgf-add dial debug level */
/*:06-02-1991-17:29-wht@n4hgf-move hdb_choose_Any to hdbintf.c */
/*:06-01-1991-23:53-wht@n4hgf-use PDE_..._LEN identifiers */
/*:04-03-1991-14:47-wht@n4hgf-must refresh both windows in terminfo curses */
/*:03-18-1991-21:39-wht@n4hgf-add wrefresh of scrw in up/down */
/*:02-05-1991-14:51-wht@n4hgf-calloc PDE instead of malloc */
/*:01-09-1991-22:31-wht@n4hgf-ISC port */
/*:08-14-1990-20:[email protected] old edit history */
#include "ecucurses.h"
#define STDIO_H_INCLUDED
#define OMIT_TERMIO_REFERENCES
#include "ecu.h"
#include "pc_scr.h"
#include "ecupde.h"
#include "ecukey.h"
#include "ecuxkey.h"
#include "esd.h"
#include "var.h"
WINDOW *window_create();
void dirw_bot_msg();
void dirw_display_phonedir_name();
void dirw_cmd_line_setup();
/* window definitions */
#define DIRW_LINES (LINES - 1)
#define DIRW_COLS 80
#define DIRW_TOP_LINES 2
#define DIRW_BOT_LINES 4
#define DIRW_CMD_LINE (DIRW_LINES - 2)
#define SCRW_LINES (DIRW_LINES - DIRW_TOP_LINES - DIRW_BOT_LINES)
#define SCRW_COLS (DIRW_COLS)
#define SCRW_TLY (DIRW_TOP_LINES)
#define SCRW_TLX 0
#define PDE_ITEM_COUNT 8
#define ADDW_LINES (PDE_ITEM_COUNT + 6)
#ifdef CFG_TelnetOption
#define ADDW_COLS 75
#else
#define ADDW_COLS 65
#endif
#define ADDW_TLY (SCRW_TLY + 1)
#define ADDW_TLX 4
extern int errno;
extern int windows_active;
extern char errmsg[];
extern char kbdintr;
extern char phonedir_name[]; /* phone directory name */
extern char *phonedir_trigger;
extern char *valid_baud_string;
UINT ttygetc();
WINDOW *dirw = 0;
WINDOW *scrw = 0;
WINDOW *addw = 0;
PDE *phdir_list_head = 0; /* pointer to first pde in linked list */
PDE *curr_pde = 0; /* current pde */
PDE *remove_pde = 0; /* if non-zero, pde just removed */
int remove_dirty_flag; /* phdir_list_dirty at remove time */
int phdir_list_quan = 0; /* count of items in list now */
int phdir_list_dirty = 0; /* phdir_list modified but not saved */
int pde_marked_for_redial_count = 0;
int scrw_curr_pde_line; /* scrw line curr_pde is on */
int phonedir_name_x; /* position for phonedir name on screen */
#define NAP_DECISEC_SINGLE_MIN 10
#define NAP_DECISEC_MULTIPLE_MIN 10
int nap_decisec_single = 150;
int nap_decisec_multiple = 50;
#if LOGICAL_LEN > 20
#define LOGICAL_DISP_LEN 20
#else
#define LOGICAL_DISP_LEN LOGICAL_LEN
#endif
/*+-------------------------------------------------------------------------
phdir_list_erase()
--------------------------------------------------------------------------*/
void
phdir_list_erase()
{
PDE *pde = phdir_list_head;
PDE *next;
while (pde)
{
next = pde->next;
free((char *)pde);
pde = next;
}
phdir_list_head = (PDE *) 0;
phdir_list_quan = 0;
curr_pde = (PDE *) 0;
remove_pde = (PDE *) 0;
pde_marked_for_redial_count = 0;
} /* end of phdir_list_erase */
/*+-------------------------------------------------------------------------
phdir_list_set_dirty(flag)
0: clean, 1 dirty, -1 do not modify;update screen only
--------------------------------------------------------------------------*/
void
phdir_list_set_dirty(flag)
int flag;
{
int itmp;
char *modified = " modified ";
if (flag != phdir_list_dirty)
{
if (flag != -1)
phdir_list_dirty = flag;
wmove(dirw, 0, DIRW_COLS - 14);
if (phdir_list_dirty)
{
wstandout(dirw);
waddstr(dirw, modified);
wstandend(dirw);
}
else
{
itmp = strlen(modified);
while (itmp--)
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(dirw, sHR);
#else
waddch(dirw, sHR & 0xFF);
#endif
}
wrefresh(dirw);
}
} /* end of phdir_list_set_dirty */
/*+-------------------------------------------------------------------------
phdir_list_add(tpde) -- add to linked list
--------------------------------------------------------------------------*/
void
phdir_list_add(tpde)
PDE *tpde;
{
PDE *this = tpde;
PDE *prev;
PDE *next;
/* if empty, init list with this one and quit */
if (phdir_list_head == (PDE *) 0)
{
phdir_list_head = this;
this->prev = (PDE *) 0;
this->next = (PDE *) 0;
phdir_list_quan++;
return;
}
/* list not empty */
prev = (PDE *) 0; /* no previous yet */
next = phdir_list_head; /* init next to top of list */
while (strcmp(next->logical, this->logical) < 0)
{
prev = next;
next = prev->next;
if (next == (PDE *) 0)
break;
}
if (prev) /* if non-zero, we will not update the list
* head */
{
/*
* 'this' is to be added to a non-empty list
*/
this->next = prev->next;
this->prev = prev;
prev->next = this;
if (next)
next->prev = this;
}
else
{
/*
* 'this' is to become the new list head (1st element)
*/
this->next = next;
this->prev = (PDE *) 0;
if (next)
next->prev = this;
phdir_list_head = this;
}
phdir_list_quan++;
} /* end of pde_add */
/*+-------------------------------------------------------------------------
phdir_list_remove(tpde) -- remove from linked list
--------------------------------------------------------------------------*/
void
phdir_list_remove(tpde)
PDE *tpde;
{
PDE *prev;
PDE *next;
prev = (PDE *) 0; /* there is no previous now */
if ((next = phdir_list_head) == (PDE *) 0) /* if empty list */
return;
while (next != tpde)
{
prev = next;
next = prev->next;
if (next == (PDE *) 0)
return;
}
/* take care of "current pde" */
if (tpde == curr_pde)
{
if (tpde->next)
curr_pde = tpde->next;
else if (tpde->prev)
curr_pde = tpde->prev;
else
curr_pde = (PDE *) 0;
}
/* marked? */
if (tpde->redial)
{
tpde->redial = 0;
pde_marked_for_redial_count--;
}
/* unlink */
if (prev) /* if non-zero, we will not update the list
* head */
{
prev->next = tpde->next;
if (tpde->next)
(tpde->next)->prev = prev;
}
else
{
phdir_list_head = tpde->next;
if (tpde->next)
(tpde->next)->prev = (PDE *) 0;
}
tpde->next = (PDE *) 0;
tpde->prev = (PDE *) 0;
phdir_list_quan--;
} /* end of phdir_list_remove */
/*+-----------------------------------------------------------------------
PDE *phdir_list_search(logical,exact_flag)
------------------------------------------------------------------------*/
PDE *
phdir_list_search(logical, exact_flag)
char *logical;
int exact_flag;
{
PDE *tpde;
if (!phdir_list_quan)
{
if (phdir_list_read())
return ((PDE *) 0);
}
if (!logical || !*logical)
return ((PDE *) 0);
tpde = phdir_list_head;
while (tpde)
{
/* only first few chars necessary for match with ulcmpb */
if (exact_flag)
{
if (strcmp(tpde->logical, logical) == 0)
return (tpde);
}
else
{
if (ulcmpb(tpde->logical, logical) < 0)
return (tpde);
}
tpde = tpde->next;
}
if (!tpde)
sprintf(errmsg, "'%s' not found", logical);
return (tpde);
} /* end of phdir_list_search */
/*+-------------------------------------------------------------------------
want_pd_create(name)
--------------------------------------------------------------------------*/
int
want_pd_create(name)
char *name;
{
UINT uctmp = XF_not_yet;
if (!dirw)
return (1);
#ifdef COMPILER_BUG_FIXED
dirw_bot_msg("type 'y' or 'n'");
while (uctmp == XF_not_yet)
{
ring_bell();
dirw_cmd_line_setup(name, "does not exist: create?");
uctmp = to_lower(ttygetc(0));
switch (uctmp)
{
case 'y':
uctmp = 1;
break;
case 'n':
uctmp = 0;
break;
default:
uctmp = XF_not_yet;
break;
}
}
dirw_bot_msg("");
return ((int)uctmp);
#else
KROCK:
dirw_bot_msg("type 'y' or 'n'");
ring_bell();
dirw_cmd_line_setup(name, "does not exist: create?");
uctmp = to_lower(ttygetc(0));
dirw_bot_msg("");
switch (uctmp)
{
case 'y':
return (1);
case 'n':
return (0);
}
goto KROCK;
#endif
} /* end of want_pd_create */
/*+-------------------------------------------------------------------------
dirw_display_phonedir_name()
--------------------------------------------------------------------------*/
void
dirw_display_phonedir_name()
{
int itmp, x;
char s80[80];
if (!dirw || !phonedir_name[0])
return;
wmove(dirw, 0, phonedir_name_x);
waddch(dirw, ' ');
strncpy(s80, phonedir_name, itmp = DIRW_COLS - phonedir_name_x - 5);
s80[itmp] = 0;
waddstr(dirw, s80);
waddch(dirw, ' ');
getyx(dirw, itmp, x);
while (x < DIRW_COLS - 1)
{
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(dirw, sHR);
#else
waddch(dirw, sHR & 0xFF);
#endif
x++;
}
} /* end of dirw_display_phonedir_name */
/*+-------------------------------------------------------------------------
dirw_display_config()
--------------------------------------------------------------------------*/
void
dirw_display_config()
{
int y, x;
if (!dirw)
return;
getyx(dirw, y, x);
while (x++ < (DIRW_COLS - 1))
waddch(dirw, sHR);
waddch(dirw, sRT);
if (pde_marked_for_redial_count)
{
wmove(dirw, DIRW_LINES - DIRW_BOT_LINES, 2);
wstandout(dirw);
wprintw(dirw, " REDIAL CYCLE wait: single=%d multiple=%d ",
nap_decisec_single / 10, nap_decisec_multiple / 10);
wmove(dirw, DIRW_LINES - DIRW_BOT_LINES, 56);
wprintw(dirw, " %2d marked entr%s ",
pde_marked_for_redial_count,
(pde_marked_for_redial_count == 1) ? "y" : "ies");
wstandend(dirw);
}
} /* end of dirw_display_config */
/*+-----------------------------------------------------------------------
dirw_display()
00000000001111111111222222222233333333334444444444555555555566666666667777777777
01234567890123456789012345678901234567890123456789012345678901234567890123456789
| entry name | telephone number | tty | baud P | description |
| 0123456789 | 0123456789012345 | 01 | baud P | 01234567890123456789012345678 |
------------------------------------------------------------------------*/
void
dirw_display()
{
if (!dirw)
return;
wmove(dirw, 1, 1);
wstandout(dirw);
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddstr(dirw,
" entry name | telephone number | tty | baud P | description "
);
#else
waddstr(dirw, " entry name ");
#ifdef __FreeBSD__
waddch(dirw, sVR);
#else
waddch(dirw, (unsigned)sVR);
#endif
waddstr(dirw, " telephone number ");
#ifdef __FreeBSD__
waddch(dirw, sVR);
#else
waddch(dirw, (unsigned)sVR);
#endif
waddstr(dirw, " tty ");
#ifdef __FreeBSD__
waddch(dirw, sVR);
#else
waddch(dirw, (unsigned)sVR);
#endif
waddstr(dirw, " baud P ");
#ifdef __FreeBSD__
waddch(dirw, sVR);
#else
waddch(dirw, (unsigned)sVR);
#endif
waddstr(dirw, " description ");
#endif
wstandend(dirw);
dirw_display_phonedir_name();
dirw_display_config();
wrefresh(dirw);
} /* end of dirw_display */
/*+-------------------------------------------------------------------------
dirw_bot_msg(msg)
--------------------------------------------------------------------------*/
void
dirw_bot_msg(msg)
char *msg;
{
int itmp;
int itmp2;
static int last_msglen = 0;
#define DIRW_BOT_LINE_TLX 2
#define DIRW_BOT_LINE_MAX_MSGLEN (DIRW_COLS - DIRW_BOT_LINE_TLX - 8)
char msg2[80];
if (!dirw || (!last_msglen && !strlen(msg)))
return;
wmove(dirw, DIRW_LINES - 1, DIRW_BOT_LINE_TLX);
if ((itmp = strlen(msg)) == 0)
{
itmp2 = last_msglen + 2;
for (itmp = 0; itmp < itmp2; itmp++)
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(dirw, sHR);
#else
waddch(dirw, sHR & 0xFF);
#endif
last_msglen = 0;
}
else
{
waddch(dirw, ' ');
if (itmp > DIRW_BOT_LINE_MAX_MSGLEN)
{
strncpy(msg2, msg, DIRW_BOT_LINE_MAX_MSGLEN + 1);
msg2[DIRW_BOT_LINE_MAX_MSGLEN + 1] = 0;
waddstr(dirw, msg2);
itmp = strlen(msg2);
}
else
{
waddstr(dirw, msg);
itmp = strlen(msg);
}
waddch(dirw, ' ');
if ((itmp2 = last_msglen - itmp) > 0)
{
while (itmp2--)
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(dirw, sHR);
#else
waddch(dirw, sHR & 0xFF);
#endif
}
last_msglen = itmp; /* remember last message length */
}
wrefresh(dirw);
} /* end of dirw_bot_msg */
/*+-------------------------------------------------------------------------
phdir_display_logical(line,tpde,stand_out)
--------------------------------------------------------------------------*/
void
phdir_display_logical(line, tpde, stand_out)
int line;
PDE *tpde;
int stand_out;
{
wmove(scrw, line, 0);
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, sVR & 0xFF);
#endif
if (tpde->redial)
{
wstandout(scrw);
waddch(scrw, '>');
wstandend(scrw);
}
else
waddch(scrw, ' ');
if (stand_out)
wstandout(scrw);
wprintw(scrw, "%-10.10s", tpde->logical);
if (stand_out)
wstandend(scrw);
} /* end of phdir_display_logical */
/*+-----------------------------------------------------------------------
phdir_display(win,line,tpde,stand_out)
00000000001111111111222222222233333333334444444444555555555566666666667777777777
01234567890123456789012345678901234567890123456789012345678901234567890123456789
| entry name | telephone number | tty | baud P | description |
| 0123456789 | 0123456789012345 | 01 | baud P | 01234567890123456789012345678 |
--------------------------------------------------------------------------*/
phdir_display(line, tpde, stand_out)
int line;
PDE *tpde;
int stand_out;
{
phdir_display_logical(line, tpde, stand_out);
waddch(scrw, ' ');
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
waddch(scrw, ' ');
#else
waddch(scrw, (unsigned)sVR);
waddch(scrw, ' ');
#endif
wprintw(scrw, "%-16.16s ", tpde->telno);
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, (unsigned)sVR);
#endif
if (tpde->tty[0])
wprintw(scrw, "%-5.5s", tpde->tty);
else
waddstr(scrw, "Any ");
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, (unsigned)sVR);
#endif
wprintw(scrw, "%6u %c ", tpde->baud,
(tpde->parity) ? to_upper(tpde->parity) : 'N');
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, (unsigned)sVR);
#endif
wprintw(scrw, " %-28.28s ", tpde->descr);
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, (unsigned)sVR);
#endif
return (0);
} /* end of phdir_display */
/*+-----------------------------------------------------------------------
scrw_fill(first_pde,curr_pde_line)
------------------------------------------------------------------------*/
void
scrw_fill(tpde, curr_pde_line)
PDE *tpde;
int *curr_pde_line;
{
int line;
int is_curr_pde;
*curr_pde_line = -1;
for (line = 0; line < SCRW_LINES; line++)
{
if (tpde)
{
if (is_curr_pde = (tpde == curr_pde))
*curr_pde_line = line;
phdir_display(line, tpde, is_curr_pde);
tpde = tpde->next;
}
else
{
wmove(scrw, line, 0);
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, (unsigned)sVR & 0xFF);
#endif
wclrtoeol(scrw);
wmove(scrw, line, SCRW_COLS - 1);
#if defined(SVR4) || defined(SCO32v4) || defined(SCO32v5)
waddch(scrw, sVR);
#else
waddch(scrw, sVR & 0xFF);
#endif
}
}
wrefresh(scrw);
} /* end of scrw_fill */
/*+-------------------------------------------------------------------------
scrw_fill_at(line_num,first_pde,curr_pde_line)
--------------------------------------------------------------------------*/
void
scrw_fill_at(line_num, tpde, curr_pde_line)
int line_num;
PDE *tpde;
int *curr_pde_line;
{
int itmp;
if (!tpde)
{
scrw_fill(tpde, curr_pde_line);
return;
}
for (itmp = 0; itmp < line_num; itmp++)
{
if (!tpde->prev)
break;
tpde = tpde->prev;
}
scrw_fill(tpde, curr_pde_line);
} /* end of scrw_fill_at */
/*+-------------------------------------------------------------------------
dirw_cmd_line_setup(prompt1,prompt2)
--------------------------------------------------------------------------*/
void
dirw_cmd_line_setup(prompt1, prompt2)
char *prompt1;
char *prompt2;
{
int icol;
int y;
int x;
char *cp;
int standout_mode;
wmove(dirw, DIRW_CMD_LINE - 1, 1);
wstandend(dirw);
standout_mode = 0;
waddch(dirw, ' ');
cp = prompt1;
while (*cp)
{
if (*cp == '~')
{
if (standout_mode)
wstandend(dirw);
else
wstandout(dirw);
standout_mode = !standout_mode;
cp++;
}
else
waddch(dirw, *cp++);
}
wstandend(dirw);
standout_mode = 0;
waddch(dirw, ' ');
getyx(dirw, y, x);
for (icol = x; icol < DIRW_COLS - 1; icol++)
waddch(dirw, ' ');
wmove(dirw, DIRW_CMD_LINE, 1);
waddch(dirw, ' ');
cp = prompt2;
while (*cp)
{
if (*cp == '~')
{
if (standout_mode)
wstandend(dirw);
else
wstandout(dirw);
standout_mode = !standout_mode;
cp++;
}
else
waddch(dirw, *cp++);
}
wstandend(dirw);
waddch(dirw, ' ');
getyx(dirw, y, x);
for (icol = x; icol < DIRW_COLS - 1; icol++)
waddch(dirw, ' ');
wmove(dirw, y, x);
wrefresh(scrw);
wrefresh(dirw);
} /* end of dirw_cmd_line_setup */
/*+-------------------------------------------------------------------------
dirw_get_cmd()
--------------------------------------------------------------------------*/
UINT
dirw_get_cmd()
{
UINT cmd;
char setupline1[128]; /* yetch ... avoid source line > 80 chars */
char setupline2[128];
char *setupline1_1 =
"~d~own ~u~p ~PgDn~ ~PgUp~ ~e~dit ~a~dd ~r~emove ~s~ave ~f~ind ";
char *setupline1_2 =
"~c~hange dial dir";
char *setupline2_1 =
"redial: ~m~ark un~M~ark ~U~nmark all ~w~ait between dial ";
char *setupline2_2 =
"~ENTER~:dial ~ESC,q~uit";
strcpy(setupline1, setupline1_1);
strcat(setupline1, setupline1_2);
strcpy(setupline2, setupline2_1);
strcat(setupline2, setupline2_2);
dirw_cmd_line_setup(setupline1, setupline2);
cmd = ttygetc(1);
dirw_bot_msg("");
return (cmd);
} /* end of dirw_get_cmd */
/*+-------------------------------------------------------------------------
field_colon_protect(fieldstr) - change field contents: comma to tilde
--------------------------------------------------------------------------*/
void
field_colon_protect(fieldstr)
char *fieldstr;
{
while (*fieldstr) /* cannot have '~' in description */
{
if (*fieldstr == '~')
*fieldstr = '-';
else if (*fieldstr == ':') /* cvt colon to tilde */
*fieldstr = '~';
fieldstr++;
}
} /* end of field_colon_protect */
/*+-------------------------------------------------------------------------
field_colon_restore(fieldstr) - change field contents: comma to tilde
--------------------------------------------------------------------------*/
void
field_colon_restore(fieldstr)
char *fieldstr;
{
while (*fieldstr) /* cannot have ':' in description */
{ /* should have picked another separator, ... */
if (*fieldstr == '~')/* ... but compatibility is important */
*fieldstr = ':';
fieldstr++;
}
} /* end of field_colon_restore */
/*+-------------------------------------------------------------------------
phdir_cmd_save()
--------------------------------------------------------------------------*/
void
phdir_cmd_save()
{
FILE *fpold;
FILE *fpnew;
PDE *tpde;
char *cp;
char phonedir_ntmp[256]; /* temp phone directory name */
char iobuf[128];
int count = 0;
if (!phdir_list_dirty)
{
dirw_bot_msg("directory has not been modified");
return;
}
strcpy(phonedir_ntmp, phonedir_name);
strcat(phonedir_ntmp, ".t");
if (!(fpnew = fopen(phonedir_ntmp, "w"))) /* open old file */
{
sprintf(iobuf, "cannot open %s", phonedir_ntmp);
dirw_bot_msg(iobuf);
ring_bell();
return;
}
/* write trigger */
fputs(phonedir_trigger, fpnew);
/* retain commented entries */
if ((fpold = fopen(phonedir_name, "r"))) /* open old file */
{
while (fgets(iobuf, sizeof(iobuf), fpold))
{
if ((iobuf[0] == '#') && strcmp(iobuf, phonedir_trigger))
fputs(iobuf, fpnew);
}
fclose(fpold);
}
/* write new entries */
tpde = phdir_list_head;
while (tpde)
{