From: Marcus Brinkmann Date: Tue, 20 Nov 2001 06:01:24 +0000 (+0000) Subject: 2001-11-20 Marcus Brinkmann X-Git-Tag: gpgme-1.2.0@1385~1275 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8cd36853821f726f9b40719aaee5d3e215efb3f1;p=gpgme.git 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. --- diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 6e28bbf..87e93c1 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/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/trunk/gpgme/Makefile.am b/trunk/gpgme/Makefile.am index 79155e3..8f7343a 100644 --- a/trunk/gpgme/Makefile.am +++ b/trunk/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/trunk/gpgme/ops.h b/trunk/gpgme/ops.h index b7aea41..f061897 100644 --- a/trunk/gpgme/ops.h +++ b/trunk/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/trunk/gpgme/rungpg.c b/trunk/gpgme/rungpg.c index 7a91444..df3bcf8 100644 --- a/trunk/gpgme/rungpg.c +++ b/trunk/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/trunk/gpgme/rungpg.h b/trunk/gpgme/rungpg.h index 6c6fc32..fbbdbf9 100644 --- a/trunk/gpgme/rungpg.h +++ b/trunk/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/trunk/gpgme/types.h b/trunk/gpgme/types.h index 895d923..8f80a0b 100644 --- a/trunk/gpgme/types.h +++ b/trunk/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/trunk/gpgme/version.c b/trunk/gpgme/version.c index 7f072ca..762b6ea 100644 --- a/trunk/gpgme/version.c +++ b/trunk/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; - - 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 */ - - 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; + 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; + + 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; } - 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;