GNUnet  0.10.x
regex_internal_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 */
26 #ifndef REGEX_INTERNAL_LIB_H
27 #define REGEX_INTERNAL_LIB_H
28 
29 #include "gnunet_util_lib.h"
30 #include "gnunet_dht_service.h"
32 #include "regex_block_lib.h"
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #if 0 /* keep Emacsens' auto-indent happy */
38 }
39 #endif
40 #endif
41 
42 
47 
48 
68  const size_t len,
69  unsigned int max_path_len);
70 
71 
78 void
80 
81 
90 int
92  const char *string);
93 
94 
105 size_t
106 REGEX_INTERNAL_get_first_key (const char *input_string,
107  size_t string_len,
108  struct GNUNET_HashCode * key);
109 
110 
121 typedef void
123  const struct GNUNET_HashCode *key,
124  const char *proof,
125  int accepting,
126  unsigned int num_edges,
127  const struct REGEX_BLOCK_Edge *edges);
128 
129 
138 void
141  void *iterator_cls);
142 
143 
154 void
157  void *iterator_cls);
158 
159 
160 
165 
169 struct REGEX_INTERNAL_Search;
170 
171 
186  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
187  const char *regex,
188  uint16_t compression,
190 
191 
198 void
200 
201 
208 void
210 
211 
222 typedef void
223 (*REGEX_INTERNAL_Found)(void *cls,
224  const struct GNUNET_PeerIdentity *id,
225  const struct GNUNET_PeerIdentity *get_path,
226  unsigned int get_path_length,
227  const struct GNUNET_PeerIdentity *put_path,
228  unsigned int put_path_length);
229 
230 
244 struct REGEX_INTERNAL_Search *
246  const char *string,
248  void *callback_cls,
250 
257 void
259 
260 
261 #if 0 /* keep Emacsens' auto-indent happy */
262 {
263 #endif
264 #ifdef __cplusplus
265 }
266 #endif
267 
268 /* end of regex_internal_lib.h */
269 #endif
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
void REGEX_INTERNAL_automaton_destroy(struct REGEX_INTERNAL_Automaton *a)
Free the memory allocated by constructing the REGEX_INTERNAL_Automaton.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Automaton representation.
void REGEX_INTERNAL_iterate_all_edges(struct REGEX_INTERNAL_Automaton *a, REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
Iterate over all edges starting from start state of automaton &#39;a&#39;.
Handle for the service.
Edge representation.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
Connection to the DHT service.
Definition: dht_api.c:205
struct REGEX_INTERNAL_Automaton * REGEX_INTERNAL_construct_dfa(const char *regex, const size_t len, unsigned int max_path_len)
Construct DFA for the given &#39;regex&#39; of length &#39;len&#39;.
static uint64_t proof
Definition: gnunet-scrypt.c:41
int REGEX_INTERNAL_eval(struct REGEX_INTERNAL_Automaton *a, const char *string)
Evaluates the given &#39;string&#39; against the given compiled regex.
void(* REGEX_INTERNAL_KeyIterator)(void *cls, const struct GNUNET_HashCode *key, const char *proof, int accepting, unsigned int num_edges, const struct REGEX_BLOCK_Edge *edges)
Iterator callback function.
Handle to store cached data about a regex announce.
void REGEX_INTERNAL_search_cancel(struct REGEX_INTERNAL_Search *h)
Stop search and free all data used by a REGEX_INTERNAL_search() call.
A 512-bit hashcode.
void REGEX_INTERNAL_iterate_reachable_edges(struct REGEX_INTERNAL_Automaton *a, REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
Iterate over all edges of automaton &#39;a&#39; that are reachable from a state with a proof of at least GNUN...
void(* REGEX_INTERNAL_Found)(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length)
Search callback function.
struct GNUNET_HashCode key
The key used in the DHT.
Struct to keep information of searches of services described by a regex using a user-provided string ...
Private ECC key encoded for transmission.
struct REGEX_INTERNAL_Search * REGEX_INTERNAL_search(struct GNUNET_DHT_Handle *dht, const char *string, REGEX_INTERNAL_Found callback, void *callback_cls, struct GNUNET_STATISTICS_Handle *stats)
Search for a peer offering a regex matching certain string in the DHT.
The identity of the host (wraps the signing key of the peer).
common function to manipulate blocks stored by regex in the DHT
REGEX_INTERNAL_Found callback
const char * regex
Regular expression.
size_t REGEX_INTERNAL_get_first_key(const char *input_string, size_t string_len, struct GNUNET_HashCode *key)
Get the first key for the given input_string.
const struct GNUNET_CRYPTO_EddsaPrivateKey * priv
Our private key.
static struct GNUNET_DHT_Handle * dht
Handle to the DHT.
struct REGEX_INTERNAL_Announcement * REGEX_INTERNAL_announce(struct GNUNET_DHT_Handle *dht, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *regex, uint16_t compression, struct GNUNET_STATISTICS_Handle *stats)
Announce a regular expression: put all states of the automaton in the DHT.
void REGEX_INTERNAL_reannounce(struct REGEX_INTERNAL_Announcement *h)
Announce again a regular expression previously announced.
void REGEX_INTERNAL_announce_cancel(struct REGEX_INTERNAL_Announcement *h)
Clear all cached data used by a regex announce.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...