/[LeafOK_CVS]/lbbs/src/init.c
ViewVC logotype

Annotation of /lbbs/src/init.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Tue Oct 19 17:11:39 2004 UTC (21 years, 5 months ago) by sysadm
Branch: MAIN
Changes since 1.3: +74 -1 lines
Content type: text/x-csrc
*** empty log message ***

1 sysadm 1.1 /***************************************************************************
2 sysadm 1.3 init.c - description
3 sysadm 1.1 -------------------
4     begin : Mon Oct 18 2004
5     copyright : (C) 2004 by Leaflet
6     email : leaflet@leafok.com
7     ***************************************************************************/
8    
9     /***************************************************************************
10     * *
11     * This program is free software; you can redistribute it and/or modify *
12     * it under the terms of the GNU General Public License as published by *
13     * the Free Software Foundation; either version 2 of the License, or *
14     * (at your option) any later version. *
15     * *
16     ***************************************************************************/
17    
18 sysadm 1.4 #include "bbs.h"
19 sysadm 1.1 #include "common.h"
20    
21     void
22     init_daemon (void)
23     {
24     int pid;
25     int i;
26    
27     if (pid = fork ())
28     exit (0);
29     else if (pid < 0)
30     exit (1);
31    
32     setsid ();
33    
34     if (pid = fork ())
35     exit (0);
36     else if (pid < 0)
37     exit (1);
38    
39     for (i = 0; i < NOFILE; ++i)
40     close (i);
41 sysadm 1.3 chdir (app_home_dir);
42 sysadm 1.1 umask (0);
43    
44 sysadm 1.2 signal (SIGCHLD, SIG_IGN);
45 sysadm 1.1
46     return;
47     }
48 sysadm 1.4
49     int
50     load_conf (const char *conf_file)
51     {
52     // Innd settings
53     char innd_id[50] = "";
54     char innd_name[50] = "";
55     char innd_server[256] = "";
56     unsigned long innd_uid = 0;
57     char innd_address[50] = "";
58     unsigned int bbsd_port = 0;
59     unsigned int innd_port = 0;
60     unsigned int ctrl_port = 0;
61     char conn_str[256] = "";
62     unsigned int if_startup = 0;
63    
64     // Load configuration
65     char c_name[256];
66     FILE *fin;
67    
68     if ((fin = fopen (conf_file, "r")) == NULL)
69     {
70     log_error ("Open bbsd.conf failed");
71     return -1;
72     }
73    
74     while (fscanf (fin, "%s", c_name) != EOF)
75     {
76     if (c_name[0] == '#')
77     continue;
78     fscanf (fin, "%*c");
79     if (strcmp (c_name, "bbs_id") == 0)
80     {
81     fscanf (fin, "%s", BBS_id);
82     }
83     if (strcmp (c_name, "bbs_name") == 0)
84     {
85     fscanf (fin, "%s", BBS_name);
86     }
87     if (strcmp (c_name, "bbs_server") == 0)
88     {
89     fscanf (fin, "%s", BBS_server);
90     }
91     if (strcmp (c_name, "bbs_address") == 0)
92     {
93     fscanf (fin, "%s", BBS_address);
94     }
95     if (strcmp (c_name, "bbs_port") == 0)
96     {
97     fscanf (fin, "%ud", &BBS_port);
98     }
99     if (strcmp (c_name, "bbs_max_client") == 0)
100     {
101     fscanf (fin, "%d", &BBS_max_client);
102     }
103     if (strcmp (c_name, "db_host") == 0)
104     {
105     fscanf (fin, "%s", DB_host);
106     }
107     if (strcmp (c_name, "db_username") == 0)
108     {
109     fscanf (fin, "%s", DB_username);
110     }
111     if (strcmp (c_name, "db_password") == 0)
112     {
113     fscanf (fin, "%s", DB_password);
114     }
115     }
116    
117     fclose (fin);
118    
119     return 0;
120     }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1