-move struct RegexBlock into regex_block_lib
[oweals/gnunet.git] / src / regex / regex_block_lib.c
index 01c591caa0a310289ee582bf2f5640bbe6b8c5e3..842c9f36669e83f3aa5a6e28549145ea0e91ec22 100644 (file)
 
 #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'.