diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-06-27 11:31:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-06-27 11:31:48 +0000 |
commit | d1b1c834fbb65d70fca837e1ab742e71e16adf50 (patch) | |
tree | ff3c5f148bee8c53a8a36447a8bd5535ed5573c2 /src/regex/regex_block_lib.c | |
parent | 1350dd76782b3cea091cd3c41dc53a6fc244414b (diff) |
-move struct RegexBlock into regex_block_lib
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'. |