+ else
+ {
+ line_orig = GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes]));
+ r_bytes += line_size + 1;
+ }
+ line = line_orig;
+ /* increment line number */
+ nr++;
+ /* tabs and '\r' are whitespace */
+ emptyline = GNUNET_YES;
+ for (i = 0; i < line_size; i++)
+ {
+ if (line[i] == '\t')
+ line[i] = ' ';
+ if (line[i] == '\r')
+ line[i] = ' ';
+ if (' ' != line[i])
+ emptyline = GNUNET_NO;
+ }
+ /* ignore empty lines */
+ if (GNUNET_YES == emptyline)
+ continue;
+
+ /* remove tailing whitespace */
+ for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));i--)
+ line[i] = '\0';
+
+ /* remove leading whitespace */
+ for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++);
+
+ /* ignore comments */
+ if ( ('#' == line[0]) || ('%' == line[0]) )
+ continue;
+
+ /* handle special "@INLINE@" directive */
+ if (0 == strncasecmp (line,
+ "@INLINE@ ",
+ strlen ("@INLINE@ ")))
+ {
+ /* @INLINE@ value */
+ value = &line[strlen ("@INLINE@ ")];
+ if (GNUNET_YES == allow_inline)
+ {
+ if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value))
+ {
+ ret = GNUNET_SYSERR; /* failed to parse included config */
+ break;
+ }
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ignoring parsing @INLINE@ configurations, not allowed!\n");
+ ret = GNUNET_SYSERR;
+ break;
+ }
+ continue;
+ }
+ if ( ('[' == line[0]) && (']' == line[line_size - 1]) )
+ {
+ /* [value] */
+ line[line_size - 1] = '\0';
+ value = &line[1];
+ GNUNET_free (section);
+ section = GNUNET_strdup (value);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Config section `%s'\n",
+ section);
+ continue;
+ }
+ if (NULL != (eq = strchr (line, '=')))
+ {
+ /* tag = value */
+ tag = GNUNET_strndup (line, eq - line);
+ /* remove tailing whitespace */
+ for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));i--)
+ tag[i] = '\0';
+
+ /* Strip whitespace */
+ value = eq + 1;
+ while (isspace ((unsigned char) value[0]))
+ value++;
+ for (i = strlen (value) - 1; (i >= 1) && (isspace ((unsigned char) value[i]));i--)
+ value[i] = '\0';
+
+ /* remove quotes */
+ i = 0;
+ if ( ('"' == value[0]) &&
+ ('"' == value[strlen (value) - 1]) )
+ {
+ value[strlen (value) - 1] = '\0';
+ value++;
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Config value %s=\"%s\"\n", tag, value);
+ GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]);
+ GNUNET_free (tag);
+ continue;
+ }
+ /* 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;