diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:48 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:48 +0200 |
| commit | 5a019f435eb0068b524566d9babf172d58d0e96e (patch) | |
| tree | b083dccdfbec4335a5967d50c4294f7501c77345 | |
| parent | 4ecbf33fae730bc79c4a47e6efda615b104754ad (diff) | |
tagging ychat-0.7.9.2ychat-0.7.9.2
51 files changed, 413 insertions, 196 deletions
@@ -1,3 +1,25 @@ +-Changes from 0.7.9.1-RELEASE to 0.7.9.2-RELEASE - +$ Added monitor/dump, and the dump command to the CLI. +$ Fixed a bug in the session manager. +$ Added gmake dist do the README. +$ Added the charset to the HTTP-header. + +-Changes from 0.7.9-RELEASE to 0.7.9.1-RELEASE - +$ Fixed etc/ychat.conf (Its now valid XML) +$ Fixed some typos. +$ Added the scripts/makedist.sh script, which can be invoked by gmake dist. +$ yhttpd.org has been renamed to yChat.org. The yhttpd.org SLD will be +$ canceled! The yhttpd.org Homepage will remain on yChat.org! + +-Changes from 0.7.8-RELEASE to 0.7.9-RELEASE - +$ In the system messages will be the user printed which has requested the + specified module. +$ Removed the cursor from the ncurses interface. +$ Added wrap::init_wrappers -> The main.cpp is now shorter. +$ Added some Makefile modifications +$ Bugfix: cleanipcache shouldn run every minute but every 10! +$ Bugfix: scripts/stats.pl now counts all text-files properly. + -Changes from 0.7.7.1-RELEASE to 0.7.8-RELEASE - $ Updated the yhttpd generation script due new sources in src/memb. $ Changd some hashmaps back into simple std::map objects, this might @@ -1,6 +1,6 @@ MAKE=`tail -n 1 make.version` PREFIX=`grep "define PREFIX" src/glob.h | cut -d'"' -f2` -all: version base modules version +all: version base modules @echo "Now edit the ychat.conf and run ychat!" @echo "The config file is searched in the following order:" @echo " ./ychat.conf " @@ -74,7 +74,7 @@ mrproper: clean @if test -f g++.version; then rm -f g++.version; fi @if test -f make.version; then rm -f make.version; fi @if test -f src/Makefile; then rm -f src/Makefile; fi - @if test -f bin/ychat; then find bin/ -name "*ychat" | xargs rm -f; fi + @if test -f bin/ychat; then find bin/ -name "*ychat*" | xargs rm -f; fi @if test -d src/mods; then find src/mods/*/ -name Makefile | xargs rm -f; fi @find . -name "*.add" | xargs rm -f @ls | grep core | xargs rm -f @@ -84,3 +84,5 @@ debug: @gdb bin/ychat ychat.core confdebug: ./configure -g3 -ggdb +dist: + @./scripts/makedist.sh @@ -1,3 +1,8 @@ +::(10.04.05)::Released yChat 0.7.9.1. This release adds the dump command for the command line interface which prints out the internal yChat data structure. This feature makes it easier to track bugs. Also, a big bug of the session manager has been wiped out. +::(08.04.05)::C++ yChat is now about 2 years old. Happy birthday yChat! The next few releases of the CURRENT branch will mostly contain bugfixes and stability improvements. We want to get ready to change 0.7-CURRENT into 0.7-STABLE in order to work on newer 0.8-CURRENT versions. +::(07.04.05)::Released yChat 0.7.9.1. This release includes some minor bugfixes. The ychat.conf file is now valid XML. Also some typos have been fixed. Also a scripts/makedist.sh script has been added which creates a .tar.bz2 ball of the current source tree. +::(10.03.05)::Released yChat 0.7.9. The logging capability has been improved. All chat command requests will be logged. The ncurses interface has been improved. Some code has been cleaned up. +::(07.03.05)::Released yChat 0.5.4. This is a STABLERELEASE. The HTTP parsing methods have been backported from yChat 0.7.8. Also some minor bugfixes were made.This is the first STABLERELEASE of yChat ever. ::(05.03.05)::Released yChat 0.7.8. This release includes an IP cache for more speed. An UNIX signal catcher class has been added. SIGUSR1 and SIGUSR2 now clean the template cache or reload all dynamic modules. Added "Allow" to the HTTPD header. Also, lots of Bugfixes and minor improvements were made. Changed the 0.5 branch into STABLE. The 0.5.4-STABLERELEASE will follow next week. The ychat-stable CVS branch has been opened, which now points to ychat-0.5. ::(02.03.05)::Released yChat 0.5.3. This is a LEGACYRELEASE. It includes a stats generation script located in the scripts/ directory which can be called by gmake stats. Also all the sources have been moved to ./src. Some minor bugfixes are included also. ::(27.02.05)::Released yChat 0.5.2. This is a LEGACYRELEASE. That means, that this version is not official supported. The 0.5.2 version might be interesting by developers who want to have a clean base structure of an existing C++ based chat system. The 0.5.2 version does not have any features besides logging in and single room chatting. Multi rooms can be added easily. @@ -1,4 +1,4 @@ -yChat; Homepage: www.yChat.org; Version 0.7.8-RELEASE +yChat; Homepage: www.yChat.org; Version 0.7.9.2-PRERELEASE Copyright (C) 2003 Paul C. Buetow, Volker Richter Copyright (C) 2004, 2005 Paul C. Buetow @@ -51,6 +51,9 @@ yhttpd does not have as much features but is easy to use and faster than apache. yhttpd is a subset of the chat. It can be generated using the srcipts/yhttpdbase.pl script in the chat's source tree. +- The ycurses - +ycurses is a easy to use and small C++ wrapper of the C ncurses API. + There are different branches: - CURRENT - @@ -198,8 +201,8 @@ lot of user and room objects are created and destroyed frequently. 1.0.0 REQUIREMENTS: -- GNU GCC G++ 3.4 - The GNU C++ compiler. +- GNU GCC G++ + The GNU C++ compiler version 3.1 or up. - GNU make 3.80 (gmake) or higher If you dont have a gmake executable but make is gnu make then you need @@ -314,6 +317,7 @@ or gmake config): gmake confdebug (runs ./configure with enabling debugging) gmake config (runs yChat configurator) gmake debug (runs gdb on ./ychat.core) + gmake dist (creates a .tar.bz2 ball) gmake gpl (shows the GNU General Public License) gmake help (shows all available ychat gmake targets) gmake mail (sends a mail to the yChat developers containing build opts.) @@ -526,7 +530,8 @@ You may contact us through the following addresses: #Ychat and #Coding at irc.german-elite.net //<<* -1.9 YHTTPD CODE BASE GENERATION +1.9.0 YHTTPD CODE BASE GENERATION See docs/yhttpd.txt //*>> + @@ -1,32 +1,37 @@ Release table -Release date Branch Release focus +Release date Release name and version Release focus -Planing: yXML 0.1-RELEASE_________ Initial release -Planung: yChat 0.5.4-STABLERELEASE N/A -Planung: yhttpd 0.7.2-RELEASE_____ Features +Planing: yhttpd 0.8-RELEASE_______ Features +Planing: yChat 0.8-RELEASE________ Features +Planing: ycurses 0.1-RELEASE______ Initial release +Planing: yChat 5.5-RELEASE________ Minor bugfixes -Mar 05th 05 yChat 0.7.8-RELEASE______ Features -Mar 02th 05 yChat 0.5.3-LEGACYRELEASE Minor improvements -Feb 27th 05 yChat 0.5.2-LEGACYRELEASE Bugfixes, code cleanup -Feb 24th 05 yChat 0.7.7.1-RELEASE____ Bugfix -Feb 21th 05 yChat 0.7.7-RELEASE______ Code cleanup -Feb 18th 05 yChat 0.7.6-RELEASE______ Improvements -Feb 15th 05 yChat 0.7.5-RELEASE______ Features, bugfixes -Feb 14th 05 yChat 0.7.4.1-RELEASE____ Bugfix -Feb 12th 05 yChat 0.7.4-RELEASE______ Bugfixes, improvements, feat. -Feb 10th 05 yChat 0.7.4-PRERELEASE___ Bugfixes, improvements, feat. -Dec 29th 04 yChat 0.7.3-RELEASE______ Bugfixes, features -Nov 09th 04 yChat 0.7.2-RELEASE______ Bugfixes, features -Nov 06th 04 yhttpd 0.7.1-RELEASE_____ Bugfixes -Nov 06th 04 yChat 0.7.1-RELEASE______ Bugfixes +Apr 10th 05: yChat 0.7.9.2-RELEASE____ Major bugfixes +Apr 07th 05: yChat 0.7.9.1-RELEASE____ Minor bugfixes +Mar 11th 05: yChat 0.7.9-RELEASE______ +Mar 08th 05: yChat 0.5.4-STABLERELEASE +Mar 05th 05 yChat 0.7.8-RELEASE______ +Mar 02th 05 yChat 0.5.3-LEGACYRELEASE +Feb 27th 05 yChat 0.5.2-LEGACYRELEASE +Feb 24th 05 yChat 0.7.7.1-RELEASE____ Major bugfixes +Feb 21th 05 yChat 0.7.7-RELEASE______ +Feb 18th 05 yChat 0.7.6-RELEASE______ +Feb 15th 05 yChat 0.7.5-RELEASE______ +Feb 14th 05 yChat 0.7.4.1-RELEASE____ Major bugfixes +Feb 12th 05 yChat 0.7.4-RELEASE______ +Feb 10th 05 yChat 0.7.4-PRERELEASE___ +Dec 29th 04 yChat 0.7.3-RELEASE______ +Nov 09th 04 yChat 0.7.2-RELEASE______ +Nov 06th 04 yhttpd 0.7.1-RELEASE_____ +Nov 06th 04 yChat 0.7.1-RELEASE______ Nov 01st 04 yhttpd 0.7-RELEASE_______ Initial release -Oct 31st 04 yChat 0.7-RELEASE________ Cleanup, features -Jan 03rd 04 yChat 0.5.1-RELEASE______ Cleanup, bugfixes -Sep 15th 03 yChat 0.6-RELEASE________ Cleanup, features -Sep 15th 03 yChat 0.5.0-RELEASE______ Features -Apr 26th 03 yChat 0.4-RELEASE________ Features -Mar 30th 03 yChat 0.3-RELEASE________ Features -Mar 24th 03 yChat 0.2-RELEASE________ Bugfixes +Oct 31st 04 yChat 0.7-RELEASE________ +Jan 03rd 04 yChat 0.5.1-RELEASE______ +Sep 15th 03 yChat 0.6-RELEASE________ +Sep 15th 03 yChat 0.5.0-RELEASE______ +Apr 26th 03 yChat 0.4-RELEASE________ +Mar 30th 03 yChat 0.3-RELEASE________ +Mar 24th 03 yChat 0.2-RELEASE________ Mar 20th 03 yChat 0.1-RELEASE________ Initial release @@ -1,7 +1,9 @@ - Must do's for next RELEASE - -$ Add thread pool decreasing +$ None specific - Might do's for next RELEASE - +$ Add CLI dump command (writes internal data structure into file, for debugging) +$ Add thread pool decreasing $ dir : public vector<string> $ Disable /help command for commands wich are not accessible for the $ specific user. @@ -9,6 +11,10 @@ $ Flood protection $ Add /nick, /beam, /su $ Add / to whisper to the last person to whom the user has been whispered the last time. +- Known bugs - +$ The session manager sometimes does not free a session. The user object might hang. +$ Using yChat via proxy sometimes causes a white chat stream. + - To do in general for some later RELEASE - $ Use libevent $ Not found sites should get a 404 error site! diff --git a/etc/ychat.conf b/etc/ychat.conf index e875420..d17ace3 100644 --- a/etc/ychat.conf +++ b/etc/ychat.conf @@ -1,4 +1,5 @@ -<?xml version="5.0" encoding="ISO-8859-1" standalone="yes" ?> +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?> +<config> <category name="chat"> <option name="defaultop"> <value>Snoop</value> @@ -461,15 +462,15 @@ <category name="session"> <option name="md5hash"> <value>true</value> - <descr>If set to true, then the session id will be hashed by MD5 to make the id even more random</descr> + <descr>If set to true, then MD5 hash of the session id will be appended to the generated session to make the temp IDs even more secure.</descr> </option> <option name="md5salt"> <value>tASDlkjadSD</value> <descr>Some random string which will affect the md5-hash. Change this to another random string!</descr> </option> <option name="length"> - <value>64</value> - <descr>Length of the generated session id. The length will be shorter if md5hash is activated</descr> + <value>32</value> + <descr>Length of the generated session id. The length will be longer if md5hash is activated</descr> </option> <option name="validchars"> <value>.abcdefghijklmnopqrstuvwxyz0123456789-_</value> @@ -589,7 +590,7 @@ <descr>If set to false, yChat strips all html tags from incoming messages</descr> </option> <option name="ipcachesize"> - <value>0</value> + <value>50</value> <descr>Specifies the IP cache size. If set to 0, the IP cache will be cleared every 10 minutes. Otherwise, the IP cache will be cleared every 10 minutes only if there are more IPs in the cache than the specified amount.</descr> </option> <category name="html"> @@ -686,3 +687,4 @@ </option> </category> </category> +</config> diff --git a/scripts/makeyhttpd.pl b/scripts/makeyhttpd.pl index 6adcc96..7dd0345 100644 --- a/scripts/makeyhttpd.pl +++ b/scripts/makeyhttpd.pl @@ -40,6 +40,7 @@ my %substituate = ( 'yChat' => 'yhttpd', 'YCHAT' => 'YHTTPD', 'CHAT' => 'HTTPD', + 'yhttpd.org' => 'yChat.org', '//>>' => '' ); @@ -156,7 +157,7 @@ sub remove_marked_lines { sub edit_yhttpd_conf { my @old = fopen("etc/yhttpd.conf"); - my @new = shift @old; + my @new = @old[0..1]; my $flag = 0; for (@old) diff --git a/scripts/stats.pl b/scripts/stats.pl index e5cc2b3..96fbdf1 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# The yChat Project (2003 - 2004) +# The yhttpd Project (2003 - 2004) # # This script generates source code and project statistics @@ -76,7 +76,7 @@ sub filestats $stats{"Number of script files"}++; $stats{"Lines of scripts"} += countlines($shift); } - elsif ( $shift =~ /(\.txt|README|INSTALL|COPYING|NEWS|SNAPSHOT|ChangeLog)$/ ) + elsif ( $shift =~ /(\.txt|[A-Z]+)$/ ) { $stats{"Number of text files"}++; $stats{"Lines of text"} += countlines($shift); diff --git a/src/chat/base.h b/src/chat/base.h index 9da4304..b995c5c 100755 --- a/src/chat/base.h +++ b/src/chat/base.h @@ -9,6 +9,9 @@ template<class type> class base : public nhashmap<type*> { +protected: + void dumpit(); + public: base(); ~base(); @@ -22,6 +25,7 @@ public: } virtual type* get_elem( string s_name, bool &b_found ); // get a element. + virtual type* get_elem( string s_name ); virtual void add_elem( type* p_type ); // add a element. // chat::msg_post sends to all users of the system a message. diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl index 0be21aa..5b0fceb 100755 --- a/src/chat/base.tmpl +++ b/src/chat/base.tmpl @@ -22,10 +22,40 @@ base<type>::get_elem( string s_name, bool &b_found ) } template<class type> +type* +base<type>::get_elem( string s_name) +{ + bool b; + return get_elem(s_name, b); +} + +template<class type> void base<type>::add_elem( type* p_type ) { nhashmap<type*>::add_elem(p_type, p_type->get_lowercase_name()); } +template<class type> +void +base<type>::dumpit() +{ + dumpable::add("[base]"); + vector<string>* p_vec = nhashmap<type*>::get_key_vector(); + + vector<string>::iterator iter; + for (iter = p_vec->begin(); iter != p_vec->end(); ++iter) + { + dumpable::add(*iter); + type* p_elem = get_elem(*iter); + if (p_elem) + { + dumpable::next_no_newline(); + dumpable::add(p_elem->dump(dumpable::get_level())); + } + } + + delete p_vec; +} + #endif diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp index 0839261..e4cbaac 100755 --- a/src/chat/chat.cpp +++ b/src/chat/chat.cpp @@ -165,7 +165,6 @@ chat::login( map<string,string> &map_params ) else { sess* p_sess = wrap::SMAN->create_session(); - //p_sess->set_value( string("nick"), (void *) new string(s_user) ); p_sess->set_user(p_user); map_params["tmpid"] = p_sess->get_tmpid(); p_user->set_tmpid( map_params["tmpid"] ); @@ -361,4 +360,11 @@ chat::string_replacer(string *p_msg) } } +void +chat::dumpit() +{ + dumpable::add("[chat]"); + base<room>::dumpit(); +} + #endif diff --git a/src/chat/chat.h b/src/chat/chat.h index 47645c3..bb087d5 100755 --- a/src/chat/chat.h +++ b/src/chat/chat.h @@ -23,6 +23,7 @@ class chat : public base<room>, public perm private: map<string,string> map_replace_strings; vector<string> vec_replace_keys; + void dumpit(); public: virtual room* get_room( string s_name ) diff --git a/src/chat/gcol.cpp b/src/chat/gcol.cpp index 7df111d..d4c9416 100755 --- a/src/chat/gcol.cpp +++ b/src/chat/gcol.cpp @@ -44,6 +44,8 @@ gcol::add_user_to_garbage( user* p_user ) p_user->s_mess_delete(); p_map_users->add_elem( p_user, tool::to_lower(p_user->get_name()) ); wrap::system_message( GARUSER + p_user->get_name() ); + p_user->destroy_session(); + #ifdef NCURSES print_garbage(); diff --git a/src/chat/room.cpp b/src/chat/room.cpp index b927d40..0e28c84 100755 --- a/src/chat/room.cpp +++ b/src/chat/room.cpp @@ -101,4 +101,14 @@ room::set_name( string s_name ) #endif } +void +room::dumpit() +{ + dumpable::add("[room]"); + dumpable::add("Name: "+get_name()); + dumpable::add("Topic: "+get_topic()); + base<user>::dumpit(); +} + + #endif diff --git a/src/chat/room.h b/src/chat/room.h index 06b0a9a..4c5fac6 100755 --- a/src/chat/room.h +++ b/src/chat/room.h @@ -23,6 +23,8 @@ private: logd* p_logd; #endif + + void dumpit(); public: room( string s_name ); diff --git a/src/chat/sman.cpp b/src/chat/sman.cpp index d80d421..530aa17 100755 --- a/src/chat/sman.cpp +++ b/src/chat/sman.cpp @@ -21,23 +21,33 @@ sman::~sman() string sman::generate_id( int i_len ) { - string valid_chars = wrap::CONF->get_elem("chat.session.validchars"); + string s_valid = wrap::CONF->get_elem("chat.session.validchars"); string s_ret = ""; srand(time(0)+tool::string2int(wrap::CONF->get_elem("chat.session.kloakkey"))); int i_char; + for (int i = 0; i < i_len; i++) { - i_char = rand() % 64; - s_ret += valid_chars[i_char]; + i_char = rand() % s_valid.length(); + s_ret += s_valid[i_char]; } if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" ) { string s_salt = wrap::CONF->get_elem("chat.session.md5salt"); - s_ret = string(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str())); - return s_ret.substr(s_ret.find(s_salt) + s_salt.length() + 3); + string s_hash(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str())); + s_ret.append(s_hash.substr(s_ret.find(s_salt) + s_salt.length() + 3)); + } + + // Prove, if the TempID already exists + sess* p_sess = get_elem(s_ret); + + if (p_sess) + { + wrap::system_message(SESSEXI); + return generate_id(i_len); } return s_ret; diff --git a/src/chat/sman.h b/src/chat/sman.h index 992fc64..13fc45a 100755 --- a/src/chat/sman.h +++ b/src/chat/sman.h @@ -7,10 +7,11 @@ #include "sess.h" #include "../maps/shashmap.h" +#include "../monitor/dump.h" using namespace std; -class sman : private shashmap<sess*> +class sman : public shashmap<sess*> { private: string generate_id( int i_len ); diff --git a/src/chat/user.cpp b/src/chat/user.cpp index 4f1646b..bac8b7e 100755 --- a/src/chat/user.cpp +++ b/src/chat/user.cpp @@ -73,23 +73,27 @@ user::initialize() void user::clean() { + destroy_session(); + set_fake( false ); + set_invisible( false ); + set_away( false, "" ); +} + +void +user::destroy_session() +{ + if ( !get_has_sess() ) + return; - // If this user has a session - if ( get_has_sess() ) - { #ifdef DATABASE - // Store all changed data into the mysql table if this user is registered: - if ( b_is_reg ) - wrap::DATA->update_user_data( get_name(), "savechangednick", map_changed_data ); + // Store all changed data into the mysql table if this user is registered: + if ( b_is_reg ) + wrap::DATA->update_user_data( get_name(), "savechangednick", map_changed_data ); #endif - wrap::SMAN->destroy_session( get_tmpid() ); - // wrap::system_message( SESSION + tool::int2string( wrap::SMAN->get_session_count() ) ); - } - - set_fake( false ); - set_invisible( false ); - set_away( false, "" ); + set_has_sess(false); + wrap::SMAN->destroy_session(get_tmpid()); + set_tmpid(""); } string @@ -411,7 +415,7 @@ user::command( string &s_command ) string s_command2 = s_command.substr(0, pos2-1); s_mod.append( s_command2 ).append( ".so" ); - dynmod *mod = wrap::MODL->get_module( s_mod ); + dynmod *mod = wrap::MODL->get_module( s_mod, get_name() ); if ( mod == NULL || wrap::CHAT->get_command_disabled( s_command2 ) || @@ -577,4 +581,15 @@ void user::reconf() {} +void +user::dumpit() +{ + dumpable::add("[user]"); + dumpable::add("Name: " + get_name() + + "; Room: " + get_room()->get_name() + + "; Status: " + tool::int2string(get_status())); + dumpable::add("TempID: " + get_tmpid()); +} + + #endif diff --git a/src/chat/user.h b/src/chat/user.h index 443eef6..1d16695 100755 --- a/src/chat/user.h +++ b/src/chat/user.h @@ -5,13 +5,14 @@ #include "../name.h" #include "../time/timo.h" +#include "../monitor/dump.h" //#include "../memb/memb.h" class room; using namespace std; -class user : public name, public timo//, public memb<string> +class user : public name, public timo, public dumpable //, public memb<string> { private: @@ -56,7 +57,8 @@ private: pthread_mutex_t mut_map_changed_data; void initialize(); - void set_changed_data( string s_varname, string s_value ); + void set_changed_data( string s_varname, string s_value ); + void dumpit(); public: pthread_cond_t cond_message; @@ -67,6 +69,7 @@ public: ~user(); void clean(); + void destroy_session(); // gets specific data of this user und stores it in // (*p_map<string,string>)["nick"]. this method will be used diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 96a0010..cc0f5e5 100755 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -37,6 +37,8 @@ cli::parse_input( string s_input ) cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl; #endif + cout << CLIPRMO << " (du)mp [part] - Prints out a dump of the data structure" << endl; + cout << CLIPRMO << " (Run without part to list all possibilities)" << endl; cout << CLIPRMO << " (e)cho VAR - Prints out configuration value of VAR" << endl; cout << CLIPRMO << " Wildcards can be used too, example: echo http*" << endl; #ifdef NCURSES @@ -78,6 +80,11 @@ cli::parse_input( string s_input ) cout << CLIPRMI; } #endif + else if ( s_input.compare("du") == 0 || s_input.compare("dump") == 0 ) + { + dump d(vectorize(s_param)); + cout << CLIPRMI; + } else if( s_input.compare("echo") == 0 || s_input.compare("e") == 0 ) { string s_val; @@ -134,6 +141,7 @@ cli::parse_input( string s_input ) { cout << CLIPRMO; wrap::MODL->reload_modules(); + cout << MODRELO << endl; cout << CLIPRMI; } //*>> @@ -207,6 +215,7 @@ cli::parse_input( string s_input ) { cout << CLIPRMO; wrap::MODL->unload_modules(); + cout << MODUNLO << endl; cout << CLIPRMI; } //*>> @@ -285,6 +294,26 @@ cli::print_rusage() delete p_rusage; } +vector<string> +cli::vectorize(string s_param) +{ + vector<string> vec_ret; + unsigned i_pos; + + for (i_pos = s_param.find(" "); + i_pos != string::npos; + i_pos = s_param.find(" ")) + { + vec_ret.push_back(s_param.substr(0, i_pos)); + s_param = s_param.substr(i_pos+1); + } + + if (!s_param.empty()) + vec_ret.push_back(s_param); + + return vec_ret; +} + #ifdef DEBUG void cli::debug_routine() diff --git a/src/cli/cli.h b/src/cli/cli.h index 23e1d1c..7d51e3f 100755 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -22,6 +22,8 @@ #include "../thrd/thro.h" #endif +#include "../monitor/dump.h" + using namespace std; #ifndef NCURSES @@ -32,8 +34,9 @@ class cli { #endif private: - int parse_input(string s_input); - + int parse_input(string s_input); + vector<string> vectorize(string s_param); + public: cli( ); ~cli( ); @@ -52,7 +55,6 @@ void start(void* p_void); void start(); #endif - }; #endif diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp index 2e5893b..38c29c4 100755 --- a/src/conf/conf.cpp +++ b/src/conf/conf.cpp @@ -36,6 +36,7 @@ conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_ cout << CFILEFA << endl; exit(1); } + else { cout << CFILEOK << "..." << endl; @@ -76,12 +77,18 @@ conf::parse_xml(TiXmlNode* p_node, vector<string>* p_vec) { //cout << p_vec->size() << ": (Value:" << p_child->Value() << ") (Type:" << p_child->Type() << ")" << endl; - if ( strcmp(p_child->Value(),"category") == 0 ) + if ( strcmp(p_child->Value(),"config") == 0 ) + { + parse_xml(p_child, p_vec); + } + + else if ( strcmp(p_child->Value(),"category") == 0 ) { p_vec->push_back(p_child->ToElement()->Attribute("name")); parse_xml(p_child, p_vec); p_vec->pop_back(); } + else if ( strcmp(p_child->Value(),"option") == 0 ) { string s_option_name = ""; diff --git a/src/configure b/src/configure index eb54cce..973e85a 100755 --- a/src/configure +++ b/src/configure @@ -156,15 +156,17 @@ perl -e ' $ofile =~ s/\.cpp/\.o/; print Fout "../obj/$ofile: $cppfile\n"; print Fout "\t\@if ! test -d `dirname ../obj/$ofile`; then mkdir -p `dirname ../obj/$ofile`; fi\n"; - if ( $ofile =~ /contrib\/.+/ ) + my $class = $ofile; + $class =~ s/\.o//; + if ( $class =~ /contrib\/.+/ ) { - my $dirname = `dirname $ofile`; - print Fout "\t\@echo -n \"Compiling contributed class $ofile \"\n"; + my $dirname = `dirname $class`; + print Fout "\t\@echo -n \"Compiling contributed class $class \"\n"; } else { - print Fout "\t\@echo -n \"Compiling base class $ofile \"\n"; + print Fout "\t\@echo -n \"Compiling base class $class \"\n"; } print Fout "\t\@\$(CC) \$(CFLAGS) \$(INCLUDES) $args -c -o ../obj/$ofile $cppfile\n"; diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp index 05f4e0a..8150608 100644 --- a/src/data/data_base.cpp +++ b/src/data/data_base.cpp @@ -47,7 +47,7 @@ data_base::data_base( ) } } -void data_base::initialize_connections() +void data_base::init_connections() { int i_min_con = tool::string2int( wrap::CONF->get_elem("chat.database.mincon") ), i_max_con = tool::string2int( wrap::CONF->get_elem("chat.database.maxcon") ); diff --git a/src/data/data_base.h b/src/data/data_base.h index 1da5ce7..79f5630 100644 --- a/src/data/data_base.h +++ b/src/data/data_base.h @@ -36,7 +36,7 @@ public: data_base(); ~data_base(); - void initialize_connections(); + void init_connections(); virtual hashmap<string> select_user_data( string s_user, string s_query ); virtual void insert_user_data( string s_user, string s_query, hashmap<string> insert_map ); virtual void update_user_data( string s_user, string s_query, hashmap<string> update_map ); @@ -83,7 +83,7 @@ /* - CONFIG - Should yChat get compiled with ncurses support? */ -//#define NCURSES +#define NCURSES /* - CONFIG - Please specify the maximum length of a HTTP post request. @@ -121,7 +121,7 @@ will print a warning message into the system messages and will not core dump if an error occurs. */ -#define CTCSEGV +//#define CTCSEGV /* - CONFIG - Please chose if you want to use verbose server outputs or not. diff --git a/src/html.cpp b/src/html.cpp index 4160f60..3f47867 100755 --- a/src/html.cpp +++ b/src/html.cpp @@ -43,12 +43,11 @@ html::parse( map<string,string> &map_params ) if ( ! if_templ ) { wrap::system_message( OFFFOUND + s_path ); - if(map_params["request"]== wrap::CONF->get_elem( "httpd.html.notfound" )) + if(map_params["request"] == wrap::CONF->get_elem( "httpd.html.notfound" )) return ""; map_params["request"] = wrap::CONF->get_elem( "httpd.html.notfound" ); return parse( map_params ); - } char c_buf; diff --git a/src/main.cpp b/src/main.cpp index ffe5484..c0adb5e 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,11 +23,6 @@ #include "incl.h" #include "sign.h" -#ifndef NCURSES -#ifdef CLI -#include "cli/cli.h" -#endif -#endif #include "maps/hashmap.h" @@ -85,98 +80,18 @@ parse_argc( int argc, char* argv[] ) int main(int argc, char* argv[]) { - map<string,string>* p_start_params = parse_argc( argc, argv ); - cout << tool::ychat_version() << endl << DESCRIP << endl << DESCRI2 << endl << CONTACT << endl << SEPERAT << endl; - - // 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 conf class. - - // Init the dynamic wrapper (is needed to pass all wrapped objects through a single pointer). - wrap::WRAP = new dynamic_wrap; - - // Init the config manager. - wrap::WRAP->CONF = wrap::CONF = new conf( CONFILE, p_start_params ); - delete p_start_params, - - // Init the statistic manager. - wrap::WRAP->STAT = wrap::STAT = new stats; - - // Init the html-template manager. - wrap::WRAP->HTML = wrap::HTML = new html; - -#ifdef LOGGING - // Init the system message logd - wrap::WRAP->LOGD = wrap::LOGD = new logd( wrap::CONF->get_elem("httpd.logging.systemfile"), - wrap::CONF->get_elem("httpd.logging.systemlines") ); -#endif - //<<* - // Init the session manager. - wrap::WRAP->SMAN = wrap::SMAN = new sman; - //*>> - - -#ifdef NCURSES - - wrap::WRAP->NCUR = wrap::NCUR = new ncur; // init the ncurses admin interface. - wrap::NCUR->run(); // run the thread - - // Wait until ncurses interface has been initialized. - do { - usleep(1000); - } while ( ! wrap::NCUR->is_ready() ); - - wrap::HTML->print_cached(0); -#endif - - // Init the thread pool - wrap::WRAP->POOL = wrap::POOL = new pool; - // Init the socket manager. - wrap::WRAP->SOCK = wrap::SOCK = new sock; - - //<<* - // Init the chat manager. - wrap::WRAP->CHAT = wrap::CHAT = new chat; - //*>> - - // Init the system timer. - wrap::WRAP->TIMR = wrap::TIMR = new timr; - wrap::TIMR->run(); // run the thread - - //<<* - // Init the module-loader manager. - wrap::WRAP->MODL = wrap::MODL = new modl; - - // Init the garbage collector - wrap::WRAP->GCOL = wrap::GCOL = new gcol; - - // Init the data manager. -#ifdef DATABASE - - wrap::WRAP->DATA = wrap::DATA = new data; -#endif - //*>> - -#ifndef NCURSES -#ifdef CLI - - cli* p_cli = new cli; - p_cli->run(); -#endif -#endif + wrap::init_wrapper(parse_argc(argc, argv)); //<<* // Initialize database connection queue #ifdef DATABASE - - wrap::DATA->initialize_connections(); + wrap::DATA->init_connections(); #endif //*>> diff --git a/src/maps/shashmap.h b/src/maps/shashmap.h index 6152ba2..99dd7c8 100644 --- a/src/maps/shashmap.h +++ b/src/maps/shashmap.h @@ -4,6 +4,8 @@ #include <pthread.h> #include "hashmap.h" +#include "../monitor/dump.h" + using namespace std; template @@ -13,11 +15,15 @@ template class hash_type = size_hash<string>, class alloc_type = compare_allocator<string> > -class shashmap : protected hashmap<obj_type, key_type_, hash_type, alloc_type> +class shashmap : protected hashmap<obj_type, key_type_, hash_type, alloc_type>, + public dumpable { private: pthread_mutex_t mut_shashmap; +protected: + virtual void dumpit(); + public: explicit shashmap(); ~shashmap(); @@ -36,6 +42,7 @@ public: virtual inline vector<key_type_>* get_key_vector(); virtual inline void run_func( void (*func)(obj_type) ); virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg ); + }; #include "shashmap.tmpl" diff --git a/src/maps/shashmap.tmpl b/src/maps/shashmap.tmpl index 4559284..c864d28 100644 --- a/src/maps/shashmap.tmpl +++ b/src/maps/shashmap.tmpl @@ -139,3 +139,17 @@ shashmap<obj_type, key_type_, hash_type, alloc_type>::run_func( void (*func)(obj hashmap<obj_type, key_type_, hash_type, alloc_type>::run_func(func, v_arg); pthread_mutex_unlock( &mut_shashmap ); } + +template<class obj_type, class key_type_, class hash_type, class alloc_type> +void +shashmap<obj_type, key_type_, hash_type, alloc_type>::dumpit() +{ + dumpable::add("[shashmap]"); + vector<key_type_>* p_vec = get_key_vector(); + + typename vector<key_type_>::iterator iter; + for (iter = p_vec->begin(); iter != p_vec->end(); ++iter) + dumpable::add(*iter); + + delete p_vec; +} diff --git a/src/modl.cpp b/src/modl.cpp index 6668109..32fe33a 100755 --- a/src/modl.cpp +++ b/src/modl.cpp @@ -113,6 +113,14 @@ modl::cache_module( string s_name, bool b_print_sys_msg ) } dynmod* +modl::get_module( string s_name, string s_user ) +{ + wrap::system_message( MODULER + s_name.substr( s_name.find_last_of("/")+1 ) + " (" + s_user + ")"); + dynmod* mod = get_elem( s_name ); + return ! mod ? cache_module( s_name, true ) : mod; +} + +dynmod* modl::get_module( string s_name ) { wrap::system_message( MODULER + s_name.substr( s_name.find_last_of("/")+1 ) ); @@ -7,7 +7,7 @@ using namespace std; -class modl : private shashmap<dynmod*> +class modl : public shashmap<dynmod*> { private: static void dlclose_( dynmod* mod ); @@ -24,6 +24,7 @@ public: ~modl(); dynmod* get_module( string s_name ); + dynmod* get_module( string s_name, string s_user ); vector<string>* get_mod_vector() { diff --git a/src/mods/commands/Makefile b/src/mods/commands/Makefile index 6aec38d..43346bb 100644 --- a/src/mods/commands/Makefile +++ b/src/mods/commands/Makefile @@ -1,11 +1,11 @@ SRCS=yc_about.cpp yc_all.cpp yc_away.cpp yc_col.cpp yc_compopt.cpp yc_exec.cpp yc_fake.cpp yc_getroom.cpp yc_getrusage.cpp yc_help.cpp yc_invisible.cpp yc_j.cpp yc_ko.cpp yc_m.cpp yc_md5.cpp yc_me.cpp yc_morph.cpp yc_msg.cpp yc_q.cpp yc_reload.cpp yc_ren.cpp yc_s.cpp yc_set.cpp yc_template.cpp yc_time.cpp yc_topic.cpp yc_uptime.cpp yc_users.cpp yc_version.cpp MODS=$(addprefix ../../../mods/commands/, $(SRCS:.cpp=.so)) -CC=g++ +CC=g++33 INCLUDES=`cat ../../includes.add` CFLAGS=`cat ../cflags.add` all: mods $(MODS): - @echo -n "Compiling command module `basename $@` " + @echo -n "Compiling command module `basename $@ | sed s/\.so// | sed s/yc_//` " @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/` @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g" diff --git a/src/mods/commands/Makefile.in b/src/mods/commands/Makefile.in index ce8c00f..7ca8455 100755 --- a/src/mods/commands/Makefile.in +++ b/src/mods/commands/Makefile.in @@ -4,7 +4,7 @@ INCLUDES=`cat ../../includes.add` CFLAGS=`cat ../cflags.add` all: mods $(MODS): - @echo -n "Compiling command module `basename $@` " + @echo -n "Compiling command module `basename $@ | sed s/\.so// | sed s/yc_//` " @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/` @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g" diff --git a/src/mods/html/Makefile b/src/mods/html/Makefile index 98deaf7..bd004f6 100644 --- a/src/mods/html/Makefile +++ b/src/mods/html/Makefile @@ -1,11 +1,11 @@ SRCS=yc_admin.cpp yc_colors.cpp yc_help.cpp yc_loggedin.cpp yc_options.cpp yc_register.cpp MODS=$(addprefix ../../../mods/html/, $(SRCS:.cpp=.so)) -CC=g++ +CC=g++33 INCLUDES=`cat ../../includes.add` CFLAGS=`cat ../cflags.add` all: mods $(MODS): - @echo -n "Compiling html module `basename $@` " + @echo -n "Compiling html module `basename $@ | sed s/\.so// | sed s/yc_//` " @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/` @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g" diff --git a/src/mods/html/Makefile.in b/src/mods/html/Makefile.in index 30f1782..b65c9e6 100755 --- a/src/mods/html/Makefile.in +++ b/src/mods/html/Makefile.in @@ -4,7 +4,7 @@ INCLUDES=`cat ../../includes.add` CFLAGS=`cat ../cflags.add` all: mods $(MODS): - @echo -n "Compiling html module `basename $@` " + @echo -n "Compiling html module `basename $@ | sed s/\.so// | sed s/yc_//` " @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/` @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g" @@ -86,6 +86,7 @@ #define SESSION "Session: Count " #define SESSDMP "Session: Dump of session" #define SESSERR "Session: Could not find session " +#define SESSEXI "Session: New TempID already exists, recalc." #define SHELLER "Shell: Could not execute command" #define SHELLEX "Shell: Executing the following command:" #define SIGSIGV "Signal: SIGV received!" @@ -112,14 +113,14 @@ #define XMLREAD "XML: Reading " #define XMLERR "XML Error: " #define XMLER1 "XML Error: Unable to load file " -#define VERSION "0.7.8" +#define VERSION "0.7.9.2" #define BRANCH "RELEASE" -#define BUILDNR 3592 -#define UNAME "FreeBSD 5.3-RELEASE-p5 i386" -#define COMPOPT "Using built-in specs.; Configured with: FreeBSD/i386 system compiler; Thread model: posix; gcc version 3.4.2 [FreeBSD] 20040728; 3.4; g++" +#define BUILDNR 3797 +#define UNAME "OpenBSD 3.6 i386" +#define COMPOPT "Reading specs from /usr/local/lib/gcc-lib/i386-unknown-openbsd3.6/3.3.2/specs; Configured with: /usr/obj/i386/gcc-3.3.2/gcc-3.3.2/configure --verbose --program-transform-name=s,^,e, --disable-nls --with-system-zlib --enable-cpp --enable-languages=c,c++,f77,objc,java --enable-sjlj-exceptions --with-gnu-as --with-gnu-ld --enable-shared --prefix=/usr/local --sysconfdir=/etc; Thread model: single; gcc version 3.3.2; 3.3; g++33" #define YCUSAGE "Usage: ./ychat {h|v}|{o confkey confvalue}\n" -#define HEADER1 "HTTP/1.0 200 OK\r\n" +#define HEADER1 "HTTP/1.1 200 OK\r\n" #define HEADER2 "Server: yChat/" VERSION "-" BRANCH "\r\n" #define HEADER3 "Cache-control: no-cache\r\n" #define HEADER4 "Pragma: no-cache\r\n" @@ -127,6 +128,7 @@ #define HEADER6 "Connection: keep-alive\r\n" #define HEADER7 "Content-Length: "; #define HEADER8 "Content-Type: "; -#define HEADER9 "Allow: GET\n"; +#define HEADER8b "; charset=ISO-8859-1\r\n"; +#define HEADER9 "Allow: GET\r\n"; #endif diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp index 9196111..9b0996c 100755 --- a/src/ncur/ncur.cpp +++ b/src/ncur/ncur.cpp @@ -212,7 +212,7 @@ ncur::switch_main_menu_( int i_choice ) def_prog_mode(); /* Save the tty modes */ endwin(); /* End curses mode temporarily */ - new cli(); /* Start CLI mode */ + delete new cli(); /* Start CLI mode */ reset_prog_mode(); /* Return to the previous tty mode*/ /* stored by def_prog_mode() */ refresh(); /* Do refresh() to restore the */ @@ -253,8 +253,9 @@ ncur::init_ncurses() clear(); noecho(); cbreak(); // Line buffering disabled. pass on everything - init_pair(1, COLOR_WHITE, COLOR_BLUE); + init_pair(1, COLOR_BLACK, COLOR_CYAN); mvprintw( 0,2, (char*)(tool::ychat_version()).c_str()); + curs_set(0); refresh(); } diff --git a/src/ncur/ncur.h b/src/ncur/ncur.h index e5627c8..1830cdf 100755 --- a/src/ncur/ncur.h +++ b/src/ncur/ncur.h @@ -29,8 +29,8 @@ private: pthread_mutex_t mut_is_ready; public: - ncur( ); // a standard constructor. - ~ncur( ); + ncur(); + ~ncur(); void start( void *p_void ); void print( char* c_print ); diff --git a/src/reqp.cpp b/src/reqp.cpp index 905f1a4..558d0b8 100755 --- a/src/reqp.cpp +++ b/src/reqp.cpp @@ -13,6 +13,7 @@ const string reqp::s_http = HEADER; const string reqp::s_http_stream = STREAM; const string reqp::s_http_colength = HEADER7; const string reqp::s_http_cotype = HEADER8; +const string reqp::s_http_cotype_add = HEADER8b; reqp::reqp( ) {} @@ -338,8 +339,9 @@ reqp::parse( int &i_sock, string s_req, map<string,string> &map_params ) if ( s_event.compare("stream") == 0 ) s_resp.append( s_http_stream ); - s_resp.append( s_http_colength + tool::int2string(s_rep.size()) + "\n" + - s_http_cotype + map_params["content-type"] + "\r\n\r\n" ); + s_resp.append( s_http_colength + tool::int2string(s_rep.size()) + "\r\n" + + s_http_cotype + map_params["content-type"] + + s_http_cotype_add + "\r\n" ); s_resp.append(s_rep); @@ -360,7 +362,7 @@ reqp::run_html_mod( string s_event, map<string,string> &map_params, user* p_user string s_mod = wrap::CONF->get_elem("httpd.modules.htmldir") + "yc_" + s_event + ".so"; - dynmod* p_module = wrap::MODL->get_module( s_mod ); + dynmod* p_module = wrap::MODL->get_module( s_mod, p_user->get_name() ); if ( p_module != NULL ) ( *( p_module->the_func ) ) ( static_cast<void*>(c) ); @@ -13,6 +13,7 @@ private: static const string s_http_stream; static const string s_http_colength; static const string s_http_cotype; + static const string s_http_cotype_add; // returns the request url from thr client's http request header // until the first "?" and stores all request parameter values diff --git a/src/sign.cpp b/src/sign.cpp index db97d19..6f4edee 100644 --- a/src/sign.cpp +++ b/src/sign.cpp @@ -30,13 +30,18 @@ sign::terminate_received(int i_param) { #ifdef NCURSES - if ( ! wrap::GCOL->remove_garbage() ) //<< - wrap::NCUR->print( GAROFFNE ); //<< + //<<* + if ( ! wrap::GCOL->remove_garbage() ) + wrap::NCUR->print( GAROFFNE ); + //*>> mvprintw( 21,2, "Good bye !"); wrap::NCUR->close_ncurses(); + + //<<* #else wrap::GCOL->remove_garbage(); + //*>> #endif exit(0); diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp index 5f6ede3..42daf24 100755 --- a/src/sock/sock.cpp +++ b/src/sock/sock.cpp @@ -306,7 +306,7 @@ sock::clean_ipcache() int i_ipcachesize = wrap::CONF->get_int("httpd.ipcachesize"); int i_currentsize = size(); - if ( i_currentsize > 0 && (i_ipcachesize == 0 || i_ipcachesize >= i_currentsize) ) + if ( i_currentsize > 0 && (i_ipcachesize == 0 || i_ipcachesize <= i_currentsize) ) { wrap::system_message( SOCKCA2+tool::int2string(i_currentsize)+","+tool::int2string(i_ipcachesize)+")"); diff --git a/src/sock/sock.h b/src/sock/sock.h index 62f32ae..bb34fc8 100755 --- a/src/sock/sock.h +++ b/src/sock/sock.h @@ -21,7 +21,7 @@ using namespace std; -class sock : protected shashmap +class sock : public shashmap < string, uint32_t, self_hash<uint32_t>, equals_allocator<uint32_t> > { private: diff --git a/src/thrd/pool.h b/src/thrd/pool.h index 78c4163..ab03b57 100755 --- a/src/thrd/pool.h +++ b/src/thrd/pool.h @@ -10,6 +10,8 @@ using namespace std; class pool { private: + friend class thro; + struct task { void(*p_func)(void*); diff --git a/src/thrd/thro.cpp b/src/thrd/thro.cpp index e35520c..8b3f1ba 100644 --- a/src/thrd/thro.cpp +++ b/src/thrd/thro.cpp @@ -23,6 +23,7 @@ thro::run( void *p_void ) { elem.p_thro = this; elem.p_void = p_void; + //wrap::POOL->add_task(start_, &elem); pthread_create( &pthread, NULL, start_, &elem ); } diff --git a/src/thrd/thro.h b/src/thrd/thro.h index 783cd0d..8e7e0cf 100644 --- a/src/thrd/thro.h +++ b/src/thrd/thro.h @@ -17,7 +17,7 @@ private: } elem; - static void* start_( void *p_void ); + static void *start_( void *p_void ); public: thro( ); diff --git a/src/time/timr.cpp b/src/time/timr.cpp index b04dc6b..1473a16 100755 --- a/src/time/timr.cpp +++ b/src/time/timr.cpp @@ -103,11 +103,11 @@ timr::start( void *v_ptr ) wrap::DATA->check_data_con_timeout(); #endif //*>> - wrap::SOCK->clean_ipcache(); - // Run every ten minutes: if ( time_now.tm_min % 10 == 0 ) { + + wrap::SOCK->clean_ipcache(); // Run every hour if ( time_now.tm_min % 60 == 0 ) { diff --git a/src/wrap.cpp b/src/wrap.cpp index f675c1a..c46d986 100755 --- a/src/wrap.cpp +++ b/src/wrap.cpp @@ -33,15 +33,93 @@ void wrap::system_message( string s_message ) { #ifdef NCURSES - wrap::NCUR->print( s_message ); + NCUR->print( s_message ); #endif -#ifdef SERVMSG +#ifdef SERVMSG cout << s_message << endl; #endif + +#ifdef LOGGING + LOGD->log_simple_line( s_message + "\n" ); +#endif +} + +void +wrap::init_wrapper(map<string,string>* p_start_params) +{ + // Init the dynamic wrapper (is needed to pass all wrapped objects through a single pointer). + WRAP = new dynamic_wrap; + + // Init the config manager. + WRAP->CONF = CONF = new conf( CONFILE, p_start_params ); + delete p_start_params, + + // Init the statistic manager. + WRAP->STAT = STAT = new stats; + + // Init the html-template manager. + WRAP->HTML = HTML = new html; + #ifdef LOGGING + // Init the system message logd + WRAP->LOGD = LOGD = new logd( CONF->get_elem("httpd.logging.systemfile"), + CONF->get_elem("httpd.logging.systemlines") ); +#endif + + //<<* + // Init the session manager. + WRAP->SMAN = SMAN = new sman; + //*>> + - wrap::LOGD->log_simple_line( s_message + "\n" ); +#ifdef NCURSES + + WRAP->NCUR = NCUR = new ncur; // init the ncurses admin interface. + NCUR->run(); // run the thread + + // Wait until ncurses interface has been initialized. + do { + usleep(1000); + } while ( ! NCUR->is_ready() ); + + HTML->print_cached(0); +#else +#ifdef CLI + cli* p_cli = new cli; + p_cli->run(); +#endif +#endif + + // Init the thread pool + WRAP->POOL = POOL = new pool; + + // Init the socket manager. + WRAP->SOCK = SOCK = new sock; + + //<<* + // Init the chat manager. + WRAP->CHAT = CHAT = new chat; + //*>> + + // Init the system timer. + WRAP->TIMR = TIMR = new timr; + + //<<* + // Init the module-loader manager. + WRAP->MODL = MODL = new modl; + + // Init the garbage collector + WRAP->GCOL = GCOL = new gcol; + + // Init the data manager. +#ifdef DATABASE + WRAP->DATA = DATA = new data; #endif + //*>> + + // Run threads + TIMR->run(); } + #endif @@ -15,15 +15,22 @@ //<<* #include "modl.h" //*>> + #ifdef NCURSES #include "ncur/ncur.h" +#else +#ifdef CLI +#include "cli/cli.h" +#endif #endif + #include "chat/sman.h" #include "sock/sock.h" -#include "stats.h" +#include "monitor/stats.h" #include "time/timr.h" #include "thrd/pool.h" + using namespace std; class dynamic_wrap @@ -73,6 +80,8 @@ public: static void system_message( string s_message ); + static void init_wrapper(map<string,string>* p_start_params); + //<<* static chat* CHAT; #ifdef DATABASE |
