+ZEND_BEGIN_ARG_INFO_EX(ai_psi_dump, 0, 0, 0)
+ ZEND_ARG_INFO(0, stream)
+ZEND_END_ARG_INFO();
+static PHP_FUNCTION(psi_dump) {
+ php_stream *s;
+ zval *r = NULL;
+ int fd = STDOUT_FILENO;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "|r!", &r)) {
+ return;
+ }
+ if (r) {
+ php_stream_from_zval(s, r);
+
+ if (SUCCESS != php_stream_cast(s, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL, (void **)&fd, 1)) {
+ RETURN_FALSE;
+ }
+ }
+ PSI_ContextDump(&PSI_G(context), fd);
+}
+
+ZEND_BEGIN_ARG_INFO_EX(ai_psi_validate, 0, 0, 1)
+ ZEND_ARG_INFO(0, file)
+ZEND_END_ARG_INFO();
+static PHP_FUNCTION(psi_validate) {
+ zend_string *file;
+ PSI_Parser P;
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "P", &file)) {
+ return;
+ }
+
+ if (!PSI_ParserInit(&P, file->val, psi_error_wrapper, 0)) {
+ RETURN_FALSE;
+ }
+
+ while (0 < PSI_ParserScan(&P)) {
+ PSI_ParserParse(&P, PSI_TokenAlloc(&P));
+ if (P.num == PSI_T_EOF) {
+ break;
+ }
+ }
+ PSI_ParserParse(&P, NULL);
+
+ if (0 == PSI_ContextValidateData(NULL, PSI_DATA(&P)) && !P.errors) {
+ RETVAL_TRUE;
+ } else {
+ RETVAL_FALSE;
+ }
+ PSI_ParserDtor(&P);
+}
+
+static PHP_MINIT_FUNCTION(psi)