changeset 448:261c1b6d936e

fcup-rvtat: added support for long strings with new fw versions
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 15 Jan 2019 06:01:04 +0000
parents e13f60d4f8dd
children b1864e3f8fb4
files rvinterf/rvtat/main.c
diffstat 1 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/rvtat/main.c	Wed Jan 09 07:58:06 2019 +0000
+++ b/rvinterf/rvtat/main.c	Tue Jan 15 06:01:04 2019 +0000
@@ -15,7 +15,7 @@
 extern u_char rvi_msg[];
 extern int rvi_msg_len;
 
-char command[256], message[256];
+char command[508], message[508];
 int cmd_with_msg;
 
 read_command_input(buf)
@@ -23,7 +23,7 @@
 {
 	char *nl;
 
-	if (!fgets(buf, 256, stdin))
+	if (!fgets(buf, 508, stdin))
 		return(0);
 	nl = index(buf, '\n');
 	if (!nl) {
@@ -34,7 +34,21 @@
 	return(1);
 }
 
-send_to_target(str)
+send_to_target_prefix(str)
+	char *str;
+{
+	u_char sendpkt[MAX_PKT_TO_TARGET];
+
+	/* fill out the packet */
+	sendpkt[0] = RVT_AT_HEADER;
+	sendpkt[1] = 0x01;
+	bcopy(str, sendpkt + 2, 252);
+	/* send it! */
+	send_pkt_to_target(sendpkt, 254);
+	return(0);
+}
+
+send_to_target_plain(str)
 	char *str;
 {
 	unsigned len;
@@ -49,6 +63,21 @@
 	return(0);
 }
 
+send_to_target(str)
+	char *str;
+{
+	unsigned len;
+
+	len = strlen(str);
+	if (len <= 254)
+		send_to_target_plain(str);
+	else {
+		send_to_target_prefix(str);
+		send_to_target_plain(str + 252);
+	}
+	return(0);
+}
+
 execute_command()
 {
 	send_to_target(command);