Index: configure.ac
===================================================================
RCS file: /cvsroot/curl/curl/configure.ac,v
retrieving revision 1.300
diff -u -r1.300 configure.ac
--- configure.ac	26 May 2008 15:09:28 -0000	1.300
+++ configure.ac	26 May 2008 22:33:51 -0000
@@ -33,7 +33,7 @@
 terms of the curl license; see COPYING for more details])
 
 AC_CONFIG_SRCDIR([lib/urldata.h])
-AM_CONFIG_HEADER(lib/config.h src/config.h)
+AM_CONFIG_HEADER(lib/config.h src/config.h include/curl/config.h)
 AM_MAINTAINER_MODE
 
 dnl SED is needed by some of the tools
@@ -1977,6 +1977,13 @@
    longlong="yes"
 )
 
+dnl Generate new CURL-prefixed defines for use in external headers
+AC_DEFINE_UNQUOTED(CURL_SIZEOF_CURL_OFF_T, $ac_cv_sizeof_curl_off_t,
+          [The size of curl_off_t as computed by sizeof.])
+AC_DEFINE_UNQUOTED(CURL_SIZEOF_LONG, $ac_cv_sizeof_long,
+          [The size of long as computed by sizeof.])
+
+
 if test "xyes" = "x$longlong"; then
   AC_MSG_CHECKING([if numberLL works])
   AC_COMPILE_IFELSE([long long val = 1000LL;],
Index: include/curl/config.h.dist
===================================================================
RCS file: include/curl/config.h.dist
diff -N include/curl/config.h.dist
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/curl/config.h.dist	26 May 2008 22:33:51 -0000
@@ -0,0 +1,69 @@
+#ifndef __CURL_CONFIG_H
+#define __CURL_CONFIG_H
+
+/*
+ * NOTE:
+ * This file is copied from include/curl/config.h.dist to include/curl/config.h
+ * when the distribution archive is made.
+ * It might then be overwritten by the configure process on platforms where that
+ * works and is used.
+ * If you check out from CVS on a non-configure platform, run the suitable
+ * buildconf* script to set up the local files.
+ */
+
+#define CURL_SIZEOF_LONG 4
+
+#if (defined(_MSC_VER) && !defined(__POCC__)) || (defined(__LCC__) && \
+     defined(WIN32))
+/* MSVC */
+#ifdef _WIN32_WCE
+#define CURL_SIZEOF_CURL_OFF_T 4
+#else
+#define CURL_SIZEOF_CURL_OFF_T 8 /* uses __int64 */
+#endif
+#else /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */
+#if (defined(__GNUC__) && defined(WIN32)) || defined(__WATCOMC__)
+/* gcc on windows or Watcom */
+#define CURL_SIZEOF_CURL_OFF_T 8 /* uses long long */
+#else /* GCC or Watcom on Windows  */
+#if defined(__ILEC400__)
+/* OS400 C compiler. */
+#define CURL_SIZEOF_CURL_OFF_T 8 /* uses long long */
+#define CURL_FORMAT_OFF_T "%lld"
+#else /* OS400 C compiler. */
+
+/* Check a range of defines to detect large file support. On Linux it seems
+   none of these are set by default, so if you don't explicitly switches on
+   large file support, this define will be made for "small file" support. */
+#ifndef _FILE_OFFSET_BITS
+#define _FILE_OFFSET_BITS 0 /* to prevent warnings in the check below */
+#define UNDEF_FILE_OFFSET_BITS
+#endif
+#ifndef FILESIZEBITS
+#define FILESIZEBITS 0 /* to prevent warnings in the check below */
+#define UNDEF_FILESIZEBITS
+#endif
+
+#if defined(_LARGE_FILES) || (_FILE_OFFSET_BITS > 32) || (FILESIZEBITS > 32) \
+   || defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)
+  /* For now, we assume at least one of these to be set for large files to
+     work! */
+#define CURL_SIZEOF_CURL_OFF_T 8
+#else /* LARGE_FILE support */
+#define CURL_SIZEOF_CURL_OFF_T 4
+#endif
+#endif /* OS400 C compiler. */
+#endif /* GCC or Watcom on Windows */
+#endif /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */
+
+#ifdef UNDEF_FILE_OFFSET_BITS
+/* this was defined above for our checks, undefine it again */
+#undef _FILE_OFFSET_BITS
+#endif
+
+#ifdef UNDEF_FILESIZEBITS
+/* this was defined above for our checks, undefine it again */
+#undef FILESIZEBITS
+#endif
+
+#endif /* __CURL_CONFIG_H */
Index: include/curl/config.h.in
===================================================================
RCS file: include/curl/config.h.in
diff -N include/curl/config.h.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/curl/config.h.in	26 May 2008 22:33:51 -0000
@@ -0,0 +1,11 @@
+#ifndef __CURL_CONFIG_H
+#define __CURL_CONFIG_H
+
+/* The size of curl_off_t as computed by sizeof */
+#undef CURL_SIZEOF_CURL_OFF_T
+
+/* The size of long as computed by sizeof */
+#undef CURL_SIZEOF_LONG
+
+#endif /* __CURL_CONFIG_H */
+
Index: include/curl/curl.h
===================================================================
RCS file: /cvsroot/curl/curl/include/curl/curl.h,v
retrieving revision 1.351
diff -u -r1.351 curl.h
--- include/curl/curl.h	20 May 2008 10:21:50 -0000	1.351
+++ include/curl/curl.h	26 May 2008 22:33:52 -0000
@@ -28,6 +28,7 @@
 */
 
 #include "curlver.h" /* the libcurl version defines */
+#include "config.h"  /* the libcurl CURL_SIZEOF_* defines */
 
 /*
  * Define WIN32 when build target is Win32 API
@@ -127,19 +128,23 @@
 #ifdef _WIN32_WCE
   typedef long curl_off_t;
 #define CURL_FORMAT_OFF_T "%ld"
+#define CURL_DETECT_OFF_T 4 /* guessed size */
 #else
   typedef signed __int64 curl_off_t;
 #define CURL_FORMAT_OFF_T "%I64d"
+#define CURL_DETECT_OFF_T 8 /* guessed size */
 #endif
 #else /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */
 #if (defined(__GNUC__) && defined(WIN32)) || defined(__WATCOMC__)
 /* gcc on windows or Watcom */
   typedef long long curl_off_t;
+#define CURL_DETECT_OFF_T 8 /* guessed size */
 #define CURL_FORMAT_OFF_T "%I64d"
 #else /* GCC or Watcom on Windows  */
 #if defined(__ILEC400__)
 /* OS400 C compiler. */
   typedef long long curl_off_t;
+#define CURL_DETECT_OFF_T 8 /* guessed size */
 #define CURL_FORMAT_OFF_T "%lld"
 #else /* OS400 C compiler. */
 
@@ -163,8 +168,10 @@
    || defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)
   /* For now, we assume at least one of these to be set for large files to
      work! */
+#define CURL_DETECT_OFF_T 8 /* guessed size */
 #define CURL_FORMAT_OFF_T "%lld"
 #else /* LARGE_FILE support */
+#define CURL_DETECT_OFF_T 4 /* guessed size */
 #define CURL_FORMAT_OFF_T "%ld"
 #endif
 #endif /* OS400 C compiler. */
@@ -181,6 +188,29 @@
 #undef FILESIZEBITS
 #endif
 
+#ifndef SIZEOF_CURL_OFF_T
+/* If SIZEOF_CURL_OFF_T is set, we assume that a configure based config is
+   somehow in use already and then the following won't really be needed.
+   We need this to not make the conditions trigger for when building libcurl
+   itself! */
+
+/*
+ * Time to do some sanity checks of the curl_off_t size compared to what
+ * libcurl was built to use.
+ */
+#if CURL_SIZEOF_LONG != CURL_SIZEOF_CURL_OFF_T
+  /* this is only a matter if the two primary data types differ in size */
+# if CURL_SIZEOF_CURL_OFF_T < CURL_DETECT_OFF_T
+#  error "libcurl was built with a smaller curl_off_t type!"
+#else
+#  error "libcurl was built with a larger curl_off_t type!"
+#endif
+
+#endif /* CURL_SIZEOF_LONG != CURL_SIZEOF_CURL_OFF_T */
+
+#endif /* SIZEOF_CURL_OFF_T */
+
+
 #ifndef curl_socket_typedef
 /* socket typedef */
 #ifdef WIN32
