+ static char line_copy[MAX_LINE_LEN + 1], line_raw_copy[MAX_LINE_LEN + 1];
+ char *token, *value, *line_ptr;
+
+ /* when externally invoked via ReadTokenValueFromLine(), copy line buffers */
+ if (line_raw == NULL)
+ {
+ strncpy(line_copy, line, MAX_LINE_LEN);
+ line_copy[MAX_LINE_LEN] = '\0';
+ line = line_copy;
+
+ strcpy(line_raw_copy, line_copy);
+ line_raw = line_raw_copy;
+ }
+
+ /* cut trailing comment from input line */
+ for (line_ptr = line; *line_ptr; line_ptr++)
+ {
+ if (*line_ptr == '#')
+ {
+ *line_ptr = '\0';
+ break;
+ }
+ }
+
+ /* cut trailing whitespaces from input line */
+ for (line_ptr = &line[strlen(line)]; line_ptr >= line; line_ptr--)
+ if ((*line_ptr == ' ' || *line_ptr == '\t') && *(line_ptr + 1) == '\0')
+ *line_ptr = '\0';
+
+ /* ignore empty lines */
+ if (*line == '\0')
+ return FALSE;
+
+ /* cut leading whitespaces from token */
+ for (token = line; *token; token++)
+ if (*token != ' ' && *token != '\t')
+ break;
+
+ /* start with empty value as reliable default */
+ value = "";
+
+ token_value_separator_found = FALSE;
+
+ /* find end of token to determine start of value */
+ for (line_ptr = token; *line_ptr; line_ptr++)
+ {
+ /* first look for an explicit token/value separator, like ':' or '=' */
+ if (*line_ptr == ':' || *line_ptr == '=')
+ {
+ *line_ptr = '\0'; /* terminate token string */
+ value = line_ptr + 1; /* set beginning of value */
+
+ token_value_separator_found = TRUE;
+
+ break;
+ }
+ }
+
+#if ALLOW_TOKEN_VALUE_SEPARATOR_BEING_WHITESPACE
+ /* fallback: if no token/value separator found, also allow whitespaces */
+ if (!token_value_separator_found && !separator_required)
+ {
+ for (line_ptr = token; *line_ptr; line_ptr++)
+ {
+ if (*line_ptr == ' ' || *line_ptr == '\t')
+ {
+ *line_ptr = '\0'; /* terminate token string */
+ value = line_ptr + 1; /* set beginning of value */
+
+ token_value_separator_found = TRUE;
+
+ break;
+ }
+ }
+
+#if CHECK_TOKEN_VALUE_SEPARATOR__WARN_IF_MISSING
+ if (token_value_separator_found)
+ {
+ if (!token_value_separator_warning)
+ {
+ Error(ERR_INFO_LINE, "-");
+
+ if (filename != NULL)
+ {
+ Error(ERR_WARN, "missing token/value separator(s) in config file:");
+ Error(ERR_INFO, "- config file: '%s'", filename);
+ }
+ else
+ {
+ Error(ERR_WARN, "missing token/value separator(s):");
+ }
+
+ token_value_separator_warning = TRUE;
+ }
+
+ if (filename != NULL)
+ Error(ERR_INFO, "- line %d: '%s'", line_nr, line_raw);
+ else
+ Error(ERR_INFO, "- line: '%s'", line_raw);
+ }
+#endif
+ }
+#endif
+
+ /* cut trailing whitespaces from token */
+ for (line_ptr = &token[strlen(token)]; line_ptr >= token; line_ptr--)
+ if ((*line_ptr == ' ' || *line_ptr == '\t') && *(line_ptr + 1) == '\0')
+ *line_ptr = '\0';
+
+ /* cut leading whitespaces from value */
+ for (; *value; value++)
+ if (*value != ' ' && *value != '\t')
+ break;
+
+ *token_ptr = token;
+ *value_ptr = value;
+
+ return TRUE;
+}
+
+boolean getTokenValueFromSetupLine(char *line, char **token, char **value)
+{
+ /* while the internal (old) interface does not require a token/value
+ separator (for downwards compatibility with existing files which
+ don't use them), it is mandatory for the external (new) interface */
+
+ return getTokenValueFromSetupLineExt(line, token, value, NULL, NULL, 0, TRUE);
+}
+
+static boolean loadSetupFileData(void *setup_file_data, char *filename,
+ boolean top_recursion_level, boolean is_hash)
+{
+ static SetupFileHash *include_filename_hash = NULL;