FreeCalypso > hg > freecalypso-tools
comparison uptools/atcmd/smsend_multmain.c @ 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 |
comparison
equal
deleted
inserted
replaced
967:6bf473f77fc4 | 968:ec736c59845c |
---|---|
9 #include <string.h> | 9 #include <string.h> |
10 #include <strings.h> | 10 #include <strings.h> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 #include "../../rvinterf/include/exitcodes.h" | 12 #include "../../rvinterf/include/exitcodes.h" |
13 | 13 |
14 int sms_write_mode, text_mode, utf8_input, ucs2_mode; | 14 int sms_write_mode, text_mode, utf8_input, ucs2_mode, allow_escape; |
15 u_char dest_addr[12]; | 15 u_char dest_addr[12]; |
16 int dest_addr_global; | 16 int dest_addr_global; |
17 char input_line[21+5+1+320+2], *msgtext; | 17 char input_line[21+5+1+320+2], *msgtext; |
18 int lineno; | 18 int lineno; |
19 int initdone; | 19 int initdone; |
22 char **argv; | 22 char **argv; |
23 { | 23 { |
24 int c; | 24 int c; |
25 extern int optind; | 25 extern int optind; |
26 | 26 |
27 while ((c = getopt(argc, argv, "B:np:RtuUwWX:")) != EOF) { | 27 while ((c = getopt(argc, argv, "B:enp:RtuUwWX:")) != EOF) { |
28 if (atinterf_cmdline_opt(c)) | 28 if (atinterf_cmdline_opt(c)) |
29 continue; | 29 continue; |
30 switch (c) { | 30 switch (c) { |
31 case 'e': | |
32 allow_escape = 1; | |
33 continue; | |
31 case 't': | 34 case 't': |
32 text_mode = 1; | 35 text_mode = 1; |
33 continue; | 36 continue; |
34 case 'u': | 37 case 'u': |
35 utf8_input = 1; | 38 utf8_input = 1; |
48 exit(ERROR_USAGE); | 51 exit(ERROR_USAGE); |
49 } | 52 } |
50 } | 53 } |
51 if (ucs2_mode && text_mode) { | 54 if (ucs2_mode && text_mode) { |
52 fprintf(stderr, "%s error: UCS-2 not supported in text mode\n", | 55 fprintf(stderr, "%s error: UCS-2 not supported in text mode\n", |
56 argv[0]); | |
57 exit(ERROR_USAGE); | |
58 } | |
59 if (allow_escape && text_mode) { | |
60 fprintf(stderr, | |
61 "%s error: escapes not supported in text mode\n", | |
53 argv[0]); | 62 argv[0]); |
54 exit(ERROR_USAGE); | 63 exit(ERROR_USAGE); |
55 } | 64 } |
56 if (argc > optind + 1) { | 65 if (argc > optind + 1) { |
57 fprintf(stderr, "usage: %s [options] [dest-addr]\n", | 66 fprintf(stderr, "usage: %s [options] [dest-addr]\n", |
139 } | 148 } |
140 init_send_process(); | 149 init_send_process(); |
141 send_in_text_mode(dest_addr, msgtext); | 150 send_in_text_mode(dest_addr, msgtext); |
142 return(0); | 151 return(0); |
143 } | 152 } |
144 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen, 0); | 153 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen, |
154 allow_escape); | |
145 if (rc == -1) { | 155 if (rc == -1) { |
146 fprintf(stderr, | 156 fprintf(stderr, |
147 "input line %d: message not valid for GSM7 charset\n", | 157 "input line %d: message not valid for GSM7 charset\n", |
148 lineno); | 158 lineno); |
149 exit(ERROR_USAGE); | 159 exit(ERROR_USAGE); |
150 } | 160 } |
151 if (rc == -2) | 161 if (rc == -2) |
152 goto toolong; | 162 goto toolong; |
163 if (rc == -3) { | |
164 fprintf(stderr, | |
165 "input line %d: message contains invalid backslash escape\n", | |
166 lineno); | |
167 exit(ERROR_USAGE); | |
168 } | |
153 init_send_process(); | 169 init_send_process(); |
154 send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen, | 170 send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen, |
155 (u_char *) 0, 0); | 171 (u_char *) 0, 0); |
156 return(0); | 172 return(0); |
157 } | 173 } |
160 { | 176 { |
161 u_short msgtext_uni[70]; | 177 u_short msgtext_uni[70]; |
162 unsigned msgtext_unilen; | 178 unsigned msgtext_unilen; |
163 int rc; | 179 int rc; |
164 | 180 |
165 rc = utf8_to_ucs2(msgtext, msgtext_uni, 70, &msgtext_unilen, 0); | 181 rc = utf8_to_ucs2(msgtext, msgtext_uni, 70, &msgtext_unilen, |
182 allow_escape); | |
166 if (rc == -1) { | 183 if (rc == -1) { |
167 fprintf(stderr, "input line %d: invalid UTF-8 message\n", | 184 fprintf(stderr, "input line %d: invalid UTF-8 message\n", |
168 lineno); | 185 lineno); |
169 exit(ERROR_USAGE); | 186 exit(ERROR_USAGE); |
170 } | 187 } |
171 if (rc == -2) { | 188 if (rc == -2) { |
172 fprintf(stderr, | 189 fprintf(stderr, |
173 "input line %d: message exceeds 70 UCS-2 chars\n", | 190 "input line %d: message exceeds 70 UCS-2 chars\n", |
191 lineno); | |
192 exit(ERROR_USAGE); | |
193 } | |
194 if (rc == -3) { | |
195 fprintf(stderr, | |
196 "input line %d: message contains invalid backslash escape\n", | |
174 lineno); | 197 lineno); |
175 exit(ERROR_USAGE); | 198 exit(ERROR_USAGE); |
176 } | 199 } |
177 init_send_process(); | 200 init_send_process(); |
178 send_pdu_ucs2(dest_addr, msgtext_uni, msgtext_unilen, (u_char *) 0, 0); | 201 send_pdu_ucs2(dest_addr, msgtext_uni, msgtext_unilen, (u_char *) 0, 0); |