[svn] GnuPG - r5248 - trunk/g10

svn author wk cvs at cvs.gnupg.org
Sat Jan 9 20:00:47 CET 2010


Author: wk
Date: 2010-01-09 20:00:46 +0100 (Sat, 09 Jan 2010)
New Revision: 5248

Modified:
   trunk/g10/ChangeLog
   trunk/g10/getkey.c
   trunk/g10/keydb.c
   trunk/g10/keylist.c
Log:
Re-indent


[The diff below has been truncated]

Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2010-01-08 19:18:49 UTC (rev 5247)
+++ trunk/g10/ChangeLog	2010-01-09 19:00:46 UTC (rev 5248)
@@ -1,3 +1,7 @@
+2010-01-09  Werner Koch  <wk at g10code.com>
+
+	* getkey.c, keylist.c: Re-indent.
+
 2010-01-08  Werner Koch  <wk at g10code.com>
 
 	* cpr.c (write_status_error): Rename to write_status_errcode.
@@ -11003,7 +11007,7 @@
 
 
  Copyright 1998,1999,2000,2001,2002,2003,2004,2005,
-	   2006,2007,2008,2009 Free Software Foundation, Inc.
+	   2006,2007,2008,2009,2010 Free Software Foundation, Inc.
 
  This file is free software; as a special exception the author gives
  unlimited permission to copy and/or distribute it, with or without

Modified: trunk/g10/getkey.c
===================================================================
--- trunk/g10/getkey.c	2010-01-08 19:18:49 UTC (rev 5247)
+++ trunk/g10/getkey.c	2010-01-09 19:00:46 UTC (rev 5248)
@@ -1,6 +1,6 @@
 /* getkey.c -  Get a key from the database
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- *               2007, 2008 Free Software Foundation, Inc.
+ *               2007, 2008, 2010  Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -43,129 +43,136 @@
 #error We need the cache for key creation
 #endif
 
-struct getkey_ctx_s {
-    int exact;
-    KBNODE keyblock;
-    KBPOS  kbpos;
-    KBNODE found_key; /* Pointer into some keyblock. */
-    strlist_t extra_list;  /* Will be freed when releasing the context.  */
-    int last_rc;
-    int req_usage;
-    int req_algo;
-    KEYDB_HANDLE kr_handle;
-    int not_allocated;
-    int nitems;
-    KEYDB_SEARCH_DESC items[1];
+struct getkey_ctx_s
+{
+  int exact;
+  KBNODE keyblock;
+  KBPOS kbpos;
+  KBNODE found_key;	 /* Pointer into some keyblock. */
+  strlist_t extra_list;	 /* Will be freed when releasing the context.  */
+  int last_rc;
+  int req_usage;
+  int req_algo;
+  KEYDB_HANDLE kr_handle;
+  int not_allocated;
+  int nitems;
+  KEYDB_SEARCH_DESC items[1];
 };
 
 #if 0
-static struct {
-    int any;
-    int okay_count;
-    int nokey_count;
-    int error_count;
+static struct
+{
+  int any;
+  int okay_count;
+  int nokey_count;
+  int error_count;
 } lkup_stats[21];
 #endif
 
-typedef struct keyid_list {
-    struct keyid_list *next;
-    u32 keyid[2];
+typedef struct keyid_list
+{
+  struct keyid_list *next;
+  u32 keyid[2];
 } *keyid_list_t;
 
 
 #if MAX_PK_CACHE_ENTRIES
-  typedef struct pk_cache_entry {
-      struct pk_cache_entry *next;
-      u32 keyid[2];
-      PKT_public_key *pk;
-  } *pk_cache_entry_t;
-  static pk_cache_entry_t pk_cache;
-  static int pk_cache_entries;	 /* number of entries in pk cache */
-  static int pk_cache_disabled;
+typedef struct pk_cache_entry
+{
+  struct pk_cache_entry *next;
+  u32 keyid[2];
+  PKT_public_key *pk;
+} *pk_cache_entry_t;
+static pk_cache_entry_t pk_cache;
+static int pk_cache_entries;	/* Number of entries in pk cache.  */
+static int pk_cache_disabled;
 #endif
 
 #if MAX_UID_CACHE_ENTRIES < 5
 #error we really need the userid cache
 #endif
-typedef struct user_id_db {
-    struct user_id_db *next;
-    keyid_list_t keyids;
-    int len;
-    char name[1];
+typedef struct user_id_db
+{
+  struct user_id_db *next;
+  keyid_list_t keyids;
+  int len;
+  char name[1];
 } *user_id_db_t;
 static user_id_db_t user_id_db;
-static int uid_cache_entries;	/* number of entries in uid cache */
+static int uid_cache_entries;	/* Number of entries in uid cache. */
 
-static void merge_selfsigs( KBNODE keyblock );
-static int lookup( GETKEY_CTX ctx, KBNODE *ret_keyblock, int secmode );
+static void merge_selfsigs (KBNODE keyblock);
+static int lookup (GETKEY_CTX ctx, KBNODE * ret_keyblock, int secmode);
 
 #if 0
 static void
-print_stats()
+print_stats ()
 {
-    int i;
-    for(i=0; i < DIM(lkup_stats); i++ ) {
-	if( lkup_stats[i].any )
-	    fprintf(stderr,
-		    "lookup stats: mode=%-2d  ok=%-6d  nokey=%-6d  err=%-6d\n",
-		    i,
-		    lkup_stats[i].okay_count,
-		    lkup_stats[i].nokey_count,
-		    lkup_stats[i].error_count );
+  int i;
+  for (i = 0; i < DIM (lkup_stats); i++)
+    {
+      if (lkup_stats[i].any)
+	fprintf (stderr,
+		 "lookup stats: mode=%-2d  ok=%-6d  nokey=%-6d  err=%-6d\n",
+		 i,
+		 lkup_stats[i].okay_count,
+		 lkup_stats[i].nokey_count, lkup_stats[i].error_count);
     }
 }
 #endif
 
 
 void
-cache_public_key( PKT_public_key *pk )
+cache_public_key (PKT_public_key * pk)
 {
 #if MAX_PK_CACHE_ENTRIES
-    pk_cache_entry_t ce;
-    u32 keyid[2];
+  pk_cache_entry_t ce;
+  u32 keyid[2];
 
-    if( pk_cache_disabled )
-	return;
+  if (pk_cache_disabled)
+    return;
 
-    if( pk->dont_cache )
-        return;
+  if (pk->dont_cache)
+    return;
 
-    if( is_ELGAMAL(pk->pubkey_algo)
-	|| pk->pubkey_algo == PUBKEY_ALGO_DSA
-	|| is_RSA(pk->pubkey_algo) ) {
-	keyid_from_pk( pk, keyid );
+  if (is_ELGAMAL (pk->pubkey_algo)
+      || pk->pubkey_algo == PUBKEY_ALGO_DSA || is_RSA (pk->pubkey_algo))
+    {
+      keyid_from_pk (pk, keyid);
     }
-    else
-	return; /* don't know how to get the keyid */
+  else
+    return; /* Don't know how to get the keyid.  */
 
-    for( ce = pk_cache; ce; ce = ce->next )
-	if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] ) {
-	    if( DBG_CACHE )
-		log_debug("cache_public_key: already in cache\n");
-	    return;
-	}
+  for (ce = pk_cache; ce; ce = ce->next)
+    if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
+      {
+	if (DBG_CACHE)
+	  log_debug ("cache_public_key: already in cache\n");
+	return;
+      }
 
-    if( pk_cache_entries >= MAX_PK_CACHE_ENTRIES ) {
-	/* fixme: use another algorithm to free some cache slots */
-	pk_cache_disabled=1;
-	if( opt.verbose > 1 )
-	    log_info(_("too many entries in pk cache - disabled\n"));
-	return;
+  if (pk_cache_entries >= MAX_PK_CACHE_ENTRIES)
+    {
+      /* fixme: Use another algorithm to free some cache slots.  */
+      pk_cache_disabled = 1;
+      if (opt.verbose > 1)
+	log_info (_("too many entries in pk cache - disabled\n"));
+      return;
     }
-    pk_cache_entries++;
-    ce = xmalloc( sizeof *ce );
-    ce->next = pk_cache;
-    pk_cache = ce;
-    ce->pk = copy_public_key( NULL, pk );
-    ce->keyid[0] = keyid[0];
-    ce->keyid[1] = keyid[1];
+  pk_cache_entries++;
+  ce = xmalloc (sizeof *ce);
+  ce->next = pk_cache;
+  pk_cache = ce;
+  ce->pk = copy_public_key (NULL, pk);
+  ce->keyid[0] = keyid[0];
+  ce->keyid[1] = keyid[1];
 #endif
 }
 
 
 /* Return a const utf-8 string with the text "[User ID not found]".
-   This fucntion is required so that we don't need to switch gettext's
-   encoding temporary. */
+   This function is required so that we don't need to switch gettext's
+   encoding temporary.  */
 static const char *
 user_id_not_found_utf8 (void)
 {
@@ -178,39 +185,40 @@
 
 
 
-/*
- * Return the user ID from the given keyblock.
+/* Return the user ID from the given keyblock.
  * We use the primary uid flag which has been set by the merge_selfsigs
  * function.  The returned value is only valid as long as then given
- * keyblock is not changed
- */
+ * keyblock is not changed.  */
 static const char *
-get_primary_uid ( KBNODE keyblock, size_t *uidlen )
+get_primary_uid (KBNODE keyblock, size_t * uidlen)
 {
-    KBNODE k;
-    const char *s;
+  KBNODE k;
+  const char *s;
 
-    for (k=keyblock; k; k=k->next ) {
-        if ( k->pkt->pkttype == PKT_USER_ID
-             && !k->pkt->pkt.user_id->attrib_data
-             && k->pkt->pkt.user_id->is_primary ) {
-            *uidlen = k->pkt->pkt.user_id->len;
-            return k->pkt->pkt.user_id->name;
-        }
-    } 
-    s = user_id_not_found_utf8 ();
-    *uidlen = strlen (s);
-    return s;
+  for (k = keyblock; k; k = k->next)
+    {
+      if (k->pkt->pkttype == PKT_USER_ID
+	  && !k->pkt->pkt.user_id->attrib_data
+	  && k->pkt->pkt.user_id->is_primary)
+	{
+	  *uidlen = k->pkt->pkt.user_id->len;
+	  return k->pkt->pkt.user_id->name;
+	}
+    }
+  s = user_id_not_found_utf8 ();
+  *uidlen = strlen (s);
+  return s;
 }
 
 
 static void
-release_keyid_list ( keyid_list_t k )
+release_keyid_list (keyid_list_t k)
 {
-    while (  k ) {
-        keyid_list_t k2 = k->next;
-        xfree (k);
-        k = k2;
+  while (k)
+    {
+      keyid_list_t k2 = k->next;
+      xfree (k);
+      k = k2;
     }
 }
 
@@ -219,203 +227,211 @@
  * Feed only public keys to this function.
  */
 static void
-cache_user_id( KBNODE keyblock )
+cache_user_id (KBNODE keyblock)
 {
-    user_id_db_t r;
-    const char *uid;
-    size_t uidlen;
-    keyid_list_t keyids = NULL;
-    KBNODE k;
+  user_id_db_t r;
+  const char *uid;
+  size_t uidlen;
+  keyid_list_t keyids = NULL;
+  KBNODE k;
 
-    for (k=keyblock; k; k = k->next ) {
-        if ( k->pkt->pkttype == PKT_PUBLIC_KEY
-             || k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
-            keyid_list_t a = xmalloc_clear ( sizeof *a );
-            /* Hmmm: For a long list of keyids it might be an advantage
-             * to append the keys */
-            keyid_from_pk( k->pkt->pkt.public_key, a->keyid );
-            /* first check for duplicates */
-            for(r=user_id_db; r; r = r->next ) {
-                keyid_list_t b = r->keyids;
-                for ( b = r->keyids; b; b = b->next ) {
-                    if( b->keyid[0] == a->keyid[0]
-                        && b->keyid[1] == a->keyid[1] ) {
-                        if( DBG_CACHE )
-                            log_debug("cache_user_id: already in cache\n");
-                        release_keyid_list ( keyids );
-                        xfree ( a );
-                        return;
-                    }
-                }
-            }
-            /* now put it into the cache */
-            a->next = keyids;
-            keyids = a;
-        }
+  for (k = keyblock; k; k = k->next)
+    {
+      if (k->pkt->pkttype == PKT_PUBLIC_KEY
+	  || k->pkt->pkttype == PKT_PUBLIC_SUBKEY)
+	{
+	  keyid_list_t a = xmalloc_clear (sizeof *a);
+	  /* Hmmm: For a long list of keyids it might be an advantage
+	   * to append the keys.  */
+	  keyid_from_pk (k->pkt->pkt.public_key, a->keyid);
+	  /* First check for duplicates.  */
+	  for (r = user_id_db; r; r = r->next)
+	    {
+	      keyid_list_t b = r->keyids;
+	      for (b = r->keyids; b; b = b->next)
+		{
+		  if (b->keyid[0] == a->keyid[0]
+		      && b->keyid[1] == a->keyid[1])
+		    {
+		      if (DBG_CACHE)
+			log_debug ("cache_user_id: already in cache\n");
+		      release_keyid_list (keyids);
+		      xfree (a);
+		      return;
+		    }
+		}
+	    }
+	  /* Now put it into the cache.  */
+	  a->next = keyids;
+	  keyids = a;
+	}
     }
-    if ( !keyids )
-        BUG (); /* No key no fun */
+  if (!keyids)
+    BUG (); /* No key no fun.  */
 
 
-    uid = get_primary_uid ( keyblock, &uidlen );
+  uid = get_primary_uid (keyblock, &uidlen);
 
-    if( uid_cache_entries >= MAX_UID_CACHE_ENTRIES ) {
-	/* fixme: use another algorithm to free some cache slots */
-	r = user_id_db;
-	user_id_db = r->next;
-        release_keyid_list ( r->keyids );
-	xfree(r);
-	uid_cache_entries--;
+  if (uid_cache_entries >= MAX_UID_CACHE_ENTRIES)
+    {
+      /* fixme: use another algorithm to free some cache slots */
+      r = user_id_db;
+      user_id_db = r->next;
+      release_keyid_list (r->keyids);
+      xfree (r);
+      uid_cache_entries--;
     }
-    r = xmalloc( sizeof *r + uidlen-1 );
-    r->keyids = keyids;
-    r->len = uidlen;
-    memcpy(r->name, uid, r->len);
-    r->next = user_id_db;
-    user_id_db = r;
-    uid_cache_entries++;
+  r = xmalloc (sizeof *r + uidlen - 1);
+  r->keyids = keyids;
+  r->len = uidlen;
+  memcpy (r->name, uid, r->len);
+  r->next = user_id_db;
+  user_id_db = r;
+  uid_cache_entries++;
 }
 
 
 void
-getkey_disable_caches()
+getkey_disable_caches ()
 {
 #if MAX_PK_CACHE_ENTRIES
-    {
-	pk_cache_entry_t ce, ce2;
+  {
+    pk_cache_entry_t ce, ce2;
 
-	for( ce = pk_cache; ce; ce = ce2 ) {
-	    ce2 = ce->next;
-	    free_public_key( ce->pk );
-	    xfree( ce );
-	}
-	pk_cache_disabled=1;
-	pk_cache_entries = 0;
-	pk_cache = NULL;
-    }
+    for (ce = pk_cache; ce; ce = ce2)
+      {
+	ce2 = ce->next;
+	free_public_key (ce->pk);
+	xfree (ce);
+      }
+    pk_cache_disabled = 1;
+    pk_cache_entries = 0;
+    pk_cache = NULL;
+  }
 #endif
-    /* fixme: disable user id cache ? */
+  /* fixme: disable user id cache ? */
 }
 
 
 static void
-pk_from_block ( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE keyblock )
+pk_from_block (GETKEY_CTX ctx, PKT_public_key * pk, KBNODE keyblock)
 {
-    KBNODE a = ctx->found_key ? ctx->found_key : keyblock;
+  KBNODE a = ctx->found_key ? ctx->found_key : keyblock;
 
-    assert ( a->pkt->pkttype == PKT_PUBLIC_KEY
-             ||  a->pkt->pkttype == PKT_PUBLIC_SUBKEY );
-     
-    copy_public_key ( pk, a->pkt->pkt.public_key );
+  assert (a->pkt->pkttype == PKT_PUBLIC_KEY
+	  || a->pkt->pkttype == PKT_PUBLIC_SUBKEY);
+
+  copy_public_key (pk, a->pkt->pkt.public_key);
 }
 
 static void
-sk_from_block ( GETKEY_CTX ctx,
-                PKT_secret_key *sk, KBNODE keyblock )
+sk_from_block (GETKEY_CTX ctx, PKT_secret_key * sk, KBNODE keyblock)
 {
-    KBNODE a = ctx->found_key ? ctx->found_key : keyblock;
+  KBNODE a = ctx->found_key ? ctx->found_key : keyblock;
 
-    assert ( a->pkt->pkttype == PKT_SECRET_KEY
-             ||  a->pkt->pkttype == PKT_SECRET_SUBKEY );
-     
-    copy_secret_key( sk, a->pkt->pkt.secret_key);
+  assert (a->pkt->pkttype == PKT_SECRET_KEY
+	  || a->pkt->pkttype == PKT_SECRET_SUBKEY);
+
+  copy_secret_key (sk, a->pkt->pkt.secret_key);
 }
 
 
-/****************
- * Get a public key and store it into the allocated pk
- * can be called with PK set to NULL to just read it into some
- * internal structures.
- */
+/* Get a public key and store it into the allocated pk can be called
+ * with PK set to NULL to just read it into some internal
+ * structures.  */
 int
-get_pubkey( PKT_public_key *pk, u32 *keyid )
+get_pubkey (PKT_public_key * pk, u32 * keyid)
 {
-    int internal = 0;
-    int rc = 0;
+  int internal = 0;
+  int rc = 0;
 
 #if MAX_PK_CACHE_ENTRIES
-    if(pk)
-      {
-	/* Try to get it from the cache.  We don't do this when pk is
-	   NULL as it does not guarantee that the user IDs are
-	   cached. */
-	pk_cache_entry_t ce;
-	for( ce = pk_cache; ce; ce = ce->next )
-	  {
-	    if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] )
-	      {
-		copy_public_key( pk, ce->pk );
-		return 0;
-	      }
-	  }
-      }
+  if (pk)
+    {
+      /* Try to get it from the cache.  We don't do this when pk is
+         NULL as it does not guarantee that the user IDs are
+         cached. */
+      pk_cache_entry_t ce;
+      for (ce = pk_cache; ce; ce = ce->next)
+	{
+	  if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
+	    {
+	      copy_public_key (pk, ce->pk);
+	      return 0;
+	    }
+	}
+    }
 #endif
-    /* more init stuff */
-    if( !pk ) {
-	pk = xmalloc_clear( sizeof *pk );
-	internal++;
+  /* More init stuff.  */
+  if (!pk)
+    {
+      pk = xmalloc_clear (sizeof *pk);
+      internal++;
     }
 
 
-    /* do a lookup */
-    {	struct getkey_ctx_s ctx;
-        KBNODE kb = NULL;
-	memset( &ctx, 0, sizeof ctx );
-        ctx.exact = 1; /* use the key ID exactly as given */
-	ctx.not_allocated = 1;
-        ctx.kr_handle = keydb_new (0);
-	ctx.nitems = 1;
-	ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
-	ctx.items[0].u.kid[0] = keyid[0];
-	ctx.items[0].u.kid[1] = keyid[1];
-        ctx.req_algo  = pk->req_algo;
-        ctx.req_usage = pk->req_usage;
-	rc = lookup( &ctx, &kb, 0 );
-        if ( !rc ) {
-            pk_from_block ( &ctx, pk, kb );
-        }
-	get_pubkey_end( &ctx );
-        release_kbnode ( kb );
-    }
-    if( !rc )
-	goto leave;
+  /* Do a lookup.  */
+  {
+    struct getkey_ctx_s ctx;
+    KBNODE kb = NULL;
+    memset (&ctx, 0, sizeof ctx);
+    ctx.exact = 1; /* Use the key ID exactly as given.  */
+    ctx.not_allocated = 1;
+    ctx.kr_handle = keydb_new (0);
+    ctx.nitems = 1;
+    ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
+    ctx.items[0].u.kid[0] = keyid[0];
+    ctx.items[0].u.kid[1] = keyid[1];
+    ctx.req_algo = pk->req_algo;
+    ctx.req_usage = pk->req_usage;
+    rc = lookup (&ctx, &kb, 0);
+    if (!rc)
+      {
+	pk_from_block (&ctx, pk, kb);
+      }
+    get_pubkey_end (&ctx);
+    release_kbnode (kb);
+  }
+  if (!rc)
+    goto leave;
 
-    rc = G10ERR_NO_PUBKEY;
+  rc = G10ERR_NO_PUBKEY;
 
-  leave:
-    if( !rc )
-	cache_public_key( pk );
-    if( internal )
-	free_public_key(pk);
-    return rc;
+leave:
+  if (!rc)
+    cache_public_key (pk);
+  if (internal)
+    free_public_key (pk);
+  return rc;
 }
 
 
 /* Get a public key and store it into the allocated pk.  This function
    differs from get_pubkey() in that it does not do a check of the key
    to avoid recursion.  It should be used only in very certain cases.
-   It will only retrieve primary keys. */
+   It will only retrieve primary keys.  */
 int
-get_pubkey_fast (PKT_public_key *pk, u32 *keyid)
+get_pubkey_fast (PKT_public_key * pk, u32 * keyid)
 {
   int rc = 0;
   KEYDB_HANDLE hd;
   KBNODE keyblock;
   u32 pkid[2];
-  
+
   assert (pk);
 #if MAX_PK_CACHE_ENTRIES
-  { /* Try to get it from the cache */
+  {
+    /* Try to get it from the cache */
     pk_cache_entry_t ce;
 
     for (ce = pk_cache; ce; ce = ce->next)
       {
-        if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
-          {
-            if (pk)
-              copy_public_key (pk, ce->pk);
-            return 0;
-          }
+	if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
+	  {
+	    if (pk)
+	      copy_public_key (pk, ce->pk);
+	    return 0;
+	  }
       }
   }
 #endif
@@ -429,20 +445,20 @@
     }
   rc = keydb_get_keyblock (hd, &keyblock);
   keydb_release (hd);
-  if (rc) 
+  if (rc)
     {
-      log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
+      log_error ("keydb_get_keyblock failed: %s\n", g10_errstr (rc));
       return G10ERR_NO_PUBKEY;
     }
 
-  assert ( keyblock->pkt->pkttype == PKT_PUBLIC_KEY
-           ||  keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY );
+  assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY
+	  || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY);
 
-  keyid_from_pk(keyblock->pkt->pkt.public_key,pkid);
-  if(keyid[0]==pkid[0] && keyid[1]==pkid[1])
-    copy_public_key (pk, keyblock->pkt->pkt.public_key );
+  keyid_from_pk (keyblock->pkt->pkt.public_key, pkid);
+  if (keyid[0] == pkid[0] && keyid[1] == pkid[1])
+    copy_public_key (pk, keyblock->pkt->pkt.public_key);
   else
-    rc=G10ERR_NO_PUBKEY;
+    rc = G10ERR_NO_PUBKEY;
 
   release_kbnode (keyblock);
 
@@ -454,24 +470,24 @@
 
 
 KBNODE
-get_pubkeyblock( u32 *keyid )
+get_pubkeyblock (u32 * keyid)
 {
-    struct getkey_ctx_s ctx;
-    int rc = 0;
-    KBNODE keyblock = NULL;
+  struct getkey_ctx_s ctx;
+  int rc = 0;
+  KBNODE keyblock = NULL;
 
-    memset( &ctx, 0, sizeof ctx );
-    /* no need to set exact here because we want the entire block */
-    ctx.not_allocated = 1;
-    ctx.kr_handle = keydb_new (0);
-    ctx.nitems = 1;
-    ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
-    ctx.items[0].u.kid[0] = keyid[0];
-    ctx.items[0].u.kid[1] = keyid[1];
-    rc = lookup( &ctx, &keyblock, 0 );
-    get_pubkey_end( &ctx );
+  memset (&ctx, 0, sizeof ctx);
+  /* No need to set exact here because we want the entire block.  */
+  ctx.not_allocated = 1;
+  ctx.kr_handle = keydb_new (0);
+  ctx.nitems = 1;
+  ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
+  ctx.items[0].u.kid[0] = keyid[0];
+  ctx.items[0].u.kid[1] = keyid[1];
+  rc = lookup (&ctx, &keyblock, 0);
+  get_pubkey_end (&ctx);
 
-    return rc ? NULL : keyblock;
+  return rc ? NULL : keyblock;
 }
 
 
@@ -481,213 +497,222 @@
  * Get a secret key and store it into sk
  */
 int
-get_seckey( PKT_secret_key *sk, u32 *keyid )
+get_seckey (PKT_secret_key * sk, u32 * keyid)
 {
-    int rc;
-    struct getkey_ctx_s ctx;
-    KBNODE kb = NULL;
+  int rc;
+  struct getkey_ctx_s ctx;
+  KBNODE kb = NULL;
 
-    memset( &ctx, 0, sizeof ctx );
-    ctx.exact = 1; /* use the key ID exactly as given */
-    ctx.not_allocated = 1;
-    ctx.kr_handle = keydb_new (1);
-    ctx.nitems = 1;
-    ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
-    ctx.items[0].u.kid[0] = keyid[0];
-    ctx.items[0].u.kid[1] = keyid[1];
-    ctx.req_algo  = sk->req_algo;
-    ctx.req_usage = sk->req_usage;
-    rc = lookup( &ctx, &kb, 1 );
-    if ( !rc ) {
-        sk_from_block ( &ctx, sk, kb );
+  memset (&ctx, 0, sizeof ctx);
+  ctx.exact = 1; /* Use the key ID exactly as given.  */
+  ctx.not_allocated = 1;
+  ctx.kr_handle = keydb_new (1);
+  ctx.nitems = 1;
+  ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
+  ctx.items[0].u.kid[0] = keyid[0];
+  ctx.items[0].u.kid[1] = keyid[1];
+  ctx.req_algo = sk->req_algo;
+  ctx.req_usage = sk->req_usage;
+  rc = lookup (&ctx, &kb, 1);
+  if (!rc)
+    {
+      sk_from_block (&ctx, sk, kb);
     }
-    get_seckey_end( &ctx );
-    release_kbnode ( kb );
+  get_seckey_end (&ctx);
+  release_kbnode (kb);
 
-    if( !rc ) {
-	/* check the secret key (this may prompt for a passprase to
-	 * unlock the secret key
-	 */
-	rc = check_secret_key( sk, 0 );
+  if (!rc)
+    {
+      /* Check the secret key (this may prompt for a passprase to
+       * unlock the secret key.  */
+      rc = check_secret_key (sk, 0);
     }
 
-    return rc;
+  return rc;
 }
 
 
-/****************
- * Check whether the secret key is available.  This is just a fast
+/* Check whether the secret key is available.  This is just a fast
  * check and does not tell us whether the secret key is valid.  It
  * merely tells other whether there is some secret key.
- * Returns: 0 := key is available
- * G10ERR_NO_SECKEY := not availabe
+ * Returns:
+ *    0                := key is available
+ *    G10ERR_NO_SECKEY := key not availabe
  */
 int
-seckey_available( u32 *keyid )
+seckey_available (u32 * keyid)
 {
-    int rc;
-    KEYDB_HANDLE hd = keydb_new (1);
+  int rc;
+  KEYDB_HANDLE hd = keydb_new (1);
 
-    rc = keydb_search_kid (hd, keyid);
-    if ( rc == -1 )
-        rc = G10ERR_NO_SECKEY;
-    keydb_release (hd);
-    return rc;
+  rc = keydb_search_kid (hd, keyid);
+  if (rc == -1)
+    rc = G10ERR_NO_SECKEY;
+  keydb_release (hd);
+  return rc;
 }
 
 
 
 static int
-skip_unusable (void *dummy, u32 *keyid, PKT_user_id *uid)
+skip_unusable (void *dummy, u32 * keyid, PKT_user_id * uid)
 {
-  int unusable=0;
+  int unusable = 0;
   KBNODE keyblock;
-  
-  (void)dummy;
 
-  keyblock=get_pubkeyblock(keyid);
-  if(!keyblock)
+  (void) dummy;
+
+  keyblock = get_pubkeyblock (keyid);
+  if (!keyblock)
     {
-      log_error("error checking usability status of %s\n",keystr(keyid));
+      log_error ("error checking usability status of %s\n", keystr (keyid));
       goto leave;
     }
 
   /* Is the user ID in question revoked/expired? */
-  if(uid)
+  if (uid)
     {
       KBNODE node;
 
-      for(node=keyblock;node;node=node->next)
+      for (node = keyblock; node; node = node->next)
 	{
-	  if(node->pkt->pkttype==PKT_USER_ID)
+	  if (node->pkt->pkttype == PKT_USER_ID)
 	    {
-	      if(cmp_user_ids(uid,node->pkt->pkt.user_id)==0
-		 && (node->pkt->pkt.user_id->is_revoked
-		     || node->pkt->pkt.user_id->is_expired))
+	      if (cmp_user_ids (uid, node->pkt->pkt.user_id) == 0
+		  && (node->pkt->pkt.user_id->is_revoked
+		      || node->pkt->pkt.user_id->is_expired))
 		{
-		  unusable=1;
+		  unusable = 1;
 		  break;
 		}
 	    }
 	}
     }
 
-  if(!unusable)
-    unusable=pk_is_disabled(keyblock->pkt->pkt.public_key);
+  if (!unusable)
+    unusable = pk_is_disabled (keyblock->pkt->pkt.public_key);
 
- leave:
-  release_kbnode(keyblock);
+leave:
+  release_kbnode (keyblock);
   return unusable;
 }
 
-/****************
- * Try to get the pubkey by the userid. This function looks for the
+
+/* Try to get the pubkey by the userid. This function looks for the
  * first pubkey certificate which has the given name in a user_id.  if
  * pk/sk has the pubkey algo set, the function will only return a
  * pubkey with that algo.  If namelist is NULL, the first key is
  * returned.  The caller should provide storage for either the pk or
  * the sk.  If ret_kb is not NULL the function will return the
- * keyblock there.
- */
-
+ * keyblock there.  */
 static int
-key_byname( GETKEY_CTX *retctx, strlist_t namelist,
-	    PKT_public_key *pk, PKT_secret_key *sk,
+key_byname (GETKEY_CTX * retctx, strlist_t namelist,
+	    PKT_public_key * pk, PKT_secret_key * sk,
 	    int secmode, int include_unusable,
-            KBNODE *ret_kb, KEYDB_HANDLE *ret_kdbhd )
+	    KBNODE * ret_kb, KEYDB_HANDLE * ret_kdbhd)
 {
-    int rc = 0;
-    int n;
-    strlist_t r;
-    GETKEY_CTX ctx;
-    KBNODE help_kb = NULL;
-    
-    if( retctx ) {/* reset the returned context in case of error */
-        assert (!ret_kdbhd);  /* not allowed because the handle is
-                                 stored in the context */
-	*retctx = NULL;
+  int rc = 0;
+  int n;
+  strlist_t r;
+  GETKEY_CTX ctx;
+  KBNODE help_kb = NULL;
+
+  if (retctx)
+    {
+      /* Reset the returned context in case of error.  */
+      assert (!ret_kdbhd); /* Not allowed because the handle is stored
+			      in the context.  */
+      *retctx = NULL;
     }
-    if (ret_kdbhd)
-        *ret_kdbhd = NULL;
+  if (ret_kdbhd)
+    *ret_kdbhd = NULL;
 
-    if(!namelist)
-      {
-	ctx = xmalloc_clear (sizeof *ctx);
-	ctx->nitems = 1;
-	ctx->items[0].mode=KEYDB_SEARCH_MODE_FIRST;
-	if(!include_unusable)
-	  ctx->items[0].skipfnc=skip_unusable;
-      }
-    else
-      {
-	/* build the search context */
-	for(n=0, r=namelist; r; r = r->next )
-	  n++;
+  if (!namelist)
+    {
+      ctx = xmalloc_clear (sizeof *ctx);
+      ctx->nitems = 1;
+      ctx->items[0].mode = KEYDB_SEARCH_MODE_FIRST;
+      if (!include_unusable)
+	ctx->items[0].skipfnc = skip_unusable;
+    }
+  else
+    {
+      /* Build the search context.  */
+      for (n = 0, r = namelist; r; r = r->next)
+	n++;
 
-	ctx = xmalloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items );
-	ctx->nitems = n;
+      ctx = xmalloc_clear (sizeof *ctx + (n - 1) * sizeof ctx->items);
+      ctx->nitems = n;
 
-	for(n=0, r=namelist; r; r = r->next, n++ )
-	  {
-            gpg_error_t err;
+      for (n = 0, r = namelist; r; r = r->next, n++)
+	{
+	  gpg_error_t err;
 
-	    err = classify_user_id (r->d, &ctx->items[n]);
-        
-	    if (ctx->items[n].exact)
-	      ctx->exact = 1;
-	    if (err)
-	      {
-		xfree (ctx);
-		return gpg_err_code (err); /* FIXME: remove gpg_err_code.  */
-	      }
-	    if(!include_unusable
-	       && ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID
-	       && ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID
-	       && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16
-	       && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20
-	       && ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR)
-	      ctx->items[n].skipfnc=skip_unusable;
-	  }
-      }
+	  err = classify_user_id (r->d, &ctx->items[n]);
 
-    ctx->kr_handle = keydb_new (secmode);
-    if ( !ret_kb ) 
-        ret_kb = &help_kb;
+	  if (ctx->items[n].exact)
+	    ctx->exact = 1;
+	  if (err)
+	    {
+	      xfree (ctx);
+	      return gpg_err_code (err); /* FIXME: remove gpg_err_code.  */
+	    }
+	  if (!include_unusable
+	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_SHORT_KID
+	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_LONG_KID
+	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR16
+	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR20
+	      && ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR)
+	    ctx->items[n].skipfnc = skip_unusable;
+	}
+    }
 
-    if( secmode ) {
-        if (sk) {
-            ctx->req_algo  = sk->req_algo;
-            ctx->req_usage = sk->req_usage;
-        }
-	rc = lookup( ctx, ret_kb, 1 );
-        if ( !rc && sk ) {
-            sk_from_block ( ctx, sk, *ret_kb );
-        }
+  ctx->kr_handle = keydb_new (secmode);
+  if (!ret_kb)
+    ret_kb = &help_kb;
+
+  if (secmode)
+    {
+      if (sk)
+	{
+	  ctx->req_algo = sk->req_algo;
+	  ctx->req_usage = sk->req_usage;
+	}
+      rc = lookup (ctx, ret_kb, 1);
+      if (!rc && sk)
+	{
+	  sk_from_block (ctx, sk, *ret_kb);
+	}
     }
-    else {
-        if (pk) {
-            ctx->req_algo  = pk->req_algo;
-            ctx->req_usage = pk->req_usage;
-        }
-	rc = lookup( ctx, ret_kb, 0 );
-        if ( !rc && pk ) {
-            pk_from_block ( ctx, pk, *ret_kb );
-        }
+  else
+    {
+      if (pk)
+	{
+	  ctx->req_algo = pk->req_algo;
+	  ctx->req_usage = pk->req_usage;
+	}
+      rc = lookup (ctx, ret_kb, 0);
+      if (!rc && pk)
+	{
+	  pk_from_block (ctx, pk, *ret_kb);
+	}
     }
 
-    release_kbnode ( help_kb );
+  release_kbnode (help_kb);
 
-    if (retctx) /* caller wants the context */
-	*retctx = ctx;
-    else {
-        if (ret_kdbhd) {
-            *ret_kdbhd = ctx->kr_handle;
-            ctx->kr_handle = NULL;
-        }
-        get_pubkey_end (ctx);
+  if (retctx) /* Caller wants the context.  */
+    *retctx = ctx;
+  else
+    {
+      if (ret_kdbhd)
+	{
+	  *ret_kdbhd = ctx->kr_handle;
+	  ctx->kr_handle = NULL;
+	}
+      get_pubkey_end (ctx);
     }
 
-    return rc;
+  return rc;
 }
 
 
@@ -700,10 +725,9 @@
    to import the key via the online mechanisms defined by
    --auto-key-locate.  */
 int
-get_pubkey_byname (GETKEY_CTX *retctx, PKT_public_key *pk,
-		   const char *name, KBNODE *ret_keyblock,
-                   KEYDB_HANDLE *ret_kdbhd, int include_unusable, 
-                   int no_akl)
+get_pubkey_byname (GETKEY_CTX * retctx, PKT_public_key * pk,
+		   const char *name, KBNODE * ret_keyblock,
+		   KEYDB_HANDLE * ret_kdbhd, int include_unusable, int no_akl)
 {
   int rc;
   strlist_t namelist = NULL;
@@ -719,7 +743,7 @@
 
   /* Check whether we the default local search has been disabled.
      This is the case if either the "nodefault" or the "local" keyword
-     are in the list of auto key locate mechanisms. 
+     are in the list of auto key locate mechanisms.
 
      ANYLOCALFIRST is set if the search order has the local method
      before any other or if "local" is used first by default.  This
@@ -728,19 +752,19 @@
      a followup call to get_pubkey_next shall succeed.  */
   if (!no_akl)
     {
-      for (akl=opt.auto_key_locate; akl; akl=akl->next)
-        if (akl->type == AKL_NODEFAULT || akl->type == AKL_LOCAL)
-          {
-            nodefault = 1;
-            break;
-          }
-      for (akl=opt.auto_key_locate; akl; akl=akl->next)
-        if (akl->type != AKL_NODEFAULT)
-          {
-            if (akl->type == AKL_LOCAL)
-              anylocalfirst = 1;
-            break;
-          }
+      for (akl = opt.auto_key_locate; akl; akl = akl->next)
+	if (akl->type == AKL_NODEFAULT || akl->type == AKL_LOCAL)
+	  {
+	    nodefault = 1;
+	    break;
+	  }
+      for (akl = opt.auto_key_locate; akl; akl = akl->next)
+	if (akl->type != AKL_NODEFAULT)
+	  {
+	    if (akl->type == AKL_LOCAL)
+	      anylocalfirst = 1;
+	    break;
+	  }
     }
 
   if (!nodefault)
@@ -755,96 +779,98 @@
     {
       add_to_strlist (&namelist, name);
       rc = key_byname (retctx, namelist, pk, NULL, 0,
-                       include_unusable, ret_keyblock, ret_kdbhd);
+		       include_unusable, ret_keyblock, ret_kdbhd);
     }
 
   /* If the requested name resembles a valid mailbox and automatic
      retrieval has been enabled, we try to import the key. */
   if (gpg_err_code (rc) == G10ERR_NO_PUBKEY && !no_akl && is_mbox)
     {
-      for (akl=opt.auto_key_locate; akl; akl=akl->next)
+      for (akl = opt.auto_key_locate; akl; akl = akl->next)
 	{
 	  unsigned char *fpr = NULL;
 	  size_t fpr_len;
-          int did_key_byname = 0;
-          int no_fingerprint = 0;
-          const char *mechanism = "?";
-          
-          switch(akl->type)
+	  int did_key_byname = 0;
+	  int no_fingerprint = 0;
+	  const char *mechanism = "?";
+
+	  switch (akl->type)
 	    {
-            case AKL_NODEFAULT:
-              /* This is a dummy mechanism.  */
-              mechanism = "None";
-              rc = G10ERR_NO_PUBKEY;
-              break;
+	    case AKL_NODEFAULT:
+	      /* This is a dummy mechanism.  */
+	      mechanism = "None";
+	      rc = G10ERR_NO_PUBKEY;
+	      break;
 
-            case AKL_LOCAL:
-              mechanism = "Local";
-              did_key_byname = 1;
-              if (retctx)
-                {
-                  get_pubkey_end (*retctx);
-                  *retctx = NULL;
-                }
-              add_to_strlist (&namelist, name);
-              rc = key_byname (anylocalfirst? retctx:NULL,
-                               namelist, pk, NULL, 0,
-                               include_unusable, ret_keyblock, ret_kdbhd);
-              break;
+	    case AKL_LOCAL:
+	      mechanism = "Local";
+	      did_key_byname = 1;
+	      if (retctx)
+		{
+		  get_pubkey_end (*retctx);
+		  *retctx = NULL;
+		}
+	      add_to_strlist (&namelist, name);
+	      rc = key_byname (anylocalfirst ? retctx : NULL,
+			       namelist, pk, NULL, 0,
+			       include_unusable, ret_keyblock, ret_kdbhd);
+	      break;
 
 	    case AKL_CERT:
-              mechanism = "DNS CERT";
+	      mechanism = "DNS CERT";
 	      glo_ctrl.in_auto_key_retrieve++;
-	      rc=keyserver_import_cert(name,&fpr,&fpr_len);
+	      rc = keyserver_import_cert (name, &fpr, &fpr_len);
 	      glo_ctrl.in_auto_key_retrieve--;
 	      break;
 
 	    case AKL_PKA:
-              mechanism = "PKA";
+	      mechanism = "PKA";
 	      glo_ctrl.in_auto_key_retrieve++;
-	      rc=keyserver_import_pka(name,&fpr,&fpr_len);
+	      rc = keyserver_import_pka (name, &fpr, &fpr_len);
 	      glo_ctrl.in_auto_key_retrieve--;
 	      break;
 
 	    case AKL_LDAP:
-              mechanism = "LDAP";
+	      mechanism = "LDAP";
 	      glo_ctrl.in_auto_key_retrieve++;
-	      rc=keyserver_import_ldap(name,&fpr,&fpr_len);
+	      rc = keyserver_import_ldap (name, &fpr, &fpr_len);
 	      glo_ctrl.in_auto_key_retrieve--;
 	      break;
 
 	    case AKL_KEYSERVER:
 	      /* Strictly speaking, we don't need to only use a valid
-		 mailbox for the getname search, but it helps cut down
-		 on the problem of searching for something like "john"
-		 and getting a whole lot of keys back. */
-	      if(opt.keyserver)
+	         mailbox for the getname search, but it helps cut down
+	         on the problem of searching for something like "john"
+	         and getting a whole lot of keys back. */
+	      if (opt.keyserver)
 		{
-                  mechanism = opt.keyserver->uri;
+		  mechanism = opt.keyserver->uri;
 		  glo_ctrl.in_auto_key_retrieve++;
-		  rc=keyserver_import_name(name,&fpr,&fpr_len,opt.keyserver);
+		  rc =
+		    keyserver_import_name (name, &fpr, &fpr_len,
+					   opt.keyserver);
 		  glo_ctrl.in_auto_key_retrieve--;
 		}
-              else
-                {
-                  mechanism = "Unconfigured keyserver";
-                  rc = G10ERR_NO_PUBKEY;
-                }
+	      else
+		{
+		  mechanism = "Unconfigured keyserver";
+		  rc = G10ERR_NO_PUBKEY;
+		}
 	      break;
 
 	    case AKL_SPEC:
 	      {
 		struct keyserver_spec *keyserver;
 
-                mechanism = akl->spec->uri;
-		keyserver=keyserver_match(akl->spec);
+		mechanism = akl->spec->uri;
+		keyserver = keyserver_match (akl->spec);
 		glo_ctrl.in_auto_key_retrieve++;
-		rc=keyserver_import_name(name,&fpr,&fpr_len,keyserver);
+		rc = keyserver_import_name (name, &fpr, &fpr_len, keyserver);
 		glo_ctrl.in_auto_key_retrieve--;
 	      }
 	      break;
 	    }
-          
+
 	  /* Use the fingerprint of the key that we actually fetched.
 	     This helps prevent problems where the key that we fetched
 	     doesn't have the same name that we used to fetch it.  In
@@ -854,54 +880,55 @@
 	     won't use the attacker's key here. */
 	  if (!rc && fpr)
 	    {
-	      char fpr_string[MAX_FINGERPRINT_LEN*2+1];
+	      char fpr_string[MAX_FINGERPRINT_LEN * 2 + 1];
 
-	      assert(fpr_len<=MAX_FINGERPRINT_LEN);
+	      assert (fpr_len <= MAX_FINGERPRINT_LEN);
 
-	      free_strlist(namelist);
-	      namelist=NULL;
+	      free_strlist (namelist);
+	      namelist = NULL;
 
-              bin2hex (fpr, fpr_len, fpr_string);
-              
-	      if(opt.verbose)
-		log_info("auto-key-locate found fingerprint %s\n",fpr_string);
+	      bin2hex (fpr, fpr_len, fpr_string);
 
-	      add_to_strlist( &namelist, fpr_string );
+	      if (opt.verbose)
+		log_info ("auto-key-locate found fingerprint %s\n",
+			  fpr_string);
+
+	      add_to_strlist (&namelist, fpr_string);
 	    }
-          else if (!rc && !fpr && !did_key_byname)
-            {
-              no_fingerprint = 1;
-              rc = G10ERR_NO_PUBKEY;
-            }
-          xfree (fpr);
-          fpr = NULL;
+	  else if (!rc && !fpr && !did_key_byname)
+	    {
+	      no_fingerprint = 1;
+	      rc = G10ERR_NO_PUBKEY;
+	    }
+	  xfree (fpr);
+	  fpr = NULL;
 
-          if (!rc && !did_key_byname)
-            {
-              if (retctx)
-                {
-                  get_pubkey_end (*retctx);
-                  *retctx = NULL;
-                }
-              rc = key_byname (anylocalfirst?retctx:NULL,
-                               namelist, pk, NULL, 0,
-                               include_unusable, ret_keyblock, ret_kdbhd);
-            }
+	  if (!rc && !did_key_byname)
+	    {
+	      if (retctx)
+		{
+		  get_pubkey_end (*retctx);
+		  *retctx = NULL;
+		}
+	      rc = key_byname (anylocalfirst ? retctx : NULL,
+			       namelist, pk, NULL, 0,
+			       include_unusable, ret_keyblock, ret_kdbhd);
+	    }
 	  if (!rc)
-            {
-              /* Key found.  */
-              log_info (_("automatically retrieved `%s' via %s\n"),
-                        name, mechanism);
-              break;  
-            }
-          if (rc != G10ERR_NO_PUBKEY || opt.verbose || no_fingerprint)
-            log_info (_("error retrieving `%s' via %s: %s\n"),
-                      name, mechanism, 
-                      no_fingerprint? _("No fingerprint"):g10_errstr(rc));
+	    {
+	      /* Key found.  */
+	      log_info (_("automatically retrieved `%s' via %s\n"),
+			name, mechanism);
+	      break;
+	    }
+	  if (rc != G10ERR_NO_PUBKEY || opt.verbose || no_fingerprint)
+	    log_info (_("error retrieving `%s' via %s: %s\n"),
+		      name, mechanism,
+		      no_fingerprint ? _("No fingerprint") : g10_errstr (rc));
 	}
     }
 
-  
+
   if (rc && retctx)
     {
       get_pubkey_end (*retctx);
@@ -920,70 +947,71 @@
 
 
 int
-get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk,
-		    strlist_t names, KBNODE *ret_keyblock )
+get_pubkey_bynames (GETKEY_CTX * retctx, PKT_public_key * pk,
+		    strlist_t names, KBNODE * ret_keyblock)
 {
-    return key_byname( retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL);
+  return key_byname (retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL);
 }
 
 int
-get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock )
+get_pubkey_next (GETKEY_CTX ctx, PKT_public_key * pk, KBNODE * ret_keyblock)
 {
-    int rc;
+  int rc;
 
-    rc = lookup( ctx, ret_keyblock, 0 );
-    if ( !rc && pk && ret_keyblock )
-        pk_from_block ( ctx, pk, *ret_keyblock );
-    
-    return rc;
+  rc = lookup (ctx, ret_keyblock, 0);
+  if (!rc && pk && ret_keyblock)
+    pk_from_block (ctx, pk, *ret_keyblock);
+
+  return rc;
 }
 
 void
-get_pubkey_end( GETKEY_CTX ctx )
+get_pubkey_end (GETKEY_CTX ctx)
 {
-    if( ctx ) {
-        memset (&ctx->kbpos, 0, sizeof ctx->kbpos);
-        keydb_release (ctx->kr_handle);
-        free_strlist (ctx->extra_list);
-	if( !ctx->not_allocated )
-	    xfree( ctx );
+  if (ctx)
+    {
+      memset (&ctx->kbpos, 0, sizeof ctx->kbpos);
+      keydb_release (ctx->kr_handle);
+      free_strlist (ctx->extra_list);
+      if (!ctx->not_allocated)
+	xfree (ctx);
     }
 }
 
 
-/****************
- * Search for a key with the given fingerprint.
+/* Search for a key with the given fingerprint.
  * FIXME:
- * We should replace this with the _byname function.  Thiscsan be done
- * by creating a userID conforming to the unified fingerprint style. 
+ * We should replace this with the _byname function.  This can be done
+ * by creating a userID conforming to the unified fingerprint style.
  */
 int
-get_pubkey_byfprint( PKT_public_key *pk,
-                     const byte *fprint, size_t fprint_len)
+get_pubkey_byfprint (PKT_public_key * pk,
+		     const byte * fprint, size_t fprint_len)
 {
-    int rc;
+  int rc;
 
-    if( fprint_len == 20 || fprint_len == 16 ) {
-	struct getkey_ctx_s ctx;
-        KBNODE kb = NULL;
+  if (fprint_len == 20 || fprint_len == 16)
+    {
+      struct getkey_ctx_s ctx;
+      KBNODE kb = NULL;
 
-	memset( &ctx, 0, sizeof ctx );
-        ctx.exact = 1 ;
-	ctx.not_allocated = 1;
-        ctx.kr_handle = keydb_new (0);
-	ctx.nitems = 1;
-	ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
-                                          : KEYDB_SEARCH_MODE_FPR20;
-	memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
-	rc = lookup( &ctx, &kb, 0 );
-        if (!rc && pk )
-            pk_from_block ( &ctx, pk, kb );
-        release_kbnode ( kb );
-	get_pubkey_end( &ctx );
+      memset (&ctx, 0, sizeof ctx);
+      ctx.exact = 1;
+      ctx.not_allocated = 1;
+      ctx.kr_handle = keydb_new (0);
+      ctx.nitems = 1;
+      ctx.items[0].mode = fprint_len == 16 ? KEYDB_SEARCH_MODE_FPR16
+	: KEYDB_SEARCH_MODE_FPR20;
+      memcpy (ctx.items[0].u.fpr, fprint, fprint_len);
+      rc = lookup (&ctx, &kb, 0);
+      if (!rc && pk)
+	pk_from_block (&ctx, pk, kb);
+      release_kbnode (kb);
+      get_pubkey_end (&ctx);
     }
-    else
-	rc = G10ERR_GENERAL; /* Oops */
-    return rc;
+  else
+    rc = G10ERR_GENERAL; /* Oops */
+  return rc;
 }
 
 
@@ -991,20 +1019,20 @@
    differs from get_pubkey_byfprint() in that it does not do a check
    of the key to avoid recursion.  It should be used only in very
    certain cases.  PK may be NULL to check just for the existance of
-   the key. */
+   the key.  */
 int
-get_pubkey_byfprint_fast (PKT_public_key *pk,
-                          const byte *fprint, size_t fprint_len)
+get_pubkey_byfprint_fast (PKT_public_key * pk,




More information about the Gnupg-commits mailing list