]> granicus.if.org Git - php/commitdiff
Added ICONV_IMPL and ICONV_VERSION constants.
authorMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 11 Oct 2002 07:50:47 +0000 (07:50 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 11 Oct 2002 07:50:47 +0000 (07:50 +0000)
@- Added ICONV_IMPL and ICONV_VERSION constants to iconv extension to
@  indicate which iconv implementation is used. (Moriyoshi)

ext/iconv/config.m4
ext/iconv/iconv.c

index d075046ecd02b3b24a8c11a6d98baad180346707..a6ffe827af222f9454acb765a0115d7e393ecc96 100644 (file)
@@ -8,8 +8,15 @@ PHP_ARG_WITH(iconv, for iconv support,
 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 @@ int main() {
 ],[
        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 eada3025af57c9c7d9132b92d1556b8a5a72ff60..b7e56710de1918906abb191c59e7f5349d4307d5 100644 (file)
@@ -106,8 +106,25 @@ static void php_iconv_init_globals(zend_iconv_globals *iconv_globals)
 
 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;
 }