diff mbox series

Resend : [PATCH] AX25 rose_call - replacing carriage return by newlines

Message ID d3e987ef-2c6d-4ae4-9b58-75d25f7793c2@free.fr (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series Resend : [PATCH] AX25 rose_call - replacing carriage return by newlines | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

F6BVP Aug. 7, 2022, 6:21 p.m. UTC
[PATCH] AX25 rose_call - replacing carriage return by newlines

Previous patch was reversed... resending correct one.

I have been using intensively rose_call application (part of 
ax25tools/user_call library) while debugging rose connect issue.

However once connected rose_call displays remote message without 
linefeed. Consequently it is impossible to read messages.

For example calling local node :

# rose_call rose0 f6bvp f6bvp-4 2080175524
Connecting to f6bvp-4 @ 2080175524 ...

*** Connected

F6BVP-4 (Commands = ?) : Aug  5 2022) for LINUX (help = h)


Then issuing command P to the connected local node, all answer
lines are superimposed.

F6BVP-4 (Commands = ?) : Switch Port


Now with the proposed patch is the complete info displayed:

# ./rose_call rose0 f6bvp f6bvp-4 2080175524

Connecting to f6bvp-4 @ 2080175524 ...

*** Connected

User call : F6BVP-0

Welcome to the last release of Fpac!

This file is fpac.hello and is displayed when

a user connects to the node.



FPAC-Node v 4.1.3 (built Aug  5 2022) for LINUX (help = h)

F6BVP-4 (Commands = ?) :


In file rose_call.c carriage returns are also replaced by newlines
in order to let error messages to be correctly displayed.

Cc: Thomas DL9SAU Osterried <thomas@osterried.de>
Cc: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: Bernard Pidoux <f6bvp@free.fr>
diff mbox series

Patch

diff --git a/linuxax25-master-f6bvp/ax25tools/user_call/user_io.c b/linuxax25-master/ax25tools/user_call/user_io.c
index 3bd6a26..92c47a6 100644
--- a/linuxax25-master/ax25tools/user_call/user_io.c
+++ b/linuxax25-master/ax25tools/user_call/user_io.c
@@ -174,6 +174,16 @@  int user_read(int fd, void *buf, size_t count)
 #endif
 }
 
+void linefeed_buffer(char *buf, size_t count)
+{
+	int i;
+
+	for (i=0 ; i < count ; i++) {
+		if(buf[i] == 0x0D)
+			buf[i] = 0x0A;
+	}
+}
+
 int select_loop(int s)
 {
 	fd_set read_fd;
@@ -199,8 +209,10 @@  int select_loop(int s)
 		select(s + 1, &read_fd, NULL, NULL, NULL);
 
 		if (FD_ISSET(s, &read_fd)) {
-			while ((n = user_read(s, buf, BUFLEN)) > 0)
+			while ((n = user_read(s, buf, BUFLEN)) > 0) {
+				linefeed_buffer(buf, BUFLEN);
 				user_write(STDOUT_FILENO, buf, n);
+			}
 			if (n == 0 || (n < 0 && errno != EAGAIN)) {
 				close(s);
 				break;


diff --git a/linuxax25-master/ax25tools/user_call/rose_call.c b/linuxax25-master-f6bvp/ax25tools/user_call/rose_call.c
index 7a7dea1..03bba08 100644
--- a/linuxax25-master/ax25tools/user_call/rose_call.c
+++ b/linuxax25-master-f6bvp/ax25tools/user_call/rose_call.c
@@ -44,13 +44,13 @@  int main(int argc, char **argv)
 			break;
 		case ':':
 		case '?':
-			err("ERROR: invalid option usage\r");
+			err("ERROR: invalid option usage\n");
 			return 1;
 		}
 	}
 
 	if (paclen_in < 1 || paclen_out < 1) {
-		err("ERROR: invalid paclen\r");
+		err("ERROR: invalid paclen\n");
 		return 1;
 	}
 
@@ -58,12 +58,12 @@  int main(int argc, char **argv)
 	 * Arguments should be "rose_call port mycall remcall remaddr"
 	 */
 	if ((argc - optind) != 4) {
-		strcpy(buffer, "ERROR: invalid number of parameters\r");
+		strcpy(buffer, "ERROR: invalid number of parameters\n");
 		err(buffer);
 	}
 
 	if (rs_config_load_ports() == 0) {
-		strcpy(buffer, "ERROR: problem with rsports file\r");
+		strcpy(buffer, "ERROR: problem with rsports file\n");
 		err(buffer);
 	}
 
@@ -75,27 +75,27 @@  int main(int argc, char **argv)
 
 	addr = rs_config_get_addr(argv[optind]);
 	if (addr == NULL) {
-		sprintf(buffer, "ERROR: invalid Rose port name - %s\r", argv[optind]);
+		sprintf(buffer, "ERROR: invalid Rose port name - %s\n", argv[optind]);
 		err(buffer);
 	}
 
 	if (rose_aton(addr, rosebind.srose_addr.rose_addr) == -1) {
-		sprintf(buffer, "ERROR: invalid Rose port address - %s\r", argv[optind]);
+		sprintf(buffer, "ERROR: invalid Rose port address - %s\n", argv[optind]);
 		err(buffer);
 	}
 
 	if (ax25_aton_entry(argv[optind + 1], rosebind.srose_call.ax25_call) == -1) {
-		sprintf(buffer, "ERROR: invalid callsign - %s\r", argv[optind + 1]);
+		sprintf(buffer, "ERROR: invalid callsign - %s\n", argv[optind + 1]);
 		err(buffer);
 	}
 
 	if (ax25_aton_entry(argv[optind + 2], roseconnect.srose_call.ax25_call) == -1) {
-		sprintf(buffer, "ERROR: invalid callsign - %s\r", argv[optind + 2]);
+		sprintf(buffer, "ERROR: invalid callsign - %s\n", argv[optind + 2]);
 		err(buffer);
 	}
 
 	if (rose_aton(argv[optind + 3], roseconnect.srose_addr.rose_addr) == -1) {
-		sprintf(buffer, "ERROR: invalid Rose address - %s\r", argv[optind + 3]);
+		sprintf(buffer, "ERROR: invalid Rose address - %s\n", argv[optind + 3]);
 		err(buffer);
 	}
 
@@ -104,7 +104,7 @@  int main(int argc, char **argv)
 	 */
 	s = socket(AF_ROSE, SOCK_SEQPACKET, 0);
 	if (s < 0) {
-		sprintf(buffer, "ERROR: cannot open Rose socket, %s\r", strerror(errno));
+		sprintf(buffer, "ERROR: cannot open Rose socket, %s\n", strerror(errno));
 		err(buffer);
 	}
 
@@ -112,11 +112,11 @@  int main(int argc, char **argv)
 	 * Set our AX.25 callsign and Rose address accordingly.
 	 */
 	if (bind(s, (struct sockaddr *)&rosebind, addrlen) != 0) {
-		sprintf(buffer, "ERROR: cannot bind Rose socket, %s\r", strerror(errno));
+		sprintf(buffer, "ERROR: cannot bind Rose socket, %s\n", strerror(errno));
 		err(buffer);
 	}
 
-	sprintf(buffer, "Connecting to %s @ %s ...\r", argv[optind + 2], argv[optind + 3]);
+	sprintf(buffer, "Connecting to %s @ %s ...\n", argv[optind + 2], argv[optind + 3]);
 	user_write(STDOUT_FILENO, buffer, strlen(buffer));
 
 	/*
@@ -132,16 +132,16 @@  int main(int argc, char **argv)
 	if (connect(s, (struct sockaddr *)&roseconnect, addrlen) != 0) {
 		switch (errno) {
 		case ECONNREFUSED:
-			strcpy(buffer, "*** Connection refused - aborting\r");
+			strcpy(buffer, "*** Connection refused - aborting\n");
 			break;
 		case ENETUNREACH:
-			strcpy(buffer, "*** No known route - aborting\r");
+			strcpy(buffer, "*** No known route - aborting\n");
 			break;
 		case EINTR:
-			strcpy(buffer, "*** Connection timed out - aborting\r");
+			strcpy(buffer, "*** Connection timed out - aborting\n");
 			break;
 		default:
-			sprintf(buffer, "ERROR: cannot connect to Rose address, %s\r", strerror(errno));
+			sprintf(buffer, "ERROR: cannot connect to Rose address, %s\n", strerror(errno));
 			break;
 		}
 
@@ -153,12 +153,12 @@  int main(int argc, char **argv)
 	 */
 	alarm(0);
 
-	strcpy(buffer, "*** Connected\r");
+	strcpy(buffer, "*** Connected\n");
 	user_write(STDOUT_FILENO, buffer, strlen(buffer));
 
 	select_loop(s);
 
-	strcpy(buffer, "\r*** Disconnected\r");
+	strcpy(buffer, "\n*** Disconnected\n");
 	user_write(STDOUT_FILENO, buffer, strlen(buffer));
 
 	end_compress();