From 6278ee39573b69b59333a876c52671d0ebbca320 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 3 Dec 2009 23:15:15 +0100 Subject: [PATCH] Add odr_atoi - like atoi but returns Odr_int --- include/yaz/odr.h | 2 ++ src/odr_mem.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/yaz/odr.h b/include/yaz/odr.h index b6abe59..ac554fc 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -340,6 +340,8 @@ YAZ_EXPORT void odr_printf(ODR o, const char *fmt, ...); YAZ_EXPORT const char **odr_get_element_path(ODR o); +YAZ_EXPORT Odr_int odr_atoi(const char *s); + YAZ_END_CDECL #include diff --git a/src/odr_mem.c b/src/odr_mem.c index 028d06d..555c443 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -124,6 +124,22 @@ int odr_seek(ODR o, int whence, int offset) o->pos = offset; return 0; } + +Odr_int odr_atoi(const char *s) +{ +#if NMEM_64 + char *endptr; +#if WIN32 + return _strtoui64(s, &endptr, 10); +#else + return strtoll(s, &endptr, 10); +#endif + +#else + return atoi(s); +#endif +} + /* * Local variables: * c-basic-offset: 4 -- 1.7.10.4