|
/* rinit_error extension for PHP */ |
|
|
|
#ifdef HAVE_CONFIG_H |
|
# include "config.h" |
|
#endif |
|
|
|
#include "php.h" |
|
#include "php_rinit_error.h" |
|
#include <main/SAPI.h> |
|
|
|
/* {{{ PHP_RINIT_FUNCTION |
|
*/ |
|
PHP_RINIT_FUNCTION(rinit_error) |
|
{ |
|
#if defined(ZTS) && defined(COMPILE_DL_RINIT_ERROR) |
|
ZEND_TSRMLS_CACHE_UPDATE(); |
|
#endif |
|
|
|
#define CT_HEADER "Content-type: text/plain" |
|
sapi_header_line line = { .line = CT_HEADER, .line_len = strlen(CT_HEADER) }; |
|
(void) sapi_header_op(SAPI_HEADER_REPLACE, &line TSRMLS_CC); |
|
|
|
SG(sapi_headers).http_response_code = 200; |
|
|
|
#define BODY "OK\r\n" |
|
(void) php_output_write(BODY, strlen(BODY) TSRMLS_CC); |
|
|
|
zend_error_noreturn(E_ERROR, "Failing RINIT"); |
|
return SUCCESS; |
|
} |
|
/* }}} */ |
|
|
|
/* {{{ rinit_error_functions[] |
|
*/ |
|
static const zend_function_entry rinit_error_functions[] = { |
|
PHP_FE_END |
|
}; |
|
/* }}} */ |
|
|
|
/* {{{ rinit_error_module_entry |
|
*/ |
|
zend_module_entry rinit_error_module_entry = { |
|
STANDARD_MODULE_HEADER, |
|
"rinit_error", /* Extension name */ |
|
rinit_error_functions, /* zend_function_entry */ |
|
NULL, /* PHP_MINIT - Module initialization */ |
|
NULL, /* PHP_MSHUTDOWN - Module shutdown */ |
|
PHP_RINIT(rinit_error), /* PHP_RINIT - Request initialization */ |
|
NULL, /* PHP_RSHUTDOWN - Request shutdown */ |
|
NULL, /* PHP_MINFO - Module info */ |
|
PHP_RINIT_ERROR_VERSION, /* Version */ |
|
STANDARD_MODULE_PROPERTIES |
|
}; |
|
/* }}} */ |
|
|
|
#ifdef COMPILE_DL_RINIT_ERROR |
|
# ifdef ZTS |
|
ZEND_TSRMLS_CACHE_DEFINE() |
|
# endif |
|
ZEND_GET_MODULE(rinit_error) |
|
#endif |
|
|