Magellan Linux

Contents of /trunk/mkinitrd-magellan/busybox/libbb/verror_msg.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 1013 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /* vi: set sw=4 ts=4: */
2 /*
3 * Utility routines.
4 *
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */
9
10 #include "libbb.h"
11 #include <syslog.h>
12
13 int logmode = LOGMODE_STDIO;
14 const char *msg_eol = "\n";
15
16 void bb_verror_msg(const char *s, va_list p, const char* strerr)
17 {
18 /* va_copy is used because it is not portable
19 * to use va_list p twice */
20 va_list p2;
21 va_copy(p2, p);
22
23 if (logmode & LOGMODE_STDIO) {
24 fflush(stdout);
25 fprintf(stderr, "%s: ", applet_name);
26 vfprintf(stderr, s, p);
27 if (!strerr)
28 fputs(msg_eol, stderr);
29 else
30 fprintf(stderr, "%s%s%s",
31 s ? ": " : "",
32 strerr, msg_eol);
33 }
34 if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) {
35 if (!strerr)
36 vsyslog(LOG_ERR, s, p2);
37 else {
38 char *msg;
39 if (vasprintf(&msg, s, p2) < 0)
40 bb_error_msg_and_die(bb_msg_memory_exhausted);
41 syslog(LOG_ERR, "%s: %s", msg, strerr);
42 free(msg);
43 }
44 }
45 va_end(p2);
46 }