diff options
| -rwxr-xr-x[-rw-r--r--] | CHAT.cpp | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | CHAT.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | CONF.cpp | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | CONF.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | HTML.cpp | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | HTML.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | MUTX.cpp | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | MUTX.h | 0 | ||||
| -rwxr-xr-x | Makefile | 107 | ||||
| -rwxr-xr-x[-rw-r--r--] | README.txt | 18 | ||||
| -rwxr-xr-x[-rw-r--r--] | SOCK.cpp | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | SOCK.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | TOOL.cpp | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | TOOL.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | base.cpp | 37 | ||||
| -rwxr-xr-x[-rw-r--r--] | base.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | chat.cpp | 30 | ||||
| -rwxr-xr-x[-rw-r--r--] | chat.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | cmnd.cpp | 10 | ||||
| -rwxr-xr-x[-rw-r--r--] | cmnd.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | conf.cpp | 10 | ||||
| -rwxr-xr-x[-rw-r--r--] | conf.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | conf.txt | 3 | ||||
| -rwxr-xr-x[-rw-r--r--] | cont.cpp | 11 | ||||
| -rwxr-xr-x[-rw-r--r--] | cont.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | data.h | 0 | ||||
| -rw-r--r-- | gfx/CVS/Root | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | gfx/y_ani_black.gif | bin | 61100 -> 61100 bytes | |||
| -rwxr-xr-x[-rw-r--r--] | gfx/y_ani_white.gif | bin | 53536 -> 53536 bytes | |||
| -rwxr-xr-x[-rw-r--r--] | glob.h | 10 | ||||
| -rwxr-xr-x[-rw-r--r--] | html.cpp | 26 | ||||
| -rwxr-xr-x[-rw-r--r--] | html.h | 1 | ||||
| -rw-r--r-- | html/CVS/Entries | 10 | ||||
| -rw-r--r-- | html/CVS/Root | 2 | ||||
| -rwxr-xr-x | html/frameset.html | 12 | ||||
| -rwxr-xr-x | html/index.html | 63 | ||||
| -rwxr-xr-x | html/input.html | 48 | ||||
| -rwxr-xr-x | html/notfound.html | 4 | ||||
| -rwxr-xr-x | html/online.html | 18 | ||||
| -rwxr-xr-x | html/stream.html | 43 | ||||
| -rwxr-xr-x[-rw-r--r--] | html/y_ani.gif | bin | 35107 -> 35107 bytes | |||
| -rwxr-xr-x[-rw-r--r--] | incl.h | 1 | ||||
| -rwxr-xr-x[-rw-r--r--] | main.cpp | 6 | ||||
| -rwxr-xr-x[-rw-r--r--] | msgs.h | 11 | ||||
| -rwxr-xr-x[-rw-r--r--] | mutx.cpp | 8 | ||||
| -rwxr-xr-x[-rw-r--r--] | mutx.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | name.cpp | 24 | ||||
| -rwxr-xr-x[-rw-r--r--] | name.h | 0 | ||||
| -rwxr-xr-x | pool.cpp | 46 | ||||
| -rwxr-xr-x[-rw-r--r--] | reqp.cpp | 145 | ||||
| -rwxr-xr-x[-rw-r--r--] | reqp.h | 11 | ||||
| -rwxr-xr-x[-rw-r--r--] | room.cpp | 11 | ||||
| -rwxr-xr-x[-rw-r--r--] | room.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | sock.cpp | 172 | ||||
| -rwxr-xr-x[-rw-r--r--] | sock.h | 18 | ||||
| -rwxr-xr-x[-rw-r--r--] | thrd.cpp | 21 | ||||
| -rwxr-xr-x[-rw-r--r--] | thrd.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | todo.txt | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | user.cpp | 92 | ||||
| -rwxr-xr-x[-rw-r--r--] | user.h | 7 |
60 files changed, 284 insertions, 754 deletions
@@ -1,95 +1,12 @@ -MAKE=`tail -n 1 make.version` -PREFIX=`grep "define PREFIX" src/glob.h | cut -d'"' -f2` -all: version base modules - @echo "Now edit the ychat.conf and run ychat!" - @echo "The config file is searched in the following order:" - @echo " ./ychat.conf " - @echo " ~/.ychat/ychat.conf " - @echo " ./etc/ychat.conf " - @echo " /etc/ychat.conf " - @echo " $(PREFIX)/etc/ychat.conf " - @echo If you want to help the yChat project please run gmake mail - @echo so that the developers receive an email about the platform - @echo being used. - @echo WARNING! This software is EXPERIMENTAL! -mail: - @echo "VERSION:" > mail.tmp - @${MAKE} version >> mail.tmp - @echo >> mail.tmp - @echo "UNAME:" >> mail.tmp - @uname -a >> mail.tmp - @echo >> mail.tmp - @echo "DATE:" >> mail.tmp - @date >> mail.tmp - @echo >> mail.tmp - @echo "COMPILER AND MAKE:" >> mail.tmp - @cat g++.version make.version >> mail.tmp - @cat mail.tmp | mail -s "Successfull build of yChat" successfullbuild@yhttpd.org - @rm -f mail.tmp -install: deinstall -uninstall: deinstall -deinstall: - @echo Install/deinstall is not supported! - @echo Start yChat with ./bin/ychat instead! - @exit 1 -modules: - @if test -d ./src/mods; then ${MAKE} -C ./src/mods; fi -clean_modules: - @if test -d ./src/mods; then ${MAKE} -C ./src/mods clean; fi -base: - @if test -f bin/ychat; then echo "Backing up old binary";if test -f bin/ychat.old; then rm -f bin/ychat.old; fi; mv bin/ychat bin/ychat.old; fi - @perl ./scripts/buildnr.pl - @perl ./scripts/setglobvals.pl - @${MAKE} -C ./src -clean_base: - @${MAKE} -C ./src clean -stats: - @perl scripts/stats.pl -run: - ./bin/ychat -base_start: base - ./bin/ychat -gpl: - @more COPYING -#//<<* -yhttpdbase: - @perl scripts/makeyhttpd.pl || echo "You need to have perl to do this!" - @echo yhttpd code base has been generated in ../yhttpd -#//*>> -clean: clean_base clean_modules -help: - @echo "You may run ${MAKE} with the following parameters:" - @grep "^ ${MAKE} " README - @echo "For more questions read the README file or contact mail@ychat.org!" -setup: - @./configure - @${MAKE} -config: - @sh -c "scripts/config.sh" - @echo If you run ${MAKE} config from the command line then you may need - @echo to rerun ./configure and recompile all now! - -mrproper: clean - @if test -f src/glob.h.org; then mv -f src/glob.h.org src/glob.h;fi - @if test -f g++.version; then rm -f g++.version; fi - @if test -f make.version; then rm -f make.version; fi - @if test -f src/Makefile; then rm -f src/Makefile; fi - @if test -f bin/ychat; then find bin/ -name "*ychat*" | xargs rm -f; fi - @if test -d src/mods; then find src/mods/*/ -name Makefile | xargs rm -f; fi - @find . -name "*.add" | xargs rm -f - @ls | grep core | xargs rm -f -version: - @./scripts/version.sh -debug: - @gdb bin/ychat ychat.core -confdebug: - ./configure -g3 -ggdb -dist: - @./scripts/makedist.sh -ssltest: - openssl genrsa -des3 -out privkey.pem 2048 - openssl req -new -x509 -key privkey.pem -out cert.pem -days 1095 - @mv -f privkey.pem cert.pem etc - - - +SRCS=base.cpp chat.cpp CHAT.cpp cmnd.cpp conf.cpp CONF.cpp cont.cpp html.cpp HTML.cpp main.cpp mutx.cpp MUTX.cpp name.cpp pool.cpp reqp.cpp room.cpp sock.cpp SOCK.cpp thrd.cpp TOOL.cpp user.cpp +OBJS=$(SRCS:.cpp=.o) +CC=c++ +LDFLAGS=-lstdc++ -g +LDADD=-pthread -D_THREAD_SAFE +all: ychat +$(SRCS): + $(CC) $(CFLAGS) -c $*.cpp +ychat: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD) +clean: + rm *.o diff --git a/README.txt b/README.txt index e68c165..af513e8 100644..100755 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ -yChat++; Version Basic 0.1b (030320); Homepage: www.yChat.org -Copyright (C) 2003 Paul C. Buetow ( Snooper@yChat.org, ICQ: 11655527 ) +yChat++; Homepage: www.yChat.org; Version 0.2 +Copyright (C) 2003 Paul C. Buetow, Volker Richter ----------------------------------------------------------------- This program is free software; you can redistribute it and/or @@ -58,6 +58,10 @@ base.cpp - Encapsulates vector fields of room's or user ( may be later main.cpp - This includes the required manager headers for starting the server and finally regulates the correct starting. +pool.cpp - The implementation of the thread pool. all threads are stored + in a queue. Each thread will be reused if the assigned job is + finished. + reqp.cpp - This class implements the http request parser. If a client starts a request to the server the reqp class will be invoked. @@ -163,7 +167,11 @@ chat room user / \ conf html -History of lines of code ( including embedded comments ): +Version Lines of code + 0.1 2402 + 0.2 2377 -Version: Lines: - Basic 0.1b 2402 +New in 0.2: + - POST request now work. + - Thread pool ( pool.cpp ). + - Bugfixes @@ -4,39 +4,20 @@ #define BASE_CPP #include "base.h" -#include "MUTX.h" base::base() { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "base::base()" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_init (&mut_vec_elem, NULL ); } base::~base( ) { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "base::~base( )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_destroy( &mut_vec_elem ); } void base::add_elem( name* p_name ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "base::add_elem( name* )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_lock ( &mut_vec_elem ); vec_elem.push_back ( p_name ); pthread_mutex_unlock( &mut_vec_elem ); @@ -45,12 +26,6 @@ base::add_elem( name* p_name ) bool base::del_elem( string &s_name ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "base::del_elem( \"" << s_name << "\" )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - vector<name*>::iterator iter; pthread_mutex_lock ( &mut_vec_elem ); @@ -73,12 +48,6 @@ base::del_elem( string &s_name ) name* base::get_elem( string &s_name, bool &b_found ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "base:get_elem( \"" << s_name << "\", bool )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - vector<name*>::iterator iter; pthread_mutex_lock ( &mut_vec_elem ); @@ -104,12 +73,6 @@ base::get_elem( string &s_name, bool &b_found ) void base::run_func( void (*func)(name*, void*), void* v_arg ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "base:run_func( void (*func)(name*, void*), void* )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - vector<name*>::iterator iter; pthread_mutex_lock ( &mut_vec_elem ); @@ -11,17 +11,10 @@ using namespace std; chat::chat( ) { -#ifdef VERBOSE - cout << "chat::chat()" << endl; -#endif - } chat::~chat( ) { -#ifdef VERBOSE - cout << "chat::~chat()" << endl; -#endif } user* @@ -34,12 +27,6 @@ chat::get_user( string &s_user ) user* chat::get_user( string &s_user, bool &b_found ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "chat::get_user( " << s_user << ", bool& )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - container param; param.elem[0] = (void*) &s_user ; @@ -56,11 +43,6 @@ chat::get_user( string &s_user, bool &b_found ) void chat::get_user_( name *name_obj, void *v_arg ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "chat::get_user_( name *name_obj, void *v_arg )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif container* param = (container*) v_arg; room *room_obj = static_cast<room*>(name_obj); param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) ); @@ -69,12 +51,6 @@ chat::get_user_( name *name_obj, void *v_arg ) void chat::login( map_string &map_params ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "chat::login( map_params )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - string s_user = map_params["nick"]; // prove if nick is empty @@ -131,12 +107,6 @@ chat::login( map_string &map_params ) void chat::post( user* u_user, map_string &map_params ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "chat::post( user* u_user, map_string &map_params )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - string s_msg( "<font color=\"" ); s_msg.append( u_user->get_col1() ) .append( "\">" ) @@ -10,20 +10,10 @@ using namespace std; cmnd::cmnd( ) { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "cmnd::cmnd( )" << cout; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif } cmnd::~cmnd() { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "cmnd::~cmnd( )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif } #endif @@ -10,26 +10,16 @@ using namespace std; conf::conf( string s_conf = CONFILE ) : name( s_conf ) { -#ifdef VERBOSE - cout << "conf::conf()" << endl; -#endif - parse( ); // parse the config file. } conf::~conf() { -#ifdef VERBOSE - cout << "conf::~conf()" << endl; -#endif } void conf::parse() { -#ifdef VERBOSE_ - cout << "conf::parse()" << endl; -#endif #ifdef _VERBOSE cout << CFILEOK << get_name() << endl; #endif @@ -17,8 +17,9 @@ # server specific configurations ( not allowed to be removed ): HTMLTEMP="html/"; # directory of the html-template files. -THRDPOOL="100"; # thread pool size. every time all threads are used so many new +THRDPOOL="10"; # thread pool size. every time all threads are used so many new # threads will be added to the pool. +THRDQUEU="100"; # length of the thread pool queue. SRVRPORT="2000"; # local port on which the server listens. STRDROOM="Lounge"; # the name of the standard room. @@ -11,11 +11,6 @@ using namespace std; string cont::get_val( string s_key ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "cont::get_val( \"" << s_key << "\" )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif if ( map_vals.find( s_key ) != map_vals.end() ) return map_vals[ s_key ]; return string(); @@ -23,12 +18,6 @@ cont::get_val( string s_key ) cont::~cont() { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "cont::cont()" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - map_vals.~map_string(); } diff --git a/gfx/CVS/Root b/gfx/CVS/Root index 4ab853d..6de547b 100644 --- a/gfx/CVS/Root +++ b/gfx/CVS/Root @@ -1 +1 @@ -:pserver:volker@cvs.exa-ds.com:/home/cvsroot +:pserver:paul@internal.ath.cx:/home/cvsroot diff --git a/gfx/y_ani_black.gif b/gfx/y_ani_black.gif Binary files differindex 06274c2..06274c2 100644..100755 --- a/gfx/y_ani_black.gif +++ b/gfx/y_ani_black.gif diff --git a/gfx/y_ani_white.gif b/gfx/y_ani_white.gif Binary files differindex 168c937..168c937 100644..100755 --- a/gfx/y_ani_white.gif +++ b/gfx/y_ani_white.gif @@ -21,20 +21,10 @@ // max length of a line read from a socket or a file ( config-file, html-template ). #define READBUF 1024 -// if defined for every http request a new thread will be created. otherwise only for the -// chat streams extra threads will be created. THRDMOD2 DOES NOT WORK RIGHT NOW!! SO -// LET THIS DEFINE UNTOUCHED! BUGFIX WILL FOLLOW! -#define THRDMOD - // definition for verbosity level 0 ( normal outputs ). see vmsg.h for custumizing all // the messages. this messages will only printed out by the master thread. #define _VERBOSE -// definition for verbosity level 1 ( constructors and destructors which are not inline ). -//#define VERBOSE - -// definition for verbosity level 2 ( all methods which are not inline except VERBOSE 1 ). -//#define VERBOSE_ ////////////////////////////////////////////////////////////////////////////////////////// // DO NOT CHANGE ANYTHING BEHIND THIS LINE! @@ -12,25 +12,12 @@ using namespace std; html::html( ) { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "html::html()" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - set_name( CONF::get().get_val( "HTMLTEMP" ) ); - pthread_mutex_init( &mut_map_vals, NULL ); } html::~html( ) { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "html::~html()" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_destroy( &mut_map_vals ); } @@ -45,13 +32,6 @@ html::clear_cache( ) string html::parse( map_string &map_params ) { - -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "html::parse( map_string& )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - string s_file = map_params["request"]; // check if s_file is in the container. @@ -132,12 +112,6 @@ html::parse( map_string &map_params ) void html::online_list( user *p_user, map_string &map_params ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "html::online_list( user*, map_string& )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - // prepare user_list. string s_list ( "" ); string s_seperator( "<br>" ); @@ -9,6 +9,7 @@ #include "user.h" #include "name.h" + using namespace std; class html : public cont, name diff --git a/html/CVS/Entries b/html/CVS/Entries index 12eb550..6738646 100644 --- a/html/CVS/Entries +++ b/html/CVS/Entries @@ -1,11 +1,9 @@ /blank.html/1.1.1.1/Fri Mar 21 15:54:56 2003// /frameset.html/1.1.1.1/Fri Mar 21 15:54:56 2003// -/index.html/1.4/Sun Mar 30 00:34:08 2003// -/input.html/1.2/Sun Mar 30 00:34:08 2003// +/index.html/1.2/Sun Mar 23 19:03:13 2003// +/input.html/1.1.1.1/Fri Mar 21 15:54:56 2003// /notfound.html/1.1.1.1/Fri Mar 21 15:54:56 2003// -/online.html/1.2/Sun Mar 30 00:34:08 2003// -/stream.html/1.2/Sun Mar 30 00:34:08 2003// -/style.css/1.1/Sun Mar 30 11:12:49 2003// +/online.html/1.1.1.1/Fri Mar 21 15:54:56 2003// +/stream.html/1.1.1.1/Fri Mar 21 15:54:56 2003// /y_ani.gif/1.1.1.1/Fri Mar 21 15:54:56 2003// -/y_black.gif/1.1/Sun Mar 30 11:12:49 2003/-kb/ D diff --git a/html/CVS/Root b/html/CVS/Root index 4ab853d..6de547b 100644 --- a/html/CVS/Root +++ b/html/CVS/Root @@ -1 +1 @@ -:pserver:volker@cvs.exa-ds.com:/home/cvsroot +:pserver:paul@internal.ath.cx:/home/cvsroot diff --git a/html/frameset.html b/html/frameset.html index 672f8fa..fe6b973 100755 --- a/html/frameset.html +++ b/html/frameset.html @@ -1,21 +1,19 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%ychat.version%% + %%PGETITLE%% </title> </head> - <frameset boders="0" rows="*,70"> + <frameset rows="*,60"> <noframes> Your browser does not support frames, </noframes> <frameset cols="*,150"> - <frame src="stream.html?event=stream&tmpid=%%tmpid%%" name="stream"> - <frame src="online.html?event=online&tmpid=%%tmpid%%" name="online"> + <frame src="stream.html?event=stream&nick=%%nick%%&tmpid=%%tmpid%%" name="stream"> + <frame src="online.html?event=online&nick=%%nick%%&tmpid=%%tmpid%%" name="online"> </frameset> <frameset rows="*,0"> - <frame src="input.html?event=input&tmpid=%%tmpid%%" name="input"> + <frame src="input.html?event=input&nick=%%nick%%&tmpid=%%tmpid%%" name="input"> <frame src="blank.html" name="blank"> </frameset> </frameset> diff --git a/html/index.html b/html/index.html index 983e7ef..172c851 100755 --- a/html/index.html +++ b/html/index.html @@ -1,54 +1,31 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> -<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title> - %%ychat.version%% + |
