aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/gnunet-regex-profiler.c83
-rw-r--r--src/regex/gnunet-service-regex.c22
-rw-r--r--src/regex/regex_internal.h15
-rw-r--r--src/regex/regex_internal_dht.c8
-rw-r--r--src/regex/regex_internal_lib.h4
5 files changed, 65 insertions, 67 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index bd223ae8e..75a1d2f99 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -23,11 +23,7 @@
23 * @brief Regex profiler for testing distributed regex use. 23 * @brief Regex profiler for testing distributed regex use.
24 * @author Bartlomiej Polot 24 * @author Bartlomiej Polot
25 * @author Maximilian Szengel 25 * @author Maximilian Szengel
26 *
27 */ 26 */
28
29#include <string.h>
30
31#include "platform.h" 27#include "platform.h"
32#include "gnunet_applications.h" 28#include "gnunet_applications.h"
33#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
@@ -727,9 +723,9 @@ find_string (void *cls);
727static void 723static void
728regex_found_handler (void *cls, 724regex_found_handler (void *cls,
729 const struct GNUNET_PeerIdentity *id, 725 const struct GNUNET_PeerIdentity *id,
730 const struct GNUNET_PeerIdentity *get_path, 726 const struct GNUNET_DHT_PathElement *get_path,
731 unsigned int get_path_length, 727 unsigned int get_path_length,
732 const struct GNUNET_PeerIdentity *put_path, 728 const struct GNUNET_DHT_PathElement *put_path,
733 unsigned int put_path_length) 729 unsigned int put_path_length)
734{ 730{
735 struct RegexPeer *peer = cls; 731 struct RegexPeer *peer = cls;
@@ -1558,53 +1554,56 @@ int
1558main (int argc, char *const *argv) 1554main (int argc, char *const *argv)
1559{ 1555{
1560 struct GNUNET_GETOPT_CommandLineOption options[] = { 1556 struct GNUNET_GETOPT_CommandLineOption options[] = {
1561 GNUNET_GETOPT_option_filename ('o', 1557 GNUNET_GETOPT_option_filename (
1562 "output-file", 1558 'o',
1563 "FILENAME", 1559 "output-file",
1564 gettext_noop ( 1560 "FILENAME",
1565 "name of the file for writing statistics"), 1561 gettext_noop (
1566 &data_filename), 1562 "name of the file for writing statistics"),
1567 1563 &data_filename),
1568 GNUNET_GETOPT_option_relative_time ('t', 1564 GNUNET_GETOPT_option_relative_time (
1569 "matching-timeout", 1565 't',
1570 "TIMEOUT", 1566 "matching-timeout",
1571 gettext_noop ( 1567 "TIMEOUT",
1572 "wait TIMEOUT before ending the experiment"), 1568 gettext_noop (
1573 &search_timeout_time), 1569 "wait TIMEOUT before ending the experiment"),
1574 1570 &search_timeout_time),
1575 GNUNET_GETOPT_option_filename ('p', 1571 GNUNET_GETOPT_option_filename (
1576 "policy-dir", 1572 'p',
1577 "DIRECTORY", 1573 "policy-dir",
1578 gettext_noop ("directory with policy files"), 1574 "DIRECTORY",
1579 &policy_dir), 1575 gettext_noop ("directory with policy files"),
1580 1576 &policy_dir),
1581 1577 GNUNET_GETOPT_option_filename (
1582 GNUNET_GETOPT_option_filename ('s', 1578 's',
1583 "strings-file", 1579 "strings-file",
1584 "FILENAME", 1580 "FILENAME",
1585 gettext_noop ( 1581 gettext_noop (
1586 "name of file with input strings"), 1582 "name of file with input strings"),
1587 &strings_file), 1583 &strings_file),
1588 1584 GNUNET_GETOPT_option_filename (
1589 GNUNET_GETOPT_option_filename ('H', 1585 'H',
1590 "hosts-file", 1586 "hosts-file",
1591 "FILENAME", 1587 "FILENAME",
1592 gettext_noop ( 1588 gettext_noop (
1593 "name of file with hosts' names"), 1589 "name of file with hosts' names"),
1594 &hosts_file), 1590 &hosts_file),
1595 1591
1596 GNUNET_GETOPT_OPTION_END 1592 GNUNET_GETOPT_OPTION_END
1597 }; 1593 };
1598 int ret; 1594 int ret;
1599 1595
1600 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 1596 if (GNUNET_OK !=
1597 GNUNET_STRINGS_get_utf8_args (argc, argv,
1598 &argc, &argv))
1601 return 2; 1599 return 2;
1602 result = GNUNET_SYSERR; 1600 result = GNUNET_SYSERR;
1603 ret = 1601 ret =
1604 GNUNET_PROGRAM_run (argc, argv, 1602 GNUNET_PROGRAM_run (argc, argv,
1605 "gnunet-regex-profiler", 1603 "gnunet-regex-profiler",
1606 _ ("Profiler for regex"), 1604 _ ("Profiler for regex"),
1607 options, &run, NULL); 1605 options,
1606 &run, NULL);
1608 if (GNUNET_OK != ret) 1607 if (GNUNET_OK != ret)
1609 return ret; 1608 return ret;
1610 if (GNUNET_OK != result) 1609 if (GNUNET_OK != result)
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c
index 7a5cc1f05..deaa6112e 100644
--- a/src/regex/gnunet-service-regex.c
+++ b/src/regex/gnunet-service-regex.c
@@ -196,9 +196,9 @@ handle_announce (void *cls,
196static void 196static void
197handle_search_result (void *cls, 197handle_search_result (void *cls,
198 const struct GNUNET_PeerIdentity *id, 198 const struct GNUNET_PeerIdentity *id,
199 const struct GNUNET_PeerIdentity *get_path, 199 const struct GNUNET_DHT_PathElement *get_path,
200 unsigned int get_path_length, 200 unsigned int get_path_length,
201 const struct GNUNET_PeerIdentity *put_path, 201 const struct GNUNET_DHT_PathElement *put_path,
202 unsigned int put_path_length) 202 unsigned int put_path_length)
203{ 203{
204 struct ClientEntry *ce = cls; 204 struct ClientEntry *ce = cls;
@@ -209,15 +209,15 @@ handle_search_result (void *cls,
209 209
210 if ((get_path_length >= 65536) || 210 if ((get_path_length >= 65536) ||
211 (put_path_length >= 65536) || 211 (put_path_length >= 65536) ||
212 ( ((get_path_length + put_path_length) * sizeof(struct 212 ( ((get_path_length + put_path_length)
213 GNUNET_PeerIdentity)) 213 * sizeof(struct GNUNET_PeerIdentity))
214 + sizeof(struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) ) 214 + sizeof(struct ResultMessage) >= GNUNET_MAX_MESSAGE_SIZE) )
215 { 215 {
216 GNUNET_break (0); 216 GNUNET_break (0);
217 return; 217 return;
218 } 218 }
219 size = (get_path_length + put_path_length) * sizeof(struct 219 size = (get_path_length + put_path_length)
220 GNUNET_PeerIdentity); 220 * sizeof(struct GNUNET_PeerIdentity);
221 env = GNUNET_MQ_msg_extra (result, 221 env = GNUNET_MQ_msg_extra (result,
222 size, 222 size,
223 GNUNET_MESSAGE_TYPE_REGEX_RESULT); 223 GNUNET_MESSAGE_TYPE_REGEX_RESULT);
@@ -225,12 +225,10 @@ handle_search_result (void *cls,
225 result->put_path_length = htons ((uint16_t) put_path_length); 225 result->put_path_length = htons ((uint16_t) put_path_length);
226 result->id = *id; 226 result->id = *id;
227 gp = &result->id; 227 gp = &result->id;
228 GNUNET_memcpy (&gp[1], 228 for (unsigned int i = 0; i<get_path_length; i++)
229 get_path, 229 gp[i + 1] = get_path[i].pred;
230 get_path_length * sizeof(struct GNUNET_PeerIdentity)); 230 for (unsigned int i = 0; i<put_path_length; i++)
231 GNUNET_memcpy (&gp[1 + get_path_length], 231 gp[i + get_path_length + 1] = put_path[i].pred;
232 put_path,
233 put_path_length * sizeof(struct GNUNET_PeerIdentity));
234 GNUNET_MQ_send (ce->mq, 232 GNUNET_MQ_send (ce->mq,
235 env); 233 env);
236} 234}
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h
index 8f29cff33..5b434b30c 100644
--- a/src/regex/regex_internal.h
+++ b/src/regex/regex_internal.h
@@ -340,10 +340,10 @@ REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len);
340 * 340 *
341 * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. 341 * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop.
342 */ 342 */
343typedef int (*REGEX_INTERNAL_traverse_check) (void *cls, 343typedef int
344 struct REGEX_INTERNAL_State *s, 344(*REGEX_INTERNAL_traverse_check) (void *cls,
345 struct REGEX_INTERNAL_Transition * 345 struct REGEX_INTERNAL_State *s,
346 t); 346 struct REGEX_INTERNAL_Transition *t);
347 347
348 348
349/** 349/**
@@ -353,9 +353,10 @@ typedef int (*REGEX_INTERNAL_traverse_check) (void *cls,
353 * @param count current count of the state, from 0 to a->state_count -1. 353 * @param count current count of the state, from 0 to a->state_count -1.
354 * @param s state. 354 * @param s state.
355 */ 355 */
356typedef void (*REGEX_INTERNAL_traverse_action) (void *cls, 356typedef void
357 const unsigned int count, 357(*REGEX_INTERNAL_traverse_action) (void *cls,
358 struct REGEX_INTERNAL_State *s); 358 const unsigned int count,
359 struct REGEX_INTERNAL_State *s);
359 360
360 361
361/** 362/**
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c
index 3fb74c319..2248de1f1 100644
--- a/src/regex/regex_internal_dht.c
+++ b/src/regex/regex_internal_dht.c
@@ -384,9 +384,9 @@ regex_next_edge (const struct RegexBlock *block,
384static void 384static void
385dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, 385dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp,
386 const struct GNUNET_HashCode *key, 386 const struct GNUNET_HashCode *key,
387 const struct GNUNET_PeerIdentity *get_path, 387 const struct GNUNET_DHT_PathElement *get_path,
388 unsigned int get_path_length, 388 unsigned int get_path_length,
389 const struct GNUNET_PeerIdentity *put_path, 389 const struct GNUNET_DHT_PathElement *put_path,
390 unsigned int put_path_length, 390 unsigned int put_path_length,
391 enum GNUNET_BLOCK_Type type, 391 enum GNUNET_BLOCK_Type type,
392 size_t size, const void *data) 392 size_t size, const void *data)
@@ -464,9 +464,9 @@ regex_find_path (const struct GNUNET_HashCode *key,
464static void 464static void
465dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, 465dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
466 const struct GNUNET_HashCode *key, 466 const struct GNUNET_HashCode *key,
467 const struct GNUNET_PeerIdentity *get_path, 467 const struct GNUNET_DHT_PathElement *get_path,
468 unsigned int get_path_length, 468 unsigned int get_path_length,
469 const struct GNUNET_PeerIdentity *put_path, 469 const struct GNUNET_DHT_PathElement *put_path,
470 unsigned int put_path_length, 470 unsigned int put_path_length,
471 enum GNUNET_BLOCK_Type type, 471 enum GNUNET_BLOCK_Type type,
472 size_t size, const void *data) 472 size_t size, const void *data)
diff --git a/src/regex/regex_internal_lib.h b/src/regex/regex_internal_lib.h
index 94fac19f9..9baf84995 100644
--- a/src/regex/regex_internal_lib.h
+++ b/src/regex/regex_internal_lib.h
@@ -221,9 +221,9 @@ REGEX_INTERNAL_announce_cancel (struct REGEX_INTERNAL_Announcement *h);
221typedef void 221typedef void
222(*REGEX_INTERNAL_Found)(void *cls, 222(*REGEX_INTERNAL_Found)(void *cls,
223 const struct GNUNET_PeerIdentity *id, 223 const struct GNUNET_PeerIdentity *id,
224 const struct GNUNET_PeerIdentity *get_path, 224 const struct GNUNET_DHT_PathElement *get_path,
225 unsigned int get_path_length, 225 unsigned int get_path_length,
226 const struct GNUNET_PeerIdentity *put_path, 226 const struct GNUNET_DHT_PathElement *put_path,
227 unsigned int put_path_length); 227 unsigned int put_path_length);
228 228
229 229