*.tests
# binaries
-rss/rss-create
-rss/*_tests
-seederd/seederd
--- /dev/null
+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
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])
# Checks for library functions.
+AC_CONFIG_FILES([Makefile])
AC_OUTPUT
#ifndef __DEFAULT_H_
#define __DEFAULT_H_
+#include<opt.h>
+
int defaults();
#endif
#include<stdarg.h>
#include<stdio.h>
+#include<threads.h>
extern int verbose_flag;
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
#ifndef __MAIN_H_
#define __MAIN_H_
+#include<getopt.h>
#include<stdlib.h>
#include<default.h>
#include<default.h>
+thrd_t logging_thread;
+
int defaults() {
+ logging_thread = thrd_current();
+
opt_set_log_level(LOG_LEVEL_DEFAULT);
return 1;
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,...);
}
}
--- /dev/null
+#include<usage.h>
+
+void usage() {
+}