-Wall \
-Werror
+if ENABLE_DEBUG
+else
+AM_CPPFLAGS += \
+ -DNDEBUG
+endif
+
bin_PROGRAMS = seederd
seederd_SOURCES = \
src/default.c \
src/log.c \
src/main.c \
+ src/opt/config.c \
src/opt/loglevel.c \
src/setup.c \
src/usage.c
LOG_LEVEL_VERBOSE = 3 /* logging and debugging info */
};
+#ifndef NDEBUG
+#define LOG_WITH_THREAD_PREFIX(level,fd,...) log_message(level,fd,LOG_THREAD_PREFIX_MESSAGE,pthread_self());log_message(level,fd,__VA_ARGS__)
+#define log_err(...) LOG_WITH_THREAD_PREFIX(LOG_LEVEL_ERRORS,stderr,__VA_ARGS__)
+#define log_info(...) LOG_WITH_THREAD_PREFIX(LOG_LEVEL_VERBOSE,stdout,__VA_ARGS__)
+#define log_msg(...) LOG_WITH_THREAD_PREFIX(LOG_LEVEL_DEFAULT,stdout,__VA_ARGS__)
+#else
#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__)
+#endif
#define LOG_FLUSH_MESSAGE "flushing log queue...\n"
#define LOG_THREAD_START_MESSAGE "logging thread start\n"
#include<getopt.h>
#include<stdlib.h>
-#include<unistd.h>
#include<default.h>
#include<log.h>
#include<setup.h>
#include<usage.h>
+#define MAIN_SHUTDOWN_MESSAGE "shutting down...\n"
+
int main(int,char**);
#endif
#include<log.h>
+#define OPT_LOADING_CONFIG_FILE_MESSAGE "loading config file %s\n"
+
+int opt_load_config_file(char*);
void opt_set_log_level(enum log_level);
#endif
int defaults() {
logging_thread = pthread_self();
+#ifndef NDEBUG
+ opt_set_log_level(LOG_LEVEL_VERBOSE);
+#else
opt_set_log_level(LOG_LEVEL_DEFAULT);
+#endif
return 1;
}
#include<main.h>
static struct option long_options[] = {
+ {"config-file", required_argument, 0, 'c'},
{"daemon", no_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{"quiet", no_argument, &verbose_flag, LOG_LEVEL_SILENT},
while(1) {
int option_index = 0;
- if((c = getopt_long(argc,argv,"dhqv",long_options,&option_index))==-1) { break; }
+ if((c = getopt_long(argc,argv,"c:dhqv",long_options,&option_index))==-1) { break; }
switch(c) {
+ case 'c':
+ if(opt_load_config_file(optarg)<0) { return EXIT_FAILURE; }
+ break;
case 'd':
log_err("not implemented\n");
return EXIT_FAILURE;
if(setup()<0) { return EXIT_FAILURE; }
+ log_err("this is a test %d %s\n",10,"what?");
+ while(1) { }
+
return EXIT_FAILURE;
}
--- /dev/null
+#include<opt.h>
+
+int opt_load_config_file(char *path) {
+ log_info(OPT_LOADING_CONFIG_FILE_MESSAGE,path);
+ log_err("not implemented\n");
+ return -1;
+}