Add odr_atoi - like atoi but returns Odr_int
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 3 Dec 2009 22:15:15 +0000 (23:15 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 3 Dec 2009 22:15:15 +0000 (23:15 +0100)
include/yaz/odr.h
src/odr_mem.c

index b6abe59..ac554fc 100644 (file)
@@ -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 const char **odr_get_element_path(ODR o);
 
+YAZ_EXPORT Odr_int odr_atoi(const char *s);
+
 YAZ_END_CDECL
 
 #include <yaz/xmalloc.h>
 YAZ_END_CDECL
 
 #include <yaz/xmalloc.h>
index 028d06d..555c443 100644 (file)
@@ -124,6 +124,22 @@ int odr_seek(ODR o, int whence, int offset)
     o->pos = offset;
     return 0;
 }
     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
 /*
  * Local variables:
  * c-basic-offset: 4