summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base.cpp92
-rw-r--r--src/base.h94
-rw-r--r--src/chat.cpp179
-rw-r--r--src/chat.h69
-rw-r--r--src/chat/base.tmpl4
-rw-r--r--src/chat/chat.cpp4
-rw-r--r--src/chat/chat.h18
-rw-r--r--src/chat/gcol.cpp9
-rw-r--r--src/chat/gcol.h5
-rw-r--r--src/chat/room.h4
-rw-r--r--src/chat/sess.cpp14
-rw-r--r--src/chat/sess.h2
-rw-r--r--src/chat/sman.cpp25
-rw-r--r--src/chat/sman.h6
-rw-r--r--src/chat/user.cpp24
-rw-r--r--src/chat/user.h15
-rw-r--r--src/cli/cli.cpp27
-rw-r--r--src/cli/cli.h21
-rw-r--r--src/conf.cpp99
-rw-r--r--src/conf.h47
-rw-r--r--src/conf/conf.cpp6
-rw-r--r--src/conf/conf.h2
-rw-r--r--src/config.h.in82
-rwxr-xr-xsrc/configure254
-rw-r--r--src/configure.ac93
-rw-r--r--src/cont.cpp47
-rw-r--r--src/cont.h52
-rw-r--r--src/data/data_base.cpp18
-rw-r--r--src/data/data_base.h5
-rw-r--r--src/glob.h72
-rw-r--r--src/hmap.cpp206
-rw-r--r--src/hmap.h146
-rw-r--r--src/html.cpp18
-rw-r--r--src/html.h5
-rw-r--r--src/incl.h4
-rw-r--r--src/lang.cpp102
-rw-r--r--src/lang.h47
-rw-r--r--src/logd.cpp2
-rw-r--r--src/main.cpp6
-rw-r--r--src/maps/hashmap.h14
-rw-r--r--src/maps/nhashmap.h8
-rw-r--r--src/maps/shashmap.h12
-rw-r--r--src/memb/memb.h93
-rw-r--r--src/memb/memb.tmpl104
-rw-r--r--src/modl.cpp26
-rw-r--r--src/modl.h5
-rw-r--r--src/mods/Makefile12
-rw-r--r--src/mods/Makefile.mods.in19
-rw-r--r--src/mods/commands/Makefile.in18
-rw-r--r--src/mods/commands/yc_ban.cpp107
-rw-r--r--src/mods/commands/yc_banned.cpp65
-rw-r--r--src/mods/commands/yc_debug.cpp67
-rw-r--r--src/mods/commands/yc_gag.cpp92
-rw-r--r--src/mods/commands/yc_help.cpp1
-rw-r--r--src/mods/commands/yc_q.cpp2
-rw-r--r--src/mods/commands/yc_ren.cpp2
-rw-r--r--src/mods/commands/yc_template.cpp (renamed from src/thrd/thro.cpp)52
-rw-r--r--src/mods/commands/yc_unban.cpp73
-rw-r--r--src/mods/commands/yc_ungag.cpp92
-rwxr-xr-xsrc/mods/configure40
-rw-r--r--src/mods/html/Makefile.in18
-rw-r--r--src/monitor/dump.cpp24
-rw-r--r--src/monitor/dump.h8
-rw-r--r--src/monitor/stats.cpp11
-rw-r--r--src/monitor/stats.h6
-rw-r--r--src/msgs.h25
-rw-r--r--src/mutx.cpp43
-rw-r--r--src/mutx.h44
-rw-r--r--src/ncur/menu.cpp141
-rw-r--r--src/ncur/menu.h63
-rw-r--r--src/ncur/ncur.cpp314
-rw-r--r--src/ncur/ncur.h75
-rw-r--r--src/pool.cpp203
-rw-r--r--src/pool.h75
-rw-r--r--src/room.cpp (renamed from src/build.h)27
-rw-r--r--src/room.h57
-rw-r--r--src/s_chat.cpp33
-rw-r--r--src/s_chat.h (renamed from src/thrd/thro.h)42
-rw-r--r--src/s_conf.cpp33
-rw-r--r--src/s_conf.h50
-rw-r--r--src/s_html.cpp33
-rw-r--r--src/s_html.h50
-rw-r--r--src/s_lang.cpp33
-rw-r--r--src/s_lang.h51
-rw-r--r--src/s_mutx.cpp33
-rw-r--r--src/s_mutx.h50
-rw-r--r--src/s_sman.cpp33
-rw-r--r--src/s_sman.h50
-rw-r--r--src/s_sock.cpp33
-rw-r--r--src/s_sock.h50
-rw-r--r--src/s_tool.cpp162
-rw-r--r--src/s_tool.h44
-rw-r--r--src/sess.cpp (renamed from src/memb/tupel.tmpl)57
-rw-r--r--src/sess.h51
-rw-r--r--src/sman.cpp80
-rw-r--r--src/sman.h59
-rw-r--r--src/sock.cpp263
-rw-r--r--src/sock.h80
-rw-r--r--src/sock/sock.cpp2
-rw-r--r--src/sock/sock.h2
-rw-r--r--src/sock/sslsock.cpp165
-rw-r--r--src/sock/sslsock.h65
-rw-r--r--src/thrd.cpp52
-rw-r--r--src/thrd.h (renamed from src/memb/tupel.h)36
-rw-r--r--src/time/timo.h2
-rw-r--r--src/time/timr.cpp26
-rw-r--r--src/time/timr.h5
-rw-r--r--src/tool/tool.cpp3
-rw-r--r--src/user.cpp167
-rw-r--r--src/user.h125
-rw-r--r--src/wrap.cpp8
-rw-r--r--src/wrap.h19
112 files changed, 4569 insertions, 1441 deletions
diff --git a/src/base.cpp b/src/base.cpp
new file mode 100644
index 0000000..68ccd80
--- /dev/null
+++ b/src/base.cpp
@@ -0,0 +1,92 @@
+/*:*
+ *: File: ./src/base.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+/*
+ This file is part of yChat
+
+ $Author: buetow $
+ $Date: 2005-11-12 15:51:43 $
+
+ $Header: /cvs/cvsroot/ychat-0.5/src/base.cpp,v 1.4 2005-11-12 15:51:43 buetow Exp $
+*/
+// template class data implementation;
+
+#ifndef BASE_CPP
+#define BASE_CPP
+
+#include "base.h"
+
+template<class type>
+base<type>::base()
+{
+ map_elem = new hmap<type*,string>(80);
+ pthread_mutex_init (&mut_map_elem, NULL );
+}
+
+template<class type>
+base<type>::~base( )
+{
+ pthread_mutex_destroy( &mut_map_elem );
+}
+
+template<class type>
+void
+base<type>::add_elem( type* p_type )
+{
+ pthread_mutex_lock ( &mut_map_elem );
+ map_elem->add_elem ( p_type, p_type->get_name());
+ pthread_mutex_unlock( &mut_map_elem );
+}
+
+template<class type>
+void
+base<type>::del_elem( string &s_name )
+{
+ pthread_mutex_lock ( &mut_map_elem );
+ map_elem->del_elem ( s_name );
+ pthread_mutex_unlock( &mut_map_elem );
+}
+
+template<class type>
+type*
+base<type>::get_elem( string &s_name, bool &b_found )
+{
+ pthread_mutex_lock ( &mut_map_elem );
+ type* p_type = map_elem->get_elem( s_name );
+ pthread_mutex_unlock( &mut_map_elem );
+
+ b_found = p_type == NULL ? false : true;
+
+ return p_type;
+}
+
+template<class type>
+void
+base<type>::run_func( void (*func)(type*, void*), void* v_arg )
+{
+ pthread_mutex_lock ( &mut_map_elem );
+ map_elem->run_func( func, v_arg );
+ pthread_mutex_unlock( &mut_map_elem );
+}
+
+#endif
diff --git a/src/base.h b/src/base.h
new file mode 100644
index 0000000..300c916
--- /dev/null
+++ b/src/base.h
@@ -0,0 +1,94 @@
+/*:*
+ *: File: ./src/base.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// template class data declaration;
+
+#ifndef BASE_H
+#define BASE_H
+
+#include "incl.h"
+#include "hmap.h"
+
+template<class type>
+class base
+{
+private:
+ hmap<type*,string>* map_elem;
+ pthread_mutex_t mut_map_elem;
+
+public:
+ base();
+ ~base();
+
+ virtual void add_elem( type* p_type ); // add a element.
+ virtual void del_elem( string &s_name ); // delete a alement.
+ virtual type* get_elem( string &s_name, bool &b_found ); // get a element.
+
+ // execute func on all elements of map_elem. v_pointer is the argument.
+ virtual void run_func( void (*func)(type*, void*), void* v_arg );
+
+ // chat::msg_post sends to all users of the system a message.
+ // room::msg_post sends to all users of the room a message.
+ // user::msg_post sends to the user a message.
+ void msg_post( string *s_msg )
+ {
+ run_func( &base<type>::msg_post_ , (void*)s_msg );
+ }
+ static void msg_post_( type* type_obj, void* v_arg )
+ {
+ string *p_msg = (string*) v_arg;
+ type_obj -> msg_post( p_msg );
+ }
+
+ void get_data( map_string *p_map_string )
+ {
+ run_func( &base<type>::get_data_ , (void*)p_map_string );
+ }
+ static void get_data_( type* type_obj, void* v_arg )
+ {
+ map_string *map_params = (map_string*) v_arg;
+ type_obj -> get_data ( map_params );
+ }
+
+ // chat::get_user_list gets a list of all users of the system.
+ // room::get_user_list gets a list of all users of the room.
+ // user::get_user_list gets a "list" of a user <font color="usercolor">username</font>seperator
+ void get_user_list( string &s_list, string &s_seperator )
+ {
+
+ container c;
+ c.elem[0] = (void*) &s_list;
+ c.elem[1] = (void*) &s_seperator;
+
+ run_func( &base<type>::get_user_list_, (void*)&c );
+ }
+ static void get_user_list_( type* type_obj, void* v_arg )
+ {
+ container *c = (container*) v_arg;
+ type_obj -> get_user_list( *((string*)c->elem[0]), *((string*)c->elem[1]) );
+ }
+};
+
+#include "base.cpp"
+
+#endif
diff --git a/src/chat.cpp b/src/chat.cpp
new file mode 100644
index 0000000..8fd60e7
--- /dev/null
+++ b/src/chat.cpp
@@ -0,0 +1,179 @@
+/*:*
+ *: File: ./src/chat.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class chat implementation.
+
+#ifndef s_chat_CXX
+#define s_chat_CXX
+
+#include "chat.h"
+#include "s_conf.h"
+#include "s_mutx.h"
+#include "s_tool.h"
+
+using namespace std;
+
+chat::chat( )
+{
+ if ( s_conf::get
+ ().get_val( "HTML" ) == "OFF" )
+ b_strip_html = true;
+ else
+ b_strip_html = false;
+
+}
+
+chat::~chat( )
+{}
+
+user*
+chat::get_user( string &s_user )
+{
+ bool b_flag;
+ return get_user( s_user, b_flag );
+}
+
+user*
+chat::get_user( string &s_user, bool &b_found )
+{
+ container param;
+
+ param.elem[0] = (void*) &s_user ;
+ param.elem[1] = (void*) &b_found;
+
+ b_found = false;
+
+ run_func( get_user_, (void*)&param );
+
+ if ( *( (bool*)param.elem[1] ) )
+ return (user*)param.elem[2];
+}
+
+void
+chat::get_user_( room *room_obj, void *v_arg )
+{
+ container* param = (container*) v_arg;
+ param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) );
+}
+
+void
+chat::login( map_string &map_params )
+{
+ string s_user = map_params["nick"];
+
+ // prove if nick is empty:
+ if ( s_user.empty() )
+ {
+ map_params["INFO"] = E_NONICK;
+ map_params["request"] = s_conf::get
+ ().get_val( "STARTMPL" ); // redirect to the startpage.
+ return;
+ }
+
+ // prove if the nick ist alphanumeric:
+ else if ( ! s_tool::is_alpha_numeric( s_user ) )
+ {
+ map_params["INFO"] = E_ALPNUM;
+ map_params["request"] = s_conf::get
+ ().get_val( "STARTMPL" ); // redirect to the startpage.
+ return;
+ }
+
+ bool b_flag;
+
+ // prove if nick is already online / logged in.
+ get_user( s_user, b_flag );
+ if ( b_flag )
+ {
+ map_params["INFO"] = E_ONLINE;
+ map_params["request"] = s_conf::get
+ ().get_val( "STARTMPL" );
+ return;
+ }
+
+ string s_room = map_params["room"];
+ room* p_room = get_room( s_room , b_flag );
+
+ // if room does not exist add room to list!
+ if ( ! b_flag )
+ {
+ p_room = new room( s_room );
+
+#ifdef VERBOSE
+
+ pthread_mutex_lock ( &s_mutx::get
+ ().mut_stdout );
+ cout << NEWROOM << s_room << endl;
+ pthread_mutex_unlock( &s_mutx::get
+ ().mut_stdout );
+#endif
+
+ add_elem( p_room );
+ }
+
+ user *p_user = new user( s_user );
+
+ // add user to the room.
+ p_room->add_user( p_user );
+ sess *ns =s_sman::get
+ ().createSession();
+ ns->setValue(string("nick"), (void *)new string(s_user) );
+ map_params["tmpid"]=ns->getId();
+ // post "username enters the chat" into the room.
+ p_room->msg_post( new string( s_user.append( s_lang::get
+ ().get_val( "USERENTR" ) ) ) );
+
+#ifdef VERBOSE
+
+ pthread_mutex_lock ( &s_mutx::get
+ ().mut_stdout );
+ cout << LOGINPR << s_user << endl;
+ pthread_mutex_unlock( &s_mutx::get
+ ().mut_stdout );
+#endif
+}
+
+void
+chat::post( user* p_user, map_string &map_params )
+{
+
+ string s_msg( map_params["message"] );
+
+ auto unsigned i_pos = s_msg.find( "/" );
+
+ if ( b_strip_html )
+ s_tool::strip_html( &s_msg );
+
+ string s_post( "<font color=\"" );
+
+ s_post.append( p_user->get_col1() )
+ .append( "\">" )
+ .append( p_user->get_name() )
+ .append( ": " )
+ .append( s_msg )
+ .append( "</font><br>\n" );
+
+ p_user->get_p_room()->msg_post( &s_post );
+}
+
+#endif
diff --git a/src/chat.h b/src/chat.h
new file mode 100644
index 0000000..02864f1
--- /dev/null
+++ b/src/chat.h
@@ -0,0 +1,69 @@
+/*:*
+ *: File: ./src/chat.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class chat declaration.
+
+#ifndef s_chat_H
+#define s_chat_H
+
+#include <vector>
+#include "incl.h"
+#include "base.h"
+#include "room.h"
+#include "user.h"
+#include "sess.h"
+#include "s_lang.h"
+#include "s_sman.h"
+
+using namespace std;
+
+class chat : public base<room>
+{
+private:
+ bool b_strip_html;
+
+public:
+
+
+ room* get_room( string &s_name, bool &b_found )
+ {
+ return static_cast<room*>( get_elem( s_name, b_found ) );
+ }
+
+ // public methods:
+ explicit chat(); // a standard constructor.
+ ~chat(); // destructor.
+
+ // get the object of a specific user.
+ virtual user* get_user( string &s_nick );
+ virtual user* get_user( string &s_nick, bool &b_found );
+ static void get_user_( room* room_obj, void *v_arg );
+
+ // will be called every time a user tries to login.
+ virtual void login( map_string &map_params );
+
+ // will be called if a user posts a message.
+ virtual void post ( user* u_user, map_string &map_params );
+};
+
+#endif
diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl
index a8db1a0..87c3a0b 100644
--- a/src/chat/base.tmpl
+++ b/src/chat/base.tmpl
@@ -50,7 +50,7 @@ type*
base<type>::get_elem( string s_name)
{
bool b;
- return get_elem(s_name, b);
+ return get_elem(s_name, b);
}
template<class type>
@@ -80,7 +80,7 @@ base<type>::dumpit()
dumpable::add
(p_elem->dump(dumpable::get_level()));
}
- }
+ }
delete p_vec;
}
diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp
index 066bfbc..a56c74d 100644
--- a/src/chat/chat.cpp
+++ b/src/chat/chat.cpp
@@ -171,6 +171,7 @@ chat::login( map<string,string> &map_params )
{
map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.online" );
map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" );
+
return;
}
@@ -187,12 +188,10 @@ chat::login( map<string,string> &map_params )
wrap::system_message( LOGINER + s_user );
return;
}
-
if ( p_user->get_has_sess() )
{
map_params["tmpid"] = p_user->get_tmpid();
}
-
else
{
sess* p_sess = wrap::SMAN->create_session();
@@ -257,6 +256,7 @@ chat::login( map<string,string> &map_params )
p_user->set_col1( map_params["color1"] );
p_user->set_col2( map_params["color2"] );
p_user->set_status( tool::string2int(map_params["status"]));
+ // p_user->set_sess( p_sess );
}
// Prove if user is the default operator.
diff --git a/src/chat/chat.h b/src/chat/chat.h
index 9da40e7..1758790 100644
--- a/src/chat/chat.h
+++ b/src/chat/chat.h
@@ -37,7 +37,7 @@ class chat;
#include "user.h"
#include "sess.h"
#include "../tool/tool.h"
-#include "../maps/shashmap.h"
+#include "../maps/hashmap.h"
using namespace std;
@@ -47,9 +47,6 @@ class chat : public base<room>, public perm
private:
map<string,string> map_replace_strings;
vector<string> vec_replace_keys;
- shashmap<string> map_banned_nicks;
- shashmap<string, unsigned, self_hash<unsigned>, equals_allocator<unsigned> > map_banned_ips;
-
void dumpit();
public:
@@ -64,11 +61,6 @@ public:
return static_cast<room*>( get_elem( s_name, b_found ) );
}
- void del_elem( string s_name )
- {
- base<room>::del_elem( s_name );
- }
-
// public methods:
explicit chat(); // a standard constructor.
~chat(); // destructor.
@@ -84,10 +76,12 @@ public:
// will be called if a user posts a message.
void post ( user* u_user, map<string,string> &map_params );
+ void del_elem( string s_name )
+ {
+ base<room>::del_elem( s_name );
+ }
+
void reconf();
void string_replacer(string *p_msg);
- string ban_nick(string &s_nick, string s_reason);
- string unban_nick(string &s_nick);
- shashmap<string>* get_map_banned_nicks();
};
#endif
diff --git a/src/chat/gcol.cpp b/src/chat/gcol.cpp
index ffdb8e5..b7f1288 100644
--- a/src/chat/gcol.cpp
+++ b/src/chat/gcol.cpp
@@ -52,6 +52,10 @@ gcol::add_room_to_garbage( room* p_room )
vec_rooms.push_back( p_room );
pthread_mutex_unlock( &mut_vec_rooms );
wrap::system_message( GARROOM + p_room->get_name() );
+#ifdef NCURSES
+
+ print_garbage();
+#endif
}
void
@@ -92,6 +96,11 @@ gcol::remove_garbage()
p_map_users->run_func( delete_users_ );
p_map_users->clear();
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+
return true;
}
diff --git a/src/chat/gcol.h b/src/chat/gcol.h
index bce0db0..a564d22 100644
--- a/src/chat/gcol.h
+++ b/src/chat/gcol.h
@@ -45,6 +45,11 @@ private:
static void delete_users_( user* user_obj );
+#ifdef NCURSES
+
+ void print_garbage( );
+#endif
+
public:
gcol();
~gcol();
diff --git a/src/chat/room.h b/src/chat/room.h
index 0988fd4..6de217a 100644
--- a/src/chat/room.h
+++ b/src/chat/room.h
@@ -47,7 +47,7 @@ private:
logd* p_logd;
#endif
-
+
void dumpit();
public:
@@ -95,7 +95,7 @@ public:
void javascript_post( string s_msg )
{
- string s_js = "<script language=\"JavaScript\">"+s_msg+"</script>\n";
+ string s_js = "<script language=\"JavaScript\">"+s_msg+"</script>\n";
base<user>::msg_post( &s_js );
}
diff --git a/src/chat/sess.cpp b/src/chat/sess.cpp
index 846876d..2007cb1 100644
--- a/src/chat/sess.cpp
+++ b/src/chat/sess.cpp
@@ -42,12 +42,6 @@ sess::get_tmpid()
return s_tmpid;
}
-void
-sess::set_tmpid(string s_tmpid)
-{
- this->s_tmpid = s_tmpid;
-}
-
string
sess::get_name()
{
@@ -74,17 +68,13 @@ void
sess::set_user(user* p_user)
{
this->p_user = p_user;
- //p_user->set_sess(this);
}
-/*
+
void
sess::invalidate()
{
- set_user(NULL);
- set_tmpid("!invalidated");
- wrap::system_message(SESSIOI);
+ this->s_tmpid = "0";
}
-*/
#endif
diff --git a/src/chat/sess.h b/src/chat/sess.h
index db4ad11..e6d9b8c 100644
--- a/src/chat/sess.h
+++ b/src/chat/sess.h
@@ -45,7 +45,7 @@ public:
~sess();
string get_tmpid();
- void set_tmpid(string s_tmpid);
+
void set_user(user* p_user);
user* get_user();
void set_name(string s_name);
diff --git a/src/chat/sman.cpp b/src/chat/sman.cpp
index 187531d..53a15f7 100644
--- a/src/chat/sman.cpp
+++ b/src/chat/sman.cpp
@@ -68,7 +68,7 @@ string sman::generate_id( int i_len )
// Prove, if the TempID already exists
sess* p_sess = get_elem(s_ret);
- if (p_sess)
+ if (p_sess)
{
wrap::system_message(SESSEXI);
return generate_id(i_len);
@@ -109,6 +109,7 @@ sman::destroy_session( string s_id )
pthread_mutex_lock( &mut_i_session_count );
i_session_count--;
+#ifdef NCURSES
wrap::system_message(string(SESSIOD) + "(" +
tool::int2string(i_continous_session_count) + "," +
@@ -116,10 +117,30 @@ sman::destroy_session( string s_id )
pthread_mutex_unlock( &mut_i_session_count );
- del_elem(s_id);
+ sess* p_sess = get_elem( s_id );
+ del_elem( s_id );
delete p_sess;
}
+#ifdef NCURSES
+void sman::print_sessions()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_SESSION_X,NCUR_SESSION_Y, "Sessions: %d ", i_session_count);
+ refresh();
+ }
+}
+
+#ifdef NCURSES
+void sman::print_init_ncurses()
+{
+ pthread_mutex_lock( &mut_i_session_count );
+ print_sessions();
+ pthread_mutex_unlock( &mut_i_session_count );
+}
+#endif
+
int
sman::get_session_count()
{
diff --git a/src/chat/sman.h b/src/chat/sman.h
index 4526ade..d97a12d 100644
--- a/src/chat/sman.h
+++ b/src/chat/sman.h
@@ -40,7 +40,6 @@ class sman : public shashmap<sess*>
private:
string generate_id( int i_len );
int i_session_count;
- int i_continous_session_count;
pthread_mutex_t mut_i_session_count;
@@ -51,8 +50,11 @@ public:
int get_session_count( );
sess *create_session( );
void destroy_session( string s_tmpid );
+#ifdef NCURSES
+
+ void print_init_ncurses();
+#endif
- //virtual void dump();
};
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
index 93dd672..b7816ab 100644
--- a/src/chat/user.cpp
+++ b/src/chat/user.cpp
@@ -73,7 +73,6 @@ user::initialize()
this -> p_room = NULL;
this -> b_is_reg = false;
- this -> b_is_gag = false;
this -> b_set_changed_data = false;
this -> b_away = false;
this -> b_fake = false;
@@ -127,7 +126,6 @@ user::destroy_session()
set_has_sess(false);
wrap::SMAN->destroy_session(get_tmpid());
- //wrap::system_message(tool::int2string(reinterpret_cast<int>(*p_sess)));
set_tmpid("");
}
@@ -314,14 +312,6 @@ user::set_p_room( room* p_room )
pthread_mutex_unlock( &mut_p_room );
}
-/*
-void
-user::set_sess( sess** p_sess )
-{
- this -> p_sess = p_sess;
-}
-*/
-
string
user::get_pass()
{
@@ -535,7 +525,7 @@ user::s_mess_delete( )
void
-user::msg_post( string *p_msg )
+user::s_mess_delete( )
{
pthread_mutex_lock ( &mut_s_mess );
s_mess.append( *p_msg );
@@ -550,6 +540,7 @@ user::post_action_msg(string s_msgkey)
get_room()->msg_post(wrap::TIMR->get_time()+" "+get_colored_bold_name()+wrap::CONF->get_elem(s_msgkey)+"<br>\n");
}
+
void
user::renew_timeout()
{
@@ -587,10 +578,11 @@ user::renew_timeout()
void
user::check_timeout( int* i_idle_timeout )
{
- double d_user_timeout = get_last_activity();
- if ( get_away() ? i_idle_timeout[1] <= d_user_timeout : i_idle_timeout[0] <= d_user_timeout )
+ int i_user_timeout = (int) get_last_activity();
+
+ if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout )
{
- wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string((int)d_user_timeout) + ")");
+ wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
string s_quit = "<script language=JavaScript>top.location.href='/"
+ wrap::CONF->get_elem("httpd.startsite")
+ "';</script>";
@@ -599,9 +591,9 @@ user::check_timeout( int* i_idle_timeout )
pthread_cond_signal( &cond_message );
}
- else if ( ! get_away() && i_idle_timeout[2] <= d_user_timeout )
+ else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout )
{
- wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string((int)d_user_timeout) + ")");
+ wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
string s_msg = wrap::CONF->get_elem("chat.msgs.userautoawaytimeout");
set_away( true, s_msg );
string s_msg2 = wrap::TIMR->get_time() + " <b>" + get_colored_name()+ "</b>" + s_msg + "<br>\n";
diff --git a/src/chat/user.h b/src/chat/user.h
index cde0729..b88a820 100644
--- a/src/chat/user.h
+++ b/src/chat/user.h
@@ -29,19 +29,13 @@
#include "../name.h"
#include "../time/timo.h"
-#include "../memb/memb.h"
#include "../monitor/dump.h"
-using namespace std;
-
class room;
-//class sess;
-class user :
- public name,
- public timo,
- public dumpable,
- public memb_base
+using namespace std;
+
+class user : public name, public timo, public dumpable
{
private:
@@ -68,6 +62,7 @@ private:
string s_col1; // user's nick color.
string s_col2; // user's text color.
string s_email; // user's email addres
+ string s_mess; // message string which has to be sent to the user.
string s_pass; // password
room* p_room; // pointer to the user's room.
// sess** p_sess; // pointer to the pointer to the session object
@@ -174,8 +169,6 @@ public:
void get_user_list( string &s_list );
void check_restore_away();
void reconf();
- bool same_rooms(user *p_user);
- string make_colors(string s_msg);
};
#endif
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index 02e3306..d2eee4a 100644
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -28,12 +28,6 @@
#include "cli.h"
#ifdef CLI
-
-#ifdef READLINE
-#include <readline/readline.h>
-#include <readline/history.h>
-#endif
-
using namespace std;
cli::cli( )
@@ -76,7 +70,7 @@ cli::parse_input( string s_input )
if ( s_input.compare("help") == 0 || s_input.compare("h") == 0)
{
cout << CLIPRMO << "COMMAND LINE INTERFACE HELP MENU" << endl
- << CLIPRMO << " !command - Uses system to run a command" << endl;
+ << CLIPRMO << " !command - Uses system to run a command" << endl;
#ifdef DEBUG
cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl;
@@ -86,6 +80,11 @@ cli::parse_input( string s_input )
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
+
+ cout << CLIPRMO << " (ex)it - Quits CLI mode and respawns ncurses mode" << endl;
+#endif
+
cout << CLIPRMO << " (h)elp - Prints out this help!" << endl;
//<<*
cout << CLIPRMO << " (m)ysql - Runs MySQL client on yChat DB" << endl
@@ -100,7 +99,7 @@ cli::parse_input( string s_input )
<< CLIPRMO << " (ru)sageh - Shows resource usage history (yChat needs to run > 1 day)" << endl
<< CLIPRMO << " (set) VAR VAL - Sets configuration value VAR to VAL" << endl
<< CLIPRMO << " (sh)ell - Runs a system shell" << endl
- << CLIPRMO << " (shut)down - Shuts down the whole server" << endl
+ << CLIPRMO << " (s)hutdown - Shuts down the whole server" << endl
<< CLIPRMO << " (t)ime - Prints out time and uptime" << endl;
cout << CLIPRMO << " (unl)oad - Unloads all loaded modules" << endl;//<<
cout << CLIPRMO << " (u)nset VAR - Deletes configuration value VAR" << endl
@@ -181,6 +180,12 @@ cli::parse_input( string s_input )
}
//*>>
+#ifdef NCURSES
+ else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 )
+ {
+ return 0;
+ }
+#endif
//<<*
else if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 )
@@ -321,6 +326,9 @@ cli::parse_input( string s_input )
void
cli::start(void* p_void)
+#else
+cli::start()
+#endif
{
cout << CLIPRMO << CLIWELC << endl;
@@ -343,6 +351,7 @@ cli::start(void* p_void)
if (!parse_input(s_input))
break;
}
+ while( parse_input(s_input) );
}
void
@@ -370,7 +379,7 @@ cli::print_rusage()
}
vector<string>
-cli::vectorize(string s_param)
+cli::vectorize(string s_param)
{
vector<string> vec_ret;
unsigned i_pos;
diff --git a/src/cli/cli.h b/src/cli/cli.h
index 98ecdd4..360d801 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -49,22 +49,29 @@ using namespace std;
class cli : public thro
{
+#endif
private:
int parse_input(string s_input);
vector<string> vectorize(string s_param);
-
+
public:
- cli( );
- ~cli( );
+cli( );
+~cli( );
#ifdef DEBUG
- void debug_routine();
+void debug_routine();
#endif
- void print_rusage();
- void start(void* p_void);
- void start();
+void print_rusage();
+
+#ifndef NCURSES
+
+void start(void* p_void);
+#else
+
+void start();
+#endif
};
#endif
diff --git a/src/conf.cpp b/src/conf.cpp
new file mode 100644
index 0000000..3dd3c6c
--- /dev/null
+++ b/src/conf.cpp
@@ -0,0 +1,99 @@
+/*:*
+ *: File: ./src/conf.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class conf implementation.
+
+#ifndef s_conf_CXX
+#define s_conf_CXX
+
+#include <fstream>
+#include "conf.h"
+
+using namespace std;
+
+conf::conf( string s_conf = CONFILE ) : name( s_conf )
+{
+ parse( ); // parse the config file.
+}
+
+conf::~conf()
+{}
+
+void
+conf::parse()
+{
+#ifdef VERBOSE
+ cout << CFILEOK << get_name() << endl;
+#endif
+
+ ifstream fs_conf( get_name().c_str() );
+
+ if ( ! fs_conf )
+ {
+#ifdef VERBOSE
+ cout << CFILENO << get_name() << endl;
+#endif
+
+ return;
+ }
+
+ char c_buf[READBUF];
+
+ while( fs_conf.getline( c_buf, READBUF ) )
+ {
+ string s_token( c_buf );
+ unsigned int ui_pos = s_token.find( "#", 0 );
+
+ // if line is commented out:
+ if ( ui_pos == 0 )
+ continue;
+
+ ui_pos = s_token.find( ";", 0 );
+
+ // if token has not been found.
+ if ( ui_pos == string::npos )
+ continue;
+
+ s_token = s_token.substr( 0 , --ui_pos );
+ ui_pos = s_token.find ( "\"", 0 );
+
+ if ( ui_pos == string::npos )
+ continue;
+
+ string s_val = s_token.substr( ui_pos+1, s_token.length() );
+ string s_key = s_token.substr( 0 , --ui_pos );
+
+#ifdef VERBOSE2
+
+ cout << s_key << "=" << s_val << endl;
+#endif
+
+ // fill the map.
+ map_vals[s_key] = s_val;
+ }
+
+ fs_conf.close();
+ fs_conf.~ifstream();
+}
+
+#endif
diff --git a/src/conf.h b/src/conf.h
new file mode 100644
index 0000000..954ce75
--- /dev/null
+++ b/src/conf.h
@@ -0,0 +1,47 @@
+/*:*
+ *: File: ./src/conf.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class conf declaration. this class parses the server config file.
+
+#ifndef s_conf_H
+#define s_conf_H
+
+#include "incl.h"
+#include "cont.h"
+#include "name.h"
+
+using namespace std;
+
+class conf : public cont, name
+{
+private:
+
+public:
+ // public methods:
+ conf ( string s_conf ); // standard constructor.
+ ~conf(); // standard destructor.
+
+ virtual void parse( ); // parses the config file.
+};
+
+#endif
diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp
index 14268d1..dee678c 100644
--- a/src/conf/conf.cpp
+++ b/src/conf/conf.cpp
@@ -30,7 +30,7 @@
using namespace std;
-conf::conf( string s_conf, map<string,string>* p_main_loop_params ) : name::name( s_conf )
+conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_conf )
{
string s_check[] = {
get_name(),
@@ -82,7 +82,7 @@ conf::conf( string s_conf, map<string,string>* p_main_loop_params ) : name::name
// Overrides ychat.conf values with command line options (ychat -o key1 value1 -o key2 value2 ...)
map<string,string>::iterator iter;
- for ( iter = p_main_loop_params->begin(); iter != p_main_loop_params->end(); iter++ )
+ for ( iter = p_start_params->begin(); iter != p_start_params->end(); iter++ )
{
shashmap<string>::del_elem_insecure(iter->first);
shashmap<string>::add_elem_insecure(iter->second, iter->first);
@@ -198,7 +198,7 @@ conf::colored_error_msg(string s_key)
int
conf::get_int(string s_key)
{
- return tool::string2int(get_elem(s_key));
+ return tool::string2int(get_elem(s_key));
}
vector<string>
diff --git a/src/conf/conf.h b/src/conf/conf.h
index 3f237ad..065fe65 100644
--- a/src/conf/conf.h
+++ b/src/conf/conf.h
@@ -43,7 +43,7 @@ private:
void parse_xml( TiXmlNode* p_node, vector<string>* p_vec);
public:
- conf(string s_conf, map<string,string>* p_main_loop_params);
+ conf(string s_conf, map<string,string>* p_start_params);
~conf();
string colored_error_msg(string s_key); //<<
diff --git a/src/config.h.in b/src/config.h.in
deleted file mode 100644
index a17fb04..0000000
--- a/src/config.h.in
+++ /dev/null
@@ -1,82 +0,0 @@
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
-/* Define to 1 if you have the `mysqlclient' library (-lmysqlclient). */
-#undef HAVE_LIBMYSQLCLIENT
-
-/* Define to 1 if you have the `pthread' library (-lpthread). */
-#undef HAVE_LIBPTHREAD
-
-/* Define to 1 if you have the `readline' library (-lreadline). */
-#undef HAVE_LIBREADLINE
-
-/* Define to 1 if you have the `ssl' library (-lssl). */
-#undef HAVE_LIBSSL
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <mysql/mysql.h> header file. */
-#undef HAVE_MYSQL_MYSQL_H
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#undef HAVE_NETINET_IN_H
-
-/* Define to 1 if you have the <openssl/ssl.h> header file. */
-#undef HAVE_OPENSSL_SSL_H
-
-/* Define to 1 if you have the <pthread.h> header file. */
-#undef HAVE_PTHREAD_H
-
-/* Define to 1 if you have the <readline/readline.h> header file. */
-#undef HAVE_READLINE_READLINE_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <time.h> header file. */
-#undef HAVE_TIME_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
diff --git a/src/configure b/src/configure
index 4682ef6..baea317 100755
--- a/src/configure
+++ b/src/configure
@@ -781,7 +781,7 @@ ac_cv_env_CPP_set=${CPP+set}
ac_cv_env_CPP_value=$CPP
#
-# Report the --help message.
+# The yChat Project (2003 - 2005)
#
if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
@@ -1017,13 +1017,252 @@ done
cat >&5 <<_ACEOF
+if ! ../scripts/checkperl.sh
+then
+ exit 1
+fi
+
+if ! test -f ../g++.version
+then
+ echo You need to run ./configure of the top level source dir first
+ exit 1
+fi
+
+perl -e '
+ use strict;
+ $|=1;
+
+ my %libadd;
+ my %incadd;
+ my $deepness = 500;
+
+ my @headers = (
+ "dlfcn.h",
+ "pthread.h",
+ "mysql/mysql.h", #//<< Not needed for yhttpd
+ "netinet/in.h",
+ "time.h",
+ "ncurses.h",
+ "::test::ext/hash_map"
+ );
+
+ my @libs = (
+ "libmysqlclient.so", #//<< Not needed for yhttpd
+ "libncurses.so"
+ );
+
+ my @headerpaths = (
+ $ENV{HOME}."/include",
+ $ENV{HOME}."/usr/include",
+ "/include",
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/lib/",
+ "/usr/pkg/include",
+ "/opt/include",
+ "/opt/local/include"
+ );
+
+ my @libpaths = (
+ $ENV{HOME}."/lib",
+ $ENV{HOME}."/usr/lib",
+ "/lib",
+ "/usr/lib",
+ "/usr/local/lib",
+ "/usr/pkg/lib",
+ "/opt/lib",
+ "/opt/local/lib"
+ );
+
+ open FILE, "glob.h" or die "glob.h: $!\n";
+ while(<FILE>)
+ {
+ if ( /\/\/#define DATABASE/ )
+ {
+ remove_from_array("mysql/mysql.h",\@headers);
+ remove_from_array("libmysqlclient.so",\@libs);
+ }
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
+ if ( /\/\/#define NCURSES/ )
+ {
+ remove_from_array("ncurses.h",\@headers);
+ remove_from_array("libncurses.so",\@libs);
+ }
+ }
+ close FILE;
+
+ if ( defined $ENV{YCHATHEADERPATHS} )
+ {
+ map { print "Adding $_...\n";
+ unshift @headerpaths, $_ } split /:/, $ENV{YCHATHEADERPATHS};
+ }
+
+ if ( defined $ENV{YCHATLIBPATHS} )
+ {
+ map { print "Adding $_...\n";
+ unshift @libpaths, $_ } split /:/, $ENV{YCHATLIBPATHS};
+ }
+
+
+ print "Headers:\n";
+
+ my $testit = 0;
+ map { $incadd{&check($deepness, $_, @headerpaths)}++ }
+ @headers;
+
+ $testit = 0;
+ print "Libraries:\n";
+ map { $libadd{&check($deepness, $_, @libpaths)}++ }
+ @libs;
+
+ my $incadd = &make_add("-I", \%incadd);
+ my $libadd = &make_add("-L", \%libadd);
+
+ for ( @libs )
+ {
+ $libadd .= "-l$_ " if s/^lib// and s/\.so$//;
+ }
+
+ print "Incadd: $incadd\n";
+ print "Libadd: $libadd\n";
+
+ `echo $incadd > includes.add`;
+ `echo $libadd > libs.add`;
+
+ print "Creating new base Makefile...\n";
+ unlink("Makefile") if -f "Makefile";
+ unlink("../err") if -f "../err";
+ open Fin, "Makefile.in" or die "Makefile.in: $!\n";
+ open Fout, ">Makefile" or die "Makefile: $!\n";
+
+ my $cpp = `echo *.cpp */*.cpp contrib/*/*.cpp | sort`;
+ my $compiler = `tail -n 1 ../g++.version`;
+ my $version = `tail -n 2 ../g++.version | head -n 1`;
+ my $uname = `uname -srm`;
+ my $compopt = join "; ", split /\n/, `cat ../g++.version`;
+
+ chomp $uname;
+ chomp $compopt;
+
+ print "Configuring for $uname...\n";
+ chomp $cpp;
+ chomp $version;
+
+ while (<Fin>)
+ {
+ s/^(CC=).*\n/$1$compiler/;
+ s/^(SRCS=).*/$1$cpp/;
+ s/ -frepo//; # unless $version =~ /3\.4/;
+ if ( $uname !~ /Linux/i ) {
+ print "Disabling -ldl flag...\n" if s/ -ldl//;
+ }
+ print Fout;
+ }
+ close Fin;
+
+ my $args = join(" -",@ARGV);
+ $args = "-".$args unless $args eq "";
+
+ for my $cppfile (split / /, $cpp)
+ {
+ my $ofile = $cppfile;
+ $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\/.+/ )
+ {
+ my $dirname = `dirname $class`;
+ $text = "\t\@echo -n \"Contributed class $class \"\n";
+ }
+
+ else
+ {
+ $text = "\t\@echo -n \"Base class $class \"\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";
+ }
+
+ close Fout;
+
+ open F, "msgs.h" or die "msgs.h: $!\n";
+ my @msgs = <F>;
+ close F;
+ unlink("msgs.h");
+ open F, ">msgs.h" or die "msgs.h: $!\n";
+
+ for (@msgs)
+ {
+ s/(UNAME)(.+)$/UNAME "$uname"/;
+ s/(COMPOPT)(.+)$/COMPOPT "$compopt"/;
+ print F;
+ }
+ close F;
+
+ if ( -d "mods" )
+ {
+ chdir("mods");
+ my $cflags = "-fno-inline -fno-default-inline";
+
+ $cflags .= " -nostdlib" if $uname =~ /FreeBSD/i && `uname -r` =~ /^4\./;
+
+ system("echo $cflags > cflags.add");
+ system("./configure");
+ chdir("..");
+ }
+
+ sub remove_from_array
+ {
+ my $elem = shift;
+ my $array = shift;
+
+ for ( my $i = 0; $i <= $#$array; ++$i )
+ {
+ if ( $$array[$i] eq $elem )
+ {
+ splice(@$array,$i,1);
+ last;
+ }
+ } # for
+ }
+
+ sub check {
+ my $deep = shift;
+
+ if ($deep == 0) {
+ print "Looking too deep! ($deepness)\n";
+ exit(1);
+ }
+
+ my $check = shift;
+ $testit = 1 if $check =~ s/::test:://;
+
+ my $print = 1;
+ if ( $_[-1] eq "subsearch" ) {
+ $print = 0;
+ pop(@_);
+ }
+
+ if ($print)
+ {
+ print "Checking for $check...";
+ print "\n" if $testit;
+ }
+ for (@_)
+ {
+ if ( -f "$_/$check" )
+ {
+ if ($testit)
+ {
+ return $_ if test_include($_, $check);
+ return "";
+ }
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
@@ -6392,4 +6631,5 @@ cat << END >> config.h
#define PREFIX "$prefix"
END
-echo You are ready to run GNU Make now!
+ exit(0);
+' `echo "$*" | sed "s/-//g"`
diff --git a/src/configure.ac b/src/configure.ac
deleted file mode 100644
index d065d76..0000000
--- a/src/configure.ac
+++ /dev/null
@@ -1,93 +0,0 @@
-dnl configure.ac Cypyright (2005, 2006) by the yChat Project
-
-AC_INIT(main.cpp, [], [paul at buetow dot org])
-AC_CONFIG_HEADER(config.h)
-AC_PROG_CXX
-AC_PREFIX_DEFAULT(/usr/local)
-
-AC_ARG_ENABLE(readline, AC_HELP_STRING([--disable-readline], [Disables readline support (default=yes)]), [], enable_readline=yes)
-AC_ARG_ENABLE(readline, AC_HELP_STRING([--disable-readline], [Disables readline support (default=yes)]))
-AC_ARG_ENABLE(ssl, AC_HELP_STRING([--enable-ssl], [Enable OpenSSL support (default=no)]))
-AC_ARG_ENABLE(mysqlclient, AC_HELP_STRING([--enable-mysql], [Enable MySQL support (default=no)]))
-
-header_error() AC_MSG_ERROR([Could not find required header, please check the installation of the required header])
-lib_error() AC_MSG_ERROR([Library test failed, please check the installation of the required library])
-
-echo "===> Checking for dependencies"
-AC_CHECK_HEADERS(dlfcn.h netinet/in.h time.h pthread.h, [], [header_error])
-AC_CHECK_LIB(pthread, pthread_create, [], [lib_error])
-
-echo -n "===> Configuring with SSL "
-if test -z $enable_ssl || test $enable_ssl != "yes"; then
- echo disabled
-else
- echo enabled
- AC_CHECK_HEADERS(openssl/ssl.h, [], [header_error])
- AC_CHECK_LIB(ssl, SSL_write, [], [lib_error])
-fi
-
-echo -n "===> Configuring with MySQL "
-if test -z $enable_mysql || test $enable_mysql != "yes"; then
- echo disabled
-else
- echo enabled
- AC_CHECK_HEADERS(mysql/mysql.h, [], [header_error])
- AC_CHECK_LIB(mysqlclient, mysql_init, [], [lib_error])
-fi
-
-echo -n "===> Configuring with readline "
-if test -z $enable_readline || test $enable_readline != "yes"; then
- echo disabled
-else
- echo enabled
- AC_CHECK_HEADERS(readline/readline.h, [], [header_error])
- AC_CHECK_LIB(readline, readline, [], [lib_error])
-fi
-
-echo "===> Checking for find with extended regexp "
-
-AC_SUBST([efind])
-if find -E ./configure >/dev/null; then
- efind='find -E'
-else
- efind='find -regextype posix-extended'
-fi
-
-if test `uname` = "Linux"; then
- echo "===> Configuring with -ldl (Linux)"
- AC_CHECK_LIB(dl, dlopen, [], [lib_error])
-fi
-
-
-AC_OUTPUT(Makefile)
-AC_OUTPUT(../Makefile)
-
-echo "===> Posttasking Makefile"
-
-SRCS=`find ./ -type f -name '*.cpp' | grep -v ./mods`
-OBJS=''
-
-echo > .Makefile || exit 1
-echo > .Makefile.deps || exit 1
-
-for src in $SRCS; do
- obj=`echo $src | sed 's/\(.*\)\.cpp/\.\.\/obj\/\1\.o/'`
- OBJS="$OBJS $obj"
- echo "$obj: $src" >> .Makefile.deps
-done
-
-echo SRCS=$SRCS >> .Makefile.tmp
-echo OBJS=$OBJS >> .Makefile.tmp
-cat Makefile >> .Makefile.tmp
-cat .Makefile.deps >> .Makefile.tmp
-mv -f .Makefile.tmp Makefile || exit 1
-rm -f .Makefile.deps
-
-echo "===> Posttasking config.h"
-cat << END >> config.h
-
-/* Program prefix. */
-#define PREFIX "$prefix"
-END
-
-echo You are ready to run GNU Make now!
diff --git a/src/cont.cpp b/src/cont.cpp
new file mode 100644
index 0000000..497b456
--- /dev/null
+++ b/src/cont.cpp
@@ -0,0 +1,47 @@
+/*:*
+ *: File: ./src/cont.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class cont implementation.
+
+#ifndef CONT_CXX
+#define CONT_CXX
+
+#include "cont.h"
+#include "s_mutx.h"
+
+using namespace std;
+
+string
+cont::get_val( string s_key )
+{
+ if ( map_vals.find( s_key ) != map_vals.end() )
+ return map_vals[ s_key ];
+ return string();
+}
+
+cont::~cont()
+{
+ map_vals.~map_string();
+}
+
+#endif
diff --git a/src/cont.h b/src/cont.h
new file mode 100644
index 0000000..810ff2d
--- /dev/null
+++ b/src/cont.h
@@ -0,0 +1,52 @@
+/*:*
+ *: File: ./src/cont.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class cont declaration. defines a simple data container class.
+
+#ifndef CONT_H
+#define CONT_H
+
+#include "incl.h"
+#include "hmap.h"
+
+using namespace std;
+
+class cont
+{
+protected:
+ map_string map_vals;
+
+public:
+ cont::~cont();
+
+ // small inline methods:
+ void clear_vals()
+ {
+ map_vals.clear();
+ } // removes all values.
+
+ // public methods:
+ virtual string get_val( string s_key ); // get a specific map_vals value.
+};
+
+#endif
diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp
index 61fc141..ede07f5 100644
--- a/src/data/data_base.cpp
+++ b/src/data/data_base.cpp
@@ -57,6 +57,11 @@ void data_base::init_connections()
for ( int i = 0; i < i_min_con && i < i_max_con; i++ )
push_back( new con() );
+
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
}
data_base::~data_base()
@@ -136,11 +141,24 @@ data_base::push_con( con* p_con )
{
pthread_mutex_lock( &mut_con );
push_front( p_con );
+#ifdef NCURSES
pthread_mutex_unlock( &mut_con );
wrap::system_message( DATAADD );
}
+#ifdef NCURSES
+void
+data_base::print_queue_size()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_CON_QUEUE_X,NCUR_CON_QUEUE_Y, "Con. queue: %d ", size());
+ refresh();
+ }
+}
+#endif
+
void
data_base::disconnect_all_connections()
{
diff --git a/src/data/data_base.h b/src/data/data_base.h
index dbad3f0..79f5630 100644
--- a/src/data/data_base.h
+++ b/src/data/data_base.h
@@ -16,6 +16,11 @@ private:
pthread_mutex_t mut_con;
int i_max_con;
+#ifdef NCURSES
+
+ void print_queue_size();
+#endif
+
protected:
hashmap< vector<string> > map_queries;
void print_query( string s_query );
diff --git a/src/glob.h b/src/glob.h
index 58ce936..96296da 100644
--- a/src/glob.h
+++ b/src/glob.h
@@ -22,21 +22,22 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
+/*
+ Notice:
+
+ All #defines which start with an CONFIG can be edited through
+ gmake config in the main directory!
+*/
+
#include "maps/hashmap.h"
// global variables.
#ifndef GLOB_H
#define GLOB_H
-#include "config.h"
-
// Definition of boolean values.
-#ifndef true
#define true 1
-#endif
-#ifndef false
#define false 0
-#endif
//<<*
/* FIRST THE YCHAT ONLY OPTIONS */
@@ -44,10 +45,13 @@
#ifdef HAVE_LIBMYSQLCLIENT
#ifdef HAVE_MYSQL_MYSQL_H
#define USE_MYSQL
-#define DATABASE
+/* - CONFIG -
+ Should all database queries printed out at the admin interface?
+ (This option wont take action if database support has not been
+ chosen)
+*/
#define DATA_PRINT_QUERIES
#endif
-#endif
#define PUSHSTR 500
@@ -57,22 +61,61 @@
#endif
#endif
+/* - CONFIG -
+ Should yChat get compiled with comand line interface support?
+*/
#define CLI
+
+/* - CONFIG -
+ What should be the name of the config file?
+*/
#define CONFILE "ychat.conf"
+/* - DISABLED -
+ Enable debugging options.
+*/
//#define DEBUG
+
+/* - 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!
+*/
//#define EXPERIM
+/* - CONFIG -
+ Should yChat get compiled with logging support?
+*/
#define LOGGING
+
+/* - CONFIG -
+ Please enter the highest networking port which is allowed to be
+ used. If yChat is unable to create the server socket on a cert-
+ ain port, it will increment the port number and retries to cre-
+ ate another socket on the incremented port number. This proced-
+ ure will continue until MAXPORT has been reached.
+*/
#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
-#ifdef HAVE_LIBREADLINE
-#ifdef HAVE_READLINE_READLINE_H
-#define READLINE
-#endif
-#endif
+/* - CONFIG -
+ Should yChat get compiled with ncurses support?
+*/
+#define NCURSES
+
+/* - CONFIG -
+ Please specify the maximum length of a HTTP post request.
+*/
+#define POSTBUF 512
#define POSTBUF 1024
#define READBUF 2048
@@ -101,6 +144,5 @@ typedef enum method_ {
} method;
// Define external executables:
-#define GMAKE "/usr/local/bin/gmake "
-
+#define GMAKE "/usr/local/bin/gmake \0"
#endif
diff --git a/src/hmap.cpp b/src/hmap.cpp
new file mode 100644
index 0000000..81db939
--- /dev/null
+++ b/src/hmap.cpp
@@ -0,0 +1,206 @@
+/*:*
+ *: File: ./src/hmap.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef hmap_cpp
+#define hmap_cpp
+
+
+#include "hmap.h"
+
+using namespace std;
+
+bool isPrime( int n );
+int nextPrime( int n );
+
+// Construct the hash table.
+template <class obj_type, class key_type>
+hmap<obj_type, key_type>::hmap( double mop )
+ : maxOccupiedPercentage(mop), array( nextPrime( 101 ) )
+{
+ cout << "hmap Constructor" << endl;
+ lookups = 0;
+ make_empty( );
+}
+
+// Insert item x into the hash table. If the item is
+// already present, do nothing
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::add_elem( const obj_type &x, const key_type &k )
+{
+ // Insert x as active
+ int currentPos = findPos( k );
+ if( isActive( currentPos ) )
+ return;
+
+ array[ currentPos ] = hash_entry( x, k, ACTIVE );
+ // cout << "Inserted=" << x << "= at " << currentPos << endl;
+ if( ++occupied > array.size( ) * maxOccupiedPercentage )
+ rehash( );
+}
+
+// Expand the hash table.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::rehash( )
+{
+ vector<hash_entry> oldArray = array;
+
+ // Create new double-sized, empty table
+ array.resize( nextPrime( 2 * oldArray.size( ) ) );
+ for( int j = 0; j < array.size( ); j++ )
+ array[ j ].info = EMPTY;
+
+ // Copy table over
+ make_empty( );
+ for( int i = 0; i < oldArray.size( ); i++ )
+ if( oldArray[ i ].info == ACTIVE )
+ add_elem( oldArray[ i ].element, oldArray[ i ].key );
+}
+
+// Hash function, can only handle strings.
+// If you want to hash other objects you will have to
+// create a hash table for them
+template <class obj_type, class key_type>
+unsigned int hmap<obj_type, key_type>::hash( const string & key ) const
+{
+ unsigned int hashVal = 0;
+ // cout << key << "%";
+
+ for( size_t i = 0; i < key.size(); i++ )
+ hashVal = ( hashVal << 5 ) ^ key[ i ] ^ hashVal;
+
+ return hashVal;
+}
+
+// Method that performs quadratic probing resolution.
+// Return the position where the search for x terminates.
+template <class obj_type, class key_type>
+int hmap<obj_type, key_type>::findPos( const key_type &k )
+{
+ int collisionNum = 0;
+ int currentPos = hash( k ) % array.size( );
+ lookups++;
+
+ while( array[ currentPos ].info != EMPTY &&
+ array[ currentPos ].key != k )
+ {
+ // cout << array[ currentPos ].element << "!=" << x << endl;
+ lookups++;
+ currentPos += 2 * ++collisionNum - 1; // Compute ith probe
+
+ if( currentPos >= array.size( ) )
+ currentPos -= array.size( );
+ }
+
+ // cout << currentPos << " ";
+ return currentPos;
+}
+
+// Remove item x from the hash table.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::del_elem( const key_type & k )
+{
+ int currentPos = findPos( k );
+ if( isActive( currentPos ) )
+ array[ currentPos ].info = DELETED;
+}
+
+// Find item x in the hash table.
+// Return a pointer to the matching item or 0 if not found
+template <class obj_type, class key_type>
+obj_type hmap<obj_type, key_type>::get_elem( const key_type &k )
+{
+ int currentPos = findPos( k );
+ if( isActive( currentPos ) )
+ return array[ currentPos ].element;
+ else
+ return 0;
+}
+
+// Make the hash table logically empty.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::make_empty( )
+{
+ occupied = 0;
+ for( int i = 0; i < array.size( ); i++ )
+ array[ i ].info = EMPTY;
+}
+
+// Return true if currentPos exists and is active.
+template <class obj_type, class key_type>
+bool hmap<obj_type, key_type>::isActive( int currentPos ) const
+{
+ return array[ currentPos ].info == ACTIVE;
+}
+
+
+// Internal method to test if a positive number is prime.
+// Not an efficient algorithm.
+template <class obj_type, class key_type>
+bool hmap<obj_type, key_type>::isPrime( int n ) const
+{
+ if( n == 2 || n == 3 )
+ return true;
+
+ else if( n == 1 || n % 2 == 0 )
+ return false;
+
+ for( int i = 3; i * i <= n; i += 2 )
+ if( n % i == 0 )
+ return false;
+
+ return true;
+}
+
+// Internal method to return a prime number at least as large as n.
+// Assumes n > 0.
+template <class obj_type, class key_type>
+int hmap<obj_type, key_type>::nextPrime( int n ) const
+{
+ if( n % 2 == 0 )
+ n++;
+
+ for( ; !isPrime( n ); n += 2 )
+ ;
+
+ return n;
+}
+template<class obj_type, class key_type>
+void
+hmap<obj_type, key_type>::run_func( void (*func)(obj_type) )
+{
+ for( int i = 0; i < array.size( ); i++ )
+ if ( array[i].info == ACTIVE )
+ ( *func ) ( array[i].element );
+}
+
+template<class obj_type, class key_type>
+void
+hmap<obj_type, key_type>::run_func( void (*func)(obj_type, void*), void* v_arg )
+{
+ for( int i = 0; i < array.size( ); i++ )
+ if ( array[i].info == ACTIVE )
+ ( *func ) ( array[i].element, v_arg );
+}
+
+#endif
+
diff --git a/src/hmap.h b/src/hmap.h
new file mode 100644
index 0000000..0360019
--- /dev/null
+++ b/src/hmap.h
@@ -0,0 +1,146 @@
+/*:*
+ *: File: ./src/hmap.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#pragma warning(disable:4786)
+
+#ifndef hmap_h
+#define hmap_h
+
+#include <vector>
+#include "incl.h"
+
+using namespace std;
+
+// void add_elem( obj_type x, key_type k ) --> Insert x
+// void del_elem( key_type k ) --> Remove x
+// obj_type get_elem( key_type k ) --> Return item that matches x
+// void make_empty( ) --> Remove all items
+
+template <class obj_type, class key_type>
+class hmap
+{
+private:
+ enum entry_type
+ {
+ ACTIVE, EMPTY, DELETED
+ };
+
+ struct hash_entry
+ {
+ obj_type element;
+ key_type key;
+ entry_type info;
+
+ hash_entry( const obj_type &e = obj_type( ), const key_type &k = key_type( ), entry_type i = EMPTY ) : element( e ), key( k ), info( i )
+ { }
+ }
+ ;
+
+ int occupied;
+
+ virtual bool isActive( int currentPos ) const;
+ virtual void rehash( );
+ virtual bool isPrime ( int n ) const;
+ virtual int nextPrime( int n ) const;
+ double maxOccupiedPercentage;
+
+protected:
+ int lookups;
+ unsigned int hash( const string &key ) const;
+ vector<hash_entry> array;
+
+public:
+ hmap( double moc );
+
+ virtual int findPos ( const key_type &k );
+ virtual void make_empty( );
+ virtual void add_elem ( const obj_type &x, const key_type &k );
+ virtual void del_elem ( const key_type &k );
+ virtual obj_type get_elem ( const key_type &k );
+
+ virtual void run_func( void (*func)(obj_type) );
+ virtual void run_func( void (*func)(obj_type, void*), void* v_arg );
+
+ // inline:
+ void getSize()
+ {
+ int size = 0;
+ for( int j = 0; j < array.size( ); j++ )
+ if (array[ j ].info == ACTIVE)
+ size++;
+ return size;
+ };
+
+ int getLookups()
+ {
+ return lookups;
+ };
+
+ int getCapacity()
+ {
+ return array.size();
+ };
+
+ double getLambda()
+ {
+ return static_cast<double>(getSize())/static_cast<double>(getCapacity());
+ }
+
+ obj_type& operator[]( key_type &k )
+ {
+ return get_elem( k );
+ }
+
+};
+
+template <class obj_type, class key_type>
+class linearhmap : public hmap<obj_type, key_type>
+{
+public:
+ linearhmap(double moc) : hmap<obj_type, key_type>(moc)
+ {}
+ ;
+
+ virtual int findPos( const key_type &k )
+ {
+ int collisionNum = 0;
+ int currentPos = hash( k ) % hmap<obj_type, key_type>::array.size( );
+ hmap<obj_type, key_type>::lookups++;
+
+ while( hmap<obj_type, key_type>::array[ currentPos ].info != hmap<obj_type, key_type>::EMPTY &&
+ hmap<obj_type, key_type>::array[ currentPos ].key != k )
+ {
+ hmap<obj_type, key_type>::lookups ++;
+ currentPos++;
+
+ if( currentPos >= hmap<obj_type, key_type>::array.size( ) )
+ currentPos -= hmap<obj_type, key_type>::array.size( );
+ }
+
+ return currentPos;
+ }
+};
+
+#include "hmap.cpp"
+
+#endif
diff --git a/src/html.cpp b/src/html.cpp
index f4278ca..23a765a 100644
--- a/src/html.cpp
+++ b/src/html.cpp
@@ -43,6 +43,11 @@ html::clear_cache( )
{
clear();
wrap::system_message( CLRHTML );
+
+#ifdef NCURSES
+
+ print_cached( 0 );
+#endif
}
string
@@ -146,5 +151,18 @@ html::online_list( user *p_user, map<string,string> &map_params )
}
//*>>
+#ifdef NCURSES
+void
+html::print_cached( int i_docs )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_CACHED_DOCS_X, NCUR_CACHED_DOCS_Y, "Docs: %d ", i_docs);
+ refresh();
+}
+
+#endif
+
#endif
diff --git a/src/html.h b/src/html.h
index e14bc55..0a32679 100644
--- a/src/html.h
+++ b/src/html.h
@@ -54,6 +54,11 @@ public:
string parse( map<string,string> &map_params );
void online_list( user *p_user, map<string,string> &map_params ); //<<
+#ifdef NCURSES
+
+ void print_cached( int i_docs );
+#endif
+
};
#endif
diff --git a/src/incl.h b/src/incl.h
index aa54d80..ca59bf3 100644
--- a/src/incl.h
+++ b/src/incl.h
@@ -29,5 +29,9 @@
#include "glob.h"
+#ifdef NCURSES
+#include <ncurses.h>
+#endif
+
#include "msgs.h"
#include "wrap.h"
diff --git a/src/lang.cpp b/src/lang.cpp
new file mode 100644
index 0000000..3477c39
--- /dev/null
+++ b/src/lang.cpp
@@ -0,0 +1,102 @@
+/*:*
+ *: File: ./src/lang.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class conf implementation.
+
+#ifndef s_lang_CXX
+#define s_lang_CXX
+
+#include <fstream>
+#include "lang.h"
+
+using namespace std;
+
+lang::lang( string s_lang = "en" ) : name( s_lang )
+{
+ parse( ); // parse the config file.
+}
+
+lang::~lang()
+{}
+
+void
+lang::parse()
+{
+#ifdef VERBOSE
+ cout << CFILEOK << get_name() << endl;
+#endif
+
+ string filename("lang/");
+ filename.append(get_name());
+
+ ifstream fs_conf( filename.c_str() );
+
+ if ( ! fs_conf )
+ {
+#ifdef VERBOSE
+ cout << CFILENO << get_name() << endl;
+#endif
+
+ return;
+ }
+
+ char c_buf[READBUF];
+
+ while( fs_conf.getline( c_buf, READBUF ) )
+ {
+ string s_token( c_buf );
+ unsigned int ui_pos = s_token.find( "#", 0 );
+
+ // if line is commented out:
+ if ( ui_pos == 0 )
+ continue;
+
+ ui_pos = s_token.find( ";", 0 );
+
+ // if token has not been found.
+ if ( ui_pos == string::npos )
+ continue;
+
+ s_token = s_token.substr( 0 , --ui_pos );
+ ui_pos = s_token.find ( "\"", 0 );
+
+ if ( ui_pos == string::npos )
+ continue;
+
+ string s_val = s_token.substr( ui_pos+1, s_token.length() );
+ string s_key = s_token.substr( 0 , --ui_pos );
+
+#ifdef VERBOSE2
+
+ cout << s_key << "=" << s_val << endl;
+#endif
+
+ // fill the map.
+ map_vals[s_key] = s_val;
+ }
+
+ fs_conf.close();
+ fs_conf.~ifstream();
+}
+
+#endif
diff --git a/src/lang.h b/src/lang.h
new file mode 100644
index 0000000..5c6d428
--- /dev/null
+++ b/src/lang.h
@@ -0,0 +1,47 @@
+/*:*
+ *: File: ./src/lang.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class conf declaration. this class parses the server config file.
+
+#ifndef s_lang_H
+#define s_lang_H
+
+#include "incl.h"
+#include "cont.h"
+#include "name.h"
+
+using namespace std;
+
+class lang : public cont, name
+{
+private:
+
+public:
+ // public methods:
+ lang ( string s_lang ); // standard constructor.
+ ~lang(); // standard destructor.
+
+ virtual void parse( ); // parses the config file.
+};
+
+#endif
diff --git a/src/logd.cpp b/src/logd.cpp
index e67c881..2a5a70e 100644
--- a/src/logd.cpp
+++ b/src/logd.cpp
@@ -105,7 +105,7 @@ logd::flush()
void
logd::log_access( map<string,string> &map_request )
{
- //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.access_lines");
+ //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.accesslines");
string s_time = get_time_string();
string s_logstr = map_request["REMOTE_ADDR"] + " - - "+s_time+" \"" + map_request["QUERY_STRING"]+"\" 200 0 \""+map_request["request"]+"\" \""+map_request["User-Agent"]+"\"\n";
diff --git a/src/main.cpp b/src/main.cpp
index df882a5..33d5aa7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -27,10 +27,6 @@
#include "maps/hashmap.h"
-#ifdef CLI
-#include "cli/cli.h"
-#endif
-
using namespace std;
map<string,string>*
@@ -88,7 +84,6 @@ main(int argc, char* argv[])
cout << tool::ychat_version() << endl
<< DESCRIP << endl
<< DESCRI2 << endl
- << DESCRI3 << endl
<< CONTACT << endl
<< SEPERAT << endl;
@@ -97,7 +92,6 @@ main(int argc, char* argv[])
//<<*
// Initialize database connection queue
#ifdef DATABASE
-
wrap::DATA->init_connections();
#endif
//*>>
diff --git a/src/maps/hashmap.h b/src/maps/hashmap.h
index 0a0535a..e533f42 100644
--- a/src/maps/hashmap.h
+++ b/src/maps/hashmap.h
@@ -30,13 +30,13 @@
using namespace std;
template<class key_type_>
-struct compare_allocator
+struct compare_allocator
{
inline bool operator()(key_type_ t_key_1, key_type_ t_key_2) const;
};
template<class key_type_>
-struct equals_allocator
+struct equals_allocator
{
inline bool operator()(key_type_ t_key_1, key_type_ t_key_2) const;
};
@@ -55,10 +55,10 @@ struct self_hash
template
<
-class obj_type,
-class key_type_ = string,
-class hash_type = size_hash<string>,
-class alloc_type = compare_allocator<string>
+ class obj_type,
+ class key_type_ = string,
+ class hash_type = size_hash<string>,
+ class alloc_type = compare_allocator<string>
>
struct hashmap : public __gnu_cxx::hash_map<key_type_, obj_type, hash_type, alloc_type>
{
@@ -66,7 +66,7 @@ struct hashmap : public __gnu_cxx::hash_map<key_type_, obj_type, hash_type, allo
virtual inline obj_type get_elem(key_type_ t_key);
virtual inline obj_type get_set_elem(obj_type t_obj, key_type_ t_key);
virtual inline obj_type get_or_callback_set
- (obj_type (*func)(void*), void* p_void, key_type_ t_key);
+ (obj_type (*func)(void*), void* p_void, key_type_ t_key);
virtual inline vector<key_type_>* get_key_vector();
virtual inline bool exists(key_type_ t_key);
virtual inline void run_func( void (*func)(obj_type) );
diff --git a/src/maps/nhashmap.h b/src/maps/nhashmap.h
index 6443219..d3afff1 100644
--- a/src/maps/nhashmap.h
+++ b/src/maps/nhashmap.h
@@ -31,10 +31,10 @@ using namespace std;
template
<
-class obj_type,
-class key_type_ = string,
-class hash_type = size_hash<string>,
-class alloc_type = compare_allocator<string>
+ class obj_type,
+ class key_type_ = string,
+ class hash_type = size_hash<string>,
+ class alloc_type = compare_allocator<string>
>
struct nhashmap : public shashmap<obj_type, key_type_, hash_type, alloc_type>
{
diff --git a/src/maps/shashmap.h b/src/maps/shashmap.h
index 445ea77..0dfddc8 100644
--- a/src/maps/shashmap.h
+++ b/src/maps/shashmap.h
@@ -34,13 +34,13 @@ using namespace std;
template
<
-class obj_type,
-class key_type_ = string,
-class hash_type = size_hash<string>,
-class alloc_type = compare_allocator<string>
+ class obj_type,
+ class key_type_ = string,
+ 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
+ public dumpable
{
private:
pthread_mutex_t mut_shashmap;
@@ -54,7 +54,7 @@ public:
virtual inline void set_elem(obj_type t_obj, key_type_ t_key);
virtual inline obj_type get_set_elem(obj_type t_obj, key_type_ t_key);
virtual inline obj_type get_or_callback_set
- (obj_type (*func)(void*), void* p_void, key_type_ t_key);
+ (obj_type (*func)(void*), void* p_void, key_type_ t_key);
virtual inline void add_elem(obj_type t_obj, key_type_ t_key);
virtual inline void add_elem_insecure(obj_type t_obj, key_type_ t_key);
virtual inline obj_type get_elem(key_type_ t_key);
diff --git a/src/memb/memb.h b/src/memb/memb.h
deleted file mode 100644
index 1997750..0000000
--- a/src/memb/memb.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*:*
- *: File: ./src/memb/memb.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#ifndef MEMB_H
-#define MEMB_H
-
-#include "../incl.h"
-#include "../wrap.h"
-#include "../maps/hashmap.h"
-#include "tupel.h"
-
-using namespace std;
-
-template<class obj_type>
-class memb
-{
-private:
- hashmap< 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
deleted file mode 100644
index 37eb2ab..0000000
--- a/src/memb/memb.tmpl
+++ /dev/null
@@ -1,104 +0,0 @@
-/*:*
- *: File: ./src/memb/memb.tmpl
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-
-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)
-{
- mutexed_tupel<obj_type> *p_tupel = map_elems.get_elem(s_key);
- if ( p_tupel )
- return p_tupel->get_elem();
-
- obj_type t_ret;
- return t_ret;
-}
-
-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);
-}
-
-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/modl.cpp b/src/modl.cpp
index f3b1e74..aa7630a 100644
--- a/src/modl.cpp
+++ b/src/modl.cpp
@@ -37,6 +37,10 @@ using namespace std;
modl::modl()
{
+#ifdef NCURSES
+ print_cached( 0 );
+#endif
+
if ( wrap::CONF->get_elem( "httpd.modules.preloadcommands" ).compare( "true" ) == 0 )
preload_modules( wrap::CONF->get_elem("httpd.modules.commandsdir") );
@@ -124,6 +128,11 @@ modl::cache_module( string s_name, bool b_print_sys_msg )
// DO NOT CLOSE AS LONG THERE EXIST A POINTER TO THE FUNCTION
// dlclose( module ); will be called in modl::~modl()!
+#ifdef NCURSES
+
+ print_cached( size() );
+#endif
+
return mod;
}
@@ -154,6 +163,11 @@ modl::unload_modules()
// then clean the hash map.
shashmap<dynmod*>::clear();
+#ifdef NCURSES
+
+ print_cached( size() );
+#endif
+
}
void
@@ -166,4 +180,16 @@ modl::reload_modules()
preload_modules( wrap::CONF->get_elem("httpd.modules.htmldir") );
}
+#ifdef NCURSES
+void
+modl::print_cached( int i_mods )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_CACHED_MODS_X, NCUR_CACHED_MODS_Y, "Mods: %d ", i_mods);
+ refresh();
+}
+#endif
+
#endif
diff --git a/src/modl.h b/src/modl.h
index 2066fa9..adfe5e7 100644
--- a/src/modl.h
+++ b/src/modl.h
@@ -38,6 +38,11 @@ private:
dynmod* cache_module ( string s_name, bool b_print_sys_msg );
void preload_modules( string s_path );
+#ifdef NCURSES
+
+ void print_cached( int i_mods );
+#endif
+
public:
modl();
~modl();
diff --git a/src/mods/Makefile b/src/mods/Makefile
index 7486bc5..1b0712b 100644
--- a/src/mods/Makefile
+++ b/src/mods/Makefile
@@ -1,15 +1,9 @@
-MAKE=gmake
+MAKE=`tail -n 1 ../../make.version`
all: mods
mods:
@${MAKE} -C ./commands #//<<
@${MAKE} -C ./html
clean:
- @for i in commands html; do \
- if [ -f $$i/Makefile ]; then ${MAKE} -C ./$$i clean; \
- fi; done
+ @${MAKE} -C ./commands clean #//<<
+ @${MAKE} -C ./html clean
@if test -d ../../mods; then rm -Rf ../../mods; fi
-mrproper: clean
- @for i in commands html; do \
- if [ -f $$i/Makefile ]; then rm -f $$i/Makefile; \
- fi; done
-
diff --git a/src/mods/Makefile.mods.in b/src/mods/Makefile.mods.in
deleted file mode 100644
index 92a5409..0000000
--- a/src/mods/Makefile.mods.in
+++ /dev/null
@@ -1,19 +0,0 @@
-SRCS=$(shell find ./ -name '*.cpp')
-MODS=$(addprefix ../../../mods/@CATEGORY@/, $(SRCS:.cpp=.so))
-CXX=@CXX@
-CXXFLAGS=@CXXFLAGS@
-all: mods
-${MODS}:
- @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
- @${CXX} ${CXXGLAGS} -shared -s -o $@ ` \
- echo $(notdir $@) | sed s/.so/.cpp/`
- @echo "mods:@CATEGORY@:`basename $@ | sed s/\.so// | sed s/yc_//` (` \
- du -hs $@ | awk '{ print $$1 }'`) "
-infotext:
- @echo "===> Compiling @CATEGORY@ modules"
-mods: infotext ${MODS}
- @echo "===> Num of @CATEGORY@ modules: `ls \
- ../../../mods/@CATEGORY@/*.so | wc -l | sed 's/ //g;'`"
-clean:
- @echo "===> Cleaning @CATEGORY@ modules"
- @if test -d ../../../mods/@CATEGORY@; then rm -Rf ../../../mods/@CATEGORY@; fi
diff --git a/src/mods/commands/Makefile.in b/src/mods/commands/Makefile.in
new file mode 100644
index 0000000..42884b6
--- /dev/null
+++ b/src/mods/commands/Makefile.in
@@ -0,0 +1,18 @@
+MODS=$(addprefix ../../../mods/commands/, $(SRCS:.cpp=.so))
+CC=COMPILER
+INCLUDES=`cat ../../includes.add`
+CFLAGS=`cat ../cflags.add`
+all: mods
+$(MODS):
+ @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
+mods: infotext $(MODS)
+ @echo "Num of command modules: "
+ @ls ../../../mods/commands/*.so | wc -l
+clean:
+ @echo Cleaning command modules
+ @if test -d ../../../mods/commands; then rm -Rf ../../../mods/commands; fi
diff --git a/src/mods/commands/yc_ban.cpp b/src/mods/commands/yc_ban.cpp
deleted file mode 100644
index 03e6470..0000000
--- a/src/mods/commands/yc_ban.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*:*
- *: File: ./src/mods/commands/yc_bannick.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../../chat/user.h"
-#include "../../chat/room.h"
-
-using namespace std;
-
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
-
- user *p_user = (user*) c->elem[1]; // the corresponding user
- vector<string> *params = (vector<string>*) c->elem[2]; // param array
- chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
- conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
- timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
-
- if ( ! params->empty() )
- {
- vector<string>::iterator iter = params->begin();
- string s_bannick_user(*iter);
- //if (string.find(".") != string::npos) {
- //}
-
- bool b_found;
- user* p_bannick_user = p_chat->get_user( s_bannick_user, b_found );
-
- if ( b_found )
- {
- string s_reason = "";
- for ( iter++; iter != params->end(); iter++ )
- s_reason.append( *iter + " " );
-
- bool b_reason = s_reason.length() > 0;
-
- string s_retmsg = p_chat->ban_nick(s_bannick_user, string("( " + p_user->get_colored_name() + (b_reason ? ": " : "") + s_reason + " )"));
- if (!s_retmsg.empty()) {
- string s_msg = "<font color=\"#"
- + p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
- + s_bannick_user + "</b> "
- + p_conf->get_elem("chat.msgs.err.alreadybanned")
- + " " + s_retmsg
- + "</font><br>\n";
-
- p_user->msg_post( &s_msg );
- return 0;
- }
-
- string s_time = "";
- if ( p_conf->get_elem("chat.printalwaystime") == "true" )
- s_time = p_timr->get_time() + " ";
-
- string s_msg = s_time + "<i> " + p_user->get_colored_bold_name() + " " + p_conf->get_elem("chat.msgs.ban") + " "
- + p_bannick_user->get_colored_bold_name();
-
- if (b_reason)
- s_msg.append( " ( " + s_reason + " )");
-
- s_msg.append("</i><br>\n");
-
- p_user->msg_post(s_msg);
- if (! p_user->same_rooms(p_bannick_user) )
- p_bannick_user->msg_post(s_msg);
-
- }
- else
- {
- string s_msg = "<font color=\"#"
- + p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
- + s_bannick_user + "</b> "
- + p_conf->get_elem("chat.msgs.err.notavailable")
- + "</font><br>\n";
-
- p_user->msg_post( &s_msg );
- }
- }
-
- return 0;
- }
-}
-
diff --git a/src/mods/commands/yc_banned.cpp b/src/mods/commands/yc_banned.cpp
deleted file mode 100644
index feeb19c..0000000
--- a/src/mods/commands/yc_banned.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*:*
- *: File: ./src/mods/commands/yc_banned.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../../chat/user.h"
-#include "../../chat/chat.h"
-#include "../../maps/shashmap.h"
-
-using namespace std;
-
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
-
- user *p_user = (user*) c->elem[1];
- chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
- conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
-
- shashmap<string>* map_banned_nicks = p_chat->get_map_banned_nicks();
- string s_msg("");
-
- if ( map_banned_nicks->size() > 0 )
- {
- vector<string>* vec_keys = map_banned_nicks->get_key_vector();
-
- for (vector<string>::iterator iter = vec_keys->begin(); iter != vec_keys->end(); ++iter)
- s_msg.append(*iter + ": " + map_banned_nicks->get_elem(*iter) + "<br>\n");
-
- }
- else
- {
- s_msg = "<font color=\"#"
- + p_conf->get_elem("chat.html.errorcolor")
- + "\">"
- + p_conf->get_elem("chat.msgs.err.nobanned")
- + "</font><br>\n";
- }
-
- p_user->msg_post( &s_msg );
- return 0;
- }
-}
-
diff --git a/src/mods/commands/yc_debug.cpp b/src/mods/commands/yc_debug.cpp
deleted file mode 100644
index 9f770b7..0000000
--- a/src/mods/commands/yc_debug.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*:*
- *: File: ./src/mods/commands/yc_msg.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../../chat/user.h"
-#include "../../chat/room.h"
-/*
- gcc -shared -o yc_name.so yc_name.cpp
-*/
-
-using namespace std;
-
-// THIS MODULE IS FOR DEBUGGING PURPOSE ONLY, IT DOESNT HAVE ANY OTHER USE!
-
-extern "C"
-{
- int valid_color( string );
-
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
-
- user *p_user = (user*) c->elem[1]; // the corresponding user
- vector<string> *params = (vector<string>*) c->elem[2]; // param array
- chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
- sman* p_sman = (sman*) ((dynamic_wrap*)c->elem[3])->SMAN;
-
- if ( ! params->empty() )
- {
- vector<string>::iterator iter = params->begin();
- string s_test_user( *iter );
- bool b_found;
- user* p_whisper_user = p_chat->get_user( s_test_user, b_found );
- sess *p_sess = p_sman->get_elem(p_user->get_tmpid());
-
- string s_msg = "DEBUG-A: " + tool::int2string(reinterpret_cast<int>(p_sess->get_user())) + "<br>";
- p_user->msg_post( &s_msg );
-
- //p_user->debug();
- s_msg = "DEBUG-B: " + tool::int2string(reinterpret_cast<int>(p_sess->get_user())) + "<br>";
- p_user->msg_post( &s_msg );
- }
-
- return 0;
- }
-}
-
diff --git a/src/mods/commands/yc_gag.cpp b/src/mods/commands/yc_gag.cpp
deleted file mode 100644
index e58a22d..0000000
--- a/src/mods/commands/yc_gag.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*:*
- *: File: ./src/mods/commands/yc_gag.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../../chat/user.h"
-#include "../../chat/room.h"
-/*
- gcc -shared -o yc_name.so yc_name.cpp
-*/
-
-using namespace std;
-
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
-
- user *p_user = (user*) c->elem[1]; // the corresponding user
- vector<string> *params = (vector<string>*) c->elem[2]; // param array
- chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
- conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
- timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
-
- if ( ! params->empty() )
- {
- vector<string>::iterator iter = params->begin();
- string s_gag_user(*iter);
- bool b_found;
- user* p_gag_user = p_chat->get_user( s_gag_user, b_found );
-
- if ( b_found )
- {
- string s_time = "";
- if ( p_conf->get_elem("chat.printalwaystime") == "true" )
- s_time = p_timr->get_time() + " ";
-
- string s_reason = "";
- for ( iter++; iter != params->end(); iter++ )
- s_reason.append( *iter + " " );
-
- if ( s_reason.length() > 0 )
- s_reason = " (" + p_user->make_colors(s_reason) + ")";
-
- string s_msg = s_time + "<i> " + p_user->get_colored_bold_name() + " " + p_conf->get_elem("chat.msgs.gag") + " "
- + p_gag_user->get_colored_bold_name() + s_reason + "</i><br>\n";
-
-
- p_user->msg_post(s_msg);
- if (! p_user->same_rooms(p_gag_user) )
- p_gag_user->msg_post(s_msg);
-
- p_gag_user->set_is_gag(true);
-
- }
- else
- {
- string s_msg = "<font color=\"#"
- + p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
- + s_gag_user + "</b> "
- + p_conf->get_elem("chat.msgs.err.notavailable")
- + "</font><br>\n";
-
- p_user->msg_post( &s_msg );
- }
- }
-
- return 0;
- }
-}
-
diff --git a/src/mods/commands/yc_help.cpp b/src/mods/commands/yc_help.cpp
index 7b4ddb9..537e4f7 100644
--- a/src/mods/commands/yc_help.cpp
+++ b/src/mods/commands/yc_help.cpp
@@ -57,7 +57,6 @@ extern "C"
s_msg.append(*iter + " " + p_conf->get_elem("chat.msgs.err.notavailable"));
}
-
else
{
s_msg.append(p_conf->get_elem("chat.msgs.err.wrongcommandusage"));
diff --git a/src/mods/commands/yc_q.cpp b/src/mods/commands/yc_q.cpp
index 5dba617..58422cf 100644
--- a/src/mods/commands/yc_q.cpp
+++ b/src/mods/commands/yc_q.cpp
@@ -41,7 +41,7 @@ extern "C"
conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
- string s_quit = "<script language='JavaScript'>top.location.href='/"
+ string s_quit = "<script confuage=JavaScript>top.location.href='/"
+ p_conf->get_elem("httpd.startsite")
+ "';</script>";
diff --git a/src/mods/commands/yc_ren.cpp b/src/mods/commands/yc_ren.cpp
index 672d378..658ff58 100644
--- a/src/mods/commands/yc_ren.cpp
+++ b/src/mods/commands/yc_ren.cpp
@@ -80,7 +80,7 @@ extern "C"
{
string s_msg = p_timr->get_time() + " "
+ p_user->get_colored_bold_name()
- + p_conf->get_elem( "chat.msgs.us_errorenamesroom" )
+ + p_conf->get_elem( "chat.msgs.userrenamesroom" )
+ "<b>" + s_room + "</b><br>\n";
p_chat->del_elem( p_room->get_lowercase_name() );
diff --git a/src/thrd/thro.cpp b/src/mods/commands/yc_template.cpp
index 1d94540..a49bb69 100644
--- a/src/thrd/thro.cpp
+++ b/src/mods/commands/yc_template.cpp
@@ -1,7 +1,7 @@
/*:*
- *: File: ./src/thrd/thro.cpp
+ *: File: ./src/mods/commands/yc_template.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
*: Copyright (C) 2003 Paul C. Buetow, Volker Richter
*: Copyright (C) 2004 Paul C. Buetow
@@ -22,46 +22,28 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-#ifndef THRO_CPP
-#define THRO_CPP
+#include <iostream>
+#include "../../chat/user.h"
-#include "thro.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
using namespace std;
-thro::thro()
-{}
-
-thro::~thro()
-{}
-
-void
-thro::run()
+extern "C"
{
- void *p_void;
- run( p_void );
-}
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
-void
-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 );
-}
+ user *p_user = (user*)c->elem[1]; // the corresponding user
+ vector<string> *params=(vector<string>*)c->elem[2]; // param array
-void*
-thro::start_( void *p_void )
-{
- elements *e = (elements*) p_void;
- e->p_thro->start( e->p_void );
-}
+ string *quitstring=new string("Text to send<br>");
+ p_user->msg_post( quitstring );
-void
-thro::start( void *p_void )
-{
- wrap::system_message( THRDSTR );
+ return 0;
+ }
}
-#endif
diff --git a/src/mods/commands/yc_unban.cpp b/src/mods/commands/yc_unban.cpp
deleted file mode 100644
index fbe7513..0000000
--- a/src/mods/commands/yc_unban.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*:*
- *: File: ./src/mods/commands/yc_unbannick.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../../chat/user.h"
-#include "../../chat/room.h"
-
-using namespace std;
-
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
-
- user *p_user = (user*) c->elem[1]; // the corresponding user
- vector<string> *params = (vector<string>*) c->elem[2]; // param array
- chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
- conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
- timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
-
- if ( ! params->empty() )
- {
- vector<string>::iterator iter = params->begin();
- string s_unbannick_user(*iter);
-
- string s_reason = p_chat->unban_nick(s_unbannick_user);
- if (s_reason.empty()) {
- string s_msg = "<font color=\"#"
- + p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
- + s_unbannick_user + "</b> "
- + p_conf->get_elem("chat.msgs.err.isnotbanned")
- + "</font><br>\n";
-
- p_user->msg_post( &s_msg );
- return 0;
- }
-
- string s_time = "";
- if ( p_conf->get_elem("chat.printalwaystime") == "true" )
- s_time = p_timr->get_time() + " ";
-
- string s_msg = s_time + "<i> " + p_user->get_colored_bold_name() + " " + p_conf->get_elem("chat.msgs.unban") + " <b>"
- + s_unbannick_user + "</b> " + s_reason + "</i><br>\n";
-
- p_user->msg_post(s_msg);
- }
-
- return 0;
- }
-}
-
diff --git a/src/mods/commands/yc_ungag.cpp b/src/mods/commands/yc_ungag.cpp
deleted file mode 100644
index 6d8c03c..0000000
--- a/src/mods/commands/yc_ungag.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*:*
- *: File: ./src/mods/commands/yc_ungag.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../../chat/user.h"
-#include "../../chat/room.h"
-/*
- gcc -shared -o yc_name.so yc_name.cpp
-*/
-
-using namespace std;
-
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
-
- user *p_user = (user*) c->elem[1]; // the corresponding user
- vector<string> *params = (vector<string>*) c->elem[2]; // param array
- chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
- conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
- timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
-
- if ( ! params->empty() )
- {
- vector<string>::iterator iter = params->begin();
- string s_ungag_user(*iter);
- bool b_found;
- user* p_ungag_user = p_chat->get_user( s_ungag_user, b_found );
-
- if ( b_found )
- {
- string s_time = "";
- if ( p_conf->get_elem("chat.printalwaystime") == "true" )
- s_time = p_timr->get_time() + " ";
-
- string s_reason = "";
- for ( iter++; iter != params->end(); iter++ )
- s_reason.append( *iter + " " );
-
- if ( s_reason.length() > 0 )
- s_reason = " (" + p_user->make_colors(s_reason) + ")";
-
- string s_msg = s_time + "<i> " + p_user->get_colored_bold_name() + " " + p_conf->get_elem("chat.msgs.ungag") + " "
- + p_ungag_user->get_colored_bold_name() + s_reason + "</i><br>\n";
-
-
- p_user->msg_post(s_msg);
- if (! p_user->same_rooms(p_ungag_user) )
- p_ungag_user->msg_post(s_msg);
-
- p_ungag_user->set_is_gag(false);
-
- }
- else
- {
- string s_msg = "<font color=\"#"
- + p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
- + s_ungag_user + "</b> "
- + p_conf->get_elem("chat.msgs.err.notavailable")
- + "</font><br>\n";
-
- p_user->msg_post( &s_msg );
- }
- }
-
- return 0;
- }
-}
-
diff --git a/src/mods/configure b/src/mods/configure
index b90a55a..839380b 100755
--- a/src/mods/configure
+++ b/src/mods/configure
@@ -1,26 +1,26 @@
-#!/bin/sh
-
-if ! test -f ../Makefile; then
- if test $1 != "fromtop"; then
- echo "===> You need to run ./configure of the top level source dir first"
- exit 1
- else
- exit 0
- fi
-fi
+#! /bin/sh
-cxx=`sed -n '/^CXX=/ { s///; p; q; }' ../Makefile`
-cxxflags=`sed -n '/^CXXFLAGS=/ { s///; p; q; }' ../Makefile`
+if ! test -f ../../g++.version
+then
+ echo You need to run ./configure of the top level source dir first
+ exit 1
+fi
+echo Creating module Makefiles...
for dir in commands html
do
- echo "===> Creating $dir module Makefiles"
- cd $dir
- sed -n "s/=@CXXFLAGS@/=$cxxflags/; s/=@CXX@/=$cxx/; s/@CATEGORY@/$dir/g; w Makefile" ../Makefile.mods.in
- for i in *.cpp
- do
- echo "../../../mods/$dir/./`echo $i | sed s/.cpp/.so/`: $i" >> Makefile
- done
- cd ..
+ if test -d $dir
+ then
+ cd $dir &&
+ srcs="SRCS=`ls *.cpp`" &&
+ echo $srcs > Makefile
+ compiler=`tail -n 1 ../../../g++.version`
+ sed s/COMPILER/$compiler/ Makefile.in >> Makefile &&
+ for i in *.cpp
+ do
+ echo "../../../mods/$dir/`echo $i | sed s/.cpp/.so/`: $i" >> Makefile
+ done
+ cd ..
+ fi
done
diff --git a/src/mods/html/Makefile.in b/src/mods/html/Makefile.in
new file mode 100644
index 0000000..4b7c728
--- /dev/null
+++ b/src/mods/html/Makefile.in
@@ -0,0 +1,18 @@
+MODS=$(addprefix ../../../mods/html/, $(SRCS:.cpp=.so))
+CC=COMPILER
+INCLUDES=`cat ../../includes.add`
+CFLAGS=`cat ../cflags.add`
+all: mods
+$(MODS):
+ @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
+mods: infotext $(MODS)
+ @echo "Num of html modules: "
+ @ls ../../../mods/html/*.so | wc -l
+clean:
+ @echo Cleaning html modules
+ @if test -d ../../../mods/html; then rm -Rf ../../../mods/html; fi
diff --git a/src/monitor/dump.cpp b/src/monitor/dump.cpp
index da220f4..e6276f4 100644
--- a/src/monitor/dump.cpp
+++ b/src/monitor/dump.cpp
@@ -32,13 +32,13 @@ using namespace std;
const string dumpable::s_sep = "->";
const int dumpable::i_max_level = 100;
-dumpable::dumpable()
+dumpable::dumpable()
{
initialize(0);
}
void
-dumpable::initialize(int i_level)
+dumpable::initialize(int i_level)
{
this->i_level = i_level;
this->i_lined = i_level;
@@ -48,13 +48,13 @@ dumpable::initialize(int i_level)
}
string
-dumpable::dump()
+dumpable::dump()
{
return dump(0);
}
string
-dumpable::dump(int i_level)
+dumpable::dump(int i_level)
{
initialize(i_level);
dumpit();
@@ -68,31 +68,29 @@ dumpable::add
if ( i_lined > i_max_level )
i_lined = i_max_level;
- if (!b_lined)
+ if (!b_lined)
s_dump.append(s_sep);
- else
- for ( int i = 0; i < i_lined; ++i )
- s_dump.append(" ");
+ else for ( int i = 0; i < i_lined; ++i )
+ s_dump.append(" ");
s_dump.append(s_line);
- if (b_next_no_nl)
+ if (b_next_no_nl)
b_next_no_nl = false;
else
s_dump.append("\n");
- if (!b_lined)
- {
+ if (!b_lined) {
b_lined = true;
i_lined = i_level + s_sep.length();
}
}
int
-dumpable::get_level() const
-{
+dumpable::get_level() const
+{
return i_lined;
}
diff --git a/src/monitor/dump.h b/src/monitor/dump.h
index e1915e7..efb2211 100644
--- a/src/monitor/dump.h
+++ b/src/monitor/dump.h
@@ -39,7 +39,7 @@ private:
string s_dump;
static const string s_sep;
- static const int i_max_level;
+ static const int i_max_level;
virtual void dumpit() = 0;
void initialize(int i_level);
@@ -64,10 +64,8 @@ protected:
(string s_line);
dumpable();
- void next_no_newline()
- {
- b_next_no_nl = true;
- }
+ void next_no_newline()
+ { b_next_no_nl = true; }
public:
string dump();
diff --git a/src/monitor/stats.cpp b/src/monitor/stats.cpp
index c8539ad..3ac55ca 100644
--- a/src/monitor/stats.cpp
+++ b/src/monitor/stats.cpp
@@ -150,6 +150,17 @@ stats::decrement_num_rooms()
pthread_mutex_unlock( &mut_num_rooms );
}
+#ifdef NCURSES
+void
+stats::print_num_rooms()
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_NUM_ROOMS_X, NCUR_NUM_ROOMS_Y, "Rooms: %d", get_num_rooms());
+ refresh();
+}
+#endif
//*>>
#endif
diff --git a/src/monitor/stats.h b/src/monitor/stats.h
index b4dd10a..0b12a82 100644
--- a/src/monitor/stats.h
+++ b/src/monitor/stats.h
@@ -62,6 +62,12 @@ public:
void update_rusage_history();
string get_rusage_history( string s_type, string s_seperator );
long get_ru_maxrss();
+ //<<*
+#ifdef NCURSES
+
+ void print_num_rooms();
+#endif
+ //*>>
};
#endif
diff --git a/src/msgs.h b/src/msgs.h
index 8f64890..3d0494a 100644
--- a/src/msgs.h
+++ b/src/msgs.h
@@ -25,14 +25,11 @@
#ifndef MSGS_H
#define MSGS_H
-#include "build.h"
-
// alphabetical ordered:
#define ACCPERR "Sock: Accept error "
#define BINDERR "Sock: Bind error "
#define CHATREP "Chat: Using replacement strings"
#define CHATDOP "Chat: Default operator login "
-#define CHATFLO "Chat: Flooding ("
#define CFILEOK "Parsing config file"
#define CFILEFA "Failed opening config file!"
#define CONTACT "Contact: http://www.yChat.org, Mail@yChat.org, ICQ: 11655527"
@@ -55,7 +52,6 @@
#define DATANEW "Data: Creating new database connection "
#define DESCRIP "Copyright (C) 2003 Paul C. Buetow, Volker Richter"
#define DESCRI2 "Copyright (C) 2004, 2005 Paul C. Buetow"
-#define DESCRI3 "Copyright (C) 2005 EXA Digital Solutions GbR"
#define DONEMSG "done"
#define DOWNMSG "Shutting down "
#define GARBAGE "Garbage: Initializing collector "
@@ -117,25 +113,18 @@
#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 "
#define SOCKSRV "Sock: Initializing server socket "
#define SOCKERR "Sock: Can't create socket, trying next port "
-#define SOCKER1 "Sock: Can't create socket, aborting"
#define SOCKER2 "Sock: Unknown hostname "
#define SOCKER4 "Sock: Incomplete HTTP request"
#define SOCKRDY "Sock: Server socket is ready "
#define SOCKCAC "Sock: Caching IP "
#define SOCKCA2 "Sock: Cleaning IP cache ("
-#define SOCKUNS "Sock: Starting unsecure transport [HTTP]"
-#ifdef OPENSSL
-#define SSLERR1 "SSL: Can't create socket"
-#define SSLERR2 "SSL: Private key does not match cert. file"
-#define SSLERR3 "SSL: Can't create new SSL context"
-#define SSLERR4 "SSL: Can't create new SSL socket via accept"
-#define SOCKSEC "SSL: Starting secure transport [HTTPS]"
-#endif
#define TECACHE "HTML: Caching document "
#define THRDSTR "Thread: Running"
#define TIMERAT "Timer: User autoaway timeout "
@@ -147,6 +136,11 @@
#define XMLREAD "XML: Reading "
#define XMLERR "XML Error: "
#define XMLER1 "XML Error: Unable to load file "
+#define VERSION "0.7.9.6"
+#define BRANCH "STABLE"
+#define BUILDNR 3810
+#define UNAME "FreeBSD 6.1-RELEASE-p4 i386"
+#define COMPOPT "Using built-in specs.; Configured with: FreeBSD/i386 system compiler; Thread model: posix; gcc version 3.4.4 [FreeBSD] 20050518; 3.4; g++"
#define YCUSAGE "Usage: ./ychat {h|v}|{o confkey confvalue}\n"
#define HEADER1 "HTTP/1.1 200 OK\r\n"
@@ -159,9 +153,6 @@
#define HEADER7 "Content-Length: ";
#define HEADER8 "Content-Type: ";
#define HEADER8b "; charset=ISO-8859-1\r\n";
-#define HEADER9 "";
-//#define HEADER9 "Accept-Ranges: bytes\r\n";
-//#define HEADER9 "Keep-Alive: timeout=15, max=99\r\nLast-Modified: Mon, 19 Dec 2005 23:00:02 GMT\r\nAccept-Ranges: bytes\r\nDate: Tue, 20 Dec 2005 03:30:10 GMT\r\n";
-//#define MEMBERE "Memb: No such member "
+#define HEADER9 "Allow: GET\r\n";
#endif
diff --git a/src/mutx.cpp b/src/mutx.cpp
new file mode 100644
index 0000000..277b193
--- /dev/null
+++ b/src/mutx.cpp
@@ -0,0 +1,43 @@
+/*:*
+ *: File: ./src/mutx.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class mutx implementation.
+
+#ifndef s_mutx_CXX
+#define s_mutx_CXX
+
+#include "mutx.h"
+
+using namespace std;
+
+mutx::mutx()
+{
+ pthread_mutex_init( &mut_stdout, NULL );
+}
+
+mutx::~mutx()
+{
+ pthread_mutex_destroy( &mut_stdout );
+}
+
+#endif
diff --git a/src/mutx.h b/src/mutx.h
new file mode 100644
index 0000000..20d688a
--- /dev/null
+++ b/src/mutx.h
@@ -0,0 +1,44 @@
+/*:*
+ *: File: ./src/mutx.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class mutx declaration.
+
+#ifndef s_mutx_H
+#define s_mutx_H
+
+#include "incl.h"
+
+using namespace std;
+
+class mutx
+{
+public:
+ // this mutex is needed for sync stdout and sdterr of different threads.
+ pthread_mutex_t mut_stdout;
+
+ // public methods.
+ explicit mutx( ); // simple constructor.
+ ~mutx( ); // simple constructor.
+};
+
+#endif
diff --git a/src/ncur/menu.cpp b/src/ncur/menu.cpp
new file mode 100644
index 0000000..f28c4ef
--- /dev/null
+++ b/src/ncur/menu.cpp
@@ -0,0 +1,141 @@
+/*:*
+ *: File: ./src/ncur/menu.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+
+#include "menu.h"
+
+#ifdef NCURSES
+
+#ifndef MENU_CPP
+#define MENU_CPP
+
+using namespace std;
+
+menu::menu( int i_startx, int i_starty, int i_width, int i_height, char *c_header, char **choices, int i_numchoices, const chtype ch )
+{
+ this->i_startx = i_startx;
+ this->i_starty = i_starty;
+ this->i_height = i_height;
+ this->i_width = i_width;
+ this->c_header = c_header;
+ this->choices = choices;
+ this->i_numchoices = i_numchoices;
+
+ initialize( ch );
+}
+
+menu::~menu()
+{
+ /*
+ wborder(win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
+ wrefresh(win);
+ delwin(win);
+ */
+}
+
+void
+menu::initialize( const chtype ch )
+{
+ this->i_highlight = 1;
+ this->i_choice = 0;
+
+ win = newwin( i_height, i_width, i_starty, i_startx );
+ wbkgd(win, ch);
+}
+
+void
+menu::display()
+{
+ int x, y, i;
+
+ x = 2;
+ y = 2;
+
+ box( win, 0, 0 );
+ mvwprintw( win, y++, x, "%s", c_header );
+
+ for( i = 0; i < i_numchoices; i++ )
+ {
+ ++y;
+
+ if( i_highlight == i+1 ) // Highlight the current selection.
+ {
+ wattron( win, A_REVERSE);
+ mvwprintw( win, y, x, "%d. %s", i, choices[i]);
+ wattroff( win, A_REVERSE);
+ } else
+ {
+ mvwprintw( win, y, x, "%d. %s", i, choices[i]);
+ }
+ }
+
+ wrefresh( win );
+}
+
+void
+menu::start( void (*swich_case_menu_action)(int) )
+{
+ refresh();
+ bool b_flag = 1;
+
+ while( b_flag )
+ {
+ keypad(win, 1);
+ display();
+ c = wgetch( win );
+
+ switch(c)
+ {
+ case KEY_UP:
+ if( i_highlight == 1 )
+ i_highlight = i_numchoices;
+ else
+ --i_highlight;
+ break;
+
+ case KEY_DOWN:
+ if( i_highlight == i_numchoices )
+ i_highlight = 1;
+ else
+ ++i_highlight;
+ break;
+
+ case 10:
+ i_choice = i_highlight;
+ break;
+
+ default:
+ mvprintw( NCUR_MENU_CHAR_X, NCUR_MENU_CHAR_Y, "%3d %c ", c, c);
+ refresh();
+ break;
+ }
+
+ // Menu action.
+ ( *swich_case_menu_action ) ( i_choice );
+ i_choice = 0;
+ }
+}
+
+#endif
+#endif
diff --git a/src/ncur/menu.h b/src/ncur/menu.h
new file mode 100644
index 0000000..f0dee8b
--- /dev/null
+++ b/src/ncur/menu.h
@@ -0,0 +1,63 @@
+/*:*
+ *: File: ./src/ncur/menu.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifdef NCURSES
+
+#ifndef MENU_H
+#define MENU_H
+
+#include <ncurses.h>
+
+using namespace std;
+
+class menu
+{
+private:
+ char **choices;
+ char *c_header;
+
+ int i_startx, i_starty, i_width, i_height, i_highlight, i_choice,
+ i_numchoices, c;
+
+ WINDOW *win;
+
+ void initialize( const chtype ch );
+
+public:
+ explicit menu( int i_startx, int i_starty, int i_width, int i_height, char *c_header, char **choices, int i_numchoices, const chtype ch );
+ ~menu( );
+
+ void display();
+ void start( void (*swich_case_menu_action)(int) );
+
+ void activate_menu_win()
+ {
+ keypad(win, 1);
+ }
+};
+
+#endif
+#endif
diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp
new file mode 100644
index 0000000..e97823c
--- /dev/null
+++ b/src/ncur/ncur.cpp
@@ -0,0 +1,314 @@
+/*:*
+ *: File: ./src/ncur/ncur.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef NCUR_CPP
+#define NCUR_CPP
+
+#include "ncur.h"
+
+#ifdef CLI
+#include "../cli/cli.h"
+#endif
+#include "../sign.h"
+
+using namespace std;
+
+#ifdef NCURSES
+
+const string GMAKE_PARAMS[] =
+ { "clean_base", "clean_modules", "all"
+ };
+const int GMAKE_ELEMENTS = 3;
+
+ncur::ncur( )
+{
+ p_messagelist = new list<char*>;
+ pthread_mutex_init( &mut_messages, NULL );
+ pthread_mutex_init( &mut_is_ready, NULL );
+ i_message_length = 45;
+ b_is_ready = false;
+}
+
+ncur::~ncur()
+{
+ pthread_mutex_destroy( &mut_messages );
+ pthread_mutex_destroy( &mut_is_ready );
+}
+
+void
+ncur::start( void *p_void )
+{
+ ncur::init_ncurses();
+
+ char *choices[] = {
+ "Unload all modules ", //<<
+ "Reload all modules ", //<<
+ //>>" ",
+ //>>" ",
+ "Clear template cache ",
+ "Run garbage collector ", //<<
+ //>>" ",
+ "Show max res. set size ",
+ "Compile changed sources ",
+ "Recompile all sources ",
+ "Show source stats ",
+ "Command line interface ",
+ //<<*
+#ifdef DATABASE
+ "Close DB connections ",
+#else
+ " ",
+#endif
+ //*>>
+ //>>" ",
+ "Shut down server"
+ };
+
+ p_serveroutput = newwin( 19, 49, 1, 31 );
+ wbkgd(p_serveroutput, COLOR_PAIR(1));
+
+ box ( p_serveroutput, 0, 0 );
+ mvwprintw( p_serveroutput, 2, 2, NCURMSG );
+ wrefresh ( p_serveroutput );
+
+ print( string("yChat ") + VERSION );
+
+
+ p_menu = new menu( 1, 1, 30, 19, NCURADM, choices, 11, COLOR_PAIR(1));
+
+ mvprintw(NCUR_SERVER_HEADER_X,NCUR_SERVER_HEADER_Y, NCURSE0);
+ mvprintw(NCUR_POOL_HEADER_X,NCUR_POOL_HEADER_Y, NCURSE1);
+ mvprintw(NCUR_DATA_HEADER_X,NCUR_DATA_HEADER_Y, NCURSE2); //<<
+ mvprintw(NCUR_CHAT_HEADER_X,NCUR_CHAT_HEADER_Y, NCURSE3); //<<
+ mvprintw(NCUR_CACHED_HEADER_X,NCUR_CACHED_HEADER_Y, NCURSE4);
+
+ wrap::HTML->print_cached(0);
+
+ is_ready(true);
+ wrap::SMAN->print_init_ncurses(); //<<
+ wrap::STAT->print_num_rooms(); //<<
+
+ p_menu->start( &switch_main_menu_ );
+
+ shutdown();
+}
+
+void
+ncur::shutdown()
+{
+ ncur::close_ncurses();
+}
+
+
+void
+ncur::print( string *p_msg )
+{
+ print( *p_msg );
+}
+
+void
+ncur::print( string s_msg )
+{
+ print( (char*)s_msg.c_str() );
+}
+
+void
+ncur::print( char* c_print )
+{
+ // Removing \n
+ if ( strlen(c_print) > i_message_length )
+ {
+ string s_tmp(c_print);
+ print( s_tmp.substr( 0, i_message_length ) );
+ print( s_tmp.substr( i_message_length, s_tmp.length()-i_message_length ) );
+ return;
+ }
+
+ int i;
+ char* c_temp = new char[i_message_length];
+ memcpy( c_temp, c_print, strlen(c_print) );
+
+ for ( i = strlen(c_print); i < i_message_length; ++i )
+ c_temp[i] = ' ';
+
+ c_temp[i] = '\0';
+
+ pthread_mutex_lock( &mut_messages );
+
+ if ( p_messagelist->size() > 12 )
+ {
+ char* c_front = p_messagelist->front();
+ p_messagelist->pop_front();
+ free(c_front);
+ }
+
+ p_messagelist->push_back( c_temp );
+
+
+ if ( is_ready() )
+ {
+ list<char*>::iterator iter;
+ iter = p_messagelist->begin();
+
+ for ( i = 4; i < 18 && iter != p_messagelist->end(); ++i, ++iter )
+ mvwprintw( p_serveroutput, i, 2, *iter );
+
+ wrefresh ( p_serveroutput );
+ }
+
+ pthread_mutex_unlock( &mut_messages );
+}
+
+void
+ncur::switch_main_menu_( int i_choice )
+{
+ int i;
+
+ if( i_choice != 0 )
+ switch ( i_choice )
+ {
+ //<<*
+ case 1:
+ wrap::MODL->unload_modules();
+ mvprintw( 20,2, "Unloaded all modules ");
+ refresh();
+ break;
+ case 2:
+ wrap::MODL->reload_modules();
+ mvprintw( 20,2, "Reloaded all modules ");
+ refresh();
+ break;
+ //*>>
+ case 3:
+ wrap::HTML->clear_cache();
+ mvprintw( 20,2, "Cleared the template cache ");
+ refresh();
+ break;
+ case 4:
+ //<<*
+ if ( ! wrap::GCOL->remove_garbage() )
+ wrap::NCUR->print( GAROFFNE );
+ mvprintw( 20,2, "Garbage collector activated ");
+ //*>>
+ refresh();
+ break;
+ case 5:
+ mvprintw( 20,2, "Showing max resident set size in memory ");
+ wrap::NCUR->print( STATRSS + string("(") + tool::int2string(
+ wrap::STAT->get_ru_maxrss()) + string(")"));
+ break;
+ case 6:
+ tool::shell_command( string(GMAKE), METH_NCURSES);
+ break;
+ case 7:
+ for ( i = 0; i < GMAKE_ELEMENTS; i++ )
+ tool::shell_command( GMAKE + GMAKE_PARAMS[i], METH_NCURSES);
+ break;
+ case 8:
+ tool::shell_command( string(GMAKE) + " stats", METH_NCURSES);
+ break;
+ case 9:
+#ifdef CLI
+
+ wrap::NCUR->is_ready(false);
+ refresh(); /* Print it on to the real screen */
+
+ def_prog_mode(); /* Save the tty modes */
+ endwin(); /* End curses mode temporarily */
+ 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 */
+ /* Screen contents */
+ wrap::NCUR->is_ready(true);
+ wrap::NCUR->activate_menu_win();
+#else
+
+ mvprintw( 20,2, "CLI mode has not been compiled in! ");
+#endif
+
+ break;
+ case 10:
+#ifdef DATABASE
+
+ wrap::DATA->disconnect_all_connections(); //<<
+#endif
+
+ break;
+
+ case 11: // Shut down server
+ sign::terminate_received(0);
+ break;
+
+ default:
+ mvprintw( 20,2, "Selection # %d not yet implemented!", i_choice-1);
+ wrap::NCUR->print( "Selection not yet implemented!" );
+ refresh();
+ break;
+ }
+}
+
+void
+ncur::init_ncurses()
+{
+ initscr();
+ start_color();
+ clear();
+ noecho();
+ cbreak(); // Line buffering disabled. pass on everything
+ init_pair(1, COLOR_BLACK, COLOR_CYAN);
+ mvprintw( 0,2, (char*)(tool::ychat_version()).c_str());
+ curs_set(0);
+ refresh();
+}
+
+void
+ncur::close_ncurses()
+{
+ refresh();
+ clrtoeol();
+ refresh();
+ endwin();
+}
+
+void
+ncur::is_ready( bool b_is_ready )
+{
+ pthread_mutex_lock( &mut_is_ready );
+ this->b_is_ready = b_is_ready;
+ pthread_mutex_unlock( &mut_is_ready );
+}
+
+bool
+ncur::is_ready()
+{
+ bool b_ret;
+ pthread_mutex_lock( &mut_is_ready );
+ b_ret = b_is_ready;
+ pthread_mutex_unlock( &mut_is_ready );
+ return b_ret;
+}
+
+#endif
+#endif
diff --git a/src/ncur/ncur.h b/src/ncur/ncur.h
new file mode 100644
index 0000000..aa4bba3
--- /dev/null
+++ b/src/ncur/ncur.h
@@ -0,0 +1,75 @@
+/*:*
+ *: File: ./src/ncur/ncur.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifdef NCURSES
+
+#ifndef NCUR_H
+#define NCUR_H
+
+#include <ncurses.h>
+#include <list>
+
+#include "menu.h"
+#include "../thrd/thro.h"
+
+using namespace std;
+
+class ncur : public thro
+{
+private:
+ friend class sign;
+ menu* p_menu;
+ WINDOW* p_serveroutput;
+ list<char*>* p_messagelist; // contains the messages for p_serveroutput!
+ int i_message_length; // the maximum length of a system message!
+ bool b_is_ready; // is set to TRUE if the admin interface is initialized.
+ static void init_ncurses();
+ static void close_ncurses();
+
+ pthread_mutex_t mut_messages;
+ pthread_mutex_t mut_is_ready;
+
+public:
+ ncur();
+ ~ncur();
+
+ void start( void *p_void );
+ void print( char* c_print );
+ void print( string s_msg );
+ void print( string* p_msg );
+ void is_ready( bool b_is_ready );
+ bool is_ready();
+ static void switch_main_menu_( int i_choice );
+ void shutdown();
+
+ void activate_menu_win()
+ {
+ p_menu->activate_menu_win();
+ }
+};
+
+#endif
+#endif
diff --git a/src/pool.cpp b/src/pool.cpp
new file mode 100644
index 0000000..e2e3db2
--- /dev/null
+++ b/src/pool.cpp
@@ -0,0 +1,203 @@
+/*:*
+ *: File: ./src/pool.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef POOL_CPP
+#define POOL_CPP
+
+#include "pool.h"
+
+using namespace std;
+
+pool::pool()
+{
+ pthread_mutex_init(&mut_threads, 0);
+ pthread_mutex_init(&mut_queue_tasks, 0);
+ pthread_mutex_init(&mut_num_avail_threads, 0);
+ pthread_cond_init(&cond_new_task, 0);
+
+ i_num_total_threads = 0;
+ i_num_avail_threads = s_tool::string2int( s_conf::get
+ ().get_val( "THRDPOOL" ) );
+ increase_pool(i_num_avail_threads);
+}
+
+pool::~pool()
+{
+ pthread_mutex_lock(&mut_queue_tasks);
+ while (!queue_tasks.empty())
+ {
+ delete queue_tasks.front();
+ queue_tasks.pop();
+ }
+ pthread_mutex_unlock(&mut_queue_tasks);
+
+ pthread_mutex_destroy(&mut_threads);
+ pthread_mutex_destroy(&mut_queue_tasks);
+ pthread_mutex_destroy(&mut_num_avail_threads);
+ pthread_cond_destroy(&cond_new_task);
+}
+
+int
+pool::increase_pool(int i_num)
+{
+#ifdef VERBOSE
+ pthread_mutex_lock ( &s_mutx::get
+ ().mut_stdout );
+ cout << POOLFLL + s_tool::int2string(i_num) +","+s_tool::int2string(i_num_total_threads)+")" << endl;
+ pthread_mutex_unlock( &s_mutx::get
+ ().mut_stdout );
+#endif
+
+ int i_max_pool_size = s_tool::string2int( s_conf::get
+ ().get_val( "THRDPMAX" ) );
+
+ for ( int i = 0; i < i_num; ++i )
+ {
+ if ( i_max_pool_size != 0 && i_num_total_threads >= i_max_pool_size )
+ {
+#ifdef VERBOSE
+ pthread_mutex_lock ( &s_mutx::get
+ ().mut_stdout );
+ cout << POOLER2+s_tool::int2string(i_max_pool_size)+")" << endl;
+ cout << POOLER1+s_tool::int2string(i)+")" << endl;
+ pthread_mutex_unlock( &s_mutx::get
+ ().mut_stdout );
+#endif
+
+ return i;
+ }
+
+ ++i_num_total_threads;
+ pthread_t p_pthread;
+ pthread_create(&p_pthread, 0, wait_for_task, (void*) this );
+ }
+
+ return i_num;
+}
+
+void
+pool::add_task( void(*p_func)(void*), void* p_void )
+{
+ pthread_mutex_lock(&mut_queue_tasks);
+ queue_tasks.push(new task(p_func, p_void));
+ pthread_mutex_unlock(&mut_queue_tasks);
+
+ pthread_cond_signal(&cond_new_task);
+
+}
+
+void*
+pool::wait_for_task( void* p_void )
+{
+ pool* p_pool = static_cast<pool*>(p_void);
+
+ for (;;)
+ {
+ pthread_mutex_lock(&p_pool->mut_threads);
+ pthread_cond_wait(&p_pool->cond_new_task, &p_pool->mut_threads);
+
+ pthread_mutex_lock(&p_pool->mut_num_avail_threads);
+ if ( --p_pool->i_num_avail_threads < 5 )
+ {
+ int i_size = 9 - p_pool->i_num_avail_threads;
+ i_size = p_pool->increase_pool(i_size);
+ p_pool->i_num_avail_threads += i_size;
+ }
+ pthread_mutex_unlock(&p_pool->mut_num_avail_threads);
+
+ 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_threads);
+
+ (*(p_task->p_func))(p_task->p_void);
+ delete p_task;
+
+ pthread_mutex_lock(&p_pool->mut_num_avail_threads);
+ p_pool->i_num_avail_threads++;
+ pthread_mutex_unlock(&p_pool->mut_num_avail_threads);
+ }
+
+ return 0;
+}
+
+void
+pool::run(void* p_void)
+{
+ add_task(run_func, p_void);
+}
+
+void
+pool::run_func(void *p_void)
+{
+#ifdef VERBOSE
+ pthread_mutex_lock ( &s_mutx::get
+ ().mut_stdout );
+ cout << THREADS << endl;
+ pthread_mutex_unlock( &s_mutx::get
+ ().mut_stdout );
+#endif
+
+ // recasting the client thread object.
+ thrd *t = (thrd*) p_void;
+
+ // start parsing the client request and sending response's back.
+ t-> run ();
+
+ // close the client socket.
+ t->~thrd();
+
+ free(p_void);
+
+#ifdef VERBOSE
+
+ pthread_mutex_lock ( &s_mutx::get
+ ().mut_stdout );
+ cout << THREADE << endl;
+ pthread_mutex_unlock( &s_mutx::get
+ ().mut_stdout );
+#endif
+}
+
+bool
+pool::allow_user_login()
+{
+ pthread_mutex_lock(&mut_num_avail_threads);
+ if ( i_num_avail_threads < 2 )
+ {
+ int i_max_pool_size = s_tool::string2int( s_conf::get
+ ().get_val( "THRDPMAX" ) );
+ if ( i_max_pool_size != 0 && i_max_pool_size == i_num_total_threads )
+ {
+ pthread_mutex_unlock(&mut_num_avail_threads);
+ return false;
+ }
+ }
+ pthread_mutex_unlock(&mut_num_avail_threads);
+
+ return true;
+}
+
+#endif
diff --git a/src/pool.h b/src/pool.h
new file mode 100644
index 0000000..fdb7202
--- /dev/null
+++ b/src/pool.h
@@ -0,0 +1,75 @@
+/*:*
+ *: File: ./src/pool.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "incl.h"
+#include "thrd.h"
+#include "s_tool.h"
+#include "s_conf.h"
+#include "s_mutx.h"
+
+#ifndef POOL_H
+#define POOL_H
+
+#include <queue>
+
+using namespace std;
+
+class pool
+{
+private:
+ struct task
+ {
+ void(*p_func)(void*);
+ void *p_void;
+
+ task(void(*p_func)(void*), void *p_void)
+ {
+ this->p_func = p_func;
+ this->p_void = p_void;
+ }
+ };
+
+ pthread_mutex_t mut_threads;
+ pthread_mutex_t mut_queue_tasks;
+ pthread_mutex_t mut_num_avail_threads;
+ pthread_cond_t cond_new_task;
+
+ int i_num_avail_threads;
+ int i_num_total_threads;
+
+ queue<task*> queue_tasks;
+
+ int increase_pool(int i_num);
+ void add_task( void(*p_func)(void*), void* p_void );
+ static void* wait_for_task(void *p_void);
+ static void run_func(void *p_void);
+
+public:
+ pool();
+ ~pool();
+
+ void run(void* p_void);
+ bool allow_user_login();
+};
+
+#endif
diff --git a/src/build.h b/src/room.cpp
index 9720ae9..841bb12 100644
--- a/src/build.h
+++ b/src/room.cpp
@@ -1,10 +1,9 @@
/*:*
- *: File: ./src/build.h
+ *: File: ./src/room.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
*:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -22,13 +21,19 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-#ifndef BUILD_H
-#define BUILD_H
+// class room implementation.
-#define VERSION "0.8.3"
-#define BRANCH "CURRENT"
-#define BUILDNR 4268
-#define UNAME "Undefined"
-#define COMPOPT "Undefined"
+#ifndef ROOM_CXX
+#define ROOM_CXX
+
+#include "room.h"
+
+using namespace std;
+
+room::room( string s_name ) : name( s_name )
+{}
+
+room::~room()
+{}
#endif
diff --git a/src/room.h b/src/room.h
new file mode 100644
index 0000000..03c0fcd
--- /dev/null
+++ b/src/room.h
@@ -0,0 +1,57 @@
+/*:*
+ *: File: ./src/room.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class room declaration.
+
+#ifndef ROOM_H
+#define ROOM_H
+
+#include "incl.h"
+#include "base.h"
+#include "name.h"
+#include "user.h"
+
+using namespace std;
+
+class room : public base<user>, public name
+{
+private:
+
+public:
+ void add_user( user* p_user )
+ {
+ p_user->set_p_room( this );
+ add_elem( p_user );
+ }
+
+ user* get_user( string &s_name, bool &b_found )
+ {
+ return static_cast<user*>( get_elem( s_name, b_found ) );
+ }
+
+ // public methods:
+ explicit room( string s_name ); // a constructor.
+ ~room(); // room destructor.
+};
+
+#endif
diff --git a/src/s_chat.cpp b/src/s_chat.cpp
new file mode 100644
index 0000000..912907e
--- /dev/null
+++ b/src/s_chat.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_chat.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GCHT_CXX
+#define GCHT_CXX
+
+#include "s_chat.h"
+
+using namespace std;
+
+chat* s_chat::obj;
+
+#endif
diff --git a/src/thrd/thro.h b/src/s_chat.h
index b7dbe1d..c2c0836 100644
--- a/src/thrd/thro.h
+++ b/src/s_chat.h
@@ -1,10 +1,9 @@
/*:*
- *: File: ./src/thrd/thro.h
+ *: File: ./src/s_chat.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
*:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -22,33 +21,30 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-#include "../incl.h"
+#ifndef GCHT_H
+#define GCHT_H
-#ifndef THRO_H
-#define THRO_H
+#include "chat.h"
using namespace std;
-class thro
+class s_chat
{
private:
- pthread_t pthread;
-
- struct elements
- {
- thro *p_thro;
- void *p_void;
- }
- elem;
-
- static void *start_( void *p_void );
+ static chat* obj;
public:
- thro( );
- ~thro( );
- void run();
- void run( void *p_void );
- virtual void start( void *p_void );
+ static void init()
+ {
+ obj = new chat();
+ }
+
+ static chat& get
+ ()
+ {
+ return *obj;
+ }
};
+
#endif
diff --git a/src/s_conf.cpp b/src/s_conf.cpp
new file mode 100644
index 0000000..1c193fe
--- /dev/null
+++ b/src/s_conf.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_conf.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GCON_CXX
+#define GCON_CXX
+
+#include "s_conf.h"
+
+using namespace std;
+
+conf* s_conf::obj;
+
+#endif
diff --git a/src/s_conf.h b/src/s_conf.h
new file mode 100644
index 0000000..8f2b0f7
--- /dev/null
+++ b/src/s_conf.h
@@ -0,0 +1,50 @@
+/*:*
+ *: File: ./src/s_conf.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GCON_H
+#define GCON_H
+
+#include "conf.h"
+
+using namespace std;
+
+class s_conf
+{
+private:
+ static conf* obj;
+
+public:
+ static void init()
+ {
+ obj = new conf( CONFILE );
+ }
+
+ static conf& get
+ ()
+ {
+ return *obj;
+ }
+};
+
+
+#endif
diff --git a/src/s_html.cpp b/src/s_html.cpp
new file mode 100644
index 0000000..b4dfd21
--- /dev/null
+++ b/src/s_html.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_html.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GHTM_CXX
+#define GHTM_CXX
+
+#include "s_html.h"
+
+using namespace std;
+
+html* s_html::obj;
+
+#endif
diff --git a/src/s_html.h b/src/s_html.h
new file mode 100644
index 0000000..6392205
--- /dev/null
+++ b/src/s_html.h
@@ -0,0 +1,50 @@
+/*:*
+ *: File: ./src/s_html.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GHTM_H
+#define GHTM_H
+
+#include "html.h"
+
+using namespace std;
+
+class s_html
+{
+private:
+ static html* obj;
+
+public:
+ static void init()
+ {
+ obj = new html();
+ }
+
+ static html& get
+ ()
+ {
+ return *obj;
+ }
+};
+
+
+#endif
diff --git a/src/s_lang.cpp b/src/s_lang.cpp
new file mode 100644
index 0000000..fda5d2c
--- /dev/null
+++ b/src/s_lang.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_lang.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GCON_CXX
+#define GCON_CXX
+
+#include "s_lang.h"
+
+using namespace std;
+
+lang* s_lang::obj;
+
+#endif
diff --git a/src/s_lang.h b/src/s_lang.h
new file mode 100644
index 0000000..a0700e7
--- /dev/null
+++ b/src/s_lang.h
@@ -0,0 +1,51 @@
+/*:*
+ *: File: ./src/s_lang.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GLANG_H
+#define GLANG_H
+
+#include "lang.h"
+#include "s_conf.h"
+using namespace std;
+
+class s_lang
+{
+private:
+ static lang* obj;
+
+public:
+ static void init()
+ {
+ obj = new lang( s_conf::get
+ ().get_val( "LANGUAGE" ) );
+ }
+
+ static lang& get
+ ()
+ {
+ return *obj;
+ }
+};
+
+
+#endif
diff --git a/src/s_mutx.cpp b/src/s_mutx.cpp
new file mode 100644
index 0000000..74dc252
--- /dev/null
+++ b/src/s_mutx.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_mutx.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GMUT_CXX
+#define GMUT_CXX
+
+#include "s_mutx.h"
+
+using namespace std;
+
+mutx* s_mutx::obj;
+
+#endif
diff --git a/src/s_mutx.h b/src/s_mutx.h
new file mode 100644
index 0000000..d59162a
--- /dev/null
+++ b/src/s_mutx.h
@@ -0,0 +1,50 @@
+/*:*
+ *: File: ./src/s_mutx.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GMUT_H
+#define GMUT_H
+
+#include "mutx.h"
+
+using namespace std;
+
+class s_mutx
+{
+private:
+ static mutx* obj;
+
+public:
+ static void init()
+ {
+ obj = new mutx();
+ }
+
+ static mutx& get
+ ()
+ {
+ return *obj;
+ }
+};
+
+
+#endif
diff --git a/src/s_sman.cpp b/src/s_sman.cpp
new file mode 100644
index 0000000..e75d2be
--- /dev/null
+++ b/src/s_sman.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_sman.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GSMAN_CXX
+#define GSMAN_CXX
+
+#include "s_sman.h"
+
+using namespace std;
+
+sman* s_sman::obj;
+
+#endif
diff --git a/src/s_sman.h b/src/s_sman.h
new file mode 100644
index 0000000..2c019f9
--- /dev/null
+++ b/src/s_sman.h
@@ -0,0 +1,50 @@
+/*:*
+ *: File: ./src/s_sman.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GSMAN_H
+#define GSMAN_H
+
+#include "sman.h"
+
+using namespace std;
+
+class s_sman
+{
+private:
+ static sman* obj;
+
+public:
+ static void init()
+ {
+ obj = new sman();
+ }
+
+ static sman& get
+ ()
+ {
+ return *obj;
+ }
+};
+
+
+#endif
diff --git a/src/s_sock.cpp b/src/s_sock.cpp
new file mode 100644
index 0000000..99ce130
--- /dev/null
+++ b/src/s_sock.cpp
@@ -0,0 +1,33 @@
+/*:*
+ *: File: ./src/s_sock.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GSOC_CXX
+#define GSOC_CXX
+
+#include "s_sock.h"
+
+using namespace std;
+
+sock* s_sock::obj;
+
+#endif
diff --git a/src/s_sock.h b/src/s_sock.h
new file mode 100644
index 0000000..5025597
--- /dev/null
+++ b/src/s_sock.h
@@ -0,0 +1,50 @@
+/*:*
+ *: File: ./src/s_sock.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GSOC_H
+#define GSOC_H
+
+#include "sock.h"
+
+using namespace std;
+
+class s_sock
+{
+private:
+ static sock* obj;
+
+public:
+ static void init()
+ {
+ obj = new sock();
+ }
+
+ static sock& get
+ ()
+ {
+ return *obj;
+ }
+};
+
+
+#endif
diff --git a/src/s_tool.cpp b/src/s_tool.cpp
new file mode 100644
index 0000000..8784d12
--- /dev/null
+++ b/src/s_tool.cpp
@@ -0,0 +1,162 @@
+/*:*
+ *: File: ./src/s_tool.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef s_tool_CXX
+#define s_tool_CXX
+
+#include <ctype.h>
+#include <time.h>
+#include "s_tool.h"
+
+bool
+s_tool::is_alpha_numeric( string &s_digit )
+{
+ auto const char *digit = s_digit.c_str();
+ auto int i_len = strlen( digit );
+
+ for( int i=0; i<i_len; i++ )
+ {
+ if ( ! isalnum( *digit ) )
+ return false;
+ digit++;
+ }
+
+ return true;
+}
+string
+s_tool::trim( string s_str )
+{
+ if(s_str.empty())
+ return "";
+ char c_cur=s_str[0];
+ auto int pos=0;
+ // left trim
+ while(c_cur==' ' || c_cur == '\n' || c_cur == '\r')
+ {
+ s_str.erase(pos,1);
+
+ c_cur=s_str[++pos];
+
+ }
+ // right trim
+
+ pos=s_str.size();
+ c_cur=s_str[s_str.size()];
+
+ while(c_cur==' ' || c_cur == '\n' || c_cur == '\0' || c_cur == '\r')
+ {
+ s_str.erase(pos,1);
+ c_cur=s_str[--pos];
+
+ }
+ return s_str;
+}
+
+string
+s_tool::getExtension( string s_file )
+{
+ int pos = s_file.find_last_of(".");
+ if(pos != string::npos)
+ {
+ string s_ext=s_file.substr(pos+1, s_file.size()-(pos+1));
+ for(int i = 0;i<s_ext.size();i++)
+ s_ext[i]=toupper(s_ext[i]);
+ return s_ext;
+ }
+ return "";
+}
+
+string
+s_tool::int2string( int i_num )
+{
+ char buf[64];
+ sprintf(buf, "%d", i_num);
+ return buf;
+}
+
+int
+s_tool::string2int( string s_digit )
+{
+ auto const char *digit = s_digit.c_str();
+ int result = 0;
+
+ // Convert each digit char and add into result.
+ while (*digit >= '0' && *digit <='9')
+ {
+ result = (result * 10) + (*digit - '0');
+ digit++;
+ }
+
+ // Check that there were no non-digits at end.
+ if (*digit != 0)
+ {
+ return -1;
+ }
+
+ return result;
+}
+
+long
+s_tool::unixtime()
+{
+ return (long) time( NULL );
+}
+
+
+void
+s_tool::strip_html( string *s_str )
+{
+ auto int i_pos;
+
+ if((i_pos=s_str->find("<",0))==string::npos)
+ return;
+ while(true)
+ {
+
+ s_str->replace(i_pos,1,"&lt;");
+
+ if((i_pos=s_str->find("<",0))==string::npos)
+ return;
+
+ }
+}
+
+string
+s_tool::replace( string s_string, string s_search, string s_replace )
+{
+ unsigned i_pos[2];
+
+ for ( i_pos[0] = s_string.find( s_search );
+ i_pos[0] != string::npos;
+ i_pos[0] = s_string.find( s_search, i_pos[1] ) )
+ {
+ s_string.replace( i_pos[0], s_search.length(), s_replace );
+ i_pos[1] = i_pos[0] + s_replace.length();
+ }
+
+ return s_string;
+}
+
+
+
+#endif
diff --git a/src/s_tool.h b/src/s_tool.h
new file mode 100644
index 0000000..7e811e1
--- /dev/null
+++ b/src/s_tool.h
@@ -0,0 +1,44 @@
+/*:*
+ *: File: ./src/s_tool.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef s_tool_H
+#define s_tool_H
+
+#include "incl.h"
+
+using namespace std;
+
+class s_tool
+{
+public:
+ static bool is_alpha_numeric( string &s_digit );
+ static int string2int( string s_digit );
+ static string int2string( int i_num );
+ static string trim( string s_str );
+ static long unixtime();
+ static void strip_html( string *s_str);
+ static string getExtension( string s_file );
+ static string replace( string s_string, string s_search, string s_replace );
+};
+
+#endif
diff --git a/src/memb/tupel.tmpl b/src/sess.cpp
index acc8c40..1b5b1e2 100644
--- a/src/memb/tupel.tmpl
+++ b/src/sess.cpp
@@ -1,10 +1,9 @@
/*:*
- *: File: ./src/memb/tupel.tmpl
+ *: File: ./src/sess.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
*:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -22,40 +21,42 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-template<class obj_type>
-tupel<obj_type>::tupel()
+#ifndef SESS_CPP
+#define SESS_CPP
+
+#include "sess.h"
+
+sess::sess( string s_id )
{
- pthread_mutex_init(&mut_tupel, NULL);
+ this->sess_id=s_id;
}
-template<class obj_type>
-tupel<obj_type>::tupel(obj_type t_obj)
+string sess::getId()
{
- this->t_obj = t_obj;
- pthread_mutex_init(&mut_tupel, NULL);
+ return this->sess_id;
}
-template<class obj_type>
-tupel<obj_type>::~tupel()
+
+void sess::invalidate()
{
- pthread_mutex_destroy(&mut_tupel);
+ this->sess_id="0";
+ this->sess_values.clear();
}
-template<class obj_type>
-obj_type
-tupel<obj_type>::get_elem()
+void sess::setValue( string s_key, void *lpvalue )
{
- pthread_mutex_lock(&mut_tupel);
- obj_type t_ret = t_obj;
- pthread_mutex_unlock(&mut_tupel);
- return t_ret;
+ this->sess_values[s_key]=lpvalue;
}
-
-template<class obj_type>
-void
-tupel<obj_type>::set_elem(obj_type t_obj)
+void *sess::getValue( string s_key )
+{
+ return this->sess_values[s_key];
+}
+string sess::dump()
{
- pthread_mutex_lock(&mut_tupel);
- this->t_obj = t_obj;
- pthread_mutex_unlock(&mut_tupel);
+ string s_ret=string("Session Dump of Session ") + this->getId();
+ map<string, void*>::const_iterator it;
+ for(it=this->sess_values.begin();it!=this->sess_values.end();it++)
+ s_ret=s_ret + "\nkey: " + it->first;
+ return s_ret;
}
+#endif
diff --git a/src/sess.h b/src/sess.h
new file mode 100644
index 0000000..9da7fde
--- /dev/null
+++ b/src/sess.h
@@ -0,0 +1,51 @@
+/*:*
+ *: File: ./src/sess.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef s_sess_H
+#define s_sess_H
+
+#include "incl.h"
+#include "cont.h"
+#include "name.h"
+#include <map>
+#include <string>
+#include "hmap.h"
+using namespace std;
+
+typedef map<string, void *> sess_map;
+
+class sess : public cont, name
+{
+
+private:
+ sess_map sess_values;
+ string sess_id;
+public:
+ sess(string s_id);
+ string getId();
+ void setValue(string s_key, void *lpvalue);
+ void *getValue( string s_key );
+ void invalidate();
+ string dump();
+};
+#endif
diff --git a/src/sman.cpp b/src/sman.cpp
new file mode 100644
index 0000000..ed6bea2
--- /dev/null
+++ b/src/sman.cpp
@@ -0,0 +1,80 @@
+/*:*
+ *: File: ./src/sman.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SMAN_CXX
+#define SMAN_CXX
+
+#include "sman.h"
+
+sman::sman()
+{
+ this->sessions=new hmap<sess *, string>(80);
+ this->sessioncount=0;
+}
+sman::~sman()
+{
+ delete this->sessions;
+}
+
+string sman::generateId( int len )
+{
+ string valid_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
+ string s_ret="";
+ srand(time(0)+160682);
+ for(int i=0;i<len;i++)
+ {
+ int i_char=rand() % 64;
+ s_ret+=valid_chars[i_char];
+ }
+ return s_ret;
+}
+sess *sman::createSession( )
+{
+ string new_id=this->generateId(s_tool::string2int( s_conf::get
+ ().get_val( "SESSION_LENGTH" ) ) );
+
+ sess* p_sess = getSession(new_id);
+
+ // Prove if session id already exists.
+ if (p_sess)
+ return createSession();
+
+ sess *new_sess= new sess( new_id );
+
+ this->sessioncount++;
+ this->sessions->add_elem( new_sess, new_id );
+
+
+ return new_sess;
+}
+
+sess *sman::getSession( string s_id )
+{
+ return this->sessions->get_elem( s_id );
+}
+void sman::destroySession( string s_id )
+{
+ this->sessioncount--;
+ this->sessions->del_elem( s_id );
+}
+#endif
diff --git a/src/sman.h b/src/sman.h
new file mode 100644
index 0000000..3ce0ee9
--- /dev/null
+++ b/src/sman.h
@@ -0,0 +1,59 @@
+/*:*
+ *: File: ./src/sman.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SMAN_H
+#define SMAN_H
+
+#include "incl.h"
+#include "hmap.h"
+#include "sess.h"
+#include "s_tool.h"
+#include "s_conf.h"
+#include <cstdlib>
+
+using namespace std;
+
+class sman
+{
+
+private:
+ hmap<sess *, string> *sessions;
+ string generateId( int len );
+ int sessioncount;
+public:
+ sman();
+ ~sman();
+ sess *getSession( string s_id );
+ int getSessionCount( )
+ {
+ return this->sessioncount;
+ }
+ sess *createSession( );
+ void destroySession( string s_id );
+
+
+};
+
+
+#endif
+
diff --git a/src/sock.cpp b/src/sock.cpp
new file mode 100644
index 0000000..5f85d02
--- /dev/null
+++ b/src/sock.cpp
@@ -0,0 +1,263 @@
+/*:*
+ *: File: ./src/sock.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class sock implementation. the multiplex socket implementation has been token from the
+// GNU C Library Examples and modified in order to fit in here ( POSIX threads etc. ).
+
+#ifndef s_sock_CXX
+#define s_sock_CXX
+
+#include <unistd.h>
+
+#include "sock.h"
+#include "s_chat.h"
+#include "s_conf.h"
+#include "s_mutx.h"
+#include "s_tool.h"
+#include "s_lang.h"
+#include "s_sman.h"
+#include "chat.h"
+#include "user.h"
+
+using namespace std;
+
+sock::sock()
+{
+ this->b_run = true;
+ this->i_req = 0;
+ this->req_parser = new reqp();
+ this->thrd_pool = new pool();
+}
+
+void
+sock::chat_stream( int i_sock, user* p_user, map_string &map_params )
+{
+ string s_msg( "\n" );
+
+ pthread_mutex_lock ( &(p_user->mut_message) );
+
+ for ( int i = 0; i < PUSHSTR; i++ )
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
+
+ do
+ {
+ s_msg = p_user->get_mess( );
+ if ( 0 > send( i_sock, s_msg.c_str(), s_msg.size(), 0 ) )
+ p_user->set_online( false );
+ pthread_cond_wait( &(p_user->cond_message), &(p_user->mut_message) );
+ }
+ while( p_user->get_online() );
+
+ // if there is still a message to send:
+ s_msg = p_user->get_mess( );
+ if ( ! s_msg.empty() )
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
+
+ pthread_mutex_unlock( &(p_user->mut_message) );
+
+ // remove the user from its room.
+ string s_user( p_user->get_name() );
+ p_user->get_p_room()->del_elem( s_user );
+
+ // post the room that the user has left the chat.
+ p_user->get_p_room()->msg_post( new string( p_user->get_name().append( s_lang::get
+ ().get_val( "USERLEAV" ) ) ) );
+ s_sman::get
+ ().destroySession( p_user->get_id() );
+#ifdef VERBOSE
+
+ cout << s_user << " left | SessionCount: " << s_sman::get
+ ().getSessionCount() << endl;
+#endif
+
+ p_user->~user();
+}
+
+int
+sock::make_socket( uint16_t i_port )
+{
+ int sock;
+ struct sockaddr_in name;
+
+ // create the server socket.
+ sock = socket (PF_INET, SOCK_STREAM, 0);
+ if (sock < 0)
+ {
+ cerr << "Sock: socket error" << endl;
+
+ if ( ((int)++i_port) > MAXPORT )
+ exit(-1);
+
+ cerr << SOCKERR << i_port << endl;
+ return make_socket( i_port );
+ }
+
+ // give the server socket a name.
+ name.sin_family = AF_INET;
+ name.sin_port = htons (i_port);
+ name.sin_addr.s_addr = htonl (INADDR_ANY);
+ int optval=1;
+
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(int));
+
+ if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0)
+ {
+ cerr << "Sock: bind error" << endl;
+
+ if ( ++i_port > MAXPORT )
+ exit(-1);
+
+ cout << SOCKERR << i_port << endl;
+ return make_socket( i_port );
+ }
+
+ return sock;
+}
+
+int
+sock::read_write( thrd* p_thrd, int i_sock )
+{
+ char c_req[2048];
+
+ int i_bytes;
+ i_bytes = read (i_sock, c_req, 2048);
+
+ if (i_bytes < 0)
+ {
+ cerr << "Sock: read error " << endl;
+ }
+
+ else
+ {
+ // stores the request params.
+ map_string map_params;
+
+ // get the s_rep ( s_html response which will be send imediatly to the client
+ // and fill map_params with request values.
+ auto string s_temp=(string)c_req;
+ struct sockaddr_in client;
+ size_t size=sizeof(client);
+
+ getpeername( i_sock, (struct sockaddr *)&client, &size);
+
+ map_params["REMOTE_ADDR"]=inet_ntoa(client.sin_addr);
+ map_params["REMOTE_PORT"]=ntohs( client.sin_port);
+
+
+ string s_rep = req_parser->parse( p_thrd, string( c_req ), map_params );
+ send( i_sock, s_rep.c_str(), s_rep.size(), 0 );
+
+ // dont need those vals anymore.
+ map_params.clear();
+
+ return 0;
+ }
+
+ return -1;
+}
+
+int
+sock::start()
+{
+ auto int i_port = s_tool::string2int( s_conf::get
+ ().get_val( "SRVRPORT" ) );
+
+ int sock;
+ fd_set active_fd_set, read_fd_set;
+ int i;
+ struct sockaddr_in clientname;
+ size_t size;
+
+#ifdef VERBOSE
+
+ cout << SOCKCRT << "localhost:" << i_port << endl;
+#endif
+
+ // create the server socket and set it up to accept connections.
+ sock = make_socket ( i_port );
+
+ if (listen (sock, 1) < 0)
+ {
+ cerr << "Sock: listen error" << endl;
+ exit( EXIT_FAILURE );
+ }
+
+#ifdef VERBOSE
+ cout << SOCKRDY << endl;
+#endif
+
+ // initialize the set of active sockets.
+ FD_ZERO (&active_fd_set);
+ FD_SET (sock, &active_fd_set);
+
+ while( b_run )
+ {
+ // block until input arrives on one or more active sockets.
+ read_fd_set = active_fd_set;
+ if (select (FD_SETSIZE, &read_fd_set, NULL, NULL, NULL) < 0)
+ {
+ cerr << "Sock: select error" << endl;
+ exit( EXIT_FAILURE );
+ }
+
+ // service all the sockets with input pending.
+ for ( i = 0; i < FD_SETSIZE; i++ )
+ if ( FD_ISSET (i, &read_fd_set) )
+ {
+ if ( i == sock )
+ {
+ // connection request on original socket.
+ i_req++;
+ int new_sock;
+ size = sizeof (clientname);
+ new_sock = accept (sock,
+ (struct sockaddr *) &clientname,
+ &size);
+
+ if (new_sock < 0)
+ {
+ cerr << "Sock: accept error" << endl;
+ close ( new_sock );
+ }
+
+#ifdef VERBOSE
+ cout << CONNECT << i_req << " "
+ << inet_ntoa( clientname.sin_addr )
+ << ":"
+ << ntohs ( clientname.sin_port )
+ << endl;
+#endif
+
+ FD_SET (new_sock, &active_fd_set);
+ }
+
+ else
+ {
+ thrd_pool->run( (void*) new thrd( i ) );
+ FD_CLR( i, &active_fd_set );
+ }
+ }
+ }
+}
+
+#endif
diff --git a/src/sock.h b/src/sock.h
new file mode 100644
index 0000000..73614bd
--- /dev/null
+++ b/src/sock.h
@@ -0,0 +1,80 @@
+/*:*
+ *: File: ./src/sock.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class sock declaration.
+
+#ifndef s_sock_H
+#define s_sock_H
+
+#include <queue>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include "incl.h"
+#include "pool.h"
+#include "reqp.h"
+#include "thrd.h"
+#include "user.h"
+using namespace std;
+
+class sock
+{
+private:
+ // total number of server requests.
+ unsigned long long int i_req;
+
+ bool b_run; // true while socket manager is running.
+ reqp* req_parser; // parses the http requests from clients.
+ pool* thrd_pool; // the thread pool.
+ // creates a server socket.
+ virtual int make_socket( uint16_t port );
+
+public:
+ // small inline methods:
+ bool get_run() const
+ {
+ return b_run;
+ }
+ bool set_run( bool b_run )
+ {
+ this->b_run = b_run;
+ }
+
+ // public methods.
+ explicit sock( ); // simple constructor.
+ virtual int read_write( thrd* p_thrd, int filedes );
+ virtual int start();
+
+ // the chat stream there all the chat messages will sent through.
+ static void chat_stream( int i_sock, user* p_user, map_string &map_params );
+
+};
+
+#endif
diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp
index 45583e3..0bfd57e 100644
--- a/src/sock/sock.cpp
+++ b/src/sock/sock.cpp
@@ -44,6 +44,7 @@ sock::sock()
this->log_daemon = new logd( wrap::CONF->get_elem( "httpd.logging.accessfile" ),
wrap::CONF->get_elem( "httpd.logging.access_lines" ) );
#endif
+}
this->ip_cache_map = new shashmap
< string, unsigned, self_hash<unsigned>, equals_allocator<unsigned> >;
@@ -545,5 +546,6 @@ sock::clean_ipcache()
SOCKCA2+tool::int2string(i_currentsize)+","+tool::int2string(i_ipcachesize)+")");
}
}
+#endif
#endif
diff --git a/src/sock/sock.h b/src/sock/sock.h
index 5b8db2f..b8ff2c4 100644
--- a/src/sock/sock.h
+++ b/src/sock/sock.h
@@ -28,11 +28,11 @@
#define SOCK_H
#include <queue>
-#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netdb.h>
#include "../reqp.h"
#include "../chat/user.h"
diff --git a/src/sock/sslsock.cpp b/src/sock/sslsock.cpp
deleted file mode 100644
index 494d572..0000000
--- a/src/sock/sslsock.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*:*
- *: File: ./src/sock/sslsock.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../incl.h"
-
-#ifdef OPENSSL
-#ifndef SSLSOCK_CPP
-#define SSLSOCK_CPP
-
-#include "sslsock.h"
-
-using namespace std;
-
-sslsock::sslsock() : sock()
-{
- s_certificate_path = wrap::CONF->get_elem( "httpd.ssl.certificatepath" );
- s_privatekey_path = wrap::CONF->get_elem( "httpd.ssl.privatekeypath" );
- p_ctx = NULL;
-}
-
-int
-sslsock::_send(_socket *p_sock, const char *sz, int len)
-{
- return SSL_write((SSL*)p_sock->p_ssl_context,sz, len);
-}
-
-int
-sslsock::_read(_socket *p_sock, char *sz, int len)
-{
- return SSL_read((SSL*)p_sock->p_ssl_context,sz,len);
-}
-
-int
-sslsock::_close(_socket *p_sock)
-{
- SSL_free((SSL*)p_sock->p_ssl_context);
- sock::_close(p_sock);
-}
-
-int
-sslsock::_make_server_socket(int i_port)
-{
- SSL_METHOD *p_ssl_method;
- unsigned long e;
- char sz[1024];
- string s_error;
-
- int i_sock = sock::_make_server_socket(i_port);
-
- if(i_sock <= 0)
- {
- wrap::system_message(SSLERR1);
- return -1;
- }
-
- SSL_load_error_strings();
- SSLeay_add_ssl_algorithms();
-
- p_ssl_method = SSLv23_server_method();
- p_ctx = SSL_CTX_new (p_ssl_method);
- if (!p_ctx)
- {
- e = ERR_get_error();
- ERR_error_string_n(e, sz, sizeof(sz) - 1);
- s_error = sz;
- wrap::system_message(SSLERR1);
- return -1;
- }
-
- if (SSL_CTX_use_certificate_file(p_ctx, s_certificate_path.c_str(), SSL_FILETYPE_PEM) <= 0)
- {
- e = ERR_get_error();
- ERR_error_string_n(e, sz, sizeof(sz) - 1);
- s_error = sz;
- wrap::system_message(SSLERR1);
- return -1;
- }
-
- if (SSL_CTX_use_PrivateKey_file(p_ctx, s_privatekey_path.c_str(), SSL_FILETYPE_PEM) <= 0)
- {
- e = ERR_get_error();
- ERR_error_string_n(e, sz, sizeof(sz) - 1);
- s_error = sz;
- wrap::system_message(SSLERR1);
- return -1;
- }
-
- if (!SSL_CTX_check_private_key(p_ctx))
- {
- wrap::system_message(SSLERR2);
- return -1;
- }
-
- return i_sock;
-}
-
-void
-sslsock::_main_loop_init()
-{
- wrap::system_message(SOCKSEC);
-}
-
-bool
-sslsock::_main_loop_do_ssl_stuff(int& i_new_sock)
-{
- SSL* p_ssl = SSL_new(p_ctx);
-
- if( p_ssl == NULL || i_new_sock < 0)
- {
- wrap::system_message(SSLERR3);
-
- close(i_new_sock);
- if(p_ssl != NULL)
- SSL_free(p_ssl);
-
- return 1;
- }
-
- else
- {
- SSL_set_fd(p_ssl, i_new_sock);
- if(SSL_accept(p_ssl) == -1)
- {
- wrap::system_message(SSLERR4);
- close(i_new_sock);
- return 1;
- }
-
- map_certs[i_new_sock] = p_ssl;
- }
-
- return 0;
-}
-
-_socket*
-sslsock::_create_container(int &i_sock)
-{
- _socket* p_sock = sock::_create_container(i_sock);
- p_sock->p_ssl_context = map_certs[i_sock];
- return p_sock;
-}
-
-#endif
-#endif
diff --git a/src/sock/sslsock.h b/src/sock/sslsock.h
deleted file mode 100644
index 8be232a..0000000
--- a/src/sock/sslsock.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*:*
- *: File: ./src/sock/sslsock.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "../incl.h"
-
-#ifdef OPENSSL
-#ifndef SSLSOCK_H
-#define SSLSOCK_H
-
-#include "sock.h"
-
-#include <openssl/rsa.h>
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/pem.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-
-using namespace std;
-
-class sslsock : public sock
-{
-private:
- SSL_CTX* p_ctx;
- string s_certificate_path;
- string s_privatekey_path;
- map<int,void*> map_certs;
-
-public:
-
- sslsock( );
- ~sslsock( );
-
- int _send(_socket *p_sock, const char *sz, int len);
- int _read(_socket *p_sock, char *sz, int len);
- int _close(_socket *p_sock);
- void _main_loop_init();
- bool _main_loop_do_ssl_stuff(int &i_new_sock);
- _socket* _create_container(int& i_sock);
- int _make_server_socket(int i_port);
-};
-
-#endif
-#endif
diff --git a/src/thrd.cpp b/src/thrd.cpp
new file mode 100644
index 0000000..6c53393
--- /dev/null
+++ b/src/thrd.cpp
@@ -0,0 +1,52 @@
+/*:*
+ *: File: ./src/thrd.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class thrd implementation.
+
+#ifndef THRD_CXX
+#define THRD_CXX
+
+#include "thrd.h"
+#include "s_sock.h"
+
+using namespace std;
+
+thrd::thrd( int i_sock )
+{
+ this->i_sock = i_sock;
+}
+
+thrd::~thrd()
+{
+ shutdown ( get_sock() , 2 );
+ close ( get_sock() );
+}
+
+void
+thrd::run()
+{
+ s_sock::get
+ ().read_write( this, i_sock );
+}
+
+#endif
diff --git a/src/memb/tupel.h b/src/thrd.h
index f4cc288..3520db2 100644
--- a/src/memb/tupel.h
+++ b/src/thrd.h
@@ -1,10 +1,9 @@
/*:*
- *: File: ./src/memb/tupel.h
+ *: File: ./src/thrd.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
*:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -22,31 +21,32 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-#ifndef TUPEL_H
-#define TUPEL_H
+// class thrd declaration.
-#include "../incl.h"
+#ifndef THRD_H
+#define THRD_H
-#define mutexed_tupel tupel
+#include "incl.h"
using namespace std;
-template<class obj_type>
-class tupel
+class thrd
{
private:
- pthread_mutex_t mut_tupel;
- obj_type t_obj;
+ int i_sock;
public:
- tupel();
- tupel(obj_type t_obj);
- ~tupel();
+ // small inline methods:
+ int get_sock()
+ {
+ return i_sock;
+ }
- inline obj_type get_elem();
- inline void set_elem(obj_type t_obj);
+ // public methods:
+ explicit thrd( int i_sock );
+ ~thrd(); // destructor.
+ virtual void run();
};
-#include "tupel.tmpl"
#endif
diff --git a/src/time/timo.h b/src/time/timo.h
index ad4012e..6fd0a19 100644
--- a/src/time/timo.h
+++ b/src/time/timo.h
@@ -40,7 +40,7 @@ public:
~timo( );
double get_last_activity();
- virtual void renew_timeout();
+ void renew_timeout();
};
#endif
diff --git a/src/time/timr.cpp b/src/time/timr.cpp
index 65ba780..41555af 100644
--- a/src/time/timr.cpp
+++ b/src/time/timr.cpp
@@ -73,6 +73,11 @@ timr::start( void *v_ptr )
{
wrap::system_message( TIMERTH );
+#ifdef NCURSES
+
+ print_time( );
+#endif
+
time_t clock_start;
time_t clock_now;
@@ -94,6 +99,12 @@ timr::start( void *v_ptr )
set_time( difftime( clock_now, clock_start ),
time_now.tm_sec, time_now.tm_min, time_now.tm_hour );
+#ifdef NCURSES
+
+ if (wrap::NCUR->is_ready())
+ print_time( );
+#endif
+
// run every minute:
if ( time_now.tm_sec == 0 )
{
@@ -120,7 +131,7 @@ timr::start( void *v_ptr )
if ( time_now.tm_min % 10 == 0 )
{
- wrap::SOCK->clean_ipcache();
+ wrap::SOCK->clean_ipcache();
// Run every hour
if ( time_now.tm_min % 60 == 0 )
{
@@ -136,6 +147,19 @@ timr::start( void *v_ptr )
}
}
+#ifdef NCURSES
+void
+timr::print_time( )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_TIME_X, NCUR_TIME_Y, "Time: %s ", get_time().c_str());
+ mvprintw( NCUR_UPTIME_X, NCUR_UPTIME_Y, "Uptime: %s ", get_uptime().c_str());
+ refresh();
+}
+#endif
+
void
timr::set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours )
{
diff --git a/src/time/timr.h b/src/time/timr.h
index 0460cba..80fa2eb 100644
--- a/src/time/timr.h
+++ b/src/time/timr.h
@@ -52,6 +52,11 @@ public:
bool get_timer_active() const;
void start( void *v_ptr );
+#ifdef NCURSES
+
+ void print_time();
+#endif
+
void set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours );
string add_zero_to_front( string s_time );
diff --git a/src/tool/tool.cpp b/src/tool/tool.cpp
index 7e793bf..f97dee0 100644
--- a/src/tool/tool.cpp
+++ b/src/tool/tool.cpp
@@ -246,6 +246,9 @@ tool::shell_command( string s_command, method m_method )
switch (m_method)
{
+ case METH_NCURSES:
+ wrap::system_message( clean_char(buf) );
+ break;
default:
s_ret.append("\n" + string(buf));
} // switch
diff --git a/src/user.cpp b/src/user.cpp
new file mode 100644
index 0000000..6ca8cdd
--- /dev/null
+++ b/src/user.cpp
@@ -0,0 +1,167 @@
+/*:*
+ *: File: ./src/user.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class user implementation.
+
+#ifndef USER_CXX
+#define USER_CXX
+
+#include "user.h"
+#include "s_conf.h"
+#include "s_tool.h"
+
+using namespace std;
+
+user::user( string s_name ) : name( s_name )
+{
+ this -> b_online = true;
+ this -> l_time = s_tool::unixtime();
+ this -> s_col1 = s_conf::get
+ ().get_val( "USERCOL1" );
+
+ pthread_mutex_init( &mut_b_online, NULL);
+ pthread_mutex_init( &mut_i_sock , NULL);
+ pthread_mutex_init( &mut_l_time , NULL);
+ pthread_mutex_init( &mut_p_room , NULL);
+ pthread_mutex_init( &mut_s_mess , NULL);
+ pthread_cond_init ( &cond_message, NULL);
+ pthread_mutex_init( &mut_message , NULL);
+}
+
+user::~user()
+{
+ pthread_mutex_destroy( &mut_b_online );
+ pthread_mutex_destroy( &mut_i_sock );
+ pthread_mutex_destroy( &mut_l_time );
+ pthread_mutex_destroy( &mut_p_room );
+ pthread_mutex_destroy( &mut_s_mess );
+ pthread_cond_destroy ( &cond_message );
+ pthread_mutex_destroy( &mut_message );
+}
+
+void
+user::get_data( map_string *p_map_data )
+{
+ string s_req = (*p_map_data)["!get"];
+
+ // get the nick and the color of the user.
+ if ( s_req == "nick" )
+ (*p_map_data)[get_name()] = get_col1();
+}
+
+string
+user::get_mess( )
+{
+ string s_ret( "" );
+ pthread_mutex_lock ( &mut_s_mess );
+ s_ret.append( s_mess );
+ s_mess = *new string("");
+ pthread_mutex_unlock( &mut_s_mess );
+
+ return s_ret;
+}
+
+bool
+user::get_online( )
+{
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_online );
+ b_ret = b_online;
+ pthread_mutex_unlock( &mut_b_online );
+ return b_ret;
+}
+
+void
+user::set_online( bool b_online )
+{
+ pthread_mutex_lock ( &mut_b_online );
+ this -> b_online = b_online;
+ pthread_mutex_unlock( &mut_b_online );
+}
+
+room*
+user::get_p_room( )
+{
+ room* p_return;
+ pthread_mutex_lock ( &mut_p_room );
+ p_return = p_room;
+ pthread_mutex_unlock( &mut_p_room );
+ return p_return;
+}
+
+void
+user::set_p_room( room* p_room )
+{
+ pthread_mutex_lock ( &mut_p_room );
+ this -> p_room = p_room;
+ pthread_mutex_unlock( &mut_p_room );
+}
+
+int
+user::get_sock( )
+{
+ int i_ret;
+ pthread_mutex_lock ( &mut_i_sock );
+ i_ret = i_sock;
+ pthread_mutex_unlock( &mut_i_sock );
+ return i_ret;
+}
+
+void
+user::set_sock( int i_sock )
+{
+ pthread_mutex_lock ( &mut_i_sock );
+ this -> i_sock = i_sock;
+ pthread_mutex_unlock( &mut_i_sock );
+}
+
+void
+user::renew_stamp( )
+{
+ pthread_mutex_lock ( &mut_l_time );
+ l_time = s_tool::unixtime();
+ pthread_mutex_unlock( &mut_l_time );
+}
+
+void
+user::msg_post( string *p_msg )
+{
+ pthread_mutex_lock ( &mut_s_mess );
+ s_mess.append( *p_msg );
+ pthread_mutex_unlock( &mut_s_mess );
+
+ pthread_cond_signal( &cond_message );
+}
+
+void
+user::get_user_list( string &s_list, string &s_seperator )
+{
+ s_list.append( "<font color=\"" )
+ .append( get_col1() )
+ .append( "\">" )
+ .append( get_name() )
+ .append( "</font>\n" )
+ .append( s_seperator );
+
+}
+#endif
diff --git a/src/user.h b/src/user.h
new file mode 100644
index 0000000..9877642
--- /dev/null
+++ b/src/user.h
@@ -0,0 +1,125 @@
+/*:*
+ *: File: ./src/user.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *:
+ *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class user declaration.
+#ifndef USER_H
+#define USER_H
+
+#include "incl.h"
+#include "hmap.h"
+#include "name.h"
+#include "s_lang.h"
+using namespace std;
+
+class room;
+
+class user : public name
+{
+private:
+ // private members:
+ bool b_away; // true if user is away.
+ bool b_online; // true if user is online.
+ int i_sock; // user's stream socket descriptor.
+ long l_time; // user's last activity time.
+ rang r_rang; // user's rang ( see enum rang @ globals.h ).
+ rang r_oldr; // user's previous rang.
+ string s_id;
+ string s_agnt; // user's http user agent.
+ string s_away; // user's last away message.
+ string s_col1; // user's nick color.
+ string s_mess; // message string which has to be sent to the user.
+ room* p_room; // pointer to the user's room.
+
+ pthread_mutex_t mut_b_online;
+ pthread_mutex_t mut_i_sock;
+ pthread_mutex_t mut_l_time;
+ pthread_mutex_t mut_s_mess;
+ pthread_mutex_t mut_p_room;
+
+public:
+ pthread_cond_t cond_message;
+ pthread_mutex_t mut_message;
+
+ // small inline methods:
+ string get_col1() const
+ {
+ return s_col1;
+ }
+ string get_id() const
+ {
+ return s_id;
+ }
+ void set_id ( string s_id )
+ {
+ this -> s_id = s_id;
+ }
+ void set_col1 ( string s_col1 )
+ {
+ this -> s_col1 = s_col1;
+ }
+
+ rang get_rang ( ) const
+ {
+ return r_rang;
+ }
+ void set_rang ( rang r_rang )
+ {
+ r_oldr = this -> r_rang;
+ this -> r_rang = r_rang;
+ }
+
+ bool new_msgs ( )
+ {
+ return s_mess.empty();
+ }
+ // public methods:
+ explicit user( string s_name ); // a standard constructor.
+ ~user(); // user destructor.
+
+ // gets specific data of this user und stores it in
+ // (*p_map_string)["nick"]. this method will be used
+ // every time data has to be got from every user of a room
+ // or even of the system.
+ virtual void get_data( map_string *p_map_data );
+
+ virtual bool get_online();
+ virtual void set_online( bool b_online );
+ virtual room* get_p_room();
+ virtual void set_p_room( room* p_room );
+ virtual int get_sock ( );
+ virtual void set_sock ( int i_sock );
+
+ // gets the message and clears s_mess;
+ virtual string get_mess();
+
+ // actualizes the user's timestamp.
+ virtual void renew_stamp();
+
+ // Here are starting methods which are mainly needed by the data<type> class.
+
+ // appends a string to s_mess including br.
+ virtual void msg_post( string *p_msg );
+ virtual void get_user_list( string &s_list, string &s_seperator );
+};
+
+#endif
diff --git a/src/wrap.cpp b/src/wrap.cpp
index c9f0ea8..ae1c9a2 100644
--- a/src/wrap.cpp
+++ b/src/wrap.cpp
@@ -44,9 +44,13 @@ html* wrap::HTML = NULL;
#ifdef LOGGING
logd* wrap::LOGD = NULL;
#endif
+#ifdef NCURSES
+ncur* wrap::NCUR = NULL;
+#endif
sock* wrap::SOCK = NULL;
stats* wrap::STAT = NULL;
timr* wrap::TIMR = NULL;
+pool* wrap::POOL = NULL;
dynamic_wrap* wrap::WRAP = NULL;
void
@@ -94,10 +98,6 @@ wrap::init_wrapper(map<string,string>* p_main_loop_params)
#ifndef OPENSSL
WRAP->SOCK = SOCK = new sock;
-#else
-
- WRAP->SOCK = SOCK = new sslsock;
-#endif
// create the server socket and set it up to accept connections.
if(SOCK->_make_server_socket ( i_port ) <= 0)
diff --git a/src/wrap.h b/src/wrap.h
index 6ddd3c7..ec56cbe 100644
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -27,11 +27,10 @@
#include "incl.h"
-#ifdef OPENSSL
+
struct socketcontainer
{
int i_sock;
- void *p_ssl_context;
};
#define _socket socketcontainer
#else
@@ -52,24 +51,24 @@ struct socketcontainer
#include "modl.h"
//*>>
+#ifdef NCURSES
+#include "ncur/ncur.h"
+#else
#ifdef CLI
#include "cli/cli.h"
#endif
+#endif
#include "chat/sman.h"
-#ifndef OPENSSL
#include "sock/sock.h"
-#else
-#include "sock/sslsock.h"
-#endif
-
#include "monitor/stats.h"
#include "time/timr.h"
#include "thrd/pool.h"
using namespace std;
+
class dynamic_wrap
{
public:
@@ -91,10 +90,15 @@ public:
logd* LOGD;
#endif
+#ifdef NCURSES
+
+ ncur* NCUR;
+#endif
sock* SOCK;
stats* STAT;
timr* TIMR;
+ pool* POOL;
};
class wrap
@@ -140,6 +144,7 @@ public:
static sock* SOCK;
static stats* STAT;
static timr* TIMR;
+ static pool* POOL;
static dynamic_wrap* WRAP;
};