# HG changeset patch # User Mychaela Falconia # Date 1520556216 0 # Node ID a8abaa85c378337de550aab5e08f0cf59b5eba4b # Parent a38805b5b6d4868202ddae87caaa5b8d353631bb fcup-smsend: preparations for adding UCS-2 support diff -r a38805b5b6d4 -r a8abaa85c378 uptools/atcmd/smsend_main.c --- a/uptools/atcmd/smsend_main.c Fri Mar 09 00:27:24 2018 +0000 +++ b/uptools/atcmd/smsend_main.c Fri Mar 09 00:43:36 2018 +0000 @@ -11,13 +11,15 @@ #include "../../rvinterf/include/exitcodes.h" #define MAX_MSG_CHARS (153*255) +#define MAX_MSG_UNI (67*255) -int sms_write_mode, text_mode, utf8_input; +int sms_write_mode, text_mode, utf8_input, ucs2_mode; int concat_enable, concat_refno_set, concat_quiet; u_char dest_addr[12]; char msgtext[MAX_MSG_CHARS*2+2]; u_char msgtext_gsm7[MAX_MSG_CHARS]; -unsigned msgtext_gsmlen; +u_short msgtext_uni[MAX_MSG_UNI]; +unsigned msgtext_gsmlen, msgtext_unilen; u_char concat_refno; process_cmdline(argc, argv) @@ -27,7 +29,7 @@ extern int optind; extern char *optarg; - while ((c = getopt(argc, argv, "B:cC:np:qRtuwWX:")) != EOF) { + while ((c = getopt(argc, argv, "B:cC:np:qRtuUwWX:")) != EOF) { if (atinterf_cmdline_opt(c)) continue; switch (c) { @@ -48,6 +50,9 @@ case 'u': utf8_input = 1; continue; + case 'U': + ucs2_mode = 1; + continue; case 'w': sms_write_mode = 1; continue; @@ -66,6 +71,11 @@ argv[0]); exit(ERROR_USAGE); } + if (ucs2_mode && text_mode) { + fprintf(stderr, "%s error: UCS-2 not supported in text mode\n", + argv[0]); + exit(ERROR_USAGE); + } if (argc > optind + 2) { fprintf(stderr, "usage: %s [options] dest-addr [message]\n", argv[0]); @@ -138,21 +148,17 @@ atinterf_exec_cmd_needok("AT+CMEE=2", 0, 0); } -main(argc, argv) - char **argv; +gsm7_mode_main() { int rc; unsigned nparts, n; u_char udh[5]; unsigned pos, remain, chunk; - if (!process_cmdline(argc, argv)) - read_msgtext_from_stdin(); if (utf8_input && utf8_to_latin1(msgtext) < 0) { fprintf(stderr, "error: invalid UTF-8 message\n"); exit(ERROR_USAGE); } - trim_trailing_newlines(); if (text_mode) { if (index(msgtext, '\n')) { fprintf(stderr, @@ -222,3 +228,12 @@ printf("Message sent as %u SMS segments\n", nparts); exit(0); } + +main(argc, argv) + char **argv; +{ + if (!process_cmdline(argc, argv)) + read_msgtext_from_stdin(); + trim_trailing_newlines(); + gsm7_mode_main(); +}