FreeCalypso > hg > sms-coding-utils
annotate libcoding/alpha_addr.c @ 17:dc1cc851025c
scripts: add support for new first octet flags
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 Aug 2023 07:39:14 +0000 |
parents | 5854e48d0ef7 |
children | c8cb05b69118 |
rev | line source |
---|---|
15
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This library module implements encoding of alphanumeric From addresses |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * that are allowed in SMS-DELIVER TPDUs. |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 u_char alpha_septets_to_digits[12] = {0, 2, 4, 6, 7, 9, 11, 13, 14, 16, 18, 20}; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 encode_alpha_addr(arg, bin) |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 char *arg; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 u_char *bin; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u_char gsm7[11]; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 rc = qstring_arg_to_gsm7(arg, gsm7, 11); |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (rc < 0) |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 return(rc); |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 bin[0] = alpha_septets_to_digits[rc]; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 bin[1] = 0x50; |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 gsm7_pack(gsm7, bin + 2, (bin[0] + 1) >> 1); |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return(0); |
5854e48d0ef7
sms-gen-tpdu: add support for alphanumeric user-addr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |