@@ -155,7 +155,7 @@ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC)
155
155
156
156
/* {{{ sapi_lsapi_flush
157
157
*/
158
- static void sapi_lsapi_flush ( void * server_context )
158
+ static void sapi_lsapi_flush ( void * server_context TSRMLS_DC )
159
159
{
160
160
if ( lsapi_mode ) {
161
161
if ( LSAPI_Flush () == -1 ) {
@@ -200,7 +200,12 @@ static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC )
200
200
static int add_variable ( const char * pKey , int keyLen , const char * pValue , int valLen ,
201
201
void * arg )
202
202
{
203
- int filter_arg = (arg == PG (http_globals )[TRACK_VARS_ENV ])?PARSE_ENV :PARSE_SERVER ;
203
+ #if PHP_MAJOR_VERSION >= 7
204
+ int filter_arg = (Z_ARR_P ((zval * )arg ) == Z_ARR (PG (http_globals )[TRACK_VARS_ENV ]))
205
+ ? PARSE_ENV : PARSE_SERVER ;
206
+ #else
207
+ int filter_arg = (arg == PG (http_globals )[TRACK_VARS_ENV ])?PARSE_ENV :PARSE_SERVER ;
208
+ #endif
204
209
char * new_val = (char * ) pValue ;
205
210
unsigned int new_val_len ;
206
211
@@ -238,27 +243,45 @@ static void litespeed_php_import_environment_variables(zval *array_ptr TSRMLS_DC
238
243
size_t alloc_size = sizeof (buf );
239
244
unsigned long nlen ; /* ptrdiff_t is not portable */
240
245
241
- if ( PG ( http_globals )[ TRACK_VARS_ENV ] &&
242
- array_ptr != PG (http_globals )[TRACK_VARS_ENV ] &&
243
- Z_TYPE_P ( PG (http_globals )[TRACK_VARS_ENV ]) == IS_ARRAY &&
244
- zend_hash_num_elements (Z_ARRVAL_P (PG (http_globals )[TRACK_VARS_ENV ])) > 0
246
+ # if PHP_MAJOR_VERSION >= 7
247
+ if ( Z_TYPE ( PG (http_globals )[TRACK_VARS_ENV ]) == IS_ARRAY &&
248
+ Z_ARR_P ( array_ptr ) != Z_ARR ( PG (http_globals )[TRACK_VARS_ENV ]) &&
249
+ zend_hash_num_elements (Z_ARRVAL (PG (http_globals )[TRACK_VARS_ENV ])) > 0
245
250
) {
246
- zval_dtor (array_ptr );
247
- * array_ptr = * PG (http_globals )[TRACK_VARS_ENV ];
248
- INIT_PZVAL (array_ptr );
249
- zval_copy_ctor (array_ptr );
251
+ zval_dtor (array_ptr );
252
+ ZVAL_DUP (array_ptr , & PG (http_globals )[TRACK_VARS_ENV ]);
250
253
return ;
251
- } else if (PG (http_globals )[TRACK_VARS_SERVER ] &&
252
- array_ptr != PG (http_globals )[TRACK_VARS_SERVER ] &&
253
- Z_TYPE_P (PG (http_globals )[TRACK_VARS_SERVER ]) == IS_ARRAY &&
254
- zend_hash_num_elements (Z_ARRVAL_P (PG (http_globals )[TRACK_VARS_SERVER ])) > 0
254
+ } else if (Z_TYPE (PG (http_globals )[TRACK_VARS_SERVER ]) == IS_ARRAY &&
255
+ Z_ARR_P (array_ptr ) != Z_ARR (PG (http_globals )[TRACK_VARS_SERVER ]) &&
256
+ zend_hash_num_elements (Z_ARRVAL (PG (http_globals )[TRACK_VARS_SERVER ])) > 0
255
257
) {
256
- zval_dtor (array_ptr );
257
- * array_ptr = * PG (http_globals )[TRACK_VARS_SERVER ];
258
- INIT_PZVAL (array_ptr );
259
- zval_copy_ctor (array_ptr );
258
+ zval_dtor (array_ptr );
259
+ ZVAL_DUP (array_ptr , & PG (http_globals )[TRACK_VARS_SERVER ]);
260
260
return ;
261
261
}
262
+ #else
263
+ if (PG (http_globals )[TRACK_VARS_ENV ] &&
264
+ array_ptr != PG (http_globals )[TRACK_VARS_ENV ] &&
265
+ Z_TYPE_P (PG (http_globals )[TRACK_VARS_ENV ]) == IS_ARRAY &&
266
+ zend_hash_num_elements (Z_ARRVAL_P (PG (http_globals )[TRACK_VARS_ENV ])) > 0
267
+ ) {
268
+ zval_dtor (array_ptr );
269
+ * array_ptr = * PG (http_globals )[TRACK_VARS_ENV ];
270
+ INIT_PZVAL (array_ptr );
271
+ zval_copy_ctor (array_ptr );
272
+ return ;
273
+ } else if (PG (http_globals )[TRACK_VARS_SERVER ] &&
274
+ array_ptr != PG (http_globals )[TRACK_VARS_SERVER ] &&
275
+ Z_TYPE_P (PG (http_globals )[TRACK_VARS_SERVER ]) == IS_ARRAY &&
276
+ zend_hash_num_elements (Z_ARRVAL_P (PG (http_globals )[TRACK_VARS_SERVER ])) > 0
277
+ ) {
278
+ zval_dtor (array_ptr );
279
+ * array_ptr = * PG (http_globals )[TRACK_VARS_SERVER ];
280
+ INIT_PZVAL (array_ptr );
281
+ zval_copy_ctor (array_ptr );
282
+ return ;
283
+ }
284
+ #endif
262
285
263
286
for (env = environ ; env != NULL && * env != NULL ; env ++ ) {
264
287
p = strchr (* env , '=' );
@@ -592,6 +615,9 @@ static int lsapi_module_main(int show_source TSRMLS_DC)
592
615
static int alter_ini ( const char * pKey , int keyLen , const char * pValue , int valLen ,
593
616
void * arg )
594
617
{
618
+ #if PHP_MAJOR_VERSION >= 7
619
+ zend_string * psKey ;
620
+ #endif
595
621
int type = ZEND_INI_PERDIR ;
596
622
if ( '\001' == * pKey ) {
597
623
++ pKey ;
@@ -606,9 +632,19 @@ static int alter_ini( const char * pKey, int keyLen, const char * pValue, int va
606
632
engine = 0 ;
607
633
}
608
634
else
609
- zend_alter_ini_entry ((char * )pKey , keyLen ,
635
+ {
636
+ #if PHP_MAJOR_VERSION >= 7
637
+ psKey = STR_INIT ( pKey , keyLen , 1 );
638
+ zend_alter_ini_entry (psKey ,
610
639
(char * )pValue , valLen ,
611
640
type , PHP_INI_STAGE_ACTIVATE );
641
+ STR_RELEASE ( psKey );
642
+ #else
643
+ zend_alter_ini_entry ((char * )pKey , keyLen ,
644
+ (char * )pValue , valLen ,
645
+ type , PHP_INI_STAGE_ACTIVATE );
646
+ #endif
647
+ }
612
648
}
613
649
return 1 ;
614
650
}
@@ -749,6 +785,9 @@ static int cli_main( int argc, char * argv[] )
749
785
char * * argend = & argv [argc ];
750
786
int ret = -1 ;
751
787
int c ;
788
+ #if PHP_MAJOR_VERSION >= 7
789
+ zend_string * psKey ;
790
+ #endif
752
791
lsapi_mode = 0 ; /* enter CLI mode */
753
792
754
793
#ifdef PHP_WIN32
@@ -763,12 +802,21 @@ static int cli_main( int argc, char * argv[] )
763
802
764
803
zend_uv .html_errors = 0 ; /* tell the engine we're in non-html mode */
765
804
CG (in_compilation ) = 0 ; /* not initialized but needed for several options */
805
+ #if PHP_MAJOR_VERSION < 7
766
806
EG (uninitialized_zval_ptr ) = NULL ;
767
-
807
+ #endif
768
808
for ( ini = ini_defaults ; * ini ; ini += 2 ) {
809
+ #if PHP_MAJOR_VERSION >= 7
810
+ psKey = STR_INIT ( * ini , strlen ( * ini ), 1 );
811
+ zend_alter_ini_entry ( psKey ,
812
+ (char * )* (ini + 1 ), strlen ( * (ini + 1 ) ),
813
+ PHP_INI_SYSTEM , PHP_INI_STAGE_ACTIVATE );
814
+ STR_RELEASE ( psKey );
815
+ #else
769
816
zend_alter_ini_entry ( (char * )* ini , strlen ( * ini )+ 1 ,
770
817
(char * )* (ini + 1 ), strlen ( * (ini + 1 ) ),
771
818
PHP_INI_SYSTEM , PHP_INI_STAGE_ACTIVATE );
819
+ #endif
772
820
}
773
821
774
822
while (( p < argend )&& (* * p == '-' )) {
@@ -1148,7 +1196,11 @@ zend_module_entry litespeed_module_entry = {
1148
1196
static int add_associate_array ( const char * pKey , int keyLen , const char * pValue , int valLen ,
1149
1197
void * arg )
1150
1198
{
1151
- add_assoc_string_ex ( (zval * )arg , (char * )pKey , keyLen + 1 , (char * )pValue , 1 );
1199
+ add_assoc_string_ex ( (zval * )arg , (char * )pKey , keyLen + 1 , (char * )pValue
1200
+ #if PHP_MAJOR_VERSION < 7
1201
+ , 1
1202
+ #endif
1203
+ );
1152
1204
return 1 ;
1153
1205
}
1154
1206
@@ -1202,7 +1254,11 @@ PHP_FUNCTION(litespeed_response_headers)
1202
1254
headerBuf [len ] = 0 ;
1203
1255
if ( len ) {
1204
1256
while ( isspace (* ++ p ));
1205
- add_assoc_string_ex (return_value , headerBuf , len + 1 , p , 1 );
1257
+ add_assoc_string_ex (return_value , headerBuf , len + 1 , p
1258
+ #if PHP_MAJOR_VERSION < 7
1259
+ , 1
1260
+ #endif
1261
+ );
1206
1262
}
1207
1263
}
1208
1264
}
@@ -1217,15 +1273,25 @@ PHP_FUNCTION(litespeed_response_headers)
1217
1273
Fetch all loaded module names */
1218
1274
PHP_FUNCTION (apache_get_modules )
1219
1275
{
1276
+ static const char * mod_names [] =
1277
+ {
1278
+ "mod_rewrite" , "mod_mime" , "mod_headers" , "mod_expires" , NULL
1279
+ };
1280
+ const char * * name = mod_names ;
1220
1281
/* TODO: */
1221
1282
if (ZEND_NUM_ARGS () > 0 ) {
1222
1283
WRONG_PARAM_COUNT ;
1223
1284
}
1224
1285
array_init (return_value );
1225
- add_next_index_string (return_value , "mod_rewrite" , 1 );
1226
- add_next_index_string (return_value , "mod_mime" , 1 );
1227
- add_next_index_string (return_value , "mod_headers" , 1 );
1228
- add_next_index_string (return_value , "mod_expires" , 1 );
1286
+ while ( * name )
1287
+ {
1288
+ add_next_index_string (return_value , * name
1289
+ #if PHP_MAJOR_VERSION < 7
1290
+ , 1
1291
+ #endif
1292
+ );
1293
+ ++ name ;
1294
+ }
1229
1295
}
1230
1296
/* }}} */
1231
1297
0 commit comments