Fixed version string and W32 spawn function
authorWerner Koch <wk@gnupg.org>
Tue, 30 Jan 2001 17:36:03 +0000 (17:36 +0000)
committerWerner Koch <wk@gnupg.org>
Tue, 30 Jan 2001 17:36:03 +0000 (17:36 +0000)
gpgme/ChangeLog
gpgme/version.c
gpgme/w32-io.c
gpgme/w32-util.c

index 0f704a5aa1e376df7e9984530e9806990441fc65..2b8c2370b470ab17355d31d053150453a520ff6a 100644 (file)
@@ -1,5 +1,9 @@
 2001-01-30  Werner Koch  <wk@gnupg.org>
 
+       * w32-io.c (_gpgme_io_spawn): Use the supplied path arg.
+
+       * version.c (get_engine_info): Return better error information.
+
        * posix-util.c, w32-util.c: New.
        (_gpgme_get_gpg_path): New, suggested by Jan-Oliver.
        * rungpg.c (_gpgme_gpg_spawn): Use new function to get GPG's path.
index f1c839703a55b2c809c0009ff051df3c3afacb11..6013d27d886934a363edefd938d20fa9031eed2d 100644 (file)
@@ -219,11 +219,13 @@ get_engine_info (void)
     const char *engine_info =NULL;
     GpgmeCtx c = NULL;
     GpgmeError err = 0;
+    const char *path = NULL;
 
     /* FIXME: make sure that only one instance does run */
     if (engine_info)
         goto leave;
 
+    path = _gpgme_get_gpg_path ();
     err = gpgme_new (&c);
     if (err) 
         goto leave;
@@ -250,15 +252,17 @@ get_engine_info (void)
         fmt = "<GnupgInfo>\n"
               " <engine>\n"
               "  <version>%s</version>\n"
+              "  <path>%s</path>\n"
               " </engine>\n"
               "</GnupgInfo>\n";
         /*(yes, I know that we allocating 2 extra bytes)*/
-        p = xtrymalloc ( strlen(fmt) + strlen (tmp_engine_version) + 1);
+        p = xtrymalloc ( strlen(fmt) + strlen(path)
+                         + strlen (tmp_engine_version) + 1);
         if (!p) {
             err = mk_error (Out_Of_Core);
             goto leave;
         }
-        sprintf (p, fmt, tmp_engine_version);
+        sprintf (p, fmt, tmp_engine_version, path);
         engine_info = p;
         xfree (tmp_engine_version); tmp_engine_version = NULL;
     }
@@ -267,8 +271,29 @@ get_engine_info (void)
     }
 
  leave:
-    if (err)
-        engine_info = "<GnupgInfo>\n<error>No engine</error>\n</GnupgInfo>\n";
+    if (err) {
+        const char *fmt;
+        const char *errstr = gpgme_strerror (err);
+        char *p;
+
+        fmt = "<GnupgInfo>\n"
+            " <engine>\n"
+            "  <error>%s</error>\n"                
+            "  <path>%s</path>\n"
+            " </engine>\n"
+            "</GnupgInfo>\n";
+
+        p = xtrymalloc ( strlen(fmt) + strlen(errstr) + strlen(path) + 1);
+        if (p) { 
+            sprintf (p, fmt, errstr, path);
+            engine_info = p;
+        }
+        else {
+            engine_info = "<GnupgInfo>\n"
+                          "  <error>Out of core</error>\n"
+                          "</GnupgInfo>\n";
+        }
+    }
     gpgme_release ( c );
     return engine_info;
 }
index 1e67a64236982057f0cc69aabb118ff747867e5f..8c19d818816691dec4c628331b17666e2e7bfef6 100644 (file)
@@ -484,9 +484,9 @@ _gpgme_io_spawn ( const char *path, char **argv,
         }
     }
 
-    DEBUG1 ("CreateProcess, args=`%s'", arg_string);
+    DEBUG2 ("CreateProcess, path=`%s' args=`%s'", path, arg_string);
     cr_flags |= CREATE_SUSPENDED; 
-    if ( !CreateProcessA (GPG_PATH,
+    if ( !CreateProcessA (path,
                           arg_string,
                           &sec_attr,     /* process security attributes */
                           &sec_attr,     /* thread security attributes */
index e84285771aec48391e01433dae73811a2f36d33a..000ce0486ae87211bc976c6fe7767d892c6bf1a2 100644 (file)
@@ -99,10 +99,10 @@ _gpgme_get_gpg_path (void)
         if (gpg_program) {
             int i;
             
-            DEBUG1 ("found gpgProgram in registry: `%s'", gpgProgram );
-            for (i=0; gpg_program[i]; s++) {
+            DEBUG1 ("found gpgProgram in registry: `%s'", gpg_program );
+            for (i=0; gpg_program[i]; i++) {
                 if (gpg_program[i] == '/')
-                    gpg_program[i] == '\\';
+                    gpg_program[i] = '\\';
             }
         }
         else {