diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-12-13 18:20:45 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-12-13 18:20:45 +0000 |
commit | cfb04309fb01de8797f85f2f945e375fd6091a99 (patch) | |
tree | c63a917781d2602db08b190b582115b56806eee4 /src/main.c | |
parent | 60fbc52f285b19ccbc9723cdae135cbb22acfe98 (diff) | |
download | mailfromd-cfb04309fb01de8797f85f2f945e375fd6091a99.tar.gz mailfromd-cfb04309fb01de8797f85f2f945e375fd6091a99.tar.bz2 |
Ported r1536 from branches/release_4_2_patches (= r1535 from tags/release_4_2):
git-svn-id: file:///svnroot/mailfromd/trunk@1538 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -42,8 +42,6 @@ #endif #include "mailfromd.h" -#include "syslog_async.h" - /* Configurable options */ @@ -81,8 +79,11 @@ int foreground; /* Stay in foreground */ int single_process_option; /* Run in single process mode. */ unsigned long source_address = INADDR_ANY; /* Source address for TCP connections */ +#ifdef USE_SYSLOG_ASYNC int use_syslog_async = DEFAULT_SYSLOG_ASYNC; /* Use asynchronous syslog implementation */ +#endif + char *syslog_tag; /* Tag to mark syslog entries with. */ char *mailfromd_state_dir; /* see init_names() */ char *pidfile; /* see init_names() */ @@ -128,9 +129,12 @@ time_t response_timeout = 30; int syslog_printer (int prio, const char *fmt, va_list ap) { +#ifdef USE_SYSLOG_ASYNC if (use_syslog_async) { vsyslog_async (prio, fmt, ap); - } else { + } else +#endif + { #if HAVE_VSYSLOG vsyslog (prio, fmt, ap); #else @@ -142,6 +146,7 @@ syslog_printer (int prio, const char *fmt, va_list ap) return 0; } +#ifdef USE_SYSLOG_ASYNC void mf_gacopyz_syslog_async_log_printer(int level, char *fmt, va_list ap) { @@ -165,6 +170,7 @@ mf_gacopyz_syslog_async_log_printer(int level, char *fmt, va_list ap) } vsyslog_async(level, fmt, ap); } +#endif int syslog_error_printer (const char *fmt, va_list ap) @@ -1069,10 +1075,12 @@ static struct argp_option options[] = { N_("Log to stderr"), GRP+1 }, { "syslog", OPTION_SYSLOG, NULL, 0, N_("Log to syslog (default)"), GRP+1 }, +#ifdef USE_SYSLOG_ASYNC { "syslog-async", OPTION_SYSLOG_ASYNC, NULL, 0, N_("Use asynchronous syslog"), GRP+1 }, { "no-syslog-async", OPTION_NO_SYSLOG_ASYNC, NULL, 0, N_("Use system syslog"), GRP+1 }, +#endif { "log-tag", OPTION_LOG_TAG, N_("STRING"), 0, N_("Set the identifier used in syslog messages to STRING"), GRP+1 }, { "source-info", OPTION_SOURCE_INFO, NULL, 0, @@ -1392,6 +1400,7 @@ parse_opt (int key, char *arg, struct argp_state *state) log_to_stderr = 0; break; +#ifdef USE_SYSLOG_ASYNC case OPTION_SYSLOG_ASYNC: use_syslog_async = 1; break; @@ -1399,7 +1408,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case OPTION_NO_SYSLOG_ASYNC: use_syslog_async = 0; break; - +#endif case OPTION_TIMEOUT: set_option("timeout", arg, 1); break; @@ -1976,11 +1985,13 @@ mailfromd_show_defaults() printf("statedir: %s\n", mailfromd_state_dir); printf("socket: %s\n", portspec); printf("pidfile: %s\n", pidfile); +#ifdef USE_SYSLOG_ASYNC #if DEFAULT_SYSLOG_ASYNC == 1 printf("default syslog: non-blocking\n"); #else printf("default syslog: blocking\n"); #endif +#endif printf("database format: "); #if defined WITH_GDBM printf("GDBM"); @@ -1997,10 +2008,13 @@ log_setup(int want_stderr) { /* Set up logging */ if (!want_stderr) { +#ifdef USE_SYSLOG_ASYNC if (use_syslog_async) { openlog_async(syslog_tag, LOG_PID, log_facility); gacopyz_set_logger(mf_gacopyz_syslog_async_log_printer); - } else { + } else +#endif + { openlog(syslog_tag, LOG_PID, log_facility); gacopyz_set_logger(gacopyz_syslog_log_printer); } |