FreeCalypso > hg > sms-coding-utils
diff libcoding/check_high_bit.c @ 12:0fe95ca922c7
sms-gen-tpdu: check the high bit of GSM7 msg input
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 05 Aug 2023 16:55:24 +0000 (21 months ago) |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libcoding/check_high_bit.c Sat Aug 05 16:55:24 2023 +0000 @@ -0,0 +1,20 @@ +/* + * The function implemented in this module is intended for validating inputs + * that are expected to be in the form of GSM7 characters carried in an octet + * string, where the high bit of every octet is expected to be cleared. + */ + +#include <sys/types.h> + +check_high_bit(buf, len) + u_char *buf; + unsigned len; +{ + unsigned n; + + for (n = 0; n < len; n++) { + if (buf[n] & 0x80) + return(-1); + } + return(0); +}