wez Tue Feb 18 04:37:55 2003 EDT Added files: /ZendEngine2 zend_stream.c zend_stream.h
Modified files: /php4 configure.in /php4/ext/standard basic_functions.c /ZendEngine2 Makefile.am flex.skl zend.c zend.h zend_compile.h zend_execute.c zend_globals.h zend_ini_scanner.l zend_language_scanner.h zend_language_scanner.l /php4/main main.c php_ini.c Log: Implement simple stream support in the ZE scanners.
Index: php4/configure.in diff -u php4/configure.in:1.422 php4/configure.in:1.423 --- php4/configure.in:1.422 Sun Feb 16 17:19:28 2003 +++ php4/configure.in Tue Feb 18 04:37:51 2003 @@ -1,4 +1,4 @@ -dnl ## $Id: configure.in,v 1.422 2003/02/16 22:19:28 wez Exp $ -*- sh -*- +dnl ## $Id: configure.in,v 1.423 2003/02/18 09:37:51 wez Exp $ -*- sh -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -1116,7 +1116,7 @@ zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \ zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \ - zend_ini.c zend_qsort.c zend_multibyte.c) + zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c) if test -r "$abs_srcdir/Zend/zend_objects.c"; then PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_mm.c) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.582 php4/ext/standard/basic_functions.c:1.583 --- php4/ext/standard/basic_functions.c:1.582 Mon Feb 17 20:23:51 2003 +++ php4/ext/standard/basic_functions.c Tue Feb 18 04:37:52 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.582 2003/02/18 01:23:51 iliaa Exp $ */ +/* $Id: basic_functions.c,v 1.583 2003/02/18 09:37:52 wez Exp $ */ #include "php.h" #include "php_streams.h" @@ -2941,21 +2941,10 @@ convert_to_string_ex(filename); - if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_ALLOW_ONLY_FILE))) { - RETURN_FALSE; - } - - if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) { - RETURN_FALSE; - } - - fh.handle.fp = VCWD_FOPEN(Z_STRVAL_PP(filename), "r"); - if (!fh.handle.fp) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open '%s' for reading", Z_STRVAL_PP(filename)); - RETURN_FALSE; - } - Z_TYPE(fh) = ZEND_HANDLE_FP; + memset(&fh, 0, sizeof(fh)); fh.filename = Z_STRVAL_PP(filename); + Z_TYPE(fh) = ZEND_HANDLE_FILENAME; + array_init(return_value); zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value); } Index: ZendEngine2/Makefile.am diff -u ZendEngine2/Makefile.am:1.49 ZendEngine2/Makefile.am:1.50 --- ZendEngine2/Makefile.am:1.49 Fri Feb 14 07:05:16 2003 +++ ZendEngine2/Makefile.am Tue Feb 18 04:37:53 2003 @@ -14,7 +14,7 @@ zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \ zend_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c \ - zend_object_API.c + zend_object_API.c zend_ts_hash.c zend_stream.c libZend_la_LDFLAGS = libZend_la_LIBADD = @ZEND_EXTRA_LIBS@ Index: ZendEngine2/flex.skl diff -u ZendEngine2/flex.skl:1.28 ZendEngine2/flex.skl:1.29 --- ZendEngine2/flex.skl:1.28 Wed Aug 14 20:25:27 2002 +++ ZendEngine2/flex.skl Tue Feb 18 04:37:53 2003 @@ -1,7 +1,8 @@ /* A Lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /usr/repository/ZendEngine2/flex.skl,v 1.28 2002/08/15 00:25:27 zeev Exp $ + * $Header: /usr/repository/ZendEngine2/flex.skl,v 1.29 2003/02/18 09:37:53 wez Exp $ + * vim:ft=lex: */ #define FLEX_SCANNER @@ -154,7 +155,7 @@ struct yy_buffer_state { %- - FILE *yy_input_file; + struct _zend_file_handle *yy_input_file; %+ istream* yy_input_file; %* @@ -256,13 +257,13 @@ /* 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 ) @@ -434,6 +435,18 @@ /* Copy whatever the last rule matched to the standard output. */ +/* Zend file handle reading */ +#ifndef ECHO +#define ECHO /* There is no output */ +#endif + +#define YY_INPUT(buf, result, max_size) \ + if ( ((result = zend_stream_read(yyin, buf, max_size TSRMLS_CC)) == 0) \ + && zend_stream_ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + + + #ifndef ECHO %- Standard (non-C++) definition /* This used to be an fputs(), but since the string might contain NUL's, @@ -524,6 +537,7 @@ if ( ! yy_start ) yy_start = 1; /* first start state */ +#if 0 if ( ! SCNG(yy_in) ) %- SCNG(yy_in) = stdin; @@ -537,6 +551,7 @@ %+ SCNG(yy_out) = &cout; %* +#endif if ( ! yy_current_buffer ) yy_current_buffer = @@ -1111,10 +1126,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 +1202,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; @@ -1251,18 +1266,13 @@ %- -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -ZEND_DLIMPORT int isatty YY_PROTO(( int )); -#endif -#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 +1296,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->handle.stream.interactive; #endif #endif %+ Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.212 ZendEngine2/zend.c:1.213 --- ZendEngine2/zend.c:1.212 Sun Feb 16 13:17:19 2003 +++ ZendEngine2/zend.c Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.212 2003/02/16 18:17:19 zeev Exp $ */ +/* $Id: zend.c,v 1.213 2003/02/18 09:37:53 wez Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -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 int (*zend_stream_open_function)(const char *filename, zend_file_handle +*handle TSRMLS_DC); ZEND_API void (*zend_block_interruptions)(void); ZEND_API void (*zend_unblock_interruptions)(void); ZEND_API void (*zend_ticks_function)(int ticks); @@ -534,6 +535,7 @@ if (!zend_fopen) { zend_fopen = zend_fopen_wrapper; } + zend_stream_open_function = utility_functions->stream_open_function; zend_message_dispatcher_p = utility_functions->message_handler; zend_block_interruptions = utility_functions->block_interruptions; zend_unblock_interruptions = utility_functions->unblock_interruptions; Index: ZendEngine2/zend.h diff -u ZendEngine2/zend.h:1.201 ZendEngine2/zend.h:1.202 --- ZendEngine2/zend.h:1.201 Sun Feb 16 06:12:42 2003 +++ ZendEngine2/zend.h Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.201 2003/02/16 11:12:42 stas Exp $ */ +/* $Id: zend.h,v 1.202 2003/02/18 09:37:53 wez Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -342,6 +342,7 @@ typedef struct _zend_class_entry zend_namespace; /* namespace is the same as class */ +#include "zend_stream.h" typedef struct _zend_utility_functions { void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); int (*printf_function)(const char *format, ...); @@ -353,6 +354,7 @@ int (*get_configuration_directive)(char *name, uint name_length, zval *contents); void (*ticks_function)(int ticks); void (*on_timeout)(int seconds TSRMLS_DC); + int (*stream_open_function)(const char *filename, zend_file_handle *handle +TSRMLS_DC); } zend_utility_functions; @@ -485,6 +487,7 @@ extern ZEND_API void (*zend_ticks_function)(int ticks); extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); extern void (*zend_on_timeout)(int seconds TSRMLS_DC); +extern ZEND_API int (*zend_stream_open_function)(const char *filename, +zend_file_handle *handle TSRMLS_DC); ZEND_API void zend_error(int type, const char *format, ...); Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.212 ZendEngine2/zend_compile.h:1.213 --- ZendEngine2/zend_compile.h:1.212 Sun Feb 16 06:34:49 2003 +++ ZendEngine2/zend_compile.h Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.212 2003/02/16 11:34:49 sebastian Exp $ */ +/* $Id: zend_compile.h,v 1.213 2003/02/18 09:37:53 wez Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -198,18 +198,6 @@ znode value; } list_llist_element; - -typedef struct _zend_file_handle { - zend_uchar type; - char *filename; - char *opened_path; - union { - int fd; - FILE *fp; - } handle; - zend_bool free_filename; -} zend_file_handle; - union _temp_variable; struct _zend_execute_data { @@ -726,6 +714,7 @@ #define ZEND_HANDLE_FP 2 #define ZEND_HANDLE_STDIOSTREAM 3 #define ZEND_HANDLE_FSTREAM 4 +#define ZEND_HANDLE_STREAM 5 #define ZEND_FETCH_STANDARD 0 #define ZEND_FETCH_ADD_LOCK 1 Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.432 ZendEngine2/zend_execute.c:1.433 --- ZendEngine2/zend_execute.c:1.432 Mon Feb 17 09:06:39 2003 +++ ZendEngine2/zend_execute.c Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.432 2003/02/17 14:06:39 zeev Exp $ */ +/* $Id: zend_execute.c,v 1.433 2003/02/18 09:37:53 wez Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -3338,28 +3338,21 @@ 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; - 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 (SUCCESS == +zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC)) { + + 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) { CG(active_namespace) = EG(active_namespace); 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_file_handle_dtor(&file_handle); failure_retval=1; } } else { @@ -3368,9 +3361,6 @@ } else { zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle.filename); } - } - if (opened_path) { - efree(opened_path); } break; } Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.118 ZendEngine2/zend_globals.h:1.119 --- ZendEngine2/zend_globals.h:1.118 Sun Feb 16 06:12:42 2003 +++ ZendEngine2/zend_globals.h Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.118 2003/02/16 11:12:42 stas Exp $ */ +/* $Id: zend_globals.h,v 1.119 2003/02/18 09:37:53 wez Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -254,8 +254,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: ZendEngine2/zend_ini_scanner.l diff -u ZendEngine2/zend_ini_scanner.l:1.29 ZendEngine2/zend_ini_scanner.l:1.30 --- ZendEngine2/zend_ini_scanner.l:1.29 Sat Feb 15 17:06:45 2003 +++ ZendEngine2/zend_ini_scanner.l Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ini_scanner.l,v 1.29 2003/02/15 22:06:45 iliaa Exp $ */ +/* $Id: zend_ini_scanner.l,v 1.30 2003/02/18 09:37:53 wez Exp $ */ #define yyleng SCNG(yy_leng) #define yytext SCNG(yy_text) @@ -71,22 +71,12 @@ 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; - break; - default: - return FAILURE; + if (FAILURE == zend_stream_fixup(fh TSRMLS_CC)) { + 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; @@ -95,11 +85,7 @@ void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC) { - switch (fh->type) { - case ZEND_HANDLE_FP: - fclose(fh->handle.fp); - break; - } + zend_stream_close(fh); } %} Index: ZendEngine2/zend_language_scanner.h diff -u ZendEngine2/zend_language_scanner.h:1.11 ZendEngine2/zend_language_scanner.h:1.12 --- ZendEngine2/zend_language_scanner.h:1.11 Fri Jan 31 20:49:14 2003 +++ ZendEngine2/zend_language_scanner.h Tue Feb 18 04:37:53 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_scanner.h,v 1.11 2003/02/01 01:49:14 sniper Exp $ */ +/* $Id: zend_language_scanner.h,v 1.12 2003/02/18 09:37:53 wez Exp $ */ #ifndef ZEND_SCANNER_H #define ZEND_SCANNER_H @@ -25,7 +25,7 @@ typedef struct _zend_lex_state { YY_BUFFER_STATE buffer_state; int state; - FILE *in; + zend_file_handle *in; uint lineno; char *filename; } zend_lex_state; Index: ZendEngine2/zend_language_scanner.l diff -u ZendEngine2/zend_language_scanner.l:1.75 ZendEngine2/zend_language_scanner.l:1.76 --- ZendEngine2/zend_language_scanner.l:1.75 Sun Feb 16 06:12:43 2003 +++ ZendEngine2/zend_language_scanner.l Tue Feb 18 04:37:54 2003 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_scanner.l,v 1.75 2003/02/16 11:12:43 stas Exp $ */ +/* $Id: zend_language_scanner.l,v 1.76 2003/02/18 09:37:54 wez Exp $ */ #define yyleng SCNG(yy_leng) #define yytext SCNG(yy_text) @@ -171,10 +171,15 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh) { + TSRMLS_FETCH(); + switch (fh->type) { case ZEND_HANDLE_FP: fclose(fh->handle.fp); break; + case ZEND_HANDLE_STREAM: + fh->handle.stream.closer(fh->handle.stream.handle TSRMLS_CC); + break; case ZEND_HANDLE_FILENAME: /* We're only supposed to get here when destructing the used_files hash, * which doesn't really contain open files, but references to their names/paths @@ -183,9 +188,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; } } @@ -199,6 +206,9 @@ case ZEND_HANDLE_FP: return fh1->handle.fp==fh2->handle.fp; break; + case ZEND_HANDLE_STREAM: + return fh1->handle.stream.handle == fh2->handle.stream.handle; + break; } return 0; } @@ -214,27 +224,14 @@ { char *file_path=NULL; - 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"); - break; - case ZEND_HANDLE_FP: - file_handle->handle.fp = file_handle->handle.fp; - break; - } - if (!file_handle->handle.fp) { + if (FAILURE == zend_stream_fixup(file_handle TSRMLS_CC)) { return FAILURE; } - file_handle->type = ZEND_HANDLE_FP; - if (file_handle->handle.fp != stdin) { - zend_llist_add_element(&CG(open_files), file_handle); - } + 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; yy_switch_to_buffer(yy_create_buffer(SCNG(yy_in), YY_BUF_SIZE TSRMLS_CC) TSRMLS_CC); BEGIN(INITIAL); @@ -339,7 +336,7 @@ retval = zend_compile_file(&file_handle, type TSRMLS_CC); - if (retval && file_handle.handle.fp) { + if (retval && file_handle.handle.stream.handle) { int dummy = 1; if (!file_handle.opened_path) { Index: php4/main/main.c diff -u php4/main/main.c:1.526 php4/main/main.c:1.527 --- php4/main/main.c:1.526 Mon Feb 17 08:29:56 2003 +++ php4/main/main.c Tue Feb 18 04:37:54 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.526 2003/02/17 13:29:56 zeev Exp $ */ +/* $Id: main.c,v 1.527 2003/02/18 09:37:54 wez Exp $ */ /* {{{ includes */ @@ -732,6 +732,32 @@ } /* }}} */ +static void stream_closer_for_zend(void *handle TSRMLS_DC) +{ + php_stream_close((php_stream*)handle); +} + +static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle +TSRMLS_DC) +{ + php_stream *stream; + + stream = php_stream_open_wrapper((char *)filename, "rb", +ENFORCE_SAFE_MODE|USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, +&handle->opened_path); + + if (stream) { + handle->type = ZEND_HANDLE_STREAM; + handle->filename = (char*)filename; + handle->free_filename = 0; + handle->handle.stream.handle = stream; + handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read; + handle->handle.stream.closer = stream_closer_for_zend; + handle->handle.stream.interactive = 0; + + return SUCCESS; + } + return FAILURE; +} + + /* {{{ php_get_configuration_directive_for_zend */ static int php_get_configuration_directive_for_zend(char *name, uint name_length, zval *contents) @@ -1185,6 +1211,7 @@ zuf.get_configuration_directive = php_get_configuration_directive_for_zend; zuf.ticks_function = php_run_ticks; zuf.on_timeout = php_on_timeout; + zuf.stream_open_function = php_stream_open_for_zend; zend_startup(&zuf, NULL, 1); #ifdef ZTS Index: php4/main/php_ini.c diff -u php4/main/php_ini.c:1.113 php4/main/php_ini.c:1.114 --- php4/main/php_ini.c:1.113 Mon Feb 3 07:25:28 2003 +++ php4/main/php_ini.c Tue Feb 18 04:37:54 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c,v 1.113 2003/02/03 12:25:28 sniper Exp $ */ +/* $Id: php_ini.c,v 1.114 2003/02/18 09:37:54 wez Exp $ */ /* Check CWD for php.ini */ #define INI_CHECK_CWD @@ -370,7 +370,7 @@ PG(safe_mode) = 0; PG(open_basedir) = NULL; - fh.handle.fp = NULL; + memset(&fh, 0, sizeof(fh)); /* Check if php_ini_path_override is a file */ if (!sapi_module.php_ini_ignore) { if (sapi_module.php_ini_path_override && sapi_module.php_ini_path_override[0]) { Index: ZendEngine2/zend_stream.c +++ ZendEngine2/zend_stream.c /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ | Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) | +----------------------------------------------------------------------+ | This source file is subject to version 2.00 of the Zend license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.zend.com/license/2_00.txt. | | If you did not receive a copy of the Zend license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ /* $Id: zend_stream.c,v 1.1 2003/02/18 09:37:54 wez Exp $ */ #include "zend.h" #include "zend_compile.h" ZEND_DLIMPORT int isatty(int fd); static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len TSRMLS_DC) { return fread(buf, 1, len, (FILE*)handle); } static void zend_stream_stdio_closer(void *handle TSRMLS_DC) { if ((FILE*)handle != stdin) fclose((FILE*)handle); } int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC) { if (zend_stream_open) { return zend_stream_open_function(filename, handle TSRMLS_CC); } handle->type = ZEND_HANDLE_FP; handle->opened_path = NULL; handle->handle.fp = zend_fopen(filename, &handle->opened_path); handle->filename = (char *)filename; handle->free_filename = 0; return (handle->handle.fp) ? SUCCESS : FAILURE; } int zend_stream_fixup(zend_file_handle *file_handle TSRMLS_DC) { switch (file_handle->type) { case ZEND_HANDLE_FILENAME: if (FAILURE == zend_stream_open(file_handle->filename, file_handle TSRMLS_CC)) { return FAILURE; } break; case ZEND_HANDLE_FD: file_handle->handle.fp = fdopen(file_handle->handle.fd, "rb"); file_handle->type = ZEND_HANDLE_FP; break; case ZEND_HANDLE_FP: file_handle->handle.fp = file_handle->handle.fp; break; case ZEND_HANDLE_STREAM: /* nothing to do */ return SUCCESS; default: return FAILURE; } if (file_handle->type == ZEND_HANDLE_FP) { if (!file_handle->handle.fp) { return FAILURE; } /* promote to stream */ file_handle->handle.stream.handle = file_handle->handle.fp; file_handle->handle.stream.reader = zend_stream_stdio_reader; file_handle->handle.stream.closer = zend_stream_stdio_closer; file_handle->type = ZEND_HANDLE_STREAM; file_handle->handle.stream.interactive = isatty(fileno(file_handle->handle.stream.handle)); } return SUCCESS; } size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC) { if (file_handle->handle.stream.interactive) { int c = '*', n; for ( n = 0; n < len && (c = zend_stream_getc( file_handle TSRMLS_CC)) != EOF && c != '\n'; ++n ) buf[n] = (char) c; if ( c == '\n' ) buf[n++] = (char) c; return n; } return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len TSRMLS_CC); } int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC) { char buf; if (zend_stream_read(file_handle, &buf, sizeof(buf) TSRMLS_CC)) { return buf; } return EOF; } int zend_stream_ferror(zend_file_handle *file_handle TSRMLS_DC) { return 0; } Index: ZendEngine2/zend_stream.h +++ ZendEngine2/zend_stream.h /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ | Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) | +----------------------------------------------------------------------+ | This source file is subject to version 2.00 of the Zend license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.zend.com/license/2_00.txt. | | If you did not receive a copy of the Zend license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ /* $Id: zend_stream.h,v 1.1 2003/02/18 09:37:54 wez Exp $ */ #ifndef ZEND_STREAM_H #define ZEND_STREAM_H /* Lightweight stream implementation for the ZE scanners. * These functions are private to the engine. * */ typedef size_t (*zend_stream_reader_t)(void *handle, char *buf, size_t len TSRMLS_DC); typedef void (*zend_stream_closer_t)(void *handle TSRMLS_DC); typedef struct _zend_stream { void *handle; zend_stream_reader_t reader; zend_stream_closer_t closer; int interactive; } zend_stream; typedef struct _zend_file_handle { zend_uchar type; char *filename; char *opened_path; union { int fd; FILE *fp; zend_stream stream; } handle; zend_bool free_filename; } zend_file_handle; int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC); int zend_stream_ferror(zend_file_handle *file_handle TSRMLS_DC); int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC); size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC); int zend_stream_fixup(zend_file_handle *file_handle TSRMLS_DC); #define zend_stream_close(handle) zend_file_handle_dtor((handle)) #endif
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php