mirror of https://github.com/deuill/go-php.git
Clean up C pre-processor mess
Currently, large parts of the C source use pre-processor tricks for maintaining compatibility between versions 5 and 7 of PHP. This contains work for cleaning the dependencies up by introducing an extra level of C source, tailored to each supported version of PHP.
This commit is contained in:
parent
a6fe19a1be
commit
4688362c1b
|
@ -26,11 +26,7 @@ const char engine_ini_defaults[] = {
|
|||
"max_input_time = -1\n\0"
|
||||
};
|
||||
|
||||
// Unbuffered write to engine context.
|
||||
//
|
||||
// The function definition for this depends on the PHP version used, and is
|
||||
// defined in the "_engine.h" file for the respective PHP version used.
|
||||
static ENGINE_UB_WRITE(str, len) {
|
||||
static int engine_ub_write(const char *str, uint len) {
|
||||
engine_context *context = SG(server_context);
|
||||
|
||||
int written = engineWriteOut(context, (void *) str, len);
|
||||
|
@ -83,7 +79,7 @@ static sapi_module_struct engine_module = {
|
|||
NULL, // Activate
|
||||
NULL, // Deactivate
|
||||
|
||||
engine_ub_write, // Unbuffered Write
|
||||
engine_ub_write_proxy, // Unbuffered Write
|
||||
NULL, // Flush
|
||||
NULL, // Get UID
|
||||
NULL, // Getenv
|
||||
|
@ -139,3 +135,5 @@ void engine_shutdown(php_engine *engine) {
|
|||
free(engine_module.ini_entries);
|
||||
free(engine);
|
||||
}
|
||||
|
||||
#include "_engine.c"
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
#ifndef ___ENGINE_H___
|
||||
#define ___ENGINE_H___
|
||||
|
||||
#define ENGINE_UB_WRITE(s, l) int engine_ub_write(const char *s, uint l)
|
||||
static int engine_ub_write_proxy(const char *str, uint len);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
#ifndef ___ENGINE_H___
|
||||
#define ___ENGINE_H___
|
||||
|
||||
#define ENGINE_UB_WRITE(s, l) size_t engine_ub_write(const char *s, size_t l)
|
||||
static size_t engine_ub_write_proxy(const char *str, size_t len);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
package engine
|
||||
|
||||
// #cgo CFLAGS: -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM
|
||||
// #cgo CFLAGS: -I/usr/include/php5/Zend -Iinclude/php5
|
||||
// #cgo CFLAGS: -I/usr/include/php5/Zend -Iinclude/php5 -Isrc/php5
|
||||
// #cgo LDFLAGS: -lphp5
|
||||
import "C"
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
package engine
|
||||
|
||||
// #cgo CFLAGS: -Iinclude/php7
|
||||
// #cgo CFLAGS: -Iinclude/php7 -Isrc/php7
|
||||
// #cgo LDFLAGS: -lphp7
|
||||
import "C"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright 2016 Alexander Palaistras. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
|
||||
static int engine_ub_write_proxy(const char *str, uint len) {
|
||||
return engine_ub_write(str, len);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright 2016 Alexander Palaistras. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
|
||||
static size_t engine_ub_write_proxy(const char *str, size_t len) {
|
||||
return engine_ub_write(str, len);
|
||||
}
|
Loading…
Reference in New Issue