$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/testbed/libgnunettestbed.la \
$(top_builddir)/src/regex/libgnunetregex.la \
+ $(top_builddir)/src/regex/libgnunetregextest.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la
gnunet_regex_profiler_DEPENDENCIES = \
$(top_builddir)/src/arm/libgnunetarm.la \
$(top_builddir)/src/dht/libgnunetdht.la \
- libgnunetregex.la
+ libgnunetregex.la \
+ libgnunetregextest.la
+
gnunet_daemon_regexprofiler_SOURCES = \
gnunet-daemon-regexprofiler.c
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/regex/libgnunetregex.la \
+ $(top_builddir)/src/regex/libgnunetregextest.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la
gnunet_daemon_regexprofiler_DEPENDENCIES = \
$(top_builddir)/src/dht/libgnunetdht.la \
+ libgnunetregextest.la \
libgnunetregex.la
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_regex_lib.h"
+#include "regex_test_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_statistics_service.h"
}
-/**
- * Load regular expressions from filename into 'rxes' array. Array needs to be freed.
- *
- * @param filename filename of the file containing the regexes, one per line.
- * @param rx string with the union of all regular expressions.
- *
- * @return number of regular expressions read from filename and in rxes array.
- * FIXME use load regex lib function
- */
-static unsigned int
-load_regexes (const char *filename, char **rx)
-{
- char *data;
- char *buf;
- uint64_t filesize;
- unsigned int offset;
- unsigned int rx_cnt;
-
- if (GNUNET_YES != GNUNET_DISK_file_test (policy_filename))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not find policy file %s\n", policy_filename);
- return 0;
- }
- if (GNUNET_OK != GNUNET_DISK_file_size (policy_filename, &filesize, GNUNET_YES, GNUNET_YES))
- filesize = 0;
- if (0 == filesize)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Policy file %s is empty.\n", policy_filename);
- return 0;
- }
- data = GNUNET_malloc (filesize);
- if (filesize != GNUNET_DISK_fn_read (policy_filename, data, filesize))
- {
- GNUNET_free (data);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not read policy file %s.\n",
- policy_filename);
- return 0;
- }
- buf = data;
- offset = 0;
- rx_cnt = 0;
- while (offset < (filesize - 1))
- {
- offset++;
- if ((data[offset] == '\n') && (buf != &data[offset]))
- {
- data[offset] = '|';
- buf = &data[offset + 1];
- rx_cnt++;
- }
- else if ((data[offset] == '\n') || (data[offset] == '\0'))
- buf = &data[offset + 1];
- }
- data[offset] = '\0';
- *rx = data;
-
- return rx_cnt;
-}
-
/**
* Scan through the policy_dir looking for the n-th filename.
*
const struct GNUNET_CONFIGURATION_Handle *cfg_)
{
char *regex = NULL;
+ char **components;
char *policy_dir;
long long unsigned int peer_id;
/* Read regexes from policy files */
GNUNET_assert (-1 != GNUNET_DISK_directory_scan (policy_dir, &scan,
(void *) (long) peer_id));
- if (0 == load_regexes (policy_filename, ®ex))
+ if (NULL == (components = GNUNET_REGEX_read_from_file (policy_filename)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Policy file %s contains no policies. Exiting.\n",
GNUNET_SCHEDULER_shutdown ();
return;
}
+ regex = GNUNET_REGEX_combine (components);
+ GNUNET_REGEX_free_from_file (components);
/* Announcing regexes from policy_filename */
- GNUNET_asprintf (&rx_with_pfx, "%s(%s)", regex_prefix, regex);
+ GNUNET_asprintf (&rx_with_pfx, "%s(%s)(0|1)*", regex_prefix, regex);
announce_regex (rx_with_pfx);
GNUNET_free (regex);
GNUNET_free (rx_with_pfx);