aboutsummaryrefslogtreecommitdiff
path: root/src/regex/regex_test_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-20 08:55:56 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-20 08:55:56 +0000
commit5f7a6c8f6816a826a2dd93eadc5039733f7db606 (patch)
tree3c22c8ff3436cc3140dfb1b24813ed4362330879 /src/regex/regex_test_lib.h
parent21a2b4f95b4488645ba5a6254fcb8919c4915f73 (diff)
downloadgnunet-5f7a6c8f6816a826a2dd93eadc5039733f7db606.tar.gz
gnunet-5f7a6c8f6816a826a2dd93eadc5039733f7db606.zip
moving functions for testing and evaluation and experiments to the test library, minimizing the internal library, renaming files according to which library they belong to
Diffstat (limited to 'src/regex/regex_test_lib.h')
-rw-r--r--src/regex/regex_test_lib.h79
1 files changed, 75 insertions, 4 deletions
diff --git a/src/regex/regex_test_lib.h b/src/regex/regex_test_lib.h
index 418f47dba..107c2ffce 100644
--- a/src/regex/regex_test_lib.h
+++ b/src/regex/regex_test_lib.h
@@ -20,15 +20,15 @@
20/** 20/**
21 * @file src/regex/regex_test_lib.h 21 * @file src/regex/regex_test_lib.h
22 * @brief library to read regexes representing IP networks from a file. 22 * @brief library to read regexes representing IP networks from a file.
23 * and simplyfinying the into one big regex, in order to run 23 * and simplifying the into one big regex, in order to run
24 * tests (regex performance, mesh profiler). 24 * tests (regex performance, regex profiler).
25 * @author Bertlomiej Polot 25 * @author Bertlomiej Polot
26 *
27 */ 26 */
28 27
29#ifndef REGEX_ITERNAL_TEST_LIB_H 28#ifndef REGEX_ITERNAL_TEST_LIB_H
30#define REGEX_ITERNAL_TEST_LIB_H 29#define REGEX_ITERNAL_TEST_LIB_H
31 30
31#include "regex_internal_lib.h"
32 32
33#ifdef __cplusplus 33#ifdef __cplusplus
34extern "C" 34extern "C"
@@ -48,6 +48,7 @@ extern "C"
48char * 48char *
49REGEX_ITERNAL_combine(char * const regexes[]); 49REGEX_ITERNAL_combine(char * const regexes[]);
50 50
51
51/** 52/**
52 * Read a set of regexes from a file, one per line and return them in an array 53 * Read a set of regexes from a file, one per line and return them in an array
53 * suitable for REGEX_ITERNAL_combine. 54 * suitable for REGEX_ITERNAL_combine.
@@ -69,6 +70,76 @@ REGEX_ITERNAL_read_from_file (const char *filename);
69void 70void
70REGEX_ITERNAL_free_from_file (char **regexes); 71REGEX_ITERNAL_free_from_file (char **regexes);
71 72
73
74/**
75 * Generate a (pseudo) random regular expression of length 'rx_length', as well
76 * as a (optional) string that will be matched by the generated regex. The
77 * returned regex needs to be freed.
78 *
79 * @param rx_length length of the random regex.
80 * @param matching_str (optional) pointer to a string that will contain a string
81 * that will be matched by the generated regex, if
82 * 'matching_str' pointer was not NULL.
83 *
84 * @return NULL if 'rx_length' is 0, a random regex of length 'rx_length', which
85 * needs to be freed, otherwise.
86 */
87char *
88REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str);
89
90
91/**
92 * Generate a random string of maximum length 'max_len' that only contains literals allowed
93 * in a regular expression. The string might be 0 chars long but is garantueed
94 * to be shorter or equal to 'max_len'.
95 *
96 * @param max_len maximum length of the string that should be generated.
97 *
98 * @return random string that needs to be freed.
99 */
100char *
101REGEX_ITERNAL_generate_random_string (size_t max_len);
102
103
104/**
105 * Options for graph creation function
106 * REGEX_ITERNAL_automaton_save_graph.
107 */
108enum REGEX_ITERNAL_GraphSavingOptions
109{
110 /**
111 * Default. Do nothing special.
112 */
113 REGEX_ITERNAL_GRAPH_DEFAULT = 0,
114
115 /**
116 * The generated graph will include extra information such as the NFA states
117 * that were used to generate the DFA state.
118 */
119 REGEX_ITERNAL_GRAPH_VERBOSE = 1,
120
121 /**
122 * Enable graph coloring. Will color each SCC in a different color.
123 */
124 REGEX_ITERNAL_GRAPH_COLORING = 2
125};
126
127
128/**
129 * Save the given automaton as a GraphViz dot file.
130 *
131 * @param a the automaton to be saved.
132 * @param filename where to save the file.
133 * @param options options for graph generation that include coloring or verbose
134 * mode
135 */
136void
137REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a,
138 const char *filename,
139 enum REGEX_ITERNAL_GraphSavingOptions options);
140
141
142
72#if 0 /* keep Emacsens' auto-indent happy */ 143#if 0 /* keep Emacsens' auto-indent happy */
73{ 144{
74 #endif 145 #endif
@@ -77,4 +148,4 @@ REGEX_ITERNAL_free_from_file (char **regexes);
77#endif 148#endif
78 149
79/* end of regex_internal_lib.h */ 150/* end of regex_internal_lib.h */
80#endif \ No newline at end of file 151#endif