X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=innduct.git;a=blobdiff_plain;f=help.c;h=34b1018661ab7f29dee8d4711ed40ce42d98c5b5;hp=144ab86f7298f9c2a2689534ab86855ce18755a8;hb=bd52671fe8ab7e1fcef0e82a91d6bf4d5d6130eb;hpb=f4aee95c41a0d6231d115386b8fbb23f6b8e349a diff --git a/help.c b/help.c index 144ab86..34b1018 100644 --- a/help.c +++ b/help.c @@ -1,7 +1,7 @@ /* * innduct * tailing reliable realtime streaming feeder for inn - * logging and utility functions + * help.c - logging and utility functions * * Copyright (C) 2010 Ian Jackson * @@ -70,37 +70,26 @@ void logv(int sysloglevel, const char *pfx, int errnoval, 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) @@ -218,6 +207,11 @@ void xsigsetdefault(int signo) { 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); @@ -235,13 +229,13 @@ void check_isreg(const struct stat *stab, const char *path, 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); }