=================================================================== RCS file: /cvs/cvs/blind/blind.c,v retrieving revision 1.12 retrieving revision 1.22 diff -u -p -r1.12 -r1.22 --- blind/blind.c 2022/03/19 10:04:59 1.12 +++ blind/blind.c 2022/04/10 19:35:20 1.22 @@ -16,18 +16,17 @@ #include #include -#include #include #include +#include #include "blind.h" #include "config.h" #include "log.h" -static void usage(void); +static void usage(void); -int daemonize = 1; -struct blind *bl; +struct blind *bl; static void usage(void) @@ -42,8 +41,9 @@ int main(int argc, char *argv[]) { int ch; - int verbose = 0; + int verbose = 0; int no_action = 0; + int daemonize = 1; const char *config = BL_CONF; while ((ch = getopt(argc, argv, "dhnvf:")) != -1) { @@ -75,31 +75,31 @@ main(int argc, char *argv[]) usage(); log_init(daemonize, LOG_DAEMON); - log_info("%s %s starting", BL_TEXT, BL_VERS); + log_info("%s %s", BL_TEXT, BL_VERS); if ((bl = config_init()) == NULL) - log_fatal("default values init failed"); + log_fatal("initialization failed"); - bl->bl_opt |= verbose; - log_setv(verbose); - log_debug("verbose mode on"); - + if (verbose) { + bl->bl_opt |= verbose; + log_set(verbose); + log_debug("verbose mode on"); + } + if (strlcpy(bl->bl_conf, config, PATH_MAX) >= PATH_MAX) - log_fatal("config file name exceeds PATH_MAX"); + log_fatal("file name exceeds PATH_MAX"); - // if (parse_config(bl, config, opt)) - // exit(1) // log_fatal("parsing conf file failed"); - // int parse_config(struct smtpd *, const char *, int); - - log_debug("conf=%s", bl->bl_conf); - log_debug("sock=%s", bl->bl_sock); + if (config_load(bl)) + log_fatal("%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) + log_debug(" opt=%d", bl->bl_opt); - // fork + process setup + communication setup + // to be continued + + free(bl); exit(0); }