=================================================================== RCS file: /cvs/cvs/blind/blind.c,v retrieving revision 1.6 retrieving revision 1.14 diff -u -p -r1.6 -r1.14 --- blind/blind.c 2022/03/17 14:30:21 1.6 +++ blind/blind.c 2022/03/20 18:47:16 1.14 @@ -17,15 +17,17 @@ #include #include #include +#include #include #include "blind.h" +#include "config.h" #include "log.h" static void usage(void); -int daemonize = 1; -int verbose = 0; +int daemonize = 1; +struct blind *bl; static void usage(void) @@ -40,6 +42,7 @@ int main(int argc, char *argv[]) { int ch; + int verbose = 0; int no_action = 0; const char *config = BL_CONF; @@ -59,7 +62,7 @@ main(int argc, char *argv[]) config = optarg; break; case 'v': - verbose = 1; + verbose = BL_OPT_VERBOSE; break; default: usage(); @@ -72,18 +75,31 @@ main(int argc, char *argv[]) usage(); log_init(daemonize, LOG_DAEMON); - log_setv(verbose); - log_info("%s %s starting", BL_TEXT, BL_VERS); - log_debug("verbose mode"); + log_info("%s %s", BL_TEXT, BL_VERS); - // todo[0]: conf file format + ideas - // todo[1]: default conf defines in blind.h - // todo[2]: struct blind in blind.h - // todo[3]: initialize defualt config in blind.c + if ((bl = config_init()) == NULL) + log_fatal("initialization failed"); + bl->bl_opt |= verbose; + log_setv(verbose); + log_debug("verbose on"); + + if (strlcpy(bl->bl_conf, config, PATH_MAX) >= PATH_MAX) + log_fatal("file name exceeds PATH_MAX"); + + log_debug("config_load: %s", bl->bl_conf); + if (config_load(bl)) + log_fatal("config_load: %s", bl->bl_conf); + + log_debug("conf=%s", bl->bl_conf); + log_debug("sock=%s", bl->bl_sock); + log_debug(" ttl=%d", bl->bl_ttl); + log_debug(" opt=%d", bl->bl_opt); + log_debug(" flg=%d", bl->bl_flg); + // TAILQ_INIT(&offline_queue) - // parse_config + // fork + process setup + communication setup exit(0); }