doc/
2003-01-30 Marcus Brinkmann <marcus@g10code.de> * gpgme.texi (Engine Information): Rewritten. gpgme/ 2003-01-30 Marcus Brinkmann <marcus@g10code.de> * gpgme.h (enum GpgmeProtocol): Remove GPGME_PROTOCOL_AUTO. * gpgme.c (gpgme_set_protocol): Don't handle GPGME_PROTOCOL_AUTO. (gpgme_get_protocol_name): New function. * engine-backend.h (struct engine_ops): New member get_req_version, remove member check_version. * engine.h (_gpgme_Engine_get_version): New prototype. * rungpg.c (gpg_get_req_version): New function. (gpg_check_version): Function removed. (_gpgme_engine_ops_gpg): Add gpg_get_req_version, remove gpg_check_version. * engine-gpgsm.c (gpgsm_get_req_version): New function. (gpgsm_check_version): Function removed. (_gpgme_engine_ops_gpgsm): Add gpgsm_get_req_version, remove gpgsm_check_version. * engine.c: Include ops.h. (_gpgme_engine_get_req_version): New function. (gpgme_engine_check_version): Rewritten. * version.c (gpgme_get_engine_info): Rewritten. * gpgme.h (gpgme_engine_info): New structure. (GpgmeEngineInfo): New type. tests/ 2003-01-30 Marcus Brinkmann <marcus@g10code.de> * Makefile.am (TESTS): Add t-engine-info. * t-engine-info.c: New file. * gpg/t-encrypt.c (main): Don't print engine info. * gpg/t-eventloop.c (main): Likewise. * gpg/t-encrypt-sign.c (main): Likewise. * gpgsm/t-encrypt.c (main): Likewise.
This commit is contained in:
parent
693b8a2ac6
commit
fdbee6b211
@ -1,3 +1,7 @@
|
|||||||
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* gpgme.texi (Engine Information): Rewritten.
|
||||||
|
|
||||||
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
|
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* gpgme.texi (I/O Callback Interface): Document new even
|
* gpgme.texi (I/O Callback Interface): Document new even
|
||||||
|
102
doc/gpgme.texi
102
doc/gpgme.texi
@ -609,41 +609,87 @@ and @code{GPGME_Invalid_Engine} if it is not.
|
|||||||
@section Engine Information
|
@section Engine Information
|
||||||
@cindex engine, information about
|
@cindex engine, information about
|
||||||
|
|
||||||
@deftypefun {const char *} gpgme_get_engine_info (void)
|
@deftp {Data type} {GpgmeEngineInfo}
|
||||||
The function @code{gpgme_get_engine_info} returns an @acronym{XML}
|
@tindex GpgmeProtocol
|
||||||
string containing information about the available protocols and the
|
The @code{GpgmeEngineInfo} type specifies a pointer to a structure
|
||||||
engine which implement them. The following information is returned
|
describing a crypto backend engine. The structure contains the
|
||||||
for each engine:
|
following elements:
|
||||||
|
|
||||||
@table @samp
|
@table @code
|
||||||
@item <protocol>
|
@item GpgmeEngineInfo next
|
||||||
The name of the protocol.
|
This is a pointer to the next engine info structure in the linked
|
||||||
@item <version>
|
list, or @code{NULL} if this is the last element.
|
||||||
The version of the engine.
|
|
||||||
@item <path>
|
@item GpgmeProtocol protocol
|
||||||
The path to the engine binary.
|
This is the protocol for which the crypo engine is used. You can
|
||||||
|
convert this to a string with @code{gpgme_get_protocol_name} for
|
||||||
|
printing.
|
||||||
|
|
||||||
|
@item const char *path
|
||||||
|
This is a string holding the path to the executable of the crypto
|
||||||
|
engine. Currently, it is never @code{NULL}, but using @code{NULL} is
|
||||||
|
reserved for future use, so always check before you use it.
|
||||||
|
|
||||||
|
@item const char *version
|
||||||
|
This is a string containing the version number of the crypto engine.
|
||||||
|
It might be @code{NULL} if the version number can not be determined,
|
||||||
|
for example because the executable doesn't exist or is invalid.
|
||||||
|
|
||||||
|
@item const char *req_version
|
||||||
|
This is a string containing the minimum required version number of the
|
||||||
|
crypto engine for @acronym{GPGME} to work correctly. This is the
|
||||||
|
version number that @code{gpgme_engine_check_version} verifies
|
||||||
|
against. Currently, it is never @code{NULL}, but using @code{NULL} is
|
||||||
|
reserved for future use, so always check before you use it.
|
||||||
@end table
|
@end table
|
||||||
|
@end deftp
|
||||||
|
|
||||||
A string is always returned. If an error occurs, the string will
|
@deftypefun GpgmeError gpgme_get_engine_info (GpgmeEngineInfo *info)
|
||||||
contain an @samp{<error>} tag with a description of the failure.
|
The function @code{gpgme_get_engine_info} returns a linked list of
|
||||||
|
engine info structures in @var{info}. Each info structure describes
|
||||||
|
one configured crypto backend engine.
|
||||||
|
|
||||||
|
The memory for the info structures is allocated the first time this
|
||||||
|
function is invoked, and must not be freed by the caller.
|
||||||
|
|
||||||
|
This function returns @code{GPGME_No_Error} if successful, and
|
||||||
|
@code{GPGME_Out_Of_Core} if not enough memory is available for the
|
||||||
|
operation.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
Here is the example output of what @code{gpgme_get_engine_info} might
|
Here is the example how you can provide more diagnostics if you
|
||||||
return on your system:
|
receive an error message which indicates that the crypto engine is
|
||||||
|
invalid.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
<EngineInfo>
|
GpgmeCtx ctx;
|
||||||
<engine>
|
GpgmeError err;
|
||||||
<protocol>OpenPGP</protocol>
|
|
||||||
<version>1.0.6</version>
|
[...]
|
||||||
<path>/usr/bin/gpg</path>
|
|
||||||
</engine>
|
if (err == GPGME_Invalid_Engine)
|
||||||
<engine>
|
@{
|
||||||
<protocol>CMS</protocol>
|
GpgmeEngineInfo info;
|
||||||
<version>0.0.0</version>
|
err = gpgme_get_engine_info (&info);
|
||||||
<path>/usr/bin/gpgsm</path>
|
if (!err)
|
||||||
</engine>
|
@{
|
||||||
</EngineInfo>
|
while (info && info->protocol != gpgme_get_protocol (ctx))
|
||||||
|
info = info->next;
|
||||||
|
if (!info)
|
||||||
|
fprintf (stderr, "GPGME compiled without support for protocol %s",
|
||||||
|
gpgme_get_protocol_name (info->protocol));
|
||||||
|
else if (info->path && !info->version)
|
||||||
|
fprintf (stderr, "Engine %s not installed properly",
|
||||||
|
info->path);
|
||||||
|
else if (info->path && info->version && info->req_version)
|
||||||
|
fprintf (stderr, "Engine %s version %s installed, "
|
||||||
|
"but at least version %s required", info->path,
|
||||||
|
info->version, info->req_version);
|
||||||
|
else
|
||||||
|
fprintf (stderr, "Unknown problem with engine for protocol %s",
|
||||||
|
gpgme_get_protocol_name (info->protocol));
|
||||||
|
@}
|
||||||
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* gpgme.h (enum GpgmeProtocol): Remove GPGME_PROTOCOL_AUTO.
|
||||||
|
* gpgme.c (gpgme_set_protocol): Don't handle GPGME_PROTOCOL_AUTO.
|
||||||
|
(gpgme_get_protocol_name): New function.
|
||||||
|
|
||||||
|
* engine-backend.h (struct engine_ops): New member
|
||||||
|
get_req_version, remove member check_version.
|
||||||
|
* engine.h (_gpgme_Engine_get_version): New prototype.
|
||||||
|
* rungpg.c (gpg_get_req_version): New function.
|
||||||
|
(gpg_check_version): Function removed.
|
||||||
|
(_gpgme_engine_ops_gpg): Add gpg_get_req_version, remove
|
||||||
|
gpg_check_version.
|
||||||
|
* engine-gpgsm.c (gpgsm_get_req_version): New function.
|
||||||
|
(gpgsm_check_version): Function removed.
|
||||||
|
(_gpgme_engine_ops_gpgsm): Add gpgsm_get_req_version, remove
|
||||||
|
gpgsm_check_version.
|
||||||
|
* engine.c: Include ops.h.
|
||||||
|
(_gpgme_engine_get_req_version): New function.
|
||||||
|
(gpgme_engine_check_version): Rewritten.
|
||||||
|
* version.c (gpgme_get_engine_info): Rewritten.
|
||||||
|
* gpgme.h (gpgme_engine_info): New structure.
|
||||||
|
(GpgmeEngineInfo): New type.
|
||||||
|
|
||||||
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
|
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* types.h: Remove byte and ulong types.
|
* types.h: Remove byte and ulong types.
|
||||||
|
@ -34,7 +34,7 @@ struct engine_ops
|
|||||||
/* Static functions. */
|
/* Static functions. */
|
||||||
const char *(*get_path) (void);
|
const char *(*get_path) (void);
|
||||||
const char *(*get_version) (void);
|
const char *(*get_version) (void);
|
||||||
GpgmeError (*check_version) (void);
|
const char *(*get_req_version) (void);
|
||||||
GpgmeError (*new) (void **r_engine);
|
GpgmeError (*new) (void **r_engine);
|
||||||
|
|
||||||
/* Member functions. */
|
/* Member functions. */
|
||||||
|
@ -113,11 +113,10 @@ gpgsm_get_version (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GpgmeError
|
static const char *
|
||||||
gpgsm_check_version (void)
|
gpgsm_get_req_version (void)
|
||||||
{
|
{
|
||||||
return _gpgme_compare_versions (gpgsm_get_version (), NEED_GPGSM_VERSION)
|
return NEED_GPGSM_VERSION;
|
||||||
? 0 : GPGME_Invalid_Engine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1437,7 +1436,7 @@ struct engine_ops _gpgme_engine_ops_gpgsm =
|
|||||||
/* Static functions. */
|
/* Static functions. */
|
||||||
_gpgme_get_gpgsm_path,
|
_gpgme_get_gpgsm_path,
|
||||||
gpgsm_get_version,
|
gpgsm_get_version,
|
||||||
gpgsm_check_version,
|
gpgsm_get_req_version,
|
||||||
gpgsm_new,
|
gpgsm_new,
|
||||||
|
|
||||||
/* Member functions. */
|
/* Member functions. */
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "gpgme.h"
|
#include "gpgme.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "sema.h"
|
#include "sema.h"
|
||||||
|
#include "ops.h"
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "engine-backend.h"
|
#include "engine-backend.h"
|
||||||
@ -54,7 +55,7 @@ static struct engine_ops *engine_ops[] =
|
|||||||
const char *
|
const char *
|
||||||
_gpgme_engine_get_path (GpgmeProtocol proto)
|
_gpgme_engine_get_path (GpgmeProtocol proto)
|
||||||
{
|
{
|
||||||
if (proto > sizeof (engine_ops) / sizeof (engine_ops[0]))
|
if (proto > DIM (engine_ops))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (engine_ops[proto] && engine_ops[proto]->get_path)
|
if (engine_ops[proto] && engine_ops[proto]->get_path)
|
||||||
@ -68,7 +69,7 @@ _gpgme_engine_get_path (GpgmeProtocol proto)
|
|||||||
const char *
|
const char *
|
||||||
_gpgme_engine_get_version (GpgmeProtocol proto)
|
_gpgme_engine_get_version (GpgmeProtocol proto)
|
||||||
{
|
{
|
||||||
if (proto > sizeof (engine_ops) / sizeof (engine_ops[0]))
|
if (proto > DIM (engine_ops))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (engine_ops[proto] && engine_ops[proto]->get_version)
|
if (engine_ops[proto] && engine_ops[proto]->get_version)
|
||||||
@ -78,20 +79,27 @@ _gpgme_engine_get_version (GpgmeProtocol proto)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Get the required version number of the engine for PROTOCOL. */
|
||||||
|
const char *
|
||||||
|
_gpgme_engine_get_req_version (GpgmeProtocol proto)
|
||||||
|
{
|
||||||
|
if (proto > DIM (engine_ops))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (engine_ops[proto] && engine_ops[proto]->get_req_version)
|
||||||
|
return (*engine_ops[proto]->get_req_version) ();
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Verify the version requirement for the engine for PROTOCOL. */
|
/* Verify the version requirement for the engine for PROTOCOL. */
|
||||||
GpgmeError
|
GpgmeError
|
||||||
gpgme_engine_check_version (GpgmeProtocol proto)
|
gpgme_engine_check_version (GpgmeProtocol proto)
|
||||||
{
|
{
|
||||||
if (proto > sizeof (engine_ops) / sizeof (engine_ops[0]))
|
return _gpgme_compare_versions (_gpgme_engine_get_version (proto),
|
||||||
return GPGME_Invalid_Value;
|
_gpgme_engine_get_req_version (proto))
|
||||||
|
? 0 : GPGME_Invalid_Engine;
|
||||||
if (!engine_ops[proto])
|
|
||||||
return GPGME_Invalid_Engine;
|
|
||||||
|
|
||||||
if (engine_ops[proto]->check_version)
|
|
||||||
return (*engine_ops[proto]->check_version) ();
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,7 +150,7 @@ _gpgme_engine_new (GpgmeProtocol proto, EngineObject *r_engine)
|
|||||||
const char *path;
|
const char *path;
|
||||||
const char *version;
|
const char *version;
|
||||||
|
|
||||||
if (proto > sizeof (engine_ops) / sizeof (engine_ops[0]))
|
if (proto > DIM (engine_ops))
|
||||||
return GPGME_Invalid_Value;
|
return GPGME_Invalid_Value;
|
||||||
|
|
||||||
if (!engine_ops[proto])
|
if (!engine_ops[proto])
|
||||||
|
@ -29,6 +29,9 @@ const char *_gpgme_engine_get_path (GpgmeProtocol proto);
|
|||||||
/* Get the version number of the engine for PROTOCOL. */
|
/* Get the version number of the engine for PROTOCOL. */
|
||||||
const char *_gpgme_engine_get_version (GpgmeProtocol proto);
|
const char *_gpgme_engine_get_version (GpgmeProtocol proto);
|
||||||
|
|
||||||
|
/* Get the version number of the engine for PROTOCOL. */
|
||||||
|
const char *_gpgme_engine_req_version (GpgmeProtocol proto);
|
||||||
|
|
||||||
/* Verify the version requirement for the engine for PROTOCOL. */
|
/* Verify the version requirement for the engine for PROTOCOL. */
|
||||||
const char *_gpgme_engine_get_info (GpgmeProtocol proto);
|
const char *_gpgme_engine_get_info (GpgmeProtocol proto);
|
||||||
|
|
||||||
|
@ -209,8 +209,6 @@ gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol protocol)
|
|||||||
case GPGME_PROTOCOL_CMS:
|
case GPGME_PROTOCOL_CMS:
|
||||||
ctx->use_cms = 1;
|
ctx->use_cms = 1;
|
||||||
break;
|
break;
|
||||||
case GPGME_PROTOCOL_AUTO:
|
|
||||||
return GPGME_Not_Implemented;
|
|
||||||
default:
|
default:
|
||||||
return GPGME_Invalid_Value;
|
return GPGME_Invalid_Value;
|
||||||
}
|
}
|
||||||
@ -229,6 +227,22 @@ gpgme_get_protocol (GpgmeCtx ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gpgme_get_protocol_name (GpgmeProtocol protocol)
|
||||||
|
{
|
||||||
|
switch (protocol)
|
||||||
|
{
|
||||||
|
case GPGME_PROTOCOL_OpenPGP:
|
||||||
|
return "OpenPGP";
|
||||||
|
|
||||||
|
case GPGME_PROTOCOL_CMS:
|
||||||
|
return "CMS";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gpgme_set_armor:
|
* gpgme_set_armor:
|
||||||
* @ctx: the context
|
* @ctx: the context
|
||||||
|
@ -218,7 +218,6 @@ typedef enum
|
|||||||
{
|
{
|
||||||
GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
|
GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
|
||||||
GPGME_PROTOCOL_CMS = 1,
|
GPGME_PROTOCOL_CMS = 1,
|
||||||
GPGME_PROTOCOL_AUTO = 2
|
|
||||||
}
|
}
|
||||||
GpgmeProtocol;
|
GpgmeProtocol;
|
||||||
|
|
||||||
@ -312,6 +311,26 @@ typedef enum {
|
|||||||
#define GPGME_KEYLIST_MODE_EXTERN 2
|
#define GPGME_KEYLIST_MODE_EXTERN 2
|
||||||
#define GPGME_KEYLIST_MODE_SIGS 4
|
#define GPGME_KEYLIST_MODE_SIGS 4
|
||||||
|
|
||||||
|
/* The engine information structure. */
|
||||||
|
struct _gpgme_engine_info
|
||||||
|
{
|
||||||
|
struct _gpgme_engine_info *next;
|
||||||
|
|
||||||
|
/* The protocol ID. */
|
||||||
|
GpgmeProtocol protocol;
|
||||||
|
|
||||||
|
/* The path to the engine binary. */
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
/* The version string of the installed engine. */
|
||||||
|
const char *version;
|
||||||
|
|
||||||
|
/* The minimum version required for GPGME. */
|
||||||
|
const char *req_version;
|
||||||
|
};
|
||||||
|
typedef struct _gpgme_engine_info *GpgmeEngineInfo;
|
||||||
|
|
||||||
|
|
||||||
/* Types for callback functions. */
|
/* Types for callback functions. */
|
||||||
|
|
||||||
/* Request a passphrase from the user. */
|
/* Request a passphrase from the user. */
|
||||||
@ -343,6 +362,9 @@ GpgmeError gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol proto);
|
|||||||
/* Get the protocol used with CTX */
|
/* Get the protocol used with CTX */
|
||||||
GpgmeProtocol gpgme_get_protocol (GpgmeCtx ctx);
|
GpgmeProtocol gpgme_get_protocol (GpgmeCtx ctx);
|
||||||
|
|
||||||
|
/* Get the string describing protocol PROTO, or NULL if invalid. */
|
||||||
|
const char *gpgme_get_protocol_name (GpgmeProtocol proto);
|
||||||
|
|
||||||
/* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
|
/* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
|
||||||
void gpgme_set_armor (GpgmeCtx ctx, int yes);
|
void gpgme_set_armor (GpgmeCtx ctx, int yes);
|
||||||
|
|
||||||
@ -798,7 +820,7 @@ GpgmeError gpgme_op_trustlist_end (GpgmeCtx ctx);
|
|||||||
const char *gpgme_check_version (const char *req_version);
|
const char *gpgme_check_version (const char *req_version);
|
||||||
|
|
||||||
/* Retrieve information about the backend engines. */
|
/* Retrieve information about the backend engines. */
|
||||||
const char *gpgme_get_engine_info (void);
|
GpgmeError gpgme_get_engine_info (GpgmeEngineInfo *engine_info);
|
||||||
|
|
||||||
/* Return a string describing ERR. */
|
/* Return a string describing ERR. */
|
||||||
const char *gpgme_strerror (GpgmeError err);
|
const char *gpgme_strerror (GpgmeError err);
|
||||||
|
@ -248,11 +248,10 @@ gpg_get_version (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GpgmeError
|
static const char *
|
||||||
gpg_check_version (void)
|
gpg_get_req_version (void)
|
||||||
{
|
{
|
||||||
return _gpgme_compare_versions (gpg_get_version (), NEED_GPG_VERSION)
|
return NEED_GPG_VERSION;
|
||||||
? 0 : GPGME_Invalid_Engine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1646,7 +1645,7 @@ struct engine_ops _gpgme_engine_ops_gpg =
|
|||||||
/* Static functions. */
|
/* Static functions. */
|
||||||
_gpgme_get_gpg_path,
|
_gpgme_get_gpg_path,
|
||||||
gpg_get_version,
|
gpg_get_version,
|
||||||
gpg_check_version,
|
gpg_get_req_version,
|
||||||
gpg_new,
|
gpg_new,
|
||||||
|
|
||||||
/* Member functions. */
|
/* Member functions. */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* version.c - version check
|
/* version.c - version check
|
||||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
Copyright (C) 2001, 2002 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||||
|
|
||||||
This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
|
|
||||||
@ -134,65 +134,57 @@ gpgme_check_version (const char *req_version)
|
|||||||
return _gpgme_compare_versions (VERSION, req_version);
|
return _gpgme_compare_versions (VERSION, req_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gpgme_get_engine_info:
|
/* Get the information about the configured and installed engines. A
|
||||||
*
|
pointer to the first engine in the statically allocated linked list
|
||||||
* Return information about the underlying crypto engines. This is an
|
is returned in *INFO. If an error occurs, it is returned. */
|
||||||
* XML string with various information. A string is always returned
|
GpgmeError
|
||||||
* even if the crypto engines is not installed; in this case a XML
|
gpgme_get_engine_info (GpgmeEngineInfo *info)
|
||||||
* string with some error information is returned.
|
|
||||||
*
|
|
||||||
* Return value: A XML string with information about the crypto
|
|
||||||
* engines.
|
|
||||||
**/
|
|
||||||
const char *
|
|
||||||
gpgme_get_engine_info ()
|
|
||||||
{
|
{
|
||||||
static const char *engine_info;
|
static GpgmeEngineInfo engine_info;
|
||||||
DEFINE_STATIC_LOCK (engine_info_lock);
|
DEFINE_STATIC_LOCK (engine_info_lock);
|
||||||
|
|
||||||
LOCK (engine_info_lock);
|
LOCK (engine_info_lock);
|
||||||
if (!engine_info)
|
if (!engine_info)
|
||||||
{
|
{
|
||||||
const char *openpgp_info = _gpgme_engine_get_info (GPGME_PROTOCOL_OpenPGP);
|
GpgmeEngineInfo *lastp = &engine_info;
|
||||||
const char *cms_info = _gpgme_engine_get_info (GPGME_PROTOCOL_CMS);
|
GpgmeProtocol proto_list[] = { GPGME_PROTOCOL_OpenPGP,
|
||||||
char *info;
|
GPGME_PROTOCOL_CMS };
|
||||||
|
int proto;
|
||||||
|
|
||||||
if (!openpgp_info && !cms_info)
|
for (proto = 0; proto < DIM (proto_list); proto++)
|
||||||
info = "<EngineInfo>\n</EngineInfo>\n";
|
|
||||||
else if (!openpgp_info || !cms_info)
|
|
||||||
{
|
{
|
||||||
const char *fmt = "<EngineInfo>\n"
|
const char *path = _gpgme_engine_get_path (proto_list[proto]);
|
||||||
"%s"
|
|
||||||
"</EngineInfo>\n";
|
|
||||||
|
|
||||||
info = malloc (strlen (fmt)
|
if (!path)
|
||||||
+ strlen (openpgp_info
|
continue;
|
||||||
? openpgp_info : cms_info) + 1);
|
|
||||||
if (info)
|
*lastp = malloc (sizeof (*engine_info));
|
||||||
sprintf (info, fmt, openpgp_info ? openpgp_info : cms_info);
|
if (!*lastp)
|
||||||
|
{
|
||||||
|
while (engine_info)
|
||||||
|
{
|
||||||
|
GpgmeEngineInfo next_info = engine_info->next;
|
||||||
|
free (engine_info);
|
||||||
|
engine_info = next_info;
|
||||||
|
}
|
||||||
|
UNLOCK (engine_info_lock);
|
||||||
|
return GPGME_Out_Of_Core;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*lastp)->protocol = proto_list[proto];
|
||||||
|
(*lastp)->path = path;
|
||||||
|
(*lastp)->version = _gpgme_engine_get_version (proto_list[proto]);
|
||||||
|
(*lastp)->req_version
|
||||||
|
= _gpgme_engine_get_req_version (proto_list[proto]);
|
||||||
|
lastp = &(*lastp)->next;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
const char *fmt = "<EngineInfo>\n"
|
|
||||||
"%s%s"
|
|
||||||
"</EngineInfo>\n";
|
|
||||||
info = malloc (strlen (fmt) + strlen (openpgp_info)
|
|
||||||
+ strlen (cms_info) + 1);
|
|
||||||
if (info)
|
|
||||||
sprintf (info, fmt, openpgp_info, cms_info);
|
|
||||||
}
|
|
||||||
if (!info)
|
|
||||||
info = "<EngineInfo>\n"
|
|
||||||
" <error>Out of core</error>\n"
|
|
||||||
"</EngineInfo>\n";
|
|
||||||
engine_info = info;
|
|
||||||
}
|
}
|
||||||
UNLOCK (engine_info_lock);
|
UNLOCK (engine_info_lock);
|
||||||
return engine_info;
|
*info = engine_info;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define LINELENGTH 80
|
#define LINELENGTH 80
|
||||||
|
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* Makefile.am (TESTS): Add t-engine-info.
|
||||||
|
* t-engine-info.c: New file.
|
||||||
|
* gpg/t-encrypt.c (main): Don't print engine info.
|
||||||
|
* gpg/t-eventloop.c (main): Likewise.
|
||||||
|
* gpg/t-encrypt-sign.c (main): Likewise.
|
||||||
|
* gpgsm/t-encrypt.c (main): Likewise.
|
||||||
|
|
||||||
2002-12-24 Marcus Brinkmann <marcus@g10code.de>
|
2002-12-24 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* gpgsm/t-verify.c (main): Adjust caller of gpgme_op_verify.
|
* gpgsm/t-verify.c (main): Adjust caller of gpgme_op_verify.
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
TESTS_ENVIRONMENT = GNUPGHOME=.
|
TESTS_ENVIRONMENT = GNUPGHOME=.
|
||||||
|
|
||||||
TESTS = t-version t-data
|
TESTS = t-version t-data t-engine-info
|
||||||
|
|
||||||
EXTRA_DIST = t-data-1.txt t-data-2.txt
|
EXTRA_DIST = t-data-1.txt t-data-2.txt
|
||||||
|
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
/* t-encrypt-sign.c - regression test
|
/* t-encrypt-sign.c - regression test
|
||||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||||
*
|
|
||||||
* This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
*
|
|
||||||
* GPGME is free software; you can redistribute it and/or modify
|
GPGME is free software; you can redistribute it and/or modify it
|
||||||
* it under the terms of the GNU General Public License as published by
|
under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
(at your option) any later version.
|
||||||
*
|
|
||||||
* GPGME is distributed in the hope that it will be useful,
|
GPGME is distributed in the hope that it will be useful, but
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
General Public License for more details.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
along with GPGME; if not, write to the Free Software Foundation,
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -94,7 +93,6 @@ main (int argc, char **argv )
|
|||||||
|
|
||||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
puts ( gpgme_get_engine_info() );
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
err = gpgme_new (&ctx);
|
err = gpgme_new (&ctx);
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
/* t-encrypt.c - regression test
|
/* t-encrypt.c - regression test
|
||||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
* Copyright (C) 2001 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||||
*
|
|
||||||
* This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
*
|
|
||||||
* GPGME is free software; you can redistribute it and/or modify
|
GPGME is free software; you can redistribute it and/or modify it
|
||||||
* it under the terms of the GNU General Public License as published by
|
under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
(at your option) any later version.
|
||||||
*
|
|
||||||
* GPGME is distributed in the hope that it will be useful,
|
GPGME is distributed in the hope that it will be useful, but
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
General Public License for more details.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
along with GPGME; if not, write to the Free Software Foundation,
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -74,7 +73,6 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
puts ( gpgme_get_engine_info() );
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
err = gpgme_new (&ctx);
|
err = gpgme_new (&ctx);
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
/* t-eventloop.c - regression test
|
/* t-eventloop.c - regression test
|
||||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
* Copyright (C) 2001, 2002 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||||
*
|
|
||||||
* This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
*
|
|
||||||
* GPGME is free software; you can redistribute it and/or modify
|
GPGME is free software; you can redistribute it and/or modify it
|
||||||
* it under the terms of the GNU General Public License as published by
|
under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
(at your option) any later version.
|
||||||
*
|
|
||||||
* GPGME is distributed in the hope that it will be useful,
|
GPGME is distributed in the hope that it will be useful, but
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
General Public License for more details.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
along with GPGME; if not, write to the Free Software Foundation,
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -205,7 +204,6 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
puts (gpgme_get_engine_info ());
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
/* t-encrypt.c - regression test
|
/* t-encrypt.c - regression test
|
||||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
* Copyright (C) 2001 g10 Code GmbH
|
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||||
*
|
|
||||||
* This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
*
|
|
||||||
* GPGME is free software; you can redistribute it and/or modify
|
GPGME is free software; you can redistribute it and/or modify it
|
||||||
* it under the terms of the GNU General Public License as published by
|
under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
(at your option) any later version.
|
||||||
*
|
|
||||||
* GPGME is distributed in the hope that it will be useful,
|
GPGME is distributed in the hope that it will be useful, but
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* GNU General Public License for more details.
|
General Public License for more details.
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
along with GPGME; if not, write to the Free Software Foundation,
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -92,7 +91,6 @@ main (int argc, char **argv )
|
|||||||
|
|
||||||
err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS);
|
err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS);
|
||||||
fail_if_err (err);
|
fail_if_err (err);
|
||||||
puts ( gpgme_get_engine_info() );
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
err = gpgme_new (&ctx);
|
err = gpgme_new (&ctx);
|
||||||
|
92
tests/t-engine-info.c
Normal file
92
tests/t-engine-info.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* t-engine-info.c - Regression test for gpgme_get_engine_info.
|
||||||
|
Copyright (C) 2003 g10 Code GmbH
|
||||||
|
|
||||||
|
This file is part of GPGME.
|
||||||
|
|
||||||
|
GPGME is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
GPGME is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with GPGME; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gpgme.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define fail_if_err(err) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (err) \
|
||||||
|
{ \
|
||||||
|
fprintf (stderr, "%s:%d: GpgmeError %s\n", \
|
||||||
|
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||||
|
exit (1); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
check_engine_info (GpgmeEngineInfo info, GpgmeProtocol protocol,
|
||||||
|
const char *path, const char *req_version)
|
||||||
|
{
|
||||||
|
if (info->protocol != protocol)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Unexpected protocol %i (expected %i instead)\n",
|
||||||
|
info->protocol, protocol);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
if (strcmp (info->path, path))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Unexpected path to executable %s (expected %s instead)",
|
||||||
|
info->path, path);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
if (strcmp (info->req_version, req_version))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Unexpected required version %s (expected %s instead)",
|
||||||
|
info->req_version, req_version);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv )
|
||||||
|
{
|
||||||
|
GpgmeEngineInfo info;
|
||||||
|
GpgmeError err;
|
||||||
|
|
||||||
|
err = gpgme_get_engine_info (&info);
|
||||||
|
fail_if_err (err);
|
||||||
|
|
||||||
|
check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION);
|
||||||
|
|
||||||
|
info = info->next;
|
||||||
|
#ifdef GPGSM_PATH
|
||||||
|
check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION);
|
||||||
|
#else
|
||||||
|
if (info)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Unexpected engine info.\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user