change dir name

This commit is contained in:
2024-12-04 04:37:49 +03:00
parent b06e791d4c
commit 85ac6fb89f
4 changed files with 0 additions and 0 deletions

52
libmysyslog-daemon/.gitignore vendored Normal file
View File

@@ -0,0 +1,52 @@
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

View File

@@ -0,0 +1,17 @@
CC = gcc
CFLAGS = -Wall -Wextra -I../libmysyslog
LDFLAGS = -L../libmysyslog -lmysyslog
TARGET = libmysyslog-daemon
all: $(TARGET)
$(TARGET): libmysyslog-daemon.o
$(CC) -o $(TARGET) libmysyslog-daemon.o $(LDFLAGS)
libmysyslog-daemon.o: libmysyslog-daemon.c
$(CC) $(CFLAGS) -c libmysyslog-daemon.c
clean:
rm -f $(TARGET) *.o
.PHONY: all clean

View File

@@ -0,0 +1,44 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include "libmysyslog.h"
#define CONFIG_PATH "/etc/mysyslog/mysyslog.cfg"
static volatile int keepRunning = 1;
void intHandler(int dummy) {
keepRunning = 0;
}
void read_config(const char* path, int* level, int* driver, int* format, char* log_path) {
FILE* file = fopen(path, "r");
if (!file) {
fprintf(stderr, "Could not open config file: %s\n", path);
exit(EXIT_FAILURE);
}
fscanf(file, "level=%d\n", level);
fscanf(file, "driver=%d\n", driver);
fscanf(file, "format=%d\n", format);
fscanf(file, "path=%s\n", log_path);
fclose(file);
}
int main() {
signal(SIGINT, intHandler);
signal(SIGTERM, intHandler);
int level, driver, format;
char log_path[256];
read_config(CONFIG_PATH, &level, &driver, &format, log_path);
while (keepRunning) {
mysyslog("Daemon log message", level, driver, format, log_path);
sleep(5); // Log every 5 seconds
}
return 0;
}

View File

@@ -0,0 +1,4 @@
level=1
driver=0
format=0
path=/var/log/mysyslog.log