summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:48 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:48 +0200
commit5a019f435eb0068b524566d9babf172d58d0e96e (patch)
treeb083dccdfbec4335a5967d50c4294f7501c77345 /src
parent4ecbf33fae730bc79c4a47e6efda615b104754ad (diff)
tagging ychat-0.7.9.2ychat-0.7.9.2
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chat/base.h4
-rwxr-xr-xsrc/chat/base.tmpl30
-rwxr-xr-xsrc/chat/chat.cpp8
-rwxr-xr-xsrc/chat/chat.h1
-rwxr-xr-xsrc/chat/gcol.cpp2
-rwxr-xr-xsrc/chat/room.cpp10
-rwxr-xr-xsrc/chat/room.h2
-rwxr-xr-xsrc/chat/sman.cpp20
-rwxr-xr-xsrc/chat/sman.h3
-rwxr-xr-xsrc/chat/user.cpp43
-rwxr-xr-xsrc/chat/user.h7
-rwxr-xr-xsrc/cli/cli.cpp29
-rwxr-xr-xsrc/cli/cli.h8
-rwxr-xr-xsrc/conf/conf.cpp9
-rwxr-xr-xsrc/configure10
-rw-r--r--src/data/data_base.cpp2
-rw-r--r--src/data/data_base.h2
-rwxr-xr-xsrc/glob.h4
-rwxr-xr-xsrc/html.cpp3
-rwxr-xr-xsrc/main.cpp89
-rw-r--r--src/maps/shashmap.h9
-rw-r--r--src/maps/shashmap.tmpl14
-rwxr-xr-xsrc/modl.cpp8
-rwxr-xr-xsrc/modl.h3
-rw-r--r--src/mods/commands/Makefile4
-rwxr-xr-xsrc/mods/commands/Makefile.in2
-rw-r--r--src/mods/html/Makefile4
-rwxr-xr-xsrc/mods/html/Makefile.in2
-rwxr-xr-xsrc/msgs.h14
-rwxr-xr-xsrc/ncur/ncur.cpp5
-rwxr-xr-xsrc/ncur/ncur.h4
-rwxr-xr-xsrc/reqp.cpp8
-rwxr-xr-xsrc/reqp.h1
-rw-r--r--src/sign.cpp9
-rwxr-xr-xsrc/sock/sock.cpp2
-rwxr-xr-xsrc/sock/sock.h2
-rwxr-xr-xsrc/thrd/pool.h2
-rw-r--r--src/thrd/thro.cpp1
-rw-r--r--src/thrd/thro.h2
-rwxr-xr-xsrc/time/timr.cpp4
-rwxr-xr-xsrc/wrap.cpp84
-rwxr-xr-xsrc/wrap.h11
42 files changed, 325 insertions, 156 deletions
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 );
diff --git a/src/glob.h b/src/glob.h
index 3fe9b7f..7d64126 100755
--- a/src/glob.h
+++ b/src/glob.h
@@ -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 ) );
diff --git a/src/modl.h b/src/modl.h
index 983bdda..73abd58 100755
--- a/src/modl.h
+++ b/src/modl.h
@@ -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"
diff --git a/src/msgs.h b/src/msgs.h
index 46bd57c..ffe811f 100755
--- a/src/msgs.h
+++ b/src/msgs.h
@@ -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) );
diff --git a/src/reqp.h b/src/reqp.h
index 4c322cd..7d6bd07 100755
--- a/src/reqp.h
+++ b/src/reqp.h
@@ -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
diff --git a/src/wrap.h b/src/wrap.h
index 51eb9dd..f2707ea 100755
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -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