From 5dcc5c2e9a77867f6c87ec3d9c4e0aae3787346c Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 3 Sep 2021 14:19:44 -0700 Subject: [PATCH] ... --- .gitignore | 3 --- Makefile.am | 19 +++++++++++++++++++ configure.ac | 7 +++++++ inc/default.h | 2 ++ inc/log.h | 10 +++++++--- inc/main.h | 1 + seederd | Bin 0 -> 24808 bytes src/default.c | 4 ++++ src/log.c | 15 +++++++++++++-- src/usage.c | 4 ++++ 10 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 Makefile.am create mode 100755 seederd create mode 100644 src/usage.c diff --git a/.gitignore b/.gitignore index 92947ef..eedf05a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 0000000..e247a38 --- /dev/null +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 87f1522..ddbe493 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/inc/default.h b/inc/default.h index bfe63a1..c043bf8 100644 --- a/inc/default.h +++ b/inc/default.h @@ -1,6 +1,8 @@ #ifndef __DEFAULT_H_ #define __DEFAULT_H_ +#include + int defaults(); #endif diff --git a/inc/log.h b/inc/log.h index 43006ce..3ecca33 100644 --- a/inc/log.h +++ b/inc/log.h @@ -3,6 +3,7 @@ #include #include +#include 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 diff --git a/inc/main.h b/inc/main.h index b00db75..99e116d 100644 --- a/inc/main.h +++ b/inc/main.h @@ -1,6 +1,7 @@ #ifndef __MAIN_H_ #define __MAIN_H_ +#include #include #include diff --git a/seederd b/seederd new file mode 100755 index 0000000000000000000000000000000000000000..c2136b197f1c9ee88fedf25130308b2f85f3b76f GIT binary patch literal 24808 zcmeHPdvqMtdB3xx*;#qzkz~o1WRb8YBFGTEj4?L0VI?Gcz4u$~ zj#iM+BbANn-k1SGqAwcHKQ(0UBHg#^iNv2s5(2!)}jP&C0L%Ka~*hxkx3`v*D&R?bn3EvbTY9ZXG*n%P3?Sh>SwbpoZz+vC5>svG~y8X2p z>h6k`(OCbwwJoEAO{1}R=3vvo_3N6}t!+*vn%BsFSEG6g<<{+e;=p^oPwz1fzVNem zC667d-uanr7rbi)wVT>N{z!)k>Fa7FZi6Pd?3Zx^hzbw!N^wwWeB143JRbew*oGHx z<6)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zwO9z|?L`=sYo46#4fDnBy$xMbGFF=vq9OS^7lsE@iSS4yK8Rfn7d`@zOCvnUiic?> znA-~qH0b_RN;{T|6B$x^c#~a>@)FtABJ8H935GAz?ZMDyUG zIQ%JywXl?+11YTZ@`x~G$>?Z=3^X=Aif2ADYRy2KhZ7*vcvvQyX?Q~^Aun-rbVLv6 zkwG|NN|~yWtt=Qv4Uw@Jp5MYFc}C-CdEAUEBbt$0^t(CmqWu|KRY&5(^fXkFvG`De z@koDvGCIK&HZzSfj&L!G^)RE_lbR*|=V!Vzqd5`Nj4Zq^V94KVYO&O1oZvff(A>}V zynbNVKuS4<=SODI2N1dTyv|@4U_}kx_MPDW0pCn={k$Gw*sAS#xj^@Gxn(;DtPZm6 z=XDFiQ(BpxB2%2$p66#;WzrIe>*w_i!{dmY{JT9Mn&dJM0D zoW3z-n%7GV1KQr*e$5u|141!n`|P?(S9n-AnCo}<|0ZqUp&j!2i(zj3ahJ6qes_RJ zRZ#n6(f_~c7J>@d{pj@75FA{v4M+=~7`x>oUfb zM4ivk_NQ{0Id;rmv50-m8l~~V64q4EUDsKQ*jt;G{&v@ZciYo?(9I*uJ?+YV>08)u z()RB79q3Z_|CYTlisrf)Zq@cmI)C2Kt?;Vs#E@^#n!6XV?|HY<7-vNdxn5=y?W#hG wPH6iXy)b+SxEpZrxaa?$G{3pJDD98$kzm1dN_YL0i`a+s +thrd_t logging_thread; + int defaults() { + logging_thread = thrd_current(); + opt_set_log_level(LOG_LEVEL_DEFAULT); return 1; diff --git a/src/log.c b/src/log.c index c10d250..5c73ef5 100644 --- 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 index 0000000..de83968 --- /dev/null +++ b/src/usage.c @@ -0,0 +1,4 @@ +#include + +void usage() { +} -- 2.39.5