Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "utils.h"
#include "error.h"

#define MAX_CONF_VARS 20
#define MAX_CONF_VARS 32

/* There are the variables accepted in the configuration file */
static char conf_vars[MAX_CONF_VARS][MAXBUF] = {
Expand All @@ -59,7 +59,9 @@ static char conf_vars[MAX_CONF_VARS][MAXBUF] = {
"USE_TLS",
"SMTP_AUTH_USER",
"SMTP_AUTH_PASS",
"VCARD"
"VCARD",
"TIMEOUT",
""
Copy link
Owner

@deanproxy deanproxy Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to just kill the MAX_CONF_VARS macro all together and have conf_vars just be a pointer-array?

static char *conf_vars[] = {
        "USE_TLS",
        /* ... */,
        "TIMEOUT",
        NULL
}

};

/**
Expand All @@ -71,7 +73,7 @@ checkVar(dstrbuf *var)
{
int i;

for (i = 0; i < MAX_CONF_VARS; i++) {
for (i = 0; strcasecmp("", conf_vars[i]) ; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then here it would be a bit more simple and performant to just say:

for (i = 0; conf_vars[i]; i++) {

if (strcasecmp(var->str, conf_vars[i]) == 0) {
return 0;
}
Expand Down Expand Up @@ -167,7 +169,7 @@ readConfig(FILE *in)
ch = line;
goto exit;
} else if (checkVar(var) < 0) {
fatal("Variable: '%s' is not valid\n", var);
fatal("Variable: '%s' is not valid\n", var->str);
ch = line;
goto exit;
}
Expand Down