iliaa Sat Feb 22 15:33:11 2003 EDT
Modified files:
/php4/ext/standard basic_functions.c file.c file.h html.c
Log:
int/long change.
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.584
php4/ext/standard/basic_functions.c:1.585
--- php4/ext/standard/basic_functions.c:1.584 Fri Feb 21 03:45:57 2003
+++ php4/ext/standard/basic_functions.c Sat Feb 22 15:33:11 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.584 2003/02/21 08:45:57 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.585 2003/02/22 20:33:11 iliaa Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -670,6 +670,7 @@
PHP_STATIC_FE("tmpfile", php_if_tmpfile,
NULL)
PHP_FE(file,
NULL)
PHP_FE(file_get_contents,
NULL)
+ PHP_FE(file_write_content,
NULL)
PHP_FE(stream_select,
first_through_third_args_force_ref)
PHP_FE(stream_context_create,
NULL)
PHP_FE(stream_context_set_params,
NULL)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.307 php4/ext/standard/file.c:1.308
--- php4/ext/standard/file.c:1.307 Tue Feb 18 10:15:22 2003
+++ php4/ext/standard/file.c Sat Feb 22 15:33:11 2003
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.307 2003/02/18 15:15:22 moriyoshi Exp $ */
+/* $Id: file.c,v 1.308 2003/02/22 20:33:11 iliaa Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -406,6 +406,67 @@
php_stream_close(md.stream);
}
+/* }}} */
+
+/* {{{ proto int file_write_content(string filename, mixed content [, char mode [,
bool use_include_path]])
+ Write a string to a file. */
+PHP_FUNCTION(file_write_content)
+{
+ zval *content;
+ char *filename, *mode;
+ int filename_len, mode_len = 0;
+ zend_bool use_include_path = 0;
+ size_t written;
+ php_stream *stream;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|sb", &filename,
&filename_len, &content, &mode, &mode_len, &use_include_path) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (!(stream = php_stream_open_wrapper(filename, (mode_len ? mode : "wb"),
(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
+ RETURN_FALSE;
+ }
+
+ /* try to set an exclusive lock on the file to prevent access to the file
while the write operation
+ * is happening.
+ */
+ php_stream_set_option(stream, PHP_STREAM_OPTION_LOCKING, F_SETLKW, (void *)
F_WRLCK TSRMLS_CC);
+
+ if (Z_TYPE_P(content) == IS_ARRAY) {
+ HashPosition pos;
+ zval **tmp;
+ size_t cur_write;
+
+ written = 0;
+ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(content), &pos);
+
+ while (zend_hash_get_current_data_ex(Z_ARRVAL_P(content), (void **)
&tmp, &pos) == SUCCESS) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(*tmp);
+
+ if ((cur_write = php_stream_write(stream, Z_STRVAL_PP(tmp),
Z_STRLEN_PP(tmp))) < 0) {
+ RETVAL_FALSE;
+ goto done;
+ }
+ written += cur_write;
+
+ zend_hash_move_forward_ex(Z_ARRVAL_P(content), &pos);
+ }
+ RETVAL_LONG(written);
+ } else {
+ SEPARATE_ZVAL(&content);
+ convert_to_string(content);
+ if ((written = php_stream_write(stream, Z_STRVAL_P(content),
Z_STRLEN_P(content))) < 0) {
+ RETVAL_FALSE;
+ } else {
+ RETVAL_LONG(written);
+ }
+ zval_ptr_dtor(&content);
+ }
+
+done:
+ php_stream_close(stream);
+}
/* }}} */
/* {{{ proto string file_get_contents(string filename [, bool use_include_path])
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.75 php4/ext/standard/file.h:1.76
--- php4/ext/standard/file.h:1.75 Mon Feb 10 17:26:53 2003
+++ php4/ext/standard/file.h Sat Feb 22 15:33:11 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.h,v 1.75 2003/02/10 22:26:53 iliaa Exp $ */
+/* $Id: file.h,v 1.76 2003/02/22 20:33:11 iliaa Exp $ */
/* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
@@ -54,6 +54,7 @@
PHP_FUNCTION(copy);
PHP_FUNCTION(file);
PHP_FUNCTION(file_get_contents);
+PHP_FUNCTION(file_write_content);
PHP_FUNCTION(set_socket_blocking); /* deprecated */
PHP_FUNCTION(stream_set_blocking);
PHP_FUNCTION(stream_select);
Index: php4/ext/standard/html.c
diff -u php4/ext/standard/html.c:1.71 php4/ext/standard/html.c:1.72
--- php4/ext/standard/html.c:1.71 Fri Jan 24 11:29:40 2003
+++ php4/ext/standard/html.c Sat Feb 22 15:33:11 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.c,v 1.71 2003/01/24 16:29:40 iliaa Exp $ */
+/* $Id: html.c,v 1.72 2003/02/22 20:33:11 iliaa Exp $ */
#include "php.h"
#if PHP_WIN32
@@ -831,11 +831,11 @@
{
char *str, *hint_charset = NULL;
int str_len, hint_charset_len = 0;
- int len, quote_style = ENT_COMPAT;
+ int len;
+ long quote_style = ENT_COMPAT;
char *replaced;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
- "e_style, &hint_charset,
&hint_charset_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
"e_style, &hint_charset, &hint_charset_len) == FAILURE) {
return;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php