]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
unbound-control -q option is quiet, patch from Mariano Absatz.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 27 Sep 2012 09:32:35 +0000 (09:32 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 27 Sep 2012 09:32:35 +0000 (09:32 +0000)
git-svn-id: file:///svn/unbound/trunk@2766 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
doc/unbound-control.8.in
smallapp/unbound-control.c

index 6317da9e051bc6f94e123cd2f15eb3b61410d24a..4b1cb8b1bfe25360b42485aafed5e5869931cabd 100644 (file)
@@ -1,6 +1,7 @@
 27 September 2012: Wouter
        - include: directive in config file accepts wildcards.  Patch from
          Paul Wouters.  Suggested use: include: "/etc/unbound.d/conf.d/*"
+       - unbound-control -q option is quiet, patch from Mariano Absatz.
 
 21 September 2012: Wouter
        - chdir to / after chroot call (suggested by Camiel Dobbelaar).
index f458338c126918425ce1c4a6406fdcca8fbefa92..620fd321140f7b38278151ef8093c9d78cc24eea 100644 (file)
@@ -14,7 +14,7 @@
 \- Unbound remote server control utility.
 .SH "SYNOPSIS"
 .B unbound\-control
-.RB [ \-h ]
+.RB [ \-hq ]
 .RB [ \-c 
 .IR cfgfile ]
 .RB [ \-s 
@@ -38,6 +38,9 @@ config file @ub_conf_file@ is used.
 .B \-s \fIserver[@port]
 IPv4 or IPv6 address of the server to contact.  If not given, the
 address is read from the config file.
+.TP
+.B \-q
+quiet, if the option is given it does not print anything if it works ok.
 .SH "COMMANDS"
 There are several commands that the server understands.
 .TP
index e438b3d20a1b28cd33a13014cf1b0d20c570f5d7..cc48866c5dbd75e89c5f8241f615efb1d2fbcd21 100644 (file)
@@ -68,6 +68,7 @@ usage()
        printf("Options:\n");
        printf("  -c file       config file, default is %s\n", CONFIGFILE);
        printf("  -s ip[@port]  server address, if omitted config is used.\n");
+       printf("  -q            quiet (don't print anything if it works ok).\n");
        printf("  -h            show this usage help.\n");
        printf("Commands:\n");
        printf("  start                         start server; runs unbound(8)\n");
@@ -263,7 +264,7 @@ send_file(SSL* ssl, FILE* in, char* buf, size_t sz)
 
 /** send command and display result */
 static int
-go_cmd(SSL* ssl, int argc, char* argv[])
+go_cmd(SSL* ssl, int quiet, int argc, char* argv[])
 {
        char pre[10];
        const char* space=" ";
@@ -297,9 +298,12 @@ go_cmd(SSL* ssl, int argc, char* argv[])
                        ssl_err("could not SSL_read");
                }
                buf[r] = 0;
-               printf("%s", buf);
-               if(first_line && strncmp(buf, "error", 5) == 0)
+               if(first_line && strncmp(buf, "error", 5) == 0) {
+                       printf("%s", buf);
                        was_error = 1;
+               } else if (!quiet)
+                       printf("%s", buf);
+
                first_line = 0;
        }
        return was_error;
@@ -307,7 +311,7 @@ go_cmd(SSL* ssl, int argc, char* argv[])
 
 /** go ahead and read config, contact server and perform command and display */
 static int
-go(const char* cfgfile, char* svr, int argc, char* argv[])
+go(const char* cfgfile, char* svr, int quiet, int argc, char* argv[])
 {
        struct config_file* cfg;
        int fd, ret;
@@ -328,7 +332,7 @@ go(const char* cfgfile, char* svr, int argc, char* argv[])
        ssl = setup_ssl(ctx, fd);
        
        /* send command */
-       ret = go_cmd(ssl, argc, argv);
+       ret = go_cmd(ssl, quiet, argc, argv);
 
        SSL_free(ssl);
 #ifndef USE_WINSOCK
@@ -350,6 +354,7 @@ extern char* optarg;
 int main(int argc, char* argv[])
 {
        int c, ret;
+       int quiet = 0;
        const char* cfgfile = CONFIGFILE;
        char* svr = NULL;
 #ifdef USE_WINSOCK
@@ -392,7 +397,7 @@ int main(int argc, char* argv[])
        }
 
        /* parse the options */
-       while( (c=getopt(argc, argv, "c:s:h")) != -1) {
+       while( (c=getopt(argc, argv, "c:s:qh")) != -1) {
                switch(c) {
                case 'c':
                        cfgfile = optarg;
@@ -400,6 +405,9 @@ int main(int argc, char* argv[])
                case 's':
                        svr = optarg;
                        break;
+               case 'q':
+                       quiet = 1;
+                       break;
                case '?':
                case 'h':
                default:
@@ -418,7 +426,7 @@ int main(int argc, char* argv[])
                }
        }
 
-       ret = go(cfgfile, svr, argc, argv);
+       ret = go(cfgfile, svr, quiet, argc, argv);
 
 #ifdef USE_WINSOCK
         WSACleanup();