X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pgplib.c;h=26b029bc0d6828d8aaa5f7f9d54874e8988d212c;hp=a271881602fc4be4a78b40102626386e000da60e;hb=75291cb065ec25499a125665cba1123ee4c64abf;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/pgplib.c b/pgplib.c index a271881..26b029b 100644 --- a/pgplib.c +++ b/pgplib.c @@ -1,26 +1,18 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1997-2000 Thomas Roessler - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later - * version. - * - * This program 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 General Public License for more - * details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111, USA. + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. */ /* Generally useful, pgp-related functions. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include @@ -31,10 +23,11 @@ #include "lib.h" #include "pgplib.h" +#include "lib/mem.h" + const char *pgp_pkalgbytype (unsigned char type) { - switch (type) - { + switch (type) { case 1: return "RSA"; case 2: @@ -60,8 +53,7 @@ const char *pgp_pkalgbytype (unsigned char type) static const char *hashalgbytype (unsigned char type) { - switch (type) - { + switch (type) { case 1: return "MD5"; case 2: @@ -79,8 +71,7 @@ static const char *hashalgbytype (unsigned char type) short pgp_canencrypt (unsigned char type) { - switch (type) - { + switch (type) { case 1: case 2: case 16: @@ -93,8 +84,7 @@ short pgp_canencrypt (unsigned char type) short pgp_cansign (unsigned char type) { - switch (type) - { + switch (type) { case 1: case 3: case 17: @@ -117,19 +107,18 @@ short pgp_get_abilities (unsigned char type) return (pgp_canencrypt (type) << 1) | pgp_cansign (type); } -void pgp_free_sig (pgp_sig_t **sigp) +void pgp_free_sig (pgp_sig_t ** sigp) { pgp_sig_t *sp, *q; - + if (!sigp || !*sigp) return; - - for (sp = *sigp; sp; sp = q) - { + + for (sp = *sigp; sp; sp = q) { q = sp->next; - FREE (&sp); + mem_free (&sp); } - + *sigp = NULL; } @@ -139,28 +128,26 @@ void pgp_free_uid (pgp_uid_t ** upp) if (!upp || !*upp) return; - for (up = *upp; up; up = q) - { + for (up = *upp; up; up = q) { q = up->next; pgp_free_sig (&up->sigs); - FREE (&up->addr); - FREE (&up); + mem_free (&up->addr); + mem_free (&up); } *upp = NULL; } -pgp_uid_t *pgp_copy_uids (pgp_uid_t *up, pgp_key_t parent) +pgp_uid_t *pgp_copy_uids (pgp_uid_t * up, pgp_key_t parent) { pgp_uid_t *l = NULL; pgp_uid_t **lp = &l; - for (; up; up = up->next) - { - *lp = safe_calloc (1, sizeof (pgp_uid_t)); - (*lp)->trust = up->trust; - (*lp)->flags = up->flags; - (*lp)->addr = safe_strdup (up->addr); + for (; up; up = up->next) { + *lp = mem_calloc (1, sizeof (pgp_uid_t)); + (*lp)->trust = up->trust; + (*lp)->flags = up->flags; + (*lp)->addr = str_dup (up->addr); (*lp)->parent = parent; lp = &(*lp)->next; } @@ -168,7 +155,7 @@ pgp_uid_t *pgp_copy_uids (pgp_uid_t *up, pgp_key_t parent) return l; } -static void _pgp_free_key (pgp_key_t *kpp) +static void _pgp_free_key (pgp_key_t * kpp) { pgp_key_t kp; @@ -178,11 +165,11 @@ static void _pgp_free_key (pgp_key_t *kpp) kp = *kpp; pgp_free_uid (&kp->address); - FREE (&kp->keyid); - FREE (kpp); + mem_free (&kp->keyid); + mem_free (kpp); } -pgp_key_t pgp_remove_key (pgp_key_t *klist, pgp_key_t key) +pgp_key_t pgp_remove_key (pgp_key_t * klist, pgp_key_t key) { pgp_key_t *last; pgp_key_t p, q, r; @@ -210,7 +197,7 @@ pgp_key_t pgp_remove_key (pgp_key_t *klist, pgp_key_t key) return q; } -void pgp_free_key (pgp_key_t *kpp) +void pgp_free_key (pgp_key_t * kpp) { pgp_key_t p, q, r; @@ -219,7 +206,7 @@ void pgp_free_key (pgp_key_t *kpp) if ((*kpp)->parent && (*kpp)->parent != *kpp) *kpp = (*kpp)->parent; - + /* Order is important here: * * - First free all children. @@ -228,10 +215,8 @@ void pgp_free_key (pgp_key_t *kpp) * - free ourselves. */ - for (p = *kpp; p; p = q) - { - for (q = p->next; q && q->parent == p; q = r) - { + for (p = *kpp; p; p = q) { + for (q = p->next; q && q->parent == p; q = r) { r = q->next; _pgp_free_key (&q); } @@ -243,4 +228,3 @@ void pgp_free_key (pgp_key_t *kpp) *kpp = NULL; } -