- else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag))
- {
- /* tag = */
- GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, "");
- }
- else
- {
- /* parse error */
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Syntax error in configuration file `%s' at line %u.\n"),
- filename, nr);
- ret = GNUNET_SYSERR;
- break;
- }
+ /* parse error */
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _("Syntax error while deserializing in line %u\n"),
+ nr);
+ ret = GNUNET_SYSERR;
+ break;
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished deserializing config\n");
+ GNUNET_free_non_null (line_orig);
+ GNUNET_free (section);
+ GNUNET_assert ( (GNUNET_OK != ret) || (r_bytes == size) );
+ return ret;
+}
+
+
+/**
+ * Parse a configuration file, add all of the options in the
+ * file to the configuration environment.
+ *
+ * @param cfg configuration to update
+ * @param filename name of the configuration file
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+int
+GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *filename)
+{
+ uint64_t fs64;
+ size_t fs;
+ char *fn;
+ char *mem;
+ int dirty;
+ int ret;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Asked to parse config file `%s'\n",
+ filename);
+ fn = GNUNET_STRINGS_filename_expand (filename);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Config file name expanded to `%s'\n",
+ fn);
+ if (NULL == fn)
+ return GNUNET_SYSERR;
+ dirty = cfg->dirty; /* back up value! */
+ if (GNUNET_SYSERR ==
+ GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Error while determining the file size of %s\n", fn);
+ GNUNET_free (fn);
+ return GNUNET_SYSERR;
+ }
+ if (fs64 > SIZE_MAX)
+ {
+ GNUNET_break (0); /* File size is more than the heap size */
+ GNUNET_free (fn);
+ return GNUNET_SYSERR;