From: Adam Dickmeiss Date: Thu, 3 Dec 2009 22:15:15 +0000 (+0100) Subject: Add odr_atoi - like atoi but returns Odr_int X-Git-Tag: v4.0.0~90 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=6278ee39573b69b59333a876c52671d0ebbca320 Add odr_atoi - like atoi but returns Odr_int --- 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