16 changed files with 274 additions and 99 deletions
-
2Zend/Makefile.am
-
42Zend/flex.skl
-
2Zend/zend.c
-
3Zend/zend.h
-
13Zend/zend_compile.h
-
20Zend/zend_execute.c
-
4Zend/zend_globals.h
-
22Zend/zend_ini_scanner.l
-
2Zend/zend_language_scanner.h
-
33Zend/zend_language_scanner.l
-
123Zend/zend_stream.c
-
59Zend/zend_stream.h
-
2configure.in
-
17ext/standard/basic_functions.c
-
27main/main.c
-
2main/php_ini.c
@ -0,0 +1,123 @@ |
|||
/* |
|||
+----------------------------------------------------------------------+ |
|||
| 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 | |
|||
| license@zend.com so we can mail you a copy immediately. | |
|||
+----------------------------------------------------------------------+ |
|||
| Authors: Wez Furlong <wez@thebrainroom.com> | |
|||
+----------------------------------------------------------------------+ |
|||
*/ |
|||
|
|||
/* $Id$ */ |
|||
|
|||
|
|||
#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; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,59 @@ |
|||
/* |
|||
+----------------------------------------------------------------------+ |
|||
| 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 | |
|||
| license@zend.com so we can mail you a copy immediately. | |
|||
+----------------------------------------------------------------------+ |
|||
| Authors: Wez Furlong <wez@thebrainroom.com> | |
|||
+----------------------------------------------------------------------+ |
|||
*/ |
|||
|
|||
/* $Id$ */ |
|||
|
|||
#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 |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue