--- /dev/null
+# CC = c89
+CC = gcc -ansi -g
+
+ARFLAGS = rv
+
+DESTDIR = $(HOME)
+# DESTDIR = /usr/local
+
+# LIBCOMPATINCS =
+# LIBCOMPATOBJS =
+
+LIBCOMPATINCS = syslog.h stdint.h libgen.h
+LIBCOMPATOBJS = libcompat.a(syslog.o)
+
+all: libcompat.a
+
+libcompat.a: $(LIBCOMPATOBJS)
+# $(AR) $(ARFLAGS) $@ $?
+
+syslog.o: syslog.c syslog.h
+
+install: $(LIBCOMPATINCS)
+ -mkdir $(DESTDIR)/include
+ cp $(LIBCOMPATINCS) $(DESTDIR)/include
+ -mkdir $(DESTDIR)/lib/$(SYSTYPE)
+ cp libcompat.a $(DESTDIR)/lib/$(SYSTYPE)
+
+clean:
+ rm -f *.o *.a
--- /dev/null
+# CC = c89
+CC = gcc -ansi
+
+INCDIR = ../
+LIBDIR = ../
+
+CFLAGS = -g -I$(INCDIR) -DLOG_PERROR_DOESNT_WORK
+LOADLIBES = -L$(LIBDIR) -lcompat -lnetinet
+
+all: testsyslog
+
+testsyslog: testsyslog.o
+ $(CC) $(CFLAGS) $(LDFLAGS) testsyslog.o $(LOADLIBES) -o testsyslog
+
+clean:
+ rm -f *.o
+
+depend:
+ gcc -MM $(CFLAGS) *.c
+
+testsyslog.o: testsyslog.c
--- /dev/null
+#include <syslog.h>
+
+int main(int argc, char *argv[]) {
+ openlog(argv[0], LOG_PERROR, LOG_LOCAL0);
+ setlogmask(LOG_UPTO(LOG_INFO));
+ syslog(LOG_INFO, "Hello, World!");
+ syslog(LOG_INFO, "%d, %d, %d, %s", 1, 2, 3, "viele");
+ syslog(LOG_DEBUG, "This is a debug message");
+ closelog();
+
+ return 0;
+}
--- /dev/null
+#ifndef OUR_LIBGEN_H
+#define OUR_LIBGEN_H
+
+#endif
--- /dev/null
+#ifndef OUR_STDINT_H
+#define OUR_STDINT_H
+
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+
+#endif
--- /dev/null
+#include <syslog.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#define OUR_IDENT_LEN 256
+
+static unsigned ourMaskpri = 0xffffffff;
+static unsigned ourLogopt = 0;
+static char ourIdent[OUR_IDENT_LEN] = "";
+
+void SYSLOG_syslog(int priority, const char *message, ...) {
+ va_list ap;
+ if ((ourLogopt & LOG_PERROR) && (ourMaskpri & (1 << priority))) {
+ fprintf(stderr, "%s: ", ourIdent);
+ va_start(ap, message);
+ vfprintf(stderr, message, ap);
+ va_end(ap);
+ fprintf(stderr, "%c", '\n');
+ }
+
+ va_start(ap, message);
+ vsyslog(priority, message, ap);
+ va_end(ap);
+}
+
+void SYSLOG_openlog(const char *ident, int logopt, int facility) {
+ strncpy(ourIdent, ident, OUR_IDENT_LEN-1);
+ ourLogopt = logopt;
+ openlog(ident, logopt, facility);
+}
+
+void SYSLOG_closelog(void) {
+ closelog();
+}
+
+int SYSLOG_setlogmask(int maskpri) {
+ ourMaskpri = maskpri;
+ return setlogmask(maskpri);
+}
--- /dev/null
+#ifndef OUR_SYSLOG_H
+#define OUR_SYSLOG_H
+
+#include </usr/include/syslog.h>
+
+#if !defined(LOG_PERROR) || defined(LOG_PERROR_DOESNT_WORK)
+
+#if !defined(LOG_PERROR)
+#define LOG_PERROR 0x20 /* log to stderr as well */
+#endif
+
+void SYSLOG_openlog(const char *ident, int logopt, int facility);
+void SYSLOG_syslog(int priority, const char *message, ...);
+void SYSLOG_closelog();
+int SYSLOG_setlogmask(int maskpri);
+
+#define syslog SYSLOG_syslog
+#define openlog SYSLOG_openlog
+#define closelog SYSLOG_closelog
+#define setlogmask SYSLOG_setlogmask
+
+#endif
+#endif