keyhash.h
1 /*
2  This file is part of Pretty Curved Privacy (pcp1).
3 
4  Copyright (C) 2013-2015 T.Linden.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19  You can contact me by mail: <tlinden AT cpan DOT org>.
20 */
21 
22 #ifndef _HAVE_KEYHASH_H
23 #define _HAVE_KEYHASH_H
24 
25 #include "structs.h"
26 
27 
28 
42 /* wrapper for HASH_ITER */
57 #define pcphash_iterate(ptx, key) \
58  pcp_key_t *__k = NULL; \
59  HASH_ITER(hh, ptx->pcpkey_hash, key, __k)
60 
61 
76 #define pcphash_iteratepub(ptx, key) \
77  pcp_pubkey_t *__p = NULL; \
78  HASH_ITER(hh, ptx->pcppubkey_hash, key, __p)
79 
89 void pcphash_del(PCPCTX *ptx, void *key, int type);
90 
92 void pcphash_clean(PCPCTX *ptx);
93 
96 
105 pcp_key_t *pcphash_keyexists(PCPCTX *ptx, char *id);
106 
115 pcp_pubkey_t *pcphash_pubkeyexists(PCPCTX *ptx, char *id);
116 
125 void pcphash_add(PCPCTX *ptx, void *key, int type);
126 
133 int pcphash_count(PCPCTX *ptx);
134 
141 int pcphash_countpub(PCPCTX *ptx);
142 
143 
144 
145 #define pcphash_iteratekeysig(ptx, key) \
146  pcp_keysig_t *__s = NULL; \
147  HASH_ITER(hh, ptx->pcpkeysig_hash, key, __s)
148 
149 pcp_keysig_t *pcphash_keysigexists(PCPCTX *ptx, char *id);
150 
151 #endif /* _HAVE_KEYHASH_H */
152