libfuse

util.c
1#include <stdlib.h>
2#include <errno.h>
3
4#include "util.h"
5
6 int libfuse_strtol(const char *str, long *res)
7{
8 char *endptr;
9 int base = 10;
10 long val;
11
12 errno = 0;
13
14 if (!str)
15 return -EINVAL;
16
17 val = strtol(str, &endptr, base);
18
19 if (errno)
20 return -errno;
21
22 if (endptr == str || *endptr != '\0')
23 return -EINVAL;
24
25 *res = val;
26 return 0;
27}