FreeCalypso > hg > freecalypso-tools
annotate uptools/atcmd/smsend_multmain.c @ 374:d1fa771abeb8
uptools: make_sms_submit_pdu() in libcoding now takes PID and DCS arguments
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Mar 2018 20:33:03 +0000 |
parents | 1fa4dcbb1c87 |
children | 88131632ce48 |
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 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 int sms_write_mode, text_mode, utf8_input; |
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; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 u_char msgtext_gsm7[160]; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 unsigned msgtext_gsmlen; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 process_cmdline(argc, argv) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 char **argv; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 int c; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 extern int optind; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 while ((c = getopt(argc, argv, "B:np:RtuwWX:")) != EOF) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (atinterf_cmdline_opt(c)) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 continue; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 switch (c) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 case 't': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 text_mode = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 continue; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 case 'u': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 utf8_input = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 continue; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 case 'w': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 sms_write_mode = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 continue; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 case 'W': |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 sms_write_mode = 2; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 continue; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 default: |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 /* error msg already printed */ |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (argc > optind + 1) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 fprintf(stderr, "usage: %s [options] [dest-addr]\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 argv[0]); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (argv[optind]) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 dest_addr_global = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 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
|
57 fprintf(stderr, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 "error: destination address argument is invalid\n"); |
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 } else |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 dest_addr_global = 0; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 preen_input_line() |
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 char *cp; |
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 cp = index(input_line, '\n'); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 if (!cp) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 fprintf(stderr, "input line %d: too long or unterminated\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 *cp = '\0'; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 if (dest_addr_global) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 msgtext = input_line; |
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 if (!input_line[0] || isspace(input_line[0])) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 inv: fprintf(stderr, "input line %d: invalid syntax\n", lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 for (cp = input_line; *cp && !isspace(*cp); cp++) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 ; |
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 goto inv; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 *cp++ = '\0'; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 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
|
91 goto inv; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 while (isspace(*cp)) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 cp++; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 msgtext = cp; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 return(1); |
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 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 preen_message() |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 int rc; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 if (utf8_input && utf8_to_latin1(msgtext) < 0) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 fprintf(stderr, "input line %d: invalid UTF-8 message\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 if (text_mode) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 if (strlen(msgtext) > 160) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 toolong: fprintf(stderr, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 "input line %d: message exceeds 160 chars\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 rc = latin1_to_gsm7(msgtext, msgtext_gsm7, 160, &msgtext_gsmlen); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 if (rc == -1) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 fprintf(stderr, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 "input line %d: message not valid for GSM7 charset\n", |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 lineno); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 exit(ERROR_USAGE); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 if (rc == -2) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 goto toolong; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 return(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 } |
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 init_send_process() |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 atinterf_init(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 /* enable verbose error messages */ |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 atinterf_exec_cmd_needok("AT+CMEE=2", 0, 0); |
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 prep_for_text_mode(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 else |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 prep_for_pdu_mode(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 if (sms_write_mode == 0) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 atinterf_exec_cmd_needok("AT+CMMS=1", 0, 0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 main(argc, argv) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 char **argv; |
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 int initdone = 0; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 process_cmdline(argc, argv); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 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
|
148 preen_input_line(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 preen_message(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 if (!initdone) { |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 init_send_process(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 initdone = 1; |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 if (text_mode) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 send_in_text_mode(dest_addr, msgtext); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 else |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 send_in_pdu_mode(dest_addr, msgtext_gsm7, |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 msgtext_gsmlen, 0, 0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 } |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 if (!initdone) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 exit(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 if (sms_write_mode == 0) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 atinterf_exec_cmd_needok("AT+CMMS=0", 0, 0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 if (sms_write_mode == 1) |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 sendafterwr_process(); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 exit(0); |
1fa4dcbb1c87
fcup-smsendmult program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 } |