mirror of
https://github.com/php/php-src.git
synced 2025-08-19 17:04:47 +02:00
made lsapi_main.c compatible with PHP7/phpng .
This commit is contained in:
parent
98b22864ff
commit
9fb816f45a
1 changed files with 92 additions and 26 deletions
|
@ -155,7 +155,7 @@ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC)
|
||||||
|
|
||||||
/* {{{ sapi_lsapi_flush
|
/* {{{ sapi_lsapi_flush
|
||||||
*/
|
*/
|
||||||
static void sapi_lsapi_flush( void * server_context )
|
static void sapi_lsapi_flush( void * server_context TSRMLS_DC )
|
||||||
{
|
{
|
||||||
if ( lsapi_mode ) {
|
if ( lsapi_mode ) {
|
||||||
if ( LSAPI_Flush() == -1) {
|
if ( LSAPI_Flush() == -1) {
|
||||||
|
@ -200,7 +200,12 @@ static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC )
|
||||||
static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen,
|
static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen,
|
||||||
void * arg )
|
void * arg )
|
||||||
{
|
{
|
||||||
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
|
int filter_arg = (Z_ARR_P((zval *)arg) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))
|
||||||
|
? PARSE_ENV : PARSE_SERVER;
|
||||||
|
#else
|
||||||
int filter_arg = (arg == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
|
int filter_arg = (arg == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
|
||||||
|
#endif
|
||||||
char * new_val = (char *) pValue;
|
char * new_val = (char *) pValue;
|
||||||
unsigned int new_val_len;
|
unsigned int new_val_len;
|
||||||
|
|
||||||
|
@ -238,6 +243,23 @@ static void litespeed_php_import_environment_variables(zval *array_ptr TSRMLS_DC
|
||||||
size_t alloc_size = sizeof(buf);
|
size_t alloc_size = sizeof(buf);
|
||||||
unsigned long nlen; /* ptrdiff_t is not portable */
|
unsigned long nlen; /* ptrdiff_t is not portable */
|
||||||
|
|
||||||
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
|
if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
|
||||||
|
Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) &&
|
||||||
|
zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0
|
||||||
|
) {
|
||||||
|
zval_dtor(array_ptr);
|
||||||
|
ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]);
|
||||||
|
return;
|
||||||
|
} else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
|
||||||
|
Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) &&
|
||||||
|
zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0
|
||||||
|
) {
|
||||||
|
zval_dtor(array_ptr);
|
||||||
|
ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (PG(http_globals)[TRACK_VARS_ENV] &&
|
if (PG(http_globals)[TRACK_VARS_ENV] &&
|
||||||
array_ptr != PG(http_globals)[TRACK_VARS_ENV] &&
|
array_ptr != PG(http_globals)[TRACK_VARS_ENV] &&
|
||||||
Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
|
Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
|
||||||
|
@ -259,6 +281,7 @@ static void litespeed_php_import_environment_variables(zval *array_ptr TSRMLS_DC
|
||||||
zval_copy_ctor(array_ptr);
|
zval_copy_ctor(array_ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (env = environ; env != NULL && *env != NULL; env++) {
|
for (env = environ; env != NULL && *env != NULL; env++) {
|
||||||
p = strchr(*env, '=');
|
p = strchr(*env, '=');
|
||||||
|
@ -592,6 +615,9 @@ static int lsapi_module_main(int show_source TSRMLS_DC)
|
||||||
static int alter_ini( const char * pKey, int keyLen, const char * pValue, int valLen,
|
static int alter_ini( const char * pKey, int keyLen, const char * pValue, int valLen,
|
||||||
void * arg )
|
void * arg )
|
||||||
{
|
{
|
||||||
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
|
zend_string * psKey;
|
||||||
|
#endif
|
||||||
int type = ZEND_INI_PERDIR;
|
int type = ZEND_INI_PERDIR;
|
||||||
if ( '\001' == *pKey ) {
|
if ( '\001' == *pKey ) {
|
||||||
++pKey;
|
++pKey;
|
||||||
|
@ -606,9 +632,19 @@ static int alter_ini( const char * pKey, int keyLen, const char * pValue, int va
|
||||||
engine = 0;
|
engine = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
|
psKey = STR_INIT( pKey, keyLen, 1 );
|
||||||
|
zend_alter_ini_entry(psKey,
|
||||||
|
(char *)pValue, valLen,
|
||||||
|
type, PHP_INI_STAGE_ACTIVATE);
|
||||||
|
STR_RELEASE( psKey );
|
||||||
|
#else
|
||||||
zend_alter_ini_entry((char *)pKey, keyLen,
|
zend_alter_ini_entry((char *)pKey, keyLen,
|
||||||
(char *)pValue, valLen,
|
(char *)pValue, valLen,
|
||||||
type, PHP_INI_STAGE_ACTIVATE);
|
type, PHP_INI_STAGE_ACTIVATE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -749,6 +785,9 @@ static int cli_main( int argc, char * argv[] )
|
||||||
char ** argend= &argv[argc];
|
char ** argend= &argv[argc];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int c;
|
int c;
|
||||||
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
|
zend_string * psKey;
|
||||||
|
#endif
|
||||||
lsapi_mode = 0; /* enter CLI mode */
|
lsapi_mode = 0; /* enter CLI mode */
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
|
@ -763,12 +802,21 @@ static int cli_main( int argc, char * argv[] )
|
||||||
|
|
||||||
zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
|
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 */
|
CG(in_compilation) = 0; /* not initialized but needed for several options */
|
||||||
|
#if PHP_MAJOR_VERSION < 7
|
||||||
EG(uninitialized_zval_ptr) = NULL;
|
EG(uninitialized_zval_ptr) = NULL;
|
||||||
|
#endif
|
||||||
for( ini = ini_defaults; *ini; ini+=2 ) {
|
for( ini = ini_defaults; *ini; ini+=2 ) {
|
||||||
|
#if PHP_MAJOR_VERSION >= 7
|
||||||
|
psKey = STR_INIT( *ini, strlen( *ini ), 1 );
|
||||||
|
zend_alter_ini_entry( psKey,
|
||||||
|
(char *)*(ini+1), strlen( *(ini+1) ),
|
||||||
|
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
|
||||||
|
STR_RELEASE( psKey );
|
||||||
|
#else
|
||||||
zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1,
|
zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1,
|
||||||
(char *)*(ini+1), strlen( *(ini+1) ),
|
(char *)*(ini+1), strlen( *(ini+1) ),
|
||||||
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
|
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
while (( p < argend )&&(**p == '-' )) {
|
while (( p < argend )&&(**p == '-' )) {
|
||||||
|
@ -1148,7 +1196,11 @@ zend_module_entry litespeed_module_entry = {
|
||||||
static int add_associate_array( const char * pKey, int keyLen, const char * pValue, int valLen,
|
static int add_associate_array( const char * pKey, int keyLen, const char * pValue, int valLen,
|
||||||
void * arg )
|
void * arg )
|
||||||
{
|
{
|
||||||
add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 );
|
add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue
|
||||||
|
#if PHP_MAJOR_VERSION < 7
|
||||||
|
, 1
|
||||||
|
#endif
|
||||||
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,7 +1254,11 @@ PHP_FUNCTION(litespeed_response_headers)
|
||||||
headerBuf[len] = 0;
|
headerBuf[len] = 0;
|
||||||
if ( len ) {
|
if ( len ) {
|
||||||
while( isspace(*++p));
|
while( isspace(*++p));
|
||||||
add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 );
|
add_assoc_string_ex(return_value, headerBuf, len+1, p
|
||||||
|
#if PHP_MAJOR_VERSION < 7
|
||||||
|
, 1
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1217,15 +1273,25 @@ PHP_FUNCTION(litespeed_response_headers)
|
||||||
Fetch all loaded module names */
|
Fetch all loaded module names */
|
||||||
PHP_FUNCTION(apache_get_modules)
|
PHP_FUNCTION(apache_get_modules)
|
||||||
{
|
{
|
||||||
|
static const char * mod_names[] =
|
||||||
|
{
|
||||||
|
"mod_rewrite", "mod_mime", "mod_headers", "mod_expires", NULL
|
||||||
|
};
|
||||||
|
const char **name = mod_names;
|
||||||
/* TODO: */
|
/* TODO: */
|
||||||
if (ZEND_NUM_ARGS() > 0) {
|
if (ZEND_NUM_ARGS() > 0) {
|
||||||
WRONG_PARAM_COUNT;
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
add_next_index_string(return_value, "mod_rewrite", 1);
|
while( *name )
|
||||||
add_next_index_string(return_value, "mod_mime", 1);
|
{
|
||||||
add_next_index_string(return_value, "mod_headers", 1);
|
add_next_index_string(return_value, *name
|
||||||
add_next_index_string(return_value, "mod_expires", 1);
|
#if PHP_MAJOR_VERSION < 7
|
||||||
|
, 1
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
++name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue