Reanmed public functions
This commit is contained in:
parent
f14941f072
commit
e047a8a263
@ -77,13 +77,15 @@ struct gpgme_data_s {
|
||||
char *private_buffer;
|
||||
};
|
||||
|
||||
struct recipient_s {
|
||||
struct recipient_s *next;
|
||||
struct user_id_s {
|
||||
struct user_id_s *next;
|
||||
int validity; /* 0 = undefined, 1 = not, 2 = marginal,
|
||||
3 = full, 4 = ultimate */
|
||||
char name[1];
|
||||
};
|
||||
|
||||
struct gpgme_recipient_set_s {
|
||||
struct recipient_s *list;
|
||||
struct gpgme_recipients_s {
|
||||
struct user_id_s *list;
|
||||
int checked; /* wether the recipients are all valid */
|
||||
};
|
||||
|
||||
|
20
gpgme/data.c
20
gpgme/data.c
@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* gpgme_new_data:
|
||||
* gpgme_data_new:
|
||||
* @r_dh: Returns a new data object.
|
||||
* @buffer: If not NULL, used to initialize the data object.
|
||||
* @size: Size of the buffer
|
||||
@ -46,7 +46,7 @@
|
||||
* Return value:
|
||||
**/
|
||||
GpgmeError
|
||||
gpgme_new_data ( GpgmeData *r_dh, const char *buffer, size_t size, int copy )
|
||||
gpgme_data_new ( GpgmeData *r_dh, const char *buffer, size_t size, int copy )
|
||||
{
|
||||
GpgmeData dh;
|
||||
|
||||
@ -78,14 +78,14 @@ gpgme_new_data ( GpgmeData *r_dh, const char *buffer, size_t size, int copy )
|
||||
}
|
||||
|
||||
/**
|
||||
* gpgme_release_data:
|
||||
* gpgme_data_release:
|
||||
* @dh: Data object
|
||||
*
|
||||
* Release the data object @dh. @dh may be NULL in which case nothing
|
||||
* happens.
|
||||
**/
|
||||
void
|
||||
gpgme_release_data ( GpgmeData dh )
|
||||
gpgme_data_release ( GpgmeData dh )
|
||||
{
|
||||
if (dh) {
|
||||
xfree (dh->private_buffer);
|
||||
@ -95,7 +95,7 @@ gpgme_release_data ( GpgmeData dh )
|
||||
|
||||
|
||||
GpgmeDataType
|
||||
gpgme_query_data_type ( GpgmeData dh )
|
||||
gpgme_data_get_type ( GpgmeData dh )
|
||||
{
|
||||
if ( !dh || !dh->data )
|
||||
return GPGME_DATA_TYPE_NONE;
|
||||
@ -104,7 +104,7 @@ gpgme_query_data_type ( GpgmeData dh )
|
||||
}
|
||||
|
||||
void
|
||||
_gpgme_set_data_mode ( GpgmeData dh, GpgmeDataMode mode )
|
||||
_gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode )
|
||||
{
|
||||
assert (dh);
|
||||
dh->mode = mode;
|
||||
@ -112,14 +112,14 @@ _gpgme_set_data_mode ( GpgmeData dh, GpgmeDataMode mode )
|
||||
|
||||
|
||||
GpgmeDataMode
|
||||
_gpgme_query_data_mode ( GpgmeData dh )
|
||||
_gpgme_data_get_mode ( GpgmeData dh )
|
||||
{
|
||||
assert (dh);
|
||||
return dh->mode;
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
gpgme_rewind_data ( GpgmeData dh )
|
||||
gpgme_data_rewind ( GpgmeData dh )
|
||||
{
|
||||
if ( !dh )
|
||||
return mk_error (Invalid_Value);
|
||||
@ -130,7 +130,7 @@ gpgme_rewind_data ( GpgmeData dh )
|
||||
}
|
||||
|
||||
GpgmeError
|
||||
gpgme_read_data ( GpgmeData dh, char *buffer, size_t length, size_t *nread )
|
||||
gpgme_data_read ( GpgmeData dh, char *buffer, size_t length, size_t *nread )
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
@ -151,7 +151,7 @@ gpgme_read_data ( GpgmeData dh, char *buffer, size_t length, size_t *nread )
|
||||
|
||||
|
||||
GpgmeError
|
||||
_gpgme_append_data ( GpgmeData dh, const char *buffer, size_t length )
|
||||
_gpgme_data_append ( GpgmeData dh, const char *buffer, size_t length )
|
||||
{
|
||||
assert (dh);
|
||||
|
||||
|
@ -39,8 +39,8 @@ encrypt_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||
|
||||
|
||||
GpgmeError
|
||||
gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
GpgmeData plain, GpgmeData ciph )
|
||||
gpgme_op_encrypt_start ( GpgmeCtx c, GpgmeRecipients recp,
|
||||
GpgmeData plain, GpgmeData ciph )
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
@ -50,14 +50,14 @@ gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
|
||||
/* do some checks */
|
||||
assert ( !c->gpg );
|
||||
if ( !gpgme_count_recipients ( recp ) ) {
|
||||
if ( !gpgme_recipients_count ( recp ) ) {
|
||||
/* Fixme: In this case we should do symmentric encryption */
|
||||
rc = mk_error (No_Recipients);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* create a process object */
|
||||
rc = _gpgme_gpg_new_object ( &c->gpg );
|
||||
rc = _gpgme_gpg_new ( &c->gpg );
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
||||
@ -73,16 +73,16 @@ gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
_gpgme_append_gpg_args_from_recipients ( recp, c->gpg );
|
||||
|
||||
/* Check the supplied data */
|
||||
if ( gpgme_query_data_type (plain) == GPGME_DATA_TYPE_NONE ) {
|
||||
if ( gpgme_data_get_type (plain) == GPGME_DATA_TYPE_NONE ) {
|
||||
rc = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_set_data_mode (plain, GPGME_DATA_MODE_OUT );
|
||||
if ( !ciph || gpgme_query_data_type (ciph) != GPGME_DATA_TYPE_NONE ) {
|
||||
_gpgme_data_set_mode (plain, GPGME_DATA_MODE_OUT );
|
||||
if ( !ciph || gpgme_data_get_type (ciph) != GPGME_DATA_TYPE_NONE ) {
|
||||
rc = mk_error (Invalid_Value);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_set_data_mode (ciph, GPGME_DATA_MODE_IN );
|
||||
_gpgme_data_set_mode (ciph, GPGME_DATA_MODE_IN );
|
||||
/* Tell the gpg object about the data */
|
||||
_gpgme_gpg_add_arg ( c->gpg, "--output" );
|
||||
_gpgme_gpg_add_arg ( c->gpg, "-" );
|
||||
@ -96,14 +96,14 @@ gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
leave:
|
||||
if (rc) {
|
||||
c->pending = 0;
|
||||
_gpgme_gpg_release_object ( c->gpg ); c->gpg = NULL;
|
||||
_gpgme_gpg_release ( c->gpg ); c->gpg = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gpgme_encrypt:
|
||||
* gpgme_op_encrypt:
|
||||
* @c: The context
|
||||
* @recp: A set of recipients
|
||||
* @in: plaintext input
|
||||
@ -116,10 +116,10 @@ gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
* Return value: 0 on success or an errorcode.
|
||||
**/
|
||||
GpgmeError
|
||||
gpgme_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
GpgmeData in, GpgmeData out )
|
||||
gpgme_op_encrypt ( GpgmeCtx c, GpgmeRecipients recp,
|
||||
GpgmeData in, GpgmeData out )
|
||||
{
|
||||
int rc = gpgme_start_encrypt ( c, recp, in, out );
|
||||
int rc = gpgme_op_encrypt_start ( c, recp, in, out );
|
||||
if ( !rc ) {
|
||||
gpgme_wait (c, 1);
|
||||
c->pending = 0;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "ops.h"
|
||||
|
||||
/**
|
||||
* gpgme_new_context:
|
||||
* gpgme_new:
|
||||
* @r_ctx: Returns the new context
|
||||
*
|
||||
* Create a new context to be used with most of the other GPGME
|
||||
@ -36,7 +36,7 @@
|
||||
* Return value: An error code
|
||||
**/
|
||||
GpgmeError
|
||||
gpgme_new_context (GpgmeCtx *r_ctx)
|
||||
gpgme_new (GpgmeCtx *r_ctx)
|
||||
{
|
||||
GpgmeCtx c;
|
||||
|
||||
@ -50,16 +50,16 @@ gpgme_new_context (GpgmeCtx *r_ctx)
|
||||
}
|
||||
|
||||
/**
|
||||
* gpgme_release_contect:
|
||||
* gpgme_release:
|
||||
* @c: Context to be released.
|
||||
*
|
||||
* Release all resources associated with the given context.
|
||||
**/
|
||||
void
|
||||
gpgme_release_context ( GpgmeCtx c )
|
||||
gpgme_release ( GpgmeCtx c )
|
||||
{
|
||||
|
||||
_gpgme_gpg_release_object ( c->gpg );
|
||||
_gpgme_gpg_release ( c->gpg );
|
||||
_gpgme_release_result ( c );
|
||||
_gpgme_key_release ( c->tmp_key );
|
||||
/* fixme: release the key_queue */
|
||||
@ -92,15 +92,6 @@ _gpgme_release_result ( GpgmeCtx c )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -33,8 +33,8 @@ typedef struct gpgme_context_s *GpgmeCtx;
|
||||
struct gpgme_data_s;
|
||||
typedef struct gpgme_data_s *GpgmeData;
|
||||
|
||||
struct gpgme_recipient_set_s;
|
||||
typedef struct gpgme_recipient_set_s *GpgmeRecipientSet;
|
||||
struct gpgme_recipients_s;
|
||||
typedef struct gpgme_recipients_s *GpgmeRecipients;
|
||||
|
||||
struct gpgme_key_s;
|
||||
typedef struct gpgme_key_s *GpgmeKey;
|
||||
@ -70,47 +70,45 @@ typedef enum {
|
||||
|
||||
|
||||
/* Context management */
|
||||
GpgmeError gpgme_new_context (GpgmeCtx *r_ctx);
|
||||
void gpgme_release_context ( GpgmeCtx c );
|
||||
GpgmeError gpgme_new (GpgmeCtx *r_ctx);
|
||||
void gpgme_release ( GpgmeCtx c );
|
||||
GpgmeCtx gpgme_wait ( GpgmeCtx c, int hang );
|
||||
|
||||
/* Functions to handle recipients */
|
||||
GpgmeError gpgme_new_recipient_set (GpgmeRecipientSet *r_rset);
|
||||
void gpgme_release_recipient_set ( GpgmeRecipientSet rset);
|
||||
GpgmeError gpgme_add_recipient (GpgmeRecipientSet rset, const char *name);
|
||||
unsigned int gpgme_count_recipients ( const GpgmeRecipientSet rset );
|
||||
GpgmeError gpgme_recipients_new (GpgmeRecipients *r_rset);
|
||||
void gpgme_recipients_release ( GpgmeRecipients rset);
|
||||
GpgmeError gpgme_recipients_add_name (GpgmeRecipients rset,
|
||||
const char *name);
|
||||
unsigned int gpgme_recipients_count ( const GpgmeRecipients rset );
|
||||
|
||||
/* Functions to handle data sources */
|
||||
GpgmeError gpgme_new_data ( GpgmeData *r_dh,
|
||||
const char *buffer, size_t size, int copy );
|
||||
void gpgme_release_data ( GpgmeData dh );
|
||||
GpgmeDataType gpgme_query_data_type ( GpgmeData dh );
|
||||
GpgmeError gpgme_rewind_data ( GpgmeData dh );
|
||||
GpgmeError gpgme_read_data ( GpgmeData dh,
|
||||
char *buffer, size_t length, size_t *nread );
|
||||
GpgmeError gpgme_data_new ( GpgmeData *r_dh,
|
||||
const char *buffer, size_t size, int copy );
|
||||
void gpgme_data_release ( GpgmeData dh );
|
||||
GpgmeDataType gpgme_data_get_type ( GpgmeData dh );
|
||||
GpgmeError gpgme_data_rewind ( GpgmeData dh );
|
||||
GpgmeError gpgme_data_read ( GpgmeData dh,
|
||||
char *buffer, size_t length, size_t *nread );
|
||||
|
||||
|
||||
|
||||
/* Basic GnuPG functions */
|
||||
GpgmeError gpgme_start_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
GpgmeData in, GpgmeData out );
|
||||
GpgmeError gpgme_start_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text );
|
||||
GpgmeError gpgme_op_encrypt_start ( GpgmeCtx c, GpgmeRecipients recp,
|
||||
GpgmeData in, GpgmeData out );
|
||||
GpgmeError gpgme_op_verify_start ( GpgmeCtx c,
|
||||
GpgmeData sig, GpgmeData text );
|
||||
|
||||
|
||||
/* Key management functions */
|
||||
GpgmeError gpgme_keylist_start ( GpgmeCtx c,
|
||||
const char *pattern, int secret_only );
|
||||
GpgmeError gpgme_keylist_next ( GpgmeCtx c, GpgmeKey *r_key );
|
||||
|
||||
|
||||
|
||||
|
||||
GpgmeError gpgme_op_keylist_start ( GpgmeCtx c,
|
||||
const char *pattern, int secret_only );
|
||||
GpgmeError gpgme_op_keylist_next ( GpgmeCtx c, GpgmeKey *r_key );
|
||||
|
||||
|
||||
/* Convenience functions for syncronous usage */
|
||||
GpgmeError gpgme_encrypt ( GpgmeCtx c, GpgmeRecipientSet recp,
|
||||
GpgmeData in, GpgmeData out );
|
||||
GpgmeError gpgme_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text );
|
||||
GpgmeError gpgme_op_encrypt ( GpgmeCtx c, GpgmeRecipients recp,
|
||||
GpgmeData in, GpgmeData out );
|
||||
GpgmeError gpgme_op_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text );
|
||||
|
||||
|
||||
/* miscellaneous functions */
|
||||
|
@ -23,13 +23,8 @@
|
||||
|
||||
#include <time.h>
|
||||
#include "types.h"
|
||||
#include "context.h"
|
||||
|
||||
struct user_id_s {
|
||||
struct user_id_s *next;
|
||||
int validity; /* 0 = undefined, 1 = not, 2 = marginal,
|
||||
3 = full, 4 = ultimate */
|
||||
char name[1];
|
||||
};
|
||||
|
||||
struct gpgme_key_s {
|
||||
struct {
|
||||
|
@ -287,7 +287,7 @@ finish_key ( GpgmeCtx ctx )
|
||||
|
||||
|
||||
GpgmeError
|
||||
gpgme_keylist_start ( GpgmeCtx c, const char *pattern, int secret_only )
|
||||
gpgme_op_keylist_start ( GpgmeCtx c, const char *pattern, int secret_only )
|
||||
{
|
||||
GpgmeError rc = 0;
|
||||
int i;
|
||||
@ -299,14 +299,14 @@ gpgme_keylist_start ( GpgmeCtx c, const char *pattern, int secret_only )
|
||||
c->out_of_core = 0;
|
||||
|
||||
if ( c->gpg ) {
|
||||
_gpgme_gpg_release_object ( c->gpg );
|
||||
_gpgme_gpg_release ( c->gpg );
|
||||
c->gpg = NULL;
|
||||
}
|
||||
_gpgme_key_release (c->tmp_key);
|
||||
c->tmp_key = NULL;
|
||||
/* Fixme: release key_queue */
|
||||
|
||||
rc = _gpgme_gpg_new_object ( &c->gpg );
|
||||
rc = _gpgme_gpg_new ( &c->gpg );
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
||||
@ -336,14 +336,14 @@ gpgme_keylist_start ( GpgmeCtx c, const char *pattern, int secret_only )
|
||||
leave:
|
||||
if (rc) {
|
||||
c->pending = 0;
|
||||
_gpgme_gpg_release_object ( c->gpg ); c->gpg = NULL;
|
||||
_gpgme_gpg_release ( c->gpg ); c->gpg = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
GpgmeError
|
||||
gpgme_keylist_next ( GpgmeCtx c, GpgmeKey *r_key )
|
||||
gpgme_op_keylist_next ( GpgmeCtx c, GpgmeKey *r_key )
|
||||
{
|
||||
struct key_queue_item_s *q;
|
||||
|
||||
|
@ -33,14 +33,14 @@ GpgmeCtx _gpgme_wait_on_condition ( GpgmeCtx c,
|
||||
|
||||
/*-- recipient.c --*/
|
||||
void _gpgme_append_gpg_args_from_recipients (
|
||||
const GpgmeRecipientSet rset,
|
||||
const GpgmeRecipients rset,
|
||||
GpgObject gpg );
|
||||
|
||||
|
||||
/*-- data.c --*/
|
||||
GpgmeDataMode _gpgme_query_data_mode ( GpgmeData dh );
|
||||
void _gpgme_set_data_mode ( GpgmeData dh, GpgmeDataMode mode );
|
||||
GpgmeError _gpgme_append_data ( GpgmeData dh,
|
||||
GpgmeDataMode _gpgme_data_get_mode ( GpgmeData dh );
|
||||
void _gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode );
|
||||
GpgmeError _gpgme_data_append ( GpgmeData dh,
|
||||
const char *buffer, size_t length );
|
||||
|
||||
/*-- key.c --*/
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include "rungpg.h"
|
||||
|
||||
GpgmeError
|
||||
gpgme_new_recipient_set (GpgmeRecipientSet *r_rset)
|
||||
gpgme_recipients_new (GpgmeRecipients *r_rset)
|
||||
{
|
||||
GpgmeRecipientSet rset;
|
||||
GpgmeRecipients rset;
|
||||
|
||||
rset = xtrycalloc ( 1, sizeof *rset );
|
||||
if (!rset)
|
||||
@ -40,7 +40,7 @@ gpgme_new_recipient_set (GpgmeRecipientSet *r_rset)
|
||||
}
|
||||
|
||||
void
|
||||
gpgme_release_recipient_set ( GpgmeRecipientSet rset )
|
||||
gpgme_recipients_release ( GpgmeRecipients rset )
|
||||
{
|
||||
/* fixme: release the linked list */
|
||||
xfree ( rset );
|
||||
@ -48,9 +48,9 @@ gpgme_release_recipient_set ( GpgmeRecipientSet rset )
|
||||
|
||||
|
||||
GpgmeError
|
||||
gpgme_add_recipient (GpgmeRecipientSet rset, const char *name )
|
||||
gpgme_recipients_add_name (GpgmeRecipients rset, const char *name )
|
||||
{
|
||||
struct recipient_s *r;
|
||||
struct user_id_s *r;
|
||||
|
||||
if (!name || !rset )
|
||||
return mk_error (Invalid_Value);
|
||||
@ -64,9 +64,9 @@ gpgme_add_recipient (GpgmeRecipientSet rset, const char *name )
|
||||
}
|
||||
|
||||
unsigned int
|
||||
gpgme_count_recipients ( const GpgmeRecipientSet rset )
|
||||
gpgme_recipients_count ( const GpgmeRecipients rset )
|
||||
{
|
||||
struct recipient_s *r;
|
||||
struct user_id_s *r;
|
||||
unsigned int count = 0;
|
||||
|
||||
if ( rset ) {
|
||||
@ -79,10 +79,10 @@ gpgme_count_recipients ( const GpgmeRecipientSet rset )
|
||||
|
||||
void
|
||||
_gpgme_append_gpg_args_from_recipients (
|
||||
const GpgmeRecipientSet rset,
|
||||
const GpgmeRecipients rset,
|
||||
GpgObject gpg )
|
||||
{
|
||||
struct recipient_s *r;
|
||||
struct user_id_s *r;
|
||||
|
||||
assert (rset);
|
||||
for (r=rset->list ; r; r = r->next ) {
|
||||
@ -92,8 +92,3 @@ _gpgme_append_gpg_args_from_recipients (
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ static GpgmeError read_colon_line ( GpgObject gpg );
|
||||
|
||||
|
||||
GpgmeError
|
||||
_gpgme_gpg_new_object ( GpgObject *r_gpg )
|
||||
_gpgme_gpg_new ( GpgObject *r_gpg )
|
||||
{
|
||||
GpgObject gpg;
|
||||
int rc = 0;
|
||||
@ -153,7 +153,7 @@ _gpgme_gpg_new_object ( GpgObject *r_gpg )
|
||||
|
||||
leave:
|
||||
if (rc) {
|
||||
_gpgme_gpg_release_object (gpg);
|
||||
_gpgme_gpg_release (gpg);
|
||||
*r_gpg = NULL;
|
||||
}
|
||||
else
|
||||
@ -162,7 +162,7 @@ _gpgme_gpg_new_object ( GpgObject *r_gpg )
|
||||
}
|
||||
|
||||
void
|
||||
_gpgme_gpg_release_object ( GpgObject gpg )
|
||||
_gpgme_gpg_release ( GpgObject gpg )
|
||||
{
|
||||
if ( !gpg )
|
||||
return;
|
||||
@ -366,7 +366,7 @@ build_argv ( GpgObject gpg )
|
||||
}
|
||||
for ( a=gpg->arglist; a; a = a->next ) {
|
||||
if ( a->data ) {
|
||||
switch ( _gpgme_query_data_mode (a->data) ) {
|
||||
switch ( _gpgme_data_get_mode (a->data) ) {
|
||||
case GPGME_DATA_MODE_NONE:
|
||||
case GPGME_DATA_MODE_INOUT:
|
||||
xfree (fd_data_map);
|
||||
@ -382,7 +382,7 @@ build_argv ( GpgObject gpg )
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( gpgme_query_data_type (a->data) ) {
|
||||
switch ( gpgme_data_get_type (a->data) ) {
|
||||
case GPGME_DATA_TYPE_NONE:
|
||||
if ( fd_data_map[datac].inbound )
|
||||
break; /* allowed */
|
||||
@ -596,7 +596,7 @@ gpg_inbound_handler ( void *opaque, pid_t pid, int fd )
|
||||
int nread;
|
||||
char buf[200];
|
||||
|
||||
assert ( _gpgme_query_data_mode (dh) == GPGME_DATA_MODE_IN );
|
||||
assert ( _gpgme_data_get_mode (dh) == GPGME_DATA_MODE_IN );
|
||||
|
||||
do {
|
||||
nread = read (fd, buf, 200 );
|
||||
@ -614,7 +614,7 @@ gpg_inbound_handler ( void *opaque, pid_t pid, int fd )
|
||||
* the read function or provides a memory area for writing to it.
|
||||
*/
|
||||
|
||||
err = _gpgme_append_data ( dh, buf, nread );
|
||||
err = _gpgme_data_append ( dh, buf, nread );
|
||||
if ( err ) {
|
||||
fprintf (stderr, "_gpgme_append_data failed: %s\n",
|
||||
gpgme_strerror(err));
|
||||
@ -659,8 +659,8 @@ gpg_outbound_handler ( void *opaque, pid_t pid, int fd )
|
||||
{
|
||||
GpgmeData dh = opaque;
|
||||
|
||||
assert ( _gpgme_query_data_mode (dh) == GPGME_DATA_MODE_OUT );
|
||||
switch ( gpgme_query_data_type (dh) ) {
|
||||
assert ( _gpgme_data_get_mode (dh) == GPGME_DATA_MODE_OUT );
|
||||
switch ( gpgme_data_get_type (dh) ) {
|
||||
case GPGME_DATA_TYPE_MEM:
|
||||
if ( write_mem_data ( dh, fd ) )
|
||||
return 1; /* ready */
|
||||
|
@ -84,8 +84,8 @@ typedef enum {
|
||||
typedef void (*GpgStatusHandler)( GpgmeCtx, GpgStatusCode code, char *args );
|
||||
typedef void (*GpgColonLineHandler)( GpgmeCtx, char *line );
|
||||
|
||||
GpgmeError _gpgme_gpg_new_object ( GpgObject *r_gpg );
|
||||
void _gpgme_gpg_release_object ( GpgObject gpg );
|
||||
GpgmeError _gpgme_gpg_new ( GpgObject *r_gpg );
|
||||
void _gpgme_gpg_release ( GpgObject gpg );
|
||||
GpgmeError _gpgme_gpg_add_arg ( GpgObject gpg, const char *arg );
|
||||
GpgmeError _gpgme_gpg_add_data ( GpgObject gpg, GpgmeData data, int dup_to );
|
||||
void _gpgme_gpg_set_status_handler ( GpgObject gpg,
|
||||
|
@ -90,7 +90,7 @@ verify_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
||||
|
||||
|
||||
GpgmeError
|
||||
gpgme_start_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
gpgme_op_verify_start ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
{
|
||||
int rc = 0;
|
||||
int i;
|
||||
@ -106,10 +106,10 @@ gpgme_start_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
* run gpg in the new --pipemode (I started with this but it is
|
||||
* not yet finished) */
|
||||
if ( c->gpg ) {
|
||||
_gpgme_gpg_release_object ( c->gpg );
|
||||
_gpgme_gpg_release ( c->gpg );
|
||||
c->gpg = NULL;
|
||||
}
|
||||
rc = _gpgme_gpg_new_object ( &c->gpg );
|
||||
rc = _gpgme_gpg_new ( &c->gpg );
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
||||
@ -122,17 +122,17 @@ gpgme_start_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
|
||||
|
||||
/* Check the supplied data */
|
||||
if ( gpgme_query_data_type (sig) == GPGME_DATA_TYPE_NONE ) {
|
||||
if ( gpgme_data_get_type (sig) == GPGME_DATA_TYPE_NONE ) {
|
||||
rc = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
if ( text && gpgme_query_data_type (text) == GPGME_DATA_TYPE_NONE ) {
|
||||
if ( text && gpgme_data_get_type (text) == GPGME_DATA_TYPE_NONE ) {
|
||||
rc = mk_error (No_Data);
|
||||
goto leave;
|
||||
}
|
||||
_gpgme_set_data_mode (sig, GPGME_DATA_MODE_OUT );
|
||||
_gpgme_data_set_mode (sig, GPGME_DATA_MODE_OUT );
|
||||
if (text) /* detached signature */
|
||||
_gpgme_set_data_mode (text, GPGME_DATA_MODE_OUT );
|
||||
_gpgme_data_set_mode (text, GPGME_DATA_MODE_OUT );
|
||||
/* Tell the gpg object about the data */
|
||||
_gpgme_gpg_add_arg ( c->gpg, "--" );
|
||||
_gpgme_gpg_add_data ( c->gpg, sig, -1 );
|
||||
@ -145,7 +145,7 @@ gpgme_start_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
leave:
|
||||
if (rc) {
|
||||
c->pending = 0;
|
||||
_gpgme_gpg_release_object ( c->gpg ); c->gpg = NULL;
|
||||
_gpgme_gpg_release ( c->gpg ); c->gpg = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -153,9 +153,9 @@ gpgme_start_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
|
||||
|
||||
GpgmeError
|
||||
gpgme_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
gpgme_op_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text )
|
||||
{
|
||||
int rc = gpgme_start_verify ( c, sig, text );
|
||||
int rc = gpgme_op_verify_start ( c, sig, text );
|
||||
if ( !rc ) {
|
||||
gpgme_wait (c, 1);
|
||||
if ( c->result_type != RESULT_TYPE_VERIFY )
|
||||
|
@ -38,9 +38,9 @@ print_data ( GpgmeData dh )
|
||||
size_t nread;
|
||||
GpgmeError err;
|
||||
|
||||
err = gpgme_rewind_data ( dh );
|
||||
err = gpgme_data_rewind ( dh );
|
||||
fail_if_err (err);
|
||||
while ( !(err = gpgme_read_data ( dh, buf, 100, &nread )) ) {
|
||||
while ( !(err = gpgme_data_read ( dh, buf, 100, &nread )) ) {
|
||||
fwrite ( buf, nread, 1, stdout );
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
@ -55,27 +55,27 @@ main (int argc, char **argv )
|
||||
GpgmeCtx ctx;
|
||||
GpgmeError err;
|
||||
GpgmeData in, out;
|
||||
GpgmeRecipientSet rset;
|
||||
GpgmeRecipients rset;
|
||||
|
||||
do {
|
||||
err = gpgme_new_context (&ctx);
|
||||
err = gpgme_new (&ctx);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_new_data ( &in, "Hallo Leute\n", 12, 0 );
|
||||
err = gpgme_data_new ( &in, "Hallo Leute\n", 12, 0 );
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_new_data ( &out, NULL, 0,0 );
|
||||
err = gpgme_data_new ( &out, NULL, 0,0 );
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_new_recipient_set (&rset);
|
||||
err = gpgme_recipients_new (&rset);
|
||||
fail_if_err (err);
|
||||
err = gpgme_add_recipient (rset, "Bob");
|
||||
err = gpgme_recipients_add_name (rset, "Bob");
|
||||
fail_if_err (err);
|
||||
err = gpgme_add_recipient (rset, "Alpha");
|
||||
err = gpgme_recipients_add_name (rset, "Alpha");
|
||||
fail_if_err (err);
|
||||
|
||||
|
||||
err = gpgme_encrypt (ctx, rset, in, out );
|
||||
err = gpgme_op_encrypt (ctx, rset, in, out );
|
||||
fail_if_err (err);
|
||||
|
||||
fflush (NULL);
|
||||
@ -83,10 +83,10 @@ main (int argc, char **argv )
|
||||
print_data (out);
|
||||
fputs ("End Result.\n", stdout );
|
||||
|
||||
gpgme_release_recipient_set (rset);
|
||||
gpgme_release_data (in);
|
||||
gpgme_release_data (out);
|
||||
gpgme_release_context (ctx);
|
||||
gpgme_recipients_release (rset);
|
||||
gpgme_data_release (in);
|
||||
gpgme_data_release (out);
|
||||
gpgme_release (ctx);
|
||||
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
|
||||
|
||||
return 0;
|
||||
|
@ -37,10 +37,10 @@ doit ( GpgmeCtx ctx, const char *pattern )
|
||||
GpgmeError err;
|
||||
GpgmeKey key;
|
||||
|
||||
err = gpgme_keylist_start (ctx, pattern, 0 );
|
||||
err = gpgme_op_keylist_start (ctx, pattern, 0 );
|
||||
fail_if_err (err);
|
||||
|
||||
while ( !(err = gpgme_keylist_next ( ctx, &key )) ) {
|
||||
while ( !(err = gpgme_op_keylist_next ( ctx, &key )) ) {
|
||||
printf ("Got key object (%p)\n", key );
|
||||
}
|
||||
if ( err != GPGME_EOF )
|
||||
@ -66,12 +66,12 @@ main (int argc, char **argv )
|
||||
}
|
||||
pattern = argc? *argv : NULL;
|
||||
|
||||
err = gpgme_new_context (&ctx);
|
||||
err = gpgme_new (&ctx);
|
||||
fail_if_err (err);
|
||||
do {
|
||||
doit ( ctx, pattern );
|
||||
} while ( loop );
|
||||
gpgme_release_context (ctx);
|
||||
gpgme_release (ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -51,32 +51,32 @@ main (int argc, char **argv )
|
||||
GpgmeError err;
|
||||
GpgmeData sig, text;
|
||||
|
||||
err = gpgme_new_context (&ctx);
|
||||
err = gpgme_new (&ctx);
|
||||
fail_if_err (err);
|
||||
|
||||
do {
|
||||
err = gpgme_new_data ( &text, test_text1, strlen (test_text1), 0 );
|
||||
err = gpgme_data_new ( &text, test_text1, strlen (test_text1), 0 );
|
||||
fail_if_err (err);
|
||||
err = gpgme_new_data ( &sig, test_sig1, strlen (test_sig1), 0 );
|
||||
err = gpgme_data_new ( &sig, test_sig1, strlen (test_sig1), 0 );
|
||||
fail_if_err (err);
|
||||
|
||||
puts ("checking a valid message:\n");
|
||||
err = gpgme_verify (ctx, sig, text );
|
||||
err = gpgme_op_verify (ctx, sig, text );
|
||||
fail_if_err (err);
|
||||
|
||||
puts ("checking a manipulated message:\n");
|
||||
gpgme_release_data (text);
|
||||
err = gpgme_new_data ( &text, test_text1f, strlen (test_text1f), 0 );
|
||||
gpgme_data_release (text);
|
||||
err = gpgme_data_new ( &text, test_text1f, strlen (test_text1f), 0 );
|
||||
fail_if_err (err);
|
||||
gpgme_rewind_data ( sig );
|
||||
err = gpgme_verify (ctx, sig, text );
|
||||
gpgme_data_rewind ( sig );
|
||||
err = gpgme_op_verify (ctx, sig, text );
|
||||
fail_if_err (err);
|
||||
|
||||
gpgme_release_data (sig);
|
||||
gpgme_release_data (text);
|
||||
gpgme_data_release (sig);
|
||||
gpgme_data_release (text);
|
||||
|
||||
} while ( argc > 1 && !strcmp( argv[1], "--loop" ) );
|
||||
gpgme_release_context (ctx);
|
||||
gpgme_release (ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user