]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Initial revision
authorhadaq <hadaq>
Thu, 25 Jul 2002 09:25:13 +0000 (09:25 +0000)
committerhadaq <hadaq>
Thu, 25 Jul 2002 09:25:13 +0000 (09:25 +0000)
compat/Makefile [new file with mode: 0644]
compat/examples/Makefile [new file with mode: 0644]
compat/examples/testsyslog.c [new file with mode: 0644]
compat/libgen.h [new file with mode: 0644]
compat/stdint.h [new file with mode: 0644]
compat/syslog.c [new file with mode: 0644]
compat/syslog.h [new file with mode: 0644]

diff --git a/compat/Makefile b/compat/Makefile
new file mode 100644 (file)
index 0000000..e50905b
--- /dev/null
@@ -0,0 +1,29 @@
+# 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
diff --git a/compat/examples/Makefile b/compat/examples/Makefile
new file mode 100644 (file)
index 0000000..9dbbacd
--- /dev/null
@@ -0,0 +1,21 @@
+# 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
diff --git a/compat/examples/testsyslog.c b/compat/examples/testsyslog.c
new file mode 100644 (file)
index 0000000..a223522
--- /dev/null
@@ -0,0 +1,12 @@
+#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;
+}
diff --git a/compat/libgen.h b/compat/libgen.h
new file mode 100644 (file)
index 0000000..faed44f
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef OUR_LIBGEN_H
+#define OUR_LIBGEN_H
+
+#endif
diff --git a/compat/stdint.h b/compat/stdint.h
new file mode 100644 (file)
index 0000000..e75ff6f
--- /dev/null
@@ -0,0 +1,12 @@
+#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
diff --git a/compat/syslog.c b/compat/syslog.c
new file mode 100644 (file)
index 0000000..58eb62f
--- /dev/null
@@ -0,0 +1,40 @@
+#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);
+}
diff --git a/compat/syslog.h b/compat/syslog.h
new file mode 100644 (file)
index 0000000..e70baf6
--- /dev/null
@@ -0,0 +1,23 @@
+#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