diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:46 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:46 +0200 |
| commit | 07706f56cd421bf8b101a5c0fe44674d36e161a0 (patch) | |
| tree | bec8b45765788370fbd148d68e05d8b437e60670 | |
| parent | 56187184e11b085b82584d3b088c62f427aae83c (diff) | |
tagging ychat-0.5.1ychat-0.5.1
| -rw-r--r--[-rwxr-xr-x] | COPYING | 1 | ||||
| -rw-r--r-- | ChangeLog | 484 | ||||
| -rwxr-xr-x | Makefile.in | 2 | ||||
| -rwxr-xr-x | README | 318 | ||||
| -rwxr-xr-x | base.cpp | 97 | ||||
| -rwxr-xr-x | base.h | 61 | ||||
| -rwxr-xr-x | chat.cpp | 80 | ||||
| -rwxr-xr-x | chat.h | 16 | ||||
| -rwxr-xr-x | cmnd.cpp | 2 | ||||
| -rw-r--r-- | cmnd/yc_getrusage.cpp | 51 | ||||
| -rwxr-xr-x | conf.cpp | 10 | ||||
| -rwxr-xr-x | conf.h | 4 | ||||
| -rwxr-xr-x | conf.txt | 46 | ||||
| -rwxr-xr-x | configure | 1618 | ||||
| -rwxr-xr-x | cont.cpp | 2 | ||||
| -rwxr-xr-x | cont.h | 1 | ||||
| -rwxr-xr-x | glob.h | 14 | ||||
| -rw-r--r-- | hmap.cpp | 9 | ||||
| -rw-r--r-- | hmap.h | 6 | ||||
| -rwxr-xr-x | html.cpp | 40 | ||||
| -rwxr-xr-x | html.h | 6 | ||||
| -rw-r--r--[-rwxr-xr-x] | html/favicon.ico | bin | 2238 -> 2238 bytes | |||
| -rwxr-xr-x | html/frameset.html | 12 | ||||
| -rwxr-xr-x | html/index.html | 21 | ||||
| -rwxr-xr-x | html/input.html | 52 | ||||
| -rwxr-xr-x | html/notfound.html | 4 | ||||
| -rwxr-xr-x | html/online.html | 21 | ||||
| -rwxr-xr-x | html/stream.html | 42 | ||||
| -rw-r--r--[-rwxr-xr-x] | html/style.css | 0 | ||||
| -rwxr-xr-x | main.cpp | 48 | ||||
| -rwxr-xr-x | msgs.h | 12 | ||||
| -rwxr-xr-x | mutx.cpp | 4 | ||||
| -rwxr-xr-x | mutx.h | 4 | ||||
| -rwxr-xr-x | name.cpp | 2 | ||||
| -rwxr-xr-x | name.h | 4 | ||||
| -rwxr-xr-x | pool.cpp | 48 | ||||
| -rwxr-xr-x | reqp.cpp | 113 | ||||
| -rwxr-xr-x | reqp.h | 6 | ||||
| -rwxr-xr-x | room.h | 4 | ||||
| -rw-r--r-- | s_conf.h | 2 | ||||
| -rw-r--r-- | s_tool.cpp | 28 | ||||
| -rw-r--r-- | s_tool.h | 1 | ||||
| -rwxr-xr-x | sock.cpp | 70 | ||||
| -rwxr-xr-x | sock.h | 16 | ||||
| -rwxr-xr-x | thrd.cpp | 5 | ||||
| -rwxr-xr-x | todo.txt | 14 | ||||
| -rwxr-xr-x | user.cpp | 37 | ||||
| -rwxr-xr-x | user.h | 15 |
48 files changed, 2831 insertions, 622 deletions
@@ -106,6 +106,7 @@ above, provided that you also meet all of these conditions: announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..b3ada67 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,484 @@ +2003-09-14 16:55 snooper + + * cmnd/yc_version.cpp: Added /version command. + +2003-09-14 16:48 snooper + + * README, msgs.h: Changed Version to 0.5 ( Will be released as soon + as possible ). + +2003-09-14 16:34 snooper + + * msgs.h: Changed version description. + +2003-09-14 16:31 snooper + + * README, conf.txt, glob.h, reqp.cpp, sock.cpp, cmnd/compile.sh: + Fixed all known bugs which already have been fixed in yChat++ + Advanced. + +2003-09-13 20:52 snooper + + * gfx/y_ani_black.gif, gfx/y_ani_white.gif, html/favicon.ico: [no + log message] + +2003-09-07 14:49 snooper + + * pool.cpp: + Removed a pthread_cond_signal which has been set twice! + +2003-09-06 23:34 rover + + * pool.cpp: fixed a typo ( multi thread bug ) + +2003-09-03 18:30 rover + + * reqp.cpp: modified End-Of-Headers to RFC compliant version + +2003-07-26 14:30 snooper + + * reqp.cpp: Added Pragma: no-cache and Expires: 0 to the HTTP + header. ( this is a bugfix ). + +2003-04-19 21:39 rover + + * chat.cpp, reqp.cpp, sess.cpp, sess.h, sman.h, sock.cpp, user.h: + identification now only depends on session + +2003-04-19 18:16 rover + + * Makefile.in, chat.cpp, chat.h, conf.txt, main.cpp, s_sman.cpp, + sess.cpp, sman.cpp, s_sman.h, sess.h, sman.h: added session + manager and session object. + +2003-04-10 17:36 rover + + * logd.cpp: fixed a typo + +2003-04-07 15:24 rover + + * hmap.cpp: added a really really important newline ( this is just + a loginfo test ) + +2003-04-07 15:18 rover + + * msgs.h: message templates are now replaced by language manager + +2003-04-05 00:17 rover + + * Makefile.in: language support + +2003-04-05 00:14 rover + + * chat.cpp, chat.h, conf.txt, lang.cpp, lang.h, main.cpp, + s_lang.cpp, s_lang.h, sock.cpp, user.cpp, user.h, lang/de, + lang/en: support for different languages in chat output + +2003-04-04 23:35 rover + + * conf.cpp, conf.txt, glob.h, s_conf.h, sock.cpp: another bug that + was caused due sed conversion + +2003-04-04 17:42 rover + + * Makefile.in: added log_daemon + +2003-04-04 17:19 rover + + * conf.txt, logd.cpp, logd.h, reqp.cpp, reqp.h, sock.cpp, sock.h: + added access log compatible logging + +2003-04-04 13:13 rover + + * sock.cpp: added IP / PORT to map_params to make logging possible + with only this map + +2003-04-04 12:41 rover + + * s_tool.cpp, s_tool.h: added trim() function to strip whitespaces + at the beginning and end of a string + +2003-04-04 12:40 rover + + * reqp.cpp, reqp.h: http headers are now stored in the requestmap + +2003-04-03 01:01 snooper + + * s_modl.cpp, s_modl.h, user.h: Minor modifications. New static + class wrapper. + +2003-04-02 23:57 snooper + + * Makefile.in, chat.h, conf.txt, main.cpp, modl.cpp, sock.cpp, + user.cpp, user.h, cmnd/yc_q.cpp: Added first command. /q ... + Todo: each user should have his own hashmap of executable + modules. Right now all users use the same module hash map. + +2003-04-02 15:23 rover + + * modl.cpp, modl.h: module loader + +2003-04-02 12:52 snooper + + * dltest.cpp, yc_test.cpp, cmnd/yc_q.cpp, cmnd/yc_test.cpp: [no log + message] + +2003-04-02 12:50 snooper + + * Makefile.in, README, base.cpp, base.h, chat.cpp, chat.h, + conf.cpp, dltest.cpp, glob.h, hmap.cpp, hmap.h, html.cpp, msgs.h, + reqp.cpp, reqp.h, sock.cpp: Dynamic module loader class. Better + hash map functionality. Some bugfixes. + +2003-03-30 15:40 paul + + * hmap.h: + Implementation of operator[]. + +2003-03-30 13:12 volker + + * html/: style.css, y_black.gif: added stylesheet and an image + +2003-03-30 03:48 paul + + * todo.txt: [no log message] + +2003-03-30 03:35 paul + + * base.cpp, conf.txt, hmap.cpp, hmap.h: The hach map now supports + explicit key bindings on each value. The [] operator still has to + be implemented. + +2003-03-30 01:34 volker + + * conf.txt, html/index.html, html/input.html, html/online.html, + html/stream.html: modified appearance and added css + +2003-03-30 01:26 paul + + * README, README.txt, cont.h: Renamed. + +2003-03-30 01:14 paul + + * base.cpp, base.h, hmap.cpp, hmap.h: All user objects and all room + objects are stored in a hash map. + +2003-03-30 01:06 volker + + * conf.txt, reqp.cpp, reqp.h, s_tool.cpp, s_tool.h: support for + different content-types + +2003-03-30 00:21 paul + + * hmap.cpp, hmap.h, main.cpp: Now handles pointer of data objects + instead of references. + +2003-03-30 00:18 volker + + * html.cpp: removed possible deadlock + +2003-03-30 00:11 volker + + * conf.txt, html.cpp: changed format how files are read into + templatecache + +2003-03-28 17:16 volker + + * todo.txt: todo is now up to date + +2003-03-28 03:51 paul + + * data.h: + + Removed data.h + +2003-03-28 03:51 paul + + * README.txt, base.h, chat.h, data.h, room.h: + + Put data.h and base.h together. + +2003-03-28 03:08 paul + + * README.txt: + + Actualizing because of the new configure script. + +2003-03-28 03:02 volker + + * configure, configure.in: [no log message] + +2003-03-28 02:59 volker + + * configure, configure.in: -ldl is not needed under *bsd. Added a + check + +2003-03-28 02:38 volker + + * Makefile, Makefile.in, configure, configure.in: added support for + bsd + +2003-03-28 01:38 volker + + * base.cpp: changed a bug in cvs keywords + +2003-03-28 01:32 volker + + * base.cpp: [no log message] + +2003-03-28 01:27 volker + + * COPYING, configure.in: this file should be in every repository ;) + +2003-03-28 01:18 volker + + * Makefile, Makefile.in, configure, configure.in: configure + dependent files + +2003-03-28 00:22 paul + + * hmap.cpp, hmap.h: + + Optimization of the hash map. + +2003-03-27 17:14 volker + + * dltest.cpp, yc_test.cpp: Dynamic module test + +2003-03-26 18:50 paul + + * html/index.html: + + Changed POST back to GET due read bug. + +2003-03-26 17:40 paul + + * reqp.cpp: + + Bugfix. + +2003-03-26 16:44 paul + + * reqp.cpp, sock.cpp, sock.h: + + Fixed segfault bug. ( stream.html request without existing user + object ). + +2003-03-26 16:17 paul + + * sock.cpp: + + Deletion of variables which are no longer needed after procession + ( e.g. map_params ). + +2003-03-26 15:57 paul + + * thrd.cpp: + + Bugfix. Now every socket connection will be closed the right way + ;). + +2003-03-26 00:03 paul + + * chat.cpp, chat.h, sock.cpp: + + Bugfix + added to the class chat a private bool b_strip_html + member. + +2003-03-25 23:52 paul + + * chat.cpp: + + Style fix. + +2003-03-25 23:41 paul + + * msgs.h, sock.cpp: + + Bugfix. + +2003-03-25 23:21 paul + + * name.h: + + Bugfix. + +2003-03-25 23:19 paul + + * Makefile, README.txt, base.cpp, base.h, conf.txt, data.h, + hmap.cpp, hmap.h, name.cpp, name.h: + + Changed because of hashmap integration. base.cpp and base.h still + have to be modified. Afterwards, all user and rooms will be + stored in a hash map. + +2003-03-25 21:06 paul + + * Makefile, hmap.cpp, hmap.h, user.h: + + Hash Map implementation. + +2003-03-25 20:12 volker + + * chat.cpp, conf.txt, s_tool.cpp, s_tool.h: added possibility to + turn html tags on/off in chat messages + +2003-03-25 19:53 paul + + * conf.txt, html.cpp: + + Bugfix. + +2003-03-25 18:44 paul + + * conf.txt: + + Bugfix. + +2003-03-25 17:22 volker + + * conf.txt, main.cpp: removed some typos that where created due to + sed conversation + +2003-03-25 15:54 volker + + * CHAT.cpp, CHAT.h, CONF.cpp, CONF.h, HTML.cpp, HTML.h, MUTX.cpp, + MUTX.h, Makefile, README.txt, SOCK.cpp, SOCK.h, TOOL.cpp, TOOL.h, + chat.cpp, chat.h, cmnd.cpp, conf.cpp, conf.h, conf.txt, cont.cpp, + data.h, glob.h, html.cpp, html.h, main.cpp, msgs.h, mutx.cpp, + mutx.h, pool.cpp, reqp.cpp, s_chat.cpp, s_chat.h, s_conf.cpp, + s_conf.h, s_html.cpp, s_html.h, s_mutx.cpp, s_mutx.h, s_sock.cpp, + s_sock.h, s_tool.cpp, s_tool.h, sock.cpp, sock.h, thrd.cpp, + user.cpp: changed filenames to windows compatible ones + +2003-03-25 00:49 paul + + * README.txt: + + Bugfixes. + +2003-03-25 00:40 paul + + * todo.txt: + + New brainstorming. + +2003-03-25 00:16 paul + + * TOOL.cpp, TOOL.h, chat.cpp, msgs.h: + + Added check routine if a login nick is alphanumeric or not. If + not a message will appear on the startpage instead of logging in + which may would end in a segmentation fault. + +2003-03-24 23:45 paul + + * main.cpp: [no log message] + +2003-03-24 23:43 paul + + * README.txt, chat.cpp, msgs.h, user.cpp, user.h: + + Added support for chat commands ( chat commands still have to be + implemented ). If you type "/testhere" ychat will tell that + there is no such command! + +2003-03-24 00:30 paul + + * Makefile, cmnd.cpp, main.cpp, msgs.h, reqp.cpp, reqp.h, sock.cpp, + sock.h, thrd.cpp, user.cpp, user.h: [no log message] + +2003-03-23 23:34 vrichter + + * reqp.cpp: removed bogus sock.h + +2003-03-23 23:29 vrichter + + * reqp.cpp, sock.cpp: bugfix POST system + +2003-03-23 20:03 vrichter + + * html/index.html: changed the method of the login form to POST + +2003-03-23 20:02 vrichter + + * reqp.cpp, reqp.h: the request parser now supports POST + +2003-03-23 16:16 paul + + * pool.cpp: + + Fixed changing date! ( System clock was set wrong ), + +2003-03-23 16:05 paul + + * pool.cpp: [no log message] + +2003-03-23 12:33 paul + + * conf.txt, pool.cpp: [no log message] + +2003-03-23 06:41 paul + + * base.cpp, chat.cpp, conf.cpp, cont.cpp, html.cpp, main.cpp, + mutx.cpp, name.cpp, reqp.cpp, room.cpp, thrd.cpp, user.cpp, + msgs.h: [no log message] + +2003-03-23 06:26 paul + + * pool.cpp: [no log message] + +2003-03-23 05:55 paul + + * Makefile, README.txt, conf.txt, glob.h, main.cpp, msgs.h, + pool.cpp, pool.h, reqp.h, sock.cpp, sock.h: [no log message] + +2003-03-22 23:07 paul + + * README.txt: [no log message] + +2003-03-22 22:56 paul + + * html.h: [no log message] + +2003-03-22 07:40 vrichter + + * reqp.h: fixed a paste error + ---------------------------------------------------------------------- + +2003-03-21 20:38 vrichter + + * yc.tgz, ychat: removed binary files that were transfered + +2003-03-21 19:31 vrichter + + * reqp.cpp, reqp.h, ychat: added url decoding + +2003-03-21 16:54 root + + * CHAT.cpp, CHAT.h, CONF.cpp, CONF.h, HTML.cpp, HTML.h, MUTX.cpp, + MUTX.h, Makefile, README.txt, SOCK.cpp, SOCK.h, TOOL.cpp, TOOL.h, + base.cpp, base.h, chat.cpp, chat.h, cmnd.cpp, cmnd.h, conf.cpp, + conf.h, conf.txt, cont.cpp, cont.h, data.h, glob.h, html.cpp, + html.h, incl.h, main.cpp, msgs.h, mutx.cpp, mutx.h, name.cpp, + name.h, reqp.cpp, reqp.h, room.cpp, room.h, sock.cpp, sock.h, + thrd.cpp, thrd.h, todo.txt, user.cpp, user.h, yc.tgz, ychat, + gfx/y_ani_black.gif, gfx/y_ani_white.gif, html/blank.html, + html/frameset.html, html/index.html, html/input.html, + html/notfound.html, html/online.html, html/stream.html, + html/y_ani.gif: Initial revision + +2003-03-21 16:54 root + + * CHAT.cpp, CHAT.h, CONF.cpp, CONF.h, HTML.cpp, HTML.h, MUTX.cpp, + MUTX.h, Makefile, README.txt, SOCK.cpp, SOCK.h, TOOL.cpp, TOOL.h, + base.cpp, base.h, chat.cpp, chat.h, cmnd.cpp, cmnd.h, conf.cpp, + conf.h, conf.txt, cont.cpp, cont.h, data.h, glob.h, html.cpp, + html.h, incl.h, main.cpp, msgs.h, mutx.cpp, mutx.h, name.cpp, + name.h, reqp.cpp, reqp.h, room.cpp, room.h, sock.cpp, sock.h, + thrd.cpp, thrd.h, todo.txt, user.cpp, user.h, yc.tgz, ychat, + gfx/y_ani_black.gif, gfx/y_ani_white.gif, html/blank.html, + html/frameset.html, html/index.html, html/input.html, + html/notfound.html, html/online.html, html/stream.html, + html/y_ani.gif: imported files into ychat cvs + diff --git a/Makefile.in b/Makefile.in index 7c2a0c1..300d035 100755 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -SRCS=base.cpp chat.cpp s_chat.cpp cmnd.cpp conf.cpp s_conf.cpp cont.cpp html.cpp s_html.cpp main.cpp mutx.cpp s_mutx.cpp name.cpp pool.cpp reqp.cpp room.cpp sock.cpp s_sock.cpp thrd.cpp s_tool.cpp user.cpp +SRCS=chat.cpp s_chat.cpp cmnd.cpp conf.cpp s_conf.cpp cont.cpp html.cpp s_html.cpp lang.cpp s_lang.cpp logd.cpp main.cpp modl.cpp s_modl.cpp mutx.cpp s_mutx.cpp name.cpp pool.cpp reqp.cpp room.cpp sock.cpp s_sock.cpp thrd.cpp s_tool.cpp user.cpp sess.cpp sman.cpp s_sman.cpp OBJS=$(SRCS:.cpp=.o) CC=g++ LDFLAGS=@LDFLAGS@ -lstdc++ -g @@ -1,7 +1,5 @@ -yhttpd; Homepage: www.yhttpd.org; Version 0.7.1-RELEASE - +yChat++ Basic; Homepage: www.yChat.org; Version 0.5.1 Copyright (C) 2003 Paul C. Buetow, Volker Richter -Copyright (C) 2004 Paul C. Buetow ----------------------------------------------------------------- This program is free software; you can redistribute it and/or @@ -17,246 +15,221 @@ 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. ------------------------------------------------------------------ -YHTTPD TABLE OF CONTENTS: +----------------------------------------------------------------- +0.0.0 YCHAT++ BASIC TABLE OF CONTENTS 1.0.0 REQUIREMENTS 1.1.0 TESTED PLATFORMS -1.2.0 IMPORTANT NOTICES -1.3.0 HOW TO OBTAIN YHTTPD +1.2.0 IMPORTANT NOTES +1.3.0 HOW TO OBTAIN YCHAT++ 1.3.1 INSTALLATION -1.3.2 INSTALLATION QUICK-START -1.4.0 HOW TO USE SCREEN WITH YHTTPD 1.5.0 CUSTOMIZATION 1.6.0 FILES 1.7.0 WRITING BUG REPORTS 1.8.0 CONTACT - 1.0.0 REQUIREMENTS: -- GNU GCC G++ 3.4 or 3.3 or 3.2 or 3.1 - The GNU C++ compiler. G++ version 3.0 or 2.x does NOT work. +- gcc 3.2 + The GNU C++ compiler. -- GNU make 3.80 (gmake) or higher - If you dont have a gmake executable but make is gnu make then you need - to add a symlink or alias from gmake to make. - yhttpd Makefiles only have been tested with GNU make and may not work with - other make versions. +1.1.0 TESTED PLATFORMS: -- ncurses 5.x - Includes libncurses and the ncurses.h header files. +The following platforms have been tested with success: -- Screen - Only needed if yhttpd should run in background with - ncurses or CLI enabled. +- Linux with GCC 3.2.0, GNU make 3.79.1 +- FreeBSD 5.1-RELEASE-p2, GCC 3.2.2, GNU make 3.80 ( standard make does not seem work on FreeBSD ). -- Perl 5.x - Is needed for some scripts. Is not needed if you use precompiled binaries. +1.2.0 IMPORTANT NOTES: -1.1.0 TESTED PLATFORMS: +Before you compile the source you have to be sure to use at least GCC +version 3.x with pthreads enabled. ( Type gcc -v to check it ). +GCC 2.95 did not work while testing on linux and WON'T BE SUPPORTED! +If you like to support yChat++, please write us an email and tell what +you can/like/would help ;-]. Please also take a look at the yChat++ +homepage which is located at http://www.yChat.org. -The following platforms have been tested with success. If you find out that -a listed platform did not work at all please contact me: +1.3.0 HOW TO OBTAIN YCHAT++: - Operating system (arch) GNU G++ GNU make -- FreeBSD 5.2.1-RELEASE (i386) 3.3.3 3.80 -- FreeBSD 4.9-RELEASE (i386) 3.3.4 3.80 -- FreeBSD 4.10-RELEASE (i386) 3.4.1 3.80 -- Gentoo Linux 2004.2 (i386) 3.3.2 3.80 -- OpenBSD 3.6 MP (i386) 3.3.2 3.80 -- Slackware Linux 10.0 (i386) 3.4.0 3.80 -- SUSE Linux 8.0, G (i386) 3.3.1 3.80 +yChat can be downloaded as a source package or through CVS. -Other platforms like Linux based systems, other BSD-Systems or UNICES -are very likely to work too. +The packages are located at http://www.yChat.org -> Sourcecode -> +Packages or go to http://programming.buetow.org/CPP-yChat . -1.2.0 IMPORTANT NOTICES: +For CVS download type also look at the homepage please. -Before you compile the source you have to be sure to use at least GCC -version 3.1 with pthreads enabled. ( Type gcc -v to check it ). -GCC 2.95 and 3.0 did not work while testing and WON'T BE SUPPORTED! -If you like to support yhttpd++, please write us an email and tell what -you can/like/would help ;-]. Please also take a look at the yhttpd++ -homepage which is located at http://www.yhttpd.org. +1.3.1 INSTALLATION: -1.3.0 HOW TO OBTAIN YHTTPD++: +Invoke "./configure" and afterwards "make", edit the conf.txt. -yhttpd can be downloaded as a source package or through CVS. +Now we want to compile all the dynamic loadable modules of ychat. +Invoke "cd cmnd && ./compile.sh && cd -". All command modules should get +compiled. -The packages are located at http://www.yhttpd.org -> Sourcecode -> -Packages or go to http://pub.buetow.org/yhttpd/CPP-yhttpd . +Now its time to run the server with ./ychat. +Then point your webbrowser to http://yourip:port ! -For CVS download type: +... have fun :-). -cvs -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot login -( You will be asked for a password. Use "just enter" ). +1.5.0 CUSTOMIZATION: -vs -z3 -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot co yhttpd -( The sources will be copied into your local folder ) +If you like to customize the design/layout/language of yChat, you will have +to edit msgs.h and glob.h before you compile the sources. Afterwards you can +change the html-template files which are placed in the html/ subdirectory. +Dynamic loadable modules can be found in the cmnd/ subdirectory. -cvs -d:pserver:anonymous@buetow.org:/usr/home/cvs/cvsroot logout -( Logs your CVS session out ). +1.6.0 FILES: ( This list is not complete ) -Now you may continue with the installation. +conf.txt - The yChat configuration file. ( read by conf.cpp ). -1.3.1 INSTALLATION: +base.cpp - Encapsulates vector fields of room's or user ( may be later + hash_maps ) and provides methods for manipulating data + objects. -Invoke "./configure". Afterwards you will get prompted with the before-compile -options of yhttpd. After choosing those options you are ready to type "gmake" -afterwards. - - -You may also invoke gmake with the following options (the PREFIX can be set -in the yhttpd configurator which will be launched by the top configure script -or gmake config): - - gmake or gmake all (compiles everything, also modules) - gmake base (only compiles the base) - gmake base_start (only compiles the base and starts the server) - gmake clean (cleans everything) - gmake clean_base (only cleans the base obj and rpo files) - gmake clean_modules (only cleans the modules .so files) - gmake config (runs yhttpd configurator) - gmake deinstall (deinstalls yhttpd from PREFIX) - gmake gpl (shows the GNU General Public License) - gmake help (shows all available yhttpd gmake targets) - gmake install (installs yhttpd to PREFIX) - gmake modules (only compiles modules) - gmake mrproper (same as gmake clean plus removing all temp files) - gmake setup (runs all configure scripts and afterwards gmake all) - gmake start (compiles everything and starts the server) - gmake stats (generates yhttpd statistics) - gmake uninstall (same as deinstall) - gmake version (shows the current version of yhttpd) - -Example: "gmake all install clean" compiles everything, installs it to PREFIX -and cleans the source directories. - -Now its time to run the server with ./bin/yhttpd. - -Aferwards point your webbrowser to http://yourip:port ! +hmap.cpp - The hash map implementation which is a very fast data + structure. is needed for saving users, rooms and so on. -... have fun :-). +main.cpp - This includes the required manager headers for starting + the server and finally regulates the correct starting. -1.3.2 INSTALLATION QUICK START: +modl.cpp - The module loader. Stores pointers of all dynamic loaded + yChat modules in a hash map object and loads new modules + if desired or returns their pointers. -If you in hury, then you may just type gmake setup. In the yhttpd configurator -you may just choose all the default values. If done, yhttpd will get compiled -and is ready to run with ./bin/yhttpd! +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. -1.4.0 HOW TO USE SCREEN WITH YHTTPD: +room.cpp - Specifies a chat room. For each chat room an instance of + this class exists. -If you are running yhttpd in ncurses mode you might want to install -the tool which is called "screen". This will enable you putting the -ncurses interface into the background, closing the terminal session -and reusing the interface later through another terminal. +thrd.cpp - This class is needed by sock.cpp while creating a POSIX thread. + All data which a thread needs to do its tasks are stored in a + thrd object and then a pointer to it will be passed to the + POSIX thread function. -Just do: - - screen -S yhttpd ./bin/yhttpd ( creates a new session and starts yhttpd in it ) - ctrl+d+a ( will detach the yhttpd session ) - ( closing the terminal ) - ( opening a new terminal ) - screen -r yhttpd ( will return you to the yhttpd process ) +user.cpp - Specifies a chat user. For each chat user an instance of + this class exists. -Screen will terminate automaticaly if all processes in its sessions are -terminated. +Abstract classes: -For a closer look read the screen manual page ( man screen ). +cont.cpp - All classes which need to store "key - value" data sets + inherit from this class. ( cont for content ). -1.5.0 CUSTOMIZATION: +name.cpp - All classes which own a private member string name inherit + from this class. It also provides public get_name and + set_name methods. + +As described ( main.cpp ), there are so called managers. Managers are +accessible through their assigned wrapper classes and may be +instanciated only once. + +chat.cpp - The chat manager. Is responsible for managing the internal + data structure of the system and also covers a lot of + important methods of the system. + +conf.cpp - The config manager. Parses the config file specified in + glob.h and stores all the values of it in a map. -If you like to customize the design/layout/language of yhttpd, you will have -to edit src/msgs.h and src/glob.h before you compile the sources. Afterwards -you can change the html-template files which are placed in the html/ -subdirectory and the language-templates which are placed in the XML config -file (etc/yhttpd.conf). +html.cpp - The html-template manager. Reads the requested html-template + files, stores them in an internal cache ( averts reading + template-files from hd twice or more ) and parses the + partivular template in order to substituate dynamic values + of it. -Notice, that you dont have to edit the src/glob.h file by hand any more, its -already done by the top ./configure script for you. +mutx.cpp - The mutex manager. Contains all global mutex handlers for + synchronizing POSIX thread shared data. until now only the + stdout is synchronized by mutx.cpp because most of objects + use their own mutex'. -You can edit the etc/yhttpd.conf to fit your needs. If you dont want to change -the config file, then you also can use yhttpd start parameters. +sock.cpp - The socket manager. Manages the socket connections. There + are multiplexed sockets. For each requests a new POSIX thread + will be created. -Exmpl: ./bin/yhttpd -o chat.database.password secretpassword +Files with a leading s_ contain static C++ classes -You can also use multiple words for a specific option. +s_chat.cpp - Static wrapper for the dynamic chat class. holds one global + reachable instance of chat until the program shuts down. -Exmpl: ./bin/yhttpd -o yhttpd.version "word1 word2 word3" +s_conf.cpp - Static wrapper for the dynamic conf class. holds one global + reachable instance of conf until the program shuts down. -will overwrite the default database password value of the yhttpd.conf. You can -do this with every configuration element by adding several -o option value -arguments to the start command. +s_html.cpp - Static wrapper for the dynamic html class. holds one global + reachable instance of conf until the program shuts down. -Dynamic loadable modules can be found in the mods/ subdirectory. (chat -commands are realized through modules too). Sources of modules can be found -in src/mods instead. If you want to create a new module just create a new -.cpp file and run in src/mods the ./configure script again. Next time -you run gmake your new module gets compiled. +s_mutx.cpp - Static wrapper for the dynamic mutx class. holds one global + reachable instance of conf until the program shuts down. -All messages defined in the msgs.h file contain server messages only ( a chat -user never wont read them, only the administrator will get to see them ). +s_sock.cpp - Static wrapper for the dynamic sock class. holds one global + reachable instance of conf until the program shuts down. -1.6.0 FILES: +s_tool.cpp - Static class which includes some usefull global reachable + methods which are not integraded in independent classes. -etc/yhttpd.conf - The yhttpd configuration file -html/* - The html template files -src/* - The yhttpd base sources -src/mods/* - The dynamic loadable modules sources -scripts/* - Some nice scripts needed for building & co. +Special header files ( all other header files which are not listed here +belong to their respective .cpp files ): -The following is created by building yhttpd: -obj/* - The object files of the compiled yhttpd base -mods/* - The compiled dynamic loadable modules -bin/yhttpd - The yhttpd binary (linked by the object files) +glob.h - Defines global variables which are known by compilation + time. -Customizable source files (if changed you need to run gmake clean all) -src/glob.h - Contains some global building options -src/msgs.h - Defines some server side messages +incl.h - This file is included from every other header file and + includes a set of headers which every class should be able + to use. +msgs.h - Defines console output messages for verbosity level 0 ( see + glob.h for setting up verbosity levels ). and also defines + all the system messages. you may edit this file for translating + the system user language. + +The basic class structure: + + base<room> base<user> + | | name + | | / \ + | | / \ + chat room user + + cont + / \ + / \ +conf html 1.7 WRITING BUG REPORTS How to submit a good bug report? -Send them to Bug@yhttpd.org. +Send them to Bug@yChat.org. First you should give the following information: -- yhttpd version, if CVS (or devel. tarball) then which day? +- yChat version, if CVS (or devel. tarball) then which day? - operating system / distribution and it's version - when did it crash? did you do something? can you reproduce the crash? -Getting backtrace of the crash also helps a lot, especially if yhttpd crashes -randomly. If after crash you see text: +Getting backtrace of the crash also helps a lot, especially if yChat crashes randomly. If after crash you see text: "segmentation fault (core dumped)" -It writes a file named "core" or "yhttpd.core" depending on your OS to directory -where you started yhttpd. If it doesn't print the "(core dumped)" or you can't -find the core file, you'll have to raise the limit for max. core file size -before running yhttpd. To do this, say: +It writes a file named "core" or "ychat.core" depending on your OS to directory where you started yChat. If it doesn't print the "(core dumped)" or you can't find the core file, you'll have to raise the limit for max. core file size before running yChat. To do this, say: ulimit -c unlimited -So, if you have the core file and GNU debugger (gdb), you can get the -backtrace with: +So, if you have the core file and GNU debugger (gdb), you can get the backtrace with: - gdb ./bin/yhttpd yhttpd.core + gdb ychat core bt Paste all the lines starting from line having #0 at the beginning. Here's an example session: - in reqp::parse(thrd*, std::string, std::map<std::string, std::string, - std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) () + in reqp::parse(thrd*, std::string, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) () (gdb) bt - #0 0x0805c287 in reqp::parse(thrd*, std::string, std::map<std::string, - std::string, std::less<std::string>, std::allocator<std::pair<std::string - const, std::string> > >&) () + #0 0x0805c287 in reqp::parse(thrd*, std::string, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) () #1 0x0806060f in sock::read_write(thrd*, int) () #2 0x080612ba in thrd::run() () #3 0x0805a3b8 in pool::run_func(void*) () @@ -264,29 +237,20 @@ Here's an example session: #5 0x281d44ae in _thread_start () from /usr/lib/libc_r.so.5 (gdb) -If you dont get such a gdb output, you need to recompile the yhttpd using -debuggig symbols. You can do it this way: - -cd yhttpd -gmake mrproper -./configure -g3 -ggdb -gmake start - 1.8 CONTACT: You may contact us through the following addresses: - Homepage - The yhttpd homepage is located at http://www.yhttpd.org + The yChat homepage is located at http://www.yChat.org - E-Mail - Paul C. Buetow: Snooper at yhttpd point org ( core developer ) - Volker Richter: Rover at yhttpd dot org ( core developer ) - Mail at yhttpd dot org ( reaches everybody of yhttpd ) + Paul C. Buetow: Snooper@yChat.org ( core developer ) + Volker Richter: Rover@yChat.org ( core developer ) + Mail@yChat.org ( reaches everybody of yChat ) - ICQ Paul C. Buetow: 11655527 - IRC - #Ychat and #Coding at irc.german-elite.net - + #ychat at irc.german-elite.net @@ -1,3 +1,11 @@ +/* + This file is part of yChat + + $Author: snooper $ + $Date: 2003/04/02 10:50:18 $ + + $Header: /cvsroot/ychat/ychat/base.cpp,v 1.8 2003/04/02 10:50:18 snooper Exp $ +*/ // template class data implementation; #ifndef BASE_CPP @@ -5,84 +13,53 @@ #include "base.h" -base::base() +template<class type> +base<type>::base() { - pthread_mutex_init (&mut_vec_elem, NULL ); + map_elem = new hmap<type*,string>(80); + pthread_mutex_init (&mut_map_elem, NULL ); } -base::~base( ) +template<class type> +base<type>::~base( ) { - pthread_mutex_destroy( &mut_vec_elem ); + pthread_mutex_destroy( &mut_map_elem ); } -void -base::add_elem( name* p_name ) +template<class type> void +base<type>::add_elem( type* p_type ) { - pthread_mutex_lock ( &mut_vec_elem ); - vec_elem.push_back ( p_name ); - pthread_mutex_unlock( &mut_vec_elem ); + pthread_mutex_lock ( &mut_map_elem ); + map_elem->add_elem ( p_type, p_type->get_name()); + pthread_mutex_unlock( &mut_map_elem ); } -bool -base::del_elem( string &s_name ) +template<class type> void +base<type>::del_elem( string &s_name ) { - vector<name*>::iterator iter; - pthread_mutex_lock ( &mut_vec_elem ); - - iter = vec_elem.begin(); - while( iter != vec_elem.end() ) - { - if ( (*iter)->get_name() == s_name ) - { - vec_elem.erase( iter ); - pthread_mutex_unlock( &mut_vec_elem ); - return true; - } - iter++; - } - - pthread_mutex_unlock( &mut_vec_elem ); - return false; + pthread_mutex_lock ( &mut_map_elem ); + map_elem->del_elem ( s_name ); + pthread_mutex_unlock( &mut_map_elem ); } -name* -base::get_elem( string &s_name, bool &b_found ) +template<class type> type* +base<type>::get_elem( string &s_name, bool &b_found ) { - vector<name*>::iterator iter; - pthread_mutex_lock ( &mut_vec_elem ); - - iter = vec_elem.begin(); - while( iter != vec_elem.end() ) - { - if ( (*iter)->get_name() == s_name ) - { - b_found = true; - pthread_mutex_unlock( &mut_vec_elem ); - return (*iter); - } - iter++; - } + pthread_mutex_lock ( &mut_map_elem ); + type* p_type = map_elem->get_elem( s_name ); + pthread_mutex_unlock( &mut_map_elem ); - pthread_mutex_unlock( &mut_vec_elem ); + b_found = p_type == NULL ? false : true; - b_found = false; - - return new name(); + return p_type; } -void -base::run_func( void (*func)(name*, void*), void* v_arg ) +template<class type> void +base<type>::run_func( void (*func)(type*, void*), void* v_arg ) { - vector<name*>::iterator iter; - pthread_mutex_lock ( &mut_vec_elem ); - - // execute func foreach element of vec_elem with - // 1st argument: a pointer of a element of vec_elem. - // 2nd argument: a void pointer of a object. - for( iter = vec_elem.begin(); iter != vec_elem.end(); iter++ ) - ( *func ) ( (*iter), v_arg ); - - pthread_mutex_unlock( &mut_vec_elem ); + pthread_mutex_lock ( &mut_map_elem ); + map_elem->run_func( func, v_arg ); + pthread_mutex_unlock( &mut_map_elem ); } #endif @@ -3,26 +3,69 @@ #ifndef BASE_H #define BASE_H -#include <vector> #include "incl.h" -#include "name.h" +#include "hmap.h" +template<class type> class base { private: - vector<name*> vec_elem ; - pthread_mutex_t mut_vec_elem; + hmap<type*,string>* map_elem; + pthread_mutex_t mut_map_elem; public: base(); ~base(); - virtual void add_elem( name* p_name ); // add a element. - virtual bool del_elem( string &s_name ); // delete a alement. - virtual name* get_elem( string &s_name, bool &b_found ); // get a element. + 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 vec_elem. v_pointer is the argument. - virtual void run_func( void (*func)(name*, void*), void* v_arg ); + // 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 @@ -1,16 +1,22 @@ // class chat implementation. -#ifndef CHAT_CXX -#define CHAT_CXX +#ifndef s_chat_CXX +#define s_chat_CXX #include "chat.h" -#include "CONF.h" -#include "MUTX.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( ) @@ -41,10 +47,9 @@ chat::get_user( string &s_user, bool &b_found ) } void -chat::get_user_( name *name_obj, void *v_arg ) +chat::get_user_( room *room_obj, void *v_arg ) { 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]) ); } @@ -53,11 +58,19 @@ chat::login( map_string &map_params ) { string s_user = map_params["nick"]; - // prove if nick is empty + // prove if nick is empty: if ( s_user.empty() ) { map_params["INFO"] = E_NONICK; - map_params["request"] = CONF::get().get_val( "STARTMPL" ); // redirect to the startpage. + 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; } @@ -68,7 +81,7 @@ chat::login( map_string &map_params ) if ( b_flag ) { map_params["INFO"] = E_ONLINE; - map_params["request"] = CONF::get().get_val( "STARTMPL" ); + map_params["request"] = s_conf::get().get_val( "STARTMPL" ); return; } @@ -80,10 +93,10 @@ chat::login( map_string &map_params ) { p_room = new room( s_room ); -#ifdef _VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cout << NEWROOM << s_room << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); #endif add_elem( p_room ); @@ -93,29 +106,42 @@ chat::login( map_string &map_params ) // 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( USERENTR ) ) ); + p_room->msg_post( new string( s_user.append( s_lang::get().get_val( "USERENTR" ) ) ) ); -#ifdef _VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cout << LOGINPR << s_user << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); #endif } void -chat::post( user* u_user, map_string &map_params ) +chat::post( user* p_user, map_string &map_params ) { - string s_msg( "<font color=\"" ); - s_msg.append( u_user->get_col1() ) - .append( "\">" ) - .append( u_user->get_name() ) - .append( ": " ) - .append( map_params["message"] ) - .append( "</font><br>\n" ); - - u_user->get_p_room()->msg_post( &s_msg ); + + string s_msg( map_params["message"] ); + + auto unsigned i_pos = s_msg.find( "/" ); + if ( i_pos == 0 ) + return p_user->command( s_msg ); + + 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 @@ -1,21 +1,27 @@ // class chat declaration. -#ifndef CHAT_H -#define CHAT_H +#ifndef s_chat_H +#define s_chat_H #include <vector> #include "incl.h" -#include "data.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 data<room> +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 ) ); @@ -28,7 +34,7 @@ public: // 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_( name* name_obj, void *v_arg ); + 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 ); @@ -4,7 +4,7 @@ #define CMND_CXX #include "cmnd.h" -#include "MUTX.h" +#include "s_mutx.h" using namespace std; diff --git a/cmnd/yc_getrusage.cpp b/cmnd/yc_getrusage.cpp new file mode 100644 index 0000000..4e10e7c --- /dev/null +++ b/cmnd/yc_getrusage.cpp @@ -0,0 +1,51 @@ +#include <stdio.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <iostream> +#include "../user.h" + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN -1 + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +typedef vector<string> str_vector; + +extern "C" { + export int extern_function(void *v_arg); + + int extern_function(void *v_arg) + { + user *p_user = (user*) v_arg; + rusage* p_rusage = new rusage; + getrusage( RUSAGE_SELF, p_rusage ); + char c_msg[1024]; + + /* see man getrusage */ + + sprintf(c_msg, "getrusage:<br>\nmaxrss: %D (max resident set size)<br>\nixrss: %D (integral shared text memory size)<br>\nidrss: %D (integral unshared data size)<br>\nisrss %D (integral unshared stack size)<br>\nminflt: %D (page reclaims)<br>\nmajflt: %D (page faults)<br>\nnswap: %D (swaps)<br>\ninblock: %D (block input operations)<br>\noublock: %D (block output operations)<br>\nmsgsnd: %D (messages sent)<br>\nmsgrcv: %D (messages received)<br>\nnsignals: %D (signals received)<br>\nnvcsw: %D (voluntary context switches)<br>\nnivcsw: %D (involuntary context switches)<br>\n", + p_rusage->ru_maxrss, + p_rusage->ru_ixrss, + p_rusage->ru_idrss, + p_rusage->ru_isrss, + p_rusage->ru_minflt, + p_rusage->ru_majflt, + p_rusage->ru_nswap, + p_rusage->ru_inblock, + p_rusage->ru_oublock, + p_rusage->ru_msgsnd, + p_rusage->ru_msgrcv, + p_rusage->ru_nsignals, + p_rusage->ru_nvcsw, + p_rusage->ru_nivcsw + ); + + p_user->msg_post( new string( c_msg ) ); + } +} + @@ -1,7 +1,7 @@ // class conf implementation. -#ifndef CONF_CXX -#define CONF_CXX +#ifndef s_conf_CXX +#define s_conf_CXX #include <fstream> #include "conf.h" @@ -20,7 +20,7 @@ conf::~conf() void conf::parse() { -#ifdef _VERBOSE +#ifdef VERBOSE cout << CFILEOK << get_name() << endl; #endif @@ -28,7 +28,7 @@ conf::parse() if ( ! fs_conf ) { -#ifdef _VERBOSE +#ifdef VERBOSE cout << CFILENO << get_name() << endl; #endif return; @@ -60,7 +60,7 @@ conf::parse() string s_val = s_token.substr( ui_pos+1, s_token.length() ); string s_key = s_token.substr( 0 , --ui_pos ); -#ifdef VERBOSE +#ifdef VERBOSE2 cout << s_key << "=" << s_val << endl; #endif @@ -1,7 +1,7 @@ // class conf declaration. this class parses the server config file. -#ifndef CONF_H -#define CONF_H +#ifndef s_conf_H +#define s_conf_H #include "incl.h" #include "cont.h" @@ -17,31 +17,47 @@ # server specific configurations ( not allowed to be removed ): HTMLTEMP="html/"; # directory of the html-template files. -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. +THRDPOOL="50"; # thread pool size. +THRDQUEU="50"; # length of the thread pool queue. +SRVRPORT="3000"; # local port on which the server listens. STRDROOM="Lounge"; # the name of the standard room. +LANGUAGE="en"; # language of the chat outputs ( CONSOLE OUTPUT IS NOT AFFECTED ) # the html template file which will be send if the requested file does not exists. NOTFOUND="notfound.html"; # specifies the standard start html-template. STARTMPL="index.html"; # user's standard nick color. -USERCOL1="#000000"; - -# superuser level names. level 0 has the most provileges. -SULEVEL0="Coder"; # programmer. -SULEVEL1="Admin"; # administrator. -SULEVEL2="Magic"; # super user with special privileges. -SULEVEL3="Super"; # temporary super user. -SULEVEL4="Basic"; # normal user without special privileges. -SULEVEL5="Guest"; # guest user, has almost no privileges. -SULEVEL6="Restr"; # a very restricted user. -SULEVEL7="Outbn"; # banned out of the system. +USERCOL1="#FFFFFF"; + +# length of the generated session id +SESSION_LENGTH="32"; + +# html = "OFF" strips all html tags from incoming messages +HTML="OFF"; + +# Logging + +# relative or absolute path to logfile +ACCESS_LOG="log/access_log"; + +# we're using buffered logging for performance +# LOG_LINES specifies after how many lines the log is flushed into a file +# if you don't want buffered logging set LOG_LINES to 1 +LOG_LINES="10"; # values which are used by the html-templates and are not sticked within the yC++ core source! GRAPHICS="http://paul.buetow.info/yChat"; # url for graphic files etc. PGETITLE="yChat++ Basic - Fast Simple Extensible"; +# do not edit beyond this line + +CT_HTM="text/html"; +CT_HTML="text/html"; +CT_GIF="image/gif"; +CT_JPG="image/jpeg"; +CT_JPEG="image/jpeg"; +CT_PNG="image/png"; +CT_DEFAULT="text/html"; + # end. @@ -1,73 +1,1555 @@ -#!/bin/sh +#! /bin/sh -if ! which perl >/dev/null +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=s_chat.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + +#AC_INIT_AUTOMAKE(yChat, 0.2) + +echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 +echo "configure:528: checking for Cygwin environment" >&5 +if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 533 "configure" +#include "confdefs.h" + +int main() { + +#ifndef __CYGWIN__ +#define __CYGWIN__ __CYGWIN32__ +#endif +return __CYGWIN__; +; return 0; } +EOF +if { (eval echo configure:544: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_cygwin=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_cygwin=no +fi +rm -f conftest* +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_cygwin" 1>&6 +CYGWIN= +test "$ac_cv_cygwin" = yes && CYGWIN=yes +echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 +echo "configure:561: checking for mingw32 environment" >&5 +if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 566 "configure" +#include "confdefs.h" + +int main() { +return __MINGW32__; +; return 0; } +EOF +if { (eval echo configure:573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_mingw32=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_mingw32=no +fi +rm -f conftest* +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_mingw32" 1>&6 +MINGW32= +test "$ac_cv_mingw32" = yes && MINGW32=yes +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:590: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 605 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:611: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 622 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:628: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 639 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:674: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CXX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CXX="$ac_cv_prog_CXX" +if test -n "$CXX"; then + echo "$ac_t""$CXX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CXX" && break +done +test -n "$CXX" || CXX="gcc" + + +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:706: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 + +ac_ext=C +# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cxx_cross + +cat > conftest.$ac_ext << EOF + +#line 717 "configure" +#include "confdefs.h" + +int main(){return(0);} +EOF +if { (eval echo configure:722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cxx_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cxx_cross=no + else + ac_cv_prog_cxx_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cxx_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 +if test $ac_cv_prog_cxx_works = no; then + { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:748: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 +cross_compiling=$ac_cv_prog_cxx_cross + +echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 +echo "configure:753: checking whether we are using GNU C++" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.C <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:762: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gxx=yes +else + ac_cv_prog_gxx=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gxx" 1>&6 + +if test $ac_cv_prog_gxx = yes; then + GXX=yes +else + GXX= +fi + +ac_test_CXXFLAGS="${CXXFLAGS+set}" +ac_save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS= +echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 +echo "configure:781: checking whether ${CXX-g++} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.cc +if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then + ac_cv_prog_cxx_g=yes +else + ac_cv_prog_cxx_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS="$ac_save_CXXFLAGS" +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + + + +echo $ac_n "checking for library containing dlopen""... $ac_c" 1>&6 +echo "configure:815: checking for library containing dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_search_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_func_search_save_LIBS="$LIBS" +ac_cv_search_dlopen="no" +cat > conftest.$ac_ext <<EOF +#line 822 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { +dlopen() +; return 0; } +EOF +if { (eval echo configure:833: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_dlopen="none required" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +test "$ac_cv_search_dlopen" = "no" && for i in dl; do +LIBS="-l$i $ac_func_search_save_LIBS" +cat > conftest.$ac_ext <<EOF +#line 844 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { +dlopen() +; return 0; } +EOF +if { (eval echo configure:855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_search_dlopen="-l$i" +break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +LIBS="$ac_func_search_save_LIBS" +fi + +echo "$ac_t""$ac_cv_search_dlopen" 1>&6 +if test "$ac_cv_search_dlopen" != "no"; then + test "$ac_cv_search_dlopen" = "none required" || LIBS="$ac_cv_search_dlopen $LIBS" + +else : + +fi +if test "$ac_cv_search_dlopen" = "-ldl"; then +LDFLAGS="$ac_cv_search_dlopen" +fi +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:883: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 888 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:896: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + ac_header_dirent=$ac_hdr; break +else + echo "$ac_t""no" 1>&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:921: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <<EOF +#line 929 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:962: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <<EOF +#line 970 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1004: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1009 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1017: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1034 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1052 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext <<EOF +#line 1073 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then - echo You need to have Perl in your PATH - exit 1 -fi - -perl -e ' - use strict; - $|=1; - sub check_gcc { - my $f = shift; - my $s = shift; - my $r = 0; - print "Checking for GNU G++ $f.$s\n"; - if ( `g++ -v 2> g++.version && tail -n 1 g++.version` =~ / $f\.$s/ ) { - `echo $f.$s >> g++.version`; - `echo g++ >> g++.version`; - $r = 1; - } else { - if (`g++$f$s -v 2> g++.version && tail -n 1 g++.version` =~ / $f\.$s/) { - `echo $f.$s >> g++.version`; - `echo g++$f$s >> g++.version`; - $r = 1; - } - } - print "No " if $r == 0; - print "GNU G++ $f.$s found!\n"; - return $r; - } - sub check_make { - print "Checking for GNU make\n"; - my $err = "No GNU make found.\nPlease install a version of GNU make!\n"; - my $make; - if (`which gmake`) { - $make = "gmake"; - } elsif ( `which make` ) { - $make = "make"; - } else { - print $err; - exit(1); - } - - `sh -c "$make -v > make.version 2>/dev/null"`; - if ( `cat make.version` =~ /GNU Make/ ) { - `echo $make >> make.version`; - } else { - print $err; - exit(1); - } - } - &check_make; - print "Checking compiler version\n"; - my $r = 0; - for (my $i = 4; $i > 0 && $r == 0; --$i ) { - $r = &check_gcc(3,$i); - } - if ($r == 0) { - print "No suitable g++ compiler found!\n"; - print "Please install a right version of GNU G++!\n"; - exit(1); - } + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1111: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1116 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1121: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF - system("sh -c \"scripts/config.sh\""); - chdir("src"); - system("./configure ".join(" ", @ARGV)); - chdir(".."); +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_hdr in string.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1151: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1156 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1161: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1188: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1193 "configure" +#include "confdefs.h" + +int main() { + +/* Ultrix mips cc rejects this. */ +typedef int charset[2]; const charset x; +/* SunOS 4.1.1 cc rejects this. */ +char const *const *ccp; +char **p; +/* NEC SVR4.0.2 mips cc rejects this. */ +struct point {int x, y;}; +static struct point const zero = {0,0}; +/* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in an arm + of an if-expression whose if-part is not a constant expression */ +const char *g = "string"; +ccp = &g + (g ? g-g : 0); +/* HPUX 7.0 cc rejects these. */ +++ccp; +p = (char**) ccp; +ccp = (char const *const *) p; +{ /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; +} +{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; +} +{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; +} +{ /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1242: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:1263: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <<EOF +#line 1270 "configure" +#include "confdefs.h" + +int main() { +} $ac_kw foo() { +; return 0; } +EOF +if { (eval echo configure:1277: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <<EOF +#define inline $ac_cv_c_inline +EOF + ;; +esac + + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CPP@%$CPP%g +s%@CXX@%$CXX%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <<EOF + +EOF +cat >> $CONFIG_STATUS <<\EOF - exit(0); -' `echo "$*" | sed "s/-//g"` +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 -echo You are ready to type gmake now! @@ -4,7 +4,7 @@ #define CONT_CXX #include "cont.h" -#include "MUTX.h" +#include "s_mutx.h" using namespace std; @@ -4,6 +4,7 @@ #define CONT_H #include "incl.h" +#include "hmap.h" using namespace std; @@ -23,7 +23,12 @@ // 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 +#define VERBOSE + +// Defines the amount of newlines which have to send to the client's +// chat stream the first log-in. ( prevents white screen because of buffers +// or proxies ). +#define PUSHSTR 1000 ////////////////////////////////////////////////////////////////////////////////////////// @@ -47,10 +52,17 @@ enum rang // some custom typedefs for datatypes which are needed often. typedef map<string, string> map_string; +typedef int function( void *v_arg ); struct container { void* elem[3]; }; +struct dynmod +{ + function *the_func ; + void *the_module; +}; + #endif @@ -1,6 +1,7 @@ #ifndef hmap_cpp #define hmap_cpp + #include "hmap.h" using namespace std; @@ -160,6 +161,14 @@ int hmap<obj_type, key_type>::nextPrime( int n ) const 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++ ) @@ -53,6 +53,7 @@ public: 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: @@ -80,6 +81,11 @@ public: 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> @@ -1,18 +1,18 @@ // class html implementation. -#ifndef HTML_CXX -#define HTML_CXX +#ifndef s_html_CXX +#define s_html_CXX #include <fstream> #include "html.h" -#include "CHAT.h" -#include "MUTX.h" +#include "s_chat.h" +#include "s_mutx.h" using namespace std; html::html( ) { - set_name( CONF::get().get_val( "HTMLTEMP" ) ); + set_name( s_conf::get().get_val( "HTMLTEMP" ) ); pthread_mutex_init( &mut_map_vals, NULL ); } @@ -43,25 +43,33 @@ html::parse( map_string &map_params ) if ( s_templ.empty() ) { auto string s_path = get_name(); - auto ifstream fs_templ( s_path.append( s_file ).c_str() ); + auto ifstream fs_templ( s_path.append( s_file ).c_str(), ios::binary ); if ( ! fs_templ ) { - map_params["request"] = CONF::get().get_val( "NOTFOUND" ); + + cerr << "File not found: " << s_file << endl; + if(map_params["request"]==s_conf::get().get_val( "NOTFOUND" )) + return ""; + + map_params["request"] = s_conf::get().get_val( "NOTFOUND" ); return parse( map_params ); + } - auto char c_buf[READBUF]; - - while( fs_templ.getline( c_buf, READBUF ) ) - s_templ.append( string( c_buf ).append( "\n" ) ); - + auto char c_buf; + while( !fs_templ.eof() ) + { + fs_templ.get( c_buf ); + s_templ+=c_buf; + } + fs_templ.close(); -#ifdef _VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cout << TECACHE << s_path << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); #endif // cache file. @@ -89,7 +97,7 @@ html::parse( map_string &map_params ) // get key and val. auto string s_key = s_templ.substr( pos[0], pos[1]-pos[0] ); - auto string s_val = CONF::get().get_val( s_key ); + auto string s_val = s_conf::get().get_val( s_key ); // if s_val is empty use map_params. if ( s_val.empty() ) @@ -1,11 +1,11 @@ // class html declaration. this class manages the html-template files. -#ifndef HTML_H -#define HTML_H +#ifndef s_html_H +#define s_html_H #include "incl.h" #include "cont.h" -#include "CONF.h" +#include "s_conf.h" #include "user.h" #include "name.h" diff --git a/html/favicon.ico b/html/favicon.ico Binary files differindex 4deafd5..4deafd5 100755..100644 --- a/html/favicon.ico +++ b/html/favicon.ico 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 b1a1793..7bc01b0 100755 --- a/html/index.html +++ b/html/index.html @@ -1,27 +1,32 @@ -<!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> - %%yhttpd.version%% + %%PGETITLE%% </title> <link rel=stylesheet href="style.css" type=text/css> </head> <body bgcolor=#000000 text=#ffff00> <table align=center width=500> <tr> -<td align=center class=header>%%yhttpd.version%%<br><br>%%INFO%%</td> +<td align=center><img src="y_black.gif" alt="ychat"></td> +<td align=center class=header>%%PGETITLE%%<br>%%INFO%%</td> </tr> <tr> -<td colspan=2> </td> + <td colspan=2> </td> </tr> <tr> -<td align=center colspan=2> -This is the demo website provided by yhttpd :-) + <td align=center colspan=2> +Enter your nick: +<form action="frameset.html" method="GET"> + <input type="hidden" name="event" value="login"> + <input type="hidden" name="room" value="%%STRDROOM%%"> + <input type="text" name="nick"> + <input type="submit" value="login"> +</form> </td> </tr> </table> <br><br> -<center><span class="signature">yhttpd is OpenSource - get it at <a target="_blank" href="http://www.yhttpd.org">http://www.yhttpd.org</a></span></center> +<center><span class="signature">yChat is OpenSource - get it at <a target="_blank" href="http://www.yChat.org">http://www.yChat.org</a></span></center> </body> </html> diff --git a/html/input.html b/html/input.html index 31ed9fe..a403d8e 100755 --- a/html/input.html +++ b/html/input.html @@ -1,60 +1,34 @@ -<!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"> + <head> <title> - %%HTML_TITLE_TAG_CONTENT%% + %%PGETITLE%% </title> - <link rel=stylesheet href="style.css" type=text/css> +<link rel=stylesheet href="style.css" type=text/css> + <script language="JavaScript"> <!-- function delout() { - document.input.message.value = document.input.message.value.replace(/&/g, '\\AND'); - document.input.submit(); - document.input.message.value = ""; document.input.message.focus(); + document.input.message.select(); + document.input.submit(); return false; } function selectinput() { document.input.message.select(); } - function popup(site,width,height) - { - var left = (screen.availWidth-width)/2; - var top = (screen.availHeight-height)/2; - var win = window.open(site,"_blank","width="+width+",height="+height+",left="+left+",top="+top+",scrollbars=yes"); - } - function chgscroll(f) - { - if(f.checked) - parent.stream.autoscroll(); - else - parent.stream.stopscroll(); - } //--> </script> </head> - <body> - <form method="GET" name="input" action="input.html" target="blank" onsubmit="return delout();"> - <div style="position: absolute; top: 5px;"> - <input class="text" type="text" name="message" size="60" maxlength="%%chat.maxlength.message%%"> - <input type="submit" value="Send" accesskey='s'> - <input type="button" value="Select" accesskey='e' onclick="javascript:selectinput();"> - </div> - <div style="position: absolute; top: 29px;"> - <a href='#' class="fancy" onclick="javascript:popup('colors.html?event=colors&tmpid=%%tmpid%%', 600, 480)">Colors</a> - <a href='#' class="fancy" onclick="javascript:popup('options.html?event=options&tmpid=%%tmpid%%', 600, 480)">Options</a> - <a href='#' class="fancy" onclick="javascript:popup('help.html?event=help&tmpid=%%tmpid%%', 600, 480)">Help</a> - <a href='#' class="fancy" onclick="javascript:popup('loggedin.html?event=loggedin&tmpid=%%tmpid%%', 600, 480)">Users</a> - <a href='#' class="fancy" onclick="javascript:popup('admin.html?event=admin&tmpid=%%tmpid%%', 600, 480)">Admin</a> - <a href='input.html?event=input&tmpid=%%tmpid%%&message=%2Fq' class="fancy" target='blank'>Logout</a> - Scrolling: - <input type="checkbox" name="scroll" checked onClick="chgscroll(this);"> - </div> - <input type="hidden" name="event" value="input"> + <body bgcolor=#000000 text=#ffffff> + <form name="input" action="input.html" target="blank" onsubmit="return delout();"> + <input type="hidden" name="event" value="post"> + <input type="hidden" name="nick" value="%%nick%%"> <input type="hidden" name="tmpid" value="%%tmpid%%"> + <input type="text" name="message" size="50"> + <input type="submit" value="send"> + <input type="button" value="select" onclick="javascript:selectinput();"> </form> </body> </html> diff --git a/html/notfound.html b/html/notfound.html index a14d44b..574e341 100755 --- a/html/notfound.html +++ b/html/notfound.html @@ -1,9 +1,7 @@ -<!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> - %%HTML_TITLE_TAG_CONTENT%% + %%PGETITLE%% </title> </head> <body> diff --git a/html/online.html b/html/online.html index 3eda553..aa14f8d 100755 --- a/html/online.html +++ b/html/online.html @@ -1,20 +1,7 @@ -<!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"> - <link rel=stylesheet href="style.css" type=text/css> - </head> - <body> - <b>%%room%%</b> - <br> - <br> - <table> - <tr> - <td> - %%topic%% - </td> - </tr> - %%userlist%% - </table> + <meta http-equiv="refresh" content="20"> +<link rel=stylesheet href="style.css" type=text/css> + <body bgcolor=#000000 text=#ffffff> + %%MESSAGE%% </body> </html> diff --git a/html/stream.html b/html/stream.html index 4814979..6678069 100755 --- a/html/stream.html +++ b/html/stream.html @@ -1,38 +1,30 @@ -<!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"> + <head> <title> - %%HTML_TITLE_TAG_CONTENT%% + %%PGETITLE%% </title> <link rel=stylesheet href="style.css" type=text/css> <script language="JavaScript"> - var scrolling; - var ison; - function autoscroll() + function autoScroll() { - if(!ison){ - scrolling = window.setInterval("window.scroll(1,1606682)",70); - ison = true; - } + window.scroll(1, 50000 ); + timer = setTimeout('autoScroll()',200); } - function stopscroll() + + autoScroll(); + + function stopScroll() { - if(ison) - { - window.clearInterval(scrolling); - ison = false; - } + clearTimeout(timer); + } + + function startScroll() + { + timer = setTimeout('autoScroll()', 200); } </script> </head> -<body class="stream"> -<h1>Engine: %%ychat.version%%</h1> -<script language="JavaScript"> - autoscroll(); -</script> - - Welcome to the chat, %%nick%%! +<body bgcolor=#000000 text=#ffffff> + Welcome to yChat %%nick%%! <br> <br> - diff --git a/html/style.css b/html/style.css index e31bd7e..e31bd7e 100755..100644 --- a/html/style.css +++ b/html/style.css @@ -1,6 +1,6 @@ /* - * yChat++; Homepage: www.yChat.org - * Copyright (C) 2003 Paul C. Buetow ( Snooper@yChat.org, ICQ: 11655527 ) + * yChat++; Contact: www.yChat.org; Mail@yChat.org + * Copyright (C) 2003 Paul C. Buetow, Volker Richter * ----------------------------------------------------------------- * * This program is free software; you can redistribute it and/or @@ -26,25 +26,34 @@ #include "incl.h" // include the chat manager. -#include "CHAT.h" +#include "s_chat.h" // include the config manager. -#include "CONF.h" +#include "s_conf.h" // include the html-template manager. -#include "HTML.h" +#include "s_html.h" // include the mutex manager for global synchronization. -#include "MUTX.h" +#include "s_mutx.h" + +// include the module loader manager for global synchronization. +#include "s_modl.h" // include the socket manager. -#include "SOCK.h" +#include "s_sock.h" + +// include the language manager +#include "s_lang.h" + +// include the session manager +#include "s_sman.h" using namespace std; int main() { -#ifdef _VERBOSE +#ifdef VERBOSE cout << " ___ _ _ " << endl << " _ _ / __\\ |__ __ _| |_ " << endl @@ -66,19 +75,22 @@ cout << " ___ _ _ " << endl // all the static data classes have to be initialized once. otherwise they will // contain only empty pointers and the chat server won't work correctly. - // the order of the initializations is very importand. for example the HTML::init() - // invokations assumes an initialized CONF class. - MUTX::init(); // init the mutex manager. - CONF::init(); // init the config manager. - HTML::init(); // init the html-template manager. - SOCK::init(); // init the socket manager. - CHAT::init(); // init the chat manager. - + // the order of the initializations is very importand. for example the s_html::init() + // invokations assumes an initialized s_conf class. + s_mutx::init(); // init the mutex manager. + s_conf::init(); // init the config manager. + s_html::init(); // init the html-template manager. + s_lang::init(); // init the language manager + s_sman::init(); // init the session manager. + s_modl::init(); // init the module-loader manager. + s_sock::init(); // init the socket manager. + s_chat::init(); // init the chat manager. + // start the socket manager. this one will listen for incoming http requests and will // forward them to the specified routines which will generate a http response. - SOCK::get().start(); + s_sock::get().start(); -#ifdef _VERBOSE +#ifdef VERBOSE cout << DOWNMSG << endl; #endif @@ -1,14 +1,11 @@ #ifndef MSGS_H #define MSGS_H -// message templates. -// will post "nickname enters the chat" into the room. -#define USERENTR " enters the chat<br>\n" -#define USERLEAV " leaves the chat<br>\n" // several error messages which will apear by the clients. -#define E_NONICK "You need to specify a nick name<br><br>" -#define E_NOTONL "An error occured. Your nick is not online<br><br>" +#define E_ALPNUM "The nick you have specified is not alphanumeric, please change that.<br><br>" +#define E_NONICK "You need to specify a nick name.<br><br>" +#define E_NOTONL "An error occured. Your nick is not online.<br><br>" #define E_ONLINE "The nick you have specified is already online. Try another nick.<br><br>" // all the custom messages for verbosity outputs. this messages may not @@ -23,6 +20,7 @@ #define DESCRIP "yChat++ Copyright (C) 2003 Paul C. Buetow, Volker Richer " #define DOWNMSG "Shutting down " #define LOGINPR "Login procedure succeeded for nick " +#define MODULEC "Caching module " #define NEWROOM "Adding room " #define REQUEST "Request string " #define SEPERAT "----------------------------------------- " @@ -33,6 +31,6 @@ #define TECACHE "Caching template " #define THREADS "Starting thread job " #define THREADE "Exiting thread job " -#define VERSION "Version: 0.2" +#define VERSION "Version: yChat++ Basic 0.5.1" #endif @@ -1,7 +1,7 @@ // class mutx implementation. -#ifndef MUTX_CXX -#define MUTX_CXX +#ifndef s_mutx_CXX +#define s_mutx_CXX #include "mutx.h" @@ -1,7 +1,7 @@ // class mutx declaration. -#ifndef MUTX_H -#define MUTX_H +#ifndef s_mutx_H +#define s_mutx_H #include "incl.h" @@ -27,4 +27,6 @@ name::set_name( string s_name ) { this->s_name = s_name; } + + #endif @@ -14,15 +14,15 @@ protected: string s_name; // object's name. public: - // small inline methods: virtual string get_name ( ) const; virtual void set_name ( string s_name ); + // public methods: explicit name( ) { }; // a standard constructor. explicit name( string s_name ); // a standard constructor. + ~name( ); - ~name(); }; #endif @@ -5,17 +5,17 @@ #include "pool.h" -#include "CONF.h" -#include "MUTX.h" -#include "TOOL.h" +#include "s_conf.h" +#include "s_mutx.h" +#include "s_tool.h" #include "thrd.h" using namespace std; pool::pool() { - i_thrd_pool_size = TOOL::string2int( CONF::get().get_val( "THRDPOOL" ) ); - i_thrd_pool_queue = TOOL::string2int( CONF::get().get_val( "THRDQUEU" ) ); + i_thrd_pool_size = s_tool::string2int( s_conf::get().get_val( "THRDPOOL" ) ); + i_thrd_pool_queue = s_tool::string2int( s_conf::get().get_val( "THRDQUEU" ) ); tpool_init( &thread_pool, i_thrd_pool_size, i_thrd_pool_queue, 0 ); } @@ -34,9 +34,9 @@ pool::tpool_init( tpool_t *tpoolp, int num_worker_threads, int max_queue_size, i // allocate a pool data structure if (( tpool = (tpool_t) malloc( sizeof( struct tpool ) ) ) == NULL ) { - pthread_mutex_lock ( &MUTX::get().mut_stdout ); + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cerr << "malloc" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); exit(-1); } @@ -47,9 +47,9 @@ pool::tpool_init( tpool_t *tpoolp, int num_worker_threads, int max_queue_size, i if ( ( tpool->threads = (pthread_t*) malloc( sizeof( pthread_t ) *num_worker_threads ) ) == NULL ) { - pthread_mutex_lock ( &MUTX::get().mut_stdout ); + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cerr << "malloc" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); exit(-1); } @@ -61,33 +61,33 @@ pool::tpool_init( tpool_t *tpoolp, int num_worker_threads, int max_queue_size, i if ( ( rtn = pthread_mutex_init( &(tpool->queue_lock), NULL ) ) != 0 ) { - pthread_mutex_lock ( &MUTX::get().mut_stdout ); + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cerr << "pthread_mutex_init " << strerror( rtn ) << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); exit(-1); } else if ( ( rtn = pthread_cond_init( &(tpool->queue_not_empty), NULL ) ) != 0 ) { - pthread_mutex_lock ( &MUTX::get().mut_stdout ); + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cerr << "pthread_cond_init " << strerror( rtn ) << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); exit(-1); } else if ( ( rtn = pthread_cond_init( &(tpool->queue_not_full), NULL ) ) != 0 ) { - pthread_mutex_lock ( &MUTX::get().mut_stdout ); + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cerr << "pthread_cond_init " << strerror( rtn ) << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); exit(-1); } else if ( ( rtn = pthread_cond_init( &(tpool->queue_empty), NULL ) ) != 0 ) { - pthread_mutex_lock ( &MUTX::get().mut_stdout ); + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cerr << "pthread_cond_init " << strerror( rtn ) << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); exit(-1); } // create threads @@ -140,10 +140,10 @@ pool::tpool_thread( void* arg ) void pool::run_func( void *v_pointer ) { -#ifdef _VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cout << THREADS << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); #endif // recasting the client thread object. @@ -157,10 +157,10 @@ void pool::run_func( void *v_pointer ) free(v_pointer); -#ifdef _VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cout << THREADE << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); #endif } @@ -197,7 +197,6 @@ pool::tpool_add_work( tpool_t tpool, void(*routine)(void*), void* arg ) /// if( tpool->cur_queue_size == 0 ) { tpool->queue_tail = tpool->queue_head = workp; - pthread_cond_signal( &(tpool->queue_not_empty) ); } else @@ -207,6 +206,7 @@ pool::tpool_add_work( tpool_t tpool, void(*routine)(void*), void* arg ) /// } tpool->cur_queue_size++; + pthread_cond_signal( &(tpool->queue_not_empty) ); pthread_mutex_unlock( &(tpool->queue_lock) ); return 1; } @@ -4,20 +4,20 @@ #define REQP_CXX #include "reqp.h" -#include "CHAT.h" -#include "HTML.h" -#include "MUTX.h" -#include "sock.h" - +#include "s_chat.h" +#include "s_html.h" +#include "s_mutx.h" +#include "s_sock.h" +#include "s_tool.h" using namespace std; // inititialization of static members. string reqp::HTTP_CODEOK = "HTTP/1.1 200 OK\n"; string reqp::HTTP_SERVER = "Server: yChat (Unix)\n"; string reqp::HTTP_CONTAC = "Contact: www.yChat.org\n"; -string reqp::HTTP_CACHEC = "Cash-control: no-cache\n"; +string reqp::HTTP_CACHEC = "Expires: 0\nCache-control: no-cache\nPragma: no-cache\n"; string reqp::HTTP_CONNEC = "Connection: keep-alive\n"; -string reqp::HTTP_COTYPE = "Content-Type: text/html\n\n"; +string reqp::HTTP_COTYPE = "Content-Type: "; reqp::reqp( ) { @@ -73,7 +73,10 @@ reqp::get_url( thrd* p_thrd, string s_req, map_string &map_params ) if ( i_request == RQ_POST && s_params.empty() ) { char c_req[READBUF]; - read ( p_thrd->get_sock() , c_req, READBUF ); + + if ( read ( p_thrd->get_sock() , c_req, READBUF ) <= 0 ) + return "NOBYTE"; + s_params = string( strstr( c_req, "event" ) ); } @@ -100,17 +103,57 @@ reqp::get_url( thrd* p_thrd, string s_req, map_string &map_params ) } while( true ); -#ifdef _VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); cout << REQUEST << s_ret << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); #endif + if ( s_ret.empty() ) + s_ret = s_conf::get().get_val( "STARTMPL" ); + map_params["request"] = s_ret; return s_ret; } +string +reqp::get_content_type( string s_file ) +{ + string s_ext=s_tool::getExtension( s_file ); + + if(s_ext=="") + s_ext="DEFAULT"; + + return s_conf::get().get_val( "CT_"+s_ext ); +} +void +reqp::parse_headers( string s_req, map_string &map_params ) +{ + int pos = s_req.find("\n"); + if(pos!=string::npos) + map_params["QUERY_STRING"]=s_tool::trim(s_req.substr(0,pos-1)); + + while(pos!=string::npos) + { + auto string s_line=s_req.substr(0,pos); + auto int pos2=s_line.find(":"); + if(pos2!=string::npos) + { + auto string key=s_tool::trim(s_line.substr(0, pos2)); + auto string value=s_tool::trim(s_line.substr(pos2+1)); + + map_params[key]=value; + + + } + s_req=s_req.substr(s_line.size()+1); + pos=s_req.find("\n"); + } + +} + + int reqp::htoi(string *s) { @@ -173,49 +216,73 @@ reqp::get_from_header( string s_req, string s_hdr ) string reqp::parse( thrd* p_thrd, string s_req, map_string &map_params ) { + + // store all request informations in map_params. store the url in + // map_params["request"]. + + if ( get_url( p_thrd, s_req, map_params ).compare("NOBYTE") == 0 ) + map_params["request"] = s_conf::get().get_val("NOTFOUND"); + + parse_headers( s_req, map_params ); // create the http header. string s_rep( HTTP_CODEOK ); s_rep.append( HTTP_SERVER ); s_rep.append( HTTP_CONTAC ); s_rep.append( HTTP_CACHEC ); s_rep.append( HTTP_CONNEC ); s_rep.append( HTTP_COTYPE ); - - // store all request informations in map_params. store the url in - // map_params["request"]. - get_url( p_thrd, s_req, map_params ); + s_rep.append( get_content_type( map_params["request"] ) ); + s_rep.append("\r\n\r\n"); // check the event variable. + string s_event( map_params["event"] ); if ( ! s_event.empty() ) { // login procedure. if ( s_event == "login" ) { - CHAT::get().login( map_params ); + s_chat::get().login( map_params ); } else { bool b_found; - user* u_user = CHAT::get().get_user( map_params["nick"], b_found ); - + +// user* p_user = s_chat::get().get_user( map_params["nick"], b_found ); + sess *sess_temp=s_sman::get().getSession( map_params["tmpid"] ); + user *p_user; + if(sess_temp!=NULL) + { + string *s_nick=static_cast<string*>(sess_temp->getValue(string("nick"))); + p_user = s_chat::get().get_user( *s_nick, b_found); + } + else + return s_rep; if ( ! b_found ) { map_params["INFO"] = E_NOTONL; - map_params["request"] = CONF::get().get_val( "STARTMPL" ); // redirect to the startpage. + map_params["request"] = s_conf::get().get_val( "STARTMPL" ); // redirect to the startpage. } - // if a message post. else if ( s_event == "post" ) - CHAT::get().post( u_user, map_params ); + s_chat::get().post( p_user, map_params ); + + + // if a chat stream + else if ( s_event == "stream" ) + { + string s_msg(s_html::get().parse( map_params ) ); + p_user->msg_post( &s_msg); + s_sock::get().chat_stream( p_thrd->get_sock(), p_user, map_params ); + } // if a request for the online list of the active room. else if ( s_event == "online" ) - HTML::get().online_list( u_user, map_params ); + s_html::get().online_list( p_user, map_params ); } } // parse and get the requested html-template and also use // the values stored in map_params for %%KEY%% substituations. - s_rep.append( HTML::get().parse( map_params ) ); + s_rep.append( s_html::get().parse( map_params ) ); // return the parsed html-template. return s_rep; @@ -24,7 +24,7 @@ private: HTTP_CACHEC, HTTP_CONNEC, HTTP_COTYPE; - + // returns the request url from thr client's http request header // until the first "?" and stores all request parameter values // ( behind "?" ) into map_params. @@ -39,7 +39,9 @@ public: // public methods. explicit reqp( ); // simple constructor. virtual string parse( thrd* p_thrd, string s_req, map_string &map_params ); - virtual string url_decode (string ); + virtual string url_decode ( string ); + virtual string get_content_type( string ); + virtual void parse_headers( string s_req, map_string &map_params ); }; #endif @@ -4,13 +4,13 @@ #define ROOM_H #include "incl.h" -#include "data.h" +#include "base.h" #include "name.h" #include "user.h" using namespace std; -class room : public data<user>, public name +class room : public base<user>, public name { private: @@ -13,7 +13,7 @@ private: public: static void init() { - obj = new conf( s_confILE ); + obj = new conf( CONFILE ); } static conf& get() @@ -20,6 +20,34 @@ s_tool::is_alpha_numeric( string &s_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 ) { @@ -10,6 +10,7 @@ class s_tool public: static bool is_alpha_numeric( string &s_digit ); static int string2int( string s_digit ); + static string trim( string s_str ); static long unixtime(); static void strip_html( string *s_str); static string getExtension( string s_file ); @@ -1,17 +1,18 @@ // 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 SOCK_CXX -#define SOCK_CXX +#ifndef s_sock_CXX +#define s_sock_CXX #include <unistd.h> #include "sock.h" -#include "CHAT.h" -#include "CONF.h" -#include "MUTX.h" -#include "TOOL.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" @@ -23,25 +24,32 @@ sock::sock() this->i_req = 0; this->req_parser = new reqp(); this->thrd_pool = new pool(); + this->log_daemon = new logd(s_conf::get().get_val( "ACCESS_LOG" )); } void -sock::chat_stream( int i_sock, map_string &map_params ) +sock::chat_stream( int i_sock, user* p_user, map_string &map_params ) { - user* p_user = CHAT::get().get_user( map_params["nick"] ); - p_user->set_sock( i_sock ); - - string s_msg( "" ); + string s_msg( "\n" ); pthread_mutex_lock ( &(p_user->mut_message) ); - while( p_user->get_online() ) + for ( int i = 0; i < PUSHSTR; i++ ) + send( i_sock, s_msg.c_str(), s_msg.size(), 0 ); + + do { - pthread_cond_wait( &(p_user->cond_message), &(p_user->mut_message) ); 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) ); @@ -50,7 +58,11 @@ sock::chat_stream( int i_sock, map_string &map_params ) 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( USERLEAV ) ) ); + 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(); } @@ -114,18 +126,26 @@ sock::read_write( thrd* p_thrd, int i_sock ) // stores the request params. map_string map_params; - // get the s_rep ( HTML response which will be send imediatly to the client + // 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 ); + string s_rep = req_parser->parse( p_thrd, string( c_req ), map_params ); // send s_rep to the client. + log_daemon->log(map_params); + send( i_sock, s_rep.c_str(), s_rep.size(), 0 ); - // prove if this is a request for a chat stream! - if ( map_params["event"] == "stream" ) - chat_stream( i_sock, map_params ); + // dont need those vals anymore. + map_params.clear(); return 0; } @@ -136,7 +156,7 @@ sock::read_write( thrd* p_thrd, int i_sock ) int sock::start() { - auto int i_port = TOOL::string2int( CONF::get().get_val( "SRVRPORT" ) ); + auto int i_port = s_tool::string2int( s_conf::get().get_val( "SRVRPORT" ) ); int sock; fd_set active_fd_set, read_fd_set; @@ -144,7 +164,7 @@ sock::start() struct sockaddr_in clientname; size_t size; -#ifdef _VERBOSE +#ifdef VERBOSE cout << SOCKCRT << "localhost:" << i_port << endl; #endif @@ -157,7 +177,7 @@ sock::start() exit( EXIT_FAILURE ); } -#ifdef _VERBOSE +#ifdef VERBOSE cout << SOCKRDY << endl; #endif @@ -195,7 +215,7 @@ sock::start() close ( new_sock ); } -#ifdef _VERBOSE +#ifdef VERBOSE cout << CONNECT << i_req << " " << inet_ntoa( clientname.sin_addr ) << ":" @@ -1,7 +1,7 @@ // class sock declaration. -#ifndef SOCK_H -#define SOCK_H +#ifndef s_sock_H +#define s_sock_H #include <queue> #include <arpa/inet.h> @@ -18,7 +18,8 @@ #include "pool.h" #include "reqp.h" #include "thrd.h" - +#include "user.h" +#include "logd.h" using namespace std; class sock @@ -30,10 +31,7 @@ private: bool b_run; // true while socket manager is running. reqp* req_parser; // parses the http requests from clients. pool* thrd_pool; // the thread pool. - - // the chat stream there all the chat messages will sent through. - static void chat_stream( int i_sock, map_string &map_params ); - + logd* log_daemon; // the log daemon // creates a server socket. virtual int make_socket( uint16_t port ); @@ -46,6 +44,10 @@ public: 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 @@ -4,7 +4,7 @@ #define THRD_CXX #include "thrd.h" -#include "SOCK.h" +#include "s_sock.h" using namespace std; @@ -16,12 +16,13 @@ thrd::thrd( int i_sock ) thrd::~thrd() { shutdown ( get_sock() , 2 ); + close ( get_sock() ); } void thrd::run() { - SOCK::get().read_write( this, i_sock ); + s_sock::get().read_write( this, i_sock ); } #endif @@ -1,7 +1,11 @@ +BRAIN-STORMING: + mysql -tempid +security: tempid and crypto commands -hash_maps -free pthread memory ( reusable thread pool ? ) -pthread mode 2 -semaphore sync ( ?? ) +hash_map []-operator +hash_map in cont +several different html templatetes + +10: bugfixes +20: goto 10 @@ -4,16 +4,17 @@ #define USER_CXX #include "user.h" -#include "CONF.h" -#include "TOOL.h" +#include "s_conf.h" +#include "s_modl.h" +#include "s_tool.h" using namespace std; user::user( string s_name ) : name( s_name ) { this -> b_online = true; - this -> l_time = TOOL::unixtime(); - this -> s_col1 = CONF::get().get_val( "USERCOL1" ); + 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); @@ -112,10 +113,36 @@ user::set_sock( int i_sock ) } void +user::command( string &s_command ) +{ + + auto unsigned int pos = s_command.find( "/" ); + while( pos != string::npos ) + { + s_command.replace( pos, 1, "" ); + pos = s_command.find( "/" ); + } + + string s_mod( "cmnd/yc_" ); + s_mod.append( s_command ).append( ".so" ); + + dynmod *mod = s_modl::get().get_module( s_mod ); + + if ( mod == NULL ) + { + msg_post( new string( s_lang::get().get_val( "ERRORCMD" ) ) ); + return; + } + + // execute the module. + ( *(mod->the_func) ) ( (void*) this ); +} + +void user::renew_stamp( ) { pthread_mutex_lock ( &mut_l_time ); - l_time = TOOL::unixtime(); + l_time = s_tool::unixtime(); pthread_mutex_unlock( &mut_l_time ); } @@ -3,8 +3,9 @@ #define USER_H #include "incl.h" +#include "hmap.h" #include "name.h" - +#include "s_lang.h" using namespace std; class room; @@ -19,6 +20,7 @@ private: 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. @@ -37,6 +39,8 @@ public: // 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; } @@ -61,19 +65,20 @@ public: virtual int get_sock ( ); virtual void set_sock ( int i_sock ); - - virtual void renew_stamp(); + // executes a command. + virtual void command( string &s_command ); // 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 |
