Annotation of /trunk/mkinitrd-magellan/busybox/libbb/info_msg.c
Parent Directory | Revision Log
Revision 1123 -
(hide annotations)
(download)
Wed Aug 18 21:56:57 2010 UTC (13 years, 9 months ago) by niro
File MIME type: text/plain
File size: 1145 byte(s)
Wed Aug 18 21:56:57 2010 UTC (13 years, 9 months ago) by niro
File MIME type: text/plain
File size: 1145 byte(s)
-updated to busybox-1.17.1
1 | niro | 532 | /* 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 | niro | 1123 | #if ENABLE_FEATURE_SYSLOG |
12 | # include <syslog.h> | ||
13 | #endif | ||
14 | niro | 532 | |
15 | niro | 816 | void FAST_FUNC bb_info_msg(const char *s, ...) |
16 | niro | 532 | { |
17 | niro | 984 | #ifdef THIS_ONE_DOESNT_DO_SINGLE_WRITE |
18 | niro | 532 | va_list p; |
19 | niro | 816 | /* va_copy is used because it is not portable |
20 | * to use va_list p twice */ | ||
21 | va_list p2; | ||
22 | niro | 532 | |
23 | va_start(p, s); | ||
24 | niro | 816 | va_copy(p2, p); |
25 | if (logmode & LOGMODE_STDIO) { | ||
26 | vprintf(s, p); | ||
27 | fputs(msg_eol, stdout); | ||
28 | } | ||
29 | niro | 1123 | # if ENABLE_FEATURE_SYSLOG |
30 | if (logmode & LOGMODE_SYSLOG) | ||
31 | niro | 816 | vsyslog(LOG_INFO, s, p2); |
32 | niro | 1123 | # endif |
33 | niro | 816 | va_end(p2); |
34 | niro | 532 | va_end(p); |
35 | niro | 984 | #else |
36 | int used; | ||
37 | char *msg; | ||
38 | va_list p; | ||
39 | |||
40 | if (logmode == 0) | ||
41 | return; | ||
42 | |||
43 | va_start(p, s); | ||
44 | used = vasprintf(&msg, s, p); | ||
45 | va_end(p); | ||
46 | if (used < 0) | ||
47 | return; | ||
48 | |||
49 | niro | 1123 | # if ENABLE_FEATURE_SYSLOG |
50 | if (logmode & LOGMODE_SYSLOG) | ||
51 | niro | 984 | syslog(LOG_INFO, "%s", msg); |
52 | niro | 1123 | # endif |
53 | niro | 984 | if (logmode & LOGMODE_STDIO) { |
54 | fflush_all(); | ||
55 | /* used = strlen(msg); - must be true already */ | ||
56 | msg[used++] = '\n'; | ||
57 | full_write(STDOUT_FILENO, msg, used); | ||
58 | } | ||
59 | |||
60 | free(msg); | ||
61 | #endif | ||
62 | niro | 532 | } |