X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/blobdiff_plain/8a4839e0036c849faf468e8e888e8465c2c4e5ea..cb0d563370248c29cdc857c409d47387d068d7f6:/config.c diff --git a/config.c b/config.c index 7315c69..9326c71 100644 --- a/config.c +++ b/config.c @@ -140,7 +140,7 @@ static int get_key(struct session *session, char *line, char **key, char **value * the value. */ } - printf("%s = %s\n", *key, *value); + /* printf("%s = %s\n", *key, *value); */ return 0; } @@ -309,7 +309,10 @@ static void process_line(struct session *session, char *key, char *value) break; if (strncasecmp(item->key, key, strlen(item->key)) == 0) { - printf("calling %p, for key = '%s' and value = '%s'\n", item->callback, key, value); + /* + * printf("calling %p, for key = '%s' and value = * '%s'\n", + * item->callback, key, value); + */ result = item->callback(session, value); if (!result) return; @@ -341,8 +344,14 @@ void bti_parse_configfile(struct session *session) if (line[n - 1] == '\n') line[n - 1] = '\0'; - /* '#' is comment markers, like bash style */ - *strchrnul(line, '#') = '\0'; + /* '#' is comment markers, like bash style + but it is a valid character in some fields, so + only treat it as a comment marker if it occurs + at the beginning of the line, or after whitespace */ + char *hashmarker = strchrnul(line, '#'); + if (line == hashmarker) line[0] = '\0'; + if (*(--hashmarker) == ' ' || *hashmarker == '\t') + *hashmarker = '\0'; c = line; while (isspace(*c)) c++;