Is direct calling "iconv.dll" really needed in Win32?

Carlo Luciano Bianco clbianco at tiscalinet.it
Fri Nov 19 01:41:52 CET 2004


Dear all,

when I was trying to fix the building problem with GnuPG 1.3.92 and the 
"vasprintf" function (see previous message), I did also the following 
experiment:

I removed from util/strgutil.c all the "#ifdef _WIN32" code for direct 
calling the "iconv.dll" library, i.e. I applied the attached patch. Of 
course, I added a "-liconv" to makefiles.

Well... it worked. The resulting gpg.exe, of course, explicitly depends on 
libiconv-2.dll, and all "make check" are ok (beside the two which never 
worked in MSYS environment).

So here comes my question. If the "standard" GnuPG code which works in a 
Linux environment works also without problems in Win32, why adding a 
"#ifdef _WIN32" code to do the same thing with a direct loading of 
"iconv.dll"?

Is this "special" code really needed for something else or can it be just 
dropped in favor of the "standard" one, which maybe can even be linked 
statically with libiconv.a solving some of the problems currently under 
discussion on gnupg-users list?

Maybe I am completely wrong, let me know...

--- strgutil.c	Wed Oct 27 16:15:59 2004
+++ strgutil.c.clb	Thu Nov 18 23:47:47 2004
@@ -38,9 +38,7 @@
 
 #ifdef USE_GNUPG_ICONV
 # include <limits.h>
-# ifndef _WIN32
-#  include <iconv.h>
-# endif
+# include <iconv.h>
 #endif
 
 #include "types.h"
@@ -102,62 +100,6 @@
 static int use_iconv = 0;
 
 
-#ifdef _WIN32
-typedef void* iconv_t;
-#ifndef ICONV_CONST
-#define ICONV_CONST const 
-#endif
-
-iconv_t (* __stdcall iconv_open) (const char *tocode, const char *fromcode);
-size_t  (* __stdcall iconv) (iconv_t cd,
-                             const char **inbuf, size_t *inbytesleft,
-                             char **outbuf, size_t *outbytesleft);
-int     (* __stdcall iconv_close) (iconv_t cd);
-
-#endif /*_WIN32*/
-
-
-
-#ifdef _WIN32
-static int 
-load_libiconv (void)
-{
-  static int done;
-  
-  if (!done)
-    {
-      void *handle;
-
-      done = 1; /* Do it right now because we might get called recursivly
-                   through gettext.  */
-    
-      handle = dlopen ("iconv.dll", RTLD_LAZY);
-      if (handle)
-        {
-          iconv_open  = dlsym (handle, "libiconv_open");
-          if (iconv_open)
-            iconv      = dlsym (handle, "libiconv");
-          if (iconv)    
-            iconv_close = dlsym (handle, "libiconv_close");
-        }
-      if (!handle || !iconv_close)
-        {
-          log_error (_("error loading `%s': %s\n"),
-                     "iconv.dll",  dlerror ());
-          iconv_open = NULL;
-          iconv = NULL;
-          iconv_close = NULL;
-          if (handle)
-              dlclose (handle);
-        }
-    }
-  return iconv_open? 0: -1;
-}    
-#endif /* _WIN32 */
-
-
-
-
 void
 free_strlist( STRLIST sl )
 {
@@ -529,11 +471,6 @@
 #ifdef USE_GNUPG_ICONV
     else {
       iconv_t cd;
-
-#ifdef _WIN32
-      if (load_libiconv ())
-          return G10ERR_GENERAL;
-#endif /*_WIN32*/      
 
       cd = iconv_open (full_newset, "utf-8");
       if (cd == (iconv_t)-1) {


-- 
| Carlo Luciano Bianco | ICQ UIN: 109517158                              |
|______________________| Home page: <http://web.tiscali.it/clbianco/>    |
|GPG DSA/ElG 1024/4096:|_________________________________________________|
|KeyID:0x5324A0DA - Fingerprint:8B00C61034120506111B143DEDBF71B45324A0DA |




More information about the Gnupg-devel mailing list