aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2001-12-05 13:23:59 +0000
committerMarcus Brinkmann <[email protected]>2001-12-05 13:23:59 +0000
commite9ece11e837aff9bbff27cdb43069a6a6f2cd236 (patch)
tree43e32a4cb9bd5218b78f347a73dc53351bebd7fd
parent2001-11-29 Marcus Brinkmann <[email protected]> (diff)
downloadgpgme-e9ece11e837aff9bbff27cdb43069a6a6f2cd236.tar.gz
gpgme-e9ece11e837aff9bbff27cdb43069a6a6f2cd236.zip
2001-12-05 Marcus Brinkmann <[email protected]>
* keylist.c (gpgme_op_keylist_next): Set pending to 0 if EOF occurs.
-rw-r--r--gpgme/ChangeLog5
-rw-r--r--gpgme/keylist.c78
2 files changed, 43 insertions, 40 deletions
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index dd78d7b2..6d4b9a9c 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,3 +1,8 @@
+2001-12-05 Marcus Brinkmann <[email protected]>
+
+ * keylist.c (gpgme_op_keylist_next): Set pending to 0 if EOF
+ occurs.
+
2001-11-26 Marcus Brinkmann <[email protected]>
* engine-gpgsm.c (_gpgme_gpgsm_op_sign): Fix stupid typo.
diff --git a/gpgme/keylist.c b/gpgme/keylist.c
index 2685f4f6..323d6360 100644
--- a/gpgme/keylist.c
+++ b/gpgme/keylist.c
@@ -367,9 +367,6 @@ finish_key ( GpgmeCtx ctx )
}
}
-
-
-
/**
* gpgme_op_keylist_start:
* @c: context
@@ -430,52 +427,53 @@ gpgme_op_keylist_start (GpgmeCtx ctx, const char *pattern, int secret_only)
return err;
}
-
/**
* gpgme_op_keylist_next:
* @c: Context
* @r_key: Returned key object
*
* Return the next key from the key listing started with
- * gpgme_op_keylist_start(). The caller must free the key using
- * gpgme_key_release().
+ * gpgme_op_keylist_start(). The caller must free the key using
+ * gpgme_key_release(). If the last key has already been returned the
+ * last time the function was called, %GPGME_EOF is returned and the
+ * operation is finished.
*
- * Return value: 0 on success, %GPGME_EOF or anoter error code.
+ * Return value: 0 on success, %GPGME_EOF or another error code.
**/
GpgmeError
-gpgme_op_keylist_next ( GpgmeCtx c, GpgmeKey *r_key )
+gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key)
{
- struct key_queue_item_s *q;
-
- if (!r_key)
- return mk_error (Invalid_Value);
- *r_key = NULL;
- if (!c)
- return mk_error (Invalid_Value);
- if ( !c->pending )
- return mk_error (No_Request);
- if ( c->out_of_core )
- return mk_error (Out_Of_Core);
-
- if ( !c->key_queue ) {
- _gpgme_wait_on_condition (c, 1, &c->key_cond );
- if ( c->out_of_core )
- return mk_error (Out_Of_Core);
- if ( !c->key_cond )
- return mk_error (EOF);
- c->key_cond = 0;
- assert ( c->key_queue );
- }
- q = c->key_queue;
- c->key_queue = q->next;
- if (!c->key_queue)
- c->key_cond = 0;
-
- *r_key = q->key;
- xfree (q);
- return 0;
-}
-
-
+ struct key_queue_item_s *queue_item;
+ if (!r_key)
+ return mk_error (Invalid_Value);
+ *r_key = NULL;
+ 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);
+ if (!ctx->key_queue)
+ {
+ _gpgme_wait_on_condition (ctx, 1, &ctx->key_cond);
+ if (ctx->out_of_core)
+ return mk_error (Out_Of_Core);
+ if (!ctx->key_cond)
+ {
+ ctx->pending = 0;
+ return mk_error (EOF);
+ }
+ ctx->key_cond = 0;
+ assert (ctx->key_queue);
+ }
+ queue_item = ctx->key_queue;
+ ctx->key_queue = queue_item->next;
+ if (!ctx->key_queue)
+ ctx->key_cond = 0;
+
+ *r_key = queue_item->key;
+ xfree (queue_item);
+ return 0;
+}