30#define LOG(kind, ...) GNUNET_log_from (kind, "regex-bck", __VA_ARGS__)
120 if ((NULL ==
proof) || (NULL ==
key))
167 "edge %.*s [%u]: %s\n",
172 if (NULL ==
ctx->xquery)
174 if (strlen (
ctx->xquery) < len)
176 if (0 == strncmp (
ctx->xquery, token, len))
201 if ((NULL != query) &&
212 " out! Is accepting: %u, xquery %p\n",
237 uint16_t num_destinations;
250 edges = (
const struct EdgeInfo *) &destinations[num_destinations];
254 if (block_len < total)
274 uint16_t num_destinations;
290 edges = (
const struct EdgeInfo *) &destinations[num_destinations];
291 aux = (
const char *) &edges[num_edges];
301 total += ntohs (edges[n].token_length);
304 fprintf (stderr,
"Expected %u, got %u\n",
306 (
unsigned int) total);
312 "Start iterating block of size %lu, proof %u, off %lu edges %u\n",
313 (
unsigned long)
size, len, (
unsigned long) off, n);
318 "Edge %u/%u, off %lu tokenlen %u (%.*s)\n",
320 ntohs (edges[n].token_length), ntohs (edges[n].token_length),
322 if (NULL != iterator)
325 ntohs (edges[n].token_length),
326 &destinations[ntohs (
327 edges[n].destination_index)]))
329 off += ntohs (edges[n].token_length);
354 uint16_t destination_indices[num_edges];
361 unsigned int unique_destinations;
366 len = strlen (
proof);
367 if (len > UINT16_MAX)
372 unique_destinations = 0;
376 slen = strlen (edges[i].label);
377 if (slen > UINT16_MAX)
383 for (j = 0; j < unique_destinations; j++)
384 if (0 == memcmp (&destinations[j],
385 &edges[i].destination,
393 destination_indices[i] = j;
394 if (j == unique_destinations)
395 destinations[unique_destinations++] = edges[i].
destination;
411 * unique_destinations);
412 edgeinfos = (
struct EdgeInfo *) &dests[unique_destinations];
413 aux = (
char *) &edgeinfos[num_edges];
416 for (i = 0; i < num_edges; i++)
418 slen = strlen (edges[i].label);
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static char * res
Currently read line or NULL on EOF.
#define GNUNET_CONSTANTS_MAX_BLOCK_SIZE
Largest block that can be stored in the DHT.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_log(kind,...)
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_PACKED
gcc-ism to get packed structs.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_malloc(size)
Wrapper around malloc.
static unsigned int size
Size of the "table".
static int check_edge(void *cls, const char *token, size_t len, const struct GNUNET_HashCode *key)
Iterator over all edges in a block, checking for a presence of a given query.
int REGEX_BLOCK_iterate(const struct RegexBlock *block, size_t size, REGEX_INTERNAL_EgdeIterator iterator, void *iter_cls)
Iterate over all edges of a block of a regex state.
int REGEX_BLOCK_get_key(const struct RegexBlock *block, size_t block_len, struct GNUNET_HashCode *key)
Obtain the key that a particular block is to be stored under.
struct RegexBlock * REGEX_BLOCK_create(const char *proof, unsigned int num_edges, const struct REGEX_BLOCK_Edge *edges, int accepting, size_t *rsize)
Construct a regex block to be stored in the DHT.
int REGEX_BLOCK_check_proof(const char *proof, size_t proof_len, const struct GNUNET_HashCode *key)
Check if the given 'proof' matches the given 'key'.
GNUNET_NETWORK_STRUCT_END int GNUNET_BLOCK_is_accepting(const struct RegexBlock *block, size_t size)
Test if this block is marked as being an accept state.
int REGEX_BLOCK_check(const struct RegexBlock *block, size_t size, const struct GNUNET_HashCode *query, const char *xquery)
Check if the regex block is well formed, including all edges.
common function to manipulate blocks stored by regex in the DHT
int(* REGEX_INTERNAL_EgdeIterator)(void *cls, const char *token, size_t len, const struct GNUNET_HashCode *key)
Iterator over edges in a block.
Struct to keep track of the xquery while iterating all the edges in a block.
const char * xquery
Xquery: string we are looking for.
int found
Has any edge matched the xquery so far? (GNUNET_OK / GNUNET_NO)
Information for each edge.
uint16_t destination_index
Index of the destination of this edge in the unique destinations array.
uint16_t token_length
Number of bytes the token for this edge takes in the token area.
struct GNUNET_HashCode destination
Destination of the edge.
Block to announce a regex state.
uint16_t num_destinations
Number of unique destinations reachable from this state.
uint16_t proof_len
Length of the proof regex string.
int16_t is_accepting
Is this state an accepting state?
uint16_t num_edges
Number of edges parting from this state.