#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/lib/gen/atoip.c,v 2.0 1995/07/27 05:56:17 empire Exp $";
#endif

/*
** Atoip - convert from decimal string to integer.
**	- use pointer to pointer to chars and update it.
**
** from PSL Empire, 1985
*/

#include "misc.h"

atoip(ptrptr)
	s_char **ptrptr;
{
	register int num;
	register s_char *cp;
	register int neg;

	if (ptrptr == 0 || *ptrptr == 0) return 0;
	cp = *ptrptr;
	num = 0;
	neg = 0;
loop:
	while (*cp == ' ' || *cp == '\t')
		cp++;
	if (*cp == '-') {
		neg++;
		cp++;
		goto loop;
	}
	while (*cp >= '0' && *cp <= '9')
		num = num * 10 + *cp++ - '0';
	*ptrptr = cp;
	return(neg ? -num : num);
}
