create project structure
This commit is contained in:
13 files changed
+221
No files matched your search
@@ -0,0 +1,16 @@
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -g
|
||||
LDFLAGS = -lm
|
||||
|
||||
LIBS = -lmysyslog -lmysyslog-text -lmysyslog-json
|
||||
|
||||
all: mysyslog-daemon
|
||||
|
||||
mysyslog-daemon: src/mysyslog-daemon.o
|
||||
$(CC) -o $@ $^ $(LIBS)
|
||||
|
||||
clean: rm -f src/*.o mysyslog-daemon
|
||||
|
||||
deb: # Deb package building logic
|
||||
|
||||
.PHONY: all clean deb
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "mysyslog.h"
|
||||
|
||||
static volatile int keep_running = 1;
|
||||
|
||||
void int_handler(int dummy) {
|
||||
keep_running = 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
signal(SIGINT, int_handler);
|
||||
signal(SIGTERM, int_handler);
|
||||
|
||||
const char* path = "/var/log/mysyslog.log";
|
||||
int driver = 1; // Default to text driver
|
||||
int format = 1; // Default to text format
|
||||
|
||||
while (keep_running) {
|
||||
mysyslog("Daemon log message", INFO, driver, format, path);
|
||||
sleep(60); // Log every minute
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user