From 5dd11c784f9f7ef0fd31de2cb7da44b1e5734132 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 1 May 2005 22:19:36 +0000 Subject: readd name of config entry in error messages --- parse.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index d0ed95f..fd91c59 100644 --- a/parse.c +++ b/parse.c @@ -59,7 +59,10 @@ getconf(char **db_array, char *name, struct dd_request *req) memset(req, '\0', sizeof(struct dd_request)); if (cgetent(&buf, db_array, name) != 0) - errx(1, "Can't find \"%s\" in dddup config", name); + errx(1, "can't find \"%s\" in dddup config", name); + + if ((req->name =strdup(name)) == NULL) + errx(1, "malloc"); /* get type of service -- optional * if no one is specified dyndns.org assumes `dynamic' @@ -69,19 +72,19 @@ getconf(char **db_array, char *name, struct dd_request *req) f_sys = SYS_DYN; } -#define DSCERR "either \"dynamic\" or \"static\" or \"custom\" " \ +#define DSCERR "%s: either \"dynamic\" or \"static\" or \"custom\" " \ "should be specified" if (cgetcap(buf, "static", ':') != NULL) { if (req->system != NULL) - errx(1, DSCERR); + errx(1, DSCERR, name); req->system = "statdns"; f_sys = SYS_STAT; } if (cgetcap(buf, "custom", ':') != NULL) { if (req->system != NULL) - errx(1, DSCERR); + errx(1, DSCERR, name); req->system = "custom"; f_sys = SYS_CUST; } @@ -89,7 +92,7 @@ getconf(char **db_array, char *name, struct dd_request *req) /* get username -- required */ switch (cgetstr(buf, "username", &user)) { case -1: - errx(1, "No username"); + errx(1, "%s: no username", name); case -2: errx(1, "malloc"); } @@ -97,7 +100,7 @@ getconf(char **db_array, char *name, struct dd_request *req) /* get password -- required */ switch (cgetstr(buf, "password", &pass)) { case -1: - errx(1, "No password"); + errx(1, "%s: no password", name); case -2: errx(1, "malloc"); } @@ -125,14 +128,14 @@ getconf(char **db_array, char *name, struct dd_request *req) } if (if_name != NULL && req->myip != NULL) - errx(1, "either \"interface\" or \"myip\" should be specified"); + errx(1, "%s: ither \"interface\" or \"myip\" should be specified", name); if (if_name != NULL) if_ntoa(if_name, &req->myip); switch (cgetstr(buf, "hostname", &req->hostname)) { case -1: - errx(1, "No hostname"); + errx(1, "%s: no hostname", name); case -2: errx(1, "malloc"); } @@ -186,7 +189,7 @@ parse_config(char *file, struct dd_request **req) *db_array = file; if (cgetent(&buf, db_array, "all") != 0) - errx(1, "Can't find \"all\" in dddup config"); + errx(1, "can't find \"all\" in dddup config"); name = strsep(&buf, ": \t"); /* skip "all" at start */ while ((name = strsep(&buf, ": \t")) != NULL) { -- cgit v1.2.3