Commit 10c76d98 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

knsupdate: add quit command

parent 6acb185d
......@@ -145,6 +145,9 @@ Displays the last answer from the server.
.TP
\fBdebug\fP
Enable debugging. This command has the same meaning as program option \fB\-d\fP\&.
.TP
\fBquit\fP
Quit the program.
.UNINDENT
.SH NOTES
.sp
......@@ -174,7 +177,7 @@ Bind\-like key format (\fBddns\-confgen\fP output) is not supported.
.SH EXAMPLES
.INDENT 0.0
.IP 1. 3
Send one update of zone example.com to server 192.168.1.1. The update
Send one update of the zone example.com to the server 192.168.1.1. The update
contains two new records:
.INDENT 3.0
.INDENT 3.5
......@@ -182,15 +185,16 @@ contains two new records:
.nf
.ft C
$ knsupdate
server 192.168.1.1
zone example.com.
origin example.com.
ttl 3600
add test1.example.com. 7200 A 192.168.2.2
add test2 TXT "hello"
show
send
answer
> server 192.168.1.1
> zone example.com.
> origin example.com.
> ttl 3600
> add test1.example.com. 7200 A 192.168.2.2
> add test2 TXT "hello"
> show
> send
> answer
> quit
.ft P
.fi
.UNINDENT
......
......@@ -123,6 +123,9 @@ Commands
**debug**
Enable debugging. This command has the same meaning as program option **-d**.
**quit**
Quit the program.
Notes
-----
......@@ -147,19 +150,20 @@ Differences with regard to ISC nsupdate:
Examples
--------
1. Send one update of zone example.com to server 192.168.1.1. The update
1. Send one update of the zone example.com to the server 192.168.1.1. The update
contains two new records::
$ knsupdate
server 192.168.1.1
zone example.com.
origin example.com.
ttl 3600
add test1.example.com. 7200 A 192.168.2.2
add test2 TXT "hello"
show
send
answer
> server 192.168.1.1
> zone example.com.
> origin example.com.
> ttl 3600
> add test1.example.com. 7200 A 192.168.2.2
> add test2 TXT "hello"
> show
> send
> answer
> quit
See Also
--------
......
......@@ -51,6 +51,7 @@ int cmd_nxrrset(const char *lp, knsupdate_params_t *params);
int cmd_oldgsstsig(const char* lp, knsupdate_params_t *params);
int cmd_origin(const char* lp, knsupdate_params_t *params);
int cmd_prereq(const char* lp, knsupdate_params_t *params);
int cmd_quit(const char* lp, knsupdate_params_t *params);
int cmd_realm(const char* lp, knsupdate_params_t *params);
int cmd_send(const char* lp, knsupdate_params_t *params);
int cmd_server(const char* lp, knsupdate_params_t *params);
......@@ -80,6 +81,7 @@ const char* cmd_array[] = {
"\xa" "oldgsstsig",
"\x6" "origin", /* {name} */
"\x6" "prereq", /* (nx|yx)(domain|rrset) {domain-name} ... */
"\x4" "quit",
"\x5" "realm", /* {[realm_name]} */
"\x4" "send",
"\x6" "server", /* {servername} [port] */
......@@ -107,6 +109,7 @@ cmd_handle_f cmd_handle[] = {
cmd_oldgsstsig,
cmd_origin,
cmd_prereq,
cmd_quit,
cmd_realm,
cmd_send,
cmd_server,
......@@ -514,7 +517,7 @@ static int process_lines(knsupdate_params_t *params, FILE *fp)
/* Process lines. */
size_t len;
FILE *input = (fp != NULL) ? fp : stdin;
while ((len = knot_getline(&buf, &buflen, input)) != -1) {
while (!params->stop && (len = knot_getline(&buf, &buflen, input)) != -1) {
int call_ret = process_line(buf, len, params);
if (call_ret != KNOT_EOK) {
/* Return the first error. */
......@@ -529,12 +532,13 @@ static int process_lines(knsupdate_params_t *params, FILE *fp)
}
/* Print program prompt if interactive. */
if (fp == NULL) {
if (fp == NULL && !params->stop) {
/* Don't mess up stdout. */
fprintf(stderr, "> ");
}
}
memset(buf, 0, buflen);
free(buf);
return ret;
}
......@@ -795,6 +799,15 @@ int cmd_prereq(const char* lp, knsupdate_params_t *params)
return ret;
}
int cmd_quit(const char* lp, knsupdate_params_t *params)
{
DBG("%s: lp='%s'\n", __func__, lp);
params->stop = true;
return KNOT_EOK;
}
int cmd_send(const char* lp, knsupdate_params_t *params)
{
DBG("%s: lp='%s'\n", __func__, lp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment