aboutsummaryrefslogtreecommitdiff
path: root/src/regex/regex_block_lib.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-06-27 11:31:48 +0000
committerChristian Grothoff <christian@grothoff.org>2013-06-27 11:31:48 +0000
commitd1b1c834fbb65d70fca837e1ab742e71e16adf50 (patch)
treeff3c5f148bee8c53a8a36447a8bd5535ed5573c2 /src/regex/regex_block_lib.c
parent1350dd76782b3cea091cd3c41dc53a6fc244414b (diff)
downloadgnunet-d1b1c834fbb65d70fca837e1ab742e71e16adf50.tar.gz
gnunet-d1b1c834fbb65d70fca837e1ab742e71e16adf50.zip
-move struct RegexBlock into regex_block_lib
Diffstat (limited to 'src/regex/regex_block_lib.c')
-rw-r--r--src/regex/regex_block_lib.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c
index 01c591caa..842c9f366 100644
--- a/src/regex/regex_block_lib.c
+++ b/src/regex/regex_block_lib.c
@@ -28,6 +28,68 @@
28 28
29#define LOG(kind,...) GNUNET_log_from (kind,"regex-bck",__VA_ARGS__) 29#define LOG(kind,...) GNUNET_log_from (kind,"regex-bck",__VA_ARGS__)
30 30
31GNUNET_NETWORK_STRUCT_BEGIN
32
33/**
34 * @brief Block to announce a regex state.
35 */
36struct RegexBlock
37{
38
39 /**
40 * Length of the proof regex string.
41 */
42 uint16_t proof_len GNUNET_PACKED;
43
44 /**
45 * Is this state an accepting state?
46 */
47 int16_t is_accepting GNUNET_PACKED;
48
49 /**
50 * Numer of edges parting from this state.
51 */
52 uint32_t n_edges GNUNET_PACKED;
53
54 /* char proof[n_proof] */
55 /* struct RegexEdge edges[n_edges] */
56};
57
58
59/**
60 * @brief A RegexBlock contains one or more of this struct in the payload.
61 */
62struct RegexEdge
63{
64 /**
65 * Destination of this edge.
66 */
67 struct GNUNET_HashCode key;
68
69 /**
70 * Length of the token towards the new state.
71 */
72 uint32_t n_token GNUNET_PACKED;
73
74 /* char token[n_token] */
75};
76
77
78GNUNET_NETWORK_STRUCT_END
79
80
81/**
82 * Test if this block is marked as being an accept state.
83 *
84 * @param block block to test
85 * @return GNUNET_YES if the block is accepting, GNUNET_NO if not
86 */
87int
88GNUNET_BLOCK_is_accepting (const struct RegexBlock *block)
89{
90 return ntohs (block->is_accepting);
91}
92
31 93
32/** 94/**
33 * Check if the given 'proof' matches the given 'key'. 95 * Check if the given 'proof' matches the given 'key'.