pollita         Thu Mar  4 17:29:24 2004 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/ftp    ftp.c 
  Log:
  MFH: Don't rely on ANSI tmpfile(), use the streams layer instead, it'll deal with 
platform issues.
  
http://cvs.php.net/diff.php/php-src/ext/ftp/ftp.c?r1=1.68.2.14&r2=1.68.2.15&ty=u
Index: php-src/ext/ftp/ftp.c
diff -u php-src/ext/ftp/ftp.c:1.68.2.14 php-src/ext/ftp/ftp.c:1.68.2.15
--- php-src/ext/ftp/ftp.c:1.68.2.14     Sat Feb 21 14:37:59 2004
+++ php-src/ext/ftp/ftp.c       Thu Mar  4 17:29:23 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ftp.c,v 1.68.2.14 2004/02/21 19:37:59 pollita Exp $ */
+/* $Id: ftp.c,v 1.68.2.15 2004/03/04 22:29:23 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1453,7 +1453,7 @@
 char**
 ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
 {
-       FILE            *tmpfp = NULL;
+       php_stream      *tmpstream = NULL;
        databuf_t       *data = NULL;
        char            *ptr;
        int             ch, lastch;
@@ -1463,7 +1463,7 @@
        char            **entry;
        char            *text;
 
-       if ((tmpfp = tmpfile()) == NULL) {
+       if ((tmpstream = php_stream_fopen_tmpfile()) == NULL) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create 
temporary file.  Check permissions in temporary files directory.");
                return NULL;
        }
@@ -1491,7 +1491,7 @@
                if (rcvd == -1)
                        goto bail;
 
-               fwrite(data->buf, rcvd, 1, tmpfp);
+               php_stream_write(tmpstream, data->buf, rcvd);
 
                size += rcvd;
                for (ptr = data->buf; rcvd; rcvd--, ptr++) {
@@ -1505,12 +1505,7 @@
 
        ftp->data = data = data_close(ftp, data);
 
-       if (ferror(tmpfp))
-               goto bail;
-
-
-
-       rewind(tmpfp);
+       php_stream_rewind(tmpstream);
 
        ret = emalloc((lines + 1) * sizeof(char**) + size * sizeof(char*));
 
@@ -1518,7 +1513,7 @@
        text = (char*) (ret + lines + 1);
        *entry = text;
        lastch = 0;
-       while ((ch = getc(tmpfp)) != EOF) {
+       while ((ch = php_stream_getc(tmpstream)) != EOF) {
                if (ch == '\n' && lastch == '\r') {
                        *(text - 1) = 0;
                        *++entry = text;
@@ -1530,10 +1525,7 @@
        }
        *entry = NULL;
 
-       if (ferror(tmpfp))
-               goto bail;
-
-       fclose(tmpfp);
+       php_stream_close(tmpstream);
 
        if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {
                efree(ret);
@@ -1543,7 +1535,7 @@
        return ret;
 bail:
        ftp->data = data_close(ftp, data);
-       fclose(tmpfp);
+       php_stream_close(tmpstream);
        if (ret)
                efree(ret);
        return NULL;

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

Reply via email to