fi
if test "$PHP_XSLT_SABLOT" != "no"; then
+ AC_MSG_CHECKING([for sablot-config])
+ if test -x $XSLT_DIR/bin/sablot-config ; then
+ AC_MSG_RESULT(found)
+ AC_DEFINE(HAVE_SABLOT_CONFIG, 1, [Whether the Sablotron config file is found])
+ dnl Use this script to register this information in phpinfo()
+ SABINF_CFLAGS=`$XSLT_DIR/bin/sablot-config --cflags`
+ SABINF_LIBS=`$XSLT_DIR/bin/sablot-config --libs`
+ SABINF_PREFIX=`$XSLT_DIR/bin/sablot-config --prefix`
+ SABINF_ALL="\"Cflags: $SABINF_CFLAGS\nLibs: $SABINF_LIBS\nPrefix: $SABINF_PREFIX\""
+ PHP_DEFINE(SAB_INFO, "$SABINF_ALL")
+ else
+ AC_MSG_RESULT(not found)
+ fi
AC_MSG_CHECKING([for Sablotron version])
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$XSLT_DIR/include"
#define XSLT_FUNCH_FREE(__var) if (__var) zval_ptr_dtor(&(__var));
#define XSLT_REG_ERRMSG(msg, handle) if (XSLT_ERRSTR(handle)) efree(XSLT_ERRSTR(handle)); \
XSLT_ERRSTR(handle) = estrdup(msg);
+#define XSLT_NO_INFO "No information available."
PHP_MINIT_FUNCTION(xslt);
PHP_MINFO_FUNCTION(xslt);
#endif
PHP_FUNCTION(xslt_backend_version);
PHP_FUNCTION(xslt_backend_name);
-
+PHP_FUNCTION(xslt_backend_info);
struct scheme_handlers {
zval *sh_get_all;
#if HAVE_SABLOT_BACKEND
+#ifdef HAVE_SABLOT_CONFIG
+#include "php_sab_info.h"
+#endif
#include <sablot.h>
#include <string.h>
#endif
PHP_FE(xslt_backend_version, NULL)
PHP_FE(xslt_backend_name, NULL)
+ PHP_FE(xslt_backend_info, NULL)
{NULL, NULL, NULL}
};
/* }}} */
php_info_print_table_row(2, "Backend", "Sablotron");
#ifdef SAB_VERSION
php_info_print_table_row(2, "Sablotron Version", SAB_VERSION);
+#endif
+#ifdef HAVE_SABLOT_CONFIG
+ php_info_print_table_row(2, "Sablotron Information", SAB_INFO);
#endif
php_info_print_table_end();
}
/* }}} */
#endif
-/* {{{ proto void xslt_backend_version()
+/* {{{ proto string xslt_backend_version()
Returns the version number of Sablotron (if available) */
PHP_FUNCTION(xslt_backend_version)
{
}
/* }}} */
-/* {{{ proto void xslt_backend_name()
+/* {{{ proto string xslt_backend_name()
Returns the name of the Backend (here "Sablotron")*/
PHP_FUNCTION(xslt_backend_name)
{
}
/* }}} */
+/* {{{ proto string xslt_backend_info()
+ Returns the information on the compilation settings of the backend */
+PHP_FUNCTION(xslt_backend_info)
+{
+#ifdef HAVE_SABLOT_CONFIG
+ RETURN_STRING(SAB_INFO, strlen(SAB_INFO));
+#else
+ RETURN_STRING(XSLT_NO_INFO, strlen(XSLT_NO_INFO));
+#endif
+}
+/* }}} */
/* {{{ free_processor()
Free an XSLT processor */
static void free_processor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
--- /dev/null
+--TEST--
+xslt_backend_info: examples for detection of backend features
+--SKIPIF--
+<?php // vim600: noet sw=4 ts=4 syn=php ai si tw=78
+include("skipif.inc");
+if(!function_exists('xslt_backend_info')) {
+ die("skip\n");
+}
+// Yeah-right-but-still
+if(xslt_backend_name() != "Sablotron") {
+ die("skip This test currently only supports Sablotron");
+}
+if("No information available" == xslt_backend_info()) {
+ die("skip Information could not be detected.");
+}
+?>
+--FILE--
+<?php
+/*
+ * Test xslt_backend_info: basically this test is provided as a how-to for
+ * x-platform packages, which rely on certain features which may or may
+ * not be available depending on what has been linked into the backend.
+ */
+
+$tmp = explode("\n", xslt_backend_info());
+$info = array();
+foreach($tmp AS $line) {
+ list($key, $value) = explode(": ", $line, 2);
+ $info[strtolower($key)] = $value;
+}
+
+if(FALSE === strstr($info['libs'], " -lexpat")) {
+ die("You're configuration is missing expat, which conflicts with sanity.");
+}
+
+if(FALSE === strstr($info['libs'], " -liconv")) {
+ echo("You don't have iconv support\n");
+} else {
+ echo("You have iconv support\n");
+}
+if(FALSE === strstr($info['libs'], " -ljs")) {
+ echo("You don't have JavaScript support\n");
+} else {
+ echo("You have JavaScript support\n");
+}
+?>
+--EXPECTREGEX--
+You (don't )?have iconv support
+You (don't )?have JavaScript support