aboutsummaryrefslogtreecommitdiff
path: root/src/regex/gnunet-daemon-regexprofiler.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-04-22 15:20:46 +0000
committerBart Polot <bart@net.in.tum.de>2013-04-22 15:20:46 +0000
commite6a98706bcdbe18ca3432dbc234c17ff893e7097 (patch)
tree227ff3364106c9e9b7754aafdaa31ba363686fcb /src/regex/gnunet-daemon-regexprofiler.c
parentbf0fb9e89a461e7aa874f11f12c81bbd83fabfbd (diff)
- add disk scan
Diffstat (limited to 'src/regex/gnunet-daemon-regexprofiler.c')
-rw-r--r--src/regex/gnunet-daemon-regexprofiler.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c
index b7054e2c70..4fb620b578 100644
--- a/src/regex/gnunet-daemon-regexprofiler.c
+++ b/src/regex/gnunet-daemon-regexprofiler.c
@@ -267,6 +267,29 @@ load_regexes (const char *filename, char **rx)
return rx_cnt;
}
+/**
+ * Scan through the policy_dir looking for the n-th filename.
+ *
+ * @param cls Closure (target number n).
+ * @param filename complete filename (absolute path).
+ * @return GNUNET_OK to continue to iterate,
+ * GNUNET_NO to stop when found
+ */
+static int
+scan (void *cls, const char *filename)
+{
+ long n = (long) cls;
+ static long c = 0;
+
+ if (c == n)
+ {
+ policy_filename = GNUNET_strdup (filename);
+ return GNUNET_NO;
+ }
+ c++;
+ return GNUNET_OK;
+}
+
/**
* @brief Main function that will be run by the scheduler.
@@ -363,6 +386,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
}
/* Read regexes from policy files */
+ GNUNET_assert (-1 != GNUNET_DISK_directory_scan (policy_dir, &scan, peer_id));
if (0 == load_regexes (policy_filename, &regex))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,