summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CVS/Entries40
-rw-r--r--src/CVS/Entries.Log1
-rw-r--r--src/chat/CVS/Entries32
-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.h8
-rw-r--r--src/cli/CVS/Entries4
-rwxr-xr-xsrc/cli/cli.cpp29
-rwxr-xr-xsrc/cli/cli.h8
-rw-r--r--src/conf/CVS/Entries4
-rwxr-xr-xsrc/conf/conf.cpp9
-rwxr-xr-xsrc/configure16
-rw-r--r--src/contrib/crypt/CVS/Entries6
-rw-r--r--src/contrib/xml/CVS/Entries8
-rw-r--r--src/data/CVS/Entries14
-rw-r--r--src/data/data_base.cpp2
-rw-r--r--src/data/data_base.h2
-rwxr-xr-xsrc/glob.h72
-rwxr-xr-xsrc/html.cpp3
-rwxr-xr-xsrc/main.cpp89
-rw-r--r--src/maps/CVS/Entries16
-rw-r--r--src/maps/shashmap.h9
-rw-r--r--src/maps/shashmap.tmpl14
-rw-r--r--src/memb/memb.h50
-rw-r--r--src/memb/memb.tmpl67
-rw-r--r--src/memb/tupel.h2
-rw-r--r--src/memb/tupel.tmpl14
-rwxr-xr-xsrc/modl.cpp8
-rwxr-xr-xsrc/modl.h3
-rw-r--r--src/mods/commands/CVS/Entries60
-rwxr-xr-xsrc/mods/commands/Makefile.in2
-rw-r--r--src/mods/html/CVS/Entries14
-rwxr-xr-xsrc/mods/html/Makefile.in4
-rwxr-xr-xsrc/msgs.h14
-rw-r--r--src/ncur/CVS/Entries8
-rwxr-xr-xsrc/ncur/ncur.cpp5
-rwxr-xr-xsrc/ncur/ncur.h4
-rwxr-xr-xsrc/reqp.cpp52
-rwxr-xr-xsrc/reqp.h7
-rw-r--r--src/sign.cpp9
-rw-r--r--src/sock/CVS/Entries4
-rwxr-xr-xsrc/sock/sock.cpp323
-rwxr-xr-xsrc/sock/sock.h38
-rw-r--r--src/stats.cpp167
-rw-r--r--src/stats.h23
-rw-r--r--src/thrd/CVS/Entries8
-rwxr-xr-xsrc/thrd/pool.cpp9
-rwxr-xr-xsrc/thrd/pool.h9
-rw-r--r--src/thrd/thro.cpp1
-rw-r--r--src/thrd/thro.h2
-rw-r--r--src/time/CVS/Entries8
-rwxr-xr-xsrc/time/timr.cpp4
-rw-r--r--src/tool/CVS/Entries8
-rwxr-xr-xsrc/wrap.cpp132
-rwxr-xr-xsrc/wrap.h21
63 files changed, 540 insertions, 1049 deletions
diff --git a/src/CVS/Entries b/src/CVS/Entries
index 7009aff..4472904 100644
--- a/src/CVS/Entries
+++ b/src/CVS/Entries
@@ -1,21 +1,23 @@
/Makefile.in/1.22/Tue Sep 7 17:14:39 2004//
-/configure/1.28/Fri Jan 7 21:00:19 2005//
-/glob.h/1.51/Sun Feb 13 03:53:35 2005//
-/html.cpp/1.18/Thu Feb 10 16:07:18 2005//
-/html.h/1.8/Fri Jan 7 21:00:19 2005//
-/incl.h/1.4/Fri Jan 7 21:00:19 2005//
-/logd.cpp/1.9/Sun Feb 6 16:38:36 2005//
-/logd.h/1.7/Sun Feb 6 16:38:36 2005//
-/main.cpp/1.30/Thu Feb 10 19:55:24 2005//
-/modl.cpp/1.16/Fri Jan 7 21:00:19 2005//
-/modl.h/1.8/Thu Nov 18 13:41:47 2004//
-/msgs.h/1.161/Mon Feb 14 20:09:50 2005//
-/name.cpp/1.7/Fri Jan 7 21:00:19 2005//
-/name.h/1.5/Fri Jan 7 21:00:19 2005//
-/reqp.cpp/1.34/Thu Feb 10 16:07:18 2005//
-/reqp.h/1.12/Sun Feb 6 16:38:36 2005//
-/stats.cpp/1.9/Fri Jan 7 21:00:19 2005//
-/stats.h/1.6/Fri Jan 7 21:00:19 2005//
-/wrap.cpp/1.15/Wed Feb 9 22:42:58 2005//
-/wrap.h/1.22/Wed Feb 9 22:42:58 2005//
+/configure/1.38/Sun Feb 27 06:28:53 2005//
+/glob.h/1.70/Fri Mar 4 21:09:34 2005//
+/html.cpp/1.23/Wed Feb 23 20:23:31 2005//
+/html.h/1.11/Wed Feb 23 03:12:05 2005//
+/incl.h/1.7/Wed Feb 23 03:12:05 2005//
+/logd.cpp/1.15/Sun Feb 27 06:28:53 2005//
+/logd.h/1.11/Wed Feb 23 03:12:05 2005//
+/main.cpp/1.37/Fri Mar 4 02:41:30 2005//
+/modl.cpp/1.18/Mon Feb 21 01:55:49 2005//
+/modl.h/1.10/Mon Feb 21 01:55:49 2005//
+/msgs.h/1.200/Sat Mar 5 11:35:09 2005//
+/name.cpp/1.8/Mon Feb 21 01:55:49 2005//
+/name.h/1.6/Mon Feb 21 01:55:49 2005//
+/reqp.cpp/1.41/Tue Mar 1 16:11:03 2005//
+/reqp.h/1.15/Wed Feb 23 03:12:05 2005//
+/sign.cpp/1.2/Fri Mar 4 21:09:34 2005//
+/sign.h/1.1/Fri Mar 4 02:41:30 2005//
+/stats.cpp/1.10/Mon Feb 21 01:55:49 2005//
+/stats.h/1.7/Mon Feb 21 01:55:49 2005//
+/wrap.cpp/1.17/Fri Feb 25 00:15:38 2005//
+/wrap.h/1.24/Fri Feb 25 00:15:38 2005//
D
diff --git a/src/CVS/Entries.Log b/src/CVS/Entries.Log
index fd574a4..7d9d881 100644
--- a/src/CVS/Entries.Log
+++ b/src/CVS/Entries.Log
@@ -5,6 +5,7 @@ A D/contrib////
A D/data////
A D/irc////
A D/maps////
+A D/memb////
A D/mods////
A D/ncur////
A D/sock////
diff --git a/src/chat/CVS/Entries b/src/chat/CVS/Entries
index 8d2fcbd..26360be 100644
--- a/src/chat/CVS/Entries
+++ b/src/chat/CVS/Entries
@@ -1,17 +1,17 @@
-/base.h/1.5/Fri Jan 7 21:00:19 2005//
-/base.tmpl/1.4/Thu Nov 18 13:41:47 2004//
-/chat.cpp/1.14/Fri Jan 7 21:00:19 2005//
-/chat.h/1.8/Fri Jan 7 21:00:19 2005//
-/gcol.cpp/1.4/Thu Nov 18 13:41:47 2004//
-/gcol.h/1.3/Thu Nov 18 13:41:47 2004//
-/perm.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/perm.h/1.5/Thu Nov 18 13:41:47 2004//
-/room.cpp/1.9/Sun Feb 6 16:38:36 2005//
-/room.h/1.5/Sun Feb 6 16:38:36 2005//
-/sess.cpp/1.5/Tue Jan 4 18:31:35 2005//
-/sess.h/1.5/Tue Jan 4 18:31:35 2005//
-/sman.cpp/1.9/Tue Jan 4 18:31:35 2005//
-/sman.h/1.4/Tue Jan 4 18:31:35 2005//
-/user.cpp/1.13/Mon Feb 14 20:09:50 2005//
-/user.h/1.6/Fri Jan 7 21:00:19 2005//
+/base.h/1.8/Mon Feb 21 01:55:49 2005//
+/base.tmpl/1.6/Mon Feb 21 01:55:49 2005//
+/chat.cpp/1.20/Fri Feb 25 00:15:38 2005//
+/chat.h/1.12/Wed Feb 23 03:12:05 2005//
+/gcol.cpp/1.7/Mon Feb 21 01:55:49 2005//
+/gcol.h/1.5/Mon Feb 21 01:55:49 2005//
+/perm.cpp/1.10/Mon Feb 21 01:55:49 2005//
+/perm.h/1.8/Mon Feb 21 01:55:49 2005//
+/room.cpp/1.11/Fri Mar 4 00:34:29 2005//
+/room.h/1.8/Fri Mar 4 00:34:29 2005//
+/sess.cpp/1.6/Mon Feb 21 01:55:49 2005//
+/sess.h/1.6/Mon Feb 21 01:55:49 2005//
+/sman.cpp/1.11/Mon Feb 21 01:55:49 2005//
+/sman.h/1.6/Mon Feb 21 01:55:49 2005//
+/user.cpp/1.17/Wed Feb 23 20:23:31 2005//
+/user.h/1.11/Mon Feb 21 01:55:49 2005//
D
diff --git a/src/chat/base.h b/src/chat/base.h
index b995c5c..9da4304 100755
--- a/src/chat/base.h
+++ b/src/chat/base.h
@@ -9,9 +9,6 @@
template<class type>
class base : public nhashmap<type*>
{
-protected:
- void dumpit();
-
public:
base();
~base();
@@ -25,7 +22,6 @@ 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 5b0fceb..0be21aa 100755
--- a/src/chat/base.tmpl
+++ b/src/chat/base.tmpl
@@ -22,40 +22,10 @@ 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 e4cbaac..0839261 100755
--- a/src/chat/chat.cpp
+++ b/src/chat/chat.cpp
@@ -165,6 +165,7 @@ 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"] );
@@ -360,11 +361,4 @@ 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 bb087d5..47645c3 100755
--- a/src/chat/chat.h
+++ b/src/chat/chat.h
@@ -23,7 +23,6 @@ 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 d4c9416..7df111d 100755
--- a/src/chat/gcol.cpp
+++ b/src/chat/gcol.cpp
@@ -44,8 +44,6 @@ 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 0e28c84..b927d40 100755
--- a/src/chat/room.cpp
+++ b/src/chat/room.cpp
@@ -101,14 +101,4 @@ 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 4c5fac6..06b0a9a 100755
--- a/src/chat/room.h
+++ b/src/chat/room.h
@@ -23,8 +23,6 @@ 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 530aa17..d80d421 100755
--- a/src/chat/sman.cpp
+++ b/src/chat/sman.cpp
@@ -21,33 +21,23 @@ sman::~sman()
string sman::generate_id( int i_len )
{
- string s_valid = wrap::CONF->get_elem("chat.session.validchars");
+ string valid_chars = 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() % s_valid.length();
- s_ret += s_valid[i_char];
+ i_char = rand() % 64;
+ s_ret += valid_chars[i_char];
}
if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" )
{
string s_salt = wrap::CONF->get_elem("chat.session.md5salt");
- 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);
+ 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);
}
return s_ret;
diff --git a/src/chat/sman.h b/src/chat/sman.h
index 13fc45a..992fc64 100755
--- a/src/chat/sman.h
+++ b/src/chat/sman.h
@@ -7,11 +7,10 @@
#include "sess.h"
#include "../maps/shashmap.h"
-#include "../monitor/dump.h"
using namespace std;
-class sman : public shashmap<sess*>
+class sman : private shashmap<sess*>
{
private:
string generate_id( int i_len );
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
index bac8b7e..4f1646b 100755
--- a/src/chat/user.cpp
+++ b/src/chat/user.cpp
@@ -73,27 +73,23 @@ 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
- set_has_sess(false);
- wrap::SMAN->destroy_session(get_tmpid());
- set_tmpid("");
+ 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, "" );
}
string
@@ -415,7 +411,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, get_name() );
+ dynmod *mod = wrap::MODL->get_module( s_mod );
if ( mod == NULL ||
wrap::CHAT->get_command_disabled( s_command2 ) ||
@@ -581,15 +577,4 @@ 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 4632e07..443eef6 100755
--- a/src/chat/user.h
+++ b/src/chat/user.h
@@ -5,13 +5,13 @@
#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 dumpable
+class user : public name, public timo//, public memb<string>
{
private:
@@ -56,8 +56,7 @@ private:
pthread_mutex_t mut_map_changed_data;
void initialize();
- void set_changed_data( string s_varname, string s_value );
- void dumpit();
+ void set_changed_data( string s_varname, string s_value );
public:
pthread_cond_t cond_message;
@@ -68,7 +67,6 @@ 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/CVS/Entries b/src/cli/CVS/Entries
index 7d01982..10c9656 100644
--- a/src/cli/CVS/Entries
+++ b/src/cli/CVS/Entries
@@ -1,3 +1,3 @@
-/cli.cpp/1.25/Wed Feb 9 22:42:58 2005//
-/cli.h/1.11/Fri Jan 7 21:00:19 2005//
+/cli.cpp/1.28/Mon Feb 28 18:03:02 2005//
+/cli.h/1.13/Mon Feb 21 02:14:23 2005//
D
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index cc0f5e5..96a0010 100755
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -37,8 +37,6 @@ 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
@@ -80,11 +78,6 @@ 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;
@@ -141,7 +134,6 @@ cli::parse_input( string s_input )
{
cout << CLIPRMO;
wrap::MODL->reload_modules();
- cout << MODRELO << endl;
cout << CLIPRMI;
}
//*>>
@@ -215,7 +207,6 @@ cli::parse_input( string s_input )
{
cout << CLIPRMO;
wrap::MODL->unload_modules();
- cout << MODUNLO << endl;
cout << CLIPRMI;
}
//*>>
@@ -294,26 +285,6 @@ 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 7d51e3f..23e1d1c 100755
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -22,8 +22,6 @@
#include "../thrd/thro.h"
#endif
-#include "../monitor/dump.h"
-
using namespace std;
#ifndef NCURSES
@@ -34,9 +32,8 @@ class cli
{
#endif
private:
- int parse_input(string s_input);
- vector<string> vectorize(string s_param);
-
+ int parse_input(string s_input);
+
public:
cli( );
~cli( );
@@ -55,6 +52,7 @@ void start(void* p_void);
void start();
#endif
+
};
#endif
diff --git a/src/conf/CVS/Entries b/src/conf/CVS/Entries
index 68ec4ab..cfb51ed 100644
--- a/src/conf/CVS/Entries
+++ b/src/conf/CVS/Entries
@@ -1,3 +1,3 @@
-/conf.cpp/1.11/Fri Jan 7 21:00:19 2005//
-/conf.h/1.7/Fri Jan 7 21:00:19 2005//
+/conf.cpp/1.14/Sun Feb 27 06:28:53 2005//
+/conf.h/1.11/Sun Feb 27 06:28:53 2005//
D
diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp
index 38c29c4..2e5893b 100755
--- a/src/conf/conf.cpp
+++ b/src/conf/conf.cpp
@@ -36,7 +36,6 @@ conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_
cout << CFILEFA << endl;
exit(1);
}
-
else
{
cout << CFILEOK << "..." << endl;
@@ -77,18 +76,12 @@ 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(),"config") == 0 )
- {
- parse_xml(p_child, p_vec);
- }
-
- else if ( strcmp(p_child->Value(),"category") == 0 )
+ 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 125890c..eb54cce 100755
--- a/src/configure
+++ b/src/configure
@@ -70,7 +70,7 @@ perl -e '
remove_from_array("libmysqlclient.so",\@libs);
}
- if ( /\/\/#define NCURSES/ )
+ elsif ( /\/\/#define NCURSES/ )
{
remove_from_array("ncurses.h",\@headers);
remove_from_array("libncurses.so",\@libs);
@@ -156,23 +156,19 @@ 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";
- my $class = $ofile;
- $class =~ s/\.o//;
-
- my $text;
- if ( $class =~ /contrib\/.+/ )
+ if ( $ofile =~ /contrib\/.+/ )
{
- my $dirname = `dirname $class`;
- $text = "\t\@echo -n \"Contributed class $class \"\n";
+ my $dirname = `dirname $ofile`;
+ print Fout "\t\@echo -n \"Compiling contributed class $ofile \"\n";
}
else
{
- $text = "\t\@echo -n \"Base class $class \"\n";
+ print Fout "\t\@echo -n \"Compiling base class $ofile \"\n";
}
print Fout "\t\@\$(CC) \$(CFLAGS) \$(INCLUDES) $args -c -o ../obj/$ofile $cppfile\n";
- print Fout $text."\t\@du -hc ../obj/$ofile | tail -n 1 | sed s/total// | sed \"s/ //g\"\n";
+ print Fout "\t\@du -hc ../obj/$ofile | tail -n 1 | sed s/total// | sed \"s/ //g\"\n";
}
close Fout;
diff --git a/src/contrib/crypt/CVS/Entries b/src/contrib/crypt/CVS/Entries
index 0548c58..78ab490 100644
--- a/src/contrib/crypt/CVS/Entries
+++ b/src/contrib/crypt/CVS/Entries
@@ -1,5 +1,5 @@
/how/1.1/Tue Aug 31 17:50:55 2004//
-/md5.cpp/1.3/Thu Nov 18 13:41:47 2004//
-/md5.h/1.3/Thu Nov 18 13:41:47 2004//
-/md5crypt.cpp/1.3/Thu Nov 18 13:41:47 2004//
+/md5.cpp/1.4/Mon Feb 21 01:55:49 2005//
+/md5.h/1.4/Mon Feb 21 01:55:49 2005//
+/md5crypt.cpp/1.4/Mon Feb 21 01:55:49 2005//
D
diff --git a/src/contrib/xml/CVS/Entries b/src/contrib/xml/CVS/Entries
index fa52de9..baf8483 100644
--- a/src/contrib/xml/CVS/Entries
+++ b/src/contrib/xml/CVS/Entries
@@ -1,6 +1,6 @@
/README/1.1/Tue Sep 7 17:28:34 2004//
-/tinyxml.cpp/1.3/Thu Nov 18 13:41:47 2004//
-/tinyxml.h/1.4/Thu Nov 18 13:41:47 2004//
-/tinyxmlerror.cpp/1.3/Thu Nov 18 13:41:47 2004//
-/tinyxmlparser.cpp/1.3/Thu Nov 18 13:41:47 2004//
+/tinyxml.cpp/1.4/Mon Feb 21 01:55:49 2005//
+/tinyxml.h/1.5/Mon Feb 21 01:55:49 2005//
+/tinyxmlerror.cpp/1.4/Mon Feb 21 01:55:49 2005//
+/tinyxmlparser.cpp/1.4/Mon Feb 21 01:55:49 2005//
D
diff --git a/src/data/CVS/Entries b/src/data/CVS/Entries
index 848bb28..eb4056f 100644
--- a/src/data/CVS/Entries
+++ b/src/data/CVS/Entries
@@ -1,10 +1,10 @@
/README/1.1/Sun Apr 11 05:17:03 2004//
-/con.cpp/1.8/Fri Jan 7 21:17:53 2005//
-/con.h/1.6/Fri Jan 7 21:17:53 2005//
+/con.cpp/1.9/Mon Feb 21 01:55:49 2005//
+/con.h/1.7/Mon Feb 21 01:55:49 2005//
/con_base.cpp/1.7/Fri Jan 7 21:17:53 2005//
-/con_base.h/1.7/Fri Jan 7 21:17:53 2005//
-/data.cpp/1.10/Fri Jan 7 21:17:53 2005//
-/data.h/1.7/Fri Jan 7 21:17:53 2005//
-/data_base.cpp/1.12/Fri Jan 7 21:17:53 2005//
-/data_base.h/1.9/Fri Jan 7 21:17:53 2005//
+/con_base.h/1.8/Mon Feb 21 01:55:49 2005//
+/data.cpp/1.13/Fri Feb 25 00:52:24 2005//
+/data.h/1.10/Fri Feb 25 00:52:24 2005//
+/data_base.cpp/1.14/Mon Feb 21 01:55:49 2005//
+/data_base.h/1.11/Mon Feb 21 01:55:49 2005//
D
diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp
index 8150608..05f4e0a 100644
--- a/src/data/data_base.cpp
+++ b/src/data/data_base.cpp
@@ -47,7 +47,7 @@ data_base::data_base( )
}
}
-void data_base::init_connections()
+void data_base::initialize_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 79f5630..1da5ce7 100644
--- a/src/data/data_base.h
+++ b/src/data/data_base.h
@@ -36,7 +36,7 @@ public:
data_base();
~data_base();
- void init_connections();
+ void initialize_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 a0d980a..3fe9b7f 100755
--- a/src/glob.h
+++ b/src/glob.h
@@ -1,11 +1,11 @@
/*
Notice:
-
+
All #defines which start with an CONFIG can be edited through
gmake config in the main directory!
*/
-#include "maps/hashmap.h"
+#include "maps/hashmap.h"
// global variables.
#ifndef GLOB_H
@@ -18,15 +18,15 @@
//<<*
/* FIRST THE YCHAT ONLY OPTIONS */
-/* - CONFIG -
+/* - CONFIG -
Should yChat get compiled with database support? Currently MyS-
QL only is a supported database.
*/
//#define DATABASE
#ifdef DATABASE
-#define USE_MYSQL
-/* - CONFIG -
+#define USE_MYSQL
+/* - CONFIG -
Should all database queries printed out at the admin interface?
(This option wont take action if database support has not been
chosen)
@@ -54,12 +54,12 @@
*/
#define CONFILE "ychat.conf"
-/* - DISABLED -
+/* - DISABLED -
Enable debugging options.
*/
//#define DEBUG
-/* - DISABLED -
+/* - DISABLED -
If you want to enable EXPERIMENTAL features, then set this val-
ue to true. Else use false which is recommended! All experimen-
al features are marked inside of the running yChat!
@@ -68,7 +68,7 @@
/* - CONFIG -
Should yChat get compiled with logging support?
-*/
+*/
#define LOGGING
/* - CONFIG -
@@ -80,33 +80,23 @@
*/
#define MAXPORT 65535
-/* Specifies the max amount of lines to read from a HTTP request
- header
-*/
-#define MAXLINES 30
-
-/* Specifies the max length of a lines to read from a HTTP request
- header
-*/
-#define MAXLENGTH 1024
-
/* - CONFIG -
Should yChat get compiled with ncurses support?
-*/
-#define NCURSES
+*/
+//#define NCURSES
-/* - CONFIG -
+/* - CONFIG -
Please specify the maximum length of a HTTP post request.
*/
#define POSTBUF 512
-/* - CONFIG -
+/* - CONFIG -
Please specify the size of a temporary buffer. (Will be used f-
or different tasks)
*/
#define READBUF 2048
-/* - CONFIG -
+/* - CONFIG -
Please specify the maximum length of a line read from a socket
or a file. ( config-file, html-template )
*/
@@ -131,9 +121,9 @@
will print a warning message into the system messages and will
not core dump if an error occurs.
*/
-//#define CTCSEGV
+#define CTCSEGV
-/* - CONFIG -
+/* - CONFIG -
Please chose if you want to use verbose server outputs or not.
The verbose messages will appear in the ncurses menu if ncurses
is enabled or in the server-window if yChat has been compiled
@@ -149,42 +139,42 @@
// The following values define the positions of the data stats in the NCURSES interface.
#ifdef NCURSES
#define NCUR_SERVER_HEADER_X 21
-#define NCUR_SERVER_HEADER_Y 2
+#define NCUR_SERVER_HEADER_Y 2
#define NCUR_PORT_X 22
#define NCUR_PORT_Y 2
#define NCUR_HITS_X 23
#define NCUR_HITS_Y 2
#define NCUR_POOL_HEADER_X 21
-#define NCUR_POOL_HEADER_Y 16
+#define NCUR_POOL_HEADER_Y 16
#define NCUR_POOL_WAIT_X 22
-#define NCUR_POOL_WAIT_Y 16
+#define NCUR_POOL_WAIT_Y 16
#define NCUR_POOL_RUNNING_X 23
-#define NCUR_POOL_RUNNING_Y 16
+#define NCUR_POOL_RUNNING_Y 16
#define NCUR_DATA_HEADER_X 21
-#define NCUR_DATA_HEADER_Y 35
+#define NCUR_DATA_HEADER_Y 35
#define NCUR_GARBAGE_X 22
#define NCUR_GARBAGE_Y 35
-#define NCUR_CON_QUEUE_X 23
+#define NCUR_CON_QUEUE_X 23
#define NCUR_CON_QUEUE_Y 35
#define NCUR_CHAT_HEADER_X 21
#define NCUR_CHAT_HEADER_Y 52
#define NCUR_NUM_ROOMS_X 22
-#define NCUR_NUM_ROOMS_Y 52
+#define NCUR_NUM_ROOMS_Y 52
#define NCUR_SESSION_X 23
-#define NCUR_SESSION_Y 52
+#define NCUR_SESSION_Y 52
#define NCUR_CACHED_HEADER_X 21
-#define NCUR_CACHED_HEADER_Y 68
+#define NCUR_CACHED_HEADER_Y 68
#define NCUR_CACHED_DOCS_X 22
-#define NCUR_CACHED_DOCS_Y 68
-#define NCUR_CACHED_MODS_X 23
-#define NCUR_CACHED_MODS_Y 68
+#define NCUR_CACHED_DOCS_Y 68
+#define NCUR_CACHED_MODS_X 23
+#define NCUR_CACHED_MODS_Y 68
#define NCUR_MENU_CHAR_X 0
-#define NCUR_MENU_CHAR_Y 33
+#define NCUR_MENU_CHAR_Y 33
#define NCUR_UPTIME_X 0
#define NCUR_UPTIME_Y 44
#define NCUR_TIME_X 0
@@ -202,13 +192,13 @@ typedef int function( void *v_arg );
struct container
{
- void* elem[4];
+ void* elem[4];
};
struct dynmod
{
- function *the_func ;
- void *the_module;
+ function *the_func ;
+ void *the_module;
};
typedef enum method_ {
diff --git a/src/html.cpp b/src/html.cpp
index 3f47867..4160f60 100755
--- a/src/html.cpp
+++ b/src/html.cpp
@@ -43,11 +43,12 @@ 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 c0adb5e..ffe5484 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,6 +23,11 @@
#include "incl.h"
#include "sign.h"
+#ifndef NCURSES
+#ifdef CLI
+#include "cli/cli.h"
+#endif
+#endif
#include "maps/hashmap.h"
@@ -80,18 +85,98 @@ 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;
- wrap::init_wrapper(parse_argc(argc, argv));
+
+ // 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
//<<*
// Initialize database connection queue
#ifdef DATABASE
- wrap::DATA->init_connections();
+
+ wrap::DATA->initialize_connections();
#endif
//*>>
diff --git a/src/maps/CVS/Entries b/src/maps/CVS/Entries
index b0587e6..991bf8b 100644
--- a/src/maps/CVS/Entries
+++ b/src/maps/CVS/Entries
@@ -1,9 +1,9 @@
-/hmap.h/1.7/Thu Nov 18 13:41:47 2004//
-/hmap.tmpl/1.7/Fri Jan 7 21:00:19 2005//
-/mtools.h/1.4/Fri Jan 7 21:00:19 2005//
-/mtools.tmpl/1.3/Thu Nov 18 13:41:47 2004//
-/nmap.h/1.4/Fri Jan 7 21:00:19 2005//
-/nmap.tmpl/1.3/Thu Nov 18 13:41:47 2004//
-/smap.h/1.9/Fri Jan 7 21:00:19 2005//
-/smap.tmpl/1.8/Fri Jan 7 21:00:19 2005//
+/hashmap.h/1.12/Fri Mar 4 21:00:44 2005//
+/hashmap.tmpl/1.6/Fri Mar 4 21:00:44 2005//
+/mtools.h/1.7/Mon Feb 21 01:55:49 2005//
+/mtools.tmpl/1.6/Mon Feb 21 01:55:49 2005//
+/nhashmap.h/1.5/Fri Mar 4 21:00:44 2005//
+/nhashmap.tmpl/1.4/Fri Mar 4 21:00:44 2005//
+/shashmap.h/1.8/Fri Mar 4 21:00:44 2005//
+/shashmap.tmpl/1.6/Fri Mar 4 21:00:45 2005//
D
diff --git a/src/maps/shashmap.h b/src/maps/shashmap.h
index 99dd7c8..6152ba2 100644
--- a/src/maps/shashmap.h
+++ b/src/maps/shashmap.h
@@ -4,8 +4,6 @@
#include <pthread.h>
#include "hashmap.h"
-#include "../monitor/dump.h"
-
using namespace std;
template
@@ -15,15 +13,11 @@ 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>,
- public dumpable
+class shashmap : protected hashmap<obj_type, key_type_, hash_type, alloc_type>
{
private:
pthread_mutex_t mut_shashmap;
-protected:
- virtual void dumpit();
-
public:
explicit shashmap();
~shashmap();
@@ -42,7 +36,6 @@ 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 c864d28..4559284 100644
--- a/src/maps/shashmap.tmpl
+++ b/src/maps/shashmap.tmpl
@@ -139,17 +139,3 @@ 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/memb/memb.h b/src/memb/memb.h
index f0df6ed..9c398ec 100644
--- a/src/memb/memb.h
+++ b/src/memb/memb.h
@@ -2,8 +2,7 @@
#define MEMB_H
#include "../incl.h"
-#include "../wrap.h"
-#include "../maps/hashmap.h"
+#include "../maps/nhashmap.h"
#include "tupel.h"
using namespace std;
@@ -12,58 +11,13 @@ template<class obj_type>
class memb
{
private:
- hashmap< mutexed_tupel<obj_type>* > map_elems;
+ nhashmap< mutexed_tupel<obj_type>* > map_elems;
public:
- memb()
- {}
- memb(vector<string> &vec_fields);
- void initialize(vector<string> &vec_fields);
inline obj_type get_elem(string s_key);
inline void set_elem(obj_type t_obj, string s_key);
-};
-struct memb_string : protected memb<string>
-{
- memb_string()
- {}
- memb_string(vector<string> &vec_fields) : memb<string>(vec_fields)
- {}
- void init_strings(vector<string> vec_fields)
- {
- initialize(vec_fields);
- }
- inline string get_string(string s_key);
- inline void set_string(string s_obj, string s_key);
-};
-
-struct memb_int : protected memb<int>
-{
- memb_int()
- {}
- void init_ints(vector<string> vec_fields)
- {
- initialize(vec_fields);
- }
- inline int get_int(string s_key);
- inline void set_int(int i_obj, string s_key);
};
-struct memb_bool : protected memb<bool>
-{
- memb_bool()
- {}
- void init_bools(vector<string> vec_fields)
- {
- initialize(vec_fields);
- }
- inline bool get_bool(string s_key);
- inline void set_bool(bool b_obj, string s_key);
-};
-
-class memb_base : public memb_string, public memb_int, public memb_bool
- {}
-;
-
#include "memb.tmpl"
#endif
diff --git a/src/memb/memb.tmpl b/src/memb/memb.tmpl
index 5c745cc..0b4da0e 100644
--- a/src/memb/memb.tmpl
+++ b/src/memb/memb.tmpl
@@ -1,20 +1,3 @@
-
-template<class obj_type>
-memb<obj_type>::memb(vector<string> &vec_fields)
-{
- initialize(vec_fields);
-}
-
-template<class obj_type>
-void
-memb<obj_type>::initialize(vector<string> &vec_fields)
-{
- obj_type t_default;
- vector<string>::iterator iter;
- for (iter = vec_fields.begin(); iter != vec_fields.end(); ++iter)
- map_elems[*iter] = new mutexed_tupel<obj_type>(t_default);
-}
-
template<class obj_type>
obj_type
memb<obj_type>::get_elem(string s_key)
@@ -23,58 +6,12 @@ memb<obj_type>::get_elem(string s_key)
if ( p_tupel )
return p_tupel->get_elem();
- obj_type t_ret;
- return t_ret;
+ return obj_type();
}
template<class obj_type>
void
memb<obj_type>::set_elem(obj_type t_obj, string s_key)
{
- mutexed_tupel<obj_type> *p_tupel = map_elems.get_elem(s_key);
- if ( p_tupel )
- {
- p_tupel->set_elem(t_obj);
- return;
- }
-
- //wrap::system_message(MEMBERE+string("("+s_key+")"));
-}
-
-string
-memb_string::get_string(string s_key)
-{
- return get_elem(s_key);
-}
-
-void
-memb_string::set_string(string s_obj, string s_key)
-{
- set_elem(s_obj, s_key);
-}
-
-int
-memb_int::get_int(string s_key)
-{
- return get_elem(s_key);
-}
-
-void
-memb_int::set_int(int i_obj, string s_key)
-{
- set_elem(i_obj, s_key);
+ // mutexed_tupel<obj_type> *p_tupel = map_elems
}
-
-bool
-memb_bool::get_bool(string s_key)
-{
- return get_elem(s_key);
-}
-
-void
-memb_bool::set_bool(bool b_obj, string s_key)
-{
- set_elem(b_obj, s_key);
-}
-
-
diff --git a/src/memb/tupel.h b/src/memb/tupel.h
index 864a092..bb1939e 100644
--- a/src/memb/tupel.h
+++ b/src/memb/tupel.h
@@ -13,9 +13,7 @@ class tupel
private:
pthread_mutex_t mut_tupel;
obj_type t_obj;
-
public:
-
tupel();
tupel(obj_type t_obj);
~tupel();
diff --git a/src/memb/tupel.tmpl b/src/memb/tupel.tmpl
index ab42748..bdde516 100644
--- a/src/memb/tupel.tmpl
+++ b/src/memb/tupel.tmpl
@@ -1,29 +1,29 @@
template<class obj_type>
tupel<obj_type>::tupel()
{
- pthread_mutex_init(&mut_tupel, NULL);
+ pthread_mutex_init( &mut_tupel, NULL );
}
template<class obj_type>
tupel<obj_type>::tupel(obj_type t_obj)
{
this->t_obj = t_obj;
- pthread_mutex_init(&mut_tupel, NULL);
+ pthread_mutex_init( &mut_tupel, NULL );
}
template<class obj_type>
tupel<obj_type>::~tupel()
{
- pthread_mutex_destroy(&mut_tupel);
+ pthread_mutex_destroy( &mut_tupel );
}
template<class obj_type>
obj_type
tupel<obj_type>::get_elem()
{
- pthread_mutex_lock(&mut_tupel);
+ pthread_mutex_lock( &mut_tupel );
obj_type t_ret = t_obj;
- pthread_mutex_unlock(&mut_tupel);
+ pthread_mutex_unlock( &mut_tupel );
return t_ret;
}
@@ -31,7 +31,7 @@ template<class obj_type>
void
tupel<obj_type>::set_elem(obj_type t_obj)
{
- pthread_mutex_lock(&mut_tupel);
+ pthread_mutex_lock( &mut_tupel );
this->t_obj = t_obj;
- pthread_mutex_unlock(&mut_tupel);
+ pthread_mutex_unlock( &mut_tupel );
}
diff --git a/src/modl.cpp b/src/modl.cpp
index 32fe33a..6668109 100755
--- a/src/modl.cpp
+++ b/src/modl.cpp
@@ -113,14 +113,6 @@ 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 73abd58..983bdda 100755
--- a/src/modl.h
+++ b/src/modl.h
@@ -7,7 +7,7 @@
using namespace std;
-class modl : public shashmap<dynmod*>
+class modl : private shashmap<dynmod*>
{
private:
static void dlclose_( dynmod* mod );
@@ -24,7 +24,6 @@ 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/CVS/Entries b/src/mods/commands/CVS/Entries
index f719ced..0d8d93b 100644
--- a/src/mods/commands/CVS/Entries
+++ b/src/mods/commands/CVS/Entries
@@ -1,32 +1,32 @@
-/Makefile/1.26/Mon Feb 14 20:09:50 2005//
+/Makefile/1.30/Wed Feb 23 05:08:04 2005//
/Makefile.in/1.7/Thu Jul 8 14:39:03 2004//
-/yc_about.cpp/1.1/Thu Dec 30 18:36:03 2004//
-/yc_all.cpp/1.1/Thu Dec 30 19:14:52 2004//
-/yc_away.cpp/1.8/Thu Nov 18 13:41:47 2004//
-/yc_col.cpp/1.8/Thu Nov 18 13:41:47 2004//
-/yc_compopt.cpp/1.3/Thu Nov 18 13:41:47 2004//
-/yc_exec.cpp/1.9/Thu Nov 18 13:41:47 2004//
-/yc_fake.cpp/1.11/Thu Nov 18 13:41:47 2004//
-/yc_getroom.cpp/1.6/Thu Nov 18 13:41:47 2004//
-/yc_getrusage.cpp/1.8/Thu Nov 18 13:41:47 2004//
-/yc_help.cpp/1.4/Thu Nov 18 13:41:47 2004//
-/yc_invisible.cpp/1.9/Thu Nov 18 13:41:47 2004//
-/yc_j.cpp/1.9/Thu Nov 18 13:41:47 2004//
-/yc_ko.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_m.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_md5.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_me.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_morph.cpp/1.3/Thu Nov 18 13:41:47 2004//
-/yc_msg.cpp/1.9/Thu Dec 30 17:44:05 2004//
-/yc_q.cpp/1.8/Thu Nov 18 13:41:47 2004//
-/yc_reload.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_ren.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_s.cpp/1.8/Thu Nov 18 13:41:47 2004//
-/yc_set.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_template.cpp/1.7/Thu Nov 18 13:41:47 2004//
-/yc_time.cpp/1.6/Thu Nov 18 13:41:47 2004//
-/yc_topic.cpp/1.10/Mon Feb 14 17:33:09 2005//
-/yc_uptime.cpp/1.6/Thu Nov 18 13:41:47 2004//
-/yc_users.cpp/1.1/Mon Feb 14 20:09:50 2005//
-/yc_version.cpp/1.9/Thu Nov 18 13:41:47 2004//
+/yc_about.cpp/1.2/Mon Feb 21 01:55:49 2005//
+/yc_all.cpp/1.2/Mon Feb 21 01:55:49 2005//
+/yc_away.cpp/1.9/Mon Feb 21 01:55:49 2005//
+/yc_col.cpp/1.10/Mon Feb 21 01:55:49 2005//
+/yc_compopt.cpp/1.4/Mon Feb 21 01:55:49 2005//
+/yc_exec.cpp/1.10/Mon Feb 21 01:55:49 2005//
+/yc_fake.cpp/1.12/Mon Feb 21 01:55:49 2005//
+/yc_getroom.cpp/1.7/Mon Feb 21 01:55:49 2005//
+/yc_getrusage.cpp/1.9/Mon Feb 21 01:55:49 2005//
+/yc_help.cpp/1.5/Mon Feb 21 01:55:49 2005//
+/yc_invisible.cpp/1.10/Mon Feb 21 01:55:49 2005//
+/yc_j.cpp/1.10/Mon Feb 21 01:55:50 2005//
+/yc_ko.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_m.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_md5.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_me.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_morph.cpp/1.4/Mon Feb 21 01:55:50 2005//
+/yc_msg.cpp/1.10/Mon Feb 21 01:55:50 2005//
+/yc_q.cpp/1.9/Mon Feb 21 01:55:50 2005//
+/yc_reload.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_ren.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_s.cpp/1.9/Mon Feb 21 01:55:50 2005//
+/yc_set.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_template.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/yc_time.cpp/1.7/Mon Feb 21 01:55:50 2005//
+/yc_topic.cpp/1.11/Mon Feb 21 01:55:50 2005//
+/yc_uptime.cpp/1.7/Mon Feb 21 01:55:50 2005//
+/yc_users.cpp/1.2/Mon Feb 21 01:55:50 2005//
+/yc_version.cpp/1.10/Mon Feb 21 01:55:50 2005//
D
diff --git a/src/mods/commands/Makefile.in b/src/mods/commands/Makefile.in
index 42884b6..ce8c00f 100755
--- a/src/mods/commands/Makefile.in
+++ b/src/mods/commands/Makefile.in
@@ -4,9 +4,9 @@ INCLUDES=`cat ../../includes.add`
CFLAGS=`cat ../cflags.add`
all: mods
$(MODS):
+ @echo -n "Compiling command module `basename $@` "
@if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
@$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/`
- @echo -n "Command module `basename $@ | sed s/\.so// | sed s/yc_//` "
@du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g"
infotext:
@echo Compiling command modules
diff --git a/src/mods/html/CVS/Entries b/src/mods/html/CVS/Entries
index 7b982b6..0d230ef 100644
--- a/src/mods/html/CVS/Entries
+++ b/src/mods/html/CVS/Entries
@@ -1,9 +1,9 @@
-/Makefile/1.22/Mon Feb 14 18:01:22 2005//
+/Makefile/1.26/Wed Feb 23 05:08:04 2005//
/Makefile.in/1.8/Thu Jul 8 14:39:03 2004//
-/yc_admin.cpp/1.5/Fri Jan 7 21:00:19 2005//
-/yc_colors.cpp/1.7/Fri Jan 7 21:00:19 2005//
-/yc_help.cpp/1.10/Fri Jan 7 21:00:19 2005//
-/yc_loggedin.cpp/1.1/Mon Feb 14 18:01:22 2005//
-/yc_options.cpp/1.7/Fri Jan 7 21:00:19 2005//
-/yc_register.cpp/1.10/Fri Jan 7 21:00:19 2005//
+/yc_admin.cpp/1.8/Fri Feb 25 00:52:24 2005//
+/yc_colors.cpp/1.10/Fri Feb 25 00:52:24 2005//
+/yc_help.cpp/1.13/Fri Feb 25 00:52:24 2005//
+/yc_loggedin.cpp/1.4/Fri Feb 25 00:52:24 2005//
+/yc_options.cpp/1.10/Fri Feb 25 00:52:24 2005//
+/yc_register.cpp/1.13/Fri Feb 25 00:52:24 2005//
D
diff --git a/src/mods/html/Makefile.in b/src/mods/html/Makefile.in
index 4b7c728..30f1782 100755
--- a/src/mods/html/Makefile.in
+++ b/src/mods/html/Makefile.in
@@ -4,12 +4,12 @@ INCLUDES=`cat ../../includes.add`
CFLAGS=`cat ../cflags.add`
all: mods
$(MODS):
+ @echo -n "Compiling html module `basename $@` "
@if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
@$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/`
- @echo -n "HTML module `basename $@ | sed s/\.so// | sed s/yc_//` "
@du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g"
infotext:
- @echo Compiling HTML modules
+ @echo Compiling html modules
mods: infotext $(MODS)
@echo "Num of html modules: "
@ls ../../../mods/html/*.so | wc -l
diff --git a/src/msgs.h b/src/msgs.h
index 293f90f..46bd57c 100755
--- a/src/msgs.h
+++ b/src/msgs.h
@@ -86,15 +86,12 @@
#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!"
#define STATUPR "Stats: Updated rusage history"
#define STATRSS "Stats: Max resident set size "
#define REUROOM "Garbage: Reusing room object "
-#define SOCKER1 "Sock: Can't create socket, aborting"
-#define SOCKUNS "Sock: Starting hypertext transport [HTTP]"
#define SOCKCLN "Sock: Initializing a client socket at "
#define SOCKCON "Sock: Connecting to "
#define SOCKCRT "Sock: Created socket on "
@@ -115,14 +112,14 @@
#define XMLREAD "XML: Reading "
#define XMLERR "XML Error: "
#define XMLER1 "XML Error: Unable to load file "
-#define VERSION "0.7.9.3"
+#define VERSION "0.7.8"
#define BRANCH "RELEASE"
-#define BUILDNR 3807
-#define UNAME "FreeBSD 5.4-RELEASE i386"
+#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 YCUSAGE "Usage: ./ychat {h|v}|{o confkey confvalue}\n"
-#define HEADER1 "HTTP/1.1 200 OK\r\n"
+#define HEADER1 "HTTP/1.0 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"
@@ -130,7 +127,6 @@
#define HEADER6 "Connection: keep-alive\r\n"
#define HEADER7 "Content-Length: ";
#define HEADER8 "Content-Type: ";
-#define HEADER8b "; charset=ISO-8859-1\r\n";
-#define HEADER9 "Allow: GET\r\n";
+#define HEADER9 "Allow: GET\n";
#endif
diff --git a/src/ncur/CVS/Entries b/src/ncur/CVS/Entries
index 9f83c6c..62769f5 100644
--- a/src/ncur/CVS/Entries
+++ b/src/ncur/CVS/Entries
@@ -1,5 +1,5 @@
-/menu.cpp/1.7/Fri Jan 7 21:00:19 2005//
-/menu.h/1.5/Fri Jan 7 21:00:19 2005//
-/ncur.cpp/1.21/Mon Feb 14 17:33:09 2005//
-/ncur.h/1.8/Fri Jan 7 21:00:19 2005//
+/menu.cpp/1.8/Mon Feb 21 01:55:50 2005//
+/menu.h/1.6/Mon Feb 21 01:55:50 2005//
+/ncur.cpp/1.23/Fri Mar 4 02:41:30 2005//
+/ncur.h/1.10/Fri Mar 4 02:41:30 2005//
D
diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp
index 9b0996c..9196111 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 */
- delete new cli(); /* Start CLI mode */
+ 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,9 +253,8 @@ ncur::init_ncurses()
clear();
noecho();
cbreak(); // Line buffering disabled. pass on everything
- init_pair(1, COLOR_BLACK, COLOR_CYAN);
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
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 1830cdf..e5627c8 100755
--- a/src/ncur/ncur.h
+++ b/src/ncur/ncur.h
@@ -29,8 +29,8 @@ private:
pthread_mutex_t mut_is_ready;
public:
- ncur();
- ~ncur();
+ ncur( ); // a standard constructor.
+ ~ncur( );
void start( void *p_void );
void print( char* c_print );
diff --git a/src/reqp.cpp b/src/reqp.cpp
index 9b5da0b..905f1a4 100755
--- a/src/reqp.cpp
+++ b/src/reqp.cpp
@@ -13,7 +13,6 @@ 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( )
{}
@@ -44,7 +43,7 @@ reqp::get_request_parameters( string s_parameters, map<string,string>& map_param
}
string
-reqp::get_url( string s_req, map<string, string> &map_params, int& i_postpayloadoffset )
+reqp::get_url( int &i_sock, string s_req, map<string, string> &map_params )
{
unsigned i_pos, i_pos2;
string s_vars( "" );
@@ -89,20 +88,31 @@ reqp::get_url( string s_req, map<string, string> &map_params, int& i_postpayload
{
if ( (i_pos2 = s_req.find("HTTP")) != string::npos )
{
- if (i_pos2 > 13)
+ if ( 13 < i_pos2 )
{
s_ret = url_decode( s_req.substr(6,i_pos2-7) );
- //wrap::system_message(s_req);
- //wrap::system_message(string("data offset=") + tool::int2string(i_postpayloadoffset));
- i_pos = s_req.find("event=",i_postpayloadoffset );
- if(i_pos != string::npos)
+ int i_len = s_ret.length();
+ int i_len2 = s_req.length()-1;
+
+ s_req = s_req.substr( i_len < i_len2 ? i_len : i_len2 );
+
+ if ( (i_pos = s_req.find("event=")) == string::npos)
{
- get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params);
+ char c_req[POSTBUF];
+ i_len = read(i_sock, c_req, POSTBUF);
+ s_req = c_req;
+ s_req = s_req.substr(0, i_len);
+
+ if ( (i_pos = s_req.find("event=")) != string::npos )
+ get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params );
+ }
+ else
+ {
+ get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params );
}
}
}
-
}
#ifdef VERBOSE
@@ -121,7 +131,7 @@ reqp::get_url( string s_req, map<string, string> &map_params, int& i_postpayload
}
string
-reqp::get_content_type(string &s_file)
+reqp::get_content_type( string s_file )
{
string s_ext(tool::get_extension( s_file ));
@@ -223,12 +233,11 @@ reqp::get_from_header( string s_req, string s_hdr )
}
string
-reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_params, int &i_postpayloadoffset )
+reqp::parse( int &i_sock, string s_req, map<string,string> &map_params )
{
-
// store all request informations in map_params. store the url in
// map_params["request"].
- get_url( s_req, map_params, i_postpayloadoffset );
+ get_url( i_sock, s_req, map_params );
parse_headers( s_req, map_params );
string s_event( map_params["event"] );
@@ -264,7 +273,7 @@ reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_para
}
else
{
- wrap::system_message(SESSERR);
+ wrap::system_message(SESSERR);
return s_rep;
}
@@ -292,7 +301,7 @@ reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_para
{
string s_msg ( wrap::HTML->parse( map_params ) );
p_user->msg_post( &s_msg);
- wrap::SOCK->chat_stream( p_sock, p_user, map_params );
+ wrap::SOCK->chat_stream( i_sock, p_user, map_params );
}
// if a request for the online list of the active room.
@@ -329,9 +338,8 @@ reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_para
if ( s_event.compare("stream") == 0 )
s_resp.append( s_http_stream );
- 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_http_colength + tool::int2string(s_rep.size()) + "\n" +
+ s_http_cotype + map_params["content-type"] + "\r\n\r\n" );
s_resp.append(s_rep);
@@ -352,7 +360,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, p_user->get_name() );
+ dynmod* p_module = wrap::MODL->get_module( s_mod );
if ( p_module != NULL )
( *( p_module->the_func ) ) ( static_cast<void*>(c) );
@@ -365,10 +373,10 @@ string
reqp::remove_dots( string s_ret )
{
// remove ".." from the request.
- unsigned i_pos;
+ unsigned pos;
- if ( (i_pos = s_ret.find( ".." )) != string::npos )
- return remove_dots(s_ret.substr(0, i_pos));
+ if( (pos = s_ret.find( ".." )) != string::npos)
+ return s_ret.substr(0, pos);
return s_ret;
}
diff --git a/src/reqp.h b/src/reqp.h
index 5a378fa..4c322cd 100755
--- a/src/reqp.h
+++ b/src/reqp.h
@@ -13,12 +13,11 @@ 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
// ( behind "?" ) into map_params.
- string get_url( string s_req, map<string,string> &map_params, int& i_postpayloadoffset );
+ string get_url( int &i_sock, string s_req, map<string,string> &map_params );
// returns a specific value of the client's http request header.
// ( s.t. like the User-Agent, Referer etc... ).
string get_from_header( string s_req, string s_hdr );
@@ -33,9 +32,9 @@ private:
public:
reqp( );
- string parse( socketcontainer* p_sock, string s_req, map<string,string> &map_params, int &i_postpayloadoffset );
+ string parse( int &i_sock, string s_req, map<string,string> &map_params );
string url_decode ( string s_url );
- string get_content_type( string& s_file );
+ string get_content_type( string s_file );
void parse_headers( string s_req, map<string,string> &map_params );
};
diff --git a/src/sign.cpp b/src/sign.cpp
index 6f4edee..db97d19 100644
--- a/src/sign.cpp
+++ b/src/sign.cpp
@@ -30,18 +30,13 @@ 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/CVS/Entries b/src/sock/CVS/Entries
index 4cdca42..0d7b592 100644
--- a/src/sock/CVS/Entries
+++ b/src/sock/CVS/Entries
@@ -1,3 +1,3 @@
-/sock.cpp/1.20/Mon Feb 14 17:33:09 2005//
-/sock.h/1.8/Thu Feb 10 19:55:24 2005//
+/sock.cpp/1.28/Tue Mar 1 09:54:29 2005//
+/sock.h/1.14/Sun Feb 27 06:28:53 2005//
D
diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp
index 8f66268..5f6ede3 100755
--- a/src/sock/sock.cpp
+++ b/src/sock/sock.cpp
@@ -5,8 +5,9 @@
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
-
#include "sock.h"
+#include "../chat/chat.h"
+#include "../chat/user.h"
using namespace std;
@@ -19,40 +20,21 @@ sock::sock()
this->log_daemon = new logd( wrap::CONF->get_elem( "httpd.logging.accessfile" ),
- wrap::CONF->get_elem( "httpd.logging.access_lines" ) );
+ wrap::CONF->get_elem( "httpd.logging.accesslines" ) );
#endif
}
-int
-sock::_send(socketcontainer *p_sock, const char *sz, int len)
-{
-
- return send( p_sock->i_sock, sz, len, 0 );
-}
-
-int
-sock::_read(socketcontainer *p_sock, char *sz, int len)
-{
-
- return read( p_sock->i_sock, sz, len );
-}
-
-int
-sock::_close(socketcontainer *p_sock)
-{
- shutdown( p_sock->i_sock, 2 );
- close ( p_sock->i_sock );
- delete p_sock;
-}
+sock::~sock()
+{}
//<<*
void
-sock::chat_stream( socketcontainer *p_sock, user *p_user, map<string,string> &map_params )
+sock::chat_stream( int i_sock, user *p_user, map<string,string> &map_params )
{
string s_msg( "\n" );
for ( int i = 0; i < PUSHSTR; i++ )
- _send(p_sock,s_msg.c_str(), s_msg.size());
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
pthread_mutex_t mutex;
pthread_mutex_init( &mutex, NULL );
@@ -62,7 +44,7 @@ sock::chat_stream( socketcontainer *p_sock, user *p_user, map<string,string> &ma
{
s_msg = p_user->get_mess( );
- if ( 0 > _send( p_sock, s_msg.c_str(), s_msg.size() ) )
+ if ( 0 > send( i_sock, s_msg.c_str(), s_msg.size(), 0 ) )
{
p_user->set_online( false );
break;
@@ -78,7 +60,7 @@ sock::chat_stream( socketcontainer *p_sock, user *p_user, map<string,string> &ma
s_msg = p_user->get_mess( );
if ( ! s_msg.empty() )
- _send( p_sock, s_msg.c_str(), s_msg.size());
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
// remove the user from its room.
string s_user( p_user->get_name() );
@@ -105,7 +87,7 @@ sock::chat_stream( socketcontainer *p_sock, user *p_user, map<string,string> &ma
//*>>
int
-sock::_make_server_socket( int i_port )
+sock::make_server_socket( int i_port )
{
size_t i_sock;
struct sockaddr_in name;
@@ -121,7 +103,7 @@ sock::_make_server_socket( int i_port )
wrap::system_message( SOCKERR );
- return _make_server_socket( i_port );
+ return make_server_socket( i_port );
}
// give the server socket a name.
@@ -143,200 +125,26 @@ sock::_make_server_socket( int i_port )
wrap::system_message( string(SOCKERR) + tool::int2string(i_port) );
// Rerun recursive.
- return _make_server_socket( i_port );
+ return make_server_socket( i_port );
}
wrap::system_message( SOCKCRT + string("localhost:") + tool::int2string(i_port) );
- i_server_port = i_port;
- i_server_sock = i_sock;
-
- return i_sock;
-}
-
-string
-sock::read_http_line(socketcontainer *p_sock)
-{
- string s_line;
- int i_total = 0;
- int i_read = 0;
- char ch;
-
- do
- {
- i_read = _read(p_sock, &ch, sizeof(ch));
-
- if(i_read <= 0)
- return "";
-
- s_line += ch;
- i_total++;
- }
- while((ch != '\n') && i_total < MAXLENGTH);
-
- if(ch != '\n')
- /*
- ** the games people play
- */
- return "";
-
- return s_line;
-}
-int
-sock::read_http(socketcontainer *p_sock, char *c_zbuf, int i_buflen, int &i_postpayloadoffset)
-{
- /*
- ** 1) Read the first line
- ** 2) If GET, handle as such
- ** 3) If POST, handle as such
- */
- char ch;
- int i_read;
- int i_ret = -1;
- int x,z;
-
- string s_content_length;
- string s_cl;
- string s_post_return;
- string s_line = read_http_line(p_sock);
-
- i_postpayloadoffset = 0;
- if(s_line.length() <= 0)
- return -1;
-
- /*
- ** GET yada\r\n Followed by stuff we don't care about :) heh.
- ** 01234
- */
- /*
- ** POST yada\r\n
- ** xxxxx
- ** Content-Length: NNN\n
- ** \n
- */
- if(s_line.substr(0,3) == "GET")
- {
- if(s_line.length() > i_buflen)
- {
- /*
- ** Buffer overflow
- */
- return -1;
- }
- else
- {
- memcpy(c_zbuf,s_line.c_str(),s_line.length());
- return s_line.length();
- }
- }
-
- else
- {
- /*
- ** POST yada
- ** 01234
- */
- if(s_line.substr(0,4) != "POST")
- return -1;
-
- /*
- ** Get us to the Content-Length:
- */
- s_post_return += s_line;
- i_postpayloadoffset += s_line.length();
-
- for(x=0 ;x < MAXLINES; x++)
- {
- s_line = read_http_line(p_sock);
- s_post_return += s_line;
- i_postpayloadoffset += s_line.length();
-
- if (s_line.compare(0, 15, "Content-Length:"))
- continue;
-
- // Match found on Content-Length:... process, and then break out and get us to the promised land
- s_content_length = s_line.substr( 16 /*strlen("Content-Length: ")*/,
- s_line.length() - 16 /*strlen("Content-Length: ")*/);
-
- /*
- ** Content-Length: 333\n
- ** 0123456789abcdefghijklmnopqrstuvwxyzAB
- */
-
- z = 0;
-
- do
- {
- ch = s_content_length[z];
- if(isdigit(ch))
- s_cl += ch;
-
- z++;
-
- }
- while(ch != '\n');
-
- break;
- }
-
- if(s_cl.length() <= 0)
- return -1;
-
- z = atoi(s_cl.c_str());
-
- /*
- ** If we are going to overflow the buffer just by the payload, leave
- ** of, if z did not convert correctly. (should have been ok by isdigit)
- */
- if(z > i_buflen || z < 0)
- return -1;
-
- /*
- ** We have MAXLINES to get to the blank line separating POST data.
- */
- for(x=0 ;x < MAXLINES; x++)
- {
- s_line = read_http_line(p_sock);
- s_post_return += s_line;
-
- i_postpayloadoffset += s_line.length();
- if(s_line == "\r\n")
- break;
- }
-
- /*
- ** funny business
- */
- if(x == MAXLINES)
- return -1;
-
- for(x=0; x < z; x++)
- {
- if(_read(p_sock,&ch,sizeof(ch)) != 1)
- return -1;
-
- s_post_return += ch;
- }
+#ifdef NCURSES
- if(s_post_return.length() > i_buflen)
- return -1;
+ mvprintw( NCUR_PORT_X,NCUR_PORT_Y, "Port: %d ", i_port);
+ refresh();
+#endif
- memcpy(c_zbuf,s_post_return.c_str(),s_post_return.length());
- return s_post_return.length();
- }
+ return i_sock;
}
int
-sock::read_write(socketcontainer* p_sock)
+sock::read_write( int* p_sock )
{
- int i_postpayloadoffset;
- int i_sock = p_sock->i_sock;
-
+ int i_sock = *p_sock;
char c_req[READSOCK];
-
- memset(c_req,0,sizeof(c_req));
-
- int i_bytes = read_http(p_sock, c_req, READSOCK-1,i_postpayloadoffset);
+ int i_bytes = read(i_sock, c_req, READSOCK);
if (i_bytes <= 0)
{
@@ -352,17 +160,25 @@ sock::read_write(socketcontainer* p_sock)
struct sockaddr_in client;
size_t size = sizeof(client);
- getpeername(i_sock, (struct sockaddr *)&client, &size);
+#ifdef CYGWIN
+ getpeername( i_sock, (struct sockaddr *)&client, (int*)&size);
+#else
+ getpeername( i_sock, (struct sockaddr *)&client, &size);
+#endif
+
uint32_t &s_addr = client.sin_addr.s_addr;
- if ( (map_params["REMOTE_ADDR"] = get_elem(s_addr)) == "" )
+ if ( (map_params["REMOTE_ADDR"] = get_elem(s_addr)) == "" )
{
map_params["REMOTE_ADDR"] = string(inet_ntoa(client.sin_addr));
set_elem(map_params["REMOTE_ADDR"], s_addr);
wrap::system_message(SOCKCAC+map_params["REMOTE_ADDR"]);
}
- string s_rep = req_parser->parse(p_sock, string(c_req), map_params, i_postpayloadoffset);
+ //map_params["REMOTE_ADDR"] = inet_ntoa_callback(&client.sin_addr);
+ //map_params["REMOTE_PORT"] = ntohs(client.sin_port);
+
+ string s_rep = req_parser->parse(i_sock, string(c_req), map_params);
#ifdef LOGGING
@@ -370,31 +186,21 @@ sock::read_write(socketcontainer* p_sock)
#endif
// send s_rep to the client.
- _send(p_sock, s_rep.c_str(), s_rep.size());
+ send(i_sock, s_rep.c_str(), s_rep.size(), 0);
// dont need those vals anymore.
map_params.clear();
- _close(p_sock);
+ shutdown( i_sock, 2 );
+ close ( i_sock );
+
return 0;
}
- _close(p_sock);
- return 1;
-}
-
-void
-sock::_main_loop_init()
-{
- wrap::system_message(SOCKUNS);
-}
+ shutdown( i_sock, 2 );
+ close ( i_sock );
-socketcontainer*
-sock::_create_container(int &i_sock)
-{
- socketcontainer* p_sock = new socketcontainer;
- p_sock->i_sock = i_sock;
- return p_sock;
+ return 1;
}
int
@@ -402,22 +208,22 @@ sock::start()
{
wrap::system_message( SOCKSRV );
pool* p_pool = wrap::POOL;
- int i_sock = i_server_sock;
#ifdef NCURSES
-
print_hits();
p_pool->print_pool_size();
#endif
int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
- _main_loop_init();
-
- int i;
+ int i_sock, i;
fd_set active_fd_set, read_fd_set;
struct sockaddr_in clientname;
size_t size;
+
+ // create the server socket and set it up to accept connections.
+ i_sock = make_server_socket ( i_port );
+
if (listen (i_sock, 1) < 0)
{
wrap::system_message( LISTERR );
@@ -430,8 +236,6 @@ sock::start()
FD_ZERO (&active_fd_set);
FD_SET (i_sock, &active_fd_set);
- print_server_port();
-
while( b_run )
{
// block until input arrives on one or more active sockets.
@@ -459,23 +263,36 @@ sock::start()
int i_new_sock;
size = sizeof(clientname);
- i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, &size);
+#ifdef CYGWIN
-#ifdef VERBOSE
+ i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, (int*)&size);
+#else
- wrap::system_message(NEWREQU
- + tool::int2string(i_req) + " "
- + string(inet_ntoa( clientname.sin_addr )) + ":"
- + tool::int2string(ntohs ( clientname.sin_port ))
- );
+ i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, &size);
#endif
- FD_SET (i_new_sock, &active_fd_set);
+ if (i_new_sock < 0)
+ {
+ wrap::system_message( ACCPERR );
+ close(i_new_sock);
+ }
+ else
+ {
+#ifdef VERBOSE
+ wrap::system_message(NEWREQU
+ + tool::int2string(i_req) + " "
+ + string(inet_ntoa( clientname.sin_addr )) + ":"
+ + tool::int2string(ntohs ( clientname.sin_port ))
+ );
+#endif
+ FD_SET (i_new_sock, &active_fd_set);
+ }
}
else
{
- socketcontainer *p_sock = _create_container(i);
+ int *p_sock = new int;
+ *p_sock = i;
p_pool->run( (void*) p_sock );
FD_CLR( i, &active_fd_set );
}
@@ -489,22 +306,16 @@ 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)+")");
+ SOCKCA2+tool::int2string(i_currentsize)+","+tool::int2string(i_ipcachesize)+")");
clear();
}
}
#ifdef NCURSES
void
-sock::print_server_port() {
- mvprintw( NCUR_PORT_X,NCUR_PORT_Y, "Port: %d ", i_server_port);
- refresh();
-}
-
-void
sock::print_hits()
{
if ( wrap::NCUR->is_ready() )
diff --git a/src/sock/sock.h b/src/sock/sock.h
index 6e93468..62f32ae 100755
--- a/src/sock/sock.h
+++ b/src/sock/sock.h
@@ -12,7 +12,6 @@
#include "../reqp.h"
#include "../chat/user.h"
-
#include "../thrd/pool.h"
#include "../maps/shashmap.h"
@@ -22,22 +21,19 @@
using namespace std;
-class sock : public shashmap
- < string, uint32_t, self_hash<uint32_t>, equals_allocator<uint32_t> >
+class sock : protected shashmap
+< string, uint32_t, self_hash<uint32_t>, equals_allocator<uint32_t> >
{
-protected:
+private:
#ifdef LOGGING
-
logd *log_daemon; // the log daemon
#endif
- int i_server_sock;
- int i_server_port;
-
// total number of server requests.
unsigned long long i_req;
bool b_run; // true while socket manager is running.
reqp *req_parser; // parses the http requests from clients.
+
char *c_buffer; // char buffer!
pthread_mutex_t mut_hits;
@@ -45,44 +41,34 @@ protected:
public:
// creates a server socket.
- int read_http(socketcontainer *p_sock, char *c_zbuf, int i_buflen, int &i_payloadoffset);
- string read_http_line(socketcontainer *p_sock);
+ int make_server_socket( int i_port );
// small inline methods:
- bool get_server_() const
- {
- return b_run;
- }
- // small inline methods:
bool get_run() const
{
return b_run;
}
+
bool set_run( bool b_run )
{
this->b_run = b_run;
}
- sock();
-
- int read_write( socketcontainer* p_sock );
+ sock( );
+ ~sock( );
+ int read_write( int* p_sock );
int start();
void clean_ipcache();
// the chat stream there all the chat messages will sent through.
- void chat_stream( socketcontainer* p_sock, user* p_user, map<string,string> &map_params ); //<<
- virtual inline int _send(socketcontainer *p_sock, const char *sz, int len);
- virtual inline int _read(socketcontainer *p_sock, char *sz, int len);
- virtual inline int _close(socketcontainer *p_sock);
- virtual void _main_loop_init();
- virtual inline socketcontainer* _create_container(int& i_sock);
- virtual int _make_server_socket(int i_port);
+ static void chat_stream( int i_sock, user* p_user, map<string,string> &map_params ); //<<
#ifdef NCURSES
- void print_server_port();
+
void print_hits();
#endif
};
+
#endif
diff --git a/src/stats.cpp b/src/stats.cpp
index 7fba04d..4579f69 100644
--- a/src/stats.cpp
+++ b/src/stats.cpp
@@ -8,128 +8,130 @@ using namespace std;
stats::stats()
{
- i_rusage_vec_size = tool::string2int(
- wrap::CONF->get_elem("httpd.stats.rusagehistory"));
+ i_rusage_vec_size = tool::string2int(
+ wrap::CONF->get_elem("httpd.stats.rusagehistory"));
- i_num_rooms = 0; //<<
+ i_num_rooms = 0; //<<
- pthread_mutex_init( &mut_vec_rusage, NULL );
- pthread_mutex_init( &mut_num_rooms, NULL ); //<<
+ pthread_mutex_init( &mut_vec_rusage, NULL );
+ pthread_mutex_init( &mut_num_rooms, NULL ); //<<
}
stats::~stats()
{
- pthread_mutex_destroy( &mut_vec_rusage );
- pthread_mutex_destroy( &mut_num_rooms ); //<<
+ pthread_mutex_destroy( &mut_vec_rusage );
+ pthread_mutex_destroy( &mut_num_rooms ); //<<
}
void
stats::update_rusage_history()
{
- wrap::system_message(STATUPR);
-
- rusage* p_rusage = new rusage;
- getrusage( RUSAGE_SELF, p_rusage );
-
- map<string,long> map_rusage;
-
- map_rusage["ru_maxrss"] = p_rusage->ru_maxrss;
- map_rusage["ru_ixrss"] = p_rusage->ru_ixrss;
- map_rusage["ru_idrss"] = p_rusage->ru_idrss;
- map_rusage["ru_isrss"] = p_rusage->ru_isrss;
- map_rusage["ru_minflt"] = p_rusage->ru_minflt;
- map_rusage["ru_majflt"] = p_rusage->ru_majflt;
- map_rusage["ru_nswap"] = p_rusage->ru_nswap;
- map_rusage["ru_inblock"] = p_rusage->ru_inblock;
- map_rusage["ru_oublock"] = p_rusage->ru_oublock;
- map_rusage["ru_msgsnd"] = p_rusage->ru_msgsnd;
- map_rusage["ru_msgrcv"] = p_rusage->ru_msgrcv;
- map_rusage["ru_nsignals"] = p_rusage->ru_nsignals;
- map_rusage["ru_nvcsw"] = p_rusage->ru_nvcsw;
- map_rusage["ru_nivcsw"] = p_rusage->ru_nivcsw;
-
- delete p_rusage;
-
- pthread_mutex_lock ( &mut_vec_rusage );
-
- if ( vec_rusage_history.size() >= i_rusage_vec_size )
- vec_rusage_history.erase( vec_rusage_history.begin() );
-
- vec_rusage_history.push_back(map_rusage);
-
- pthread_mutex_unlock( &mut_vec_rusage );
+ wrap::system_message(STATUPR);
+
+ rusage* p_rusage = new rusage;
+ getrusage( RUSAGE_SELF, p_rusage );
+
+ map<string,long> map_rusage;
+
+ map_rusage["ru_maxrss"] = p_rusage->ru_maxrss;
+ map_rusage["ru_ixrss"] = p_rusage->ru_ixrss;
+ map_rusage["ru_idrss"] = p_rusage->ru_idrss;
+ map_rusage["ru_isrss"] = p_rusage->ru_isrss;
+ map_rusage["ru_minflt"] = p_rusage->ru_minflt;
+ map_rusage["ru_majflt"] = p_rusage->ru_majflt;
+ map_rusage["ru_nswap"] = p_rusage->ru_nswap;
+ map_rusage["ru_inblock"] = p_rusage->ru_inblock;
+ map_rusage["ru_oublock"] = p_rusage->ru_oublock;
+ map_rusage["ru_msgsnd"] = p_rusage->ru_msgsnd;
+ map_rusage["ru_msgrcv"] = p_rusage->ru_msgrcv;
+ map_rusage["ru_nsignals"] = p_rusage->ru_nsignals;
+ map_rusage["ru_nvcsw"] = p_rusage->ru_nvcsw;
+ map_rusage["ru_nivcsw"] = p_rusage->ru_nivcsw;
+
+ delete p_rusage;
+
+ pthread_mutex_lock ( &mut_vec_rusage );
+
+ if ( vec_rusage_history.size() >= i_rusage_vec_size )
+ vec_rusage_history.erase( vec_rusage_history.begin() );
+
+ vec_rusage_history.push_back(map_rusage);
+
+ pthread_mutex_unlock( &mut_vec_rusage );
}
void
stats::set_rusage_vec_size( int i_rusage_vec_size )
{
- pthread_mutex_lock ( &mut_vec_rusage );
- this->i_rusage_vec_size = i_rusage_vec_size;
- pthread_mutex_unlock( &mut_vec_rusage );
+ pthread_mutex_lock ( &mut_vec_rusage );
+ this->i_rusage_vec_size = i_rusage_vec_size;
+ pthread_mutex_unlock( &mut_vec_rusage );
}
long
stats::get_ru_maxrss()
{
- rusage* p_rusage = new rusage;
- getrusage( RUSAGE_SELF, p_rusage );
+ rusage* p_rusage = new rusage;
+ getrusage( RUSAGE_SELF, p_rusage );
- long l_ret = p_rusage->ru_maxrss;
- delete p_rusage;
+ long l_ret = p_rusage->ru_maxrss;
+ delete p_rusage;
- return l_ret;
+ return l_ret;
}
string
stats::get_rusage_history( string s_type, string s_seperator )
{
- string s_ret;
- int i_count = 0;
- vector< map<string,long> >::iterator iter;
-
- pthread_mutex_lock ( &mut_vec_rusage );
-
- for ( iter = vec_rusage_history.begin();
- iter != vec_rusage_history.end();
- iter++, i_count++ )
- s_ret.append(s_seperator +
- tool::int2string(i_count) + ". " + iter->find(s_type)->first + " " +
- tool::int2string( iter->find(s_type)->second) + "\n");
-
- pthread_mutex_unlock( &mut_vec_rusage );
-
- return s_ret;
+ string s_ret;
+ int i_count = 0;
+ vector< map<string,long> >::iterator iter;
+
+ pthread_mutex_lock ( &mut_vec_rusage );
+
+ for ( iter = vec_rusage_history.begin();
+ iter != vec_rusage_history.end();
+ iter++, i_count++ )
+ s_ret.append(s_seperator +
+ tool::int2string(i_count) + ". " + iter->find(s_type)->first + " " +
+ tool::int2string( iter->find(s_type)->second) + "\n");
+
+ pthread_mutex_unlock( &mut_vec_rusage );
+
+ return s_ret;
}
//<<*
-int
+int
stats::get_num_rooms()
{
- pthread_mutex_lock ( &mut_num_rooms );
- int i_ret = i_num_rooms;
- pthread_mutex_unlock( &mut_num_rooms );
- return i_ret;
+ pthread_mutex_lock ( &mut_num_rooms );
+ int i_ret = i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+ return i_ret;
}
-void
+void
stats::increment_num_rooms()
{
- pthread_mutex_lock ( &mut_num_rooms );
- ++i_num_rooms;
- pthread_mutex_unlock( &mut_num_rooms );
+ pthread_mutex_lock ( &mut_num_rooms );
+ ++i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
#ifdef NCURSES
- print_num_rooms();
+
+ print_num_rooms();
#endif
}
-void
+void
stats::decrement_num_rooms()
{
- pthread_mutex_lock ( &mut_num_rooms );
- --i_num_rooms;
- pthread_mutex_unlock( &mut_num_rooms );
+ pthread_mutex_lock ( &mut_num_rooms );
+ --i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
#ifdef NCURSES
- print_num_rooms();
+
+ print_num_rooms();
#endif
}
@@ -137,12 +139,13 @@ stats::decrement_num_rooms()
void
stats::print_num_rooms()
{
- if ( !wrap::NCUR->is_ready() )
- return;
+ if ( !wrap::NCUR->is_ready() )
+ return;
- mvprintw( NCUR_NUM_ROOMS_X, NCUR_NUM_ROOMS_Y, "Rooms: %d", get_num_rooms());
- refresh();
+ mvprintw( NCUR_NUM_ROOMS_X, NCUR_NUM_ROOMS_Y, "Rooms: %d", get_num_rooms());
+ refresh();
}
#endif
//*>>
+
#endif
diff --git a/src/stats.h b/src/stats.h
index 647f504..4458b6a 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -4,30 +4,30 @@
#define STATS_H
#include "tool/tool.h"
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
-#include <iostream>
using namespace std;
class stats
{
private:
- // Specifies the max. amount of elements in vec_rusage_history;
- int i_rusage_vec_size;
- // History of the last i_rusage_vec_size rusage values.
- vector< map<string,long> > vec_rusage_history;
- pthread_mutex_t mut_vec_rusage;
+ // Specifies the max. amount of elements in vec_rusage_history;
+ int i_rusage_vec_size;
+ // History of the last i_rusage_vec_size rusage values.
+ vector< map<string,long> > vec_rusage_history;
+ pthread_mutex_t mut_vec_rusage;
+
+ int i_num_rooms; //<<
+ pthread_mutex_t mut_num_rooms; //<<
- int i_num_rooms; //<<
- pthread_mutex_t mut_num_rooms; //<<
-
- void set_rusage_vec_size( int i_rusage_vec_size );
+ void set_rusage_vec_size( int i_rusage_vec_size );
public:
- stats( );
+ stats( );
~stats( );
//<<*
@@ -40,6 +40,7 @@ public:
long get_ru_maxrss();
//<<*
#ifdef NCURSES
+
void print_num_rooms();
#endif
//*>>
diff --git a/src/thrd/CVS/Entries b/src/thrd/CVS/Entries
index 00f4a55..f9507bd 100644
--- a/src/thrd/CVS/Entries
+++ b/src/thrd/CVS/Entries
@@ -1,5 +1,5 @@
-/pool.cpp/1.12/Sun Feb 13 03:53:35 2005//
-/pool.h/1.9/Sun Feb 13 00:49:29 2005//
-/thro.cpp/1.5/Fri Jan 7 21:00:19 2005//
-/thro.h/1.4/Fri Jan 7 21:00:19 2005//
+/pool.cpp/1.17/Fri Feb 25 01:22:35 2005//
+/pool.h/1.11/Fri Feb 25 00:15:38 2005//
+/thro.cpp/1.6/Mon Feb 21 01:55:50 2005//
+/thro.h/1.5/Mon Feb 21 01:55:50 2005//
D
diff --git a/src/thrd/pool.cpp b/src/thrd/pool.cpp
index dd29d6a..1f4ace6 100755
--- a/src/thrd/pool.cpp
+++ b/src/thrd/pool.cpp
@@ -14,7 +14,7 @@ pool::pool()
i_num_total_threads = 0;
i_num_avail_threads = tool::string2int( wrap::CONF->get_elem( "httpd.thread.initpoolsize" ) );
- increase_pool(i_num_avail_threads);
+ increase_pool(i_num_avail_threads);
}
pool::~pool()
@@ -91,10 +91,10 @@ pool::wait_for_task( void* p_void )
}
pthread_mutex_unlock(&p_pool->mut_num_avail_threads);
- pthread_mutex_lock(&p_pool->mut_queue_tasks);
+ pthread_mutex_lock(&p_pool->mut_queue_tasks);
task* p_task = p_pool->queue_tasks.front();
p_pool->queue_tasks.pop();
- pthread_mutex_unlock(&p_pool->mut_queue_tasks);
+ pthread_mutex_unlock(&p_pool->mut_queue_tasks);
pthread_mutex_unlock(&p_pool->mut_threads);
@@ -118,8 +118,9 @@ pool::run(void* p_void)
void
pool::run_func(void *p_void)
{
- socketcontainer* p_sock = static_cast<socketcontainer*>(p_void);
+ int* p_sock = static_cast<int*>(p_void);
wrap::SOCK->read_write(p_sock);
+ delete p_sock;
}
bool
diff --git a/src/thrd/pool.h b/src/thrd/pool.h
index 3a5f7b6..78c4163 100755
--- a/src/thrd/pool.h
+++ b/src/thrd/pool.h
@@ -7,11 +7,9 @@
using namespace std;
-class pool
+class pool
{
private:
- friend class thro;
-
struct task
{
void(*p_func)(void*);
@@ -22,7 +20,7 @@ private:
this->p_func = p_func;
this->p_void = p_void;
}
- };
+ };
pthread_mutex_t mut_threads;
pthread_mutex_t mut_queue_tasks;
@@ -43,11 +41,10 @@ public:
pool();
~pool();
- void run(void* p_void);
+ void run(void* p_void);
bool allow_user_login();
#ifdef NCURSES
-
void print_pool_size();
#endif
};
diff --git a/src/thrd/thro.cpp b/src/thrd/thro.cpp
index 8b3f1ba..e35520c 100644
--- a/src/thrd/thro.cpp
+++ b/src/thrd/thro.cpp
@@ -23,7 +23,6 @@ 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 8e7e0cf..783cd0d 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/CVS/Entries b/src/time/CVS/Entries
index 1320336..a469506 100644
--- a/src/time/CVS/Entries
+++ b/src/time/CVS/Entries
@@ -1,5 +1,5 @@
-/timo.cpp/1.4/Fri Jan 7 21:00:19 2005//
-/timo.h/1.3/Thu Nov 18 13:41:47 2004//
-/timr.cpp/1.11/Mon Feb 14 17:33:09 2005//
-/timr.h/1.4/Fri Jan 7 21:00:19 2005//
+/timo.cpp/1.5/Mon Feb 21 01:55:50 2005//
+/timo.h/1.4/Mon Feb 21 01:55:50 2005//
+/timr.cpp/1.15/Tue Mar 1 09:57:00 2005//
+/timr.h/1.5/Mon Feb 21 01:55:50 2005//
D
diff --git a/src/time/timr.cpp b/src/time/timr.cpp
index 1473a16..b04dc6b 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/tool/CVS/Entries b/src/tool/CVS/Entries
index 8e29732..0f8f81b 100644
--- a/src/tool/CVS/Entries
+++ b/src/tool/CVS/Entries
@@ -1,5 +1,5 @@
-/dir.cpp/1.5/Fri Jan 7 21:00:19 2005//
-/dir.h/1.4/Fri Jan 7 21:00:19 2005//
-/tool.cpp/1.8/Fri Jan 7 21:00:19 2005//
-/tool.h/1.8/Fri Jan 7 21:00:19 2005//
+/dir.cpp/1.6/Mon Feb 21 01:55:50 2005//
+/dir.h/1.5/Mon Feb 21 01:55:50 2005//
+/tool.cpp/1.9/Mon Feb 21 01:55:50 2005//
+/tool.h/1.9/Mon Feb 21 01:55:50 2005//
D
diff --git a/src/wrap.cpp b/src/wrap.cpp
index d7e0dba..f675c1a 100755
--- a/src/wrap.cpp
+++ b/src/wrap.cpp
@@ -6,140 +6,42 @@
using namespace std;
//<<*
-chat* wrap::CHAT = NULL;
+chat* wrap::CHAT;
#ifdef DATABASE
-data* wrap::DATA = NULL;
+data* wrap::DATA;
#endif
-gcol* wrap::GCOL = NULL;
-sman* wrap::SMAN = NULL;
-modl* wrap::MODL = NULL;
+gcol* wrap::GCOL;
+sman* wrap::SMAN;
+modl* wrap::MODL;
//*>>
-conf* wrap::CONF = NULL;
-html* wrap::HTML = NULL;
+conf* wrap::CONF;
+html* wrap::HTML;
#ifdef LOGGING
-logd* wrap::LOGD = NULL;
+logd* wrap::LOGD;
#endif
#ifdef NCURSES
-ncur* wrap::NCUR = NULL;
+ncur* wrap::NCUR;
#endif
-sock* wrap::SOCK = NULL;
-stats* wrap::STAT = NULL;
-timr* wrap::TIMR = NULL;
-pool* wrap::POOL = NULL;
-dynamic_wrap* wrap::WRAP = NULL;
+sock* wrap::SOCK;
+stats* wrap::STAT;
+timr* wrap::TIMR;
+pool* wrap::POOL;
+dynamic_wrap* wrap::WRAP;
void
wrap::system_message( string s_message )
{
#ifdef NCURSES
- if(NCUR)
- {
- NCUR->print( s_message );
- }
-
- else
- {
- cout << s_message << endl;
- }
+ wrap::NCUR->print( s_message );
#endif
-
#ifdef SERVMSG
- cout << s_message << endl;
-#endif
-#ifdef LOGGING
-
- LOGD->log_simple_line( s_message + "\n" );
+ cout << s_message << endl;
#endif
-}
-
-void
-wrap::init_wrapper(map<string,string>* p_main_loop_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_main_loop_params );
- delete p_main_loop_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;
- //*>>
- // Init the socket manager.
- int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
-
- WRAP->SOCK = SOCK = new sock;
- // create the server socket and set it up to accept connections.
- if(SOCK->_make_server_socket ( i_port ) <= 0)
- {
- system_message(SOCKER1);
- exit(-1);
- }
-
-#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 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;
+ wrap::LOGD->log_simple_line( s_message + "\n" );
#endif
- //*>>
-
- // Run threads
- TIMR->run();
}
-
#endif
diff --git a/src/wrap.h b/src/wrap.h
index f5c47dd..51eb9dd 100755
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -2,13 +2,6 @@
#define WRAP_H
#include "incl.h"
-
-
-struct socketcontainer
-{
- int i_sock;
-};
-
#ifdef DATABASE
#include "data/data.h"
#endif
@@ -22,26 +15,17 @@ struct socketcontainer
//<<*
#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 "monitor/stats.h"
+#include "stats.h"
#include "time/timr.h"
#include "thrd/pool.h"
-
using namespace std;
-
class dynamic_wrap
{
public:
@@ -89,8 +73,6 @@ public:
static void system_message( string s_message );
- static void init_wrapper(map<string,string>* p_main_loop_params);
-
//<<*
static chat* CHAT;
#ifdef DATABASE
@@ -126,5 +108,4 @@ public:
static dynamic_wrap* WRAP;
};
-
#endif