Instead of taking your patch we should use the last version of saschas patch and add the "zend_file_handle fh = {0}" initializations in the browscap and sapi modules by hand.
I attached saschas last patch updated with the initalization issues. This should be all which was reverted. If somebody with karma for everywhere could commit it, we have the fd-lexer-patch back.
(Jani: my last patch was not correct because of whitespace issuses...)
At 02:25 31.05.2003 +0300, you wrote:
Hopefully attached.
--Jani
-- Donate at: https://www.paypal.com/affil/pal=sniper%40php.net All donated funds will be used for recreation :)
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
----- Uwe Schindler Addr 1: Bamberger Str. 24a, D-96049 Bamberg Addr 2: Drausnickstr. 153, D-91052 Erlangen http://www.thetaphi.de - http:///www.schindlers-software.de eMails: [EMAIL PROTECTED] (private); [EMAIL PROTECTED] (company) Tel./Fax: +49 700 PCLATEIN (+49 700 72528346)
Schindlers Software - Home of Schindlers PC-LATEIN 3.10
DIE Software zum Lateinlernen!
Index: Zend/flex.skl
===================================================================
RCS file: /repository/Zend/flex.skl,v
retrieving revision 1.27.4.3
diff -u -r1.27.4.3 flex.skl
--- Zend/flex.skl 21 May 2003 07:53:20 -0000 1.27.4.3
+++ Zend/flex.skl 31 May 2003 00:15:29 -0000
@@ -9,6 +9,22 @@
#define YY_FLEX_MINOR_VERSION 5
%-
+
+/* for HAVE_* */
+#include "zend.h"
+
+/* for recv */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+/* for read */
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdio.h>
%*
@@ -154,7 +170,7 @@
struct yy_buffer_state
{
%-
- FILE *yy_input_file;
+ struct _zend_file_handle *yy_input_file;
%+
istream* yy_input_file;
%*
@@ -238,31 +254,19 @@
#define yy_init SCNG(init)
#define yy_start SCNG(start)
-#ifdef ZTS
-#define TSRMLS_D void ***tsrm_ls
-#define TSRMLS_DC , TSRMLS_D
-#define TSRMLS_C tsrm_ls
-#define TSRMLS_CC , TSRMLS_C
-#else
-#define TSRMLS_D
-#define TSRMLS_DC
-#define TSRMLS_C
-#define TSRMLS_CC
-#endif
-
/* Flag which is used to allow yywrap()'s to do buffer switches
* instead of setting up a fresh yyin. A bit of a hack ...
*/
/* static int yy_did_buffer_switch_on_eof; */
#define yy_did_buffer_switch_on_eof SCNG(_yy_did_buffer_switch_on_eof)
-void yyrestart YY_PROTO(( FILE *input_file TSRMLS_DC ));
+void yyrestart YY_PROTO(( struct _zend_file_handle *input_file TSRMLS_DC ));
void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer TSRMLS_DC ));
void yy_load_buffer_state YY_PROTO(( TSRMLS_D ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size TSRMLS_DC ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( struct _zend_file_handle *file, int size
TSRMLS_DC ));
void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b TSRMLS_DC ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file TSRMLS_DC ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, struct _zend_file_handle *file
TSRMLS_DC ));
void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b TSRMLS_DC ));
#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer TSRMLS_CC )
@@ -322,11 +326,6 @@
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
%*
-#undef TSRMLS_D
-#undef TSRMLS_DC
-#undef TSRMLS_C
-#undef TSRMLS_CC
-
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
@@ -435,19 +434,25 @@
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
-%- Standard (non-C++) definition
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, SCNG(yy_out) )
-%+ C++ definition
-#define ECHO LexerOutput( yytext, yyleng )
-%*
+#define ECHO
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
+
+#define YY_INPUT(buf,result,max_size) do { \
+ result = yyin->type == ZEND_HANDLE_FD ? \
+ read(yyin->handle.fd, buf, max_size) \
+ : yyin->type == ZEND_HANDLE_FP ? \
+ fread(buf, 1, max_size, yyin->handle.fp) \
+ : yyin->type == ZEND_HANDLE_SOCKET_FD ? \
+ recv(yyin->handle.fd, buf, max_size, 0) \
+ : -1;
\
+ if (result < 0)
\
+ YY_FATAL_ERROR("input in flex scanner failed"); \
+} while (0)
+
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
%% fread()/read() definition of YY_INPUT goes here unless we're doing C++
@@ -524,6 +529,7 @@
if ( ! yy_start )
yy_start = 1; /* first start state */
+#if 0
if ( ! SCNG(yy_in) )
%-
SCNG(yy_in) = stdin;
@@ -537,6 +543,7 @@
%+
SCNG(yy_out) = &cout;
%*
+#endif
if ( ! yy_current_buffer )
yy_current_buffer =
@@ -1111,10 +1118,10 @@
%-
#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file TSRMLS_DC )
+void yyrestart( struct _zend_file_handle *input_file TSRMLS_DC )
#else
void yyrestart( input_file TSRMLS_CC )
-FILE *input_file;
+struct _zend_file_handle *input_file;
#endif
%+
void yyFlexLexer::yyrestart( istream* input_file TSRMLS_DC )
@@ -1187,10 +1194,10 @@
%-
#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size TSRMLS_DC )
+YY_BUFFER_STATE yy_create_buffer( struct _zend_file_handle *file, int size TSRMLS_DC )
#else
YY_BUFFER_STATE yy_create_buffer( file, size TSRMLS_CC )
-FILE *file;
+struct _zend_file_handle *file;
int size;
#ifdef ZTS
void ***tsrm_ls;
@@ -1258,11 +1265,11 @@
#endif
#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file TSRMLS_DC )
+void yy_init_buffer( YY_BUFFER_STATE b, struct _zend_file_handle *file TSRMLS_DC )
#else
void yy_init_buffer( b, file TSRMLS_CC )
YY_BUFFER_STATE b;
-FILE *file;
+struct _zend_file_handle *file;
#ifdef ZTS
void ***tsrm_ls;
#endif
@@ -1286,7 +1293,7 @@
#if YY_NEVER_INTERACTIVE
b->yy_is_interactive = 0;
#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+ b->yy_is_interactive = file ? (file->is_tty == ZEND_TTY_YES ? 1 : file->is_tty
== ZEND_TTY_NO ? 0 : file->type == ZEND_HANDLE_FD ? file->is_tty =
isatty(file->handle.fd) : file->type == ZEND_HANDLE_FP ? file->is_tty =
isatty(fileno(file->handle.fp)) : 0) : 0;
#endif
#endif
%+
Index: Zend/zend.c
===================================================================
RCS file: /repository/Zend/zend.c,v
retrieving revision 1.162.2.5
diff -u -r1.162.2.5 zend.c
--- Zend/zend.c 21 May 2003 07:53:20 -0000 1.162.2.5
+++ Zend/zend.c 31 May 2003 00:15:30 -0000
@@ -48,6 +48,7 @@
ZEND_API int (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write;
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
+ZEND_API zend_bool (*zend_open)(const char *filename, zend_file_handle *);
ZEND_API void (*zend_block_interruptions)(void);
ZEND_API void (*zend_unblock_interruptions)(void);
ZEND_API void (*zend_ticks_function)(int ticks);
@@ -255,6 +256,18 @@
}
+static zend_bool zend_open_wrapper(const char *filename, zend_file_handle *fh)
+{
+ fh->handle.fp = zend_fopen(filename, &fh->opened_path);
+
+ if (fh->handle.fp) {
+ fh->type = ZEND_HANDLE_FP;
+ return SUCCESS;
+ }
+ return FAILURE;
+}
+
+
static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
{
if (opened_path) {
@@ -432,6 +445,10 @@
zend_fopen = utility_functions->fopen_function;
if (!zend_fopen) {
zend_fopen = zend_fopen_wrapper;
+ }
+ zend_open = utility_functions->open_function;
+ if (!zend_open) {
+ zend_open = zend_open_wrapper;
}
zend_message_dispatcher_p = utility_functions->message_handler;
zend_block_interruptions = utility_functions->block_interruptions;
Index: Zend/zend.h
===================================================================
RCS file: /repository/Zend/zend.h,v
retrieving revision 1.164.2.7
diff -u -r1.164.2.7 zend.h
--- Zend/zend.h 21 May 2003 07:53:20 -0000 1.164.2.7
+++ Zend/zend.h 31 May 2003 00:15:30 -0000
@@ -279,6 +279,7 @@
int (*handle_property_set)(zend_property_reference *property_reference, zval
*value);
};
+struct _zend_file_handle;
typedef struct _zend_utility_functions {
@@ -292,6 +293,7 @@
int (*get_configuration_directive)(char *name, uint name_length, zval
*contents);
void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds TSRMLS_DC);
+ zend_bool (*open_function)(const char *filename, struct _zend_file_handle *);
} zend_utility_functions;
@@ -417,6 +419,7 @@
extern ZEND_API int (*zend_printf)(const char *format, ...);
extern ZEND_API zend_write_func_t zend_write;
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
+extern ZEND_API zend_bool (*zend_open)(const char *filename, struct _zend_file_handle
*fh);
extern ZEND_API void (*zend_block_interruptions)(void);
extern ZEND_API void (*zend_unblock_interruptions)(void);
extern ZEND_API void (*zend_ticks_function)(int ticks);
Index: Zend/zend_compile.h
===================================================================
RCS file: /repository/Zend/zend_compile.h,v
retrieving revision 1.144.4.4
diff -u -r1.144.4.4 zend_compile.h
--- Zend/zend_compile.h 21 May 2003 07:53:20 -0000 1.144.4.4
+++ Zend/zend_compile.h 31 May 2003 00:15:30 -0000
@@ -173,9 +173,10 @@
FILE *fp;
} handle;
zend_bool free_filename;
+ enum { ZEND_TTY_NO = 0, ZEND_TTY_YES = 1, ZEND_TTY_UNKNOWN} is_tty;
} zend_file_handle;
-
+#define ZEND_IS_VALID_FILE_HANDLE(hn) ((((hn)->type == ZEND_HANDLE_FD || (hn)->type
== ZEND_HANDLE_SOCKET_FD) && (hn)->handle.fd >= 0) || ((hn)->type == ZEND_HANDLE_FP &&
(hn)->handle.fp != NULL))
#define IS_CONST (1<<0)
#define IS_TMP_VAR (1<<1)
@@ -568,6 +569,7 @@
#define ZEND_HANDLE_FP 2
#define ZEND_HANDLE_STDIOSTREAM 3
#define ZEND_HANDLE_FSTREAM 4
+#define ZEND_HANDLE_SOCKET_FD 5
#define ZEND_DECLARE_CLASS 1
#define ZEND_DECLARE_FUNCTION 2
Index: Zend/zend_execute.c
===================================================================
RCS file: /repository/Zend/zend_execute.c,v
retrieving revision 1.316.2.10
diff -u -r1.316.2.10 zend_execute.c
--- Zend/zend_execute.c 21 May 2003 07:53:20 -0000 1.316.2.10
+++ Zend/zend_execute.c 31 May 2003 00:15:31 -0000
@@ -2101,27 +2101,23 @@
switch (EX(opline)->op2.u.constant.value.lval)
{
case ZEND_INCLUDE_ONCE:
case ZEND_REQUIRE_ONCE: {
- char *opened_path=NULL;
int dummy = 1;
zend_file_handle
file_handle;
- file_handle.handle.fp
= zend_fopen(inc_filename->value.str.val, &opened_path);
- file_handle.type =
ZEND_HANDLE_FP;
+
zend_open(inc_filename->value.str.val, &file_handle);
file_handle.filename =
inc_filename->value.str.val;
-
file_handle.opened_path = opened_path;
file_handle.free_filename = 0;
- if
(file_handle.handle.fp) {
- if(
!opened_path ) {
-
opened_path = file_handle.opened_path = estrndup(inc_filename->value.str.val,
inc_filename->value.str.len);
+ if
(ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
+ if(
!file_handle.opened_path ) {
+
file_handle.opened_path = estrndup(inc_filename->value.str.val,
inc_filename->value.str.len);
}
- if
(zend_hash_add(&EG(included_files), opened_path, strlen(opened_path)+1, (void
*)&dummy, sizeof(int), NULL)==SUCCESS) {
+ if
(zend_hash_add(&EG(included_files), file_handle.opened_path,
strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) {
new_op_array = zend_compile_file(&file_handle,
(EX(opline)->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE)
TSRMLS_CC);
zend_destroy_file_handle(&file_handle TSRMLS_CC);
-
opened_path = NULL; /* zend_destroy_file_handle() already frees it */
} else {
-
fclose(file_handle.handle.fp);
+
zend_destroy_file_handle(&file_handle TSRMLS_CC);
failure_retval=1;
}
} else {
@@ -2130,9 +2126,6 @@
} else {
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle.filename);
}
- }
- if (opened_path) {
-
efree(opened_path);
}
break;
}
Index: Zend/zend_globals.h
===================================================================
RCS file: /repository/Zend/zend_globals.h,v
retrieving revision 1.93.2.3
diff -u -r1.93.2.3 zend_globals.h
--- Zend/zend_globals.h 21 May 2003 07:53:20 -0000 1.93.2.3
+++ Zend/zend_globals.h 31 May 2003 00:15:31 -0000
@@ -238,8 +238,8 @@
};
struct _zend_scanner_globals {
- FILE *yy_in;
- FILE *yy_out;
+ zend_file_handle *yy_in;
+ zend_file_handle *yy_out;
int yy_leng;
char *yy_text;
struct yy_buffer_state *current_buffer;
Index: Zend/zend_ini_parser.y
===================================================================
RCS file: /repository/Zend/zend_ini_parser.y,v
retrieving revision 1.18.2.5
diff -u -r1.18.2.5 zend_ini_parser.y
--- Zend/zend_ini_parser.y 18 May 2003 13:16:45 -0000 1.18.2.5
+++ Zend/zend_ini_parser.y 31 May 2003 00:15:31 -0000
@@ -163,7 +163,7 @@
CG(ini_parser_unbuffered_errors) = unbuffered_errors;
retval = ini_parse(TSRMLS_C);
- zend_ini_close_file(fh TSRMLS_CC);
+ zend_file_handle_dtor(fh);
if (retval==0) {
return SUCCESS;
Index: Zend/zend_ini_scanner.h
===================================================================
RCS file: /repository/Zend/zend_ini_scanner.h,v
retrieving revision 1.10.8.2
diff -u -r1.10.8.2 zend_ini_scanner.h
--- Zend/zend_ini_scanner.h 21 May 2003 07:53:21 -0000 1.10.8.2
+++ Zend/zend_ini_scanner.h 31 May 2003 00:15:31 -0000
@@ -5,7 +5,6 @@
int zend_ini_scanner_get_lineno(TSRMLS_D);
char *zend_ini_scanner_get_filename(TSRMLS_D);
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC);
-void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC);
int ini_lex(zval *ini_lval TSRMLS_DC);
END_EXTERN_C()
Index: Zend/zend_ini_scanner.l
===================================================================
RCS file: /repository/Zend/zend_ini_scanner.l,v
retrieving revision 1.26.2.4
diff -u -r1.26.2.4 zend_ini_scanner.l
--- Zend/zend_ini_scanner.l 21 May 2003 07:53:21 -0000 1.26.2.4
+++ Zend/zend_ini_scanner.l 31 May 2003 00:15:31 -0000
@@ -33,6 +33,10 @@
#include "zend_ini_parser.h"
#include "zend_ini_scanner.h"
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
#undef YYSTYPE
#define YYSTYPE zval
@@ -69,36 +73,23 @@
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC)
{
- FILE *fp;
-
switch (fh->type) {
- case ZEND_HANDLE_FP:
- fp = fh->handle.fp;
- break;
case ZEND_HANDLE_FILENAME:
- fp = zend_fopen(fh->filename, NULL);
fh->type = ZEND_HANDLE_FP;
+ fh->handle.fp = zend_fopen(fh->filename, NULL);
break;
- default:
- return FAILURE;
}
+ if (!ZEND_IS_VALID_FILE_HANDLE(fh))
+ return FAILURE;
+
init_ini_scanner(TSRMLS_C);
- yyin = fp;
+ yyin = fh;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE TSRMLS_CC) TSRMLS_CC);
ini_filename = fh->filename;
return SUCCESS;
}
-
-void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC)
-{
- switch (fh->type) {
- case ZEND_HANDLE_FP:
- fclose(fh->handle.fp);
- break;
- }
-}
%}
Index: Zend/zend_language_scanner.h
===================================================================
RCS file: /repository/Zend/zend_language_scanner.h,v
retrieving revision 1.10.4.3
diff -u -r1.10.4.3 zend_language_scanner.h
--- Zend/zend_language_scanner.h 21 May 2003 07:53:21 -0000 1.10.4.3
+++ Zend/zend_language_scanner.h 31 May 2003 00:15:31 -0000
@@ -24,7 +24,7 @@
typedef struct _zend_lex_state {
YY_BUFFER_STATE buffer_state;
int state;
- FILE *in;
+ zend_file_handle *in;
uint lineno;
char *filename;
#ifdef ZEND_MULTIBYTE
Index: Zend/zend_language_scanner.l
===================================================================
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.54.2.19
diff -u -r1.54.2.19 zend_language_scanner.l
--- Zend/zend_language_scanner.l 21 May 2003 07:58:49 -0000 1.54.2.19
+++ Zend/zend_language_scanner.l 31 May 2003 00:15:31 -0000
@@ -198,6 +198,15 @@
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh)
{
switch (fh->type) {
+ case ZEND_HANDLE_SOCKET_FD:
+#ifdef ZEND_WIN32
+ closesocket(fh->handle.fd);
+ break;
+#endif
+ /* fall-through */
+ case ZEND_HANDLE_FD:
+ close(fh->handle.fd);
+ break;
case ZEND_HANDLE_FP:
fclose(fh->handle.fp);
break;
@@ -209,9 +218,11 @@
}
if (fh->opened_path) {
efree(fh->opened_path);
+ fh->opened_path = NULL;
}
if (fh->free_filename && fh->filename) {
efree(fh->filename);
+ fh->filename = NULL;
}
}
@@ -225,6 +236,10 @@
case ZEND_HANDLE_FP:
return fh1->handle.fp==fh2->handle.fp;
break;
+ case ZEND_HANDLE_SOCKET_FD:
+ case ZEND_HANDLE_FD:
+ return fh1->handle.fd==fh2->handle.fd;
+ break;
}
return 0;
}
@@ -239,28 +254,27 @@
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
{
char *file_path=NULL;
+ int do_add = 1;
switch (file_handle->type) {
case ZEND_HANDLE_FILENAME:
- file_handle->handle.fp = zend_fopen(file_handle->filename,
&file_handle->opened_path);
- break;
- case ZEND_HANDLE_FD:
- file_handle->handle.fp = fdopen(file_handle->handle.fd, "r");
+ if (zend_open(file_handle->filename, file_handle) == FAILURE)
+ return FAILURE;
break;
- case ZEND_HANDLE_FP:
- file_handle->handle.fp = file_handle->handle.fp;
- break;
- }
- if (!file_handle->handle.fp) {
- return FAILURE;
}
+ file_handle->is_tty = ZEND_TTY_UNKNOWN;
- file_handle->type = ZEND_HANDLE_FP;
- if (file_handle->handle.fp != stdin) {
+ if (!ZEND_IS_VALID_FILE_HANDLE(file_handle))
+ return FAILURE;
+
+ if (file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp == stdin)
+ do_add = 0;
+
+ if (do_add) {
zend_llist_add_element(&CG(open_files), file_handle);
}
/* Reset the scanner for scanning the new file */
- SCNG(yy_in) = file_handle->handle.fp;
+ SCNG(yy_in) = file_handle;
#ifdef ZEND_MULTIBYTE
if (zend_read_file(TSRMLS_C) != 0) {
return FAILURE;
@@ -407,9 +421,8 @@
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.opened_path = NULL;
-
retval = zend_compile_file(&file_handle, type TSRMLS_CC);
- if (retval && file_handle.handle.fp) {
+ if (retval && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
int dummy = 1;
if (!file_handle.opened_path) {
Index: ext/standard/basic_functions.c
===================================================================
RCS file: /repository/php4/ext/standard/basic_functions.c,v
retrieving revision 1.543.2.17
diff -u -r1.543.2.17 basic_functions.c
--- ext/standard/basic_functions.c 21 May 2003 09:34:12 -0000 1.543.2.17
+++ ext/standard/basic_functions.c 31 May 2003 00:15:33 -0000
@@ -2840,7 +2840,7 @@
PHP_FUNCTION(parse_ini_file)
{
zval **filename, **process_sections;
- zend_file_handle fh;
+ zend_file_handle fh = {0};
zend_ini_parser_cb_t ini_parser_cb;
switch (ARG_COUNT(ht)) {
Index: ext/standard/browscap.c
===================================================================
RCS file: /repository/php4/ext/standard/browscap.c,v
retrieving revision 1.60.2.6
diff -u -r1.60.2.6 browscap.c
--- ext/standard/browscap.c 6 Jan 2003 21:43:50 -0000 1.60.2.6
+++ ext/standard/browscap.c 31 May 2003 00:15:33 -0000
@@ -154,7 +154,7 @@
char *browscap = INI_STR("browscap");
if (browscap) {
- zend_file_handle fh;
+ zend_file_handle fh = {0};
if (zend_hash_init(&browser_hash, 0, NULL, (dtor_func_t)
browscap_entry_dtor, 1)==FAILURE) {
return FAILURE;
Index: main/main.c
===================================================================
RCS file: /repository/php4/main/main.c,v
retrieving revision 1.512.2.37
diff -u -r1.512.2.37 main.c
--- main/main.c 21 May 2003 22:54:38 -0000 1.512.2.37
+++ main/main.c 31 May 2003 00:15:34 -0000
@@ -763,6 +763,17 @@
}
/* }}} */
+
+/* {{{ php_open_wrapper_for_zend
+ */
+static zend_bool php_open_wrapper_for_zend(const char *filename, struct
_zend_file_handle *fh)
+{
+ TSRMLS_FETCH();
+
+ return php_stream_open_wrapper_as_file_handle((char *)filename, "rb",
ENFORCE_SAFE_MODE|USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, fh);
+}
+/* }}} */
+
/* {{{ php_get_configuration_directive_for_zend
*/
static int php_get_configuration_directive_for_zend(char *name, uint name_length,
zval *contents)
@@ -1096,6 +1107,7 @@
zuf.printf_function = php_printf;
zuf.write_function = php_body_write_wrapper;
zuf.fopen_function = php_fopen_wrapper_for_zend;
+ zuf.open_function = php_open_wrapper_for_zend;
zuf.message_handler = php_message_handler_for_zend;
zuf.block_interruptions = sapi_module.block_interruptions;
zuf.unblock_interruptions = sapi_module.unblock_interruptions;
Index: main/php_ini.c
===================================================================
RCS file: /repository/php4/main/php_ini.c,v
retrieving revision 1.106.2.11
diff -u -r1.106.2.11 php_ini.c
--- main/php_ini.c 21 May 2003 09:34:13 -0000 1.106.2.11
+++ main/php_ini.c 31 May 2003 00:15:34 -0000
@@ -236,7 +236,7 @@
int safe_mode_state;
char *open_basedir;
int free_ini_search_path=0;
- zend_file_handle fh;
+ zend_file_handle fh = {0};
struct stat sb;
char ini_file[MAXPATHLEN];
char *p;
Index: main/php_streams.h
===================================================================
RCS file: /repository/php4/main/php_streams.h,v
retrieving revision 1.61.2.13
diff -u -r1.61.2.13 php_streams.h
--- main/php_streams.h 21 May 2003 10:19:03 -0000 1.61.2.13
+++ main/php_streams.h 31 May 2003 00:15:34 -0000
@@ -554,6 +554,10 @@
#define php_stream_open_wrapper_as_file(path, mode, options, opened_path)
_php_stream_open_wrapper_as_file((path), (mode), (options), (opened_path) STREAMS_CC
TSRMLS_CC)
+
+PHPAPI zend_bool _php_stream_open_wrapper_as_file_handle(char * path, char * mode,
int options, zend_file_handle * STREAMS_DC TSRMLS_DC);
+#define php_stream_open_wrapper_as_file_handle(path, mode, options, fh)
_php_stream_open_wrapper_as_file_handle((path), (mode), (options), (fh) STREAMS_CC
TSRMLS_CC)
+
/* for user-space streams */
PHPAPI extern php_stream_ops php_stream_userspace_ops;
PHPAPI extern php_stream_ops php_stream_userspace_dir_ops;
Index: main/streams.c
===================================================================
RCS file: /repository/php4/main/Attic/streams.c,v
retrieving revision 1.125.2.67
diff -u -r1.125.2.67 streams.c
--- main/streams.c 28 May 2003 10:15:00 -0000 1.125.2.67
+++ main/streams.c 31 May 2003 00:15:35 -0000
@@ -2729,6 +2729,42 @@
+
+
+/* {{{ php_stream_open_wrapper_as_file_handle */
+PHPAPI zend_bool _php_stream_open_wrapper_as_file_handle(char *path, char *mode, int
options, zend_file_handle *fh STREAMS_DC TSRMLS_DC)
+{
+ php_stream *stream = NULL;
+
+ stream = php_stream_open_wrapper_rel(path, mode, options|STREAM_WILL_CAST,
&fh->opened_path);
+
+ if (stream == NULL)
+ return FAILURE;
+
+ if (php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_TRY_HARD
+ | PHP_STREAM_CAST_RELEASE, (void **) &fh->handle.fd,
+ REPORT_ERRORS) == SUCCESS) {
+ if ((options & STREAM_OPEN_FOR_INCLUDE)
+ && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) {
+ fh->type = ZEND_HANDLE_SOCKET_FD;
+ } else {
+ fh->type = ZEND_HANDLE_FD;
+ }
+ } else if (php_stream_cast(stream, PHP_STREAM_AS_STDIO
+ |PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE,
+ (void**) &fh->handle.fp, REPORT_ERRORS) == SUCCESS) {
+ fh->type = ZEND_HANDLE_FP;
+ } else {
+ php_stream_close(stream);
+ if (fh->opened_path)
+ efree(fh->opened_path);
+ fh->opened_path = NULL;
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ php_stream_make_seekable */
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream,
int flags STREAMS_DC TSRMLS_DC)
{
Index: sapi/aolserver/aolserver.c
===================================================================
RCS file: /repository/php4/sapi/aolserver/aolserver.c,v
retrieving revision 1.72.2.3
diff -u -r1.72.2.3 aolserver.c
--- sapi/aolserver/aolserver.c 21 May 2003 09:34:13 -0000 1.72.2.3
+++ sapi/aolserver/aolserver.c 31 May 2003 00:15:36 -0000
@@ -404,7 +404,7 @@
static int
php_ns_module_main(TSRMLS_D)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
Index: sapi/apache/mod_php4.c
===================================================================
RCS file: /repository/php4/sapi/apache/Attic/mod_php4.c,v
retrieving revision 1.146.2.10
diff -u -r1.146.2.10 mod_php4.c
--- sapi/apache/mod_php4.c 21 May 2003 09:34:13 -0000 1.146.2.10
+++ sapi/apache/mod_php4.c 31 May 2003 00:15:36 -0000
@@ -534,7 +534,7 @@
TSRMLS_FETCH();
if (AP(in_request)) {
- zend_file_handle fh;
+ zend_file_handle fh = {0};
fh.filename = r->filename;
fh.opened_path = NULL;
Index: sapi/apache/sapi_apache.c
===================================================================
RCS file: /repository/php4/sapi/apache/sapi_apache.c,v
retrieving revision 1.40.4.4
diff -u -r1.40.4.4 sapi_apache.c
--- sapi/apache/sapi_apache.c 21 May 2003 09:34:13 -0000 1.40.4.4
+++ sapi/apache/sapi_apache.c 31 May 2003 00:15:36 -0000
@@ -28,7 +28,7 @@
int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
{
int retval = OK;
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
if (php_request_startup(TSRMLS_C) == FAILURE) {
return FAILURE;
Index: sapi/apache2filter/sapi_apache2.c
===================================================================
RCS file: /repository/php4/sapi/apache2filter/sapi_apache2.c,v
retrieving revision 1.91.2.15
diff -u -r1.91.2.15 sapi_apache2.c
--- sapi/apache2filter/sapi_apache2.c 23 May 2003 02:42:22 -0000 1.91.2.15
+++ sapi/apache2filter/sapi_apache2.c 31 May 2003 00:15:36 -0000
@@ -452,7 +452,7 @@
}
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b =
APR_BUCKET_NEXT(b)) {
- zend_file_handle zfd;
+ zend_file_handle zfd = {0};
if (!ctx->request_processed && APR_BUCKET_IS_FILE(b)) {
const char *path;
Index: sapi/apache2handler/sapi_apache2.c
===================================================================
RCS file: /repository/php4/sapi/apache2handler/sapi_apache2.c,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 sapi_apache2.c
--- sapi/apache2handler/sapi_apache2.c 23 May 2003 02:42:22 -0000 1.1.2.15
+++ sapi/apache2handler/sapi_apache2.c 31 May 2003 00:15:36 -0000
@@ -514,7 +514,7 @@
php_get_highlight_struct(&syntax_highlighter_ini);
highlight_file((char *)r->filename, &syntax_highlighter_ini TSRMLS_CC);
} else {
- zend_file_handle zfd;
+ zend_file_handle zfd = {0};
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = (char *) r->filename;
Index: sapi/caudium/caudium.c
===================================================================
RCS file: /repository/php4/sapi/caudium/caudium.c,v
retrieving revision 1.28.2.3
diff -u -r1.28.2.3 caudium.c
--- sapi/caudium/caudium.c 21 May 2003 09:34:14 -0000 1.28.2.3
+++ sapi/caudium/caudium.c 31 May 2003 00:15:37 -0000
@@ -564,7 +564,7 @@
static void php_caudium_module_main(php_caudium_request *ureq)
{
int res;
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
#ifndef USE_PIKE_LEVEL_THREADS
struct thread_state *state;
extern struct program *thread_id_prog;
Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /repository/php4/sapi/cgi/cgi_main.c,v
retrieving revision 1.190.2.34
diff -u -r1.190.2.34 cgi_main.c
--- sapi/cgi/cgi_main.c 30 May 2003 17:03:10 -0000 1.190.2.34
+++ sapi/cgi/cgi_main.c 31 May 2003 00:15:37 -0000
@@ -912,7 +912,7 @@
{
int exit_status = SUCCESS;
int cgi = 0, c, i, len;
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
int retval = FAILURE;
char *s;
/* temporary locals */
Index: sapi/cli/php_cli.c
===================================================================
RCS file: /repository/php4/sapi/cli/php_cli.c,v
retrieving revision 1.51.2.22
diff -u -r1.51.2.22 php_cli.c
--- sapi/cli/php_cli.c 30 May 2003 17:03:10 -0000 1.51.2.22
+++ sapi/cli/php_cli.c 31 May 2003 00:15:38 -0000
@@ -517,7 +517,7 @@
{
int exit_status = SUCCESS;
int c;
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
/* temporary locals */
int behavior=PHP_MODE_STANDARD;
int orig_optind=optind;
Index: sapi/isapi/php4isapi.c
===================================================================
RCS file: /repository/php4/sapi/isapi/php4isapi.c,v
retrieving revision 1.92.2.6
diff -u -r1.92.2.6 php4isapi.c
--- sapi/isapi/php4isapi.c 21 May 2003 09:34:15 -0000 1.92.2.6
+++ sapi/isapi/php4isapi.c 31 May 2003 00:15:38 -0000
@@ -717,7 +717,7 @@
DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
zend_bool stack_overflown=0;
#ifdef PHP_ENABLE_SEH
LPEXCEPTION_POINTERS e;
Index: sapi/phttpd/phttpd.c
===================================================================
RCS file: /repository/php4/sapi/phttpd/phttpd.c,v
retrieving revision 1.35.2.3
diff -u -r1.35.2.3 phttpd.c
--- sapi/phttpd/phttpd.c 21 May 2003 09:34:16 -0000 1.35.2.3
+++ sapi/phttpd/phttpd.c 31 May 2003 00:15:38 -0000
@@ -247,7 +247,7 @@
int php_doit(TSRMLS_D TSRMLS_DC)
{
struct stat sb;
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
struct httpinfo *hip = PHG(cip)->hip;
TSRMLS_FETCH();
Index: sapi/pi3web/pi3web_sapi.c
===================================================================
RCS file: /repository/php4/sapi/pi3web/pi3web_sapi.c,v
retrieving revision 1.46.2.4
diff -u -r1.46.2.4 pi3web_sapi.c
--- sapi/pi3web/pi3web_sapi.c 21 May 2003 09:34:16 -0000 1.46.2.4
+++ sapi/pi3web/pi3web_sapi.c 31 May 2003 00:15:38 -0000
@@ -387,7 +387,7 @@
DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
int iRet = PIAPI_COMPLETED;
TSRMLS_FETCH();
Index: sapi/roxen/roxen.c
===================================================================
RCS file: /repository/php4/sapi/roxen/roxen.c,v
retrieving revision 1.53.2.4
diff -u -r1.53.2.4 roxen.c
--- sapi/roxen/roxen.c 21 May 2003 09:34:16 -0000 1.53.2.4
+++ sapi/roxen/roxen.c 31 May 2003 00:15:38 -0000
@@ -575,7 +575,7 @@
{
int res, len;
char *dir;
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
#ifdef ROXEN_USE_ZTS
GET_THIS();
#endif
Index: sapi/servlet/servlet.c
===================================================================
RCS file: /repository/php4/sapi/servlet/servlet.c,v
retrieving revision 1.65.2.5
diff -u -r1.65.2.5 servlet.c
--- sapi/servlet/servlet.c 21 May 2003 09:34:16 -0000 1.65.2.5
+++ sapi/servlet/servlet.c 31 May 2003 00:15:39 -0000
@@ -310,7 +310,7 @@
jstring contentType, jint contentLength,
jstring authUser, jboolean display_source_mode)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
int retval;
#ifndef VIRTUAL_DIR
char cwd[MAXPATHLEN];
Index: sapi/thttpd/thttpd.c
===================================================================
RCS file: /repository/php4/sapi/thttpd/thttpd.c,v
retrieving revision 1.77.2.11
diff -u -r1.77.2.11 thttpd.c
--- sapi/thttpd/thttpd.c 21 May 2003 09:34:16 -0000 1.77.2.11
+++ sapi/thttpd/thttpd.c 31 May 2003 00:15:39 -0000
@@ -388,7 +388,7 @@
static void thttpd_module_main(int show_source TSRMLS_DC)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
if (php_request_startup(TSRMLS_C) == FAILURE) {
return;
Index: sapi/tux/php_tux.c
===================================================================
RCS file: /repository/php4/sapi/tux/php_tux.c,v
retrieving revision 1.18.2.4
diff -u -r1.18.2.4 php_tux.c
--- sapi/tux/php_tux.c 21 May 2003 09:34:17 -0000 1.18.2.4
+++ sapi/tux/php_tux.c 31 May 2003 00:15:39 -0000
@@ -296,7 +296,7 @@
static void tux_module_main(TSRMLS_D)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
Index: sapi/webjames/webjames.c
===================================================================
RCS file: /repository/php4/sapi/webjames/webjames.c,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 webjames.c
--- sapi/webjames/webjames.c 21 May 2003 09:34:17 -0000 1.5.2.3
+++ sapi/webjames/webjames.c 31 May 2003 00:15:39 -0000
@@ -142,7 +142,7 @@
static void webjames_module_main(TSRMLS_D)
{
- zend_file_handle file_handle;
+ zend_file_handle file_handle = {0};
FILE *fp=NULL;
char *path;
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
