aboutsummaryrefslogtreecommitdiffstats
path: root/src/pt-tls-client/pt-tls-client.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-06-02 11:55:59 +0200
committerMartin Willi <martin@revosec.ch>2014-06-04 15:53:06 +0200
commitb7d71ff95d22eeb6cbd30da3ba83e5010ffa3d8a (patch)
tree90fd7de886553284adcf50b9ce2f6a1afcbcbcd0 /src/pt-tls-client/pt-tls-client.c
parent481f1d1c9a24f773d2556f2435348b88ca6c7ae6 (diff)
downloadstrongswan-b7d71ff95d22eeb6cbd30da3ba83e5010ffa3d8a.tar.bz2
strongswan-b7d71ff95d22eeb6cbd30da3ba83e5010ffa3d8a.tar.xz
pt-tls-client: Support platforms not having syslog()
Diffstat (limited to 'src/pt-tls-client/pt-tls-client.c')
-rw-r--r--src/pt-tls-client/pt-tls-client.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pt-tls-client/pt-tls-client.c b/src/pt-tls-client/pt-tls-client.c
index b2d439abe..8b41ae25e 100644
--- a/src/pt-tls-client/pt-tls-client.c
+++ b/src/pt-tls-client/pt-tls-client.c
@@ -21,7 +21,9 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_SYSLOG
#include <syslog.h>
+#endif
#include <pt_tls.h>
#include <pt_tls_client.h>
@@ -126,13 +128,13 @@ static bool load_key(char *filename)
* Logging and debug level
*/
static bool log_to_stderr = TRUE;
+#ifdef HAVE_SYSLOG
static bool log_to_syslog = TRUE;
+#endif /* HAVE_SYSLOG */
static level_t default_loglevel = 1;
static void dbg_pt_tls(debug_t group, level_t level, char *fmt, ...)
{
- char buffer[8192];
- char *current = buffer, *next;
va_list args;
if (level <= default_loglevel)
@@ -144,8 +146,12 @@ static void dbg_pt_tls(debug_t group, level_t level, char *fmt, ...)
va_end(args);
fprintf(stderr, "\n");
}
+#ifdef HAVE_SYSLOG
if (log_to_syslog)
{
+ char buffer[8192];
+ char *current = buffer, *next;
+
/* write in memory buffer first */
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, args);
@@ -163,6 +169,7 @@ static void dbg_pt_tls(debug_t group, level_t level, char *fmt, ...)
current = next;
}
}
+#endif /* HAVE_SYSLOG */
}
}
@@ -177,10 +184,12 @@ static void init_log(const char *program)
{
setbuf(stderr, NULL);
}
+#ifdef HAVE_SYSLOG
if (log_to_syslog)
{
openlog(program, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
}
+#endif /* HAVE_SYSLOG */
}
/**