1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*:*
*: File: ./src/main.cpp
*:
*: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
*:
*: Copyright (C) 2003 Paul C. Buetow, Volker Richter
*: Copyright (C) 2005 EXA Digital Solutions GbR
*: Copyright (C) 2004, 2006 Paul C. Buetow
*:
*: This program is free software; you can redistribute it and/or
*: modify it under the terms of the GNU General Public License
*: as published by the Free Software Foundation; either version 2
*: of the License, or (at your option) any later version.
*:
*: This program is distributed in the hope that it will be useful,
*: but WITHOUT ANY WARRANTY; without even the implied warranty of
*: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*: GNU General Public License for more details.
*:
*: You should have received a copy of the GNU General Public License
*: along with this program; if not, write to the Free Software
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
#include "incl.h"
#include "sign.h"
#include "maps/hashmap.h"
using namespace std;
map<string,string>*
parse_argc( int argc, char* argv[] )
{
map<string,string>* start_params = new map<string,string>;
string s_output = "";
// Set to 1 if a config option key has to be read
// ( ./ychat -o key1 value1 -o key2 value2 ... );
bool b_conf = 0;
// Will store the key of an additional option value (see also b_conf)
string s_key;
for (int i=1; argv[i] != 0; i++)
{
if ( !s_key.empty() )
{
(*start_params)[s_key] = string(argv[i]);
s_key.clear();
}
else if ( b_conf )
{
s_key = string(argv[i]);
b_conf = 0;
}
else
{
if ( string(argv[i]).find("v") != string::npos )
s_output.append(tool::ychat_version()+"\n");
if ( string(argv[i]).find("h") != string::npos )
s_output.append( YCUSAGE );
if ( string(argv[i]).find("o") != string::npos )
b_conf = 1;
}
}
if ( !s_output.empty() )
{
cout << s_output;
delete start_params;
exit(1);
}
return start_params;
}
int
main(int argc, char* argv[])
{
cout << tool::ychat_version() << endl
<< DESCRIP << endl
<< DESCRI2 << endl
<< CONTACT << endl
<< SEPERAT << endl;
wrap::init_wrapper(parse_argc(argc, argv));
//<<*
// Initialize database connection queue
#ifdef DATABASE
wrap::DATA->init_connections();
#endif
//*>>
sign::init_signal_handlers();
#ifdef CLI
cli _cli;
_cli.run();
#endif
// start the socket manager. this one will listen for incoming http requests and will
// forward them to the specified routines which will generate a http response.
wrap::SOCK->start();
cout << DOWNMSG << endl;
return 0;
}
|