1 /* Copyright (C) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
27 #include "utmpd-private.h"
30 /* This variable indicates if we have forked. If set, we log messages
31 via the system logger. Otherwise we simply print the program name
32 and the message to standard error. */
36 /* Log error message MESSAGE, which is a printf-style format string
38 If ERRNUM is nonzero, also log its corresponding system error message.
39 Exit with status STATUS if it is nonzero. */
41 error (int status
, int errnum
, const char *message
, ...)
46 va_start (ap
, message
);
47 vasprintf (&buffer
, message
, ap
);
53 syslog (LOG_ERR
, "%s", buffer
);
55 syslog (LOG_ERR
, "%s: %s", buffer
, strerror (errnum
));
60 fprintf (stderr
, "%s: %s\n", program_invocation_name
, buffer
);
62 fprintf (stderr
, "%s: %s: %s\n", program_invocation_name
, buffer
,
73 /* Log warning message MESSAGE, which is a printf-style format string
75 If ERRNUM is nonzero, also log its corresponding system error message. */
77 warning (int errnum
, const char *message
, ...)
82 va_start (ap
, message
);
83 vasprintf (&buffer
, message
, ap
);
89 syslog (LOG_WARNING
, "%s", buffer
);
91 syslog (LOG_WARNING
, "%s: %s", buffer
, strerror (errnum
));
96 printf ("%s: %s\n", program_invocation_name
, buffer
);
98 printf ("%s: %s: %s\n", program_invocation_name
, buffer
,