aboutsummaryrefslogtreecommitdiff
path: root/src/regex/test_regex_eval_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-20 08:32:50 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-20 08:32:50 +0000
commit21a2b4f95b4488645ba5a6254fcb8919c4915f73 (patch)
tree00c92cb7103cc14fba7e63e8dee99fe711856863 /src/regex/test_regex_eval_api.c
parent5533b105943b4f6dd688c1758350cd83ebeab3b9 (diff)
continuing refactoring of regex library structure, disambiguating symbol names between old regex library which is now internal and the public API; moving IP-to-regex conversion functions to tun library, as only vpn is using those to begin with
Diffstat (limited to 'src/regex/test_regex_eval_api.c')
-rw-r--r--src/regex/test_regex_eval_api.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c
index ce6f923157..8cdefb17d3 100644
--- a/src/regex/test_regex_eval_api.c
+++ b/src/regex/test_regex_eval_api.c
@@ -25,7 +25,7 @@
#include <regex.h>
#include <time.h>
#include "platform.h"
-#include "gnunet_regex_lib.h"
+#include "regex_internal_lib.h"
#include "regex_internal.h"
enum Match_Result
@@ -66,7 +66,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
int eval_check;
int eval_canonical;
int eval_canonical_check;
- struct GNUNET_REGEX_Automaton *dfa;
+ struct REGEX_ITERNAL_Automaton *dfa;
regex_t rx;
regmatch_t matchptr[1];
char error[200];
@@ -80,7 +80,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
/* Generate random regex and a string that matches the regex */
matching_str = GNUNET_malloc (rx_length + 1);
- rand_rx = GNUNET_REGEX_generate_random_regex (rx_length, matching_str);
+ rand_rx = REGEX_ITERNAL_generate_random_regex (rx_length, matching_str);
/* Now match */
result = 0;
@@ -88,21 +88,21 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
{
if (0 < i)
{
- matching_str = GNUNET_REGEX_generate_random_string (max_str_len);
+ matching_str = REGEX_ITERNAL_generate_random_string (max_str_len);
}
/* Match string using DFA */
- dfa = GNUNET_REGEX_construct_dfa (rand_rx, strlen (rand_rx), 0);
+ dfa = REGEX_ITERNAL_construct_dfa (rand_rx, strlen (rand_rx), 0);
if (NULL == dfa)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constructing DFA failed\n");
goto error;
}
- eval = GNUNET_REGEX_eval (dfa, matching_str);
+ eval = REGEX_ITERNAL_eval (dfa, matching_str);
/* save the canonical regex for later comparison */
- canonical_regex = GNUNET_strdup (GNUNET_REGEX_get_canonical_regex (dfa));
- GNUNET_REGEX_automaton_destroy (dfa);
+ canonical_regex = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (dfa));
+ REGEX_ITERNAL_automaton_destroy (dfa);
/* Match string using glibc regex */
if (0 != regcomp (&rx, rand_rx, REG_EXTENDED))
@@ -123,7 +123,7 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
/* Match canonical regex */
dfa =
- GNUNET_REGEX_construct_dfa (canonical_regex, strlen (canonical_regex),
+ REGEX_ITERNAL_construct_dfa (canonical_regex, strlen (canonical_regex),
0);
if (NULL == dfa)
{
@@ -131,8 +131,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len,
goto error;
}
- eval_canonical = GNUNET_REGEX_eval (dfa, matching_str);
- GNUNET_REGEX_automaton_destroy (dfa);
+ eval_canonical = REGEX_ITERNAL_eval (dfa, matching_str);
+ REGEX_ITERNAL_automaton_destroy (dfa);
if (0 != regcomp (&rx, canonical_regex, REG_EXTENDED))
{
@@ -192,7 +192,7 @@ error:
* @return 0 on successfull, non 0 otherwise
*/
int
-test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx,
+test_automaton (struct REGEX_ITERNAL_Automaton *a, regex_t * rx,
struct Regex_String_Pair *rxstr)
{
int result;
@@ -212,7 +212,7 @@ test_automaton (struct GNUNET_REGEX_Automaton *a, regex_t * rx,
for (i = 0; i < rxstr->string_count; i++)
{
- eval = GNUNET_REGEX_eval (a, rxstr->strings[i]);
+ eval = REGEX_ITERNAL_eval (a, rxstr->strings[i]);
eval_check = regexec (rx, rxstr->strings[i], 1, matchptr, 0);
/* 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,
"string: %s\nexpected result: %i\n"
"gnunet regex: %i\nglibc regex: %i\nglibc error: %s\n"
"rm_so: %i\nrm_eo: %i\n\n", rxstr->regex,
- GNUNET_REGEX_get_canonical_regex (a), rxstr->strings[i],
+ REGEX_ITERNAL_get_canonical_regex (a), rxstr->strings[i],
rxstr->expected_results[i], eval, eval_check, error,
matchptr[0].rm_so, matchptr[0].rm_eo);
}
@@ -246,7 +246,7 @@ main (int argc, char *argv[])
{
GNUNET_log_setup ("test-regex", "WARNING", NULL);
- struct GNUNET_REGEX_Automaton *a;
+ struct REGEX_ITERNAL_Automaton *a;
regex_t rx;
int i;
int check_nfa;
@@ -336,19 +336,19 @@ main (int argc, char *argv[])
}
/* NFA test */
- a = GNUNET_REGEX_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex));
+ a = REGEX_ITERNAL_construct_nfa (rxstr[i].regex, strlen (rxstr[i].regex));
check_nfa += test_automaton (a, &rx, &rxstr[i]);
- GNUNET_REGEX_automaton_destroy (a);
+ REGEX_ITERNAL_automaton_destroy (a);
/* DFA test */
- a = GNUNET_REGEX_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
+ a = REGEX_ITERNAL_construct_dfa (rxstr[i].regex, strlen (rxstr[i].regex), 0);
check_dfa += test_automaton (a, &rx, &rxstr[i]);
- check_proof = GNUNET_strdup (GNUNET_REGEX_get_canonical_regex (a));
- GNUNET_REGEX_automaton_destroy (a);
+ check_proof = GNUNET_strdup (REGEX_ITERNAL_get_canonical_regex (a));
+ REGEX_ITERNAL_automaton_destroy (a);
- a = GNUNET_REGEX_construct_dfa (check_proof, strlen (check_proof), 0);
+ a = REGEX_ITERNAL_construct_dfa (check_proof, strlen (check_proof), 0);
check_dfa += test_automaton (a, &rx, &rxstr[i]);
- GNUNET_REGEX_automaton_destroy (a);
+ REGEX_ITERNAL_automaton_destroy (a);
if (0 != check_dfa)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check_proof: %s\n", check_proof);
GNUNET_free_non_null (check_proof);