gpgme-tool: Return more detailed XML from KEYLIST
[gpgme.git] / src / version.c
index f777da440cc2877fa3058dd0117b085ecbe4cb5c..227a1067f60c4cb6f02faf5233131128ca664092 100644 (file)
@@ -1,19 +1,19 @@
 /* version.c - Version check routines.
    Copyright (C) 2000 Werner Koch (dd9jn)
    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008 g10 Code GmbH
+
    This file is part of GPGME.
+
    GPGME is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
-   
+
    GPGME is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
-   
+
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -22,6 +22,7 @@
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include <stdlib.h>
 #include <string.h>
 #include <limits.h>
 #include <ctype.h>
@@ -34,8 +35,9 @@
 #include "debug.h"
 #include "context.h"
 
-/* For _gpgme_sema_subsystem_init ().  */
+/* For _gpgme_sema_subsystem_init and _gpgme_status_init.  */
 #include "sema.h"
+#include "util.h"
 
 #ifdef HAVE_ASSUAN_H
 #include "assuan.h"
@@ -64,27 +66,18 @@ do_subsystem_inits (void)
     return;
 
 #ifdef HAVE_W32_SYSTEM
-      {
-        WSADATA wsadat;
-        
-        WSAStartup (0x202, &wsadat);
-      }
-#endif
-
-  _gpgme_sema_subsystem_init ();
-#ifdef HAVE_ASSUAN_H
-  assuan_set_assuan_err_source (GPG_ERR_SOURCE_GPGME);
-#endif /*HAVE_ASSUAN_H*/
-  _gpgme_debug_subsystem_init ();
-  _gpgme_io_subsystem_init ();
-#if defined(HAVE_W32_SYSTEM) && defined(HAVE_ASSUAN_H)
   /* We need to make sure that the sockets are initialized.  */
   {
     WSADATA wsadat;
-    
+
     WSAStartup (0x202, &wsadat);
   }
-#endif /*HAVE_W32_SYSTEM && HAVE_ASSUAN_H*/
+#endif
+
+  _gpgme_sema_subsystem_init ();
+  _gpgme_debug_subsystem_init ();
+  _gpgme_io_subsystem_init ();
+  _gpgme_status_init ();
 
   done = 1;
 }
@@ -166,7 +159,7 @@ _gpgme_compare_versions (const char *my_version,
 
   if (my_major > rq_major
       || (my_major == rq_major && my_minor > rq_minor)
-      || (my_major == rq_major && my_minor == rq_minor 
+      || (my_major == rq_major && my_minor == rq_minor
          && my_micro > rq_micro)
       || (my_major == rq_major && my_minor == rq_minor
          && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0))
@@ -192,13 +185,13 @@ gpgme_check_version (const char *req_version)
   do_subsystem_inits ();
 
   /* Catch-22: We need to get at least the debug subsystem ready
-     before using the tarce facility.  If we won't the tarce would
+     before using the trace facility.  If we won't the trace would
      automagically initialize the debug system with out the locks
      being initialized and missing the assuan log level setting. */
-  TRACE2 (DEBUG_INIT, "gpgme_check_version", 0,
+  TRACE2 (DEBUG_INIT, "gpgme_check_version", 0,
          "req_version=%s, VERSION=%s",
           req_version? req_version:"(null)", VERSION);
+
   result = _gpgme_compare_versions (VERSION, req_version) ? VERSION : NULL;
   if (result != NULL)
     _gpgme_selftest = 0;
@@ -215,17 +208,18 @@ gpgme_check_version_internal (const char *req_version,
 {
   const char *result;
 
-  TRACE2 (DEBUG_INIT, "gpgme_check_version_internal: ", 0,
-         "req_version=%s, offset_sig_validity=%i",
-         req_version ? req_version : "(null)", offset_sig_validity);
-
   result = gpgme_check_version (req_version);
   if (result == NULL)
     return result;
 
+  /* Catch-22, see above.  */
+  TRACE2 (DEBUG_INIT, "gpgme_check_version_internal", 0,
+         "req_version=%s, offset_sig_validity=%i",
+         req_version ? req_version : "(null)", offset_sig_validity);
+
   if (offset_sig_validity != offsetof (struct _gpgme_signature, validity))
     {
-      TRACE1 (DEBUG_INIT, "gpgme_check_version_internal", 0,
+      TRACE1 (DEBUG_INIT, "gpgme_check_version_internal", 0,
              "offset_sig_validity mismatch: expected %i",
              offsetof (struct _gpgme_signature, validity));
       _gpgme_selftest = GPG_ERR_SELFTEST_FAILED;
@@ -239,7 +233,7 @@ gpgme_check_version_internal (const char *req_version,
 
 /* Extract the version string of a program from STRING.  The version
    number is expected to be in GNU style format:
-   
+
      foo 1.2.3
      foo (bar system) 1.2.3
      foo 1.2.3 cruft
@@ -310,7 +304,7 @@ _gpgme_get_program_version (const char *const file_name)
 
   cfd[0].fd = rp[1];
 
-  status = _gpgme_io_spawn (file_name, argv, 0, cfd, NULL);
+  status = _gpgme_io_spawn (file_name, argv, 0, cfd, NULL, NULL, NULL);
   if (status < 0)
     {
       _gpgme_io_close (rp[0]);