diff options
29 files changed, 664 insertions, 904 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bc8069614..91b4daf51 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -64,7 +64,7 @@ SUBDIRS = \ | |||
64 | regex \ | 64 | regex \ |
65 | mesh \ | 65 | mesh \ |
66 | lockmanager \ | 66 | lockmanager \ |
67 | stream \ | 67 | stream \ |
68 | fs \ | 68 | fs \ |
69 | $(LINUX_DIR) \ | 69 | $(LINUX_DIR) \ |
70 | $(MINGW_DIR) \ | 70 | $(MINGW_DIR) \ |
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 827e9985a..11897f32f 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -69,7 +69,6 @@ gnunetinclude_HEADERS = \ | |||
69 | gnunet_program_lib.h \ | 69 | gnunet_program_lib.h \ |
70 | gnunet_protocols.h \ | 70 | gnunet_protocols.h \ |
71 | gnunet_resolver_service.h \ | 71 | gnunet_resolver_service.h \ |
72 | gnunet_regex_lib.h \ | ||
73 | gnunet_regex_service.h \ | 72 | gnunet_regex_service.h \ |
74 | gnunet_scheduler_lib.h \ | 73 | gnunet_scheduler_lib.h \ |
75 | gnunet_server_lib.h \ | 74 | gnunet_server_lib.h \ |
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 3bb1ea359..c670a19fb 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h | |||
@@ -46,6 +46,18 @@ | |||
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | /** | ||
50 | * Maximum regex string length for use with GNUNET_TUN_ipv4toregex | ||
51 | */ | ||
52 | #define GNUNET_TUN_IPV4_REGEXLEN 32 + 6 | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Maximum regex string length for use with GNUNET_TUN_ipv6toregex | ||
57 | */ | ||
58 | #define GNUNET_TUN_IPV6_REGEXLEN 128 + 6 | ||
59 | |||
60 | |||
49 | GNUNET_NETWORK_STRUCT_BEGIN | 61 | GNUNET_NETWORK_STRUCT_BEGIN |
50 | 62 | ||
51 | /** | 63 | /** |
@@ -417,4 +429,31 @@ GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp, | |||
417 | uint16_t payload_length); | 429 | uint16_t payload_length); |
418 | 430 | ||
419 | 431 | ||
432 | /** | ||
433 | * Create a regex in 'rxstr' from the given 'ip' and 'netmask'. | ||
434 | * | ||
435 | * @param ip IPv4 representation. | ||
436 | * @param netmask netmask for the ip. | ||
437 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV4_REGEXLEN | ||
438 | * bytes long. | ||
439 | */ | ||
440 | void | ||
441 | GNUNET_TUN_ipv4toregex (const struct in_addr *ip, const char *netmask, | ||
442 | char *rxstr); | ||
443 | |||
444 | |||
445 | /** | ||
446 | * Create a regex in 'rxstr' from the given 'ipv6' and 'prefixlen'. | ||
447 | * | ||
448 | * @param ipv6 IPv6 representation. | ||
449 | * @param prefixlen length of the ipv6 prefix. | ||
450 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV6_REGEXLEN | ||
451 | * bytes long. | ||
452 | */ | ||
453 | void | ||
454 | GNUNET_TUN_ipv6toregex (const struct in6_addr *ipv6, | ||
455 | unsigned int prefixlen, char *rxstr); | ||
456 | |||
457 | |||
458 | |||
420 | #endif | 459 | #endif |
diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index 5b59a4652..bf1eed0e5 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am | |||
@@ -79,19 +79,19 @@ gnunet_service_mesh_SOURCES = \ | |||
79 | mesh_common.c | 79 | mesh_common.c |
80 | gnunet_service_mesh_CFLAGS = $(AM_CFLAGS) | 80 | gnunet_service_mesh_CFLAGS = $(AM_CFLAGS) |
81 | gnunet_service_mesh_LDADD = \ | 81 | gnunet_service_mesh_LDADD = \ |
82 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
83 | $(top_builddir)/src/regex/libgnunetregexnew.la \ | ||
82 | $(top_builddir)/src/util/libgnunetutil.la \ | 84 | $(top_builddir)/src/util/libgnunetutil.la \ |
83 | $(top_builddir)/src/core/libgnunetcore.la \ | 85 | $(top_builddir)/src/core/libgnunetcore.la \ |
84 | $(top_builddir)/src/dht/libgnunetdht.la \ | 86 | $(top_builddir)/src/dht/libgnunetdht.la \ |
85 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 87 | $(top_builddir)/src/block/libgnunetblock.la |
86 | $(top_builddir)/src/block/libgnunetblock.la \ | ||
87 | $(top_builddir)/src/regex/libgnunetregex.la | ||
88 | gnunet_service_mesh_DEPENDENCIES = \ | 88 | gnunet_service_mesh_DEPENDENCIES = \ |
89 | $(top_builddir)/src/util/libgnunetutil.la \ | 89 | $(top_builddir)/src/util/libgnunetutil.la \ |
90 | $(top_builddir)/src/core/libgnunetcore.la \ | 90 | $(top_builddir)/src/core/libgnunetcore.la \ |
91 | $(top_builddir)/src/dht/libgnunetdht.la \ | 91 | $(top_builddir)/src/dht/libgnunetdht.la \ |
92 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 92 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
93 | $(top_builddir)/src/block/libgnunetblock.la \ | 93 | $(top_builddir)/src/block/libgnunetblock.la \ |
94 | $(top_builddir)/src/regex/libgnunetregex.la | 94 | $(top_builddir)/src/regex/libgnunetregexnew.la |
95 | if LINUX | 95 | if LINUX |
96 | gnunet_service_mesh_LDFLAGS = -lrt | 96 | gnunet_service_mesh_LDFLAGS = -lrt |
97 | endif | 97 | endif |
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 0d85cda13..b16c7bf78 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #include "block_mesh.h" | 52 | #include "block_mesh.h" |
53 | #include "gnunet_dht_service.h" | 53 | #include "gnunet_dht_service.h" |
54 | #include "gnunet_statistics_service.h" | 54 | #include "gnunet_statistics_service.h" |
55 | #include "gnunet_regex_lib.h" | 55 | #include "gnunet_regex_service.h" |
56 | 56 | ||
57 | #define MESH_BLOOM_SIZE 128 | 57 | #define MESH_BLOOM_SIZE 128 |
58 | 58 | ||
@@ -65,6 +65,7 @@ | |||
65 | GNUNET_TIME_UNIT_MINUTES,\ | 65 | GNUNET_TIME_UNIT_MINUTES,\ |
66 | 10) | 66 | 10) |
67 | 67 | ||
68 | |||
68 | #if MESH_DEBUG_CONNECTION | 69 | #if MESH_DEBUG_CONNECTION |
69 | #define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 70 | #define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
70 | #else | 71 | #else |
@@ -198,7 +199,7 @@ struct MeshRegexDescriptor | |||
198 | /** | 199 | /** |
199 | * Handle to announce the regex. | 200 | * Handle to announce the regex. |
200 | */ | 201 | */ |
201 | struct GNUNET_REGEX_announce_handle *h; | 202 | struct GNUNET_REGEX_Announcement *h; |
202 | }; | 203 | }; |
203 | 204 | ||
204 | 205 | ||
@@ -221,7 +222,7 @@ struct MeshRegexSearchInfo | |||
221 | /** | 222 | /** |
222 | * Regex search handle. | 223 | * Regex search handle. |
223 | */ | 224 | */ |
224 | struct GNUNET_REGEX_search_handle *search_handle; | 225 | struct GNUNET_REGEX_Search *search_handle; |
225 | 226 | ||
226 | /** | 227 | /** |
227 | * Peer that is connecting via connect_by_string. When connected, free ctx. | 228 | * Peer that is connecting via connect_by_string. When connected, free ctx. |
@@ -931,10 +932,10 @@ static struct GNUNET_CONTAINER_MultiHashMap *incoming_tunnels; | |||
931 | */ | 932 | */ |
932 | static struct GNUNET_CONTAINER_MultiHashMap *peers; | 933 | static struct GNUNET_CONTAINER_MultiHashMap *peers; |
933 | 934 | ||
934 | /* | 935 | /** |
935 | * Handle to communicate with transport | 936 | * Configuration handle |
936 | */ | 937 | */ |
937 | // static struct GNUNET_TRANSPORT_Handle *transport_handle; | 938 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
938 | 939 | ||
939 | /** | 940 | /** |
940 | * Handle to communicate with core. | 941 | * Handle to communicate with core. |
@@ -1388,16 +1389,11 @@ regex_put (struct MeshRegexDescriptor *regex) | |||
1388 | if (NULL == regex->h) | 1389 | if (NULL == regex->h) |
1389 | { | 1390 | { |
1390 | DEBUG_REGEX (" first put, creating DFA\n"); | 1391 | DEBUG_REGEX (" first put, creating DFA\n"); |
1391 | regex->h = GNUNET_REGEX_announce (dht_handle, | 1392 | regex->h = GNUNET_REGEX_announce (cfg, |
1392 | &my_full_id, | 1393 | &my_full_id, |
1393 | regex->regex, | 1394 | regex->regex, |
1394 | regex->compression, | 1395 | app_announce_time, |
1395 | stats); | 1396 | regex->compression); |
1396 | } | ||
1397 | else | ||
1398 | { | ||
1399 | DEBUG_REGEX (" not first put, using cached data\n"); | ||
1400 | GNUNET_REGEX_reannounce (regex->h); | ||
1401 | } | 1397 | } |
1402 | DEBUG_REGEX (" regex_put (%s) end\n", regex->regex); | 1398 | DEBUG_REGEX (" regex_put (%s) end\n", regex->regex); |
1403 | } | 1399 | } |
@@ -6317,7 +6313,6 @@ handle_local_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
6317 | c = next; | 6313 | c = next; |
6318 | } | 6314 | } |
6319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " done!\n"); | 6315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " done!\n"); |
6320 | return; | ||
6321 | } | 6316 | } |
6322 | 6317 | ||
6323 | 6318 | ||
@@ -7219,10 +7214,9 @@ handle_local_connect_by_string (void *cls, struct GNUNET_SERVER_Client *client, | |||
7219 | 7214 | ||
7220 | t->regex_search = info; | 7215 | t->regex_search = info; |
7221 | 7216 | ||
7222 | info->search_handle = GNUNET_REGEX_search (dht_handle, | 7217 | info->search_handle = GNUNET_REGEX_search (cfg, |
7223 | info->description, | 7218 | info->description, |
7224 | ®ex_found_handler, info, | 7219 | ®ex_found_handler, info); |
7225 | stats); | ||
7226 | 7220 | ||
7227 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 7221 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
7228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connect by string processed\n"); | 7222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connect by string processed\n"); |
@@ -8249,6 +8243,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
8249 | { | 8243 | { |
8250 | char *keyfile; | 8244 | char *keyfile; |
8251 | 8245 | ||
8246 | cfg = c; | ||
8252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n"); | 8247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n"); |
8253 | server_handle = server; | 8248 | server_handle = server; |
8254 | 8249 | ||
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index cbd66fa1d..6e6fd443a 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -22,21 +22,24 @@ libexec_PROGRAMS = \ | |||
22 | 22 | ||
23 | gnunet_service_regex_SOURCES = \ | 23 | gnunet_service_regex_SOURCES = \ |
24 | gnunet-service-regex.c | 24 | gnunet-service-regex.c |
25 | gnunet_service_regex_LDADD = \ | 25 | gnunet_service_regex_LDADD = -lm \ |
26 | $(top_builddir)/src/regex/libgnunetregex.la \ | 26 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
27 | $(top_builddir)/src/regex/libgnunetregexblock.la \ | ||
27 | $(top_builddir)/src/dht/libgnunetdht.la \ | 28 | $(top_builddir)/src/dht/libgnunetdht.la \ |
28 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 29 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
29 | $(top_builddir)/src/util/libgnunetutil.la \ | 30 | $(top_builddir)/src/util/libgnunetutil.la \ |
30 | $(GN_LIBINTL) | 31 | $(GN_LIBINTL) |
31 | gnunet_service_regex_DEPENDENCIES = \ | 32 | gnunet_service_regex_DEPENDENCIES = \ |
32 | libgnunetregex.la | 33 | libgnunetregex_internal.a |
33 | # todo: link files from libgnunetregex statically into gnunet_service_regex, | 34 | # todo: link files from libgnunetregex statically into gnunet_service_regex, |
34 | # rename API prefix to avoid collision with 'libgnunetregexnew'... | 35 | # rename API prefix to avoid collision with 'libgnunetregexnew'... |
35 | 36 | ||
37 | noinst_LIBRARIES = \ | ||
38 | libgnunetregex_internal.a \ | ||
39 | libgnunetregextest.a | ||
36 | 40 | ||
37 | lib_LTLIBRARIES = \ | 41 | lib_LTLIBRARIES = \ |
38 | libgnunetregexblock.la \ | 42 | libgnunetregexblock.la \ |
39 | libgnunetregex.la \ | ||
40 | libgnunetregexnew.la | 43 | libgnunetregexnew.la |
41 | 44 | ||
42 | 45 | ||
@@ -50,20 +53,13 @@ libgnunetregexblock_la_LDFLAGS = \ | |||
50 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | 53 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ |
51 | -version-info 1:0:0 | 54 | -version-info 1:0:0 |
52 | 55 | ||
53 | libgnunetregex_la_SOURCES = \ | 56 | |
57 | libgnunetregex_internal_a_SOURCES = \ | ||
54 | regex_internal.h regex.c \ | 58 | regex_internal.h regex.c \ |
55 | regex_graph.c regex_random.c \ | 59 | regex_graph.c regex_random.c \ |
56 | regex_dht.c | 60 | regex_dht.c |
57 | libgnunetregex_la_LIBADD = -lm \ | 61 | libgnunetregex_internal_a_DEPENDENCIES = \ |
58 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
59 | $(top_builddir)/src/dht/libgnunetdht.la \ | ||
60 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
61 | $(top_builddir)/src/regex/libgnunetregexblock.la | ||
62 | libgnunetregex_la_DEPENDENCIES = \ | ||
63 | libgnunetregexblock.la | 62 | libgnunetregexblock.la |
64 | libgnunetregex_la_LDFLAGS = \ | ||
65 | $(GN_LIB_LDFLAGS) \ | ||
66 | -version-info 2:0:1 | ||
67 | 63 | ||
68 | 64 | ||
69 | libgnunetregexnew_la_SOURCES = \ | 65 | libgnunetregexnew_la_SOURCES = \ |
@@ -75,8 +71,6 @@ libgnunetregexnew_la_LDFLAGS = \ | |||
75 | -version-info 3:0:0 | 71 | -version-info 3:0:0 |
76 | 72 | ||
77 | 73 | ||
78 | plugindir = $(libdir)/gnunet | ||
79 | |||
80 | plugin_LTLIBRARIES = \ | 74 | plugin_LTLIBRARIES = \ |
81 | libgnunet_plugin_block_regex.la | 75 | libgnunet_plugin_block_regex.la |
82 | 76 | ||
@@ -99,21 +93,19 @@ gnunet_regex_simulation_profiler_SOURCES = \ | |||
99 | gnunet-regex-simulation-profiler.c | 93 | gnunet-regex-simulation-profiler.c |
100 | gnunet_regex_simulation_profiler_LDADD = \ | 94 | gnunet_regex_simulation_profiler_LDADD = \ |
101 | $(top_builddir)/src/util/libgnunetutil.la \ | 95 | $(top_builddir)/src/util/libgnunetutil.la \ |
102 | $(top_builddir)/src/regex/libgnunetregex.la \ | 96 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
103 | $(top_builddir)/src/mysql/libgnunetmysql.la | 97 | $(top_builddir)/src/mysql/libgnunetmysql.la |
104 | gnunet_regex_simulation_profiler_DEPENDENCIES = \ | 98 | gnunet_regex_simulation_profiler_DEPENDENCIES = \ |
105 | libgnunetregex.la | 99 | libgnunetregex_internal.a |
106 | endif | 100 | endif |
107 | 101 | ||
108 | noinst_LTLIBRARIES = libgnunetregextest.la | 102 | libgnunetregextest_a_SOURCES = \ |
109 | |||
110 | libgnunetregextest_la_SOURCES = \ | ||
111 | regex_test_lib.c regex_test_lib.h | 103 | regex_test_lib.c regex_test_lib.h |
112 | libgnunetregextest_la_LIBADD = \ | 104 | libgnunetregextest_a_LIBADD = \ |
113 | $(top_builddir)/src/util/libgnunetutil.la \ | 105 | $(top_builddir)/src/util/libgnunetutil.la \ |
114 | $(top_builddir)/src/regex/libgnunetregex.la | 106 | $(top_builddir)/src/regex/libgnunetregex_internal.a |
115 | libgnunetregextest_la_DEPENDENCIES = \ | 107 | libgnunetregextest_a_DEPENDENCIES = \ |
116 | libgnunetregex.la | 108 | libgnunetregex_internal.a |
117 | 109 | ||
118 | 110 | ||
119 | noinst_PROGRAMS = $(noinst_mysql_progs) \ | 111 | noinst_PROGRAMS = $(noinst_mysql_progs) \ |
@@ -123,43 +115,46 @@ noinst_PROGRAMS = $(noinst_mysql_progs) \ | |||
123 | 115 | ||
124 | perf_regex_SOURCES = \ | 116 | perf_regex_SOURCES = \ |
125 | perf-regex.c | 117 | perf-regex.c |
126 | perf_regex_LDADD = \ | 118 | perf_regex_LDADD = -lm \ |
127 | $(top_builddir)/src/util/libgnunetutil.la \ | 119 | $(top_builddir)/src/util/libgnunetutil.la \ |
128 | $(top_builddir)/src/regex/libgnunetregex.la \ | 120 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
129 | $(top_builddir)/src/regex/libgnunetregextest.la | 121 | $(top_builddir)/src/regex/libgnunetregexblock.la \ |
122 | $(top_builddir)/src/regex/libgnunetregextest.a | ||
130 | perf_regex_DEPENDENCIES = \ | 123 | perf_regex_DEPENDENCIES = \ |
131 | libgnunetregex.la \ | 124 | libgnunetregex_internal.a \ |
132 | libgnunetregextest.la | 125 | libgnunetregextest.a |
133 | 126 | ||
134 | gnunet_regex_profiler_SOURCES = \ | 127 | gnunet_regex_profiler_SOURCES = \ |
135 | gnunet-regex-profiler.c | 128 | gnunet-regex-profiler.c |
136 | gnunet_regex_profiler_LDADD = \ | 129 | gnunet_regex_profiler_LDADD = -lm \ |
137 | $(top_builddir)/src/util/libgnunetutil.la \ | 130 | $(top_builddir)/src/util/libgnunetutil.la \ |
138 | $(top_builddir)/src/arm/libgnunetarm.la \ | 131 | $(top_builddir)/src/arm/libgnunetarm.la \ |
139 | $(top_builddir)/src/dht/libgnunetdht.la \ | 132 | $(top_builddir)/src/dht/libgnunetdht.la \ |
140 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 133 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
141 | $(top_builddir)/src/regex/libgnunetregex.la \ | 134 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
142 | $(top_builddir)/src/regex/libgnunetregextest.la \ | 135 | $(top_builddir)/src/regex/libgnunetregexblock.la \ |
136 | $(top_builddir)/src/regex/libgnunetregextest.a \ | ||
143 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 137 | $(top_builddir)/src/statistics/libgnunetstatistics.la |
144 | gnunet_regex_profiler_DEPENDENCIES = \ | 138 | gnunet_regex_profiler_DEPENDENCIES = \ |
145 | $(top_builddir)/src/arm/libgnunetarm.la \ | 139 | $(top_builddir)/src/arm/libgnunetarm.la \ |
146 | $(top_builddir)/src/dht/libgnunetdht.la \ | 140 | $(top_builddir)/src/dht/libgnunetdht.la \ |
147 | libgnunetregex.la \ | 141 | libgnunetregex_internal.a \ |
148 | libgnunetregextest.la | 142 | libgnunetregextest.a |
149 | 143 | ||
150 | 144 | ||
151 | gnunet_daemon_regexprofiler_SOURCES = \ | 145 | gnunet_daemon_regexprofiler_SOURCES = \ |
152 | gnunet-daemon-regexprofiler.c | 146 | gnunet-daemon-regexprofiler.c |
153 | gnunet_daemon_regexprofiler_LDADD = \ | 147 | gnunet_daemon_regexprofiler_LDADD = -lm \ |
154 | $(top_builddir)/src/util/libgnunetutil.la \ | 148 | $(top_builddir)/src/util/libgnunetutil.la \ |
155 | $(top_builddir)/src/dht/libgnunetdht.la \ | 149 | $(top_builddir)/src/dht/libgnunetdht.la \ |
156 | $(top_builddir)/src/regex/libgnunetregex.la \ | 150 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
157 | $(top_builddir)/src/regex/libgnunetregextest.la \ | 151 | $(top_builddir)/src/regex/libgnunetregexblock.la \ |
152 | $(top_builddir)/src/regex/libgnunetregextest.a \ | ||
158 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 153 | $(top_builddir)/src/statistics/libgnunetstatistics.la |
159 | gnunet_daemon_regexprofiler_DEPENDENCIES = \ | 154 | gnunet_daemon_regexprofiler_DEPENDENCIES = \ |
160 | $(top_builddir)/src/dht/libgnunetdht.la \ | 155 | $(top_builddir)/src/dht/libgnunetdht.la \ |
161 | libgnunetregextest.la \ | 156 | libgnunetregextest.a \ |
162 | libgnunetregex.la | 157 | libgnunetregex_internal.a |
163 | 158 | ||
164 | 159 | ||
165 | 160 | ||
@@ -167,8 +162,7 @@ check_PROGRAMS = \ | |||
167 | test_regex_eval_api \ | 162 | test_regex_eval_api \ |
168 | test_regex_iterate_api \ | 163 | test_regex_iterate_api \ |
169 | test_regex_proofs \ | 164 | test_regex_proofs \ |
170 | test_regex_graph_api \ | 165 | test_regex_graph_api |
171 | test_regex_iptoregex | ||
172 | 166 | ||
173 | if ENABLE_TEST_RUN | 167 | if ENABLE_TEST_RUN |
174 | TESTS = $(check_PROGRAMS) | 168 | TESTS = $(check_PROGRAMS) |
@@ -176,34 +170,32 @@ endif | |||
176 | 170 | ||
177 | test_regex_eval_api_SOURCES = \ | 171 | test_regex_eval_api_SOURCES = \ |
178 | test_regex_eval_api.c | 172 | test_regex_eval_api.c |
179 | test_regex_eval_api_LDADD = \ | 173 | test_regex_eval_api_LDADD = -lm \ |
180 | $(top_builddir)/src/regex/libgnunetregex.la \ | 174 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
175 | $(top_builddir)/src/regex/libgnunetregexblock.la \ | ||
181 | $(top_builddir)/src/util/libgnunetutil.la | 176 | $(top_builddir)/src/util/libgnunetutil.la |
182 | 177 | ||
183 | test_regex_iterate_api_SOURCES = \ | 178 | test_regex_iterate_api_SOURCES = \ |
184 | test_regex_iterate_api.c | 179 | test_regex_iterate_api.c |
185 | test_regex_iterate_api_LDADD = \ | 180 | test_regex_iterate_api_LDADD = -lm \ |
186 | $(top_builddir)/src/regex/libgnunetregex.la \ | 181 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
182 | $(top_builddir)/src/regex/libgnunetregexblock.la \ | ||
187 | $(top_builddir)/src/util/libgnunetutil.la | 183 | $(top_builddir)/src/util/libgnunetutil.la |
188 | 184 | ||
189 | test_regex_proofs_SOURCES = \ | 185 | test_regex_proofs_SOURCES = \ |
190 | test_regex_proofs.c | 186 | test_regex_proofs.c |
191 | test_regex_proofs_LDADD = \ | 187 | test_regex_proofs_LDADD = -lm \ |
192 | $(top_builddir)/src/regex/libgnunetregex.la \ | 188 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
189 | $(top_builddir)/src/regex/libgnunetregexblock.la \ | ||
193 | $(top_builddir)/src/util/libgnunetutil.la | 190 | $(top_builddir)/src/util/libgnunetutil.la |
194 | 191 | ||
195 | test_regex_graph_api_SOURCES = \ | 192 | test_regex_graph_api_SOURCES = \ |
196 | test_regex_graph_api.c | 193 | test_regex_graph_api.c |
197 | test_regex_graph_api_LDADD = \ | 194 | test_regex_graph_api_LDADD = -lm \ |
198 | $(top_builddir)/src/regex/libgnunetregex.la \ | 195 | $(top_builddir)/src/regex/libgnunetregex_internal.a \ |
196 | $(top_builddir)/src/regex/libgnunetregexblock.la \ | ||
199 | $(top_builddir)/src/util/libgnunetutil.la | 197 | $(top_builddir)/src/util/libgnunetutil.la |
200 | 198 | ||
201 | test_regex_iptoregex_SOURCES = \ | ||
202 | test_regex_iptoregex.c | ||
203 | test_regex_iptoregex_LDADD = \ | ||
204 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
205 | $(top_builddir)/src/regex/libgnunetregex.la | ||
206 | |||
207 | 199 | ||
208 | EXTRA_DIST = \ | 200 | EXTRA_DIST = \ |
209 | regex_simulation_profiler_test.conf | 201 | regex_simulation_profiler_test.conf |
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index 88621d882..6a61aa6f0 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c | |||
@@ -29,7 +29,7 @@ | |||
29 | */ | 29 | */ |
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_regex_lib.h" | 32 | #include "regex_internal_lib.h" |
33 | #include "regex_test_lib.h" | 33 | #include "regex_test_lib.h" |
34 | #include "gnunet_dht_service.h" | 34 | #include "gnunet_dht_service.h" |
35 | #include "gnunet_statistics_service.h" | 35 | #include "gnunet_statistics_service.h" |
@@ -57,7 +57,7 @@ static struct GNUNET_DHT_Handle *dht_handle; | |||
57 | /** | 57 | /** |
58 | * Peer's regex announce handle. | 58 | * Peer's regex announce handle. |
59 | */ | 59 | */ |
60 | static struct GNUNET_REGEX_announce_handle *announce_handle; | 60 | static struct REGEX_ITERNAL_Announcement *announce_handle; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Periodically reannounce regex. | 63 | * Periodically reannounce regex. |
@@ -109,7 +109,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
109 | 109 | ||
110 | if (NULL != announce_handle) | 110 | if (NULL != announce_handle) |
111 | { | 111 | { |
112 | GNUNET_REGEX_announce_cancel (announce_handle); | 112 | REGEX_ITERNAL_announce_cancel (announce_handle); |
113 | announce_handle = NULL; | 113 | announce_handle = NULL; |
114 | } | 114 | } |
115 | 115 | ||
@@ -160,7 +160,7 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
160 | "First time, creating regex: %s\n", | 160 | "First time, creating regex: %s\n", |
161 | regex); | 161 | regex); |
162 | memset (&id, 0, sizeof (struct GNUNET_PeerIdentity)); | 162 | memset (&id, 0, sizeof (struct GNUNET_PeerIdentity)); |
163 | announce_handle = GNUNET_REGEX_announce (dht_handle, | 163 | announce_handle = REGEX_ITERNAL_announce (dht_handle, |
164 | &id, | 164 | &id, |
165 | regex, | 165 | regex, |
166 | (unsigned int) max_path_compression, | 166 | (unsigned int) max_path_compression, |
@@ -169,7 +169,7 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
169 | else | 169 | else |
170 | { | 170 | { |
171 | GNUNET_assert (NULL != announce_handle); | 171 | GNUNET_assert (NULL != announce_handle); |
172 | GNUNET_REGEX_reannounce (announce_handle); | 172 | REGEX_ITERNAL_reannounce (announce_handle); |
173 | } | 173 | } |
174 | 174 | ||
175 | random_delay = | 175 | random_delay = |
@@ -330,7 +330,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
330 | /* Read regexes from policy files */ | 330 | /* Read regexes from policy files */ |
331 | GNUNET_assert (-1 != GNUNET_DISK_directory_scan (policy_dir, &scan, | 331 | GNUNET_assert (-1 != GNUNET_DISK_directory_scan (policy_dir, &scan, |
332 | (void *) (long) peer_id)); | 332 | (void *) (long) peer_id)); |
333 | if (NULL == (components = GNUNET_REGEX_read_from_file (policy_filename))) | 333 | if (NULL == (components = REGEX_ITERNAL_read_from_file (policy_filename))) |
334 | { | 334 | { |
335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
336 | "Policy file %s contains no policies. Exiting.\n", | 336 | "Policy file %s contains no policies. Exiting.\n", |
@@ -339,8 +339,8 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
339 | GNUNET_SCHEDULER_shutdown (); | 339 | GNUNET_SCHEDULER_shutdown (); |
340 | return; | 340 | return; |
341 | } | 341 | } |
342 | regex = GNUNET_REGEX_combine (components); | 342 | regex = REGEX_ITERNAL_combine (components); |
343 | GNUNET_REGEX_free_from_file (components); | 343 | REGEX_ITERNAL_free_from_file (components); |
344 | 344 | ||
345 | /* Announcing regexes from policy_filename */ | 345 | /* Announcing regexes from policy_filename */ |
346 | GNUNET_asprintf (&rx_with_pfx, "%s(%s)(0|1)*", regex_prefix, regex); | 346 | GNUNET_asprintf (&rx_with_pfx, "%s(%s)(0|1)*", regex_prefix, regex); |
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 83395aad1..e6f35a6f4 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "platform.h" | 31 | #include "platform.h" |
32 | #include "gnunet_applications.h" | 32 | #include "gnunet_applications.h" |
33 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
34 | #include "gnunet_regex_lib.h" | 34 | #include "regex_internal_lib.h" |
35 | #include "gnunet_arm_service.h" | 35 | #include "gnunet_arm_service.h" |
36 | #include "gnunet_dht_service.h" | 36 | #include "gnunet_dht_service.h" |
37 | #include "gnunet_testbed_service.h" | 37 | #include "gnunet_testbed_service.h" |
@@ -150,7 +150,7 @@ struct RegexPeer | |||
150 | /** | 150 | /** |
151 | * Handle to a running regex search. | 151 | * Handle to a running regex search. |
152 | */ | 152 | */ |
153 | struct GNUNET_REGEX_search_handle *search_handle; | 153 | struct REGEX_ITERNAL_Search *search_handle; |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Testbed operation handle for DHT. | 156 | * Testbed operation handle for DHT. |
@@ -702,7 +702,7 @@ find_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
702 | * Method called when we've found a peer that announced a regex | 702 | * Method called when we've found a peer that announced a regex |
703 | * that matches our search string. Now get the statistics. | 703 | * that matches our search string. Now get the statistics. |
704 | * | 704 | * |
705 | * @param cls Closure provided in GNUNET_REGEX_search. | 705 | * @param cls Closure provided in REGEX_ITERNAL_search. |
706 | * @param id Peer providing a regex that matches the string. | 706 | * @param id Peer providing a regex that matches the string. |
707 | * @param get_path Path of the get request. | 707 | * @param get_path Path of the get request. |
708 | * @param get_path_length Lenght of get_path. | 708 | * @param get_path_length Lenght of get_path. |
@@ -1039,7 +1039,7 @@ dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
1039 | GNUNET_assert (peer->dht_handle == ca_result); | 1039 | GNUNET_assert (peer->dht_handle == ca_result); |
1040 | 1040 | ||
1041 | peer->search_str_matched = GNUNET_NO; | 1041 | peer->search_str_matched = GNUNET_NO; |
1042 | peer->search_handle = GNUNET_REGEX_search (peer->dht_handle, | 1042 | peer->search_handle = REGEX_ITERNAL_search (peer->dht_handle, |
1043 | peer->search_str, | 1043 | peer->search_str, |
1044 | ®ex_found_handler, peer, | 1044 | ®ex_found_handler, peer, |
1045 | NULL); | 1045 | NULL); |
@@ -1081,7 +1081,7 @@ dht_da (void *cls, void *op_result) | |||
1081 | 1081 | ||
1082 | if (NULL != peer->search_handle) | 1082 | if (NULL != peer->search_handle) |
1083 | { | 1083 | { |
1084 | GNUNET_REGEX_search_cancel (peer->search_handle); | 1084 | REGEX_ITERNAL_search_cancel (peer->search_handle); |
1085 | peer->search_handle = NULL; | 1085 | peer->search_handle = NULL; |
1086 | } | 1086 | } |
1087 | 1087 | ||
diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index 604d25612..b3d1ff873 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include "platform.h" | 29 | #include "platform.h" |
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_regex_lib.h" | 31 | #include "regex_internal_lib.h" |
32 | #include "gnunet_mysql_lib.h" | 32 | #include "gnunet_mysql_lib.h" |
33 | #include <mysql/mysql.h> | 33 | #include <mysql/mysql.h> |
34 | 34 | ||
@@ -335,7 +335,7 @@ return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) | |||
335 | static void | 335 | static void |
336 | regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | 336 | regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, |
337 | int accepting, unsigned int num_edges, | 337 | int accepting, unsigned int num_edges, |
338 | const struct GNUNET_REGEX_Edge *edges) | 338 | const struct REGEX_ITERNAL_Edge *edges) |
339 | { | 339 | { |
340 | unsigned int i; | 340 | unsigned int i; |
341 | int result; | 341 | int result; |
@@ -460,10 +460,10 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | |||
460 | static int | 460 | static int |
461 | announce_regex (const char *regex) | 461 | announce_regex (const char *regex) |
462 | { | 462 | { |
463 | struct GNUNET_REGEX_Automaton *dfa; | 463 | struct REGEX_ITERNAL_Automaton *dfa; |
464 | 464 | ||
465 | dfa = | 465 | dfa = |
466 | GNUNET_REGEX_construct_dfa (regex, strlen (regex), max_path_compression); | 466 | REGEX_ITERNAL_construct_dfa (regex, strlen (regex), max_path_compression); |
467 | 467 | ||
468 | if (NULL == dfa) | 468 | if (NULL == dfa) |
469 | { | 469 | { |
@@ -473,9 +473,9 @@ announce_regex (const char *regex) | |||
473 | return GNUNET_SYSERR; | 473 | return GNUNET_SYSERR; |
474 | } | 474 | } |
475 | 475 | ||
476 | GNUNET_REGEX_iterate_all_edges (dfa, ®ex_iterator, NULL); | 476 | REGEX_ITERNAL_iterate_all_edges (dfa, ®ex_iterator, NULL); |
477 | 477 | ||
478 | GNUNET_REGEX_automaton_destroy (dfa); | 478 | REGEX_ITERNAL_automaton_destroy (dfa); |
479 | 479 | ||
480 | return GNUNET_OK; | 480 | return GNUNET_OK; |
481 | } | 481 | } |
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c index 28f3a20b8..f0a39a361 100644 --- a/src/regex/gnunet-service-regex.c +++ b/src/regex/gnunet-service-regex.c | |||
@@ -26,7 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_regex_lib.h" | 29 | #include "regex_internal_lib.h" |
30 | #include "regex_ipc.h" | 30 | #include "regex_ipc.h" |
31 | 31 | ||
32 | 32 | ||
@@ -54,12 +54,12 @@ struct ClientEntry | |||
54 | /** | 54 | /** |
55 | * Search handle (if this client is searching). | 55 | * Search handle (if this client is searching). |
56 | */ | 56 | */ |
57 | struct GNUNET_REGEX_search_handle *sh; | 57 | struct REGEX_ITERNAL_Search *sh; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Announcement handle (if this client is announcing). | 60 | * Announcement handle (if this client is announcing). |
61 | */ | 61 | */ |
62 | struct GNUNET_REGEX_announce_handle *ah; | 62 | struct REGEX_ITERNAL_Announcement *ah; |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Refresh frequency for announcements. | 65 | * Refresh frequency for announcements. |
@@ -143,12 +143,12 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
143 | } | 143 | } |
144 | if (NULL != ce->ah) | 144 | if (NULL != ce->ah) |
145 | { | 145 | { |
146 | GNUNET_REGEX_announce_cancel (ce->ah); | 146 | REGEX_ITERNAL_announce_cancel (ce->ah); |
147 | ce->ah = NULL; | 147 | ce->ah = NULL; |
148 | } | 148 | } |
149 | if (NULL != ce->sh) | 149 | if (NULL != ce->sh) |
150 | { | 150 | { |
151 | GNUNET_REGEX_search_cancel (ce->sh); | 151 | REGEX_ITERNAL_search_cancel (ce->sh); |
152 | ce->sh = NULL; | 152 | ce->sh = NULL; |
153 | } | 153 | } |
154 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, ce); | 154 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, ce); |
@@ -171,7 +171,7 @@ reannounce (void *cls, | |||
171 | { | 171 | { |
172 | struct ClientEntry *ce = cls; | 172 | struct ClientEntry *ce = cls; |
173 | 173 | ||
174 | GNUNET_REGEX_reannounce (ce->ah); | 174 | REGEX_ITERNAL_reannounce (ce->ah); |
175 | ce->refresh_task = GNUNET_SCHEDULER_add_delayed (ce->frequency, | 175 | ce->refresh_task = GNUNET_SCHEDULER_add_delayed (ce->frequency, |
176 | &reannounce, | 176 | &reannounce, |
177 | ce); | 177 | ce); |
@@ -207,7 +207,7 @@ handle_announce (void *cls, | |||
207 | } | 207 | } |
208 | ce = GNUNET_new (struct ClientEntry); | 208 | ce = GNUNET_new (struct ClientEntry); |
209 | ce->client = client; | 209 | ce->client = client; |
210 | ce->ah = GNUNET_REGEX_announce (dht, | 210 | ce->ah = REGEX_ITERNAL_announce (dht, |
211 | &am->pid, | 211 | &am->pid, |
212 | regex, | 212 | regex, |
213 | ntohs (am->compression), | 213 | ntohs (am->compression), |
@@ -311,7 +311,7 @@ handle_search (void *cls, | |||
311 | } | 311 | } |
312 | ce = GNUNET_new (struct ClientEntry); | 312 | ce = GNUNET_new (struct ClientEntry); |
313 | ce->client = client; | 313 | ce->client = client; |
314 | ce->sh = GNUNET_REGEX_search (dht, | 314 | ce->sh = REGEX_ITERNAL_search (dht, |
315 | string, | 315 | string, |
316 | &handle_search_result, | 316 | &handle_search_result, |
317 | ce, | 317 | ce, |
diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c index 8fce34f37..210b16b81 100644 --- a/src/regex/perf-regex.c +++ b/src/regex/perf-regex.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <regex.h> | 26 | #include <regex.h> |
27 | #include <time.h> | 27 | #include <time.h> |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_regex_lib.h" | 29 | #include "regex_internal_lib.h" |
30 | #include "regex_test_lib.h" | 30 | #include "regex_test_lib.h" |
31 | 31 | ||
32 | static const char *exe; | 32 | static const char *exe; |
@@ -53,7 +53,7 @@ iter (void *cls, | |||
53 | const char *proof, | 53 | const char *proof, |
54 | int accepting, | 54 | int accepting, |
55 | unsigned int num_edges, | 55 | unsigned int num_edges, |
56 | const struct GNUNET_REGEX_Edge *edges) | 56 | const struct REGEX_ITERNAL_Edge *edges) |
57 | { | 57 | { |
58 | unsigned int i; | 58 | unsigned int i; |
59 | 59 | ||
@@ -66,9 +66,9 @@ iter (void *cls, | |||
66 | } | 66 | } |
67 | 67 | ||
68 | static void | 68 | static void |
69 | print_dfa (struct GNUNET_REGEX_Automaton* dfa) | 69 | print_dfa (struct REGEX_ITERNAL_Automaton* dfa) |
70 | { | 70 | { |
71 | GNUNET_REGEX_iterate_all_edges (dfa, iter, NULL); | 71 | REGEX_ITERNAL_iterate_all_edges (dfa, iter, NULL); |
72 | } | 72 | } |
73 | 73 | ||
74 | /** | 74 | /** |
@@ -84,7 +84,7 @@ print_dfa (struct GNUNET_REGEX_Automaton* dfa) | |||
84 | int | 84 | int |
85 | main (int argc, char *const *argv) | 85 | main (int argc, char *const *argv) |
86 | { | 86 | { |
87 | struct GNUNET_REGEX_Automaton* dfa; | 87 | struct REGEX_ITERNAL_Automaton* dfa; |
88 | char **regexes; | 88 | char **regexes; |
89 | char *buffer; | 89 | char *buffer; |
90 | char *regex; | 90 | char *regex; |
@@ -98,14 +98,14 @@ main (int argc, char *const *argv) | |||
98 | usage(); | 98 | usage(); |
99 | return 1; | 99 | return 1; |
100 | } | 100 | } |
101 | regexes = GNUNET_REGEX_read_from_file (argv[1]); | 101 | regexes = REGEX_ITERNAL_read_from_file (argv[1]); |
102 | 102 | ||
103 | if (NULL == regexes) | 103 | if (NULL == regexes) |
104 | { | 104 | { |
105 | usage(); | 105 | usage(); |
106 | return 2; | 106 | return 2; |
107 | } | 107 | } |
108 | buffer = GNUNET_REGEX_combine (regexes); | 108 | buffer = REGEX_ITERNAL_combine (regexes); |
109 | 109 | ||
110 | GNUNET_asprintf (®ex, "GNVPN-0001-PAD(%s)(0|1)*", buffer); | 110 | GNUNET_asprintf (®ex, "GNVPN-0001-PAD(%s)(0|1)*", buffer); |
111 | size = strlen (regex); | 111 | size = strlen (regex); |
@@ -114,11 +114,11 @@ main (int argc, char *const *argv) | |||
114 | // return 0; | 114 | // return 0; |
115 | 115 | ||
116 | compression = atoi (argv[2]); | 116 | compression = atoi (argv[2]); |
117 | dfa = GNUNET_REGEX_construct_dfa (regex, size, compression); | 117 | dfa = REGEX_ITERNAL_construct_dfa (regex, size, compression); |
118 | print_dfa (dfa); | 118 | print_dfa (dfa); |
119 | GNUNET_REGEX_automaton_destroy (dfa); | 119 | REGEX_ITERNAL_automaton_destroy (dfa); |
120 | GNUNET_free (buffer); | 120 | GNUNET_free (buffer); |
121 | GNUNET_REGEX_free_from_file (regexes); | 121 | REGEX_ITERNAL_free_from_file (regexes); |
122 | GNUNET_free (regex); | 122 | GNUNET_free (regex); |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index bfee12d7f..43e59ea8c 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c | |||
@@ -107,10 +107,10 @@ evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type, | |||
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Block with no xquery\n"); | 107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Block with no xquery\n"); |
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " key: %s, %u edges\n", | 108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " key: %s, %u edges\n", |
109 | GNUNET_h2s (&rblock->key), ntohl (rblock->n_edges)); | 109 | GNUNET_h2s (&rblock->key), ntohl (rblock->n_edges)); |
110 | GNUNET_REGEX_block_iterate (rblock, reply_block_size, &rdebug, NULL); | 110 | REGEX_ITERNAL_block_iterate (rblock, reply_block_size, &rdebug, NULL); |
111 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 111 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
112 | } | 112 | } |
113 | switch (GNUNET_REGEX_block_check (reply_block, | 113 | switch (REGEX_ITERNAL_block_check (reply_block, |
114 | reply_block_size, | 114 | reply_block_size, |
115 | xquery)) | 115 | xquery)) |
116 | { | 116 | { |
diff --git a/src/regex/regex.c b/src/regex/regex.c index 711e5458b..ecb3044e3 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c | |||
@@ -24,11 +24,12 @@ | |||
24 | * @author Maximilian Szengel | 24 | * @author Maximilian Szengel |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_container_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_crypto_lib.h" | 28 | #include "gnunet_regex_service.h" |
29 | #include "gnunet_regex_lib.h" | 29 | #include "regex_internal_lib.h" |
30 | #include "regex_internal.h" | 30 | #include "regex_internal.h" |
31 | 31 | ||
32 | |||
32 | /** | 33 | /** |
33 | * Set this to GNUNET_YES to enable state naming. Used to debug NFA->DFA | 34 | * Set this to GNUNET_YES to enable state naming. Used to debug NFA->DFA |
34 | * creation. Disabled by default for better performance. | 35 | * creation. Disabled by default for better performance. |
@@ -38,17 +39,17 @@ | |||
38 | /** | 39 | /** |
39 | * Set of states using MDLL API. | 40 | * Set of states using MDLL API. |
40 | */ | 41 | */ |
41 | struct GNUNET_REGEX_StateSet_MDLL | 42 | struct REGEX_ITERNAL_StateSet_MDLL |
42 | { | 43 | { |
43 | /** | 44 | /** |
44 | * MDLL of states. | 45 | * MDLL of states. |
45 | */ | 46 | */ |
46 | struct GNUNET_REGEX_State *head; | 47 | struct REGEX_ITERNAL_State *head; |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * MDLL of states. | 50 | * MDLL of states. |
50 | */ | 51 | */ |
51 | struct GNUNET_REGEX_State *tail; | 52 | struct REGEX_ITERNAL_State *tail; |
52 | 53 | ||
53 | /** | 54 | /** |
54 | * Length of the MDLL. | 55 | * Length of the MDLL. |
@@ -64,8 +65,8 @@ struct GNUNET_REGEX_StateSet_MDLL | |||
64 | * @param state state to be appended | 65 | * @param state state to be appended |
65 | */ | 66 | */ |
66 | static void | 67 | static void |
67 | state_set_append (struct GNUNET_REGEX_StateSet *set, | 68 | state_set_append (struct REGEX_ITERNAL_StateSet *set, |
68 | struct GNUNET_REGEX_State *state) | 69 | struct REGEX_ITERNAL_State *state) |
69 | { | 70 | { |
70 | if (set->off == set->size) | 71 | if (set->off == set->size) |
71 | GNUNET_array_grow (set->states, set->size, set->size * 2 + 4); | 72 | GNUNET_array_grow (set->states, set->size, set->size * 2 + 4); |
@@ -103,12 +104,12 @@ nullstrcmp (const char *str1, const char *str2) | |||
103 | * @param to_state state to where the transition should point to | 104 | * @param to_state state to where the transition should point to |
104 | */ | 105 | */ |
105 | static void | 106 | static void |
106 | state_add_transition (struct GNUNET_REGEX_Context *ctx, | 107 | state_add_transition (struct REGEX_ITERNAL_Context *ctx, |
107 | struct GNUNET_REGEX_State *from_state, const char *label, | 108 | struct REGEX_ITERNAL_State *from_state, const char *label, |
108 | struct GNUNET_REGEX_State *to_state) | 109 | struct REGEX_ITERNAL_State *to_state) |
109 | { | 110 | { |
110 | struct GNUNET_REGEX_Transition *t; | 111 | struct REGEX_ITERNAL_Transition *t; |
111 | struct GNUNET_REGEX_Transition *oth; | 112 | struct REGEX_ITERNAL_Transition *oth; |
112 | 113 | ||
113 | if (NULL == from_state) | 114 | if (NULL == from_state) |
114 | { | 115 | { |
@@ -131,7 +132,7 @@ state_add_transition (struct GNUNET_REGEX_Context *ctx, | |||
131 | break; | 132 | break; |
132 | } | 133 | } |
133 | 134 | ||
134 | t = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Transition)); | 135 | t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition)); |
135 | if (NULL != ctx) | 136 | if (NULL != ctx) |
136 | t->id = ctx->transition_id++; | 137 | t->id = ctx->transition_id++; |
137 | if (NULL != label) | 138 | if (NULL != label) |
@@ -155,8 +156,8 @@ state_add_transition (struct GNUNET_REGEX_Context *ctx, | |||
155 | * @param transition transition that should be removed from state 'state'. | 156 | * @param transition transition that should be removed from state 'state'. |
156 | */ | 157 | */ |
157 | static void | 158 | static void |
158 | state_remove_transition (struct GNUNET_REGEX_State *state, | 159 | state_remove_transition (struct REGEX_ITERNAL_State *state, |
159 | struct GNUNET_REGEX_Transition *transition) | 160 | struct REGEX_ITERNAL_Transition *transition) |
160 | { | 161 | { |
161 | if (NULL == state || NULL == transition) | 162 | if (NULL == state || NULL == transition) |
162 | return; | 163 | return; |
@@ -187,8 +188,8 @@ state_remove_transition (struct GNUNET_REGEX_State *state, | |||
187 | static int | 188 | static int |
188 | state_compare (const void *a, const void *b) | 189 | state_compare (const void *a, const void *b) |
189 | { | 190 | { |
190 | struct GNUNET_REGEX_State **s1 = (struct GNUNET_REGEX_State **) a; | 191 | struct REGEX_ITERNAL_State **s1 = (struct REGEX_ITERNAL_State **) a; |
191 | struct GNUNET_REGEX_State **s2 = (struct GNUNET_REGEX_State **) b; | 192 | struct REGEX_ITERNAL_State **s2 = (struct REGEX_ITERNAL_State **) b; |
192 | 193 | ||
193 | return (*s1)->id - (*s2)->id; | 194 | return (*s1)->id - (*s2)->id; |
194 | } | 195 | } |
@@ -204,9 +205,9 @@ state_compare (const void *a, const void *b) | |||
204 | * @return number of edges. | 205 | * @return number of edges. |
205 | */ | 206 | */ |
206 | static unsigned int | 207 | static unsigned int |
207 | state_get_edges (struct GNUNET_REGEX_State *s, struct GNUNET_REGEX_Edge *edges) | 208 | state_get_edges (struct REGEX_ITERNAL_State *s, struct REGEX_ITERNAL_Edge *edges) |
208 | { | 209 | { |
209 | struct GNUNET_REGEX_Transition *t; | 210 | struct REGEX_ITERNAL_Transition *t; |
210 | unsigned int count; | 211 | unsigned int count; |
211 | 212 | ||
212 | if (NULL == s) | 213 | if (NULL == s) |
@@ -236,8 +237,8 @@ state_get_edges (struct GNUNET_REGEX_State *s, struct GNUNET_REGEX_Edge *edges) | |||
236 | * @return 0 if the sets are equal, otherwise non-zero | 237 | * @return 0 if the sets are equal, otherwise non-zero |
237 | */ | 238 | */ |
238 | static int | 239 | static int |
239 | state_set_compare (struct GNUNET_REGEX_StateSet *sset1, | 240 | state_set_compare (struct REGEX_ITERNAL_StateSet *sset1, |
240 | struct GNUNET_REGEX_StateSet *sset2) | 241 | struct REGEX_ITERNAL_StateSet *sset2) |
241 | { | 242 | { |
242 | int result; | 243 | int result; |
243 | unsigned int i; | 244 | unsigned int i; |
@@ -263,7 +264,7 @@ state_set_compare (struct GNUNET_REGEX_StateSet *sset1, | |||
263 | * @param set set to be cleared | 264 | * @param set set to be cleared |
264 | */ | 265 | */ |
265 | static void | 266 | static void |
266 | state_set_clear (struct GNUNET_REGEX_StateSet *set) | 267 | state_set_clear (struct REGEX_ITERNAL_StateSet *set) |
267 | { | 268 | { |
268 | GNUNET_array_grow (set->states, set->size, 0); | 269 | GNUNET_array_grow (set->states, set->size, 0); |
269 | set->off = 0; | 270 | set->off = 0; |
@@ -277,7 +278,7 @@ state_set_clear (struct GNUNET_REGEX_StateSet *set) | |||
277 | * @param a automaton to be cleared | 278 | * @param a automaton to be cleared |
278 | */ | 279 | */ |
279 | static void | 280 | static void |
280 | automaton_fragment_clear (struct GNUNET_REGEX_Automaton *a) | 281 | automaton_fragment_clear (struct REGEX_ITERNAL_Automaton *a) |
281 | { | 282 | { |
282 | if (NULL == a) | 283 | if (NULL == a) |
283 | return; | 284 | return; |
@@ -297,10 +298,10 @@ automaton_fragment_clear (struct GNUNET_REGEX_Automaton *a) | |||
297 | * @param s state that should be destroyed | 298 | * @param s state that should be destroyed |
298 | */ | 299 | */ |
299 | static void | 300 | static void |
300 | automaton_destroy_state (struct GNUNET_REGEX_State *s) | 301 | automaton_destroy_state (struct REGEX_ITERNAL_State *s) |
301 | { | 302 | { |
302 | struct GNUNET_REGEX_Transition *t; | 303 | struct REGEX_ITERNAL_Transition *t; |
303 | struct GNUNET_REGEX_Transition *next_t; | 304 | struct REGEX_ITERNAL_Transition *next_t; |
304 | 305 | ||
305 | if (NULL == s) | 306 | if (NULL == s) |
306 | return; | 307 | return; |
@@ -327,12 +328,12 @@ automaton_destroy_state (struct GNUNET_REGEX_State *s) | |||
327 | * @param s state to remove | 328 | * @param s state to remove |
328 | */ | 329 | */ |
329 | static void | 330 | static void |
330 | automaton_remove_state (struct GNUNET_REGEX_Automaton *a, | 331 | automaton_remove_state (struct REGEX_ITERNAL_Automaton *a, |
331 | struct GNUNET_REGEX_State *s) | 332 | struct REGEX_ITERNAL_State *s) |
332 | { | 333 | { |
333 | struct GNUNET_REGEX_State *s_check; | 334 | struct REGEX_ITERNAL_State *s_check; |
334 | struct GNUNET_REGEX_Transition *t_check; | 335 | struct REGEX_ITERNAL_Transition *t_check; |
335 | struct GNUNET_REGEX_Transition *t_check_next; | 336 | struct REGEX_ITERNAL_Transition *t_check_next; |
336 | 337 | ||
337 | if (NULL == a || NULL == s) | 338 | if (NULL == a || NULL == s) |
338 | return; | 339 | return; |
@@ -367,15 +368,15 @@ automaton_remove_state (struct GNUNET_REGEX_Automaton *a, | |||
367 | * @param s2 second state, will be destroyed | 368 | * @param s2 second state, will be destroyed |
368 | */ | 369 | */ |
369 | static void | 370 | static void |
370 | automaton_merge_states (struct GNUNET_REGEX_Context *ctx, | 371 | automaton_merge_states (struct REGEX_ITERNAL_Context *ctx, |
371 | struct GNUNET_REGEX_Automaton *a, | 372 | struct REGEX_ITERNAL_Automaton *a, |
372 | struct GNUNET_REGEX_State *s1, | 373 | struct REGEX_ITERNAL_State *s1, |
373 | struct GNUNET_REGEX_State *s2) | 374 | struct REGEX_ITERNAL_State *s2) |
374 | { | 375 | { |
375 | struct GNUNET_REGEX_State *s_check; | 376 | struct REGEX_ITERNAL_State *s_check; |
376 | struct GNUNET_REGEX_Transition *t_check; | 377 | struct REGEX_ITERNAL_Transition *t_check; |
377 | struct GNUNET_REGEX_Transition *t; | 378 | struct REGEX_ITERNAL_Transition *t; |
378 | struct GNUNET_REGEX_Transition *t_next; | 379 | struct REGEX_ITERNAL_Transition *t_next; |
379 | int is_dup; | 380 | int is_dup; |
380 | 381 | ||
381 | if (s1 == s2) | 382 | if (s1 == s2) |
@@ -436,8 +437,8 @@ automaton_merge_states (struct GNUNET_REGEX_Context *ctx, | |||
436 | * @param s state that should be added | 437 | * @param s state that should be added |
437 | */ | 438 | */ |
438 | static void | 439 | static void |
439 | automaton_add_state (struct GNUNET_REGEX_Automaton *a, | 440 | automaton_add_state (struct REGEX_ITERNAL_Automaton *a, |
440 | struct GNUNET_REGEX_State *s) | 441 | struct REGEX_ITERNAL_State *s) |
441 | { | 442 | { |
442 | GNUNET_CONTAINER_DLL_insert (a->states_head, a->states_tail, s); | 443 | GNUNET_CONTAINER_DLL_insert (a->states_head, a->states_tail, s); |
443 | a->state_count++; | 444 | a->state_count++; |
@@ -459,12 +460,12 @@ automaton_add_state (struct GNUNET_REGEX_Automaton *a, | |||
459 | * @param action_cls closure for action. | 460 | * @param action_cls closure for action. |
460 | */ | 461 | */ |
461 | static void | 462 | static void |
462 | automaton_state_traverse (struct GNUNET_REGEX_State *s, int *marks, | 463 | automaton_state_traverse (struct REGEX_ITERNAL_State *s, int *marks, |
463 | unsigned int *count, | 464 | unsigned int *count, |
464 | GNUNET_REGEX_traverse_check check, void *check_cls, | 465 | REGEX_ITERNAL_traverse_check check, void *check_cls, |
465 | GNUNET_REGEX_traverse_action action, void *action_cls) | 466 | REGEX_ITERNAL_traverse_action action, void *action_cls) |
466 | { | 467 | { |
467 | struct GNUNET_REGEX_Transition *t; | 468 | struct REGEX_ITERNAL_Transition *t; |
468 | 469 | ||
469 | if (GNUNET_YES == marks[s->traversal_id]) | 470 | if (GNUNET_YES == marks[s->traversal_id]) |
470 | return; | 471 | return; |
@@ -502,15 +503,15 @@ automaton_state_traverse (struct GNUNET_REGEX_State *s, int *marks, | |||
502 | * @param action_cls closure for action | 503 | * @param action_cls closure for action |
503 | */ | 504 | */ |
504 | void | 505 | void |
505 | GNUNET_REGEX_automaton_traverse (const struct GNUNET_REGEX_Automaton *a, | 506 | REGEX_ITERNAL_automaton_traverse (const struct REGEX_ITERNAL_Automaton *a, |
506 | struct GNUNET_REGEX_State *start, | 507 | struct REGEX_ITERNAL_State *start, |
507 | GNUNET_REGEX_traverse_check check, | 508 | REGEX_ITERNAL_traverse_check check, |
508 | void *check_cls, | 509 | void *check_cls, |
509 | GNUNET_REGEX_traverse_action action, | 510 | REGEX_ITERNAL_traverse_action action, |
510 | void *action_cls) | 511 | void *action_cls) |
511 | { | 512 | { |
512 | unsigned int count; | 513 | unsigned int count; |
513 | struct GNUNET_REGEX_State *s; | 514 | struct REGEX_ITERNAL_State *s; |
514 | 515 | ||
515 | if (NULL == a || 0 == a->state_count) | 516 | if (NULL == a || 0 == a->state_count) |
516 | return; | 517 | return; |
@@ -1155,7 +1156,7 @@ sb_strkcmp (const struct StringBuffer *str1, | |||
1155 | 1156 | ||
1156 | 1157 | ||
1157 | /** | 1158 | /** |
1158 | * Helper function used as 'action' in 'GNUNET_REGEX_automaton_traverse' | 1159 | * Helper function used as 'action' in 'REGEX_ITERNAL_automaton_traverse' |
1159 | * function to create the depth-first numbering of the states. | 1160 | * function to create the depth-first numbering of the states. |
1160 | * | 1161 | * |
1161 | * @param cls states array. | 1162 | * @param cls states array. |
@@ -1164,9 +1165,9 @@ sb_strkcmp (const struct StringBuffer *str1, | |||
1164 | */ | 1165 | */ |
1165 | static void | 1166 | static void |
1166 | number_states (void *cls, const unsigned int count, | 1167 | number_states (void *cls, const unsigned int count, |
1167 | struct GNUNET_REGEX_State *s) | 1168 | struct REGEX_ITERNAL_State *s) |
1168 | { | 1169 | { |
1169 | struct GNUNET_REGEX_State **states = cls; | 1170 | struct REGEX_ITERNAL_State **states = cls; |
1170 | 1171 | ||
1171 | s->dfs_id = count; | 1172 | s->dfs_id = count; |
1172 | if (NULL != states) | 1173 | if (NULL != states) |
@@ -1603,16 +1604,16 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1603 | * @param a automaton for which to assign proofs and hashes, must not be NULL | 1604 | * @param a automaton for which to assign proofs and hashes, must not be NULL |
1604 | */ | 1605 | */ |
1605 | static int | 1606 | static int |
1606 | automaton_create_proofs (struct GNUNET_REGEX_Automaton *a) | 1607 | automaton_create_proofs (struct REGEX_ITERNAL_Automaton *a) |
1607 | { | 1608 | { |
1608 | unsigned int n = a->state_count; | 1609 | unsigned int n = a->state_count; |
1609 | struct GNUNET_REGEX_State *states[n]; | 1610 | struct REGEX_ITERNAL_State *states[n]; |
1610 | struct StringBuffer *R_last; | 1611 | struct StringBuffer *R_last; |
1611 | struct StringBuffer *R_cur; | 1612 | struct StringBuffer *R_cur; |
1612 | struct StringBuffer R_cur_r; | 1613 | struct StringBuffer R_cur_r; |
1613 | struct StringBuffer R_cur_l; | 1614 | struct StringBuffer R_cur_l; |
1614 | struct StringBuffer *R_swap; | 1615 | struct StringBuffer *R_swap; |
1615 | struct GNUNET_REGEX_Transition *t; | 1616 | struct REGEX_ITERNAL_Transition *t; |
1616 | struct StringBuffer complete_regex; | 1617 | struct StringBuffer complete_regex; |
1617 | unsigned int i; | 1618 | unsigned int i; |
1618 | unsigned int j; | 1619 | unsigned int j; |
@@ -1630,7 +1631,7 @@ automaton_create_proofs (struct GNUNET_REGEX_Automaton *a) | |||
1630 | } | 1631 | } |
1631 | 1632 | ||
1632 | /* create depth-first numbering of the states, initializes 'state' */ | 1633 | /* create depth-first numbering of the states, initializes 'state' */ |
1633 | GNUNET_REGEX_automaton_traverse (a, a->start, NULL, NULL, &number_states, | 1634 | REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, &number_states, |
1634 | states); | 1635 | states); |
1635 | 1636 | ||
1636 | for (i = 0; i < n; i++) | 1637 | for (i = 0; i < n; i++) |
@@ -1762,18 +1763,18 @@ automaton_create_proofs (struct GNUNET_REGEX_Automaton *a) | |||
1762 | * | 1763 | * |
1763 | * @return new DFA state | 1764 | * @return new DFA state |
1764 | */ | 1765 | */ |
1765 | static struct GNUNET_REGEX_State * | 1766 | static struct REGEX_ITERNAL_State * |
1766 | dfa_state_create (struct GNUNET_REGEX_Context *ctx, | 1767 | dfa_state_create (struct REGEX_ITERNAL_Context *ctx, |
1767 | struct GNUNET_REGEX_StateSet *nfa_states) | 1768 | struct REGEX_ITERNAL_StateSet *nfa_states) |
1768 | { | 1769 | { |
1769 | struct GNUNET_REGEX_State *s; | 1770 | struct REGEX_ITERNAL_State *s; |
1770 | char *pos; | 1771 | char *pos; |
1771 | size_t len; | 1772 | size_t len; |
1772 | struct GNUNET_REGEX_State *cstate; | 1773 | struct REGEX_ITERNAL_State *cstate; |
1773 | struct GNUNET_REGEX_Transition *ctran; | 1774 | struct REGEX_ITERNAL_Transition *ctran; |
1774 | unsigned int i; | 1775 | unsigned int i; |
1775 | 1776 | ||
1776 | s = GNUNET_malloc (sizeof (struct GNUNET_REGEX_State)); | 1777 | s = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_State)); |
1777 | s->id = ctx->state_id++; | 1778 | s->id = ctx->state_id++; |
1778 | s->index = -1; | 1779 | s->index = -1; |
1779 | s->lowlink = -1; | 1780 | s->lowlink = -1; |
@@ -1815,7 +1816,7 @@ dfa_state_create (struct GNUNET_REGEX_Context *ctx, | |||
1815 | pos[-1] = '}'; | 1816 | pos[-1] = '}'; |
1816 | s->name = GNUNET_realloc (s->name, strlen (s->name) + 1); | 1817 | s->name = GNUNET_realloc (s->name, strlen (s->name) + 1); |
1817 | 1818 | ||
1818 | memset (nfa_states, 0, sizeof (struct GNUNET_REGEX_StateSet)); | 1819 | memset (nfa_states, 0, sizeof (struct REGEX_ITERNAL_StateSet)); |
1819 | return s; | 1820 | return s; |
1820 | } | 1821 | } |
1821 | 1822 | ||
@@ -1834,10 +1835,10 @@ dfa_state_create (struct GNUNET_REGEX_Context *ctx, | |||
1834 | * @return length of the substring comsumed from 'str' | 1835 | * @return length of the substring comsumed from 'str' |
1835 | */ | 1836 | */ |
1836 | static unsigned int | 1837 | static unsigned int |
1837 | dfa_move (struct GNUNET_REGEX_State **s, const char *str) | 1838 | dfa_move (struct REGEX_ITERNAL_State **s, const char *str) |
1838 | { | 1839 | { |
1839 | struct GNUNET_REGEX_Transition *t; | 1840 | struct REGEX_ITERNAL_Transition *t; |
1840 | struct GNUNET_REGEX_State *new_s; | 1841 | struct REGEX_ITERNAL_State *new_s; |
1841 | unsigned int len; | 1842 | unsigned int len; |
1842 | unsigned int max_len; | 1843 | unsigned int max_len; |
1843 | 1844 | ||
@@ -1875,7 +1876,7 @@ dfa_move (struct GNUNET_REGEX_State **s, const char *str) | |||
1875 | * @param s state where the marked attribute will be set to GNUNET_YES. | 1876 | * @param s state where the marked attribute will be set to GNUNET_YES. |
1876 | */ | 1877 | */ |
1877 | static void | 1878 | static void |
1878 | mark_states (void *cls, const unsigned int count, struct GNUNET_REGEX_State *s) | 1879 | mark_states (void *cls, const unsigned int count, struct REGEX_ITERNAL_State *s) |
1879 | { | 1880 | { |
1880 | s->marked = GNUNET_YES; | 1881 | s->marked = GNUNET_YES; |
1881 | } | 1882 | } |
@@ -1888,17 +1889,17 @@ mark_states (void *cls, const unsigned int count, struct GNUNET_REGEX_State *s) | |||
1888 | * @param a DFA automaton | 1889 | * @param a DFA automaton |
1889 | */ | 1890 | */ |
1890 | static void | 1891 | static void |
1891 | dfa_remove_unreachable_states (struct GNUNET_REGEX_Automaton *a) | 1892 | dfa_remove_unreachable_states (struct REGEX_ITERNAL_Automaton *a) |
1892 | { | 1893 | { |
1893 | struct GNUNET_REGEX_State *s; | 1894 | struct REGEX_ITERNAL_State *s; |
1894 | struct GNUNET_REGEX_State *s_next; | 1895 | struct REGEX_ITERNAL_State *s_next; |
1895 | 1896 | ||
1896 | /* 1. unmark all states */ | 1897 | /* 1. unmark all states */ |
1897 | for (s = a->states_head; NULL != s; s = s->next) | 1898 | for (s = a->states_head; NULL != s; s = s->next) |
1898 | s->marked = GNUNET_NO; | 1899 | s->marked = GNUNET_NO; |
1899 | 1900 | ||
1900 | /* 2. traverse dfa from start state and mark all visited states */ | 1901 | /* 2. traverse dfa from start state and mark all visited states */ |
1901 | GNUNET_REGEX_automaton_traverse (a, a->start, NULL, NULL, &mark_states, NULL); | 1902 | REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, &mark_states, NULL); |
1902 | 1903 | ||
1903 | /* 3. delete all states that were not visited */ | 1904 | /* 3. delete all states that were not visited */ |
1904 | for (s = a->states_head; NULL != s; s = s_next) | 1905 | for (s = a->states_head; NULL != s; s = s_next) |
@@ -1917,11 +1918,11 @@ dfa_remove_unreachable_states (struct GNUNET_REGEX_Automaton *a) | |||
1917 | * @param a DFA automaton | 1918 | * @param a DFA automaton |
1918 | */ | 1919 | */ |
1919 | static void | 1920 | static void |
1920 | dfa_remove_dead_states (struct GNUNET_REGEX_Automaton *a) | 1921 | dfa_remove_dead_states (struct REGEX_ITERNAL_Automaton *a) |
1921 | { | 1922 | { |
1922 | struct GNUNET_REGEX_State *s; | 1923 | struct REGEX_ITERNAL_State *s; |
1923 | struct GNUNET_REGEX_State *s_next; | 1924 | struct REGEX_ITERNAL_State *s_next; |
1924 | struct GNUNET_REGEX_Transition *t; | 1925 | struct REGEX_ITERNAL_Transition *t; |
1925 | int dead; | 1926 | int dead; |
1926 | 1927 | ||
1927 | GNUNET_assert (DFA == a->type); | 1928 | GNUNET_assert (DFA == a->type); |
@@ -1960,16 +1961,16 @@ dfa_remove_dead_states (struct GNUNET_REGEX_Automaton *a) | |||
1960 | * @return GNUNET_OK on success | 1961 | * @return GNUNET_OK on success |
1961 | */ | 1962 | */ |
1962 | static int | 1963 | static int |
1963 | dfa_merge_nondistinguishable_states (struct GNUNET_REGEX_Context *ctx, | 1964 | dfa_merge_nondistinguishable_states (struct REGEX_ITERNAL_Context *ctx, |
1964 | struct GNUNET_REGEX_Automaton *a) | 1965 | struct REGEX_ITERNAL_Automaton *a) |
1965 | { | 1966 | { |
1966 | uint32_t *table; | 1967 | uint32_t *table; |
1967 | struct GNUNET_REGEX_State *s1; | 1968 | struct REGEX_ITERNAL_State *s1; |
1968 | struct GNUNET_REGEX_State *s2; | 1969 | struct REGEX_ITERNAL_State *s2; |
1969 | struct GNUNET_REGEX_Transition *t1; | 1970 | struct REGEX_ITERNAL_Transition *t1; |
1970 | struct GNUNET_REGEX_Transition *t2; | 1971 | struct REGEX_ITERNAL_Transition *t2; |
1971 | struct GNUNET_REGEX_State *s1_next; | 1972 | struct REGEX_ITERNAL_State *s1_next; |
1972 | struct GNUNET_REGEX_State *s2_next; | 1973 | struct REGEX_ITERNAL_State *s2_next; |
1973 | int change; | 1974 | int change; |
1974 | unsigned int num_equal_edges; | 1975 | unsigned int num_equal_edges; |
1975 | unsigned int i; | 1976 | unsigned int i; |
@@ -2077,8 +2078,8 @@ dfa_merge_nondistinguishable_states (struct GNUNET_REGEX_Context *ctx, | |||
2077 | * @return GNUNET_OK on success | 2078 | * @return GNUNET_OK on success |
2078 | */ | 2079 | */ |
2079 | static int | 2080 | static int |
2080 | dfa_minimize (struct GNUNET_REGEX_Context *ctx, | 2081 | dfa_minimize (struct REGEX_ITERNAL_Context *ctx, |
2081 | struct GNUNET_REGEX_Automaton *a) | 2082 | struct REGEX_ITERNAL_Automaton *a) |
2082 | { | 2083 | { |
2083 | if (NULL == a) | 2084 | if (NULL == a) |
2084 | return GNUNET_SYSERR; | 2085 | return GNUNET_SYSERR; |
@@ -2101,7 +2102,7 @@ dfa_minimize (struct GNUNET_REGEX_Context *ctx, | |||
2101 | /** | 2102 | /** |
2102 | * Context for adding strided transitions to a DFA. | 2103 | * Context for adding strided transitions to a DFA. |
2103 | */ | 2104 | */ |
2104 | struct GNUNET_REGEX_Strided_Context | 2105 | struct REGEX_ITERNAL_Strided_Context |
2105 | { | 2106 | { |
2106 | /** | 2107 | /** |
2107 | * Length of the strides. | 2108 | * Length of the strides. |
@@ -2112,12 +2113,12 @@ struct GNUNET_REGEX_Strided_Context | |||
2112 | * Strided transitions DLL. New strided transitions will be stored in this DLL | 2113 | * Strided transitions DLL. New strided transitions will be stored in this DLL |
2113 | * and afterwards added to the DFA. | 2114 | * and afterwards added to the DFA. |
2114 | */ | 2115 | */ |
2115 | struct GNUNET_REGEX_Transition *transitions_head; | 2116 | struct REGEX_ITERNAL_Transition *transitions_head; |
2116 | 2117 | ||
2117 | /** | 2118 | /** |
2118 | * Strided transitions DLL. | 2119 | * Strided transitions DLL. |
2119 | */ | 2120 | */ |
2120 | struct GNUNET_REGEX_Transition *transitions_tail; | 2121 | struct REGEX_ITERNAL_Transition *transitions_tail; |
2121 | }; | 2122 | }; |
2122 | 2123 | ||
2123 | 2124 | ||
@@ -2133,16 +2134,16 @@ struct GNUNET_REGEX_Strided_Context | |||
2133 | */ | 2134 | */ |
2134 | void | 2135 | void |
2135 | dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, | 2136 | dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, |
2136 | struct GNUNET_REGEX_State *start, | 2137 | struct REGEX_ITERNAL_State *start, |
2137 | struct GNUNET_REGEX_State *s) | 2138 | struct REGEX_ITERNAL_State *s) |
2138 | { | 2139 | { |
2139 | struct GNUNET_REGEX_Strided_Context *ctx = cls; | 2140 | struct REGEX_ITERNAL_Strided_Context *ctx = cls; |
2140 | struct GNUNET_REGEX_Transition *t; | 2141 | struct REGEX_ITERNAL_Transition *t; |
2141 | char *new_label; | 2142 | char *new_label; |
2142 | 2143 | ||
2143 | if (depth == ctx->stride) | 2144 | if (depth == ctx->stride) |
2144 | { | 2145 | { |
2145 | t = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Transition)); | 2146 | t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition)); |
2146 | t->label = GNUNET_strdup (label); | 2147 | t->label = GNUNET_strdup (label); |
2147 | t->to_state = s; | 2148 | t->to_state = s; |
2148 | t->from_state = start; | 2149 | t->from_state = start; |
@@ -2183,7 +2184,7 @@ dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, | |||
2183 | */ | 2184 | */ |
2184 | void | 2185 | void |
2185 | dfa_add_multi_strides (void *cls, const unsigned int count, | 2186 | dfa_add_multi_strides (void *cls, const unsigned int count, |
2186 | struct GNUNET_REGEX_State *s) | 2187 | struct REGEX_ITERNAL_State *s) |
2187 | { | 2188 | { |
2188 | dfa_add_multi_strides_helper (cls, 0, NULL, s, s); | 2189 | dfa_add_multi_strides_helper (cls, 0, NULL, s, s); |
2189 | } | 2190 | } |
@@ -2197,19 +2198,19 @@ dfa_add_multi_strides (void *cls, const unsigned int count, | |||
2197 | * @param stride_len length of the strides. | 2198 | * @param stride_len length of the strides. |
2198 | */ | 2199 | */ |
2199 | void | 2200 | void |
2200 | GNUNET_REGEX_dfa_add_multi_strides (struct GNUNET_REGEX_Context *regex_ctx, | 2201 | REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx, |
2201 | struct GNUNET_REGEX_Automaton *dfa, | 2202 | struct REGEX_ITERNAL_Automaton *dfa, |
2202 | const unsigned int stride_len) | 2203 | const unsigned int stride_len) |
2203 | { | 2204 | { |
2204 | struct GNUNET_REGEX_Strided_Context ctx = { stride_len, NULL, NULL }; | 2205 | struct REGEX_ITERNAL_Strided_Context ctx = { stride_len, NULL, NULL }; |
2205 | struct GNUNET_REGEX_Transition *t; | 2206 | struct REGEX_ITERNAL_Transition *t; |
2206 | struct GNUNET_REGEX_Transition *t_next; | 2207 | struct REGEX_ITERNAL_Transition *t_next; |
2207 | 2208 | ||
2208 | if (1 > stride_len || GNUNET_YES == dfa->is_multistrided) | 2209 | if (1 > stride_len || GNUNET_YES == dfa->is_multistrided) |
2209 | return; | 2210 | return; |
2210 | 2211 | ||
2211 | /* Compute the new transitions of given stride_len */ | 2212 | /* Compute the new transitions of given stride_len */ |
2212 | GNUNET_REGEX_automaton_traverse (dfa, dfa->start, NULL, NULL, | 2213 | REGEX_ITERNAL_automaton_traverse (dfa, dfa->start, NULL, NULL, |
2213 | &dfa_add_multi_strides, &ctx); | 2214 | &dfa_add_multi_strides, &ctx); |
2214 | 2215 | ||
2215 | /* Add all the new transitions to the automaton. */ | 2216 | /* Add all the new transitions to the automaton. */ |
@@ -2240,14 +2241,14 @@ GNUNET_REGEX_dfa_add_multi_strides (struct GNUNET_REGEX_Context *regex_ctx, | |||
2240 | * @param transitions_tail transitions DLL. | 2241 | * @param transitions_tail transitions DLL. |
2241 | */ | 2242 | */ |
2242 | void | 2243 | void |
2243 | dfa_compress_paths_helper (struct GNUNET_REGEX_Automaton *dfa, | 2244 | dfa_compress_paths_helper (struct REGEX_ITERNAL_Automaton *dfa, |
2244 | struct GNUNET_REGEX_State *start, | 2245 | struct REGEX_ITERNAL_State *start, |
2245 | struct GNUNET_REGEX_State *cur, char *label, | 2246 | struct REGEX_ITERNAL_State *cur, char *label, |
2246 | unsigned int max_len, | 2247 | unsigned int max_len, |
2247 | struct GNUNET_REGEX_Transition **transitions_head, | 2248 | struct REGEX_ITERNAL_Transition **transitions_head, |
2248 | struct GNUNET_REGEX_Transition **transitions_tail) | 2249 | struct REGEX_ITERNAL_Transition **transitions_tail) |
2249 | { | 2250 | { |
2250 | struct GNUNET_REGEX_Transition *t; | 2251 | struct REGEX_ITERNAL_Transition *t; |
2251 | char *new_label; | 2252 | char *new_label; |
2252 | 2253 | ||
2253 | 2254 | ||
@@ -2257,7 +2258,7 @@ dfa_compress_paths_helper (struct GNUNET_REGEX_Automaton *dfa, | |||
2257 | max_len == strlen (label)) || | 2258 | max_len == strlen (label)) || |
2258 | (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label)))) | 2259 | (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label)))) |
2259 | { | 2260 | { |
2260 | t = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Transition)); | 2261 | t = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Transition)); |
2261 | t->label = GNUNET_strdup (label); | 2262 | t->label = GNUNET_strdup (label); |
2262 | t->to_state = cur; | 2263 | t->to_state = cur; |
2263 | t->from_state = start; | 2264 | t->from_state = start; |
@@ -2305,15 +2306,15 @@ dfa_compress_paths_helper (struct GNUNET_REGEX_Automaton *dfa, | |||
2305 | * @param max_len maximal length of the compressed paths. | 2306 | * @param max_len maximal length of the compressed paths. |
2306 | */ | 2307 | */ |
2307 | static void | 2308 | static void |
2308 | dfa_compress_paths (struct GNUNET_REGEX_Context *regex_ctx, | 2309 | dfa_compress_paths (struct REGEX_ITERNAL_Context *regex_ctx, |
2309 | struct GNUNET_REGEX_Automaton *dfa, unsigned int max_len) | 2310 | struct REGEX_ITERNAL_Automaton *dfa, unsigned int max_len) |
2310 | { | 2311 | { |
2311 | struct GNUNET_REGEX_State *s; | 2312 | struct REGEX_ITERNAL_State *s; |
2312 | struct GNUNET_REGEX_State *s_next; | 2313 | struct REGEX_ITERNAL_State *s_next; |
2313 | struct GNUNET_REGEX_Transition *t; | 2314 | struct REGEX_ITERNAL_Transition *t; |
2314 | struct GNUNET_REGEX_Transition *t_next; | 2315 | struct REGEX_ITERNAL_Transition *t_next; |
2315 | struct GNUNET_REGEX_Transition *transitions_head = NULL; | 2316 | struct REGEX_ITERNAL_Transition *transitions_head = NULL; |
2316 | struct GNUNET_REGEX_Transition *transitions_tail = NULL; | 2317 | struct REGEX_ITERNAL_Transition *transitions_tail = NULL; |
2317 | 2318 | ||
2318 | if (NULL == dfa) | 2319 | if (NULL == dfa) |
2319 | return; | 2320 | return; |
@@ -2368,13 +2369,13 @@ dfa_compress_paths (struct GNUNET_REGEX_Context *regex_ctx, | |||
2368 | * | 2369 | * |
2369 | * @return new NFA fragment | 2370 | * @return new NFA fragment |
2370 | */ | 2371 | */ |
2371 | static struct GNUNET_REGEX_Automaton * | 2372 | static struct REGEX_ITERNAL_Automaton * |
2372 | nfa_fragment_create (struct GNUNET_REGEX_State *start, | 2373 | nfa_fragment_create (struct REGEX_ITERNAL_State *start, |
2373 | struct GNUNET_REGEX_State *end) | 2374 | struct REGEX_ITERNAL_State *end) |
2374 | { | 2375 | { |
2375 | struct GNUNET_REGEX_Automaton *n; | 2376 | struct REGEX_ITERNAL_Automaton *n; |
2376 | 2377 | ||
2377 | n = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Automaton)); | 2378 | n = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Automaton)); |
2378 | 2379 | ||
2379 | n->type = NFA; | 2380 | n->type = NFA; |
2380 | n->start = NULL; | 2381 | n->start = NULL; |
@@ -2404,11 +2405,11 @@ nfa_fragment_create (struct GNUNET_REGEX_State *start, | |||
2404 | * @param states_tail tail of the DLL of states | 2405 | * @param states_tail tail of the DLL of states |
2405 | */ | 2406 | */ |
2406 | static void | 2407 | static void |
2407 | nfa_add_states (struct GNUNET_REGEX_Automaton *n, | 2408 | nfa_add_states (struct REGEX_ITERNAL_Automaton *n, |
2408 | struct GNUNET_REGEX_State *states_head, | 2409 | struct REGEX_ITERNAL_State *states_head, |
2409 | struct GNUNET_REGEX_State *states_tail) | 2410 | struct REGEX_ITERNAL_State *states_tail) |
2410 | { | 2411 | { |
2411 | struct GNUNET_REGEX_State *s; | 2412 | struct REGEX_ITERNAL_State *s; |
2412 | 2413 | ||
2413 | if (NULL == n || NULL == states_head) | 2414 | if (NULL == n || NULL == states_head) |
2414 | { | 2415 | { |
@@ -2442,12 +2443,12 @@ nfa_add_states (struct GNUNET_REGEX_Automaton *n, | |||
2442 | * | 2443 | * |
2443 | * @return new NFA state | 2444 | * @return new NFA state |
2444 | */ | 2445 | */ |
2445 | static struct GNUNET_REGEX_State * | 2446 | static struct REGEX_ITERNAL_State * |
2446 | nfa_state_create (struct GNUNET_REGEX_Context *ctx, int accepting) | 2447 | nfa_state_create (struct REGEX_ITERNAL_Context *ctx, int accepting) |
2447 | { | 2448 | { |
2448 | struct GNUNET_REGEX_State *s; | 2449 | struct REGEX_ITERNAL_State *s; |
2449 | 2450 | ||
2450 | s = GNUNET_malloc (sizeof (struct GNUNET_REGEX_State)); | 2451 | s = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_State)); |
2451 | s->id = ctx->state_id++; | 2452 | s->id = ctx->state_id++; |
2452 | s->accepting = accepting; | 2453 | s->accepting = accepting; |
2453 | s->marked = GNUNET_NO; | 2454 | s->marked = GNUNET_NO; |
@@ -2472,18 +2473,18 @@ nfa_state_create (struct GNUNET_REGEX_Context *ctx, int accepting) | |||
2472 | * pass NULL for epsilon transition | 2473 | * pass NULL for epsilon transition |
2473 | */ | 2474 | */ |
2474 | static void | 2475 | static void |
2475 | nfa_closure_set_create (struct GNUNET_REGEX_StateSet *ret, | 2476 | nfa_closure_set_create (struct REGEX_ITERNAL_StateSet *ret, |
2476 | struct GNUNET_REGEX_Automaton *nfa, | 2477 | struct REGEX_ITERNAL_Automaton *nfa, |
2477 | struct GNUNET_REGEX_StateSet *states, const char *label) | 2478 | struct REGEX_ITERNAL_StateSet *states, const char *label) |
2478 | { | 2479 | { |
2479 | struct GNUNET_REGEX_State *s; | 2480 | struct REGEX_ITERNAL_State *s; |
2480 | unsigned int i; | 2481 | unsigned int i; |
2481 | struct GNUNET_REGEX_StateSet_MDLL cls_stack; | 2482 | struct REGEX_ITERNAL_StateSet_MDLL cls_stack; |
2482 | struct GNUNET_REGEX_State *clsstate; | 2483 | struct REGEX_ITERNAL_State *clsstate; |
2483 | struct GNUNET_REGEX_State *currentstate; | 2484 | struct REGEX_ITERNAL_State *currentstate; |
2484 | struct GNUNET_REGEX_Transition *ctran; | 2485 | struct REGEX_ITERNAL_Transition *ctran; |
2485 | 2486 | ||
2486 | memset (ret, 0, sizeof (struct GNUNET_REGEX_StateSet)); | 2487 | memset (ret, 0, sizeof (struct REGEX_ITERNAL_StateSet)); |
2487 | if (NULL == states) | 2488 | if (NULL == states) |
2488 | return; | 2489 | return; |
2489 | 2490 | ||
@@ -2527,7 +2528,7 @@ nfa_closure_set_create (struct GNUNET_REGEX_StateSet *ret, | |||
2527 | ret->states[i]->contained = 0; | 2528 | ret->states[i]->contained = 0; |
2528 | 2529 | ||
2529 | if (ret->off > 1) | 2530 | if (ret->off > 1) |
2530 | qsort (ret->states, ret->off, sizeof (struct GNUNET_REGEX_State *), | 2531 | qsort (ret->states, ret->off, sizeof (struct REGEX_ITERNAL_State *), |
2531 | &state_compare); | 2532 | &state_compare); |
2532 | } | 2533 | } |
2533 | 2534 | ||
@@ -2538,11 +2539,11 @@ nfa_closure_set_create (struct GNUNET_REGEX_StateSet *ret, | |||
2538 | * @param ctx context | 2539 | * @param ctx context |
2539 | */ | 2540 | */ |
2540 | static void | 2541 | static void |
2541 | nfa_add_concatenation (struct GNUNET_REGEX_Context *ctx) | 2542 | nfa_add_concatenation (struct REGEX_ITERNAL_Context *ctx) |
2542 | { | 2543 | { |
2543 | struct GNUNET_REGEX_Automaton *a; | 2544 | struct REGEX_ITERNAL_Automaton *a; |
2544 | struct GNUNET_REGEX_Automaton *b; | 2545 | struct REGEX_ITERNAL_Automaton *b; |
2545 | struct GNUNET_REGEX_Automaton *new_nfa; | 2546 | struct REGEX_ITERNAL_Automaton *new_nfa; |
2546 | 2547 | ||
2547 | b = ctx->stack_tail; | 2548 | b = ctx->stack_tail; |
2548 | GNUNET_assert (NULL != b); | 2549 | GNUNET_assert (NULL != b); |
@@ -2574,12 +2575,12 @@ nfa_add_concatenation (struct GNUNET_REGEX_Context *ctx) | |||
2574 | * @param ctx context | 2575 | * @param ctx context |
2575 | */ | 2576 | */ |
2576 | static void | 2577 | static void |
2577 | nfa_add_star_op (struct GNUNET_REGEX_Context *ctx) | 2578 | nfa_add_star_op (struct REGEX_ITERNAL_Context *ctx) |
2578 | { | 2579 | { |
2579 | struct GNUNET_REGEX_Automaton *a; | 2580 | struct REGEX_ITERNAL_Automaton *a; |
2580 | struct GNUNET_REGEX_Automaton *new_nfa; | 2581 | struct REGEX_ITERNAL_Automaton *new_nfa; |
2581 | struct GNUNET_REGEX_State *start; | 2582 | struct REGEX_ITERNAL_State *start; |
2582 | struct GNUNET_REGEX_State *end; | 2583 | struct REGEX_ITERNAL_State *end; |
2583 | 2584 | ||
2584 | a = ctx->stack_tail; | 2585 | a = ctx->stack_tail; |
2585 | 2586 | ||
@@ -2617,9 +2618,9 @@ nfa_add_star_op (struct GNUNET_REGEX_Context *ctx) | |||
2617 | * @param ctx context | 2618 | * @param ctx context |
2618 | */ | 2619 | */ |
2619 | static void | 2620 | static void |
2620 | nfa_add_plus_op (struct GNUNET_REGEX_Context *ctx) | 2621 | nfa_add_plus_op (struct REGEX_ITERNAL_Context *ctx) |
2621 | { | 2622 | { |
2622 | struct GNUNET_REGEX_Automaton *a; | 2623 | struct REGEX_ITERNAL_Automaton *a; |
2623 | 2624 | ||
2624 | a = ctx->stack_tail; | 2625 | a = ctx->stack_tail; |
2625 | 2626 | ||
@@ -2644,12 +2645,12 @@ nfa_add_plus_op (struct GNUNET_REGEX_Context *ctx) | |||
2644 | * @param ctx context | 2645 | * @param ctx context |
2645 | */ | 2646 | */ |
2646 | static void | 2647 | static void |
2647 | nfa_add_question_op (struct GNUNET_REGEX_Context *ctx) | 2648 | nfa_add_question_op (struct REGEX_ITERNAL_Context *ctx) |
2648 | { | 2649 | { |
2649 | struct GNUNET_REGEX_Automaton *a; | 2650 | struct REGEX_ITERNAL_Automaton *a; |
2650 | struct GNUNET_REGEX_Automaton *new_nfa; | 2651 | struct REGEX_ITERNAL_Automaton *new_nfa; |
2651 | struct GNUNET_REGEX_State *start; | 2652 | struct REGEX_ITERNAL_State *start; |
2652 | struct GNUNET_REGEX_State *end; | 2653 | struct REGEX_ITERNAL_State *end; |
2653 | 2654 | ||
2654 | a = ctx->stack_tail; | 2655 | a = ctx->stack_tail; |
2655 | 2656 | ||
@@ -2685,13 +2686,13 @@ nfa_add_question_op (struct GNUNET_REGEX_Context *ctx) | |||
2685 | * @param ctx context | 2686 | * @param ctx context |
2686 | */ | 2687 | */ |
2687 | static void | 2688 | static void |
2688 | nfa_add_alternation (struct GNUNET_REGEX_Context *ctx) | 2689 | nfa_add_alternation (struct REGEX_ITERNAL_Context *ctx) |
2689 | { | 2690 | { |
2690 | struct GNUNET_REGEX_Automaton *a; | 2691 | struct REGEX_ITERNAL_Automaton *a; |
2691 | struct GNUNET_REGEX_Automaton *b; | 2692 | struct REGEX_ITERNAL_Automaton *b; |
2692 | struct GNUNET_REGEX_Automaton *new_nfa; | 2693 | struct REGEX_ITERNAL_Automaton *new_nfa; |
2693 | struct GNUNET_REGEX_State *start; | 2694 | struct REGEX_ITERNAL_State *start; |
2694 | struct GNUNET_REGEX_State *end; | 2695 | struct REGEX_ITERNAL_State *end; |
2695 | 2696 | ||
2696 | b = ctx->stack_tail; | 2697 | b = ctx->stack_tail; |
2697 | GNUNET_assert (NULL != b); | 2698 | GNUNET_assert (NULL != b); |
@@ -2729,11 +2730,11 @@ nfa_add_alternation (struct GNUNET_REGEX_Context *ctx) | |||
2729 | * @param label label for nfa transition | 2730 | * @param label label for nfa transition |
2730 | */ | 2731 | */ |
2731 | static void | 2732 | static void |
2732 | nfa_add_label (struct GNUNET_REGEX_Context *ctx, const char *label) | 2733 | nfa_add_label (struct REGEX_ITERNAL_Context *ctx, const char *label) |
2733 | { | 2734 | { |
2734 | struct GNUNET_REGEX_Automaton *n; | 2735 | struct REGEX_ITERNAL_Automaton *n; |
2735 | struct GNUNET_REGEX_State *start; | 2736 | struct REGEX_ITERNAL_State *start; |
2736 | struct GNUNET_REGEX_State *end; | 2737 | struct REGEX_ITERNAL_State *end; |
2737 | 2738 | ||
2738 | GNUNET_assert (NULL != ctx); | 2739 | GNUNET_assert (NULL != ctx); |
2739 | 2740 | ||
@@ -2752,7 +2753,7 @@ nfa_add_label (struct GNUNET_REGEX_Context *ctx, const char *label) | |||
2752 | * @param ctx context | 2753 | * @param ctx context |
2753 | */ | 2754 | */ |
2754 | static void | 2755 | static void |
2755 | GNUNET_REGEX_context_init (struct GNUNET_REGEX_Context *ctx) | 2756 | REGEX_ITERNAL_context_init (struct REGEX_ITERNAL_Context *ctx) |
2756 | { | 2757 | { |
2757 | if (NULL == ctx) | 2758 | if (NULL == ctx) |
2758 | { | 2759 | { |
@@ -2772,13 +2773,13 @@ GNUNET_REGEX_context_init (struct GNUNET_REGEX_Context *ctx) | |||
2772 | * @param regex regular expression string | 2773 | * @param regex regular expression string |
2773 | * @param len length of the string | 2774 | * @param len length of the string |
2774 | * | 2775 | * |
2775 | * @return NFA, needs to be freed using GNUNET_REGEX_destroy_automaton | 2776 | * @return NFA, needs to be freed using REGEX_ITERNAL_destroy_automaton |
2776 | */ | 2777 | */ |
2777 | struct GNUNET_REGEX_Automaton * | 2778 | struct REGEX_ITERNAL_Automaton * |
2778 | GNUNET_REGEX_construct_nfa (const char *regex, const size_t len) | 2779 | REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len) |
2779 | { | 2780 | { |
2780 | struct GNUNET_REGEX_Context ctx; | 2781 | struct REGEX_ITERNAL_Context ctx; |
2781 | struct GNUNET_REGEX_Automaton *nfa; | 2782 | struct REGEX_ITERNAL_Automaton *nfa; |
2782 | const char *regexp; | 2783 | const char *regexp; |
2783 | char curlabel[2]; | 2784 | char curlabel[2]; |
2784 | char *error_msg; | 2785 | char *error_msg; |
@@ -2800,7 +2801,7 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len) | |||
2800 | 2801 | ||
2801 | return NULL; | 2802 | return NULL; |
2802 | } | 2803 | } |
2803 | GNUNET_REGEX_context_init (&ctx); | 2804 | REGEX_ITERNAL_context_init (&ctx); |
2804 | 2805 | ||
2805 | regexp = regex; | 2806 | regexp = regex; |
2806 | curlabel[1] = '\0'; | 2807 | curlabel[1] = '\0'; |
@@ -2923,7 +2924,7 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len) | |||
2923 | nfa->regex = GNUNET_strdup (regex); | 2924 | nfa->regex = GNUNET_strdup (regex); |
2924 | 2925 | ||
2925 | /* create depth-first numbering of the states for pretty printing */ | 2926 | /* create depth-first numbering of the states for pretty printing */ |
2926 | GNUNET_REGEX_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL); | 2927 | REGEX_ITERNAL_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL); |
2927 | 2928 | ||
2928 | /* No multistriding added so far */ | 2929 | /* No multistriding added so far */ |
2929 | nfa->is_multistrided = GNUNET_NO; | 2930 | nfa->is_multistrided = GNUNET_NO; |
@@ -2940,7 +2941,7 @@ error: | |||
2940 | while (NULL != (nfa = ctx.stack_head)) | 2941 | while (NULL != (nfa = ctx.stack_head)) |
2941 | { | 2942 | { |
2942 | GNUNET_CONTAINER_DLL_remove (ctx.stack_head, ctx.stack_tail, nfa); | 2943 | GNUNET_CONTAINER_DLL_remove (ctx.stack_head, ctx.stack_tail, nfa); |
2943 | GNUNET_REGEX_automaton_destroy (nfa); | 2944 | REGEX_ITERNAL_automaton_destroy (nfa); |
2944 | } | 2945 | } |
2945 | 2946 | ||
2946 | return NULL; | 2947 | return NULL; |
@@ -2957,17 +2958,17 @@ error: | |||
2957 | * for starting. | 2958 | * for starting. |
2958 | */ | 2959 | */ |
2959 | static void | 2960 | static void |
2960 | construct_dfa_states (struct GNUNET_REGEX_Context *ctx, | 2961 | construct_dfa_states (struct REGEX_ITERNAL_Context *ctx, |
2961 | struct GNUNET_REGEX_Automaton *nfa, | 2962 | struct REGEX_ITERNAL_Automaton *nfa, |
2962 | struct GNUNET_REGEX_Automaton *dfa, | 2963 | struct REGEX_ITERNAL_Automaton *dfa, |
2963 | struct GNUNET_REGEX_State *dfa_state) | 2964 | struct REGEX_ITERNAL_State *dfa_state) |
2964 | { | 2965 | { |
2965 | struct GNUNET_REGEX_Transition *ctran; | 2966 | struct REGEX_ITERNAL_Transition *ctran; |
2966 | struct GNUNET_REGEX_State *new_dfa_state; | 2967 | struct REGEX_ITERNAL_State *new_dfa_state; |
2967 | struct GNUNET_REGEX_State *state_contains; | 2968 | struct REGEX_ITERNAL_State *state_contains; |
2968 | struct GNUNET_REGEX_State *state_iter; | 2969 | struct REGEX_ITERNAL_State *state_iter; |
2969 | struct GNUNET_REGEX_StateSet tmp; | 2970 | struct REGEX_ITERNAL_StateSet tmp; |
2970 | struct GNUNET_REGEX_StateSet nfa_set; | 2971 | struct REGEX_ITERNAL_StateSet nfa_set; |
2971 | 2972 | ||
2972 | for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next) | 2973 | for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next) |
2973 | { | 2974 | { |
@@ -3019,23 +3020,23 @@ construct_dfa_states (struct GNUNET_REGEX_Context *ctx, | |||
3019 | * @param max_path_len limit the path compression length to the | 3020 | * @param max_path_len limit the path compression length to the |
3020 | * given value. If set to 1, no path compression is applied. Set to 0 for | 3021 | * given value. If set to 1, no path compression is applied. Set to 0 for |
3021 | * maximal possible path compression (generally not desireable). | 3022 | * maximal possible path compression (generally not desireable). |
3022 | * @return DFA, needs to be freed using GNUNET_REGEX_automaton_destroy. | 3023 | * @return DFA, needs to be freed using REGEX_ITERNAL_automaton_destroy. |
3023 | */ | 3024 | */ |
3024 | struct GNUNET_REGEX_Automaton * | 3025 | struct REGEX_ITERNAL_Automaton * |
3025 | GNUNET_REGEX_construct_dfa (const char *regex, const size_t len, | 3026 | REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len, |
3026 | unsigned int max_path_len) | 3027 | unsigned int max_path_len) |
3027 | { | 3028 | { |
3028 | struct GNUNET_REGEX_Context ctx; | 3029 | struct REGEX_ITERNAL_Context ctx; |
3029 | struct GNUNET_REGEX_Automaton *dfa; | 3030 | struct REGEX_ITERNAL_Automaton *dfa; |
3030 | struct GNUNET_REGEX_Automaton *nfa; | 3031 | struct REGEX_ITERNAL_Automaton *nfa; |
3031 | struct GNUNET_REGEX_StateSet nfa_start_eps_cls; | 3032 | struct REGEX_ITERNAL_StateSet nfa_start_eps_cls; |
3032 | struct GNUNET_REGEX_StateSet singleton_set; | 3033 | struct REGEX_ITERNAL_StateSet singleton_set; |
3033 | 3034 | ||
3034 | GNUNET_REGEX_context_init (&ctx); | 3035 | REGEX_ITERNAL_context_init (&ctx); |
3035 | 3036 | ||
3036 | /* Create NFA */ | 3037 | /* Create NFA */ |
3037 | // fprintf (stderr, "N"); | 3038 | // fprintf (stderr, "N"); |
3038 | nfa = GNUNET_REGEX_construct_nfa (regex, len); | 3039 | nfa = REGEX_ITERNAL_construct_nfa (regex, len); |
3039 | 3040 | ||
3040 | if (NULL == nfa) | 3041 | if (NULL == nfa) |
3041 | { | 3042 | { |
@@ -3044,12 +3045,12 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len, | |||
3044 | return NULL; | 3045 | return NULL; |
3045 | } | 3046 | } |
3046 | 3047 | ||
3047 | dfa = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Automaton)); | 3048 | dfa = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Automaton)); |
3048 | dfa->type = DFA; | 3049 | dfa->type = DFA; |
3049 | dfa->regex = GNUNET_strdup (regex); | 3050 | dfa->regex = GNUNET_strdup (regex); |
3050 | 3051 | ||
3051 | /* Create DFA start state from epsilon closure */ | 3052 | /* Create DFA start state from epsilon closure */ |
3052 | memset (&singleton_set, 0, sizeof (struct GNUNET_REGEX_StateSet)); | 3053 | memset (&singleton_set, 0, sizeof (struct REGEX_ITERNAL_StateSet)); |
3053 | state_set_append (&singleton_set, nfa->start); | 3054 | state_set_append (&singleton_set, nfa->start); |
3054 | nfa_closure_set_create (&nfa_start_eps_cls, nfa, &singleton_set, NULL); | 3055 | nfa_closure_set_create (&nfa_start_eps_cls, nfa, &singleton_set, NULL); |
3055 | state_set_clear (&singleton_set); | 3056 | state_set_clear (&singleton_set); |
@@ -3058,20 +3059,20 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len, | |||
3058 | 3059 | ||
3059 | // fprintf (stderr, "D"); | 3060 | // fprintf (stderr, "D"); |
3060 | construct_dfa_states (&ctx, nfa, dfa, dfa->start); | 3061 | construct_dfa_states (&ctx, nfa, dfa, dfa->start); |
3061 | GNUNET_REGEX_automaton_destroy (nfa); | 3062 | REGEX_ITERNAL_automaton_destroy (nfa); |
3062 | 3063 | ||
3063 | /* Minimize DFA */ | 3064 | /* Minimize DFA */ |
3064 | // fprintf (stderr, "M"); | 3065 | // fprintf (stderr, "M"); |
3065 | if (GNUNET_OK != dfa_minimize (&ctx, dfa)) | 3066 | if (GNUNET_OK != dfa_minimize (&ctx, dfa)) |
3066 | { | 3067 | { |
3067 | GNUNET_REGEX_automaton_destroy (dfa); | 3068 | REGEX_ITERNAL_automaton_destroy (dfa); |
3068 | return NULL; | 3069 | return NULL; |
3069 | } | 3070 | } |
3070 | 3071 | ||
3071 | /* Create proofs and hashes for all states */ | 3072 | /* Create proofs and hashes for all states */ |
3072 | if (GNUNET_OK != automaton_create_proofs (dfa)) | 3073 | if (GNUNET_OK != automaton_create_proofs (dfa)) |
3073 | { | 3074 | { |
3074 | GNUNET_REGEX_automaton_destroy (dfa); | 3075 | REGEX_ITERNAL_automaton_destroy (dfa); |
3075 | return NULL; | 3076 | return NULL; |
3076 | } | 3077 | } |
3077 | 3078 | ||
@@ -3084,16 +3085,16 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len, | |||
3084 | 3085 | ||
3085 | 3086 | ||
3086 | /** | 3087 | /** |
3087 | * Free the memory allocated by constructing the GNUNET_REGEX_Automaton data | 3088 | * Free the memory allocated by constructing the REGEX_ITERNAL_Automaton data |
3088 | * structure. | 3089 | * structure. |
3089 | * | 3090 | * |
3090 | * @param a automaton to be destroyed | 3091 | * @param a automaton to be destroyed |
3091 | */ | 3092 | */ |
3092 | void | 3093 | void |
3093 | GNUNET_REGEX_automaton_destroy (struct GNUNET_REGEX_Automaton *a) | 3094 | REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a) |
3094 | { | 3095 | { |
3095 | struct GNUNET_REGEX_State *s; | 3096 | struct REGEX_ITERNAL_State *s; |
3096 | struct GNUNET_REGEX_State *next_state; | 3097 | struct REGEX_ITERNAL_State *next_state; |
3097 | 3098 | ||
3098 | if (NULL == a) | 3099 | if (NULL == a) |
3099 | return; | 3100 | return; |
@@ -3121,10 +3122,10 @@ GNUNET_REGEX_automaton_destroy (struct GNUNET_REGEX_Automaton *a) | |||
3121 | * @return 0 if string matches, non 0 otherwise | 3122 | * @return 0 if string matches, non 0 otherwise |
3122 | */ | 3123 | */ |
3123 | static int | 3124 | static int |
3124 | evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) | 3125 | evaluate_dfa (struct REGEX_ITERNAL_Automaton *a, const char *string) |
3125 | { | 3126 | { |
3126 | const char *strp; | 3127 | const char *strp; |
3127 | struct GNUNET_REGEX_State *s; | 3128 | struct REGEX_ITERNAL_State *s; |
3128 | unsigned int step_len; | 3129 | unsigned int step_len; |
3129 | 3130 | ||
3130 | if (DFA != a->type) | 3131 | if (DFA != a->type) |
@@ -3164,14 +3165,14 @@ evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
3164 | * @return 0 if string matches, non 0 otherwise | 3165 | * @return 0 if string matches, non 0 otherwise |
3165 | */ | 3166 | */ |
3166 | static int | 3167 | static int |
3167 | evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | 3168 | evaluate_nfa (struct REGEX_ITERNAL_Automaton *a, const char *string) |
3168 | { | 3169 | { |
3169 | const char *strp; | 3170 | const char *strp; |
3170 | char str[2]; | 3171 | char str[2]; |
3171 | struct GNUNET_REGEX_State *s; | 3172 | struct REGEX_ITERNAL_State *s; |
3172 | struct GNUNET_REGEX_StateSet sset; | 3173 | struct REGEX_ITERNAL_StateSet sset; |
3173 | struct GNUNET_REGEX_StateSet new_sset; | 3174 | struct REGEX_ITERNAL_StateSet new_sset; |
3174 | struct GNUNET_REGEX_StateSet singleton_set; | 3175 | struct REGEX_ITERNAL_StateSet singleton_set; |
3175 | unsigned int i; | 3176 | unsigned int i; |
3176 | int result; | 3177 | int result; |
3177 | 3178 | ||
@@ -3187,7 +3188,7 @@ evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
3187 | return 0; | 3188 | return 0; |
3188 | 3189 | ||
3189 | result = 1; | 3190 | result = 1; |
3190 | memset (&singleton_set, 0, sizeof (struct GNUNET_REGEX_StateSet)); | 3191 | memset (&singleton_set, 0, sizeof (struct REGEX_ITERNAL_StateSet)); |
3191 | state_set_append (&singleton_set, a->start); | 3192 | state_set_append (&singleton_set, a->start); |
3192 | nfa_closure_set_create (&sset, a, &singleton_set, NULL); | 3193 | nfa_closure_set_create (&sset, a, &singleton_set, NULL); |
3193 | state_set_clear (&singleton_set); | 3194 | state_set_clear (&singleton_set); |
@@ -3226,7 +3227,7 @@ evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
3226 | * @return 0 if string matches, non 0 otherwise | 3227 | * @return 0 if string matches, non 0 otherwise |
3227 | */ | 3228 | */ |
3228 | int | 3229 | int |
3229 | GNUNET_REGEX_eval (struct GNUNET_REGEX_Automaton *a, const char *string) | 3230 | REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a, const char *string) |
3230 | { | 3231 | { |
3231 | int result; | 3232 | int result; |
3232 | 3233 | ||
@@ -3261,7 +3262,7 @@ GNUNET_REGEX_eval (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
3261 | * @return | 3262 | * @return |
3262 | */ | 3263 | */ |
3263 | const char * | 3264 | const char * |
3264 | GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a) | 3265 | REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a) |
3265 | { | 3266 | { |
3266 | if (NULL == a) | 3267 | if (NULL == a) |
3267 | return NULL; | 3268 | return NULL; |
@@ -3278,10 +3279,10 @@ GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a) | |||
3278 | * @return number of transitions in the given automaton. | 3279 | * @return number of transitions in the given automaton. |
3279 | */ | 3280 | */ |
3280 | unsigned int | 3281 | unsigned int |
3281 | GNUNET_REGEX_get_transition_count (struct GNUNET_REGEX_Automaton *a) | 3282 | REGEX_ITERNAL_get_transition_count (struct REGEX_ITERNAL_Automaton *a) |
3282 | { | 3283 | { |
3283 | unsigned int t_count; | 3284 | unsigned int t_count; |
3284 | struct GNUNET_REGEX_State *s; | 3285 | struct REGEX_ITERNAL_State *s; |
3285 | 3286 | ||
3286 | if (NULL == a) | 3287 | if (NULL == a) |
3287 | return 0; | 3288 | return 0; |
@@ -3306,7 +3307,7 @@ GNUNET_REGEX_get_transition_count (struct GNUNET_REGEX_Automaton *a) | |||
3306 | * to construct the key | 3307 | * to construct the key |
3307 | */ | 3308 | */ |
3308 | size_t | 3309 | size_t |
3309 | GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len, | 3310 | REGEX_ITERNAL_get_first_key (const char *input_string, size_t string_len, |
3310 | struct GNUNET_HashCode * key) | 3311 | struct GNUNET_HashCode * key) |
3311 | { | 3312 | { |
3312 | unsigned int size; | 3313 | unsigned int size; |
@@ -3336,7 +3337,7 @@ GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len, | |||
3336 | * @return GNUNET_OK if the proof is valid for the given key. | 3337 | * @return GNUNET_OK if the proof is valid for the given key. |
3337 | */ | 3338 | */ |
3338 | int | 3339 | int |
3339 | GNUNET_REGEX_check_proof (const char *proof, const struct GNUNET_HashCode *key) | 3340 | REGEX_ITERNAL_check_proof (const char *proof, const struct GNUNET_HashCode *key) |
3340 | { | 3341 | { |
3341 | struct GNUNET_HashCode key_check; | 3342 | struct GNUNET_HashCode key_check; |
3342 | 3343 | ||
@@ -3364,15 +3365,15 @@ GNUNET_REGEX_check_proof (const char *proof, const struct GNUNET_HashCode *key) | |||
3364 | */ | 3365 | */ |
3365 | static void | 3366 | static void |
3366 | iterate_initial_edge (const unsigned int min_len, const unsigned int max_len, | 3367 | iterate_initial_edge (const unsigned int min_len, const unsigned int max_len, |
3367 | char *consumed_string, struct GNUNET_REGEX_State *state, | 3368 | char *consumed_string, struct REGEX_ITERNAL_State *state, |
3368 | GNUNET_REGEX_KeyIterator iterator, void *iterator_cls) | 3369 | REGEX_ITERNAL_KeyIterator iterator, void *iterator_cls) |
3369 | { | 3370 | { |
3370 | unsigned int i; | 3371 | unsigned int i; |
3371 | char *temp; | 3372 | char *temp; |
3372 | struct GNUNET_REGEX_Transition *t; | 3373 | struct REGEX_ITERNAL_Transition *t; |
3373 | unsigned int num_edges = state->transition_count; | 3374 | unsigned int num_edges = state->transition_count; |
3374 | struct GNUNET_REGEX_Edge edges[num_edges]; | 3375 | struct REGEX_ITERNAL_Edge edges[num_edges]; |
3375 | struct GNUNET_REGEX_Edge edge[1]; | 3376 | struct REGEX_ITERNAL_Edge edge[1]; |
3376 | struct GNUNET_HashCode hash; | 3377 | struct GNUNET_HashCode hash; |
3377 | struct GNUNET_HashCode hash_new; | 3378 | struct GNUNET_HashCode hash_new; |
3378 | 3379 | ||
@@ -3454,15 +3455,15 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len, | |||
3454 | * @param iterator_cls closure. | 3455 | * @param iterator_cls closure. |
3455 | */ | 3456 | */ |
3456 | void | 3457 | void |
3457 | GNUNET_REGEX_iterate_all_edges (struct GNUNET_REGEX_Automaton *a, | 3458 | REGEX_ITERNAL_iterate_all_edges (struct REGEX_ITERNAL_Automaton *a, |
3458 | GNUNET_REGEX_KeyIterator iterator, | 3459 | REGEX_ITERNAL_KeyIterator iterator, |
3459 | void *iterator_cls) | 3460 | void *iterator_cls) |
3460 | { | 3461 | { |
3461 | struct GNUNET_REGEX_State *s; | 3462 | struct REGEX_ITERNAL_State *s; |
3462 | 3463 | ||
3463 | for (s = a->states_head; NULL != s; s = s->next) | 3464 | for (s = a->states_head; NULL != s; s = s->next) |
3464 | { | 3465 | { |
3465 | struct GNUNET_REGEX_Edge edges[s->transition_count]; | 3466 | struct REGEX_ITERNAL_Edge edges[s->transition_count]; |
3466 | unsigned int num_edges; | 3467 | unsigned int num_edges; |
3467 | 3468 | ||
3468 | num_edges = state_get_edges (s, edges); | 3469 | num_edges = state_get_edges (s, edges); |
@@ -3479,116 +3480,6 @@ GNUNET_REGEX_iterate_all_edges (struct GNUNET_REGEX_Automaton *a, | |||
3479 | } | 3480 | } |
3480 | 3481 | ||
3481 | 3482 | ||
3482 | /** | ||
3483 | * Create a string with binary IP notation for the given 'addr' in 'str'. | ||
3484 | * | ||
3485 | * @param af address family of the given 'addr'. | ||
3486 | * @param addr address that should be converted to a string. | ||
3487 | * struct in_addr * for IPv4 and struct in6_addr * for IPv6. | ||
3488 | * @param str string that will contain binary notation of 'addr'. Expected | ||
3489 | * to be at least 33 bytes long for IPv4 and 129 bytes long for IPv6. | ||
3490 | */ | ||
3491 | static void | ||
3492 | iptobinstr (const int af, const void *addr, char *str) | ||
3493 | { | ||
3494 | int i; | ||
3495 | |||
3496 | switch (af) | ||
3497 | { | ||
3498 | case AF_INET: | ||
3499 | { | ||
3500 | uint32_t b = htonl (((struct in_addr *) addr)->s_addr); | ||
3501 | |||
3502 | str[32] = '\0'; | ||
3503 | str += 31; | ||
3504 | for (i = 31; i >= 0; i--) | ||
3505 | { | ||
3506 | *str = (b & 1) + '0'; | ||
3507 | str--; | ||
3508 | b >>= 1; | ||
3509 | } | ||
3510 | break; | ||
3511 | } | ||
3512 | case AF_INET6: | ||
3513 | { | ||
3514 | struct in6_addr b = *(const struct in6_addr *) addr; | ||
3515 | |||
3516 | str[128] = '\0'; | ||
3517 | str += 127; | ||
3518 | for (i = 127; i >= 0; i--) | ||
3519 | { | ||
3520 | *str = (b.s6_addr[i / 8] & 1) + '0'; | ||
3521 | str--; | ||
3522 | b.s6_addr[i / 8] >>= 1; | ||
3523 | } | ||
3524 | break; | ||
3525 | } | ||
3526 | } | ||
3527 | } | ||
3528 | |||
3529 | |||
3530 | /** | ||
3531 | * Get the ipv4 network prefix from the given 'netmask'. | ||
3532 | * | ||
3533 | * @param netmask netmask for which to get the prefix len. | ||
3534 | * | ||
3535 | * @return length of ipv4 prefix for 'netmask'. | ||
3536 | */ | ||
3537 | static unsigned int | ||
3538 | ipv4netmasktoprefixlen (const char *netmask) | ||
3539 | { | ||
3540 | struct in_addr a; | ||
3541 | unsigned int len; | ||
3542 | uint32_t t; | ||
3543 | |||
3544 | if (1 != inet_pton (AF_INET, netmask, &a)) | ||
3545 | return 0; | ||
3546 | len = 32; | ||
3547 | for (t = htonl (~a.s_addr); 0 != t; t >>= 1) | ||
3548 | len--; | ||
3549 | return len; | ||
3550 | } | ||
3551 | |||
3552 | |||
3553 | /** | ||
3554 | * Create a regex in 'rxstr' from the given 'ip' and 'netmask'. | ||
3555 | * | ||
3556 | * @param ip IPv4 representation. | ||
3557 | * @param netmask netmask for the ip. | ||
3558 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV4_REGEXLEN | ||
3559 | * bytes long. | ||
3560 | */ | ||
3561 | void | ||
3562 | GNUNET_REGEX_ipv4toregex (const struct in_addr *ip, const char *netmask, | ||
3563 | char *rxstr) | ||
3564 | { | ||
3565 | unsigned int pfxlen; | ||
3566 | |||
3567 | pfxlen = ipv4netmasktoprefixlen (netmask); | ||
3568 | iptobinstr (AF_INET, ip, rxstr); | ||
3569 | rxstr[pfxlen] = '\0'; | ||
3570 | if (pfxlen < 32) | ||
3571 | strcat (rxstr, "(0|1)+"); | ||
3572 | } | ||
3573 | |||
3574 | |||
3575 | /** | ||
3576 | * Create a regex in 'rxstr' from the given 'ipv6' and 'prefixlen'. | ||
3577 | * | ||
3578 | * @param ipv6 IPv6 representation. | ||
3579 | * @param prefixlen length of the ipv6 prefix. | ||
3580 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV6_REGEXLEN | ||
3581 | * bytes long. | ||
3582 | */ | ||
3583 | void | ||
3584 | GNUNET_REGEX_ipv6toregex (const struct in6_addr *ipv6, unsigned int prefixlen, | ||
3585 | char *rxstr) | ||
3586 | { | ||
3587 | iptobinstr (AF_INET6, ipv6, rxstr); | ||
3588 | rxstr[prefixlen] = '\0'; | ||
3589 | if (prefixlen < 128) | ||
3590 | strcat (rxstr, "(0|1)+"); | ||
3591 | } | ||
3592 | 3483 | ||
3593 | 3484 | ||
3594 | /* end of regex.c */ | 3485 | /* end of regex.c */ |
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index 2c0e185f1..383cf5626 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c | |||
@@ -92,7 +92,7 @@ check_edge (void *cls, | |||
92 | 92 | ||
93 | 93 | ||
94 | int | 94 | int |
95 | GNUNET_REGEX_block_check (const struct RegexBlock *block, | 95 | REGEX_ITERNAL_block_check (const struct RegexBlock *block, |
96 | size_t size, | 96 | size_t size, |
97 | const char *xquery) | 97 | const char *xquery) |
98 | { | 98 | { |
@@ -109,7 +109,7 @@ GNUNET_REGEX_block_check (const struct RegexBlock *block, | |||
109 | ctx.xquery = xquery; | 109 | ctx.xquery = xquery; |
110 | ctx.found = GNUNET_NO; | 110 | ctx.found = GNUNET_NO; |
111 | ctx.key = GNUNET_strdup (GNUNET_h2s (&block->key)); | 111 | ctx.key = GNUNET_strdup (GNUNET_h2s (&block->key)); |
112 | res = GNUNET_REGEX_block_iterate (block, size, &check_edge, &ctx); | 112 | res = REGEX_ITERNAL_block_iterate (block, size, &check_edge, &ctx); |
113 | GNUNET_free (ctx.key); | 113 | GNUNET_free (ctx.key); |
114 | if (GNUNET_SYSERR == res) | 114 | if (GNUNET_SYSERR == res) |
115 | return GNUNET_SYSERR; | 115 | return GNUNET_SYSERR; |
@@ -120,9 +120,9 @@ GNUNET_REGEX_block_check (const struct RegexBlock *block, | |||
120 | 120 | ||
121 | 121 | ||
122 | int | 122 | int |
123 | GNUNET_REGEX_block_iterate (const struct RegexBlock *block, | 123 | REGEX_ITERNAL_block_iterate (const struct RegexBlock *block, |
124 | size_t size, | 124 | size_t size, |
125 | GNUNET_REGEX_EgdeIterator iterator, | 125 | REGEX_ITERNAL_EgdeIterator iterator, |
126 | void *iter_cls) | 126 | void *iter_cls) |
127 | { | 127 | { |
128 | struct RegexEdge *edge; | 128 | struct RegexEdge *edge; |
diff --git a/src/regex/regex_block_lib.h b/src/regex/regex_block_lib.h index e68f34bda..2ef7ef30c 100644 --- a/src/regex/regex_block_lib.h +++ b/src/regex/regex_block_lib.h | |||
@@ -52,7 +52,7 @@ extern "C" | |||
52 | * GNUNET_SYSERR if the block is invalid. | 52 | * GNUNET_SYSERR if the block is invalid. |
53 | */ | 53 | */ |
54 | int | 54 | int |
55 | GNUNET_REGEX_block_check (const struct RegexBlock *block, | 55 | REGEX_ITERNAL_block_check (const struct RegexBlock *block, |
56 | size_t size, | 56 | size_t size, |
57 | const char *xquery); | 57 | const char *xquery); |
58 | 58 | ||
@@ -66,7 +66,7 @@ GNUNET_REGEX_block_check (const struct RegexBlock *block, | |||
66 | * | 66 | * |
67 | * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise. | 67 | * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise. |
68 | */ | 68 | */ |
69 | typedef int (*GNUNET_REGEX_EgdeIterator)(void *cls, | 69 | typedef int (*REGEX_ITERNAL_EgdeIterator)(void *cls, |
70 | const char *token, | 70 | const char *token, |
71 | size_t len, | 71 | size_t len, |
72 | const struct GNUNET_HashCode *key); | 72 | const struct GNUNET_HashCode *key); |
@@ -89,9 +89,9 @@ typedef int (*GNUNET_REGEX_EgdeIterator)(void *cls, | |||
89 | * be errors in further edges. | 89 | * be errors in further edges. |
90 | */ | 90 | */ |
91 | int | 91 | int |
92 | GNUNET_REGEX_block_iterate (const struct RegexBlock *block, | 92 | REGEX_ITERNAL_block_iterate (const struct RegexBlock *block, |
93 | size_t size, | 93 | size_t size, |
94 | GNUNET_REGEX_EgdeIterator iterator, | 94 | REGEX_ITERNAL_EgdeIterator iterator, |
95 | void *iter_cls); | 95 | void *iter_cls); |
96 | 96 | ||
97 | #if 0 /* keep Emacsens' auto-indent happy */ | 97 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/regex/regex_dht.c b/src/regex/regex_dht.c index 30bac4b94..1cc4107e8 100644 --- a/src/regex/regex_dht.c +++ b/src/regex/regex_dht.c | |||
@@ -24,7 +24,7 @@ | |||
24 | * @author Bartlomiej Polot | 24 | * @author Bartlomiej Polot |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_regex_lib.h" | 27 | #include "regex_internal_lib.h" |
28 | #include "regex_block_lib.h" | 28 | #include "regex_block_lib.h" |
29 | #include "gnunet_dht_service.h" | 29 | #include "gnunet_dht_service.h" |
30 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
@@ -42,7 +42,7 @@ | |||
42 | #define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE | 42 | #define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | struct GNUNET_REGEX_announce_handle | 45 | struct REGEX_ITERNAL_Announcement |
46 | { | 46 | { |
47 | /** | 47 | /** |
48 | * DHT handle to use, must be initialized externally. | 48 | * DHT handle to use, must be initialized externally. |
@@ -57,7 +57,7 @@ struct GNUNET_REGEX_announce_handle | |||
57 | /** | 57 | /** |
58 | * Automaton representation of the regex (expensive to build). | 58 | * Automaton representation of the regex (expensive to build). |
59 | */ | 59 | */ |
60 | struct GNUNET_REGEX_Automaton* dfa; | 60 | struct REGEX_ITERNAL_Automaton* dfa; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Identity under which to announce the regex. | 63 | * Identity under which to announce the regex. |
@@ -87,9 +87,9 @@ regex_iterator (void *cls, | |||
87 | const char *proof, | 87 | const char *proof, |
88 | int accepting, | 88 | int accepting, |
89 | unsigned int num_edges, | 89 | unsigned int num_edges, |
90 | const struct GNUNET_REGEX_Edge *edges) | 90 | const struct REGEX_ITERNAL_Edge *edges) |
91 | { | 91 | { |
92 | struct GNUNET_REGEX_announce_handle *h = cls; | 92 | struct REGEX_ITERNAL_Announcement *h = cls; |
93 | struct RegexBlock *block; | 93 | struct RegexBlock *block; |
94 | struct RegexEdge *block_edge; | 94 | struct RegexEdge *block_edge; |
95 | size_t size; | 95 | size_t size; |
@@ -182,41 +182,41 @@ regex_iterator (void *cls, | |||
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | struct GNUNET_REGEX_announce_handle * | 185 | struct REGEX_ITERNAL_Announcement * |
186 | GNUNET_REGEX_announce (struct GNUNET_DHT_Handle *dht, | 186 | REGEX_ITERNAL_announce (struct GNUNET_DHT_Handle *dht, |
187 | const struct GNUNET_PeerIdentity *id, | 187 | const struct GNUNET_PeerIdentity *id, |
188 | const char *regex, | 188 | const char *regex, |
189 | uint16_t compression, | 189 | uint16_t compression, |
190 | struct GNUNET_STATISTICS_Handle *stats) | 190 | struct GNUNET_STATISTICS_Handle *stats) |
191 | { | 191 | { |
192 | struct GNUNET_REGEX_announce_handle *h; | 192 | struct REGEX_ITERNAL_Announcement *h; |
193 | 193 | ||
194 | GNUNET_assert (NULL != dht); | 194 | GNUNET_assert (NULL != dht); |
195 | h = GNUNET_malloc (sizeof (struct GNUNET_REGEX_announce_handle)); | 195 | h = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Announcement)); |
196 | h->regex = regex; | 196 | h->regex = regex; |
197 | h->dht = dht; | 197 | h->dht = dht; |
198 | h->stats = stats; | 198 | h->stats = stats; |
199 | h->id = *id; | 199 | h->id = *id; |
200 | h->dfa = GNUNET_REGEX_construct_dfa (regex, | 200 | h->dfa = REGEX_ITERNAL_construct_dfa (regex, |
201 | strlen (regex), | 201 | strlen (regex), |
202 | compression); | 202 | compression); |
203 | GNUNET_REGEX_reannounce (h); | 203 | REGEX_ITERNAL_reannounce (h); |
204 | return h; | 204 | return h; |
205 | } | 205 | } |
206 | 206 | ||
207 | void | 207 | void |
208 | GNUNET_REGEX_reannounce (struct GNUNET_REGEX_announce_handle *h) | 208 | REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h) |
209 | { | 209 | { |
210 | GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */ | 210 | GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */ |
211 | LOG (GNUNET_ERROR_TYPE_INFO, "GNUNET_REGEX_reannounce: %.60s\n", h->regex); | 211 | LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_ITERNAL_reannounce: %.60s\n", h->regex); |
212 | LOG (GNUNET_ERROR_TYPE_DEBUG, " full: %s\n", h->regex); | 212 | LOG (GNUNET_ERROR_TYPE_DEBUG, " full: %s\n", h->regex); |
213 | GNUNET_REGEX_iterate_all_edges (h->dfa, ®ex_iterator, h); | 213 | REGEX_ITERNAL_iterate_all_edges (h->dfa, ®ex_iterator, h); |
214 | } | 214 | } |
215 | 215 | ||
216 | void | 216 | void |
217 | GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_announce_handle *h) | 217 | REGEX_ITERNAL_announce_cancel (struct REGEX_ITERNAL_Announcement *h) |
218 | { | 218 | { |
219 | GNUNET_REGEX_automaton_destroy (h->dfa); | 219 | REGEX_ITERNAL_automaton_destroy (h->dfa); |
220 | GNUNET_free (h); | 220 | GNUNET_free (h); |
221 | } | 221 | } |
222 | 222 | ||
@@ -239,7 +239,7 @@ struct RegexSearchContext | |||
239 | /** | 239 | /** |
240 | * Information about the search. | 240 | * Information about the search. |
241 | */ | 241 | */ |
242 | struct GNUNET_REGEX_search_handle *info; | 242 | struct REGEX_ITERNAL_Search *info; |
243 | 243 | ||
244 | /** | 244 | /** |
245 | * We just want to look for one edge, the longer the better. | 245 | * We just want to look for one edge, the longer the better. |
@@ -258,7 +258,7 @@ struct RegexSearchContext | |||
258 | * Struct to keep information of searches of services described by a regex | 258 | * Struct to keep information of searches of services described by a regex |
259 | * using a user-provided string service description. | 259 | * using a user-provided string service description. |
260 | */ | 260 | */ |
261 | struct GNUNET_REGEX_search_handle | 261 | struct REGEX_ITERNAL_Search |
262 | { | 262 | { |
263 | /** | 263 | /** |
264 | * DHT handle to use, must be initialized externally. | 264 | * DHT handle to use, must be initialized externally. |
@@ -298,7 +298,7 @@ struct GNUNET_REGEX_search_handle | |||
298 | /** | 298 | /** |
299 | * @param callback Callback for found peers. | 299 | * @param callback Callback for found peers. |
300 | */ | 300 | */ |
301 | GNUNET_REGEX_Found callback; | 301 | REGEX_ITERNAL_Found callback; |
302 | 302 | ||
303 | /** | 303 | /** |
304 | * @param callback_cls Closure for @c callback. | 304 | * @param callback_cls Closure for @c callback. |
@@ -350,7 +350,7 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
350 | { | 350 | { |
351 | const struct RegexAccept *block = data; | 351 | const struct RegexAccept *block = data; |
352 | struct RegexSearchContext *ctx = cls; | 352 | struct RegexSearchContext *ctx = cls; |
353 | struct GNUNET_REGEX_search_handle *info = ctx->info; | 353 | struct REGEX_ITERNAL_Search *info = ctx->info; |
354 | 354 | ||
355 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Got regex results from DHT!\n"); | 355 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Got regex results from DHT!\n"); |
356 | LOG (GNUNET_ERROR_TYPE_INFO, " accept for %s (key %s)\n", | 356 | LOG (GNUNET_ERROR_TYPE_INFO, " accept for %s (key %s)\n", |
@@ -429,7 +429,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
429 | { | 429 | { |
430 | const struct RegexBlock *block = data; | 430 | const struct RegexBlock *block = data; |
431 | struct RegexSearchContext *ctx = cls; | 431 | struct RegexSearchContext *ctx = cls; |
432 | struct GNUNET_REGEX_search_handle *info = ctx->info; | 432 | struct REGEX_ITERNAL_Search *info = ctx->info; |
433 | void *copy; | 433 | void *copy; |
434 | size_t len; | 434 | size_t len; |
435 | char *datastore; | 435 | char *datastore; |
@@ -465,7 +465,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
465 | 465 | ||
466 | memcpy (proof, &block[1], len); | 466 | memcpy (proof, &block[1], len); |
467 | proof[len] = '\0'; | 467 | proof[len] = '\0'; |
468 | if (GNUNET_OK != GNUNET_REGEX_check_proof (proof, key)) | 468 | if (GNUNET_OK != REGEX_ITERNAL_check_proof (proof, key)) |
469 | { | 469 | { |
470 | GNUNET_break_op (0); | 470 | GNUNET_break_op (0); |
471 | return; | 471 | return; |
@@ -545,7 +545,7 @@ regex_edge_iterator (void *cls, | |||
545 | const struct GNUNET_HashCode *key) | 545 | const struct GNUNET_HashCode *key) |
546 | { | 546 | { |
547 | struct RegexSearchContext *ctx = cls; | 547 | struct RegexSearchContext *ctx = cls; |
548 | struct GNUNET_REGEX_search_handle *info = ctx->info; | 548 | struct REGEX_ITERNAL_Search *info = ctx->info; |
549 | const char *current; | 549 | const char *current; |
550 | size_t current_len; | 550 | size_t current_len; |
551 | 551 | ||
@@ -604,7 +604,7 @@ regex_next_edge (const struct RegexBlock *block, | |||
604 | struct RegexSearchContext *ctx) | 604 | struct RegexSearchContext *ctx) |
605 | { | 605 | { |
606 | struct RegexSearchContext *new_ctx; | 606 | struct RegexSearchContext *new_ctx; |
607 | struct GNUNET_REGEX_search_handle *info = ctx->info; | 607 | struct REGEX_ITERNAL_Search *info = ctx->info; |
608 | struct GNUNET_DHT_GetHandle *get_h; | 608 | struct GNUNET_DHT_GetHandle *get_h; |
609 | struct GNUNET_HashCode *hash; | 609 | struct GNUNET_HashCode *hash; |
610 | const char *rest; | 610 | const char *rest; |
@@ -613,7 +613,7 @@ regex_next_edge (const struct RegexBlock *block, | |||
613 | /* Find the longest match for the current string position, | 613 | /* Find the longest match for the current string position, |
614 | * among tokens in the given block */ | 614 | * among tokens in the given block */ |
615 | ctx->longest_match = 0; | 615 | ctx->longest_match = 0; |
616 | result = GNUNET_REGEX_block_iterate (block, size, | 616 | result = REGEX_ITERNAL_block_iterate (block, size, |
617 | ®ex_edge_iterator, ctx); | 617 | ®ex_edge_iterator, ctx); |
618 | GNUNET_break (GNUNET_OK == result); | 618 | GNUNET_break (GNUNET_OK == result); |
619 | 619 | ||
@@ -672,14 +672,14 @@ regex_next_edge (const struct RegexBlock *block, | |||
672 | } | 672 | } |
673 | 673 | ||
674 | 674 | ||
675 | struct GNUNET_REGEX_search_handle * | 675 | struct REGEX_ITERNAL_Search * |
676 | GNUNET_REGEX_search (struct GNUNET_DHT_Handle *dht, | 676 | REGEX_ITERNAL_search (struct GNUNET_DHT_Handle *dht, |
677 | const char *string, | 677 | const char *string, |
678 | GNUNET_REGEX_Found callback, | 678 | REGEX_ITERNAL_Found callback, |
679 | void *callback_cls, | 679 | void *callback_cls, |
680 | struct GNUNET_STATISTICS_Handle *stats) | 680 | struct GNUNET_STATISTICS_Handle *stats) |
681 | { | 681 | { |
682 | struct GNUNET_REGEX_search_handle *h; | 682 | struct REGEX_ITERNAL_Search *h; |
683 | struct GNUNET_DHT_GetHandle *get_h; | 683 | struct GNUNET_DHT_GetHandle *get_h; |
684 | struct RegexSearchContext *ctx; | 684 | struct RegexSearchContext *ctx; |
685 | struct GNUNET_HashCode key; | 685 | struct GNUNET_HashCode key; |
@@ -687,10 +687,10 @@ GNUNET_REGEX_search (struct GNUNET_DHT_Handle *dht, | |||
687 | size_t len; | 687 | size_t len; |
688 | 688 | ||
689 | /* Initialize handle */ | 689 | /* Initialize handle */ |
690 | LOG (GNUNET_ERROR_TYPE_INFO, "GNUNET_REGEX_search: %s\n", string); | 690 | LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_ITERNAL_search: %s\n", string); |
691 | GNUNET_assert (NULL != dht); | 691 | GNUNET_assert (NULL != dht); |
692 | GNUNET_assert (NULL != callback); | 692 | GNUNET_assert (NULL != callback); |
693 | h = GNUNET_malloc (sizeof (struct GNUNET_REGEX_search_handle)); | 693 | h = GNUNET_malloc (sizeof (struct REGEX_ITERNAL_Search)); |
694 | h->dht = dht; | 694 | h->dht = dht; |
695 | h->description = GNUNET_strdup (string); | 695 | h->description = GNUNET_strdup (string); |
696 | h->callback = callback; | 696 | h->callback = callback; |
@@ -701,7 +701,7 @@ GNUNET_REGEX_search (struct GNUNET_DHT_Handle *dht, | |||
701 | 701 | ||
702 | /* Initialize context */ | 702 | /* Initialize context */ |
703 | len = strlen (string); | 703 | len = strlen (string); |
704 | size = GNUNET_REGEX_get_first_key (string, len, &key); | 704 | size = REGEX_ITERNAL_get_first_key (string, len, &key); |
705 | ctx = GNUNET_malloc (sizeof (struct RegexSearchContext)); | 705 | ctx = GNUNET_malloc (sizeof (struct RegexSearchContext)); |
706 | ctx->position = size; | 706 | ctx->position = size; |
707 | ctx->info = h; | 707 | ctx->info = h; |
@@ -781,7 +781,7 @@ regex_free_result (void *cls, | |||
781 | * @param ctx The search context. | 781 | * @param ctx The search context. |
782 | */ | 782 | */ |
783 | static void | 783 | static void |
784 | regex_cancel_search (struct GNUNET_REGEX_search_handle *ctx) | 784 | regex_cancel_search (struct REGEX_ITERNAL_Search *ctx) |
785 | { | 785 | { |
786 | GNUNET_free (ctx->description); | 786 | GNUNET_free (ctx->description); |
787 | GNUNET_CONTAINER_multihashmap_iterate (ctx->dht_get_handles, | 787 | GNUNET_CONTAINER_multihashmap_iterate (ctx->dht_get_handles, |
@@ -803,7 +803,7 @@ regex_cancel_search (struct GNUNET_REGEX_search_handle *ctx) | |||
803 | } | 803 | } |
804 | 804 | ||
805 | void | 805 | void |
806 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_search_handle *h) | 806 | REGEX_ITERNAL_search_cancel (struct REGEX_ITERNAL_Search *h) |
807 | { | 807 | { |
808 | regex_cancel_search (h); | 808 | regex_cancel_search (h); |
809 | GNUNET_free (h); | 809 | GNUNET_free (h); |
diff --git a/src/regex/regex_graph.c b/src/regex/regex_graph.c index 0b5c571eb..4789fd635 100644 --- a/src/regex/regex_graph.c +++ b/src/regex/regex_graph.c | |||
@@ -23,14 +23,14 @@ | |||
23 | * @author Maximilian Szengel | 23 | * @author Maximilian Szengel |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_regex_lib.h" | 26 | #include "regex_internal_lib.h" |
27 | #include "regex_internal.h" | 27 | #include "regex_internal.h" |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Context for graph creation. Passed as the cls to | 30 | * Context for graph creation. Passed as the cls to |
31 | * GNUNET_REGEX_automaton_save_graph_step. | 31 | * REGEX_ITERNAL_automaton_save_graph_step. |
32 | */ | 32 | */ |
33 | struct GNUNET_REGEX_Graph_Context | 33 | struct REGEX_ITERNAL_Graph_Context |
34 | { | 34 | { |
35 | /** | 35 | /** |
36 | * File pointer to the dot file used for output. | 36 | * File pointer to the dot file used for output. |
@@ -63,12 +63,12 @@ struct GNUNET_REGEX_Graph_Context | |||
63 | */ | 63 | */ |
64 | static void | 64 | static void |
65 | scc_tarjan_strongconnect (unsigned int *scc_counter, | 65 | scc_tarjan_strongconnect (unsigned int *scc_counter, |
66 | struct GNUNET_REGEX_State *v, unsigned int *index, | 66 | struct REGEX_ITERNAL_State *v, unsigned int *index, |
67 | struct GNUNET_REGEX_State **stack, | 67 | struct REGEX_ITERNAL_State **stack, |
68 | unsigned int *stack_size) | 68 | unsigned int *stack_size) |
69 | { | 69 | { |
70 | struct GNUNET_REGEX_State *w; | 70 | struct REGEX_ITERNAL_State *w; |
71 | struct GNUNET_REGEX_Transition *t; | 71 | struct REGEX_ITERNAL_Transition *t; |
72 | 72 | ||
73 | v->index = *index; | 73 | v->index = *index; |
74 | v->lowlink = *index; | 74 | v->lowlink = *index; |
@@ -113,12 +113,12 @@ scc_tarjan_strongconnect (unsigned int *scc_counter, | |||
113 | * @param a the automaton for which SCCs should be computed and assigned. | 113 | * @param a the automaton for which SCCs should be computed and assigned. |
114 | */ | 114 | */ |
115 | static void | 115 | static void |
116 | scc_tarjan (struct GNUNET_REGEX_Automaton *a) | 116 | scc_tarjan (struct REGEX_ITERNAL_Automaton *a) |
117 | { | 117 | { |
118 | unsigned int index; | 118 | unsigned int index; |
119 | unsigned int scc_counter; | 119 | unsigned int scc_counter; |
120 | struct GNUNET_REGEX_State *v; | 120 | struct REGEX_ITERNAL_State *v; |
121 | struct GNUNET_REGEX_State *stack[a->state_count]; | 121 | struct REGEX_ITERNAL_State *stack[a->state_count]; |
122 | unsigned int stack_size; | 122 | unsigned int stack_size; |
123 | 123 | ||
124 | for (v = a->states_head; NULL != v; v = v->next) | 124 | for (v = a->states_head; NULL != v; v = v->next) |
@@ -143,18 +143,18 @@ scc_tarjan (struct GNUNET_REGEX_Automaton *a) | |||
143 | /** | 143 | /** |
144 | * Save a state to an open file pointer. cls is expected to be a file pointer to | 144 | * Save a state to an open file pointer. cls is expected to be a file pointer to |
145 | * an open file. Used only in conjunction with | 145 | * an open file. Used only in conjunction with |
146 | * GNUNET_REGEX_automaton_save_graph. | 146 | * REGEX_ITERNAL_automaton_save_graph. |
147 | * | 147 | * |
148 | * @param cls file pointer. | 148 | * @param cls file pointer. |
149 | * @param count current count of the state, not used. | 149 | * @param count current count of the state, not used. |
150 | * @param s state. | 150 | * @param s state. |
151 | */ | 151 | */ |
152 | void | 152 | void |
153 | GNUNET_REGEX_automaton_save_graph_step (void *cls, unsigned int count, | 153 | REGEX_ITERNAL_automaton_save_graph_step (void *cls, unsigned int count, |
154 | struct GNUNET_REGEX_State *s) | 154 | struct REGEX_ITERNAL_State *s) |
155 | { | 155 | { |
156 | struct GNUNET_REGEX_Graph_Context *ctx = cls; | 156 | struct REGEX_ITERNAL_Graph_Context *ctx = cls; |
157 | struct GNUNET_REGEX_Transition *ctran; | 157 | struct REGEX_ITERNAL_Transition *ctran; |
158 | char *s_acc = NULL; | 158 | char *s_acc = NULL; |
159 | char *s_tran = NULL; | 159 | char *s_tran = NULL; |
160 | char *name; | 160 | char *name; |
@@ -267,13 +267,13 @@ GNUNET_REGEX_automaton_save_graph_step (void *cls, unsigned int count, | |||
267 | * mode | 267 | * mode |
268 | */ | 268 | */ |
269 | void | 269 | void |
270 | GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | 270 | REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a, |
271 | const char *filename, | 271 | const char *filename, |
272 | enum GNUNET_REGEX_GraphSavingOptions options) | 272 | enum REGEX_ITERNAL_GraphSavingOptions options) |
273 | { | 273 | { |
274 | char *start; | 274 | char *start; |
275 | char *end; | 275 | char *end; |
276 | struct GNUNET_REGEX_Graph_Context ctx; | 276 | struct REGEX_ITERNAL_Graph_Context ctx; |
277 | 277 | ||
278 | if (NULL == a) | 278 | if (NULL == a) |
279 | { | 279 | { |
@@ -289,9 +289,9 @@ GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | |||
289 | 289 | ||
290 | ctx.filep = fopen (filename, "w"); | 290 | ctx.filep = fopen (filename, "w"); |
291 | ctx.verbose = | 291 | ctx.verbose = |
292 | (0 == (options & GNUNET_REGEX_GRAPH_VERBOSE)) ? GNUNET_NO : GNUNET_YES; | 292 | (0 == (options & REGEX_ITERNAL_GRAPH_VERBOSE)) ? GNUNET_NO : GNUNET_YES; |
293 | ctx.coloring = | 293 | ctx.coloring = |
294 | (0 == (options & GNUNET_REGEX_GRAPH_COLORING)) ? GNUNET_NO : GNUNET_YES; | 294 | (0 == (options & REGEX_ITERNAL_GRAPH_COLORING)) ? GNUNET_NO : GNUNET_YES; |
295 | 295 | ||
296 | if (NULL == ctx.filep) | 296 | if (NULL == ctx.filep) |
297 | { | 297 | { |
@@ -307,8 +307,8 @@ GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | |||
307 | start = "digraph G {\nrankdir=LR\n"; | 307 | start = "digraph G {\nrankdir=LR\n"; |
308 | fwrite (start, strlen (start), 1, ctx.filep); | 308 | fwrite (start, strlen (start), 1, ctx.filep); |
309 | 309 | ||
310 | GNUNET_REGEX_automaton_traverse (a, a->start, NULL, NULL, | 310 | REGEX_ITERNAL_automaton_traverse (a, a->start, NULL, NULL, |
311 | &GNUNET_REGEX_automaton_save_graph_step, | 311 | ®EX_ITERNAL_automaton_save_graph_step, |
312 | &ctx); | 312 | &ctx); |
313 | 313 | ||
314 | end = "\n}\n"; | 314 | end = "\n}\n"; |
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index 00badc54d..17f5f8419 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #ifndef REGEX_INTERNAL_H | 25 | #ifndef REGEX_INTERNAL_H |
26 | #define REGEX_INTERNAL_H | 26 | #define REGEX_INTERNAL_H |
27 | 27 | ||
28 | #include "gnunet_regex_lib.h" | 28 | #include "regex_internal_lib.h" |
29 | 29 | ||
30 | #ifdef __cplusplus | 30 | #ifdef __cplusplus |
31 | extern "C" | 31 | extern "C" |
@@ -47,17 +47,17 @@ extern "C" | |||
47 | * which they origin ('from_state'). Each state can have 0-n transitions. | 47 | * which they origin ('from_state'). Each state can have 0-n transitions. |
48 | * If label is NULL, this is considered to be an epsilon transition. | 48 | * If label is NULL, this is considered to be an epsilon transition. |
49 | */ | 49 | */ |
50 | struct GNUNET_REGEX_Transition | 50 | struct REGEX_ITERNAL_Transition |
51 | { | 51 | { |
52 | /** | 52 | /** |
53 | * This is a linked list. | 53 | * This is a linked list. |
54 | */ | 54 | */ |
55 | struct GNUNET_REGEX_Transition *prev; | 55 | struct REGEX_ITERNAL_Transition *prev; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * This is a linked list. | 58 | * This is a linked list. |
59 | */ | 59 | */ |
60 | struct GNUNET_REGEX_Transition *next; | 60 | struct REGEX_ITERNAL_Transition *next; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Unique id of this transition. | 63 | * Unique id of this transition. |
@@ -72,30 +72,30 @@ struct GNUNET_REGEX_Transition | |||
72 | /** | 72 | /** |
73 | * State to which this transition leads. | 73 | * State to which this transition leads. |
74 | */ | 74 | */ |
75 | struct GNUNET_REGEX_State *to_state; | 75 | struct REGEX_ITERNAL_State *to_state; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * State from which this transition origins. | 78 | * State from which this transition origins. |
79 | */ | 79 | */ |
80 | struct GNUNET_REGEX_State *from_state; | 80 | struct REGEX_ITERNAL_State *from_state; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | /** | 84 | /** |
85 | * A state. Can be used in DFA and NFA automatons. | 85 | * A state. Can be used in DFA and NFA automatons. |
86 | */ | 86 | */ |
87 | struct GNUNET_REGEX_State; | 87 | struct REGEX_ITERNAL_State; |
88 | 88 | ||
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Set of states. | 91 | * Set of states. |
92 | */ | 92 | */ |
93 | struct GNUNET_REGEX_StateSet | 93 | struct REGEX_ITERNAL_StateSet |
94 | { | 94 | { |
95 | /** | 95 | /** |
96 | * Array of states. | 96 | * Array of states. |
97 | */ | 97 | */ |
98 | struct GNUNET_REGEX_State **states; | 98 | struct REGEX_ITERNAL_State **states; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Number of entries in *use* in the 'states' array. | 101 | * Number of entries in *use* in the 'states' array. |
@@ -112,37 +112,37 @@ struct GNUNET_REGEX_StateSet | |||
112 | /** | 112 | /** |
113 | * A state. Can be used in DFA and NFA automatons. | 113 | * A state. Can be used in DFA and NFA automatons. |
114 | */ | 114 | */ |
115 | struct GNUNET_REGEX_State | 115 | struct REGEX_ITERNAL_State |
116 | { | 116 | { |
117 | /** | 117 | /** |
118 | * This is a linked list to keep states in an automaton. | 118 | * This is a linked list to keep states in an automaton. |
119 | */ | 119 | */ |
120 | struct GNUNET_REGEX_State *prev; | 120 | struct REGEX_ITERNAL_State *prev; |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * This is a linked list to keep states in an automaton. | 123 | * This is a linked list to keep states in an automaton. |
124 | */ | 124 | */ |
125 | struct GNUNET_REGEX_State *next; | 125 | struct REGEX_ITERNAL_State *next; |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * This is a multi DLL for StateSet_MDLL. | 128 | * This is a multi DLL for StateSet_MDLL. |
129 | */ | 129 | */ |
130 | struct GNUNET_REGEX_State *prev_SS; | 130 | struct REGEX_ITERNAL_State *prev_SS; |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * This is a multi DLL for StateSet_MDLL. | 133 | * This is a multi DLL for StateSet_MDLL. |
134 | */ | 134 | */ |
135 | struct GNUNET_REGEX_State *next_SS; | 135 | struct REGEX_ITERNAL_State *next_SS; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * This is a multi DLL for StateSet_MDLL Stack. | 138 | * This is a multi DLL for StateSet_MDLL Stack. |
139 | */ | 139 | */ |
140 | struct GNUNET_REGEX_State *prev_ST; | 140 | struct REGEX_ITERNAL_State *prev_ST; |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * This is a multi DLL for StateSet_MDLL Stack. | 143 | * This is a multi DLL for StateSet_MDLL Stack. |
144 | */ | 144 | */ |
145 | struct GNUNET_REGEX_State *next_ST; | 145 | struct REGEX_ITERNAL_State *next_ST; |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * Unique state id. | 148 | * Unique state id. |
@@ -222,12 +222,12 @@ struct GNUNET_REGEX_State | |||
222 | /** | 222 | /** |
223 | * DLL of transitions. | 223 | * DLL of transitions. |
224 | */ | 224 | */ |
225 | struct GNUNET_REGEX_Transition *transitions_head; | 225 | struct REGEX_ITERNAL_Transition *transitions_head; |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * DLL of transitions. | 228 | * DLL of transitions. |
229 | */ | 229 | */ |
230 | struct GNUNET_REGEX_Transition *transitions_tail; | 230 | struct REGEX_ITERNAL_Transition *transitions_tail; |
231 | 231 | ||
232 | /** | 232 | /** |
233 | * Number of incoming transitions. Used for compressing DFA paths. | 233 | * Number of incoming transitions. Used for compressing DFA paths. |
@@ -238,14 +238,14 @@ struct GNUNET_REGEX_State | |||
238 | * Set of states on which this state is based on. Used when creating a DFA out | 238 | * Set of states on which this state is based on. Used when creating a DFA out |
239 | * of several NFA states. | 239 | * of several NFA states. |
240 | */ | 240 | */ |
241 | struct GNUNET_REGEX_StateSet nfa_set; | 241 | struct REGEX_ITERNAL_StateSet nfa_set; |
242 | }; | 242 | }; |
243 | 243 | ||
244 | 244 | ||
245 | /** | 245 | /** |
246 | * Type of an automaton. | 246 | * Type of an automaton. |
247 | */ | 247 | */ |
248 | enum GNUNET_REGEX_AutomatonType | 248 | enum REGEX_ITERNAL_AutomatonType |
249 | { | 249 | { |
250 | NFA, | 250 | NFA, |
251 | DFA | 251 | DFA |
@@ -255,28 +255,28 @@ enum GNUNET_REGEX_AutomatonType | |||
255 | /** | 255 | /** |
256 | * Automaton representation. | 256 | * Automaton representation. |
257 | */ | 257 | */ |
258 | struct GNUNET_REGEX_Automaton | 258 | struct REGEX_ITERNAL_Automaton |
259 | { | 259 | { |
260 | /** | 260 | /** |
261 | * Linked list of NFAs used for partial NFA creation. | 261 | * Linked list of NFAs used for partial NFA creation. |
262 | */ | 262 | */ |
263 | struct GNUNET_REGEX_Automaton *prev; | 263 | struct REGEX_ITERNAL_Automaton *prev; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * Linked list of NFAs used for partial NFA creation. | 266 | * Linked list of NFAs used for partial NFA creation. |
267 | */ | 267 | */ |
268 | struct GNUNET_REGEX_Automaton *next; | 268 | struct REGEX_ITERNAL_Automaton *next; |
269 | 269 | ||
270 | /** | 270 | /** |
271 | * First state of the automaton. This is mainly used for constructing an NFA, | 271 | * First state of the automaton. This is mainly used for constructing an NFA, |
272 | * where each NFA itself consists of one or more NFAs linked together. | 272 | * where each NFA itself consists of one or more NFAs linked together. |
273 | */ | 273 | */ |
274 | struct GNUNET_REGEX_State *start; | 274 | struct REGEX_ITERNAL_State *start; |
275 | 275 | ||
276 | /** | 276 | /** |
277 | * End state of the partial NFA. This is undefined for DFAs | 277 | * End state of the partial NFA. This is undefined for DFAs |
278 | */ | 278 | */ |
279 | struct GNUNET_REGEX_State *end; | 279 | struct REGEX_ITERNAL_State *end; |
280 | 280 | ||
281 | /** | 281 | /** |
282 | * Number of states in the automaton. | 282 | * Number of states in the automaton. |
@@ -286,17 +286,17 @@ struct GNUNET_REGEX_Automaton | |||
286 | /** | 286 | /** |
287 | * DLL of states. | 287 | * DLL of states. |
288 | */ | 288 | */ |
289 | struct GNUNET_REGEX_State *states_head; | 289 | struct REGEX_ITERNAL_State *states_head; |
290 | 290 | ||
291 | /** | 291 | /** |
292 | * DLL of states | 292 | * DLL of states |
293 | */ | 293 | */ |
294 | struct GNUNET_REGEX_State *states_tail; | 294 | struct REGEX_ITERNAL_State *states_tail; |
295 | 295 | ||
296 | /** | 296 | /** |
297 | * Type of the automaton. | 297 | * Type of the automaton. |
298 | */ | 298 | */ |
299 | enum GNUNET_REGEX_AutomatonType type; | 299 | enum REGEX_ITERNAL_AutomatonType type; |
300 | 300 | ||
301 | /** | 301 | /** |
302 | * Regex | 302 | * Regex |
@@ -321,10 +321,10 @@ struct GNUNET_REGEX_Automaton | |||
321 | * @param regex regular expression string. | 321 | * @param regex regular expression string. |
322 | * @param len length of the string. | 322 | * @param len length of the string. |
323 | * | 323 | * |
324 | * @return NFA, needs to be freed using GNUNET_REGEX_automaton_destroy. | 324 | * @return NFA, needs to be freed using REGEX_ITERNAL_automaton_destroy. |
325 | */ | 325 | */ |
326 | struct GNUNET_REGEX_Automaton * | 326 | struct REGEX_ITERNAL_Automaton * |
327 | GNUNET_REGEX_construct_nfa (const char *regex, const size_t len); | 327 | REGEX_ITERNAL_construct_nfa (const char *regex, const size_t len); |
328 | 328 | ||
329 | 329 | ||
330 | /** | 330 | /** |
@@ -339,9 +339,9 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len); | |||
339 | * | 339 | * |
340 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. | 340 | * @return GNUNET_YES to proceed traversal, GNUNET_NO to stop. |
341 | */ | 341 | */ |
342 | typedef int (*GNUNET_REGEX_traverse_check) (void *cls, | 342 | typedef int (*REGEX_ITERNAL_traverse_check) (void *cls, |
343 | struct GNUNET_REGEX_State * s, | 343 | struct REGEX_ITERNAL_State * s, |
344 | struct GNUNET_REGEX_Transition * t); | 344 | struct REGEX_ITERNAL_Transition * t); |
345 | 345 | ||
346 | 346 | ||
347 | /** | 347 | /** |
@@ -351,9 +351,9 @@ typedef int (*GNUNET_REGEX_traverse_check) (void *cls, | |||
351 | * @param count current count of the state, from 0 to a->state_count -1. | 351 | * @param count current count of the state, from 0 to a->state_count -1. |
352 | * @param s state. | 352 | * @param s state. |
353 | */ | 353 | */ |
354 | typedef void (*GNUNET_REGEX_traverse_action) (void *cls, | 354 | typedef void (*REGEX_ITERNAL_traverse_action) (void *cls, |
355 | const unsigned int count, | 355 | const unsigned int count, |
356 | struct GNUNET_REGEX_State * s); | 356 | struct REGEX_ITERNAL_State * s); |
357 | 357 | ||
358 | 358 | ||
359 | /** | 359 | /** |
@@ -370,11 +370,11 @@ typedef void (*GNUNET_REGEX_traverse_action) (void *cls, | |||
370 | * @param action_cls closure for action | 370 | * @param action_cls closure for action |
371 | */ | 371 | */ |
372 | void | 372 | void |
373 | GNUNET_REGEX_automaton_traverse (const struct GNUNET_REGEX_Automaton *a, | 373 | REGEX_ITERNAL_automaton_traverse (const struct REGEX_ITERNAL_Automaton *a, |
374 | struct GNUNET_REGEX_State *start, | 374 | struct REGEX_ITERNAL_State *start, |
375 | GNUNET_REGEX_traverse_check check, | 375 | REGEX_ITERNAL_traverse_check check, |
376 | void *check_cls, | 376 | void *check_cls, |
377 | GNUNET_REGEX_traverse_action action, | 377 | REGEX_ITERNAL_traverse_action action, |
378 | void *action_cls); | 378 | void *action_cls); |
379 | 379 | ||
380 | /** | 380 | /** |
@@ -389,7 +389,7 @@ GNUNET_REGEX_automaton_traverse (const struct GNUNET_REGEX_Automaton *a, | |||
389 | * @return canonical regex string. | 389 | * @return canonical regex string. |
390 | */ | 390 | */ |
391 | const char * | 391 | const char * |
392 | GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a); | 392 | REGEX_ITERNAL_get_canonical_regex (struct REGEX_ITERNAL_Automaton *a); |
393 | 393 | ||
394 | 394 | ||
395 | /** | 395 | /** |
@@ -400,14 +400,14 @@ GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a); | |||
400 | * @return number of transitions in the given automaton. | 400 | * @return number of transitions in the given automaton. |
401 | */ | 401 | */ |
402 | unsigned int | 402 | unsigned int |
403 | GNUNET_REGEX_get_transition_count (struct GNUNET_REGEX_Automaton *a); | 403 | REGEX_ITERNAL_get_transition_count (struct REGEX_ITERNAL_Automaton *a); |
404 | 404 | ||
405 | 405 | ||
406 | /** | 406 | /** |
407 | * Context that contains an id counter for states and transitions as well as a | 407 | * Context that contains an id counter for states and transitions as well as a |
408 | * DLL of automatons used as a stack for NFA construction. | 408 | * DLL of automatons used as a stack for NFA construction. |
409 | */ | 409 | */ |
410 | struct GNUNET_REGEX_Context | 410 | struct REGEX_ITERNAL_Context |
411 | { | 411 | { |
412 | /** | 412 | /** |
413 | * Unique state id. | 413 | * Unique state id. |
@@ -420,14 +420,14 @@ struct GNUNET_REGEX_Context | |||
420 | unsigned int transition_id; | 420 | unsigned int transition_id; |
421 | 421 | ||
422 | /** | 422 | /** |
423 | * DLL of GNUNET_REGEX_Automaton's used as a stack. | 423 | * DLL of REGEX_ITERNAL_Automaton's used as a stack. |
424 | */ | 424 | */ |
425 | struct GNUNET_REGEX_Automaton *stack_head; | 425 | struct REGEX_ITERNAL_Automaton *stack_head; |
426 | 426 | ||
427 | /** | 427 | /** |
428 | * DLL of GNUNET_REGEX_Automaton's used as a stack. | 428 | * DLL of REGEX_ITERNAL_Automaton's used as a stack. |
429 | */ | 429 | */ |
430 | struct GNUNET_REGEX_Automaton *stack_tail; | 430 | struct REGEX_ITERNAL_Automaton *stack_tail; |
431 | }; | 431 | }; |
432 | 432 | ||
433 | 433 | ||
@@ -439,8 +439,8 @@ struct GNUNET_REGEX_Context | |||
439 | * @param stride_len length of the strides. | 439 | * @param stride_len length of the strides. |
440 | */ | 440 | */ |
441 | void | 441 | void |
442 | GNUNET_REGEX_dfa_add_multi_strides (struct GNUNET_REGEX_Context *regex_ctx, | 442 | REGEX_ITERNAL_dfa_add_multi_strides (struct REGEX_ITERNAL_Context *regex_ctx, |
443 | struct GNUNET_REGEX_Automaton *dfa, | 443 | struct REGEX_ITERNAL_Automaton *dfa, |
444 | const unsigned int stride_len); | 444 | const unsigned int stride_len); |
445 | 445 | ||
446 | 446 | ||
@@ -458,7 +458,7 @@ GNUNET_REGEX_dfa_add_multi_strides (struct GNUNET_REGEX_Context *regex_ctx, | |||
458 | * needs to be freed, otherwise. | 458 | * needs to be freed, otherwise. |
459 | */ | 459 | */ |
460 | char * | 460 | char * |
461 | GNUNET_REGEX_generate_random_regex (size_t rx_length, char *matching_str); | 461 | REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str); |
462 | 462 | ||
463 | 463 | ||
464 | /** | 464 | /** |
@@ -471,7 +471,7 @@ GNUNET_REGEX_generate_random_regex (size_t rx_length, char *matching_str); | |||
471 | * @return random string that needs to be freed. | 471 | * @return random string that needs to be freed. |
472 | */ | 472 | */ |
473 | char * | 473 | char * |
474 | GNUNET_REGEX_generate_random_string (size_t max_len); | 474 | REGEX_ITERNAL_generate_random_string (size_t max_len); |
475 | 475 | ||
476 | 476 | ||
477 | #if 0 /* keep Emacsens' auto-indent happy */ | 477 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_regex_lib.h b/src/regex/regex_internal_lib.h index 7d08e073a..f14665538 100644 --- a/src/include/gnunet_regex_lib.h +++ b/src/regex/regex_internal_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -18,14 +18,14 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file include/gnunet_regex_lib.h | 21 | * @file regex/regex_internal_lib.h |
22 | * @brief library to parse regular expressions into dfa | 22 | * @brief library to parse regular expressions into dfa |
23 | * @author Maximilian Szengel | 23 | * @author Maximilian Szengel |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef GNUNET_REGEX_LIB_H | 27 | #ifndef REGEX_INTERNAL_LIB_H |
28 | #define GNUNET_REGEX_LIB_H | 28 | #define REGEX_INTERNAL_LIB_H |
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_dht_service.h" | 31 | #include "gnunet_dht_service.h" |
@@ -40,34 +40,18 @@ extern "C" | |||
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | 42 | ||
43 | /** | ||
44 | * Constant for how many bytes the initial string regex should have. | ||
45 | */ | ||
46 | #define GNUNET_REGEX_INITIAL_BYTES 24 | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Maximum regex string length for use with GNUNET_REGEX_ipv4toregex | ||
51 | */ | ||
52 | #define GNUNET_REGEX_IPV4_REGEXLEN 32 + 6 | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Maximum regex string length for use with GNUNET_REGEX_ipv6toregex | ||
57 | */ | ||
58 | #define GNUNET_REGEX_IPV6_REGEXLEN 128 + 6 | ||
59 | 43 | ||
60 | 44 | ||
61 | /** | 45 | /** |
62 | * Automaton (NFA/DFA) representation. | 46 | * Automaton (NFA/DFA) representation. |
63 | */ | 47 | - */ |
64 | struct GNUNET_REGEX_Automaton; | 48 | struct REGEX_ITERNAL_Automaton; |
65 | 49 | ||
66 | 50 | ||
67 | /** | 51 | /** |
68 | * Edge representation. | 52 | * Edge representation. |
69 | */ | 53 | */ |
70 | struct GNUNET_REGEX_Edge | 54 | struct REGEX_ITERNAL_Edge |
71 | { | 55 | { |
72 | /** | 56 | /** |
73 | * Label of the edge. FIXME: might want to not consume exactly multiples of 8 bits, need length? | 57 | * Label of the edge. FIXME: might want to not consume exactly multiples of 8 bits, need length? |
@@ -96,44 +80,44 @@ struct GNUNET_REGEX_Edge | |||
96 | * @param max_path_len limit the path compression length to the | 80 | * @param max_path_len limit the path compression length to the |
97 | * given value. If set to 1, no path compression is applied. Set to 0 for | 81 | * given value. If set to 1, no path compression is applied. Set to 0 for |
98 | * maximal possible path compression (generally not desireable). | 82 | * maximal possible path compression (generally not desireable). |
99 | * @return DFA, needs to be freed using GNUNET_REGEX_automaton_destroy. | 83 | * @return DFA, needs to be freed using REGEX_ITERNAL_automaton_destroy. |
100 | */ | 84 | */ |
101 | struct GNUNET_REGEX_Automaton * | 85 | struct REGEX_ITERNAL_Automaton * |
102 | GNUNET_REGEX_construct_dfa (const char *regex, const size_t len, | 86 | REGEX_ITERNAL_construct_dfa (const char *regex, const size_t len, |
103 | unsigned int max_path_len); | 87 | unsigned int max_path_len); |
104 | 88 | ||
105 | 89 | ||
106 | /** | 90 | /** |
107 | * Free the memory allocated by constructing the GNUNET_REGEX_Automaton. | 91 | * Free the memory allocated by constructing the REGEX_ITERNAL_Automaton. |
108 | * data structure. | 92 | * data structure. |
109 | * | 93 | * |
110 | * @param a automaton to be destroyed. | 94 | * @param a automaton to be destroyed. |
111 | */ | 95 | */ |
112 | void | 96 | void |
113 | GNUNET_REGEX_automaton_destroy (struct GNUNET_REGEX_Automaton *a); | 97 | REGEX_ITERNAL_automaton_destroy (struct REGEX_ITERNAL_Automaton *a); |
114 | 98 | ||
115 | 99 | ||
116 | /** | 100 | /** |
117 | * Options for graph creation function | 101 | * Options for graph creation function |
118 | * GNUNET_REGEX_automaton_save_graph. | 102 | * REGEX_ITERNAL_automaton_save_graph. |
119 | */ | 103 | */ |
120 | enum GNUNET_REGEX_GraphSavingOptions | 104 | enum REGEX_ITERNAL_GraphSavingOptions |
121 | { | 105 | { |
122 | /** | 106 | /** |
123 | * Default. Do nothing special. | 107 | * Default. Do nothing special. |
124 | */ | 108 | */ |
125 | GNUNET_REGEX_GRAPH_DEFAULT = 0, | 109 | REGEX_ITERNAL_GRAPH_DEFAULT = 0, |
126 | 110 | ||
127 | /** | 111 | /** |
128 | * The generated graph will include extra information such as the NFA states | 112 | * The generated graph will include extra information such as the NFA states |
129 | * that were used to generate the DFA state. | 113 | * that were used to generate the DFA state. |
130 | */ | 114 | */ |
131 | GNUNET_REGEX_GRAPH_VERBOSE = 1, | 115 | REGEX_ITERNAL_GRAPH_VERBOSE = 1, |
132 | 116 | ||
133 | /** | 117 | /** |
134 | * Enable graph coloring. Will color each SCC in a different color. | 118 | * Enable graph coloring. Will color each SCC in a different color. |
135 | */ | 119 | */ |
136 | GNUNET_REGEX_GRAPH_COLORING = 2 | 120 | REGEX_ITERNAL_GRAPH_COLORING = 2 |
137 | }; | 121 | }; |
138 | 122 | ||
139 | 123 | ||
@@ -146,9 +130,9 @@ enum GNUNET_REGEX_GraphSavingOptions | |||
146 | * mode | 130 | * mode |
147 | */ | 131 | */ |
148 | void | 132 | void |
149 | GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | 133 | REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a, |
150 | const char *filename, | 134 | const char *filename, |
151 | enum GNUNET_REGEX_GraphSavingOptions options); | 135 | enum REGEX_ITERNAL_GraphSavingOptions options); |
152 | 136 | ||
153 | 137 | ||
154 | /** | 138 | /** |
@@ -160,7 +144,7 @@ GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | |||
160 | * @return 0 if string matches, non 0 otherwise. | 144 | * @return 0 if string matches, non 0 otherwise. |
161 | */ | 145 | */ |
162 | int | 146 | int |
163 | GNUNET_REGEX_eval (struct GNUNET_REGEX_Automaton *a, | 147 | REGEX_ITERNAL_eval (struct REGEX_ITERNAL_Automaton *a, |
164 | const char *string); | 148 | const char *string); |
165 | 149 | ||
166 | 150 | ||
@@ -176,7 +160,7 @@ GNUNET_REGEX_eval (struct GNUNET_REGEX_Automaton *a, | |||
176 | * to construct the key | 160 | * to construct the key |
177 | */ | 161 | */ |
178 | size_t | 162 | size_t |
179 | GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len, | 163 | REGEX_ITERNAL_get_first_key (const char *input_string, size_t string_len, |
180 | struct GNUNET_HashCode * key); | 164 | struct GNUNET_HashCode * key); |
181 | 165 | ||
182 | 166 | ||
@@ -189,7 +173,7 @@ GNUNET_REGEX_get_first_key (const char *input_string, size_t string_len, | |||
189 | * @return GNUNET_OK if the proof is valid for the given key. | 173 | * @return GNUNET_OK if the proof is valid for the given key. |
190 | */ | 174 | */ |
191 | int | 175 | int |
192 | GNUNET_REGEX_check_proof (const char *proof, | 176 | REGEX_ITERNAL_check_proof (const char *proof, |
193 | const struct GNUNET_HashCode *key); | 177 | const struct GNUNET_HashCode *key); |
194 | 178 | ||
195 | 179 | ||
@@ -203,12 +187,12 @@ GNUNET_REGEX_check_proof (const char *proof, | |||
203 | * @param num_edges number of edges leaving current state. | 187 | * @param num_edges number of edges leaving current state. |
204 | * @param edges edges leaving current state. | 188 | * @param edges edges leaving current state. |
205 | */ | 189 | */ |
206 | typedef void (*GNUNET_REGEX_KeyIterator)(void *cls, | 190 | typedef void (*REGEX_ITERNAL_KeyIterator)(void *cls, |
207 | const struct GNUNET_HashCode *key, | 191 | const struct GNUNET_HashCode *key, |
208 | const char *proof, | 192 | const char *proof, |
209 | int accepting, | 193 | int accepting, |
210 | unsigned int num_edges, | 194 | unsigned int num_edges, |
211 | const struct GNUNET_REGEX_Edge *edges); | 195 | const struct REGEX_ITERNAL_Edge *edges); |
212 | 196 | ||
213 | 197 | ||
214 | /** | 198 | /** |
@@ -220,51 +204,25 @@ typedef void (*GNUNET_REGEX_KeyIterator)(void *cls, | |||
220 | * @param iterator_cls closure. | 204 | * @param iterator_cls closure. |
221 | */ | 205 | */ |
222 | void | 206 | void |
223 | GNUNET_REGEX_iterate_all_edges (struct GNUNET_REGEX_Automaton *a, | 207 | REGEX_ITERNAL_iterate_all_edges (struct REGEX_ITERNAL_Automaton *a, |
224 | GNUNET_REGEX_KeyIterator iterator, | 208 | REGEX_ITERNAL_KeyIterator iterator, |
225 | void *iterator_cls); | 209 | void *iterator_cls); |
226 | 210 | ||
227 | 211 | ||
228 | /** | ||
229 | * Create a regex in 'rxstr' from the given 'ip' and 'netmask'. | ||
230 | * | ||
231 | * @param ip IPv4 representation. | ||
232 | * @param netmask netmask for the ip. | ||
233 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV4_REGEXLEN | ||
234 | * bytes long. | ||
235 | */ | ||
236 | void | ||
237 | GNUNET_REGEX_ipv4toregex (const struct in_addr *ip, const char *netmask, | ||
238 | char *rxstr); | ||
239 | |||
240 | |||
241 | /** | ||
242 | * Create a regex in 'rxstr' from the given 'ipv6' and 'prefixlen'. | ||
243 | * | ||
244 | * @param ipv6 IPv6 representation. | ||
245 | * @param prefixlen length of the ipv6 prefix. | ||
246 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV6_REGEXLEN | ||
247 | * bytes long. | ||
248 | */ | ||
249 | void | ||
250 | GNUNET_REGEX_ipv6toregex (const struct in6_addr *ipv6, | ||
251 | unsigned int prefixlen, char *rxstr); | ||
252 | |||
253 | |||
254 | 212 | ||
255 | /** | 213 | /** |
256 | * Handle to store cached data about a regex announce. | 214 | * Handle to store cached data about a regex announce. |
257 | */ | 215 | */ |
258 | struct GNUNET_REGEX_announce_handle; | 216 | struct REGEX_ITERNAL_Announcement; |
259 | 217 | ||
260 | /** | 218 | /** |
261 | * Handle to store data about a regex search. | 219 | * Handle to store data about a regex search. |
262 | */ | 220 | */ |
263 | struct GNUNET_REGEX_search_handle; | 221 | struct REGEX_ITERNAL_Search; |
264 | 222 | ||
265 | /** | 223 | /** |
266 | * Announce a regular expression: put all states of the automaton in the DHT. | 224 | * Announce a regular expression: put all states of the automaton in the DHT. |
267 | * Does not free resources, must call GNUNET_REGEX_announce_cancel for that. | 225 | * Does not free resources, must call REGEX_ITERNAL_announce_cancel for that. |
268 | * | 226 | * |
269 | * @param dht An existing and valid DHT service handle. CANNOT be NULL. | 227 | * @param dht An existing and valid DHT service handle. CANNOT be NULL. |
270 | * @param id ID to announce as provider of regex. Own ID in most cases. | 228 | * @param id ID to announce as provider of regex. Own ID in most cases. |
@@ -273,10 +231,10 @@ struct GNUNET_REGEX_search_handle; | |||
273 | * @param stats Optional statistics handle to report usage. Can be NULL. | 231 | * @param stats Optional statistics handle to report usage. Can be NULL. |
274 | * | 232 | * |
275 | * @return Handle to reuse o free cached resources. | 233 | * @return Handle to reuse o free cached resources. |
276 | * Must be freed by calling GNUNET_REGEX_announce_cancel. | 234 | * Must be freed by calling REGEX_ITERNAL_announce_cancel. |
277 | */ | 235 | */ |
278 | struct GNUNET_REGEX_announce_handle * | 236 | struct REGEX_ITERNAL_Announcement * |
279 | GNUNET_REGEX_announce (struct GNUNET_DHT_Handle *dht, | 237 | REGEX_ITERNAL_announce (struct GNUNET_DHT_Handle *dht, |
280 | const struct GNUNET_PeerIdentity *id, | 238 | const struct GNUNET_PeerIdentity *id, |
281 | const char *regex, | 239 | const char *regex, |
282 | uint16_t compression, | 240 | uint16_t compression, |
@@ -286,33 +244,33 @@ GNUNET_REGEX_announce (struct GNUNET_DHT_Handle *dht, | |||
286 | * Announce again a regular expression previously announced. | 244 | * Announce again a regular expression previously announced. |
287 | * Does use caching to speed up process. | 245 | * Does use caching to speed up process. |
288 | * | 246 | * |
289 | * @param h Handle returned by a previous GNUNET_REGEX_announce call. | 247 | * @param h Handle returned by a previous REGEX_ITERNAL_announce call. |
290 | */ | 248 | */ |
291 | void | 249 | void |
292 | GNUNET_REGEX_reannounce (struct GNUNET_REGEX_announce_handle *h); | 250 | REGEX_ITERNAL_reannounce (struct REGEX_ITERNAL_Announcement *h); |
293 | 251 | ||
294 | 252 | ||
295 | /** | 253 | /** |
296 | * Clear all cached data used by a regex announce. | 254 | * Clear all cached data used by a regex announce. |
297 | * Does not close DHT connection. | 255 | * Does not close DHT connection. |
298 | * | 256 | * |
299 | * @param h Handle returned by a previous GNUNET_REGEX_announce call. | 257 | * @param h Handle returned by a previous REGEX_ITERNAL_announce call. |
300 | */ | 258 | */ |
301 | void | 259 | void |
302 | GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_announce_handle *h); | 260 | REGEX_ITERNAL_announce_cancel (struct REGEX_ITERNAL_Announcement *h); |
303 | 261 | ||
304 | 262 | ||
305 | /** | 263 | /** |
306 | * Search callback function. | 264 | * Search callback function. |
307 | * | 265 | * |
308 | * @param cls Closure provided in GNUNET_REGEX_search. | 266 | * @param cls Closure provided in REGEX_ITERNAL_search. |
309 | * @param id Peer providing a regex that matches the string. | 267 | * @param id Peer providing a regex that matches the string. |
310 | * @param get_path Path of the get request. | 268 | * @param get_path Path of the get request. |
311 | * @param get_path_length Lenght of get_path. | 269 | * @param get_path_length Lenght of get_path. |
312 | * @param put_path Path of the put request. | 270 | * @param put_path Path of the put request. |
313 | * @param put_path_length Length of the put_path. | 271 | * @param put_path_length Length of the put_path. |
314 | */ | 272 | */ |
315 | typedef void (*GNUNET_REGEX_Found)(void *cls, | 273 | typedef void (*REGEX_ITERNAL_Found)(void *cls, |
316 | const struct GNUNET_PeerIdentity *id, | 274 | const struct GNUNET_PeerIdentity *id, |
317 | const struct GNUNET_PeerIdentity *get_path, | 275 | const struct GNUNET_PeerIdentity *get_path, |
318 | unsigned int get_path_length, | 276 | unsigned int get_path_length, |
@@ -322,7 +280,7 @@ typedef void (*GNUNET_REGEX_Found)(void *cls, | |||
322 | 280 | ||
323 | /** | 281 | /** |
324 | * Search for a peer offering a regex matching certain string in the DHT. | 282 | * Search for a peer offering a regex matching certain string in the DHT. |
325 | * The search runs until GNUNET_REGEX_search_cancel is called, even if results | 283 | * The search runs until REGEX_ITERNAL_search_cancel is called, even if results |
326 | * are returned. | 284 | * are returned. |
327 | * | 285 | * |
328 | * @param dht An existing and valid DHT service handle. | 286 | * @param dht An existing and valid DHT service handle. |
@@ -332,23 +290,23 @@ typedef void (*GNUNET_REGEX_Found)(void *cls, | |||
332 | * @param stats Optional statistics handle to report usage. Can be NULL. | 290 | * @param stats Optional statistics handle to report usage. Can be NULL. |
333 | * | 291 | * |
334 | * @return Handle to stop search and free resources. | 292 | * @return Handle to stop search and free resources. |
335 | * Must be freed by calling GNUNET_REGEX_search_cancel. | 293 | * Must be freed by calling REGEX_ITERNAL_search_cancel. |
336 | */ | 294 | */ |
337 | struct GNUNET_REGEX_search_handle * | 295 | struct REGEX_ITERNAL_Search * |
338 | GNUNET_REGEX_search (struct GNUNET_DHT_Handle *dht, | 296 | REGEX_ITERNAL_search (struct GNUNET_DHT_Handle *dht, |
339 | const char *string, | 297 | const char *string, |
340 | GNUNET_REGEX_Found callback, | 298 | REGEX_ITERNAL_Found callback, |
341 | void *callback_cls, | 299 | void *callback_cls, |
342 | struct GNUNET_STATISTICS_Handle *stats); | 300 | struct GNUNET_STATISTICS_Handle *stats); |
343 | 301 | ||
344 | /** | 302 | /** |
345 | * Stop search and free all data used by a GNUNET_REGEX_search call. | 303 | * Stop search and free all data used by a REGEX_ITERNAL_search call. |
346 | * Does not close DHT connection. | 304 | * Does not close DHT connection. |
347 | * | 305 | * |
348 | * @param h Handle returned by a previous GNUNET_REGEX_search call. | 306 | * @param h Handle returned by a previous REGEX_ITERNAL_search call. |
349 | */ | 307 | */ |
350 | void | 308 | void |
351 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_search_handle *h); | 309 | REGEX_ITERNAL_search_cancel (struct REGEX_ITERNAL_Search *h); |
352 | 310 | ||
353 | 311 | ||
354 | #if 0 /* keep Emacsens' auto-indent happy */ | 312 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -358,5 +316,5 @@ GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_search_handle *h); | |||
358 | } | 316 | } |
359 | #endif | 317 | #endif |
360 | 318 | ||
361 | /* end of gnunet_regex_lib.h */ | 319 | /* end of regex_internal_lib.h */ |
362 | #endif | 320 | #endif |
diff --git a/src/regex/regex_random.c b/src/regex/regex_random.c index eee0c7334..6093ed2eb 100644 --- a/src/regex/regex_random.c +++ b/src/regex/regex_random.c | |||
@@ -23,7 +23,7 @@ | |||
23 | * @author Maximilian Szengel | 23 | * @author Maximilian Szengel |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_regex_lib.h" | 26 | #include "regex_internal_lib.h" |
27 | #include "gnunet_crypto_lib.h" | 27 | #include "gnunet_crypto_lib.h" |
28 | #include "regex_internal.h" | 28 | #include "regex_internal.h" |
29 | 29 | ||
@@ -61,7 +61,7 @@ get_random_literal () | |||
61 | * needs to be freed, otherwise. | 61 | * needs to be freed, otherwise. |
62 | */ | 62 | */ |
63 | char * | 63 | char * |
64 | GNUNET_REGEX_generate_random_regex (size_t rx_length, char *matching_str) | 64 | REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str) |
65 | { | 65 | { |
66 | char *rx; | 66 | char *rx; |
67 | char *rx_p; | 67 | char *rx_p; |
@@ -147,7 +147,7 @@ GNUNET_REGEX_generate_random_regex (size_t rx_length, char *matching_str) | |||
147 | * @return random string that needs to be freed. | 147 | * @return random string that needs to be freed. |
148 | */ | 148 | */ |
149 | char * | 149 | char * |
150 | GNUNET_REGEX_generate_random_string (size_t max_len) | 150 | REGEX_ITERNAL_generate_random_string (size_t max_len) |
151 | { | 151 | { |
152 | unsigned int i; | 152 | unsigned int i; |
153 | char *str; | 153 | char *str; |
diff --git a/src/regex/regex_test_lib.c b/src/regex/regex_test_lib.c index df873c112..dbb864370 100644 --- a/src/regex/regex_test_lib.c +++ b/src/regex/regex_test_lib.c | |||
@@ -305,7 +305,7 @@ regex_ctx_destroy (struct RegexCombineCtx *ctx) | |||
305 | * This function DOES NOT support arbitrary regex combining. | 305 | * This function DOES NOT support arbitrary regex combining. |
306 | */ | 306 | */ |
307 | char * | 307 | char * |
308 | GNUNET_REGEX_combine (char * const regexes[]) | 308 | REGEX_ITERNAL_combine (char * const regexes[]) |
309 | { | 309 | { |
310 | unsigned int i; | 310 | unsigned int i; |
311 | char *combined; | 311 | char *combined; |
@@ -333,15 +333,15 @@ GNUNET_REGEX_combine (char * const regexes[]) | |||
333 | 333 | ||
334 | /** | 334 | /** |
335 | * Read a set of regexes from a file, one per line and return them in an array | 335 | * Read a set of regexes from a file, one per line and return them in an array |
336 | * suitable for GNUNET_REGEX_combine. | 336 | * suitable for REGEX_ITERNAL_combine. |
337 | * The array must be free'd using GNUNET_REGEX_free_from_file. | 337 | * The array must be free'd using REGEX_ITERNAL_free_from_file. |
338 | * | 338 | * |
339 | * @param filename Name of the file containing the regexes. | 339 | * @param filename Name of the file containing the regexes. |
340 | * | 340 | * |
341 | * @return A newly allocated, NULL terminated array of regexes. | 341 | * @return A newly allocated, NULL terminated array of regexes. |
342 | */ | 342 | */ |
343 | char ** | 343 | char ** |
344 | GNUNET_REGEX_read_from_file (const char *filename) | 344 | REGEX_ITERNAL_read_from_file (const char *filename) |
345 | { | 345 | { |
346 | struct GNUNET_DISK_FileHandle *f; | 346 | struct GNUNET_DISK_FileHandle *f; |
347 | unsigned int nr; | 347 | unsigned int nr; |
@@ -421,7 +421,7 @@ GNUNET_REGEX_read_from_file (const char *filename) | |||
421 | * @param regexes NULL-terminated array of regexes. | 421 | * @param regexes NULL-terminated array of regexes. |
422 | */ | 422 | */ |
423 | void | 423 | void |
424 | GNUNET_REGEX_free_from_file (char **regexes) | 424 | REGEX_ITERNAL_free_from_file (char **regexes) |
425 | { | 425 | { |
426 | unsigned int i; | 426 | unsigned int i; |
427 | 427 | ||
diff --git a/src/regex/regex_test_lib.h b/src/regex/regex_test_lib.h index 5e13c29de..418f47dba 100644 --- a/src/regex/regex_test_lib.h +++ b/src/regex/regex_test_lib.h | |||
@@ -26,8 +26,8 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef GNUNET_REGEX_TEST_LIB_H | 29 | #ifndef REGEX_ITERNAL_TEST_LIB_H |
30 | #define GNUNET_REGEX_TEST_LIB_H | 30 | #define REGEX_ITERNAL_TEST_LIB_H |
31 | 31 | ||
32 | 32 | ||
33 | #ifdef __cplusplus | 33 | #ifdef __cplusplus |
@@ -46,19 +46,19 @@ extern "C" | |||
46 | * @return A string with a single regex that matches any of the original regexes | 46 | * @return A string with a single regex that matches any of the original regexes |
47 | */ | 47 | */ |
48 | char * | 48 | char * |
49 | GNUNET_REGEX_combine(char * const regexes[]); | 49 | REGEX_ITERNAL_combine(char * const regexes[]); |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Read a set of regexes from a file, one per line and return them in an array | 52 | * Read a set of regexes from a file, one per line and return them in an array |
53 | * suitable for GNUNET_REGEX_combine. | 53 | * suitable for REGEX_ITERNAL_combine. |
54 | * The array must be free'd using GNUNET_REGEX_free_from_file. | 54 | * The array must be free'd using REGEX_ITERNAL_free_from_file. |
55 | * | 55 | * |
56 | * @param filename Name of the file containing the regexes. | 56 | * @param filename Name of the file containing the regexes. |
57 | * | 57 | * |
58 | * @return A newly allocated, NULL terminated array of regexes. | 58 | * @return A newly allocated, NULL terminated array of regexes. |
59 | */ | 59 | */ |
60 | char ** | 60 | char ** |
61 | GNUNET_REGEX_read_from_file (const char *filename); | 61 | REGEX_ITERNAL_read_from_file (const char *filename); |
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
@@ -67,7 +67,7 @@ GNUNET_REGEX_read_from_file (const char *filename); | |||
67 | * @param regexes NULL-terminated array of regexes. | 67 | * @param regexes NULL-terminated array of regexes. |
68 | */ | 68 | */ |
69 | void | 69 | void |
70 | GNUNET_REGEX_free_from_file (char **regexes); | 70 | REGEX_ITERNAL_free_from_file (char **regexes); |
71 | 71 | ||
72 | #if 0 /* keep Emacsens' auto-indent happy */ | 72 | #if 0 /* keep Emacsens' auto-indent happy */ |
73 | { | 73 | { |
@@ -76,5 +76,5 @@ GNUNET_REGEX_free_from_file (char **regexes); | |||
76 | } | 76 | } |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | /* end of gnunet_regex_lib.h */ | 79 | /* end of regex_internal_lib.h */ |
80 | #endif \ No newline at end of file | 80 | #endif \ No newline at end of file |
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c index ce6f92315..8cdefb17d 100644 --- a/src/regex/test_regex_eval_api.c +++ b/src/regex/test_regex_eval_api.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <regex.h> | 25 | #include <regex.h> |
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_regex_lib.h" | 28 | #include "regex_internal_lib.h" |
29 | #include "regex_internal.h" | 29 | #include "regex_internal.h" |
30 | 30 | ||
31 | enum Match_Result | 31 | enum Match_Result |
@@ -66,7 +66,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
66 | int eval_check; | 66 | int eval_check; |
67 | int eval_canonical; | 67 | int eval_canonical; |
68 | int eval_canonical_check; | 68 | int eval_canonical_check; |
69 | struct GNUNET_REGEX_Automaton *dfa; | 69 | struct REGEX_ITERNAL_Automaton *dfa; |
70 | regex_t rx; | 70 | regex_t rx; |
71 | regmatch_t matchptr[1]; | 71 | regmatch_t matchptr[1]; |
72 | char error[200]; | 72 | char error[200]; |
@@ -80,7 +80,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
80 | 80 | ||
81 | /* Generate random regex and a string that matches the regex */ | 81 | /* Generate random regex and a string that matches the regex */ |
82 | matching_str = GNUNET_malloc (rx_length + 1); | 82 | matching_str = GNUNET_malloc (rx_length + 1); |
83 | rand_rx = GNUNET_REGEX_generate_random_regex (rx_length, matching_str); | 83 | rand_rx = REGEX_ITERNAL_generate_random_regex (rx_length, matching_str); |
84 | 84 | ||
85 | /* Now match */ | 85 | /* Now match */ |
86 | result = 0; | 86 | result = 0; |
@@ -88,21 +88,21 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
88 | { | 88 | { |
89 | if (0 < i) | 89 | if (0 < i) |
90 | { | 90 | { |
91 | matching_str = GNUNET_REGEX_generate_random_string (max_str_len); | 91 | matching_str = REGEX_ITERNAL_generate_random_string (max_str_len); |
92 | } | 92 | } |
93 | 93 | ||
94 | /* Match string using DFA */ | 94 | /* Match string using DFA */ |
95 | dfa = GNUNET_REGEX_construct_dfa (rand_rx, strlen (rand_rx), 0); | 95 | dfa = REGEX_ITERNAL_construct_dfa (rand_rx, strlen (rand_rx), 0); |
96 | if (NULL == dfa) | 96 | if (NULL == dfa) |
97 | { | 97 | { |
98 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); | 98 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n"); |
99 | goto error; | 99 | goto error; |
100 | } | 100 | } |
101 | 101 | ||
102 | eval = GNUNET_REGEX_eval (dfa, matching_str); | 102 | eval = REGEX_ITERNAL_eval (dfa, matching_str); |
103 | /* save the canonical regex for later comparison */ | 103 | /* save the canonical regex for later comparison */ |
104 | canonical_regex = GNUNET_strdup (GNUNET_REGEX_get_canonical_regex (dfa)); | 104 | canonical_regex = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (dfa)); |
105 | GNUNET_REGEX_automaton_destroy (dfa); | 105 | REGEX_ITERNAL_automaton_destroy (dfa); |
106 | 106 | ||
107 | /* Match string using glibc regex */ | 107 | /* Match string using glibc regex */ |
108 | if (0 != regcomp (&rx, rand_rx, REG_EXTENDED)) | 108 | if (0 != regcomp (&rx, rand_rx, REG_EXTENDED)) |
@@ -123,7 +123,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
123 | 123 | ||
124 | /* Match canonical regex */ | 124 | /* Match canonical regex */ |
125 | dfa = | 125 | dfa = |
126 | GNUNET_REGEX_construct_dfa (canonical_regex, strlen (canonical_regex), | 126 | REGEX_ITERNAL_construct_dfa (canonical_regex, strlen (canonical_regex), |
127 | 0); | 127 | 0); |
128 | if (NULL == dfa) | 128 | if (NULL == dfa) |
129 | { | 129 | { |
@@ -131,8 +131,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
131 | goto error; | 131 | goto error; |
132 | } | 132 | } |
133 | 133 | ||
134 | eval_canonical = GNUNET_REGEX_eval (dfa, matching_str); | 134 | eval_canonical = REGEX_ITERNAL_eval (dfa, matching_str); |
135 | GNUNET_REGEX_automaton_destroy (dfa); | 135 | REGEX_ITERNAL_automaton_destroy (dfa); |
136 | 136 | ||
137 | if (0 != regcomp (&rx, canonical_regex, REG_EXTENDED)) | 137 | if (0 != regcomp (&rx, canonical_regex, REG_EXTENDED)) |
138 | { | 138 | { |
@@ -192,7 +192,7 @@ error: | |||
192 | * @return 0 on successfull, non 0 otherwise | 192 | * @return 0 on successfull, non 0 otherwise |
193 | */ | 193 | */ |
194 | int | 194 | int |
195 | test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx, | 195 | test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx, |
196 | struct Regex_String_Pair *rxstr) | 196 | struct Regex_String_Pair *rxstr) |
197 | { | 197 | { |
198 | int result; | 198 | int result; |
@@ -212,7 +212,7 @@ test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx, | |||
212 | 212 | ||
213 | for (i = 0; i < rxstr->string_count; i++) | 213 | for (i = 0; i < rxstr->string_count; i++) |
214 | { | 214 | { |
215 | eval = GNUNET_REGEX_eval (a, rxstr->strings[i]); | 215 | eval = REGEX_ITERNAL_eval (a, rxstr->strings[i]); |
216 | eval_check = regexec (rx, rxstr->strings[i], 1, matchptr, 0); | 216 | eval_check = regexec (rx, rxstr->strings[i], 1, matchptr, 0); |
217 | 217 | ||
218 | /* We only want to match the whole string, because that's what our DFA does, | 218 | /* We only want to match the whole string, because that's what our DFA does, |
@@ -233,7 +233,7 @@ test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx, | |||
233 | "string: %s\nexpected result: %i\n" | 233 | "string: %s\nexpected result: %i\n" |
234 | "gnunet regex: %i\nglibc regex: %i\nglibc error: %s\n" | 234 | "gnunet regex: %i\nglibc regex: %i\nglibc error: %s\n" |
235 | "rm_so: %i\nrm_eo: %i\n\n", rxstr->regex, | 235 | "rm_so: %i\nrm_eo: %i\n\n", rxstr->regex, |
236 | GNUNET_REGEX_get_canonical_regex (a), rxstr->strings[i], | 236 | REGEX_ITERNAL_get_canonical_regex (a), rxstr->strings[i], |
237 | rxstr->expected_results[i], eval, eval_check, error, | 237 | rxstr->expected_results[i], eval, eval_check, error, |
238 | matchptr[0].rm_so, matchptr[0].rm_eo); | 238 | matchptr[0].rm_so, matchptr[0].rm_eo); |
239 | } | 239 | } |
@@ -246,7 +246,7 @@ main (int argc, char *argv[]) | |||
246 | { | 246 | { |
247 | GNUNET_log_setup ("test-regex", "WARNING", NULL); | 247 | GNUNET_log_setup ("test-regex", "WARNING", NULL); |
248 | 248 | ||
249 | struct GNUNET_REGEX_Automaton *a; | 249 | struct REGEX_ITERNAL_Automaton *a; |
250 | regex_t rx; | 250 | regex_t rx; |
251 | int i; | 251 | int i; |
252 | int check_nfa; | 252 | int check_nfa; |
@@ -336,19 +336,19 @@ main (int argc, char *argv[]) | |||
336 | } | 336 | } |
337 | 337 | ||
338 | /* NFA test */ | 338 | /* NFA test */ |
339 | a = GNUNET_REGEX_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex)); | 339 | a = REGEX_ITERNAL_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex)); |
340 | check_nfa += test_automaton (a, &rx, &rxstr[i]); | 340 | check_nfa += test_automaton (a, &rx, &rxstr[i]); |
341 | GNUNET_REGEX_automaton_destroy (a); | 341 | REGEX_ITERNAL_automaton_destroy (a); |
342 | 342 | ||
343 | /* DFA test */ | 343 | /* DFA test */ |
344 | a = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); | 344 | a = REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); |
345 | check_dfa += test_automaton (a, &rx, &rxstr[i]); | 345 | check_dfa += test_automaton (a, &rx, &rxstr[i]); |
346 | check_proof = GNUNET_strdup (GNUNET_REGEX_get_canonical_regex (a)); | 346 | check_proof = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (a)); |
347 | GNUNET_REGEX_automaton_destroy (a); | 347 | REGEX_ITERNAL_automaton_destroy (a); |
348 | 348 | ||
349 | a = GNUNET_REGEX_construct_dfa (check_proof, strlen (check_proof), 0); | 349 | a = REGEX_ITERNAL_construct_dfa (check_proof, strlen (check_proof), 0); |
350 | check_dfa += test_automaton (a, &rx, &rxstr[i]); | 350 | check_dfa += test_automaton (a, &rx, &rxstr[i]); |
351 | GNUNET_REGEX_automaton_destroy (a); | 351 | REGEX_ITERNAL_automaton_destroy (a); |
352 | if (0 != check_dfa) | 352 | if (0 != check_dfa) |
353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof); | 353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof); |
354 | GNUNET_free_non_null (check_proof); | 354 | GNUNET_free_non_null (check_proof); |
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c index 3ae607352..303a0ce07 100644 --- a/src/regex/test_regex_graph_api.c +++ b/src/regex/test_regex_graph_api.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <regex.h> | 25 | #include <regex.h> |
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_regex_lib.h" | 28 | #include "regex_internal_lib.h" |
29 | #include "regex_internal.h" | 29 | #include "regex_internal.h" |
30 | 30 | ||
31 | #define KEEP_FILES 1 | 31 | #define KEEP_FILES 1 |
@@ -73,7 +73,7 @@ int | |||
73 | main (int argc, char *argv[]) | 73 | main (int argc, char *argv[]) |
74 | { | 74 | { |
75 | int error; | 75 | int error; |
76 | struct GNUNET_REGEX_Automaton *a; | 76 | struct REGEX_ITERNAL_Automaton *a; |
77 | unsigned int i; | 77 | unsigned int i; |
78 | const char *filename = "test_graph.dot"; | 78 | const char *filename = "test_graph.dot"; |
79 | 79 | ||
@@ -97,58 +97,58 @@ main (int argc, char *argv[]) | |||
97 | for (i = 0; i < 12; i++) | 97 | for (i = 0; i < 12; i++) |
98 | { | 98 | { |
99 | /* Check NFA graph creation */ | 99 | /* Check NFA graph creation */ |
100 | a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); | 100 | a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i])); |
101 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); | 101 | REGEX_ITERNAL_automaton_save_graph (a, filename, REGEX_ITERNAL_GRAPH_DEFAULT); |
102 | GNUNET_REGEX_automaton_destroy (a); | 102 | REGEX_ITERNAL_automaton_destroy (a); |
103 | error += filecheck (filename); | 103 | error += filecheck (filename); |
104 | 104 | ||
105 | a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); | 105 | a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i])); |
106 | GNUNET_REGEX_automaton_save_graph (a, filename, | 106 | REGEX_ITERNAL_automaton_save_graph (a, filename, |
107 | GNUNET_REGEX_GRAPH_DEFAULT | | 107 | REGEX_ITERNAL_GRAPH_DEFAULT | |
108 | GNUNET_REGEX_GRAPH_VERBOSE); | 108 | REGEX_ITERNAL_GRAPH_VERBOSE); |
109 | GNUNET_REGEX_automaton_destroy (a); | 109 | REGEX_ITERNAL_automaton_destroy (a); |
110 | error += filecheck (filename); | 110 | error += filecheck (filename); |
111 | 111 | ||
112 | a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); | 112 | a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i])); |
113 | GNUNET_REGEX_automaton_save_graph (a, filename, | 113 | REGEX_ITERNAL_automaton_save_graph (a, filename, |
114 | GNUNET_REGEX_GRAPH_DEFAULT | | 114 | REGEX_ITERNAL_GRAPH_DEFAULT | |
115 | GNUNET_REGEX_GRAPH_COLORING); | 115 | REGEX_ITERNAL_GRAPH_COLORING); |
116 | GNUNET_REGEX_automaton_destroy (a); | 116 | REGEX_ITERNAL_automaton_destroy (a); |
117 | error += filecheck (filename); | 117 | error += filecheck (filename); |
118 | 118 | ||
119 | a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); | 119 | a = REGEX_ITERNAL_construct_nfa (regex[i], strlen (regex[i])); |
120 | GNUNET_REGEX_automaton_save_graph (a, filename, | 120 | REGEX_ITERNAL_automaton_save_graph (a, filename, |
121 | GNUNET_REGEX_GRAPH_DEFAULT | | 121 | REGEX_ITERNAL_GRAPH_DEFAULT | |
122 | GNUNET_REGEX_GRAPH_VERBOSE | | 122 | REGEX_ITERNAL_GRAPH_VERBOSE | |
123 | GNUNET_REGEX_GRAPH_COLORING); | 123 | REGEX_ITERNAL_GRAPH_COLORING); |
124 | GNUNET_REGEX_automaton_destroy (a); | 124 | REGEX_ITERNAL_automaton_destroy (a); |
125 | error += filecheck (filename); | 125 | error += filecheck (filename); |
126 | 126 | ||
127 | 127 | ||
128 | /* Check DFA graph creation */ | 128 | /* Check DFA graph creation */ |
129 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); | 129 | a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 0); |
130 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); | 130 | REGEX_ITERNAL_automaton_save_graph (a, filename, REGEX_ITERNAL_GRAPH_DEFAULT); |
131 | GNUNET_REGEX_automaton_destroy (a); | 131 | REGEX_ITERNAL_automaton_destroy (a); |
132 | error += filecheck (filename); | 132 | error += filecheck (filename); |
133 | 133 | ||
134 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); | 134 | a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 0); |
135 | GNUNET_REGEX_automaton_save_graph (a, filename, | 135 | REGEX_ITERNAL_automaton_save_graph (a, filename, |
136 | GNUNET_REGEX_GRAPH_DEFAULT | | 136 | REGEX_ITERNAL_GRAPH_DEFAULT | |
137 | GNUNET_REGEX_GRAPH_VERBOSE); | 137 | REGEX_ITERNAL_GRAPH_VERBOSE); |
138 | GNUNET_REGEX_automaton_destroy (a); | 138 | REGEX_ITERNAL_automaton_destroy (a); |
139 | error += filecheck (filename); | 139 | error += filecheck (filename); |
140 | 140 | ||
141 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); | 141 | a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 0); |
142 | GNUNET_REGEX_automaton_save_graph (a, filename, | 142 | REGEX_ITERNAL_automaton_save_graph (a, filename, |
143 | GNUNET_REGEX_GRAPH_DEFAULT | | 143 | REGEX_ITERNAL_GRAPH_DEFAULT | |
144 | GNUNET_REGEX_GRAPH_COLORING); | 144 | REGEX_ITERNAL_GRAPH_COLORING); |
145 | GNUNET_REGEX_automaton_destroy (a); | 145 | REGEX_ITERNAL_automaton_destroy (a); |
146 | error += filecheck (filename); | 146 | error += filecheck (filename); |
147 | 147 | ||
148 | 148 | ||
149 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 4); | 149 | a = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 4); |
150 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); | 150 | REGEX_ITERNAL_automaton_save_graph (a, filename, REGEX_ITERNAL_GRAPH_DEFAULT); |
151 | GNUNET_REGEX_automaton_destroy (a); | 151 | REGEX_ITERNAL_automaton_destroy (a); |
152 | error += filecheck (filename); | 152 | error += filecheck (filename); |
153 | 153 | ||
154 | } | 154 | } |
diff --git a/src/regex/test_regex_iterate_api.c b/src/regex/test_regex_iterate_api.c index 695bc3075..dd6c09347 100644 --- a/src/regex/test_regex_iterate_api.c +++ b/src/regex/test_regex_iterate_api.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <regex.h> | 25 | #include <regex.h> |
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_regex_lib.h" | 28 | #include "regex_internal_lib.h" |
29 | #include "regex_internal.h" | 29 | #include "regex_internal.h" |
30 | 30 | ||
31 | /** | 31 | /** |
@@ -36,7 +36,7 @@ | |||
36 | /** | 36 | /** |
37 | * Set to GNUNET_YES to save a debug graph. | 37 | * Set to GNUNET_YES to save a debug graph. |
38 | */ | 38 | */ |
39 | #define GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO | 39 | #define REGEX_ITERNAL_ITERATE_SAVE_DEBUG_GRAPH GNUNET_NO |
40 | 40 | ||
41 | static unsigned int transition_counter; | 41 | static unsigned int transition_counter; |
42 | 42 | ||
@@ -61,7 +61,7 @@ struct RegexStringPair | |||
61 | static void | 61 | static void |
62 | key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | 62 | key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, |
63 | int accepting, unsigned int num_edges, | 63 | int accepting, unsigned int num_edges, |
64 | const struct GNUNET_REGEX_Edge *edges) | 64 | const struct REGEX_ITERNAL_Edge *edges) |
65 | { | 65 | { |
66 | unsigned int i; | 66 | unsigned int i; |
67 | struct IteratorContext *ctx = cls; | 67 | struct IteratorContext *ctx = cls; |
@@ -101,7 +101,7 @@ key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, | |||
101 | ctx->match_count++; | 101 | ctx->match_count++; |
102 | } | 102 | } |
103 | 103 | ||
104 | if (GNUNET_OK != GNUNET_REGEX_check_proof (proof, key)) | 104 | if (GNUNET_OK != REGEX_ITERNAL_check_proof (proof, key)) |
105 | { | 105 | { |
106 | ctx->error++; | 106 | ctx->error++; |
107 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 107 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -117,7 +117,7 @@ main (int argc, char *argv[]) | |||
117 | GNUNET_log_setup ("test-regex", "WARNING", NULL); | 117 | GNUNET_log_setup ("test-regex", "WARNING", NULL); |
118 | 118 | ||
119 | int error; | 119 | int error; |
120 | struct GNUNET_REGEX_Automaton *dfa; | 120 | struct REGEX_ITERNAL_Automaton *dfa; |
121 | unsigned int i; | 121 | unsigned int i; |
122 | unsigned int num_transitions; | 122 | unsigned int num_transitions; |
123 | char *filename = NULL; | 123 | char *filename = NULL; |
@@ -161,7 +161,7 @@ main (int argc, char *argv[]) | |||
161 | 161 | ||
162 | 162 | ||
163 | /* Create graph */ | 163 | /* Create graph */ |
164 | if (GNUNET_YES == GNUNET_REGEX_ITERATE_SAVE_DEBUG_GRAPH) | 164 | if (GNUNET_YES == REGEX_ITERNAL_ITERATE_SAVE_DEBUG_GRAPH) |
165 | { | 165 | { |
166 | GNUNET_asprintf (&filename, "iteration_graph_%u.dot", i); | 166 | GNUNET_asprintf (&filename, "iteration_graph_%u.dot", i); |
167 | ctx.graph_filep = fopen (filename, "w"); | 167 | ctx.graph_filep = fopen (filename, "w"); |
@@ -191,10 +191,10 @@ main (int argc, char *argv[]) | |||
191 | ctx.strings = rxstr[i].strings; | 191 | ctx.strings = rxstr[i].strings; |
192 | ctx.match_count = 0; | 192 | ctx.match_count = 0; |
193 | dfa = | 193 | dfa = |
194 | GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); | 194 | REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); |
195 | GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx); | 195 | REGEX_ITERNAL_iterate_all_edges (dfa, key_iterator, &ctx); |
196 | num_transitions = | 196 | num_transitions = |
197 | GNUNET_REGEX_get_transition_count (dfa) - dfa->start->transition_count; | 197 | REGEX_ITERNAL_get_transition_count (dfa) - dfa->start->transition_count; |
198 | 198 | ||
199 | if (transition_counter < num_transitions) | 199 | if (transition_counter < num_transitions) |
200 | { | 200 | { |
@@ -218,7 +218,7 @@ main (int argc, char *argv[]) | |||
218 | error += (ctx.string_count - ctx.match_count); | 218 | error += (ctx.string_count - ctx.match_count); |
219 | } | 219 | } |
220 | 220 | ||
221 | GNUNET_REGEX_automaton_destroy (dfa); | 221 | REGEX_ITERNAL_automaton_destroy (dfa); |
222 | 222 | ||
223 | /* Finish graph */ | 223 | /* Finish graph */ |
224 | if (GNUNET_YES == ctx.should_save_graph) | 224 | if (GNUNET_YES == ctx.should_save_graph) |
@@ -238,9 +238,9 @@ main (int argc, char *argv[]) | |||
238 | ctx.match_count = 0; | 238 | ctx.match_count = 0; |
239 | 239 | ||
240 | dfa = | 240 | dfa = |
241 | GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); | 241 | REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0); |
242 | GNUNET_REGEX_dfa_add_multi_strides (NULL, dfa, 2); | 242 | REGEX_ITERNAL_dfa_add_multi_strides (NULL, dfa, 2); |
243 | GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx); | 243 | REGEX_ITERNAL_iterate_all_edges (dfa, key_iterator, &ctx); |
244 | 244 | ||
245 | if (ctx.match_count < ctx.string_count) | 245 | if (ctx.match_count < ctx.string_count) |
246 | { | 246 | { |
@@ -249,7 +249,7 @@ main (int argc, char *argv[]) | |||
249 | error += (ctx.string_count - ctx.match_count); | 249 | error += (ctx.string_count - ctx.match_count); |
250 | } | 250 | } |
251 | 251 | ||
252 | GNUNET_REGEX_automaton_destroy (dfa); | 252 | REGEX_ITERNAL_automaton_destroy (dfa); |
253 | } | 253 | } |
254 | 254 | ||
255 | error += ctx.error; | 255 | error += ctx.error; |
diff --git a/src/regex/test_regex_proofs.c b/src/regex/test_regex_proofs.c index 92a3a411f..f5bac0ad7 100644 --- a/src/regex/test_regex_proofs.c +++ b/src/regex/test_regex_proofs.c | |||
@@ -23,7 +23,7 @@ | |||
23 | * @author Maximilian Szengel | 23 | * @author Maximilian Szengel |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_regex_lib.h" | 26 | #include "regex_internal_lib.h" |
27 | #include "regex_internal.h" | 27 | #include "regex_internal.h" |
28 | 28 | ||
29 | 29 | ||
@@ -42,17 +42,17 @@ static unsigned int | |||
42 | test_proof (const char *regex) | 42 | test_proof (const char *regex) |
43 | { | 43 | { |
44 | unsigned int error; | 44 | unsigned int error; |
45 | struct GNUNET_REGEX_Automaton *dfa; | 45 | struct REGEX_ITERNAL_Automaton *dfa; |
46 | char *c_rx1; | 46 | char *c_rx1; |
47 | const char *c_rx2; | 47 | const char *c_rx2; |
48 | 48 | ||
49 | dfa = GNUNET_REGEX_construct_dfa (regex, strlen (regex), 1); | 49 | dfa = REGEX_ITERNAL_construct_dfa (regex, strlen (regex), 1); |
50 | GNUNET_assert (NULL != dfa); | 50 | GNUNET_assert (NULL != dfa); |
51 | c_rx1 = GNUNET_strdup (GNUNET_REGEX_get_canonical_regex (dfa)); | 51 | c_rx1 = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (dfa)); |
52 | GNUNET_REGEX_automaton_destroy (dfa); | 52 | REGEX_ITERNAL_automaton_destroy (dfa); |
53 | dfa = GNUNET_REGEX_construct_dfa (c_rx1, strlen (c_rx1), 1); | 53 | dfa = REGEX_ITERNAL_construct_dfa (c_rx1, strlen (c_rx1), 1); |
54 | GNUNET_assert (NULL != dfa); | 54 | GNUNET_assert (NULL != dfa); |
55 | c_rx2 = GNUNET_REGEX_get_canonical_regex (dfa); | 55 | c_rx2 = REGEX_ITERNAL_get_canonical_regex (dfa); |
56 | 56 | ||
57 | error = (0 == strcmp (c_rx1, c_rx2)) ? 0 : 1; | 57 | error = (0 == strcmp (c_rx1, c_rx2)) ? 0 : 1; |
58 | 58 | ||
@@ -64,7 +64,7 @@ test_proof (const char *regex) | |||
64 | } | 64 | } |
65 | 65 | ||
66 | GNUNET_free (c_rx1); | 66 | GNUNET_free (c_rx1); |
67 | GNUNET_REGEX_automaton_destroy (dfa); | 67 | REGEX_ITERNAL_automaton_destroy (dfa); |
68 | 68 | ||
69 | return error; | 69 | return error; |
70 | } | 70 | } |
@@ -90,7 +90,7 @@ test_proofs_random (unsigned int count, size_t rx_length) | |||
90 | 90 | ||
91 | for (i = 0; i < count; i++) | 91 | for (i = 0; i < count; i++) |
92 | { | 92 | { |
93 | rand_rx = GNUNET_REGEX_generate_random_regex (rx_length, NULL); | 93 | rand_rx = REGEX_ITERNAL_generate_random_regex (rx_length, NULL); |
94 | failures += test_proof (rand_rx); | 94 | failures += test_proof (rand_rx); |
95 | GNUNET_free (rand_rx); | 95 | GNUNET_free (rand_rx); |
96 | } | 96 | } |
@@ -123,20 +123,20 @@ test_proofs_static () | |||
123 | 123 | ||
124 | const char *canon_rx1; | 124 | const char *canon_rx1; |
125 | const char *canon_rx2; | 125 | const char *canon_rx2; |
126 | struct GNUNET_REGEX_Automaton *dfa1; | 126 | struct REGEX_ITERNAL_Automaton *dfa1; |
127 | struct GNUNET_REGEX_Automaton *dfa2; | 127 | struct REGEX_ITERNAL_Automaton *dfa2; |
128 | 128 | ||
129 | error = 0; | 129 | error = 0; |
130 | 130 | ||
131 | for (i = 0; i < 8; i += 2) | 131 | for (i = 0; i < 8; i += 2) |
132 | { | 132 | { |
133 | dfa1 = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 1); | 133 | dfa1 = REGEX_ITERNAL_construct_dfa (regex[i], strlen (regex[i]), 1); |
134 | dfa2 = GNUNET_REGEX_construct_dfa (regex[i + 1], strlen (regex[i + 1]), 1); | 134 | dfa2 = REGEX_ITERNAL_construct_dfa (regex[i + 1], strlen (regex[i + 1]), 1); |
135 | GNUNET_assert (NULL != dfa1); | 135 | GNUNET_assert (NULL != dfa1); |
136 | GNUNET_assert (NULL != dfa2); | 136 | GNUNET_assert (NULL != dfa2); |
137 | 137 | ||
138 | canon_rx1 = GNUNET_REGEX_get_canonical_regex (dfa1); | 138 | canon_rx1 = REGEX_ITERNAL_get_canonical_regex (dfa1); |
139 | canon_rx2 = GNUNET_REGEX_get_canonical_regex (dfa2); | 139 | canon_rx2 = REGEX_ITERNAL_get_canonical_regex (dfa2); |
140 | 140 | ||
141 | error += (0 == strcmp (canon_rx1, canon_rx2)) ? 0 : 1; | 141 | error += (0 == strcmp (canon_rx1, canon_rx2)) ? 0 : 1; |
142 | 142 | ||
@@ -147,8 +147,8 @@ test_proofs_static () | |||
147 | regex[i], canon_rx1, regex[i + 1], canon_rx2); | 147 | regex[i], canon_rx1, regex[i + 1], canon_rx2); |
148 | } | 148 | } |
149 | 149 | ||
150 | GNUNET_REGEX_automaton_destroy (dfa1); | 150 | REGEX_ITERNAL_automaton_destroy (dfa1); |
151 | GNUNET_REGEX_automaton_destroy (dfa2); | 151 | REGEX_ITERNAL_automaton_destroy (dfa2); |
152 | } | 152 | } |
153 | 153 | ||
154 | return error; | 154 | return error; |
diff --git a/src/tun/Makefile.am b/src/tun/Makefile.am index 3b2b573b6..96e79d0d8 100644 --- a/src/tun/Makefile.am +++ b/src/tun/Makefile.am | |||
@@ -12,18 +12,19 @@ endif | |||
12 | lib_LTLIBRARIES = libgnunettun.la | 12 | lib_LTLIBRARIES = libgnunettun.la |
13 | 13 | ||
14 | libgnunettun_la_SOURCES = \ | 14 | libgnunettun_la_SOURCES = \ |
15 | tun.c | 15 | tun.c \ |
16 | regex.c | ||
16 | libgnunettun_la_LIBADD = \ | 17 | libgnunettun_la_LIBADD = \ |
17 | $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \ | 18 | $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \ |
18 | $(LTLIBINTL) | 19 | $(LTLIBINTL) |
19 | libgnunettun_la_LDFLAGS = \ | 20 | libgnunettun_la_LDFLAGS = \ |
20 | $(GN_LIB_LDFLAGS) \ | 21 | $(GN_LIB_LDFLAGS) \ |
21 | -version-info 0:0:0 | 22 | -version-info 1:0:1 |
22 | 23 | ||
23 | 24 | ||
24 | check_PROGRAMS = \ | 25 | check_PROGRAMS = \ |
25 | test_tun | 26 | test_tun \ |
26 | 27 | test_regex | |
27 | 28 | ||
28 | if ENABLE_TEST_RUN | 29 | if ENABLE_TEST_RUN |
29 | TESTS = $(check_PROGRAMS) | 30 | TESTS = $(check_PROGRAMS) |
@@ -34,3 +35,10 @@ test_tun_SOURCES = \ | |||
34 | test_tun_LDADD = \ | 35 | test_tun_LDADD = \ |
35 | $(top_builddir)/src/util/libgnunetutil.la \ | 36 | $(top_builddir)/src/util/libgnunetutil.la \ |
36 | $(top_builddir)/src/tun/libgnunettun.la | 37 | $(top_builddir)/src/tun/libgnunettun.la |
38 | |||
39 | |||
40 | test_regex_SOURCES = \ | ||
41 | test_regex.c | ||
42 | test_regex_LDADD = \ | ||
43 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
44 | $(top_builddir)/src/tun/libgnunettun.la | ||
diff --git a/src/regex/test_regex_iptoregex.c b/src/tun/test_regex.c index e33e7929a..c4c618d85 100644 --- a/src/regex/test_regex_iptoregex.c +++ b/src/tun/test_regex.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -18,12 +18,12 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file regex/test_regex_iptoregex.c | 21 | * @file tun/test_regex.c |
22 | * @brief simple test for regex.c iptoregex functions | 22 | * @brief simple test for regex.c iptoregex functions |
23 | * @author Maximilian Szengel | 23 | * @author Maximilian Szengel |
24 | */ | 24 | */ |
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_regex_lib.h" | 26 | #include "gnunet_tun_lib.h" |
27 | 27 | ||
28 | 28 | ||
29 | static int | 29 | static int |
@@ -39,7 +39,7 @@ test_iptoregex (const char *ipv4, const char *netmask, const char *expectedv4, | |||
39 | char rxv6[GNUNET_REGEX_IPV6_REGEXLEN]; | 39 | char rxv6[GNUNET_REGEX_IPV6_REGEXLEN]; |
40 | 40 | ||
41 | GNUNET_assert (1 == inet_pton (AF_INET, ipv4, &a)); | 41 | GNUNET_assert (1 == inet_pton (AF_INET, ipv4, &a)); |
42 | GNUNET_REGEX_ipv4toregex (&a, netmask, rxv4); | 42 | GNUNET_TUN_ipv4toregex (&a, netmask, rxv4); |
43 | 43 | ||
44 | 44 | ||
45 | if (0 != strcmp (rxv4, expectedv4)) | 45 | if (0 != strcmp (rxv4, expectedv4)) |
@@ -50,7 +50,7 @@ test_iptoregex (const char *ipv4, const char *netmask, const char *expectedv4, | |||
50 | } | 50 | } |
51 | 51 | ||
52 | GNUNET_assert (1 == inet_pton (AF_INET6, ipv6, &b)); | 52 | GNUNET_assert (1 == inet_pton (AF_INET6, ipv6, &b)); |
53 | GNUNET_REGEX_ipv6toregex (&b, prefixlen, rxv6); | 53 | GNUNET_TUN_ipv6toregex (&b, prefixlen, rxv6); |
54 | 54 | ||
55 | if (0 != strcmp (rxv6, expectedv6)) | 55 | if (0 != strcmp (rxv6, expectedv6)) |
56 | { | 56 | { |
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 2ab53047b..bc2327e96 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -49,16 +49,6 @@ | |||
49 | */ | 49 | */ |
50 | #define MAX_MESSAGE_QUEUE_SIZE 4 | 50 | #define MAX_MESSAGE_QUEUE_SIZE 4 |
51 | 51 | ||
52 | /** | ||
53 | * Maximum regex string length for use with GNUNET_REGEX_ipv4toregex | ||
54 | */ | ||
55 | #define GNUNET_REGEX_IPV4_REGEXLEN 32 + 6 | ||
56 | |||
57 | /** | ||
58 | * Maximum regex string length for use with GNUNET_REGEX_ipv6toregex | ||
59 | */ | ||
60 | #define GNUNET_REGEX_IPV6_REGEXLEN 128 + 6 | ||
61 | |||
62 | 52 | ||
63 | /** | 53 | /** |
64 | * State we keep for each of our tunnels. | 54 | * State we keep for each of our tunnels. |
@@ -769,118 +759,6 @@ send_to_tunnel (struct TunnelMessageQueueEntry *tnq, | |||
769 | 759 | ||
770 | 760 | ||
771 | /** | 761 | /** |
772 | * Create a string with binary IP notation for the given 'addr' in 'str'. | ||
773 | * | ||
774 | * @param af address family of the given 'addr'. | ||
775 | * @param addr address that should be converted to a string. | ||
776 | * struct in_addr * for IPv4 and struct in6_addr * for IPv6. | ||
777 | * @param str string that will contain binary notation of 'addr'. Expected | ||
778 | * to be at least 33 bytes long for IPv4 and 129 bytes long for IPv6. | ||
779 | */ | ||
780 | static void | ||
781 | iptobinstr (const int af, const void *addr, char *str) | ||
782 | { | ||
783 | int i; | ||
784 | |||
785 | switch (af) | ||
786 | { | ||
787 | case AF_INET: | ||
788 | { | ||
789 | uint32_t b = htonl (((struct in_addr *) addr)->s_addr); | ||
790 | |||
791 | str[32] = '\0'; | ||
792 | str += 31; | ||
793 | for (i = 31; i >= 0; i--) | ||
794 | { | ||
795 | *str = (b & 1) + '0'; | ||
796 | str--; | ||
797 | b >>= 1; | ||
798 | } | ||
799 | break; | ||
800 | } | ||
801 | case AF_INET6: | ||
802 | { | ||
803 | struct in6_addr b = *(const struct in6_addr *) addr; | ||
804 | |||
805 | str[128] = '\0'; | ||
806 | str += 127; | ||
807 | for (i = 127; i >= 0; i--) | ||
808 | { | ||
809 | *str = (b.s6_addr[i / 8] & 1) + '0'; | ||
810 | str--; | ||
811 | b.s6_addr[i / 8] >>= 1; | ||
812 | } | ||
813 | break; | ||
814 | } | ||
815 | } | ||
816 | } | ||
817 | |||
818 | |||
819 | /** | ||
820 | * Get the ipv4 network prefix from the given 'netmask'. | ||
821 | * | ||
822 | * @param netmask netmask for which to get the prefix len. | ||
823 | * | ||
824 | * @return length of ipv4 prefix for 'netmask'. | ||
825 | */ | ||
826 | static unsigned int | ||
827 | ipv4netmasktoprefixlen (const char *netmask) | ||
828 | { | ||
829 | struct in_addr a; | ||
830 | unsigned int len; | ||
831 | uint32_t t; | ||
832 | |||
833 | if (1 != inet_pton (AF_INET, netmask, &a)) | ||
834 | return 0; | ||
835 | len = 32; | ||
836 | for (t = htonl (~a.s_addr); 0 != t; t >>= 1) | ||
837 | len--; | ||
838 | return len; | ||
839 | } | ||
840 | |||
841 | |||
842 | /** | ||
843 | * Create a regex in 'rxstr' from the given 'ip' and 'netmask'. | ||
844 | * | ||
845 | * @param ip IPv4 representation. | ||
846 | * @param netmask netmask for the ip. | ||
847 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV4_REGEXLEN | ||
848 | * bytes long. | ||
849 | */ | ||
850 | static void | ||
851 | ipv4toregex (const struct in_addr *ip, const char *netmask, | ||
852 | char *rxstr) | ||
853 | { | ||
854 | unsigned int pfxlen; | ||
855 | |||
856 | pfxlen = ipv4netmasktoprefixlen (netmask); | ||
857 | iptobinstr (AF_INET, ip, rxstr); | ||
858 | rxstr[pfxlen] = '\0'; | ||
859 | if (pfxlen < 32) | ||
860 | strcat (rxstr, "(0|1)+"); | ||
861 | } | ||
862 | |||
863 | |||
864 | /** | ||
865 | * Create a regex in 'rxstr' from the given 'ipv6' and 'prefixlen'. | ||
866 | * | ||
867 | * @param ipv6 IPv6 representation. | ||
868 | * @param prefixlen length of the ipv6 prefix. | ||
869 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV6_REGEXLEN | ||
870 | * bytes long. | ||
871 | */ | ||
872 | static void | ||
873 | ipv6toregex (const struct in6_addr *ipv6, unsigned int prefixlen, | ||
874 | char *rxstr) | ||
875 | { | ||
876 | iptobinstr (AF_INET6, ipv6, rxstr); | ||
877 | rxstr[prefixlen] = '\0'; | ||
878 | if (prefixlen < 128) | ||
879 | strcat (rxstr, "(0|1)+"); | ||
880 | } | ||
881 | |||
882 | |||
883 | /** | ||
884 | * Regex has found a potential exit peer for us; consider using it. | 762 | * Regex has found a potential exit peer for us; consider using it. |
885 | * | 763 | * |
886 | * @param cls the 'struct TunnelState' | 764 | * @param cls the 'struct TunnelState' |
@@ -973,9 +851,9 @@ create_tunnel_to_destination (struct DestinationEntry *de, | |||
973 | { | 851 | { |
974 | case AF_INET: | 852 | case AF_INET: |
975 | { | 853 | { |
976 | char address[GNUNET_REGEX_IPV4_REGEXLEN]; | 854 | char address[GNUNET_TUN_IPV4_REGEXLEN]; |
977 | 855 | ||
978 | ipv4toregex (&de->details.exit_destination.ip.v4, | 856 | GNUNET_TUN_ipv4toregex (&de->details.exit_destination.ip.v4, |
979 | "255.255.255.255", address); | 857 | "255.255.255.255", address); |
980 | GNUNET_asprintf (&policy, "%s%s%s", | 858 | GNUNET_asprintf (&policy, "%s%s%s", |
981 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | 859 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |
@@ -985,9 +863,9 @@ create_tunnel_to_destination (struct DestinationEntry *de, | |||
985 | } | 863 | } |
986 | case AF_INET6: | 864 | case AF_INET6: |
987 | { | 865 | { |
988 | char address[GNUNET_REGEX_IPV6_REGEXLEN]; | 866 | char address[GNUNET_TUN_IPV6_REGEXLEN]; |
989 | 867 | ||
990 | ipv6toregex (&de->details.exit_destination.ip.v6, | 868 | GNUNET_TUN_ipv6toregex (&de->details.exit_destination.ip.v6, |
991 | 128, address); | 869 | 128, address); |
992 | GNUNET_asprintf (&policy, "%s%s%s", | 870 | GNUNET_asprintf (&policy, "%s%s%s", |
993 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, | 871 | GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, |