X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/052b36d05a622a93733b735acce2de865b14627b..5d01b1b9514a258c5a3c201e944f676cb2c467f0:/key-flags.c diff --git a/key-flags.c b/key-flags.c index 7840462..bf5b70f 100644 --- a/key-flags.c +++ b/key-flags.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: key-flags.c,v 1.2 2000/02/12 18:21:02 mdw Exp $ + * $Id$ * * Reading and writing key flag strings * * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,29 +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-flags.c,v $ - * Revision 1.2 2000/02/12 18:21:02 mdw - * Overhaul of key management (again). - * - * Revision 1.1 1999/12/22 15:47:48 mdw - * Major key-management revision. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -63,7 +52,7 @@ typedef struct flagent { unsigned m; } flagent; -static flagent flagtab[] = { +static const flagent flagtab[] = { /* --- Encoding types --- */ @@ -71,6 +60,8 @@ static flagent flagtab[] = { { "integer", KENC_MP, KF_ENCMASK }, { "struct", KENC_STRUCT, KF_ENCMASK }, { "encrypt", KENC_ENCRYPT, KF_ENCMASK }, + { "string", KENC_STRING, KF_ENCMASK }, + { "ec", KENC_EC, KF_ENCMASK }, /* --- Classes of keys --- */ @@ -111,10 +102,12 @@ int key_readflags(const char *p, char **pp, unsigned *ff, unsigned *mm) for (;;) { size_t sz = strcspn(p, ",:"); - flagent *e, *ee = 0; + const flagent *e, *ee = 0; /* --- Look up the string in the flags table --- */ + if (sz == 4 && strncmp(p, "none", 4) == 0) + goto next; for (e = flagtab; e->name; e++) { if (strncmp(e->name, p, sz) == 0) { if (e->name[sz] == 0) { @@ -138,6 +131,7 @@ int key_readflags(const char *p, char **pp, unsigned *ff, unsigned *mm) return (KERR_BADFLAGS); m |= ee->m; f |= ee->f; + next: p += sz; if (*p == 0 || *p == ':') break; @@ -165,7 +159,7 @@ int key_readflags(const char *p, char **pp, unsigned *ff, unsigned *mm) void key_writeflags(unsigned f, dstr *d) { int del = 0; - flagent *e; + const flagent *e; unsigned m = 0; for (e = flagtab; e->name; e++) { @@ -191,16 +185,17 @@ void key_writeflags(unsigned f, dstr *d) int key_match(key_data *k, const key_filter *kf) { - sym_iter i; - key_struct *ks; + key_subkeyiter i; + const char *tag; + key_data *kd; if (!kf) return (1); if ((k->e & KF_ENCMASK) != KENC_STRUCT) return ((k->e & kf->m) == kf->f); - for (sym_mkiter(&i, &k->u.s); (ks = sym_next(&i)) != 0; ) { - if (key_match(&ks->k, kf)) + for (key_mksubkeyiter(&i, k); key_nextsubkey(&i, &tag, &kd); ) { + if (key_match(kd, kf)) return (1); } return (0);