/*
* innduct
* tailing reliable realtime streaming feeder for inn
- * logging and utility functions
+ * help.c - logging and utility functions
*
* Copyright (C) 2010 Ian Jackson <ijackson@chiark.greenend.org.uk>
*
exit(estatus); \
}
-#define DEFLOG(fn, pfx, sysloglevel, err) \
- static void fn(const char *fmt, ...) { \
- VA; \
- logv(sysloglevel, pfx, err, fmt, al); \
- va_end(al); \
+#define DEFLOG(fn, pfx, sysloglevel, err) \
+ void fn(const char *fmt, ...) { \
+ VA; \
+ logv(sysloglevel, pfx, err, fmt, al); \
+ va_end(al); \
}
-#define INNLOGSET_DECLARE(fn, pfx, sysloglevel) \
- static void duct_log_##fn(int l, const char *fmt, va_list al, int errval) \
- PRINTF(3,0); \
- static void duct_log_##fn(int l, const char *fmt, va_list al, int errval) { \
- logv(sysloglevel, pfx, errval ? errval : -1, fmt, al); \
+#define INNLOGSET_DEFINE(fn, pfx, sysloglevel) \
+ void duct_log_##fn(int l, const char *fmt, va_list al, int errval) { \
+ logv(sysloglevel, pfx, errval ? errval : -1, fmt, al); \
}
-#define INNLOGSET_CALL(fn, pfx, sysloglevel) \
- message_handlers_##fn(1, duct_log_##fn);
-static int innduct_fatal_cleanup(void) { return 12; } /* used for libinn die */
-
/* We want to extend the set of logging functions from inn, and we
* want to prepend the site name to all our messages. */
DEFFATAL(syscrash, "critical", LOG_CRIT, errno, 16);
DEFFATAL(crash, "critical", LOG_CRIT, -1, 16);
-#define INNLOGSETS(INNLOGSET) \
- INNLOGSET(die, "fatal", LOG_ERR) \
- INNLOGSET(warn, "warning", LOG_WARNING) \
- INNLOGSET(notice, "notice", LOG_NOTICE) \
- INNLOGSET(trace, "trace", LOG_NOTICE)
-INNLOGSETS(INNLOGSET_DECLARE)
+INNLOGSETS(INNLOGSET_DEFINE)
DEFLOG(info, "info", LOG_INFO, -1)
DEFLOG(dbg, "debug", LOG_DEBUG, -1)
sa.sa_handler= SIG_DFL;
xsigaction(signo,&sa);
}
+void raise_default(int signo) {
+ xsigsetdefault(signo);
+ raise(signo);
+ abort();
+}
void xgettimeofday(struct timeval *tv_r) {
int r= gettimeofday(tv_r,0);
what, path, (unsigned long)stab->st_mode);
}
-static void xfstat(int fd, struct stat *stab_r, const char *what) {
+void xfstat(int fd, struct stat *stab_r, const char *what) {
int r= fstat(fd, stab_r);
if (r) syscrash("could not fstat %s", what);
}
-static void xfstat_isreg(int fd, struct stat *stab_r,
- const char *path, const char *what) {
+void xfstat_isreg(int fd, struct stat *stab_r,
+ const char *path, const char *what) {
xfstat(fd, stab_r, what);
check_isreg(stab_r, path, what);
}