--- lbbs/src/main.c 2004/10/18 08:16:18 1.1 +++ lbbs/src/main.c 2004/10/19 17:11:39 1.4 @@ -1,5 +1,5 @@ /*************************************************************************** - bbsd.c - description + main.c - description ------------------- begin : Mon Oct 11 2004 copyright : (C) 2004 by Leaflet @@ -15,26 +15,53 @@ * * ***************************************************************************/ +#include "bbs.h" #include "common.h" int main (int argc, char *argv[]) { - FILE *fp; - time_t t; - + char log_dir[256], file_log_std[256], file_log_error[256], file_config[256]; + + //Initialize daemon init_daemon (); + //Initialize log + strncpy(app_home_dir, argv[0], rindex(argv[0],'/')-argv[0]+1); + strcpy(log_dir, app_home_dir); + strcat(log_dir, "log/"); + strcpy(file_log_std, log_dir); + strcpy(file_log_error, log_dir); + strcat(file_log_std, "bbsd.log"); + strcat(file_log_error, "error.log"); + mkdir(log_dir,0700); + if (log_begin(file_log_std,file_log_error)<0) + exit(-1); + + //Load configuration + strcpy(file_config, app_home_dir); + strcat(file_config, "conf/bbsd.conf"); + if (load_conf(file_config)<0) + exit(-2); + + //Initialize socket server + net_server(BBS_address, BBS_port); + +/* + FILE *fp; + time_t t; + while (1) - { - sleep (60); - if ((fp = fopen ("bbsd.log", "a")) >= 0) + { + sleep (60); + if ((fp = fopen ("bbsd.log", "a")) >= 0) { t = time (0); fprintf (fp, "I'm here at %s\n", asctime (localtime (&t))); fclose (fp); } - } + } +*/ return 0; }