view libcoding/check_high_bit.c @ 27:7418ca2e9949

libcoding: add functions from freecalypso-tools/uptools/libcoding that are needed for sms-pdu-decode & pcm-sms-decode
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Jun 2024 02:29:29 +0000
parents 0fe95ca922c7
children
line wrap: on
line source

/*
 * 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);
}