2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid
[] = "@(#)getlong.c 10.3 (Sleepycat) 4/10/98";
14 #ifndef NO_SYSTEM_INCLUDES
25 * Return a long value inside of basic parameters.
27 * PUBLIC: void get_long __P((char *, long, long, long *));
30 get_long(p
, min
, max
, storep
)
32 long min
, max
, *storep
;
38 val
= strtol(p
, &end
, 10);
39 if ((val
== LONG_MIN
|| val
== LONG_MAX
) && errno
== ERANGE
)
41 if (p
[0] == '\0' || end
[0] != '\0')
42 errx(1, "%s: Invalid numeric argument", p
);
44 errx(1, "%s: Less than minimum value (%ld)", p
, min
);
46 errx(1, "%s: Greater than maximum value (%ld)", p
, max
);