summaryrefslogtreecommitdiff
path: root/os_compat.h
diff options
context:
space:
mode:
authorRobert Norris <rw_norris@hotmail.com>2017-03-05 18:43:33 +0000
committerFred Wright <fw@fwright.net>2017-03-05 13:43:14 -0800
commit9f870a11218d0bc6364d6b333fd878106746adf9 (patch)
tree2e69141ae377dcb27c09fa7771b61fd30272fc43 /os_compat.h
parenta32c93f5c70af935e4ff02e19959da65f078d166 (diff)
downloadgpsd-9f870a11218d0bc6364d6b333fd878106746adf9.tar.gz
OS syslog compatibility fallback.
Mainly for Windows systems which doesn't have syslog(). Implement simple fallback to print to stderr, rather than a more complicated use of Windows Event Log. Also basic fallbacks for openlog() and closelog() which don't really do anything. TESTED: Functions build on Windows cross build 'scons build-all check' passes on Linux Signed-off-by: Fred Wright <fw@fwright.net>
Diffstat (limited to 'os_compat.h')
-rw-r--r--os_compat.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/os_compat.h b/os_compat.h
index 00e56559..9321809f 100644
--- a/os_compat.h
+++ b/os_compat.h
@@ -57,6 +57,38 @@ int clock_gettime(clockid_t, struct timespec *);
int os_daemon(int nochdir, int noclose);
+
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#else
+/*
+ * Substitutes for syslog functions
+ * (only subset of defines used by gpsd components listed)
+ *
+ */
+/* Copy of syslog.h defines when otherwise not available */
+/* priorities (these are ordered) */
+#define LOG_EMERG 0 /* system is unusable */
+#define LOG_ALERT 1 /* action must be taken immediately */
+#define LOG_CRIT 2 /* critical conditions */
+#define LOG_ERR 3 /* error conditions */
+#define LOG_WARNING 4 /* warning conditions */
+#define LOG_NOTICE 5 /* normal but significant condition */
+#define LOG_INFO 6 /* informational */
+#define LOG_DEBUG 7 /* debug-level messages */
+/* Option flags for openlog */
+#define LOG_PID 0x01 /* log the pid with each message */
+#define LOG_PERROR 0x20 /* log to stderr as well */
+/* facility codes */
+#define LOG_USER (1<<3) /* random user-level messages */
+#define LOG_DAEMON (3<<3) /* system daemons */
+
+void syslog(int priority, const char *format, ...);
+void openlog(const char *__ident, int __option, int __facility);
+void closelog(void);
+#endif /* !HAVE_SYSLOG_H */
+
+
/* Provide BSD strlcat()/strlcpy() on platforms that don't have it */
#ifndef HAVE_STRLCAT