summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.c21
-rw-r--r--request.c12
-rw-r--r--request.h8
3 files changed, 21 insertions, 20 deletions
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) {
diff --git a/request.c b/request.c
index 2a01792..4dd4817 100644
--- a/request.c
+++ b/request.c
@@ -67,7 +67,11 @@ build_request(struct dd_request *req, char *buf)
#define RET_OK 0
#define RET_ERR 1
-static struct dd_retcode retcode[] = {
+static struct {
+ const char *code;
+ const char *message;
+ const char ret;
+} retcode[] = {
{ "badsys", "bad system parameter", RET_ERR },
{ "badagent", "useragent has been blocked", RET_ERR },
{ "badauth", "bad authorization", RET_ERR },
@@ -85,7 +89,7 @@ static struct dd_retcode retcode[] = {
};
static int
-parse_answer(char *buf)
+parse_answer(char *buf, char *name)
{
char *p;
int i;
@@ -98,7 +102,7 @@ parse_answer(char *buf)
for (i = 0; retcode[i].code != NULL; i++) {
if (strstr(p, retcode[i].code)) {
if (verbose)
- warnx("%s", retcode[i].message);
+ warnx("%s: %s", name, retcode[i].message);
return retcode[i].ret;
}
}
@@ -126,7 +130,7 @@ do_request(int reqc, struct dd_request **reqv)
if (debug)
printf("response:\n%s\n", buf);
- if (parse_answer(buf) == RET_OK)
+ if (parse_answer(buf, reqv[i]->name) == RET_OK)
ret--;
}
diff --git a/request.h b/request.h
index d28f3fc..1cd4046 100644
--- a/request.h
+++ b/request.h
@@ -23,7 +23,7 @@
#define DYNDNSPORT2 8245
struct dd_request {
-/* char *name; */
+ char *name;
char *auth;
char *system;
char *hostname;
@@ -34,12 +34,6 @@ struct dd_request {
char *offline;
};
-struct dd_retcode {
- const char *code;
- const char *message;
- const int ret;
-};
-
__BEGIN_DECLS
int do_request(int, struct dd_request **);
__END_DECLS