GNUnet  0.10.x
regex_block_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012,2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
27 #ifndef REGEX_BLOCK_LIB_H_
28 #define REGEX_BLOCK_LIB_H_
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #if 0
34 /* keep Emacsens' auto-indent happy */
35 }
36 #endif
37 #endif
38 
39 #include "platform.h"
40 #include "block_regex.h"
41 
42 
46 struct RegexBlock;
47 
48 
57  const char *label;
58 
63 };
64 
65 
74 int
75 REGEX_BLOCK_check_proof(const char *proof,
76  size_t proof_len,
77  const struct GNUNET_HashCode *key);
78 
79 
92 int
93 REGEX_BLOCK_check(const struct RegexBlock *block,
94  size_t size,
95  const struct GNUNET_HashCode *query,
96  const char *xquery);
97 
98 
99 /* FIXME: might want to use 'struct REGEX_BLOCK_Edge' here instead of 3 arguments! */
100 
110 typedef int
112  const char *token,
113  size_t len,
114  const struct GNUNET_HashCode *key);
115 
116 
132 int
133 REGEX_BLOCK_iterate(const struct RegexBlock *block,
134  size_t size,
136  void *iter_cls);
137 
138 
147 int
148 REGEX_BLOCK_get_key(const struct RegexBlock *block,
149  size_t block_len,
150  struct GNUNET_HashCode *key);
151 
152 
160 int
161 GNUNET_BLOCK_is_accepting(const struct RegexBlock *block,
162  size_t block_len);
163 
164 
175 struct RegexBlock *
176 REGEX_BLOCK_create(const char *proof,
177  unsigned int num_edges,
178  const struct REGEX_BLOCK_Edge *edges,
179  int accepting,
180  size_t *rsize);
181 
182 
183 #if 0 /* keep Emacsens' auto-indent happy */
184 {
185 #endif
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 /* ifndef REGEX_BLOCK_LIB_H */
191 #endif
192 /* end of regex_block_lib.h */
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
int(* REGEX_INTERNAL_EgdeIterator)(void *cls, const char *token, size_t len, const struct GNUNET_HashCode *key)
Iterator over edges in a block.
struct GNUNET_HashCode destination
Destionation of the edge.
int REGEX_BLOCK_check_proof(const char *proof, size_t proof_len, const struct GNUNET_HashCode *key)
Check if the given &#39;proof&#39; matches the given &#39;key&#39;.
int GNUNET_BLOCK_is_accepting(const struct RegexBlock *block, size_t block_len)
Test if this block is marked as being an accept state.
uint16_t num_edges
Number of edges parting from this state.
struct RegexBlock * REGEX_BLOCK_create(const char *proof, unsigned int num_edges, const struct REGEX_BLOCK_Edge *edges, int accepting, size_t *rsize)
Construct a regex block to be stored in the DHT.
Block to announce a regex state.
Edge representation.
int REGEX_BLOCK_get_key(const struct RegexBlock *block, size_t block_len, struct GNUNET_HashCode *key)
Obtain the key that a particular block is to be stored under.
static uint64_t proof
Definition: gnunet-scrypt.c:41
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
Definition: peer.c:66
int REGEX_BLOCK_check(const struct RegexBlock *block, size_t size, const struct GNUNET_HashCode *query, const char *xquery)
Check if the regex block is well formed, including all edges.
const char * label
Label of the edge.
int REGEX_BLOCK_iterate(const struct RegexBlock *block, size_t size, REGEX_INTERNAL_EgdeIterator iterator, void *iter_cls)
Iterate over all edges of a block of a regex state.
regex block formats
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...