From f6eaaabb0b2fab12cf597b8c1d12d470a13e581f Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 14 May 2015 14:58:10 +0800 Subject: [PATCH 204/210] xl2tpd-control: enhance output of print_error(). - Add prefix "xl2tpd-control: " to print_error() output. - Output response from xl2tpd only when -d is enabled as result of control command can be retrieved from exit code. - Remove some redundant and not that useful verbose output. --- xl2tpd-control.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xl2tpd-control.c b/xl2tpd-control.c index abc0324..6b08850 100644 --- a/xl2tpd-control.c +++ b/xl2tpd-control.c @@ -164,7 +164,6 @@ int main (int argc, char *argv[]) { control_filename = strdup (CONTROL_PIPE); } - print_error (DEBUG_LEVEL, "set control filename to %s\n", control_filename); /* parse command name */ for (command = commands; command->name; command++) @@ -176,10 +175,7 @@ int main (int argc, char *argv[]) } } - if (command->name) - { - print_error (DEBUG_LEVEL, "get command %s\n", command->name); - } else { + if (!command->name) { print_error (ERROR_LEVEL, "error: no such command %s\n", argv[i]); return -1; } @@ -303,7 +299,8 @@ int main (int argc, char *argv[]) int command_result_code = read_result ( result_fd, rbuf, CONTROL_PIPE_MESSAGE_SIZE ); - printf ("%s", rbuf); + /* rbuf contains a newline, make it double to form a boundary. */ + print_error (DEBUG_LEVEL, "command response: \n%s\n", rbuf); return command_result_code; } @@ -313,6 +310,7 @@ void print_error (int level, const char *fmt, ...) if (level > log_level) return; va_list args; va_start (args, fmt); + fprintf (stderr, "xl2tpd-control: "); vfprintf (stderr, fmt, args); va_end (args); } -- 1.7.10.4