jani Thu May 21 01:39:49 2009 UTC Modified files: /php-src/ext/standard file.c Log: ws
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.545&r2=1.546&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.545 php-src/ext/standard/file.c:1.546 --- php-src/ext/standard/file.c:1.545 Fri May 8 10:01:40 2009 +++ php-src/ext/standard/file.c Thu May 21 01:39:48 2009 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.545 2009/05/08 10:01:40 lbarnaud Exp $ */ +/* $Id: file.c,v 1.546 2009/05/21 01:39:48 jani Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -43,60 +43,65 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> + #ifdef PHP_WIN32 -#include <io.h> -#define O_RDONLY _O_RDONLY -#include "win32/param.h" -#include "win32/winutil.h" -#include "win32/fnmatch.h" +# include <io.h> +# define O_RDONLY _O_RDONLY +# include "win32/param.h" +# include "win32/winutil.h" +# include "win32/fnmatch.h" #elif defined(NETWARE) -#include <sys/param.h> -#include <sys/select.h> -#ifdef USE_WINSOCK -#include <novsock2.h> -#else -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#endif -#else -#if HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif -#if HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif -#if defined(NETWARE) && defined(USE_WINSOCK) -#include <novsock2.h> +# include <sys/param.h> +# include <sys/select.h> +# ifdef USE_WINSOCK +# include <novsock2.h> +# else +# include <sys/socket.h> +# include <netinet/in.h> +# include <netdb.h> +# endif #else -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#endif -#if HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif +# if HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif +# if HAVE_SYS_SELECT_H +# include <sys/select.h> +# endif +# if defined(NETWARE) && defined(USE_WINSOCK) +# include <novsock2.h> +# else +# include <sys/socket.h> +# include <netinet/in.h> +# include <netdb.h> +# endif +# if HAVE_ARPA_INET_H +# include <arpa/inet.h> +# endif #endif + #include "ext/standard/head.h" #include "php_string.h" #include "file.h" + #if HAVE_PWD_H -#ifdef PHP_WIN32 -#include "win32/pwd.h" -#else -#include <pwd.h> -#endif +# ifdef PHP_WIN32 +# include "win32/pwd.h" +# else +# include <pwd.h> +# endif #endif + #ifdef HAVE_SYS_TIME_H -#include <sys/time.h> +# include <sys/time.h> #endif + #include "fsock.h" #include "fopen_wrappers.h" #include "streamsfuncs.h" #include "php_globals.h" #ifdef HAVE_SYS_FILE_H -#include <sys/file.h> +# include <sys/file.h> #endif #if MISSING_FCLOSE_DECL @@ -104,7 +109,7 @@ #endif #ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> +# include <sys/mman.h> #endif #include "scanf.h" @@ -117,18 +122,18 @@ #endif #if defined(HAVE_FNMATCH) && !defined(PHP_WIN32) -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include <fnmatch.h> +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +# include <fnmatch.h> #endif #ifdef HAVE_WCHAR_H -#include <wchar.h> +# include <wchar.h> #endif #ifndef S_ISDIR -#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) +# define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) #endif /* }}} */ @@ -198,7 +203,7 @@ REGISTER_LONG_CONSTANT("LOCK_UN", PHP_LOCK_UN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("LOCK_NB", PHP_LOCK_NB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_NOTIFY_CONNECT", PHP_STREAM_NOTIFY_CONNECT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_NOTIFY_CONNECT", PHP_STREAM_NOTIFY_CONNECT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_NOTIFY_AUTH_REQUIRED", PHP_STREAM_NOTIFY_AUTH_REQUIRED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_NOTIFY_AUTH_RESULT", PHP_STREAM_NOTIFY_AUTH_RESULT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_NOTIFY_MIME_TYPE_IS", PHP_STREAM_NOTIFY_MIME_TYPE_IS, CONST_CS | CONST_PERSISTENT); @@ -209,9 +214,9 @@ REGISTER_LONG_CONSTANT("STREAM_NOTIFY_COMPLETED", PHP_STREAM_NOTIFY_COMPLETED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_NOTIFY_RESOLVE", PHP_STREAM_NOTIFY_RESOLVE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO", PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN", PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR", PHP_STREAM_NOTIFY_SEVERITY_ERR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_INFO", PHP_STREAM_NOTIFY_SEVERITY_INFO, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_WARN", PHP_STREAM_NOTIFY_SEVERITY_WARN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("STREAM_NOTIFY_SEVERITY_ERR", PHP_STREAM_NOTIFY_SEVERITY_ERR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_FILTER_READ", PHP_STREAM_FILTER_READ, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_FILTER_WRITE", PHP_STREAM_FILTER_WRITE, CONST_CS | CONST_PERSISTENT); @@ -239,11 +244,13 @@ #elif defined(AF_INET) REGISTER_LONG_CONSTANT("STREAM_PF_INET", AF_INET, CONST_CS|CONST_PERSISTENT); #endif + #ifdef PF_INET6 REGISTER_LONG_CONSTANT("STREAM_PF_INET6", PF_INET6, CONST_CS|CONST_PERSISTENT); #elif defined(AF_INET6) REGISTER_LONG_CONSTANT("STREAM_PF_INET6", AF_INET6, CONST_CS|CONST_PERSISTENT); #endif + #ifdef PF_UNIX REGISTER_LONG_CONSTANT("STREAM_PF_UNIX", PF_UNIX, CONST_CS|CONST_PERSISTENT); #elif defined(AF_UNIX) @@ -254,30 +261,38 @@ /* most people will use this one when calling socket() or socketpair() */ REGISTER_LONG_CONSTANT("STREAM_IPPROTO_IP", IPPROTO_IP, CONST_CS|CONST_PERSISTENT); #endif + #ifdef IPPROTO_TCP REGISTER_LONG_CONSTANT("STREAM_IPPROTO_TCP", IPPROTO_TCP, CONST_CS|CONST_PERSISTENT); #endif + #ifdef IPPROTO_UDP REGISTER_LONG_CONSTANT("STREAM_IPPROTO_UDP", IPPROTO_UDP, CONST_CS|CONST_PERSISTENT); #endif + #ifdef IPPROTO_ICMP REGISTER_LONG_CONSTANT("STREAM_IPPROTO_ICMP", IPPROTO_ICMP, CONST_CS|CONST_PERSISTENT); #endif + #ifdef IPPROTO_RAW REGISTER_LONG_CONSTANT("STREAM_IPPROTO_RAW", IPPROTO_RAW, CONST_CS|CONST_PERSISTENT); #endif REGISTER_LONG_CONSTANT("STREAM_SOCK_STREAM", SOCK_STREAM, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_SOCK_DGRAM", SOCK_DGRAM, CONST_CS|CONST_PERSISTENT); + #ifdef SOCK_RAW REGISTER_LONG_CONSTANT("STREAM_SOCK_RAW", SOCK_RAW, CONST_CS|CONST_PERSISTENT); #endif + #ifdef SOCK_SEQPACKET REGISTER_LONG_CONSTANT("STREAM_SOCK_SEQPACKET", SOCK_SEQPACKET, CONST_CS|CONST_PERSISTENT); #endif + #ifdef SOCK_RDM REGISTER_LONG_CONSTANT("STREAM_SOCK_RDM", SOCK_RDM, CONST_CS|CONST_PERSISTENT); #endif + REGISTER_LONG_CONSTANT("STREAM_PEEK", STREAM_PEEK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("STREAM_OOB", STREAM_OOB, CONST_CS | CONST_PERSISTENT); @@ -287,18 +302,18 @@ REGISTER_LONG_CONSTANT("FILE_USE_INCLUDE_PATH", PHP_FILE_USE_INCLUDE_PATH, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILE_IGNORE_NEW_LINES", PHP_FILE_IGNORE_NEW_LINES, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILE_SKIP_EMPTY_LINES", PHP_FILE_SKIP_EMPTY_LINES, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FILE_APPEND", PHP_FILE_APPEND, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILE_APPEND", PHP_FILE_APPEND, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILE_NO_DEFAULT_CONTEXT", PHP_FILE_NO_DEFAULT_CONTEXT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FILE_TEXT", PHP_FILE_TEXT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FILE_BINARY", PHP_FILE_BINARY, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILE_TEXT", PHP_FILE_TEXT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILE_BINARY", PHP_FILE_BINARY, CONST_CS | CONST_PERSISTENT); #ifdef HAVE_FNMATCH REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FNM_PATHNAME", FNM_PATHNAME, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FNM_PERIOD", FNM_PERIOD, CONST_CS | CONST_PERSISTENT); -#ifdef FNM_CASEFOLD /* a GNU extension */ /* TODO emulate if not available */ +# ifdef FNM_CASEFOLD /* a GNU extension */ /* TODO emulate if not available */ REGISTER_LONG_CONSTANT("FNM_CASEFOLD", FNM_CASEFOLD, CONST_CS | CONST_PERSISTENT); -#endif +# endif #endif return SUCCESS; @@ -953,7 +968,7 @@ if ((fd = php_open_temporary_fd(dir, p, &opened_path TSRMLS_CC)) >= 0) { UChar *utmpnam; int utmpnam_len; - + close(fd); if (SUCCESS == php_stream_path_decode(NULL, &utmpnam, &utmpnam_len, opened_path, strlen(opened_path), REPORT_ERRORS, FG(default_context))) { @@ -1011,7 +1026,7 @@ if (stream == NULL) { RETURN_FALSE; } - + php_stream_to_zval(stream, return_value); } /* }}} */ @@ -1028,12 +1043,12 @@ } PHP_STREAM_TO_ZVAL(stream, &arg1); - + if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id); RETURN_FALSE; } - + if (!stream->is_persistent) { zend_list_delete(stream->rsrc_id); } else { @@ -1304,7 +1319,7 @@ int type, result, argc = 0; zval ***args = NULL; zval **format; - zval *file_handle; + zval *file_handle; char *buf; UChar *u_buf; void *what; @@ -1315,11 +1330,9 @@ what = zend_fetch_resource(&file_handle TSRMLS_CC, -1, "File-Handle", &type, 2, php_file_le_stream(), php_file_le_pstream()); - /* - * we can't do a ZEND_VERIFY_RESOURCE(what), otherwise we end up + /* we can't do a ZEND_VERIFY_RESOURCE(what), otherwise we end up * with a leak if we have an invalid filehandle. This needs changing - * if the code behind ZEND_VERIFY_RESOURCE changed. - cc - */ + * if the code behind ZEND_VERIFY_RESOURCE changed. - cc */ if (!what) { if (args) { efree(args); @@ -1377,7 +1390,7 @@ } php_stream_from_zval(stream, &zstream); - + if (argc > 2 && write_len <= 0) { RETURN_LONG(0); } @@ -1623,7 +1636,7 @@ if (BG(umask) == -1) { BG(umask) = oldumask; } - + if (zend_parse_parameters(arg_count TSRMLS_CC, "|l", &arg1) == FAILURE) { return; } @@ -1902,7 +1915,7 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The first argument to copy() function cannot be a directory"); return FAILURE; } - + switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL)) { case -1: /* non-statable stream */ @@ -2103,7 +2116,7 @@ smart_str_appendl(&csvline, &delimiter, 1); } zend_hash_move_forward_ex(Z_ARRVAL_P(fields), &pos); - + if (Z_TYPE_PP(field_tmp) != IS_STRING) { zval_dtor(&field); } @@ -2245,7 +2258,7 @@ if (php_stream_get_line_ex(stream, stream->readbuf_type, buf, len + 1, len + 1, &buf_len) == NULL) { efree(buf.v); RETVAL_FALSE; - goto cleanup; + goto cleanup; } } @@ -2384,7 +2397,7 @@ if (p >= e) break; goto ready_state; } - + /* Otherwise, starting a new field without enclosures */ state = PHP_FGETCSV_FIELD_NO_ENC; field_start = p++; @@ -2592,7 +2605,7 @@ if (p >= e) break; goto ready_state; } - + /* Otherwise, starting a new field without enclosures */ state = PHP_FGETCSV_FIELD_NO_ENC; field_start = p++; @@ -2769,7 +2782,7 @@ #ifdef ZTS if (VCWD_ACCESS(resolved_path_buff, F_OK)) { RETVAL_FALSE; - } else + } else #endif { UChar *path;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php