/* -*-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.
*
* 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 <mLib/dstr.h>
/* --- 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 --- */
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 {
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);
}
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);
}
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 -------------------------------------------------*/