--- libupnp/configure.ac	2006-03-06 07:59:33.000000000 +1100
+++ libupnp-1.4.0/configure.ac	2006-05-03 16:34:48.000000000 +1000
@@ -10,7 +10,7 @@
 
 AC_PREREQ(2.59)
 
-AC_INIT([libupnp], [1.3.1], [r3mi@users.sourceforge.net])
+AC_INIT([libupnp], [1.4.0], [r3mi@users.sourceforge.net])
 # *Independently* of the above libupnp package version, the libtool version
 # of the 3 libraries need to be updated whenever there is a change :
 # "current:revision:age" (this is NOT the same as the package version), where:
@@ -20,7 +20,7 @@
 # 	- interfaces removed:			age=0
 AC_SUBST([LT_VERSION_IXML],       [2:0:0])
 AC_SUBST([LT_VERSION_THREADUTIL], [2:0:0])
-AC_SUBST([LT_VERSION_UPNP],       [2:1:0])
+AC_SUBST([LT_VERSION_UPNP],       [3:1:0])
 
 
 AC_CONFIG_AUX_DIR(config.aux)
@@ -41,6 +41,7 @@
 #    installed libraries.
 #
 AC_CONFIG_HEADERS([autoconfig.h upnp/inc/upnpconfig.h])
+AC_SYS_LARGEFILE_SENSITIVE
 
 AC_REVISION([$Revision: 1.8 $])
 
@@ -124,9 +125,12 @@
 fi
 AX_CFLAGS_WARN_ALL
 
-# Arrange for large-file support (can be disabled with --disable-largefile).
-# Define _FILE_OFFSET_BITS and _LARGE_FILES if necessary
-AC_SYS_LARGEFILE
+#
+# Lot's of stuff to ensure large file support
+#
+AC_TYPE_OFF_T
+AC_DEFINE(_LARGE_FILE_SOURCE, [], [Large files support])
+AC_DEFINE(_FILE_OFFSET_BITS, [64], [File Offset size])
 
 
 #
diff -Naur -x '*.*o' -x 'bigfiles.patch~' libupnp/upnp/src/api/upnpapi.c libupnp-1.4.0/upnp/src/api/upnpapi.c
--- libupnp/upnp/src/api/upnpapi.c	2006-03-01 09:27:59.000000000 +1100
+++ libupnp-1.4.0/upnp/src/api/upnpapi.c	2006-04-23 13:55:28.000000000 +1000
@@ -902,7 +902,7 @@
     char aliasStr[LINE_SIZE];
     char *temp_str = NULL;
     FILE *fp = NULL;
-    unsigned fileLen;
+    off_t fileLen;
     unsigned num_read;
     time_t last_modified;
     struct stat file_info;
diff -Naur -x '*.*o' -x 'bigfiles.patch~' libupnp/upnp/src/genlib/net/http/httpreadwrite.c libupnp-1.4.0/upnp/src/genlib/net/http/httpreadwrite.c
--- libupnp/upnp/src/genlib/net/http/httpreadwrite.c	2006-03-06 04:58:50.000000000 +1100
+++ libupnp-1.4.0/upnp/src/genlib/net/http/httpreadwrite.c	2006-04-21 20:43:19.000000000 +1000
@@ -355,7 +355,7 @@
                     return UPNP_E_FILE_READ_ERROR;
                 }
             } else if( Instr && Instr->IsRangeActive ) {
-                if( fseek( Fp, Instr->RangeOffset, SEEK_CUR ) != 0 ) {
+                if( fseeko( Fp, Instr->RangeOffset, SEEK_CUR ) != 0 ) {
                     free( ChunkBuf );
                     return UPNP_E_FILE_READ_ERROR;
                 }
@@ -1619,6 +1619,7 @@
 *				memory ptr
 *		'c':	(no args) appends CRLF "\r\n"
 *		'd':	arg = int number		// appends decimal number
+*		'h':	arg = off_t number		// appends off_t number
 *		't':	arg = time_t * gmt_time	// appends time in RFC 1123 fmt
 *		'D':	(no args) appends HTTP DATE: header
 *		'S':	(no args) appends HTTP SERVER: header
@@ -1651,6 +1652,7 @@
     char c;
     char *s = NULL;
     int num;
+    off_t bignum;
     size_t length;
     time_t *loc_time;
     time_t curr_time;
@@ -1738,6 +1740,16 @@
             }
         }
 
+        else if( c == 'h' )     // off_t
+        {
+            bignum = ( off_t )va_arg( argp, off_t );
+
+            sprintf( tempbuf, "%lld", bignum );
+            if( membuffer_append( buf, tempbuf, strlen( tempbuf ) ) != 0 ) {
+                goto error_handler;
+            }
+        }
+
         else if( c == 't' || c == 'D' ) // date
         {
             if( c == 'D' ) {
@@ -1779,12 +1791,12 @@
 
         else if( c == 'N' ) {
             // content-length header
-            num = ( int )va_arg( argp, int );
+            bignum = ( off_t )va_arg( argp, off_t );
 
-            assert( num >= 0 );
+            assert( bignum >= 0 );
             if( http_MakeMessage
-                ( buf, http_major_version, http_minor_version, "sdc",
-                  "CONTENT-LENGTH: ", num ) != 0 ) {
+                ( buf, http_major_version, http_minor_version, "shc",
+                  "CONTENT-LENGTH: ", bignum ) != 0 ) {
                 goto error_handler;
             }
         }
@@ -1832,9 +1844,9 @@
                      "<html><body><h1>",
                      status_code, http_get_code_text( status_code ),
                      "</h1></body></html>" );
-            num = strlen( tempbuf );
+            bignum = strlen( tempbuf );
 
-            if( http_MakeMessage( buf, http_major_version, http_minor_version, "NTcs", num, // content-length
+            if( http_MakeMessage( buf, http_major_version, http_minor_version, "NTcs", bignum, // content-length
                                   "text/html",  // content-type
                                   tempbuf ) != 0 )  // body
             {
diff -Naur -x '*.*o' -x 'bigfiles.patch~' libupnp/upnp/src/genlib/net/http/webserver.c libupnp-1.4.0/upnp/src/genlib/net/http/webserver.c
--- libupnp/upnp/src/genlib/net/http/webserver.c	2006-02-23 08:38:03.000000000 +1100
+++ libupnp-1.4.0/upnp/src/genlib/net/http/webserver.c	2006-04-21 21:03:41.000000000 +1000
@@ -628,7 +628,7 @@
     rc = get_content_type( filename, &info->content_type );
 
     DBGONLY( UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
-                         "file info: %s, length: %d, last_mod=%s readable=%d\n",
+                         "file info: %s, length: %lld, last_mod=%s readable=%d\n",
                          filename, info->file_length,
                          asctime( gmtime( &info->last_modified ) ),
                          info->is_readable ); )
diff -Naur -x '*.*o' -x 'bigfiles.patch~' libupnp/upnp/src/inc/httpreadwrite.h libupnp-1.4.0/upnp/src/inc/httpreadwrite.h
--- libupnp/upnp/src/inc/httpreadwrite.h	2006-02-19 00:50:55.000000000 +1100
+++ libupnp-1.4.0/upnp/src/inc/httpreadwrite.h	2006-04-21 17:08:21.000000000 +1000
@@ -415,6 +415,7 @@
 *				memory ptr
 *		'c':	(no args) appends CRLF "\r\n"
 *		'd':	arg = int number		// appends decimal number
+*		'h':	arg = off_t number		// appends off_t number
 *		't':	arg = time_t * gmt_time	// appends time in RFC 1123 fmt
 *		'D':	(no args) appends HTTP DATE: header
 *		'S':	(no args) appends HTTP SERVER: header
diff -Naur -x '*.*o' -x 'bigfiles.patch~' libupnp/upnp/src/inc/webserver.h libupnp-1.4.0/upnp/src/inc/webserver.h
--- libupnp/upnp/src/inc/webserver.h	2003-02-14 03:19:20.000000000 +1100
+++ libupnp-1.4.0/upnp/src/inc/webserver.h	2006-04-21 21:00:42.000000000 +1000
@@ -48,8 +48,8 @@
    int  IsRangeActive;
    int  IsTrailers;
    char RangeHeader[200];
-   long RangeOffset;
-   long ReadSendSize;  // Read from local source and send on the network.
+   off_t RangeOffset;
+   off_t ReadSendSize;  // Read from local source and send on the network.
    long RecvWriteSize; // Recv from the network and write into local file.
 
    //Later few more member could be added depending on the requirement.
diff -Naur -x '*.*o' -x 'bigfiles.patch~' libupnp/upnp/src/soap/soap_device.c libupnp-1.4.0/upnp/src/soap/soap_device.c
--- libupnp/upnp/src/soap/soap_device.c	2006-02-23 08:38:04.000000000 +1100
+++ libupnp-1.4.0/upnp/src/soap/soap_device.c	2006-04-23 11:06:17.000000000 +1000
@@ -182,7 +182,7 @@
                      IN const char *err_msg,
                      IN http_message_t * hmsg )
 {
-    int content_length;
+    off_t content_length;
     int timeout_secs = SOAP_TIMEOUT;
     int major,
       minor;
@@ -257,7 +257,7 @@
                          IN const char *var_value,
                          IN http_message_t * hmsg )
 {
-    int content_length;
+    off_t content_length;
     int timeout_secs = SOAP_TIMEOUT;
     int major,
       minor;
@@ -678,7 +678,7 @@
     int major,
       minor;
     int err_code;
-    int content_length;
+    off_t content_length;
     int ret_code;
     int timeout_secs = SOAP_TIMEOUT;
     static char *start_body =
--- libupnp/upnp/inc/upnp.h	2006-03-06 04:24:24.000000000 +1100
+++ libupnp-1.4.0/upnp/inc/upnp.h	2006-05-03 15:40:54.000000000 +1000
@@ -36,6 +36,14 @@
 
 //@{
 
+#if defined MYLIB_LARGEFILE_SENSITIVE && _FILE_OFFSET_BITS+0 != 64
+  #if defined __GNUC__
+  #warning libupnp requires largefile mode - use AC_SYS_LARGEFILE
+  #else
+  # error  libupnp requires largefile mode - use AC_SYS_LARGEFILE
+  #endif
+#endif 
+
 #include <stdio.h>
 #include "ixml.h"
 #include "upnpconfig.h"
@@ -835,7 +843,7 @@
   /** The length of the file. A length less than 0 indicates the size 
    *  is unknown, and data will be sent until 0 bytes are returned from
    *  a read call. */
-  int file_length;
+  off_t file_length;
 
   /** The time at which the contents of the file was modified;
    *  The time system is always local (not GMT). */
@@ -929,7 +937,7 @@
    int (*seek) (
      IN UpnpWebFileHandle fileHnd,  /** The handle of the file to move the 
                                         file pointer. */
-     IN long offset,                /** The number of bytes to move in the 
+     IN off_t offset,                /** The number of bytes to move in the 
                                         file.  Positive values move foward and 
                                         negative values move backward.  Note 
                                         that this must be positive if the 
@@ -2587,4 +2595,3 @@
 //@} The API
 
 #endif
-
