| 17 |
|
|
| 18 |
#include "bbs.h" |
#include "bbs.h" |
| 19 |
#include "common.h" |
#include "common.h" |
| 20 |
|
#include "io.h" |
| 21 |
|
#include <unistd.h> |
| 22 |
|
#include <signal.h> |
| 23 |
|
#include <sys/param.h> |
| 24 |
|
#include <sys/types.h> |
| 25 |
|
#include <sys/stat.h> |
| 26 |
|
|
| 27 |
void |
void |
| 28 |
init_daemon (void) |
init_daemon (void) |
| 42 |
else if (pid < 0) |
else if (pid < 0) |
| 43 |
exit (1); |
exit (1); |
| 44 |
|
|
| 45 |
for (i = 0; i < NOFILE; ++i) |
// for (i = 0; i < NOFILE; ++i) |
| 46 |
close (i); |
// close (i); |
| 47 |
chdir (app_home_dir); |
chdir (app_home_dir); |
| 48 |
umask (0); |
umask (0); |
| 49 |
|
|
| 55 |
int |
int |
| 56 |
load_conf (const char *conf_file) |
load_conf (const char *conf_file) |
| 57 |
{ |
{ |
| 58 |
// Innd settings |
char temp[256]; |
|
char innd_id[50] = ""; |
|
|
char innd_name[50] = ""; |
|
|
char innd_server[256] = ""; |
|
|
unsigned long innd_uid = 0; |
|
|
char innd_address[50] = ""; |
|
|
unsigned int bbsd_port = 0; |
|
|
unsigned int innd_port = 0; |
|
|
unsigned int ctrl_port = 0; |
|
|
char conn_str[256] = ""; |
|
|
unsigned int if_startup = 0; |
|
| 59 |
|
|
| 60 |
// Load configuration |
// Load configuration |
| 61 |
char c_name[256]; |
char c_name[256]; |
| 63 |
|
|
| 64 |
if ((fin = fopen (conf_file, "r")) == NULL) |
if ((fin = fopen (conf_file, "r")) == NULL) |
| 65 |
{ |
{ |
| 66 |
log_error ("Open bbsd.conf failed"); |
log_error ("Open %s failed", conf_file); |
| 67 |
return -1; |
return -1; |
| 68 |
} |
} |
| 69 |
|
|
| 70 |
while (fscanf (fin, "%s", c_name) != EOF) |
while (fscanf (fin, "%s", c_name) != EOF) |
| 71 |
{ |
{ |
| 72 |
if (c_name[0] == '#') |
if (c_name[0] == '#') |
| 73 |
continue; |
{ |
| 74 |
|
fgets (temp, 256, fin); |
| 75 |
|
continue; |
| 76 |
|
} |
| 77 |
fscanf (fin, "%*c"); |
fscanf (fin, "%*c"); |
| 78 |
if (strcmp (c_name, "bbs_id") == 0) |
if (strcmp (c_name, "bbs_id") == 0) |
| 79 |
{ |
{ |
| 99 |
{ |
{ |
| 100 |
fscanf (fin, "%d", &BBS_max_client); |
fscanf (fin, "%d", &BBS_max_client); |
| 101 |
} |
} |
| 102 |
|
if (strcmp (c_name, "bbs_max_user") == 0) |
| 103 |
|
{ |
| 104 |
|
fscanf (fin, "%d", &BBS_max_user); |
| 105 |
|
} |
| 106 |
|
if (strcmp (c_name, "bbs_start_dt") == 0) |
| 107 |
|
{ |
| 108 |
|
int y = 0, m = 0, d = 0; |
| 109 |
|
fscanf (fin, "%d-%d-%d", &y, &m, &d); |
| 110 |
|
sprintf (BBS_start_dt, "%4dÄê%2dÔÂ%2dÈÕ", y, m, d); |
| 111 |
|
} |
| 112 |
if (strcmp (c_name, "db_host") == 0) |
if (strcmp (c_name, "db_host") == 0) |
| 113 |
{ |
{ |
| 114 |
fscanf (fin, "%s", DB_host); |
fscanf (fin, "%s", DB_host); |
| 121 |
{ |
{ |
| 122 |
fscanf (fin, "%s", DB_password); |
fscanf (fin, "%s", DB_password); |
| 123 |
} |
} |
| 124 |
|
if (strcmp (c_name, "db_database") == 0) |
| 125 |
|
{ |
| 126 |
|
fscanf (fin, "%s", DB_database); |
| 127 |
|
} |
| 128 |
} |
} |
| 129 |
|
|
| 130 |
fclose (fin); |
fclose (fin); |
| 131 |
|
|
| 132 |
return 0; |
return 0; |
| 133 |
} |
} |