annotate libcoding/check_high_bit.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 0fe95ca922c7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The function implemented in this module is intended for validating inputs
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * that are expected to be in the form of GSM7 characters carried in an octet
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * string, where the high bit of every octet is expected to be cleared.
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 check_high_bit(buf, len)
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 u_char *buf;
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned len;
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 unsigned n;
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 for (n = 0; n < len; n++) {
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (buf[n] & 0x80)
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 return(-1);
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 }
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return(0);
0fe95ca922c7 sms-gen-tpdu: check the high bit of GSM7 msg input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }