GNUnet  0.17.6
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
122 (*REGEX_INTERNAL_KeyIterator)(void *cls,
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 
164 
168 struct REGEX_INTERNAL_Search;
169 
170 
185  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
186  const char *regex,
187  uint16_t compression,
189 
190 
197 void
199 
200 
207 void
209 
210 
221 typedef void
222 (*REGEX_INTERNAL_Found)(void *cls,
223  const struct GNUNET_PeerIdentity *id,
224  const struct GNUNET_DHT_PathElement *get_path,
225  unsigned int get_path_length,
226  const struct GNUNET_DHT_PathElement *put_path,
227  unsigned int put_path_length);
228 
229 
243 struct REGEX_INTERNAL_Search *
245  const char *string,
247  void *callback_cls,
249 
256 void
258 
259 
260 #if 0 /* keep Emacsens' auto-indent happy */
261 {
262 #endif
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 /* end of regex_internal_lib.h */
268 #endif
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static struct GNUNET_DHT_Handle * dht
Handle to the DHT.
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static uint64_t proof
Definition: gnunet-scrypt.c:48
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
API to the DHT service.
API to create, modify and access statistics.
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
common function to manipulate blocks stored by regex in the DHT
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.
void REGEX_INTERNAL_search_cancel(struct REGEX_INTERNAL_Search *h)
Stop search and free all data used by a REGEX_INTERNAL_search() call.
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 'a'.
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.
void(* REGEX_INTERNAL_Found)(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length)
Search callback function.
int REGEX_INTERNAL_eval(struct REGEX_INTERNAL_Automaton *a, const char *string)
Evaluates the given 'string' against the given compiled regex.
void REGEX_INTERNAL_iterate_reachable_edges(struct REGEX_INTERNAL_Automaton *a, REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
Iterate over all edges of automaton 'a' that are reachable from a state with a proof of at least GNUN...
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.
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 'regex' of length 'len'.
void REGEX_INTERNAL_announce_cancel(struct REGEX_INTERNAL_Announcement *h)
Clear all cached data used by a regex announce.
void REGEX_INTERNAL_reannounce(struct REGEX_INTERNAL_Announcement *h)
Announce again a regular expression previously announced.
void REGEX_INTERNAL_automaton_destroy(struct REGEX_INTERNAL_Automaton *a)
Free the memory allocated by constructing the REGEX_INTERNAL_Automaton.
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.
Private ECC key encoded for transmission.
Connection to the DHT service.
Definition: dht_api.c:237
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
Handle for the service.
Edge representation.
Handle to store cached data about a regex announce.
const struct GNUNET_CRYPTO_EddsaPrivateKey * priv
Our private key.
const char * regex
Regular expression.
Automaton representation.
Struct to keep information of searches of services described by a regex using a user-provided string ...
REGEX_INTERNAL_Found callback