+HashTable psi_cpp_defaults;
+
+PHP_MINIT_FUNCTION(psi_cpp)
+{
+ struct psi_parser parser;
+ struct psi_parser_input *predef;
+
+ PSI_G(search_path) = pemalloc(strlen(PSI_G(directory)) + strlen(psi_cpp_search) + 1 + 1, 1);
+ sprintf(PSI_G(search_path), "%s:%s", PSI_G(directory), psi_cpp_search);
+
+ if (!psi_parser_init(&parser, psi_error_wrapper, PSI_SILENT)) {
+ return FAILURE;
+ }
+
+ if (!(predef = psi_parser_open_string(&parser, psi_cpp_predef, sizeof(psi_cpp_predef) - 1))) {
+ psi_parser_dtor(&parser);
+ return FAILURE;
+ }
+
+ if (!psi_parser_parse(&parser, predef)) {
+ psi_parser_input_free(&predef);
+ psi_parser_dtor(&parser);
+ return FAILURE;
+ }
+ psi_parser_input_free(&predef);
+
+ zend_hash_init(&psi_cpp_defaults, 0, NULL, NULL, 1);
+ zend_hash_copy(&psi_cpp_defaults, &parser.preproc->defs, NULL);
+
+ psi_parser_dtor(&parser);
+
+ return SUCCESS;
+}
+
+PHP_MSHUTDOWN_FUNCTION(psi_cpp)
+{
+ struct psi_cpp_macro_decl *macro;
+
+ ZEND_HASH_FOREACH_PTR(&psi_cpp_defaults, macro)
+ {
+ psi_cpp_macro_decl_free(¯o);
+ }
+ ZEND_HASH_FOREACH_END();
+
+ zend_hash_destroy(&psi_cpp_defaults);
+
+ return SUCCESS;
+}
+