Last change
on this file since 3332 was 3320, checked in by Bruno Cornec, 10 years ago |
- Re-add (thanks git BTW) the 2.2.9 branch which had been destroyed in
the move to 3.0
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 KB
|
Rev | Line | |
---|
[3320] | 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 source tree.
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #include "libbb.h"
|
---|
| 11 | #if ENABLE_FEATURE_SYSLOG
|
---|
| 12 | # include <syslog.h>
|
---|
| 13 | #endif
|
---|
| 14 |
|
---|
| 15 | void FAST_FUNC bb_info_msg(const char *s, ...)
|
---|
| 16 | {
|
---|
| 17 | #ifdef THIS_ONE_DOESNT_DO_SINGLE_WRITE
|
---|
| 18 | va_list p;
|
---|
| 19 | /* va_copy is used because it is not portable
|
---|
| 20 | * to use va_list p twice */
|
---|
| 21 | va_list p2;
|
---|
| 22 |
|
---|
| 23 | va_start(p, s);
|
---|
| 24 | va_copy(p2, p);
|
---|
| 25 | if (logmode & LOGMODE_STDIO) {
|
---|
| 26 | vprintf(s, p);
|
---|
| 27 | fputs(msg_eol, stdout);
|
---|
| 28 | }
|
---|
| 29 | # if ENABLE_FEATURE_SYSLOG
|
---|
| 30 | if (logmode & LOGMODE_SYSLOG)
|
---|
| 31 | vsyslog(LOG_INFO, s, p2);
|
---|
| 32 | # endif
|
---|
| 33 | va_end(p2);
|
---|
| 34 | va_end(p);
|
---|
| 35 | #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 | # if ENABLE_FEATURE_SYSLOG
|
---|
| 50 | if (logmode & LOGMODE_SYSLOG)
|
---|
| 51 | syslog(LOG_INFO, "%s", msg);
|
---|
| 52 | # endif
|
---|
| 53 | 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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.