]> granicus.if.org Git - php/commitdiff
- implement xslt_backend_info
authorMelvyn Sopacua <msopacua@php.net>
Sun, 10 Nov 2002 12:18:03 +0000 (12:18 +0000)
committerMelvyn Sopacua <msopacua@php.net>
Sun, 10 Nov 2002 12:18:03 +0000 (12:18 +0000)
- add test for it
- fix some prototypes

ext/xslt/config.m4
ext/xslt/php_sablot.h
ext/xslt/sablot.c
ext/xslt/tests/xslt_backend_info.phpt [new file with mode: 0644]

index 9d69355f3ac181a331def7694721aeab7b82648f..d721721764cf34e74dedf03535e24c754a3ccc66 100644 (file)
@@ -58,6 +58,19 @@ if test "$PHP_XSLT" != "no"; then
   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"
index c35c9e001ecf134217605295f1a9ce6ee641ecf9..620519371502424c4da48b2af9709a31592774b2 100644 (file)
@@ -50,6 +50,7 @@ extern zend_module_entry xslt_module_entry;
 #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);
@@ -72,7 +73,7 @@ PHP_FUNCTION(xslt_getopt);
 #endif
 PHP_FUNCTION(xslt_backend_version);
 PHP_FUNCTION(xslt_backend_name);
-
+PHP_FUNCTION(xslt_backend_info);
 
 struct scheme_handlers {
        zval *sh_get_all;
index b8de408f95b9bc5292496a9b6b97d3f0c3b23b4b..f55003757e2afd1a5e5349a9a8291846a6bea2db 100644 (file)
@@ -32,6 +32,9 @@
 
 #if HAVE_SABLOT_BACKEND
 
+#ifdef HAVE_SABLOT_CONFIG
+#include "php_sab_info.h"
+#endif
 #include <sablot.h>
 
 #include <string.h>
@@ -99,6 +102,7 @@ function_entry xslt_functions[] = {
 #endif
        PHP_FE(xslt_backend_version,     NULL)
        PHP_FE(xslt_backend_name,        NULL)
+    PHP_FE(xslt_backend_info,        NULL)
        {NULL, NULL, NULL}
 };
 /* }}} */
@@ -192,6 +196,9 @@ PHP_MINFO_FUNCTION(xslt)
        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();
 }
@@ -758,7 +765,7 @@ PHP_FUNCTION(xslt_getopt)
 /* }}} */
 #endif
 
-/* {{{ proto void xslt_backend_version()
+/* {{{ proto string xslt_backend_version()
    Returns the version number of Sablotron (if available) */
 PHP_FUNCTION(xslt_backend_version)
 {
@@ -770,7 +777,7 @@ 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)
 {
@@ -778,6 +785,17 @@ 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)
diff --git a/ext/xslt/tests/xslt_backend_info.phpt b/ext/xslt/tests/xslt_backend_info.phpt
new file mode 100644 (file)
index 0000000..7db9157
--- /dev/null
@@ -0,0 +1,49 @@
+--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