FreeCalypso > hg > freecalypso-tools
annotate uptools/atcmd/smsend_multmain.c @ 410:e3d976e1f814
loadtools/loadtool.help: update for FC devices having flash2
like the Pirelli DP-L10
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 25 Oct 2018 18:19:02 +0000 |
parents | f8c693d16978 |
children | dc2fd8e6f42c |
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 |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
14 int sms_write_mode, text_mode, utf8_input, ucs2_mode; |
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 |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
27 while ((c = getopt(argc, argv, "B:np: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) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 case 't': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 text_mode = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 continue; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 case 'u': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 utf8_input = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 continue; |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
37 case 'U': |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
38 ucs2_mode = 1; |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
39 continue; |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 case 'w': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 sms_write_mode = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 continue; |
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 = 2; |
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 default: |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* error msg already printed */ |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
51 if (ucs2_mode && text_mode) { |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
52 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
|
53 argv[0]); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
54 exit(ERROR_USAGE); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
55 } |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 if (argc > optind + 1) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 fprintf(stderr, "usage: %s [options] [dest-addr]\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 argv[0]); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 if (argv[optind]) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 dest_addr_global = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 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
|
64 fprintf(stderr, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 "error: destination address argument is invalid\n"); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } else |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 dest_addr_global = 0; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 preen_input_line() |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 char *cp; |
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 cp = index(input_line, '\n'); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 if (!cp) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 fprintf(stderr, "input line %d: too long or unterminated\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 *cp = '\0'; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 if (dest_addr_global) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 msgtext = input_line; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 if (!input_line[0] || isspace(input_line[0])) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 inv: fprintf(stderr, "input line %d: invalid syntax\n", 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 for (cp = input_line; *cp && !isspace(*cp); cp++) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 ; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 if (!*cp) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 goto inv; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 *cp++ = '\0'; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 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
|
98 goto inv; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 while (isspace(*cp)) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 cp++; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 msgtext = cp; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 return(1); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
105 init_send_process() |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 { |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
107 if (initdone) |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
108 return(0); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
109 atinterf_init(); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
110 /* enable verbose error messages */ |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
111 atinterf_exec_cmd_needok("AT+CMEE=2", 0, 0); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
112 if (text_mode) |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
113 prep_for_text_mode(); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
114 else |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
115 prep_for_pdu_mode(); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
116 if (sms_write_mode == 0) |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
117 atinterf_exec_cmd_needok("AT+CMMS=1", 0, 0); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
118 initdone = 1; |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
119 return(1); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
120 } |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
121 |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
122 process_msg_gsm7() |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
123 { |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
124 u_char msgtext_gsm7[160]; |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
125 unsigned msgtext_gsmlen; |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 int rc; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 if (utf8_input && utf8_to_latin1(msgtext) < 0) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 fprintf(stderr, "input line %d: invalid UTF-8 message\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (text_mode) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 if (strlen(msgtext) > 160) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 toolong: fprintf(stderr, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 "input line %d: message exceeds 160 chars\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
140 init_send_process(); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
141 send_in_text_mode(dest_addr, msgtext); |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 if (rc == -1) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 fprintf(stderr, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 "input line %d: message not valid for GSM7 charset\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 if (rc == -2) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 goto toolong; |
382
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
153 init_send_process(); |
88131632ce48
fcup-smsendmult: preparations for adding UCS-2 support
Mychaela Falconia <falcon@freecalypso.org>
parents:
373
diff
changeset
|
154 send_in_pdu_mode(dest_addr, msgtext_gsm7, msgtext_gsmlen, 0, 0); |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 |
383
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
158 process_msg_ucs2() |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
159 { |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
160 u_short msgtext_uni[70]; |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
161 unsigned msgtext_unilen; |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
162 int rc; |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
163 |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
164 rc = utf8_to_ucs2(msgtext, msgtext_uni, 70, &msgtext_unilen); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
165 if (rc == -1) { |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
166 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
|
167 lineno); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
168 exit(ERROR_USAGE); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
169 } |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
170 if (rc == -2) { |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
171 fprintf(stderr, |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
172 "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
|
173 lineno); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
174 exit(ERROR_USAGE); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
175 } |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
176 init_send_process(); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
177 send_pdu_ucs2(dest_addr, msgtext_uni, msgtext_unilen, 0, 0); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
178 return(0); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
179 } |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
180 |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 main(argc, argv) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 char **argv; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 process_cmdline(argc, argv); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 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
|
186 preen_input_line(); |
383
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
187 if (ucs2_mode) |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
188 process_msg_ucs2(); |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
189 else |
f8c693d16978
fcup-smsendmult: UCS-2 send mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
382
diff
changeset
|
190 process_msg_gsm7(); |
373
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 if (!initdone) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 exit(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 if (sms_write_mode == 0) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 atinterf_exec_cmd_needok("AT+CMMS=0", 0, 0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 if (sms_write_mode == 1) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 sendafterwr_process(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 exit(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |