libpcp  0.2.1
keyhash.h
1 /*
2  This file is part of Pretty Curved Privacy (pcp1).
3 
4  Copyright (C) 2013 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 
35 #include "uthash.h"
36 #include "key.h"
37 
38 /* storage of keys in a global hash */
39 
41 extern pcp_key_t *pcpkey_hash;
42 
45 
46 extern pcp_key_t *__k;
47 extern pcp_pubkey_t *__p;
48 
49 /* wrapper for HASH_ITER */
64 #define pcphash_iterate(key) \
65  __k = NULL; \
66  HASH_ITER(hh, pcpkey_hash, key, __k)
67 
68 
83 #define pcphash_iteratepub(key) \
84  __p = NULL; \
85  HASH_ITER(hh, pcppubkey_hash, key, __p)
86 
88 void pcphash_init();
89 
97 void pcphash_del(void *key, int type);
98 
105 void pcphash_clean();
106 
113 pcp_key_t *pcphash_keyexists(char *id);
114 
122 
129 void pcphash_add(void *key, int type);
130 
135 int pcphash_count();
136 
141 int pcphash_countpub();
142 
144 extern pcp_keysig_t *pcpkeysig_hash;
145 extern pcp_keysig_t *__s;
146 
147 #define pcphash_iteratekeysig(key) \
148  __s = NULL; \
149  HASH_ITER(hh, pcpkeysig_hash, key, __s)
150 
151 pcp_keysig_t *pcphash_keysigexists(char *id);
152 
153 #endif /* _HAVE_KEYHASH_H */
154