version 1.1, 2022/03/13 23:06:39 |
version 1.14, 2022/03/20 18:47:16 |
|
|
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <unistd.h> |
|
#include <string.h> |
|
#include <syslog.h> |
|
|
|
#include "blind.h" |
|
#include "config.h" |
|
#include "log.h" |
|
|
|
static void usage(void); |
|
|
|
int daemonize = 1; |
|
struct blind *bl; |
|
|
|
static void |
|
usage(void) |
|
{ |
|
extern char *__progname; |
|
|
|
fprintf(stderr, "usage: %s [-dhnv] [-f file]\n", __progname); |
|
exit(1); |
|
} |
|
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
printf("under construction\n"); |
int ch; |
|
int verbose = 0; |
|
int no_action = 0; |
|
const char *config = BL_CONF; |
|
|
|
while ((ch = getopt(argc, argv, "dhnvf:")) != -1) { |
|
switch (ch) { |
|
case 'd': |
|
daemonize = 0; |
|
break; |
|
case 'h': |
|
fprintf(stderr, BL_TEXT " " BL_VERS "\n"); |
|
usage(); |
|
break; |
|
case 'n': |
|
no_action = 1; |
|
break; |
|
case 'f': |
|
config = optarg; |
|
break; |
|
case 'v': |
|
verbose = BL_OPT_VERBOSE; |
|
break; |
|
default: |
|
usage(); |
|
} |
|
} |
|
argc -= optind; |
|
argv += optind; |
|
|
|
if (argc || *argv) |
|
usage(); |
|
|
|
log_init(daemonize, LOG_DAEMON); |
|
log_info("%s %s", BL_TEXT, BL_VERS); |
|
|
|
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) |
|
|
|
// fork + process setup + communication setup |
|
|
exit(0); |
exit(0); |
} |
} |