diff options
Diffstat (limited to 'src/regex/regex_block_lib.c')
-rw-r--r-- | src/regex/regex_block_lib.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index 01c591caa0..842c9f3666 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c @@ -28,6 +28,68 @@ #define LOG(kind,...) GNUNET_log_from (kind,"regex-bck",__VA_ARGS__) +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * @brief Block to announce a regex state. + */ +struct RegexBlock +{ + + /** + * Length of the proof regex string. + */ + uint16_t proof_len GNUNET_PACKED; + + /** + * Is this state an accepting state? + */ + int16_t is_accepting GNUNET_PACKED; + + /** + * Numer of edges parting from this state. + */ + uint32_t n_edges GNUNET_PACKED; + + /* char proof[n_proof] */ + /* struct RegexEdge edges[n_edges] */ +}; + + +/** + * @brief A RegexBlock contains one or more of this struct in the payload. + */ +struct RegexEdge +{ + /** + * Destination of this edge. + */ + struct GNUNET_HashCode key; + + /** + * Length of the token towards the new state. + */ + uint32_t n_token GNUNET_PACKED; + + /* char token[n_token] */ +}; + + +GNUNET_NETWORK_STRUCT_END + + +/** + * Test if this block is marked as being an accept state. + * + * @param block block to test + * @return GNUNET_YES if the block is accepting, GNUNET_NO if not + */ +int +GNUNET_BLOCK_is_accepting (const struct RegexBlock *block) +{ + return ntohs (block->is_accepting); +} + /** * Check if the given 'proof' matches the given 'key'. |