--- smallapp/unbound-control.c.orig 2012-09-22 15:56:27.000000000 -0300 +++ smallapp/unbound-control.c 2012-09-22 15:58:10.000000000 -0300 @@ -68,6 +68,7 @@ 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 command and display result */ static int -go_cmd(SSL* ssl, int argc, char* argv[]) +go_cmd(SSL* ssl, char quiet, int argc, char* argv[]) { char pre[10]; const char* space=" "; @@ -297,9 +298,12 @@ 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 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, char quiet, int argc, char* argv[]) { struct config_file* cfg; int fd, ret; @@ -328,7 +332,7 @@ 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 @@ int main(int argc, char* argv[]) { int c, ret; + char quiet = 0; const char* cfgfile = CONFIGFILE; char* svr = NULL; #ifdef USE_WINSOCK @@ -392,7 +397,7 @@ } /* 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 @@ case 's': svr = optarg; break; + case 'q': + quiet = 1; + break; case '?': case 'h': default: @@ -418,7 +426,7 @@ } } - ret = go(cfgfile, svr, argc, argv); + ret = go(cfgfile, svr, quiet, argc, argv); #ifdef USE_WINSOCK WSACleanup();