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 */
};
/**
- * 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
* 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;
}
/**
- * 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);
GpgmeDataType
-gpgme_query_data_type ( GpgmeData dh )
+gpgme_data_get_type ( GpgmeData dh )
{
if ( !dh || !dh->data )
return GPGME_DATA_TYPE_NONE;
}
void
-_gpgme_set_data_mode ( GpgmeData dh, GpgmeDataMode mode )
+_gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode )
{
assert (dh);
dh->mode = 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);
}
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;
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);
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;
/* 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;
_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, "-" );
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
* 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;
#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
* Return value: An error code
**/
GpgmeError
-gpgme_new_context (GpgmeCtx *r_ctx)
+gpgme_new (GpgmeCtx *r_ctx)
{
GpgmeCtx c;
}
/**
- * 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 */
-
-
-
-
-
-
-
-
-
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;
/* 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 */
#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 {
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;
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;
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;
/*-- 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 --*/
#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)
}
void
-gpgme_release_recipient_set ( GpgmeRecipientSet rset )
+gpgme_recipients_release ( GpgmeRecipients rset )
{
/* fixme: release the linked list */
xfree ( 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);
}
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 ) {
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 ) {
}
-
-
-
-
-
GpgmeError
-_gpgme_gpg_new_object ( GpgObject *r_gpg )
+_gpgme_gpg_new ( GpgObject *r_gpg )
{
GpgObject gpg;
int rc = 0;
leave:
if (rc) {
- _gpgme_gpg_release_object (gpg);
+ _gpgme_gpg_release (gpg);
*r_gpg = NULL;
}
else
}
void
-_gpgme_gpg_release_object ( GpgObject gpg )
+_gpgme_gpg_release ( GpgObject gpg )
{
if ( !gpg )
return;
}
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);
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 */
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 );
* 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));
{
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 */
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,
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;
* 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;
/* 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 );
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_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 )
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)
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);
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;
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 )
}
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;
}
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;
}