summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authoradmin (centauri.fritz.box) <puppet@mx.buetow.org>2014-07-01 20:17:26 +0200
committeradmin (centauri.fritz.box) <puppet@mx.buetow.org>2014-07-01 20:17:26 +0200
commit0b4ccf59b27f0a8de71b10120b50c916fdbc46a0 (patch)
tree4252a66e1438004c08c1ac96338a0352a2408d58 /src/main.cpp
parenta7aa66722070de6ab2e84e5a1311b96c98f36e14 (diff)
parentc67ed39bc994a0aef06454c1e3044e79f712b739 (diff)
Merge remote-tracking branch 'remotes/github/ychat-0.7' into ychat-0.7ychat-0.7
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp146
1 files changed, 76 insertions, 70 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 873f07d..7705313 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/main.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,81 +22,86 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// needed for ignoring SIGPIPE.
-#include <signal.h>
-
-// include header files which are included from every class too.
#include "incl.h"
+#include "sign.h"
-// include the chat manager.
-#include "s_chat.h"
-
-// include the config manager.
-#include "s_conf.h"
-
-// include the html-template manager.
-#include "s_html.h"
-
-// include the mutex manager for global synchronization.
-#include "s_mutx.h"
-
-// include the socket manager.
-#include "s_sock.h"
-
-// include the language manager
-#include "s_lang.h"
-
-// include the session manager
-#include "s_sman.h"
+#include "maps/hashmap.h"
using namespace std;
-int main()
+map<string,string>*
+parse_argc( int argc, char* argv[] )
{
-#ifdef VERBOSE
-
- cout << " ___ _ _ " << endl
- << " _ _ / __\\ |__ __ _| |_ " << endl
- << "| | | |/ / | '_ \\ / _` | __|" << endl
- << "| |_| / /___| | | | (_| | |_ " << endl
- << " \\__, \\____/|_| |_|\\__,_|\\__|" << endl
- << " |___/ " << endl << endl
-
- << DESCRIP << endl
- << DESCRI2 << endl
- << DESCRI3 << endl
- << DESCRI4 << endl
- << VERSION << endl
- << CONTACT << endl
- << SEPERAT << endl
- << STARTMS << endl ;
-#endif
+ 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;
+}
- // ignore SIGPIPE. otherwise the server will shut down with "Broken pipe" if
- // a client unexpected disconnects himself from a SOCK_STREAM.
- signal( SIGPIPE, SIG_IGN );
-
- // all the static data classes have to be initialized once. otherwise they will
- // contain only empty pointers and the chat server won't work correctly.
- // the order of the initializations is very importand. for example the s_html::init()
- // invokations assumes an initialized s_conf class.
- s_mutx::init(); // init the mutex manager.
- s_conf::init(); // init the config manager.
- s_html::init(); // init the html-template manager.
- s_lang::init(); // init the language manager
- s_sman::init(); // init the session manager.
- s_sock::init(); // init the socket manager.
- s_chat::init(); // init the chat manager.
-
- // 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.
- s_sock::get
- ().start();
-
-#ifdef VERBOSE
-
- cout << DOWNMSG << endl;
+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();
+
+ // 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();
- return 0;
+ cout << DOWNMSG << endl;
+ return 0;
}