annotate uptools/atcmd/smsend_multmain.c @ 988:5a6019ed7e72

pln-ppb-test: implement read-id
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 00:04:18 +0000
parents ec736c59845c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This is the main module for the fcup-smsendmult utility.
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <unistd.h>
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "../../rvinterf/include/exitcodes.h"
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
14 int sms_write_mode, text_mode, utf8_input, ucs2_mode, allow_escape;
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 u_char dest_addr[12];
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int dest_addr_global;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char input_line[21+5+1+320+2], *msgtext;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 int lineno;
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
19 int initdone;
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 process_cmdline(argc, argv)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char **argv;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int c;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 extern int optind;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
27 while ((c = getopt(argc, argv, "B:enp:RtuUwWX:")) != EOF) {
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (atinterf_cmdline_opt(c))
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 continue;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 switch (c) {
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
31 case 'e':
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
32 allow_escape = 1;
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
33 continue;
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 case 't':
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 text_mode = 1;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 continue;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 case 'u':
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 utf8_input = 1;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 continue;
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
40 case 'U':
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
41 ucs2_mode = 1;
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
42 continue;
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 case 'w':
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 sms_write_mode = 1;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 continue;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 case 'W':
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 sms_write_mode = 2;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 continue;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 default:
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /* error msg already printed */
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
54 if (ucs2_mode && text_mode) {
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
55 fprintf(stderr, "%s error: UCS-2 not supported in text mode\n",
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
56 argv[0]);
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
57 exit(ERROR_USAGE);
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
58 }
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
59 if (allow_escape && text_mode) {
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
60 fprintf(stderr,
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
61 "%s error: escapes not supported in text mode\n",
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
62 argv[0]);
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
63 exit(ERROR_USAGE);
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
64 }
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 if (argc > optind + 1) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 fprintf(stderr, "usage: %s [options] [dest-addr]\n",
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 argv[0]);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (argv[optind]) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 dest_addr_global = 1;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 if (parse_and_encode_dest_addr(argv[optind], dest_addr) < 0) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 fprintf(stderr,
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 "error: destination address argument is invalid\n");
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 } else
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 dest_addr_global = 0;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 return(0);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 preen_input_line()
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 char *cp;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 cp = index(input_line, '\n');
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 if (!cp) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 fprintf(stderr, "input line %d: too long or unterminated\n",
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 lineno);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 *cp = '\0';
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 if (dest_addr_global) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 msgtext = input_line;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 return(0);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 if (!input_line[0] || isspace(input_line[0])) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 inv: fprintf(stderr, "input line %d: invalid syntax\n", lineno);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 for (cp = input_line; *cp && !isspace(*cp); cp++)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 ;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 if (!*cp)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 goto inv;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 *cp++ = '\0';
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 if (parse_and_encode_dest_addr(input_line, dest_addr) < 0)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 goto inv;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 while (isspace(*cp))
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 cp++;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 msgtext = cp;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 return(1);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
114 init_send_process()
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 {
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
116 if (initdone)
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
117 return(0);
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
118 atinterf_init();
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
119 /* enable verbose error messages */
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 383
diff changeset
120 atinterf_exec_cmd_needok("AT+CMEE=2", (char *) 0, (void *) 0);
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
121 if (text_mode)
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
122 prep_for_text_mode();
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
123 else
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
124 prep_for_pdu_mode();
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
125 if (sms_write_mode == 0)
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 383
diff changeset
126 atinterf_exec_cmd_needok("AT+CMMS=1", (char *) 0, (void *) 0);
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
127 initdone = 1;
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
128 return(1);
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
129 }
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
130
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
131 process_msg_gsm7()
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
132 {
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
133 u_char msgtext_gsm7[160];
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
134 unsigned msgtext_gsmlen;
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 int rc;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 if (utf8_input && utf8_to_latin1(msgtext) < 0) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 fprintf(stderr, "input line %d: invalid UTF-8 message\n",
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 lineno);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 if (text_mode) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 if (strlen(msgtext) > 160) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 toolong: fprintf(stderr,
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 "input line %d: message exceeds 160 chars\n",
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 lineno);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 }
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
149 init_send_process();
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
150 send_in_text_mode(dest_addr, msgtext);
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 return(0);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 }
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
153 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen,
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
154 allow_escape);
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 if (rc == -1) {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 fprintf(stderr,
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 "input line %d: message not valid for GSM7 charset\n",
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 lineno);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 exit(ERROR_USAGE);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 if (rc == -2)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 goto toolong;
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
163 if (rc == -3) {
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
164 fprintf(stderr,
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
165 "input line %d: message contains invalid backslash escape\n",
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
166 lineno);
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
167 exit(ERROR_USAGE);
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
168 }
382
88131632ce48 fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents: 373
diff changeset
169 init_send_process();
965
2969032bdfac fcup-smsend[mult]: fix buglet in K&R C NULL pointer passing
Mychaela Falconia <falcon@freecalypso.org>
parents: 467
diff changeset
170 send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen,
2969032bdfac fcup-smsend[mult]: fix buglet in K&R C NULL pointer passing
Mychaela Falconia <falcon@freecalypso.org>
parents: 467
diff changeset
171 (u_char *) 0, 0);
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 return(0);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174
383
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
175 process_msg_ucs2()
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
176 {
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
177 u_short msgtext_uni[70];
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
178 unsigned msgtext_unilen;
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
179 int rc;
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
180
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
181 rc = utf8_to_ucs2(msgtext, msgtext_uni, 70, &msgtext_unilen,
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
182 allow_escape);
383
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
183 if (rc == -1) {
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
184 fprintf(stderr, "input line %d: invalid UTF-8 message\n",
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
185 lineno);
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
186 exit(ERROR_USAGE);
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
187 }
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
188 if (rc == -2) {
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
189 fprintf(stderr,
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
190 "input line %d: message exceeds 70 UCS-2 chars\n",
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
191 lineno);
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
192 exit(ERROR_USAGE);
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
193 }
968
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
194 if (rc == -3) {
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
195 fprintf(stderr,
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
196 "input line %d: message contains invalid backslash escape\n",
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
197 lineno);
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
198 exit(ERROR_USAGE);
ec736c59845c fcup-smsendmult: support -e like plain fcup-smsend
Mychaela Falconia <falcon@freecalypso.org>
parents: 967
diff changeset
199 }
383
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
200 init_send_process();
965
2969032bdfac fcup-smsend[mult]: fix buglet in K&R C NULL pointer passing
Mychaela Falconia <falcon@freecalypso.org>
parents: 467
diff changeset
201 send_pdu_ucs2(dest_addr, msgtext_uni, msgtext_unilen, (u_char *) 0, 0);
383
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
202 return(0);
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
203 }
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
204
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 main(argc, argv)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 char **argv;
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 {
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 process_cmdline(argc, argv);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 for (lineno = 1; fgets(input_line, sizeof input_line, stdin); lineno++){
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 preen_input_line();
383
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
211 if (ucs2_mode)
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
212 process_msg_ucs2();
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
213 else
f8c693d16978 fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 382
diff changeset
214 process_msg_gsm7();
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 }
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 if (!initdone)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 exit(0);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 if (sms_write_mode == 0)
467
dc2fd8e6f42c uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents: 383
diff changeset
219 atinterf_exec_cmd_needok("AT+CMMS=0", (char *) 0, (void *) 0);
373
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 if (sms_write_mode == 1)
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 sendafterwr_process();
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 exit(0);
1fa4dcbb1c87 fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 }