diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-06-27 16:13:48 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-06-27 16:13:48 +0000 |
commit | 24f2c9d570bd181c622955506f6ecc000d5b2a98 (patch) | |
tree | 9bfb6f07aae4ce7e6df353becbb371fb63c24651 /src/regex/regex_internal.h | |
parent | 039c0a8e1c193c692c4f492d75cc2b98643203ef (diff) | |
download | gnunet-24f2c9d570bd181c622955506f6ecc000d5b2a98.tar.gz gnunet-24f2c9d570bd181c622955506f6ecc000d5b2a98.zip |
new and improved tests
Diffstat (limited to 'src/regex/regex_internal.h')
-rw-r--r-- | src/regex/regex_internal.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h new file mode 100644 index 000000000..8ea597d40 --- /dev/null +++ b/src/regex/regex_internal.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file src/regex/regex_internal.h | ||
22 | * @brief common internal definitions for regex library | ||
23 | * @author Maximilian Szengel | ||
24 | */ | ||
25 | #ifndef REGEX_INTERNAL_H | ||
26 | #define REGEX_INTERNAL_H | ||
27 | |||
28 | #include "gnunet_regex_lib.h" | ||
29 | |||
30 | #ifdef __cplusplus | ||
31 | extern "C" | ||
32 | { | ||
33 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
34 | } | ||
35 | #endif | ||
36 | #endif | ||
37 | |||
38 | /** | ||
39 | * char array of literals that are allowed inside a regex (apart from the | ||
40 | * operators) | ||
41 | */ | ||
42 | #define ALLOWED_LITERALS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Get the canonical regex of the given automaton. | ||
47 | * When constructing the automaton a proof is computed for each state, | ||
48 | * consisting of the regular expression leading to this state. A complete | ||
49 | * regex for the automaton can be computed by combining these proofs. | ||
50 | * As of now this function is only useful for testing. | ||
51 | * | ||
52 | * @param a automaton for which the canonical regex should be returned. | ||
53 | * | ||
54 | * @return | ||
55 | */ | ||
56 | const char * | ||
57 | GNUNET_REGEX_get_canonical_regex (struct GNUNET_REGEX_Automaton *a); | ||
58 | |||
59 | |||
60 | /** | ||
61 | * Generate a (pseudo) random regular expression of length 'rx_length', as well | ||
62 | * as a (optional) string that will be matched by the generated regex. The | ||
63 | * returned regex needs to be freed. | ||
64 | * | ||
65 | * @param rx_length length of the random regex. | ||
66 | * @param matching_str (optional) pointer to a string that will contain a string | ||
67 | * that will be matched by the generated regex, if | ||
68 | * 'matching_str' pointer was not NULL. | ||
69 | * | ||
70 | * @return NULL if 'rx_length' is 0, a random regex of length 'rx_length', which | ||
71 | * needs to be freed, otherwise. | ||
72 | */ | ||
73 | char * | ||
74 | GNUNET_REGEX_generate_random_regex (size_t rx_length, char *matching_str); | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Generate a random string of maximum length 'max_len' that only contains literals allowed | ||
79 | * in a regular expression. The string might be 0 chars long but is garantueed | ||
80 | * to be shorter or equal to 'max_len'. | ||
81 | * | ||
82 | * @param max_len maximum length of the string that should be generated. | ||
83 | * | ||
84 | * @return random string that needs to be freed. | ||
85 | */ | ||
86 | char * | ||
87 | GNUNET_REGEX_generate_random_string (size_t max_len); | ||
88 | |||
89 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
90 | { | ||
91 | #endif | ||
92 | #ifdef __cplusplus | ||
93 | } | ||
94 | #endif | ||
95 | |||
96 | #endif | ||