]> granicus.if.org Git - php/commitdiff
Fix fopencookie detection for newer versions of glibc.
authorWez Furlong <wez@php.net>
Sun, 17 Nov 2002 19:14:49 +0000 (19:14 +0000)
committerWez Furlong <wez@php.net>
Sun, 17 Nov 2002 19:14:49 +0000 (19:14 +0000)
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.

acinclude.m4
main/streams.c

index 6908696165ecd6d3440a1f7c3ccdad0e5d009cf0..457e2970cf49670ab0d30249a9d5b2dda23efc2c 100644 (file)
@@ -1487,16 +1487,16 @@ AC_DEFUN([PHP_FOPENCOOKIE],[
 #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 @@ main() {
   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 @@ main() {
       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 bf0633664ddf488fa5365c4f5af7413be5032234..cc097fab790112ffe23f4c0963fedab54bde26b5 100755 (executable)
@@ -1756,12 +1756,12 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz
        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;