提交 d56aff52 编写于 作者: D Daniel P. Berrange

Added xstrtol_ll and xstrtol_ull convenience functions

上级 e05a8790
Sun Jan 20 11:01:22 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/internal.h: Add xstrtol_ull, xstrtol_ll convenience
functions
Sun Jan 20 10:54:22 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/xend_internal.c: Fix nodeinfo compat with Xen 3.2.0 and
......
......@@ -308,6 +308,42 @@ xstrtol_ui(char const *s, char **end_ptr, int base, unsigned int *result)
return 0;
}
static inline int
xstrtol_ll(char const *s, char **end_ptr, int base, long long *result)
{
long long val;
char *p;
int err;
errno = 0;
val = strtoll(s, &p, base);
err = (errno || (!end_ptr && *p) || p == s || (long long) val != val);
if (end_ptr)
*end_ptr = p;
if (err)
return -1;
*result = val;
return 0;
}
/* Just like xstrtol_i, above, but produce an "unsigned long long" value. */
static inline int
xstrtol_ull(char const *s, char **end_ptr, int base, unsigned long long *result)
{
unsigned long long val;
char *p;
int err;
errno = 0;
val = strtoull(s, &p, base);
err = (errno || (!end_ptr && *p) || p == s || (unsigned long long) val != val);
if (end_ptr)
*end_ptr = p;
if (err)
return -1;
*result = val;
return 0;
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册