summaryrefslogtreecommitdiffhomepage
path: root/src/conf.c
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2018-12-18 23:36:04 +0000
committerrofl0r <rofl0r@users.noreply.github.com>2019-12-21 00:43:45 +0000
commit1186c297b4651d5c84ac7a387b07cbc12ec0c69a (patch)
treee3947353f25392b2fa4ff8f600c61c2aeaa80fcf /src/conf.c
parentb935dc85c3fca51de8e131d6aa2047f8a0404f0c (diff)
conf.c: pass lineno to handler funcs
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/conf.c b/src/conf.c
index d7cf5b6..575fc6c 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -91,7 +91,8 @@
* All configuration handling functions are REQUIRED to be defined
* with the same function template as below.
*/
-typedef int (*CONFFILE_HANDLER) (struct config_s *, const char *, regmatch_t[]);
+typedef int (*CONFFILE_HANDLER) (struct config_s *, const char *,
+ unsigned long, regmatch_t[]);
/*
* Define the pattern used by any directive handling function. The
@@ -106,7 +107,7 @@ typedef int (*CONFFILE_HANDLER) (struct config_s *, const char *, regmatch_t[]);
*/
#define HANDLE_FUNC(func) \
int func(struct config_s* conf, const char* line, \
- regmatch_t match[])
+ unsigned long lineno, regmatch_t match[])
/*
* List all the handling functions. These are defined later, but they need
@@ -369,7 +370,8 @@ config_free_regex (void)
* Returns 0 if a match was found and successfully processed; otherwise,
* a negative number is returned.
*/
-static int check_match (struct config_s *conf, const char *line)
+static int check_match (struct config_s *conf, const char *line,
+ unsigned long lineno)
{
regmatch_t match[RE_MAX_MATCHES];
unsigned int i;
@@ -380,7 +382,7 @@ static int check_match (struct config_s *conf, const char *line)
assert (directives[i].cre);
if (!regexec
(directives[i].cre, line, RE_MAX_MATCHES, match, 0))
- return (*directives[i].handler) (conf, line, match);
+ return (*directives[i].handler) (conf, line, lineno, match);
}
return -1;
@@ -395,7 +397,7 @@ static int config_parse (struct config_s *conf, FILE * f)
unsigned long lineno = 1;
while (fgets (buffer, sizeof (buffer), f)) {
- if (check_match (conf, buffer)) {
+ if (check_match (conf, buffer, lineno)) {
printf ("Syntax error on line %ld\n", lineno);
return 1;
}