]> infiniteadaptability.org Git - seeder/commitdiff
...
authoralex <[email protected]>
Fri, 3 Sep 2021 21:19:44 +0000 (14:19 -0700)
committeralex <[email protected]>
Fri, 3 Sep 2021 21:19:44 +0000 (14:19 -0700)
.gitignore
Makefile.am [new file with mode: 0644]
configure.ac
inc/default.h
inc/log.h
inc/main.h
seederd [new file with mode: 0755]
src/default.c
src/log.c
src/usage.c [new file with mode: 0644]

index 92947ef2ffa86440489d839fc1696e69bd757af2..eedf05a8d0c95d8dbae44c327c4415d1ac58b97f 100644 (file)
@@ -25,6 +25,3 @@ stamp-h1
 *.tests
 
 # binaries
-rss/rss-create
-rss/*_tests
-seederd/seederd
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..e247a38
--- /dev/null
@@ -0,0 +1,19 @@
+AM_CPPFLAGS = \
+       -I$(top_builddir)/inc/ \
+       -I$(top_srcdir)/inc/
+
+bin_PROGRAMS = seederd
+
+seederd_SOURCES = \
+       src/default.c \
+       src/log.c \
+       src/main.c \
+       src/opt/loglevel.c \
+       src/usage.c
+
+seederd_SOURCES += \
+       inc/default.h \
+       inc/log.h \
+       inc/main.h \
+       inc/opt.h \
+       inc/usage.h
index 87f152292fb9b00bbf2a5522ab9ff2ffe19c506a..ddbe49341c586e1d3fe3a11a1fa043f5f865b26c 100644 (file)
@@ -1,5 +1,11 @@
 AC_PREREQ([2.69])
 AC_INIT([seeder], [0.0.0])
+
+# Store build files not in main directory
+AC_CONFIG_AUX_DIR([build-aux])
+
+AM_INIT_AUTOMAKE([foreign subdir-objects nostdinc -Wall -Werror])
+
 AC_CONFIG_SRCDIR([src/main.c])
 AC_CONFIG_HEADERS([config.h])
 
@@ -15,4 +21,5 @@ AC_CHECK_HEADERS([stdlib.h])
 
 # Checks for library functions.
 
+AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
index bfe63a16a5b5547b77e9884c59b15c20a2e64357..c043bf8b1d720fcfb3828eb505e11819e0ab1855 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __DEFAULT_H_
 #define __DEFAULT_H_
 
+#include<opt.h>
+
 int defaults();
 
 #endif
index 43006ce1a6aa693bcd49898832acb4104d45810a..3ecca338271041caf2cf2b8b9948d6d935bd3517 100644 (file)
--- a/inc/log.h
+++ b/inc/log.h
@@ -3,6 +3,7 @@
 
 #include<stdarg.h>
 #include<stdio.h>
+#include<threads.h>
 
 extern int verbose_flag;
 
@@ -13,10 +14,13 @@ enum log_level {
        LOG_LEVEL_VERBOSE = 3  /* logging and debugging info */
 };
 
-#define log_err(...) log_message(LOG_LEVEL_ERRORS,stderr,__VA_ARGS__)
-#define log_info(...) log_message(LOG_LEVEL_VERBOSE,stdout,__VA_ARGS__)
-#define log_msg(...) log_message(LOG_LEVEL_DEFAULT,stdout,__VA_ARGS__)
+extern thrd_t logging_thread;
 
+#define log_err(...) log_enqueue(LOG_LEVEL_ERRORS,stderr,__VA_ARGS__)
+#define log_info(...) log_enqueue(LOG_LEVEL_VERBOSE,stdout,__VA_ARGS__)
+#define log_msg(...) log_enqueue(LOG_LEVEL_DEFAULT,stdout,__VA_ARGS__)
+
+void log_enqueue(enum log_level,FILE*,const char*,...);
 void log_message(enum log_level,FILE*,const char*,...);
 
 #endif
index b00db758ad195f0d91d0e7c56537587cefec704d..99e116d0d13a0877a460dce4f1a391b5d3cc402c 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __MAIN_H_
 #define __MAIN_H_
 
+#include<getopt.h>
 #include<stdlib.h>
 
 #include<default.h>
diff --git a/seederd b/seederd
new file mode 100755 (executable)
index 0000000..c2136b1
Binary files /dev/null and b/seederd differ
index b891dc47b3e8ec166b5172a7be34f223cf6dac02..262fd21e3c3cd8b45f445527b0dd49828eeff7e0 100644 (file)
@@ -1,6 +1,10 @@
 #include<default.h>
 
+thrd_t logging_thread;
+
 int defaults() {
+       logging_thread = thrd_current();
+
        opt_set_log_level(LOG_LEVEL_DEFAULT);
        
        return 1;
index c10d250120ad89d140bbf310ca98b192fd2a1af7..5c73ef529f4e42de9255a2f32fc472591c886f1d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2,11 +2,22 @@
 
 int verbose_flag = LOG_LEVEL_DEFAULT;
 
+void log_enqueue(enum log_level level, FILE *out_stream, const char *format,...) {
+       va_list args;
+       va_start(args,format);
+       vsnprintf(buf,format,args);
+       va_end(args);
+}
+
 void log_message(enum log_level level, FILE *out_stream, const char *format,...) {
-       if(level<=verbose_flag) {
+       if(level>verbose_flag) { return; }
+
+       if(thrd_equal(logging_thread,thrd_current)) {
                va_list args;
                va_start(args,format);
-               vfprintf(out_stream,format,args);
+               vfprintf(out_stream,message);
                va_end(args);
+       } else {
+               log_enqueue(level,out_stream,format,...);
        }
 }
diff --git a/src/usage.c b/src/usage.c
new file mode 100644 (file)
index 0000000..de83968
--- /dev/null
@@ -0,0 +1,4 @@
+#include<usage.h>
+
+void usage() {
+}