libfuse
util.c
1#include <stdlib.h>
2#include <errno.h>
3
4#ifndef FUSE_USE_VERSION
5#define FUSE_USE_VERSION (FUSE_MAKE_VERSION(3, 18))
6#endif
7
8#include "util.h"
9#include "fuse_log.h"
10#include "fuse_lowlevel.h"
11#include <stdio.h>
12
13int libfuse_strtol(const char *str, long *res)
14{
15 char *endptr;
16 int base = 10;
17 long val;
18
19 errno = 0;
20
21 if (!str)
22 return -EINVAL;
23
24 val = strtol(str, &endptr, base);
25
26 if (errno)
27 return -errno;
28
29 if (endptr == str || *endptr != '\0')
30 return -EINVAL;
31
32 *res = val;
33 return 0;
34}
35