moriyoshi               Fri Oct 11 03:50:47 2002 EDT

  Modified files:              
    /php4/ext/iconv     config.m4 iconv.c 
  Log:
  Added ICONV_IMPL and ICONV_VERSION constants. 
  @- Added ICONV_IMPL and ICONV_VERSION constants to iconv extension to 
  @  indicate which iconv implementation is used. (Moriyoshi) 
  
  
  
Index: php4/ext/iconv/config.m4
diff -u php4/ext/iconv/config.m4:1.14 php4/ext/iconv/config.m4:1.15
--- php4/ext/iconv/config.m4:1.14       Wed Sep  4 01:17:16 2002
+++ php4/ext/iconv/config.m4    Fri Oct 11 03:50:47 2002
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.14 2002/09/04 05:17:16 yohgaki Exp $
+dnl $Id: config.m4,v 1.15 2002/10/11 07:50:47 moriyoshi Exp $
 dnl
 
 PHP_ARG_WITH(iconv, for iconv support,
@@ -8,8 +8,15 @@
 if test "$PHP_ICONV" != "no"; then
 
   PHP_SETUP_ICONV(ICONV_SHARED_LIBADD, [
-       AC_MSG_CHECKING([if iconv supports errno])
-       AC_TRY_RUN([
+    iconv_avail="yes";
+  ],[
+    iconv_avail="no";
+  ])
+
+  if test "$iconv_avail" != "no"; then
+
+    AC_MSG_CHECKING([if iconv supports errno])
+    AC_TRY_RUN([
 #define LIBICONV_PLUG
 #include <iconv.h>
 #include <errno.h>
@@ -39,17 +46,37 @@
 ],[
        AC_MSG_RESULT(yes)
     PHP_DEFINE([ICONV_SUPPORTS_ERRNO],1)
-    AC_DEFINE(ICONV_SUPPORTS_ERRNO,1,[Whether iconv supports error no or not])
+    AC_DEFINE([ICONV_SUPPORTS_ERRNO],1,[Whether iconv supports error no or not])
 ],[
     PHP_DEFINE([ICONV_SUPPORTS_ERRNO],0)
-    AC_DEFINE(ICONV_SUPPORTS_ERRNO,0,[Whether iconv supports error no or not])
+    AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
        AC_MSG_RESULT(no)
 ])
+    if test -z "$iconv_lib_name"; then
+      AC_MSG_CHECKING([if iconv is glibc's])
+      AC_TRY_COMPILE([#include <iconv.h>],[void __gconv(); int main() { __gconv(); } 
+],[
+      AC_MSG_RESULT(yes)
+      PHP_DEFINE([ICONV_IMPL],["glibc"])
+      AC_DEFINE([ICONV_IMPL],["glibc"],[Which iconv implementation to use])
+],[
+      AC_MSG_RESULT(no)
+])
+    else
+      case "$iconv_lib_name" in
+        iconv [)]
+          PHP_DEFINE([ICONV_IMPL],["libiconv"])
+          AC_DEFINE([ICONV_IMPL],["libiconv"],[Which iconv implementation to use])
+          ;;
+        giconv [)]
+          PHP_DEFINE([ICONV_IMPL],["giconv"])
+          AC_DEFINE([ICONV_IMPL],["giconv"],[Which iconv implementation to use])
+          ;;
+      esac
+    fi 
 
     PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared)
     PHP_SUBST(ICONV_SHARED_LIBADD)
-  ], [
+  else
     AC_MSG_ERROR(Please reinstall the iconv library.)
-  ])
-
+  fi
 fi
Index: php4/ext/iconv/iconv.c
diff -u php4/ext/iconv/iconv.c:1.48 php4/ext/iconv/iconv.c:1.49
--- php4/ext/iconv/iconv.c:1.48 Sat Sep  7 17:08:47 2002
+++ php4/ext/iconv/iconv.c      Fri Oct 11 03:50:47 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iconv.c,v 1.48 2002/09/07 21:08:47 yohgaki Exp $ */
+/* $Id: iconv.c,v 1.49 2002/10/11 07:50:47 moriyoshi Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -106,8 +106,25 @@
 
 PHP_MINIT_FUNCTION(miconv)
 {
+       char *impl_name = "unknown";
+       char *version = "";
+
        ZEND_INIT_MODULE_GLOBALS(iconv, php_iconv_init_globals, NULL);
        REGISTER_INI_ENTRIES();
+
+#if HAVE_LIBICONV
+       {
+               static char buf[16];
+               impl_name = "libiconv"; 
+               snprintf( buf, sizeof(buf), "%d.%d", ((_libiconv_version >> 8) & 0x0f),
+                                                    (_libiconv_version & 0x0f) ); 
+               version = buf;
+       }
+#endif
+
+       REGISTER_STRING_CONSTANT( "ICONV_IMPL", ICONV_IMPL, CONST_CS | 
+CONST_PERSISTENT );
+       REGISTER_STRING_CONSTANT( "ICONV_VERSION", version, CONST_CS | 
+CONST_PERSISTENT );
+
        return SUCCESS;
 }
 



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

Reply via email to