385
419
wputs(dialwin, "\n");
386
420
wprintf(dialwin, " %s : %s\n", _("Dialing"), d->name);
387
wprintf(dialwin, _(" At : %s\n"), d->number);
421
wprintf(dialwin, _(" At : %s"), d->number);
422
wprintf(dialwin, "\n"); /* help translators */
388
423
if (d->lastdate[0] && d->lasttime[0]) /* jl 26.01.98 */
389
wprintf(dialwin, _(" Last on : %s at %s\n"), d->lastdate, d->lasttime);
391
wprintf(dialwin, "\n");
424
wprintf(dialwin, _(" Last on : %s at %s"), d->lastdate, d->lasttime);
425
wprintf(dialwin, "\n");
392
426
wredraw(dialwin, 1);
394
428
/* Tell keyboard routines we need them. */
395
429
keyboard(KSIGIO, 0);
397
431
maxretries = atoi(P_MRETRIES);
398
if (maxretries <= 0) maxretries = 1;
399
434
rdelay = atoi(P_MRDELAY);
400
if (rdelay < 0) rdelay = 0;
402
438
/* Main retry loop of dial() */
404
while(++retries <= maxretries) {
406
/* See if we need to try the next tagged entry. */
407
if (retries > 1 && (d->flags & FL_TAG)) {
410
if (d == (struct dialent *)NULL) d = dialents;
411
} while(!(d->flags & FL_TAG));
412
wlocate(dialwin, 0, 1);
413
wprintf(dialwin, _(" Dialing : %s"), d->name);
415
wprintf(dialwin, _("\n At : %s"), d->number);
417
if (d->lastdate[0] && d->lasttime[0]) {
418
wprintf(dialwin, _("\n Last on : %s at %s"),
419
d->lastdate, d->lasttime);
424
/* Calculate dial time */
425
dialtime = atoi(P_MDIALTIME);
426
if (dialtime == 0) dialtime = 45;
431
wlocate(dialwin, 0, 4);
432
wprintf(dialwin, _(" Time : %-3d"), dialtime);
433
if (maxretries > 1) wprintf(dialwin, _(" Attempt #%d"), retries);
434
wputs(dialwin, _("\n\n\n Escape to cancel, space to retry."));
438
switch(d->dialtype) {
440
mputs(P_MDIALPRE, 0);
442
mputs(P_MDIALSUF, 0);
445
mputs(P_MDIALPRE2, 0);
447
mputs(P_MDIALSUF2, 0);
450
mputs(P_MDIALPRE3, 0);
452
mputs(P_MDIALSUF3, 0);
456
/* Wait 'till the modem says something */
461
while(dialtime > 0) {
463
x = check_io(portfd_connected, 0, 1000, buf, NULL);
467
f = keyboard(KGETKEY, 0);
468
/* Cancel if escape was pressed. */
469
if (f == K_ESC) mputs(P_MDIALCAN, 0);
471
/* On space retry. */
473
mputs(P_MDIALCAN, 0);
474
dialfailed(_("Cancelled"), 4);
478
(void) keyboard(KSTOP, 0);
483
/* Data available from the modem. Put in buffer. */
484
if (*s == '\r' || *s == '\n') {
485
/* We look for [\r\n]STRING[\r\n] */
488
} else if (modidx < 127) {
489
/* Normal character. Add. */
490
modbuf[modidx++] = *s;
493
/* Skip to next received char */
495
/* Only look when we got a whole line. */
497
!strncmp(modbuf, P_MCONNECT, strlen(P_MCONNECT))) {
498
timer_update(); /* the login scipt may take long.. */
500
/* Try to do auto-bauding */
501
if (sscanf(modbuf + strlen(P_MCONNECT), "%ld", &nb) == 1)
505
/* Try to figure out if this system supports DCD */
506
f = m_getdcd(portfd);
509
/* jl 22.05.97, 22.09.97, 05.04.99 */
510
if (P_LOGCONN[0] == 'Y')
511
do_log("%s %s, %s",modbuf, d->name, d->number);
513
ptime=localtime(&now);
514
sprintf(d->lastdate,"%4.4d%2.2d%2.2d",
515
(ptime->tm_year)+1900,(ptime->tm_mon)+1,
517
sprintf(d->lasttime,"%02d:%02d",
518
ptime->tm_hour,ptime->tm_min);
522
if (d->convfile[0]) {
523
loadconv(d->convfile); /* jl 21.09.97 */
524
strcpy(P_CONVF, d->convfile);
528
wlocate(dialwin, 1, 7);
529
if (d->script[0] == 0) {
531
_("Connected. Press any key to continue"));
533
if (P_SOUND[0] == 'Y')
536
x = check_io(-1, 0, 0, NULL, NULL);
538
(void) keyboard(KGETKEY, 0);
440
while (++retries <= maxretries) {
442
/* See if we need to try the next tagged entry. */
443
if (retries > 1 && (d->flags & FL_TAG)) {
446
if (d == (struct dialent *)NULL)
448
} while (!(d->flags & FL_TAG));
449
wlocate(dialwin, 0, 1);
450
wprintf(dialwin, " %s : %s", _("Dialing"), d->name);
452
wprintf(dialwin, "\n"); /* helps translators */
453
wprintf(dialwin, _(" At : %s"), d->number);
455
if (d->lastdate[0] && d->lasttime[0]) {
456
wprintf(dialwin, "\n"); /* don't merge with next printf, helps translators */
457
wprintf(dialwin, _(" Last on : %s at %s"),
458
d->lastdate, d->lasttime);
463
/* Calculate dial time */
464
dialtime = atoi(P_MDIALTIME);
471
wlocate(dialwin, 0, 4);
472
wprintf(dialwin, _(" Time : %-3d"), dialtime);
474
wprintf(dialwin, _(" Attempt #%d"), retries);
475
wputs(dialwin, _("\n\n\n Escape to cancel, space to retry."));
479
switch (d->dialtype) {
481
mputs(P_MDIALPRE, 0);
483
mputs(P_MDIALSUF, 0);
486
mputs(P_MDIALPRE2, 0);
488
mputs(P_MDIALSUF2, 0);
491
mputs(P_MDIALPRE3, 0);
493
mputs(P_MDIALSUF3, 0);
497
/* Wait 'till the modem says something */
502
while (dialtime > 0) {
504
x = check_io(portfd_connected, 0, 1000, buf, NULL);
508
f = keyboard(KGETKEY, 0);
509
/* Cancel if escape was pressed. */
511
mputs(P_MDIALCAN, 0);
513
/* On space retry. */
515
mputs(P_MDIALCAN, 0);
516
dialfailed(_("Cancelled"), 4);
525
/* Data available from the modem. Put in buffer. */
526
if (*s == '\r' || *s == '\n') {
527
/* We look for [\r\n]STRING[\r\n] */
530
} else if (modidx < 127) {
531
/* Normal character. Add. */
532
modbuf[modidx++] = *s;
535
/* Skip to next received char */
538
/* Only look when we got a whole line. */
540
!strncmp(modbuf, P_MCONNECT, strlen(P_MCONNECT))) {
541
timer_update(); /* the login scipt may take long.. */
543
/* Try to do auto-bauding */
544
if (sscanf(modbuf + strlen(P_MCONNECT), "%ld", &nb) == 1)
548
/* Try to figure out if this system supports DCD */
549
f = m_getdcd(portfd);
552
/* jl 22.05.97, 22.09.97, 05.04.99 */
553
if (P_LOGCONN[0] == 'Y')
554
do_log("%s %s, %s",modbuf, d->name, d->number);
556
ptime = localtime(&now);
557
sprintf(d->lastdate,"%4.4d%2.2d%2.2d",
558
(ptime->tm_year)+1900,(ptime->tm_mon)+1,
560
sprintf(d->lasttime,"%02d:%02d",
561
ptime->tm_hour,ptime->tm_min);
564
if (d->convfile[0]) {
565
loadconv(d->convfile); /* jl 21.09.97 */
566
strcpy(P_CONVF, d->convfile);
569
wlocate(dialwin, 1, 7);
570
if (d->script[0] == 0) {
572
_("Connected. Press any key to continue"));
574
if (P_SOUND[0] == 'Y')
577
x = check_io(-1, 0, 0, NULL, NULL);
579
keyboard(KGETKEY, 0);
541
/* MARK updated 02/17/94 - If VC_MUSIC is not */
542
/* defined, then at least make some beeps! */
543
if (P_SOUND[0] == 'Y')
544
wputs(dialwin,"\007\007\007");
582
/* MARK updated 02/17/94 - If VC_MUSIC is not */
583
/* defined, then at least make some beeps! */
584
if (P_SOUND[0] == 'Y')
585
wputs(dialwin,"\007\007\007");
546
x = check_io(-1, 0, 0, NULL, NULL);
548
(void) keyboard(KGETKEY, 0);
552
/* Print out the connect strings. */
553
wprintf(us, "\r\n%s\r\n", modbuf);
556
/* Un-tag this entry. */
559
/* store pointer to the entry that ANSWERED */
560
if (d2 != (struct dialent**)NULL)
561
*d2 = d; /* jl 23.09.97 */
563
/* Here should placed code to untag phones with similar names */
564
if (P_MULTILINE[0] == 'Y') {
569
while (d3 != (struct dialent*)NULL) {
570
if (!strcmp(d3->name, d->name))
571
d3->flags &= ~FL_TAG;
579
for(f = 0; f < 3; f++) {
580
if (f == 0) t = P_MNOCON1;
581
if (f == 1) t = P_MNOCON2;
582
if (f == 2) t = P_MNOCON3;
583
if (f == 3) t = P_MNOCON4;
584
if ((*t) && (!strncmp(modbuf, t, strlen(t)))) {
585
if (retries < maxretries) {
586
x = dialfailed(t, rdelay);
593
if (maxretries == 1) reason = t;
599
/* Do timer routines here. */
602
dialtime -= (now - last);
603
if (dialtime < 0) dialtime = 0;
604
wlocate(dialwin, 11, 4);
605
wprintf(dialwin, "%-3d ", dialtime);
607
mputs(P_MDIALCAN, 0);
608
reason = _("Timeout");
610
if (retries < maxretries) {
611
x = dialfailed(reason, rdelay);
587
x = check_io(-1, 0, 0, NULL, NULL);
589
keyboard(KGETKEY, 0);
593
/* Print out the connect strings. */
594
wprintf(us, "\r\n%s\r\n", modbuf);
597
/* Un-tag this entry. */
600
/* store pointer to the entry that ANSWERED */
601
if (d2 != (struct dialent**)NULL)
602
*d2 = d; /* jl 23.09.97 */
604
/* Here should placed code to untag phones with similar names */
605
if (P_MULTILINE[0] == 'Y') {
606
struct dialent *d3 = dialents;
608
while (d3 != (struct dialent*)NULL) {
609
if (!strcmp(d3->name, d->name))
610
d3->flags &= ~FL_TAG;
617
for (f = 0; f < 3; f++) {
626
if ((*t) && (!strncmp(modbuf, t, strlen(t)))) {
627
if (retries < maxretries) {
628
x = dialfailed(t, rdelay);
642
/* Do timer routines here. */
645
dialtime -= (now - last);
648
wlocate(dialwin, 11, 4);
649
wprintf(dialwin, "%-3d ", dialtime);
651
mputs(P_MDIALCAN, 0);
652
reason = _("Timeout");
654
if (retries < maxretries) {
655
x = dialfailed(reason, rdelay);
622
666
} /* End of main while cq MainLoop */
623
667
dialfailed(reason, -1);
624
668
keyboard(KSTOP, 0);
625
669
wclose(dialwin, 1);
630
674
* Create an empty entry.
632
static struct dialent *mkstdent()
676
static struct dialent *mkstdent(void)
636
d = (struct dialent *)malloc(sizeof (struct dialent));
638
if (d == (struct dialent *)0) return(d);
678
struct dialent *d = (struct dialent *)malloc(sizeof (struct dialent));
680
if (d == (struct dialent *)0)
641
684
d->number[0] = 0;
772
806
/* Try to open ~/.dialdir */
773
807
if ((fp = sfopen(dfile, "r")) == (FILE *)NULL) {
774
if (errno == EPERM) {
775
werror(_("Cannot open ~/.dialdir: permission denied"));
776
dialents = mkstdent();
780
dialents = mkstdent();
808
if (errno == EPERM) {
809
werror(_("Cannot open ~/.dialdir: permission denied"));
810
dialents = mkstdent();
814
dialents = mkstdent();
784
818
/* Get size of the file */
785
819
fseek(fp, 0L, SEEK_END);
786
820
size = ftell(fp);
788
dialents = mkstdent();
822
dialents = mkstdent();
793
827
/* Get version of the dialing directory */
794
828
fseek(fp, 0L, SEEK_SET);
795
829
fread(&dial_ver, sizeof(dial_ver), 1, fp);
796
830
if (dial_ver.magic != DIALMAGIC) {
797
/* First version without version info. */
798
dial_ver.version = 0;
799
fseek(fp, 0L, SEEK_SET);
831
/* First version without version info. */
832
dial_ver.version = 0;
833
fseek(fp, 0L, SEEK_SET);
801
size -= sizeof(dial_ver);
835
size -= sizeof(dial_ver);
803
837
/* See if the size of the file is allright. */
804
switch(dial_ver.version) {
807
dial_ver.size = sizeof(struct v1_dialent);
811
dial_ver.size = sizeof(struct v3_dialent);
814
/* dial_ver.size = sizeof(struct dialent); */
815
/* Removed the forced setting to add flexibility.
816
* Now you don't need to change the version number
817
* if you just add fields to the end of the dialent structure
818
* before the *next pointer and don't change existing fields.
819
* Just update the initialization in the functions
820
* v4_read and mkstdent (and whatever you added the field for)
823
if (dial_ver.size < 200 ||
824
dial_ver.size > sizeof(struct dialent)) {
825
werror(_("Phonelist garbled (unknown version?)"));
827
dialents = mkstdent();
832
werror(_("Unknown dialing directory version"));
834
dialents = mkstdent();
838
switch (dial_ver.version) {
841
dial_ver.size = sizeof(struct v1_dialent);
845
dial_ver.size = sizeof(struct v3_dialent);
848
/* dial_ver.size = sizeof(struct dialent); */
849
/* Removed the forced setting to add flexibility.
850
* Now you don't need to change the version number
851
* if you just add fields to the end of the dialent structure
852
* before the *next pointer and don't change existing fields.
853
* Just update the initialization in the functions
854
* v4_read and mkstdent (and whatever you added the field for)
857
if (dial_ver.size < 200 ||
858
dial_ver.size > sizeof(struct dialent)) {
859
werror(_("Phonelist garbled (unknown version?)"));
861
dialents = mkstdent();
866
werror(_("Unknown dialing directory version"));
868
dialents = mkstdent();
838
872
if (size % dial_ver.size != 0) {
839
werror(_("Phonelist garbled (?)"));
842
dialents = mkstdent();
873
werror(_("Phonelist garbled (?)"));
876
dialents = mkstdent();
846
880
/* Read in the dialing entries */
847
881
nrents = size / dial_ver.size;
848
882
if (nrents == 0) {
849
dialents = mkstdent();
883
dialents = mkstdent();
854
888
for(f = 1; f <= nrents; f++) {
855
if ((d = (struct dialent *)malloc(sizeof (struct dialent))) ==
856
(struct dialent *)0) {
858
dialents = mkstdent();
860
prev->next = (struct dialent *)0;
862
werror(_("Out of memory while reading dialing directory"));
866
switch(dial_ver.version) {
880
v4_read(fp, d, &dial_ver);
883
/* MINIX terminal type is obsolete */
884
if (d->term == 2) d->term = 1;
886
if (prev != (struct dialent *)0)
889
if ((d = (struct dialent *)malloc(sizeof (struct dialent))) ==
890
(struct dialent *)0) {
892
dialents = mkstdent();
894
prev->next = (struct dialent *)0;
896
werror(_("Out of memory while reading dialing directory"));
900
switch (dial_ver.version) {
914
v4_read(fp, d, &dial_ver);
917
/* MINIX terminal type is obsolete */
921
if (prev != (struct dialent *)0)
892
927
d->next = (struct dialent *)0;
894
929
if (dial_ver.size < sizeof(struct dialent)) {
895
930
if (snprintf(copycmd,sizeof(copycmd),
896
"cp %s %s.%hd",dfile,dfile,dial_ver.size) > 0) {
931
"cp %s %s.%hd",dfile,dfile,dial_ver.size) > 0) {
897
932
if (P_LOGFNAME[0] != 0)
898
do_log("%s", copycmd);
933
do_log("%s", copycmd);
899
934
if (system(copycmd) == 0) {
900
snprintf(copycmd,sizeof(copycmd),
901
_("Old dialdir copied as %s.%hd"),dfile,dial_ver.size);
902
w=mc_tell("%s", copycmd);
935
snprintf(copycmd,sizeof(copycmd),
936
_("Old dialdir copied as %s.%hd"),dfile,dial_ver.size);
937
w = mc_tell("%s", copycmd);
915
950
* Write the new $HOME/.dialdir
917
static void writedialdir()
952
static void writedialdir(void)
919
954
struct dialent *d;
968
1008
* Get entry "no" in list.
970
static struct dialent *getno(no)
1010
static struct dialent *getno(int no)
973
1012
struct dialent *d;
977
if (no >= nrents) return((struct dialent *)NULL);
979
while(no--) d = d->next;
1016
if (no < 0 || no >= nrents)
1017
return (struct dialent *)NULL;
983
1025
/* Note: Minix does not exist anymore. */
984
static char *te[] = { "VT102", "MINIX", "ANSI " };
1026
static const char *te[] = { "VT102", "MINIX", "ANSI " };
1029
* Display a "dedit" entry
1030
* We need to make sure that the previous value
1031
* gets fully overwritten in all languages (i.e. arbitrary strings)!
1033
static void dedit_toggle_entry(WIN *w, int x, int y, int toggle,
1034
char *toggle_true, char *toggle_false)
1036
int lt = mbslen(toggle_true);
1037
int lf = mbslen(toggle_false);
1038
int l = ((lt > lf) ? lt : lf) + 1;
1039
char *buf, *s = toggle ? toggle_true : toggle_false;
1042
if (!(buf = alloca(l)))
1046
for (i = mbslen(s); i < l - 1; i++)
987
1055
* Edit an entry.
1057
static void dedit(struct dialent *d)
994
char* name = _(" A - Name :"),
995
* number = _(" B - Number :"),
996
* dial_string = _(" C - Dial string # :"),
997
* local_echo = _(" D - Local echo :"),
998
* script = _(" E - Script :"),
999
* username = _(" F - Username :"),
1000
* password = _(" G - Password :"),
1001
* terminal_emulation = _(" H - Terminal Emulation :"),
1002
* backspace_key_sends = _(" I - Backspace key sends :"),
1003
* linewrap = _(" J - Linewrap :"),
1004
* line_settings = _(" K - Line Settings :"),
1005
* conversion_table = _(" L - Conversion table :"),
1006
* question = _("Change which setting?");
1061
char *name = _(" A - Name :"),
1062
*number = _(" B - Number :"),
1063
*dial_string = _(" C - Dial string # :"),
1064
*local_echo = _(" D - Local echo :"),
1065
*script = _(" E - Script :"),
1066
*username = _(" F - Username :"),
1067
*password = _(" G - Password :"),
1068
*terminal_emulation = _(" H - Terminal Emulation :"),
1069
*backspace_key_sends = _(" I - Backspace key sends :"),
1070
*linewrap = _(" J - Linewrap :"),
1071
*line_settings = _(" K - Line Settings :"),
1072
*conversion_table = _(" L - Conversion table :"),
1073
*question = _("Change which setting?");
1008
1075
w = wopen(5, 4, 75, 19, BDOUBLE, stdattr, mfcolor, mbcolor, 0, 0, 1);
1009
1076
wprintf(w, "%s %s\n", name, d->name);
1027
1094
wputs(w, question);
1031
wlocate(w, strlen (question) + 5, 15);
1033
if (c >= 'a') c -= 32;
1041
wlocate(w, strlen (name) + 1, 0);
1042
(void) wgets(w, d->name, 31, 32);
1045
wlocate(w, strlen (number) + 1, 1);
1046
(void) wgets(w, d->number, 31, 32);
1049
d->dialtype = (d->dialtype + 1) % 3;
1050
wlocate(w, strlen (dial_string) + 1, 2);
1051
wprintf(w, "%d", d->dialtype + 1);
1055
d->flags ^= FL_ECHO;
1056
wlocate(w, strlen (local_echo) + 1, 3);
1057
wprintf(w, "%s", _(yesno(d->flags & FL_ECHO)));
1061
wlocate(w, strlen (script) + 1, 4);
1062
(void) wgets(w, d->script, 31, 32);
1065
wlocate(w, strlen (username) + 1, 5);
1066
(void) wgets(w, d->username, 31, 32);
1069
wlocate(w, strlen (password) + 1, 6);
1070
(void) wgets(w, d->password, 31, 32);
1073
d->term = (d->term % 3) + 1;
1074
/* MINIX == 2 is obsolete. */
1075
if (d->term == 2) d->term = 3;
1076
wlocate(w, strlen (terminal_emulation) + 1, 7);
1077
wputs(w, te[d->term - 1]);
1098
wlocate(w, mbslen (question) + 5, 15);
1109
wlocate(w, mbslen (name) + 1, 0);
1110
wgets(w, d->name, 31, 32);
1113
wlocate(w, mbslen (number) + 1, 1);
1114
wgets(w, d->number, 31, 32);
1117
d->dialtype = (d->dialtype + 1) % 3;
1118
wlocate(w, mbslen (dial_string) + 1, 2);
1119
wprintf(w, "%d", d->dialtype + 1);
1123
d->flags ^= FL_ECHO;
1124
wlocate(w, mbslen (local_echo) + 1, 3);
1125
wprintf(w, "%s", _(yesno(d->flags & FL_ECHO)));
1129
wlocate(w, mbslen (script) + 1, 4);
1130
wgets(w, d->script, 31, 32);
1133
wlocate(w, mbslen (username) + 1, 5);
1134
wgets(w, d->username, 31, 32);
1137
wlocate(w, mbslen (password) + 1, 6);
1138
wgets(w, d->password, 31, 32);
1141
d->term = (d->term % 3) + 1;
1142
/* MINIX == 2 is obsolete. */
1145
wlocate(w, mbslen (terminal_emulation) + 1, 7);
1146
wputs(w, te[d->term - 1]);
1079
/* Also set backspace key. */
1080
if (d->term == ANSI) {
1081
d->flags &= ~FL_DEL;
1082
d->flags |= FL_WRAP;
1084
d->flags &= ~FL_WRAP;
1087
wlocate(w, strlen (backspace_key_sends) + 1, 8);
1088
wputs(w, d->flags & FL_DEL ? _("Delete ") : _("Backspace"));
1089
wlocate(w, strlen (linewrap) + 1, 9);
1090
wputs(w, d->flags & FL_WRAP ? _("On ") : _("Off"));
1094
wlocate(w, strlen (backspace_key_sends) + 1, 8);
1095
wputs(w, d->flags & FL_DEL ? _("Delete ") : _("Backspace"));
1098
d->flags ^= FL_WRAP;
1099
wlocate(w, strlen (linewrap) + 1, 9);
1100
wputs(w, d->flags & FL_WRAP ? _("On ") : _("Off"));
1103
get_bbp(d->baud, d->bits, d->parity, d->stopb, 1);
1104
wlocate(w, strlen (line_settings) + 1, 10);
1105
wprintf(w, "%s %s%s%s ",
1106
d->baud, d->bits, d->parity, d->stopb);
1108
case 'L': /* jl 21.09.97 */
1109
wlocate(w, strlen (conversion_table) + 1, 11);
1110
(void) wgets(w, d->convfile, 15, 16);
1148
/* Also set backspace key. */
1149
if (d->term == ANSI) {
1150
d->flags &= ~FL_DEL;
1151
d->flags |= FL_WRAP;
1154
d->flags &= ~FL_WRAP;
1156
dedit_toggle_entry(w, mbslen(backspace_key_sends) + 1, 8,
1157
d->flags & FL_DEL, _("Delete"), _("Backspace"));
1158
dedit_toggle_entry(w, mbslen(linewrap) + 1, 9,
1159
d->flags & FL_WRAP, _("On"), _("Off"));
1163
dedit_toggle_entry(w, mbslen(backspace_key_sends) + 1, 8,
1164
d->flags & FL_DEL, _("Delete"), _("Backspace"));
1167
d->flags ^= FL_WRAP;
1168
dedit_toggle_entry(w, mbslen(linewrap) + 1, 9,
1169
d->flags & FL_WRAP, _("On"), _("Off"));
1172
get_bbp(d->baud, d->bits, d->parity, d->stopb, 1);
1173
wlocate(w, mbslen (line_settings) + 1, 10);
1174
wprintf(w, "%s %s%s%s ",
1175
d->baud, d->bits, d->parity, d->stopb);
1177
case 'L': /* jl 21.09.97 */
1178
wlocate(w, mbslen (conversion_table) + 1, 11);
1179
wgets(w, d->convfile, 15, 16);
1118
1187
static WIN *dsub;
1120
N_(" Dial Find Add Edit Remove moVe Manual ");
1121
/* 12345678901234567890123456789012345678901234567890123456
1188
static const char *const what[] =
1190
/* TRANSLATORS: Translation of each of these menu items should not be
1191
* longer than 7 characters. The upper-case letter is a shortcut,
1192
* so keep them unique and ASCII; 'h', 'j', 'k', 'l' are reserved */
1193
N_("Dial"), N_("Find"), N_("Add"), N_("Edit"), N_("Remove"), N_("moVe"),
1196
/* Offsets of what[] entries from position_dialing_directory */
1197
#define DIALOPTS (sizeof(what) / sizeof(*what))
1198
#define DIAL_WIDTH 8 /* Width of one entry */
1199
static size_t what_lens[DIALOPTS]; /* Number of bytes for <= 7 characters */
1200
/* Number of ' ' padding entries at left and right, left is >= 1 */
1201
static int what_padding[DIALOPTS][2];
1123
1203
static int dprev;
1124
#define DIALOPTS 7 /* Number of commands in vertical dial menu */
1205
/* Draw an entry in the horizontal menu */
1206
static void horiz_draw(size_t k)
1208
static const char spaces[] = " ";
1210
wprintf(dsub, "%.*s", what_padding[k][0], spaces);
1211
wprintf(dsub, "%.*s", what_lens[k], _(what[k]));
1212
wprintf(dsub, "%.*s", what_padding[k][1], spaces);
1127
1216
* Highlight a choice in the horizontal menu.
1129
static void dhili(position_dialing_directory, k)
1130
int position_dialing_directory, k;
1218
static void dhili(int position_dialing_directory, int k)
1132
/* acme@conectiva.com.br 28/02/1998
1133
hack to make i18n strings work with _this_ hack ;> :
1134
the i18n string must have a options with the same size (padded
1135
with spaces... I only hope the translations are smart enough to
1136
figure this out... ;> */
1138
int option_size = strlen (_(what)) / DIALOPTS;
1140
if (k == dprev) return;
1142
1223
if (dprev >= 0) {
1143
wlocate(dsub, position_dialing_directory + option_size * dprev, 0);
1148
wsetattr(dsub, XA_REVERSE | stdattr);
1149
wprintf(dsub, "%*.*s", option_size, option_size, _(what) + option_size * dprev);
1224
wlocate(dsub, position_dialing_directory + DIAL_WIDTH * dprev, 0);
1228
wsetattr(dsub, XA_REVERSE | stdattr);
1153
wlocate(dsub, position_dialing_directory + option_size * k, 0);
1233
wlocate(dsub, position_dialing_directory + DIAL_WIDTH * k, 0);
1154
1234
if (!useattr) {
1157
wsetattr(dsub, stdattr);
1158
wprintf(dsub, "%*.*s", option_size, option_size, _(what) + option_size * k);
1237
wsetattr(dsub, stdattr);
1163
static char *fmt = "\r %2d %c%-16.16s%-16.16s%8.8s %5.5s %4d %-15.15s\n";
1242
static const char *fmt = "\r %2d %c%-16.16s%-16.16s%8.8s %5.5s %4d %-15.15s\n";
1166
1245
* Print the dialing directory. Only draw from "cur" to bottom.
1168
static void prdir(dialw, top, cur)
1247
static void prdir(WIN *dialw, int top, int cur)
1173
1250
struct dialent *d;
1247
1324
/* First remove cursor bar from the old position */
1248
1325
wcurbar(dialw, ocur + 1 - *top, XA_NORMAL | stdattr);
1249
1326
if (cur < *top)
1251
1328
else if (cur - *top > dialw->ys - 3)
1253
1330
prdir(dialw, *top, *top);
1254
1331
wcurbar(dialw, cur + 1 - *top, XA_REVERSE | stdattr);
1256
1333
} /* end redraw condition */
1258
1334
} /* end loop */
1263
1339
/* Little menu. */
1264
static char *d_yesno[] = { N_(" Yes "), N_(" No "), CNULL };
1340
static const char *d_yesno[] = { N_(" Yes "), N_(" No "), NULL };
1266
1342
/* Try to dial an entry. */
1267
static void dial_entry(d)
1343
static void dial_entry(struct dialent *d)
1271
1346
struct dialent *d2;
1273
1348
/* Change settings for this entry. */
1274
1349
if (atoi(d->baud) != 0) {
1275
strcpy(P_BAUDRATE, d->baud);
1276
strcpy(P_PARITY, d->parity);
1277
strcpy(P_BITS, d->bits);
1278
strcpy(P_STOPB, d->stopb);
1350
strcpy(P_BAUDRATE, d->baud);
1351
strcpy(P_PARITY, d->parity);
1352
strcpy(P_BITS, d->bits);
1353
strcpy(P_STOPB, d->stopb);
1282
1357
newtype = d->term;
1283
1358
vt_set(-1, d->flags & FL_WRAP, NULL, -1, -1, d->flags & FL_ECHO, -1, -1);
1285
1359
local_echo = d->flags & FL_ECHO;
1287
1360
if (newtype != terminal)
1288
init_emul(newtype, 1);
1361
init_emul(newtype, 1);
1290
1363
/* Set backspace key. */
1291
1364
keyboard(KSETBS, d->flags & FL_DEL ? 127 : 8);
1292
1365
strcpy(P_BACKSPACE, d->flags & FL_DEL ? "DEL" : "BS");
1294
1367
/* Now that everything has been set, dial. */
1295
if ((nb = dial(d, &d2)) < 0) return;
1368
if ((nb = dial(d, &d2)) < 0)
1297
1371
if (d2 != (struct dialent *)NULL)
1298
1372
d = d2; /* jl 22.09.97 */
1300
1374
/* Did we detect a baudrate , and can we set it? */
1301
1375
if (P_MAUTOBAUD[0] == 'Y' && nb) {
1302
sprintf(P_BAUDRATE, "%ld", nb);
1306
else if (P_SHOWSPD[0] == 'l')
1376
sprintf(P_BAUDRATE, "%ld", nb);
1379
} else if (P_SHOWSPD[0] == 'l')
1309
1382
/* Make sure the last date is updated / jl 22.06.97 */
1310
1383
writedialdir();
1312
1385
/* Run script if needed. */
1313
if (d->script[0]) runscript(0, d->script, d->username, d->password);
1387
runscript(0, d->script, d->username, d->password);
1315
1389
/* Remember _what_ we dialed.. */
1316
1390
dial_name = d->name;
1317
1391
dial_number = d->number;
1318
1392
dial_user = d->username;
1319
1393
dial_pass = d->password;
1385
1460
char *s, dname[128];
1386
1461
static char manual[128];
1387
1462
int changed = 0;
1388
static char *tag_exit = N_("( Escape to exit, Space to tag )"),
1389
*move_exit = N_(" Move entry up/down, Escape to exit");
1463
static const char *tag_exit = N_("( Escape to exit, Space to tag )"),
1464
*move_exit = N_(" Move entry up/down, Escape to exit");
1390
1465
unsigned int tagmvlen = 0;
1391
int position_dialing_directory = ((COLS / 2) + 32 - strlen (_(what))) / 2;
1467
int position_dialing_directory = ((COLS / 2) + 32 - DIALOPTS * DIAL_WIDTH) / 2;
1395
1471
tagmvlen = strlen(_(move_exit));
1396
1472
if (strlen(_(tag_exit)) > tagmvlen)
1397
tagmvlen = strlen(_(tag_exit));
1473
tagmvlen = strlen(_(tag_exit));
1399
1475
/* Allright, draw the dialing directory! */
1402
1478
x1 = (COLS / 2) - 37;
1403
1479
x2 = (COLS / 2) + 37;
1404
dsub = wopen(x1 - 1, LINES - 3, x2 + 1, LINES - 3, BNONE,
1405
XA_REVERSE | stdattr, mfcolor, mbcolor, 0, 0, 1);
1480
dsub = wopen(x1 - 1, LINES - 3, x2 + 1, LINES - 3, BNONE,
1481
XA_REVERSE | stdattr, mfcolor, mbcolor, 0, 0, 1);
1406
1482
w = wopen(x1, 2, x2, LINES - 6, BSINGLE, stdattr, mfcolor, mbcolor, 0, 0, 1);
1407
1483
wcursor(w, CNONE);
1408
1484
wtitle(w, TMID, _("Dialing Directory"));
1410
_(" Name Number Last on Times Script\n"));
1486
_(" Name Number Last on Times Script\n"));
1487
for (i = 0; i < DIALOPTS; i++) {
1488
const char *str, *c;
1493
for (j = 0; j < DIAL_WIDTH - 1 && *c != 0; j++) {
1495
c += one_mbtowc(&wc, c, MB_LEN_MAX);
1497
what_lens[i] = c - str;
1498
j = DIAL_WIDTH - j; /* Characters left for padding */
1499
what_padding[i][1] = j / 2; /* Rounding down */
1500
what_padding[i][0] = j - what_padding[i][1]; /* >= 1 */
1411
1502
wlocate(dsub, position_dialing_directory, 0);
1412
wputs(dsub, _(what));
1503
for (i = 0; i < DIALOPTS; i++)
1414
1506
wsetregion(w, 1, w->ys - 1);
1415
1507
w->doscroll = 0;
1418
1510
wlocate(w, position_dialing_directory, w->ys - 1);
1419
1511
wprintf(w, "%*.*s", tagmvlen,tagmvlen, tag_exit);
1420
1512
dhili(position_dialing_directory, subm);
1422
1514
wredraw(dsub, 1);
1425
1517
wcurbar(w, cur + 1 - top, XA_REVERSE | stdattr);
1432
switch(c = wxgetch()) {
1439
cur += (cur < nrents - 1);
1444
if (subm < 0) subm = DIALOPTS - 1;
1448
subm = (subm + 1) % DIALOPTS;
1451
case '\002': /* Control-B */
1456
case '\006': /* Control-F */
1460
case 'd': /* Dial. */
1464
case 'f': /* Find. */
1468
case 'a': /* Add. */
1472
case 'e': /* Edit. */
1476
case 'r': /* Remove. */
1480
case 'v': /* moVe entry */
1484
case 'm': /* Manual. */
1488
case ' ': /* Tag. */
1489
wlocate(w, 4, cur + 1 - top);
1491
wsetattr(w, XA_REVERSE | stdattr);
1492
wprintf(w, "%c", d->flags & FL_TAG ? '>' : ' ');
1493
wsetattr(w, XA_NORMAL | stdattr);
1494
cur += (cur < nrents - 1);
1499
quit = (subm==5 ? 2 : 1);
1504
/* Decide if we have to delete the cursor bar */
1505
if (cur != ocur || quit == 1)
1506
wcurbar(w, ocur + 1 - top, XA_NORMAL | stdattr);
1512
if (cur - top > w->ys - 3) {
1516
if (cur != ocur) wcurbar(w, cur + 1 - top, XA_REVERSE | stdattr);
1518
dhili(position_dialing_directory, subm);
1524
switch (c = wxgetch()) {
1531
cur += (cur < nrents - 1);
1537
subm = DIALOPTS - 1;
1541
subm = (subm + 1) % DIALOPTS;
1544
case '\002': /* Control-B */
1549
case '\006': /* Control-F */
1553
case ' ': /* Tag. */
1554
wlocate(w, 4, cur + 1 - top);
1556
wsetattr(w, XA_REVERSE | stdattr);
1557
wprintf(w, "%c", d->flags & FL_TAG ? '>' : ' ');
1558
wsetattr(w, XA_NORMAL | stdattr);
1559
cur += (cur < nrents - 1);
1565
quit = (subm == 5 ? 2 : 1);
1568
for (i = 0; i < DIALOPTS; i++) {
1569
if (strchr(_(what[i]), toupper(c)) != NULL) {
1576
/* Decide if we have to delete the cursor bar */
1577
if (cur != ocur || quit == 1)
1578
wcurbar(w, ocur + 1 - top, XA_NORMAL | stdattr);
1584
if (cur - top > w->ys - 3) {
1589
wcurbar(w, cur + 1 - top, XA_REVERSE | stdattr);
1591
dhili(position_dialing_directory, subm);
1521
1594
/* ESC means quit */
1522
1595
if (c == '\033') {
1523
if (changed) writedialdir();
1528
1602
/* Page up or down ? */
1529
1603
if (pgud == 1) { /* Page up */
1532
if (top < 0) top = 0;
1535
if (ocur != top) prdir(w, top, cur);
1539
1615
if (pgud == 2) { /* Page down */
1541
if (top < nrents - w->ys + 2) {
1543
if (top > nrents - w->ys + 2) {
1544
top = nrents - w->ys + 2;
1550
if (ocur != top) prdir(w, top, cur);
1617
if (top < nrents - w->ys + 2) {
1619
if (top > nrents - w->ys + 2)
1620
top = nrents - w->ys + 2;
1555
1631
/* Dial an entry */
1556
1632
if (subm == 0) {
1559
if (changed) writedialdir();
1561
/* See if any entries were tagged. */
1562
if (!(d->flags & FL_TAG)) {
1563
/* First check the entries from the highlighted one to end.. */
1564
for (d1 = d; d1; d1 = d1->next)
1565
if (d1->flags & FL_TAG) {
1569
/* ..and if none of them was tagged, check from the begining. */
1571
for(d1 = dialents; d1 && d1!=d; d1 = d1->next)
1572
if (d1->flags & FL_TAG) {
1576
/* If no tags were found, we'll dial the highlighted one */
1638
/* See if any entries were tagged. */
1639
if (!(d->flags & FL_TAG)) {
1640
/* First check the entries from the highlighted one to end.. */
1641
for (d1 = d; d1; d1 = d1->next)
1642
if (d1->flags & FL_TAG) {
1646
/* ..and if none of them was tagged, check from the begining. */
1648
for (d1 = dialents; d1 && d1!=d; d1 = d1->next)
1649
if (d1->flags & FL_TAG) {
1653
/* If no tags were found, we'll dial the highlighted one */
1581
1658
/* Find an entry */
1582
1659
if (subm == 1) {
1583
s = input(_("Find an entry"), dname);
1584
if (s == NULL || s[0] == 0) goto again;
1586
for(d = dialents; d; d = d->next, x1++)
1587
if (strstr(d->name, s)) break;
1592
/* Set current to found entry. */
1595
/* Find out if it fits on screen. */
1596
if (cur < top || cur >= top + w->ys - 2) {
1597
/* No, try to put it in the middle. */
1598
top = cur - (w->ys / 2) + 1;
1599
if (top < 0) top = 0;
1600
if (top > nrents - w->ys + 2) {
1601
top = nrents - w->ys + 2;
1604
if (ocur != top) prdir(w, top, top);
1660
s = input(_("Find an entry"), dname);
1661
if (s == NULL || s[0] == 0)
1664
for (d = dialents; d; d = d->next, x1++)
1665
if (strstr(d->name, s))
1671
/* Set current to found entry. */
1674
/* Find out if it fits on screen. */
1675
if (cur < top || cur >= top + w->ys - 2) {
1676
/* No, try to put it in the middle. */
1677
top = cur - (w->ys / 2) + 1;
1680
if (top > nrents - w->ys + 2)
1681
top = nrents - w->ys + 2;
1608
1688
/* Add / insert an entry */
1609
1689
if (subm == 2) {
1611
if (d1 == (struct dialent *)0) {
1623
if (cur - top > w->ys - 3) {
1691
if (d1 == (struct dialent *)0) {
1703
if (cur - top > w->ys - 3) {
1631
1711
/* Edit an entry */
1632
1712
if (subm == 3) {
1635
wlocate(w, 0, cur + 1 - top);
1636
wprintf(w, fmt, cur+1, (d->flags & FL_TAG) ? 16 : ' ', d->name,
1637
d->number, d->lastdate, d->lasttime, d->count, d->script);
1715
wlocate(w, 0, cur + 1 - top);
1716
wprintf(w, fmt, cur+1, (d->flags & FL_TAG) ? 16 : ' ', d->name,
1717
d->number, d->lastdate, d->lasttime, d->count, d->script);
1640
1720
/* Delete an entry from the list */
1641
1721
if (subm == 4 && ask(_("Remove entry?"), d_yesno) == 0) {
1645
d = dialents = mkstdent();
1652
getno(cur - 1)->next = d->next;
1655
if (cur - top == 0 && top == nrents) {
1660
if (cur == nrents) cur--;
1663
if (nrents - top <= w->ys - 3) {
1664
wlocate(w, 0, nrents - top + 1);
1725
d = dialents = mkstdent();
1732
getno(cur - 1)->next = d->next;
1735
if (cur - top == 0 && top == nrents) {
1744
if (nrents - top <= w->ys - 3) {
1745
wlocate(w, 0, nrents - top + 1);
1670
1751
/* Move the entry up/down in directory. */
1671
1752
if (subm == 5) {
1672
wlocate(w, position_dialing_directory, w->ys - 1);
1673
wprintf(w, "%*.*s", tagmvlen,tagmvlen, move_exit);
1674
cur = move_entry (w, d, cur, &top);
1678
wlocate(w, position_dialing_directory, w->ys - 1);
1679
wprintf(w, "%*.*s", tagmvlen,tagmvlen, tag_exit);
1753
wlocate(w, position_dialing_directory, w->ys - 1);
1754
wprintf(w, "%*.*s", tagmvlen,tagmvlen, move_exit);
1755
cur = move_entry (w, d, cur, &top);
1759
wlocate(w, position_dialing_directory, w->ys - 1);
1760
wprintf(w, "%*.*s", tagmvlen,tagmvlen, tag_exit);
1682
1763
/* Dial a number manually. */
1683
1764
if (subm == 6) {
1684
s = input(_("Enter number"), manual);
1686
if (changed) writedialdir();
1690
strncpy(d_man->number, manual, sizeof(d_man->number));
1691
(void) dial(d_man, (struct dialent**)NULL);
1692
if (P_SHOWSPD[0] == 'l')
1765
s = input(_("Enter number"), manual);
1772
strncpy(d_man->number, manual, sizeof(d_man->number));
1773
dial(d_man, (struct dialent**)NULL);
1774
if (P_SHOWSPD[0] == 'l')