xref: /illumos-gate/usr/src/cmd/ipf/lib/common/ratoi.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
5*7c478bd9Sstevel@tonic-gate  *
6*7c478bd9Sstevel@tonic-gate  * $Id: ratoi.c,v 1.4 2001/06/09 17:09:25 darrenr Exp $
7*7c478bd9Sstevel@tonic-gate  */
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate #include "ipf.h"
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate 
ratoi(ps,pi,min,max)12*7c478bd9Sstevel@tonic-gate int	ratoi(ps, pi, min, max)
13*7c478bd9Sstevel@tonic-gate char 	*ps;
14*7c478bd9Sstevel@tonic-gate int	*pi, min, max;
15*7c478bd9Sstevel@tonic-gate {
16*7c478bd9Sstevel@tonic-gate 	int i;
17*7c478bd9Sstevel@tonic-gate 	char *pe;
18*7c478bd9Sstevel@tonic-gate 
19*7c478bd9Sstevel@tonic-gate 	i = (int)strtol(ps, &pe, 0);
20*7c478bd9Sstevel@tonic-gate 	if (*pe != '\0' || i < min || i > max)
21*7c478bd9Sstevel@tonic-gate 		return 0;
22*7c478bd9Sstevel@tonic-gate 	*pi = i;
23*7c478bd9Sstevel@tonic-gate 	return 1;
24*7c478bd9Sstevel@tonic-gate }
25