msopacua                Sun Nov 10 07:18:02 2002 EDT

  Added files:                 
    /php4/ext/xslt/tests        xslt_backend_info.phpt 

  Modified files:              
    /php4/ext/xslt      config.m4 php_sablot.h sablot.c 
  Log:
  - implement xslt_backend_info
  - add test for it
  - fix some prototypes
  
  
Index: php4/ext/xslt/config.m4
diff -u php4/ext/xslt/config.m4:1.29 php4/ext/xslt/config.m4:1.30
--- php4/ext/xslt/config.m4:1.29        Thu Oct 31 16:21:00 2002
+++ php4/ext/xslt/config.m4     Sun Nov 10 07:18:02 2002
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.29 2002/10/31 21:21:00 msopacua Exp $
+dnl $Id: config.m4,v 1.30 2002/11/10 12:18:02 msopacua Exp $
 dnl
 dnl +------------------------------------------------------------------------------+
 dnl |  This is where the magic of the extension reallly is.  Depending on what     |
@@ -58,6 +58,19 @@
   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: php4/ext/xslt/php_sablot.h
diff -u php4/ext/xslt/php_sablot.h:1.16 php4/ext/xslt/php_sablot.h:1.17
--- php4/ext/xslt/php_sablot.h:1.16     Thu Oct 31 16:21:00 2002
+++ php4/ext/xslt/php_sablot.h  Sun Nov 10 07:18:02 2002
@@ -50,6 +50,7 @@
 #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 @@
 #endif
 PHP_FUNCTION(xslt_backend_version);
 PHP_FUNCTION(xslt_backend_name);
-
+PHP_FUNCTION(xslt_backend_info);
 
 struct scheme_handlers {
        zval *sh_get_all;
Index: php4/ext/xslt/sablot.c
diff -u php4/ext/xslt/sablot.c:1.67 php4/ext/xslt/sablot.c:1.68
--- php4/ext/xslt/sablot.c:1.67 Sat Nov  2 10:01:42 2002
+++ php4/ext/xslt/sablot.c      Sun Nov 10 07:18:02 2002
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sablot.c,v 1.67 2002/11/02 15:01:42 msopacua Exp $ */
+/* $Id: sablot.c,v 1.68 2002/11/10 12:18:02 msopacua Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -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 @@
 #endif
        PHP_FE(xslt_backend_version,     NULL)
        PHP_FE(xslt_backend_name,        NULL)
+    PHP_FE(xslt_backend_info,        NULL)
        {NULL, NULL, NULL}
 };
 /* }}} */
@@ -193,6 +197,9 @@
 #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 @@
 /* }}} */
 #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 @@
 }
 /* }}} */
 
-/* {{{ 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 @@
 }
 /* }}} */
 
+/* {{{ 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)

Index: php4/ext/xslt/tests/xslt_backend_info.phpt
+++ php4/ext/xslt/tests/xslt_backend_info.phpt
--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



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to