]> infiniteadaptability.org Git - seeder/commitdiff
...
authoralex <[email protected]>
Fri, 3 Sep 2021 23:53:58 +0000 (16:53 -0700)
committeralex <[email protected]>
Fri, 3 Sep 2021 23:53:58 +0000 (16:53 -0700)
inc/log.h
inc/setup.h [new file with mode: 0644]
src/default.c
src/log.c
src/main.c
src/setup.c [new file with mode: 0644]

index 3ecca338271041caf2cf2b8b9948d6d935bd3517..08dcf18aa7dfba4176cbe59e419fc1882b5d5911 100644 (file)
--- a/inc/log.h
+++ b/inc/log.h
@@ -3,7 +3,6 @@
 
 #include<stdarg.h>
 #include<stdio.h>
-#include<threads.h>
 
 extern int verbose_flag;
 
@@ -14,13 +13,12 @@ enum log_level {
        LOG_LEVEL_VERBOSE = 3  /* logging and debugging info */
 };
 
-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*,...);
+void log_poll();
 
 #endif
diff --git a/inc/setup.h b/inc/setup.h
new file mode 100644 (file)
index 0000000..9077be8
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __SETUP_H_
+#define __SETUP_H_
+
+#include<pthread.h>
+
+int setup();
+
+#endif
index 262fd21e3c3cd8b45f445527b0dd49828eeff7e0..b891dc47b3e8ec166b5172a7be34f223cf6dac02 100644 (file)
@@ -1,10 +1,6 @@
 #include<default.h>
 
-thrd_t logging_thread;
-
 int defaults() {
-       logging_thread = thrd_current();
-
        opt_set_log_level(LOG_LEVEL_DEFAULT);
        
        return 1;
index 5c73ef529f4e42de9255a2f32fc472591c886f1d..38691a2f75add3092a54283cc9d3e596e92b958a 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -12,7 +12,7 @@ void log_enqueue(enum log_level level, FILE *out_stream, const char *format,...)
 void log_message(enum log_level level, FILE *out_stream, const char *format,...) {
        if(level>verbose_flag) { return; }
 
-       if(thrd_equal(logging_thread,thrd_current)) {
+       if(thrd_equal(logging_thread,thrd_current())) {
                va_list args;
                va_start(args,format);
                vfprintf(out_stream,message);
@@ -21,3 +21,10 @@ void log_message(enum log_level level, FILE *out_stream, const char *format,...)
                log_enqueue(level,out_stream,format,...);
        }
 }
+
+int log_poll(void *arg) {
+       while(1) {
+       }
+
+       return 1;
+}
index 84740b56f8365bc91ce274abf17fb32b6833bfe4..97a854bf14aabed37c9e699134b0457fb2880ce0 100644 (file)
@@ -40,5 +40,8 @@ int main(int argc, char **argv) {
 
        log_msg("here?\n");
 
+       if(setup()<0) { return EXIT_FAILURE; }
+
+       log_msg("here!\n");
        return EXIT_FAILURE;
 }
diff --git a/src/setup.c b/src/setup.c
new file mode 100644 (file)
index 0000000..b71171c
--- /dev/null
@@ -0,0 +1,8 @@
+#include<setup.h>
+
+int setup() {
+       if(pthread_create(&logging_thread,&log_poll)!=0) {
+               perror("pthread_create");
+               return -1;
+       }
+}