/* {{{ MINIT */ static PHP_MINIT_FUNCTION(jsond) { if (!php_json_already_exists()) { /* register jsond function */ if (zend_register_functions(NULL, jsond_functions, NULL, 0 TSRMLS_CC) == FAILURE) { zend_error(E_CORE_WARNING,"jsond: Unable to register functions"); return FAILURE; } #if PHP_VERSION_ID > 50399 php_json_register_serializable_interface(TSRMLS_C); #endif } #if PHP_VERSION_ID < 50500 else if (zend_register_functions(NULL, jsond_54_functions, NULL, 0 TSRMLS_CC) == FAILURE) { zend_error(E_CORE_WARNING,"jsond: Unable to register functions"); return FAILURE; } #endif #if PHP_VERSION_ID < 50400 php_json_register_serializable_interface(TSRMLS_C); #endif /* decoding options */ PHP_JSOND_REGISTER_LONG_CONSTANT("OBJECT_AS_ARRAY", PHP_JSON_OBJECT_AS_ARRAY); PHP_JSOND_REGISTER_LONG_CONSTANT("BIGINT_AS_STRING", PHP_JSON_BIGINT_AS_STRING); /* encoding options */ PHP_JSOND_REGISTER_LONG_CONSTANT("HEX_TAG", PHP_JSON_HEX_TAG); PHP_JSOND_REGISTER_LONG_CONSTANT("HEX_AMP", PHP_JSON_HEX_AMP); PHP_JSOND_REGISTER_LONG_CONSTANT("HEX_APOS", PHP_JSON_HEX_APOS); PHP_JSOND_REGISTER_LONG_CONSTANT("HEX_QUOT", PHP_JSON_HEX_QUOT); PHP_JSOND_REGISTER_LONG_CONSTANT("FORCE_OBJECT", PHP_JSON_FORCE_OBJECT); PHP_JSOND_REGISTER_LONG_CONSTANT("NUMERIC_CHECK", PHP_JSON_NUMERIC_CHECK); PHP_JSOND_REGISTER_LONG_CONSTANT("UNESCAPED_SLASHES", PHP_JSON_UNESCAPED_SLASHES); PHP_JSOND_REGISTER_LONG_CONSTANT("PRETTY_PRINT", PHP_JSON_PRETTY_PRINT); PHP_JSOND_REGISTER_LONG_CONSTANT("UNESCAPED_UNICODE", PHP_JSON_UNESCAPED_UNICODE); PHP_JSOND_REGISTER_LONG_CONSTANT("PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR); PHP_JSOND_REGISTER_LONG_CONSTANT("PRESERVE_ZERO_FRACTION", PHP_JSON_PRESERVE_ZERO_FRACTION); /* error constants */ PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_NONE", PHP_JSON_ERROR_NONE); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_DEPTH", PHP_JSON_ERROR_DEPTH); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_STATE_MISMATCH", PHP_JSON_ERROR_STATE_MISMATCH); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_CTRL_CHAR", PHP_JSON_ERROR_CTRL_CHAR); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_SYNTAX", PHP_JSON_ERROR_SYNTAX); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_UTF8", PHP_JSON_ERROR_UTF8); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_RECURSION", PHP_JSON_ERROR_RECURSION); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_INF_OR_NAN", PHP_JSON_ERROR_INF_OR_NAN); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_UNSUPPORTED_TYPE", PHP_JSON_ERROR_UNSUPPORTED_TYPE); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_INVALID_PROPERTY_NAME", PHP_JSON_ERROR_INVALID_PROPERTY_NAME); PHP_JSOND_REGISTER_LONG_CONSTANT("ERROR_UTF16", PHP_JSON_ERROR_UTF16); return SUCCESS; }
static int register_new_func(char *func_name, uint nKeyLength, zend_function *func) { char *n_func_name; int len = append_prefix_len + nKeyLength + 1; php_printf("%d\n", len); n_func_name = emalloc(len); memset(n_func_name, 0, len); memcpy(n_func_name, append_prefix, append_prefix_len); memcpy(n_func_name + append_prefix_len, func_name, nKeyLength); zend_function_entry override_functions[] = { { n_func_name, func->internal_function.handler, NULL, 0, 0}, PHP_FE_END /* Must be the last line in override_echo_functions[] */ }; if (zend_register_functions(NULL, override_functions, EG(function_table), MODULE_PERSISTENT TSRMLS_CC) == SUCCESS) { return SUCCESS; } return FAILURE; }
/* {{{ goemphp php_startup(ini) */ void php_startup() { php_embed_init(0, NULL PTSRMLS_CC); if (zend_register_functions(NULL, go_functions, CG(function_table), MODULE_PERSISTENT TSRMLS_CC) == FAILURE) { } }