2014-06-04 12:07:34 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
unsigned long
|
|
|
|
estrtoul(const char *s, int base)
|
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
unsigned long n;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
n = strtoul(s, &end, base);
|
2014-07-09 15:39:32 +00:00
|
|
|
if (*end != '\0') {
|
|
|
|
if (base == 0)
|
2014-06-04 12:07:34 +00:00
|
|
|
eprintf("%s: not an integer\n", s);
|
|
|
|
else
|
|
|
|
eprintf("%s: not a base %d integer\n", s, base);
|
|
|
|
}
|
2014-07-09 15:39:32 +00:00
|
|
|
if (errno != 0)
|
2014-06-04 12:07:34 +00:00
|
|
|
eprintf("%s:", s);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|