Skip to content

Commit 1ba1a4a

Browse files
authoredFeb 19, 2021
Clean-up exits (no Ctrl-C/Alt-Q) (Tlf#249)
* clean exits (no Ctrl-C/Alt-Q)
1 parent 9db266d commit 1ba1a4a

File tree

6 files changed

+39
-60
lines changed

6 files changed

+39
-60
lines changed
 

‎share/help.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ Alt-T Tune Alt-N Note in log
88
Alt-V Band down (CW Speed?) Alt-P Turn PTT on/off
99
Alt-H Show help.txt Alt-W CW Weight
1010
Alt-I Show talk messages Alt-J See QRG's
11-
Alt-K CW from Keyboard Alt-X Exit program (Alt-q)
12-
Alt-M Multi display (Alt-c) Alt-S Score window (Alt-r)
13-
Alt-, Show bandmap Alt-J Show frequency
11+
Alt-K CW from Keyboard Alt-X Exit program
12+
Alt-M Multi display (Alt-C) Alt-S Score window (Alt-R)
1413
Alt-Z Show worked zones Alt-G Grab call (min. 2 letters from bandmap)
14+
Alt-, Show bandmap
1515

1616
<CTRL+?>
1717
Ctrl-A Add a spot to list Ctrl-B Cluster send
18-
Ctrl-C Quit Tlf Ctrl-P MUF display
1918
Ctrl-G Grab a bandmap spot Ctrl-V Toggle grab direction
2019
Ctrl-PgUp Auto CQ delay + Ctrl-PgDn Auto CQ delay -
2120
Ctrl-K CW from keyboard Ctrl-F Frequency control window
2221
Ctrl-T Show talk messages Ctrl-R LPT0 pin 14 on/off (SSB mic)
22+
Ctrl-P MUF display
2323

2424

2525
<direct keyboard commands>
@@ -77,6 +77,7 @@ $ Switch to MEM and clear it (pop)
7777
:MAP Filter band map content
7878
:SYNc Synchronize log in network
7979
:EXIt Exit program
80+
:QUIt Exit program
8081
:MULt Toggle remaining multi display
8182
:CONtest Toggle contest mode on/off
8283
:SCOre Toggle score window on/off
@@ -87,7 +88,6 @@ $ Switch to MEM and clear it (pop)
8788
:TRXcont Toggle TRX control on/off
8889
:CHAR Autosend: number of chars before starting to send
8990
:SOUnd Record sound files
90-
:WRIte Write cabrillo
91-
:ADIf Write Adif
92-
:EXIt Exit tlf
91+
:WRIte Write Cabrillo
92+
:ADIf Write ADIF
9393
:TONe Set sidetone (0 = off)

‎src/callinput.c

+6-12
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ int callinput(void) {
148148
char instring[2] = { '\0', '\0' };
149149
static int lastwindow;
150150

151-
152151
attron(modify_attr(COLOR_PAIR(NORMCOLOR)));
153152

154153
printcall(); /* print call input field */
@@ -779,20 +778,15 @@ int callinput(void) {
779778
break;
780779
}
781780

782-
// Alt-q (M-q) or Alt-x (M-x), Exit
783-
case ALT_Q:
781+
// Alt-x (M-x), Exit
784782
case ALT_X: {
785-
mvprintw(13, 29, "You want to leave tlf? (y/n): ");
786-
while (x != 'n' && x != 'N') {
787-
788-
x = key_get();
783+
mvprintw(13, 29, "Do you want to leave Tlf? (y/n): ");
784+
while (x != 'N') {
789785

790-
if (x == 'y' || x == 'Y') {
791-
cleanup_telnet();
792-
endwin();
786+
x = toupper(key_get());
793787

794-
puts("\n\nThanks for using TLF.. 73\n");
795-
exit(0);
788+
if (x == 'Y') {
789+
exit(EXIT_SUCCESS);
796790
}
797791
}
798792
x = ESCAPE;

‎src/changepars.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,9 @@ int changepars(void) {
275275

276276
break;
277277
}
278-
case 19: /* EXIT */
278+
case 19: /* EXIT */
279279
case 38: { /* QUIT */
280-
clear();
281-
cleanup_telnet();
282-
endwin();
283-
puts("\n\nThanks for using TLF.. 73\n");
284-
exit(0);
285-
break;
280+
exit(EXIT_SUCCESS);
286281
}
287282
case 20: { /* TXFILE */
288283
break;

‎src/main.c

+20-12
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ const static struct argp argp = { options, parse_opt, NULL, program_description
474474

475475

476476
/** initialize user interface */
477-
void ui_init() {
477+
static void ui_init() {
478478

479479
/* modify stdin terminals attributes to allow Ctrl-Q/S key recognition */
480480
tcgetattr(STDIN_FILENO, &oldt);
@@ -557,7 +557,7 @@ void ui_init() {
557557

558558

559559
/* setup colors */
560-
void ui_color_init() {
560+
static void ui_color_init() {
561561

562562
if (use_rxvt == 1) { // use rxvt colours
563563
init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_RED);
@@ -629,7 +629,7 @@ static void init_variables() {
629629
/** load all databases
630630
*
631631
* \return EXIT_FAILURE if not successful */
632-
int databases_load() {
632+
static int databases_load() {
633633
int status;
634634

635635
showmsg("Reading country data");
@@ -700,7 +700,7 @@ int databases_load() {
700700
return EXIT_SUCCESS;
701701
}
702702

703-
void hamlib_init() {
703+
static void hamlib_init() {
704704

705705
if (no_trx_control) {
706706
trx_control = false;
@@ -729,7 +729,7 @@ void hamlib_init() {
729729
}
730730
}
731731

732-
void fldigi_init() {
732+
static void fldigi_init() {
733733
#ifdef HAVE_LIBXMLRPC
734734
int status;
735735

@@ -743,7 +743,7 @@ void fldigi_init() {
743743
#endif
744744
}
745745

746-
void lan_init() {
746+
static void lan_init() {
747747
if (lan_active) {
748748
if (lan_recv_init() < 0) /* set up the network */
749749
showmsg("LAN receive init failed");
@@ -758,7 +758,7 @@ void lan_init() {
758758
}
759759

760760

761-
void packet_init() {
761+
static void packet_init() {
762762
if (nopacket)
763763
packetinterface = 0;
764764

@@ -776,7 +776,7 @@ void packet_init() {
776776
}
777777

778778

779-
void keyer_init() {
779+
static void keyer_init() {
780780
char keyerbuff[3];
781781

782782
if (cwkeyer == NET_KEYER) {
@@ -822,7 +822,7 @@ void keyer_init() {
822822
}
823823

824824

825-
void show_GPL() {
825+
static void show_GPL() {
826826
printw("\n\n\n");
827827
printw(" TTTTT L FFFFF\n");
828828
printw(" T L F \n");
@@ -842,7 +842,7 @@ void show_GPL() {
842842
}
843843

844844

845-
int isFirstStart() {
845+
static int isFirstStart() {
846846
FILE *fp;
847847

848848
if ((fp = fopen(".paras", "r")) == NULL) {
@@ -856,7 +856,7 @@ int isFirstStart() {
856856
/* write empty .paras file to remember that tlf got already started once
857857
* in these directory and GPL has been shown
858858
*/
859-
void mark_GPL_seen() {
859+
static void mark_GPL_seen() {
860860

861861
FILE *fp = fopen(".paras", "w");
862862
if (fp) {
@@ -870,7 +870,7 @@ void mark_GPL_seen() {
870870
* Cleanup initialisations made by tlf. Will be called after exit() from
871871
* logit() or background_process()
872872
*/
873-
void tlf_cleanup() {
873+
static void tlf_cleanup() {
874874
if (pthread_self() != background_thread) {
875875
pthread_cancel(background_thread);
876876
pthread_join(background_thread, NULL);
@@ -895,8 +895,13 @@ void tlf_cleanup() {
895895

896896
endwin();
897897
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
898+
899+
puts("\n\nThanks for using Tlf.. 73\n");
898900
}
899901

902+
static void ignore(int sig) {
903+
// no action except ignoring Ctrl-C
904+
}
900905

901906
/* ------------------------------------------------------------------------*/
902907
/* Main loop of the program */
@@ -1002,6 +1007,9 @@ int main(int argc, char *argv[]) {
10021007

10031008
bm_init(); /* initialize bandmap */
10041009

1010+
if (signal(SIGINT, SIG_IGN) != SIG_IGN) { /* ignore Ctrl-C */
1011+
signal(SIGINT, ignore);
1012+
}
10051013
atexit(tlf_cleanup); /* register cleanup function */
10061014

10071015
/* Create the background thread */

‎src/parse_logcfg.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static int cfg_thisnode(const cfg_arg_t arg) {
492492

493493
if (strlen(str) != 1 || str[0] < 'A' || str[0] > 'A' + MAXNODES) {
494494
g_free(str);
495-
error_details = g_strdup_printf("name name is A..%c", 'A' + MAXNODES - 1);
495+
error_details = g_strdup_printf("name is A..%c", 'A' + MAXNODES - 1);
496496
return PARSE_WRONG_PARAMETER;
497497
}
498498

‎tlf.1.in

+3-21
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ You can exit and close @PACKAGE_NAME@ with the
205205
or
206206
.BR :QUI t
207207
commands or with
208-
.BR Ctrl\-C ,
209-
.BR Alt\-Q \ or
210208
.BR Alt\-X \.
211209
.P
212210
At restart @PACKAGE_NAME@ recalculates the score, which may take some time
@@ -289,10 +287,7 @@ Edit the log with your favourite editor. Be careful!
289287
.TQ
290288
.BR :QUI t
291289
Exit @PACKAGE_NAME@ (synonym to
292-
.BR Ctrl\-C ,
293-
.BR Alt\-Q ,
294-
and
295-
.BR Alt\-X ")."
290+
.BR Alt\-X ", but without asking for confirmation)."
296291
.
297292
.TP
298293
.BR :FIL ter
@@ -787,15 +782,6 @@ Add a spot to bandmap and broadcast it on the local network.
787782
Send a spot to the DX Cluster (a connection to a DX cluster must exit).
788783
.
789784
.TP
790-
.B Ctrl-C
791-
Exit @PACKAGE_NAME@ (synonyms to
792-
.BR :EXI t,
793-
.BR :QUI t,
794-
.BR Alt-Q ,
795-
and
796-
.BR Alt-X ")."
797-
.
798-
.TP
799785
.B Ctrl-E
800786
Ends modem capture for RTTY mode in QTC window (started with
801787
.BR Ctrl-S ).
@@ -935,15 +921,11 @@ Add Note to log.
935921
Toggle PTT (via \fBcwdaemon\fR).
936922
.
937923
.TP
938-
.B Alt-Q
939-
.TQ
940924
.B Alt-X
941925
Exit @PACKAGE_NAME@ (synonym to
942-
.BR :EXI "t ,"
943-
.BR :QUI "t ,"
944-
.BR Ctrl-C ,
926+
.BR :EXI "t "
945927
and
946-
.BR Ctrl-D ")."
928+
.BR :QUI "t, but asks for confirmation)."
947929
.
948930
.TP
949931
.B Alt-R

0 commit comments

Comments
 (0)
Please sign in to comment.