+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &string, &flags, &errcnt)) {
+ return;
+ }
+
+ if (!psi_parser_init(&P, psi_error_wrapper, flags)) {
+ RETURN_FALSE;
+ }
+ if (!(I = psi_parser_open_string(&P, string->val, string->len))) {
+ psi_parser_dtor(&P);
+ RETURN_FALSE;
+ }
+
+ psi_parser_parse(&P, I);
+ psi_data_ctor(&D, P.error, P.flags);
+ psi_validate_scope_ctor(&S);
+ S.cpp = P.preproc;
+
+ RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)));
+
+ if (errcnt) {
+ ZVAL_DEREF(errcnt);
+ convert_to_long(errcnt);
+ ZVAL_LONG(errcnt, P.errors);
+ }
+
+ psi_validate_scope_dtor(&S);
+ psi_data_dtor(&D);
+ psi_parser_dtor(&P);
+ psi_parser_input_free(&I);
+}
+
+PHP_MINIT_FUNCTION(psi_debug);
+PHP_MINIT_FUNCTION(psi_cpp);
+PHP_MINIT_FUNCTION(psi_builtin);
+PHP_MINIT_FUNCTION(psi_context);
+static PHP_MINIT_FUNCTION(psi)
+{
+ zend_class_entry ce = {0};
+
+ REGISTER_INI_ENTRIES();
+
+ zend_register_long_constant(ZEND_STRL("PSI_DEBUG"), PSI_DEBUG, CONST_CS|CONST_PERSISTENT, module_number);
+ zend_register_long_constant(ZEND_STRL("PSI_SILENT"), PSI_SILENT, CONST_CS|CONST_PERSISTENT, module_number);
+
+ INIT_NS_CLASS_ENTRY(ce, "psi", "object", NULL);
+ psi_class_entry = zend_register_internal_class_ex(&ce, NULL);
+ psi_class_entry->create_object = psi_object_init;
+
+ memcpy(&psi_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ psi_object_handlers.offset = XtOffsetOf(psi_object, std);
+ psi_object_handlers.free_obj = psi_object_free;
+ psi_object_handlers.clone_obj = NULL;
+
+ if (SUCCESS != PHP_MINIT(psi_debug)(type, module_number)) {
+ return FAILURE;
+ }
+ if (SUCCESS != PHP_MINIT(psi_builtin)(type, module_number)) {
+ return FAILURE;
+ }
+ if (SUCCESS != PHP_MINIT(psi_cpp)(type, module_number)) {
+ return FAILURE;
+ }
+ if (SUCCESS != PHP_MINIT(psi_context)(type, module_number)) {
+ return FAILURE;
+ }
+