From 6e9b15d7ed5ee3d5340f2d9bb2886caeac1883ae Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 30 Jan 2001 17:36:03 +0000 Subject: [PATCH] Fixed version string and W32 spawn function --- gpgme/ChangeLog | 4 ++++ gpgme/version.c | 33 +++++++++++++++++++++++++++++---- gpgme/w32-io.c | 4 ++-- gpgme/w32-util.c | 6 +++--- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 0f704a5..2b8c237 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,5 +1,9 @@ 2001-01-30 Werner Koch + * 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. diff --git a/gpgme/version.c b/gpgme/version.c index f1c8397..6013d27 100644 --- a/gpgme/version.c +++ b/gpgme/version.c @@ -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 = "\n" " \n" " %s\n" + " %s\n" " \n" "\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 = "\nNo engine\n\n"; + if (err) { + const char *fmt; + const char *errstr = gpgme_strerror (err); + char *p; + + fmt = "\n" + " \n" + " %s\n" + " %s\n" + " \n" + "\n"; + + p = xtrymalloc ( strlen(fmt) + strlen(errstr) + strlen(path) + 1); + if (p) { + sprintf (p, fmt, errstr, path); + engine_info = p; + } + else { + engine_info = "\n" + " Out of core\n" + "\n"; + } + } gpgme_release ( c ); return engine_info; } diff --git a/gpgme/w32-io.c b/gpgme/w32-io.c index 1e67a64..8c19d81 100644 --- a/gpgme/w32-io.c +++ b/gpgme/w32-io.c @@ -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 */ diff --git a/gpgme/w32-util.c b/gpgme/w32-util.c index e842857..000ce04 100644 --- a/gpgme/w32-util.c +++ b/gpgme/w32-util.c @@ -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 { -- 2.26.2