2001-11-20 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2001-11-20 06:01:24 +00:00
parent a441158cc7
commit ad428df905
7 changed files with 83 additions and 38 deletions

View File

@ -1,3 +1,26 @@
2001-11-20 Marcus Brinkmann <marcus@g10code.de>
* 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 <marcus@g10code.de> 2001-11-20 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (libgpgme_la_INCLUDES): Remove obsolete directive. * Makefile.am (libgpgme_la_INCLUDES): Remove obsolete directive.

View File

@ -54,20 +54,14 @@ libgpgme_la_SOURCES = \
genkey.c \ genkey.c \
delete.c \ delete.c \
rungpg.c rungpg.h status-table.h \ 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 \ sema.h posix-sema.c w32-sema.c \
syshdr.h io.h posix-io.c w32-io.c \ syshdr.h io.h posix-io.c w32-io.c \
gpgme.c debug.c version.c errors.c gpgme.c debug.c version.c errors.c
errors.c : gpgme.h errors.c : gpgme.h
$(srcdir)/mkerrors < $(srcdir)/gpgme.h > errors.c $(srcdir)/mkerrors < $(srcdir)/gpgme.h > errors.c
status-table.h : rungpg.h status-table.h : rungpg.h
$(srcdir)/mkstatus < $(srcdir)/rungpg.h > status-table.h $(srcdir)/mkstatus < $(srcdir)/rungpg.h > status-table.h

View File

@ -96,6 +96,8 @@ GpgmeError _gpgme_passphrase_start (GpgmeCtx ctx);
GpgmeError _gpgme_passphrase_result (GpgmeCtx ctx); GpgmeError _gpgme_passphrase_result (GpgmeCtx ctx);
/*-- version.c --*/ /*-- version.c --*/
const char *_gpgme_compare_versions (const char *my_version,
const char *req_version);
char *_gpgme_get_program_version (const char *const path); char *_gpgme_get_program_version (const char *const path);
#endif /* OPS_H */ #endif /* OPS_H */

View File

@ -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 GpgmeError
_gpgme_gpg_new ( GpgObject *r_gpg ) _gpgme_gpg_new ( GpgObject *r_gpg )

View File

@ -96,6 +96,8 @@ typedef void (*GpgColonLineHandler)( GpgmeCtx, char *line );
typedef const char *(*GpgCommandHandler)(void*, GpgStatusCode code, typedef const char *(*GpgCommandHandler)(void*, GpgStatusCode code,
const char *keyword); const char *keyword);
const char *_gpgme_gpg_get_version (void);
GpgmeError _gpgme_gpg_check_version (void);
GpgmeError _gpgme_gpg_new ( GpgObject *r_gpg ); GpgmeError _gpgme_gpg_new ( GpgObject *r_gpg );
void _gpgme_gpg_release ( GpgObject gpg ); void _gpgme_gpg_release ( GpgObject gpg );

View File

@ -44,11 +44,18 @@ typedef enum {
* Declaration of internal objects * 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 --*/ /*-- rungpg.c --*/
struct gpg_object_s; struct gpg_object_s;
typedef struct gpg_object_s *GpgObject; typedef struct gpg_object_s *GpgObject;
/*-- verify.c --*/ /*-- verify.c --*/
struct verify_result_s; struct verify_result_s;
typedef struct verify_result_s *VerifyResult; typedef struct verify_result_s *VerifyResult;

View File

@ -82,35 +82,36 @@ parse_version_string( const char *s, int *major, int *minor, int *micro )
return s; /* patchlevel */ return s; /* patchlevel */
} }
static const char * const char *
compare_versions ( const char *my_version, const char *req_version ) _gpgme_compare_versions (const char *my_version,
const char *req_version)
{ {
int my_major, my_minor, my_micro; int my_major, my_minor, my_micro;
int rq_major, rq_minor, rq_micro; int rq_major, rq_minor, rq_micro;
const char *my_plvl, *rq_plvl; const char *my_plvl, *rq_plvl;
if ( !req_version ) if (!req_version)
return my_version; return my_version;
my_plvl = parse_version_string ( my_version, my_plvl = parse_version_string (my_version, &my_major, &my_minor, &my_micro);
&my_major, &my_minor, &my_micro ); if (!my_plvl)
if ( !my_plvl ) return NULL; /* Very strange: our own version is bogus. */
return NULL; /* very strange: our own version is bogus */ rq_plvl = parse_version_string(req_version,
rq_plvl = parse_version_string( req_version, &rq_major, &rq_minor, &rq_micro);
&rq_major, &rq_minor, &rq_micro ); if (!rq_plvl)
if ( !rq_plvl ) return NULL; /* Requested version string is invalid. */
return NULL; /* req version string is invalid */
if ( my_major > rq_major 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_major == rq_major && my_minor == rq_minor
&& my_micro > rq_micro) && my_micro > rq_micro)
|| (my_major == rq_major && my_minor == rq_minor || (my_major == rq_major && my_minor == rq_minor
&& my_micro == rq_micro && my_micro == rq_micro
&& strcmp( my_plvl, rq_plvl ) >= 0) ) { && strcmp( my_plvl, rq_plvl ) >= 0))
return my_version; {
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 * Return value: The version string or NULL
**/ **/
const char * const char *
gpgme_check_version ( const char *req_version ) gpgme_check_version (const char *req_version)
{ {
do_subsystem_inits (); do_subsystem_inits ();
return compare_versions ( VERSION, req_version ); return _gpgme_compare_versions (VERSION, req_version);
} }
/** /**
* gpgme_get_engine_info: * gpgme_get_engine_info:
* *
@ -179,7 +179,7 @@ gpgme_check_engine ()
return mk_error (Out_Of_Core); return mk_error (Out_Of_Core);
memcpy (ver, s, s2-s); memcpy (ver, s, s2-s);
ver[s2-s] = 0; ver[s2-s] = 0;
s = compare_versions ( ver, NEED_GPG_VERSION ); s = _gpgme_compare_versions ( ver, NEED_GPG_VERSION );
xfree (ver); xfree (ver);
if (s) if (s)
return 0; return 0;