X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/1aaed0baa0fb203218a0e20c1f776b679a4b7287..a1e745ad3b306d1e5173588e39d71b132466365e:/key-fetch.c diff --git a/key-fetch.c b/key-fetch.c index 9f4863a..08a800b 100644 --- a/key-fetch.c +++ b/key-fetch.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: key-fetch.c,v 1.1 2000/06/17 10:42:54 mdw Exp $ + * $Id$ * * Higher-level key unpacking * * (c) 2000 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,26 +15,18 @@ * 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, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: key-fetch.c,v $ - * Revision 1.1 2000/06/17 10:42:54 mdw - * Convenient table-driven extraction of structured keys. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -88,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 --- */ @@ -115,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 { @@ -161,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); } @@ -181,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); } @@ -204,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) - free(kps); -} + xfree(kps); +} /*----- That's all, folks -------------------------------------------------*/