summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/parse.c b/parse.c
index 8f6e687..d0ed95f 100644
--- a/parse.c
+++ b/parse.c
@@ -61,26 +61,28 @@ getconf(char **db_array, char *name, struct dd_request *req)
if (cgetent(&buf, db_array, name) != 0)
errx(1, "Can't find \"%s\" in dddup config", name);
- /* get type of service -- optional */
- if (cgetcap(buf, "dyndns", ':') != NULL) {
+ /* get type of service -- optional
+ * if no one is specified dyndns.org assumes `dynamic'
+ */
+ if (cgetcap(buf, "dynamic", ':') != NULL) {
req->system = "dyndns";
f_sys = SYS_DYN;
}
-#define DSCERR "either \"dyndns\" or \"statdns\" or \"custdns\" " \
- "should be specifed"
+#define DSCERR "either \"dynamic\" or \"static\" or \"custom\" " \
+ "should be specified"
- if (cgetcap(buf, "statdns", ':') != NULL) {
+ if (cgetcap(buf, "static", ':') != NULL) {
if (req->system != NULL)
errx(1, DSCERR);
req->system = "statdns";
f_sys = SYS_STAT;
}
- if (cgetcap(buf, "custdns", ':') != NULL) {
+ if (cgetcap(buf, "custom", ':') != NULL) {
if (req->system != NULL)
errx(1, DSCERR);
- req->system = "custdns";
+ req->system = "custom";
f_sys = SYS_CUST;
}
@@ -106,7 +108,7 @@ getconf(char **db_array, char *name, struct dd_request *req)
base64_encode(auth, strlen(auth), &req->auth);
memset(&auth, '\0', sizeof(auth));
- /* interface -> set "req->myip" */
+ /* interface -- determine IP and set "req->myip" */
switch (cgetstr(buf, "interface", &if_name)) {
case -1:
if_name = NULL;
@@ -123,7 +125,7 @@ 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 specifed");
+ errx(1, "either \"interface\" or \"myip\" should be specified");
if (if_name != NULL)
if_ntoa(if_name, &req->myip);
@@ -135,6 +137,7 @@ getconf(char **db_array, char *name, struct dd_request *req)
errx(1, "malloc");
}
+ /* following options are all optional */
if (f_sys & (SYS_DYN|SYS_STAT)) {
if (cgetcap(buf, "wildcard", ':') != NULL)
req->wildcard = "ON";
@@ -189,8 +192,7 @@ parse_config(char *file, struct dd_request **req)
while ((name = strsep(&buf, ": \t")) != NULL) {
if (*name) {
req[count] = malloc(sizeof(struct dd_request));
- getconf(db_array, name, req[count]);
- count++;
+ getconf(db_array, name, req[count++]);
}
}
@@ -198,6 +200,7 @@ parse_config(char *file, struct dd_request **req)
#if DEBUG
if (debug) {
+ int i;
for (i = 0; i < count; i++) {
printf("===> No. %d\n", i);
print_config(req[i]);
@@ -211,9 +214,8 @@ parse_config(char *file, struct dd_request **req)
int
free_config(int reqc, struct dd_request **reqv)
{
- int i;
+ while (reqc > 0)
+ free(reqv[--reqc]);
- for (i = 0; i < reqc; i++)
- free(reqv[i]);
return 0;
}