2002-01-15 Marcus Brinkmann <marcus@g10code.de>
* trustlist.c: Various source clean ups. (my_isdigit): Removed. (gpgme_op_trustlist_end): New function.
This commit is contained in:
parent
f6638fe7a3
commit
a901ea0358
@ -1,3 +1,9 @@
|
|||||||
|
2002-01-15 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* trustlist.c: Various source clean ups.
|
||||||
|
(my_isdigit): Removed.
|
||||||
|
(gpgme_op_trustlist_end): New function.
|
||||||
|
|
||||||
2002-01-13 Marcus Brinkmann <marcus@g10code.de>
|
2002-01-13 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* gpgme.c: Various source clean ups, like renaming C to CTX where
|
* gpgme.c: Various source clean ups, like renaming C to CTX where
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* trustlist.c - key listing
|
/* trustlist.c - key listing
|
||||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||||
* Copyright (C) 2001 g10 Code GmbH
|
* Copyright (C) 2001, 2002 g10 Code GmbH
|
||||||
*
|
*
|
||||||
* This file is part of GPGME.
|
* This file is part of GPGME.
|
||||||
*
|
*
|
||||||
@ -30,9 +30,8 @@
|
|||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "ops.h"
|
#include "ops.h"
|
||||||
|
|
||||||
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
|
struct gpgme_trust_item_s
|
||||||
|
{
|
||||||
struct gpgme_trust_item_s {
|
|
||||||
int level;
|
int level;
|
||||||
char keyid[16+1];
|
char keyid[16+1];
|
||||||
int type;
|
int type;
|
||||||
@ -52,14 +51,14 @@ trust_item_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
trustlist_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
trustlist_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||||
{
|
{
|
||||||
if (ctx->out_of_core)
|
if (ctx->out_of_core)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case STATUS_EOF:
|
case STATUS_EOF:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -69,7 +68,6 @@ trustlist_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This handler is used to parse the output of --list-trust-path:
|
* This handler is used to parse the output of --list-trust-path:
|
||||||
* Format:
|
* Format:
|
||||||
@ -96,32 +94,38 @@ trustlist_colon_handler ( GpgmeCtx ctx, char *line )
|
|||||||
if (!line)
|
if (!line)
|
||||||
return; /* EOF */
|
return; /* EOF */
|
||||||
|
|
||||||
for (p = line; p; p = pend) {
|
for (p = line; p; p = pend)
|
||||||
|
{
|
||||||
field++;
|
field++;
|
||||||
pend = strchr (p, ':');
|
pend = strchr (p, ':');
|
||||||
if (pend)
|
if (pend)
|
||||||
*pend++ = 0;
|
*pend++ = 0;
|
||||||
|
|
||||||
switch (field) {
|
switch (field)
|
||||||
|
{
|
||||||
case 1: /* level */
|
case 1: /* level */
|
||||||
q = xtrymalloc (sizeof *q);
|
q = xtrymalloc (sizeof *q);
|
||||||
if ( !q ) {
|
if (!q)
|
||||||
|
{
|
||||||
ctx->out_of_core = 1;
|
ctx->out_of_core = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
q->next = NULL;
|
q->next = NULL;
|
||||||
q->item = item = trust_item_new ();
|
q->item = item = trust_item_new ();
|
||||||
if (!q->item) {
|
if (!q->item)
|
||||||
|
{
|
||||||
xfree (q);
|
xfree (q);
|
||||||
ctx->out_of_core = 1;
|
ctx->out_of_core = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* fixme: lock queue, keep a tail pointer */
|
/* fixme: lock queue, keep a tail pointer */
|
||||||
if ( !(q2 = ctx->trust_queue) )
|
q2 = ctx->trust_queue;
|
||||||
|
if (!q2)
|
||||||
ctx->trust_queue = q;
|
ctx->trust_queue = q;
|
||||||
else {
|
else
|
||||||
for ( ; q2->next; q2 = q2->next )
|
{
|
||||||
;
|
while (q2->next)
|
||||||
|
q2 = q2->next;
|
||||||
q2->next = q;
|
q2->next = q;
|
||||||
}
|
}
|
||||||
/* fixme: unlock queue */
|
/* fixme: unlock queue */
|
||||||
@ -154,6 +158,7 @@ trustlist_colon_handler ( GpgmeCtx ctx, char *line )
|
|||||||
ctx->key_cond = 1;
|
ctx->key_cond = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GpgmeError
|
GpgmeError
|
||||||
gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level)
|
gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level)
|
||||||
{
|
{
|
||||||
@ -191,7 +196,8 @@ gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level)
|
|||||||
err = _gpgme_engine_start (ctx->engine, ctx);
|
err = _gpgme_engine_start (ctx->engine, ctx);
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
if (err) {
|
if (err)
|
||||||
|
{
|
||||||
ctx->pending = 0;
|
ctx->pending = 0;
|
||||||
_gpgme_engine_release (ctx->engine);
|
_gpgme_engine_release (ctx->engine);
|
||||||
ctx->engine = NULL;
|
ctx->engine = NULL;
|
||||||
@ -215,7 +221,8 @@ gpgme_op_trustlist_next ( GpgmeCtx c, GpgmeTrustItem *r_item )
|
|||||||
if (c->out_of_core)
|
if (c->out_of_core)
|
||||||
return mk_error (Out_Of_Core);
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
if ( !c->trust_queue ) {
|
if (!c->trust_queue)
|
||||||
|
{
|
||||||
_gpgme_wait_on_condition (c, 1, &c->key_cond);
|
_gpgme_wait_on_condition (c, 1, &c->key_cond);
|
||||||
if (c->out_of_core)
|
if (c->out_of_core)
|
||||||
return mk_error (Out_Of_Core);
|
return mk_error (Out_Of_Core);
|
||||||
@ -233,6 +240,28 @@ gpgme_op_trustlist_next ( GpgmeCtx c, GpgmeTrustItem *r_item )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gpgme_op_trustlist_end:
|
||||||
|
* @c: Context
|
||||||
|
*
|
||||||
|
* Ends the trustlist operation and allows to use the context for some
|
||||||
|
* other operation next.
|
||||||
|
**/
|
||||||
|
GpgmeError
|
||||||
|
gpgme_op_trustlist_end (GpgmeCtx ctx)
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return mk_error (Invalid_Value);
|
||||||
|
if (!ctx->pending)
|
||||||
|
return mk_error (No_Request);
|
||||||
|
if (ctx->out_of_core)
|
||||||
|
return mk_error (Out_Of_Core);
|
||||||
|
|
||||||
|
ctx->pending = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gpgme_trust_item_release (GpgmeTrustItem item)
|
gpgme_trust_item_release (GpgmeTrustItem item)
|
||||||
{
|
{
|
||||||
@ -256,7 +285,8 @@ gpgme_trust_item_get_string_attr ( GpgmeTrustItem item, GpgmeAttr what,
|
|||||||
if (idx)
|
if (idx)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (what) {
|
switch (what)
|
||||||
|
{
|
||||||
case GPGME_ATTR_KEYID:
|
case GPGME_ATTR_KEYID:
|
||||||
val = item->keyid;
|
val = item->keyid;
|
||||||
break;
|
break;
|
||||||
@ -289,7 +319,8 @@ gpgme_trust_item_get_int_attr ( GpgmeTrustItem item, GpgmeAttr what,
|
|||||||
if (idx)
|
if (idx)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (what) {
|
switch (what)
|
||||||
|
{
|
||||||
case GPGME_ATTR_LEVEL:
|
case GPGME_ATTR_LEVEL:
|
||||||
val = item->level;
|
val = item->level;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user