From f2891d8771cb23cc70d973c6785bec20e31f511e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 2 Mar 2010 12:29:46 +0100 Subject: [PATCH] Add odr_strtol (strtol for Odr_int). --- include/yaz/odr.h | 2 ++ src/odr_mem.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/yaz/odr.h b/include/yaz/odr.h index 8d8cc49..eb12dd4 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -342,6 +342,8 @@ YAZ_EXPORT const char **odr_get_element_path(ODR o); YAZ_EXPORT Odr_int odr_atoi(const char *s); +YAZ_EXPORT Odr_int odr_strtol(const char *nptr, char **endptr, int base); + YAZ_END_CDECL #include diff --git a/src/odr_mem.c b/src/odr_mem.c index 88f012c..9972c10 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -125,21 +125,26 @@ int odr_seek(ODR o, int whence, int offset) return 0; } -Odr_int odr_atoi(const char *s) +Odr_int odr_strtol(const char *nptr, char **endptr, int base) { #if NMEM_64 - char *endptr; #if WIN32 - return _strtoui64(s, &endptr, 10); + return _strtoui64(nptr, endptr, base); #else - return strtoll(s, &endptr, 10); + return strtoll(nptr, endptr, base); #endif #else - return atoi(s); + return strtol(nptr, endptr, base); #endif } +Odr_int odr_atoi(const char *s) +{ + char *endptr; + return odr_strtol(s, &endptr, 10); +} + /* * Local variables: * c-basic-offset: 4 -- 1.7.10.4