usage.c: remove reference to busybox.h
[oweals/busybox.git] / libbb / verror_msg.c
index d55da73ff3a958624995537cf06146504f543c96..526b9d36c59d74c4e974441ffb2c7eb527edeb4e 100644 (file)
@@ -7,14 +7,11 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <syslog.h>
 #include "libbb.h"
+#include <syslog.h>
 
-int logmode = LOGMODE_STDIO;
+smallint logmode = LOGMODE_STDIO;
+const char *msg_eol = "\n";
 
 void bb_verror_msg(const char *s, va_list p, const char* strerr)
 {
@@ -25,12 +22,14 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr)
 
        if (logmode & LOGMODE_STDIO) {
                fflush(stdout);
-               fprintf(stderr, "%s: ", bb_applet_name);
+               fprintf(stderr, "%s: ", applet_name);
                vfprintf(stderr, s, p);
                if (!strerr)
-                       fputc('\n', stderr);
+                       fputs(msg_eol, stderr);
                else
-                       fprintf(stderr, ": %s\n", strerr);
+                       fprintf(stderr, "%s%s%s",
+                                       s ? ": " : "",
+                                       strerr, msg_eol);
        }
        if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) {
                if (!strerr)