X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pgplib.c;h=d9e5ff9f53aae23aa9a5d34ae012cd7a6c9103a9;hp=258b1c3cb1544ffeea9d945b016b9161b2e6da53;hb=d9960a434f5c00a534a0dabe02ae5ab8d4881569;hpb=f404a0ca916be07049af51a3022baaaaab94def6 diff --git a/pgplib.c b/pgplib.c index 258b1c3..d9e5ff9 100644 --- a/pgplib.c +++ b/pgplib.c @@ -1,22 +1,10 @@ /* + * 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. */ @@ -31,14 +19,15 @@ #include #include +#include + #include "mutt.h" #include "lib.h" #include "pgplib.h" const char *pgp_pkalgbytype (unsigned char type) { - switch (type) - { + switch (type) { case 1: return "RSA"; case 2: @@ -64,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: @@ -83,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: @@ -97,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: @@ -121,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); + p_delete(&sp); } - + *sigp = NULL; } @@ -143,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); + p_delete(&up->addr); + p_delete(&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 = p_new(pgp_uid_t, 1); + (*lp)->trust = up->trust; + (*lp)->flags = up->flags; + (*lp)->addr = m_strdup(up->addr); (*lp)->parent = parent; lp = &(*lp)->next; } @@ -172,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; @@ -182,11 +165,11 @@ static void _pgp_free_key (pgp_key_t *kpp) kp = *kpp; pgp_free_uid (&kp->address); - FREE (&kp->keyid); - FREE (kpp); + p_delete(&kp->keyid); + p_delete(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; @@ -214,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; @@ -223,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. @@ -232,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); } @@ -247,4 +228,3 @@ void pgp_free_key (pgp_key_t *kpp) *kpp = NULL; } -