aboutsummaryrefslogtreecommitdiff
path: root/src/regex/regex_block_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-05-22 13:26:36 +0000
committerChristian Grothoff <christian@grothoff.org>2015-05-22 13:26:36 +0000
commitbad29fd9a1cc3b1c7df7b992212568918c961b52 (patch)
tree692be9fda2a949f844690e360ce9d6d5f50f8916 /src/regex/regex_block_lib.h
parent7b636c9e74039f14b25e70d1050432d9782efef9 (diff)
downloadgnunet-bad29fd9a1cc3b1c7df7b992212568918c961b52.tar.gz
gnunet-bad29fd9a1cc3b1c7df7b992212568918c961b52.zip
add logging and in particular checks to make sure no '.' wildcards are during initial transitions of the DFA
Diffstat (limited to 'src/regex/regex_block_lib.h')
-rw-r--r--src/regex/regex_block_lib.h55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/regex/regex_block_lib.h b/src/regex/regex_block_lib.h
index e5685ba9a..20cfd6ceb 100644
--- a/src/regex/regex_block_lib.h
+++ b/src/regex/regex_block_lib.h
@@ -52,7 +52,8 @@ struct RegexBlock;
52struct REGEX_BLOCK_Edge 52struct REGEX_BLOCK_Edge
53{ 53{
54 /** 54 /**
55 * Label of the edge. FIXME: might want to not consume exactly multiples of 8 bits, need length! 55 * Label of the edge. FIXME: might want to not consume exactly
56 * multiples of 8 bits, need length!
56 */ 57 */
57 const char *label; 58 const char *label;
58 59
@@ -67,10 +68,9 @@ struct REGEX_BLOCK_Edge
67 * Check if the given 'proof' matches the given 'key'. 68 * Check if the given 'proof' matches the given 'key'.
68 * 69 *
69 * @param proof partial regex of a state 70 * @param proof partial regex of a state
70 * @param proof_len number of bytes in 'proof' 71 * @param proof_len number of bytes in @a proof
71 * @param key hash of a state. 72 * @param key hash of a state.
72 * 73 * @return #GNUNET_OK if the proof is valid for the given key.
73 * @return GNUNET_OK if the proof is valid for the given key.
74 */ 74 */
75int 75int
76REGEX_BLOCK_check_proof (const char *proof, 76REGEX_BLOCK_check_proof (const char *proof,
@@ -82,14 +82,13 @@ REGEX_BLOCK_check_proof (const char *proof,
82 * Check if the regex block is well formed, including all edges. 82 * Check if the regex block is well formed, including all edges.
83 * 83 *
84 * @param block The start of the block. 84 * @param block The start of the block.
85 * @param size The size of the block. 85 * @param size The size of the @a block.
86 * @param query the query for the block 86 * @param query the query for the @a block
87 * @param xquery String describing the edge we are looking for. 87 * @param xquery String describing the edge we are looking for.
88 * Can be NULL in case this is a put block. 88 * Can be NULL in case this is a put block.
89 * 89 * @return #GNUNET_OK in case it's fine.
90 * @return GNUNET_OK in case it's fine. 90 * #GNUNET_NO in case the xquery exists and is not found (IRRELEVANT).
91 * GNUNET_NO in case the xquery exists and is not found (IRRELEVANT). 91 * #GNUNET_SYSERR if the block is invalid.
92 * GNUNET_SYSERR if the block is invalid.
93 */ 92 */
94int 93int
95REGEX_BLOCK_check (const struct RegexBlock *block, 94REGEX_BLOCK_check (const struct RegexBlock *block,
@@ -107,13 +106,13 @@ REGEX_BLOCK_check (const struct RegexBlock *block,
107 * @param token Token that follows to next state. 106 * @param token Token that follows to next state.
108 * @param len Length of token. 107 * @param len Length of token.
109 * @param key Hash of next state. 108 * @param key Hash of next state.
110 * 109 * @return #GNUNET_YES if should keep iterating, #GNUNET_NO otherwise.
111 * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise.
112 */ 110 */
113typedef int (*REGEX_INTERNAL_EgdeIterator)(void *cls, 111typedef int
114 const char *token, 112(*REGEX_INTERNAL_EgdeIterator)(void *cls,
115 size_t len, 113 const char *token,
116 const struct GNUNET_HashCode *key); 114 size_t len,
115 const struct GNUNET_HashCode *key);
117 116
118 117
119/** 118/**
@@ -122,29 +121,29 @@ typedef int (*REGEX_INTERNAL_EgdeIterator)(void *cls,
122 * @param block Block to iterate over. 121 * @param block Block to iterate over.
123 * @param size Size of block. 122 * @param size Size of block.
124 * @param iterator Function to call on each edge in the block. 123 * @param iterator Function to call on each edge in the block.
125 * @param iter_cls Closure for the iterator. 124 * @param iter_cls Closure for the @a iterator.
126 * 125 * @return #GNUNET_SYSERR if an error has been encountered.
127 * @return GNUNET_SYSERR if an error has been encountered. 126 * #GNUNET_OK if no error has been encountered.
128 * GNUNET_OK if no error has been encountered.
129 * Note that if the iterator stops the iteration by returning 127 * Note that if the iterator stops the iteration by returning
130 * GNUNET_NO, the block will no longer be checked for further errors. 128 * #GNUNET_NO, the block will no longer be checked for further errors.
131 * The return value will be GNUNET_OK meaning that no errors were 129 * The return value will be #GNUNET_OK meaning that no errors were
132 * found until the edge last notified to the iterator, but there might 130 * found until the edge last notified to the iterator, but there might
133 * be errors in further edges. 131 * be errors in further edges.
134 */ 132 */
135int 133int
136REGEX_BLOCK_iterate (const struct RegexBlock *block, 134REGEX_BLOCK_iterate (const struct RegexBlock *block,
137 size_t size, 135 size_t size,
138 REGEX_INTERNAL_EgdeIterator iterator, 136 REGEX_INTERNAL_EgdeIterator iterator,
139 void *iter_cls); 137 void *iter_cls);
138
140 139
141/** 140/**
142 * Obtain the key that a particular block is to be stored under. 141 * Obtain the key that a particular block is to be stored under.
143 * 142 *
144 * @param block block to get the key from 143 * @param block block to get the key from
145 * @param block_len number of bytes in block 144 * @param block_len number of bytes in @a block
146 * @param key where to store the key 145 * @param key where to store the key
147 * @return GNUNET_OK on success, GNUNET_SYSERR if the block is malformed 146 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block is malformed
148 */ 147 */
149int 148int
150REGEX_BLOCK_get_key (const struct RegexBlock *block, 149REGEX_BLOCK_get_key (const struct RegexBlock *block,
@@ -157,7 +156,7 @@ REGEX_BLOCK_get_key (const struct RegexBlock *block,
157 * 156 *
158 * @param block block to test 157 * @param block block to test
159 * @param size number of bytes in block 158 * @param size number of bytes in block
160 * @return GNUNET_YES if the block is accepting, GNUNET_NO if not 159 * @return #GNUNET_YES if the block is accepting, #GNUNET_NO if not
161 */ 160 */
162int 161int
163GNUNET_BLOCK_is_accepting (const struct RegexBlock *block, 162GNUNET_BLOCK_is_accepting (const struct RegexBlock *block,