-/**
- * 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;
-}
-