changeset 940:ec5f51d33fdc

rvinterf code structure: factor out output_cont_logpref()
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 24 May 2023 06:43:15 +0000
parents 4d2e6a2dd1a1
children 8fc3b72eb2c6
files rvinterf/lowlevel/output.c rvinterf/lowlevel/rviftmode.c
diffstat 2 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/lowlevel/output.c	Wed May 24 06:29:13 2023 +0000
+++ b/rvinterf/lowlevel/output.c	Wed May 24 06:43:15 2023 +0000
@@ -50,3 +50,13 @@
 	if (logF)
 		fprintf(logF, "%s\n", item);
 }
+
+void
+output_cont_logpref(item)
+	char *item;
+{
+	if (logF)
+		fprintf(logF, "%s\n", item);
+	else if (!no_output)
+		printf("%s\n", item);
+}
--- a/rvinterf/lowlevel/rviftmode.c	Wed May 24 06:29:13 2023 +0000
+++ b/rvinterf/lowlevel/rviftmode.c	Wed May 24 06:43:15 2023 +0000
@@ -17,7 +17,8 @@
 extern size_t rxpkt_len;
 
 extern int verbose;
-extern FILE *logF;
+
+extern void output_cont_logpref();
 
 static int
 verify_cksum(pkt, pktlen)
@@ -347,16 +348,6 @@
 	}
 }
 
-static void
-hexdump_out(line)
-	char *line;
-{
-	if (logF)
-		fprintf(logF, "%s\n", line);
-	else
-		printf("%s\n", line);
-}
-
 void
 log_sent_tm(pkt, pktlen)
 	u_char *pkt;
@@ -367,7 +358,7 @@
 	sprintf(headline, "Sent Test Mode cmd (%s)", summary);
 	output_line(headline);
 	if (verbose >= 1)
-		packet_hex_dump(pkt, pktlen, hexdump_out);
+		packet_hex_dump(pkt, pktlen, output_cont_logpref);
 }
 
 void
@@ -379,5 +370,6 @@
 	sprintf(headline, "Rx Test Mode resp (%s)", summary);
 	output_line(headline);
 	if (verbose >= 1)
-		packet_hex_dump(rxpkt, (unsigned) rxpkt_len, hexdump_out);
+		packet_hex_dump(rxpkt, (unsigned) rxpkt_len,
+				output_cont_logpref);
 }