-static void vMessage(uint32_t class, char *message, va_list args)
-{
- FILE *dest=stdout;
- if (class & message_level) {
- if (class&M_FATAL || class&M_ERROR || class&M_WARNING) {
- dest=stderr;
- }
- vfprintf(dest,message,args);
- }
-/* XXX do something about syslog output here */
-#if 0
- /* Maybe send message to syslog */
- vsprintf(buff, message, args);
- /* XXX Send each line as a separate log entry */
- log(syslog_prio[level], buff);
-#endif /* 0 */
-}
-
-void Message(uint32_t class, char *message, ...)
-{
- va_list ap;
-
- va_start(ap,message);
-
- vMessage(class,message,ap);
-
- va_end(ap);
-}
-
-static void vfatal(int status, bool_t perror, char *message, va_list args)
-{
- int err;
-
- err=errno;
-
- enter_phase(PHASE_SHUTDOWN);
- if (perror) {
- Message(M_FATAL, "secnet fatal error: ");
- vMessage(M_FATAL, message, args);
- Message(M_FATAL, ": %s\n",strerror(err));
- }
- else {
- Message(M_FATAL, "secnet fatal error: ");
- vMessage(M_FATAL,message,args);
- }
- exit(status);
-}
-
-void fatal(char *message, ...)
-{
- va_list args;
- va_start(args,message);
- vfatal(current_phase,False,message,args);
- va_end(args);
-}
-
-void fatal_status(int status, char *message, ...)
-{
- va_list args;
- va_start(args,message);
- vfatal(status,False,message,args);
- va_end(args);
-}
-
-void fatal_perror(char *message, ...)
-{
- va_list args;
- va_start(args,message);
- vfatal(current_phase,True,message,args);
- va_end(args);
-}
-
-void fatal_perror_status(int status, char *message, ...)
-{
- va_list args;
- va_start(args,message);
- vfatal(status,True,message,args);
- va_end(args);
-}
-
-void cfgfatal(struct cloc loc, string_t facility, char *message, ...)
-{
- va_list args;
-
- va_start(args,message);
-
- enter_phase(PHASE_SHUTDOWN);
-
- if (loc.file && loc.line) {
- Message(M_FATAL, "config error (%s, %s:%d): ",facility,loc.file,
- loc.line);
- } else if (!loc.file && loc.line) {
- Message(M_FATAL, "config error (%s, line %d): ",facility,loc.line);
- } else {
- Message(M_FATAL, "config error (%s): ",facility);
- }
-
- vMessage(M_FATAL,message,args);
- va_end(args);
- exit(current_phase);
-}
-
-char *safe_strdup(char *s, char *message)