diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regex/regex_block_lib.c | 43 | ||||
-rw-r--r-- | src/regex/regex_internal.c | 64 | ||||
-rw-r--r-- | src/regex/regex_internal.h | 4 | ||||
-rw-r--r-- | src/regex/regex_internal_dht.c | 6 |
4 files changed, 2 insertions, 115 deletions
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index cbfb553ce..048d6d743 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c | |||
@@ -110,14 +110,6 @@ GNUNET_BLOCK_is_accepting (const struct RegexBlock *block, | |||
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | /** | ||
114 | * Check if the given 'proof' matches the given 'key'. | ||
115 | * | ||
116 | * @param proof partial regex of a state | ||
117 | * @param proof_len number of bytes in 'proof' | ||
118 | * @param key hash of a state. | ||
119 | * @return #GNUNET_OK if the proof is valid for the given key. | ||
120 | */ | ||
121 | int | 113 | int |
122 | REGEX_BLOCK_check_proof (const char *proof, | 114 | REGEX_BLOCK_check_proof (const char *proof, |
123 | size_t proof_len, | 115 | size_t proof_len, |
@@ -187,18 +179,6 @@ check_edge (void *cls, | |||
187 | } | 179 | } |
188 | 180 | ||
189 | 181 | ||
190 | /** | ||
191 | * Check if the regex block is well formed, including all edges. | ||
192 | * | ||
193 | * @param block The start of the block. | ||
194 | * @param size The size of the block. | ||
195 | * @param query the query for the block | ||
196 | * @param xquery String describing the edge we are looking for. | ||
197 | * Can be NULL in case this is a put block. | ||
198 | * @return #GNUNET_OK in case it's fine. | ||
199 | * #GNUNET_NO in case the xquery exists and is not found (IRRELEVANT). | ||
200 | * #GNUNET_SYSERR if the block is invalid. | ||
201 | */ | ||
202 | int | 182 | int |
203 | REGEX_BLOCK_check (const struct RegexBlock *block, | 183 | REGEX_BLOCK_check (const struct RegexBlock *block, |
204 | size_t size, | 184 | size_t size, |
@@ -246,14 +226,6 @@ REGEX_BLOCK_check (const struct RegexBlock *block, | |||
246 | } | 226 | } |
247 | 227 | ||
248 | 228 | ||
249 | /** | ||
250 | * Obtain the key that a particular block is to be stored under. | ||
251 | * | ||
252 | * @param block block to get the key from | ||
253 | * @param block_len number of bytes in block | ||
254 | * @param key where to store the key | ||
255 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block is malformed | ||
256 | */ | ||
257 | int | 229 | int |
258 | REGEX_BLOCK_get_key (const struct RegexBlock *block, | 230 | REGEX_BLOCK_get_key (const struct RegexBlock *block, |
259 | size_t block_len, | 231 | size_t block_len, |
@@ -289,21 +261,6 @@ REGEX_BLOCK_get_key (const struct RegexBlock *block, | |||
289 | } | 261 | } |
290 | 262 | ||
291 | 263 | ||
292 | /** | ||
293 | * Iterate over all edges of a block of a regex state. | ||
294 | * | ||
295 | * @param block Block to iterate over. | ||
296 | * @param size Size of @a block. | ||
297 | * @param iterator Function to call on each edge in the block. | ||
298 | * @param iter_cls Closure for the @a iterator. | ||
299 | * @return #GNUNET_SYSERR if an error has been encountered. | ||
300 | * #GNUNET_OK if no error has been encountered. | ||
301 | * Note that if the iterator stops the iteration by returning | ||
302 | * #GNUNET_NO, the block will no longer be checked for further errors. | ||
303 | * The return value will be GNUNET_OK meaning that no errors were | ||
304 | * found until the edge last notified to the iterator, but there might | ||
305 | * be errors in further edges. | ||
306 | */ | ||
307 | int | 264 | int |
308 | REGEX_BLOCK_iterate (const struct RegexBlock *block, | 265 | REGEX_BLOCK_iterate (const struct RegexBlock *block, |
309 | size_t size, | 266 | size_t size, |
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index aa40851a9..c4fab6b56 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -501,19 +501,6 @@ automaton_state_traverse (struct REGEX_INTERNAL_State *s, | |||
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | /** | ||
505 | * Traverses the given automaton using depth-first-search (DFS) from it's start | ||
506 | * state, visiting all reachable states and calling 'action' on each one of | ||
507 | * them. | ||
508 | * | ||
509 | * @param a automaton to be traversed. | ||
510 | * @param start start state, pass a->start or NULL to traverse the whole automaton. | ||
511 | * @param check function that is checked before advancing on each transition | ||
512 | * in the DFS. | ||
513 | * @param check_cls closure for @a check. | ||
514 | * @param action action to be performed on each state. | ||
515 | * @param action_cls closure for @a action | ||
516 | */ | ||
517 | void | 504 | void |
518 | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, | 505 | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, |
519 | struct REGEX_INTERNAL_State *start, | 506 | struct REGEX_INTERNAL_State *start, |
@@ -3041,23 +3028,6 @@ construct_dfa_states (struct REGEX_INTERNAL_Context *ctx, | |||
3041 | } | 3028 | } |
3042 | 3029 | ||
3043 | 3030 | ||
3044 | /** | ||
3045 | * Construct DFA for the given 'regex' of length 'len'. | ||
3046 | * | ||
3047 | * Path compression means, that for example a DFA o -> a -> b -> c -> o will be | ||
3048 | * compressed to o -> abc -> o. Note that this parameter influences the | ||
3049 | * non-determinism of states of the resulting NFA in the DHT (number of outgoing | ||
3050 | * edges with the same label). For example for an application that stores IPv4 | ||
3051 | * addresses as bitstrings it could make sense to limit the path compression to | ||
3052 | * 4 or 8. | ||
3053 | * | ||
3054 | * @param regex regular expression string. | ||
3055 | * @param len length of the regular expression. | ||
3056 | * @param max_path_len limit the path compression length to the | ||
3057 | * given value. If set to 1, no path compression is applied. Set to 0 for | ||
3058 | * maximal possible path compression (generally not desirable). | ||
3059 | * @return DFA, needs to be freed using REGEX_INTERNAL_automaton_destroy. | ||
3060 | */ | ||
3061 | struct REGEX_INTERNAL_Automaton * | 3031 | struct REGEX_INTERNAL_Automaton * |
3062 | REGEX_INTERNAL_construct_dfa (const char *regex, | 3032 | REGEX_INTERNAL_construct_dfa (const char *regex, |
3063 | const size_t len, | 3033 | const size_t len, |
@@ -3118,12 +3088,6 @@ REGEX_INTERNAL_construct_dfa (const char *regex, | |||
3118 | } | 3088 | } |
3119 | 3089 | ||
3120 | 3090 | ||
3121 | /** | ||
3122 | * Free the memory allocated by constructing the REGEX_INTERNAL_Automaton data | ||
3123 | * structure. | ||
3124 | * | ||
3125 | * @param a automaton to be destroyed | ||
3126 | */ | ||
3127 | void | 3091 | void |
3128 | REGEX_INTERNAL_automaton_destroy (struct REGEX_INTERNAL_Automaton *a) | 3092 | REGEX_INTERNAL_automaton_destroy (struct REGEX_INTERNAL_Automaton *a) |
3129 | { | 3093 | { |
@@ -3251,13 +3215,6 @@ evaluate_nfa (struct REGEX_INTERNAL_Automaton *a, const char *string) | |||
3251 | } | 3215 | } |
3252 | 3216 | ||
3253 | 3217 | ||
3254 | /** | ||
3255 | * Evaluates the given @a string against the given compiled regex @a a | ||
3256 | * | ||
3257 | * @param a automaton | ||
3258 | * @param string string to check | ||
3259 | * @return 0 if string matches, non-0 otherwise | ||
3260 | */ | ||
3261 | int | 3218 | int |
3262 | REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a, const char *string) | 3219 | REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a, const char *string) |
3263 | { | 3220 | { |
@@ -3284,17 +3241,6 @@ REGEX_INTERNAL_eval (struct REGEX_INTERNAL_Automaton *a, const char *string) | |||
3284 | } | 3241 | } |
3285 | 3242 | ||
3286 | 3243 | ||
3287 | /** | ||
3288 | * Get the canonical regex of the given automaton. | ||
3289 | * When constructing the automaton a proof is computed for each state, | ||
3290 | * consisting of the regular expression leading to this state. A complete | ||
3291 | * regex for the automaton can be computed by combining these proofs. | ||
3292 | * As of now this function is only useful for testing. | ||
3293 | * | ||
3294 | * @param a automaton for which the canonical regex should be returned. | ||
3295 | * | ||
3296 | * @return | ||
3297 | */ | ||
3298 | const char * | 3244 | const char * |
3299 | REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a) | 3245 | REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a) |
3300 | { | 3246 | { |
@@ -3685,16 +3631,6 @@ iterate_reachables (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
3685 | } | 3631 | } |
3686 | 3632 | ||
3687 | 3633 | ||
3688 | /** | ||
3689 | * Iterate over all edges of automaton 'a' that are reachable from a state with | ||
3690 | * a proof of at least GNUNET_REGEX_INITIAL_BYTES characters. | ||
3691 | * | ||
3692 | * Call the iterator for each such edge. | ||
3693 | * | ||
3694 | * @param a automaton. | ||
3695 | * @param iterator iterator called for each reachable edge. | ||
3696 | * @param iterator_cls closure. | ||
3697 | */ | ||
3698 | void | 3634 | void |
3699 | REGEX_INTERNAL_iterate_reachable_edges (struct REGEX_INTERNAL_Automaton *a, | 3635 | REGEX_INTERNAL_iterate_reachable_edges (struct REGEX_INTERNAL_Automaton *a, |
3700 | REGEX_INTERNAL_KeyIterator iterator, | 3636 | REGEX_INTERNAL_KeyIterator iterator, |
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index 5b434b30c..8d4526d1f 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -368,9 +368,9 @@ typedef void | |||
368 | * @param start start state, pass a->start or NULL to traverse the whole automaton. | 368 | * @param start start state, pass a->start or NULL to traverse the whole automaton. |
369 | * @param check function that is checked before advancing on each transition | 369 | * @param check function that is checked before advancing on each transition |
370 | * in the DFS. | 370 | * in the DFS. |
371 | * @param check_cls closure for check. | 371 | * @param check_cls closure for @a check. |
372 | * @param action action to be performed on each state. | 372 | * @param action action to be performed on each state. |
373 | * @param action_cls closure for action | 373 | * @param action_cls closure for @a action |
374 | */ | 374 | */ |
375 | void | 375 | void |
376 | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, | 376 | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, |
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index e578fba2c..bda979edb 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c | |||
@@ -216,12 +216,6 @@ REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, | |||
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | /** | ||
220 | * Announce again a regular expression previously announced. | ||
221 | * Does use caching to speed up process. | ||
222 | * | ||
223 | * @param h Handle returned by a previous #REGEX_INTERNAL_announce call(). | ||
224 | */ | ||
225 | void | 219 | void |
226 | REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) | 220 | REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) |
227 | { | 221 | { |