Skip to content

Commit bc07681

Browse files
author
Nate Morrison
committedMar 22, 2022
Restores terminal background colour on exit
NOTE: Standard output from Direwolf is not affected.
1 parent fe6cba2 commit bc07681

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+170
-9
lines changed
 

‎src/aclients.c

+13
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ int main (int argc, char *argv[])
221221

222222
if (num_clients < 1 || num_clients > MAX_CLIENTS) {
223223
printf ("Specify up to %d TNCs on the command line.\n", MAX_CLIENTS);
224+
dw_printf ("\e[0m\e\n\e[0J\e");
224225
exit (1);
225226
}
226227

@@ -236,13 +237,15 @@ int main (int argc, char *argv[])
236237
p = strtok (stemp, "=");
237238
if (p == NULL) {
238239
printf ("Internal error 1\n");
240+
dw_printf ("\e[0m\e\n\e[0J\e");
239241
exit (1);
240242
}
241243
strlcpy (hostname[j], "localhost", sizeof(hostname[j]));
242244
strlcpy (port[j], p, sizeof(port[j]));
243245
p = strtok (NULL, "=");
244246
if (p == NULL) {
245247
printf ("Missing description after %s\n", port[j]);
248+
dw_printf ("\e[0m\e\n\e[0J\e");
246249
exit (1);
247250
}
248251
strlcpy (description[j], p, sizeof(description[j]));
@@ -291,6 +294,7 @@ int main (int argc, char *argv[])
291294
}
292295
if (client_th[j] == NULL) {
293296
printf ("Internal error: Could not create client thread %d.\n", j);
297+
dw_printf ("\e[0m\e\n\e[0J\e");
294298
exit (1);
295299
}
296300
#else
@@ -302,6 +306,7 @@ int main (int argc, char *argv[])
302306
}
303307
if (e != 0) {
304308
perror("Internal error: Could not create client thread.");
309+
dw_printf ("\e[0m\e\n\e[0J\e");
305310
exit (1);
306311
}
307312
#endif
@@ -438,6 +443,7 @@ static void * client_thread_net (void *arg)
438443
hostname[my_index], gai_strerror(err));
439444
#endif
440445
freeaddrinfo(ai_head);
446+
dw_printf ("\e[0m\e\n\e[0J\e");
441447
exit (1);
442448
}
443449

@@ -536,6 +542,7 @@ static void * client_thread_net (void *arg)
536542

537543
printf("Client %d unable to connect to %s on %s (%s), port %s\n",
538544
my_index, description[my_index], hostname[my_index], ipaddr_str, port[my_index] );
545+
dw_printf ("\e[0m\e\n\e[0J\e");
539546
exit (1);
540547
}
541548

@@ -563,6 +570,7 @@ static void * client_thread_net (void *arg)
563570

564571
if (n != sizeof(mon_cmd)) {
565572
printf ("Read error, client %d received %d command bytes. Terminating.\n", my_index, n);
573+
dw_printf ("\e[0m\e\n\e[0J\e");
566574
exit (1);
567575
}
568576

@@ -577,6 +585,7 @@ static void * client_thread_net (void *arg)
577585

578586
if (n != mon_cmd.data_len) {
579587
printf ("Read error, client %d received %d data bytes.\n", my_index, n);
588+
dw_printf ("\e[0m\e\n\e[0J\e");
580589
exit (1);
581590
}
582591
}
@@ -682,6 +691,7 @@ static void * client_thread_serial (void *arg)
682691
if (fd == MYFDERROR) {
683692
printf("Client %d unable to connect to %s on %s.\n",
684693
my_index, description[my_index], port[my_index] );
694+
dw_printf ("\e[0m\e\n\e[0J\e");
685695
exit (1);
686696
}
687697

@@ -732,6 +742,7 @@ static void * client_thread_serial (void *arg)
732742
if (fd == MYFDERROR) {
733743
printf("Client %d unable to connect to %s on %s.\n",
734744
my_index, description[my_index], port[my_index] );
745+
dw_printf ("\e[0m\e\n\e[0J\e");
735746
exit (1);
736747
}
737748

@@ -781,6 +792,7 @@ static void * client_thread_serial (void *arg)
781792
if (! ReadFile (fd, &ch, 1, &n, NULL)) {
782793
printf ("Read error on %s.\n", description[my_index]);
783794
CloseHandle (fd);
795+
dw_printf ("\e[0m\e\n\e[0J\e");
784796
exit (1);
785797
}
786798

@@ -790,6 +802,7 @@ static void * client_thread_serial (void *arg)
790802
if ( ( n = read(fd, & ch, 1)) < 0) {
791803
printf ("Read error on %s.\n", description[my_index]);
792804
close (fd);
805+
dw_printf ("\e[0m\e\n\e[0J\e");
793806
exit (1);
794807
}
795808
#endif

‎src/appserver.c

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static void usage()
5656
dw_printf (" mycall is required because that is the callsign for \n");
5757
dw_printf (" which the TNC will accept connections. \n");
5858
dw_printf (" \n");
59+
dw_printf ("\e[0m\e\n\e[0J\e");
5960
exit (EXIT_FAILURE);
6061
}
6162

@@ -192,6 +193,7 @@ int main (int argc, char *argv[])
192193
if (agwlib_init (tnc_hostname, tnc_port, agwlib_G_ask_port_information) != 0) {
193194
text_color_set(DW_COLOR_ERROR);
194195
dw_printf ("Could not attach to network TNC %s:%s.\n", tnc_hostname, tnc_port);
196+
dw_printf ("\e[0m\e\n\e[0J\e");
195197
exit (EXIT_FAILURE);
196198
}
197199

0 commit comments

Comments
 (0)