You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.9 KiB

  1. From f6eaaabb0b2fab12cf597b8c1d12d470a13e581f Mon Sep 17 00:00:00 2001
  2. From: Yousong Zhou <yszhou4tech@gmail.com>
  3. Date: Thu, 14 May 2015 14:58:10 +0800
  4. Subject: [PATCH 204/210] xl2tpd-control: enhance output of print_error().
  5. - Add prefix "xl2tpd-control: " to print_error() output.
  6. - Output response from xl2tpd only when -d is enabled as result of
  7. control command can be retrieved from exit code.
  8. - Remove some redundant and not that useful verbose output.
  9. ---
  10. xl2tpd-control.c | 10 ++++------
  11. 1 file changed, 4 insertions(+), 6 deletions(-)
  12. diff --git a/xl2tpd-control.c b/xl2tpd-control.c
  13. index abc0324..6b08850 100644
  14. --- a/xl2tpd-control.c
  15. +++ b/xl2tpd-control.c
  16. @@ -164,7 +164,6 @@ int main (int argc, char *argv[])
  17. {
  18. control_filename = strdup (CONTROL_PIPE);
  19. }
  20. - print_error (DEBUG_LEVEL, "set control filename to %s\n", control_filename);
  21. /* parse command name */
  22. for (command = commands; command->name; command++)
  23. @@ -176,10 +175,7 @@ int main (int argc, char *argv[])
  24. }
  25. }
  26. - if (command->name)
  27. - {
  28. - print_error (DEBUG_LEVEL, "get command %s\n", command->name);
  29. - } else {
  30. + if (!command->name) {
  31. print_error (ERROR_LEVEL, "error: no such command %s\n", argv[i]);
  32. return -1;
  33. }
  34. @@ -303,7 +299,8 @@ int main (int argc, char *argv[])
  35. int command_result_code = read_result (
  36. result_fd, rbuf, CONTROL_PIPE_MESSAGE_SIZE
  37. );
  38. - printf ("%s", rbuf);
  39. + /* rbuf contains a newline, make it double to form a boundary. */
  40. + print_error (DEBUG_LEVEL, "command response: \n%s\n", rbuf);
  41. return command_result_code;
  42. }
  43. @@ -313,6 +310,7 @@ void print_error (int level, const char *fmt, ...)
  44. if (level > log_level) return;
  45. va_list args;
  46. va_start (args, fmt);
  47. + fprintf (stderr, "xl2tpd-control: ");
  48. vfprintf (stderr, fmt, args);
  49. va_end (args);
  50. }
  51. --
  52. 1.7.10.4