changeset 968:ec736c59845c

fcup-smsendmult: support -e like plain fcup-smsend
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 01 Sep 2023 17:32:54 +0000
parents 6bf473f77fc4
children 8cf7d41f2821
files uptools/atcmd/smsend_multmain.c
diffstat 1 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/uptools/atcmd/smsend_multmain.c	Fri Sep 01 16:43:35 2023 +0000
+++ b/uptools/atcmd/smsend_multmain.c	Fri Sep 01 17:32:54 2023 +0000
@@ -11,7 +11,7 @@
 #include <unistd.h>
 #include "../../rvinterf/include/exitcodes.h"
 
-int sms_write_mode, text_mode, utf8_input, ucs2_mode;
+int sms_write_mode, text_mode, utf8_input, ucs2_mode, allow_escape;
 u_char dest_addr[12];
 int dest_addr_global;
 char input_line[21+5+1+320+2], *msgtext;
@@ -24,10 +24,13 @@
 	int c;
 	extern int optind;
 
-	while ((c = getopt(argc, argv, "B:np:RtuUwWX:")) != EOF) {
+	while ((c = getopt(argc, argv, "B:enp:RtuUwWX:")) != EOF) {
 		if (atinterf_cmdline_opt(c))
 			continue;
 		switch (c) {
+		case 'e':
+			allow_escape = 1;
+			continue;
 		case 't':
 			text_mode = 1;
 			continue;
@@ -53,6 +56,12 @@
 			argv[0]);
 		exit(ERROR_USAGE);
 	}
+	if (allow_escape && text_mode) {
+		fprintf(stderr,
+			"%s error: escapes not supported in text mode\n",
+			argv[0]);
+		exit(ERROR_USAGE);
+	}
 	if (argc > optind + 1) {
 		fprintf(stderr, "usage: %s [options] [dest-addr]\n",
 			argv[0]);
@@ -141,7 +150,8 @@
 		send_in_text_mode(dest_addr, msgtext);
 		return(0);
 	}
-	rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen, 0);
+	rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen,
+			    allow_escape);
 	if (rc == -1) {
 		fprintf(stderr,
 			"input line %d: message not valid for GSM7 charset\n",
@@ -150,6 +160,12 @@
 	}
 	if (rc == -2)
 		goto toolong;
+	if (rc == -3) {
+		fprintf(stderr,
+		"input line %d: message contains invalid backslash escape\n",
+			lineno);
+		exit(ERROR_USAGE);
+	}
 	init_send_process();
 	send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen,
 			 (u_char *) 0, 0);
@@ -162,7 +178,8 @@
 	unsigned msgtext_unilen;
 	int rc;
 
-	rc = utf8_to_ucs2(msgtext, msgtext_uni, 70, &msgtext_unilen, 0);
+	rc = utf8_to_ucs2(msgtext, msgtext_uni, 70, &msgtext_unilen,
+			  allow_escape);
 	if (rc == -1) {
 		fprintf(stderr, "input line %d: invalid UTF-8 message\n",
 			lineno);
@@ -174,6 +191,12 @@
 			lineno);
 		exit(ERROR_USAGE);
 	}
+	if (rc == -3) {
+		fprintf(stderr,
+		"input line %d: message contains invalid backslash escape\n",
+			lineno);
+		exit(ERROR_USAGE);
+	}
 	init_send_process();
 	send_pdu_ucs2(dest_addr, msgtext_uni, msgtext_unilen, (u_char *) 0, 0);
 	return(0);