diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-04-18 10:07:28 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-04-18 10:07:28 +0000 |
commit | 82d41c577fba27be3798bc477d6e99d1fda40d49 (patch) | |
tree | eb4c47b7800ce6895603483cfa704b06f5480901 /src/regex | |
parent | 7e454dfc7e59450d4bfb68f1dd591cc687a7e221 (diff) | |
download | gnunet-82d41c577fba27be3798bc477d6e99d1fda40d49.tar.gz gnunet-82d41c577fba27be3798bc477d6e99d1fda40d49.zip |
- fixes, refactor
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 9e7e85909..07749c5ec 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -1222,37 +1222,44 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1222 | const struct GNUNET_CONFIGURATION_Handle *config) | 1222 | const struct GNUNET_CONFIGURATION_Handle *config) |
1223 | { | 1223 | { |
1224 | unsigned int nsearchstrs; | 1224 | unsigned int nsearchstrs; |
1225 | unsigned int i; | ||
1226 | char *hosts_file; | ||
1227 | char *strings_file; | ||
1225 | 1228 | ||
1226 | if (NULL == args[0]) | 1229 | if (NULL == config) |
1227 | { | 1230 | { |
1228 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1229 | _("No hosts-file specified on command line. Exiting.\n")); | 1232 | _("No configuration file given. Exiting\n")); |
1233 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1230 | return; | 1234 | return; |
1231 | } | 1235 | } |
1232 | if (NULL == args[1]) | 1236 | if (GNUNET_OK != |
1237 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", | ||
1238 | "REGEX_PREFIX", | ||
1239 | ®ex_prefix)) | ||
1233 | { | 1240 | { |
1234 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1235 | _("No policy directory specified on command line. Exiting.\n")); | 1242 | _("Configuration option \"regex_prefix\" missing. Exiting\n")); |
1243 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1236 | return; | 1244 | return; |
1237 | } | 1245 | } |
1238 | if (NULL == config) | 1246 | |
1247 | hosts_file = args[0]; | ||
1248 | if (NULL == hosts_file) | ||
1239 | { | 1249 | { |
1240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1250 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1241 | _("No configuration file given. Exiting\n")); | 1251 | _("No hosts-file specified on command line. Exiting.\n")); |
1242 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1243 | return; | 1252 | return; |
1244 | } | 1253 | } |
1245 | 1254 | policy_dir = args[1]; | |
1246 | if (GNUNET_OK != | 1255 | if (NULL == policy_dir) |
1247 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX", | ||
1248 | ®ex_prefix)) | ||
1249 | { | 1256 | { |
1250 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1251 | _("Configuration option \"regex_prefix\" missing. Exiting\n")); | 1258 | _("No policy directory specified on command line. Exiting.\n")); |
1252 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
1253 | return; | 1259 | return; |
1254 | } | 1260 | } |
1255 | 1261 | ||
1262 | |||
1256 | if ( (NULL != data_filename) && | 1263 | if ( (NULL != data_filename) && |
1257 | (NULL == (data_file = | 1264 | (NULL == (data_file = |
1258 | GNUNET_DISK_file_open (data_filename, | 1265 | GNUNET_DISK_file_open (data_filename, |
@@ -1261,28 +1268,31 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1261 | GNUNET_DISK_OPEN_CREATE, | 1268 | GNUNET_DISK_OPEN_CREATE, |
1262 | GNUNET_DISK_PERM_USER_READ | | 1269 | GNUNET_DISK_PERM_USER_READ | |
1263 | GNUNET_DISK_PERM_USER_WRITE))) ) | 1270 | GNUNET_DISK_PERM_USER_WRITE))) ) |
1271 | { | ||
1264 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 1272 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
1265 | "open", | 1273 | "open", |
1266 | data_filename); | 1274 | data_filename); |
1267 | if (GNUNET_YES != GNUNET_DISK_directory_test (args[1], GNUNET_YES)) | 1275 | } |
1276 | if (GNUNET_YES != GNUNET_DISK_directory_test (policy_dir, GNUNET_YES)) | ||
1268 | { | 1277 | { |
1269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1278 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1270 | _("Specified policies directory does not exist. Exiting.\n")); | 1279 | _("Specified policies directory does not exist. Exiting.\n")); |
1271 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1280 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1272 | return; | 1281 | return; |
1273 | } | 1282 | } |
1274 | policy_dir = args[1]; | 1283 | strings_file = args[2]; |
1275 | if (GNUNET_YES != GNUNET_DISK_file_test (args[2])) | 1284 | if (GNUNET_YES != GNUNET_DISK_file_test (strings_file)) |
1276 | { | 1285 | { |
1277 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1286 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1278 | _("No search strings file given. Exiting.\n")); | 1287 | _("No search strings file given. Exiting.\n")); |
1279 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1288 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1280 | return; | 1289 | return; |
1281 | } | 1290 | } |
1282 | nsearchstrs = load_search_strings (args[2], &search_strings, num_search_strings); | 1291 | nsearchstrs = load_search_strings (strings_file, |
1292 | &search_strings, | ||
1293 | num_search_strings); | ||
1283 | if (num_search_strings != nsearchstrs) | 1294 | if (num_search_strings != nsearchstrs) |
1284 | { | 1295 | { |
1285 | num_search_strings = nsearchstrs; | ||
1286 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1296 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1287 | _("Error loading search strings." | 1297 | _("Error loading search strings." |
1288 | "Given file does not contain enough strings. Exiting.\n")); | 1298 | "Given file does not contain enough strings. Exiting.\n")); |
@@ -1307,12 +1317,27 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1307 | reannounce_period_max = | 1317 | reannounce_period_max = |
1308 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); | 1318 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); |
1309 | } | 1319 | } |
1310 | unsigned int i; | ||
1311 | for (i = 0; i < num_search_strings; i++) | 1320 | for (i = 0; i < num_search_strings; i++) |
1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "search string: %s\n", search_strings[i]); | 1321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1322 | "search string: %s\n", | ||
1323 | search_strings[i]); | ||
1324 | event_mask = 0LL; | ||
1325 | /* event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); | ||
1326 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); | ||
1327 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | ||
1328 | event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);*/ | ||
1329 | GNUNET_TESTBED_run (args[0], | ||
1330 | cfg, | ||
1331 | num_peers, | ||
1332 | event_mask, | ||
1333 | NULL, /* master_controller_cb, */ | ||
1334 | NULL, /* master_controller_cb cls */ | ||
1335 | &test_master, | ||
1336 | NULL); /* test_master cls */ | ||
1313 | abort_task = | 1337 | abort_task = |
1314 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1338 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1315 | (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, | 1339 | (GNUNET_TIME_UNIT_SECONDS, 5), |
1340 | &do_abort, | ||
1316 | (void*) __LINE__); | 1341 | (void*) __LINE__); |
1317 | } | 1342 | } |
1318 | 1343 | ||