annotate libcoding/alpha_addr_enc.c @ 31:19476164c54d

doc/SMS-PDU-decoding: document imported utilities
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 Jun 2024 18:48:58 +0000
parents c8cb05b69118
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
26
c8cb05b69118 libcoding alpha addr: support both encoding and decoding
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
8 extern u_char alpha_septets_to_digits[12];
15
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 }