#include "regex_internal_lib.h"
Go to the source code of this file.
Enumerations | |
enum | REGEX_TEST_GraphSavingOptions { REGEX_TEST_GRAPH_DEFAULT = 0 , REGEX_TEST_GRAPH_VERBOSE = 1 , REGEX_TEST_GRAPH_COLORING = 2 } |
Options for graph creation function REGEX_TEST_automaton_save_graph. More... | |
Functions | |
char * | REGEX_TEST_combine (char *const regexes[], unsigned int alphabet_size) |
Combine an array of regexes into a single prefix-shared regex. More... | |
char ** | REGEX_TEST_read_from_file (const char *filename) |
Read a set of regexes from a file, one per line and return them in an array suitable for REGEX_TEST_combine. More... | |
void | REGEX_TEST_free_from_file (char **regexes) |
Free all memory reserved for a set of regexes created by read_from_file. More... | |
char * | REGEX_TEST_generate_random_regex (size_t rx_length, char *matching_str) |
Generate a (pseudo) random regular expression of length 'rx_length', as well as a (optional) string that will be matched by the generated regex. More... | |
char * | REGEX_TEST_generate_random_string (size_t max_len) |
Generate a random string of maximum length 'max_len' that only contains literals allowed in a regular expression. More... | |
void | REGEX_TEST_automaton_save_graph (struct REGEX_INTERNAL_Automaton *a, const char *filename, enum REGEX_TEST_GraphSavingOptions options) |
Save the given automaton as a GraphViz dot file. More... | |
Options for graph creation function REGEX_TEST_automaton_save_graph.
Definition at line 116 of file regex_test_lib.h.
char * REGEX_TEST_combine | ( | char *const | regexes[], |
unsigned int | alphabet_size | ||
) |
Combine an array of regexes into a single prefix-shared regex.
Returns a prefix-combine regex that matches the same strings as any of the original regexes.
WARNING: only useful for reading specific regexes for specific applications, namely the gnunet-regex-profiler / gnunet-regex-daemon. This function DOES NOT support arbitrary regex combining.
regexes | A NULL-terminated array of regexes. |
alphabet_size | Size of the alphabet the regex uses. |
Definition at line 545 of file regex_test_lib.c.
References ctx, debugctx(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, new_regex_ctx(), regex_add(), regex_combine(), and regex_ctx_destroy().
Referenced by main(), and run().
char ** REGEX_TEST_read_from_file | ( | const char * | filename | ) |
Read a set of regexes from a file, one per line and return them in an array suitable for REGEX_TEST_combine.
The array must be free'd using REGEX_TEST_free_from_file.
filename | Name of the file containing the regexes. |
Definition at line 581 of file regex_test_lib.c.
References removetrailingwhitespace::f, filename, GNUNET_array_grow, GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_handle_size(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_realloc, and size.
Referenced by main(), and run().
void REGEX_TEST_free_from_file | ( | char ** | regexes | ) |
Free all memory reserved for a set of regexes created by read_from_file.
regexes | NULL-terminated array of regexes. |
Definition at line 652 of file regex_test_lib.c.
References GNUNET_free.
Referenced by main(), and run().
char * REGEX_TEST_generate_random_regex | ( | size_t | rx_length, |
char * | matching_str | ||
) |
Generate a (pseudo) random regular expression of length 'rx_length', as well as a (optional) string that will be matched by the generated regex.
The returned regex needs to be freed.
rx_length | length of the random regex. |
matching_str | (optional) pointer to a string that will contain a string that will be matched by the generated regex, if 'matching_str' pointer was not NULL. |
The returned regex needs to be freed.
rx_length | length of the random regex. |
matching_str | (optional) pointer to a string that will contain a string that will be matched by the generated regex, if 'matching_str' pointer was not NULL. Make sure you allocated at least rx_length+1 bytes for this string. |
Definition at line 64 of file regex_test_random.c.
References get_random_literal(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), and GNUNET_malloc.
char * REGEX_TEST_generate_random_string | ( | size_t | max_len | ) |
Generate a random string of maximum length 'max_len' that only contains literals allowed in a regular expression.
The string might be 0 chars long but is garantueed to be shorter or equal to 'max_len'.
max_len | maximum length of the string that should be generated. |
Definition at line 155 of file regex_test_random.c.
References get_random_literal(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_malloc, and GNUNET_strdup.
void REGEX_TEST_automaton_save_graph | ( | struct REGEX_INTERNAL_Automaton * | a, |
const char * | filename, | ||
enum REGEX_TEST_GraphSavingOptions | options | ||
) |
Save the given automaton as a GraphViz dot file.
a | the automaton to be saved. |
filename | where to save the file. |
options | options for graph generation that include coloring or verbose mode |
Definition at line 270 of file regex_test_graph.c.
References automaton_save_graph_step(), ctx, end, filename, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_YES, options, REGEX_INTERNAL_automaton_traverse(), REGEX_TEST_GRAPH_COLORING, REGEX_TEST_GRAPH_VERBOSE, scc_tarjan(), start, and REGEX_INTERNAL_Automaton::start.