cc-hash.c: New file containing hash-related code from hashsum and dsig.
[u/mdw/catacomb] / key-fetch.c
index d80382f..08a800b 100644 (file)
@@ -7,7 +7,7 @@
  * (c) 2000 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Catacomb.
  *
  * it under the terms of the GNU Library General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
- * 
+ *
  * Catacomb is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Library General Public
  * License along with Catacomb; if not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -80,8 +80,9 @@ key_packdef *key_fetchinit(const key_fetchdef *kf,
 
   /* --- Fill in the top part --- */
 
-  kp->kp.kd.e = KENC_STRUCT;
+  kp->kp.e = KENC_STRUCT;
   kp->kp.p = &kp[1];
+  kp->kp.kd = 0;
   kpd = &kp->kp;
 
   /* --- Initialize for the main loop --- */
@@ -107,7 +108,8 @@ key_packdef *key_fetchinit(const key_fetchdef *kf,
 
     while (kf->name) {
       kp->name = kf->name;
-      kp->kp.kd.e = kf->e;
+      kp->kp.e = kf->e;
+      kp->kp.kd = 0;
       if ((kf->e & KF_ENCMASK) != KENC_STRUCT)
        kp->kp.p = cp + kf->off;
       else {
@@ -153,7 +155,7 @@ int key_fetch(key_packdef *kp, key *k)
   int e;
 
   key_fulltag(k, &d);
-  e = key_unpack(kp, &k->k, &d);
+  e = key_unpack(kp, k->k, &d);
   dstr_destroy(&d);
   return (e);
 }
@@ -173,13 +175,13 @@ int key_fetch(key_packdef *kp, key *k)
 int key_fetchbyname(key_packdef *kp, key_file *kf, const char *tag)
 {
   dstr d = DSTR_INIT;
-  key_data *kd;
+  key_data **kd;
   int e;
 
   if (key_qtag(kf, tag, &d, 0, &kd))
     e = KERR_NOTFOUND;
   else
-    e = key_unpack(kp, kd, &d);
+    e = key_unpack(kp, *kd, &d);
   dstr_destroy(&d);
   return (e);
 }
@@ -196,11 +198,11 @@ int key_fetchbyname(key_packdef *kp, key_file *kf, const char *tag)
 
 void key_fetchdone(key_packdef *kp)
 {
-  key_packstruct *kps = (key_packstruct *)(((char *)kp) -
-                                          offsetof(key_packstruct, kp));
+  key_packstruct *kps =
+    (key_packstruct *)(((char *)kp) - offsetof(key_packstruct, kp));
   key_unpackdone(kp);
   if (kps->name)
     xfree(kps);
-}  
+}
 
 /*----- That's all, folks -------------------------------------------------*/