diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 6e28bbfa..87e93c14 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,26 @@ +2001-11-20 Marcus Brinkmann + + * types.h: Add types EngineObject and GpgsmObject. + + * Makefile.am (libgpgme_la_SOURCES): Add engine-gpgsm.h, + engine-gpgsm.c, engine.h and engine.c. + * engine.h: New file. + * engine.c: Likewise. + * engine-gpgsm.h: Likewise. + * engine-gpgsm.c: Likewise. + + * rungpg.c (_gpgme_gpg_get_version): New function. + (_gpgme_gpg_check_version): Likewise. + * rungpg.h: Add prototypes for _gpgme_gpg_get_version and + _gpgme_gpg_check_version. + + * version.c (compare_versions): Rename to ... + (_gpgme_compare_versions): ... this. Make non-static. + (gpgme_check_version): Use _gpgme_compare_versions rather than + compare_versions. + (gpgme_check_engine): Likewise. + * ops.h (_gpgme_get_program_version): Add prototype. + 2001-11-20 Marcus Brinkmann * Makefile.am (libgpgme_la_INCLUDES): Remove obsolete directive. diff --git a/gpgme/Makefile.am b/gpgme/Makefile.am index 79155e3b..8f7343af 100644 --- a/gpgme/Makefile.am +++ b/gpgme/Makefile.am @@ -54,20 +54,14 @@ libgpgme_la_SOURCES = \ genkey.c \ delete.c \ rungpg.c rungpg.h status-table.h \ + engine-gpgsm.c engine-gpgsm.h \ + engine.c engine.h \ sema.h posix-sema.c w32-sema.c \ syshdr.h io.h posix-io.c w32-io.c \ gpgme.c debug.c version.c errors.c - errors.c : gpgme.h $(srcdir)/mkerrors < $(srcdir)/gpgme.h > errors.c status-table.h : rungpg.h $(srcdir)/mkstatus < $(srcdir)/rungpg.h > status-table.h - - - - - - - diff --git a/gpgme/ops.h b/gpgme/ops.h index b7aea41f..f0618973 100644 --- a/gpgme/ops.h +++ b/gpgme/ops.h @@ -96,6 +96,8 @@ GpgmeError _gpgme_passphrase_start (GpgmeCtx ctx); GpgmeError _gpgme_passphrase_result (GpgmeCtx ctx); /*-- version.c --*/ +const char *_gpgme_compare_versions (const char *my_version, + const char *req_version); char *_gpgme_get_program_version (const char *const path); #endif /* OPS_H */ diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c index 7a914445..df3bcf82 100644 --- a/gpgme/rungpg.c +++ b/gpgme/rungpg.c @@ -177,8 +177,25 @@ close_notify_handler ( int fd, void *opaque ) } } +const char * +_gpgme_gpg_get_version (void) +{ + static const char *gpg_version; + /* FIXME: Locking. */ + if (!gpg_version) + gpg_version = _gpgme_get_program_version (_gpgme_get_gpg_path ()); + return gpg_version; +} + +GpgmeError +_gpgme_gpg_check_version (void) +{ + return _gpgme_compare_versions (_gpgme_gpg_get_version (), + NEED_GPG_VERSION) + ? 0 : mk_error (Invalid_Engine); +} GpgmeError _gpgme_gpg_new ( GpgObject *r_gpg ) diff --git a/gpgme/rungpg.h b/gpgme/rungpg.h index 6c6fc32a..fbbdbf9a 100644 --- a/gpgme/rungpg.h +++ b/gpgme/rungpg.h @@ -96,6 +96,8 @@ typedef void (*GpgColonLineHandler)( GpgmeCtx, char *line ); typedef const char *(*GpgCommandHandler)(void*, GpgStatusCode code, const char *keyword); +const char *_gpgme_gpg_get_version (void); +GpgmeError _gpgme_gpg_check_version (void); GpgmeError _gpgme_gpg_new ( GpgObject *r_gpg ); void _gpgme_gpg_release ( GpgObject gpg ); diff --git a/gpgme/types.h b/gpgme/types.h index 895d9239..8f80a0b3 100644 --- a/gpgme/types.h +++ b/gpgme/types.h @@ -44,11 +44,18 @@ typedef enum { * Declaration of internal objects */ +/*-- engine.c --*/ +struct engine_object_s; +typedef struct engine_object_s *EngineObject; + +/*-- engine-gpgsm.c --*/ +struct gpgsm_object_s; +typedef struct gpgsm_object_s *GpgsmObject; + /*-- rungpg.c --*/ struct gpg_object_s; typedef struct gpg_object_s *GpgObject; - /*-- verify.c --*/ struct verify_result_s; typedef struct verify_result_s *VerifyResult; diff --git a/gpgme/version.c b/gpgme/version.c index 7f072ca1..762b6eac 100644 --- a/gpgme/version.c +++ b/gpgme/version.c @@ -82,35 +82,36 @@ parse_version_string( const char *s, int *major, int *minor, int *micro ) return s; /* patchlevel */ } -static const char * -compare_versions ( const char *my_version, const char *req_version ) +const char * +_gpgme_compare_versions (const char *my_version, + const char *req_version) { - int my_major, my_minor, my_micro; - int rq_major, rq_minor, rq_micro; - const char *my_plvl, *rq_plvl; + int my_major, my_minor, my_micro; + int rq_major, rq_minor, rq_micro; + const char *my_plvl, *rq_plvl; - if ( !req_version ) - return my_version; + if (!req_version) + return my_version; - my_plvl = parse_version_string ( my_version, - &my_major, &my_minor, &my_micro ); - if ( !my_plvl ) - return NULL; /* very strange: our own version is bogus */ - rq_plvl = parse_version_string( req_version, - &rq_major, &rq_minor, &rq_micro ); - if ( !rq_plvl ) - return NULL; /* req version string is invalid */ + my_plvl = parse_version_string (my_version, &my_major, &my_minor, &my_micro); + if (!my_plvl) + return NULL; /* Very strange: our own version is bogus. */ + rq_plvl = parse_version_string(req_version, + &rq_major, &rq_minor, &rq_micro); + if (!rq_plvl) + return NULL; /* Requested version string is invalid. */ - if ( my_major > rq_major - || (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) ) { - return my_version; + if (my_major > rq_major + || (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)) + { + return my_version; } - return NULL; + return NULL; } @@ -129,13 +130,12 @@ compare_versions ( const char *my_version, const char *req_version ) * Return value: The version string or NULL **/ const char * -gpgme_check_version ( const char *req_version ) +gpgme_check_version (const char *req_version) { - do_subsystem_inits (); - return compare_versions ( VERSION, req_version ); + do_subsystem_inits (); + return _gpgme_compare_versions (VERSION, req_version); } - /** * gpgme_get_engine_info: * @@ -179,7 +179,7 @@ gpgme_check_engine () return mk_error (Out_Of_Core); memcpy (ver, s, s2-s); ver[s2-s] = 0; - s = compare_versions ( ver, NEED_GPG_VERSION ); + s = _gpgme_compare_versions ( ver, NEED_GPG_VERSION ); xfree (ver); if (s) return 0;