Hopefully attached.
   
   --Jani
   

-- 
Donate at: https://www.paypal.com/affil/pal=sniper%40php.net
All donated funds will be used for recreation :)
? fd_patch
Index: NEWS
===================================================================
RCS file: /repository/php4/NEWS,v
retrieving revision 1.1247.2.227
diff -u -r1.1247.2.227 NEWS
--- NEWS        30 May 2003 21:40:13 -0000      1.1247.2.227
+++ NEWS        30 May 2003 23:22:06 -0000
@@ -1,6 +1,7 @@
 PHP 4                                                                      NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Jul 2003, Version 4.3.3
+- Improved the engine to use POSIX/socket IO where feasible. (Sascha)
 - Improved NSAPI SAPI module (Uwe Schindler)
   . php4_init (magnus.conf): new parameter to set alternate path to php.ini.
     (php_ini="/path/to/php.ini")
@@ -9,9 +10,6 @@
     (See sapi/nsapi/nsapi-readme.txt for more information)
   . Added support for virtual()
   . Synced $_SERVER variables to be similar to Apache variables
-- Added long options into CLI & CGI (e.g. --version). (Marcus)
-- Added new command line parameters -B, -F, -R and -E which allow to process 
-  stdin line by line (See 'php -h' or 'man php' for more). (Marcus)
 - Added DBA handler 'inifile' to support ini files. (Marcus)
 - Added a "DEBUG" note to 'php -v' output when --enable-debug is used. (Derick)
 - Fixed ext/yaz to not log unless yaz.log_file is set. (Adam Dickmeiss)
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       30 May 2003 23:22:07 -0000
@@ -1,7 +1,7 @@
 /* A Lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /repository/Zend/flex.skl,v 1.27.4.3 2003/05/21 07:53:20 zeev Exp $
+ * $Header: /repository/Zend/flex.skl,v 1.27.4.2 2003/05/13 23:58:19 sas Exp $
  */
 
 #define FLEX_SCANNER
@@ -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;
 %*
@@ -178,13 +194,6 @@
         */
        int yy_is_our_buffer;
 
-       /* Whether this is an "interactive" input source; if so, and
-        * if we're using stdio for input, then we want to use getc()
-        * instead of fread(), to make sure we stop fetching input after
-        * each newline.
-        */
-       int yy_is_interactive;
-
        /* Whether we're considered to be at the beginning of a line.
         * If so, '^' rules will be active on the next match, otherwise
         * not.
@@ -238,31 +247,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 )
 
@@ -282,7 +279,6 @@
        { \
        if ( ! yy_current_buffer ) \
                yy_current_buffer = yy_create_buffer( SCNG(yy_in), YY_BUF_SIZE 
TSRMLS_CC ); \
-       yy_current_buffer->yy_is_interactive = is_interactive; \
        }
 
 #define yy_set_bol(at_bol) \
@@ -322,11 +318,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 +426,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 +521,7 @@
                if ( ! yy_start )
                        yy_start = 1;   /* first start state */
 
+#if 0
                if ( ! SCNG(yy_in) )
 %-
                        SCNG(yy_in) = stdin;
@@ -537,6 +535,7 @@
 %+
                        SCNG(yy_out) = &cout;
 %*
+#endif
 
                if ( ! yy_current_buffer )
                        yy_current_buffer =
@@ -1111,10 +1110,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 +1186,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;
@@ -1253,23 +1252,21 @@
 %-
 #ifndef YY_ALWAYS_INTERACTIVE
 #ifndef YY_NEVER_INTERACTIVE
-extern 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
 #endif
 
 %+
-extern "C" int isatty YY_PROTO(( int ));
 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file TSRMLS_DC )
 %*
 
@@ -1280,17 +1277,7 @@
        b->yy_fill_buffer = 1;
 
 %-
-#if YY_ALWAYS_INTERACTIVE
-       b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
-       b->yy_is_interactive = 0;
-#else
-       b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
 %+
-       b->yy_is_interactive = (file == (istream *) &cin) ? 1 : 0;
 %*
        }
 
@@ -1363,7 +1350,6 @@
        b->yy_is_our_buffer = 0;
        b->yy_input_file = 0;
        b->yy_n_chars = b->yy_buf_size;
-       b->yy_is_interactive = 0;
        b->yy_at_bol = 1;
        b->yy_fill_buffer = 0;
        b->yy_buffer_status = YY_BUFFER_NEW;
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 30 May 2003 23:22:07 -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 30 May 2003 23:22:07 -0000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.h,v 1.164.2.7 2003/05/21 07:53:20 zeev Exp $ */
+/* $Id: zend.h,v 1.164.2.6 2003/05/13 23:08:19 sas Exp $ */
 
 #ifndef ZEND_H
 #define ZEND_H
@@ -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 30 May 2003 23:22:07 -0000
@@ -175,7 +175,7 @@
        zend_bool free_filename;
 } 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 +568,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 30 May 2003 23:22:08 -0000
@@ -2101,38 +2101,32 @@
                                        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;
+                                                               zend_file_handle 
file_handle = {0};
 
-                                                               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 
(zend_open(inc_filename->value.str.val, &file_handle) == SUCCESS 
+                                                                               && 
ZEND_IS_VALID_FILE_HANDLE(&file_handle)) {
 
-                                                               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);
+                                                                       
file_handle.filename = inc_filename->value.str.val;
+                                                                       
file_handle.free_filename = 0;
+
+                                                                       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_file_handle_dtor(&file_handle);
                                                                                
failure_retval=1;
                                                                        }
                                                                } else {
                                                                        if 
(EX(opline)->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE) {
-                                                                               
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle.filename);
+                                                                               
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, inc_filename->value.str.val);
                                                                        } else {
-                                                                               
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle.filename);
+                                                                               
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, inc_filename->value.str.val);
                                                                        }
-                                                               }
-                                                               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 30 May 2003 23:22:08 -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_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     30 May 2003 23:22:08 -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     30 May 2003 23:22:08 -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,41 @@
 
 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;
-       }
+    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;
+    }
 }
+
 
 %}
 
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        30 May 2003 23:22:08 -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        30 May 2003 23:22:09 -0000
@@ -74,6 +74,11 @@
 #endif
 
 
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+
+
 /* Globals Macros */
 #define SCNG   LANG_SCNG
 #ifdef ZTS
@@ -198,6 +203,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 +223,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 +241,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 +259,28 @@
 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) != SUCCESS)
+                               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->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;
+       else if (file_handle->type == ZEND_HANDLE_FD && file_handle->handle.fd == 
STDIN_FILENO)
+               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;
@@ -391,7 +411,7 @@
 
 zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
 {
-       zend_file_handle file_handle;
+       zend_file_handle file_handle = {0};
        zval tmp;
        zend_op_array *retval;
        char *opened_path = NULL;
@@ -407,9 +427,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) {
@@ -544,7 +563,7 @@
 int highlight_file(char *filename, zend_syntax_highlighter_ini 
*syntax_highlighter_ini TSRMLS_DC)
 {
        zend_lex_state original_lex_state;
-       zend_file_handle file_handle;
+       zend_file_handle file_handle = {0};
 
        file_handle.type = ZEND_HANDLE_FILENAME;
        file_handle.filename = filename;
@@ -666,27 +685,41 @@
        SCNG(code) = NULL;
        SCNG(code_size) = 0;
 
-       do {
-               n = fread(buf, 1, 8192, SCNG(yy_in));
-               if (n) {
-                       SCNG(code_size) += n;
-                       if (SCNG(code)) {
-                               SCNG(code) = (char*)erealloc(SCNG(code), 
SCNG(code_size)+1);
-                               if (!SCNG(code)) {
-                                       return -1;
-                               }
-                       } else {
-                               SCNG(code) = (char*)emalloc(SCNG(code_size)+1);
-                               if (!SCNG(code)) {
-                                       return -1;
-                               }
+       for (;;) {
+               switch (SCNG(yy_in)->type) {
+                       case ZEND_HANDLE_FD:
+                               n = read(SCNG(yy_in)->handle.fd, buf, sizeof(buf));
+                               break;
+                       case ZEND_HANDLE_FP:
+                               n = fread(buf, sizeof(buf[0]), sizeof(buf) / 
sizeof(buf[0]), SCNG(yy_in)->handle.fp);
+                               break;
+                       case ZEND_HANDLE_SOCKET_FD:
+                               n =     recv(SCNG(yy_in)->handle.fd, buf, sizeof(buf), 
0);
+               }
+
+               if (n <= 0) {
+                       break;
+               }
+
+               SCNG(code_size) += n;
+               if (SCNG(code)) {
+                       SCNG(code) = (char*)erealloc(SCNG(code), SCNG(code_size)+1);
+                       if (!SCNG(code)) {
+                               return -1;
+                       }
+               } else {
+                       SCNG(code) = (char*)emalloc(SCNG(code_size)+1);
+                       if (!SCNG(code)) {
+                               return -1;
                        }
-                       memcpy(SCNG(code)+SCNG(code_size)-n, buf, n);
                }
-       } while(n);
-       if (ferror(SCNG(yy_in))) {
+               memcpy(SCNG(code)+SCNG(code_size)-n, buf, n);
+       }
+
+       if (n < 0) {
                return -1;
        }
+
        if (!SCNG(code)) {
                SCNG(code) = emalloc(SCNG(code_size)+1);
        }
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      30 May 2003 23:22:17 -0000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.543.2.17 2003/05/21 09:34:12 zeev Exp $ */
+/* $Id: basic_functions.c,v 1.543.2.16 2003/05/19 17:45:50 derick Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -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.11
diff -u -r1.60.2.11 browscap.c
--- ext/standard/browscap.c     27 May 2003 17:24:09 -0000      1.60.2.11
+++ ext/standard/browscap.c     30 May 2003 23:22:17 -0000
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: browscap.c,v 1.60.2.11 2003/05/27 17:24:09 sniper Exp $ */
+/* $Id: browscap.c,v 1.60.2.9 2003/05/17 07:55:18 sas Exp $ */
 
 #include "php.h"
 #include "php_regex.h"
@@ -150,7 +150,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 30 May 2003 23:22:17 -0000
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: main.c,v 1.512.2.37 2003/05/21 22:54:38 iliaa Exp $ */
+/* $Id: main.c,v 1.512.2.35 2003/05/17 07:55:18 sas Exp $ */
 
 /* {{{ includes
  */
@@ -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;
@@ -1591,7 +1603,7 @@
 PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
 {
        zend_file_handle *prepend_file_p, *append_file_p;
-       zend_file_handle prepend_file, append_file;
+       zend_file_handle prepend_file = {0}, append_file = {0};
 #if HAVE_BROKEN_GETCWD 
        int old_cwd_fd = -1;
 #else
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      30 May 2003 23:22:17 -0000
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ini.c,v 1.106.2.11 2003/05/21 09:34:13 zeev Exp $ */
+/* $Id: php_ini.c,v 1.106.2.10 2003/05/17 07:55:18 sas Exp $ */
 
 /* Check CWD for php.ini */
 #define INI_CHECK_CWD
@@ -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;
@@ -347,7 +347,6 @@
        PG(safe_mode) = 0;
        PG(open_basedir) = 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: 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  30 May 2003 23:22:17 -0000
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h,v 1.61.2.13 2003/05/21 10:19:03 zeev Exp $ */
+/* $Id: php_streams.h,v 1.61.2.12 2003/05/13 23:09:27 sas Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -553,6 +553,9 @@
 PHPAPI FILE * _php_stream_open_wrapper_as_file(char * path, char * mode, int options, 
char **opened_path STREAMS_DC TSRMLS_DC);
 #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;
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      30 May 2003 23:22:18 -0000
@@ -2728,6 +2728,45 @@
 
 
 
+/* {{{ 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;
+       int is_sock = 0;
+
+       stream = php_stream_open_wrapper_rel(path, mode, options|STREAM_WILL_CAST, 
&fh->opened_path);
+
+       if (stream == NULL)
+               return FAILURE;
+
+       if ((options & STREAM_OPEN_FOR_INCLUDE) 
+                       && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) {
+               is_sock = 1;
+       }
+
+       if (php_stream_can_cast(stream, PHP_STREAM_AS_FD) == SUCCESS &&
+                       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 (is_sock) {
+                       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  30 May 2003 23:22:18 -0000
@@ -22,7 +22,7 @@
  * - CGI/1.1 conformance
  */
 
-/* $Id: aolserver.c,v 1.72.2.3 2003/05/21 09:34:13 zeev Exp $ */
+/* $Id: aolserver.c,v 1.72.2.2 2003/05/17 08:06:52 sas Exp $ */
 
 /* conflict between PHP and AOLserver headers */
 #define Debug php_Debug
@@ -205,7 +205,7 @@
        int i;
        
        php_info_print_table_start();
-       php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 
1.72.2.3 2003/05/21 09:34:13 zeev Exp $");
+       php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 
1.72.2.2 2003/05/17 08:06:52 sas Exp $");
        php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
        php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
        php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -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      30 May 2003 23:22:18 -0000
@@ -17,7 +17,7 @@
    | PHP 4.0 patches by Zeev Suraski <[EMAIL PROTECTED]>                      |
    +----------------------------------------------------------------------+
  */
-/* $Id: mod_php4.c,v 1.146.2.10 2003/05/21 09:34:13 zeev Exp $ */
+/* $Id: mod_php4.c,v 1.146.2.9 2003/05/17 08:06:52 sas Exp $ */
 
 #include "php_apache_http.h"
 #include "http_conf_globals.h"
@@ -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   30 May 2003 23:22:18 -0000
@@ -19,7 +19,7 @@
    | Stig Bakken <[EMAIL PROTECTED]>                                            |
    +----------------------------------------------------------------------+
  */
-/* $Id: sapi_apache.c,v 1.40.4.4 2003/05/21 09:34:13 zeev Exp $ */
+/* $Id: sapi_apache.c,v 1.40.4.3 2003/05/17 08:06:52 sas Exp $ */
 
 #include "php_apache_http.h"
 
@@ -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   30 May 2003 23:22:18 -0000
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c,v 1.91.2.15 2003/05/23 02:42:22 iliaa Exp $ */
+/* $Id: sapi_apache2.c,v 1.91.2.13 2003/05/20 07:34:08 moriyoshi Exp $ */
 
 #include <fcntl.h>
 
@@ -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  30 May 2003 23:22:18 -0000
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c,v 1.1.2.15 2003/05/23 02:42:22 iliaa Exp $ */
+/* $Id: sapi_apache2.c,v 1.1.2.13 2003/05/20 07:34:08 moriyoshi Exp $ */
 
 #include <fcntl.h>
 
@@ -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      30 May 2003 23:22:19 -0000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: caudium.c,v 1.28.2.3 2003/05/21 09:34:14 zeev Exp $ */
+/* $Id: caudium.c,v 1.28.2.2 2003/05/17 08:06:52 sas Exp $ */
 
 #include "php.h"
 #ifdef HAVE_CAUDIUM
@@ -444,7 +444,7 @@
 {
   /*  char buf[512]; */
   php_info_print_table_start();
-  php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.28.2.3 
2003/05/21 09:34:14 zeev Exp $");
+  php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.28.2.2 
2003/05/17 08:06:52 sas Exp $");
   /*  php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
       php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
       php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -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 30 May 2003 23:22:20 -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  30 May 2003 23:22:20 -0000
@@ -89,39 +89,11 @@
 #define PHP_MODE_LINT        4
 #define PHP_MODE_STRIP       5
 #define PHP_MODE_CLI_DIRECT  6
-#define PHP_MODE_PROCESS_STDIN 7
 
-static char *optarg = NULL;
-static int optind = 1;
+extern char *ap_php_optarg;
+extern int ap_php_optind;
 
-static const opt_struct OPTIONS[] = {
-       {'a', 0, "interactive"},
-       {'B', 1, "process-begin"},
-       {'C', 0, "no-chdir"}, /* for compatibility with CGI (do not chdir to script 
directory) */
-       {'c', 1, "php-ini"},
-       {'d', 1, "define"},
-       {'E', 1, "process-end"},
-       {'e', 0, "profile-info"},
-       {'F', 1, "process-file"},
-       {'f', 1, "file"},
-       {'g', 1, "global"},
-       {'h', 0, "help"},
-       {'i', 0, "info"},
-       {'l', 0, "syntax-check"},
-       {'m', 0, "modules"},
-       {'n', 0, "no-php-ini"},
-       {'q', 0, "no-header"}, /* for compatibility with CGI (do not generate HTTP 
headers) */
-       {'R', 1, "process-code"},
-       {'H', 0, "hide-args"},
-       {'r', 1, "run"},
-       {'s', 0, "syntax-highlight"},
-       {'s', 0, "syntax-highlighting"},
-       {'w', 0, "strip"},
-       {'?', 0, "usage"},/* help alias (both '?' and 'usage') */
-       {'v', 0, "version"},
-       {'z', 1, "zend-extension"},
-       {'-', 0, NULL} /* end of args */
-};
+#define OPTSTRING "aCc:d:ef:g:hilmnqr:sw?vz:"
 
 static int print_module_info(zend_module_entry *module, void *arg TSRMLS_DC)
 {
@@ -358,12 +330,9 @@
                prog = "php";
        }
        
-       php_printf( "Usage: %s [options] [-f] <file> [--] [args...]\n"
-                   "       %s [options] -r <code> [--] [args...]\n"
-                   "       %s [options] [-B <begin_code>] -R <code> [-E <end_code>] 
[--] [args...]\n"
-                   "       %s [options] [-B <begin_code>] -F <file> [-E <end_code>] 
[--] [args...]\n"
-                   "       %s [options] -- [args...]\n"
-                   "\n"
+       php_printf( "Usage: %s [options] [-f] <file> [args...]\n"
+                   "       %s [options] -r <code> [args...]\n"
+                   "       %s [options] [-- args...]\n"
                                "  -a               Run interactively\n"
                                "  -c <path>|<file> Look for php.ini file in this 
directory\n"
                                "  -n               No php.ini file will be used\n"
@@ -375,11 +344,6 @@
                                "  -l               Syntax check only (lint)\n"
                                "  -m               Show compiled in modules\n"
                                "  -r <code>        Run PHP <code> without using 
script tags <?..?>\n"
-                               "  -B <begin_code>  Run PHP <begin_code> before 
processing input lines\n"
-                               "  -R <code>        Run PHP <code> for every input 
line\n"
-                               "  -F <file>        Parse and execute <file> for every 
input line\n"
-                               "  -E <end_code>    Run PHP <end_code> after 
processing all input lines\n"
-                               "  -H               Hide any passed arguments from 
external tools.\n"
                                "  -s               Display colour syntax highlighted 
source.\n"
                                "  -v               Version number\n"
                                "  -w               Display source with stripped 
comments and whitespace.\n"
@@ -387,8 +351,7 @@
                                "\n"
                                "  args...          Arguments passed to script. Use -- 
args when first argument \n"
                                "                   starts with - or script is read 
from stdin\n"
-                               "\n"
-                               , prog, prog, prog, prog, prog);
+                               , prog, prog, prog);
 }
 /* }}} */
 
@@ -423,9 +386,6 @@
        efree(*arg);
 }
 
-static php_stream_context *sc_in_process = NULL;
-static php_stream *s_in_process = NULL;
-
 static void cli_register_file_handles(TSRMLS_D)
 {
        zval *zin, *zout, *zerr;
@@ -445,9 +405,6 @@
                return;
        }
 
-       sc_in_process = sc_in;
-       s_in_process = s_in;
-
        php_stream_to_zval(s_in,  zin);
        php_stream_to_zval(s_out, zout);
        php_stream_to_zval(s_err, zerr);
@@ -475,42 +432,6 @@
        FREE_ZVAL(zerr);
 }
 
-static const char *param_mode_conflict = "Either execute direct code, process stdin 
or use a file.\n";
-
-/* {{{ cli_seek_file_begin
- */
-static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, int 
*lineno TSRMLS_DC)
-{
-       int c;
-
-       *lineno = 1;
-
-       if (!(file_handle->handle.fp = VCWD_FOPEN(script_file, "rb"))) {
-               php_printf("Could not open input file: %s.\n", script_file);
-               return FAILURE;
-       }
-       file_handle->filename = script_file;
-       /* #!php support */
-       c = fgetc(file_handle->handle.fp);
-       if (c == '#') {
-               while (c != 10 && c != 13) {
-                       c = fgetc(file_handle->handle.fp);      /* skip to end of line 
*/
-               }
-               /* handle situations where line is terminated by \r\n */
-               if (c == 13) {
-                       if (fgetc(file_handle->handle.fp) != 10) {
-                               long pos = ftell(file_handle->handle.fp);
-                               fseek(file_handle->handle.fp, pos - 1, SEEK_SET);
-                       }
-               }
-               *lineno = -2;
-       } else {
-               rewind(file_handle->handle.fp);
-       }
-       return SUCCESS;
-}
-/* }}} */
-
 /* {{{ main
  */
 int main(int argc, char *argv[])
@@ -520,18 +441,16 @@
        zend_file_handle file_handle;
 /* temporary locals */
        int behavior=PHP_MODE_STANDARD;
-       int orig_optind=optind;
-       char *orig_optarg=optarg;
+       int no_headers=1;
+       int orig_optind=ap_php_optind;
+       char *orig_optarg=ap_php_optarg;
        char *arg_free=NULL, **arg_excp=&arg_free;
        char *script_file=NULL;
        zend_llist global_vars;
-       int interactive=0;
+       int interactive=0, is_hashbang=0;
        int module_started = 0;
-       int lineno = 0;
-       char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
-       const char *param_error=NULL;
-       int scan_input = 0;
-       int hide_argv = 0;
+       char *exec_direct=NULL;
+       char *param_error=NULL;
 /* end of temporary locals */
 #ifdef ZTS
        zend_compiler_globals *compiler_globals;
@@ -570,18 +489,18 @@
 #endif
 
 
-       while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0))!=-1) {
+       while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
                switch (c) {
                case 'c':
-                       cli_sapi_module.php_ini_path_override = strdup(optarg);
+                       cli_sapi_module.php_ini_path_override = strdup(ap_php_optarg);
                        break;
                case 'n':
                        cli_sapi_module.php_ini_ignore = 1;
                        break;
                }
        }
-       optind = orig_optind;
-       optarg = orig_optarg;
+       ap_php_optind = orig_optind;
+       ap_php_optarg = orig_optarg;
 
        cli_sapi_module.executable_location = argv[0];
 
@@ -606,69 +525,23 @@
        module_started = 1;
 
        zend_first_try {
-               zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
-
-               zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
-               CG(in_compilation) = 0; /* not initialized but needed for several 
options */
-               EG(uninitialized_zval_ptr) = NULL;
-
-               if (cli_sapi_module.php_ini_path_override && 
cli_sapi_module.php_ini_ignore) {
-                       PUTS("You cannot use both -n and -c switch. Use -h for 
help.\n");
-                       exit_status=1;
-                       goto out_err;
-               }
-       
-               while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0)) != 
-1) {
+               while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
                        switch (c) {
-
-                       case 'h': /* help & quit */
                        case '?':
+                               no_headers = 1;
                                php_output_startup();
                                php_output_activate(TSRMLS_C);
+                               SG(headers_sent) = 1;
                                php_cli_usage(argv[0]);
                                php_end_ob_buffers(1 TSRMLS_CC);
-                               exit_status=1;
-                               goto out_err;
-
-
-                       case 'i': /* php info & quit */
-                               if (php_request_startup(TSRMLS_C)==FAILURE) {
-                                       goto err;
-                       }
-                               php_print_info(0xFFFFFFFF TSRMLS_CC);
-                               php_end_ob_buffers(1 TSRMLS_CC);
-                               exit_status=1;
-                               goto out;
-
-                       case 'm': /* list compiled in modules */
-                               php_output_startup();
-                               php_output_activate(TSRMLS_C);
-                               php_printf("[PHP Modules]\n");
-                               print_modules(TSRMLS_C);
-                               php_printf("\n[Zend Modules]\n");
-                               print_extensions(TSRMLS_C);
-                               php_printf("\n");
-                               php_end_ob_buffers(1 TSRMLS_CC);
-                               exit_status=1;
-                               goto out_err;
-
-                       case 'v': /* show php version & quit */
-                               if (php_request_startup(TSRMLS_C)==FAILURE) {
-                                       goto err;
-                               }
-#if ZEND_DEBUG
-                               php_printf("PHP %s (%s) (built: %s %s) 
(DEBUG)\nCopyright (c) 1997-2003 The PHP Group\n%s", PHP_VERSION, sapi_module.name, 
__DATE__, __TIME__, get_zend_version());
-#else
-                               php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 
1997-2003 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, 
get_zend_version());
-#endif
-                               php_end_ob_buffers(1 TSRMLS_CC);
-                               exit_status=1;
-                               goto out;
-
-                       default:
+                               exit(1);
                                break;
                        }
                }
+               ap_php_optind = orig_optind;
+               ap_php_optarg = orig_optarg;
+
+               zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
 
         /* Set some CLI defaults */
                SG(options) |= SAPI_OPTION_NO_CHDIR;
@@ -678,9 +551,19 @@
                INI_HARDCODED("implicit_flush", "1");
                INI_HARDCODED("max_execution_time", "0");
 
-               optind = orig_optind;
-               optarg = orig_optarg;
-               while ((c = php_getopt(argc, argv, OPTIONS, &optarg, &optind, 0)) != 
-1) {
+               zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
+               CG(in_compilation) = 0; /* not initialized but needed for several 
options */
+               EG(uninitialized_zval_ptr) = NULL;
+
+               if (cli_sapi_module.php_ini_path_override && 
cli_sapi_module.php_ini_ignore) {
+                       SG(headers_sent) = 1;
+                       SG(request_info).no_headers = 1;
+                       PUTS("You cannot use both -n and -c switch. Use -h for 
help.\n");
+                       exit_status=1;
+                       goto out_err;
+               }
+       
+               while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) {
                        switch (c) {
 
                        case 'a':       /* interactive mode */
@@ -692,56 +575,80 @@
                                /* This is default so NOP */
                                break;
                        case 'd': /* define ini entries on command line */
-                               define_command_line_ini_entry(optarg);
+                               define_command_line_ini_entry(ap_php_optarg);
                                break;
 
                        case 'e': /* enable extended info output */
                                CG(extended_info) = 1;
                                break;
 
-                       case 'F':
-                               if (behavior == PHP_MODE_PROCESS_STDIN) {
-                                       if (exec_run || script_file) {
-                                               param_error = "You can use -R or -F 
only once.\n";
-                                               break;
-                                       }
-                               } else if (behavior != PHP_MODE_STANDARD) {
-                                       param_error = param_mode_conflict;
-                                       break;
-                               }
-                               behavior=PHP_MODE_PROCESS_STDIN;
-                               script_file = optarg;
-                               break;
-
                        case 'f': /* parse file */
-                               if (behavior == PHP_MODE_CLI_DIRECT || behavior == 
PHP_MODE_PROCESS_STDIN) {
-                                       param_error = param_mode_conflict;
-                                       break;
-                               } else if (script_file) {
-                                       param_error = "You can use -f only once.\n";
+                               if (behavior == PHP_MODE_CLI_DIRECT) {
+                                       param_error = "Either execute direct code or 
use a file.\n";
                                        break;
                                }
-                               script_file = optarg;
+                               script_file = ap_php_optarg;
+                               no_headers = 1;
                                break;
 
                        case 'g': /* define global variables on command line */
                                {
-                                       char *arg = estrdup(optarg);
+                                       char *arg = estrdup(ap_php_optarg);
 
                                        zend_llist_add_element(&global_vars, &arg);
                                }
                                break;
 
+                       case 'h': /* help & quit */
+                       case '?':
+                               no_headers = 1;
+                               php_output_startup();
+                               php_output_activate(TSRMLS_C);
+                               SG(headers_sent) = 1;
+                               php_cli_usage(argv[0]);
+                               php_end_ob_buffers(1 TSRMLS_CC);
+                               exit_status=1;
+                               zend_ini_deactivate(TSRMLS_C);
+                               goto out_err;
+
+                       case 'i': /* php info & quit */
+                               if (php_request_startup(TSRMLS_C)==FAILURE) {
+                                       goto err;
+                               }
+                               if (no_headers) {
+                                       SG(headers_sent) = 1;
+                                       SG(request_info).no_headers = 1;
+                               }
+                               php_print_info(0xFFFFFFFF TSRMLS_CC);
+                               php_end_ob_buffers(1 TSRMLS_CC);
+                               exit_status=1;
+                               goto out;
+
                        case 'l': /* syntax check mode */
                                if (behavior != PHP_MODE_STANDARD) {
                                        break;
                                }
+                               no_headers = 1;
                                behavior=PHP_MODE_LINT;
                                break;
 
+                       case 'm': /* list compiled in modules */
+                               php_output_startup();
+                               php_output_activate(TSRMLS_C);
+                               SG(headers_sent) = 1;
+                               php_printf("[PHP Modules]\n");
+                               print_modules(TSRMLS_C);
+                               php_printf("\n[Zend Modules]\n");
+                               print_extensions(TSRMLS_C);
+                               php_printf("\n");
+                               php_end_ob_buffers(1 TSRMLS_CC);
+                               exit_status=1;
+                               zend_ini_deactivate(TSRMLS_C);
+                               goto out_err;
+
 #if 0 /* not yet operational, see also below ... */
                        case '': /* generate indented source mode*/
-                               if (behavior == PHP_MODE_CLI_DIRECT || behavior == 
PHP_MODE_PROCESS_STDIN) {
+                               if (behavior == PHP_MODE_CLI_DIRECT) {
                                        param_error = "Source indenting only works for 
files.\n";
                                        break;
                                }
@@ -754,72 +661,38 @@
                                break;
 
                        case 'r': /* run code from command line */
-                               if (behavior == PHP_MODE_CLI_DIRECT) {
-                                       if (exec_direct || script_file) {
-                                               param_error = "You can use -r only 
once.\n";
-                                               break;
-                                       }
-                               } else if (behavior != PHP_MODE_STANDARD) {
-                                       param_error = param_mode_conflict;
+                               if (behavior != PHP_MODE_STANDARD) {
+                                       param_error = "Either execute direct code or 
use a file.\n";
                                        break;
                                }
                                behavior=PHP_MODE_CLI_DIRECT;
-                               exec_direct=optarg;
-                               break;
-
-                       case 'R':
-                               if (behavior == PHP_MODE_PROCESS_STDIN) {
-                                       if (exec_run || script_file) {
-                                               param_error = "You can use -R or -F 
only once.\n";
-                                       break;
-                               }
-                               } else if (behavior != PHP_MODE_STANDARD) {
-                                       param_error = param_mode_conflict;
-                                       break;
-                               }
-                               behavior=PHP_MODE_PROCESS_STDIN;
-                               exec_run=optarg;
-                               break;
-
-                       case 'B':
-                               if (behavior == PHP_MODE_PROCESS_STDIN) {
-                                       if (exec_begin) {
-                                               param_error = "You can use -B only 
once.\n";
-                                               break;
-                               }
-                               } else if (behavior != PHP_MODE_STANDARD) {
-                                       param_error = param_mode_conflict;
-                                       break;
-                               }
-                               behavior=PHP_MODE_PROCESS_STDIN;
-                               exec_begin=optarg;
-                               break;
-
-                       case 'E':
-                               if (behavior == PHP_MODE_PROCESS_STDIN) {
-                                       if (exec_end) {
-                                               param_error = "You can use -E only 
once.\n";
-                                               break;
-                                       }
-                               } else if (behavior != PHP_MODE_STANDARD) {
-                                       param_error = param_mode_conflict;
-                                       break;
-                               }
-                               scan_input = 1;
-                               behavior=PHP_MODE_PROCESS_STDIN;
-                               exec_end=optarg;
+                               exec_direct=ap_php_optarg;
                                break;
 
                        case 's': /* generate highlighted HTML from source */
-                               if (behavior == PHP_MODE_CLI_DIRECT || behavior == 
PHP_MODE_PROCESS_STDIN) {
+                               if (behavior == PHP_MODE_CLI_DIRECT) {
                                        param_error = "Source highlighting only works 
for files.\n";
                                        break;
                                }
                                behavior=PHP_MODE_HIGHLIGHT;
                                break;
 
+                       case 'v': /* show php version & quit */
+                               no_headers = 1;
+                               if (php_request_startup(TSRMLS_C)==FAILURE) {
+                                       goto err;
+                               }
+                               if (no_headers) {
+                                       SG(headers_sent) = 1;
+                                       SG(request_info).no_headers = 1;
+                               }
+                               php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 
1997-2003 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, 
get_zend_version());
+                               php_end_ob_buffers(1 TSRMLS_CC);
+                               exit_status=1;
+                               goto out;
+
                        case 'w':
-                               if (behavior == PHP_MODE_CLI_DIRECT || behavior == 
PHP_MODE_PROCESS_STDIN) {
+                               if (behavior == PHP_MODE_CLI_DIRECT) {
                                        param_error = "Source stripping only works for 
files.\n";
                                        break;
                                }
@@ -827,10 +700,7 @@
                                break;
 
                        case 'z': /* load extension file */
-                               zend_load_extension(optarg);
-                               break;
-                       case 'H':
-                               hide_argv = 1;
+                               zend_load_extension(ap_php_optarg);
                                break;
 
                        default:
@@ -839,6 +709,8 @@
                }
 
                if (param_error) {
+                       SG(headers_sent) = 1;
+                       SG(request_info).no_headers = 1;
                        PUTS(param_error);
                        exit_status=1;
                        goto out_err;
@@ -847,25 +719,38 @@
                CG(interactive) = interactive;
 
                /* only set script_file if not set already and not in direct mode and 
not at end of parameter list */
-               if (argc > optind 
-                 && !script_file 
-                 && behavior!=PHP_MODE_CLI_DIRECT 
-                 && behavior!=PHP_MODE_PROCESS_STDIN 
-                 && strcmp(argv[optind-1],"--")) 
-               {
-                       script_file=argv[optind];
-                       optind++;
+               if (argc > ap_php_optind && !script_file && 
behavior!=PHP_MODE_CLI_DIRECT && strcmp(argv[ap_php_optind-1],"--")) {
+                       no_headers = 1;
+                       script_file=argv[ap_php_optind];
+                       ap_php_optind++;
                }
                if (script_file) {
-                       if (cli_seek_file_begin(&file_handle, script_file, &lineno 
TSRMLS_CC) != SUCCESS) {
+                       if (!(file_handle.handle.fp = VCWD_FOPEN(script_file, "rb"))) {
+                               SG(headers_sent) = 1;
+                               SG(request_info).no_headers = 1;
+                               php_printf("Could not open input file: %s.\n", 
script_file);
                                goto err;
                        }
+                       file_handle.filename = script_file;
                        script_filename = script_file;
+                       /* #!php support */
+                       c = fgetc(file_handle.handle.fp);
+                       if (c == '#') {
+                               while (c != 10 && c != 13) {
+                                       c = fgetc(file_handle.handle.fp);       /* 
skip to end of line */
+                               }
+                               /* handle situations where line is terminated by \r\n 
*/
+                               if (c == 13) {
+                                       if (fgetc(file_handle.handle.fp) != 10) {
+                                               long pos = 
ftell(file_handle.handle.fp);
+                                               fseek(file_handle.handle.fp, pos - 1, 
SEEK_SET);
+                                       }
+                               }
+                               is_hashbang = 1;
+                       } else {
+                               rewind(file_handle.handle.fp);
+                       }
                } else {
-                       /* We could handle PHP_MODE_PROCESS_STDIN in a different 
manner  */
-                       /* here but this would make things only more complicated. And 
it */
-                       /* is consitent with the way -R works where the stdin file 
handle*/
-                       /* is also accessible. */
                        file_handle.filename = "-";
                        file_handle.handle.fp = stdin;
                }
@@ -874,30 +759,34 @@
                file_handle.free_filename = 0;
                php_self = file_handle.filename;
 
-               /* before registering argv to module exchange the *new* argv[0] */
+               /* before registering argv to modulule exchange the *new* argv[0] */
                /* we can achieve this without allocating more memory */
-               SG(request_info).argc=argc-optind+1;
-               arg_excp = argv+optind-1;
-               arg_free = argv[optind-1];
+               SG(request_info).argc=argc-ap_php_optind+1;
+               arg_excp = argv+ap_php_optind-1;
+               arg_free = argv[ap_php_optind-1];
                SG(request_info).path_translated = file_handle.filename;
-               argv[optind-1] = file_handle.filename;
-               SG(request_info).argv=argv+optind-1;
+               argv[ap_php_optind-1] = file_handle.filename;
+               SG(request_info).argv=argv+ap_php_optind-1;
 
                if (php_request_startup(TSRMLS_C)==FAILURE) {
                        *arg_excp = arg_free;
                        fclose(file_handle.handle.fp);
+                       SG(headers_sent) = 1;
+                       SG(request_info).no_headers = 1;
                        php_request_shutdown((void *) 0);
                        PUTS("Could not startup.\n");
                        goto err;
                }
-               CG(zend_lineno) = lineno;
-               *arg_excp = arg_free; /* reconstuct argv */
 
-               if (hide_argv) {
-                       int i;
-                       for (i = 1; i < argc; i++) {
-                               memset(argv[i], 0, strlen(argv[i]));
-                       }
+               /* Correct line numbers when #!php is used. This is reset in 
php_request_startup(). */
+               if (is_hashbang) {
+                       CG(zend_lineno) = -2;
+               }
+
+               *arg_excp = arg_free; /* reconstuct argv */
+               if (no_headers) {
+                       SG(headers_sent) = 1;
+                       SG(request_info).no_headers = 1;
                }
 
                /* This actually destructs the elements of the list - ugly hack */
@@ -955,58 +844,6 @@
                                exit_status=254;
                        }
                        break;
-                       
-               case PHP_MODE_PROCESS_STDIN:
-                       {
-                               char *input;
-                               size_t len, index = 0;
-                               pval *argn, *argi;
-
-                               cli_register_file_handles(TSRMLS_C);
-       
-                               if (exec_begin && zend_eval_string(exec_begin, NULL, 
"Command line begin code" TSRMLS_CC) == FAILURE) {
-                                       exit_status=254;
-                               }
-                               ALLOC_ZVAL(argi);
-                               Z_TYPE_P(argi) = IS_LONG;
-                               Z_LVAL_P(argi) = index;
-                               INIT_PZVAL(argi);
-                               zend_hash_update(&EG(symbol_table), "argi", 
sizeof("argi"), &argi, sizeof(pval *), NULL);
-                               while (exit_status == SUCCESS && 
(input=php_stream_gets(s_in_process, NULL, 0)) != NULL) {
-                                       len = strlen(input);
-                                       while (len-- && (input[len]=='\n' || 
input[len]=='\r')) {
-                                               input[len] = '\0';
-                                       }
-                                       ALLOC_ZVAL(argn);
-                                       Z_TYPE_P(argn) = IS_STRING;
-                                       Z_STRLEN_P(argn) = ++len;
-                                       Z_STRVAL_P(argn) = estrndup(input, len);
-                                       INIT_PZVAL(argn);
-                                       zend_hash_update(&EG(symbol_table), "argn", 
sizeof("argn"), &argn, sizeof(pval *), NULL);
-                                       Z_LVAL_P(argi) = ++index;
-                                       if (exec_run) {
-                                               if (zend_eval_string(exec_run, NULL, 
"Command line run code" TSRMLS_CC) == FAILURE) {
-                                                       exit_status=254;
-                                               }
-                                       } else {
-                                               if (script_file) {
-                                                       if 
(cli_seek_file_begin(&file_handle, script_file, &lineno TSRMLS_CC) != SUCCESS) {
-                                                               exit_status = 1;
-                                                       } else {
-                                                               CG(zend_lineno) = 
lineno;
-                                                               
php_execute_script(&file_handle TSRMLS_CC);
-                                                               exit_status = 
EG(exit_status);
-                                                       }
-                                               }
-                                       }
-                                       efree(input);
-                               }
-                               if (exec_end && zend_eval_string(exec_end, NULL, 
"Command line end code" TSRMLS_CC) == FAILURE) {
-                                       exit_status=254;
-                               }
-       
-                               break;
-                       }
                }
 
                if (cli_sapi_module.php_ini_path_override) {
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      30 May 2003 23:22:21 -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        30 May 2003 23:22:21 -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   30 May 2003 23:22:21 -0000
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: pi3web_sapi.c,v 1.46.2.4 2003/05/21 09:34:16 zeev Exp $ */
+/* $Id: pi3web_sapi.c,v 1.46.2.3 2003/05/17 08:06:53 sas Exp $ */
 
 #include "pi3web_sapi.h"
 #include "php.h"
@@ -78,7 +78,7 @@
        PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n");
        PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server 
Information</th></tr>\n");
        php_info_print_table_header(2, "Information Field", "Value");
-       php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: 
pi3web_sapi.c,v 1.46.2.4 2003/05/21 09:34:16 zeev Exp $");
+       php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: 
pi3web_sapi.c,v 1.46.2.3 2003/05/17 08:06:53 sas Exp $");
        php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp());
        snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled());
        php_info_print_table_row(2, "Debug Enabled", variable_buf);
@@ -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  30 May 2003 23:22:22 -0000
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: roxen.c,v 1.53.2.4 2003/05/21 09:34:16 zeev Exp $ */
+/* $Id: roxen.c,v 1.53.2.3 2003/05/17 08:06:53 sas Exp $ */
 
 #include "php.h"
 #ifdef HAVE_ROXEN
@@ -438,7 +438,7 @@
 {
   /*  char buf[512]; */
   php_info_print_table_start();
-  php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.53.2.4 
2003/05/21 09:34:16 zeev Exp $");
+  php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.53.2.3 
2003/05/17 08:06:53 sas Exp $");
   /*  php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
       php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
       php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -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      30 May 2003 23:22:22 -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        30 May 2003 23:22:22 -0000
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: thttpd.c,v 1.77.2.11 2003/05/21 09:34:16 zeev Exp $ */
+/* $Id: thttpd.c,v 1.77.2.10 2003/05/17 08:06:53 sas Exp $ */
 
 #include "php.h"
 #include "SAPI.h"
@@ -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  30 May 2003 23:22:23 -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    30 May 2003 23:22:23 -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

Reply via email to