@@ -, +, @@ --- ssmtp.c | 34 ++++++++++++++++++++++++++++------ 1 files changed, 28 insertions(+), 6 deletions(-) --- a/ssmtp.c +++ a/ssmtp.c @@ -850,6 +850,32 @@ char *firsttok(char **s, const char *delim) } /* + * This is a simple trim function that only trim the space on the left of the string. + * It will not duplicate the original string. It returns a pointer of the original string which is not a space + * Args: + * char *str: + * Address of the pointer to the string we are going to trim. + * Return value: + * The pointer to the first none space character in the original string. + * You do not need to free this pointer. + */ +char *trimleft(char *str) { + if(str == (char *)NULL) + return NULL; + + while(str != (char *)NULL) { + if(isspace(*str)) { + str++; + continue; + } + + break; + } + + return str; +} + +/* read_config() -- Open and parse config file and extract values of variables */ bool_t read_config() @@ -869,15 +895,11 @@ bool_t read_config() } while(fgets(buf, sizeof(buf), fp)) { - char *begin=buf; + char *begin=trimleft(buf); char *rightside; - /* Make comments invisible */ - if((p = strchr(buf, '#'))) { - *p = (char)NULL; - } /* Ignore malformed lines and comments */ - if(strchr(buf, '=') == (char *)NULL) continue; + if(*begin == '#' || strchr(buf, '=') == (char *)NULL) continue; /* Parse out keywords */ p=firsttok(&begin, "= \t\n"); --