view target-utils/libcommon/hexarg.c @ 1014:961efadd530a default tip

fc-shell TCH DL handler: add support for CSD modes TCH DL capture mechanism in FC Tourmaline firmware has been extended to support CSD modes in addition to speech - add the necessary support on the host tools side. It needs to be noted that this mechanism in its present state does NOT provide the debug utility value that was sought: as we learned only after the code was implemented, TI's DSP has a misfeature in that the buffer we are reading (a_dd_0[]) is zeroed out when the IDS block is enabled, i.e., we are reading all zeros and not the real DL bits we were after. But since the code has already been written, we are keeping it - perhaps we can do some tests with IDS disabled.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Nov 2024 06:27:43 +0000
parents e7502631a0f9
children
line wrap: on
line source

/*
 * Many commands take hex arguments.  This module contains the parse_hexarg()
 * function, which is a wrapper around strtoul that performs some additional
 * checks.
 */

#include <sys/types.h>
#include <ctype.h>
#include <stdlib.h>

parse_hexarg(arg, maxdigits, valp)
	char *arg;
	int maxdigits;
	u_long *valp;
{
	char *cp = arg, *bp;
	int len;

	if (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X'))
		cp += 2;
	for (bp = cp; *cp; cp++)
		if (!isxdigit(*cp))
			return(-1);
	len = cp - bp;
	if (len < 1 || len > maxdigits)
		return(-1);
	*valp = strtoul(arg, 0, 16);
	return(0);
}