changeset 3002:9f765960fca6 HEAD

If strtoull() isn't supported, fallback to strtouq(). If that's not found either, use our own implementation.
author Timo Sirainen <tss@iki.fi>
date Mon, 20 Dec 2004 06:39:47 +0200
parents d86d770ffb85
children 95fad52fec69
files configure.in src/lib/compat.c src/lib/compat.h
diffstat 3 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Sun Dec 19 10:33:58 2004 +0200
+++ b/configure.in	Mon Dec 20 06:39:47 2004 +0200
@@ -1,4 +1,4 @@
-AC_INIT(dovecot, 1.0-test52, [dovecot@dovecot.org])
+AC_INIT(dovecot, 1.0-test59, [dovecot@dovecot.org])
 AC_CONFIG_SRCDIR([src])
 
 AC_CONFIG_HEADERS([config.h])
@@ -258,7 +258,7 @@
 dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
 AC_CHECK_FUNCS(fcntl flock lockf inet_aton sigaction getpagesize madvise \
                strcasecmp stricmp vsnprintf vsyslog writev pread \
-	       setrlimit setproctitle seteuid setreuid)
+	       setrlimit setproctitle seteuid setreuid strtoull strtouq)
 
 dnl * I/O loop function
 have_ioloop=no
--- a/src/lib/compat.c	Sun Dec 19 10:33:58 2004 +0200
+++ b/src/lib/compat.c	Mon Dec 20 06:39:47 2004 +0200
@@ -11,6 +11,7 @@
 #include "lib.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -184,3 +185,26 @@
 	return p == NULL ? path : p + 1;
 }
 #endif
+
+#ifndef HAVE_STRTOULL
+unsigned long long int my_strtoull(const char *nptr, char **endptr, int base)
+{
+#ifdef HAVE_STRTOUQ
+	return strtouq(nptr, endptr, base);
+#else
+	unsigned long ret = 0;
+
+	/* we support only base-10 in our fallback implementation.. */
+	i_assert(base == 10);
+
+	for (; *nptr != '\0'; nptr++) {
+		if (*nptr < '0' || *nptr > '9')
+			break;
+		ret = ret * 10 + (*nptr - '0');
+	}
+	if (endptr != NULL)
+		*endptr = (char *)nptr;
+	return ret;
+#endif
+}
+#endif
--- a/src/lib/compat.h	Sun Dec 19 10:33:58 2004 +0200
+++ b/src/lib/compat.h	Mon Dec 20 06:39:47 2004 +0200
@@ -118,6 +118,11 @@
 char *my_basename(char *path);
 #endif
 
+#ifndef HAVE_STRTOULL
+#  define strtoull my_strtoull
+unsigned long long int my_strtoull(const char *nptr, char **endptr, int base);
+#endif
+
 /* ctype.h isn't safe with signed chars,
    use our own instead if really needed */
 #define i_toupper(x) ((char) toupper((int) (unsigned char) (x)))