wez             Sun Nov 17 14:14:50 2002 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4       acinclude.m4 
    /php4/main  streams.c 
  Log:
  Fix fopencookie detection for newer versions of glibc.
  The GNU people strike again with their useless docs; fopencookie does NOT
  use "fpos_t *" as documented :/
  Additionally, it appears that the the libio layer buffers in chunks of 8KB,
  so our test needs to exploit this in order to function correctly.
  Thanks to Derick for doing some groundwork.
  
  
Index: php4/acinclude.m4
diff -u php4/acinclude.m4:1.218 php4/acinclude.m4:1.218.2.1
--- php4/acinclude.m4:1.218     Tue Oct 29 06:24:26 2002
+++ php4/acinclude.m4   Sun Nov 17 14:14:49 2002
@@ -1,4 +1,4 @@
-dnl $Id: acinclude.m4,v 1.218 2002/10/29 11:24:26 sniper Exp $
+dnl $Id: acinclude.m4,v 1.218.2.1 2002/11/17 19:14:49 wez Exp $
 dnl
 dnl This file contains local autoconf functions.
 
@@ -1487,16 +1487,16 @@
 #include <stdio.h>
 
 struct cookiedata {
-       fpos_t pos;
+       __off64t pos;
 };
 
-size_t reader(void *cookie, char *buffer, size_t size)
+__ssize_t reader(void *cookie, char *buffer, size_t size)
 { return size; }
-size_t writer(void *cookie, const char *buffer, size_t size)
+__ssize_t writer(void *cookie, const char *buffer, size_t size)
 { return size; }
 int closer(void *cookie)
 { return 0; }
-int seeker(void *cookie, fpos_t *position, int whence)
+int seeker(void *cookie, __off64t *position, int whence)
 { ((struct cookiedata*)cookie)->pos = *position; return 0; }
 
 cookie_io_functions_t funcs = {reader, writer, seeker, closer};
@@ -1505,13 +1505,13 @@
   struct cookiedata g = { 0 };
   FILE *fp = fopencookie(&g, "r", funcs);
 
-  if (fp && fseek(fp, 69, SEEK_SET) == 0 && g.pos == 69)
+  if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
          exit(0);
   exit(1);
 }
 
                                           ],
-                                          [ cookie_io_functions_use_fpos_t=yes ],
+                                          [ cookie_io_functions_use_off64t=yes ],
                                           [ ] )
                
       else
@@ -1532,8 +1532,8 @@
       if test "$have_fopen_cookie" = "yes" ; then
         AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
         AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
-               if test "$cookie_io_functions_use_fpos_t" = "yes" ; then
-          AC_DEFINE(COOKIE_SEEKER_USES_FPOS_T, 1, [ ])
+               if test "$cookie_io_functions_use_off64t" = "yes" ; then
+          AC_DEFINE(COOKIE_SEEKER_USES_OFF64T, 1, [ ])
                fi
       fi      
 
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.125.2.10 php4/main/streams.c:1.125.2.11
--- php4/main/streams.c:1.125.2.10      Sat Nov 16 20:06:31 2002
+++ php4/main/streams.c Sun Nov 17 14:14:49 2002
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.125.2.10 2002/11/17 01:06:31 wez Exp $ */
+/* $Id: streams.c,v 1.125.2.11 2002/11/17 19:14:49 wez Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -1756,12 +1756,12 @@
        return php_stream_write(((php_stream *)cookie), (char *)buffer, size);
 }
 
-#ifdef COOKIE_SEEKER_USES_FPOS_T
-static int stream_cookie_seeker(void *cookie, fpos_t *position, int whence)
+#ifdef COOKIE_SEEKER_USES_OFF64T
+static int stream_cookie_seeker(void *cookie, __off64t *position, int whence)
 {
        TSRMLS_FETCH();
 
-       *position = php_stream_seek((php_stream *)cookie, *position, whence);
+       *position = php_stream_seek((php_stream *)cookie, (off_t)*position, whence);
 
        if (*position == -1)
                return -1;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to