summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradmin (centauri.fritz.box) <puppet@mx.buetow.org>2014-06-30 23:29:37 +0200
committeradmin (centauri.fritz.box) <puppet@mx.buetow.org>2014-06-30 23:29:37 +0200
commit751eada68e49f9ffae9a0be743d88a3ce956883f (patch)
tree153d0a87fbe67911da4fde73e327b272b437c156
parent002c8534bfe2c266959dd42c9c71c17182977d87 (diff)
parentdee37a84ae65ba8bd1e0dab6132955bbc195fa57 (diff)
Merge remote-tracking branch 'remotes/github/0.7' into 0.70.7@210.7
-rw-r--r--CHANGES204
-rw-r--r--INSTALL1
-rw-r--r--Makefile85
-rw-r--r--README542
-rw-r--r--SHORTDESC4
-rwxr-xr-xconfigure76
-rw-r--r--docs/header.txt5
-rw-r--r--docs/yhttpd.txt3
-rw-r--r--etc/ychat.conf690
-rw-r--r--html/admin.html33
-rw-r--r--html/colors.html416
-rw-r--r--html/demo.html27
-rw-r--r--html/favicon.icobin2239 -> 2238 bytes
-rw-r--r--html/frameset.html12
-rw-r--r--html/help.html28
-rw-r--r--html/images/away.gifbin0 -> 141 bytes
-rw-r--r--html/images/blank.gifbin0 -> 43 bytes
-rw-r--r--html/images/guest.pngbin0 -> 260 bytes
-rw-r--r--html/images/ircuser.pngbin0 -> 282 bytes
-rw-r--r--html/images/rang0.pngbin0 -> 390 bytes
-rw-r--r--html/images/rang1.pngbin0 -> 261 bytes
-rw-r--r--html/images/rang2.pngbin0 -> 282 bytes
-rw-r--r--html/index.html46
-rw-r--r--html/input.html52
-rw-r--r--html/loggedin.html27
-rw-r--r--html/notfound.html4
-rw-r--r--html/online.html21
-rw-r--r--html/options.html50
-rw-r--r--html/register.html53
-rw-r--r--html/robots.txt2
-rw-r--r--html/stream.html42
-rw-r--r--html/style.css45
-rw-r--r--html/test.cgi9
-rw-r--r--html/urlredirect.html9
-rw-r--r--log/.keepme0
-rw-r--r--log/rooms/.keepme0
-rw-r--r--scripts/README6
-rwxr-xr-xscripts/astyle.sh3
-rwxr-xr-xscripts/buildnr.pl26
-rwxr-xr-xscripts/checkperl.sh13
-rwxr-xr-xscripts/config.pl144
-rwxr-xr-xscripts/makedist.sh27
-rwxr-xr-xscripts/makeyhttpd.pl198
-rwxr-xr-xscripts/screen.sh3
-rwxr-xr-xscripts/setglobvals.pl32
-rwxr-xr-xscripts/version.sh9
-rw-r--r--src/Makefile.in34
-rw-r--r--src/chat/base.h119
-rw-r--r--src/chat/base.tmpl85
-rw-r--r--src/chat/chat.cpp394
-rw-r--r--src/chat/chat.h87
-rw-r--r--src/chat/gcol.cpp209
-rw-r--r--src/chat/gcol.h67
-rw-r--r--src/chat/perm.cpp107
-rw-r--r--src/chat/perm.h66
-rw-r--r--src/chat/room.cpp138
-rw-r--r--src/chat/room.h117
-rw-r--r--src/chat/sess.cpp80
-rw-r--r--src/chat/sess.h55
-rw-r--r--src/chat/sman.cpp153
-rw-r--r--src/chat/sman.h66
-rw-r--r--src/chat/user.cpp619
-rw-r--r--src/chat/user.h163
-rw-r--r--src/cli/cli.cpp376
-rw-r--r--src/cli/cli.h85
-rw-r--r--src/conf/conf.cpp204
-rw-r--r--src/conf/conf.h53
-rwxr-xr-xsrc/configure1875
-rw-r--r--src/contrib/README5
-rw-r--r--src/contrib/crypt/how1
-rw-r--r--src/contrib/crypt/md5.cpp294
-rw-r--r--src/contrib/crypt/md5.h58
-rw-r--r--src/contrib/crypt/md5crypt.cpp186
-rw-r--r--src/contrib/xml/README504
-rw-r--r--src/contrib/xml/tinyxml.cpp1452
-rw-r--r--src/contrib/xml/tinyxml.h1654
-rw-r--r--src/contrib/xml/tinyxmlerror.cpp75
-rw-r--r--src/contrib/xml/tinyxmlparser.cpp1577
-rw-r--r--src/data/README4
-rw-r--r--src/data/con.cpp68
-rw-r--r--src/data/con.h46
-rw-r--r--src/data/con_base.cpp43
-rw-r--r--src/data/con_base.h43
-rw-r--r--src/data/data.cpp227
-rw-r--r--src/data/data.h53
-rw-r--r--src/data/data_base.cpp251
-rw-r--r--src/data/data_base.h72
-rw-r--r--src/glob.h236
-rw-r--r--src/html.cpp191
-rw-r--r--src/html.h57
-rw-r--r--src/incl.h24
-rw-r--r--src/logd.cpp199
-rw-r--r--src/logd.h61
-rw-r--r--src/main.cpp146
-rw-r--r--src/maps/hashmap.h77
-rw-r--r--src/maps/hashmap.tmpl150
-rw-r--r--src/maps/mtools.h35
-rw-r--r--src/maps/mtools.tmpl36
-rw-r--r--src/maps/nhashmap.h45
-rw-r--r--src/maps/nhashmap.tmpl35
-rw-r--r--src/maps/shashmap.h73
-rw-r--r--src/maps/shashmap.tmpl179
-rw-r--r--src/modl.cpp195
-rw-r--r--src/modl.h63
-rw-r--r--src/mods/Makefile9
-rw-r--r--src/mods/commands/Makefile.in18
-rw-r--r--src/mods/commands/yc_about.cpp83
-rw-r--r--src/mods/commands/yc_all.cpp73
-rw-r--r--src/mods/commands/yc_away.cpp96
-rw-r--r--src/mods/commands/yc_col.cpp112
-rw-r--r--src/mods/commands/yc_compopt.cpp47
-rw-r--r--src/mods/commands/yc_exec.cpp90
-rw-r--r--src/mods/commands/yc_fake.cpp54
-rw-r--r--src/mods/commands/yc_getroom.cpp77
-rw-r--r--src/mods/commands/yc_getrusage.cpp81
-rw-r--r--src/mods/commands/yc_help.cpp76
-rw-r--r--src/mods/commands/yc_invisible.cpp55
-rw-r--r--src/mods/commands/yc_j.cpp128
-rw-r--r--src/mods/commands/yc_ko.cpp96
-rw-r--r--src/mods/commands/yc_m.cpp68
-rw-r--r--src/mods/commands/yc_md5.cpp78
-rw-r--r--src/mods/commands/yc_me.cpp69
-rw-r--r--src/mods/commands/yc_morph.cpp76
-rw-r--r--src/mods/commands/yc_msg.cpp92
-rw-r--r--src/mods/commands/yc_q.cpp54
-rw-r--r--src/mods/commands/yc_reload.cpp49
-rw-r--r--src/mods/commands/yc_ren.cpp98
-rw-r--r--src/mods/commands/yc_s.cpp72
-rw-r--r--src/mods/commands/yc_set.cpp124
-rw-r--r--src/mods/commands/yc_template.cpp49
-rw-r--r--src/mods/commands/yc_time.cpp46
-rw-r--r--src/mods/commands/yc_topic.cpp102
-rw-r--r--src/mods/commands/yc_uptime.cpp46
-rw-r--r--src/mods/commands/yc_users.cpp52
-rw-r--r--src/mods/commands/yc_version.cpp47
-rwxr-xr-xsrc/mods/configure26
-rw-r--r--src/mods/html/Makefile.in18
-rw-r--r--src/mods/html/yc_admin.cpp96
-rw-r--r--src/mods/html/yc_colors.cpp61
-rw-r--r--src/mods/html/yc_help.cpp74
-rw-r--r--src/mods/html/yc_loggedin.cpp53
-rw-r--r--src/mods/html/yc_options.cpp80
-rw-r--r--src/mods/html/yc_register.cpp120
-rw-r--r--src/monitor/dump.cpp141
-rw-r--r--src/monitor/dump.h75
-rw-r--r--src/monitor/stats.cpp174
-rw-r--r--src/monitor/stats.h73
-rw-r--r--src/msgs.h163
-rw-r--r--src/name.cpp43
-rw-r--r--src/name.h29
-rw-r--r--src/ncur/menu.cpp141
-rw-r--r--src/ncur/menu.h63
-rw-r--r--src/ncur/ncur.cpp314
-rw-r--r--src/ncur/ncur.h75
-rw-r--r--src/reqp.cpp604
-rw-r--r--src/reqp.h64
-rw-r--r--src/sign.cpp92
-rw-r--r--src/sign.h45
-rw-r--r--src/sock/sock.cpp544
-rw-r--r--src/sock/sock.h112
-rw-r--r--src/thrd/pool.cpp181
-rw-r--r--src/thrd/pool.h79
-rw-r--r--src/thrd/thro.cpp67
-rw-r--r--src/thrd/thro.h54
-rw-r--r--src/time/timo.cpp62
-rw-r--r--src/time/timo.h46
-rw-r--r--src/time/timr.cpp218
-rw-r--r--src/time/timr.h88
-rw-r--r--src/tool/dir.cpp90
-rw-r--r--src/tool/dir.h59
-rw-r--r--src/tool/tool.cpp264
-rw-r--r--src/tool/tool.h53
-rw-r--r--src/wrap.cpp169
-rw-r--r--src/wrap.h154
174 files changed, 21109 insertions, 2486 deletions
diff --git a/CHANGES b/CHANGES
index 7ebb73a..69f4e97 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,36 +1,170 @@
-Changes from 0.5.5-STABLERELEASE to 0.5.6-BASIC
-- Rearanged the startup messages
-- Set 2000 as the standard port (3000 has been used before)
-- Run astyle on src/*.{h,cpp}
-- Fixed some errors in the README file
-- Added the SHORTDESC file
-- Changed Copyright to EXA Digital Solutions
-- Added .pm to scripts/stats.pl
-- Modified the README (New CVS pserver)
-- Added the headers and header rules to the Makefile
-- Added the docs directory and the containing header.txt file which
- does have a header skel for the source files (all source files now do
- have a new source header containgin copyrights)
-- The ychat-0.5 CVS branch now also has ychat-basic as its synonym
-- Added the replace rule to the top level Makefile
-
-Changes from 0.5.4-STABLERELEASE to 0.5.5-STABLERELEASE
-- Added scripts/version.sh (can be invoked by gmake version)
-- Fixed a bug in the session manager.
-- Removed the large animated GIF graphic.
-
-Changes from 0.5.3-LEGACYRELEASE to 0.5.4-STABLERELEASE
-- Backported reqp::get_url from yChat 0.7.8-CURRENT.
-- Tagged 0.5-STABLE
-
-Changes from 0.5.2-LEGACYRELEASE to 0.5.3-LEGACYRLEASE
-- Code cleanup
-- Added ./scripts/*
-- Added gmake stats option
-
-Changes from 0.5.1-RELEASE to 0.5.2-LEGACYRLEASE
-- Changed this branch into a LEGACY branch.
-- Rewrote the dynamic thread pool (backport from 0.7.8-CURRENT).
-- Added scripts/*
-- Code now uses ANSI C++ style with 2 space code indenting.
+-Changes from 0.7.9.5-STABLERELEASE to 0.7.9.6-STABLE
+$ Typos
+$ Using XHTML now instead of HTML
+$ New CSS Style
+-Changes from 0.7.9.4-STABLERELEASE to 0.7.9.5-STABLERELEASE -
+$ Added .pm to scripts/stats.pl
+$ Modified the README (New CVS pserver)
+$ Added docs/header.txt as a source header skel
+$ All .cpp, .h and .tmpl files now do have a new source header
+$ containging copyright infos etc.
+$ Bugfix in src/sock/sock.cpp (No clear() w/ ncurses disabled)
+$ Bugfix in src/cli/cli.cpp (No more segfault by reading empty strings
+$ or commands with leading whitespaces)
+
+-Changes from 0.7.9.3-STABLERELEASE to 0.7.9.4-STABLERELEASE -
+$ Removed the TODO list. All major feature changes will be in the CURRENT
+$ branch.
+$ Added the SHORTDESC file
+$ Changed Copyright to "EXA Digital Solutions GbR"
+
+-Changes from 0.7.9.2-RELEASE to 0.7.9.3-STABLERELEASE -
+$ The 0.7 branch is now STABLE.
+$ Modified the Makefiles, so that they produce valid output while using
+$ the -j flag of gmake.
+$ Fixed a mini bug in the src/configure script.
+$ Backported some security related HTTP patches from the 0.8-CURRENT branch.
+
+-Changes from 0.7.9.1-RELEASE to 0.7.9.2-RELEASE -
+$ Added monitor/dump, and the dump command to the CLI.
+$ Fixed a bug in the session manager.
+$ Added gmake dist do the README.
+$ Added the charset to the HTTP-header.
+
+-Changes from 0.7.9-RELEASE to 0.7.9.1-RELEASE -
+$ Fixed etc/ychat.conf (Its now valid XML)
+$ Fixed some typos.
+$ Added the scripts/makedist.sh script, which can be invoked by gmake dist.
+$ yhttpd.org has been renamed to yChat.org. The yhttpd.org SLD will be
+$ canceled! The yhttpd.org Homepage will remain on yChat.org!
+
+-Changes from 0.7.8-RELEASE to 0.7.9-RELEASE -
+$ In the system messages will be the user printed which has requested the
+ specified module.
+$ Removed the cursor from the ncurses interface.
+$ Added wrap::init_wrappers -> The main.cpp is now shorter.
+$ Added some Makefile modifications
+$ Bugfix: cleanipcache shouldn run every minute but every 10!
+$ Bugfix: scripts/stats.pl now counts all text-files properly.
+
+-Changes from 0.7.7.1-RELEASE to 0.7.8-RELEASE -
+$ Updated the yhttpd generation script due new sources in src/memb.
+$ Changd some hashmaps back into simple std::map objects, this might
+$ has resulted in some bugs due slow hashmap initialization time.
+$ Hashmaps now only should being used on permanent objects.
+$ Rewrote the dynamic thread pool.
+$ makeyhttpd now also removes the yChat specific form etc/yhttpd.conf
+$ automatically.
+$ Implemnted an IP Cache (makes yChat faster).
+$ Implemented signal catcher:
+$ SIGUSR1 will clear the html template cache.
+$ SIGUSR2 will reload the dynamic modules.
+$ SIGSEGV can be catched if defined in src/glob.h.
+$ SIGHUP, SIGINT and SIGTERM will shutdown yChat cleanly.
+$ Added Allow: GET to the HTTP header.
+$ Bugfix: The httpd.logging.accesslines now will be read correctly.
+$ Bugfix: JavaScript messages now wont be logged.
+
+-Changes from 0.7.7-RELEASE to 0.7.7.1-RELEASE -
+$ Bugfix in main.cpp which resulted in a core dump on yChat startup.
+
+-Changes from 0.7.6-RELEASE to 0.7.7-RELEASE -
+$ Major code cleanup.
+$ Bugfix in /col.
+$ Bugfix in gcol #1 (destroy session also if no database is used).
+$ Bugfix in gcol #2 (now runs each hour not once a day).
+$ Renew the style.css and stream.html.
+
+-Changes from 0.7.5-RELEASE to 0.7.6-RELEASE -
+$ Removed the old hash maps and included the SGI C++ STL extenstion
+$ hash_map.
+
+-Changes from 0.7.4.1-RELEASE to 0.7.5-RELEASE -
+$ Garbage collector will now run once a hour rather than each ten minutes.
+$ Dynamic thread pool improvements.
+$ Removed equiv-http-refresh meta tag from the online list.
+$ Minor bugfix in the /topic command.
+$ Implemented "User list".
+
+-Changes from 0.7.4-RELEASE to 0.7.4.1-RELEASE -
+$ Dynamic thread pool bugfix (dead lock).
+
+-Changes from 0.7.3-RELEASE to 0.7.4-RELEASE -
+$ Code cleanup.
+$ Made the thread pool increasing dynamic.
+$ Added some thread pool optimazions.
+$ Added some more ${MAKE} vars to the Makefiles.
+$ Added Content-length to the HTTPD header.
+$ Added the !command to the command line interface.
+$ Added Content-type text/plain.
+$ Added scrolling checkbox to input.html.
+$ Removed modl from yhttpd. Dynamic modules are not needed in yhttpd yet.
+$ Improved session engine.
+$ Fixed auto logout bug.
+$ Fixed newline bug (one \n too much for each html template).
+$ Logging can now be completely disabled.
+
+-Changes from 0.7.2 to 0.7.3-RELEASE -
+$ Added FreeBSD 5.3-RELEASE support.
+$ Added chat.enableguest option.
+$ Added the /all command (Global system message).
+$ Renamed the /getstatus command into /about.
+$ Fixed the &-bug (& should be allowed in messages). \AND is now a
+$ synonym for & too.
+$ Fixed the /msg bug (In /msg the string replacer should be activated).
+$ Fixed logging bug (do not log any timestamps if there are no messages).
+
+-Changes from 0.7.1 to 0.7.2-RELEASE -
+$ New features:
+$ /morph.
+$ Added the new standard html template design.
+$ Bugfixes:
+$ /away prints a . instead of a : if no away reason is given.
+$ /ko message was wrong. Displayed not room name of the user to be kicked out.
+$ /invisible command displayed wrong private messages.
+$ /getstatus had no help text.
+$ /msg and /s should now print the system time if printalwaystime == true.
+$ Added a blank to the /uptime message.
+$ /topic now prints the topic in the user's color.
+$ Fixed some typos.
+
+-Changes from 0.7.0 to 0.7.1-RELEASE -
+$ Added ${MAKE} to the config file because some Linux distros dont use
+$ the "gmake" command for GNU make but just "make"! Modified the
+$ configure script to generate a make.version file.
+$ Removed some typos from the ychat.conf.
+$ Fixed the auto away message. This one will be posted in the room
+$ as public rather than only private to the auto-away-user.
+$ Fixed some documentation stuff for yhttpd because yhttpd does not
+$ need MySQL at all.
+$ Added the chat.maxlength.word option.
+
+-Changes from 0.6 to 0.7.0-RELEASE -
+$ Better stability .
+$ Better performance (using more hmaps).
+$ HTML color switcher menu.
+$ New commands: /away /room /j /ren.
+$ Simple garbage collector for old user and room objects.
+$ Use of the database (MySQL).
+$ Nick registration and password protection.
+$ Status images for Operator, Half-Operator, Voiced user and Guests.
+$ New Makefiles.
+$ Useful Perl scripts for sourcecode stats generation etc.
+$ Added system_log and room logging to access_log logging.
+$ Added time-offset option.
+$ Added to the admin interface new options.
+$ Added Logout button.
+$ Added string replacer there certain substr. of postings will be replaced by another string (such as smiley images).
+$ Added Superuser levels and the /ko and /set commands.
+$ Added admin CLI (Command Line Interface) mode.
+$ Added memory rusage history which tracks memory usage for the last 10 days.
+$ Added HTTP POST request parsing.
+$ Made yChat more modular so yhttpd can be extracted from it
+$ (scripts/makeyhttpd.pl).
+$ Added CGI support.
+$ Rewrote big parts of the Makefiles and the configure scripts.
+$ Made it compatible to GNU G++ 3.4, 3.3, 3.2 and 3.1 (3.0 and earlier do not
+$ work).
+$ XML based configuration file (ychat.conf).
+$ Added default operator option: chat.defaultop.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..b112205
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1 @@
+See the README file.
diff --git a/Makefile b/Makefile
index 4842efd..a8cf882 100644
--- a/Makefile
+++ b/Makefile
@@ -1,28 +1,92 @@
-MAKE=gmake
+MAKE=`tail -n 1 make.version`
+PREFIX=`grep "define PREFIX" src/glob.h | cut -d'"' -f2`
HEADER?=docs/header.txt
-all: base
- @echo "Now edit the ./conf.txt file and run ./ychat!"
+all: version base modules
+ @echo "Now edit the ychat.conf and run ychat!"
+ @echo "The config file is searched in the following order:"
+ @echo " ./ychat.conf "
+ @echo " ~/.ychat/ychat.conf "
+ @echo " ./etc/ychat.conf "
+ @echo " /etc/ychat.conf "
+ @echo " $(PREFIX)/etc/ychat.conf "
+ @echo If you want to help the yChat project please run gmake mail
+ @echo so that the developers receive an email about the platform
+ @echo being used.
+ @echo WARNING! This software is EXPERIMENTAL!
+mail:
+ @echo "VERSION:" > mail.tmp
+ @${MAKE} version >> mail.tmp
+ @echo >> mail.tmp
+ @echo "UNAME:" >> mail.tmp
+ @uname -a >> mail.tmp
+ @echo >> mail.tmp
+ @echo "DATE:" >> mail.tmp
+ @date >> mail.tmp
+ @echo >> mail.tmp
+ @echo "COMPILER AND MAKE:" >> mail.tmp
+ @cat g++.version make.version >> mail.tmp
+ @cat mail.tmp | mail -s "Successfull build of yChat" successfullbuild@yhttpd.org
+ @rm -f mail.tmp
install: deinstall
uninstall: deinstall
deinstall:
@echo Install/deinstall is not supported!
- @echo Start yChat with ./ychat instead!
+ @echo Start yChat with ./bin/ychat instead!
@exit 1
+modules:
+ @if test -d ./src/mods; then ${MAKE} -C ./src/mods; fi
+clean_modules:
+ @if test -d ./src/mods; then ${MAKE} -C ./src/mods clean; fi
base:
+ @if test -f bin/ychat; then echo "Backing up old binary";if test -f bin/ychat.old; then rm -f bin/ychat.old; fi; mv bin/ychat bin/ychat.old; fi
+ @perl ./scripts/buildnr.pl
+ @perl ./scripts/setglobvals.pl
@${MAKE} -C ./src
clean_base:
@${MAKE} -C ./src clean
stats:
@perl scripts/stats.pl
run:
- ./ychat
+ ./bin/ychat
+base_start: base
+ ./bin/ychat
gpl:
@more COPYING
-clean: clean_base
-debug:
- @gdb ./ychat ychat.core
+#//<<*
+yhttpdbase:
+ @perl scripts/makeyhttpd.pl || echo "You need to have perl to do this!"
+ @echo yhttpd code base has been generated in ../yhttpd
+#//*>>
+clean: clean_base clean_modules
+help:
+ @echo "You may run ${MAKE} with the following parameters:"
+ @grep "^ ${MAKE} " README
+ @echo "For more questions read the README file or contact mail@ychat.org!"
+setup:
+ @./configure
+ @${MAKE}
+config:
+ @sh -c "scripts/config.sh"
+ @echo If you run ${MAKE} config from the command line then you may need
+ @echo to rerun ./configure and recompile all now!
+
+mrproper: clean
+ @if test -f src/glob.h.org; then mv -f src/glob.h.org src/glob.h;fi
+ @if test -f g++.version; then rm -f g++.version; fi
+ @if test -f make.version; then rm -f make.version; fi
+ @if test -f src/Makefile; then rm -f src/Makefile; fi
+ @if test -f bin/ychat; then find bin/ -name "*ychat*" | xargs rm -f; fi
+ @if test -d src/mods; then find src/mods/*/ -name Makefile | xargs rm -f; fi
+ @find . -name "*.add" | xargs rm -f
+ @ls | grep core | xargs rm -f
version:
- @sh ./scripts/version.sh
+ @./scripts/version.sh
+debug:
+ @gdb bin/ychat ychat.core
+confdebug:
+ ./configure -g3 -ggdb
+dist:
+ @./scripts/makedist.sh
headers:
@find -E ./ -regex '\./src/.*\.(h|(cpp)|(tmpl))' -exec \
sh -c 'export FILE={}; ${MAKE} header' \;
@@ -32,6 +96,3 @@ header:
@header=`sed 's/\(.*\)/ echo " \*: \1"/' ${HEADER}`; \
echo '/*:*' > ${FILE}; eval "$$header" >> ${FILE}; \
echo ' *:*/' >> ${FILE}; cat .tmp >> ${FILE}; rm -f .tmp
-replace:
- @find ./ -type f -exec sh -c 'sed -n "s/$(FROM)/$(INTO)/g; \
- w .tmp" {} && mv -f .tmp {}' \;
diff --git a/README b/README
index 8de9114..99f356d 100644
--- a/README
+++ b/README
@@ -1,6 +1,7 @@
-yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
-Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+Copyright (C) 2003 Paul C. Buetow, Volker Richter
+Copyright (C) 2004 Paul C. Buetow
Copyright (C) 2005 EXA Digital Solutions GbR
-----------------------------------------------------------------
This program is free software; you can redistribute it and/or
@@ -16,40 +17,256 @@ 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.
-
-----------------------------------------------------------------
-0.0.0 BASIC YCHAT 0.5 TABLE OF CONTENTS
+YCHAT TABLE OF CONTENTS:
+
+0.0.0 ABOUT RELEASES
+0.0.1 YCHAT FEATURES //<<
1.0.0 REQUIREMENTS
1.1.0 TESTED PLATFORMS
-1.2.0 IMPORTANT NOTES
+1.2.0 IMPORTANT NOTICES
1.3.0 HOW TO OBTAIN YCHAT
1.3.1 INSTALLATION
+1.3.2 INSTALLATION QUICK-START
+1.3.3 MYSQL SETUP //<<
+1.4.0 HOW TO USE SCREEN WITH YCHAT
+1.4.1 HOW TO USE SIGNALS WITH YCHAT
1.5.0 CUSTOMIZATION
1.6.0 FILES
1.7.0 WRITING BUG REPORTS
1.8.0 CONTACT
+1.9.0 YHTTPD CODE BASE GENERATION //<<
+2.0.0 CREDITS
+
+0.0.0 ABOUT RELEASES
+
+There are several projects involved:
+
+- The chat -
+Its a HTTP based chat server written in C++. Clients are normal web browsers
+such as MSIE or Gecko based browsers using only CSS, HTML and JavaScript.
+
+- The httpd -
+Its a small http server based on the chat's socket and threading engine.
+yhttpd does not have as much features but is easy to use and faster than
+apache. yhttpd is a subset of the chat. It can be generated using the
+srcipts/yhttpdbase.pl script in the chat's source tree.
+
+- The ycurses -
+ycurses is a easy to use and small C++ wrapper of the C ncurses API.
+
+There are different branches:
+
+- CURRENT -
+The CURRENT branch is unstable, this is the bleeding developing edge with
+all the new experimental features.
+
+A RELEASE of CURRENT can be referred as CURRENTRELEASE.
+
+- STABLE -
+The STABLE branch is more stable than CURRENT. This branch may get new
+features as well. But those will be more conservative compared to
+CURRENT.
+
+A RELEASE of STABLE can be referred as STABLERELEASE.
+
+- BASIC -
+The BASIC branch is a very minimal one. This branch may get bugfixes and
+updates and might get minor improvements. This is a version of yChat
+with only very few features.
+
+A RELEASE of BASIC can be referred as BASICRELEASE.
+
+- LEGACY -
+The LEGACY branch has no real support. This branch may get bugfixes and
+updates and might get minor improvements. But there is no garuantee to
+be bug free and stable at all. LEGACY versions are of historic meaning.
+
+- DEVEL -
+DEVEL is only a meta name. If a version is labeled with DEVEL, then its
+currently undefined if this is a CURRENT, STABLE or LEGACY branch. It
+can be everything. Commonly DEVEL versions are CURRENT.
+
+There are also releases made:
+
+- RELEASE -
+There can be RELEASEs made out of each branch. While a branch can get
+new features, a RELEASE can not. A RELEASE of a branch is just like
+a snapshot. RELEASEs are complete versions to test and use. But keep
+in mind, that a RELEASE of the STABLE branch is recommended over a
+RELEASE of a CURRENT or a LEGACY branch in a production environment.
+RELEASEs of CURRENT are still the bleeding edge and RELEASEs of LEGACY
+may be out of date.
+
+//<<*
+0.0.1 YCHAT FEATURES
+
+- Its free & portable -
+yChat is developed under the GNU general public license and is based on GNU
+tools (gcc, gmake), other open source library stuff (such as libncurses etc.)
+and should run on any POSIX capable operating system (such as all Linux based
+systems, FreeBSD, NetBSD, OpenBSD and other BSD-Systems and on UNICES like
+IRIX, HP-UX, Solaris etc.).
+
+- There is no need for special chat clients -
+yChat is web based, that means clients may only connect to the chat server
+with an normal web browser such as Microsoft Internet Explorer or any Gecko-
+Engine powerd browsers like Mozilla, Firefox, Camino etc.
+
+- It has features of a real HTTP webserver -
+yChat runs completely stand alone and does not need another webserver to build
+on like Apache and does not need to be run via any kind of CGI. yChat creates
+its own socket on a customized port (standard port: 2000) and seems to be a full
+featured HTTP web server to the clients (web browsers).
+
+The yChat code base can be converted to an yhttpd code base automaticaly. yhttpd
+is the webserver subset of yChat which runs completely stand alone and provides
+normal websites to the net. It also supports Common Gateway Interface (CGI)
+scripting.
+
+- Its fast and secure -
+yChat is written in C++ which is faster than any Java based Chat-Server or any
+server written in a scripting language like PHP, Python or Perl. As the
+internal data structures hash maps are used to garuantee searching certain
+values in O(1) amount of time. If a hash maps gets full, it will be rehashed.
+Currently, yChat has been measured providing over 1000 hits/requests per second
+on a FreeBSD based server box while using less than 2% of CPU usage
+on a Athlon XP 1900+. Performance seems to be limited by your bandwith only.
+Also, each user gets its own session id (random string) with a standard length
+of 50 chars to authenticate each logged in user. The length of the session id
+can be redefined as well. Also, the session id will get md5-hashed optionally
+so thats even harder to reverse engineering the session ids of other users.
+
+- Its HTML template based and easy to customize via XML based configuration -
+All HTML sites are predefined as HTML-Template files and can be easily modified
+to use with an customized web design. Also, a lot of yChat preferences can be
+set in the main configuration file (ychat.conf). ychat.conf is completely written
+in XML 1.0 which makes it easier to use the configuration options in programs of
+3rd persons which may want to write some usefull tools for yChat.
+yChat caches all HTML and web images to improve overall performance. If needed, the
+cache can be cleared to recache new versions of the template files.
+
+- Its language template based -
+The administrator can easily create a new language in which all system messages
+appear to the Chat-User. The predefined languages is english but others can be
+added easily. The language can be edited in the XML based configuration file.
+
+- MySQL based database -
+Registered users are stored in a MySQL database. C++ Programmers may feel free
+to replace the database wrapper class (data.h) with another database routines
+to use other databases such as PostgreSQL, SQLite or a text based database etc.
+If wished, you can disable database support in the pre-compile options.
+
+- It has an administration interface -
+yChat includes an ncurses based administration interface which tracks some
+interesting statistics and system messages and enables you to do certain
+administrative tasks. In addition, you can switch to the CLI (command line
+interface) mode of the administration interface in order to be provided with
+more available functions (like keeping track of the current system usage etc.).
+If you dont like ncurses and/or the CLI you can disable both options in the pre-
+compile options.
+
+- It has logging capabilities -
+The logging manager keeps track to all yChat system messages (such as users
+wich log in and out, modules which are loaded, MySQL queries etc.). Also, an
+Apache-Style combined log file format is created by yChat (you can parse this
+logfile with any Apache logfile parser like awstats etc.). And last but not
+least, all public messages of all available rooms will be logged to disk as
+well . To improve performance, you can define the logging puffer (standardly
+new logs will be written to disk after each 20 lines). If you want to log
+everything immediately, you can reset this option to 1 in ychat.conf.
+
+- Its modular through own command and dynamic HTML engine -
+All chat commands are realized through dynamic loadable module files which can
+be recompiled and reloaded without restarting the whole yChat server. Also
+HTML-Sites with certain tasks can be compiled as a module like
+mods/html/yc_register.so, mods/html/yc_options.so and mods/html/yc_colors.so
+etc. so you can also program your dynamic yChat websites in C++.
+
+- Its multi threaded (POSIX threads) -
+There is only one main process which spawns several threads, each for its own
+unique task. For example one thread is used to handle the socket manager which
+waits for incoming TCP/IP requests, another thread schedules the system timer
+which proves if clients are still active or frees not needed memory in certain
+time intervals (see also "Garbage collector"). Also, each Chat-User gets it own
+thread. There is no need of memory wastage by creating for each task a new
+process. All User-Threads are managed by a thread pool to avoid CPU wastage
+creating every time a new thread by reusing thread objects which have done its
+jobs already and have been readded into the queue of the thread pool. The
+standard sizes of the queue and the total pool size can be set in ychat.conf.
+
+- Its using a smart garbage collection engine -
+All users and rooms which dont have to be kept in the main memory (because the
+user has logged out or the room has been destroyed because it was empty) will
+not be deleted immediately but be placed for about 10 minutes in the yChat
+garbage collector. Each time a new room is created the systems checks the
+garbage to reuse an inactive room object. If a certain user wants to log in, the
+system checks if he is already present in the garbage collector. If yes, he will
+be reactivated without wasting expensive database queries to fetch the user's
+options. This improves overall performance on heavily loaded yChat servers if a
+lot of user and room objects are created and destroyed frequently.
+//*>>
1.0.0 REQUIREMENTS:
-- gcc 3.x
- The GNU C++ compiler.
+- GNU GCC G++
+ The GNU C++ compiler version 3.1 or up.
+
+- 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.
+ yChat Makefiles only have been tested with GNU make and may not work with
+ other make versions.
+
+- SGI STL extension
+ Includes ext/hash_map which may be already default on every Linux distro.
+ On *BSD you have to install it first before compiling. On FreeBSD
+ /usr/ports/devel/stlport is your friend.
+
+//<<*
+- mysql-client 4.x (3.x may do too but is not supported)
+ Includes libmysqlclient and the mysql.h header files.
+
+//*>>
+- ncurses 5.x
+ Includes libncurses and the ncurses.h header files.
+
+- Screen
+ Only needed if yChat should run in background with
+ ncurses or CLI enabled.
+
+- Perl 5.x
+ Is needed for some scripts. Is not needed if you use precompiled binaries.
1.1.0 TESTED PLATFORMS:
-The following platforms have been tested with success:
+The following platforms have been tested with success. If you find out that
+a listed platform did not work at all please contact me:
-- Linux with GCC 3.2.0, GNU make 3.79.1
-- FreeBSD 5.1-RELEASE-p2, GCC 3.2.2, GNU make 3.80
-- FreeBSD 5.3-RELEASE, GCC 3.4, GNU make 3.80
-- FreeBSD 5.4-RELEASE, GCC 3.4.2, GNU make 3.80
+ Operating system (arch) GNU G++ GNU make
+- FreeBSD 5.3-RELEASE (i386) 3.4.2 3.80
-1.2.0 IMPORTANT NOTES:
+ Tested longer time before:
+- FreeBSD 5.2.1-RELEASE (i386) 3.3.3 3.80
+- FreeBSD 4.10-RELEASE (i386) 3.4.1 3.80
+- FreeBSD 4.9-RELEASE (i386) 3.3.4 3.80
+- Gentoo Linux 2004 (i386) 3.3.2 3.80
+- OpenBSD 3.6 SMP (i386) 3.3.2 3.80
+- Red Hat Linux 8.0 SMP (i386) 3.2-7 3.79
+- Slackware Linux 10.0 (i386) 3.4.0 3.80
+- SUSE Linux 9.0 (i386) 3.3.1 3.80
+- SUSE Linux 8.1 (i386) 3.2 3.79.1
+
+Other platforms like Linux based systems, other BSD-Systems or UNICES
+are very likely to work too.
+
+1.2.0 IMPORTANT NOTICES:
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
+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 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.
@@ -58,14 +275,13 @@ homepage which is located at http://www.yChat.org.
yChat can be downloaded as a source package or through CVS.
The packages are located at http://www.yChat.org -> Release Versions
-Packages or go to http://programming.buetow.org/yChat .
For CVS download type:
cvs -d:pserver:anonymous@buetow.org:/cvs/cvsroot login
( You will be asked for a password. Use "just enter" ).
-cvs -z3 -d:pserver:anonymous@buetow.org:/cvs/cvsroot co ychat-basic
+cvs -z3 -d:pserver:anonymous@buetow.org:/cvs/cvsroot co BRANCH
( The sources will be copied into your local folder )
cvs -d:pserver:anonymous@buetow.org:/cvs/cvsroot logout
@@ -73,148 +289,183 @@ cvs -d:pserver:anonymous@buetow.org:/cvs/cvsroot logout
Now you may continue with the installation.
+There are different branches in the CVS:
-1.3.1 INSTALLATION:
+ychat: This is the latest CURRENT branch of yChat.
+ychat-stable: This is the latest STABLE branch of yChat.
+ychat-X.Y: This is the branch with the specified version prefix.
+yhttpd: This is the latest CURRENT snapshot of yhttpd.
-Invoke "./configure" and afterwards "gmake", edit the conf.txt.
+The CURRENT branch of ychat is mostly untested and unstable, so don't
+cry if you get errors.
-Now we want to compile all the dynamic loadable modules of ychat.
-Invoke "cd cmnd && ./compile.sh && cd -". All command modules should get
-compiled.
+1.3.1 INSTALLATION:
-Now its time to run the server with ./ychat.
-Then point your webbrowser to http://yourip:port !
+Invoke "./configure". Afterwards you will get prompted with the before-compile
+options of yChat. After choosing those options you are ready to type "gmake"
+afterwards. See below what gmake is doing.
+
+//<<*
+If you have choosen MySQL database support, then take a look at section 1.3.2
+how to setup a valid database table. Be also sure to enter the valid MySQL
+accessing data in the yChat configuration file which is normally located in
+the etc/ychat.conf file if not changed by you with the yChat configurator.
+//*>>
+
+You may also invoke gmake with the following options (the PREFIX can be set
+in the yChat configurator which will be launched by the top configure script
+or gmake config):
+
+ gmake or gmake all (compiles everything, also modules and runs "gmake mail")
+ 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 confdebug (runs ./configure with enabling debugging)
+ gmake config (runs yChat configurator)
+ gmake debug (runs gdb on ./ychat.core)
+ gmake dist (creates a .tar.bz2 ball)
+ gmake gpl (shows the GNU General Public License)
+ gmake help (shows all available ychat gmake targets)
+ gmake mail (sends a mail to the yChat developers containing build opts.)
+ 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 stats (generates ychat statistics)
+ gmake version (shows the current version of yChat)
+//<<*
+ gmake yhttpdbase (generates an yhttpd code base)
+//*>> (See section 1.9 to read about this marks)
+
+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/ychat.
+
+Aferwards point your webbrowser to http://yourip:port !
... have fun :-).
-1.5.0 CUSTOMIZATION:
-
-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.
-
-1.6.0 FILES: ( This list is not complete )
-
-conf.txt - The yChat configuration file. ( read by conf.cpp ).
-
-Files in ./src:
-
-base.cpp - Encapsulates vector fields of room's or user ( may be later
- hash_maps ) and provides methods for manipulating data
- objects.
+1.3.2 INSTALLATION QUICK START:
-hmap.cpp - The hash map implementation which is a very fast data
- structure. is needed for saving users, rooms and so on.
+If you in hury, then you may just type gmake setup. In the yChat configurator
+you may just choose all the default values. If done, yChat will get compiled
+and is ready to run with ./bin/ychat!
-main.cpp - This includes the required manager headers for starting
- the server and finally regulates the correct starting.
-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.
+//<<*
+1.3.3 MYSQL SETUP
-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.
+If you chose to use MySQL database support you have to create a valid database
+to use with yChat.
-reqp.cpp - This class implements the http request parser. If a client
- starts a request to the server the reqp class will be
- invoked.
+Create a new MySQL database called 'ychat' and type the following command into
+a MySQL command line client of your choice:
-room.cpp - Specifies a chat room. For each chat room an instance of
- this class exists.
+USE ychat
+CREATE TABLE `user` (
+ `uid` int(10) NOT NULL auto_increment,
+ `nick` varchar(30) NOT NULL default '',
+ `password` varchar(30) NOT NULL default '',
+ `color1` varchar(30),
+ `color2` varchar(30),
+ `email` varchar(50) default '-',
+ `registerdate` varchar(30) default '-',
+ `logincounter` varchar(10) default '0',
+ `status` char(1) default '3',
+ PRIMARY KEY (`uid`),
+ KEY `uid` (`uid`)
+) TYPE=MyISAM;
+GRANT ALL PRIVILEGES ON ychat.* to ychat@localhost IDENTIFIED BY "yctest";
-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.
+This database uses the default MySQL access informations which are stored in the
+ychat.conf file.
+//*>>
-user.cpp - Specifies a chat user. For each chat user an instance of
- this class exists.
+1.4.0 HOW TO USE SCREEN WITH YCHAT:
-Abstract classes:
+If you are running yChat 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.
-cont.cpp - All classes which need to store "key - value" data sets
- inherit from this class. ( cont for content ).
+Just do:
+
+ screen -S ychat ./bin/ychat ( creates a new session and starts yChat in it )
+ ctrl+d+a ( will detach the yChat session )
+ ( closing the terminal )
+ ( opening a new terminal )
+ screen -r ychat ( will return you to the yChat process )
-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.
+Screen will terminate automaticaly if all processes in its sessions are
+terminated.
-As described ( main.cpp ), there are so called managers. Managers are
-accessible through their assigned wrapper classes and may be
-instanciated only once.
+For a closer look read the screen manual page ( man screen ).
-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.
+1.4.1 HOW TO USE SIGNALS WITH YCHAT:
-conf.cpp - The config manager. Parses the config file specified in
- glob.h and stores all the values of it in a map.
+You can send UNIX signals to yChat. This becomes very interesting if you
+don't use the command line interface or the ncurses interface and you
+don't have access to the options below.
-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.
+Run one of the following commands to send the signal you want:
+($PID is here the process id of the current yChat process)
-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'.
+kill -USR1 $PID # yChat clears the HTML template cache
+kill -USR2 $PID # yChat reloads all dynamic loadable modules //<<
+kill -HUP $PID # yChat will shutdown savely
-sock.cpp - The socket manager. Manages the socket connections. There
- are multiplexed sockets. For each requests a new POSIX thread
- will be created.
+1.5.0 CUSTOMIZATION:
-Files with a leading s_ contain static C++ classes
+If you like to customize the design/layout/language of yChat, 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/ychat.conf).
-s_chat.cpp - Static wrapper for the dynamic chat class. holds one global
- reachable instance of chat until the program shuts down.
+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.
-s_conf.cpp - Static wrapper for the dynamic conf class. holds one global
- reachable instance of conf until the program shuts down.
+You can edit the etc/ychat.conf to fit your needs. If you dont want to change
+the config file, then you also can use ychat start parameters.
-s_html.cpp - Static wrapper for the dynamic html class. holds one global
- reachable instance of conf until the program shuts down.
+Exmpl: ./bin/ychat -o chat.database.password secretpassword
-s_mutx.cpp - Static wrapper for the dynamic mutx class. holds one global
- reachable instance of conf until the program shuts down.
+You can also use multiple words for a specific option.
-s_sock.cpp - Static wrapper for the dynamic sock class. holds one global
- reachable instance of conf until the program shuts down.
+Exmpl: ./bin/ychat -o ychat.version "word1 word2 word3"
-s_tool.cpp - Static class which includes some usefull global reachable
- methods which are not integraded in independent classes.
+will overwrite the default database password value of the ychat.conf. You can
+do this with every configuration element by adding several -o option value
+arguments to the start command.
-Special header files ( all other header files which are not listed here
-belong to their respective .cpp files ):
+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.
-glob.h - Defines global variables which are known by compilation
- time.
+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 ).
-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.
+1.6.0 FILES:
-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.
+etc/ychat.conf - The yChat configuration file
+html/* - The html template files
+src/* - The yChat base sources
+src/mods/* - The dynamic loadable modules sources
+scripts/* - Some nice scripts needed for building & co.
-The basic class structure:
+The following is created by building yChat:
+obj/* - The object files of the compiled yChat base
+mods/* - The compiled dynamic loadable modules
+bin/ychat - The yChat binary (linked by the object files)
- base<room> base<user>
- | | name
- | | / \
- | | / \
- chat room user
+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
- cont
- / \
- / \
-conf html
1.7 WRITING BUG REPORTS
@@ -227,26 +478,34 @@ First you should give the following information:
- 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 yChat 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 "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:
+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 ychat core
+ gdb ./bin/ychat 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*) ()
@@ -254,6 +513,12 @@ 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 yChat using
+debuggig symbols. You can do it this way:
+
+cd ychat
+gmake clean confdebug all run
+
1.8 CONTACT:
You may contact us through the following addresses:
@@ -263,16 +528,33 @@ You may contact us through the following addresses:
The EXA Digital Solutions homepage is located at http://www.exa-ds.com
- E-Mail
- Paul C. Buetow: Buetow at yChat dot org ( core developer )
+ Paul C. Buetow: Buetow at yChat point org ( core developer )
Mail at yChat dot org ( reaches everybody of yChat )
- ICQ
Paul C. Buetow: 11655527
- IRC
- #ychat at irc.german-elite.net
+ #Ychat and #Coding at irc.german-elite.net
- EXA Digital Solutions GbR
Laubenstr. 16b
D-44866 Bochum
Germany
+
+//<<*
+1.9.0 YHTTPD CODE BASE GENERATION
+
+See docs/yhttpd.txt
+//*>>
+
+2.0.0 CREDITS
+
+Thanks to the following persons. Without them yChat would not be like today:
+
+- Volker Richter <volker at exa-ds dot de> of EXA Digital Solutions GbR
+ (http://www.exa-ds.com) for adding initial MySQL support and lots of more
+ code.
+
+- Joshia Teitelbaum <joshuat at cryptomail.org> of CryptpMail.org for adding
+ lots of security patches in the HTTP header handling.
diff --git a/SHORTDESC b/SHORTDESC
index fce0ad0..7d00cbc 100644
--- a/SHORTDESC
+++ b/SHORTDESC
@@ -1,4 +1,4 @@
-The yChat 0.5 branch is marked as BASIC and contains a very light and fast
-chat system without any special features.
+The yChat 0.7 branch is marked as STABLE and will only get bugfixes and minor
+improvements. Most of the new stuff will go into the CURRENT branch instead.
WWW: http://www.yChat.org
diff --git a/configure b/configure
index 333efb0..9aab971 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,77 @@
#!/bin/sh
-cd ./src
-./configure
+if ! ./scripts/checkperl.sh
+then
+ 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);
+ }
+
+ system("perl \"scripts/config.pl\"");
+ chdir("src");
+ system("./configure ".join(" ", @ARGV));
+ chdir("..");
+
+ exit(0);
+' `echo "$*" | sed "s/-//g"`
+
+if test -f err
+then
+ rm -f err
+else
+ echo You are ready to type gmake now!
+fi
diff --git a/docs/header.txt b/docs/header.txt
index cbaebde..f123dfe 100644
--- a/docs/header.txt
+++ b/docs/header.txt
@@ -1,8 +1,9 @@
File: ${FILE}
-yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
-Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+Copyright (C) 2003 Paul C. Buetow, Volker Richter
+Copyright (C) 2004 Paul C. Buetow
Copyright (C) 2005 EXA Digital Solutions GbR
This program is free software; you can redistribute it and/or
diff --git a/docs/yhttpd.txt b/docs/yhttpd.txt
new file mode 100644
index 0000000..749a8c5
--- /dev/null
+++ b/docs/yhttpd.txt
@@ -0,0 +1,3 @@
+All lines marked //<< and all lines between the //<<* and
+the //*>> marks are used to remove code from the yChat source
+tree to generate an yhttpd tree out of it.
diff --git a/etc/ychat.conf b/etc/ychat.conf
new file mode 100644
index 0000000..0bdb3c1
--- /dev/null
+++ b/etc/ychat.conf
@@ -0,0 +1,690 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
+<config>
+<category name="chat">
+ <option name="defaultop">
+ <value>Snoop</value>
+ <descr>The default user which has operator status</descr>
+ </option>
+ <option name="enableguest">
+ <value>true</value>
+ <descr>Is set to true if guest chatters are allowed. If database support is disabled this option HAS to be enabled otherwise no login will work because all chatter are treated as guests if there is no database!</descr>
+ </option>
+ <option name="defaultrang">
+ <value>3</value>
+ <descr>The default user rang/status</descr>
+ </option>
+ <option name="defaultroom">
+ <value>Lounge</value>
+ <descr>The default chat room</descr>
+ </option>
+ <option name="printalwaystime">
+ <value>true</value>
+ <descr>If true, for each message in the chat window will be printed out the current time</descr>
+ </option>
+ <option name="timeoffset">
+ <value>0</value>
+ <descr>The time offset. Negative values are not allowed. If you have an offset of X please enter 24+X+12 here. Example: Offset = -6, 24-6+12 = 30 :)</descr>
+ </option>
+ <category name="permissions">
+ <option name="uptime">
+ <value>1</value>
+ </option>
+ <option name="ko">
+ <value>1</value>
+ </option>
+ <option name="topic">
+ <value>2</value>
+ </option>
+ <option name="ren">
+ <value>1</value>
+ </option>
+ <option name="version">
+ <value>3</value>
+ </option>
+ <option name="compopt">
+ <value>3</value>
+ </option>
+ <option name="s">
+ <value>3</value>
+ </option>
+ <option name="msg">
+ <value>3</value>
+ </option>
+ <option name="users">
+ <value>3</value>
+ </option>
+ <option name="me">
+ <value>3</value>
+ </option>
+ <option name="m">
+ <value>3</value>
+ </option>
+ <option name="j">
+ <value>3</value>
+ </option>
+ <option name="getroom">
+ <value>3</value>
+ </option>
+ <option name="morph">
+ <value>3</value>
+ </option>
+ <option name="away">
+ <value>3</value>
+ </option>
+ <option name="q">
+ <value>3</value>
+ </option>
+ <option name="time">
+ <value>3</value>
+ </option>
+ <option name="col">
+ <value>3</value>
+ </option>
+ <option name="help">
+ <value>3</value>
+ </option>
+ </category>
+ <category name="database">
+ <option name="mincon">
+ <value>2</value>
+ <descr>The amount of database connections which will be created at yChat startup</descr>
+ </option>
+ <option name="maxcon">
+ <value>10</value>
+ <descr>The maximum amount of concurrent connections to the database</descr>
+ </option>
+ <option name="contimeout">
+ <value>600</value>
+ <descr>Seconds of idling after a database connection will be closed. Will be checked once each minute</descr>
+ </option>
+ <option name="serverhost">
+ <value>localhost</value>
+ <descr>Specifies hostname oder ip address of the MySQL database server</descr>
+ </option>
+ <option name="user">
+ <value>ychat</value>
+ <descr>Specifies the MySQL username</descr>
+ </option>
+ <option name="password">
+ <value>hahaha</value>
+ <descr>Specifies the MySQL password</descr>
+ </option>
+ <option name="dbname">
+ <value>ychat_advanced</value>
+ <descr>Specifies the MySQL database name</descr>
+ </option>
+ <option name="port">
+ <value>3306</value>
+ <descr>Specifies the MySQL server port</descr>
+ </option>
+ <category name="mysql">
+ <option name="registernick">
+ <value>user nick password color1 color2 email registerdate</value>
+ <descr>Specifies the fields which will be saved into the database if a new user has been registered</descr>
+ </option>
+ <option name="savechangednick">
+ <value>user password color1 color2 status email</value>
+ <descr>Specifies the fields which will be saved into the database if a new user has been changed then the user loggs out or goes offline</descr>
+ </option>
+ <option name="selectlogin">
+ <value>user nick password color1 color2 status email</value>
+ <descr>Specifies the fields which will be selected from the database if a registered user loggs in</descr>
+ </option>
+ <option name="selectnick">
+ <value>user nick</value>
+ <descr>Specifies the fields which will be selected from the database a user tries to logg in. Here only the nick will be fetched to check if the username is registered or not</descr>
+ </option>
+ </category>
+ </category>
+ <category name="maxlength">
+ <option name="word">
+ <value>50</value>
+ <descr>Maximum length of a word inside a chat message. The word will be seperate by a blank if exceeded</descr>
+ </option>
+ <option name="message">
+ <value>500</value>
+ <descr>Maximum length of a chat message</descr>
+ </option>
+ <option name="username">
+ <value>15</value>
+ <descr>Maximum length of a user name</descr>
+ </option>
+ <option name="roomname">
+ <value>20</value>
+ <descr>Maximum length of a room name</descr>
+ </option>
+ <option name="emailaddress">
+ <value>20</value>
+ <descr>Maximum length of an email address</descr>
+ </option>
+ <option name="password">
+ <value>20</value>
+ <descr>Maximum length of the user password</descr>
+ </option>
+ <option name="topic">
+ <value>20</value>
+ <descr>Maximum length of a room&apos;s topic</descr>
+ </option>
+ </category>
+ <category name="system">
+ <option name="mysqlclient">
+ <value>/usr/local/bin/mysql</value>
+ <descr>Full path to the mysql client program</descr>
+ </option>
+ </category>
+ <category name="msgs">
+ <option name="userlist">
+ <value>List of logged in users: </value>
+ </option>
+ <option name="system">
+ <value>Global system message: </value>
+ </option>
+ <option name="servertime">
+ <value>The server system time: </value>
+ </option>
+ <option name="guest">
+ <value>This person is a guest chatter!</value>
+ </option>
+ <option name="lastactivity">
+ <value>Last activity:</value>
+ </option>
+ <option name="userrenamesroom">
+ <value> renames the room into </value>
+ </option>
+ <option name="usermorphs">
+ <value> morphs his name into </value>
+ </option>
+ <option name="optionschanged">
+ <value>Your options have been changed!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="rang0">
+ <value>Operator</value>
+ </option>
+ <option name="rang1">
+ <value>Half-Operator</value>
+ </option>
+ <option name="rang2">
+ <value>Voiced user</value>
+ </option>
+ <option name="registernick">
+ <value>Your nick has been registered successfully. You may log in now!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="reloadonlineframe">
+ <value>Reloaded online frame</value>
+ </option>
+ <option name="scream">
+ <value> screams:</value>
+ </option>
+ <option name="servertime">
+ <value>The server system time::</value>
+ </option>
+ <option name="setcommandstatus">
+ <value> sets command status</value>
+ </option>
+ <option name="setmodeaway">
+ <value> sets mode away</value>
+ </option>
+ <option name="setmodefake">
+ <value>Fake modus acticated!</value>
+ </option>
+ <option name="setmodeinvisible">
+ <value>Invisible modus activated!</value>
+ </option>
+ <option name="topic">
+ <value> changes the topic to:</value>
+ </option>
+ <option name="topiccut">
+ <value>The topic you have choosen was too long and has been cut!</value>
+ </option>
+ <option name="topicdelete">
+ <value> deletes the topic of the room.</value>
+ </option>
+ <option name="unsetmodeaway">
+ <value> is back </value>
+ </option>
+ <option name="unsetmodefake">
+ <value>Fake modus deactivated!</value>
+ </option>
+ <option name="unsetmodeinvisible">
+ <value>Invisible modus deactivated!</value>
+ </option>
+ <option name="uptime">
+ <value>yChat uptime: </value>
+ </option>
+ <option name="userautoawaytimeout">
+ <value> has been set to away (auto away)</value>
+ </option>
+ <option name="userenterschat">
+ <value> enters the chat.</value>
+ </option>
+ <option name="userentersroom">
+ <value> enters the room </value>
+ </option>
+ <option name="userhasstatus">
+ <value> has status </value>
+ </option>
+ <option name="userinroom">
+ <value> is in room </value>
+ </option>
+ <option name="userkicksout1">
+ <value> kicks </value>
+ </option>
+ <option name="userkicksout2">
+ <value> out of the chat at room </value>
+ </option>
+ <option name="userleaveschat">
+ <value> leaves the chat.</value>
+ </option>
+ <option name="userleavesroom">
+ <value> leaves this room and switches to </value>
+ </option>
+ <option name="whisper">
+ <value> whispers to you</value>
+ </option>
+ <option name="whisperto">
+ <value>Whispered to </value>
+ </option>
+ <category name="help">
+ <option name="all">
+ <value>Writes a global system message into all available rooms. Usage: /all MESSAGE</value>
+ </option>
+ <option name="away">
+ <value>Sets mode away. Usage: /away AWAYTEST</value>
+ </option>
+ <option name="col">
+ <value>Changes the color. Usage: /col NICKCOLOR TEXTCOLOR</value>
+ </option>
+ <option name="exec">
+ <value>Executes a command in the system shell. Usage: /exec SHELLCOMMAND</value>
+ </option>
+ <option name="fake">
+ <value>Hides status logo. Usage: /fake</value>
+ </option>
+ <option name="getrusage">
+ <value>Shows informations describing the resources utilized by the yChat process. Usage: /getrusage</value>
+ </option>
+ <option name="about">
+ <value>Gets some usefull and interesting infos about NICK. Usage: /about NICK</value>
+ </option>
+ <option name="help">
+ <value>Shows help text for a specific command. Usage: /help chatcommand</value>
+ </option>
+ <option name="invisible">
+ <value>Activates or deactivates the invisible mode</value>
+ </option>
+ <option name="j">
+ <value>Changes the room. Usage: /j ROOMNAME</value>
+ </option>
+ <option name="ko">
+ <value>Kicks a user out of the chat. Usage: /ko NICKNAME</value>
+ </option>
+ <option name="m">
+ <value>Writes the text italic (two colors). Usage: /m ACTION</value>
+ </option>
+ <option name="morph">
+ <value>Morphes your current nick into MORPHNICK. This command is used to change the upper and lower case letters of your current nick. Usage: /morph MORPHNICK</value>
+ </option>
+ <option name="md5">
+ <value>MD5 hashes SOME STRINGS with SALT. Usage: /md5 SOME STRINGS SALT</value>
+ </option>
+ <option name="me">
+ <value>Writes the text italic (one color). Usage: /m ACTION</value>
+ </option>
+ <option name="msg">
+ <value>Whispers TEXT to NICKNAME. Usage: /msg NICKNAME TEXT</value>
+ </option>
+ <option name="version">
+ <value>Shows the version of the running yChat server. Usage: /version</value>
+ </option>
+ <option name="compopt">
+ <value>Shows some options of the compiler being used to build this yChat version. It also shows the current systen architecture and operating system as well as the yChat build number. Usage: /compopt</value>
+ </option>
+ <option name="q">
+ <value>Leaving the chat. Usage: /q</value>
+ </option>
+ <option name="ren">
+ <value>Renames the current room into NEWROOMNAME. Usage: /ren NEWROOMNAME</value>
+ </option>
+ <option name="reload">
+ <value>Reloads the online frame of the current room. Usage: /reload</value>
+ </option>
+ <option name="set">
+ <value>Changes command permissions. P.e.: &quot;/set q status 3&quot; allows the command from status 3 or &quot;/set q disable 1&quot; deactivates the command. Disable 0 reactivates the command again. Usage: /set COMMAND MODE VAL</value>
+ </option>
+ <option name="getroom">
+ <value>Shows the room of the specific user. Useage: /getroom NICKNAME</value>
+ </option>
+ <option name="time">
+ <value>Shows the server system time. Usage: /time</value>
+ </option>
+ <option name="uptime">
+ <value>Shows the yChat uptime. Usage: /uptime</value>
+ </option>
+ <option name="users">
+ <value>Shows currently logged in users. Usage: /users</value>
+ </option>
+ <option name="s">
+ <value>Screams the TEXT. Usage: /s TEXT</value>
+ </option>
+ <option name="topic">
+ <value>Changes the topic of the current room into TOPIC. Usage: /topic TOPIC</value>
+ </option>
+ </category>
+ <category name="err">
+ <option name="alpnum">
+ <value>The nick you have specifued is not alphanumeric, please change that.&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="alreadyinroom">
+ <value>You are already in the room</value>
+ </option>
+ <option name="changepassword">
+ <value>The old password you have entered is wrong. In order to change your password you need to enter a correct old password!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="changepassword2">
+ <value>The two password fiels oth the new password are not identical. Please check that again otherwise the password will not be changed!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="emaillength">
+ <value>Your email address is too long!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="execcommand">
+ <value>Could not execute command!</value>
+ </option>
+ <option name="findingcommand">
+ <value>No such command!&lt;br&gt;</value>
+ </option>
+ <option name="maxuserlimit">
+ <value>You cant log in because the maxuser limit has been reached. Please try again later.&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="messagelength">
+ <value>Your message was too long and has been shortened!</value>
+ </option>
+ <option name="morphnick">
+ <value>Your morph nick needs to be the same like your current nick, only up- and lowercase letters are allowed to differ!</value>
+ </option>
+ <option name="nicklength">
+ <value>Your nick is too long!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="nonick">
+ <value>You need to specify a nickname!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="noguest">
+ <value>Guest chatting is currently disabled. Please use a registered nick!</value>
+ </option>
+ <option name="noroom">
+ <value>You have to enter a valid room name!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="notavailable">
+ <value>is not available!</value>
+ </option>
+ <option name="notonline">
+ <value>An error occured. Your nick is not online!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="online">
+ <value>The nick you have specified is already online. Please try another nick!!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="passlength">
+ <value>Your password is too long!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="registerexists">
+ <value>The nickname you want to register already exists. Please choose another one!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="registerpassword">
+ <value>The password selections differ. Please re-enter your password fields!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="roomexists">
+ <value>The new name of the room you have choosen is already taken by another room!</value>
+ </option>
+ <option name="roomnamelength">
+ <value>Your room name too long!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ <option name="wrongcommandusage">
+ <value>Wrong command usage. Please read the help site or type /help commandname!</value>
+ </option>
+ <option name="wrongpassword">
+ <value>The nickname you have selected already exists in the user database and you have entered a wrong password!&lt;br&gt;&lt;br&gt;</value>
+ </option>
+ </category>
+ </category>
+ <category name="idle">
+ <option name="awaytimeout">
+ <value>1800</value>
+ <descr>Seconds of inanctivity after a user will get logged out if the user is away</descr>
+ </option>
+ <option name="autoawaytimeout">
+ <value>500</value>
+ <descr>Seconds until a user will be set to away automatically</descr>
+ </option>
+ <option name="timeout">
+ <value>900</value>
+ <descr>Seconds of inactivity after a user will get logged out automatically</descr>
+ </option>
+ </category>
+ <category name="session">
+ <option name="md5hash">
+ <value>true</value>
+ <descr>If set to true, then MD5 hash of the session id will be appended to the generated session to make the temp IDs even more secure.</descr>
+ </option>
+ <option name="md5salt">
+ <value>tASDlkjadSD</value>
+ <descr>Some random string which will affect the md5-hash. Change this to another random string!</descr>
+ </option>
+ <option name="length">
+ <value>32</value>
+ <descr>Length of the generated session id. The length will be longer if md5hash is activated</descr>
+ </option>
+ <option name="validchars">
+ <value>.abcdefghijklmnopqrstuvwxyz0123456789-_</value>
+ <descr>Valid chars which can be in a session id. The generated session will use other chars if md5hash is activated</descr>
+ </option>
+ <option name="kloakkey">
+ <value>123987</value>
+ <descr>Some numner which will affect the session id. Change this to another random number!</descr>
+ </option>
+ </category>
+ <category name="html">
+ <option name="tagsallow">
+ <value>false</value>
+ <descr>If set to false, yChat strips all html tags from incoming messages</descr>
+ </option>
+ <option name="ghost">
+ <value>size="1" color="#999999"</value>
+ <descr>Specifies the font-parameters for the nick name if the user is a ghost chatter</descr>
+ </option>
+ <option name="errorcolor">
+ <value>FF0000</value>
+ <descr>Specifies the standard error message color</descr>
+ </option>
+ <option name="sysmsgcolor">
+ <value>FF0000</value>
+ <descr>Specifies the standard system message color</descr>
+ </option>
+ <option name="onlinebefore">
+ <value>&lt;tr&gt;&lt;td&gt;</value>
+ <descr>HTML-Tags which will be placed before each nickname in the user online frame</descr>
+ </option>
+ <option name="onlinebehind">
+ <value>&lt;/td&gt;&lt;/tr&gt;</value>
+ <descr>HTML-Tags which will be placed behind each nickname in the user online frame</descr>
+ </option>
+ <category name="rangimages">
+ <option name="location">
+ <value>images/</value>
+ <descr>Specifies the location of the status (status) symbols of the users. This path has to be reachable through the web, e.g.: &quot;http://www.webreachable.com/images/&quot;. If no http:// is specified then the images are inside the conf:httpd.templatedir directory</descr>
+ </option>
+ <option name="options">
+ <value> width=&quot;16&quot; height=&quot;16&quot;</value>
+ <descr>Options to add to the &lt;img&gt; tag (leave first char blank)</descr>
+ </option>
+ </category>
+ <category name="user">
+ <option name="color1">
+ <value>AAAAAA</value>
+ <descr>User&apos;s standard nick color in hexadecimal</descr>
+ </option>
+ <option name="color2">
+ <value>FFFFFF</value>
+ <descr>User&apos;s standard text color in hexadecimal</descr>
+ </option>
+ </category>
+ <category name="replace">
+ <option name="activate">
+ <value>true</value>
+ <descr>If set to true, then this replace option will be used</descr>
+ </option>
+ <category name="from">
+ <option name="red">
+ <value>red</value>
+ </option>
+ <option name="green">
+ <value>green</value>
+ </option>
+ <option name="orange">
+ <value>orange</value>
+ </option>
+ <option name="yellow">
+ <value>yellow</value>
+ </option>
+ </category>
+ <category name="into">
+ <option name="red">
+ <value>&lt;font color=&quot;red&quot;&gt;red&lt;/font&gt;</value>
+ </option>
+ <option name="green">
+ <value>&lt;font color=&quot;green&quot;&gt;green&lt;/font&gt;</value>
+ </option>
+ <option name="orange">
+ <value>&lt;font color=&quot;orange&quot;&gt;orange&lt;/font&gt;</value>
+ </option>
+ <option name="yellow">
+ <value>&lt;font color=&quot;yellow&quot;&gt;yellow&lt;/font&gt;</value>
+ </option>
+ </category>
+ </category>
+ </category>
+ <category name="logging">
+ <option name="roomlogdir">
+ <value>log/rooms/</value>
+ <descr>Specifies the relative or absolute path to the directory of the room log files</descr>
+ </option>
+ <option name="roomloglines">
+ <value>0</value>
+ <descr>Number of room log lines which will be buffered in the main memory until they will be written into the file</descr>
+ </option>
+ </category>
+</category>
+<category name="httpd">
+ <option name="serverport">
+ <value>2000</value>
+ <descr>Local port on which the server listens</descr>
+ </option>
+ <option name="enablecgi">
+ <value>false</value>
+ <descr>Support for CGI scripts</descr>
+ </option>
+ <option name="startsite">
+ <value>index.html</value>
+ <descr>Specifies the standard start HTML-template</descr>
+ </option>
+ <option name="templatedir">
+ <value>html/</value>
+ <descr>If set to false, yChat strips all html tags from incoming messages</descr>
+ </option>
+ <option name="ipcachesize">
+ <value>50</value>
+ <descr>Specifies the IP cache size. If set to 0, the IP cache will be cleared every 10 minutes. Otherwise, the IP cache will be cleared every 10 minutes only if there are more IPs in the cache than the specified amount.</descr>
+ </option>
+ <category name="html">
+ <option name="notfound">
+ <value>notfound.html</value>
+ <descr>The HTML site which will be displayed if the requested file does not exists</descr>
+ </option>
+ </category>
+ <category name="thread">
+ <option name="initpoolsize">
+ <value>10</value>
+ <descr>Initial number of threads running at the same time. If there are less than 5 threads in the pool waiting, the thread pool will resize to 10.</descr>
+ </option>
+ <option name="maxpoolsize">
+ <value>0</value>
+ <descr>Maximum amount of parallel running threads. Change this to 0 if you want to use unlimited threads. If you have set a number not equal to 0, then there have to be at least 2 waiting threads to allow a new user login. A maxpoolsize of 52 means a max user limit of 50 users.</descr>
+ </option>
+ </category>
+ <category name="stats">
+ <option name="rusagehistory">
+ <value>7</value>
+ <descr>Number of days to track the system resource usage. You can check the history in the CLI mode</descr>
+ </option>
+ </category>
+ <category name="system">
+ <option name="shell">
+ <value>tcsh</value>
+ <descr>The external command for the system shell which can be selected in the CLI mode</descr>
+ </option>
+ </category>
+ <category name="modules">
+ <option name="commandsdir">
+ <value>mods/commands/</value>
+ <descr>Specifies the relative or absolute path to the command&apos;s .so module files which can be loaded and unloaded at runtime</descr>
+ </option>
+ <option name="htmldir">
+ <value>mods/html/</value>
+ <descr>Specifies the relative or absolute path to the html&apos;s .so module files which can be loaded and unloaded at runtime</descr>
+ </option>
+ <option name="preloadcommands">
+ <value>true</value>
+ <descr>If set to true, all command modules will be preloaded at server startup</descr>
+ </option>
+ <option name="preloadhtml">
+ <value>true</value>
+ <descr>If set to true, all html modules will be preloaded at server startup</descr>
+ </option>
+ </category>
+ <category name="logging">
+ <option name="accessfile">
+ <value>log/access_log</value>
+ <descr>Specifies the relative or absolute path to the apache combined style log file</descr>
+ </option>
+ <option name="systemfile">
+ <value>log/system_log</value>
+ <descr>Specifies the relative or absolute path to the system messsage log file</descr>
+ </option>
+ <option name="accesslines">
+ <value>0</value>
+ <descr>Number of access log lines which will be buffered in the main memory until they will be written into the file</descr>
+ </option>
+ <option name="systemlines">
+ <value>0</value>
+ <descr>Number of system log lines which will be buffered in the main memory until they will be written into the file</descr>
+ </option>
+ </category>
+ <category name="contenttypes">
+ <option name="htm">
+ <value>text/html</value>
+ </option>
+ <option name="html">
+ <value>text/html</value>
+ </option>
+ <option name="gif">
+ <value>image/gif</value>
+ </option>
+ <option name="jpg">
+ <value>image/jpeg</value>
+ </option>
+ <option name="jpe">
+ <value>image/jpeg</value>
+ </option>
+ <option name="jpeg">
+ <value>image/jpeg</value>
+ </option>
+ <option name="png">
+ <value>image/png</value>
+ </option>
+ <option name="txt">
+ <value>text/plain</value>
+ </option>
+ <option name="default">
+ <value>text/html</value>
+ </option>
+ </category>
+</category>
+</config>
diff --git a/html/admin.html b/html/admin.html
new file mode 100644
index 0000000..3dee7a2
--- /dev/null
+++ b/html/admin.html
@@ -0,0 +1,33 @@
+<!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>
+ Admin options - %%ychat.version%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+</head>
+<body>
+<table align=center width=500>
+<tr><td>
+ Hello %%nick%%, all chat configuration options available are summarized below.
+ Please also keep in mind, that all sensible informations such as passwords are hidden.
+
+ This site is for demonstration purporse only.
+ <br>
+ <br>
+ All options summarized here come from the XML based ychat.conf configuration file.
+</td></tr>
+<tr><td>
+<br>
+%%content%%
+</td></tr>
+</table>
+<br><br>
+ <center>
+ <span class="signature">
+ yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a>
+ </span>
+ </center>
+</body>
+</html>
diff --git a/html/colors.html b/html/colors.html
new file mode 100644
index 0000000..8b23014
--- /dev/null
+++ b/html/colors.html
@@ -0,0 +1,416 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>
+ Color menu - %%ychat.version%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+<script lang="javascript" type="text/javascript">
+ <!--
+ function insertcode( code )
+ {
+ document.colors.elements[radiovalue(document.colors.inputvalue)].value = code;
+ }
+ function radiovalue(robj)
+ {
+ for (var i=0; i<robj.length; i++)
+ if (robj[i].checked)
+ return robj[i].value;
+ return false;
+ }
+ function doonsubmit()
+ {
+ document.hiddenform.message.value = "/col " + document.colors.col1.value + " " + document.colors.col2.value;
+ document.hiddenform.submit();
+ return true;
+ }
+//-->
+</script>
+<body>
+ <center>
+ %%msgs%%
+ <form name="colors" action="colors.html" onsubmit="return doonsubmit();">
+ <table>
+ <tr>
+ <td>
+ <div>
+ <input type="radio" name="inputvalue" value="col1" checked>
+ Color 1
+ <br>
+ (color of your nickname):
+ <br>
+ <input class="text" name="col1" size="6" maxlength="6" value="%%col1%%">
+ </div>
+ </td>
+ <td width=20>
+ </td>
+ <td>
+ <div>
+ <input type="radio" name="inputvalue" value="col2">
+ Color 2
+ <br>
+ (color of your text messages):
+ <br>
+ <input class="text" name="col2" size="6" maxlength="6" value="%%col2%%">
+ </div>
+ </td>
+ </tr>
+ </table>
+ <br>
+ <br>
+ <table cellspacing=0 cellpadding=5 border=0>
+ <tr>
+ <td bgcolor="000000"><span style="color:#FFFFFF; text-decoration:line-through;">000000</span></td>
+ <td bgcolor="000033"><span style="color:#FFFFFF; text-decoration:line-through;">000033</span></td>
+ <td bgcolor="000066"><span style="color:#FFFFFF; text-decoration:line-through;">000066</span></td>
+ <td bgcolor="000099"><span style="color:#FFFFFF; text-decoration:line-through;">000099</span></td>
+
+ <td bgcolor="0000CC"><span style="color:#FFFFFF; text-decoration:line-through;">0000CC</span></td>
+ <td bgcolor="0000FF"><a href="javascript:insertcode('0000FF');" style="color:#FFFFFF;">0000FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="003300"><span style="color:#FFFFFF; text-decoration:line-through;">003300</span></td>
+ <td bgcolor="003333"><span style="color:#FFFFFF; text-decoration:line-through;">003333</span></td>
+ <td bgcolor="003366"><span style="color:#FFFFFF; text-decoration:line-through;">003366</span></td>
+
+ <td bgcolor="003399"><a href="javascript:insertcode('003399');" style="color:#FFFFFF;">003399</a></td>
+ <td bgcolor="0033CC"><a href="javascript:insertcode('0033CC');" style="color:#FFFFFF;">0033CC</a></td>
+ <td bgcolor="0033FF"><a href="javascript:insertcode('0033FF');" style="color:#FFFFFF;">0033FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="006600"><span style="color:#FFFFFF; text-decoration:line-through;">006600</span></td>
+ <td bgcolor="006633"><span style="color:#FFFFFF; text-decoration:line-through;">006633</span></td>
+
+ <td bgcolor="006666"><a href="javascript:insertcode('006666');" style="color:#FFFFFF;">006666</a></td>
+ <td bgcolor="006699"><a href="javascript:insertcode('006699');" style="color:#FFFFFF;">006699</a></td>
+ <td bgcolor="0066CC"><a href="javascript:insertcode('0066CC');" style="color:#FFFFFF;">0066CC</a></td>
+ <td bgcolor="0066FF"><a href="javascript:insertcode('0066FF');" style="color:#FFFFFF;">0066FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="009900"><a href="javascript:insertcode('009900');" style="color:#FFFFFF;">009900</a></td>
+
+ <td bgcolor="009933"><a href="javascript:insertcode('009933');" style="color:#FFFFFF;">009933</a></td>
+ <td bgcolor="009966"><a href="javascript:insertcode('009966');" style="color:#FFFFFF;">009966</a></td>
+ <td bgcolor="009999"><a href="javascript:insertcode('009999');" style="color:#FFFFFF;">009999</a></td>
+ <td bgcolor="0099CC"><a href="javascript:insertcode('0099CC');" style="color:#FFFFFF;">0099CC</a></td>
+ <td bgcolor="0099FF"><a href="javascript:insertcode('0099FF');" style="color:#FFFFFF;">0099FF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="00CC00"><a href="javascript:insertcode('00CC00');" style="color:#000000;">00CC00</a></td>
+ <td bgcolor="00CC33"><a href="javascript:insertcode('00CC33');" style="color:#000000;">00CC33</a></td>
+ <td bgcolor="00CC66"><a href="javascript:insertcode('00CC66');" style="color:#000000;">00CC66</a></td>
+ <td bgcolor="00CC99"><a href="javascript:insertcode('00CC99');" style="color:#000000;">00CC99</a></td>
+ <td bgcolor="00CCCC"><a href="javascript:insertcode('00CCCC');" style="color:#000000;">00CCCC</a></td>
+
+ <td bgcolor="00CCFF"><a href="javascript:insertcode('00CCFF');" style="color:#000000;">00CCFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="00FF00"><a href="javascript:insertcode('00FF00');" style="color:#000000;">00FF00</a></td>
+ <td bgcolor="00FF33"><a href="javascript:insertcode('00FF33');" style="color:#000000;">00FF33</a></td>
+ <td bgcolor="00FF66"><a href="javascript:insertcode('00FF66');" style="color:#000000;">00FF66</a></td>
+ <td bgcolor="00FF99"><a href="javascript:insertcode('00FF99');" style="color:#000000;">00FF99</a></td>
+
+ <td bgcolor="00FFCC"><a href="javascript:insertcode('00FFCC');" style="color:#000000;">00FFCC</a></td>
+ <td bgcolor="00FFFF"><a href="javascript:insertcode('00FFFF');" style="color:#000000;">00FFFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="330000"><span style="color:#FFFFFF; text-decoration:line-through;">330000</span></td>
+ <td bgcolor="330033"><span style="color:#FFFFFF; text-decoration:line-through;">330033</span></td>
+ <td bgcolor="330066"><span style="color:#FFFFFF; text-decoration:line-through;">330066</span></td>
+
+ <td bgcolor="330099"><a href="javascript:insertcode('330099');" style="color:#FFFFFF;">330099</a></td>
+ <td bgcolor="3300CC"><a href="javascript:insertcode('3300CC');" style="color:#FFFFFF;">3300CC</a></td>
+ <td bgcolor="3300FF"><a href="javascript:insertcode('3300FF');" style="color:#FFFFFF;">3300FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="333300"><span style="color:#FFFFFF; text-decoration:line-through;">333300</span></td>
+ <td bgcolor="333333"><span style="color:#FFFFFF; text-decoration:line-through;">333333</span></td>
+
+ <td bgcolor="333366"><a href="javascript:insertcode('333366');" style="color:#FFFFFF;">333366</a></td>
+ <td bgcolor="333399"><a href="javascript:insertcode('333399');" style="color:#FFFFFF;">333399</a></td>
+ <td bgcolor="3333CC"><a href="javascript:insertcode('3333CC');" style="color:#FFFFFF;">3333CC</a></td>
+ <td bgcolor="3333FF"><a href="javascript:insertcode('3333FF');" style="color:#FFFFFF;">3333FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="336600"><a href="javascript:insertcode('336600');" style="color:#FFFFFF;">336600</a></td>
+
+ <td bgcolor="336633"><a href="javascript:insertcode('336633');" style="color:#FFFFFF;">336633</a></td>
+ <td bgcolor="336666"><a href="javascript:insertcode('336666');" style="color:#FFFFFF;">336666</a></td>
+ <td bgcolor="336699"><a href="javascript:insertcode('336699');" style="color:#FFFFFF;">336699</a></td>
+ <td bgcolor="3366CC"><a href="javascript:insertcode('3366CC');" style="color:#FFFFFF;">3366CC</a></td>
+ <td bgcolor="3366FF"><a href="javascript:insertcode('3366FF');" style="color:#FFFFFF;">3366FF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="339900"><a href="javascript:insertcode('339900');" style="color:#FFFFFF;">339900</a></td>
+ <td bgcolor="339933"><a href="javascript:insertcode('339933');" style="color:#FFFFFF;">339933</a></td>
+ <td bgcolor="339966"><a href="javascript:insertcode('339966');" style="color:#FFFFFF;">339966</a></td>
+ <td bgcolor="339999"><a href="javascript:insertcode('339999');" style="color:#FFFFFF;">339999</a></td>
+ <td bgcolor="3399CC"><a href="javascript:insertcode('3399CC');" style="color:#FFFFFF;">3399CC</a></td>
+
+ <td bgcolor="3399FF"><a href="javascript:insertcode('3399FF');" style="color:#FFFFFF;">3399FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="33CC00"><a href="javascript:insertcode('33CC00');" style="color:#000000;">33CC00</a></td>
+ <td bgcolor="33CC33"><a href="javascript:insertcode('33CC33');" style="color:#000000;">33CC33</a></td>
+ <td bgcolor="33CC66"><a href="javascript:insertcode('33CC66');" style="color:#000000;">33CC66</a></td>
+ <td bgcolor="33CC99"><a href="javascript:insertcode('33CC99');" style="color:#000000;">33CC99</a></td>
+
+ <td bgcolor="33CCCC"><a href="javascript:insertcode('33CCCC');" style="color:#000000;">33CCCC</a></td>
+ <td bgcolor="33CCFF"><a href="javascript:insertcode('33CCFF');" style="color:#000000;">33CCFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="33FF00"><a href="javascript:insertcode('33FF00');" style="color:#000000;">33FF00</a></td>
+ <td bgcolor="33FF33"><a href="javascript:insertcode('33FF33');" style="color:#000000;">33FF33</a></td>
+ <td bgcolor="33FF66"><a href="javascript:insertcode('33FF66');" style="color:#000000;">33FF66</a></td>
+
+ <td bgcolor="33FF99"><a href="javascript:insertcode('33FF99');" style="color:#000000;">33FF99</a></td>
+ <td bgcolor="33FFCC"><a href="javascript:insertcode('33FFCC');" style="color:#000000;">33FFCC</a></td>
+ <td bgcolor="33FFFF"><a href="javascript:insertcode('33FFFF');" style="color:#000000;">33FFFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="660000"><span style="color:#FFFFFF; text-decoration:line-through;">660000</span></td>
+ <td bgcolor="660033"><span style="color:#FFFFFF; text-decoration:line-through;">660033</span></td>
+
+ <td bgcolor="660066"><a href="javascript:insertcode('660066');" style="color:#FFFFFF;">660066</a></td>
+ <td bgcolor="660099"><a href="javascript:insertcode('660099');" style="color:#FFFFFF;">660099</a></td>
+ <td bgcolor="6600CC"><a href="javascript:insertcode('6600CC');" style="color:#FFFFFF;">6600CC</a></td>
+ <td bgcolor="6600FF"><a href="javascript:insertcode('6600FF');" style="color:#FFFFFF;">6600FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="663300"><a href="javascript:insertcode('663300');" style="color:#FFFFFF;">663300</a></td>
+
+ <td bgcolor="663333"><a href="javascript:insertcode('663333');" style="color:#FFFFFF;">663333</a></td>
+ <td bgcolor="663366"><a href="javascript:insertcode('663366');" style="color:#FFFFFF;">663366</a></td>
+ <td bgcolor="663399"><a href="javascript:insertcode('663399');" style="color:#FFFFFF;">663399</a></td>
+ <td bgcolor="6633CC"><a href="javascript:insertcode('6633CC');" style="color:#FFFFFF;">6633CC</a></td>
+ <td bgcolor="6633FF"><a href="javascript:insertcode('6633FF');" style="color:#FFFFFF;">6633FF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="666600"><a href="javascript:insertcode('666600');" style="color:#FFFFFF;">666600</a></td>
+ <td bgcolor="666633"><a href="javascript:insertcode('666633');" style="color:#FFFFFF;">666633</a></td>
+ <td bgcolor="666666"><a href="javascript:insertcode('666666');" style="color:#FFFFFF;">666666</a></td>
+ <td bgcolor="666699"><a href="javascript:insertcode('666699');" style="color:#FFFFFF;">666699</a></td>
+ <td bgcolor="6666CC"><a href="javascript:insertcode('6666CC');" style="color:#FFFFFF;">6666CC</a></td>
+
+ <td bgcolor="6666FF"><a href="javascript:insertcode('6666FF');" style="color:#FFFFFF;">6666FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="669900"><a href="javascript:insertcode('669900');" style="color:#000000;">669900</a></td>
+ <td bgcolor="669933"><a href="javascript:insertcode('669933');" style="color:#000000;">669933</a></td>
+ <td bgcolor="669966"><a href="javascript:insertcode('669966');" style="color:#000000;">669966</a></td>
+ <td bgcolor="669999"><a href="javascript:insertcode('669999');" style="color:#000000;">669999</a></td>
+
+ <td bgcolor="6699CC"><a href="javascript:insertcode('6699CC');" style="color:#000000;">6699CC</a></td>
+ <td bgcolor="6699FF"><a href="javascript:insertcode('6699FF');" style="color:#000000;">6699FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="66CC00"><a href="javascript:insertcode('66CC00');" style="color:#000000;">66CC00</a></td>
+ <td bgcolor="66CC33"><a href="javascript:insertcode('66CC33');" style="color:#000000;">66CC33</a></td>
+ <td bgcolor="66CC66"><a href="javascript:insertcode('66CC66');" style="color:#000000;">66CC66</a></td>
+
+ <td bgcolor="66CC99"><a href="javascript:insertcode('66CC99');" style="color:#000000;">66CC99</a></td>
+ <td bgcolor="66CCCC"><a href="javascript:insertcode('66CCCC');" style="color:#000000;">66CCCC</a></td>
+ <td bgcolor="66CCFF"><a href="javascript:insertcode('66CCFF');" style="color:#000000;">66CCFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="66FF00"><a href="javascript:insertcode('66FF00');" style="color:#000000;">66FF00</a></td>
+ <td bgcolor="66FF33"><a href="javascript:insertcode('66FF33');" style="color:#000000;">66FF33</a></td>
+
+ <td bgcolor="66FF66"><a href="javascript:insertcode('66FF66');" style="color:#000000;">66FF66</a></td>
+ <td bgcolor="66FF99"><a href="javascript:insertcode('66FF99');" style="color:#000000;">66FF99</a></td>
+ <td bgcolor="66FFCC"><a href="javascript:insertcode('66FFCC');" style="color:#000000;">66FFCC</a></td>
+ <td bgcolor="66FFFF"><a href="javascript:insertcode('66FFFF');" style="color:#000000;">66FFFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="990000"><a href="javascript:insertcode('990000');" style="color:#FFFFFF;">990000</a></td>
+
+ <td bgcolor="990033"><a href="javascript:insertcode('990033');" style="color:#FFFFFF;">990033</a></td>
+ <td bgcolor="990066"><a href="javascript:insertcode('990066');" style="color:#FFFFFF;">990066</a></td>
+ <td bgcolor="990099"><a href="javascript:insertcode('990099');" style="color:#FFFFFF;">990099</a></td>
+ <td bgcolor="9900CC"><a href="javascript:insertcode('9900CC');" style="color:#FFFFFF;">9900CC</a></td>
+ <td bgcolor="9900FF"><a href="javascript:insertcode('9900FF');" style="color:#FFFFFF;">9900FF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="993300"><a href="javascript:insertcode('993300');" style="color:#FFFFFF;">993300</a></td>
+ <td bgcolor="993333"><a href="javascript:insertcode('993333');" style="color:#FFFFFF;">993333</a></td>
+ <td bgcolor="993366"><a href="javascript:insertcode('993366');" style="color:#FFFFFF;">993366</a></td>
+ <td bgcolor="993399"><a href="javascript:insertcode('993399');" style="color:#FFFFFF;">993399</a></td>
+ <td bgcolor="9933CC"><a href="javascript:insertcode('9933CC');" style="color:#FFFFFF;">9933CC</a></td>
+
+ <td bgcolor="9933FF"><a href="javascript:insertcode('9933FF');" style="color:#FFFFFF;">9933FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="996600"><a href="javascript:insertcode('996600');" style="color:#FFFFFF;">996600</a></td>
+ <td bgcolor="996633"><a href="javascript:insertcode('996633');" style="color:#FFFFFF;">996633</a></td>
+ <td bgcolor="996666"><a href="javascript:insertcode('996666');" style="color:#FFFFFF;">996666</a></td>
+ <td bgcolor="996699"><a href="javascript:insertcode('996699');" style="color:#FFFFFF;">996699</a></td>
+
+ <td bgcolor="9966CC"><a href="javascript:insertcode('9966CC');" style="color:#FFFFFF;">9966CC</a></td>
+ <td bgcolor="9966FF"><a href="javascript:insertcode('9966FF');" style="color:#FFFFFF;">9966FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="999900"><a href="javascript:insertcode('999900');" style="color:#000000;">999900</a></td>
+ <td bgcolor="999933"><a href="javascript:insertcode('999933');" style="color:#000000;">999933</a></td>
+ <td bgcolor="999966"><a href="javascript:insertcode('999966');" style="color:#000000;">999966</a></td>
+
+ <td bgcolor="999999"><a href="javascript:insertcode('999999');" style="color:#000000;">999999</a></td>
+ <td bgcolor="9999CC"><a href="javascript:insertcode('9999CC');" style="color:#000000;">9999CC</a></td>
+ <td bgcolor="9999FF"><a href="javascript:insertcode('9999FF');" style="color:#000000;">9999FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="99CC00"><a href="javascript:insertcode('99CC00');" style="color:#000000;">99CC00</a></td>
+ <td bgcolor="99CC33"><a href="javascript:insertcode('99CC33');" style="color:#000000;">99CC33</a></td>
+
+ <td bgcolor="99CC66"><a href="javascript:insertcode('99CC66');" style="color:#000000;">99CC66</a></td>
+ <td bgcolor="99CC99"><a href="javascript:insertcode('99CC99');" style="color:#000000;">99CC99</a></td>
+ <td bgcolor="99CCCC"><a href="javascript:insertcode('99CCCC');" style="color:#000000;">99CCCC</a></td>
+ <td bgcolor="99CCFF"><a href="javascript:insertcode('99CCFF');" style="color:#000000;">99CCFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="99FF00"><a href="javascript:insertcode('99FF00');" style="color:#000000;">99FF00</a></td>
+
+ <td bgcolor="99FF33"><a href="javascript:insertcode('99FF33');" style="color:#000000;">99FF33</a></td>
+ <td bgcolor="99FF66"><a href="javascript:insertcode('99FF66');" style="color:#000000;">99FF66</a></td>
+ <td bgcolor="99FF99"><a href="javascript:insertcode('99FF99');" style="color:#000000;">99FF99</a></td>
+ <td bgcolor="99FFCC"><a href="javascript:insertcode('99FFCC');" style="color:#000000;">99FFCC</a></td>
+ <td bgcolor="99FFFF"><a href="javascript:insertcode('99FFFF');" style="color:#000000;">99FFFF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="CC0000"><a href="javascript:insertcode('CC0000');" style="color:#FFFFFF;">CC0000</a></td>
+ <td bgcolor="CC0033"><a href="javascript:insertcode('CC0033');" style="color:#FFFFFF;">CC0033</a></td>
+ <td bgcolor="CC0066"><a href="javascript:insertcode('CC0066');" style="color:#FFFFFF;">CC0066</a></td>
+ <td bgcolor="CC0099"><a href="javascript:insertcode('CC0099');" style="color:#FFFFFF;">CC0099</a></td>
+ <td bgcolor="CC00CC"><a href="javascript:insertcode('CC00CC');" style="color:#FFFFFF;">CC00CC</a></td>
+
+ <td bgcolor="CC00FF"><a href="javascript:insertcode('CC00FF');" style="color:#FFFFFF;">CC00FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="CC3300"><a href="javascript:insertcode('CC3300');" style="color:#FFFFFF;">CC3300</a></td>
+ <td bgcolor="CC3333"><a href="javascript:insertcode('CC3333');" style="color:#FFFFFF;">CC3333</a></td>
+ <td bgcolor="CC3366"><a href="javascript:insertcode('CC3366');" style="color:#FFFFFF;">CC3366</a></td>
+ <td bgcolor="CC3399"><a href="javascript:insertcode('CC3399');" style="color:#FFFFFF;">CC3399</a></td>
+
+ <td bgcolor="CC33CC"><a href="javascript:insertcode('CC33CC');" style="color:#FFFFFF;">CC33CC</a></td>
+ <td bgcolor="CC33FF"><a href="javascript:insertcode('CC33FF');" style="color:#FFFFFF;">CC33FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="CC6600"><a href="javascript:insertcode('CC6600');" style="color:#000000;">CC6600</a></td>
+ <td bgcolor="CC6633"><a href="javascript:insertcode('CC6633');" style="color:#000000;">CC6633</a></td>
+ <td bgcolor="CC6666"><a href="javascript:insertcode('CC6666');" style="color:#000000;">CC6666</a></td>
+
+ <td bgcolor="CC6699"><a href="javascript:insertcode('CC6699');" style="color:#000000;">CC6699</a></td>
+ <td bgcolor="CC66CC"><a href="javascript:insertcode('CC66CC');" style="color:#000000;">CC66CC</a></td>
+ <td bgcolor="CC66FF"><a href="javascript:insertcode('CC66FF');" style="color:#000000;">CC66FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="CC9900"><a href="javascript:insertcode('CC9900');" style="color:#000000;">CC9900</a></td>
+ <td bgcolor="CC9933"><a href="javascript:insertcode('CC9933');" style="color:#000000;">CC9933</a></td>
+
+ <td bgcolor="CC9966"><a href="javascript:insertcode('CC9966');" style="color:#000000;">CC9966</a></td>
+ <td bgcolor="CC9999"><a href="javascript:insertcode('CC9999');" style="color:#000000;">CC9999</a></td>
+ <td bgcolor="CC99CC"><a href="javascript:insertcode('CC99CC');" style="color:#000000;">CC99CC</a></td>
+ <td bgcolor="CC99FF"><a href="javascript:insertcode('CC99FF');" style="color:#000000;">CC99FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="CCCC00"><a href="javascript:insertcode('CCCC00');" style="color:#000000;">CCCC00</a></td>
+
+ <td bgcolor="CCCC33"><a href="javascript:insertcode('CCCC33');" style="color:#000000;">CCCC33</a></td>
+ <td bgcolor="CCCC66"><a href="javascript:insertcode('CCCC66');" style="color:#000000;">CCCC66</a></td>
+ <td bgcolor="CCCC99"><a href="javascript:insertcode('CCCC99');" style="color:#000000;">CCCC99</a></td>
+ <td bgcolor="CCCCCC"><a href="javascript:insertcode('CCCCCC');" style="color:#000000;">CCCCCC</a></td>
+ <td bgcolor="CCCCFF"><a href="javascript:insertcode('CCCCFF');" style="color:#000000;">CCCCFF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="CCFF00"><a href="javascript:insertcode('CCFF00');" style="color:#000000;">CCFF00</a></td>
+ <td bgcolor="CCFF33"><a href="javascript:insertcode('CCFF33');" style="color:#000000;">CCFF33</a></td>
+ <td bgcolor="CCFF66"><a href="javascript:insertcode('CCFF66');" style="color:#000000;">CCFF66</a></td>
+ <td bgcolor="CCFF99"><a href="javascript:insertcode('CCFF99');" style="color:#000000;">CCFF99</a></td>
+ <td bgcolor="CCFFCC"><a href="javascript:insertcode('CCFFCC');" style="color:#000000;">CCFFCC</a></td>
+
+ <td bgcolor="CCFFFF"><a href="javascript:insertcode('CCFFFF');" style="color:#000000;">CCFFFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="FF0000"><a href="javascript:insertcode('FF0000');" style="color:#FFFFFF;">FF0000</a></td>
+ <td bgcolor="FF0033"><a href="javascript:insertcode('FF0033');" style="color:#FFFFFF;">FF0033</a></td>
+ <td bgcolor="FF0066"><a href="javascript:insertcode('FF0066');" style="color:#FFFFFF;">FF0066</a></td>
+ <td bgcolor="FF0099"><a href="javascript:insertcode('FF0099');" style="color:#FFFFFF;">FF0099</a></td>
+
+ <td bgcolor="FF00CC"><a href="javascript:insertcode('FF00CC');" style="color:#FFFFFF;">FF00CC</a></td>
+ <td bgcolor="FF00FF"><a href="javascript:insertcode('FF00FF');" style="color:#FFFFFF;">FF00FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="FF3300"><a href="javascript:insertcode('FF3300');" style="color:#FFFFFF;">FF3300</a></td>
+ <td bgcolor="FF3333"><a href="javascript:insertcode('FF3333');" style="color:#FFFFFF;">FF3333</a></td>
+ <td bgcolor="FF3366"><a href="javascript:insertcode('FF3366');" style="color:#FFFFFF;">FF3366</a></td>
+
+ <td bgcolor="FF3399"><a href="javascript:insertcode('FF3399');" style="color:#FFFFFF;">FF3399</a></td>
+ <td bgcolor="FF33CC"><a href="javascript:insertcode('FF33CC');" style="color:#FFFFFF;">FF33CC</a></td>
+ <td bgcolor="FF33FF"><a href="javascript:insertcode('FF33FF');" style="color:#FFFFFF;">FF33FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="FF6600"><a href="javascript:insertcode('FF6600');" style="color:#000000;">FF6600</a></td>
+ <td bgcolor="FF6633"><a href="javascript:insertcode('FF6633');" style="color:#000000;">FF6633</a></td>
+
+ <td bgcolor="FF6666"><a href="javascript:insertcode('FF6666');" style="color:#000000;">FF6666</a></td>
+ <td bgcolor="FF6699"><a href="javascript:insertcode('FF6699');" style="color:#000000;">FF6699</a></td>
+ <td bgcolor="FF66CC"><a href="javascript:insertcode('FF66CC');" style="color:#000000;">FF66CC</a></td>
+ <td bgcolor="FF66FF"><a href="javascript:insertcode('FF66FF');" style="color:#000000;">FF66FF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="FF9900"><a href="javascript:insertcode('FF9900');" style="color:#000000;">FF9900</a></td>
+
+ <td bgcolor="FF9933"><a href="javascript:insertcode('FF9933');" style="color:#000000;">FF9933</a></td>
+ <td bgcolor="FF9966"><a href="javascript:insertcode('FF9966');" style="color:#000000;">FF9966</a></td>
+ <td bgcolor="FF9999"><a href="javascript:insertcode('FF9999');" style="color:#000000;">FF9999</a></td>
+ <td bgcolor="FF99CC"><a href="javascript:insertcode('FF99CC');" style="color:#000000;">FF99CC</a></td>
+ <td bgcolor="FF99FF"><a href="javascript:insertcode('FF99FF');" style="color:#000000;">FF99FF</a></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="FFCC00"><a href="javascript:insertcode('FFCC00');" style="color:#000000;">FFCC00</a></td>
+ <td bgcolor="FFCC33"><a href="javascript:insertcode('FFCC33');" style="color:#000000;">FFCC33</a></td>
+ <td bgcolor="FFCC66"><a href="javascript:insertcode('FFCC66');" style="color:#000000;">FFCC66</a></td>
+ <td bgcolor="FFCC99"><a href="javascript:insertcode('FFCC99');" style="color:#000000;">FFCC99</a></td>
+ <td bgcolor="FFCCCC"><a href="javascript:insertcode('FFCCCC');" style="color:#000000;">FFCCCC</a></td>
+
+ <td bgcolor="FFCCFF"><a href="javascript:insertcode('FFCCFF');" style="color:#000000;">FFCCFF</a></td>
+ </tr>
+ <tr>
+ <td bgcolor="FFFF00"><a href="javascript:insertcode('FFFF00');" style="color:#000000;">FFFF00</a></td>
+ <td bgcolor="FFFF33"><a href="javascript:insertcode('FFFF33');" style="color:#000000;">FFFF33</a></td>
+ <td bgcolor="FFFF66"><a href="javascript:insertcode('FFFF66');" style="color:#000000;">FFFF66</a></td>
+ <td bgcolor="FFFF99"><a href="javascript:insertcode('FFFF99');" style="color:#000000;">FFFF99</a></td>
+
+ <td bgcolor="FFFFCC"><a href="javascript:insertcode('FFFFCC');" style="color:#000000;">FFFFCC</a></td>
+ <td bgcolor="FFFFFF"><a href="javascript:insertcode('FFFFFF');" style="color:#000000;">FFFFFF</a></td>
+ </tr>
+ </table>
+ <br>
+ <br>
+ <input type="hidden" name="event" value="colors">
+ <input type="hidden" name="flag" value="submit">
+ <input type="hidden" name="tmpid" value="%%tmpid%%">
+ <input type="submit" value="Save colors ...">
+ </form>
+ <form name="hiddenform" action="input.html" target="blank" onsubmit="return false;">
+ <input type="hidden" name="event" value="input">
+ <input type="hidden" name="tmpid" value="%%tmpid%%">
+ <input type="hidden" name="message">
+ </form>
+ </center>
+ <br>
+ <center>
+ <span class="signature">
+ yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a>
+ </span>
+ </center>
+ <br>
+ <br>
+</body>
+</html>
diff --git a/html/demo.html b/html/demo.html
new file mode 100644
index 0000000..b04ee15
--- /dev/null
+++ b/html/demo.html
@@ -0,0 +1,27 @@
+<!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%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+</head>
+<body>
+<table align=center width=500>
+<tr>
+<td align=center class=header>%%ychat.version%%<br><br>%%INFO%%</td>
+</tr>
+<tr>
+<td colspan=2>&nbsp;</td>
+</tr>
+<tr>
+<td align=center colspan=2>
+This is the demo website provided by yChat :-)
+</td>
+</tr>
+</table>
+<br><br>
+<center><span class="signature">yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a></span></center>
+</body>
+</html>
diff --git a/html/favicon.ico b/html/favicon.ico
index c13f566..4deafd5 100644
--- a/html/favicon.ico
+++ b/html/favicon.ico
Binary files differ
diff --git a/html/frameset.html b/html/frameset.html
index fe6b973..672f8fa 100644
--- a/html/frameset.html
+++ b/html/frameset.html
@@ -1,19 +1,21 @@
+<!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>
- %%PGETITLE%%
+ %%ychat.version%%
</title>
</head>
- <frameset rows="*,60">
+ <frameset boders="0" rows="*,70">
<noframes>
Your browser does not support frames,
</noframes>
<frameset cols="*,150">
- <frame src="stream.html?event=stream&nick=%%nick%%&tmpid=%%tmpid%%" name="stream">
- <frame src="online.html?event=online&nick=%%nick%%&tmpid=%%tmpid%%" name="online">
+ <frame src="stream.html?event=stream&tmpid=%%tmpid%%" name="stream">
+ <frame src="online.html?event=online&tmpid=%%tmpid%%" name="online">
</frameset>
<frameset rows="*,0">
- <frame src="input.html?event=input&nick=%%nick%%&tmpid=%%tmpid%%" name="input">
+ <frame src="input.html?event=input&tmpid=%%tmpid%%" name="input">
<frame src="blank.html" name="blank">
</frameset>
</frameset>
diff --git a/html/help.html b/html/help.html
new file mode 100644
index 0000000..ad9a25f
--- /dev/null
+++ b/html/help.html
@@ -0,0 +1,28 @@
+<!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>
+ Chat-help - %%ychat.version%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+</head>
+<body>
+<table align=center width=500>
+<tr><td>
+ Hello %%nick%%, all chat commands available are summarized below (Please notice that only currently
+ in memory loaded command modules are listed here which should be the case by yChat default configuration). You can also access help for a specific command with the /help command. Example: /help commandname:
+</td></tr>
+<tr><td>
+<br>
+%%content%%
+</td></tr>
+</table>
+<br><br>
+ <center>
+ <span class="signature">
+ yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a>
+ </span>
+ </center>
+</body>
+</html>
diff --git a/html/images/away.gif b/html/images/away.gif
new file mode 100644
index 0000000..c001883
--- /dev/null
+++ b/html/images/away.gif
Binary files differ
diff --git a/html/images/blank.gif b/html/images/blank.gif
new file mode 100644
index 0000000..1d11fa9
--- /dev/null
+++ b/html/images/blank.gif
Binary files differ
diff --git a/html/images/guest.png b/html/images/guest.png
new file mode 100644
index 0000000..597dd12
--- /dev/null
+++ b/html/images/guest.png
Binary files differ
diff --git a/html/images/ircuser.png b/html/images/ircuser.png
new file mode 100644
index 0000000..36176d9
--- /dev/null
+++ b/html/images/ircuser.png
Binary files differ
diff --git a/html/images/rang0.png b/html/images/rang0.png
new file mode 100644
index 0000000..23dfae6
--- /dev/null
+++ b/html/images/rang0.png
Binary files differ
diff --git a/html/images/rang1.png b/html/images/rang1.png
new file mode 100644
index 0000000..7c51679
--- /dev/null
+++ b/html/images/rang1.png
Binary files differ
diff --git a/html/images/rang2.png b/html/images/rang2.png
new file mode 100644
index 0000000..36176d9
--- /dev/null
+++ b/html/images/rang2.png
Binary files differ
diff --git a/html/index.html b/html/index.html
index e8de35c..983e7ef 100644
--- a/html/index.html
+++ b/html/index.html
@@ -1,32 +1,54 @@
+<!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>
- %%PGETITLE%%
+ %%ychat.version%%
</title>
<link rel=stylesheet href="style.css" type=text/css>
</head>
-<body bgcolor=#000000 text=#ffff00>
+<body>
<table align=center width=500>
<tr>
-<td align=center class=header>%%PGETITLE%%</td>
-<td align=center class=header>%%INFO%%</td>
+<td>
+<center>
+%%ychat.version%%<br><br>%%INFO%%
+</center>
+</td>
</tr>
<tr>
- <td colspan=2>&nbsp;</td>
+<td colspan=2>&nbsp;</td>
</tr>
<tr>
- <td align=center colspan=2>
-Enter your nick:
-<form action="frameset.html" method="GET">
+<td align=center colspan=2>
+<form action="frameset.html" method="POST">
<input type="hidden" name="event" value="login">
- <input type="hidden" name="room" value="%%STRDROOM%%">
- <input type="text" name="nick">
- <input type="submit" value="login">
+Enter your nick:<br>
+ <input class="text" type="text" name="nick" value="%%nick%%" maxlength="%%chat.maxlength.username%%" accesskey="n">
+<br>
+<br>
+Enter your password:<br>
+ <input class="text" type="password" name="password" value="%%pass%%" maxlength="%%chat.maxlength.password%%" accesskey="p">
+<br>
+<br>
+Enter your room:<br>
+ <input class="text" type="text" name="room" value="%%chat.defaultroom%%" maxlength="%%chat.maxlength.roomname%%" accesskey="r">
+<br>
+<br>
+ <input type="hidden" name="end" value="end">
+ <input type="submit" value="login" accesskey="s">
</form>
+<br>
+<a class="fancy" href="register.html">Register</a> a new nick
+<br>
+<br>
+If you don't want to register you may login
+<br>
+without a password using an unregistered nick.
</td>
</tr>
</table>
<br><br>
-<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>
+<center><span class="signature">yChat is OpenSource - get it at <a class="fancy" 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 a403d8e..31ed9fe 100644
--- a/html/input.html
+++ b/html/input.html
@@ -1,34 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
- <head>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>
- %%PGETITLE%%
+ %%HTML_TITLE_TAG_CONTENT%%
</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.focus();
- document.input.message.select();
+ document.input.message.value = document.input.message.value.replace(/&/g, '\\AND');
document.input.submit();
+ document.input.message.value = "";
+ document.input.message.focus();
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 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%%">
+ <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">
<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/loggedin.html b/html/loggedin.html
new file mode 100644
index 0000000..59083b8
--- /dev/null
+++ b/html/loggedin.html
@@ -0,0 +1,27 @@
+<!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>
+ Logged in users - %%ychat.version%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+</head>
+<body>
+<table align="center">
+<tr><td>
+All currently logged in users:
+</td></tr>
+<tr><td>
+<br>
+%%USERLIST%%
+</td></tr>
+</table>
+<br><br>
+ <center>
+ <span class="signature">
+ yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a>
+ </span>
+ </center>
+</body>
+</html>
diff --git a/html/notfound.html b/html/notfound.html
index 574e341..a14d44b 100644
--- a/html/notfound.html
+++ b/html/notfound.html
@@ -1,7 +1,9 @@
+<!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>
- %%PGETITLE%%
+ %%HTML_TITLE_TAG_CONTENT%%
</title>
</head>
<body>
diff --git a/html/online.html b/html/online.html
index aa14f8d..3eda553 100644
--- a/html/online.html
+++ b/html/online.html
@@ -1,7 +1,20 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
- <meta http-equiv="refresh" content="20">
-<link rel=stylesheet href="style.css" type=text/css>
- <body bgcolor=#000000 text=#ffffff>
- %%MESSAGE%%
+<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>
</body>
</html>
diff --git a/html/options.html b/html/options.html
new file mode 100644
index 0000000..4dd5b35
--- /dev/null
+++ b/html/options.html
@@ -0,0 +1,50 @@
+<!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>
+ Options menu - %%ychat.version%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+<body>
+<table align=center width=500>
+<tr><td>
+ %%msgs%%
+ %%nick%%, all chat options available are summarized below:
+</td></tr>
+<tr><td>
+<br>
+<form name="options" action="options.html">
+Your E-Mail address:<br>
+ <input class="text" type="text" size="40" maxlength="%%chat.maxlength.emailaddress%%" name="email" value="%%email%%" accesskey="e">
+<br>
+<br>
+Your old password (needed if you want to enter a new password):<br>
+ <input class="text" type="password" maxlength="%%chat.maxlength.password%%" name="pass" accesskey="p">
+<br>
+<br>
+Your new password:<br>
+ <input class="text" type="password" maxlength="%%chat.maxlength.password%%" name="newpass" accesskey="q">
+<br>
+<br>
+Your new password again:<br>
+ <input class="text" type="password" maxlength="%%chat.maxlength.password%%" name="newpass2" accesskey="r">
+<br>
+<br>
+ <input type="hidden" name="event" value="options">
+ <input type="hidden" name="flag" value="submit">
+ <input type="hidden" name="tmpid" value="%%tmpid%%">
+ <input type="submit" value="Save options" accesskey="s">
+<form>
+</td></tr>
+</table>
+<br><br>
+ <center>
+ <span class="signature">
+ yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a>
+ </span>
+ </center>
+ <br>
+ <br>
+</body>
+</html>
diff --git a/html/register.html b/html/register.html
new file mode 100644
index 0000000..082e805
--- /dev/null
+++ b/html/register.html
@@ -0,0 +1,53 @@
+<!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>
+ Nick registration - %%ychat.version%%
+</title>
+<link rel=stylesheet href="style.css" type=text/css>
+</head>
+<body>
+<table align=center width=500>
+<tr>
+<td>
+<center>
+Nick registration<br><br>%%INFO%%
+</center>
+</td>
+</tr>
+<tr>
+<td colspan=2>&nbsp;</td>
+</tr>
+<tr>
+<td align=center colspan=2>
+<form action="register.html" method="POST">
+ <input type="hidden" value="register" name="event">
+Enter your desired nick:<br>
+ <input class="text" type="text" maxlength="%%chat.maxlength.username%%" name="nick" value="%%nick%%" accesskey="n">
+<br>
+<br>
+Enter your E-Mail address:<br>
+ <input class="text" type="text" maxlength="%%chat.maxlength.emailaddress%%" name="email" value="%%email%%" accesskey="e">
+<br>
+<br>
+Enter your password:<br>
+ <input class="text" type="password" maxlength="%%chat.maxlength.password%%" name="pass" accesskey="p">
+<br>
+<br>
+Enter your password again:<br>
+ <input class="text" type="password" maxlength="%%chat.maxlength.password%%" name="pass2" accesskey="q">
+<br>
+<br>
+ <input type="hidden" name="end" value="end">
+ <input type="submit" value="Register" accesskey="s">
+</form>
+<br>
+If you don't want to register go <a class="fancy" href="%%httpd.startsite%%">back</a>
+</td>
+</tr>
+</table>
+<br><br>
+<center><span class="signature">yChat is OpenSource - get it at <a class="fancy" target="_blank" href="http://www.yChat.org">http://www.yChat.org</a></span></center>
+</body>
+</html>
diff --git a/html/robots.txt b/html/robots.txt
new file mode 100644
index 0000000..eb05362
--- /dev/null
+++ b/html/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow:
diff --git a/html/stream.html b/html/stream.html
index 6678069..ed08a23 100644
--- a/html/stream.html
+++ b/html/stream.html
@@ -1,30 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
- <head>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>
- %%PGETITLE%%
+ %%HTML_TITLE_TAG_CONTENT%%
</title>
<link rel=stylesheet href="style.css" type=text/css>
<script language="JavaScript">
- function autoScroll()
+ var scrolling;
+ var ison;
+ function autoscroll()
{
- window.scroll(1, 50000 );
- timer = setTimeout('autoScroll()',200);
+ if(!ison){
+ scrolling = window.setInterval("window.scroll(1,1606682)",70);
+ ison = true;
+ }
}
-
- autoScroll();
-
- function stopScroll()
+ function stopscroll()
{
- clearTimeout(timer);
- }
-
- function startScroll()
- {
- timer = setTimeout('autoScroll()', 200);
+ if(ison)
+ {
+ window.clearInterval(scrolling);
+ ison = false;
+ }
}
</script>
</head>
-<body bgcolor=#000000 text=#ffffff>
- Welcome to yChat %%nick%%!
+<body class="stream">
+<h1>Engine: %%ychat.version%%</h2>
+<script language="JavaScript">
+ autoscroll();
+</script>
+
+ Welcome to the chat, %%nick%%!
<br>
<br>
+
diff --git a/html/style.css b/html/style.css
index e31bd7e..4b6d9ca 100644
--- a/html/style.css
+++ b/html/style.css
@@ -1,11 +1,48 @@
-BODY, TD {
+body, div {
font-family: Verdana, Helvetica, sans-serif;
+ background-color: #000000;
+ color: #FFFFEF;
font-size: 11pt;
}
-A {
- color: #dddddd;
+
+input {
+ color: #000000;
+ font-family: Verdana, Helvetica, sans-serif;
+ text-decoration: none;
+ font-size: 9pt;
+ padding: 2px;
+}
+
+input.text {
+ background-color: #FFFFEF;
+}
+
+.fancy {
+ font-family: Verdana, Helvetica, sans-serif;
+ font-size: 9pt;
+ color: #FFFFEF;
+ padding: 2px;
+}
+
+a:hover.fancy {
+ text-decoration: none;
+ color: #FFFFEF;
+ background-color: #000000;
+}
+
+h1 {
+ background-color: #ffa500;
+ border: solid #000000 1px;
+ font-size: 20pt;
+ padding: 13px;
+ font-width: bold;
+}
+
+body.stream {
+ background-color: #323232;
}
+
.signature {
- color: #dddddd;
+ color: #AAAAAA;
font-size: 9pt;
}
diff --git a/html/test.cgi b/html/test.cgi
new file mode 100644
index 0000000..12b7f75
--- /dev/null
+++ b/html/test.cgi
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+print "<html><body>\n";
+print "Hello World!\n";
+print "</body></html>\n";
+
+
diff --git a/html/urlredirect.html b/html/urlredirect.html
new file mode 100644
index 0000000..7e7cbde
--- /dev/null
+++ b/html/urlredirect.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<body>
+<script language='JavaScript'>
+ open("%%url%%", "_new");
+<script>
+</body>
+</html>
diff --git a/log/.keepme b/log/.keepme
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/log/.keepme
diff --git a/log/rooms/.keepme b/log/rooms/.keepme
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/log/rooms/.keepme
diff --git a/scripts/README b/scripts/README
new file mode 100644
index 0000000..189b169
--- /dev/null
+++ b/scripts/README
@@ -0,0 +1,6 @@
+All scripts should be run from the yChat main directory, example:
+
+./scripts/makeyhttpd.pl
+
+
+A ./makeyhttpd.pl WILL NOT work :)
diff --git a/scripts/astyle.sh b/scripts/astyle.sh
index 757364e..b9dbc45 100755
--- a/scripts/astyle.sh
+++ b/scripts/astyle.sh
@@ -1,6 +1,5 @@
#!/bin/sh
-
-# The yChat Project (2004, 2005)
+# The yChat Project (2004)
#
# This uses "astyle" to format C++ code into a specific code style!
diff --git a/scripts/buildnr.pl b/scripts/buildnr.pl
new file mode 100755
index 0000000..ee3d3e2
--- /dev/null
+++ b/scripts/buildnr.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+# The yChat Project (2003)
+#
+# This script increases the BUILNR of msgs,h each time the yChat
+# gets recompiled!
+
+use strict;
+
+open MSGS, "src/msgs.h";
+my @msgs = <MSGS>;
+close MSGS;
+
+foreach (@msgs)
+{
+ if ( /define BUILDNR/ )
+ {
+ s/(BUILDNR )(.+)$/$1.($2+1)/e;
+ print;
+ next;
+ }
+}
+
+open MSGS, ">src/msgs.h";
+print MSGS @msgs;
+close MSGS;
diff --git a/scripts/checkperl.sh b/scripts/checkperl.sh
new file mode 100755
index 0000000..fa5e98f
--- /dev/null
+++ b/scripts/checkperl.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# The yChat Project (2005)
+#
+# This scripts checks for a perl installation
+
+if ! which perl >/dev/null
+then
+ echo You need to have Perl in your PATH!
+ exit 1
+fi
+
+echo Using `which perl`
+exit 0
diff --git a/scripts/config.pl b/scripts/config.pl
new file mode 100755
index 0000000..79b1c49
--- /dev/null
+++ b/scripts/config.pl
@@ -0,0 +1,144 @@
+#!/usr/bin/perl
+
+# The yChat Project (2004, 2005)
+#
+# This script modifues the src/glob.h file.
+
+use strict;
+use scripts::modules::file;
+
+print <<END;
+Welcome to the yChat configurator!
+You may also edit the src/glob.h file manually instead of using
+this configurator option. Please also notice that this are only
+before-compile options. All setups which can be made after com-
+iling are placed in the yChat configuration file.
+END
+
+my $sep = "================================================================\n";
+my $stdin;
+
+for (;;)
+{
+ print "$sep Do you want to use the default before-compile options?\n";
+ print " (yes/no) [default is NO] ";
+ $stdin = <STDIN>;
+ chomp $stdin;
+ prove_if_default(\$stdin);
+ print "\n";
+
+ if ( $stdin eq "yes")
+ {
+ print " You chose to use all the default before-compile options. Exiti-\n";
+ print " ng the configurator now!\n";
+ print $sep;
+ exit(0);
+ }
+
+ last if $stdin eq "no" or $stdin eq "";
+ print " Wrong input: You need to specify yes or no!\n";
+} # for
+
+`cp src/glob.h src/glob.h.org` unless -f "src/glob.h.org";
+
+my @glob = fopen("src/glob.h.org");
+my $flag = 0;
+
+for (@glob)
+{
+ if ( $flag == 0 && /- CONFIG -/ )
+ {
+ print $sep;
+ $flag = 1;
+ next;
+ }
+
+ elsif ( $flag == 1 )
+ {
+ if ( /\*\// )
+ {
+ $flag = 2;
+ }
+
+ else
+ {
+ print;
+ }
+
+ next;
+ }
+
+ elsif ( $flag == 2 )
+ {
+ if ( /#define (.+) (.+)/ )
+ {
+ my $def = $1;
+ my $val = $2;
+ my $flg = 0;
+
+ $flg = 1 if $val =~ s/"//g;
+
+ print " [Press enter to use default value: $val] ";
+ $stdin = <STDIN>;
+ chomp $stdin;
+
+ unless ( prove_if_default(\$stdin) )
+ {
+ $stdin = "\"$stdin\"" if $flg == 1;
+ $_ = "#define $def $stdin\n";
+ }
+
+ print "\n";
+ $flag = 0;
+ next;
+ }
+
+ elsif ( /#define .+/ )
+ {
+ my $default = "true";
+ my $stdin;
+
+ for (;;)
+ {
+ $default = "false" if /\/\/#define/;
+
+ print " [Press enter to use default value: $default] ";
+ $stdin = <STDIN>;
+ chomp $stdin;
+
+ last if $stdin eq "" || $stdin eq "true" || $stdin eq "false";
+ print " Wrong input: You need to specify true or false!\n";
+ }
+
+ if ( $default eq "true" )
+ {
+ $_ = "//$_"
+ unless prove_if_default(\$stdin);
+ }
+
+ else
+ {
+ s/^\/\///
+ unless prove_if_default(\$stdin);
+ }
+
+ print "\n";
+ $flag = 0;
+ next;
+ }
+ }
+} // for
+
+ fwrite("src/glob.h", @glob);
+
+sub prove_if_default
+{
+ my $val = shift;
+ if ( $$val eq "" )
+ {
+ print " -> Using default option!\n";
+ return 1;
+ }
+ print " -> Using new option $$val!\n";
+ return 0;
+}
diff --git a/scripts/makedist.sh b/scripts/makedist.sh
new file mode 100755
index 0000000..6c51a07
--- /dev/null
+++ b/scripts/makedist.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# The yChat Project (2005)
+#
+# This script creates a .tar.bz2 ball.
+
+pwd=`pwd` && base=`basename $pwd` && cd .. &&
+version=`grep VERSION $base/src/msgs.h | head -n 1 | cut -d'"' -f2` &&
+prefix="$base-$version"
+package="$prefix.tar.bz2"
+
+echo Copying files... &&
+rm -Rf $prefix 2>/dev/null >/dev/null
+cp -Rp $base $prefix && cd $prefix &&
+
+echo Cleaning... &&
+gmake mrproper 2>/dev/null >/dev/null
+find . -name CVS | xargs rm -Rf
+cd .. &&
+
+echo Compressing... &&
+if test -f $package; then rm -f $package; fi &&
+tar cjf $package $prefix &&
+
+echo Finishing... &&
+rm -Rf $prefix 2>/dev/null >/dev/null
+cd $base &&
+du -h ../$package
diff --git a/scripts/makeyhttpd.pl b/scripts/makeyhttpd.pl
new file mode 100755
index 0000000..7dd0345
--- /dev/null
+++ b/scripts/makeyhttpd.pl
@@ -0,0 +1,198 @@
+#!/usr/bin/perl
+
+# The yChat & yhttpd Project (2004, 2005)
+#
+# This scripts modifies the yChat sources to yhttpd sources.
+
+use strict;
+use scripts::modules::file;
+
+my @delete = (
+ 'CHANGES',
+ 'g++.version',
+ 'TODO',
+ 'NEWS',
+ 'docs',
+ 'src/chat',
+ 'src/memb',
+ 'src/data',
+ 'src/irc',
+ 'src/contrib/crypt',
+ 'src/modl.h',
+ 'src/modl.cpp',
+ 'src/mods',
+ 'obj',
+ 'mods',
+ 'html',
+ 'log/rooms',
+ 'scripts/makeyhttpd.pl',
+ 'scripts/mergeconf.pl',
+ 'bin/ychat',
+ 'bin/ychat.old',
+);
+
+my @createdir = (
+ 'html'
+);
+
+my %substituate = (
+ 'ychat' => 'yhttpd',
+ 'yChat' => 'yhttpd',
+ 'YCHAT' => 'YHTTPD',
+ 'CHAT' => 'HTTPD',
+ 'yhttpd.org' => 'yChat.org',
+ '//>>' => ''
+);
+
+if ( -d "../yhttpd" ) {
+ print "Removing ../yhttpd\n";
+ system("rm -Rf ../yhttpd");
+}
+
+print "Creating new ../yhttpd\n";
+system("cp -Rp ../ychat ../yhttpd");
+
+chdir("../yhttpd");
+system("gmake clean");
+
+my @deletelines;
+foreach (@delete) {
+ next unless -d $_;
+ foreach (dopen($_)) {
+ next unless /\.h$/;
+ push @deletelines, $_;
+ }
+}
+
+print "Moving html templates\n";
+system("mv html/test.cgi .");
+system("mv html/demo.html .");
+system("mv html/style.css .");
+system("mv html/notfound.html .");
+
+print "Removing dirs and files\n->";
+foreach (@delete) {
+ next unless -f $_ || -d $_;
+ print " $_";
+ system("rm -Rf $_");
+}
+
+print "\nDeleting CVS directories\n";
+system("find . -name CVS | xargs rm -Rf");
+
+print "Creating new dirs\n->";
+foreach (@createdir) {
+ print " $_";
+ system("mkdir $_");
+}
+
+print "\nRenaming config file\n";
+system("mv etc/ychat.conf etc/yhttpd.conf");
+
+print "Moving html templates\n";
+system("mv demo.html html/index.html");
+system("mv test.cgi notfound.html style.css html");
+
+print "Editing etc/yhttpd.conf\n";
+&edit_yhttpd_conf();
+print "Removing marked lines of code\n->";
+&remove_marked_lines('.');
+print "\nEdit version numbers\n->";
+&edit_version_numbers('yhttpd/src/msgs.h','yhttpd/README');
+
+sub remove_marked_lines {
+ my $dir = shift;
+ chdir($dir);
+
+ for (&dopen("."))
+ {
+ next if /^\.+$/;
+ print " $_";
+
+ if ( -f $_ )
+ {
+ my @newfile;
+ my $flag = 0;
+
+ for my $line (fopen($_))
+ {
+ $flag = 1 if $line =~ /\/\/<<\*/;
+ if ($flag == 0 && $line !~ /\/\/<</) {
+ for ( @deletelines )
+ {
+ if ($line =~ /$_/)
+ {
+ $flag = 3;
+ last;
+ }
+ }
+
+ if ($flag != 3 )
+ {
+ map { $line =~ s/$_/$substituate{$_}/eg } keys %substituate;
+ push @newfile, $line;
+ }
+
+ else
+ {
+ $flag = 0;
+ }
+ }
+ $flag = 0 if $line =~ /\/\/\*>>/;
+ }
+
+ &fwrite($_, @newfile);
+ }
+
+ elsif ( -d $_ )
+ {
+ # Recursive
+ &remove_marked_lines($_);
+ }
+ }
+
+ chdir('..');
+}
+
+sub edit_yhttpd_conf
+{
+ my @old = fopen("etc/yhttpd.conf");
+ my @new = @old[0..1];
+
+ my $flag = 0;
+ for (@old)
+ {
+ if ($flag == 0)
+ {
+ if (/<category name="httpd">/)
+ {
+ $flag = 1;
+ push @new, $_;
+ }
+ }
+
+ else
+ {
+ push @new, $_;
+ }
+ }
+
+ fwrite("etc/yhttpd.conf", @new);
+}
+
+sub edit_version_numbers
+{
+ for (@_)
+ {
+ print " $_";
+ my @file = fopen $_;
+ for (@file)
+ {
+ s/([0-9]+\.[0-9]+)\.[0-9]+(-*)/$1$2/g for @file;
+ s/RELEASE/DEVEL/g;
+ }
+ fwrite($_,@file);
+ }
+}
+
+print "\n";
diff --git a/scripts/screen.sh b/scripts/screen.sh
new file mode 100755
index 0000000..6d5b7aa
--- /dev/null
+++ b/scripts/screen.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+screen -S ychat ./bin/ychat
diff --git a/scripts/setglobvals.pl b/scripts/setglobvals.pl
new file mode 100755
index 0000000..13288a5
--- /dev/null
+++ b/scripts/setglobvals.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+# The yChat Project (2003)
+#
+# This script sets up some variables in src/glob.h
+
+use strict;
+
+use scripts::modules::file;
+
+my $file = 'src/glob.h';
+my $gmake = `which gmake`;
+my @glob = fopen($file);
+chomp($gmake);
+
+print "-> Setting values in $file\n";
+
+my $modified = 0;
+foreach (@glob)
+{
+ if (/^(#define GMAKE) "(.*)"/)
+ {
+ if ($2 ne "$gmake \\0")
+ {
+ s/^$1 "$2"/#define GMAKE "$gmake \\0"/;
+ print " -> Set $gmake\n";
+ fwrite($file,@glob);
+ last;
+ }
+ }
+}
+
diff --git a/scripts/version.sh b/scripts/version.sh
index be1b351..46b9fc5 100755
--- a/scripts/version.sh
+++ b/scripts/version.sh
@@ -1,6 +1,11 @@
#!/bin/sh
# The yChat Project (2005)
#
-# This script shows yChat VERSION-BRANCH
+# This script shows yChat VERSION-BRANCH Build BUILDNUMBER
+
+version=`grep VERSION src/msgs.h | head -n 1 | cut -d'"' -f2`
+branch=`grep BRANCH src/msgs.h | head -n 1 | cut -d'"' -f2`
+build=`grep BUILD src/msgs.h | tail -n 1 | cut -d' ' -f3`
+echo "yChat $version-$branch Build $build"
+
-sed -n 's/.*VERSION.*: \(.*\)".*/\1/p' src/msgs.h
diff --git a/src/Makefile.in b/src/Makefile.in
index 6f43bf9..0382389 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,17 +1,21 @@
-SRCS=chat.cpp s_chat.cpp conf.cpp s_conf.cpp cont.cpp html.cpp s_html.cpp lang.cpp s_lang.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 sess.cpp sman.cpp s_sman.cpp
-#logd.cpp modl.cpp s_modl.cpp cmnd.cpp
-OBJS=$(SRCS:.cpp=.o)
-CC=g++
-LDFLAGS=@LDFLAGS@ -lstdc++ -g
-LDADD=-pthread -D_THREAD_SAFE
+SRCS=WILLBEADDEDBYCONFIGURE
+OBJS=$(addprefix ../obj/,$(SRCS:.cpp=.o))
+CC=WILLBEADDEDBYCONFIGURE
+LIBADD=`cat libs.add`
+LDFLAGS=$(LIBADD) -lstdc++
+LDADD=-pthread -D_THREAD_SAFE -export-dynamic -ldl
+INCLUDES=`cat includes.add`
+CFLAGS=-fno-inline -fno-default-inline -frepo
all: ychat
$(SRCS):
- $(CC) $(CFLAGS) -c $*.cpp
-ychat: $(OBJS)
- $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
- @mv -f ychat ..
-mrproper: clean
- @rm -f Makefile config.log config.cache config.status
- rm -f ../ychat
-clean:
- rm *.o
+ $(CC) $(INCLUDES) $(CFLAGS) -c $*.cpp
+infotext:
+ @echo Compiling base
+ychat: infotext $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
+ @mv ychat ../bin
+ @echo -n "Size of linked executable: "
+ @du -hc ../bin/ychat | tail -n 1
+clean:
+ @echo Cleaning base obj
+ @if test -d ../obj; then rm -Rf ../obj; fi
diff --git a/src/chat/base.h b/src/chat/base.h
new file mode 100644
index 0000000..bfdd6f6
--- /dev/null
+++ b/src/chat/base.h
@@ -0,0 +1,119 @@
+/*:*
+ *: File: ./src/chat/base.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef BASE_H
+#define BASE_H
+
+#include <map>
+#include "../maps/nhashmap.h"
+
+template<class type>
+class base : public nhashmap<type*>
+{
+protected:
+ void dumpit();
+
+public:
+ base();
+ ~base();
+
+ static string to_lower( string s )
+ {
+ string s_tmp("");
+ for(int i=0;i < s.size() ;i++)
+ s_tmp=s_tmp+(char)tolower(s.at(i));
+ return s_tmp;
+ }
+
+ virtual type* get_elem( string s_name, bool &b_found ); // get a element.
+ virtual type* get_elem( string s_name );
+ virtual void add_elem( type* p_type ); // add a element.
+
+ // chat::msg_post sends to all users of the system a message.
+ // room::msg_post sends to all users of the room a message.
+ // user::msg_post sends to the user a message.
+ virtual void msg_post( string *s_msg )
+ {
+ nhashmap<type*>::run_func( &base<type>::msg_post_ , (void*)s_msg );
+ }
+
+ static void msg_post_( type* type_obj, void* v_arg )
+ {
+ type_obj -> msg_post( (string*) v_arg );
+ }
+
+ virtual void check_timeout( int* i_timeout_settings )
+ {
+ nhashmap<type*>::run_func( &base<type>::check_timeout_ , (void*)i_timeout_settings );
+ }
+
+ static void check_timeout_( type* type_obj, void* v_arg )
+ {
+ type_obj -> check_timeout( (int*) v_arg );
+ }
+
+ virtual void reconf()
+ {
+ nhashmap<type*>::run_func( &base<type>::reconf_ );
+ }
+
+ static void reconf_ ( type* type_obj )
+ {
+ type_obj -> reconf ();
+ }
+
+ void get_data( map<string,string> *p_map_string )
+ {
+ nhashmap<type*>::run_func( &base<type>::get_data_ , (void*)p_map_string );
+ }
+
+ static void get_data_( type* type_obj, void* v_arg )
+ {
+ type_obj -> get_data ( (map<string,string>*) v_arg );
+ }
+
+
+ // 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 )
+ {
+ container c;
+ c.elem[0] = (void*) &s_list;
+
+ nhashmap<type*>::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]) );
+ }
+};
+
+#include "base.tmpl"
+
+#endif
diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl
new file mode 100644
index 0000000..c94ed44
--- /dev/null
+++ b/src/chat/base.tmpl
@@ -0,0 +1,85 @@
+/*:*
+ *: File: ./src/chat/base.tmpl
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef BASE_CPP
+#define BASE_CPP
+
+#include "base.h"
+
+template<class type>
+base<type>::base()
+{}
+
+template<class type>
+base<type>::~base( )
+{}
+
+template<class type>
+type*
+base<type>::get_elem( string s_name, bool &b_found )
+{
+ s_name = to_lower(s_name);
+ type* p_type = nhashmap<type*>::get_elem( s_name );
+ b_found = p_type == NULL ? false : true;
+ return p_type;
+}
+
+template<class type>
+type*
+base<type>::get_elem( string s_name)
+{
+ bool b;
+ return get_elem(s_name, b);
+}
+
+template<class type>
+void
+base<type>::add_elem( type* p_type )
+{
+ nhashmap<type*>::add_elem(p_type, p_type->get_lowercase_name());
+}
+
+template<class type>
+void
+base<type>::dumpit()
+{
+ dumpable::add("[base]");
+ vector<string>* p_vec = nhashmap<type*>::get_key_vector();
+
+ vector<string>::iterator iter;
+ for (iter = p_vec->begin(); iter != p_vec->end(); ++iter)
+ {
+ dumpable::add(*iter);
+ type* p_elem = get_elem(*iter);
+ if (p_elem)
+ {
+ dumpable::next_no_newline();
+ dumpable::add(p_elem->dump(dumpable::get_level()));
+ }
+ }
+
+ delete p_vec;
+}
+
+#endif
diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp
new file mode 100644
index 0000000..764da85
--- /dev/null
+++ b/src/chat/chat.cpp
@@ -0,0 +1,394 @@
+/*:*
+ *: File: ./src/chat/chat.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class chat implementation.
+
+#ifndef CHAT_CPP
+#define CHAT_CPP
+
+#include "chat.h"
+#include "../tool/tool.h"
+#include "../maps/mtools.h"
+#include <list>
+
+using namespace std;
+
+chat::chat( )
+{
+ { // Set up replace strings;
+ wrap::system_message(CHATREP);
+ vector<string>* p_vec_keys = wrap::CONF->get_key_vector();
+
+ for (vector<string>::iterator iter = p_vec_keys->begin();
+ iter != p_vec_keys->end();
+ iter++ )
+ {
+ if ( iter->length() >= 24 && iter->compare( 0, 22, "chat.html.replace.from" ) == 0 )
+ {
+ string s_from = wrap::CONF->get_elem(*iter);
+ map_replace_strings[s_from] = "chat.html.replace.into." + s_from;
+ vec_replace_keys.push_back(s_from);
+ }
+ }
+
+ sort(vec_replace_keys.begin(), vec_replace_keys.end());
+ delete p_vec_keys;
+ }
+}
+
+chat::~chat( )
+{
+ // Delete all room objects!
+ run_func( mtools<room*>::delete_obj );
+}
+
+user*
+chat::get_user( string &s_user )
+{
+ bool b_flag;
+ return get_user( s_user, b_flag );
+}
+
+user*
+chat::get_user( string &s_user, bool &b_found )
+{
+ container param;
+
+ param.elem[0] = (void*) &s_user ;
+ param.elem[1] = (void*) &b_found;
+
+ b_found = false;
+
+ base<room>::run_func( get_user_, (void*)&param );
+
+ if ( *( (bool*) param.elem[1] ) )
+ return (user*) param.elem[2];
+}
+
+void
+chat::get_user_( room *room_obj, void *v_arg )
+{
+ container* param = (container*) v_arg;
+
+ if ( *((bool*)param->elem[1]) )
+ return;
+
+ param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) );
+}
+
+void
+chat::login( map<string,string> &map_params )
+{
+ string s_user = map_params["nick"];
+
+ // prove if nick is empty:
+ if ( s_user.empty() )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nonick" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE0 );
+ return;
+ }
+
+ // prove if the nick is alphanumeric:
+ else if ( ! tool::is_alpha_numeric( s_user ) )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.alpnum" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE1 + s_user );
+ return;
+ }
+
+ // prove if the nick is too long:
+ else if ( s_user.length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.username") ) )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nicklength" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE2 + s_user );
+ return;
+ }
+
+ // prove if the room name is too long:
+ else if ( map_params["room"].length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.roomname") ) )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.roomnamelength" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] );
+ return;
+ }
+
+ // prove if the room name is valid
+ else if ( map_params["room"].length() < 1 )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noroom" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] );
+ return;
+ }
+
+ // prove if maxpoolsize (threads) allows this login
+ else if ( !wrap::POOL->allow_user_login() )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.maxuserlimit" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE5 + s_user);
+ return;
+ }
+
+ bool b_flag;
+
+ // prove if nick is already online / logged in.
+ get_user( s_user, b_flag );
+
+ if ( b_flag )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.online" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" );
+
+ return;
+ }
+
+ // Prove if user is recycleable from the garbage collector:
+ user *p_user = wrap::GCOL->get_user_from_garbage( s_user );
+
+ if ( p_user != NULL )
+ {
+ // 1. possibility to prove the password at login! (using recycled user)
+ if ( p_user->get_pass() != map_params["password"] )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINER + s_user );
+ return;
+ }
+ if ( p_user->get_has_sess() )
+ {
+ map_params["tmpid"] = p_user->get_tmpid();
+ }
+ else
+ {
+ sess* p_sess = wrap::SMAN->create_session();
+ p_sess->set_user(p_user);
+ map_params["tmpid"] = p_sess->get_tmpid();
+ p_user->set_tmpid( map_params["tmpid"] );
+ p_user->set_has_sess( true );
+ }
+ }
+ else // if ( p_user == NULL ) // If not in garbage create a new user!
+ {
+ p_user = new user( s_user );
+
+ // prove if nick is registered, else create a guest chatter.
+#ifdef DATABASE
+
+ hashmap<string> map_results = wrap::DATA->select_user_data( tool::to_lower(s_user), "selectlogin");
+
+ if ( map_results["nick"] == tool::to_lower(s_user) )
+ {
+ p_user->set_is_reg( true );
+ // User exists in database, prove password:
+ // 2. possibility to prove the password at login! (using new created user from database)
+ if ( map_results["password"] != map_params["password"] )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINER + s_user );
+ return;
+ }
+ else
+ { // If registered use saved options
+ map_params["registered"] = "yes";
+ map_params["color1"] = map_results["color1"];
+ map_params["color2"] = map_results["color2"];
+ map_params["email"] = map_results["email"];
+ map_params["status"] = map_results["status"];
+ }
+ }
+ else
+#endif
+
+ { // If not registered prove if guest chatting is enabled.
+ if (wrap::CONF->get_elem("chat.enableguest") != "true")
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noguest" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ wrap::system_message( LOGINE4 + s_user );
+ return;
+ }
+
+ // Guest chatter are enabled, use standard font colors
+ map_params["color1"] = wrap::CONF->get_elem( "chat.html.user.color1" );
+ map_params["color2"] = wrap::CONF->get_elem( "chat.html.user.color2" );
+ map_params["status"] = wrap::CONF->get_elem( "chat.defaultrang" );
+ }
+
+ sess* p_sess = wrap::SMAN->create_session();
+ p_sess->set_user(p_user);
+ map_params["tmpid"] = p_sess->get_tmpid();
+ p_user->set_tmpid( map_params["tmpid"] );
+ p_user->set_col1( map_params["color1"] );
+ p_user->set_col2( map_params["color2"] );
+ p_user->set_status( tool::string2int(map_params["status"]));
+ // p_user->set_sess( p_sess );
+ }
+
+ // Prove if user is the default operator.
+ if ( tool::to_lower(wrap::CONF->get_elem("chat.defaultop")) == tool::to_lower(s_user) )
+ {
+ wrap::system_message(CHATDOP);
+ p_user->set_status(0);
+ }
+
+ string s_room = map_params["room"];
+ room* p_room = get_room( s_room , b_flag );
+
+ // if room does not exist add room to list!
+ if ( ! b_flag )
+ {
+ p_room = wrap::GCOL->get_room_from_garbage();
+
+ if ( p_room )
+ {
+ p_room->set_name( s_room );
+ wrap::system_message( REUROOM + s_room );
+ }
+ else
+ {
+ p_room = new room( s_room );
+ wrap::system_message( NEWROOM + s_room );
+ }
+
+ add_elem( p_room );
+ }
+
+ // add user to the room.
+ p_room->add_user( p_user );
+
+ wrap::system_message( NEWUSER + s_user );
+
+ // post "username enters the chat" into the room.
+ string s_msg = wrap::TIMR->get_time() + " " + p_user->get_colored_bold_name() + wrap::CONF->get_elem( "chat.msgs.userenterschat" ) + "<br>\n";
+
+ // If created a new user from database while logging on (not a recycled user, they already have this set)
+ if ( map_params["registered"] == "yes" )
+ {
+ p_user->set_email( map_params["email"] );
+ p_user->set_pass( map_params["password"] );
+ // Now we will store all wanted user data into MySQL after logging out! (recycled user already have this set)
+ p_user->set_changed_data_on();
+ }
+ p_room->msg_post( &s_msg );
+}
+
+void
+chat::post( user* p_user, map<string,string> &map_params )
+{
+ p_user->renew_timeout();
+
+ string s_msg( map_params["message"] );
+
+ if ( s_msg.empty() )
+ return;
+
+ int i_max_message_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.message" ));
+ if ( s_msg.length() > i_max_message_length )
+ {
+ s_msg = s_msg.substr( 0, i_max_message_length );
+ string s_private = "<font color=\"" + wrap::CONF->get_elem( "chat.html.errorcolor" ) + "\">"
+ + wrap::CONF->get_elem( "chat.msgs.err.messagelength" ) + "</font><br>\n";
+ p_user->msg_post( &s_private );
+ }
+
+ int i_max_word_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.word" ));
+
+ // Check max word length
+ list<string> list_msg = tool::split_string( s_msg, " ");
+ list<string>::iterator iter = list_msg.begin();
+
+ for ( s_msg = ""; iter != list_msg.end(); ++iter )
+ {
+ if ( iter->length() > i_max_word_length )
+ {
+ string s_tmp[] = { iter->substr(0, i_max_word_length ), iter->substr(i_max_word_length) };
+ iter = list_msg.erase( iter );
+ iter = list_msg.insert( iter, s_tmp[1] );
+ iter = list_msg.insert( iter, s_tmp[0] );
+ --iter;
+ }
+ else
+ {
+ s_msg.append(*iter + " ");
+ }
+ }
+
+ if ( wrap::CONF->get_elem( "chat.html.tagsallow" ) != "true" )
+ tool::strip_html( &s_msg );
+
+ unsigned i_pos = s_msg.find( "/" );
+ if ( i_pos == 0 )
+ return p_user->command( s_msg );
+
+ string_replacer(&s_msg);
+ string s_post;
+
+ if ( wrap::CONF->get_elem( "chat.printalwaystime" ) == "true" )
+ s_post.append( wrap::TIMR->get_time() + " " );
+
+ s_post.append( "<font color=\"#" )
+ .append( p_user->get_col1() )
+ .append( "\">" )
+ .append( p_user->get_name() )
+ .append( ":</font> <font color=\"#")
+ .append( p_user->get_col2() )
+ .append( "\">" )
+ .append( s_msg )
+ .append( "</font><br>\n" );
+
+ p_user->get_room()->msg_post( &s_post );
+}
+
+void
+chat::reconf()
+{}
+
+void
+chat::string_replacer(string *p_msg)
+{
+ if ( wrap::CONF->get_elem( "chat.html.replace.activate" ) == "true" )
+ {
+ for (vector<string>::iterator iter = vec_replace_keys.end()-1;
+ iter != vec_replace_keys.begin();
+ iter-- )
+ *p_msg = tool::replace( *p_msg, *iter, wrap::CONF->get_elem(map_replace_strings[*iter]) );
+ }
+}
+
+void
+chat::dumpit()
+{
+ dumpable::add("[chat]");
+ base<room>::dumpit();
+}
+
+#endif
diff --git a/src/chat/chat.h b/src/chat/chat.h
new file mode 100644
index 0000000..b61ed95
--- /dev/null
+++ b/src/chat/chat.h
@@ -0,0 +1,87 @@
+/*:*
+ *: File: ./src/chat/chat.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class chat declaration.
+
+class chat;
+
+#ifndef CHAT_H
+#define CHAT_H
+
+#include <vector>
+#include "../incl.h"
+#include "base.h"
+#include "perm.h"
+#include "room.h"
+#include "user.h"
+#include "sess.h"
+#include "../tool/tool.h"
+#include "../maps/hashmap.h"
+
+using namespace std;
+
+#undef chat
+class chat : public base<room>, public perm
+{
+private:
+ map<string,string> map_replace_strings;
+ vector<string> vec_replace_keys;
+ void dumpit();
+
+public:
+ virtual room* get_room( string s_name )
+ {
+ bool b_bool;
+ return get_room( s_name, b_bool );
+ }
+
+ virtual room* get_room( string &s_name, bool &b_found )
+ {
+ return static_cast<room*>( get_elem( s_name, b_found ) );
+ }
+
+ // public methods:
+ explicit chat(); // a standard constructor.
+ ~chat(); // destructor.
+
+ // get the object of a specific user.
+ user* get_user( string &s_nick );
+ user* get_user( string &s_nick, bool &b_found );
+ static void get_user_( room* room_obj, void *v_arg );
+
+ // will be called every time a user tries to login.
+ void login( map<string,string> &map_params );
+
+ // will be called if a user posts a message.
+ void post ( user* u_user, map<string,string> &map_params );
+
+ void del_elem( string s_name )
+ {
+ base<room>::del_elem( s_name );
+ }
+
+ void reconf();
+ void string_replacer(string *p_msg);
+};
+#endif
diff --git a/src/chat/gcol.cpp b/src/chat/gcol.cpp
new file mode 100644
index 0000000..099f11e
--- /dev/null
+++ b/src/chat/gcol.cpp
@@ -0,0 +1,209 @@
+/*:*
+ *: File: ./src/chat/gcol.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef GCOL_CPP
+#define GCOL_CPP
+
+#include "gcol.h"
+
+using namespace std;
+
+gcol::gcol()
+{
+ pthread_mutex_init( &mut_vec_rooms , NULL);
+
+ p_map_users = new shashmap<user*>;
+ wrap::system_message( GARBAGE );
+
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+}
+
+gcol::~gcol()
+{
+ remove_garbage();
+ pthread_mutex_destroy( &mut_vec_rooms );
+ delete p_map_users;
+}
+
+void
+gcol::add_room_to_garbage( room* p_room )
+{
+ pthread_mutex_lock ( &mut_vec_rooms );
+ vec_rooms.push_back( p_room );
+ pthread_mutex_unlock( &mut_vec_rooms );
+ wrap::system_message( GARROOM + p_room->get_name() );
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+}
+
+void
+gcol::add_user_to_garbage( user* p_user )
+{
+ p_user->s_mess_delete();
+ p_map_users->add_elem( p_user, tool::to_lower(p_user->get_name()) );
+ wrap::system_message( GARUSER + p_user->get_name() );
+ p_user->destroy_session();
+
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+}
+
+bool
+gcol::remove_garbage()
+{
+ bool b_empty;
+
+ pthread_mutex_lock ( &mut_vec_rooms );
+ b_empty = ( vec_rooms.empty() && p_map_users->size() == 0);
+ pthread_mutex_unlock( &mut_vec_rooms );
+
+ if ( b_empty )
+ return false;
+
+ wrap::system_message( GARBACT );
+
+ pthread_mutex_lock ( &mut_vec_rooms );
+ for ( vector<room*>::iterator iter = vec_rooms.begin();
+ iter != vec_rooms.end(); iter++ )
+ {
+ wrap::system_message( REMROOM + (*iter)->get_name() );
+ delete *iter;
+ }
+ vec_rooms.clear();
+ pthread_mutex_unlock( &mut_vec_rooms );
+
+
+ p_map_users->run_func( delete_users_ );
+ p_map_users->clear();
+
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+
+ return true;
+}
+
+room*
+gcol::get_room_from_garbage()
+{
+ pthread_mutex_lock ( &mut_vec_rooms );
+
+ if ( vec_rooms.empty() )
+ {
+ pthread_mutex_unlock( &mut_vec_rooms );
+ return NULL;
+ }
+
+
+ room* p_room = vec_rooms.back();
+ vec_rooms.pop_back();
+ pthread_mutex_unlock( &mut_vec_rooms );
+
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+
+ return p_room;
+}
+
+room*
+gcol::get_room_from_garbage_or_new( string s_room )
+{
+ room* p_room = get_room_from_garbage();
+ if ( p_room == NULL )
+ return new room( s_room );
+ p_room->set_name( s_room );
+ return p_room;
+}
+
+user*
+gcol::get_user_from_garbage( string s_user )
+{
+
+ user* p_user = p_map_users->get_elem( tool::to_lower(s_user) );
+ ;
+
+ if ( p_user != NULL )
+ {
+ p_map_users->del_elem( tool::to_lower(s_user) );
+ p_user->set_name( s_user );
+ p_user->set_online( true );
+ p_user->set_invisible( false );
+ p_user->renew_timeout();
+ wrap::system_message(GARUSE2 + p_user->get_name() );
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+
+ }
+
+ return p_user;
+}
+
+void
+gcol::delete_users_( user *user_obj )
+{
+ wrap::system_message( REMUSER + user_obj->get_name() );
+ user_obj->clean();
+ delete user_obj;
+}
+
+void
+gcol::lock_mutex()
+{
+ pthread_mutex_lock ( &mut_vec_rooms );
+}
+
+void
+gcol::unlock_mutex()
+{
+ pthread_mutex_unlock ( &mut_vec_rooms );
+}
+
+#ifdef NCURSES
+void
+gcol::print_garbage( )
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ pthread_mutex_lock ( &mut_vec_rooms );
+ mvprintw( NCUR_GARBAGE_X,NCUR_GARBAGE_Y, "Garbage: %d ", p_map_users->size() + vec_rooms.size() );
+ pthread_mutex_unlock( &mut_vec_rooms );
+ refresh();
+ }
+}
+
+#endif
+
+#endif
diff --git a/src/chat/gcol.h b/src/chat/gcol.h
new file mode 100644
index 0000000..ab84269
--- /dev/null
+++ b/src/chat/gcol.h
@@ -0,0 +1,67 @@
+/*:*
+ *: File: ./src/chat/gcol.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// garbage collector
+#include "../incl.h"
+
+#ifndef GCOL_H
+#define GCOL_H
+
+#include <vector>
+#include "room.h"
+#include "user.h"
+#include "../maps/shashmap.h"
+
+using namespace std;
+
+class gcol
+{
+private:
+ vector<room*> vec_rooms;
+ shashmap<user*>* p_map_users;
+
+ pthread_mutex_t mut_vec_rooms;
+
+ static void delete_users_( user* user_obj );
+
+#ifdef NCURSES
+
+ void print_garbage( );
+#endif
+
+public:
+ gcol();
+ ~gcol();
+
+ bool remove_garbage();
+ void add_room_to_garbage( room* p_room );
+ void add_user_to_garbage( user* p_user );
+ virtual room* get_room_from_garbage();
+ virtual room* get_room_from_garbage_or_new( string s_room );
+ user* get_user_from_garbage( string s_user );
+ virtual void lock_mutex();
+ virtual void unlock_mutex();
+};
+
+#endif
diff --git a/src/chat/perm.cpp b/src/chat/perm.cpp
new file mode 100644
index 0000000..f84d4de
--- /dev/null
+++ b/src/chat/perm.cpp
@@ -0,0 +1,107 @@
+/*:*
+ *: File: ./src/chat/perm.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef PERM_CPP
+#define PERM_CPP
+
+#include "perm.h"
+#include "../maps/mtools.h"
+
+using namespace std;
+
+perm::perm()
+{
+ p_command_status = new shashmap< valwrap<int>* >;
+ p_command_disabled = new shashmap< valwrap<bool>* >;
+
+ set_standard_command_permissions();
+}
+
+perm::~perm()
+{
+ p_command_status->run_func( &mtools< valwrap<int>* >::delete_obj );
+ p_command_disabled->run_func( &mtools< valwrap<bool>* >::delete_obj );
+
+ delete p_command_status;
+ delete p_command_disabled;
+}
+
+int
+perm::get_command_status( string s_command )
+{
+ if ( p_command_status->exists( s_command ) )
+ return p_command_status->get_elem( s_command )->val;
+
+ return 0;
+}
+
+void
+perm::set_command_status( string s_command, int i_int )
+{
+ valwrap<int>* p_val = p_command_status->get_set_elem( new valwrap<int>(i_int), s_command );
+
+ if ( p_val )
+ delete p_val;
+}
+
+bool
+perm::get_command_disabled( string s_command )
+{
+ if ( p_command_disabled->exists( s_command ) )
+ return p_command_disabled->get_elem( s_command )->val;
+ return 0;
+}
+
+void
+perm::set_command_disabled( string s_command, bool b_bool )
+{
+ valwrap<bool>* p_val = p_command_disabled->get_set_elem( new valwrap<bool>(b_bool), s_command );
+
+ if ( p_val )
+ delete p_val;
+}
+
+void
+perm::set_standard_command_permissions()
+{
+ wrap::system_message(PERMSTD);
+
+ vector<string>* p_vec_keys = wrap::CONF->get_key_vector();
+
+ for (vector<string>::iterator iter = p_vec_keys->
+ begin();
+ iter != p_vec_keys->end();
+ iter++ )
+ {
+ if ( iter->length() > 17 && iter->compare( 0, 16, "chat.permissions" ) == 0 )
+ {
+ valwrap<int>* p_val = new valwrap<int>( tool::string2int( wrap::CONF->get_elem(*iter) ) );
+ p_command_status->add_elem( p_val, iter->substr(17) );
+ }
+ }
+
+ delete p_vec_keys;
+}
+
+#endif
diff --git a/src/chat/perm.h b/src/chat/perm.h
new file mode 100644
index 0000000..5fc34c3
--- /dev/null
+++ b/src/chat/perm.h
@@ -0,0 +1,66 @@
+/*:*
+ *: File: ./src/chat/perm.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+#include "../maps/shashmap.h"
+
+#ifndef PERM_H
+#define PERM_H
+
+using namespace std;
+
+template<class type_>
+struct valwrap
+{
+ type_ val;
+ valwrap(type_ i)
+ {
+ val = i;
+ }
+
+ type_ get_val()
+ {
+ return val;
+ }
+};
+
+class perm
+{
+private:
+ shashmap< valwrap<int>* >* p_command_status;
+ shashmap< valwrap<bool>* >* p_command_disabled;
+
+ void set_standard_command_permissions();
+
+public:
+ perm( );
+ ~perm( );
+
+ virtual int get_command_status( string s_command );
+ virtual bool get_command_disabled( string s_command );
+ virtual void set_command_status( string s_command, int i_int );
+ virtual void set_command_disabled( string s_command, bool b_bool );
+};
+
+#endif
diff --git a/src/chat/room.cpp b/src/chat/room.cpp
new file mode 100644
index 0000000..9ff5517
--- /dev/null
+++ b/src/chat/room.cpp
@@ -0,0 +1,138 @@
+/*:*
+ *: File: ./src/chat/room.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef ROOM_CPP
+#define ROOM_CPP
+
+#include "room.h"
+#include "../maps/mtools.h"
+
+using namespace std;
+
+room::room( string s_name ) : name( s_name )
+{
+ pthread_mutex_init( &mut_s_topic, NULL );
+#ifdef LOGGING
+
+ p_logd = new logd( wrap::CONF->get_elem("chat.logging.roomlogdir") + get_lowercase_name(),
+ wrap::CONF->get_elem("chat.logging.roomloglines") );
+#endif
+
+ wrap::STAT->increment_num_rooms();
+}
+
+room::~room()
+{
+ wrap::STAT->decrement_num_rooms();
+
+ // Delete all user objects
+ run_func( mtools<user*>::delete_obj );
+
+#ifdef LOGGING
+
+ delete p_logd;
+#endif
+
+ pthread_mutex_destroy( &mut_s_topic );
+ pthread_mutex_destroy( &mut_s_name );
+}
+
+string
+room::get_topic()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_topic );
+ s_ret = s_topic;
+ pthread_mutex_unlock( &mut_s_topic );
+ return s_ret;
+}
+
+void
+room::set_topic( string s_topic )
+{
+ pthread_mutex_lock ( &mut_s_topic );
+ if ( s_topic == "" )
+ this->s_topic = "";
+ else
+ this->s_topic = s_topic + "<br><br>";
+ pthread_mutex_unlock( &mut_s_topic );
+ reload_onlineframe();
+}
+
+void
+room::set_topic( string s_topic, string s_color )
+{
+ set_topic( "<font color=\"#" + s_color + "\">" + s_topic + "</font>");
+}
+
+void
+room::clean_room()
+{
+ pthread_mutex_lock ( &mut_s_topic );
+ this->s_topic = "";
+ pthread_mutex_unlock( &mut_s_topic );
+ wrap::CHAT->del_elem( get_lowercase_name() );
+ wrap::GCOL->add_room_to_garbage( this );
+}
+
+void
+room::reload_onlineframe()
+{
+ javascript_post("parent.online.location.reload();");
+}
+
+void
+room::set_name( string s_name )
+{
+ if ( tool::to_lower(s_name) == get_lowercase_name() )
+ {
+ name::set_name( s_name );
+ return;
+ }
+
+#ifdef LOGGING
+ p_logd->flush_logs();
+#endif
+
+ if ( s_name == "" )
+ return;
+
+ name::set_name( s_name );
+#ifdef LOGGING
+
+ p_logd->set_logfile( wrap::CONF->get_elem("chat.logging.roomlogdir"), get_lowercase_name() );
+#endif
+}
+
+void
+room::dumpit()
+{
+ dumpable::add("[room]");
+ dumpable::add("Name: "+get_name());
+ dumpable::add("Topic: "+get_topic());
+ base<user>::dumpit();
+}
+
+
+#endif
diff --git a/src/chat/room.h b/src/chat/room.h
new file mode 100644
index 0000000..8f673f5
--- /dev/null
+++ b/src/chat/room.h
@@ -0,0 +1,117 @@
+/*:*
+ *: File: ./src/chat/room.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+// class room declaration.
+
+#include "../incl.h"
+#include "../wrap.h"
+
+#ifndef ROOM_H
+#define ROOM_H
+
+#include "base.h"
+#include "../name.h"
+#include "user.h"
+#include "../tool/tool.h"
+#include "../logd.h"
+
+using namespace std;
+
+class room : public base<user>, public name
+{
+private:
+ string s_topic;
+ pthread_mutex_t mut_s_topic;
+#ifdef LOGGING
+
+ logd* p_logd;
+#endif
+
+ void dumpit();
+
+public:
+ room( string s_name );
+ ~room();
+
+ virtual void reload_onlineframe();
+
+ void add_user( user* p_user )
+ {
+ add_elem( p_user );
+ p_user->set_p_room( this );
+ reload_onlineframe();
+ }
+
+ user* get_user( string &s_name, bool &b_found )
+ {
+ return static_cast<user*>( get_elem( s_name, b_found ) );
+ }
+
+ void del_elem( string &s_name )
+ {
+ base<user>::del_elem( s_name );
+
+ if ( base<user>::size() == 0 )
+ clean_room();
+
+ else
+ reload_onlineframe();
+ }
+
+ void msg_post( string s_msg )
+ {
+ msg_post( &s_msg );
+ }
+
+ void msg_post( string *p_msg )
+ {
+#ifdef LOGGING
+ p_logd->log_simple_line( logd::remove_html_tags(*p_msg) );
+#endif
+
+ base<user>::msg_post( p_msg );
+ }
+
+ void javascript_post( string s_msg )
+ {
+ string s_js = "<script language=\"JavaScript\">"+s_msg+"</script>\n";
+ base<user>::msg_post( &s_js );
+ }
+
+ string get_bold_name()
+ {
+ return "<b>" + get_name() + "</b>";
+ }
+
+ virtual void set_name( string s_name );
+ string get_topic();
+ void set_topic( string s_topic );
+ void set_topic( string s_topic, string s_color );
+ void clean_room();
+
+
+
+};
+
+#endif
diff --git a/src/chat/sess.cpp b/src/chat/sess.cpp
new file mode 100644
index 0000000..485b643
--- /dev/null
+++ b/src/chat/sess.cpp
@@ -0,0 +1,80 @@
+/*:*
+ *: File: ./src/chat/sess.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SESS_CPP
+#define SESS_CPP
+
+#include "sess.h"
+
+sess::sess( string s_tmpid )
+{
+ this->p_user = NULL;
+ this->s_tmpid = s_tmpid;
+}
+
+sess::~sess()
+{}
+
+string
+sess::get_tmpid()
+{
+ return s_tmpid;
+}
+
+string
+sess::get_name()
+{
+ if ( p_user = NULL )
+ return "";
+
+ return p_user->get_name();
+}
+
+void
+sess::set_name(string s_name)
+{
+ if ( p_user != NULL )
+ p_user->set_name(s_name);
+}
+
+user*
+sess::get_user()
+{
+ return p_user;
+}
+
+void
+sess::set_user(user* p_user)
+{
+ this->p_user = p_user;
+}
+
+
+void
+sess::invalidate()
+{
+ this->s_tmpid = "0";
+}
+
+#endif
diff --git a/src/chat/sess.h b/src/chat/sess.h
new file mode 100644
index 0000000..f008ea2
--- /dev/null
+++ b/src/chat/sess.h
@@ -0,0 +1,55 @@
+/*:*
+ *: File: ./src/chat/sess.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef SESS_H
+#define SESS_H
+
+#include <string>
+#include "user.h"
+
+class cont;
+
+using namespace std;
+
+class sess
+{
+private:
+ string s_tmpid;
+ user *p_user;
+
+public:
+ sess(string s_tmpid);
+ ~sess();
+
+ string get_tmpid();
+
+ void set_user(user* p_user);
+ user* get_user();
+ void set_name(string s_name);
+ string get_name();
+ void invalidate();
+};
+#endif
diff --git a/src/chat/sman.cpp b/src/chat/sman.cpp
new file mode 100644
index 0000000..661085f
--- /dev/null
+++ b/src/chat/sman.cpp
@@ -0,0 +1,153 @@
+/*:*
+ *: File: ./src/chat/sman.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SMAN_CPP
+#define SMAN_CPP
+
+#include "sman.h"
+#include "../tool/tool.h"
+#include "../maps/mtools.h"
+#include "../contrib/crypt/md5.h"
+
+sman::sman()
+{
+ i_session_count = 0;
+ pthread_mutex_init( &mut_i_session_count, NULL );
+}
+
+sman::~sman()
+{
+ // Delete each session object of the shashmap!
+ shashmap<sess*>::run_func( mtools<sess*>::delete_obj );
+ pthread_mutex_destroy( &mut_i_session_count );
+}
+
+string sman::generate_id( int i_len )
+{
+ string s_valid = wrap::CONF->get_elem("chat.session.validchars");
+ string s_ret = "";
+
+ srand(time(0)+tool::string2int(wrap::CONF->get_elem("chat.session.kloakkey")));
+ int i_char;
+
+
+ for (int i = 0; i < i_len; i++)
+ {
+ i_char = rand() % s_valid.length();
+ s_ret += s_valid[i_char];
+ }
+
+ if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" )
+ {
+ string s_salt = wrap::CONF->get_elem("chat.session.md5salt");
+ string s_hash(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str()));
+ s_ret.append(s_hash.substr(s_ret.find(s_salt) + s_salt.length() + 3));
+ }
+
+ // Prove, if the TempID already exists
+ sess* p_sess = get_elem(s_ret);
+
+ if (p_sess)
+ {
+ wrap::system_message(SESSEXI);
+ return generate_id(i_len);
+ }
+
+ return s_ret;
+}
+
+sess *sman::create_session( )
+{
+ string s_tmpid = generate_id( tool::string2int( wrap::CONF->get_elem( "chat.session.length" ) ) );
+
+ sess* p_sess = new sess( s_tmpid );
+
+ pthread_mutex_lock( &mut_i_session_count );
+ i_session_count++;
+#ifdef NCURSES
+
+ print_sessions();
+#endif
+
+ pthread_mutex_unlock( &mut_i_session_count );
+
+ //????
+ add_elem( p_sess, s_tmpid );
+
+ return p_sess;
+}
+
+sess *sman::get_session( string s_id )
+{
+ return get_elem( s_id );
+}
+
+void
+sman::destroy_session( string s_id )
+{
+ pthread_mutex_lock( &mut_i_session_count );
+ i_session_count--;
+#ifdef NCURSES
+
+ print_sessions();
+#endif
+
+ pthread_mutex_unlock( &mut_i_session_count );
+
+ sess* p_sess = get_elem( s_id );
+ del_elem( s_id );
+ delete p_sess;
+}
+
+#ifdef NCURSES
+void sman::print_sessions()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_SESSION_X,NCUR_SESSION_Y, "Sessions: %d ", i_session_count);
+ refresh();
+ }
+}
+
+#ifdef NCURSES
+void sman::print_init_ncurses()
+{
+ pthread_mutex_lock( &mut_i_session_count );
+ print_sessions();
+ pthread_mutex_unlock( &mut_i_session_count );
+}
+#endif
+
+int
+sman::get_session_count()
+{
+ int i_ret;
+ pthread_mutex_lock( &mut_i_session_count );
+ i_ret = i_session_count;
+ pthread_mutex_unlock( &mut_i_session_count );
+ return i_ret;
+}
+
+#endif
+#endif
diff --git a/src/chat/sman.h b/src/chat/sman.h
new file mode 100644
index 0000000..5211fbd
--- /dev/null
+++ b/src/chat/sman.h
@@ -0,0 +1,66 @@
+/*:*
+ *: File: ./src/chat/sman.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef SMAN_H
+#define SMAN_H
+
+#include <cstdlib>
+
+#include "sess.h"
+#include "../maps/shashmap.h"
+#include "../monitor/dump.h"
+
+using namespace std;
+
+class sman : public shashmap<sess*>
+{
+private:
+ string generate_id( int i_len );
+ int i_session_count;
+
+ pthread_mutex_t mut_i_session_count;
+#ifdef NCURSES
+
+ void print_sessions();
+#endif
+
+public:
+ sman();
+ ~sman();
+ sess *get_session( string s_tmpid );
+ int get_session_count( );
+ sess *create_session( );
+ void destroy_session( string s_tmpid );
+#ifdef NCURSES
+
+ void print_init_ncurses();
+#endif
+
+};
+
+
+#endif
+
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
new file mode 100644
index 0000000..5fa4ccb
--- /dev/null
+++ b/src/chat/user.cpp
@@ -0,0 +1,619 @@
+/*:*
+ *: File: ./src/chat/user.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef USER_CPP
+#define USER_CPP
+
+#include "user.h"
+#include "../tool/tool.h"
+
+using namespace std;
+
+user::user() : name( "" )
+{
+ initialize();
+}
+
+user::user( string s_name ) : name( s_name )
+{
+ initialize();
+}
+
+user::~user()
+{
+ // pthread_mutex_destroy( & mut_map_mods );
+ pthread_mutex_destroy( & mut_away );
+ pthread_mutex_destroy( & mut_b_online );
+ pthread_mutex_destroy( & mut_b_fake );
+ pthread_mutex_destroy( & mut_b_invisible );
+ pthread_mutex_destroy( & mut_b_has_sess );
+ pthread_mutex_destroy( & mut_b_is_reg );
+ pthread_mutex_destroy( & mut_s_mess );
+ pthread_mutex_destroy( & mut_s_pass );
+ pthread_mutex_destroy( & mut_p_room );
+ pthread_mutex_destroy( & mut_s_col1 );
+ pthread_mutex_destroy( & mut_s_col2 );
+ pthread_mutex_destroy( & mut_s_email );
+ pthread_mutex_destroy( & mut_s_tmpid );
+ pthread_mutex_destroy( & mut_i_status );
+ pthread_mutex_destroy( & mut_map_changed_data );
+ pthread_cond_destroy ( &cond_message );
+ pthread_mutex_destroy( &mut_message );
+}
+
+void
+user::initialize()
+{
+ this -> b_is_reg = false;
+ this -> b_set_changed_data = false;
+ this -> b_away = false;
+ this -> b_fake = false;
+ this -> b_invisible = false;
+ this -> s_col1 = wrap::CONF->get_elem( "chat.html.user.color1" );
+ this -> s_col2 = wrap::CONF->get_elem( "chat.html.user.color2" );
+
+ // pthread_mutex_init( & mut_map_mods , NULL );
+ pthread_mutex_init( & mut_away , NULL );
+ pthread_mutex_init( & mut_b_online , NULL );
+ pthread_mutex_init( & mut_b_fake , NULL );
+ pthread_mutex_init( & mut_b_invisible , NULL );
+ pthread_mutex_init( & mut_b_has_sess , NULL );
+ pthread_mutex_init( & mut_b_is_reg , NULL );
+ pthread_mutex_init( & mut_s_mess , NULL );
+ pthread_mutex_init( & mut_s_pass , NULL );
+ pthread_mutex_init( & mut_p_room , NULL );
+ pthread_mutex_init( & mut_s_col1 , NULL );
+ pthread_mutex_init( & mut_s_col2 , NULL );
+ pthread_mutex_init( & mut_s_email , NULL );
+ pthread_mutex_init( & mut_s_tmpid , NULL );
+ pthread_mutex_init( & mut_i_status , NULL );
+ pthread_mutex_init( & mut_map_changed_data , NULL );
+ pthread_cond_init ( &cond_message, NULL);
+ pthread_mutex_init( &mut_message , NULL);
+ renew_timeout();
+}
+
+void
+user::clean()
+{
+ destroy_session();
+ set_fake( false );
+ set_invisible( false );
+ set_away( false, "" );
+}
+
+void
+user::destroy_session()
+{
+ if ( !get_has_sess() )
+ return;
+
+#ifdef DATABASE
+ // Store all changed data into the mysql table if this user is registered:
+ if ( b_is_reg )
+ wrap::DATA->update_user_data( get_name(), "savechangednick", map_changed_data );
+#endif
+
+ set_has_sess(false);
+ wrap::SMAN->destroy_session(get_tmpid());
+ set_tmpid("");
+}
+
+string
+user::get_colored_name()
+{
+ return "<font color=\"#" + get_col1() + "\">" + get_name() + "</font>";
+}
+
+void
+user::get_data( map<string,string> *p_map_data )
+{
+ string s_req = (*p_map_data)["!get"];
+
+ // get the nick and the color of the user.
+ if ( s_req == "nick" )
+ (*p_map_data)[get_name()] = get_col1();
+}
+
+string
+user::get_mess( )
+{
+ pthread_mutex_lock ( &mut_s_mess );
+ string s_ret = s_mess;
+ s_mess = "";
+ pthread_mutex_unlock( &mut_s_mess );
+ return s_ret;
+}
+
+bool
+user::get_online( )
+{
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_online );
+ b_ret = b_online;
+ pthread_mutex_unlock( &mut_b_online );
+ return b_ret;
+}
+bool
+user::get_fake( )
+{
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_fake );
+ b_ret = b_fake;
+ pthread_mutex_unlock( &mut_b_fake );
+ return b_ret;
+}
+bool
+user::get_invisible( )
+{
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_invisible );
+ b_ret = b_invisible;
+ pthread_mutex_unlock( &mut_b_invisible );
+ return b_ret;
+}
+
+bool
+user::get_has_sess( )
+{
+ bool b_ret;
+ pthread_mutex_lock ( &mut_b_has_sess );
+ b_ret = b_has_sess;
+ pthread_mutex_unlock( &mut_b_has_sess );
+ return b_ret;
+}
+
+void
+user::set_has_sess( bool b_has_sess )
+{
+ pthread_mutex_lock ( &mut_b_has_sess );
+ this->b_has_sess = b_has_sess;
+ pthread_mutex_unlock( &mut_b_has_sess );
+}
+
+bool
+user::get_is_reg( )
+{
+ bool b_ret;
+ b_ret = b_is_reg;
+ return b_ret;
+}
+
+void
+user::set_is_reg( bool b_is_reg )
+{
+ this -> b_is_reg = b_is_reg;
+}
+
+void
+user::set_online( bool b_online )
+{
+ pthread_mutex_lock ( &mut_b_online );
+ this -> b_online = b_online;
+ pthread_mutex_unlock( &mut_b_online );
+}
+
+void
+user::set_fake( bool b_fake )
+{
+ pthread_mutex_lock ( &mut_b_fake );
+ this -> b_fake = b_fake;
+ pthread_mutex_unlock( &mut_b_fake );
+}
+
+void
+user::set_invisible( bool b_invisible )
+{
+ pthread_mutex_lock ( &mut_b_invisible );
+ this -> b_invisible = b_invisible;
+ pthread_mutex_unlock( &mut_b_invisible );
+}
+
+bool
+user::get_away()
+{
+ bool b_ret;
+ pthread_mutex_lock ( &mut_away );
+ b_ret = b_away;
+ pthread_mutex_unlock( &mut_away );
+ return b_ret;
+}
+
+string
+user::get_away_msg()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_away );
+ s_ret = s_away;
+ pthread_mutex_unlock( &mut_away );
+ return s_ret;
+}
+
+void
+user::set_away( bool b_away, string s_away )
+{
+ pthread_mutex_lock ( &mut_away );
+ this -> b_away = b_away;
+ this -> s_away = s_away;
+ pthread_mutex_unlock( &mut_away );
+}
+
+void
+user::set_away( bool b_away )
+{
+ pthread_mutex_lock ( &mut_away );
+ this -> b_away = b_away;
+ pthread_mutex_unlock( &mut_away );
+}
+
+room*
+user::get_room( )
+{
+ room* p_return;
+ pthread_mutex_lock ( &mut_p_room );
+ p_return = p_room;
+ pthread_mutex_unlock( &mut_p_room );
+ return p_return;
+}
+
+void
+user::set_p_room( room* p_room )
+{
+ pthread_mutex_lock ( &mut_p_room );
+ this -> p_room = p_room;
+ pthread_mutex_unlock( &mut_p_room );
+}
+
+string
+user::get_pass()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_pass );
+ s_ret = s_pass;
+ pthread_mutex_unlock( &mut_s_pass );
+ return s_ret;
+}
+
+string
+user::get_col1()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_col1 );
+ s_ret = s_col1;
+ pthread_mutex_unlock( &mut_s_col1 );
+ return s_ret;
+}
+
+string
+user::get_col2()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_col2 );
+ s_ret = s_col2;
+ pthread_mutex_unlock( &mut_s_col2 );
+ return s_ret;
+}
+
+string
+user::get_email()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_email );
+ s_ret = s_email;
+ pthread_mutex_unlock( &mut_s_email );
+ return s_ret;
+}
+
+string
+user::get_tmpid()
+{
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_tmpid );
+ s_ret = s_tmpid;
+ pthread_mutex_unlock( &mut_s_tmpid );
+ return s_ret;
+}
+
+void
+user::set_tmpid ( string s_tmpid )
+{
+ pthread_mutex_lock ( &mut_s_tmpid );
+ this -> s_tmpid = s_tmpid;
+ pthread_mutex_unlock( &mut_s_tmpid );
+}
+
+void
+user::set_pass ( string s_pass )
+{
+ set_changed_data( "password", s_pass );
+ pthread_mutex_lock ( &mut_s_pass );
+ this -> s_pass = s_pass;
+ pthread_mutex_unlock( &mut_s_pass );
+}
+
+void
+user::set_col1 ( string s_col1 )
+{
+ set_changed_data( "color1", s_col1 );
+ pthread_mutex_lock ( &mut_s_col1 );
+ this -> s_col1 = s_col1;
+ pthread_mutex_unlock( &mut_s_col1 );
+}
+
+void
+user::set_col2 ( string s_col2 )
+{
+ set_changed_data( "color2", s_col2 );
+ pthread_mutex_lock ( &mut_s_col2 );
+ this -> s_col2 = s_col2;
+ pthread_mutex_unlock( &mut_s_col2 );
+}
+
+void
+user::set_email ( string s_email )
+{
+ set_changed_data( "email", s_email );
+ pthread_mutex_lock ( &mut_s_email );
+ this -> s_email = s_email;
+ pthread_mutex_unlock( &mut_s_email );
+}
+
+int
+user::get_status ( )
+{
+ int r_ret;
+ pthread_mutex_lock ( &mut_i_status );
+ r_ret = i_status;
+ pthread_mutex_unlock(&mut_i_status );
+ return r_ret;
+}
+
+void
+user::set_status ( int i_status )
+{
+ set_changed_data( "status", tool::int2string(i_status));
+ pthread_mutex_lock ( &mut_i_status );
+ i_old_status = this -> i_status;
+ this -> i_status = i_status;
+ pthread_mutex_unlock( &mut_i_status );
+}
+
+void
+user::set_changed_data( string s_varname, string s_value )
+{
+ if ( b_set_changed_data )
+ {
+ pthread_mutex_lock ( &mut_map_changed_data );
+ map_changed_data[s_varname] = s_value;
+ pthread_mutex_unlock( &mut_map_changed_data );
+ }
+}
+
+bool
+user::new_msgs ( )
+{
+ pthread_mutex_lock ( &mut_s_mess );
+ return s_mess.empty();
+ pthread_mutex_unlock( &mut_s_mess );
+}
+
+void
+user::command( string &s_command )
+{
+ check_restore_away();
+
+ unsigned pos = s_command.find( "/" );
+ unsigned pos2 = s_command.find( " " );
+ if( pos != string::npos )
+ {
+ s_command.replace( pos, 1, "" );
+ }
+ else
+ return;
+
+ if (pos2 == string::npos)
+ pos2 = s_command.size() + 1;
+
+ string s_mod( wrap::CONF->get_elem("httpd.modules.commandsdir") + "yc_" );
+ string s_command2 = s_command.substr(0, pos2-1);
+ s_mod.append( s_command2 ).append( ".so" );
+
+ dynmod *mod = wrap::MODL->get_module( s_mod, get_name() );
+
+ if ( mod == NULL ||
+ wrap::CHAT->get_command_disabled( s_command2 ) ||
+ get_status() > wrap::CHAT->get_command_status( s_command2 ) )
+ {
+ string s_msg = "<font color=\"" + wrap::CONF->get_elem("chat.html.errorcolor") + "\">"
+ + wrap::CONF->get_elem( "chat.msgs.err.findingcommand" )
+ + "</font>\n";
+ msg_post( &s_msg );
+ return;
+ }
+
+ vector<string> params;
+
+ // execute the module.
+ if (s_command.find(" ") != string::npos)
+ {
+ s_command = s_command.substr(s_command2.size()+1);
+ pos = s_command.find(" ");
+ pos2 = 0;
+
+ while (pos != string::npos)
+ {
+ string sParam = s_command.substr(pos2, pos - pos2);
+ params.push_back(sParam);
+ pos2 = pos + 1;
+ pos = s_command.find(" ", pos2);
+ }
+
+ if (pos2 < s_command.size())
+ {
+ params.push_back(s_command.substr(pos2, s_command.size()-pos2));
+ }
+
+ }
+
+ container* c = new container;
+ //c->elem[0]=(void*) unreserved
+ c->elem[1] = (void*) this;
+ c->elem[2] = (void*) &params;
+ c->elem[3] = (void*) wrap::WRAP;
+
+ ( *(mod->the_func) ) ( static_cast<void*>(c) );
+
+ delete c;
+}
+
+
+void
+user::s_mess_delete( )
+{
+ pthread_mutex_lock ( &mut_s_mess );
+ s_mess = "";
+ pthread_mutex_unlock( &mut_s_mess );
+}
+
+
+void
+user::msg_post( string *p_msg )
+{
+ pthread_mutex_lock ( &mut_s_mess );
+ s_mess.append( *p_msg );
+ pthread_mutex_unlock( &mut_s_mess );
+
+ pthread_cond_signal( &cond_message );
+}
+
+void
+user::check_timeout( int* i_idle_timeout )
+{
+ int i_user_timeout = (int) get_last_activity();
+
+ if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout )
+ {
+ wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
+ string s_quit = "<script language=JavaScript>top.location.href='/"
+ + wrap::CONF->get_elem("httpd.startsite")
+ + "';</script>";
+ msg_post( &s_quit );
+ set_online( false );
+
+ pthread_cond_signal( &cond_message );
+ }
+ else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout )
+ {
+ wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
+ string s_msg = wrap::CONF->get_elem("chat.msgs.userautoawaytimeout");
+ set_away( true, s_msg );
+ string s_msg2 = wrap::TIMR->get_time() + " <b>" + get_colored_name()+ "</b>" + s_msg + "<br>\n";
+ get_room()->msg_post( &s_msg2 );
+ get_room()->reload_onlineframe();
+ }
+}
+
+void
+user::get_user_list( string &s_list )
+{
+ if ( get_invisible() )
+ return;
+
+ s_list.append( wrap::CONF->get_elem("chat.html.onlinebefore") );
+
+ if ( get_away() )
+ {
+ s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location")+ "away.gif\"" )
+ .append( " alt='" )
+ .append( get_away_msg() )
+ .append( "' title='" )
+ .append( get_away_msg() )
+ .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
+ }
+ else if ( ! get_is_reg() )
+ {
+ string s_msgs = wrap::CONF->get_elem("chat.msgs.guest");
+ s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location")+ "guest.png\"" )
+ .append( " alt='" )
+ .append( s_msgs )
+ .append( "' title='" )
+ .append( s_msgs )
+ .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
+ }
+ else if ( get_status() != tool::string2int( wrap::CONF->get_elem("chat.defaultrang") ) && ! get_fake() )
+ {
+ string s_status = "rang" + tool::int2string( get_status() );
+ string s_msgs = wrap::CONF->get_elem( "chat.msgs." + s_status );
+ s_list.append("<img src=\"" + wrap::CONF->get_elem("chat.html.rangimages.location") + tool::to_lower(s_status) + ".png\"" )
+ .append( " alt='" )
+ .append( s_msgs )
+ .append( "' title='" )
+ .append( s_msgs )
+ .append( "'" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> " );
+ }
+ else
+ {
+ s_list.append("<img src=\"images/blank.gif\"" + wrap::CONF->get_elem("chat.html.rangimages.options") + "> ");
+ }
+
+ s_list.append( get_colored_name() );
+ s_list.append( wrap::CONF->get_elem("chat.html.onlinebehind") );
+ s_list.append( "\n" );
+}
+
+void
+user::check_restore_away()
+{
+ if ( get_away() )
+ {
+ get_room()->msg_post(
+ new string(
+ wrap::TIMR->get_time()
+ + " <b>" + get_colored_name()
+ + "</b> " + wrap::CONF->get_elem( "chat.msgs.unsetmodeaway" )
+ + "( <font color=" + get_col2() + ">"
+ + get_away_msg() + "</font>)<br>\n"
+ )
+ );
+ set_away( false );
+ get_room()->reload_onlineframe();
+ }
+}
+
+void
+user::reconf()
+{}
+
+void
+user::dumpit()
+{
+ dumpable::add("[user]");
+ dumpable::add("Name: " + get_name() +
+ "; Room: " + get_room()->get_name() +
+ "; Status: " + tool::int2string(get_status()));
+ dumpable::add("TempID: " + get_tmpid());
+}
+
+
+#endif
diff --git a/src/chat/user.h b/src/chat/user.h
new file mode 100644
index 0000000..c5535a5
--- /dev/null
+++ b/src/chat/user.h
@@ -0,0 +1,163 @@
+/*:*
+ *: File: ./src/chat/user.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef USER_H
+#define USER_H
+
+#include "../name.h"
+#include "../time/timo.h"
+#include "../monitor/dump.h"
+
+class room;
+
+using namespace std;
+
+class user : public name, public timo, public dumpable
+{
+private:
+
+ // private members:
+ bool b_online; // true if user is online.
+ bool b_has_sess; // true if user already has a session!
+ bool b_is_reg; // true if user is registered
+ bool b_away; // true if user is away.
+ bool b_fake; // true if user hides his status logo (does not work for guest)
+ bool b_invisible; // true if user hides his status logo (does not work for guest)
+ int i_status; // user's rang ( see enum rang @ globals.h ).
+ int i_old_status; // user's previous status.
+ string s_tmpid;
+ string s_agnt; // user's http user agent.
+ string s_away; // user's last away message.
+ string s_col1; // user's nick color.
+ string s_col2; // user's text color.
+ string s_email; // user's email addres
+ string s_mess; // message string which has to be sent to the user.
+ string s_pass; // password
+ room* p_room; // pointer to the user's room.
+
+ hashmap<string> map_changed_data; // Needed to tell yChat which data to change after user is removed!
+ bool b_set_changed_data; // Only set change data if required!
+
+ // Modules which are allowed to be executed by the user.
+
+ pthread_mutex_t mut_away;
+ pthread_mutex_t mut_b_online;
+ pthread_mutex_t mut_b_fake;
+ pthread_mutex_t mut_b_invisible;
+ pthread_mutex_t mut_b_has_sess;
+ pthread_mutex_t mut_b_is_reg;
+ pthread_mutex_t mut_s_mess;
+ pthread_mutex_t mut_s_pass;
+ pthread_mutex_t mut_p_room;
+ pthread_mutex_t mut_s_col1;
+ pthread_mutex_t mut_s_col2;
+ pthread_mutex_t mut_s_email;
+ pthread_mutex_t mut_s_tmpid;
+ pthread_mutex_t mut_i_status;
+ pthread_mutex_t mut_map_changed_data;
+
+ void initialize();
+ void set_changed_data( string s_varname, string s_value );
+ void dumpit();
+
+public:
+ pthread_cond_t cond_message;
+ pthread_mutex_t mut_message;
+
+ user();
+ user(string s_name);
+ ~user();
+
+ void clean();
+ void destroy_session();
+
+ // gets specific data of this user und stores it in
+ // (*p_map<string,string>)["nick"]. this method will be used
+ // every time data has to be got from every user of a room
+ // or even of the system.
+ void get_data( map<string,string> *p_map_data );
+
+ string get_colored_name();
+ string get_colored_bold_name()
+ {
+ return "<b>" + get_colored_name() + "</b>";
+ }
+ bool get_online();
+ bool get_fake();
+ bool get_invisible();
+ bool get_has_sess();
+ bool get_is_reg();
+ void set_online( bool b_online );
+ void set_fake( bool b_fake );
+ void set_invisible( bool b_invisible );
+ void set_has_sess( bool b_has_sess );
+ void set_is_reg( bool b_is_reg );
+ void set_changed_data_on()
+ {
+ b_set_changed_data = 1;
+ }
+ bool get_away( );
+ string get_away_msg( );
+ void set_away( bool b_away, string s_away );
+ void set_away( bool b_away );
+ room* get_room();
+ void set_p_room( room* p_room );
+ string get_pass();
+ string get_col1();
+ string get_col2();
+ string get_email();
+ string get_tmpid();
+ void set_tmpid( string s_tmpid );
+ void set_pass( string s_col1 );
+ void set_col1( string s_col1 );
+ void set_col2( string s_col2 );
+ void set_email( string s_email );
+ int get_status( );
+ void set_status( int i_status );
+ bool new_msgs ( );
+ void check_timeout( int* i_idle_timeout );
+
+ // executes a command.
+ void command( string &s_command );
+
+ // gets the message and clears s_mess;
+ string get_mess();
+
+
+ // Here are starting methods which are mainly needed by the data<type> class.
+ // appends a string to s_mess including br.
+ void msg_post( string s_msg )
+ {
+ msg_post( &s_msg );
+ }
+ void msg_post( string *p_msg );
+ void s_mess_delete( );
+ void get_user_list( string &s_list );
+ void check_restore_away();
+ void reconf();
+};
+
+#endif
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
new file mode 100644
index 0000000..e730130
--- /dev/null
+++ b/src/cli/cli.cpp
@@ -0,0 +1,376 @@
+/*:*
+ *: File: ./src/cli/cli.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef CLI_CPP
+#define CLI_CPP
+
+#include "cli.h"
+
+#ifdef CLI
+using namespace std;
+
+cli::cli( )
+{
+#ifdef NCURSES
+ start();
+#endif
+}
+
+cli::~cli()
+{}
+
+int
+cli::parse_input( string s_input )
+{
+ string s_param = "";
+ unsigned i_pos;
+
+ // Check for empty string or ignore leading whitespaces
+ while(1)
+ {
+ if (s_input.empty())
+ {
+ cout << CLIPRMI;
+ return 1;
+ }
+
+ i_pos = s_input.find_first_of(" ");
+
+ if (i_pos != 0)
+ break;
+ s_input.erase(s_input.begin());
+ }
+
+ if ( i_pos != string::npos )
+ {
+ s_param = s_input.substr(i_pos+1);
+ s_input = s_input.substr(0, i_pos);
+ }
+
+ if ( s_input.compare("help") == 0 || s_input.compare("h") == 0)
+ {
+ cout << CLIPRMO << "COMMAND LINE INTERFACE HELP MENU" << endl
+ << CLIPRMO << " !command - Uses system to run a command" << endl;
+#ifdef DEBUG
+
+ cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl;
+#endif
+
+ cout << CLIPRMO << " (du)mp [part] - Prints out a dump of the data structure" << endl;
+ cout << CLIPRMO << " (Run without part to list all possibilities)" << endl;
+ cout << CLIPRMO << " (e)cho VAR - Prints out configuration value of VAR" << endl;
+ cout << CLIPRMO << " Wildcards can be used too, example: echo http*" << endl;
+#ifdef NCURSES
+
+ cout << CLIPRMO << " (ex)it - Quits CLI mode and respawns ncurses mode" << endl;
+#endif
+
+ cout << CLIPRMO << " (h)elp - Prints out this help!" << endl;
+ //<<*
+ cout << CLIPRMO << " (m)ysql - Runs MySQL client on yChat DB" << endl
+ << CLIPRMO << " (rel)oad - Reloads all modules" << endl;
+ //*>>
+#ifdef EXPERIM
+
+ cout << CLIPRMO << " (re)conf - Reloads configuration (EXPERIMENTAL)" << endl;
+#endif
+
+ cout << CLIPRMO << " (r)usage - Shows current resource usage" << endl
+ << CLIPRMO << " (ru)sageh - Shows resource usage history (yChat needs to run > 1 day)" << endl
+ << CLIPRMO << " (set) VAR VAL - Sets configuration value VAR to VAL" << endl
+ << CLIPRMO << " (sh)ell - Runs a system shell" << endl
+ << CLIPRMO << " (s)hutdown - Shuts down the whole server" << endl
+ << CLIPRMO << " (t)ime - Prints out time and uptime" << endl;
+ cout << CLIPRMO << " (unl)oad - Unloads all loaded modules" << endl;//<<
+ cout << CLIPRMO << " (u)nset VAR - Deletes configuration value VAR" << endl
+ << CLIPRMO << " (v)ersion - Prints out version" << endl;
+ cout << CLIPRMI;
+ }
+ else if( s_input.at(0) == '!' )
+ {
+ system( s_input.substr(1).c_str() );
+ cout << CLIPRMI;
+ }
+
+#ifdef DEBUG
+ else if ( s_input.compare("d") == 0 || s_input.compare("debug") == 0 )
+ {
+ debug_routine();
+ cout << CLIPRMI;
+ }
+#endif
+ else if ( s_input.compare("du") == 0 || s_input.compare("dump") == 0 )
+ {
+ dump d(vectorize(s_param));
+ cout << CLIPRMI;
+ }
+ else if( s_input.compare("echo") == 0 || s_input.compare("e") == 0 )
+ {
+ string s_val;
+
+ // Check wildcards
+ unsigned i_pos = s_param.find("*");
+ if ( i_pos != string::npos )
+ {
+ s_param = s_param.substr( 0, i_pos );
+ vector<string>* p_vec = wrap::CONF->get_key_vector();
+ sort(p_vec->begin(), p_vec->end());
+ vector<string>::iterator iter;
+
+ for ( iter = p_vec->begin(); iter != p_vec->end(); iter++ )
+ if ( iter->find(s_param) == 0 )
+ s_val.append( *iter + " := " + wrap::CONF->get_elem(*iter) + "\n" + CLIPRMO );
+ delete p_vec;
+ }
+ else
+ {
+ s_val = wrap::CONF->get_elem(s_param);
+ }
+
+ if( s_val.empty() )
+ s_val = "Value not set";
+
+ cout << CLIPRMO << s_val << endl;
+ cout << CLIPRMI;
+ }
+
+ //<<*
+ else if( s_input.compare("mysql") == 0 || s_input.compare("m") == 0 )
+ {
+ cout << CLIPRMO << CLIMSQL << endl;
+
+ system((wrap::CONF->get_elem("chat.system.mysqlclient") + " -p -h " +
+ wrap::CONF->get_elem("chat.database.serverhost") + " -u " +
+ wrap::CONF->get_elem("chat.database.user") ).c_str());
+
+ cout << CLIPRMO << CLIWELC << endl;
+ cout << CLIPRMI;
+ }
+ //*>>
+
+#ifdef NCURSES
+ else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 )
+ {
+ return 0;
+ }
+#endif
+
+ //<<*
+ else if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 )
+ {
+ cout << CLIPRMO;
+ wrap::MODL->reload_modules();
+ cout << MODRELO << endl;
+ cout << CLIPRMI;
+ }
+ //*>>
+
+#ifdef EXPERIM
+ else if( s_input.compare("reconf") == 0 || s_input.compare("re") == 0 )
+ {
+ wrap::CHAT->reconf();
+ cout << CLIPRMI;
+ }
+#endif
+
+ else if( s_input.compare("rusage") == 0 || s_input.compare("r") == 0 )
+ {
+ print_rusage();
+ cout << CLIPRMI;
+ }
+ else if( s_input.compare("ru") == 0 || s_input.compare("rusageh") == 0 )
+ {
+ cout << wrap::STAT->get_rusage_history( "ru_maxrss", string(CLIPRMO) + " " );
+ cout << CLIPRMI;
+ }
+ else if( s_input.compare("set") == 0 )
+ {
+ string s_varname = "";
+ i_pos = s_param.find_first_of(" ");
+
+ if ( i_pos != string::npos )
+ {
+ s_varname = s_param.substr(0, i_pos);
+
+ if ( s_param.length() > i_pos+1 )
+ s_param = s_param.substr(i_pos+1);
+
+ else
+ s_param = "";
+ }
+
+ string s_old_val = wrap::CONF->get_elem(s_varname);
+
+ if ( !s_old_val.empty() )
+ {
+ cout << CLIPRMO << "Old value: " << s_old_val << endl;
+ wrap::CONF->del_elem(s_varname);
+ }
+
+ wrap::CONF->add_elem(s_param, s_varname);
+ cout << CLIPRMO << "New value: " << s_param << endl;
+ cout << CLIPRMI;
+ }
+ else if( s_input.compare("shell") == 0 || s_input.compare("sh") == 0 )
+ {
+ cout << CLIPRMO << CLISHEL << endl;
+ system(wrap::CONF->get_elem("httpd.system.shell").c_str());
+ cout << CLIPRMO << CLIWELC << endl;
+ cout << CLIPRMI;
+ }
+ else if( s_input.compare("shutdown") == 0 || s_input.compare("s") == 0 )
+ {
+ exit(0);
+ }
+ else if( s_input.compare("t") == 0 || s_input.compare("time") == 0 )
+ {
+ cout << CLIPRMO << "Time: " << wrap::TIMR->get_time() << endl
+ << CLIPRMO << "Uptime: " << wrap::TIMR->get_uptime() << endl;
+ cout << CLIPRMI;
+ }
+
+ //<<*
+ else if( s_input.compare("unl") == 0 || s_input.compare("unload") == 0 )
+ {
+ cout << CLIPRMO;
+ wrap::MODL->unload_modules();
+ cout << MODUNLO << endl;
+ cout << CLIPRMI;
+ }
+ //*>>
+
+ else if( s_input.compare("u") == 0 || s_input.compare("unset") == 0 )
+ {
+ if (!s_param.empty())
+ {
+ string s_old_val = wrap::CONF->get_elem(s_param);
+ if ( !s_old_val.empty() )
+ {
+ cout << CLIPRMO << "Deleted variable " << s_param << " with value: " << s_old_val << endl;
+ wrap::CONF->del_elem(s_param);
+ }
+ else
+ {
+ cout << CLIPRMO << "Variable " << s_param << " was not set" << endl;
+ }
+ cout << CLIPRMI;
+ }
+ }
+ else if( s_input.compare("v") == 0 || s_input.compare("version") == 0 )
+ {
+ cout << CLIPRMO << tool::ychat_version() << " " << UNAME << endl;
+ cout << CLIPRMI;
+ }
+ else
+ {
+ cout << CLIPRMO << CLIHELP << "\"" << s_input << "\"" << endl;
+ cout << CLIPRMI;
+ }
+
+ return 1;
+}
+
+void
+#ifndef NCURSES
+cli::start(void* p_void)
+#else
+cli::start()
+#endif
+{
+ cout << CLIPRMO << CLIWELC << endl;
+
+ string s_input;
+ cout << CLIPRMI;
+
+ do
+ {
+ getline(cin, s_input);
+ }
+ while( parse_input(s_input) );
+}
+
+void
+cli::print_rusage()
+{
+ rusage* p_rusage = new rusage;
+ getrusage( RUSAGE_SELF, p_rusage );
+
+ cout << CLIPRMO << "ru_maxrss: " << p_rusage->ru_maxrss << "\t(max resident set size)" << endl
+ << CLIPRMO << "ru_ixrss: " << p_rusage->ru_ixrss << "\t(integral shared text memory size)" << endl
+ << CLIPRMO << "ru_idrss: " << p_rusage->ru_idrss << "\t(integral unshared data size)" << endl
+ << CLIPRMO << "ru_isrss: " << p_rusage->ru_isrss << "\t(integral unshared stack size)" << endl
+ << CLIPRMO << "ru_minflt: " << p_rusage->ru_minflt << "\t(page reclaims)" << endl
+ << CLIPRMO << "ru_majflt: " << p_rusage->ru_majflt << "\t(page faults)" << endl
+ << CLIPRMO << "ru_nswap: " << p_rusage->ru_nswap << "\t(swaps)" << endl
+ << CLIPRMO << "ru_inblock: " << p_rusage->ru_inblock << "\t(block input operations)" << endl
+ << CLIPRMO << "ru_oublock: " << p_rusage->ru_oublock << "\t(block output operations)" << endl
+ << CLIPRMO << "ru_msgsnd: " << p_rusage->ru_msgsnd << "\t(messages sent)" << endl
+ << CLIPRMO << "ru_msgrcv: " << p_rusage->ru_msgrcv << "\t(messages received)" << endl
+ << CLIPRMO << "ru_nsignals: " << p_rusage->ru_nsignals << "\t(signals received)" << endl
+ << CLIPRMO << "ru_nvcsw: " << p_rusage->ru_nvcsw << "\t(voluntary context switches)" << endl
+ << CLIPRMO << "ru_nivcsw: " << p_rusage->ru_nivcsw << "\t(involuntary context switches)" << endl;
+
+ delete p_rusage;
+}
+
+vector<string>
+cli::vectorize(string s_param)
+{
+ vector<string> vec_ret;
+ unsigned i_pos;
+
+ for (i_pos = s_param.find(" ");
+ i_pos != string::npos;
+ i_pos = s_param.find(" "))
+ {
+ vec_ret.push_back(s_param.substr(0, i_pos));
+ s_param = s_param.substr(i_pos+1);
+ }
+
+ if (!s_param.empty())
+ vec_ret.push_back(s_param);
+
+ return vec_ret;
+}
+
+#ifdef DEBUG
+void
+cli::debug_routine()
+{
+ rusage* p_rusage = new rusage;
+ for(;;)
+ {
+ /*
+ ossl *p_tmp = new ossl;
+ getrusage( RUSAGE_SELF, p_rusage );
+ cout << CLIPRMO << "ru_maxrss: " << p_rusage->ru_maxrss << "\t(max resident set size)" << endl;
+ delete p_tmp;
+ */
+ }
+ delete p_rusage;
+}
+#endif
+
+#endif
+#endif
diff --git a/src/cli/cli.h b/src/cli/cli.h
new file mode 100644
index 0000000..df3d33b
--- /dev/null
+++ b/src/cli/cli.h
@@ -0,0 +1,85 @@
+/*:*
+ *: File: ./src/cli/cli.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <iostream>
+#include <vector>
+
+#ifndef RUSAGE_SELF
+#define RUSAGE_SELF 0
+#endif
+#ifndef RUSAGE_CHILDREN
+#define RUSAGE_CHILDREN -1
+#endif
+
+#include "../incl.h"
+
+#ifndef CLI_H
+#define CLI_H
+#ifdef CLI
+
+#ifndef NCURSES
+#include "../thrd/thro.h"
+#endif
+
+#include "../monitor/dump.h"
+
+using namespace std;
+
+#ifndef NCURSES
+class cli : public thro
+{
+#else
+class cli
+{
+#endif
+private:
+ int parse_input(string s_input);
+ vector<string> vectorize(string s_param);
+
+public:
+cli( );
+~cli( );
+
+#ifdef DEBUG
+
+void debug_routine();
+#endif
+
+void print_rusage();
+
+#ifndef NCURSES
+
+void start(void* p_void);
+#else
+
+void start();
+#endif
+};
+
+#endif
+#endif
diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp
new file mode 100644
index 0000000..a8b8410
--- /dev/null
+++ b/src/conf/conf.cpp
@@ -0,0 +1,204 @@
+/*:*
+ *: File: ./src/conf/conf.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef CONF_CPP
+#define CONF_CPP
+
+#include <fstream>
+#include "conf.h"
+
+using namespace std;
+
+conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_conf )
+{
+ string s_check[] = {
+ get_name(),
+ string(getenv("HOME"))+string("/.ychat/") + get_name(),
+ string("./etc/") + get_name(),
+ string("/etc/") + get_name(),
+ string(PREFIX+string("etc/")+get_name()) };
+
+ string s_config;
+
+ for ( int i = 0; i < 4; ++i )
+ {
+ cout << "Checking for " << s_check[i];
+ ifstream if_check( s_check[i].c_str() );
+ if( if_check )
+ {
+ s_config = s_check[i];
+ if_check.close();
+ cout << "... ok!" << endl;
+ break;
+ }
+ cout << "... not ok!" << endl;
+ }
+
+ if ( s_config.empty() )
+ {
+ cout << CFILEFA << endl;
+ exit(1);
+ }
+
+ else
+ {
+ cout << CFILEOK << "..." << endl;
+ }
+
+ p_xml = new TiXmlDocument(s_config.c_str());
+ TiXmlBase::SetCondenseWhiteSpace( false );
+
+ if ( !p_xml->LoadFile() )
+ {
+ cout << XMLER1 << endl;
+ exit(1);
+ }
+
+ vector<string> vec_string;
+ parse_xml(p_xml, &vec_string);
+
+ shashmap<string>::add_elem_insecure(tool::ychat_version(), "ychat.version");
+
+ // Overrides ychat.conf values with command line options (ychat -o key1 value1 -o key2 value2 ...)
+ map<string,string>::iterator iter;
+ for ( iter = p_start_params->begin(); iter != p_start_params->end(); iter++ )
+ {
+ shashmap<string>::del_elem_insecure(iter->first);
+ shashmap<string>::add_elem_insecure(iter->second, iter->first);
+ }
+
+ delete p_xml;
+}
+
+void
+conf::parse_xml(TiXmlNode* p_node, vector<string>* p_vec)
+{
+ if ( p_node->NoChildren() )
+ return;
+
+ for ( TiXmlNode* p_child = p_node->FirstChild(); p_child; p_child = p_child->NextSibling() )
+ {
+ //cout << p_vec->size() << ": (Value:" << p_child->Value() << ") (Type:" << p_child->Type() << ")" << endl;
+
+ if ( strcmp(p_child->Value(),"config") == 0 )
+ {
+ parse_xml(p_child, p_vec);
+ }
+
+ else if ( strcmp(p_child->Value(),"category") == 0 )
+ {
+ p_vec->push_back(p_child->ToElement()->Attribute("name"));
+ parse_xml(p_child, p_vec);
+ p_vec->pop_back();
+ }
+
+ else if ( strcmp(p_child->Value(),"option") == 0 )
+ {
+ string s_option_name = "";
+
+ for ( vector<string>::iterator iter = p_vec->
+ begin();
+ iter != p_vec->end();
+ ++iter )
+ s_option_name.append(*iter + ".");
+
+ TiXmlElement* p_element = p_child->ToElement();
+ exit_if_xml_error();
+
+ s_option_name.append(p_element->Attribute("name"));
+
+#ifdef VERBOSE
+ cout << XMLREAD << s_option_name;
+#endif
+
+ TiXmlNode *p_node_value = p_element->FirstChild("value");
+ TiXmlNode *p_node_descr = p_element->FirstChild("descr");
+
+ TiXmlText* p_text_value = NULL;
+ TiXmlText* p_text_descr = NULL;
+
+ if ( p_node_value && p_node_value->FirstChild()
+ )
+ p_text_value = p_node_value->FirstChild()->ToText();
+
+ if ( p_node_descr && p_node_descr->FirstChild()
+ )
+ p_text_descr = p_node_descr->FirstChild()->ToText();
+
+ if ( !p_text_value )
+ continue;
+
+#ifdef VERBOSE
+ cout << " := " << p_text_value->Value() << endl;
+#endif
+
+ shashmap<string>::add_elem_insecure(p_text_value->Value(), s_option_name);
+
+ if ( !p_text_descr )
+ continue;
+
+ s_option_name.append(".descr");
+#ifdef VERBOSE
+ cout << XMLREAD << s_option_name << endl;
+#endif
+ shashmap<string>::add_elem_insecure(p_text_descr->Value(), s_option_name);
+ }
+ }
+
+ exit_if_xml_error()
+ ;
+}
+
+conf::~conf()
+{
+ delete p_xml;
+}
+
+void
+conf::exit_if_xml_error() const
+{
+ if ( p_xml->Error() )
+ {
+ cout << XMLERR << p_xml->ErrorDesc() << endl;
+ exit(1);
+ }
+}
+
+//<<*
+string
+conf::colored_error_msg(string s_key)
+{
+ return "<font color=\"#"
+ + shashmap<string>::get_elem("chat.html.errorcolor")
+ + "\">" + shashmap<string>::get_elem(s_key) + "</font><br>\n";
+}
+//*>>
+
+int
+conf::get_int(string s_key)
+{
+ return tool::string2int(get_elem(s_key));
+}
+
+#endif
diff --git a/src/conf/conf.h b/src/conf/conf.h
new file mode 100644
index 0000000..2353422
--- /dev/null
+++ b/src/conf/conf.h
@@ -0,0 +1,53 @@
+/*:*
+ *: File: ./src/conf/conf.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef CONF_H
+#define CONF_H
+
+class conf; // Predefine for nmap.tmpl
+
+#include <map>
+#include "../incl.h"
+#include "../maps/shashmap.h"
+#include "../name.h"
+#include "../contrib/xml/tinyxml.h"
+
+using namespace std;
+
+class conf : public shashmap<string>, name
+{
+private:
+ TiXmlDocument* p_xml;
+ void exit_if_xml_error() const;
+ void parse_xml( TiXmlNode* p_node, vector<string>* p_vec);
+
+public:
+ conf(string s_conf, map<string,string>* p_start_params);
+ ~conf();
+
+ string colored_error_msg(string s_key); //<<
+ int get_int(string s_key);
+};
+
+#endif
diff --git a/src/configure b/src/configure
index 8c5f0a7..125890c 100755
--- a/src/configure
+++ b/src/configure
@@ -1,1555 +1,334 @@
-#! /bin/sh
+#!/bin/sh
-# 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); }
+# The yChat Project (2003 - 2005)
+#
-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
+if ! ../scripts/checkperl.sh
then
- :
-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
-
+ exit 1
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
-
-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
+if ! test -f ../g++.version
+then
+ echo You need to run ./configure of the top level source dir first
+ exit 1
+fi
+
+perl -e '
+ use strict;
+ $|=1;
+
+ my %libadd;
+ my %incadd;
+ my $deepness = 500;
+
+ my @headers = (
+ "dlfcn.h",
+ "pthread.h",
+ "mysql/mysql.h", #//<< Not needed for yhttpd
+ "netinet/in.h",
+ "time.h",
+ "ncurses.h",
+ "::test::ext/hash_map"
+ );
+
+ my @libs = (
+ "libmysqlclient.so", #//<< Not needed for yhttpd
+ "libncurses.so"
+ );
+
+ my @headerpaths = (
+ $ENV{HOME}."/include",
+ $ENV{HOME}."/usr/include",
+ "/include",
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/lib/",
+ "/usr/pkg/include",
+ "/opt/include",
+ "/opt/local/include"
+ );
+
+ my @libpaths = (
+ $ENV{HOME}."/lib",
+ $ENV{HOME}."/usr/lib",
+ "/lib",
+ "/usr/lib",
+ "/usr/local/lib",
+ "/usr/pkg/lib",
+ "/opt/lib",
+ "/opt/local/lib"
+ );
+
+ open FILE, "glob.h" or die "glob.h: $!\n";
+ while(<FILE>)
+ {
+ if ( /\/\/#define DATABASE/ )
+ {
+ remove_from_array("mysql/mysql.h",\@headers);
+ remove_from_array("libmysqlclient.so",\@libs);
+ }
+
+ if ( /\/\/#define NCURSES/ )
+ {
+ remove_from_array("ncurses.h",\@headers);
+ remove_from_array("libncurses.so",\@libs);
+ }
+ }
+ close FILE;
+
+ if ( defined $ENV{YCHATHEADERPATHS} )
+ {
+ map { print "Adding $_...\n";
+ unshift @headerpaths, $_ } split /:/, $ENV{YCHATHEADERPATHS};
+ }
+
+ if ( defined $ENV{YCHATLIBPATHS} )
+ {
+ map { print "Adding $_...\n";
+ unshift @libpaths, $_ } split /:/, $ENV{YCHATLIBPATHS};
+ }
+
+
+ print "Headers:\n";
+
+ my $testit = 0;
+ map { $incadd{&check($deepness, $_, @headerpaths)}++ }
+ @headers;
+
+ $testit = 0;
+ print "Libraries:\n";
+ map { $libadd{&check($deepness, $_, @libpaths)}++ }
+ @libs;
+
+ my $incadd = &make_add("-I", \%incadd);
+ my $libadd = &make_add("-L", \%libadd);
+
+ for ( @libs )
+ {
+ $libadd .= "-l$_ " if s/^lib// and s/\.so$//;
+ }
+
+ print "Incadd: $incadd\n";
+ print "Libadd: $libadd\n";
+
+ `echo $incadd > includes.add`;
+ `echo $libadd > libs.add`;
+
+ print "Creating new base Makefile...\n";
+ unlink("Makefile") if -f "Makefile";
+ unlink("../err") if -f "../err";
+ open Fin, "Makefile.in" or die "Makefile.in: $!\n";
+ open Fout, ">Makefile" or die "Makefile: $!\n";
+
+ my $cpp = `echo *.cpp */*.cpp contrib/*/*.cpp | sort`;
+ my $compiler = `tail -n 1 ../g++.version`;
+ my $version = `tail -n 2 ../g++.version | head -n 1`;
+ my $uname = `uname -srm`;
+ my $compopt = join "; ", split /\n/, `cat ../g++.version`;
+
+ chomp $uname;
+ chomp $compopt;
+
+ print "Configuring for $uname...\n";
+ chomp $cpp;
+ chomp $version;
+
+ while (<Fin>)
+ {
+ s/^(CC=).*\n/$1$compiler/;
+ s/^(SRCS=).*/$1$cpp/;
+ s/ -frepo//; # unless $version =~ /3\.4/;
+ if ( $uname !~ /Linux/i ) {
+ print "Disabling -ldl flag...\n" if s/ -ldl//;
+ }
+ print Fout;
+ }
+ close Fin;
-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
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
+ my $args = join(" -",@ARGV);
+ $args = "-".$args unless $args eq "";
+
+ for my $cppfile (split / /, $cpp)
+ {
+ my $ofile = $cppfile;
+ $ofile =~ s/\.cpp/\.o/;
+ print Fout "../obj/$ofile: $cppfile\n";
+ print Fout "\t\@if ! test -d `dirname ../obj/$ofile`; then mkdir -p `dirname ../obj/$ofile`; fi\n";
+ my $class = $ofile;
+ $class =~ s/\.o//;
+
+ my $text;
+ if ( $class =~ /contrib\/.+/ )
+ {
+ my $dirname = `dirname $class`;
+ $text = "\t\@echo -n \"Contributed class $class \"\n";
+ }
+
+ else
+ {
+ $text = "\t\@echo -n \"Base class $class \"\n";
+ }
+
+ print Fout "\t\@\$(CC) \$(CFLAGS) \$(INCLUDES) $args -c -o ../obj/$ofile $cppfile\n";
+ print Fout $text."\t\@du -hc ../obj/$ofile | tail -n 1 | sed s/total// | sed \"s/ //g\"\n";
+ }
+
+ close Fout;
+
+ open F, "msgs.h" or die "msgs.h: $!\n";
+ my @msgs = <F>;
+ close F;
+ unlink("msgs.h");
+ open F, ">msgs.h" or die "msgs.h: $!\n";
+
+ for (@msgs)
+ {
+ s/(UNAME)(.+)$/UNAME "$uname"/;
+ s/(COMPOPT)(.+)$/COMPOPT "$compopt"/;
+ print F;
+ }
+ close F;
+
+ if ( -d "mods" )
+ {
+ chdir("mods");
+ my $cflags = "-fno-inline -fno-default-inline";
+
+ $cflags .= " -nostdlib" if $uname =~ /FreeBSD/i && `uname -r` =~ /^4\./;
+
+ system("echo $cflags > cflags.add");
+ system("./configure");
+ chdir("..");
+ }
+
+ sub remove_from_array
+ {
+ my $elem = shift;
+ my $array = shift;
+
+ for ( my $i = 0; $i <= $#$array; ++$i )
+ {
+ if ( $$array[$i] eq $elem )
+ {
+ splice(@$array,$i,1);
+ last;
+ }
+ } # for
+ }
+
+ sub check {
+ my $deep = shift;
+
+ if ($deep == 0) {
+ print "Looking too deep! ($deepness)\n";
+ exit(1);
+ }
+
+ my $check = shift;
+ $testit = 1 if $check =~ s/::test:://;
+
+ my $print = 1;
+ if ( $_[-1] eq "subsearch" ) {
+ $print = 0;
+ pop(@_);
+ }
+
+ if ($print)
+ {
+ print "Checking for $check...";
+ print "\n" if $testit;
+ }
+
+ for (@_)
+ {
+ if ( -f "$_/$check" )
+ {
+ if ($testit)
+ {
+ return $_ if test_include($_, $check);
+ return "";
+ }
+
+ else
+ {
+ print "OK\n";
+ return "" if $_ eq "/usr/lib" or $_ eq "/usr/include";
+ return $_;
+ }
+ }
+ }
+
+ for (@_)
+ {
+ next unless -d $_;
+ opendir D, $_ or warn "$_: $!\n";
+ my @dir = readdir(D);
+ closedir D;
+
+ for my $dir ( @dir )
+ {
+ next if $dir =~ /^\.+$/ or !-d "$_/$dir";
+ my $path = &check($deep-1, $check, "$_/$dir", "subsearch");
+ return $path if $path ne "";
+ }
+ }
+
+ if ($print)
+ {
+ print "NOT OK\n";
+ print "Please make sure that you have the needed software installed!\n";
+ print "If you have a special path for your includes then edit src/configure!\n";
+ print "Or set the environment variables YCHATHEADERPATHS and YCHATLIBPATHS.\n";
+ print " Example: setenv YCHATHEADERPATHS \"/your/header/includes:/a/includes\"\n";
+ print "(The environment variables have to be seperated by an :)\n";
+ print "PS: You may use the locate and/or find command to search for files.\n";
+ exit(1);
+ }
+
+ `touch ../err`;
+ return "";
+ }
+
+ sub make_add {
+ my $flag = shift;
+ my $add = shift;
+ my $ret = "";
+
+ for (reverse keys %$add) {
+ next unless /.+/;
+ $ret .= "$flag$_ ";
+ }
+ return $ret;
+ }
+
+ sub test_include
+ {
+ my $shift = shift;
+ my $check = shift;
+ my $return = 0;
+ print "Testing $shift/$check...";
+
+ `echo "\#include \\"maps/hashmap.h\\"" > __test.cpp`;
+ `echo "int main(void){return 0;}" >> __test.cpp`;
+ my $cmd = "`tail -n 1 ../g++.version` -I$shift __test.cpp -o /dev/null 2>/dev/null";
+ system $cmd;
+
+ unless ($?)
+ {
+ print "OK\n";
+ $return = 1;
+ }
+
+ else
+ {
+ print "Not OK\n";
+ }
+
+ unlink "__test.cpp" if -f "__test.cpp";
+ return $return;
+ }
+
+ exit(0);
+' `echo "$*" | sed "s/-//g"`
diff --git a/src/contrib/README b/src/contrib/README
new file mode 100644
index 0000000..873f114
--- /dev/null
+++ b/src/contrib/README
@@ -0,0 +1,5 @@
+This directory includes source code which has been included directly into yChat but is not
+programmed by the yChat project explicitly which means the source code here is from extern.
+
+Used versions:
+tinyxml 2.3.2
diff --git a/src/contrib/crypt/how b/src/contrib/crypt/how
new file mode 100644
index 0000000..d60c94b
--- /dev/null
+++ b/src/contrib/crypt/how
@@ -0,0 +1 @@
+hash = md5::MD5Crypt(this->password.c_str(), salt);
diff --git a/src/contrib/crypt/md5.cpp b/src/contrib/crypt/md5.cpp
new file mode 100644
index 0000000..390c42d
--- /dev/null
+++ b/src/contrib/crypt/md5.cpp
@@ -0,0 +1,294 @@
+/*:*
+ *: File: ./src/contrib/crypt/md5.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+#include <string.h> /* for memcpy() */
+#include "md5.h"
+
+namespace md5
+{
+
+#ifndef HIGHFIRST
+#define byteReverse(buf, len) /* Nothing */
+#else
+void byteReverse(unsigned char *buf, unsigned longs);
+
+#ifndef ASM_MD5
+/*
+* Note: this code is harmless on little-endian machines.
+*/
+void
+byteReverse(unsigned char *buf, unsigned longs)
+{
+ uint32 t;
+ do
+ {
+ t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(uint32 *) buf = t;
+ buf += 4;
+ }
+ while (--longs);
+}
+#endif
+#endif
+
+/*
+ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+void
+MD5Init(struct MD5Context *ctx)
+{
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+void
+MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
+{
+ uint32 t;
+
+ /* Update bitcount */
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+
+ /* Handle any leading odd-sized chunks */
+
+ if (t)
+ {
+ unsigned char *p = (unsigned char *) ctx->in + t;
+
+ t = 64 - t;
+ if (len < t)
+ {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += t;
+ len -= t;
+ }
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64)
+ {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+void
+MD5Final(unsigned char digest[16], struct MD5Context *ctx)
+{
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8)
+ {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ }
+ else
+ {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count - 8);
+ }
+ byteReverse(ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ((uint32 *) ctx->in)[14] = ctx->bits[0];
+ ((uint32 *) ctx->in)[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ byteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+}
+
+#ifndef ASM_MD5
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data. MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+void
+MD5Transform(uint32 buf[4], uint32 const in[16])
+{
+ register uint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+
+#endif
+}
diff --git a/src/contrib/crypt/md5.h b/src/contrib/crypt/md5.h
new file mode 100644
index 0000000..49bbd94
--- /dev/null
+++ b/src/contrib/crypt/md5.h
@@ -0,0 +1,58 @@
+/*:*
+ *: File: ./src/contrib/crypt/md5.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef MD5_H
+#define MD5_H
+
+namespace md5
+{
+#ifdef __alpha
+typedef unsigned int uint32;
+#else
+
+typedef unsigned long uint32;
+#endif
+
+struct MD5Context
+{
+ uint32 buf[4];
+ uint32 bits[2];
+ unsigned char in[64];
+};
+
+void MD5Init(struct MD5Context *context);
+void MD5Update(struct MD5Context *context, unsigned char const *buf,
+ unsigned len);
+void MD5Final(unsigned char digest[16], struct MD5Context *context);
+void MD5Transform(uint32 buf[4], uint32 const in[16]);
+
+
+char *
+MD5Crypt(const char *pw, const char *salt);
+/*
+ * This is needed to make RSAREF happy on some MS-DOS compilers.
+ */
+typedef struct MD5Context MD5_CTX;
+}
+#endif /* !MD5_H */
diff --git a/src/contrib/crypt/md5crypt.cpp b/src/contrib/crypt/md5crypt.cpp
new file mode 100644
index 0000000..39aa4dd
--- /dev/null
+++ b/src/contrib/crypt/md5crypt.cpp
@@ -0,0 +1,186 @@
+/*:*
+ *: File: ./src/contrib/crypt/md5crypt.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ * Ported from FreeBSD to Linux, only minimal changes. --marekm
+ */
+
+#include <unistd.h>
+/* #include <stdio.h> */
+#include <string.h>
+#include "md5.h"
+
+namespace md5
+{
+
+static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+static void
+to64(char *s, unsigned long v, int n)
+{
+ while (--n >= 0)
+ {
+ *s++ = itoa64[v&0x3f];
+ v >>= 6;
+ }
+}
+
+/*
+ * UNIX password
+ *
+ * Use MD5 for what it is best at...
+ */
+
+char *
+MD5Crypt(const char *pw, const char *salt)
+{
+ static char *magic = "$1$"; /*
+ * This string is magic for
+ * this algorithm. Having
+ * it this way, we can get
+ * get better later on
+ */
+ static char passwd[120], *p;
+ static const char *sp,*ep;
+ unsigned char final[16];
+ int sl,pl,i,j;
+ MD5_CTX ctx,ctx1;
+ unsigned long l;
+
+ /* Refine the Salt first */
+ sp = salt;
+
+ /* If it starts with the magic string, then skip that */
+ if(!strncmp(sp,magic,strlen(magic)))
+ sp += strlen(magic);
+
+ /* It stops at the first '$', max 8 chars */
+ for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
+ continue;
+
+ /* get the length of the true salt */
+ sl = ep - sp;
+
+ MD5Init(&ctx);
+
+ /* The password first, since that is what is most unknown */
+ MD5Update(&ctx,(const unsigned char*)pw,strlen(pw));
+
+ /* Then our magic string */
+ MD5Update(&ctx,(const unsigned char*)magic,strlen(magic));
+
+ /* Then the raw salt */
+ MD5Update(&ctx,(const unsigned char*)sp,sl);
+
+ /* Then just as many characters of the MD5(pw,salt,pw) */
+ MD5Init(&ctx1);
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ MD5Update(&ctx1,(const unsigned char*)sp,sl);
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ MD5Final(final,&ctx1);
+ for(pl = strlen(pw); pl > 0; pl -= 16)
+ MD5Update(&ctx,final,pl>16 ? 16 : pl);
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final,0,sizeof final);
+
+ /* Then something really weird... */
+ for (j=0,i = strlen(pw); i ; i >>= 1)
+ if(i&1)
+ MD5Update(&ctx, final+j, 1);
+ else
+ MD5Update(&ctx, (const unsigned char*)pw+j, 1);
+
+ /* Now make the output string */
+ strcpy(passwd,magic);
+ strncat(passwd,sp,sl);
+ strcat(passwd,"$");
+
+ MD5Final(final,&ctx);
+
+ /*
+ * and now, just to make sure things don't run too fast
+ * On a 60 Mhz Pentium this takes 34 msec, so you would
+ * need 30 seconds to build a 1000 entry dictionary...
+ */
+ for(i=0;i<1000;i++)
+ {
+ MD5Init(&ctx1);
+ if(i & 1)
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ else
+ MD5Update(&ctx1,final,16);
+
+ if(i % 3)
+ MD5Update(&ctx1,(const unsigned char*)sp,sl);
+
+ if(i % 7)
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+
+ if(i & 1)
+ MD5Update(&ctx1,final,16);
+ else
+ MD5Update(&ctx1,(const unsigned char*)pw,strlen(pw));
+ MD5Final(final,&ctx1);
+ }
+
+ p = passwd + strlen(passwd);
+
+ l = (final[ 0]<<16) | (final[ 6]<<8) | final[12];
+ to64(p,l,4);
+ p += 4;
+ l = (final[ 1]<<16) | (final[ 7]<<8) | final[13];
+ to64(p,l,4);
+ p += 4;
+ l = (final[ 2]<<16) | (final[ 8]<<8) | final[14];
+ to64(p,l,4);
+ p += 4;
+ l = (final[ 3]<<16) | (final[ 9]<<8) | final[15];
+ to64(p,l,4);
+ p += 4;
+ l = (final[ 4]<<16) | (final[10]<<8) | final[ 5];
+ to64(p,l,4);
+ p += 4;
+ l = final[11] ;
+ to64(p,l,2);
+ p += 2;
+ *p = '\0';
+
+ /* Don't leave anything around in vm they could use. */
+ memset(final,0,sizeof final);
+
+ return passwd;
+}
+
+}
diff --git a/src/contrib/xml/README b/src/contrib/xml/README
new file mode 100644
index 0000000..c03aaad
--- /dev/null
+++ b/src/contrib/xml/README
@@ -0,0 +1,504 @@
+ATTENTION:
+
+This version of TinyXML has ben very little modified by
+Paul C. Buetow in 2004 to fit the yChat project.
+
+To get the original source go to
+http://www.sourceforge.net/projects/tinyxml
+
+/** @mainpage
+
+<h1> TinyXml </h1>
+
+TinyXml is a simple, small, C++ XML parser that can be easily
+integrating into other programs.
+
+
+<h2> What it does. </h2>
+
+In brief, TinyXml parses an XML document, and builds from that a
+Document Object Model (DOM) that can be read, modified, and saved.
+
+XML stands for "eXtensible Markup Language." It allows you to create
+your own document markups. Where HTML does a very good job of marking
+documents for browsers, XML allows you to define any kind of document
+markup, for example a document that describes a "to do" list for an
+organizer application. XML is a very structured and convenient format.
+All those random file formats created to store application data can
+all be replaced with XML. One parser for everything.
+
+The best place for the complete, correct, and quite frankly hard to
+read spec is at <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
+http://www.w3.org/TR/2004/REC-xml-20040204/</a>. An intro to XML
+(that I really like) can be found at
+<a href="http://skew.org/xml/tutorial/">http://skew.org/xml/tutorial</a>.
+
+There are different ways to access and interact with XML data.
+TinyXml uses a Document Object Model (DOM), meaning the XML data is parsed
+into a C++ objects that can be browsed and manipulated, and then
+written to disk or another output stream. You can also construct an XML document from
+scratch with C++ objects and write this to disk or another output
+stream.
+
+TinyXml is designed to be easy and fast to learn. It is two headers
+and four cpp files. Simply add these to your project and off you go.
+There is an example file - xmltest.cpp - to get you started.
+
+TinyXml is released under the ZLib license,
+so you can use it in open source or commercial code. The details
+of the license are at the top of every source file.
+
+TinyXml attempts to be a flexible parser, but with truly correct and
+compliant XML output. TinyXml should compile on any reasonably C++
+compliant system. It does not rely on exceptions or RTTI. It can be
+compiled with or without STL support. TinyXml fully supports
+the UTF-8 encoding, and the first 64k character entities.
+
+
+<h2> What it doesn't do. </h2>
+
+It doesnt parse or use DTDs (Document Type Definitions) or XSLs
+(eXtensible Stylesheet Language.) There are other parsers out there
+(check out www.sourceforge.org, search for XML) that are much more fully
+featured. But they are also much bigger, take longer to set up in
+your project, have a higher learning curve, and often have a more
+restrictive license. If you are working with browsers or have more
+complete XML needs, TinyXml is not the parser for you.
+
+The following DTD syntax will not parse at this time in TinyXml:
+
+@verbatim
+ <!DOCTYPE Archiv [
+ <!ELEMENT Comment (#PCDATA)>
+ ]>
+@endverbatim
+
+because TinyXml sees this as a !DOCTYPE node with an illegally
+embedded !ELEMENT node. This may be addressed in the future.
+
+<h2> Code Status. </h2>
+
+TinyXml is mature, tested code. It is very stable. If you find
+bugs, please file a bug report is on the sourceforge web site
+(www.sourceforge.net/projects/tinyxml).
+We'll get them straightened out as soon as possible.
+
+There are some areas of improvement; please check sourceforge if you are
+interested in working on TinyXml.
+
+
+<h2> Features </h2>
+
+<h3> Using STL </h3>
+
+TinyXml can be compiled to use or not use STL. When using STL, TinyXml
+uses the std::string class, and fully supports std::istream, std::ostream,
+operator<<, and operator>>. Many API methods have both 'const char*' and
+'const std::string&' forms.
+
+When STL support is compiled out, no STL files are included whatsover. All
+the string classes are implemented by TinyXml itself. API methods
+all use the 'const char*' form for input.
+
+Use the compile time #define:
+
+ TIXML_USE_STL
+
+to compile one version or the other. This can be passed by the compiler,
+or set as the first line of "tinyxml.h".
+
+Note: If compiling the test code in Linux, setting the environment
+variable TINYXML_USE_STL=YES/NO will control STL compilation. In the
+Windows project file, STL and non STL targets are provided. In your project,
+its probably easiest to add the line "#define TIXML_USE_STL" as the first
+line of tinyxml.h.
+
+<h3> UTF-8 </h3>
+
+TinyXml supports UTF-8 allowing to manipulate XML files in any language. TinyXml
+also supports "legacy mode" - the encoding used before UTF-8 support and
+probably best described as "extended ascii".
+
+Normally, TinyXml will try to detect the correct encoding and use it. However,
+by setting the value of TIXML_DEFAULT_ENCODING in the header file, TinyXml
+can be forced to always use one encoding.
+
+TinyXml will assume Legacy Mode until one of the following occurs:
+<ol>
+ <li> If the non-standard but common "UTF-8 lead bytes" (0xef 0xbb 0xbf)
+ begin the file or data stream, TinyXml will read it as UTF-8. </li>
+ <li> If the declaration tag is read, and it has an encoding="UTF-8", then
+ TinyXml will read it as UTF-8. </li>
+ <li> If the declaration tag is read, and it has no encoding specified, then
+ TinyXml will read it as UTF-8. </li>
+ <li> If the declaration tag is read, and it has an encoding="something else", then
+ TinyXml will read it as Legacy Mode. In legacy mode, TinyXml will
+ work as it did before. It's not clear what that mode does exactly, but
+ old content should keep working.</li>
+ <li> Until one of the above criteria is met, TinyXml runs in Legacy Mode.</li>
+</ol>
+
+What happens if the encoding is incorrectly set or detected? TinyXml will try
+to read and pass through text seen as improperly encoded. You may get some strange
+results or mangled characters. You may want to force TinyXml to the correct mode.
+
+<b> You may force TinyXml to Legacy Mode by using LoadFile( TIXML_ENCODING_LEGACY ) or
+LoadFile( filename, TIXML_ENCODING_LEGACY ). You may force it to use legacy mode all
+the time by setting TIXML_DEFAULT_ENCODING = TIXML_ENCODING_LEGACY. Likewise, you may
+force it to TIXML_ENCODING_UTF8 with the same technique.</b>
+
+For English users, using English XML, UTF-8 is the same as low-ASCII. You
+don't need to be aware of UTF-8 or change your code in any way. You can think
+of UTF-8 as a "superset" of ASCII.
+
+UTF-8 is not a double byte format - but it is a standard encoding of Unicode!
+TinyXml does not use or directly support wchar, TCHAR, or Microsofts _UNICODE at this time.
+It is common to see the term "Unicode" improperly refer to UTF-16, a wide byte encoding
+of unicode. This is a source of confusion.
+
+For "high-ascii" languages - everything not English, pretty much - TinyXml can
+handle all languages, at the same time, as long as the XML is encoded
+in UTF-8. That can be a little tricky, older programs and operating systems
+tend to use the "default" or "traditional" code page. Many apps (and almost all
+modern ones) can output UTF-8, but older or stubborn (or just broken) ones
+still output text in the default code page.
+
+For example, Japanese systems traditionally use SHIFT-JIS encoding.
+Text encoded as SHIFT-JIS can not be read by tinyxml.
+A good text editor can import SHIFT-JIS and then save as UTF-8.
+
+The <a href="http://skew.org/xml/tutorial/">Skew.org link</a> does a great
+job covering the encoding issue.
+
+The test file "utf8test.xml" is an XML containing English, Spanish, Russian,
+and Simplified Chinese. (Hopefully they are translated correctly). The file
+"utf8test.gif" is a screen capture of the XML file, rendered in IE. Note that
+if you don't have the correct fonts (Simplified Chinese or Russian) on your
+system, you won't see output that matches the GIF file even if you can parse
+it correctly. Also note that (at least on my Windows machine) console output
+is in a Western code page, so that Print() or printf() cannot correctly display
+the file. This is not a bug in TinyXml - just an OS issue. No data is lost or
+destroyed by TinyXml. The console just doesn't render UTF-8.
+
+
+<h3> Entities </h3>
+TinyXml recognizes the pre-defined "character entities", meaning special
+characters. Namely:
+
+@verbatim
+ &amp; &
+ &lt; <
+ &gt; >
+ &quot; "
+ &apos; '
+@endverbatim
+
+These are recognized when the XML document is read, and translated to there
+UTF-8 equivalents. For instance, text with the XML of:
+
+@verbatim
+ Far &amp; Away
+@endverbatim
+
+will have the Value() of "Far & Away" when queried from the TiXmlText object,
+and will be written back to the XML stream/file as an ampersand. Older versions
+of TinyXml "preserved" character entities, but the newer versions will translate
+them into characters.
+
+Additionally, any character can be specified by its Unicode code point:
+The syntax "&#xA0;" or "&#160;" are both to the non-breaking space characher.
+
+
+<h3> Streams </h3>
+With TIXML_USE_STL on,
+TiXml has been modified to support both C (FILE) and C++ (operator <<,>>)
+streams. There are some differences that you may need to be aware of.
+
+C style output:
+ - based on FILE*
+ - the Print() and SaveFile() methods
+
+ Generates formatted output, with plenty of white space, intended to be as
+ human-readable as possible. They are very fast, and tolerant of ill formed
+ XML documents. For example, an XML document that contains 2 root elements
+ and 2 declarations, will still print.
+
+C style input:
+ - based on FILE*
+ - the Parse() and LoadFile() methods
+
+ A fast, tolerant read. Use whenever you don't need the C++ streams.
+
+C++ style ouput:
+ - based on std::ostream
+ - operator<<
+
+ Generates condensed output, intended for network transmission rather than
+ readability. Depending on your system's implementation of the ostream class,
+ these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML:
+ a document should contain the correct one root element. Additional root level
+ elements will not be streamed out.
+
+C++ style input:
+ - based on std::istream
+ - operator>>
+
+ Reads XML from a stream, making it useful for network transmission. The tricky
+ part is knowing when the XML document is complete, since there will almost
+ certainly be other data in the stream. TinyXml will assume the XML data is
+ complete after it reads the root element. Put another way, documents that
+ are ill-constructed with more than one root element will not read correctly.
+ Also note that operator>> is somewhat slower than Parse, due to both
+ implementation of the STL and limitations of TinyXml.
+
+<h3> White space </h3>
+The world simply does not agree on whether white space should be kept, or condensed.
+For example, pretend the '_' is a space, and look at "Hello____world". HTML, and
+at least some XML parsers, will interpret this as "Hello_world". They condense white
+space. Some XML parsers do not, and will leave it as "Hello____world". (Remember
+to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become
+Hello___world.
+
+It's an issue that hasn't been resolved to my satisfaction. TinyXml supports the
+first 2 approaches. Call TiXmlBase::SetCondenseWhiteSpace( bool ) to set the desired behavior.
+The default is to condense white space.
+
+If you change the default, you should call TiXmlBase::SetCondenseWhiteSpace( bool )
+before making any calls to Parse XML data, and I don't recommend changing it after
+it has been set.
+
+
+<h3> Handles </h3>
+
+Where browsing an XML document in a robust way, it is important to check
+for null returns from method calls. An error safe implementation can
+generate a lot of code like:
+
+@verbatim
+TiXmlElement* root = document.FirstChildElement( "Document" );
+if ( root )
+{
+ TiXmlElement* element = root->FirstChildElement( "Element" );
+ if ( element )
+ {
+ TiXmlElement* child = element->FirstChildElement( "Child" );
+ if ( child )
+ {
+ TiXmlElement* child2 = child->NextSiblingElement( "Child" );
+ if ( child2 )
+ {
+ // Finally do something useful.
+@endverbatim
+
+Handles have been introduced to clean this up. Using the TiXmlHandle class,
+the previous code reduces to:
+
+@verbatim
+TiXmlHandle docHandle( &document );
+TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).Element();
+if ( child2 )
+{
+ // do something useful
+@endverbatim
+
+Which is much easier to deal with. See TiXmlHandle for more information.
+
+
+<h3> Row and Column tracking </h3>
+Being able to track nodes and attributes back to their origin location
+in source files can be very important for some applications. Additionally,
+knowing where parsing errors occured in the original source can be very
+time saving.
+
+TinyXml can tracks the row and column origin of all nodes and attributes
+in a text file. The TiXmlBase::Row() and TiXmlBase::Column() methods return
+the origin of the node in the source text. The correct tabs can be
+configured in TiXmlDocument::SetTabSize().
+
+
+<h2> Using and Installing </h2>
+
+To Compile and Run xmltest:
+
+A Linux Makefile and a Windows Visual C++ .dsw file is provided.
+Simply compile and run. It will write the file demotest.xml to your
+disk and generate output on the screen. It also tests walking the
+DOM by printing out the number of nodes found using different
+techniques.
+
+The Linux makefile is very generic and will
+probably run on other systems, but is only tested on Linux. You no
+longer need to run 'make depend'. The dependecies have been
+hard coded.
+
+<h3>Windows project file for VC6</h3>
+<ul>
+<li>tinyxml: tinyxml library, non-STL </li>
+<li>tinyxmlSTL: tinyxml library, STL </li>
+<li>tinyXmlTest: test app, non-STL </li>
+<li>tinyXmlTestSTL: test app, STL </li>
+</ul>
+
+<h3>Linux Make file</h3>
+At the top of the makefile you can set:
+
+PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in
+the makefile.
+
+In the tinyxml directory, type "make clean" then "make". The executable
+file 'xmltest' will be created.
+
+
+
+<h3>To Use in an Application:</h3>
+
+Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, and tinystr.cpp to your
+project or make file. That's it! It should compile on any reasonably
+compliant C++ system. You do not need to enable exceptions or
+RTTI for TinyXml.
+
+
+<h2> How TinyXml works. </h2>
+
+An example is probably the best way to go. Take:
+@verbatim
+ <?xml version="1.0" standalone=no>
+ <!-- Our to do list data -->
+ <ToDo>
+ <Item priority="1"> Go to the <bold>Toy store!</bold></Item>
+ <Item priority="2"> Do bills</Item>
+ </ToDo>
+@endverbatim
+
+Its not much of a To Do list, but it will do. To read this file
+(say "demo.xml") you would create a document, and parse it in:
+@verbatim
+ TiXmlDocument doc( "demo.xml" );
+ doc.LoadFile();
+@endverbatim
+
+And its ready to go. Now lets look at some lines and how they
+relate to the DOM.
+
+@verbatim
+<?xml version="1.0" standalone=no>
+@endverbatim
+
+ The first line is a declaration, and gets turned into the
+ TiXmlDeclaration class. It will be the first child of the
+ document node.
+
+ This is the only directive/special tag parsed by by TinyXml.
+ Generally directive targs are stored in TiXmlUnknown so the
+ commands wont be lost when it is saved back to disk.
+
+@verbatim
+<!-- Our to do list data -->
+@endverbatim
+
+ A comment. Will become a TiXmlComment object.
+
+@verbatim
+<ToDo>
+@endverbatim
+
+ The "ToDo" tag defines a TiXmlElement object. This one does not have
+ any attributes, but does contain 2 other elements.
+
+@verbatim
+<Item priority="1">
+@endverbatim
+
+ Creates another TiXmlElement which is a child of the "ToDo" element.
+ This element has 1 attribute, with the name "priority" and the value
+ "1".
+
+Go to the
+
+ A TiXmlText. This is a leaf node and cannot contain other nodes.
+ It is a child of the "Item" TiXmlElement.
+
+@verbatim
+<bold>
+@endverbatim
+
+
+ Another TiXmlElement, this one a child of the "Item" element.
+
+Etc.
+
+Looking at the entire object tree, you end up with:
+@verbatim
+TiXmlDocument "demo.xml"
+ TiXmlDeclaration "version='1.0'" "standalone=no"
+ TiXmlComment " Our to do list data"
+ TiXmlElement "ToDo"
+ TiXmlElement "Item" Attribtutes: priority = 1
+ TiXmlText "Go to the "
+ TiXmlElement "bold"
+ TiXmlText "Toy store!"
+ TiXmlElement "Item" Attributes: priority=2
+ TiXmlText "bills"
+@endverbatim
+
+<h2> Documentation </h2>
+
+The documentation is build with Doxygen, using the 'dox'
+configuration file.
+
+<h2> License </h2>
+
+TinyXml is released under the zlib license:
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+
+<h2> References </h2>
+
+The World Wide Web Consortium is the definitive standard body for
+XML, and there web pages contain huge amounts of information.
+
+The definitive spec: <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
+http://www.w3.org/TR/2004/REC-xml-20040204/</a>
+
+I also recommend "XML Pocket Reference" by Robert Eckstein and published by
+OReilly...the book that got the whole thing started.
+
+<h2> Contributors, Contacts, and a Brief History </h2>
+
+Thanks very much to everyone who sends suggestions, bugs, ideas, and
+encouragement. It all helps, and makes this project fun. A special thanks
+to the contributors on the web pages that keep it lively.
+
+So many people have sent in bugs and ideas, that rather than list here
+we try to give credit due in the "changes.txt" file.
+
+TinyXml was originally written be Lee Thomason. (Often the "I" still
+in the documenation.) Lee reviews changes and releases new versions,
+with the help of Yves Berquin and the tinyXml community.
+
+We appreciate your suggestions, and would love to know if you
+use TinyXml. Hopefully you will enjoy it and find it useful.
+Please post questions, comments, file bugs, or contact us at:
+
+www.sourceforge.net/projects/tinyxml
+
+Lee Thomason,
+Yves Berquin
+*/
diff --git a/src/contrib/xml/tinyxml.cpp b/src/contrib/xml/tinyxml.cpp
new file mode 100644
index 0000000..0670645
--- /dev/null
+++ b/src/contrib/xml/tinyxml.cpp
@@ -0,0 +1,1452 @@
+/*:*
+ *: File: ./src/contrib/xml/tinyxml.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include <ctype.h>
+#include "tinyxml.h"
+
+#ifdef TIXML_USE_STL
+#include <sstream>
+#endif
+
+
+bool TiXmlBase::condenseWhiteSpace = true;
+
+void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream )
+{
+ TIXML_STRING buffer;
+ PutString( str, &buffer );
+ (*stream) << buffer;
+}
+
+void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString )
+{
+ int i=0;
+
+ while( i<(int)str.length() )
+ {
+ unsigned char c = (unsigned char) str[i];
+
+ if ( c == '&'
+ && i < ( (int)str.length() - 2 )
+ && str[i+1] == '#'
+ && str[i+2] == 'x' )
+ {
+ // Hexadecimal character reference.
+ // Pass through unchanged.
+ // &#xA9; -- copyright symbol, for example.
+ //
+ // The -1 is a bug fix from Rob Laveaux. It keeps
+ // an overflow from happening if there is no ';'.
+ // There are actually 2 ways to exit this loop -
+ // while fails (error case) and break (semicolon found).
+ // However, there is no mechanism (currently) for
+ // this function to return an error.
+ while ( i<(int)str.length()-1 )
+ {
+ outString->append( str.c_str() + i, 1 );
+ ++i;
+ if ( str[i] == ';' )
+ break;
+ }
+ }
+ else if ( c == '&' )
+ {
+ outString->append( entity[0].str, entity[0].strLength );
+ ++i;
+ }
+ else if ( c == '<' )
+ {
+ outString->append( entity[1].str, entity[1].strLength );
+ ++i;
+ }
+ else if ( c == '>' )
+ {
+ outString->append( entity[2].str, entity[2].strLength );
+ ++i;
+ }
+ else if ( c == '\"' )
+ {
+ outString->append( entity[3].str, entity[3].strLength );
+ ++i;
+ }
+ else if ( c == '\'' )
+ {
+ outString->append( entity[4].str, entity[4].strLength );
+ ++i;
+ }
+ else if ( c < 32 )
+ {
+ // Easy pass at non-alpha/numeric/symbol
+ // Below 32 is symbolic.
+ char buf[ 32 ];
+ sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
+ outString->append( buf, strlen( buf ) );
+ ++i;
+ }
+ else
+ {
+ //char realc = (char) c;
+ //outString->append( &realc, 1 );
+ *outString += (char) c; // somewhat more efficient function call.
+ ++i;
+ }
+ }
+}
+
+
+// <-- Strange class for a bug fix. Search for STL_STRING_BUG
+TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str )
+{
+ buffer = new char[ str.length()+1 ];
+ if ( buffer )
+ {
+ strcpy( buffer, str.c_str() );
+ }
+}
+
+
+TiXmlBase::StringToBuffer::~StringToBuffer()
+{
+ delete [] buffer;
+}
+// End strange bug fix. -->
+
+
+TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
+{
+ parent = 0;
+ type = _type;
+ firstChild = 0;
+ lastChild = 0;
+ prev = 0;
+ next = 0;
+}
+
+
+TiXmlNode::~TiXmlNode()
+{
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
+
+ while ( node )
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
+}
+
+
+void TiXmlNode::CopyTo( TiXmlNode* target ) const
+{
+ target->SetValue (value.c_str() );
+ target->userData = userData;
+}
+
+
+void TiXmlNode::Clear()
+{
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
+
+ while ( node )
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
+
+ firstChild = 0;
+ lastChild = 0;
+}
+
+
+TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
+{
+ node->parent = this;
+
+ node->prev = lastChild;
+ node->next = 0;
+
+ if ( lastChild )
+ lastChild->next = node;
+ else
+ firstChild = node; // it was an empty list.
+
+ lastChild = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
+{
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
+
+ return LinkEndChild( node );
+}
+
+
+TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
+{
+ if ( !beforeThis || beforeThis->parent != this )
+ return 0;
+
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
+ node->parent = this;
+
+ node->next = beforeThis;
+ node->prev = beforeThis->prev;
+ if ( beforeThis->prev )
+ {
+ beforeThis->prev->next = node;
+ }
+ else
+ {
+ assert( firstChild == beforeThis );
+ firstChild = node;
+ }
+ beforeThis->prev = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
+{
+ if ( !afterThis || afterThis->parent != this )
+ return 0;
+
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
+ node->parent = this;
+
+ node->prev = afterThis;
+ node->next = afterThis->next;
+ if ( afterThis->next )
+ {
+ afterThis->next->prev = node;
+ }
+ else
+ {
+ assert( lastChild == afterThis );
+ lastChild = node;
+ }
+ afterThis->next = node;
+ return node;
+}
+
+
+TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
+{
+ if ( replaceThis->parent != this )
+ return 0;
+
+ TiXmlNode* node = withThis.Clone();
+ if ( !node )
+ return 0;
+
+ node->next = replaceThis->next;
+ node->prev = replaceThis->prev;
+
+ if ( replaceThis->next )
+ replaceThis->next->prev = node;
+ else
+ lastChild = node;
+
+ if ( replaceThis->prev )
+ replaceThis->prev->next = node;
+ else
+ firstChild = node;
+
+ delete replaceThis;
+ node->parent = this;
+ return node;
+}
+
+
+bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
+{
+ if ( removeThis->parent != this )
+ {
+ assert( 0 );
+ return false;
+ }
+
+ if ( removeThis->next )
+ removeThis->next->prev = removeThis->prev;
+ else
+ lastChild = removeThis->prev;
+
+ if ( removeThis->prev )
+ removeThis->prev->next = removeThis->next;
+ else
+ firstChild = removeThis->next;
+
+ delete removeThis;
+ return true;
+}
+
+TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
+{
+ TiXmlNode* node;
+ for ( node = firstChild; node; node = node->next )
+ {
+ if ( node->SValue() == TIXML_STRING( _value ))
+ return node;
+ }
+ return 0;
+}
+
+TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
+{
+ TiXmlNode* node;
+ for ( node = lastChild; node; node = node->prev )
+ {
+ if ( node->SValue() == TIXML_STRING (_value))
+ return node;
+ }
+ return 0;
+}
+
+TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const
+{
+ if ( !previous )
+ {
+ return FirstChild();
+ }
+ else
+ {
+ assert( previous->parent == this );
+ return previous->NextSibling();
+ }
+}
+
+TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const
+{
+ if ( !previous )
+ {
+ return FirstChild( val );
+ }
+ else
+ {
+ assert( previous->parent == this );
+ return previous->NextSibling( val );
+ }
+}
+
+TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
+{
+ TiXmlNode* node;
+ for ( node = next; node; node = node->next )
+ {
+ if ( node->SValue() == TIXML_STRING (_value))
+ return node;
+ }
+ return 0;
+}
+
+
+TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const
+{
+ TiXmlNode* node;
+ for ( node = prev; node; node = node->prev )
+ {
+ if ( node->SValue() == TIXML_STRING (_value))
+ return node;
+ }
+ return 0;
+}
+
+void TiXmlElement::RemoveAttribute( const char * name )
+{
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( node )
+ {
+ attributeSet.Remove( node );
+ delete node;
+ }
+}
+
+TiXmlElement* TiXmlNode::FirstChildElement() const
+{
+ TiXmlNode* node;
+
+ for ( node = FirstChild();
+ node;
+ node = node->NextSibling() )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
+}
+
+TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
+{
+ TiXmlNode* node;
+
+ for ( node = FirstChild( _value );
+ node;
+ node = node->NextSibling( _value ) )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
+}
+
+
+TiXmlElement* TiXmlNode::NextSiblingElement() const
+{
+ TiXmlNode* node;
+
+ for ( node = NextSibling();
+ node;
+ node = node->NextSibling() )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
+}
+
+TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
+{
+ TiXmlNode* node;
+
+ for ( node = NextSibling( _value );
+ node;
+ node = node->NextSibling( _value ) )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
+}
+
+
+
+TiXmlDocument* TiXmlNode::GetDocument() const
+{
+ const TiXmlNode* node;
+
+ for( node = this; node; node = node->parent )
+ {
+ if ( node->ToDocument() )
+ return node->ToDocument();
+ }
+ return 0;
+}
+
+
+TiXmlElement::TiXmlElement (const char * _value)
+ : TiXmlNode( TiXmlNode::ELEMENT )
+{
+ firstChild = lastChild = 0;
+ value = _value;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlElement::TiXmlElement( const std::string& _value )
+ : TiXmlNode( TiXmlNode::ELEMENT )
+{
+ firstChild = lastChild = 0;
+ value = _value;
+}
+#endif
+
+
+TiXmlElement::TiXmlElement( const TiXmlElement& copy)
+ : TiXmlNode( TiXmlNode::ELEMENT )
+{
+ firstChild = lastChild = 0;
+ copy.CopyTo( this );
+}
+
+
+void TiXmlElement::operator=( const TiXmlElement& base )
+{
+ ClearThis();
+ base.CopyTo( this );
+}
+
+
+TiXmlElement::~TiXmlElement()
+{
+ ClearThis();
+}
+
+
+void TiXmlElement::ClearThis()
+{
+ Clear();
+ while( attributeSet.First() )
+ {
+ TiXmlAttribute* node = attributeSet.First();
+ attributeSet.Remove( node );
+ delete node;
+ }
+}
+
+
+const char * TiXmlElement::Attribute( const char * name ) const
+{
+ TiXmlAttribute* node = attributeSet.Find( name );
+
+ if ( node )
+ return node->Value();
+
+ return 0;
+}
+
+
+const char * TiXmlElement::Attribute( const char * name, int* i ) const
+{
+ const char * s = Attribute( name );
+ if ( i )
+ {
+ if ( s )
+ *i = atoi( s );
+ else
+ *i = 0;
+ }
+ return s;
+}
+
+
+const char * TiXmlElement::Attribute( const char * name, double* d ) const
+{
+ const char * s = Attribute( name );
+ if ( d )
+ {
+ if ( s )
+ *d = atof( s );
+ else
+ *d = 0;
+ }
+ return s;
+}
+
+
+int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
+{
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( !node )
+ return TIXML_NO_ATTRIBUTE;
+
+ return node->QueryIntValue( ival );
+}
+
+
+int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
+{
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( !node )
+ return TIXML_NO_ATTRIBUTE;
+
+ return node->QueryDoubleValue( dval );
+}
+
+
+void TiXmlElement::SetAttribute( const char * name, int val )
+{
+ char buf[64];
+ sprintf( buf, "%d", val );
+ SetAttribute( name, buf );
+}
+
+
+void TiXmlElement::SetDoubleAttribute( const char * name, double val )
+{
+ char buf[128];
+ sprintf( buf, "%f", val );
+ SetAttribute( name, buf );
+}
+
+
+void TiXmlElement::SetAttribute( const char * name, const char * _value )
+{
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( node )
+ {
+ node->SetValue( _value );
+ return;
+ }
+
+ TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
+ if ( attrib )
+ {
+ attributeSet.Add( attrib );
+ }
+ else
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ }
+}
+
+void TiXmlElement::Print( FILE* cfile, int depth ) const
+{
+ int i;
+ for ( i=0; i<depth; i++ )
+ {
+ fprintf( cfile, " " );
+ }
+
+ fprintf( cfile, "<%s", value.c_str() );
+
+ TiXmlAttribute* attrib;
+ for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
+ {
+ fprintf( cfile, " " );
+ attrib->Print( cfile, depth );
+ }
+
+ // There are 3 different formatting approaches:
+ // 1) An element without children is printed as a <foo /> node
+ // 2) An element with only a text child is printed as <foo> text </foo>
+ // 3) An element with children is printed on multiple lines.
+ TiXmlNode* node;
+ if ( !firstChild )
+ {
+ fprintf( cfile, " />" );
+ }
+ else if ( firstChild == lastChild && firstChild->ToText() )
+ {
+ fprintf( cfile, ">" );
+ firstChild->Print( cfile, depth + 1 );
+ fprintf( cfile, "</%s>", value.c_str() );
+ }
+ else
+ {
+ fprintf( cfile, ">" );
+
+ for ( node = firstChild; node; node=node->NextSibling() )
+ {
+ if ( !node->ToText() )
+ {
+ fprintf( cfile, "\n" );
+ }
+ node->Print( cfile, depth+1 );
+ }
+ fprintf( cfile, "\n" );
+ for( i=0; i<depth; ++i )
+ fprintf( cfile, " " );
+ fprintf( cfile, "</%s>", value.c_str() );
+ }
+}
+
+void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const
+{
+ (*stream) << "<" << value;
+
+ TiXmlAttribute* attrib;
+ for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
+ {
+ (*stream) << " ";
+ attrib->StreamOut( stream );
+ }
+
+ // If this node has children, give it a closing tag. Else
+ // make it an empty tag.
+ TiXmlNode* node;
+ if ( firstChild )
+ {
+ (*stream) << ">";
+
+ for ( node = firstChild; node; node=node->NextSibling() )
+ {
+ node->StreamOut( stream );
+ }
+ (*stream) << "</" << value << ">";
+ }
+ else
+ {
+ (*stream) << " />";
+ }
+}
+
+
+void TiXmlElement::CopyTo( TiXmlElement* target ) const
+{
+ // superclass:
+ TiXmlNode::CopyTo( target );
+
+ // Element class:
+ // Clone the attributes, then clone the children.
+ TiXmlAttribute* attribute = 0;
+ for( attribute = attributeSet.First();
+ attribute;
+ attribute = attribute->Next() )
+ {
+ target->SetAttribute( attribute->Name(), attribute->Value() );
+ }
+
+ TiXmlNode* node = 0;
+ for ( node = firstChild; node; node = node->NextSibling() )
+ {
+ target->LinkEndChild( node->Clone() );
+ }
+}
+
+
+TiXmlNode* TiXmlElement::Clone() const
+{
+ TiXmlElement* clone = new TiXmlElement( Value() );
+ if ( !clone )
+ return 0;
+
+ CopyTo( clone );
+ return clone;
+}
+
+
+TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+ tabsize = 4;
+ ClearError();
+}
+
+TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+ tabsize = 4;
+ value = documentName;
+ ClearError();
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+ tabsize = 4;
+ value = documentName;
+ ClearError();
+}
+#endif
+
+
+TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+ copy.CopyTo( this );
+}
+
+
+void TiXmlDocument::operator=( const TiXmlDocument& copy )
+{
+ Clear();
+ copy.CopyTo( this );
+}
+
+
+bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
+{
+ // See STL_STRING_BUG below.
+ StringToBuffer buf( value );
+
+ if ( buf.buffer && LoadFile( buf.buffer, encoding ) )
+ return true;
+
+ return false;
+}
+
+
+bool TiXmlDocument::SaveFile() const
+{
+ // See STL_STRING_BUG below.
+ StringToBuffer buf( value );
+
+ if ( buf.buffer && SaveFile( buf.buffer ) )
+ return true;
+
+ return false;
+}
+
+bool TiXmlDocument::LoadFile( const char* filename, TiXmlEncoding encoding )
+{
+ // Delete the existing data:
+ Clear();
+ location.Clear();
+
+ // There was a really terrifying little bug here. The code:
+ // value = filename
+ // in the STL case, cause the assignment method of the std::string to
+ // be called. What is strange, is that the std::string had the same
+ // address as it's c_str() method, and so bad things happen. Looks
+ // like a bug in the Microsoft STL implementation.
+ // See STL_STRING_BUG above.
+ // Fixed with the StringToBuffer class.
+ value = filename;
+
+ FILE* file = fopen( value.c_str (), "r" );
+
+ if ( file )
+ {
+ // Get the file size, so we can pre-allocate the string. HUGE speed impact.
+ long length = 0;
+ fseek( file, 0, SEEK_END );
+ length = ftell( file );
+ fseek( file, 0, SEEK_SET );
+
+ // Strange case, but good to handle up front.
+ if ( length == 0 )
+ {
+ fclose( file );
+ return false;
+ }
+
+ // If we have a file, assume it is all one big XML file, and read it in.
+ // The document parser may decide the document ends sooner than the entire file, however.
+ TIXML_STRING data;
+ data.reserve( length );
+
+ const int BUF_SIZE = 2048;
+ char buf[BUF_SIZE];
+
+ while( fgets( buf, BUF_SIZE, file ) )
+ {
+ data += buf;
+ }
+ fclose( file );
+
+ Parse( data.c_str(), 0, encoding );
+
+ if ( Error() )
+ return false;
+ else
+ return true;
+ }
+ SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return false;
+}
+
+bool TiXmlDocument::SaveFile( const char * filename ) const
+{
+ // The old c stuff lives on...
+ FILE* fp = fopen( filename, "w" );
+ if ( fp )
+ {
+ Print( fp, 0 );
+ fclose( fp );
+ return true;
+ }
+ return false;
+}
+
+
+void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
+{
+ TiXmlNode::CopyTo( target );
+
+ target->error = error;
+ target->errorDesc = errorDesc.c_str ();
+
+ TiXmlNode* node = 0;
+ for ( node = firstChild; node; node = node->NextSibling() )
+ {
+ target->LinkEndChild( node->Clone() );
+ }
+}
+
+
+TiXmlNode* TiXmlDocument::Clone() const
+{
+ TiXmlDocument* clone = new TiXmlDocument();
+ if ( !clone )
+ return 0;
+
+ CopyTo( clone );
+ return clone;
+}
+
+
+void TiXmlDocument::Print( FILE* cfile, int depth ) const
+{
+ TiXmlNode* node;
+ for ( node=FirstChild(); node; node=node->NextSibling() )
+ {
+ node->Print( cfile, depth );
+ fprintf( cfile, "\n" );
+ }
+}
+
+void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const
+{
+ TiXmlNode* node;
+ for ( node=FirstChild(); node; node=node->NextSibling() )
+ {
+ node->StreamOut( out );
+
+ // Special rule for streams: stop after the root element.
+ // The stream in code will only read one element, so don't
+ // write more than one.
+ if ( node->ToElement() )
+ break;
+ }
+}
+
+
+TiXmlAttribute* TiXmlAttribute::Next() const
+{
+ // We are using knowledge of the sentinel. The sentinel
+ // have a value or name.
+ if ( next->value.empty() && next->name.empty() )
+ return 0;
+ return next;
+}
+
+
+TiXmlAttribute* TiXmlAttribute::Previous() const
+{
+ // We are using knowledge of the sentinel. The sentinel
+ // have a value or name.
+ if ( prev->value.empty() && prev->name.empty() )
+ return 0;
+ return prev;
+}
+
+
+void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const
+{
+ TIXML_STRING n, v;
+
+ PutString( name, &n );
+ PutString( value, &v );
+
+ if (value.find ('\"') == TIXML_STRING::npos)
+ fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
+ else
+ fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
+}
+
+
+void TiXmlAttribute::StreamOut( TIXML_OSTREAM * stream ) const
+{
+ if (value.find( '\"' ) != TIXML_STRING::npos)
+ {
+ PutString( name, stream );
+ (*stream) << "=" << "'";
+ PutString( value, stream );
+ (*stream) << "'";
+ }
+ else
+ {
+ PutString( name, stream );
+ (*stream) << "=" << "\"";
+ PutString( value, stream );
+ (*stream) << "\"";
+ }
+}
+
+int TiXmlAttribute::QueryIntValue( int* ival ) const
+{
+ if ( sscanf( value.c_str(), "%d", ival ) == 1 )
+ return TIXML_SUCCESS;
+ return TIXML_WRONG_TYPE;
+}
+
+int TiXmlAttribute::QueryDoubleValue( double* dval ) const
+{
+ if ( sscanf( value.c_str(), "%lf", dval ) == 1 )
+ return TIXML_SUCCESS;
+ return TIXML_WRONG_TYPE;
+}
+
+void TiXmlAttribute::SetIntValue( int _value )
+{
+ char buf [64];
+ sprintf (buf, "%d", _value);
+ SetValue (buf);
+}
+
+void TiXmlAttribute::SetDoubleValue( double _value )
+{
+ char buf [64];
+ sprintf (buf, "%lf", _value);
+ SetValue (buf);
+}
+
+const int TiXmlAttribute::IntValue() const
+{
+ return atoi (value.c_str ());
+}
+
+const double TiXmlAttribute::DoubleValue() const
+{
+ return atof (value.c_str ());
+}
+
+
+TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
+{
+ copy.CopyTo( this );
+}
+
+
+void TiXmlComment::operator=( const TiXmlComment& base )
+{
+ Clear();
+ base.CopyTo( this );
+}
+
+
+void TiXmlComment::Print( FILE* cfile, int depth ) const
+{
+ for ( int i=0; i<depth; i++ )
+ {
+ fputs( " ", cfile );
+ }
+ fprintf( cfile, "<!--%s-->", value.c_str() );
+}
+
+void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const
+{
+ (*stream) << "<!--";
+ //PutString( value, stream );
+ (*stream) << value;
+ (*stream) << "-->";
+}
+
+
+void TiXmlComment::CopyTo( TiXmlComment* target ) const
+{
+ TiXmlNode::CopyTo( target );
+}
+
+
+TiXmlNode* TiXmlComment::Clone() const
+{
+ TiXmlComment* clone = new TiXmlComment();
+
+ if ( !clone )
+ return 0;
+
+ CopyTo( clone );
+ return clone;
+}
+
+
+void TiXmlText::Print( FILE* cfile, int /*depth*/ ) const
+{
+ TIXML_STRING buffer;
+ PutString( value, &buffer );
+ fprintf( cfile, "%s", buffer.c_str() );
+}
+
+
+void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const
+{
+ PutString( value, stream );
+}
+
+
+void TiXmlText::CopyTo( TiXmlText* target ) const
+{
+ TiXmlNode::CopyTo( target );
+}
+
+
+TiXmlNode* TiXmlText::Clone() const
+{
+ TiXmlText* clone = 0;
+ clone = new TiXmlText( "" );
+
+ if ( !clone )
+ return 0;
+
+ CopyTo( clone );
+ return clone;
+}
+
+
+TiXmlDeclaration::TiXmlDeclaration( const char * _version,
+ const char * _encoding,
+ const char * _standalone )
+ : TiXmlNode( TiXmlNode::DECLARATION )
+{
+ version = _version;
+ encoding = _encoding;
+ standalone = _standalone;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
+ const std::string& _encoding,
+ const std::string& _standalone )
+ : TiXmlNode( TiXmlNode::DECLARATION )
+{
+ version = _version;
+ encoding = _encoding;
+ standalone = _standalone;
+}
+#endif
+
+
+TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
+ : TiXmlNode( TiXmlNode::DECLARATION )
+{
+ copy.CopyTo( this );
+}
+
+
+void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
+{
+ Clear();
+ copy.CopyTo( this );
+}
+
+
+void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/ ) const
+{
+ fprintf (cfile, "<?xml ");
+
+ if ( !version.empty() )
+ fprintf (cfile, "version=\"%s\" ", version.c_str ());
+ if ( !encoding.empty() )
+ fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
+ if ( !standalone.empty() )
+ fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
+ fprintf (cfile, "?>");
+}
+
+void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const
+{
+ (*stream) << "<?xml ";
+
+ if ( !version.empty() )
+ {
+ (*stream) << "version=\"";
+ PutString( version, stream );
+ (*stream) << "\" ";
+ }
+ if ( !encoding.empty() )
+ {
+ (*stream) << "encoding=\"";
+ PutString( encoding, stream );
+ (*stream ) << "\" ";
+ }
+ if ( !standalone.empty() )
+ {
+ (*stream) << "standalone=\"";
+ PutString( standalone, stream );
+ (*stream) << "\" ";
+ }
+ (*stream) << "?>";
+}
+
+
+void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const
+{
+ TiXmlNode::CopyTo( target );
+
+ target->version = version;
+ target->encoding = encoding;
+ target->standalone = standalone;
+}
+
+
+TiXmlNode* TiXmlDeclaration::Clone() const
+{
+ TiXmlDeclaration* clone = new TiXmlDeclaration();
+
+ if ( !clone )
+ return 0;
+
+ CopyTo( clone );
+ return clone;
+}
+
+
+void TiXmlUnknown::Print( FILE* cfile, int depth ) const
+{
+ for ( int i=0; i<depth; i++ )
+ fprintf( cfile, " " );
+ fprintf( cfile, "<%s>", value.c_str() );
+}
+
+
+void TiXmlUnknown::StreamOut( TIXML_OSTREAM * stream ) const
+{
+ (*stream) << "<" << value << ">"; // Don't use entities here! It is unknown.
+}
+
+
+void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const
+{
+ TiXmlNode::CopyTo( target );
+}
+
+
+TiXmlNode* TiXmlUnknown::Clone() const
+{
+ TiXmlUnknown* clone = new TiXmlUnknown();
+
+ if ( !clone )
+ return 0;
+
+ CopyTo( clone );
+ return clone;
+}
+
+
+TiXmlAttributeSet::TiXmlAttributeSet()
+{
+ sentinel.next = &sentinel;
+ sentinel.prev = &sentinel;
+}
+
+
+TiXmlAttributeSet::~TiXmlAttributeSet()
+{
+ assert( sentinel.next == &sentinel );
+ assert( sentinel.prev == &sentinel );
+}
+
+
+void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
+{
+ assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set.
+
+ addMe->next = &sentinel;
+ addMe->prev = sentinel.prev;
+
+ sentinel.prev->next = addMe;
+ sentinel.prev = addMe;
+}
+
+void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
+{
+ TiXmlAttribute* node;
+
+ for( node = sentinel.next; node != &sentinel; node = node->next )
+ {
+ if ( node == removeMe )
+ {
+ node->prev->next = node->next;
+ node->next->prev = node->prev;
+ node->next = 0;
+ node->prev = 0;
+ return;
+ }
+ }
+ assert( 0 ); // we tried to remove a non-linked attribute.
+}
+
+TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const
+{
+ TiXmlAttribute* node;
+
+ for( node = sentinel.next; node != &sentinel; node = node->next )
+ {
+ if ( node->name == name )
+ return node;
+ }
+ return 0;
+}
+
+
+#ifdef TIXML_USE_STL
+TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base)
+{
+ TIXML_STRING tag;
+ tag.reserve( 8 * 1000 );
+ base.StreamIn( &in, &tag );
+
+ base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
+ return in;
+}
+#endif
+
+
+TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base)
+{
+ base.StreamOut (& out);
+ return out;
+}
+
+
+#ifdef TIXML_USE_STL
+std::string & operator<< (std::string& out, const TiXmlNode& base )
+{
+ std::ostringstream os_stream( std::ostringstream::out );
+ base.StreamOut( &os_stream );
+
+ out.append( os_stream.str() );
+ return out;
+}
+#endif
+
+
+TiXmlHandle TiXmlHandle::FirstChild() const
+{
+ if ( node )
+ {
+ TiXmlNode* child = node->FirstChild();
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const
+{
+ if ( node )
+ {
+ TiXmlNode* child = node->FirstChild( value );
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement() const
+{
+ if ( node )
+ {
+ TiXmlElement* child = node->FirstChildElement();
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const
+{
+ if ( node )
+ {
+ TiXmlElement* child = node->FirstChildElement( value );
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::Child( int count ) const
+{
+ if ( node )
+ {
+ int i;
+ TiXmlNode* child = node->FirstChild();
+ for ( i=0;
+ child && i<count;
+ child = child->NextSibling(), ++i )
+ {
+ // nothing
+ }
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const
+{
+ if ( node )
+ {
+ int i;
+ TiXmlNode* child = node->FirstChild( value );
+ for ( i=0;
+ child && i<count;
+ child = child->NextSibling( value ), ++i )
+ {
+ // nothing
+ }
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement( int count ) const
+{
+ if ( node )
+ {
+ int i;
+ TiXmlElement* child = node->FirstChildElement();
+ for ( i=0;
+ child && i<count;
+ child = child->NextSiblingElement(), ++i )
+ {
+ // nothing
+ }
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const
+{
+ if ( node )
+ {
+ int i;
+ TiXmlElement* child = node->FirstChildElement( value );
+ for ( i=0;
+ child && i<count;
+ child = child->NextSiblingElement( value ), ++i )
+ {
+ // nothing
+ }
+ if ( child )
+ return TiXmlHandle( child );
+ }
+ return TiXmlHandle( 0 );
+}
diff --git a/src/contrib/xml/tinyxml.h b/src/contrib/xml/tinyxml.h
new file mode 100644
index 0000000..3066a40
--- /dev/null
+++ b/src/contrib/xml/tinyxml.h
@@ -0,0 +1,1654 @@
+/*:*
+ *: File: ./src/contrib/xml/tinyxml.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+
+#ifndef TINYXML_INCLUDED
+#define TINYXML_INCLUDED
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4530 )
+#pragma warning( disable : 4786 )
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+// Help out windows:
+#if defined( _DEBUG ) && !defined( DEBUG )
+#define DEBUG
+#endif
+
+#if defined( DEBUG ) && defined( _MSC_VER )
+#include <windows.h>
+#define TIXML_LOG OutputDebugString
+#else
+#define TIXML_LOG printf
+#endif
+
+#include <string>
+#include <iostream>
+#define TIXML_STRING std::string
+#define TIXML_ISTREAM std::istream
+#define TIXML_OSTREAM std::ostream
+
+class TiXmlDocument;
+class TiXmlElement;
+class TiXmlComment;
+class TiXmlUnknown;
+class TiXmlAttribute;
+class TiXmlText;
+class TiXmlDeclaration;
+class TiXmlParsingData;
+
+const int TIXML_MAJOR_VERSION = 2;
+const int TIXML_MINOR_VERSION = 3;
+const int TIXML_PATCH_VERSION = 2;
+
+/* Internal structure for tracking location of items
+ in the XML file.
+*/
+struct TiXmlCursor
+{
+ TiXmlCursor()
+ {
+ Clear();
+ }
+ void Clear()
+ {
+ row = col = -1;
+ }
+
+ int row; // 0 based.
+ int col; // 0 based.
+};
+
+
+// Only used by Attribute::Query functions
+enum
+{
+ TIXML_SUCCESS,
+ TIXML_NO_ATTRIBUTE,
+ TIXML_WRONG_TYPE
+};
+
+
+// Used by the parsing routines.
+enum TiXmlEncoding
+{
+ TIXML_ENCODING_UNKNOWN,
+ TIXML_ENCODING_UTF8,
+ TIXML_ENCODING_LEGACY
+};
+
+const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
+
+/** TiXmlBase is a base class for every class in TinyXml.
+ It does little except to establish that TinyXml classes
+ can be printed and provide some utility functions.
+
+ In XML, the document and elements can contain
+ other elements and other types of nodes.
+
+ @verbatim
+ A Document can contain: Element (container or leaf)
+ Comment (leaf)
+ Unknown (leaf)
+ Declaration( leaf )
+
+ An Element can contain: Element (container or leaf)
+ Text (leaf)
+ Attributes (not on tree)
+ Comment (leaf)
+ Unknown (leaf)
+
+ A Decleration contains: Attributes (not on tree)
+ @endverbatim
+*/
+class TiXmlBase
+{
+ friend class TiXmlNode;
+ friend class TiXmlElement;
+ friend class TiXmlDocument;
+
+public:
+ TiXmlBase() : userData(0)
+ {}
+ virtual ~TiXmlBase()
+ {}
+
+ /** All TinyXml classes can print themselves to a filestream.
+ This is a formatted print, and will insert tabs and newlines.
+
+ (For an unformatted stream, use the << operator.)
+ */
+ virtual void Print( FILE* cfile, int depth ) const = 0;
+
+ /** The world does not agree on whether white space should be kept or
+ not. In order to make everyone happy, these global, static functions
+ are provided to set whether or not TinyXml will condense all white space
+ into a single space or not. The default is to condense. Note changing this
+ values is not thread safe.
+ */
+ static void SetCondenseWhiteSpace( bool condense )
+ {
+ condenseWhiteSpace = condense;
+ }
+
+ /// Return the current white space setting.
+ static bool IsWhiteSpaceCondensed()
+ {
+ return condenseWhiteSpace;
+ }
+
+ /** Return the position, in the original source file, of this node or attribute.
+ The row and column are 1-based. (That is the first row and first column is
+ 1,1). If the returns values are 0 or less, then the parser does not have
+ a row and column value.
+
+ Generally, the row and column value will be set when the TiXmlDocument::Load(),
+ TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set
+ when the DOM was created from operator>>.
+
+ The values reflect the initial load. Once the DOM is modified programmatically
+ (by adding or changing nodes and attributes) the new values will NOT update to
+ reflect changes in the document.
+
+ There is a minor performance cost to computing the row and column. Computation
+ can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.
+
+ @sa TiXmlDocument::SetTabSize()
+ */
+ int Row() const
+ {
+ return location.row + 1;
+ }
+ int Column() const
+ {
+ return location.col + 1;
+ } ///< See Row()
+
+ void SetUserData( void* user )
+ {
+ userData = user;
+ }
+ void* GetUserData()
+ {
+ return userData;
+ }
+
+ // Table that returs, for a given lead byte, the total number of bytes
+ // in the UTF-8 sequence.
+ static const int utf8ByteTable[256];
+
+ virtual const char* Parse( const char* p,
+ TiXmlParsingData* data,
+ TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
+
+protected:
+
+ // See STL_STRING_BUG
+ // Utility class to overcome a bug.
+ class StringToBuffer
+ {
+ public:
+ StringToBuffer( const TIXML_STRING& str );
+ ~StringToBuffer();
+ char* buffer;
+ };
+
+ static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
+ inline static bool IsWhiteSpace( char c )
+ {
+ return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
+ }
+
+ virtual void StreamOut (TIXML_OSTREAM *) const = 0;
+
+#ifdef TIXML_USE_STL
+
+ static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
+ static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
+#endif
+
+ /* Reads an XML name into the string provided. Returns
+ a pointer just past the last character of the name,
+ or 0 if the function has an error.
+ */
+ static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
+
+ /* Reads text. Returns a pointer past the given end tag.
+ Wickedly complex options, but it keeps the (sensitive) code in one place.
+ */
+ static const char* ReadText( const char* in, // where to start
+ TIXML_STRING* text, // the string read
+ bool ignoreWhiteSpace, // whether to keep the white space
+ const char* endTag, // what ends this text
+ bool ignoreCase, // whether to ignore case in the end tag
+ TiXmlEncoding encoding ); // the current encoding
+
+ // If an entity has been found, transform it into a character.
+ static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
+
+ // Get a character, while interpreting entities.
+ // The length can be from 0 to 4 bytes.
+ inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
+ {
+ assert( p );
+ if ( encoding == TIXML_ENCODING_UTF8 )
+ {
+ *length = utf8ByteTable[ *((unsigned char*)p) ];
+ assert( *length >= 0 && *length < 5 );
+ }
+ else
+ {
+ *length = 1;
+ }
+
+ if ( *length == 1 )
+ {
+ if ( *p == '&' )
+ return GetEntity( p, _value, length, encoding );
+ *_value = *p;
+ return p+1;
+ }
+ else if ( *length )
+ {
+ strncpy( _value, p, *length );
+ return p + (*length);
+ }
+ else
+ {
+ // Not valid text.
+ return 0;
+ }
+ }
+
+ // Puts a string to a stream, expanding entities as it goes.
+ // Note this should not contian the '<', '>', etc, or they will be transformed into entities!
+ static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
+
+ static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
+
+ // Return true if the next characters in the stream are any of the endTag sequences.
+ // Ignore case only works for english, and should only be relied on when comparing
+ // to Engilish words: StringEqual( p, "version", true ) is fine.
+ static bool StringEqual( const char* p,
+ const char* endTag,
+ bool ignoreCase,
+ TiXmlEncoding encoding );
+
+
+ enum
+ {
+ TIXML_NO_ERROR = 0,
+ TIXML_ERROR,
+ TIXML_ERROR_OPENING_FILE,
+ TIXML_ERROR_OUT_OF_MEMORY,
+ TIXML_ERROR_PARSING_ELEMENT,
+ TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
+ TIXML_ERROR_READING_ELEMENT_VALUE,
+ TIXML_ERROR_READING_ATTRIBUTES,
+ TIXML_ERROR_PARSING_EMPTY,
+ TIXML_ERROR_READING_END_TAG,
+ TIXML_ERROR_PARSING_UNKNOWN,
+ TIXML_ERROR_PARSING_COMMENT,
+ TIXML_ERROR_PARSING_DECLARATION,
+ TIXML_ERROR_DOCUMENT_EMPTY,
+ TIXML_ERROR_EMBEDDED_NULL,
+
+ TIXML_ERROR_STRING_COUNT
+ };
+ static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
+
+ TiXmlCursor location;
+
+ /// Field containing a generic user pointer
+ void* userData;
+
+ // None of these methods are reliable for any language except English.
+ // Good for approximation, not great for accuracy.
+ static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
+ static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
+ inline static int ToLower( int v, TiXmlEncoding encoding )
+ {
+ if ( encoding == TIXML_ENCODING_UTF8 )
+ {
+ if ( v < 128 )
+ return tolower( v );
+ return v;
+ }
+ else
+ {
+ return tolower( v );
+ }
+ }
+ static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
+
+private:
+ TiXmlBase( const TiXmlBase& ); // not implemented.
+ void operator=( const TiXmlBase& base ); // not allowed.
+
+ struct Entity
+ {
+ const char* str;
+ unsigned int strLength;
+ char chr;
+ };
+ enum
+ {
+ NUM_ENTITY = 5,
+ MAX_ENTITY_LENGTH = 6
+
+ };
+ static Entity entity[ NUM_ENTITY ];
+ static bool condenseWhiteSpace;
+};
+
+
+/** The parent class for everything in the Document Object Model.
+ (Except for attributes).
+ Nodes have siblings, a parent, and children. A node can be
+ in a document, or stand on its own. The type of a TiXmlNode
+ can be queried, and it can be cast to its more defined type.
+*/
+class TiXmlNode : public TiXmlBase
+{
+ friend class TiXmlDocument;
+ friend class TiXmlElement;
+
+public:
+#ifdef TIXML_USE_STL
+
+ /** An input stream operator, for every class. Tolerant of newlines and
+ formatting, but doesn't expect them.
+ */
+ friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
+
+ /** An output stream operator, for every class. Note that this outputs
+ without any newlines or formatting, as opposed to Print(), which
+ includes tabs and new lines.
+
+ The operator<< and operator>> are not completely symmetric. Writing
+ a node to a stream is very well defined. You'll get a nice stream
+ of output, without any extra whitespace or newlines.
+
+ But reading is not as well defined. (As it always is.) If you create
+ a TiXmlElement (for example) and read that from an input stream,
+ the text needs to define an element or junk will result. This is
+ true of all input streams, but it's worth keeping in mind.
+
+ A TiXmlDocument will read nodes until it reads a root element, and
+ all the children of that root element.
+ */
+ friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
+
+ /// Appends the XML node or attribute to a std::string.
+ friend std::string& operator<< (std::string& out, const TiXmlNode& base );
+
+#else
+ // Used internally, not part of the public API.
+ friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base);
+#endif
+
+ /** The types of XML nodes supported by TinyXml. (All the
+ unsupported types are picked up by UNKNOWN.)
+ */
+ enum NodeType
+ {
+ DOCUMENT,
+ ELEMENT,
+ COMMENT,
+ UNKNOWN,
+ TEXT,
+ DECLARATION,
+ TYPECOUNT
+ };
+
+ virtual ~TiXmlNode();
+
+ /** The meaning of 'value' changes for the specific type of
+ TiXmlNode.
+ @verbatim
+ Document: filename of the xml file
+ Element: name of the element
+ Comment: the comment text
+ Unknown: the tag contents
+ Text: the text string
+ @endverbatim
+
+ The subclasses will wrap this function.
+ */
+ const char * Value() const
+ {
+ return value.c_str ();
+ }
+
+ /** Changes the value of the node. Defined as:
+ @verbatim
+ Document: filename of the xml file
+ Element: name of the element
+ Comment: the comment text
+ Unknown: the tag contents
+ Text: the text string
+ @endverbatim
+ */
+ void SetValue(const char * _value)
+ {
+ value = _value;
+ }
+
+#ifdef TIXML_USE_STL
+ /// STL std::string form.
+ void SetValue( const std::string& _value )
+ {
+ StringToBuffer buf( _value );
+ SetValue( buf.buffer ? buf.buffer : "" );
+ }
+#endif
+
+ /// Delete all the children of this node. Does not affect 'this'.
+ void Clear();
+
+ /// One step up the DOM.
+ TiXmlNode* Parent() const
+ {
+ return parent;
+ }
+
+ TiXmlNode* FirstChild() const
+ {
+ return firstChild;
+ } ///< The first child of this node. Will be null if there are no children.
+ TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
+
+ TiXmlNode* LastChild() const
+ {
+ return lastChild;
+ } /// The last child of this node. Will be null if there are no children.
+ TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children.
+
+#ifdef TIXML_USE_STL
+
+ TiXmlNode* FirstChild( const std::string& _value ) const
+ {
+ return FirstChild (_value.c_str ());
+ } ///< STL std::string form.
+ TiXmlNode* LastChild( const std::string& _value ) const
+ {
+ return LastChild (_value.c_str ());
+ } ///< STL std::string form.
+#endif
+
+ /** An alternate way to walk the children of a node.
+ One way to iterate over nodes is:
+ @verbatim
+ for( child = parent->FirstChild(); child; child = child->NextSibling() )
+ @endverbatim
+
+ IterateChildren does the same thing with the syntax:
+ @verbatim
+ child = 0;
+ while( child = parent->IterateChildren( child ) )
+ @endverbatim
+
+ IterateChildren takes the previous child as input and finds
+ the next one. If the previous child is null, it returns the
+ first. IterateChildren will return null when done.
+ */
+ TiXmlNode* IterateChildren( TiXmlNode* previous ) const;
+
+ /// This flavor of IterateChildren searches for children with a particular 'value'
+ TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const;
+
+#ifdef TIXML_USE_STL
+
+ TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const
+ {
+ return IterateChildren (_value.c_str (), previous);
+ } ///< STL std::string form.
+#endif
+
+ /** Add a new node related to this. Adds a child past the LastChild.
+ Returns a pointer to the new object or NULL if an error occured.
+ */
+ TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
+
+
+ /** Add a new node related to this. Adds a child past the LastChild.
+
+ NOTE: the node to be added is passed by pointer, and will be
+ henceforth owned (and deleted) by tinyXml. This method is efficient
+ and avoids an extra copy, but should be used with care as it
+ uses a different memory model than the other insert functions.
+
+ @sa InsertEndChild
+ */
+ TiXmlNode* LinkEndChild( TiXmlNode* addThis );
+
+ /** Add a new node related to this. Adds a child before the specified child.
+ Returns a pointer to the new object or NULL if an error occured.
+ */
+ TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
+
+ /** Add a new node related to this. Adds a child after the specified child.
+ Returns a pointer to the new object or NULL if an error occured.
+ */
+ TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
+
+ /** Replace a child of this node.
+ Returns a pointer to the new object or NULL if an error occured.
+ */
+ TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
+
+ /// Delete a child of this node.
+ bool RemoveChild( TiXmlNode* removeThis );
+
+ /// Navigate to a sibling node.
+ TiXmlNode* PreviousSibling() const
+ {
+ return prev;
+ }
+
+ /// Navigate to a sibling node.
+ TiXmlNode* PreviousSibling( const char * ) const;
+
+#ifdef TIXML_USE_STL
+
+ TiXmlNode* PreviousSibling( const std::string& _value ) const
+ {
+ return PreviousSibling (_value.c_str ());
+ } ///< STL std::string form.
+ TiXmlNode* NextSibling( const std::string& _value) const
+ {
+ return NextSibling (_value.c_str ());
+ } ///< STL std::string form.
+#endif
+
+ /// Navigate to a sibling node.
+ TiXmlNode* NextSibling() const
+ {
+ return next;
+ }
+
+ /// Navigate to a sibling node with the given 'value'.
+ TiXmlNode* NextSibling( const char * ) const;
+
+ /** Convenience function to get through elements.
+ Calls NextSibling and ToElement. Will skip all non-Element
+ nodes. Returns 0 if there is not another element.
+ */
+ TiXmlElement* NextSiblingElement() const;
+
+ /** Convenience function to get through elements.
+ Calls NextSibling and ToElement. Will skip all non-Element
+ nodes. Returns 0 if there is not another element.
+ */
+ TiXmlElement* NextSiblingElement( const char * ) const;
+
+#ifdef TIXML_USE_STL
+
+ TiXmlElement* NextSiblingElement( const std::string& _value) const
+ {
+ return NextSiblingElement (_value.c_str ());
+ } ///< STL std::string form.
+#endif
+
+ /// Convenience function to get through elements.
+ TiXmlElement* FirstChildElement() const;
+
+ /// Convenience function to get through elements.
+ TiXmlElement* FirstChildElement( const char * value ) const;
+
+#ifdef TIXML_USE_STL
+
+ TiXmlElement* FirstChildElement( const std::string& _value ) const
+ {
+ return FirstChildElement (_value.c_str ());
+ } ///< STL std::string form.
+#endif
+
+ /** Query the type (as an enumerated value, above) of this node.
+ The possible types are: DOCUMENT, ELEMENT, COMMENT,
+ UNKNOWN, TEXT, and DECLARATION.
+ */
+ virtual int Type() const
+ {
+ return type;
+ }
+
+ /** Return a pointer to the Document this node lives in.
+ Returns null if not in a document.
+ */
+ TiXmlDocument* GetDocument() const;
+
+ /// Returns true if this node has no children.
+ bool NoChildren() const
+ {
+ return !firstChild;
+ }
+
+ TiXmlDocument* ToDocument() const
+ {
+ return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0;
+ } ///< Cast to a more defined type. Will return null not of the requested type.
+ TiXmlElement* ToElement() const
+ {
+ return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0;
+ } ///< Cast to a more defined type. Will return null not of the requested type.
+ TiXmlComment* ToComment() const
+ {
+ return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0;
+ } ///< Cast to a more defined type. Will return null not of the requested type.
+ TiXmlUnknown* ToUnknown() const
+ {
+ return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0;
+ } ///< Cast to a more defined type. Will return null not of the requested type.
+ TiXmlText* ToText() const
+ {
+ return ( this && type == TEXT ) ? (TiXmlText*) this : 0;
+ } ///< Cast to a more defined type. Will return null not of the requested type.
+ TiXmlDeclaration* ToDeclaration() const
+ {
+ return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0;
+ } ///< Cast to a more defined type. Will return null not of the requested type.
+
+ /** Create an exact duplicate of this node and return it. The memory must be deleted
+ by the caller.
+ */
+ virtual TiXmlNode* Clone() const = 0;
+
+protected:
+ TiXmlNode( NodeType _type );
+
+ // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
+ // and the assignment operator.
+ void CopyTo( TiXmlNode* target ) const;
+
+#ifdef TIXML_USE_STL
+ // The real work of the input operator.
+ virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
+#endif
+
+ // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
+ TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
+
+ // Internal Value function returning a TIXML_STRING
+ const TIXML_STRING& SValue() const
+ {
+ return value ;
+ }
+
+ TiXmlNode* parent;
+ NodeType type;
+
+ TiXmlNode* firstChild;
+ TiXmlNode* lastChild;
+
+ TIXML_STRING value;
+
+ TiXmlNode* prev;
+ TiXmlNode* next;
+
+private:
+ TiXmlNode( const TiXmlNode& ); // not implemented.
+ void operator=( const TiXmlNode& base ); // not allowed.
+};
+
+
+/** An attribute is a name-value pair. Elements have an arbitrary
+ number of attributes, each with a unique name.
+
+ @note The attributes are not TiXmlNodes, since they are not
+ part of the tinyXML document object model. There are other
+ suggested ways to look at this problem.
+*/
+class TiXmlAttribute : public TiXmlBase
+{
+ friend class TiXmlAttributeSet;
+
+public:
+ /// Construct an empty attribute.
+ TiXmlAttribute() : TiXmlBase()
+ {
+ document = 0;
+ prev = next = 0;
+ }
+
+#ifdef TIXML_USE_STL
+ /// std::string constructor.
+ TiXmlAttribute( const std::string& _name, const std::string& _value )
+ {
+ name = _name;
+ value = _value;
+ document = 0;
+ prev = next = 0;
+ }
+#endif
+
+ /// Construct an attribute with a name and value.
+ TiXmlAttribute( const char * _name, const char * _value )
+ {
+ name = _name;
+ value = _value;
+ document = 0;
+ prev = next = 0;
+ }
+
+ const char* Name() const
+ {
+ return name.c_str ();
+ } ///< Return the name of this attribute.
+ const char* Value() const
+ {
+ return value.c_str ();
+ } ///< Return the value of this attribute.
+ const int IntValue() const; ///< Return the value of this attribute, converted to an integer.
+ const double DoubleValue() const; ///< Return the value of this attribute, converted to a double.
+
+ /** QueryIntValue examines the value string. It is an alternative to the
+ IntValue() method with richer error checking.
+ If the value is an integer, it is stored in 'value' and
+ the call returns TIXML_SUCCESS. If it is not
+ an integer, it returns TIXML_WRONG_TYPE.
+
+ A specialized but useful call. Note that for success it returns 0,
+ which is the opposite of almost all other TinyXml calls.
+ */
+ int QueryIntValue( int* value ) const;
+ /// QueryDoubleValue examines the value string. See QueryIntValue().
+ int QueryDoubleValue( double* value ) const;
+
+ void SetName( const char* _name )
+ {
+ name = _name;
+ } ///< Set the name of this attribute.
+ void SetValue( const char* _value )
+ {
+ value = _value;
+ } ///< Set the value.
+
+ void SetIntValue( int value ); ///< Set the value from an integer.
+ void SetDoubleValue( double value ); ///< Set the value from a double.
+
+#ifdef TIXML_USE_STL
+ /// STL std::string form.
+ void SetName( const std::string& _name )
+ {
+ StringToBuffer buf( _name );
+ SetName ( buf.buffer ? buf.buffer : "error" );
+ }
+ /// STL std::string form.
+ void SetValue( const std::string& _value )
+ {
+ StringToBuffer buf( _value );
+ SetValue( buf.buffer ? buf.buffer : "error" );
+ }
+#endif
+
+ /// Get the next sibling attribute in the DOM. Returns null at end.
+ TiXmlAttribute* Next() const;
+ /// Get the previous sibling attribute in the DOM. Returns null at beginning.
+ TiXmlAttribute* Previous() const;
+
+ bool operator==( const TiXmlAttribute& rhs ) const
+ {
+ return rhs.name == name;
+ }
+ bool operator<( const TiXmlAttribute& rhs ) const
+ {
+ return name < rhs.name;
+ }
+ bool operator>( const TiXmlAttribute& rhs ) const
+ {
+ return name > rhs.name;
+ }
+
+ /* Attribute parsing starts: first letter of the name
+ returns: the next char after the value end quote
+ */
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+ // Prints this Attribute to a FILE stream.
+ virtual void Print( FILE* cfile, int depth ) const;
+
+ virtual void StreamOut( TIXML_OSTREAM * out ) const;
+ // [internal use]
+ // Set the document pointer so the attribute can report errors.
+ void SetDocument( TiXmlDocument* doc )
+ {
+ document = doc;
+ }
+
+private:
+ TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
+ void operator=( const TiXmlAttribute& base ); // not allowed.
+
+ TiXmlDocument* document; // A pointer back to a document, for error reporting.
+ TIXML_STRING name;
+ TIXML_STRING value;
+ TiXmlAttribute* prev;
+ TiXmlAttribute* next;
+};
+
+
+/* A class used to manage a group of attributes.
+ It is only used internally, both by the ELEMENT and the DECLARATION.
+
+ The set can be changed transparent to the Element and Declaration
+ classes that use it, but NOT transparent to the Attribute
+ which has to implement a next() and previous() method. Which makes
+ it a bit problematic and prevents the use of STL.
+
+ This version is implemented with circular lists because:
+ - I like circular lists
+ - it demonstrates some independence from the (typical) doubly linked list.
+*/
+class TiXmlAttributeSet
+{
+public:
+ TiXmlAttributeSet();
+ ~TiXmlAttributeSet();
+
+ void Add( TiXmlAttribute* attribute );
+ void Remove( TiXmlAttribute* attribute );
+
+ TiXmlAttribute* First() const
+ {
+ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next;
+ }
+ TiXmlAttribute* Last() const
+ {
+ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev;
+ }
+ TiXmlAttribute* Find( const char * name ) const;
+
+private:
+ TiXmlAttribute sentinel;
+};
+
+
+/** The element is a container class. It has a value, the element name,
+ and can contain other elements, text, comments, and unknowns.
+ Elements also contain an arbitrary number of attributes.
+*/
+class TiXmlElement : public TiXmlNode
+{
+public:
+ /// Construct an element.
+ TiXmlElement (const char * in_value);
+
+#ifdef TIXML_USE_STL
+ /// std::string constructor.
+ TiXmlElement( const std::string& _value );
+#endif
+
+ TiXmlElement( const TiXmlElement& );
+
+ void operator=( const TiXmlElement& base );
+
+ virtual ~TiXmlElement();
+
+ /** Given an attribute name, Attribute() returns the value
+ for the attribute of that name, or null if none exists.
+ */
+ const char* Attribute( const char* name ) const;
+
+ /** Given an attribute name, Attribute() returns the value
+ for the attribute of that name, or null if none exists.
+ If the attribute exists and can be converted to an integer,
+ the integer value will be put in the return 'i', if 'i'
+ is non-null.
+ */
+ const char* Attribute( const char* name, int* i ) const;
+
+ /** Given an attribute name, Attribute() returns the value
+ for the attribute of that name, or null if none exists.
+ If the attribute exists and can be converted to an double,
+ the double value will be put in the return 'd', if 'd'
+ is non-null.
+ */
+ const char* Attribute( const char* name, double* d ) const;
+
+ /** QueryIntAttribute examines the attribute - it is an alternative to the
+ Attribute() method with richer error checking.
+ If the attribute is an integer, it is stored in 'value' and
+ the call returns TIXML_SUCCESS. If it is not
+ an integer, it returns TIXML_WRONG_TYPE. If the attribute
+ does not exist, then TIXML_NO_ATTRIBUTE is returned.
+ */
+ int QueryIntAttribute( const char* name, int* value ) const;
+ /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
+ int QueryDoubleAttribute( const char* name, double* value ) const;
+
+ /** Sets an attribute of name to a given value. The attribute
+ will be created if it does not exist, or changed if it does.
+ */
+ void SetAttribute( const char* name, const char * value );
+
+#ifdef TIXML_USE_STL
+
+ const char* Attribute( const std::string& name ) const
+ {
+ return Attribute( name.c_str() );
+ }
+ const char* Attribute( const std::string& name, int* i ) const
+ {
+ return Attribute( name.c_str(), i );
+ }
+ const char* Attribute( const std::string& name, double* d ) const
+ {
+ return Attribute( name.c_str(), d );
+ }
+ int QueryIntAttribute( const std::string& name, int* value ) const
+ {
+ return QueryIntAttribute( name.c_str(), value );
+ }
+ int QueryDoubleAttribute( const std::string& name, double* value ) const
+ {
+ return QueryDoubleAttribute( name.c_str(), value );
+ }
+
+ /// STL std::string form.
+ void SetAttribute( const std::string& name, const std::string& _value )
+ {
+ StringToBuffer n( name );
+ StringToBuffer v( _value );
+ if ( n.buffer && v.buffer )
+ SetAttribute (n.buffer, v.buffer );
+ }
+ ///< STL std::string form.
+ void SetAttribute( const std::string& name, int _value )
+ {
+ StringToBuffer n( name );
+ if ( n.buffer )
+ SetAttribute (n.buffer, _value);
+ }
+#endif
+
+ /** Sets an attribute of name to a given value. The attribute
+ will be created if it does not exist, or changed if it does.
+ */
+ void SetAttribute( const char * name, int value );
+
+ /** Sets an attribute of name to a given value. The attribute
+ will be created if it does not exist, or changed if it does.
+ */
+ void SetDoubleAttribute( const char * name, double value );
+
+ /** Deletes an attribute with the given name.
+ */
+ void RemoveAttribute( const char * name );
+#ifdef TIXML_USE_STL
+
+ void RemoveAttribute( const std::string& name )
+ {
+ RemoveAttribute (name.c_str ());
+ } ///< STL std::string form.
+#endif
+
+ TiXmlAttribute* FirstAttribute() const
+ {
+ return attributeSet.First();
+ } ///< Access the first attribute in this element.
+ TiXmlAttribute* LastAttribute() const
+ {
+ return attributeSet.Last();
+ } ///< Access the last attribute in this element.
+
+ /// Creates a new Element and returns it - the returned element is a copy.
+ virtual TiXmlNode* Clone() const;
+ // Print the Element to a FILE stream.
+ virtual void Print( FILE* cfile, int depth ) const;
+
+ /* Attribtue parsing starts: next char past '<'
+ returns: next char past '>'
+ */
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+protected:
+
+ void CopyTo( TiXmlElement* target ) const;
+ void ClearThis(); // like clear, but initializes 'this' object as well
+
+ // Used to be public [internal use]
+#ifdef TIXML_USE_STL
+
+ virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
+#endif
+
+ virtual void StreamOut( TIXML_OSTREAM * out ) const;
+
+ /* [internal use]
+ Reads the "value" of the element -- another element, or text.
+ This should terminate with the current end tag.
+ */
+ const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
+
+private:
+
+ TiXmlAttributeSet attributeSet;
+};
+
+
+/** An XML comment.
+*/
+class TiXmlComment : public TiXmlNode
+{
+public:
+ /// Constructs an empty comment.
+ TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT )
+ {}
+ TiXmlComment( const TiXmlComment& );
+ void operator=( const TiXmlComment& base );
+
+ virtual ~TiXmlComment()
+ {}
+
+ /// Returns a copy of this Comment.
+ virtual TiXmlNode* Clone() const;
+ /// Write this Comment to a FILE stream.
+ virtual void Print( FILE* cfile, int depth ) const;
+
+ /* Attribtue parsing starts: at the ! of the !--
+ returns: next char past '>'
+ */
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+protected:
+ void CopyTo( TiXmlComment* target ) const;
+
+ // used to be public
+#ifdef TIXML_USE_STL
+
+ virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
+#endif
+
+ virtual void StreamOut( TIXML_OSTREAM * out ) const;
+
+private:
+
+};
+
+
+/** XML text. Contained in an element.
+*/
+class TiXmlText : public TiXmlNode
+{
+ friend class TiXmlElement;
+public:
+ /// Constructor.
+ TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT)
+ {
+ SetValue( initValue );
+ }
+ virtual ~TiXmlText()
+ {}
+
+#ifdef TIXML_USE_STL
+ /// Constructor.
+ TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
+ {
+ SetValue( initValue );
+ }
+#endif
+
+ TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT )
+ {
+ copy.CopyTo( this );
+ }
+ void operator=( const TiXmlText& base )
+ {
+ base.CopyTo( this );
+ }
+
+ /// Write this text object to a FILE stream.
+ virtual void Print( FILE* cfile, int depth ) const;
+
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+protected :
+ /// [internal use] Creates a new Element and returns it.
+ virtual TiXmlNode* Clone() const;
+ void CopyTo( TiXmlText* target ) const;
+
+ virtual void StreamOut ( TIXML_OSTREAM * out ) const;
+ bool Blank() const; // returns true if all white space and new lines
+ // [internal use]
+#ifdef TIXML_USE_STL
+
+ virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
+#endif
+
+private:
+};
+
+
+/** In correct XML the declaration is the first entry in the file.
+ @verbatim
+ <?xml version="1.0" standalone="yes"?>
+ @endverbatim
+
+ TinyXml will happily read or write files without a declaration,
+ however. There are 3 possible attributes to the declaration:
+ version, encoding, and standalone.
+
+ Note: In this version of the code, the attributes are
+ handled as special cases, not generic attributes, simply
+ because there can only be at most 3 and they are always the same.
+*/
+class TiXmlDeclaration : public TiXmlNode
+{
+public:
+ /// Construct an empty declaration.
+ TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION )
+ {}
+
+#ifdef TIXML_USE_STL
+ /// Constructor.
+ TiXmlDeclaration( const std::string& _version,
+ const std::string& _encoding,
+ const std::string& _standalone );
+#endif
+
+ /// Construct.
+ TiXmlDeclaration( const char* _version,
+ const char* _encoding,
+ const char* _standalone );
+
+ TiXmlDeclaration( const TiXmlDeclaration& copy );
+ void operator=( const TiXmlDeclaration& copy );
+
+ virtual ~TiXmlDeclaration()
+ {}
+
+ /// Version. Will return an empty string if none was found.
+ const char *Version() const
+ {
+ return version.c_str ();
+ }
+ /// Encoding. Will return an empty string if none was found.
+ const char *Encoding() const
+ {
+ return encoding.c_str ();
+ }
+ /// Is this a standalone document?
+ const char *Standalone() const
+ {
+ return standalone.c_str ();
+ }
+
+ /// Creates a copy of this Declaration and returns it.
+ virtual TiXmlNode* Clone() const;
+ /// Print this declaration to a FILE stream.
+ virtual void Print( FILE* cfile, int depth ) const;
+
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+protected:
+ void CopyTo( TiXmlDeclaration* target ) const;
+ // used to be public
+#ifdef TIXML_USE_STL
+
+ virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
+#endif
+
+ virtual void StreamOut ( TIXML_OSTREAM * out) const;
+
+private:
+
+ TIXML_STRING version;
+ TIXML_STRING encoding;
+ TIXML_STRING standalone;
+};
+
+
+/** Any tag that tinyXml doesn't recognize is saved as an
+ unknown. It is a tag of text, but should not be modified.
+ It will be written back to the XML, unchanged, when the file
+ is saved.
+
+ DTD tags get thrown into TiXmlUnknowns.
+*/
+class TiXmlUnknown : public TiXmlNode
+{
+public:
+ TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN )
+ {}
+ virtual ~TiXmlUnknown()
+ {}
+
+ TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN )
+ {
+ copy.CopyTo( this );
+ }
+ void operator=( const TiXmlUnknown& copy )
+ {
+ copy.CopyTo( this );
+ }
+
+ /// Creates a copy of this Unknown and returns it.
+ virtual TiXmlNode* Clone() const;
+ /// Print this Unknown to a FILE stream.
+ virtual void Print( FILE* cfile, int depth ) const;
+
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+protected:
+ void CopyTo( TiXmlUnknown* target ) const;
+
+#ifdef TIXML_USE_STL
+
+ virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
+#endif
+
+ virtual void StreamOut ( TIXML_OSTREAM * out ) const;
+
+private:
+
+};
+
+
+/** Always the top level node. A document binds together all the
+ XML pieces. It can be saved, loaded, and printed to the screen.
+ The 'value' of a document node is the xml file name.
+*/
+class TiXmlDocument : public TiXmlNode
+{
+public:
+ /// Create an empty document, that has no name.
+ TiXmlDocument();
+ /// Create a document with a name. The name of the document is also the filename of the xml.
+ TiXmlDocument( const char * documentName );
+
+#ifdef TIXML_USE_STL
+ /// Constructor.
+ TiXmlDocument( const std::string& documentName );
+#endif
+
+ TiXmlDocument( const TiXmlDocument& copy );
+ void operator=( const TiXmlDocument& copy );
+
+ virtual ~TiXmlDocument()
+ {}
+
+ /** Load a file using the current document value.
+ Returns true if successful. Will delete any existing
+ document data before loading.
+ */
+ bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+ /// Save a file using the current document value. Returns true if successful.
+ bool SaveFile() const;
+ /// Load a file using the given filename. Returns true if successful.
+ bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+ /// Save a file using the given filename. Returns true if successful.
+ bool SaveFile( const char * filename ) const;
+
+#ifdef TIXML_USE_STL
+
+ bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
+ {
+ StringToBuffer f( filename );
+ return ( f.buffer && LoadFile( f.buffer, encoding ));
+ }
+ bool SaveFile( const std::string& filename ) const ///< STL std::string version.
+ {
+ StringToBuffer f( filename );
+ return ( f.buffer && SaveFile( f.buffer ));
+ }
+#endif
+
+ /** Parse the given null terminated block of xml data. Passing in an encoding to this
+ method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml
+ to use that encoding, regardless of what TinyXml might otherwise try to detect.
+ */
+ virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+ /** Get the root element -- the only top level element -- of the document.
+ In well formed XML, there should only be one. TinyXml is tolerant of
+ multiple elements at the document level.
+ */
+ TiXmlElement* RootElement() const
+ {
+ return FirstChildElement();
+ }
+
+ /** If an error occurs, Error will be set to true. Also,
+ - The ErrorId() will contain the integer identifier of the error (not generally useful)
+ - The ErrorDesc() method will return the name of the error. (very useful)
+ - The ErrorRow() and ErrorCol() will return the location of the error (if known)
+ */
+ bool Error() const
+ {
+ return error;
+ }
+
+ /// Contains a textual (english) description of the error if one occurs.
+ const char * ErrorDesc() const
+ {
+ return errorDesc.c_str ();
+ }
+
+ /** Generally, you probably want the error string ( ErrorDesc() ). But if you
+ prefer the ErrorId, this function will fetch it.
+ */
+ const int ErrorId() const
+ {
+ return errorId;
+ }
+
+ /** Returns the location (if known) of the error. The first column is column 1,
+ and the first row is row 1. A value of 0 means the row and column wasn't applicable
+ (memory errors, for example, have no row/column) or the parser lost the error. (An
+ error in the error reporting, in that case.)
+
+ @sa SetTabSize, Row, Column
+ */
+ int ErrorRow()
+ {
+ return errorLocation.row+1;
+ }
+ int ErrorCol()
+ {
+ return errorLocation.col+1;
+ } ///< The column where the error occured. See ErrorRow()
+
+ /** By calling this method, with a tab size
+ greater than 0, the row and column of each node and attribute is stored
+ when the file is loaded. Very useful for tracking the DOM back in to
+ the source file.
+
+ The tab size is required for calculating the location of nodes. If not
+ set, the default of 4 is used. The tabsize is set per document. Setting
+ the tabsize to 0 disables row/column tracking.
+
+ Note that row and column tracking is not supported when using operator>>.
+
+ The tab size needs to be enabled before the parse or load. Correct usage:
+ @verbatim
+ TiXmlDocument doc;
+ doc.SetTabSize( 8 );
+ doc.Load( "myfile.xml" );
+ @endverbatim
+
+ @sa Row, Column
+ */
+ void SetTabSize( int _tabsize )
+ {
+ tabsize = _tabsize;
+ }
+
+ int TabSize() const
+ {
+ return tabsize;
+ }
+
+ /** If you have handled the error, it can be reset with this call. The error
+ state is automatically cleared if you Parse a new XML block.
+ */
+ void ClearError()
+ {
+ error = false;
+ errorId = 0;
+ errorDesc = "";
+ errorLocation.row = errorLocation.col = 0;
+ //errorLocation.last = 0;
+ }
+
+ /** Dump the document to standard out. */
+ void Print() const
+ {
+ Print( stdout, 0 );
+ }
+
+ /// Print this Document to a FILE stream.
+ virtual void Print( FILE* cfile, int depth = 0 ) const;
+ // [internal use]
+ void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
+
+protected :
+ virtual void StreamOut ( TIXML_OSTREAM * out) const;
+ // [internal use]
+ virtual TiXmlNode* Clone() const;
+#ifdef TIXML_USE_STL
+
+ virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
+#endif
+
+private:
+ void CopyTo( TiXmlDocument* target ) const;
+
+ bool error;
+ int errorId;
+ TIXML_STRING errorDesc;
+ int tabsize;
+ TiXmlCursor errorLocation;
+};
+
+
+/**
+ A TiXmlHandle is a class that wraps a node pointer with null checks; this is
+ an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml
+ DOM structure. It is a separate utility class.
+
+ Take an example:
+ @verbatim
+ <Document>
+ <Element attributeA = "valueA">
+ <Child attributeB = "value1" />
+ <Child attributeB = "value2" />
+ </Element>
+ <Document>
+ @endverbatim
+
+ Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
+ easy to write a *lot* of code that looks like:
+
+ @verbatim
+ TiXmlElement* root = document.FirstChildElement( "Document" );
+ if ( root )
+ {
+ TiXmlElement* element = root->FirstChildElement( "Element" );
+ if ( element )
+ {
+ TiXmlElement* child = element->FirstChildElement( "Child" );
+ if ( child )
+ {
+ TiXmlElement* child2 = child->NextSiblingElement( "Child" );
+ if ( child2 )
+ {
+ // Finally do something useful.
+ @endverbatim
+
+ And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
+ of such code. A TiXmlHandle checks for null pointers so it is perfectly safe
+ and correct to use:
+
+ @verbatim
+ TiXmlHandle docHandle( &document );
+ TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).Element();
+ if ( child2 )
+ {
+ // do something useful
+ @endverbatim
+
+ Which is MUCH more concise and useful.
+
+ It is also safe to copy handles - internally they are nothing more than node pointers.
+ @verbatim
+ TiXmlHandle handleCopy = handle;
+ @endverbatim
+
+ What they should not be used for is iteration:
+
+ @verbatim
+ int i=0;
+ while ( true )
+ {
+ TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).Element();
+ if ( !child )
+ break;
+ // do something
+ ++i;
+ }
+ @endverbatim
+
+ It seems reasonable, but it is in fact two embedded while loops. The Child method is
+ a linear walk to find the element, so this code would iterate much more than it needs
+ to. Instead, prefer:
+
+ @verbatim
+ TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).Element();
+
+ for( child; child; child=child->NextSiblingElement() )
+ {
+ // do something
+ }
+ @endverbatim
+*/
+class TiXmlHandle
+{
+public:
+ /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
+ TiXmlHandle( TiXmlNode* node )
+ {
+ this->node = node;
+ }
+ /// Copy constructor
+ TiXmlHandle( const TiXmlHandle& ref )
+ {
+ this->node = ref.node;
+ }
+ TiXmlHandle operator=( const TiXmlHandle& ref )
+ {
+ this->node = ref.node;
+ return *this;
+ }
+
+ /// Return a handle to the first child node.
+ TiXmlHandle FirstChild() const;
+ /// Return a handle to the first child node with the given name.
+ TiXmlHandle FirstChild( const char * value ) const;
+ /// Return a handle to the first child element.
+ TiXmlHandle FirstChildElement() const;
+ /// Return a handle to the first child element with the given name.
+ TiXmlHandle FirstChildElement( const char * value ) const;
+
+ /** Return a handle to the "index" child with the given name.
+ The first child is 0, the second 1, etc.
+ */
+ TiXmlHandle Child( const char* value, int index ) const;
+ /** Return a handle to the "index" child.
+ The first child is 0, the second 1, etc.
+ */
+ TiXmlHandle Child( int index ) const;
+ /** Return a handle to the "index" child element with the given name.
+ The first child element is 0, the second 1, etc. Note that only TiXmlElements
+ are indexed: other types are not counted.
+ */
+ TiXmlHandle ChildElement( const char* value, int index ) const;
+ /** Return a handle to the "index" child element.
+ The first child element is 0, the second 1, etc. Note that only TiXmlElements
+ are indexed: other types are not counted.
+ */
+ TiXmlHandle ChildElement( int index ) const;
+
+#ifdef TIXML_USE_STL
+
+ TiXmlHandle FirstChild( const std::string& _value ) const
+ {
+ return FirstChild( _value.c_str() );
+ }
+ TiXmlHandle FirstChildElement( const std::string& _value ) const
+ {
+ return FirstChildElement( _value.c_str() );
+ }
+
+ TiXmlHandle Child( const std::string& _value, int index ) const
+ {
+ return Child( _value.c_str(), index );
+ }
+ TiXmlHandle ChildElement( const std::string& _value, int index ) const
+ {
+ return ChildElement( _value.c_str(), index );
+ }
+#endif
+
+ /// Return the handle as a TiXmlNode. This may return null.
+ TiXmlNode* Node() const
+ {
+ return node;
+ }
+ /// Return the handle as a TiXmlElement. This may return null.
+ TiXmlElement* Element() const
+ {
+ return ( ( node && node->ToElement() ) ? node->ToElement() : 0 );
+ }
+ /// Return the handle as a TiXmlText. This may return null.
+ TiXmlText* Text() const
+ {
+ return ( ( node && node->ToText() ) ? node->ToText() : 0 );
+ }
+ /// Return the handle as a TiXmlUnknown. This may return null;
+ TiXmlUnknown* Unknown() const
+ {
+ return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 );
+ }
+
+private:
+ TiXmlNode* node;
+};
+
+
+#endif
+
diff --git a/src/contrib/xml/tinyxmlerror.cpp b/src/contrib/xml/tinyxmlerror.cpp
new file mode 100644
index 0000000..e2cff82
--- /dev/null
+++ b/src/contrib/xml/tinyxmlerror.cpp
@@ -0,0 +1,75 @@
+/*:*
+ *: File: ./src/contrib/xml/tinyxmlerror.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include "tinyxml.h"
+
+// The goal of the seperate error file is to make the first
+// step towards localization. tinyxml (currently) only supports
+// latin-1, but at least the error messages could now be translated.
+//
+// It also cleans up the code a bit.
+//
+
+const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
+ {
+ "No error",
+ "Error",
+ "Failed to open file",
+ "Memory allocation failed.",
+ "Error parsing Element.",
+ "Failed to read Element name",
+ "Error reading Element value.",
+ "Error reading Attributes.",
+ "Error: empty tag.",
+ "Error reading end tag.",
+ "Error parsing Unknown.",
+ "Error parsing Comment.",
+ "Error parsing Declaration.",
+ "Error document empty.",
+ "Error null (0) or unexpected EOF found in input stream.",
+ };
diff --git a/src/contrib/xml/tinyxmlparser.cpp b/src/contrib/xml/tinyxmlparser.cpp
new file mode 100644
index 0000000..5a7a322
--- /dev/null
+++ b/src/contrib/xml/tinyxmlparser.cpp
@@ -0,0 +1,1577 @@
+/*:*
+ *: File: ./src/contrib/xml/tinyxmlparser.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include "tinyxml.h"
+#include <ctype.h>
+
+//#define DEBUG_PARSER
+
+// Note tha "PutString" hardcodes the same list. This
+// is less flexible than it appears. Changing the entries
+// or order will break putstring.
+TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
+ {
+ { "&amp;", 5, '&' },
+ { "&lt;", 4, '<' },
+ { "&gt;", 4, '>' },
+ { "&quot;", 6, '\"' },
+ { "&apos;", 6, '\'' }
+ };
+
+// Bunch of unicode info at:
+// http://www.unicode.org/faq/utf_bom.html
+// Including the basic of this table, which determines the #bytes in the
+// sequence from the lead byte. 1 placed for invalid sequences --
+// although the result will be junk, pass it through as much as possible.
+// Beware of the non-characters in UTF-8:
+// ef bb bf (Microsoft "lead bytes")
+// ef bf be
+// ef bf bf
+
+
+
+const int TiXmlBase::utf8ByteTable[256] =
+ {
+ // 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
+ 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
+ 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid
+ };
+
+
+void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
+{
+ const unsigned long BYTE_MASK = 0xBF;
+ const unsigned long BYTE_MARK = 0x80;
+ const unsigned long FIRST_BYTE_MARK[7] =
+ {
+ 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
+ };
+
+ if (input < 0x80)
+ *length = 1;
+ else if ( input < 0x800 )
+ *length = 2;
+ else if ( input < 0x10000 )
+ *length = 3;
+ else if ( input < 0x200000 )
+ *length = 4;
+ else
+ {
+ *length = 0;
+ return;
+ } // This code won't covert this correctly anyway.
+
+ output += *length;
+
+ // Scary scary fall throughs.
+ switch (*length)
+ {
+ case 4:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 3:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 2:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 1:
+ --output;
+ *output = (char)(input | FIRST_BYTE_MARK[*length]);
+ }
+}
+
+
+/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding encoding )
+{
+ // This will only work for low-ascii, everything else is assumed to be a valid
+ // letter. I'm not sure this is the best approach, but it is quite tricky trying
+ // to figure out alhabetical vs. not across encoding. So take a very
+ // conservative approach.
+
+ // if ( encoding == TIXML_ENCODING_UTF8 )
+ // {
+ if ( anyByte < 127 )
+ return isalpha( anyByte );
+ else
+ return 1; // What else to do? The unicode set is huge...get the english ones right.
+ // }
+ // else
+ // {
+ // return isalpha( anyByte );
+ // }
+}
+
+
+/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding )
+{
+ // This will only work for low-ascii, everything else is assumed to be a valid
+ // letter. I'm not sure this is the best approach, but it is quite tricky trying
+ // to figure out alhabetical vs. not across encoding. So take a very
+ // conservative approach.
+
+ // if ( encoding == TIXML_ENCODING_UTF8 )
+ // {
+ if ( anyByte < 127 )
+ return isalnum( anyByte );
+ else
+ return 1; // What else to do? The unicode set is huge...get the english ones right.
+ // }
+ // else
+ // {
+ // return isalnum( anyByte );
+ // }
+}
+
+
+class TiXmlParsingData
+{
+ friend class TiXmlDocument;
+public:
+ void Stamp( const char* now, TiXmlEncoding encoding );
+
+ const TiXmlCursor& Cursor()
+ {
+ return cursor;
+ }
+
+private:
+ // Only used by the document!
+ TiXmlParsingData( const char* start, int _tabsize, int row, int col )
+ {
+ assert( start );
+ stamp = start;
+ tabsize = _tabsize;
+ cursor.row = row;
+ cursor.col = col;
+ }
+
+ TiXmlCursor cursor;
+ const char* stamp;
+ int tabsize;
+};
+
+
+void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
+{
+ assert( now );
+
+ // Do nothing if the tabsize is 0.
+ if ( tabsize < 1 )
+ {
+ return;
+ }
+
+ // Get the current row, column.
+ int row = cursor.row;
+ int col = cursor.col;
+ const char* p = stamp;
+ assert( p );
+
+ while ( p < now )
+ {
+ // Code contributed by Fletcher Dunn: (modified by lee)
+ switch (*p)
+ {
+ case 0:
+ // We *should* never get here, but in case we do, don't
+ // advance past the terminating null character, ever
+ return;
+
+ case '\r':
+ // bump down to the next line
+ ++row;
+ col = 0;
+ // Eat the character
+ ++p;
+
+ // Check for \r\n sequence, and treat this as a single character
+ if (*p == '\n')
+ {
+ ++p;
+ }
+ break;
+
+ case '\n':
+ // bump down to the next line
+ ++row;
+ col = 0;
+
+ // Eat the character
+ ++p;
+
+ // Check for \n\r sequence, and treat this as a single
+ // character. (Yes, this bizarre thing does occur still
+ // on some arcane platforms...)
+ if (*p == '\r')
+ {
+ ++p;
+ }
+ break;
+
+ case '\t':
+ // Eat the character
+ ++p;
+
+ // Skip to next tab stop
+ col = (col / tabsize + 1) * tabsize;
+ break;
+
+ case (char)(0xef):
+ if ( encoding == TIXML_ENCODING_UTF8 )
+ {
+ if ( *(p+1) && *(p+2) )
+ {
+ // In these cases, don't advance the column. These are
+ // 0-width spaces.
+ if ( *(p+1)==(char)(0xbb) && *(p+2)==(char)(0xbf) )
+ p += 3;
+ else if ( *(p+1)==(char)(0xbf) && *(p+2)==(char)(0xbe) )
+ p += 3;
+ else if ( *(p+1)==(char)(0xbf) && *(p+2)==(char)(0xbf) )
+ p += 3;
+ else
+ {
+ p +=3;
+ ++col;
+ } // A normal character.
+ }
+ }
+ else
+ {
+ ++p;
+ ++col;
+ }
+ break;
+
+ default:
+ if ( encoding == TIXML_ENCODING_UTF8 )
+ {
+ // Eat the 1 to 4 byte utf8 character.
+ int step = TiXmlBase::utf8ByteTable[*((unsigned char*)p)];
+ if ( step == 0 )
+ step = 1; // Error case from bad encoding, but handle gracefully.
+ p += step;
+
+ // Just advance one column, of course.
+ ++col;
+ }
+ else
+ {
+ ++p;
+ ++col;
+ }
+ break;
+ }
+ }
+ cursor.row = row;
+ cursor.col = col;
+ assert( cursor.row >= -1 );
+ assert( cursor.col >= -1 );
+ stamp = p;
+ assert( stamp );
+}
+
+
+const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
+{
+ if ( !p || !*p )
+ {
+ return 0;
+ }
+ if ( encoding == TIXML_ENCODING_UTF8 )
+ {
+ while ( *p )
+ {
+ // Skip the stupid Microsoft UTF-8 Byte order marks
+ if ( *(p+0)==(char) 0xef
+ && *(p+1)==(char) 0xbb
+ && *(p+2)==(char) 0xbf )
+ {
+ p += 3;
+ continue;
+ }
+ else if(*(p+0)==(char) 0xef
+ && *(p+1)==(char) 0xbf
+ && *(p+2)==(char) 0xbe )
+ {
+ p += 3;
+ continue;
+ }
+ else if(*(p+0)==(char) 0xef
+ && *(p+1)==(char) 0xbf
+ && *(p+2)==(char) 0xbf )
+ {
+ p += 3;
+ continue;
+ }
+
+ if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space.
+ ++p;
+ else
+ break;
+ }
+ }
+ else
+ {
+ while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
+ ++p;
+ }
+
+ return p;
+}
+
+#ifdef TIXML_USE_STL
+/*static*/ bool TiXmlBase::StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag )
+{
+ for( ;; )
+ {
+ if ( !in->good() )
+ return false;
+
+ int c = in->peek();
+ // At this scope, we can't get to a document. So fail silently.
+ if ( !IsWhiteSpace( c ) || c <= 0 )
+ return true;
+
+ *tag += (char) in->get
+ ();
+ }
+}
+
+/*static*/ bool TiXmlBase::StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag )
+{
+ //assert( character > 0 && character < 128 ); // else it won't work in utf-8
+ while ( in->good() )
+ {
+ int c = in->peek();
+ if ( c == character )
+ return true;
+ if ( c <= 0 ) // Silent failure: can't get document at this scope
+ return false;
+
+ in->get
+ ();
+ *tag += (char) c;
+ }
+ return false;
+}
+#endif
+
+const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding )
+{
+ *name = "";
+ assert( p );
+
+ // Names start with letters or underscores.
+ // Of course, in unicode, tinyxml has no idea what a letter *is*. The
+ // algorithm is generous.
+ //
+ // After that, they can be letters, underscores, numbers,
+ // hyphens, or colons. (Colons are valid ony for namespaces,
+ // but tinyxml can't tell namespaces from names.)
+ if ( p && *p
+ && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
+ {
+ while( p && *p
+ && ( IsAlphaNum( (unsigned char ) *p, encoding )
+ || *p == '_'
+ || *p == '-'
+ || *p == '.'
+ || *p == ':' ) )
+ {
+ (*name) += *p;
+ ++p;
+ }
+ return p;
+ }
+ return 0;
+}
+
+const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding )
+{
+ // Presume an entity, and pull it out.
+ TIXML_STRING ent;
+ int i;
+ *length = 0;
+
+ if ( *(p+1) && *(p+1) == '#' && *(p+2) )
+ {
+ unsigned long ucs = 0;
+ unsigned delta = 0;
+ unsigned mult = 1;
+
+ if ( *(p+2) == 'x' )
+ {
+ // Hexadecimal.
+ if ( !*(p+3) )
+ return 0;
+
+ const char* q = p+3;
+ q = strchr( q, ';' );
+
+ if ( !q || !*q )
+ return 0;
+
+ delta = q-p;
+ --q;
+
+ while ( *q != 'x' )
+ {
+ if ( *q >= '0' && *q <= '9' )
+ ucs += mult * (*q - '0');
+ else if ( *q >= 'a' && *q <= 'f' )
+ ucs += mult * (*q - 'a' + 10);
+ else if ( *q >= 'A' && *q <= 'F' )
+ ucs += mult * (*q - 'A' + 10 );
+ else
+ return 0;
+ mult *= 16;
+ --q;
+ }
+ }
+ else
+ {
+ // Decimal.
+ if ( !*(p+2) )
+ return 0;
+
+ const char* q = p+2;
+ q = strchr( q, ';' );
+
+ if ( !q || !*q )
+ return 0;
+
+ delta = q-p;
+ --q;
+
+ while ( *q != '#' )
+ {
+ if ( *q >= '0' && *q <= '9' )
+ ucs += mult * (*q - '0');
+ else
+ return 0;
+ mult *= 10;
+ --q;
+ }
+ }
+ if ( encoding == TIXML_ENCODING_UTF8 )
+ {
+ // convert the UCS to UTF-8
+ ConvertUTF32ToUTF8( ucs, value, length );
+ }
+ else
+ {
+ *value = (char)ucs;
+ *length = 1;
+ }
+ return p + delta + 1;
+ }
+
+ // Now try to match it.
+ for( i=0; i<NUM_ENTITY; ++i )
+ {
+ if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
+ {
+ assert( strlen( entity[i].str ) == entity[i].strLength );
+ *value = entity[i].chr;
+ *length = 1;
+ return ( p + entity[i].strLength );
+ }
+ }
+
+ // So it wasn't an entity, its unrecognized, or something like that.
+ *value = *p; // Don't put back the last one, since we return it!
+ return p+1;
+}
+
+
+bool TiXmlBase::StringEqual( const char* p,
+ const char* tag,
+ bool ignoreCase,
+ TiXmlEncoding encoding )
+{
+ assert( p );
+ assert( tag );
+ if ( !p || !*p )
+ {
+ assert( 0 );
+ return false;
+ }
+
+ const char* q = p;
+
+ if ( ignoreCase )
+ {
+ while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) )
+ {
+ ++q;
+ ++tag;
+ }
+
+ if ( *tag == 0 )
+ return true;
+ }
+ else
+ {
+ while ( *q && *tag && *q == *tag )
+ {
+ ++q;
+ ++tag;
+ }
+
+ if ( *tag == 0 ) // Have we found the end of the tag, and everything equal?
+ return true;
+ }
+ return false;
+}
+
+const char* TiXmlBase::ReadText( const char* p,
+ TIXML_STRING * text,
+ bool trimWhiteSpace,
+ const char* endTag,
+ bool caseInsensitive,
+ TiXmlEncoding encoding )
+{
+ *text = "";
+ if ( !trimWhiteSpace // certain tags always keep whitespace
+ || !condenseWhiteSpace ) // if true, whitespace is always kept
+ {
+ // Keep all the white space.
+ while ( p && *p
+ && !StringEqual( p, endTag, caseInsensitive, encoding )
+ )
+ {
+ int len;
+ char cArr[4] = { 0, 0, 0, 0 };
+ p = GetChar( p, cArr, &len, encoding );
+ text->append( cArr, len );
+ }
+ }
+ else
+ {
+ bool whitespace = false;
+
+ // Remove leading white space:
+ p = SkipWhiteSpace( p, encoding );
+ while ( p && *p
+ && !StringEqual( p, endTag, caseInsensitive, encoding ) )
+ {
+ if ( *p == '\r' || *p == '\n' )
+ {
+ whitespace = true;
+ ++p;
+ }
+ else if ( IsWhiteSpace( *p ) )
+ {
+ whitespace = true;
+ ++p;
+ }
+ else
+ {
+ // If we've found whitespace, add it before the
+ // new character. Any whitespace just becomes a space.
+ if ( whitespace )
+ {
+ (*text) += ' ';
+ whitespace = false;
+ }
+ int len;
+ char cArr[4] = { 0, 0, 0, 0 };
+ p = GetChar( p, cArr, &len, encoding );
+ if ( len == 1 )
+ (*text) += cArr[0]; // more efficient
+ else
+ text->append( cArr, len );
+ }
+ }
+ }
+ return p + strlen( endTag );
+}
+
+#ifdef TIXML_USE_STL
+
+void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
+{
+ // The basic issue with a document is that we don't know what we're
+ // streaming. Read something presumed to be a tag (and hope), then
+ // identify it, and call the appropriate stream method on the tag.
+ //
+ // This "pre-streaming" will never read the closing ">" so the
+ // sub-tag can orient itself.
+
+ if ( !StreamTo( in, '<', tag ) )
+ {
+ SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+
+ while ( in->good() )
+ {
+ int tagIndex = (int) tag->length();
+ while ( in->good() && in->peek() != '>' )
+ {
+ int c = in->get
+ ();
+ if ( c <= 0 )
+ {
+ SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ break;
+ }
+ (*tag) += (char) c;
+ }
+
+ if ( in->good() )
+ {
+ // We now have something we presume to be a node of
+ // some sort. Identify it, and call the node to
+ // continue streaming.
+ TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
+
+ if ( node )
+ {
+ node->StreamIn( in, tag );
+ bool isElement = node->ToElement() != 0;
+ delete node;
+ node = 0;
+
+ // If this is the root element, we're done. Parsing will be
+ // done by the >> operator.
+ if ( isElement )
+ {
+ return;
+ }
+ }
+ else
+ {
+ SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+ }
+ }
+ // We should have returned sooner.
+ SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
+}
+
+#endif
+
+const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
+{
+ ClearError();
+
+ // Parse away, at the document level. Since a document
+ // contains nothing but other tags, most of what happens
+ // here is skipping white space.
+ if ( !p || !*p )
+ {
+ SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return 0;
+ }
+
+ // Note that, for a document, this needs to come
+ // before the while space skip, so that parsing
+ // starts from the pointer we are given.
+ location.Clear();
+ if ( prevData )
+ {
+ location.row = prevData->cursor.row;
+ location.col = prevData->cursor.col;
+ }
+ else
+ {
+ location.row = 0;
+ location.col = 0;
+ }
+ TiXmlParsingData data( p, TabSize(), location.row, location.col );
+ location = data.Cursor();
+
+ if ( encoding == TIXML_ENCODING_UNKNOWN )
+ {
+ // Check for the Microsoft UTF-8 lead bytes.
+ if ( *(p+0) && *(p+0) == (char)(0xef)
+ && *(p+1) && *(p+1) == (char)(0xbb)
+ && *(p+2) && *(p+2) == (char)(0xbf) )
+ {
+ encoding = TIXML_ENCODING_UTF8;
+ }
+ }
+
+ p = SkipWhiteSpace( p, encoding );
+ if ( !p )
+ {
+ SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return 0;
+ }
+
+ while ( p && *p )
+ {
+ TiXmlNode* node = Identify( p, encoding );
+ if ( node )
+ {
+ p = node->Parse( p, &data, encoding );
+ LinkEndChild( node );
+ }
+ else
+ {
+ break;
+ }
+
+ // Did we get encoding info?
+ if ( encoding == TIXML_ENCODING_UNKNOWN
+ && node->ToDeclaration() )
+ {
+ TiXmlDeclaration* dec = node->ToDeclaration();
+ const char* enc = dec->Encoding();
+ assert( enc );
+
+ if ( *enc == 0 )
+ encoding = TIXML_ENCODING_UTF8;
+ else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
+ encoding = TIXML_ENCODING_UTF8;
+ else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
+ encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
+ else
+ encoding = TIXML_ENCODING_LEGACY;
+ }
+
+ p = SkipWhiteSpace( p, encoding );
+ }
+
+ // All is well.
+ return p;
+}
+
+void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ // The first error in a chain is more accurate - don't set again!
+ if ( error )
+ return;
+
+ assert( err > 0 && err < TIXML_ERROR_STRING_COUNT );
+ error = true;
+ errorId = err;
+ errorDesc = errorString[ errorId ];
+
+ errorLocation.Clear();
+ if ( pError && data )
+ {
+ //TiXmlParsingData data( pError, prevData );
+ data->Stamp( pError, encoding );
+ errorLocation = data->Cursor();
+ }
+}
+
+
+TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
+{
+ TiXmlNode* returnNode = 0;
+
+ p = SkipWhiteSpace( p, encoding );
+ if( !p || !*p || *p != '<' )
+ {
+ return 0;
+ }
+
+ TiXmlDocument* doc = GetDocument();
+ p = SkipWhiteSpace( p, encoding );
+
+ if ( !p || !*p )
+ {
+ return 0;
+ }
+
+ // What is this thing?
+ // - Elements start with a letter or underscore, but xml is reserved.
+ // - Comments: <!--
+ // - Decleration: <?xml
+ // - Everthing else is unknown to tinyxml.
+ //
+
+ const char* xmlHeader =
+ { "<?xml"
+ };
+ const char* commentHeader =
+ { "<!--"
+ };
+ const char* dtdHeader =
+ { "<!"
+ };
+
+ if ( StringEqual( p, xmlHeader, true, encoding ) )
+ {
+#ifdef DEBUG_PARSER
+ TIXML_LOG( "XML parsing Declaration\n" );
+#endif
+
+ returnNode = new TiXmlDeclaration();
+ }
+ else if ( StringEqual( p, commentHeader, false, encoding ) )
+ {
+#ifdef DEBUG_PARSER
+ TIXML_LOG( "XML parsing Comment\n" );
+#endif
+
+ returnNode = new TiXmlComment();
+ }
+ else if ( StringEqual( p, dtdHeader, false, encoding ) )
+ {
+#ifdef DEBUG_PARSER
+ TIXML_LOG( "XML parsing Unknown(1)\n" );
+#endif
+
+ returnNode = new TiXmlUnknown();
+ }
+ else if ( IsAlpha( *(p+1), encoding )
+ || *(p+1) == '_' )
+ {
+#ifdef DEBUG_PARSER
+ TIXML_LOG( "XML parsing Element\n" );
+#endif
+
+ returnNode = new TiXmlElement( "" );
+ }
+ else
+ {
+#ifdef DEBUG_PARSER
+ TIXML_LOG( "XML parsing Unknown(2)\n" );
+#endif
+
+ returnNode = new TiXmlUnknown();
+ }
+
+ if ( returnNode )
+ {
+ // Set the parent, so it can report errors
+ returnNode->parent = this;
+ }
+ else
+ {
+ if ( doc )
+ doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+ }
+ return returnNode;
+}
+
+#ifdef TIXML_USE_STL
+
+void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
+{
+ // We're called with some amount of pre-parsing. That is, some of "this"
+ // element is in "tag". Go ahead and stream to the closing ">"
+ while( in->good() )
+ {
+ int c = in->get
+ ();
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+ (*tag) += (char) c ;
+
+ if ( c == '>' )
+ break;
+ }
+
+ if ( tag->length() < 3 )
+ return;
+
+ // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
+ // If not, identify and stream.
+
+ if ( tag->at( tag->length() - 1 ) == '>'
+ && tag->at( tag->length() - 2 ) == '/' )
+ {
+ // All good!
+ return;
+ }
+ else if ( tag->at( tag->length() - 1 ) == '>' )
+ {
+ // There is more. Could be:
+ // text
+ // closing tag
+ // another node.
+ for ( ;; )
+ {
+ StreamWhiteSpace( in, tag );
+
+ // Do we have text?
+ if ( in->good() && in->peek() != '<' )
+ {
+ // Yep, text.
+ TiXmlText text( "" );
+ text.StreamIn( in, tag );
+
+ // What follows text is a closing tag or another node.
+ // Go around again and figure it out.
+ continue;
+ }
+
+ // We now have either a closing tag...or another node.
+ // We should be at a "<", regardless.
+ if ( !in->good() )
+ return;
+ assert( in->peek() == '<' );
+ int tagIndex = tag->length();
+
+ bool closingTag = false;
+ bool firstCharFound = false;
+
+ for( ;; )
+ {
+ if ( !in->good() )
+ return;
+
+ int c = in->peek();
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+
+ if ( c == '>' )
+ break;
+
+ *tag += (char) c;
+ in->get
+ ();
+
+ if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
+ {
+ firstCharFound = true;
+ if ( c == '/' )
+ closingTag = true;
+ }
+ }
+ // If it was a closing tag, then read in the closing '>' to clean up the input stream.
+ // If it was not, the streaming will be done by the tag.
+ if ( closingTag )
+ {
+ if ( !in->good() )
+ return;
+
+ int c = in->get
+ ();
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+ assert( c == '>' );
+ *tag += (char) c;
+
+ // We are done, once we've found our closing tag.
+ return;
+ }
+ else
+ {
+ // If not a closing tag, id it, and stream.
+ const char* tagloc = tag->c_str() + tagIndex;
+ TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING );
+ if ( !node )
+ return;
+ node->StreamIn( in, tag );
+ delete node;
+ node = 0;
+
+ // No return: go around from the beginning: text, closing tag, or node.
+ }
+ }
+ }
+}
+#endif
+
+const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ p = SkipWhiteSpace( p, encoding );
+ TiXmlDocument* document = GetDocument();
+
+ if ( !p || !*p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
+ return 0;
+ }
+
+ // TiXmlParsingData data( p, prevData );
+ if ( data )
+ {
+ data->Stamp( p, encoding );
+ location = data->Cursor();
+ }
+
+ if ( *p != '<' )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
+ return 0;
+ }
+
+ p = SkipWhiteSpace( p+1, encoding );
+
+ // Read the name.
+ const char* pErr = p;
+
+ p = ReadName( p, &value, encoding );
+ if ( !p || !*p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
+ return 0;
+ }
+
+ TIXML_STRING endTag ("</");
+ endTag += value;
+ endTag += ">";
+
+ // Check for and read attributes. Also look for an empty
+ // tag or an end tag.
+ while ( p && *p )
+ {
+ pErr = p;
+ p = SkipWhiteSpace( p, encoding );
+ if ( !p || !*p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
+ return 0;
+ }
+ if ( *p == '/' )
+ {
+ ++p;
+ // Empty tag.
+ if ( *p != '>' )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
+ return 0;
+ }
+ return (p+1);
+ }
+ else if ( *p == '>' )
+ {
+ // Done with attributes (if there were any.)
+ // Read the value -- which can include other
+ // elements -- read the end tag, and return.
+ ++p;
+ p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
+ if ( !p || !*p )
+ return 0;
+
+ // We should find the end tag now
+ if ( StringEqual( p, endTag.c_str(), false, encoding ) )
+ {
+ p += endTag.length();
+ return p;
+ }
+ else
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
+ return 0;
+ }
+ }
+ else
+ {
+ // Try to read an attribute:
+ TiXmlAttribute* attrib = new TiXmlAttribute();
+ if ( !attrib )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
+ return 0;
+ }
+
+ attrib->SetDocument( document );
+ const char* pErr = p;
+ p = attrib->Parse( p, data, encoding );
+
+ if ( !p || !*p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
+ delete attrib;
+ return 0;
+ }
+
+ // Handle the strange case of double attributes:
+ TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
+ if ( node )
+ {
+ node->SetValue( attrib->Value() );
+ delete attrib;
+ return 0;
+ }
+
+ attributeSet.Add( attrib );
+ }
+ }
+ return p;
+}
+
+
+const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ TiXmlDocument* document = GetDocument();
+
+ const char* pWithWhiteSpace = p;
+ // Read in text and elements in any order.
+ p = SkipWhiteSpace( p, encoding );
+ while ( p && *p )
+ {
+ if ( *p != '<' )
+ {
+ // Take what we have, make a text element.
+ TiXmlText* textNode = new TiXmlText( "" );
+
+ if ( !textNode )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
+ return 0;
+ }
+
+ if ( TiXmlBase::IsWhiteSpaceCondensed() )
+ {
+ p = textNode->Parse( p, data, encoding );
+ }
+ else
+ {
+ // Special case: we want to keep the white space
+ // so that leading spaces aren't removed.
+ p = textNode->Parse( pWithWhiteSpace, data, encoding );
+ }
+
+ if ( !textNode->Blank() )
+ LinkEndChild( textNode );
+ else
+ delete textNode;
+ }
+ else
+ {
+ // We hit a '<'
+ // Have we hit a new element or an end tag?
+ if ( StringEqual( p, "</", false, encoding ) )
+ {
+ return p;
+ }
+ else
+ {
+ TiXmlNode* node = Identify( p, encoding );
+ if ( node )
+ {
+ p = node->Parse( p, data, encoding );
+ LinkEndChild( node );
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+ p = SkipWhiteSpace( p, encoding );
+ }
+
+ if ( !p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
+ }
+ return p;
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
+{
+ while ( in->good() )
+ {
+ int c = in->get
+ ();
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+ (*tag) += (char) c;
+
+ if ( c == '>' )
+ {
+ // All is well.
+ return;
+ }
+ }
+}
+#endif
+
+
+const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ TiXmlDocument* document = GetDocument();
+ p = SkipWhiteSpace( p, encoding );
+
+ // TiXmlParsingData data( p, prevData );
+ if ( data )
+ {
+ data->Stamp( p, encoding );
+ location = data->Cursor();
+ }
+ if ( !p || !*p || *p != '<' )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding );
+ return 0;
+ }
+ ++p;
+ value = "";
+
+ while ( p && *p && *p != '>' )
+ {
+ value += *p;
+ ++p;
+ }
+
+ if ( !p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
+ }
+ if ( *p == '>' )
+ return p+1;
+ return p;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
+{
+ while ( in->good() )
+ {
+ int c = in->get
+ ();
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+
+ (*tag) += (char) c;
+
+ if ( c == '>'
+ && tag->at( tag->length() - 2 ) == '-'
+ && tag->at( tag->length() - 3 ) == '-' )
+ {
+ // All is well.
+ return;
+ }
+ }
+}
+#endif
+
+
+const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ TiXmlDocument* document = GetDocument();
+ value = "";
+
+ p = SkipWhiteSpace( p, encoding );
+
+ // TiXmlParsingData data( p, prevData );
+ if ( data )
+ {
+ data->Stamp( p, encoding );
+ location = data->Cursor();
+ }
+ const char* startTag = "<!--";
+ const char* endTag = "-->";
+
+ if ( !StringEqual( p, startTag, false, encoding ) )
+ {
+ document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
+ return 0;
+ }
+ p += strlen( startTag );
+ p = ReadText( p, &value, false, endTag, false, encoding );
+ return p;
+}
+
+
+const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ p = SkipWhiteSpace( p, encoding );
+ if ( !p || !*p )
+ return 0;
+
+ int tabsize = 4;
+ if ( document )
+ tabsize = document->TabSize();
+
+ // TiXmlParsingData data( p, prevData );
+ if ( data )
+ {
+ data->Stamp( p, encoding );
+ location = data->Cursor();
+ }
+ // Read the name, the '=' and the value.
+ const char* pErr = p;
+ p = ReadName( p, &name, encoding );
+ if ( !p || !*p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
+ return 0;
+ }
+ p = SkipWhiteSpace( p, encoding );
+ if ( !p || !*p || *p != '=' )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+ return 0;
+ }
+
+ ++p; // skip '='
+ p = SkipWhiteSpace( p, encoding );
+ if ( !p || !*p )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+ return 0;
+ }
+
+ const char* end;
+
+ if ( *p == '\'' )
+ {
+ ++p;
+ end = "\'";
+ p = ReadText( p, &value, false, end, false, encoding );
+ }
+ else if ( *p == '"' )
+ {
+ ++p;
+ end = "\"";
+ p = ReadText( p, &value, false, end, false, encoding );
+ }
+ else
+ {
+ // All attribute values should be in single or double quotes.
+ // But this is such a common error that the parser will try
+ // its best, even without them.
+ value = "";
+ while ( p && *p // existence
+ && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
+ && *p != '/' && *p != '>' ) // tag end
+ {
+ value += *p;
+ ++p;
+ }
+ }
+ return p;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
+{
+ while ( in->good() )
+ {
+ int c = in->peek();
+ if ( c == '<' )
+ return;
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+
+ (*tag) += (char) c;
+ in->get
+ ();
+ }
+}
+#endif
+
+const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+ value = "";
+ // TiXmlParsingData data( p, prevData );
+ if ( data )
+ {
+ data->Stamp( p, encoding );
+ location = data->Cursor();
+ }
+ bool ignoreWhite = true;
+
+ const char* end = "<";
+ p = ReadText( p, &value, ignoreWhite, end, false, encoding );
+ if ( p )
+ return p-1; // don't truncate the '<'
+ return 0;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
+{
+ while ( in->good() )
+ {
+ int c = in->get
+ ();
+ if ( c <= 0 )
+ {
+ TiXmlDocument* document = GetDocument();
+ if ( document )
+ document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+ return;
+ }
+ (*tag) += (char) c;
+
+ if ( c == '>' )
+ {
+ // All is well.
+ return;
+ }
+ }
+}
+#endif
+
+const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding )
+{
+ p = SkipWhiteSpace( p, _encoding );
+ // Find the beginning, find the end, and look for
+ // the stuff in-between.
+ TiXmlDocument* document = GetDocument();
+ if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) )
+ {
+ if ( document )
+ document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
+ return 0;
+ }
+ // TiXmlParsingData data( p, prevData );
+ if ( data )
+ {
+ data->Stamp( p, _encoding );
+ location = data->Cursor();
+ }
+ p += 5;
+
+ version = "";
+ encoding = "";
+ standalone = "";
+
+ while ( p && *p )
+ {
+ if ( *p == '>' )
+ {
+ ++p;
+ return p;
+ }
+
+ p = SkipWhiteSpace( p, _encoding );
+ if ( StringEqual( p, "version", true, _encoding ) )
+ {
+ TiXmlAttribute attrib;
+ p = attrib.Parse( p, data, _encoding );
+ version = attrib.Value();
+ }
+ else if ( StringEqual( p, "encoding", true, _encoding ) )
+ {
+ TiXmlAttribute attrib;
+ p = attrib.Parse( p, data, _encoding );
+ encoding = attrib.Value();
+ }
+ else if ( StringEqual( p, "standalone", true, _encoding ) )
+ {
+ TiXmlAttribute attrib;
+ p = attrib.Parse( p, data, _encoding );
+ standalone = attrib.Value();
+ }
+ else
+ {
+ // Read over whatever it is.
+ while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
+ ++p;
+ }
+ }
+ return 0;
+}
+
+bool TiXmlText::Blank() const
+{
+ for ( unsigned i=0; i<value.length(); i++ )
+ if ( !IsWhiteSpace( value[i] ) )
+ return false;
+ return true;
+}
+
diff --git a/src/data/README b/src/data/README
new file mode 100644
index 0000000..6a993bb
--- /dev/null
+++ b/src/data/README
@@ -0,0 +1,4 @@
+ - ./data.*
+ The database wrapper
+
+
diff --git a/src/data/con.cpp b/src/data/con.cpp
new file mode 100644
index 0000000..e6943fe
--- /dev/null
+++ b/src/data/con.cpp
@@ -0,0 +1,68 @@
+/*:*
+ *: File: ./src/data/con.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "con.h"
+
+using namespace std;
+
+#ifdef DATABASE
+#ifndef CON_CPP
+#define CON_CPP
+
+con::con()
+{
+ p_mysql = mysql_init(NULL);
+
+ while ( !p_mysql )
+ {
+ wrap::system_message( MYSQLE1 );
+ usleep( 30000000 );
+ mysql_init(p_mysql);
+ }
+
+ while ( mysql_real_connect(
+ p_mysql,
+ (const char*)wrap::CONF->get_elem("chat.database.serverhost").c_str(),
+ (const char*)wrap::CONF->get_elem("chat.database.user").c_str(),
+ (const char*)wrap::CONF->get_elem("chat.database.password").c_str(),
+ (const char*)wrap::CONF->get_elem("chat.database.dbname").c_str(),
+ tool::string2int(wrap::CONF->get_elem("chat.database.port")),
+ NULL, 0 ) == NULL )
+ {
+ wrap::system_message( MYSQLQU + string( mysql_error(p_mysql) ) );
+ usleep( 30000000 );
+ }
+}
+
+con::~con()
+{
+ if ( p_mysql )
+ {
+ if (mysql_ping( p_mysql ) != 0)
+ mysql_close( p_mysql );
+ }
+}
+
+#endif
+#endif
diff --git a/src/data/con.h b/src/data/con.h
new file mode 100644
index 0000000..298249d
--- /dev/null
+++ b/src/data/con.h
@@ -0,0 +1,46 @@
+/*:*
+ *: File: ./src/data/con.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+#ifdef DATABASE
+
+#ifndef CON_H
+#define CON_H
+
+#include <mysql/mysql.h>
+#include <iostream>
+#include "con_base.h"
+
+using namespace std;
+
+class con : public con_base
+{
+public:
+ MYSQL* p_mysql;
+ con( );
+ ~con( );
+};
+
+#endif
+#endif
diff --git a/src/data/con_base.cpp b/src/data/con_base.cpp
new file mode 100644
index 0000000..7e89577
--- /dev/null
+++ b/src/data/con_base.cpp
@@ -0,0 +1,43 @@
+/*:*
+ *: File: ./src/data/con_base.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "con_base.h"
+
+#ifdef DATABASE
+#ifndef CON_BASE_CPP
+#define CON_BASE_CPP
+
+using namespace std;
+
+con_base::con_base()
+{
+ renew_timeout( );
+}
+
+con_base::~con_base()
+{}
+
+
+#endif
+#endif
diff --git a/src/data/con_base.h b/src/data/con_base.h
new file mode 100644
index 0000000..1b2853a
--- /dev/null
+++ b/src/data/con_base.h
@@ -0,0 +1,43 @@
+/*:*
+ *: File: ./src/data/con_base.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+#ifdef DATABASE
+
+#ifndef CON_BASE_H
+#define CON_BASE_H
+
+#include "../time/timo.h"
+
+using namespace std;
+
+class con_base : public timo
+{
+public:
+ con_base( );
+ ~con_base( );
+};
+
+#endif
+#endif
diff --git a/src/data/data.cpp b/src/data/data.cpp
new file mode 100644
index 0000000..c4bae2e
--- /dev/null
+++ b/src/data/data.cpp
@@ -0,0 +1,227 @@
+/*:*
+ *: File: ./src/data/data.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "data.h"
+
+#ifdef DATABASE
+#ifndef DATA_CPP
+#define DATA_CPP
+
+using namespace std;
+
+data::data()
+{}
+
+data::~data()
+{}
+
+hashmap<string>
+data::select_user_data( string s_user, string s_query)
+{
+ string s_where_rule = " WHERE nick = \"" + s_user + "\"";
+ vector<string> vec_elements;
+ MYSQL_RES* p_result = select_query( s_query, s_where_rule, vec_elements );
+ return parse_result( p_result, vec_elements );
+}
+
+MYSQL_RES*
+data::select_query( string s_query, string s_where_rule, vector<string>& vec_elements )
+{
+ con* p_con = get_con();
+
+ vec_elements = map_queries[s_query];
+ string s_mysql_query = "SELECT ";
+ vector<string>::iterator iter = vec_elements.begin();
+
+ string s_table = *iter;
+ iter++;
+
+ while ( iter != vec_elements.end() )
+ {
+ s_mysql_query.append( secure_query(*iter) );
+ if ( ++iter != vec_elements.end() )
+ s_mysql_query.append( ", " );
+ }
+
+ s_mysql_query.append(" FROM " + s_table + s_where_rule );
+ print_query( MYSQLQU + s_mysql_query );
+
+ MYSQL_RES* p_result = NULL;
+
+ if ( 0 == mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
+ {
+ p_result = mysql_store_result( p_con->p_mysql );
+ push_con( p_con );
+ }
+ else
+ {
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+ if (p_con != NULL)
+ delete p_con;
+ }
+
+ return p_result;
+}
+
+hashmap<string>
+data::parse_result( MYSQL_RES* p_result, vector<string>& vec_elements )
+{
+ hashmap<string> map_ret;
+ if ( p_result != NULL )
+ {
+ MYSQL_ROW row;
+ vector<string>::iterator vec_iter = vec_elements.begin();
+ vec_iter++;
+
+ while( (row = mysql_fetch_row(p_result)) )
+ for ( int i=0; i < mysql_num_fields(p_result); i++, vec_iter++ )
+ map_ret[*vec_iter] = string(row[i]);
+
+ mysql_free_result( p_result );
+ }
+ return map_ret;
+}
+
+void
+data::insert_user_data( string s_user, string s_query, map<string,string> insert_map )
+{
+ insert_query( s_query, insert_map );
+}
+
+void
+data::insert_query( string s_query, map<string,string> map_insert )
+{
+ vector<string> vec_elements = map_queries[s_query];
+ vector<string>::iterator iter = vec_elements.begin();
+
+ string s_table = *iter;
+ iter++;
+ string s_mysql_query = "INSERT INTO " + s_table + " (";
+
+ while ( iter != vec_elements.end() )
+ {
+ s_mysql_query.append( *iter );
+
+ if ( ++iter != vec_elements.end() )
+ s_mysql_query.append( ", " );
+ else
+ s_mysql_query.append( ") VALUES(" );
+ }
+
+ iter = vec_elements.begin();
+ iter++;
+
+ while ( iter != vec_elements.end() )
+ {
+ s_mysql_query.append( "\"" + secure_query(map_insert[*iter]) + "\"" );
+ if ( ++iter != vec_elements.end() )
+ s_mysql_query.append( ", " );
+ else
+ s_mysql_query.append( ")" );
+ }
+
+ print_query( MYSQLQU + s_mysql_query );
+
+ con* p_con = get_con();
+
+ if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+
+ push_con( p_con );
+
+ return;
+}
+
+void
+data::update_user_data( string s_user, string s_query, hashmap<string> update_map )
+{
+ vector<string> vec_elements = map_queries[s_query];
+
+ if ( vec_elements.size() == 0 )
+ return;
+
+ vector<string>::iterator iter = vec_elements.begin();
+ vector<string>::iterator iter_second = vec_elements.begin();
+ iter_second++;
+
+ string s_table = *iter;
+ iter++;
+ string s_mysql_query = "UPDATE " + s_table + " SET ";
+ bool b_flag = 0;
+
+ while ( iter != vec_elements.end() )
+ {
+ if ( update_map[*iter] == "" ) // Dont update data if it has not been changed / if its empty!
+ {
+ iter++;
+ continue;
+ }
+
+ if ( iter != iter_second && b_flag )
+ s_mysql_query.append( ", " );
+
+ s_mysql_query.append( *iter + "=\"" + secure_query(update_map[*iter]) + "\"" );
+ b_flag = 1;
+ iter++;
+ }
+
+ if ( b_flag )
+ {
+ s_mysql_query.append( " WHERE nick=\"" + tool::to_lower(s_user) + "\"" );
+
+ con* p_con = get_con();
+ print_query( MYSQLQU + s_mysql_query );
+
+ if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+
+ push_con( p_con );
+ }
+}
+
+string
+data::secure_query( string s_mysql_query )
+{
+ // Prevent from MySQL injection attacks (escaping " and \)
+ unsigned i_pos = s_mysql_query.find("\\");
+
+ while ( i_pos != string::npos )
+ {
+ s_mysql_query.replace( i_pos, 1, "/" );
+ i_pos = s_mysql_query.find("\\");
+ }
+
+ i_pos = s_mysql_query.find("\"");
+
+ while ( i_pos != string::npos )
+ {
+ s_mysql_query.replace( i_pos, 1, "'" );
+ i_pos = s_mysql_query.find("\"");
+ }
+
+ return s_mysql_query;
+}
+
+#endif
+#endif
diff --git a/src/data/data.h b/src/data/data.h
new file mode 100644
index 0000000..a452c86
--- /dev/null
+++ b/src/data/data.h
@@ -0,0 +1,53 @@
+/*:*
+ *: File: ./src/data/data.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+#ifdef DATABASE
+
+#ifndef DATA_H
+#define DATA_H
+
+#include "data_base.h"
+#include <mysql/mysql.h>
+
+using namespace std;
+
+class data : public data_base // data implementation used in data.h
+{
+private:
+ MYSQL_RES* select_query( string s_query, string s_where_rule, vector<string>& vec_elements );
+ hashmap<string> parse_result( MYSQL_RES* p_result, vector<string>& vec_elements );
+ void insert_query( string s_query, map<string,string> map_insert );
+ string secure_query( string s_mysql_query );
+public:
+ data( );
+ ~data( );
+
+ hashmap<string> select_user_data( string s_user, string s_query );
+ void insert_user_data( string s_user, string s_query, map<string,string> insert_map );
+ void update_user_data( string s_user, string s_query, hashmap<string> update_map );
+};
+
+#endif
+#endif
diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp
new file mode 100644
index 0000000..b8e79b4
--- /dev/null
+++ b/src/data/data_base.cpp
@@ -0,0 +1,251 @@
+/*:*
+ *: File: ./src/data/data_base.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "data_base.h"
+
+#ifdef DATABASE
+#ifndef DATA_BASE_CPP
+#define DATA_BASE_CPP
+
+using namespace std;
+
+data_base::data_base( )
+{
+ pthread_mutex_init ( &mut_con, NULL );
+
+ vector<string> vec_keys = *wrap::CONF->get_key_vector();
+ vector<string>::iterator iter;
+
+ // Reads all DATA_ elements of conf.txt!
+ for ( iter = vec_keys.begin(); iter != vec_keys.end(); iter++ )
+ {
+ if ( iter->length() > 20
+ && iter->compare(0, 19, "chat.database.mysql") == 0
+ && iter->find(".descr") == string::npos )
+ {
+ vector<string> vec_tokens;
+ string s_element = wrap::CONF->get_elem(*iter);
+ unsigned i_pos = 0;
+
+ for ( bool b_find = 1; b_find; )
+ {
+ i_pos = s_element.find_first_of( " ", 0 );
+
+ if ( i_pos != string::npos )
+ {
+ vec_tokens.push_back( s_element.substr(0, i_pos) );
+ s_element = s_element.substr( i_pos+1 );
+ }
+ else
+ {
+ vec_tokens.push_back( s_element );
+ b_find = 0;
+ }
+ }
+
+ string s_mysqlquery = iter->substr(20);
+ wrap::system_message(MYSQLQ2 + s_mysqlquery);
+ map_queries[s_mysqlquery] = vec_tokens;
+ }
+ }
+}
+
+void data_base::init_connections()
+{
+ int i_min_con = tool::string2int( wrap::CONF->get_elem("chat.database.mincon") ),
+ i_max_con = tool::string2int( wrap::CONF->get_elem("chat.database.maxcon") );
+
+ wrap::system_message(DATAIN0 + tool::int2string(i_max_con));
+ wrap::system_message(DATAIN1 + tool::int2string(i_min_con));
+
+ for ( int i = 0; i < i_min_con && i < i_max_con; i++ )
+ push_back( new con() );
+
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
+}
+
+data_base::~data_base()
+{
+ pthread_mutex_destroy ( &mut_con );
+}
+
+hashmap<string>
+data_base::select_user_data( string s_user, string s_query)
+{
+ print_query( DATAQUE + s_query );
+ hashmap<string> map_ret;
+ return map_ret;
+}
+
+void
+data_base::insert_user_data( string s_user, string s_query, hashmap<string> insert_map )
+{
+ print_query( DATAQUE + s_query );
+}
+
+
+void
+data_base::update_user_data( string s_user, string s_query, hashmap<string> update_map )
+{
+ print_query( DATAQUE + s_query );
+}
+
+void
+data_base::print_query( string s_query )
+{
+#ifdef DATA_PRINT_QUERIES
+ print_query_( s_query );
+#endif
+}
+
+#ifdef DATA_PRINT_QUERIES
+void
+data_base::print_query_( string s_query )
+{
+ wrap::system_message( s_query );
+}
+#endif
+
+con*
+data_base::get_con()
+{
+ pthread_mutex_lock( &mut_con );
+
+ if ( empty() )
+ {
+ wrap::system_message( DATANEW + string("(") + tool::int2string(size()+1) + ")" );
+ pthread_mutex_unlock( &mut_con );
+ return new con;
+ }
+ else if ( size() > i_max_con-1 )
+ {
+ wrap::system_message( DATAMAX + string("(") + tool::int2string(i_max_con) + ")" );
+ usleep( 5000000 );
+ pthread_mutex_unlock( &mut_con );
+ return get_con();
+ }
+
+
+ con* p_con = *begin();
+ pop_front();
+
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
+
+ pthread_mutex_unlock( &mut_con );
+ wrap::system_message( DATAGET );
+
+ p_con->renew_timeout();
+ return p_con;
+}
+
+void
+data_base::push_con( con* p_con )
+{
+ pthread_mutex_lock( &mut_con );
+ push_front( p_con );
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
+
+ pthread_mutex_unlock( &mut_con );
+ wrap::system_message( DATAADD );
+}
+
+#ifdef NCURSES
+void
+data_base::print_queue_size()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_CON_QUEUE_X,NCUR_CON_QUEUE_Y, "Con. queue: %d ", size());
+ refresh();
+ }
+}
+#endif
+
+void
+data_base::disconnect_all_connections()
+{
+ wrap::system_message( DATADIS );
+ pthread_mutex_lock( &mut_con );
+
+ while ( !empty() )
+ {
+ con* p_con = *begin();
+ pop_front();
+ delete p_con;
+ }
+
+ pthread_mutex_unlock( &mut_con );
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
+}
+
+void
+data_base::check_data_con_timeout()
+{
+ int i_timeout_time = tool::string2int(wrap::CONF->get_elem("chat.database.contimeout"));
+ int i_last_activity;
+
+ pthread_mutex_lock( &mut_con );
+
+ list< list<con*>::iterator > erase_list;
+ for ( list<con*>::iterator iter = begin();
+ iter != end(); iter++ )
+ {
+ i_last_activity = (int) (*iter)->get_last_activity();
+ if ( i_timeout_time <= i_last_activity )
+ {
+ con* p_con = *iter;
+ erase_list.push_back(iter);
+ delete p_con;
+ wrap::system_message(DATADI2 + tool::int2string(size()-erase_list.size()+1) + ","
+ + tool::int2string(i_timeout_time) + ","
+ + tool::int2string(i_last_activity) + ")");
+ }
+ }
+ for ( list< list<con*>::iterator >::iterator erase_iter = erase_list.begin();
+ erase_iter != erase_list.end(); erase_iter++ )
+ erase( *erase_iter );
+
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
+
+ pthread_mutex_unlock( &mut_con );
+}
+
+
+#endif
+#endif
diff --git a/src/data/data_base.h b/src/data/data_base.h
new file mode 100644
index 0000000..8aece61
--- /dev/null
+++ b/src/data/data_base.h
@@ -0,0 +1,72 @@
+/*:*
+ *: File: ./src/data/data_base.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+#ifdef DATABASE
+
+#ifndef DATA_BASE_H
+#define DATA_BASE_H
+
+#include <vector>
+#include <list>
+#include "con.h"
+
+using namespace std;
+
+class data_base : protected list<con*>
+{
+private:
+ pthread_mutex_t mut_con;
+ int i_max_con;
+
+#ifdef NCURSES
+
+ void print_queue_size();
+#endif
+
+protected:
+ hashmap< vector<string> > map_queries;
+ void print_query( string s_query );
+#ifdef DATA_PRINT_QUERIES
+
+ virtual void print_query_( string s_query );
+#endif
+
+ con* get_con();
+ void push_con( con* p_con );
+
+public:
+ data_base();
+ ~data_base();
+
+ void init_connections();
+ virtual hashmap<string> select_user_data( string s_user, string s_query );
+ virtual void insert_user_data( string s_user, string s_query, hashmap<string> insert_map );
+ virtual void update_user_data( string s_user, string s_query, hashmap<string> update_map );
+ void disconnect_all_connections();
+ void check_data_con_timeout();
+};
+
+#endif
+#endif
diff --git a/src/glob.h b/src/glob.h
index 62cf5f4..66cada0 100644
--- a/src/glob.h
+++ b/src/glob.h
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/glob.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,38 +22,199 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// global variables.
+/*
+ Notice:
+
+ All #defines which start with an CONFIG can be edited through
+ gmake config in the main directory!
+*/
+
+#include "maps/hashmap.h"
+// global variables.
#ifndef GLOB_H
#define GLOB_H
-#include <map>
-#include <pthread.h>
-
-// definition of boolean values.
+// Definition of boolean values.
#define true 1
#define false 0
-// config filename.
-#define CONFILE "conf.txt"
+//<<*
+/* FIRST THE YCHAT ONLY OPTIONS */
+
+/* - CONFIG -
+ Should yChat get compiled with database support? Currently MyS-
+ QL only is a supported database.
+*/
+//#define DATABASE
+
+#ifdef DATABASE
+#define USE_MYSQL
+/* - CONFIG -
+ Should all database queries printed out at the admin interface?
+ (This option wont take action if database support has not been
+ chosen)
+*/
+#define DATA_PRINT_QUERIES
+#endif
-// the highest port which is allowed to use. if ychat is unable to create the server
-// socket it will increment the port number and tries to create another socket.
-// this procedure will go on until MAXPORT is reached.
+/* - CONFIG -
+ Defines the amount of newlines which have to be sent to the clie-
+ nt's chat stream after the first log-in. It prevents a white scr-
+ een because of browser buffers or proxies.
+*/
+#define PUSHSTR 500
+
+/* AFTERWARDS THE YCHAT AND YHTTPD OPTIONS */
+//*>>
+
+/* - CONFIG -
+ Should yChat get compiled with comand line interface support?
+*/
+#define CLI
+
+/* - CONFIG -
+ What should be the name of the config file?
+*/
+#define CONFILE "ychat.conf"
+
+/* - DISABLED -
+ Enable debugging options.
+*/
+//#define DEBUG
+
+/* - DISABLED -
+ If you want to enable EXPERIMENTAL features, then set this val-
+ ue to true. Else use false which is recommended! All experimen-
+ al features are marked inside of the running yChat!
+*/
+//#define EXPERIM
+
+/* - CONFIG -
+ Should yChat get compiled with logging support?
+*/
+#define LOGGING
+
+/* - CONFIG -
+ Please enter the highest networking port which is allowed to be
+ used. If yChat is unable to create the server socket on a cert-
+ ain port, it will increment the port number and retries to cre-
+ ate another socket on the incremented port number. This proced-
+ ure will continue until MAXPORT has been reached.
+*/
#define MAXPORT 65535
-// max length of a line read from a socket or a file ( config-file, html-template ).
-#define READBUF 1024
-
-// 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
-
-// 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
+/* Specifies the max amount of lines to read from a HTTP request
+ header
+*/
+#define MAXLINES 30
+
+/* Specifies the max length of a lines to read from a HTTP request
+ header
+*/
+#define MAXLENGTH 1024
+
+/* - CONFIG -
+ Should yChat get compiled with ncurses support?
+*/
+#define NCURSES
+
+/* - CONFIG -
+ Please specify the maximum length of a HTTP post request.
+*/
+#define POSTBUF 512
+
+/* - CONFIG -
+ Please specify the size of a temporary buffer. (Will be used f-
+ or different tasks)
+*/
+#define READBUF 2048
+
+/* - CONFIG -
+ Please specify the maximum length of a line read from a socket
+ or a file. ( config-file, html-template )
+*/
+#define READSOCK 2048
+
+/* - CONFIG -
+ In which prefix should yChat be installed if typing gmake inst-
+ all?
+*/
+#define PREFIX "/usr/local"
+
+/* - CONFIG -
+ DO NOT USE TOGETHER WITH NCURSES! Displays important server mes-
+ ages. This one will print all messages to stdout if no NCURSES
+ is defined. Don't use this until NCURSES is defined! all messag-
+ es will appear in the ncurses interface anyways.
+*/
+//#define SERVMSG
+
+/* - CONFIG -
+ Set to true if you want yChat to catch the SIGSEGV signal. yChat
+ will print a warning message into the system messages and will
+ not core dump if an error occurs.
+*/
+//#define CTCSEGV
+
+/* - CONFIG -
+ Please chose if you want to use verbose server outputs or not.
+ The verbose messages will appear in the ncurses menu if ncurses
+ is enabled or in the server-window if yChat has been compiled
+ without ncurses support. This option shows you all incoming
+ requests with the client IP and port numbers. You probably want
+ this to be turned off if you have heavy server load.
+*/
+//#define VERBOSE
+
+
+
+
+// The following values define the positions of the data stats in the NCURSES interface.
+#ifdef NCURSES
+#define NCUR_SERVER_HEADER_X 21
+#define NCUR_SERVER_HEADER_Y 2
+#define NCUR_PORT_X 22
+#define NCUR_PORT_Y 2
+#define NCUR_HITS_X 23
+#define NCUR_HITS_Y 2
+
+#define NCUR_POOL_HEADER_X 21
+#define NCUR_POOL_HEADER_Y 16
+#define NCUR_POOL_WAIT_X 22
+#define NCUR_POOL_WAIT_Y 16
+#define NCUR_POOL_RUNNING_X 23
+#define NCUR_POOL_RUNNING_Y 16
+
+#define NCUR_DATA_HEADER_X 21
+#define NCUR_DATA_HEADER_Y 35
+#define NCUR_GARBAGE_X 22
+#define NCUR_GARBAGE_Y 35
+#define NCUR_CON_QUEUE_X 23
+#define NCUR_CON_QUEUE_Y 35
+
+#define NCUR_CHAT_HEADER_X 21
+#define NCUR_CHAT_HEADER_Y 52
+#define NCUR_NUM_ROOMS_X 22
+#define NCUR_NUM_ROOMS_Y 52
+#define NCUR_SESSION_X 23
+#define NCUR_SESSION_Y 52
+
+#define NCUR_CACHED_HEADER_X 21
+#define NCUR_CACHED_HEADER_Y 68
+#define NCUR_CACHED_DOCS_X 22
+#define NCUR_CACHED_DOCS_Y 68
+#define NCUR_CACHED_MODS_X 23
+#define NCUR_CACHED_MODS_Y 68
+
+#define NCUR_MENU_CHAR_X 0
+#define NCUR_MENU_CHAR_Y 33
+#define NCUR_UPTIME_X 0
+#define NCUR_UPTIME_Y 44
+#define NCUR_TIME_X 0
+#define NCUR_TIME_Y 64
+#endif
//////////////////////////////////////////////////////////////////////////////////////////
// DO NOT CHANGE ANYTHING BEHIND THIS LINE!
@@ -60,32 +222,24 @@
using namespace std;
-// internal rang descriptors ( their external names may be specified different )
-enum rang
-{
- CODER , // programmer.
- ADMIN , // administrator.
- MAGIC , // super user with special privileges.
- SUPER , // temporary super user.
- BASIC , // normal user without special privileges.
- GUEST , // guest user, has almost no privileges.
- RESTR , // a very restrivted user.
- OUTBN // banned out of the system.
-};
-
-// 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];
+ void* elem[4];
};
struct dynmod
{
- function *the_func ;
- void *the_module;
+ function *the_func ;
+ void *the_module;
};
+typedef enum method_ {
+ METH_NCURSES,
+ METH_RETSTRING
+} method;
+
+// Define external executables:
+#define GMAKE "/usr/local/bin/gmake \0"
#endif
diff --git a/src/html.cpp b/src/html.cpp
index 34ea91a..52225b0 100644
--- a/src/html.cpp
+++ b/src/html.cpp
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/html.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,150 +22,152 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// class html implementation.
-
-#ifndef s_html_CXX
-#define s_html_CXX
+#ifndef HTML_CPP
+#define HTML_CPP
#include <fstream>
#include "html.h"
-#include "s_chat.h"
-#include "s_mutx.h"
using namespace std;
html::html( )
{
- set_name( s_conf::get
- ().get_val( "HTMLTEMP" ) );
- pthread_mutex_init( &mut_map_vals, NULL );
+ set_name( wrap::CONF->get_elem( "httpd.templatedir" ) );
}
html::~html( )
-{
- pthread_mutex_destroy( &mut_map_vals );
-}
+{}
void
html::clear_cache( )
{
- pthread_mutex_lock ( &mut_map_vals );
- clear_vals();
- pthread_mutex_unlock( &mut_map_vals );
+ clear();
+ wrap::system_message( CLRHTML );
+
+#ifdef NCURSES
+
+ print_cached( 0 );
+#endif
}
string
-html::parse( map_string &map_params )
+html::parse( map<string,string> &map_params )
{
- string s_file = map_params["request"];
+ string s_file = map_params["request"];
- // check if s_file is in the container.
- pthread_mutex_lock ( &mut_map_vals );
- string s_templ = get_val( s_file );
- pthread_mutex_unlock( &mut_map_vals );
+ // check if s_file is in the container.
+ string s_templ;
- // if not, read file.
- if ( s_templ.empty() )
- {
- auto string s_path = get_name();
- auto ifstream fs_templ( s_path.append( s_file ).c_str(), ios::binary );
+ // if not, read file.
+ if ( ! shashmap<string>::exists( s_file ) )
+ {
+ string s_path = get_name();
+ ifstream if_templ( s_path.append( s_file ).c_str(), ios::binary );
- if ( ! fs_templ )
- {
+ if ( ! if_templ )
+ {
+ wrap::system_message( OFFFOUND + s_path );
+ if(map_params["request"] == wrap::CONF->get_elem( "httpd.html.notfound" ))
+ return "";
- cerr << "File not found: " << s_file << endl;
- if(map_params["request"]==s_conf::get
- ().get_val( "NOTFOUND" ))
- return "";
+ map_params["request"] = wrap::CONF->get_elem( "httpd.html.notfound" );
+ return parse( map_params );
+ }
- map_params["request"] = s_conf::get
- ().get_val( "NOTFOUND" );
- return parse( map_params );
+ char c_buf;
+ while( !if_templ.eof() )
+ {
+ if_templ.get( c_buf );
+ s_templ += c_buf;
+ }
- }
+ if ( map_params["content-type"].compare(0,5,"text/") == 0 )
+ s_templ.erase(s_templ.end()-1);
- auto char c_buf;
- while( !fs_templ.eof() )
- {
- fs_templ.get( c_buf );
- s_templ+=c_buf;
- }
+ if_templ.close();
- fs_templ.close();
+ wrap::system_message( TECACHE + s_path );
-#ifdef VERBOSE
+ // cache file.
+ shashmap<string>::add_elem(s_templ, s_file);
+#ifdef NCURSES
- pthread_mutex_lock ( &s_mutx::get
- ().mut_stdout );
- cout << TECACHE << s_path << endl;
- pthread_mutex_unlock( &s_mutx::get
- ().mut_stdout );
+ print_cached( shashmap<string>::size() );
#endif
- // cache file.
- pthread_mutex_lock ( &mut_map_vals );
- map_vals[ s_file ] = s_templ;
- pthread_mutex_unlock( &mut_map_vals );
- }
+ }
+ else
+ {
+ s_templ = shashmap<string>::get_elem( s_file );
+ }
- // find %%KEY%% token and substituate those.
- auto unsigned int pos[2];
- pos[0] = pos[1] = 0;
+ // find %%KEY%% token and substituate those.
+ unsigned pos[2];
+ pos[0] = pos[1] = 0;
- do
- {
- pos[0] = s_templ.find( "%%", pos[1] );
+ for(;;)
+ {
+ pos[0] = s_templ.find( "%%", pos[1] );
- if ( pos[0] == string::npos )
- break;
+ if ( pos[0] == string::npos )
+ break;
- pos[0] += 2;
- pos[1] = s_templ.find( "%%", pos[0] );
+ pos[0] += 2;
+ pos[1] = s_templ.find( "%%", pos[0] );
- if ( pos[0] == string::npos )
- break;
+ if ( pos[0] == string::npos )
+ break;
- // get key and val.
- auto string s_key = s_templ.substr( pos[0], pos[1]-pos[0] );
- auto string s_val = s_conf::get
- ().get_val( s_key );
+ // get key and val.
+ string s_key = s_templ.substr( pos[0], pos[1]-pos[0] );
+ string s_val = wrap::CONF->get_elem( s_key );
- // if s_val is empty use map_params.
- if ( s_val.empty() )
- s_val = map_params[ s_key ];
+ // if s_val is empty use map_params.
+ if ( s_val.empty() )
+ s_val = map_params[ s_key ];
- // substituate key with val.
- s_templ.replace( pos[0]-2, pos[1]-pos[0]+4, s_val );
+ // substituate key with val.
+ s_templ.replace( pos[0]-2, pos[1]-pos[0]+4, s_val );
- // calculate the string displacement.
- auto int i_dif = s_val.length() - ( pos[1] - pos[0] + 4);
+ // calculate the string displacement.
+ int i_diff = s_val.length() - ( pos[1] - pos[0] + 4);
- pos[1] += 2 + i_dif;
+ pos[1] += 2 + i_diff;
- }
- while( true );
+ };
- return s_templ;
+ return s_templ;
}
+//<<*
void
-html::online_list( user *p_user, map_string &map_params )
+html::online_list( user *p_user, map<string,string> &map_params )
{
- // prepare user_list.
- string s_list ( "" );
- string s_seperator( "<br>" );
+ // prepare user_list.
+ string s_list;
+
+ room* p_room = p_user->get_room();
- p_user->get_p_room()->get_user_list( s_list, s_seperator );
+ p_room->get_user_list( s_list );
- // use the collected data as a message in html-templates.
- map_params["MESSAGE"] = s_list;
+ map_params["room"] = p_room->get_name();
+ map_params["topic"] = p_room->get_topic();
+ map_params["userlist"] = s_list;
+}
+//*>>
- // renew the timestamp.
- p_user->renew_stamp();
+#ifdef NCURSES
+void
+html::print_cached( int i_docs )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
- // send a ping to the client chat stream.
- p_user->msg_post( new string("\n") );
+ mvprintw( NCUR_CACHED_DOCS_X, NCUR_CACHED_DOCS_Y, "Docs: %d ", i_docs);
+ refresh();
}
#endif
+#endif
+
diff --git a/src/html.h b/src/html.h
index 79703e0..3f55ba8 100644
--- a/src/html.h
+++ b/src/html.h
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/html.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -22,44 +23,42 @@
*:*/
// class html declaration. this class manages the html-template files.
+#include "incl.h"
-#ifndef s_html_H
-#define s_html_H
+#ifndef HTML_H
+#define HTML_H
-#include "incl.h"
-#include "cont.h"
-#include "s_conf.h"
-#include "user.h"
+#include "maps/shashmap.h"
+#include "chat/user.h"
#include "name.h"
-
using namespace std;
-class html : public cont, name
+class html : public shashmap<string>, name
{
-private:
- // needed for synchronizing the map_vals.
- pthread_mutex_t mut_map_vals;
-
public:
- // public methods.
- explicit html( ); // simple constructor.
- ~html( );
+ html( );
+ ~html( );
- // clears the template cache so that new html templates will be read
- // from hard disk. this method is needed after changeing s.t. on
- // the html-template files.
- void clear_cache( );
+ // Clears the template cache so that new html templates will be read
+ // from hard disk. This method is needed after changeing s.t. on
+ // the html-template files.
+ void clear_cache( );
- // returns a parsed html-template. this method will check first if the
- // required html-template exists inside the classes template cache. if not
- // then the file will be read from file and added to the cache.
- // afterwards the html-template will be parsed and returned.
- // map_params contains the client request parameters which also will be
- // used for string substituation.
- virtual string parse( map_string &map_params );
+ // Returns a parsed html-template. this method will check first if the
+ // required html-template exists inside the classes template cache. if not
+ // then the file will be read from file and added to the cache.
+ // afterwards the html-template will be parsed and returned.
+ // map_params contains the client request parameters which also will be
+ // used for string substituation.
+ string parse( map<string,string> &map_params );
+
+ void online_list( user *p_user, map<string,string> &map_params ); //<<
+#ifdef NCURSES
+
+ void print_cached( int i_docs );
+#endif
- virtual void online_list( user *p_user, map_string &map_params );
};
#endif
diff --git a/src/incl.h b/src/incl.h
index ef9eebd..dc6c363 100644
--- a/src/incl.h
+++ b/src/incl.h
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/incl.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,19 +22,16 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// contains header files which are included by all classes.
-
-// include some std headers.
-#include <iostream>
-
-// since thread synchronization is a big issue this header needs
-// to be included by every other file too.
#include <pthread.h>
-
-// std::string.
+#include <iostream>
#include <string>
+#include <map>
-// include all the custom global variables.
#include "glob.h"
-// include all the custom messages.
+
+#ifdef NCURSES
+#include <ncurses.h>
+#endif
+
#include "msgs.h"
+#include "wrap.h"
diff --git a/src/logd.cpp b/src/logd.cpp
new file mode 100644
index 0000000..8ab6891
--- /dev/null
+++ b/src/logd.cpp
@@ -0,0 +1,199 @@
+/*:*
+ *: File: ./src/logd.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+
+#ifndef LOGD_CPP
+#define LOGD_CPP
+
+#include "logd.h"
+
+#ifdef LOGGING
+
+#include <fstream>
+
+logd::logd( string s_filename, string s_log_lines )
+{
+ initialize( s_filename, tool::string2int(s_log_lines) );
+}
+
+logd::logd( string s_filename, int i_log_lines )
+{
+ initialize( s_filename, i_log_lines );
+}
+
+logd::~logd()
+{
+ flush_logs();
+ pthread_mutex_destroy( &mut_s_logging );
+}
+
+void
+logd::initialize( string s_filename, int i_log_lines )
+{
+ pthread_mutex_init( &mut_s_logging, NULL );
+
+ if( s_filename.empty() )
+ {
+ wrap::system_message( LOGERR2 );
+ exit(1);
+ }
+
+ //if (wrap::NCUR->is_ready())
+ // wrap::system_message(LOGGINI+s_filename);
+
+ s_logfile = s_filename;
+ i_lines = i_log_lines;
+}
+
+string
+logd::get_time_string()
+{
+ struct tm *t_m;
+ time_t t_cur = time(NULL);
+ t_m = gmtime(&t_cur);
+
+ char c_buf[100];
+ c_buf[99] = '\0';
+ strftime(c_buf, 100, "[%d/%b/%Y:%H:%M:%S %z]", t_m);
+
+ return string(c_buf);
+}
+
+void
+logd::flush()
+{
+ ofstream of_output;
+ of_output.open(s_logfile.c_str(), ios::app);
+
+ if( of_output == NULL )
+ {
+ wrap::system_message( LOGERR1 + s_logfile );
+ exit(1);
+ }
+
+ while( ! s_queue.empty() )
+ {
+ string s_l=s_queue.front();
+ s_queue.pop();
+ of_output.write( s_l.c_str(), s_l.size() );
+ }
+
+ of_output.close();
+}
+
+void
+logd::log_access( map<string,string> &map_request )
+{
+ //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.accesslines");
+
+ string s_time = get_time_string();
+ string s_logstr = map_request["REMOTE_ADDR"] + " - - "+s_time+" \"" + map_request["QUERY_STRING"]+"\" 200 0 \""+map_request["request"]+"\" \""+map_request["User-Agent"]+"\"\n";
+
+ pthread_mutex_lock ( &mut_s_logging );
+ s_queue.push(s_logstr);
+
+ if ( s_queue.size() > i_lines )
+ flush();
+
+ pthread_mutex_unlock( &mut_s_logging );
+}
+
+void
+logd::log_simple_line( string s_line )
+{
+ // Dont log empty lines!
+ if (s_line.empty())
+ return;
+
+ string s_time = get_time_string();
+ string s_logstr = s_time + " " + s_line;
+
+ pthread_mutex_lock ( &mut_s_logging );
+ s_queue.push(s_logstr);
+
+ if ( s_queue.size() > i_lines )
+ flush();
+
+ pthread_mutex_unlock( &mut_s_logging );
+}
+
+void
+logd::set_logfile( string s_path, string s_filename )
+{
+ // Remove "/" from filename!
+ unsigned i_pos = s_filename.find( "/" );
+ while ( i_pos != string::npos )
+ {
+ s_filename.replace( i_pos, 1, "SLASH" );
+ i_pos = s_filename.find( "/" );
+ }
+
+ // Remove "\" from filename (for non unix systems)!
+ i_pos = s_filename.find( "\\" );
+ while ( i_pos != string::npos )
+ {
+ s_filename.replace( i_pos, 1, "BACKSLASH" );
+ i_pos = s_filename.find( "\\" );
+ }
+
+ pthread_mutex_lock ( &mut_s_logging );
+ this->s_logfile = s_path + s_filename;
+ pthread_mutex_unlock( &mut_s_logging );
+}
+
+void
+logd::flush_logs()
+{
+ pthread_mutex_lock ( &mut_s_logging );
+ flush();
+ pthread_mutex_unlock( &mut_s_logging );
+}
+
+string
+logd::remove_html_tags( string s_logs )
+{
+ unsigned pos[2];
+
+ while ( (pos[0] = s_logs.find("<")) != string::npos )
+ {
+ if ( (pos[1] = s_logs.find(">", pos[0])) != string::npos )
+ s_logs.replace( pos[0], pos[1]-pos[0]+1, "");
+ else
+ break;
+ }
+
+ if ( s_logs == "\n" )
+ return "";
+
+ return s_logs;
+}
+
+void
+logd::set_lines( const int i_lines )
+{
+ this->i_lines = i_lines;
+}
+
+#endif
+#endif
diff --git a/src/logd.h b/src/logd.h
new file mode 100644
index 0000000..8c7dff8
--- /dev/null
+++ b/src/logd.h
@@ -0,0 +1,61 @@
+/*:*
+ *: File: ./src/logd.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "incl.h"
+
+#ifdef LOGGING
+#ifndef LOGD_H
+#define LOGD_H
+
+#include <queue>
+#include <time.h>
+
+class logd
+{
+private:
+ string s_logfile;
+ queue<string> s_queue;
+ pthread_mutex_t mut_s_logging;
+ int i_lines;
+
+ void initialize( string s_filename, int i_log_lines );
+ void flush();
+ void set_lines( const int i_lines );
+ string get_time_string();
+
+public:
+ logd( string s_filename, string s_log_lines );
+ logd( string s_filename, int i_log_lines );
+ ~logd();
+
+ void set_logfile( string s_path, string s_filename );
+ void log_access( map<string,string> &map_request );
+ void log_simple_line( string s_line );
+ void flush_logs();
+ static string remove_html_tags( string s_log );
+};
+
+#endif
+#endif
+
diff --git a/src/main.cpp b/src/main.cpp
index 873f07d..7705313 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/main.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,81 +22,86 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// needed for ignoring SIGPIPE.
-#include <signal.h>
-
-// include header files which are included from every class too.
#include "incl.h"
+#include "sign.h"
-// include the chat manager.
-#include "s_chat.h"
-
-// include the config manager.
-#include "s_conf.h"
-
-// include the html-template manager.
-#include "s_html.h"
-
-// include the mutex manager for global synchronization.
-#include "s_mutx.h"
-
-// include the socket manager.
-#include "s_sock.h"
-
-// include the language manager
-#include "s_lang.h"
-
-// include the session manager
-#include "s_sman.h"
+#include "maps/hashmap.h"
using namespace std;
-int main()
+map<string,string>*
+parse_argc( int argc, char* argv[] )
{
-#ifdef VERBOSE
-
- cout << " ___ _ _ " << endl
- << " _ _ / __\\ |__ __ _| |_ " << endl
- << "| | | |/ / | '_ \\ / _` | __|" << endl
- << "| |_| / /___| | | | (_| | |_ " << endl
- << " \\__, \\____/|_| |_|\\__,_|\\__|" << endl
- << " |___/ " << endl << endl
-
- << DESCRIP << endl
- << DESCRI2 << endl
- << DESCRI3 << endl
- << DESCRI4 << endl
- << VERSION << endl
- << CONTACT << endl
- << SEPERAT << endl
- << STARTMS << endl ;
-#endif
+ map<string,string>* start_params = new map<string,string>;
+
+ string s_output = "";
+
+ // Set to 1 if a config option key has to be read
+ // ( ./ychat -o key1 value1 -o key2 value2 ... );
+ bool b_conf = 0;
+
+ // Will store the key of an additional option value (see also b_conf)
+ string s_key;
+
+ for (int i=1; argv[i] != 0; i++)
+ {
+ if ( !s_key.empty() )
+ {
+ (*start_params)[s_key] = string(argv[i]);
+ s_key.clear();
+ }
+ else if ( b_conf )
+ {
+ s_key = string(argv[i]);
+ b_conf = 0;
+ }
+ else
+ {
+ if ( string(argv[i]).find("v") != string::npos )
+ s_output.append(tool::ychat_version()+"\n");
+
+ if ( string(argv[i]).find("h") != string::npos )
+ s_output.append( YCUSAGE );
+
+ if ( string(argv[i]).find("o") != string::npos )
+ b_conf = 1;
+ }
+ }
+
+ if ( !s_output.empty() )
+ {
+ cout << s_output;
+ delete start_params;
+ exit(1);
+ }
+
+ return start_params;
+}
- // ignore SIGPIPE. otherwise the server will shut down with "Broken pipe" if
- // a client unexpected disconnects himself from a SOCK_STREAM.
- signal( SIGPIPE, SIG_IGN );
-
- // all the static data classes have to be initialized once. otherwise they will
- // contain only empty pointers and the chat server won't work correctly.
- // the order of the initializations is very importand. for example the s_html::init()
- // invokations assumes an initialized 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_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.
- s_sock::get
- ().start();
-
-#ifdef VERBOSE
-
- cout << DOWNMSG << endl;
+int
+main(int argc, char* argv[])
+{
+ cout << tool::ychat_version() << endl
+ << DESCRIP << endl
+ << DESCRI2 << endl
+ << CONTACT << endl
+ << SEPERAT << endl;
+
+ wrap::init_wrapper(parse_argc(argc, argv));
+
+ //<<*
+ // Initialize database connection queue
+#ifdef DATABASE
+ wrap::DATA->init_connections();
#endif
+ //*>>
+
+ sign::init_signal_handlers();
+
+ // 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.
+ wrap::SOCK->start();
- return 0;
+ cout << DOWNMSG << endl;
+ return 0;
}
diff --git a/src/maps/hashmap.h b/src/maps/hashmap.h
new file mode 100644
index 0000000..771c190
--- /dev/null
+++ b/src/maps/hashmap.h
@@ -0,0 +1,77 @@
+/*:*
+ *: File: ./src/maps/hashmap.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef HASHMAP_H
+#define HASHMAP_H
+
+#include <ext/hash_map>
+
+using namespace std;
+
+template<class key_type_>
+struct compare_allocator
+{
+ inline bool operator()(key_type_ t_key_1, key_type_ t_key_2) const;
+};
+
+template<class key_type_>
+struct equals_allocator
+{
+ inline bool operator()(key_type_ t_key_1, key_type_ t_key_2) const;
+};
+
+template<class key_type_>
+struct size_hash
+{
+ inline int operator()(key_type_ t_key) const;
+};
+
+template<class key_type_>
+struct self_hash
+{
+ inline int operator()(key_type_ t_key) const;
+};
+
+template
+<
+ class obj_type,
+ class key_type_ = string,
+ class hash_type = size_hash<string>,
+ class alloc_type = compare_allocator<string>
+>
+struct hashmap : public __gnu_cxx::hash_map<key_type_, obj_type, hash_type, alloc_type>
+{
+ virtual inline void set_elem(obj_type t_obj, key_type_ t_key);
+ virtual inline obj_type get_elem(key_type_ t_key);
+ virtual inline obj_type get_set_elem(obj_type t_obj, key_type_ t_key);
+ virtual inline obj_type get_or_callback_set
+ (obj_type (*func)(void*), void* p_void, key_type_ t_key);
+ virtual inline vector<key_type_>* get_key_vector();
+ virtual inline bool exists(key_type_ t_key);
+ virtual inline void run_func( void (*func)(obj_type) );
+ virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg );
+};
+
+#include "hashmap.tmpl"
+#endif
diff --git a/src/maps/hashmap.tmpl b/src/maps/hashmap.tmpl
new file mode 100644
index 0000000..ea1ee41
--- /dev/null
+++ b/src/maps/hashmap.tmpl
@@ -0,0 +1,150 @@
+/*:*
+ *: File: ./src/maps/hashmap.tmpl
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+template<class key_type_>
+bool
+compare_allocator<key_type_>::operator()(key_type_ t_key_1, key_type_ t_key_2) const
+{
+ return t_key_1.compare(t_key_2) == 0;
+}
+
+template<class key_type_>
+bool
+equals_allocator<key_type_>::operator()(key_type_ t_key_1, key_type_ t_key_2) const
+{
+ return t_key_1 == t_key_2;
+}
+
+template<class key_type_>
+int
+size_hash<key_type_>::operator()(key_type_ t_key) const
+{
+ int i_hash = 0;
+ int i_size = t_key.size();
+
+ for( size_t i = 0; i < i_size; ++i )
+ i_hash = ( i_hash << 5 ) ^ t_key.at(i) ^ i_hash;
+
+ return i_hash;
+}
+
+template<class key_type_>
+int
+self_hash<key_type_>::operator()(key_type_ t_key) const
+{
+ return t_key;
+}
+
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+hashmap<obj_type, key_type_, hash_type, alloc_type>::get_set_elem(obj_type t_obj, key_type_ t_key)
+{
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter = this->find(t_key);
+
+ if ( iter == this->end() )
+ {
+ set_elem(t_obj, t_key);
+ return obj_type();
+ }
+
+ obj_type t_ret = iter->second;
+ iter->second = t_obj;
+
+ return t_ret;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+hashmap<obj_type, key_type_, hash_type, alloc_type>::get_or_callback_set
+(obj_type (*func)(void*), void* p_void, key_type_ t_key)
+{
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter = this->find(t_key);
+
+ if ( iter == this->end() )
+ {
+ obj_type t_obj = (*func) (p_void);
+ set_elem(t_obj, t_key);
+ return t_obj;
+ }
+
+ return iter->second;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+hashmap<obj_type, key_type_, hash_type, alloc_type>::set_elem(obj_type t_obj, key_type_ t_key)
+{
+ (*this)[t_key] = t_obj;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+hashmap<obj_type, key_type_, hash_type, alloc_type>::get_elem(key_type_ t_key)
+{
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter = this->find(t_key);
+
+ if ( iter != this->end() )
+ return iter->second;
+
+ return obj_type();
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+vector<key_type_>*
+hashmap<obj_type, key_type_, hash_type, alloc_type>::get_key_vector()
+{
+ vector<key_type_>* p_vec = new vector<key_type_>;
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter;
+
+ for ( iter = this->begin(); iter != this->end(); ++iter )
+ p_vec->push_back(iter->first);
+
+ return p_vec;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+bool
+hashmap<obj_type, key_type_, hash_type, alloc_type>::exists(key_type_ t_key)
+{
+ return this->find(t_key) != this->end();
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+hashmap<obj_type, key_type_, hash_type, alloc_type>::run_func( void (*func)(obj_type) )
+{
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter;
+ for ( iter = this->begin(); iter != this->end(); ++iter )
+ ( *func ) ( iter->second );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+hashmap<obj_type, key_type_, hash_type, alloc_type>::run_func( void (*func)(obj_type, void*), void* v_arg )
+{
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter;
+ for ( iter = this->begin(); iter != this->end(); ++iter )
+ ( *func ) ( iter->second, v_arg );
+}
diff --git a/src/maps/mtools.h b/src/maps/mtools.h
new file mode 100644
index 0000000..c506674
--- /dev/null
+++ b/src/maps/mtools.h
@@ -0,0 +1,35 @@
+/*:*
+ *: File: ./src/maps/mtools.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef MTOOLS_H
+#define MTOOLS_H
+
+template <class type_>
+struct mtools
+{
+ static void delete_obj(type_ type_obj);
+};
+
+#include "mtools.tmpl"
+#endif
diff --git a/src/maps/mtools.tmpl b/src/maps/mtools.tmpl
new file mode 100644
index 0000000..3fb4a5f
--- /dev/null
+++ b/src/maps/mtools.tmpl
@@ -0,0 +1,36 @@
+/*:*
+ *: File: ./src/maps/mtools.tmpl
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef MTOOLS_TMPL
+#define MTOOLS_TMPL
+
+template <class type_>
+void
+mtools<type_>::delete_obj( type_ type_obj )
+{
+ if ( type_obj )
+ delete type_obj;
+}
+
+#endif
diff --git a/src/maps/nhashmap.h b/src/maps/nhashmap.h
new file mode 100644
index 0000000..1c14a1c
--- /dev/null
+++ b/src/maps/nhashmap.h
@@ -0,0 +1,45 @@
+/*:*
+ *: File: ./src/maps/nhashmap.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef NHASHMAP_H
+#define NHASHMAP_H
+
+#include "shashmap.h"
+
+using namespace std;
+
+template
+<
+ class obj_type,
+ class key_type_ = string,
+ class hash_type = size_hash<string>,
+ class alloc_type = compare_allocator<string>
+>
+struct nhashmap : public shashmap<obj_type, key_type_, hash_type, alloc_type>
+{
+ inline obj_type get_elem(key_type_ t_key);
+};
+
+#include "nhashmap.tmpl"
+#endif
diff --git a/src/maps/nhashmap.tmpl b/src/maps/nhashmap.tmpl
new file mode 100644
index 0000000..57afb81
--- /dev/null
+++ b/src/maps/nhashmap.tmpl
@@ -0,0 +1,35 @@
+/*:*
+ *: File: ./src/maps/nhashmap.tmpl
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+nhashmap<obj_type, key_type_, hash_type, alloc_type>::get_elem(key_type_ t_key)
+{
+ typename hashmap<obj_type, key_type_, hash_type, alloc_type>::iterator iter = this->find(t_key);
+
+ if ( iter != this->end() )
+ return iter->second;
+
+ return NULL;
+}
diff --git a/src/maps/shashmap.h b/src/maps/shashmap.h
new file mode 100644
index 0000000..1d8d585
--- /dev/null
+++ b/src/maps/shashmap.h
@@ -0,0 +1,73 @@
+/*:*
+ *: File: ./src/maps/shashmap.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SHASHMAP_H
+#define SHASHMAP_H
+
+#include <pthread.h>
+#include "hashmap.h"
+
+#include "../monitor/dump.h"
+
+using namespace std;
+
+template
+<
+ class obj_type,
+ class key_type_ = string,
+ class hash_type = size_hash<string>,
+ class alloc_type = compare_allocator<string>
+>
+class shashmap : protected hashmap<obj_type, key_type_, hash_type, alloc_type>,
+ public dumpable
+{
+private:
+ pthread_mutex_t mut_shashmap;
+
+protected:
+ virtual void dumpit();
+
+public:
+ explicit shashmap();
+ ~shashmap();
+ virtual inline void set_elem(obj_type t_obj, key_type_ t_key);
+ virtual inline obj_type get_set_elem(obj_type t_obj, key_type_ t_key);
+ virtual inline obj_type get_or_callback_set
+ (obj_type (*func)(void*), void* p_void, key_type_ t_key);
+ virtual inline void add_elem(obj_type t_obj, key_type_ t_key);
+ virtual inline void add_elem_insecure(obj_type t_obj, key_type_ t_key);
+ virtual inline obj_type get_elem(key_type_ t_key);
+ virtual inline void del_elem(key_type_ t_key);
+ virtual inline void del_elem_insecure(key_type_ t_key);
+ virtual inline void clear();
+ virtual inline int size();
+ virtual inline bool exists(key_type_ t_key);
+ virtual inline vector<key_type_>* get_key_vector();
+ virtual inline void run_func( void (*func)(obj_type) );
+ virtual inline void run_func( void (*func)(obj_type, void*), void* v_arg );
+
+};
+
+#include "shashmap.tmpl"
+#endif
diff --git a/src/maps/shashmap.tmpl b/src/maps/shashmap.tmpl
new file mode 100644
index 0000000..7a1c9ae
--- /dev/null
+++ b/src/maps/shashmap.tmpl
@@ -0,0 +1,179 @@
+/*:*
+ *: File: ./src/maps/shashmap.tmpl
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+shashmap<obj_type, key_type_, hash_type, alloc_type>::shashmap()
+{
+ pthread_mutex_init( &mut_shashmap, NULL );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+shashmap<obj_type, key_type_, hash_type, alloc_type>::~shashmap()
+{
+ pthread_mutex_destroy( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::add_elem(obj_type t_obj, key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ (*this)[t_key] = t_obj;
+ pthread_mutex_unlock( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::add_elem_insecure(obj_type t_obj, key_type_ t_key)
+{
+ (*this)[t_key] = t_obj;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+shashmap<obj_type, key_type_, hash_type, alloc_type>::get_set_elem(obj_type t_obj, key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ obj_type t_ret = hashmap<obj_type, key_type_, hash_type, alloc_type>::get_set_elem(t_obj, t_key);
+ pthread_mutex_unlock( &mut_shashmap );
+ return t_ret;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+shashmap<obj_type, key_type_, hash_type, alloc_type>::get_or_callback_set
+(obj_type (*func)(void*), void* p_void, key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ obj_type t_ret = hashmap<obj_type, key_type_, hash_type, alloc_type>::get_or_callback_set
+ (func, p_void, t_key);
+ pthread_mutex_unlock( &mut_shashmap );
+ return t_ret;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::set_elem(obj_type t_obj, key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ (*this)[t_key] = t_obj;
+ pthread_mutex_unlock( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+obj_type
+shashmap<obj_type, key_type_, hash_type, alloc_type>::get_elem(key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ obj_type t_ret = hashmap<obj_type, key_type_, hash_type, alloc_type>::get_elem(t_key);
+ pthread_mutex_unlock( &mut_shashmap );
+ return t_ret;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::del_elem(key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ hashmap<obj_type, key_type_, hash_type, alloc_type>::erase(t_key);
+ pthread_mutex_unlock( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::del_elem_insecure(key_type_ t_key)
+{
+ hashmap<obj_type, key_type_, hash_type, alloc_type>::erase(t_key);
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+vector<key_type_>*
+shashmap<obj_type, key_type_, hash_type, alloc_type>::get_key_vector()
+{
+ pthread_mutex_lock( &mut_shashmap );
+ vector<key_type_>* p_vec = hashmap<obj_type, key_type_, hash_type, alloc_type>::get_key_vector();
+ pthread_mutex_unlock( &mut_shashmap );
+ return p_vec;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::clear()
+{
+ pthread_mutex_lock( &mut_shashmap );
+ hashmap<obj_type, key_type_, hash_type, alloc_type>::clear();
+ pthread_mutex_unlock( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+int
+shashmap<obj_type, key_type_, hash_type, alloc_type>::size()
+{
+ pthread_mutex_lock( &mut_shashmap );
+ int i_size = hashmap<obj_type, key_type_, hash_type, alloc_type>::size();
+ pthread_mutex_unlock( &mut_shashmap );
+ return i_size;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+bool
+shashmap<obj_type, key_type_, hash_type, alloc_type>::exists(key_type_ t_key)
+{
+ pthread_mutex_lock( &mut_shashmap );
+ bool b_ret = hashmap<obj_type, key_type_, hash_type, alloc_type>::exists(t_key);
+ pthread_mutex_unlock( &mut_shashmap );
+ return b_ret;
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::run_func( void (*func)(obj_type) )
+{
+ pthread_mutex_lock( &mut_shashmap );
+ hashmap<obj_type, key_type_, hash_type, alloc_type>::run_func(func);
+ pthread_mutex_unlock( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::run_func( void (*func)(obj_type, void*), void* v_arg )
+{
+ pthread_mutex_lock( &mut_shashmap );
+ hashmap<obj_type, key_type_, hash_type, alloc_type>::run_func(func, v_arg);
+ pthread_mutex_unlock( &mut_shashmap );
+}
+
+template<class obj_type, class key_type_, class hash_type, class alloc_type>
+void
+shashmap<obj_type, key_type_, hash_type, alloc_type>::dumpit()
+{
+ dumpable::add("[shashmap]");
+ vector<key_type_>* p_vec = get_key_vector();
+
+ typename vector<key_type_>::iterator iter;
+ for (iter = p_vec->begin(); iter != p_vec->end(); ++iter)
+ dumpable::add(*iter);
+
+ delete p_vec;
+}
diff --git a/src/modl.cpp b/src/modl.cpp
new file mode 100644
index 0000000..284154f
--- /dev/null
+++ b/src/modl.cpp
@@ -0,0 +1,195 @@
+/*:*
+ *: File: ./src/modl.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef MODL_CPP
+#define MODL_CPP
+
+#include <limits.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "modl.h"
+#include "tool/dir.h"
+
+using namespace std;
+
+modl::modl()
+{
+#ifdef NCURSES
+ print_cached( 0 );
+#endif
+
+ if ( wrap::CONF->get_elem( "httpd.modules.preloadcommands" ).compare( "true" ) == 0 )
+ preload_modules( wrap::CONF->get_elem("httpd.modules.commandsdir") );
+
+ if ( wrap::CONF->get_elem( "httpd.modules.preloadhtml" ).compare( "true" ) == 0 )
+ preload_modules( wrap::CONF->get_elem("httpd.modules.htmldir") );
+}
+
+modl::~modl()
+{
+ // dlclose all the_module's first!
+ run_func( &modl::dlclose_ );
+
+ // then clean the hash map.
+ unload_modules();
+}
+
+void
+modl::preload_modules( string s_path )
+{
+ dir* p_dir = new dir();
+ p_dir->open_dir( s_path );
+
+ p_dir->read_dir();
+
+ vector<string> dir_vec = p_dir->get_dir_vec();
+
+ if ( ! dir_vec.empty() )
+ {
+ vector<string>::iterator iter = dir_vec.begin();
+
+ do
+ {
+ if ( iter->length() >= 3 && iter->compare( iter->length()-3, 3, ".so" ) == 0 )
+ cache_module( s_path + *iter, false );
+ }
+ while ( ++iter != dir_vec.end() );
+ }
+
+ dir_vec.clear();
+
+ // This also closes the dir.
+ delete p_dir;
+}
+
+void
+modl::dlclose_( dynmod* mod )
+{
+ dlclose( mod->the_module );
+ free ( mod );
+}
+
+dynmod*
+modl::cache_module( string s_name, bool b_print_sys_msg )
+{
+ void *the_module = NULL;
+ function *the_func = NULL;
+
+ the_module = dlopen( s_name.c_str(), RTLD_LAZY );
+ //the_module = dlopen( s_name.c_str(), RTLD_NOW );
+
+ if ( the_module == NULL )
+ {
+ wrap::system_message( dlerror() );
+ return NULL;
+ }
+
+ the_func = (function*) dlsym( the_module, "extern_function" );
+
+ if ( the_func == NULL )
+ {
+ wrap::system_message( dlerror() );
+ return NULL;
+ }
+
+ if ( b_print_sys_msg )
+ wrap::system_message( MODULEC + s_name.substr( s_name.find_last_of("/")+1 ) );
+
+ dynmod *mod = new dynmod; // encapsulates the function and module handler.
+ mod->the_func = the_func ; // the function to execute
+ mod->the_module = the_module; // the module handler to close if function
+
+ // is not needed anymore.
+ add_elem( mod, s_name );
+
+ // DO NOT CLOSE AS LONG THERE EXIST A POINTER TO THE FUNCTION
+ // dlclose( module ); will be called in modl::~modl()!
+
+#ifdef NCURSES
+
+ print_cached( size() );
+#endif
+
+ return mod;
+}
+
+dynmod*
+modl::get_module( string s_name, string s_user )
+{
+ wrap::system_message( MODULER + s_name.substr( s_name.find_last_of("/")+1 ) + " (" + s_user + ")");
+ dynmod* mod = get_elem( s_name );
+ return ! mod ? cache_module( s_name, true ) : mod;
+}
+
+dynmod*
+modl::get_module( string s_name )
+{
+ wrap::system_message( MODULER + s_name.substr( s_name.find_last_of("/")+1 ) );
+ dynmod* mod = get_elem( s_name );
+ return ! mod ? cache_module( s_name, true ) : mod;
+}
+
+void
+modl::unload_modules()
+{
+ wrap::system_message( MODUNLO );
+
+ // dlclose all the_module's first!
+ run_func( &modl::dlclose_ );
+
+ // then clean the hash map.
+ shashmap<dynmod*>::clear();
+
+#ifdef NCURSES
+
+ print_cached( size() );
+#endif
+
+}
+
+void
+modl::reload_modules()
+{
+ unload_modules();
+
+ wrap::system_message( MODRELO );
+ preload_modules( wrap::CONF->get_elem("httpd.modules.commandsdir") );
+ preload_modules( wrap::CONF->get_elem("httpd.modules.htmldir") );
+}
+
+#ifdef NCURSES
+void
+modl::print_cached( int i_mods )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_CACHED_MODS_X, NCUR_CACHED_MODS_Y, "Mods: %d ", i_mods);
+ refresh();
+}
+#endif
+
+#endif
diff --git a/src/modl.h b/src/modl.h
new file mode 100644
index 0000000..618c9a3
--- /dev/null
+++ b/src/modl.h
@@ -0,0 +1,63 @@
+/*:*
+ *: File: ./src/modl.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "incl.h"
+
+#ifndef MODL_H
+#define MODL_H
+
+#include "maps/shashmap.h"
+
+using namespace std;
+
+class modl : public shashmap<dynmod*>
+{
+private:
+ static void dlclose_( dynmod* mod );
+ dynmod* cache_module ( string s_name, bool b_print_sys_msg );
+ void preload_modules( string s_path );
+
+#ifdef NCURSES
+
+ void print_cached( int i_mods );
+#endif
+
+public:
+ modl();
+ ~modl();
+
+ dynmod* get_module( string s_name );
+ dynmod* get_module( string s_name, string s_user );
+
+ vector<string>* get_mod_vector()
+ {
+ vector<string>* p_ret = get_key_vector();
+ return p_ret;
+ }
+
+ void unload_modules();
+ void reload_modules();
+};
+
+#endif
diff --git a/src/mods/Makefile b/src/mods/Makefile
new file mode 100644
index 0000000..1b0712b
--- /dev/null
+++ b/src/mods/Makefile
@@ -0,0 +1,9 @@
+MAKE=`tail -n 1 ../../make.version`
+all: mods
+mods:
+ @${MAKE} -C ./commands #//<<
+ @${MAKE} -C ./html
+clean:
+ @${MAKE} -C ./commands clean #//<<
+ @${MAKE} -C ./html clean
+ @if test -d ../../mods; then rm -Rf ../../mods; fi
diff --git a/src/mods/commands/Makefile.in b/src/mods/commands/Makefile.in
new file mode 100644
index 0000000..42884b6
--- /dev/null
+++ b/src/mods/commands/Makefile.in
@@ -0,0 +1,18 @@
+MODS=$(addprefix ../../../mods/commands/, $(SRCS:.cpp=.so))
+CC=COMPILER
+INCLUDES=`cat ../../includes.add`
+CFLAGS=`cat ../cflags.add`
+all: mods
+$(MODS):
+ @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
+ @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/`
+ @echo -n "Command module `basename $@ | sed s/\.so// | sed s/yc_//` "
+ @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g"
+infotext:
+ @echo Compiling command modules
+mods: infotext $(MODS)
+ @echo "Num of command modules: "
+ @ls ../../../mods/commands/*.so | wc -l
+clean:
+ @echo Cleaning command modules
+ @if test -d ../../../mods/commands; then rm -Rf ../../../mods/commands; fi
diff --git a/src/mods/commands/yc_about.cpp b/src/mods/commands/yc_about.cpp
new file mode 100644
index 0000000..b4449a1
--- /dev/null
+++ b/src/mods/commands/yc_about.cpp
@@ -0,0 +1,83 @@
+/*:*
+ *: File: ./src/mods/commands/yc_about.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ string s_searched_user( *iter );
+ bool b_found;
+ user* p_searched_user = p_chat->get_user( s_searched_user, b_found );
+
+ if ( b_found )
+ {
+ string s_msg = "<b>" + p_searched_user->get_colored_name() + "</b>"
+ + p_conf->get_elem("chat.msgs.userhasstatus") + "<b>"
+ + tool::int2string(p_searched_user->get_status())
+ + "</b>, "
+ + p_conf->get_elem("chat.msgs.userinroom") + "<b>"
+ + p_searched_user->get_room()->get_name()
+ + "</b><br>\n"
+ + p_conf->get_elem("chat.msgs.lastactivity") + "<b>"
+ + tool::int2string((int)( p_searched_user->get_last_activity()))
+ + "</b><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+ else
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\"><b>"
+ + s_searched_user + "</b> "
+ + p_conf->get_elem("chat.msgs.err.notavailable")
+ + "</font><br>\n";
+ p_user->msg_post( &s_msg );
+
+ }
+ }
+
+ return 0;
+ }
+
+}
+
diff --git a/src/mods/commands/yc_all.cpp b/src/mods/commands/yc_all.cpp
new file mode 100644
index 0000000..24edb56
--- /dev/null
+++ b/src/mods/commands/yc_all.cpp
@@ -0,0 +1,73 @@
+/*:*
+ *: File: ./src/mods/commands/yc_all.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../chat/chat.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params= (vector<string>*) c->elem[2]; // param array
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+
+ string s_tmp = "";
+ string s_msg = "";
+
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ s_tmp.append( *iter + " " );
+
+ s_msg = p_timr->get_time() + " <b><font color=\"#"
+ + p_conf->get_elem("chat.html.sysmsgcolor")
+ + "\"> "
+ + p_conf->get_elem("chat.msgs.system");
+
+ p_chat->string_replacer(&s_tmp);
+ s_msg.append( s_tmp + "</font></b><br>\n" );
+ p_chat->msg_post( &s_msg );
+ return 0;
+ }
+
+ s_msg = p_conf->colored_error_msg("chat.msgs.err.wrongcommandusage");
+ p_user->msg_post(s_msg);
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_away.cpp b/src/mods/commands/yc_away.cpp
new file mode 100644
index 0000000..0e879fc
--- /dev/null
+++ b/src/mods/commands/yc_away.cpp
@@ -0,0 +1,96 @@
+/*:*
+ *: File: ./src/mods/commands/yc_away.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1]; // the corresponding user
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+
+ string s_msg;
+ string s_away;
+ string s_col;
+
+ vector<string>::iterator iter;
+
+ string s_time = p_timr->get_time();
+
+ s_away.append( s_time ).append( " " );
+
+ s_msg = s_time
+ + " "
+ + p_user->get_colored_bold_name()
+ + " "
+ + p_conf->get_elem("chat.msgs.setmodeaway")
+ + "<font color=" + p_user->get_col2() + ">";
+
+ if ( params->size() > 0 )
+ {
+ s_msg.append(": ");
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ {
+ s_msg.append( " " + *iter );
+ s_away.append( *iter + " " );
+ }
+ }
+ else
+ {
+ s_msg.append(".");
+ }
+
+ s_msg.append( "</font><br>\n" );
+
+ room* p_room = p_user->get_room();
+
+ // Remove ' from away message:
+ auto unsigned int pos;
+
+ do
+ {
+ pos = s_away.find_first_of( "'" );
+ if ( pos == string::npos )
+ break;
+ s_away.replace( pos, 1, "\"" );
+ }
+ while (true);
+
+ p_user->set_away( true, s_away );
+ p_room->reload_onlineframe();
+ p_room->msg_post ( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_col.cpp b/src/mods/commands/yc_col.cpp
new file mode 100644
index 0000000..dca1bde
--- /dev/null
+++ b/src/mods/commands/yc_col.cpp
@@ -0,0 +1,112 @@
+/*:*
+ *: File: ./src/mods/commands/yc_col.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../wrap.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+#include "../../tool/tool.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+
+ user *p_user = (user*)c->elem[1]; // the corresponding user
+ vector<string> *params= (vector<string>*) c->elem[2]; // param array
+
+ string s_color;
+ string s_color2;
+
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ if ( params->empty() )
+ {
+ s_color = p_conf->get_elem( "chat.html.user.color1" );
+ s_color2 = p_conf->get_elem( "chat.html.user.color2" );
+ }
+ else
+ {
+ s_color = (string) params->front();
+ params->erase( params->begin() );
+ if ( ! params->empty() )
+ s_color2 = (string) params->front();
+ else
+ s_color2 = p_conf->get_elem( "chat.html.user.color1" );
+ }
+
+ s_color = tool::to_lower( s_color );
+ s_color2 = tool::to_lower( s_color2 );
+
+ if( valid_color(s_color) != 1 )
+ {
+ string *answerstring=new string(s_color + " is not a valid color.<br>\n");
+ p_user->msg_post( answerstring );
+ }
+ else if( valid_color(s_color2) != 1 )
+ {
+ string *answerstring=new string( s_color2 + " is not a valid color.<br>\n");
+ p_user->msg_post( answerstring );
+ }
+ else
+ {
+ string *answerstring=new string(p_timr->get_time() + " " + p_user->get_colored_bold_name()+ " changes color to <font color=\"#"
+ + s_color + "\">" + s_color + "</font> <font color=\"#"
+ + s_color2 + "\">" + s_color2 + "</font><br>\n");
+ p_user->get_room()->msg_post( answerstring );
+ p_user->set_col1(s_color);
+ p_user->set_col2(s_color2);
+ p_user->get_room()->reload_onlineframe();
+ }
+
+ return 0;
+ }
+ int valid_color( string s_color )
+ {
+
+ if(s_color.size()!=6)
+ return 0;
+ string valid="abcdef0123456789";
+ for(int i=0;i<s_color.size();i++)
+ {
+ string s_char=s_color.substr(i,1);
+ if(valid.find(s_char)==string::npos)
+ return 0;
+ }
+
+ return 1;
+ }
+
+}
+
diff --git a/src/mods/commands/yc_compopt.cpp b/src/mods/commands/yc_compopt.cpp
new file mode 100644
index 0000000..43e5e1b
--- /dev/null
+++ b/src/mods/commands/yc_compopt.cpp
@@ -0,0 +1,47 @@
+/*:*
+ *: File: ./src/mods/commands/yc_compopt.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../msgs.h"
+#include "../../chat/user.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+ user *p_user = (user*)c->elem[1]; // the corresponding user
+ p_user->msg_post( tool::ychat_version() + " " + UNAME + "<br>\n" + COMPOPT + "<br>\n");
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_exec.cpp b/src/mods/commands/yc_exec.cpp
new file mode 100644
index 0000000..6f2d533
--- /dev/null
+++ b/src/mods/commands/yc_exec.cpp
@@ -0,0 +1,90 @@
+/*:*
+ *: File: ./src/mods/commands/yc_exec.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+#include <unistd.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1]; // the corresponding user
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+
+ string s_command;
+ string s_msg = p_timr->get_time();
+ string s_output;
+
+ vector<string>::iterator iter;
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ s_command.append( " " + *iter );
+
+ s_command.append(" 2>error.log");
+
+ s_msg.append( " " + s_command + "<br>\n" );
+
+ p_user->msg_post( &s_msg );
+
+ FILE *file;
+ char buffer[READBUF];
+
+ if( (file=popen(s_command.c_str(), "r")) == NULL )
+ {
+ s_output = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + p_conf->get_elem("chat.msgs.err.execcommand")
+ + "</font><br>\n";
+ p_user->msg_post( &s_output );
+ }
+ else
+ {
+ s_output.append("<hr>\n");
+ while(true)
+ {
+ if(fgets(buffer, READBUF, file) == NULL)
+ break;
+
+ s_output.append( string(buffer) + "<br>\n" );
+ }
+
+ p_user->msg_post( &s_output );
+ pclose(file);
+ }
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_fake.cpp b/src/mods/commands/yc_fake.cpp
new file mode 100644
index 0000000..3eb1442
--- /dev/null
+++ b/src/mods/commands/yc_fake.cpp
@@ -0,0 +1,54 @@
+/*:*
+ *: File: ./src/mods/commands/yc_fake.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1]; // the corresponding user
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ bool b_fake = p_user->get_fake();
+
+ string s_msg = (b_fake == 1
+ ? p_conf->get_elem("chat.msgs.unsetmodefake") + "<br>\n"
+ : p_conf->get_elem("chat.msgs.setmodefake") + "<br>\n");
+
+
+ p_user->set_fake( !b_fake );
+ p_user->get_room()->reload_onlineframe();
+ p_user->msg_post ( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_getroom.cpp b/src/mods/commands/yc_getroom.cpp
new file mode 100644
index 0000000..4b22d81
--- /dev/null
+++ b/src/mods/commands/yc_getroom.cpp
@@ -0,0 +1,77 @@
+/*:*
+ *: File: ./src/mods/commands/yc_getroom.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ string s_searched_user( *iter );
+ bool b_found;
+ user* p_searched_user = p_chat->get_user( s_searched_user, b_found );
+
+ if ( b_found )
+ {
+ string s_msg = "<b>" + p_searched_user->get_colored_name() + "</b>"
+ + p_conf->get_elem("chat.msgs.userinroom") + "<b>"
+ + p_searched_user->get_room()->get_name()
+ + "</b><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+ else
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\"><b>"
+ + s_searched_user + "</b> "
+ + p_conf->get_elem("chat.msgs.err.notavailable")
+ + "</font><br>\n";
+ p_user->msg_post( &s_msg );
+
+ }
+ }
+
+ return 0;
+ }
+
+}
+
diff --git a/src/mods/commands/yc_getrusage.cpp b/src/mods/commands/yc_getrusage.cpp
new file mode 100644
index 0000000..56a7fbb
--- /dev/null
+++ b/src/mods/commands/yc_getrusage.cpp
@@ -0,0 +1,81 @@
+/*:*
+ *: File: ./src/mods/commands/yc_getrusage.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <iostream>
+#include "../../chat/user.h"
+
+#ifndef RUSAGE_SELF
+#define RUSAGE_SELF 0
+#endif
+#ifndef RUSAGE_CHILDREN
+#define RUSAGE_CHILDREN -1
+#endif
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ 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 ) );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_help.cpp b/src/mods/commands/yc_help.cpp
new file mode 100644
index 0000000..33faf60
--- /dev/null
+++ b/src/mods/commands/yc_help.cpp
@@ -0,0 +1,76 @@
+/*:*
+ *: File: ./src/mods/commands/yc_help.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/user.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ string s_msg = "";
+
+ if (params->size() >= 1)
+ {
+ vector<string>::iterator iter = params->begin();
+
+ string s_help = p_conf->get_elem("chat.msgs.help." + *iter);
+
+ if ( s_help != "" )
+ {
+ s_msg.append("<b>" + *iter + ":</b> " + s_help + "<br>\n");
+ p_user->msg_post( &s_msg );
+ return 0;
+ }
+
+ s_msg.append(*iter + " " + p_conf->get_elem("chat.msgs.err.notavailable"));
+ }
+ else
+ {
+ s_msg.append(p_conf->get_elem("chat.msgs.err.wrongcommandusage"));
+ }
+
+ s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\"> "
+ + s_msg
+ + "</font><br>\n";
+
+ p_user->msg_post( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_invisible.cpp b/src/mods/commands/yc_invisible.cpp
new file mode 100644
index 0000000..5eea510
--- /dev/null
+++ b/src/mods/commands/yc_invisible.cpp
@@ -0,0 +1,55 @@
+/*:*
+ *: File: ./src/mods/commands/yc_invisible.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1]; // the corresponding user
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ bool b_invisible = p_user->get_invisible();
+
+ string s_msg = b_invisible
+ ? p_conf->get_elem("chat.msgs.setmodeinvisible")
+ + "<br>\n"
+ : p_conf->get_elem("chat.msgs.unsetmodeinvisible")
+ + "<br>\n";
+
+ p_user->set_invisible( !b_invisible );
+ p_user->get_room()->reload_onlineframe();
+ p_user->msg_post ( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_j.cpp b/src/mods/commands/yc_j.cpp
new file mode 100644
index 0000000..15e97cc
--- /dev/null
+++ b/src/mods/commands/yc_j.cpp
@@ -0,0 +1,128 @@
+/*:*
+ *: File: ./src/mods/commands/yc_j.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string> *) c->elem[2]; // param array
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ gcol* p_gcol = (gcol*) ((dynamic_wrap*)c->elem[3])->GCOL;
+
+ if ( ! params->empty() )
+ {
+ vector<string> ::iterator iter;
+
+ string s_room;
+
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ {
+ s_room.append( *iter );
+ if ( iter+1 != params->end() )
+ s_room.append(" ");
+ }
+
+ int i_max_room_len = tool::string2int( p_conf->get_elem("chat.maxlength.roomname") );
+ if ( i_max_room_len < s_room.length() )
+ s_room = s_room.substr(0, i_max_room_len );
+
+ if ( tool::to_lower(s_room) == p_user->get_room()->get_lowercase_name() )
+ {
+ string s_msg = "<font color=\"" + p_conf->get_elem("chat.html.errorcolor") + "\">"
+ + p_conf->get_elem("chat.msgs.err.alreadyinroom") + "<b>"
+ + p_user->get_room()->get_name() + "</b></font><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+ else
+ {
+ string s_user = p_timr->get_time() + " " + p_user->get_colored_bold_name();
+ string s_msg = s_user + p_conf->get_elem( "chat.msgs.userleavesroom" ) + "<b>";
+ string s_msg2 = s_user + p_conf->get_elem( "chat.msgs.userentersroom" ) + "<b>";
+
+ bool b_flag;
+ room* p_room = p_chat->get_room( s_room , b_flag );
+
+ // if room does not exist add room to list!
+ if ( p_room == NULL )
+ {
+ p_room = p_gcol->get_room_from_garbage_or_new( s_room );
+
+ s_msg.append( s_room + "</b><br>\n" );
+ s_msg2.append( s_room + "</b><br>\n" );
+
+ room* p_room_old = p_user->get_room();
+
+ string s_name_lowercase = p_user->get_lowercase_name();
+ p_user->get_room()->del_elem( s_name_lowercase );
+
+ p_gcol->lock_mutex();
+ if ( p_room_old != NULL )
+ p_room_old->msg_post( &s_msg );
+ p_gcol->unlock_mutex();
+
+ p_room->add_user( p_user );
+ p_chat->add_elem( p_room );
+ p_room->msg_post( &s_msg2 );
+ }
+ else // p_room != NULL
+ {
+ s_msg.append( p_room->get_name() + "</b><br>\n" );
+ s_msg2.append( p_room->get_name() + "</b><br>\n" );
+
+ room* p_room_old = p_user->get_room();
+
+ string s_name_lowercase = p_user->get_lowercase_name();
+ p_user->get_room()->del_elem( s_name_lowercase );
+
+ p_gcol->lock_mutex();
+ if ( p_room_old != NULL )
+ p_room_old->msg_post( &s_msg );
+ p_gcol->unlock_mutex();
+
+ p_room->add_user( p_user );
+ p_room->msg_post( &s_msg2 );
+ }
+ }
+ }
+
+ return 0;
+ }
+
+}
+
diff --git a/src/mods/commands/yc_ko.cpp b/src/mods/commands/yc_ko.cpp
new file mode 100644
index 0000000..40592eb
--- /dev/null
+++ b/src/mods/commands/yc_ko.cpp
@@ -0,0 +1,96 @@
+/*:*
+ *: File: ./src/mods/commands/yc_ko.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ string s_searched_user( *iter );
+ bool b_found;
+ user* p_searched_user = p_chat->get_user( s_searched_user, b_found );
+
+ if ( b_found )
+ {
+
+ string s_msg = p_timr->get_time() + " "
+ + p_user->get_colored_bold_name()
+ + p_conf->get_elem( "chat.msgs.userkicksout1" )
+ + p_searched_user->get_colored_bold_name()
+ + p_conf->get_elem( "chat.msgs.userkicksout2" )
+ + p_searched_user->get_room()->get_bold_name()
+ + "<br>\n";
+
+ room* p_room1 = p_user->get_room();
+ room* p_room2 = p_searched_user->get_room();
+
+ p_room1->msg_post( &s_msg );
+
+ if ( p_room1->get_lowercase_name() !=
+ p_room2->get_lowercase_name() )
+ p_room2->msg_post( &s_msg );
+
+ string s_kick = "<script confuage=JavaScript>top.location.href='/"
+ + p_conf->get_elem("httpd.startsite")
+ + "';</script>";
+
+ p_searched_user->msg_post( &s_kick );
+ p_searched_user->set_online(false);
+ }
+ else
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\"><b>"
+ + s_searched_user + "</b> "
+ + p_conf->get_elem("chat.msgs.err.notavailable")
+ + "</font><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+ }
+
+ return 0;
+ }
+
+}
+
diff --git a/src/mods/commands/yc_m.cpp b/src/mods/commands/yc_m.cpp
new file mode 100644
index 0000000..fa63719
--- /dev/null
+++ b/src/mods/commands/yc_m.cpp
@@ -0,0 +1,68 @@
+/*:*
+ *: File: ./src/mods/commands/yc_m.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params= (vector<string>*) c->elem[2]; // param array
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ string s_msg = "";
+
+ if ( p_conf->get_elem("chat.printalwaystime") == "true" )
+ s_msg = p_timr->get_time() + " ";
+
+ s_msg.append( "<i>" + p_user->get_colored_name()
+ + " <font color=\"#" + p_user->get_col2()
+ + "\">" );
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ s_msg.append( *iter + " " );
+ }
+
+ s_msg.append( "</font></i><br>\n" );
+ p_user->get_room()->msg_post( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_md5.cpp b/src/mods/commands/yc_md5.cpp
new file mode 100644
index 0000000..4e81ede
--- /dev/null
+++ b/src/mods/commands/yc_md5.cpp
@@ -0,0 +1,78 @@
+/*:*
+ *: File: ./src/mods/commands/yc_md5.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/user.h"
+#include "../../contrib/crypt/md5.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ if (params->size() >= 2)
+ {
+ vector<string>::iterator iter;
+ string s_string = "";
+ string s_salt = "";
+
+ for (iter = params->begin(); iter+1 != params->end(); ++iter)
+ {
+ s_string.append(*iter);
+ }
+
+ s_salt = *iter;
+
+ string s_msg = "Crypt: <b>" + s_string + "</b>, Salt: <b>"
+ + s_salt + "</b> = <b>" +
+ + md5::MD5Crypt(s_string.c_str(), s_salt.c_str())
+ + "</b><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+ else
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\"> "
+ + p_conf->get_elem("ERR_WRONG_COMMAND_USAGE")
+ + "</font><br>\n";
+ p_user->msg_post( &s_msg );
+
+ }
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_me.cpp b/src/mods/commands/yc_me.cpp
new file mode 100644
index 0000000..d105723
--- /dev/null
+++ b/src/mods/commands/yc_me.cpp
@@ -0,0 +1,69 @@
+/*:*
+ *: File: ./src/mods/commands/yc_me.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params= (vector<string>*) c->elem[2]; // param array
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ string s_msg = "";
+
+ if ( p_conf->get_elem("chat.printalwaystime") == "true" )
+ s_msg = p_timr->get_time() + " ";
+
+ s_msg.append( "<i><font color=\"#" +p_user->get_col1() + "\">"
+ + p_user->get_name() + " ");
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ s_msg.append( *iter + " " );
+ }
+
+ s_msg.append( "</font></i><br>\n" );
+ p_user->get_room()->msg_post( &s_msg );
+
+ return 0;
+
+ }
+}
+
diff --git a/src/mods/commands/yc_morph.cpp b/src/mods/commands/yc_morph.cpp
new file mode 100644
index 0000000..22a8174
--- /dev/null
+++ b/src/mods/commands/yc_morph.cpp
@@ -0,0 +1,76 @@
+/*:*
+ *: File: ./src/mods/commands/yc_morph.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+#include "../../tool/tool.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c = (container*) v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *p_params = (vector<string>*) c->elem[2]; // param array
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ if ( p_params->empty() )
+ {
+ string s_msg = p_conf->colored_error_msg("chat.msgs.err.wrongcommandusage");
+ p_user->msg_post(s_msg);
+ }
+ else
+ {
+ string s_morphed_name = p_params->at(0);
+
+ if ( tool::to_lower(s_morphed_name) != p_user->get_lowercase_name() )
+ {
+ string s_msg = p_conf->colored_error_msg("chat.msgs.err.morphnick");
+ p_user->msg_post(s_msg);
+ }
+ else
+ {
+ string s_msg = p_timr->get_time() + " " + p_user->get_colored_bold_name() + p_conf->get_elem( "chat.msgs.usermorphs" ) + "<font color=\"#" + p_user->get_col1() + "\"><b>" + s_morphed_name + "</b></font><br>\n";
+
+ room* p_room = p_user->get_room();
+ p_room->msg_post( &s_msg );
+ p_user->set_name( s_morphed_name );
+ p_room->reload_onlineframe();
+ }
+ }
+
+ return 0;
+ }
+
+}
+
+
diff --git a/src/mods/commands/yc_msg.cpp b/src/mods/commands/yc_msg.cpp
new file mode 100644
index 0000000..8889e9f
--- /dev/null
+++ b/src/mods/commands/yc_msg.cpp
@@ -0,0 +1,92 @@
+/*:*
+ *: File: ./src/mods/commands/yc_msg.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ string s_whisper_user( *iter );
+ bool b_found;
+ user* p_whisper_user = p_chat->get_user( s_whisper_user, b_found );
+
+ if ( b_found )
+ {
+ string s_time = "";
+ if ( p_conf->get_elem("chat.printalwaystime") == "true" )
+ s_time = p_timr->get_time() + " ";
+
+ string s_msg = s_time + "<i> " + p_conf->get_elem("chat.msgs.whisperto") + " " + p_whisper_user->get_colored_name() + ": <font color=\"#" + p_user->get_col2() + "\">";
+
+ string s_whisper_msg = s_time + "<i>" + p_user->get_colored_name() + " " + p_conf->get_elem("chat.msgs.whisper") + ": <font color=\"#" + p_user->get_col2() + "\">";
+
+ string s_tmp = "";
+ for ( iter++; iter != params->end(); iter++ )
+ s_tmp.append( *iter + " " );
+
+ p_chat->string_replacer(&s_tmp);
+
+ s_msg .append( s_tmp + "</font></i><br>\n" );
+ s_whisper_msg.append( s_tmp + "</font></i><br>\n" );
+
+ p_user ->msg_post( &s_msg );
+ p_whisper_user->msg_post( &s_whisper_msg );
+ }
+ else
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\"><b>"
+ + s_whisper_user + "</b> "
+ + p_conf->get_elem("chat.msgs.err.notavailable")
+ + "</font><br>\n";
+
+ p_user->msg_post( &s_msg );
+ }
+ }
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_q.cpp b/src/mods/commands/yc_q.cpp
new file mode 100644
index 0000000..37f472c
--- /dev/null
+++ b/src/mods/commands/yc_q.cpp
@@ -0,0 +1,54 @@
+/*:*
+ *: File: ./src/mods/commands/yc_q.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../chat/user.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container* c = (container*) v_arg;
+ user* p_user = (user*)c->elem[1];
+
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ string s_quit = "<script confuage=JavaScript>top.location.href='/"
+ + p_conf->get_elem("httpd.startsite")
+ + "';</script>";
+
+ p_user->msg_post( &s_quit );
+ p_user->set_online(false);
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_reload.cpp b/src/mods/commands/yc_reload.cpp
new file mode 100644
index 0000000..2fe7522
--- /dev/null
+++ b/src/mods/commands/yc_reload.cpp
@@ -0,0 +1,49 @@
+/*:*
+ *: File: ./src/mods/commands/yc_reload.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1]; // the corresponding user
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+
+ string s_msg = p_conf->get_elem("chat.msgs.reloadonlineframe")
+ + "<br>\n";
+
+ p_user->get_room()->reload_onlineframe();
+ p_user->msg_post ( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_ren.cpp b/src/mods/commands/yc_ren.cpp
new file mode 100644
index 0000000..90de221
--- /dev/null
+++ b/src/mods/commands/yc_ren.cpp
@@ -0,0 +1,98 @@
+/*:*
+ *: File: ./src/mods/commands/yc_ren.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c = (container*) v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter;
+
+ string s_room;
+
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ {
+ s_room.append( *iter );
+ if ( iter+1 != params->end() )
+ s_room.append(" ");
+ }
+
+ int i_max_room_len = tool::string2int( p_conf->get_elem("chat.maxlength.roomname") );
+ if ( i_max_room_len < s_room.length() )
+ s_room = s_room.substr(0, i_max_room_len );
+
+ bool b_found;
+ string s_room_lower = tool::to_lower(s_room);
+ room* p_room = p_user->get_room();
+
+ if ( s_room_lower != p_room->get_lowercase_name() &&
+ NULL != p_chat->get_room( s_room_lower , b_found ) )
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\">"
+ + p_conf->get_elem("chat.msgs.err.roomexists")
+ + "</font><br>\n";
+
+ p_user->msg_post( &s_msg );
+ }
+ else
+ {
+ string s_msg = p_timr->get_time() + " "
+ + p_user->get_colored_bold_name()
+ + p_conf->get_elem( "chat.msgs.userrenamesroom" )
+ + "<b>" + s_room + "</b><br>\n";
+
+ p_chat->del_elem( p_room->get_lowercase_name() );
+ p_room->set_name( s_room );
+ p_chat->add_elem( p_room );
+ p_room->msg_post( &s_msg );
+ p_room->reload_onlineframe();
+ }
+ }
+
+ return 0;
+ }
+
+}
+
diff --git a/src/mods/commands/yc_s.cpp b/src/mods/commands/yc_s.cpp
new file mode 100644
index 0000000..42213ac
--- /dev/null
+++ b/src/mods/commands/yc_s.cpp
@@ -0,0 +1,72 @@
+/*:*
+ *: File: ./src/mods/commands/yc_s.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/user.h"
+#include "../../chat/room.h"
+
+using namespace std;
+
+extern "C"
+{
+ string to_upper( string &s_msg )
+ {
+ char* c_msg = (char*) s_msg.c_str();
+
+ for ( int i = 0; i < strlen( c_msg ); i++ )
+ c_msg[i] = toupper( c_msg[i] );
+
+ return string( c_msg );
+ };
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ vector<string> *params= (vector<string>*) c->elem[2]; // param array
+
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ string s_time = "";
+ if ( p_conf->get_elem("chat.printalwaystime") == "true" )
+ s_time = p_timr->get_time() + " ";
+
+ string s_msg = s_time + "<i>" + p_user->get_colored_name() + " " + p_conf->get_elem("chat.msgs.scream") + " <font color=\"#" + p_user->get_col2() + "\"><b>";
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter = params->begin();
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ s_msg.append( to_upper(*iter) + " " );
+ }
+
+ s_msg.append( "</b></font></i><br>\n" );
+ p_user->get_room()->msg_post( &s_msg );
+
+ return 0;
+
+ }
+}
+
diff --git a/src/mods/commands/yc_set.cpp b/src/mods/commands/yc_set.cpp
new file mode 100644
index 0000000..8d59908
--- /dev/null
+++ b/src/mods/commands/yc_set.cpp
@@ -0,0 +1,124 @@
+/*:*
+ *: File: ./src/mods/commands/yc_set.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1];
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+
+ bool b_invalid_syntax = 0;
+
+ if ( params->size() >= 3 )
+ {
+ string s_msg;
+ string s_command_name = params->at(0);
+ string s_option = params->at(1);
+ string s_newval = params->at(2);
+
+ if ( s_option == "status" )
+ {
+ const char* c_newval = s_newval.c_str();
+ if ( isdigit( c_newval[0] ) )
+ {
+ int i_newval = c_newval[0] - '0';
+
+ s_msg = p_timr->get_time()
+ + " "
+ + p_user->get_colored_bold_name()
+ + " "
+ + p_conf->get_elem("chat.msgs.setcommandstatus")
+ + " ("
+ + s_command_name + "," + s_newval + ","
+ + tool::int2string( p_chat->get_command_disabled(s_command_name))
+ + ")<br>\n";
+
+ p_user->get_room()->msg_post(&s_msg);
+ p_chat->set_command_status( s_command_name, i_newval );
+ }
+ }
+ else if ( s_option == "disable" )
+ {
+ const char* c_newval = s_newval.c_str();
+ if ( isdigit( c_newval[0] ) )
+ {
+ int i_newval = c_newval[0] - '0';
+
+ if ( i_newval != 0 )
+ i_newval = 1;
+
+ s_newval = tool::int2string(i_newval);
+
+ s_msg = p_timr->get_time()
+ + " "
+ + p_user->get_colored_bold_name()
+ + " "
+ + p_conf->get_elem("chat.msgs.setcommandstatus")
+ + " ("
+ + s_command_name + ","
+ + tool::int2string( p_chat->get_command_status(s_command_name))
+ + "," + s_newval + ")<br>\n";
+
+ p_user->get_room()->msg_post(&s_msg);
+ p_chat->set_command_disabled( s_command_name, (bool)i_newval );
+ }
+ }
+ else
+ {
+ b_invalid_syntax = 1;
+ }
+
+ }
+ else
+ {
+ b_invalid_syntax = 1;
+ }
+
+ if ( b_invalid_syntax )
+ {
+ string s_msg = "<font color=\"#"
+ + p_conf->get_elem("chat.html.errorcolor")
+ + "\">"
+ + p_conf->get_elem("chat.msgs.err.wrongcommandusage")
+ + "</font><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_template.cpp b/src/mods/commands/yc_template.cpp
new file mode 100644
index 0000000..a49bb69
--- /dev/null
+++ b/src/mods/commands/yc_template.cpp
@@ -0,0 +1,49 @@
+/*:*
+ *: File: ./src/mods/commands/yc_template.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../chat/user.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*)c->elem[1]; // the corresponding user
+ vector<string> *params=(vector<string>*)c->elem[2]; // param array
+
+ string *quitstring=new string("Text to send<br>");
+ p_user->msg_post( quitstring );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_time.cpp b/src/mods/commands/yc_time.cpp
new file mode 100644
index 0000000..31198a1
--- /dev/null
+++ b/src/mods/commands/yc_time.cpp
@@ -0,0 +1,46 @@
+/*:*
+ *: File: ./src/mods/commands/yc_time.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ string s_msg = p_conf->get_elem("chat.msgs.servertime") + p_timr->get_time() + "<br>\n";
+
+ p_user->msg_post( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_topic.cpp b/src/mods/commands/yc_topic.cpp
new file mode 100644
index 0000000..b2dfed5
--- /dev/null
+++ b/src/mods/commands/yc_topic.cpp
@@ -0,0 +1,102 @@
+/*:*
+ *: File: ./src/mods/commands/yc_topic.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../tool/tool.h"
+#include "../../incl.h"
+#include "../../chat/room.h"
+#include "../../chat/user.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user* p_user = (user*) c->elem[1]; // the corresponding user
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ vector<string> *params = (vector<string>*) c->elem[2]; // param array
+
+ string s_msg;
+ string s_topic;
+ string s_col;
+
+ room* p_room = p_user->get_room();
+
+ if ( ! params->empty() )
+ {
+ vector<string>::iterator iter;
+
+ s_col = "<font color=\"" + p_user->get_col1() + "\">";
+
+ s_msg = p_timr->get_time()
+ + " "
+ + p_user->get_colored_bold_name()
+ + " "
+ + p_conf->get_elem("chat.msgs.topic")
+ + s_col;
+
+ for ( iter = params->begin(); iter != params->end(); iter++ )
+ {
+ s_msg.append( " " + *iter );
+ s_topic.append( *iter + " " );
+ }
+ s_msg.append( "</font>" );
+
+ int i_topic_length = tool::string2int(p_conf->get_elem("chat.maxlength.topic"));
+ if ( s_topic.length() > i_topic_length )
+ {
+ s_topic = s_topic.substr(0, i_topic_length );
+ s_topic.append(" ... ");
+
+ string s_private_msg = "<font color=#" + p_conf->get_elem("chat.html.errorcolor")
+ + ">" + p_conf->get_elem( "chat.msgs.topiccut" ) + "</font><br>";
+
+ p_user->msg_post ( &s_private_msg );
+ }
+
+ s_topic = "( " + s_topic + ")";
+ p_room->set_topic( s_topic, p_user->get_col1() );
+ }
+ else
+ {
+ s_msg = p_timr->get_time()
+ + " "
+ + p_user->get_colored_bold_name()
+ + " "
+ + p_conf->get_elem("chat.msgs.topicdelete");
+
+ p_room->set_topic( "" );
+ }
+
+ s_msg.append( "<script confuage='JavaScript'>parent.online.location.reload();</script><br>\n" );
+
+ p_room->msg_post ( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_uptime.cpp b/src/mods/commands/yc_uptime.cpp
new file mode 100644
index 0000000..c86f440
--- /dev/null
+++ b/src/mods/commands/yc_uptime.cpp
@@ -0,0 +1,46 @@
+/*:*
+ *: File: ./src/mods/commands/yc_uptime.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+
+ user *p_user = (user*) c->elem[1]; // the corresponding user
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
+
+ string s_msg = p_conf->get_elem("chat.msgs.uptime") + p_timr->get_uptime() + "<br>\n";
+
+ p_user->msg_post( &s_msg );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_users.cpp b/src/mods/commands/yc_users.cpp
new file mode 100644
index 0000000..f5cf3fc
--- /dev/null
+++ b/src/mods/commands/yc_users.cpp
@@ -0,0 +1,52 @@
+/*:*
+ *: File: ./src/mods/commands/yc_users.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/chat.h"
+#include "../../chat/user.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+ chat* p_chat = (chat*) ((dynamic_wrap*)c->elem[3])->CHAT;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
+ user *p_user = (user*)c->elem[1];
+
+ string s_list;
+ p_chat->get_user_list(s_list);
+ p_user->msg_post( p_conf->get_elem("chat.msgs.userlist") +
+ "<br><table>" + s_list + "</table>\n");
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/commands/yc_version.cpp b/src/mods/commands/yc_version.cpp
new file mode 100644
index 0000000..797b6c7
--- /dev/null
+++ b/src/mods/commands/yc_version.cpp
@@ -0,0 +1,47 @@
+/*:*
+ *: File: ./src/mods/commands/yc_version.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include <iostream>
+#include "../../msgs.h"
+#include "../../chat/user.h"
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int valid_color( string );
+
+ int extern_function(void *v_arg)
+ {
+ container *c=(container *)v_arg;
+ user *p_user = (user*)c->elem[1]; // the corresponding user
+ p_user->msg_post( tool::ychat_version() + "<br>\n");
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/configure b/src/mods/configure
new file mode 100755
index 0000000..839380b
--- /dev/null
+++ b/src/mods/configure
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+if ! test -f ../../g++.version
+then
+ echo You need to run ./configure of the top level source dir first
+ exit 1
+fi
+
+echo Creating module Makefiles...
+for dir in commands html
+do
+ if test -d $dir
+ then
+ cd $dir &&
+ srcs="SRCS=`ls *.cpp`" &&
+ echo $srcs > Makefile
+ compiler=`tail -n 1 ../../../g++.version`
+ sed s/COMPILER/$compiler/ Makefile.in >> Makefile &&
+ for i in *.cpp
+ do
+ echo "../../../mods/$dir/`echo $i | sed s/.cpp/.so/`: $i" >> Makefile
+ done
+ cd ..
+ fi
+done
+
diff --git a/src/mods/html/Makefile.in b/src/mods/html/Makefile.in
new file mode 100644
index 0000000..4b7c728
--- /dev/null
+++ b/src/mods/html/Makefile.in
@@ -0,0 +1,18 @@
+MODS=$(addprefix ../../../mods/html/, $(SRCS:.cpp=.so))
+CC=COMPILER
+INCLUDES=`cat ../../includes.add`
+CFLAGS=`cat ../cflags.add`
+all: mods
+$(MODS):
+ @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
+ @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/`
+ @echo -n "HTML module `basename $@ | sed s/\.so// | sed s/yc_//` "
+ @du -hc $@ | tail -n 1 | sed s/total// | sed "s/ //g"
+infotext:
+ @echo Compiling HTML modules
+mods: infotext $(MODS)
+ @echo "Num of html modules: "
+ @ls ../../../mods/html/*.so | wc -l
+clean:
+ @echo Cleaning html modules
+ @if test -d ../../../mods/html; then rm -Rf ../../../mods/html; fi
diff --git a/src/mods/html/yc_admin.cpp b/src/mods/html/yc_admin.cpp
new file mode 100644
index 0000000..9201021
--- /dev/null
+++ b/src/mods/html/yc_admin.cpp
@@ -0,0 +1,96 @@
+/*:*
+ *: File: ./src/mods/html/yc_admin.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+#include "../../tool/tool.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ string replace_chars(string s_string)
+ {
+ s_string = tool::replace(s_string, "<", "&lt;");
+ s_string = tool::replace(s_string, ">", "&gt;");
+ s_string = tool::replace(s_string, "\n", "<br>");
+ return s_string;
+ }
+
+ int extern_function(void *v_arg)
+ {
+ container* c = (container*) v_arg;
+ dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0];
+ user* p_user = (user*) c->elem[2];
+ conf* p_conf = (conf*) p_wrap->CONF;
+ string* p_content = &(*((map<string,string>*) c->elem[1]))["content"];
+
+ vector<string>* p_vec_keys = p_conf->get_key_vector();
+ sort(p_vec_keys->begin(), p_vec_keys->end());
+ vector<string>::iterator p_vec_keys_iter = p_vec_keys->begin();
+
+ p_content->append( "Currently are " + tool::int2string(p_vec_keys->size()) + " options available!<br><br>\n");
+ p_content->append( "<table bordercolor=\"1\">\n" );
+
+ for( ;p_vec_keys_iter != p_vec_keys->end(); ++p_vec_keys_iter )
+ {
+
+ if ( p_vec_keys_iter->find(".descr") != string::npos )
+ continue;
+
+ p_content->append( "<tr><td>\n<font color=\"#FFFFFF\"><b>" + *p_vec_keys_iter + "\n</b></font></td></tr>\n" );
+
+ string s_descr = p_conf->get_elem(*p_vec_keys_iter + ".descr");
+ if ( s_descr.length()
+ > 0 )
+ {
+ p_content->append( "<tr><td><font color=\"#CCCCCC\">\n" );
+ p_content->append( replace_chars(p_conf->get_elem(*p_vec_keys_iter + ".descr")) );
+ p_content->append( "\n</font></td></tr>\n" );
+ }
+
+ p_content->append( "<tr><td>\n" );
+
+ // Hide some fields!
+ if ( p_vec_keys_iter->find(".password")
+ != string::npos
+ || p_vec_keys_iter->find("base.user") != string::npos
+ || p_vec_keys_iter->find(".dbname") != string::npos )
+ p_content->append( "X X X X X X X X X X" );
+
+ else
+ p_content->append( replace_chars(p_conf->get_elem(*p_vec_keys_iter)) );
+
+ p_content->append( "<br><br></td></tr>\n" );
+ } // while
+
+ p_content->append( "</table>\n<br>\n" );
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/html/yc_colors.cpp b/src/mods/html/yc_colors.cpp
new file mode 100644
index 0000000..4f717ad
--- /dev/null
+++ b/src/mods/html/yc_colors.cpp
@@ -0,0 +1,61 @@
+/*:*
+ *: File: ./src/mods/html/yc_colors.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container* c = (container*) v_arg;
+ dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0];
+ conf* p_conf = (conf*) p_wrap->CONF;
+ string* p_col1 = &(*((map<string,string>*) c->elem[1]))["col1"];
+ string* p_col2 = &(*((map<string,string>*) c->elem[1]))["col2"];
+ string* p_flag = &(*((map<string,string>*) c->elem[1]))["flag"];
+ user* p_user = (user*) c->elem[2];
+
+ p_col1->erase(0);
+ p_col2->erase(0);
+
+ p_col1->append( p_user->get_col1() );
+ p_col2->append( p_user->get_col2() );
+
+ if ( *p_flag == "submit" )
+ {
+ string* p_msgs = &(*((map<string,string>*) c->elem[1])
+ )["msgs"];
+ p_msgs->append( p_conf->get_elem( "chat.msgs.optionschanged" ) );
+ }
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/html/yc_help.cpp b/src/mods/html/yc_help.cpp
new file mode 100644
index 0000000..b7a0237
--- /dev/null
+++ b/src/mods/html/yc_help.cpp
@@ -0,0 +1,74 @@
+/*:*
+ *: File: ./src/mods/html/yc_help.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container* c = (container*) v_arg;
+ dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0];
+ user* p_user = (user*) c->elem[2];
+
+ modl* p_modl = (modl*) p_wrap->MODL;
+ conf* p_conf = (conf*) p_wrap->CONF;
+ chat* p_chat = (chat*) p_wrap->CHAT;
+ string* s_content = &(*((map<string,string>*) c->elem[1]))["content"];
+
+ vector<string>* p_vec_keys = p_modl->get_mod_vector();
+
+ sort(p_vec_keys->begin(), p_vec_keys->end());
+ vector<string>::iterator p_vec_keys_iter = p_vec_keys->begin();
+
+ while( p_vec_keys_iter != p_vec_keys->end() )
+ {
+
+ if ( p_vec_keys_iter->find( "mods/commands/", 0 ) != string::npos )
+ {
+
+ string s_command_name = p_vec_keys_iter->substr(17);
+ s_command_name.erase( s_command_name.find( ".so" ) );
+
+ if ( !p_chat->get_command_disabled( s_command_name ) &&
+ p_chat->get_command_status( s_command_name ) >= p_user->get_status())
+ {
+ s_content->append( "<table bordercolor=\"1\">\n" );
+ s_content->append( "<tr><td><font color=\"#FFFFFF\"><b>/" + s_command_name + "</b></font></td></tr>\n" );
+ s_content->append( "<tr><td>" + p_conf->get_elem("chat.msgs.help." + s_command_name) + "</td></tr>\n" );
+ s_content->append( "</table>\n<br>\n" );
+ }
+ }
+ p_vec_keys_iter++;
+ }
+ return 0;
+ }
+}
+
diff --git a/src/mods/html/yc_loggedin.cpp b/src/mods/html/yc_loggedin.cpp
new file mode 100644
index 0000000..6f7d020
--- /dev/null
+++ b/src/mods/html/yc_loggedin.cpp
@@ -0,0 +1,53 @@
+/*:*
+ *: File: ./src/mods/html/yc_loggedin.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../chat/chat.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container* c = (container*) v_arg;
+ dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0];
+ chat* p_chat = (chat*) p_wrap->CHAT;
+ map<string,string>* p_map = (map<string,string>*) c->elem[1];
+
+ /*
+ string s_list;
+ p_chat->get_user_list(s_list);
+ (*p_map)["USERLIST"] = s_list;
+ */
+
+ p_chat->get_user_list((*p_map)["USERLIST"]);
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/html/yc_options.cpp b/src/mods/html/yc_options.cpp
new file mode 100644
index 0000000..71d5eef
--- /dev/null
+++ b/src/mods/html/yc_options.cpp
@@ -0,0 +1,80 @@
+/*:*
+ *: File: ./src/mods/html/yc_options.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+ container* c = (container*) v_arg;
+ dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0];
+ conf* p_conf = (conf*) p_wrap->CONF;
+ string* p_flag = &(*((map<string,string>*) c->elem[1]))["flag"];
+ string* p_email = &(*((map<string,string>*) c->elem[1]))["email"];
+ string* p_pass = &(*((map<string,string>*) c->elem[1]))["pass"];
+ string* p_newpass = &(*((map<string,string>*) c->elem[1]))["newpass"];
+ string* p_newpass2 = &(*((map<string,string>*) c->elem[1]))["newpass2"];
+ user* p_user = (user*) c->elem[2];
+
+ if ( *p_flag == "submit" )
+ {
+ string* p_msgs = &(*((map<string,string>*) c->elem[1])
+ )["msgs"];
+
+ // If the password has to be changed:
+ if ( *p_pass != "" || *p_newpass != "" || *p_newpass2 != "" )
+ {
+ if ( p_user->get_pass() != *p_pass )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword" ) );
+ return 0;
+ }
+
+ if ( *p_newpass != *p_newpass2 )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword2" ) );
+ return 0;
+ }
+ p_user->set_pass( *p_newpass );
+ }
+
+ p_user->set_email( *p_email );
+ p_msgs->append( p_conf->get_elem( "chat.msgs.optionschanged" ) );
+ }
+ else
+ {
+ p_email->append( p_user->get_email() );
+ }
+
+ return 0;
+ }
+}
+
diff --git a/src/mods/html/yc_register.cpp b/src/mods/html/yc_register.cpp
new file mode 100644
index 0000000..e39deaf
--- /dev/null
+++ b/src/mods/html/yc_register.cpp
@@ -0,0 +1,120 @@
+/*:*
+ *: File: ./src/mods/html/yc_register.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../../incl.h"
+
+/*
+ gcc -shared -o yc_name.so yc_name.cpp
+*/
+
+using namespace std;
+
+extern "C"
+{
+ int extern_function(void *v_arg)
+ {
+#ifdef DATABASE
+ container* c = (container*) v_arg;
+ dynamic_wrap* p_wrap = (dynamic_wrap*) c->elem[0];
+ conf* p_conf = (conf*) p_wrap->CONF;
+ data* p_data = (data*) p_wrap->DATA;
+ string* p_msgs = &(*((map<string,string>*) c->elem[1]))["INFO"];
+ string* p_nick = &(*((map<string,string>*) c->elem[1]))["nick"];
+ string* p_email = &(*((map<string,string>*) c->elem[1]))["email"];
+ string* p_pass = &(*((map<string,string>*) c->elem[1]))["pass"];
+ string* p_pass2 = &(*((map<string,string>*) c->elem[1]))["pass2"];
+ string* p_request = &(*((map<string,string>*) c->elem[1]))["request"];
+ user* p_user = (user*) c->elem[2];
+ string s_nick = *p_nick;
+
+
+ p_user->set_name( "!" + s_nick );
+ p_user->set_has_sess( false );
+ *p_nick = tool::to_lower(*p_nick);
+
+ if ( *p_pass != *p_pass2 )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.registerpassword" ) )
+ ;
+ }
+
+ // prove if the nick is alphanumeric:
+ else if ( ! tool::is_alpha_numeric( *p_nick ) )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.alpnum" ) )
+ ;
+ }
+
+ // prove if the nick is too long:
+ else if ( p_nick->length() > tool::string2int( p_conf->get_elem("chat.maxlength.username")
+ ) )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.nicklength" ) );
+ }
+ else if ( p_pass->length() > tool::string2int( p_conf->get_elem("chat.maxlength.password")
+ ) )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.passlength" ) );
+ }
+ else if ( p_email->length() > tool::string2int( p_conf->get_elem("chat.maxlength.emailaddress")
+ ) )
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.emaillength" ) );
+ }
+ else
+ {
+ hashmap<string> result_map = p_data->select_user_data( *p_nick, "selectnick" );
+ if (result_map["nick"] == *p_nick)
+ {
+ p_msgs->append( p_conf->get_elem( "chat.msgs.err.registerexists" ) );
+ }
+ else
+ {
+ p_user->set_name( s_nick );
+ p_msgs->append( p_conf->get_elem( "chat.msgs.registernick" ) );
+ p_request->replace( 0, p_request->length(), p_conf->get_elem("httpd.startsite") );
+
+ map<string,string> map_insert = *((map<string,string>*) c->elem[1]);
+ map_insert["password"] = *p_pass;
+ map_insert["color1"] = p_conf->get_elem("chat.html.user.color1");
+ map_insert["color2"] = p_conf->get_elem("chat.html.user.color2");
+ map_insert["registerdate"] = tool::int2string((int)tool::unixtime());
+
+ p_user->set_pass( map_insert["password"] );
+ p_user->set_email( map_insert["email"] );
+ p_user->set_col1( map_insert["color1"] );
+ p_user->set_col2( map_insert["color2"] );
+ p_user->set_is_reg( 1 );
+ p_user->set_status( tool::string2int(p_conf->get_elem("chat.defaultrang") ) );
+
+ p_data->insert_user_data( *p_nick, "registernick", map_insert );
+ }
+ }
+
+ return 0;
+#endif
+
+ }
+}
+
diff --git a/src/monitor/dump.cpp b/src/monitor/dump.cpp
new file mode 100644
index 0000000..3927241
--- /dev/null
+++ b/src/monitor/dump.cpp
@@ -0,0 +1,141 @@
+/*:*
+ *: File: ./src/monitor/dump.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef DUMP_CPP
+#define DUMP_CPP
+
+#include "dump.h"
+
+using namespace std;
+
+const string dumpable::s_sep = "->";
+const int dumpable::i_max_level = 100;
+
+dumpable::dumpable()
+{
+ initialize(0);
+}
+
+void
+dumpable::initialize(int i_level)
+{
+ this->i_level = i_level;
+ this->i_lined = i_level;
+ this->b_lined = false;
+ this->b_next_no_nl = false;
+ this->s_dump = "";
+}
+
+string
+dumpable::dump()
+{
+ return dump(0);
+}
+
+string
+dumpable::dump(int i_level)
+{
+ initialize(i_level);
+ dumpit();
+ return s_dump;
+}
+
+void
+dumpable::add(string s_line)
+{
+ if ( i_lined > i_max_level )
+ i_lined = i_max_level;
+
+ if (!b_lined)
+ s_dump.append(s_sep);
+
+ else for ( int i = 0; i < i_lined; ++i )
+ s_dump.append(" ");
+
+ s_dump.append(s_line);
+
+ if (b_next_no_nl)
+ b_next_no_nl = false;
+
+ else
+ s_dump.append("\n");
+
+ if (!b_lined) {
+ b_lined = true;
+ i_lined = i_level + s_sep.length();
+ }
+}
+
+int
+dumpable::get_level() const
+{
+ return i_lined;
+}
+
+dump::dump(vector<string> vec_params)
+{
+ if (vec_params.empty())
+ {
+ cout << CLIPRMO << "all conf sock";
+ cout << " chat modl sman"; //<< Not for yhttpd
+ cout << endl;
+ return;
+ }
+
+ cout << run(vec_params);
+}
+
+string
+dump::run(vector<string> &vec_params)
+{
+ string s_ret("");
+ string s_part;
+
+ vector<string>::iterator iter;
+ for (iter = vec_params.begin(); iter != vec_params.end(); ++iter)
+ {
+ s_part = *iter;
+
+ if (!s_part.compare("conf") || !s_part.compare("all"))
+ s_ret.append(wrap::CONF->dump());
+
+ if (!s_part.compare("sock") || !s_part.compare("all"))
+ s_ret.append(wrap::SOCK->dump());
+
+ //<<*
+ if (!s_part.compare("modl") || !s_part.compare("all"))
+ s_ret.append(wrap::MODL->dump());
+
+ if (!s_part.compare("sman") || !s_part.compare("all"))
+ s_ret.append(wrap::SMAN->dump());
+
+ if (!s_part.compare("chat") || !s_part.compare("all"))
+ s_ret.append(wrap::CHAT->dump());
+ //*>>
+ }
+
+ return s_ret;
+}
+
+#endif
diff --git a/src/monitor/dump.h b/src/monitor/dump.h
new file mode 100644
index 0000000..30da644
--- /dev/null
+++ b/src/monitor/dump.h
@@ -0,0 +1,75 @@
+/*:*
+ *: File: ./src/monitor/dump.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef DUMP_H
+#define DUMP_H
+
+using namespace std;
+
+class dumpable
+{
+private:
+ int i_level;
+ int i_lined;
+ bool b_lined;
+ bool b_next_no_nl;
+ string s_dump;
+
+ static const string s_sep;
+ static const int i_max_level;
+
+ virtual void dumpit() = 0;
+ void initialize(int i_level);
+ void reset();
+
+protected:
+ void add(unsigned i_num)
+ { add("<unsigned>"); }
+
+ void add(int i_num)
+ { add("<int>"); }
+
+ void add(string s_line);
+ dumpable();
+
+ void next_no_newline()
+ { b_next_no_nl = true; }
+
+public:
+ string dump();
+ string dump(int i_level);
+ int get_level() const;
+};
+
+class dump
+{
+private:
+ string run(vector<string> &vec_params);
+public:
+ dump(vector<string> vec_params);
+};
+
+#endif
diff --git a/src/monitor/stats.cpp b/src/monitor/stats.cpp
new file mode 100644
index 0000000..28661f5
--- /dev/null
+++ b/src/monitor/stats.cpp
@@ -0,0 +1,174 @@
+/*:*
+ *: File: ./src/monitor/stats.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef STATS_CPP
+#define STATS_CPP
+
+#include "stats.h"
+
+using namespace std;
+
+stats::stats()
+{
+ i_rusage_vec_size = tool::string2int(
+ wrap::CONF->get_elem("httpd.stats.rusagehistory"));
+
+ i_num_rooms = 0; //<<
+
+ pthread_mutex_init( &mut_vec_rusage, NULL );
+ pthread_mutex_init( &mut_num_rooms, NULL ); //<<
+
+}
+
+stats::~stats()
+{
+ pthread_mutex_destroy( &mut_vec_rusage );
+ pthread_mutex_destroy( &mut_num_rooms ); //<<
+}
+
+void
+stats::update_rusage_history()
+{
+ wrap::system_message(STATUPR);
+
+ rusage* p_rusage = new rusage;
+ getrusage( RUSAGE_SELF, p_rusage );
+
+ map<string,long> map_rusage;
+
+ map_rusage["ru_maxrss"] = p_rusage->ru_maxrss;
+ map_rusage["ru_ixrss"] = p_rusage->ru_ixrss;
+ map_rusage["ru_idrss"] = p_rusage->ru_idrss;
+ map_rusage["ru_isrss"] = p_rusage->ru_isrss;
+ map_rusage["ru_minflt"] = p_rusage->ru_minflt;
+ map_rusage["ru_majflt"] = p_rusage->ru_majflt;
+ map_rusage["ru_nswap"] = p_rusage->ru_nswap;
+ map_rusage["ru_inblock"] = p_rusage->ru_inblock;
+ map_rusage["ru_oublock"] = p_rusage->ru_oublock;
+ map_rusage["ru_msgsnd"] = p_rusage->ru_msgsnd;
+ map_rusage["ru_msgrcv"] = p_rusage->ru_msgrcv;
+ map_rusage["ru_nsignals"] = p_rusage->ru_nsignals;
+ map_rusage["ru_nvcsw"] = p_rusage->ru_nvcsw;
+ map_rusage["ru_nivcsw"] = p_rusage->ru_nivcsw;
+
+ delete p_rusage;
+
+ pthread_mutex_lock ( &mut_vec_rusage );
+
+ if ( vec_rusage_history.size() >= i_rusage_vec_size )
+ vec_rusage_history.erase( vec_rusage_history.begin() );
+
+ vec_rusage_history.push_back(map_rusage);
+
+ pthread_mutex_unlock( &mut_vec_rusage );
+}
+
+void
+stats::set_rusage_vec_size( int i_rusage_vec_size )
+{
+ pthread_mutex_lock ( &mut_vec_rusage );
+ this->i_rusage_vec_size = i_rusage_vec_size;
+ pthread_mutex_unlock( &mut_vec_rusage );
+}
+
+long
+stats::get_ru_maxrss()
+{
+ rusage* p_rusage = new rusage;
+ getrusage( RUSAGE_SELF, p_rusage );
+
+ long l_ret = p_rusage->ru_maxrss;
+ delete p_rusage;
+
+ return l_ret;
+}
+
+string
+stats::get_rusage_history( string s_type, string s_seperator )
+{
+ string s_ret;
+ int i_count = 0;
+ vector< map<string,long> >::iterator iter;
+
+ pthread_mutex_lock ( &mut_vec_rusage );
+
+ for ( iter = vec_rusage_history.begin();
+ iter != vec_rusage_history.end();
+ iter++, i_count++ )
+ s_ret.append(s_seperator +
+ tool::int2string(i_count) + ". " + iter->find(s_type)->first + " " +
+ tool::int2string( iter->find(s_type)->second) + "\n");
+
+ pthread_mutex_unlock( &mut_vec_rusage );
+
+ return s_ret;
+}
+
+//<<*
+int
+stats::get_num_rooms()
+{
+ pthread_mutex_lock ( &mut_num_rooms );
+ int i_ret = i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+ return i_ret;
+}
+
+void
+stats::increment_num_rooms()
+{
+ pthread_mutex_lock ( &mut_num_rooms );
+ ++i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+#ifdef NCURSES
+
+ print_num_rooms();
+#endif
+}
+void
+stats::decrement_num_rooms()
+{
+ pthread_mutex_lock ( &mut_num_rooms );
+ --i_num_rooms;
+ pthread_mutex_unlock( &mut_num_rooms );
+#ifdef NCURSES
+
+ print_num_rooms();
+#endif
+}
+
+#ifdef NCURSES
+void
+stats::print_num_rooms()
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_NUM_ROOMS_X, NCUR_NUM_ROOMS_Y, "Rooms: %d", get_num_rooms());
+ refresh();
+}
+#endif
+//*>>
+
+#endif
diff --git a/src/monitor/stats.h b/src/monitor/stats.h
new file mode 100644
index 0000000..87755ab
--- /dev/null
+++ b/src/monitor/stats.h
@@ -0,0 +1,73 @@
+/*:*
+ *: File: ./src/monitor/stats.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef STATS_H
+#define STATS_H
+
+#include "../tool/tool.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+using namespace std;
+
+class stats
+{
+private:
+ // Specifies the max. amount of elements in vec_rusage_history;
+ int i_rusage_vec_size;
+ // History of the last i_rusage_vec_size rusage values.
+ vector< map<string,long> > vec_rusage_history;
+ pthread_mutex_t mut_vec_rusage;
+
+ int i_num_rooms; //<<
+ pthread_mutex_t mut_num_rooms; //<<
+
+ void set_rusage_vec_size( int i_rusage_vec_size );
+
+public:
+ stats( );
+ ~stats( );
+
+ //<<*
+ int get_num_rooms();
+ void increment_num_rooms();
+ void decrement_num_rooms();
+ //*>>
+ void update_rusage_history();
+ string get_rusage_history( string s_type, string s_seperator );
+ long get_ru_maxrss();
+ //<<*
+#ifdef NCURSES
+
+ void print_num_rooms();
+#endif
+ //*>>
+};
+
+#endif
diff --git a/src/msgs.h b/src/msgs.h
index 50a5131..3a341cf 100644
--- a/src/msgs.h
+++ b/src/msgs.h
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/msgs.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -24,42 +25,136 @@
#ifndef MSGS_H
#define MSGS_H
+// alphabetical ordered:
+#define ACCPERR "Sock: Accept error "
+#define BINDERR "Sock: Bind error "
+#define CHATREP "Chat: Using replacement strings"
+#define CHATDOP "Chat: Default operator login "
+#define CFILEOK "Parsing config file"
+#define CFILEFA "Failed opening config file!"
+#define CONTACT "Contact: http://www.yChat.org, Mail@yChat.org, ICQ: 11655527"
+#define CLRHTML "HTML: Cleared the document cache "
+#define CLIWELC "Command Line Interface (type help for a list of all commands)"
+#define CLIPRMO ">> "
+#define CLIPRMI "<< "
+#define CLIHELP "Unknown command (use help)"
+#define CLIMSQL "Spawing system mysql client (enter exit to return)"
+#define CLISHEL "Spawing system shell (enter exit to return)"
+#define DATAADD "Data: Adding used connection into the queue"
+#define DATADIS "Data: Closing all connections"
+#define DATADI2 "Data: Closing idle connection ("
+#define DATAQUE "Data: "
+#define DATAGET "Data: Using database connection queue "
+#define DATAIN0 "Data: Initializing maxcon to "
+#define DATAIN1 "Data: Initializing mincon to "
+#define DATAMAX "Data: Max database connections reached "
+#define DATAMA0 "Data: Max database connections "
+#define DATANEW "Data: Creating new database connection "
+#define DESCRIP "Copyright (C) 2003 Paul C. Buetow, Volker Richter"
+#define DESCRI2 "Copyright (C) 2004, 2005 Paul C. Buetow"
+#define DONEMSG "done"
+#define DOWNMSG "Shutting down "
+#define GARBAGE "Garbage: Initializing collector "
+#define GARBACT "Garbage collector activated "
+#define GAROFFNE "Garbage: No garbage to remove available "
+#define GARROOM "Garbage: Added room "
+#define GARUSER "Garbage: Added user "
+#define GARUSE2 "Garbage: Recycle user "
+#define LISTERR "Sock: Listen error "
+#define LOGGINI "Logging: Init on "
+#define LOGERR1 "Logging: Could not open logfile "
+#define LOGERR2 "Logging: No filename specified "
+#define LOGINER "Chat: Login failed (password), nick: "
+#define LOGINE0 "Chat: Login failed (empty nick)"
+#define LOGINE1 "Chat: Login failed (alpha nick), nick: "
+#define LOGINE2 "Chat: Login failed (nick length), nick: "
+#define LOGINE3 "Chat: Login failed (room length), nick/room: "
+#define LOGINE4 "Chat: Login failed (guests disabled), nick: "
+#define LOGINE5 "Chat: Login failed (not enough threads), nick: "
+#define MODULEC "Modl: Caching "
+#define MODULER "Modl: Requesting "
+#define MODUNLO "Modl: Unloading all modules "
+#define MODRELO "Modl: Reloading all modules "
-// several error messages which will apear by the clients.
-#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>"
+#ifdef DATABASE
+#define MYSQLQU "MySQL: "
+#define MYSQLQ2 "MySQL: Adding query "
+#define MYSQLE1 "MySQL: Error running mysql_init "
+#endif
-// all the custom messages for verbosity outputs. this messages may not
-// be used for html-template value substituation except the CONTACT and
-// DESCRIP variables. the verbosity output will appear in the standard
-// output of the server.
-// alphabetical ordered.
-#define CFILEOK "Parsing config file "
-#define CFILENO "Failed opening config file "
-#define CONNECT "Receiving connection "
-#define CONTACT "Homepage: http://www.yChat.org"
-#define DESCRIP "yChat Server Daemon"
-#define DESCRI2 "Copyright (C) 2003 Paul C. Buetow, Volker Richer"
-#define DESCRI3 "Copyright (C) 2005 Paul C. Buetow"
-#define DESCRI4 "Copyright (C) 2005 EXA Digital Solutions GbR"
-#define DOWNMSG "Shutting down "
-#define LOGINPR "Login procedure succeeded for nick "
-#define MODULEC "Caching module "
-#define NEWROOM "Adding room "
+#ifdef CTCSEGV
+#define SIGNSEG "Signal: Received SIGSEGV"
+#endif
+
+#define NCURADM "ADMINISTRATOR's MAIN MENU"
+#define NCURMSG "SERVER SYSTEM MESSAGES"
+#define NCURSE0 "HTTP server: "
+#define NCURSE1 "Thread pool: "
+#define NCURSE2 "Data stats: "
+#define NCURSE3 "Chat stats: "
+#define NCURSE4 "Caching: "
+#define NEWREQU "Sock: New request "
+#define NEWROOM "Chat: New room "
+#define NEWUSER "Chat: New user "
+#define OFFFOUND "HTML: File not found "
+#define PERMSTD "Reading standard command exec permissions"
#define POOLER1 "Pool: Did not allocate all threads ("
#define POOLER2 "Pool: Max pool size reached ("
#define POOLFLL "Pool: Allocating new threads ("
-#define REQUEST "Request string "
-#define SEPERAT "----------------------------------------- "
-#define SOCKCRT "Creating server socket "
-#define SOCKERR "Could not create socket. Trying next port "
-#define SOCKRDY "Server socket is ready. See port above "
-#define STARTMS "Starting up "
-#define TECACHE "Caching template "
-#define THREADS "Starting thread job "
-#define THREADE "Exiting thread job "
-#define VERSION "Version: yChat 0.5.6-BASIC"
+#define READERR "Sock: Read error "
+#define REMROOM "Garbage: Removing room "
+#define REMUSER "Garbage: Removing user "
+#define REQUEST "Reqp: Request string "
+#define SELCERR "Sock: Select error "
+#define SEPERAT "-----------------------"
+#define SESSION "Session: Count "
+#define SESSDMP "Session: Dump of session"
+#define SESSERR "Session: Could not find session "
+#define SESSEXI "Session: New TempID already exists, recalc."
+#define SHELLER "Shell: Could not execute command"
+#define SHELLEX "Shell: Executing the following command:"
+#define SIGSIGV "Signal: SIGV received!"
+#define STATUPR "Stats: Updated rusage history"
+#define STATRSS "Stats: Max resident set size "
+#define REUROOM "Garbage: Reusing room object "
+#define SOCKER1 "Sock: Can't create socket, aborting"
+#define SOCKUNS "Sock: Starting hypertext transport [HTTP]"
+#define SOCKCLN "Sock: Initializing a client socket at "
+#define SOCKCON "Sock: Connecting to "
+#define SOCKCRT "Sock: Created socket on "
+#define SOCKSRV "Sock: Initializing server socket "
+#define SOCKERR "Sock: Can't create socket, trying next port "
+#define SOCKER2 "Sock: Unknown hostname "
+#define SOCKRDY "Sock: Server socket is ready "
+#define SOCKCAC "Sock: Caching IP "
+#define SOCKCA2 "Sock: Cleaning IP cache ("
+#define TECACHE "HTML: Caching document "
+#define THRDSTR "Thread: Running"
+#define TIMERAT "Timer: User autoaway timeout "
+#define TIMERIN "Timer: Initializing "
+#define TIMEROF "Timer: Setting offset to "
+#define TIMERTH "Timer: Starting timer thread "
+#define TIMERTO "Timer: User logout timeout "
+#define TIMERUP "Timer: System uptime "
+#define XMLREAD "XML: Reading "
+#define XMLERR "XML Error: "
+#define XMLER1 "XML Error: Unable to load file "
+#define VERSION "0.7.9.6"
+#define BRANCH "STABLE"
+#define BUILDNR 3810
+#define UNAME "FreeBSD 6.1-RELEASE-p4 i386"
+#define COMPOPT "Using built-in specs.; Configured with: FreeBSD/i386 system compiler; Thread model: posix; gcc version 3.4.4 [FreeBSD] 20050518; 3.4; g++"
+#define YCUSAGE "Usage: ./ychat {h|v}|{o confkey confvalue}\n"
+
+#define HEADER1 "HTTP/1.1 200 OK\r\n"
+#define HEADER2 "Server: yChat/" VERSION "-" BRANCH "\r\n"
+#define HEADER3 "Cache-control: no-cache\r\n"
+#define HEADER4 "Pragma: no-cache\r\n"
+#define HEADER5 "Transfer-Encoding: chunked\r\n"
+#define HEADER6 "Connection: keep-alive\r\n"
+#define HEADER7 "Content-Length: ";
+#define HEADER8 "Content-Type: ";
+#define HEADER8b "; charset=ISO-8859-1\r\n";
+#define HEADER9 "Allow: GET\r\n";
#endif
diff --git a/src/name.cpp b/src/name.cpp
index 5860a00..134fd11 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/name.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,34 +22,52 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// class name implementation.
-
-#ifndef NAME_CXX
-#define NAME_CXX
+#ifndef NAME_CPP
+#define NAME_CPP
#include "name.h"
+#include "tool/tool.h"
using namespace std;
+name::name()
+{
+ pthread_mutex_init( &mut_s_name, NULL);
+}
+
name::name( string s_name )
{
- set_name( s_name );
+ pthread_mutex_init( &mut_s_name, NULL);
+ set_name( s_name );
}
name::~name()
-{}
+{
+ pthread_mutex_destroy( &mut_s_name );
+}
string
-name::get_name() const
+name::get_name()
{
- return s_name;
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_name );
+ s_ret = s_name;
+ pthread_mutex_unlock( &mut_s_name );
+ return s_ret;
+}
+
+string
+name::get_lowercase_name()
+{
+ return tool::to_lower( get_name() );
}
void
name::set_name( string s_name )
{
- this->s_name = s_name;
+ pthread_mutex_lock ( &mut_s_name );
+ this->s_name = s_name;
+ pthread_mutex_unlock( &mut_s_name );
}
-
#endif
diff --git a/src/name.h b/src/name.h
index ea9563d..26040f5 100644
--- a/src/name.h
+++ b/src/name.h
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/name.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,33 +22,27 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// class name declaration.
+#include "incl.h"
#ifndef NAME_H
#define NAME_H
-#include "incl.h"
-
using namespace std;
class name
{
protected:
- // private members:
- string s_name; // object's name.
+ string s_name; // object's name.
+ pthread_mutex_t mut_s_name;
public:
- 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( );
+ virtual string get_name ( );
+ virtual string get_lowercase_name ( );
+ virtual void set_name ( string s_name );
+ name();
+ name( string s_name ); // a standard constructor.
+ ~name();
};
#endif
diff --git a/src/ncur/menu.cpp b/src/ncur/menu.cpp
new file mode 100644
index 0000000..f28c4ef
--- /dev/null
+++ b/src/ncur/menu.cpp
@@ -0,0 +1,141 @@
+/*:*
+ *: File: ./src/ncur/menu.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+
+#include "menu.h"
+
+#ifdef NCURSES
+
+#ifndef MENU_CPP
+#define MENU_CPP
+
+using namespace std;
+
+menu::menu( int i_startx, int i_starty, int i_width, int i_height, char *c_header, char **choices, int i_numchoices, const chtype ch )
+{
+ this->i_startx = i_startx;
+ this->i_starty = i_starty;
+ this->i_height = i_height;
+ this->i_width = i_width;
+ this->c_header = c_header;
+ this->choices = choices;
+ this->i_numchoices = i_numchoices;
+
+ initialize( ch );
+}
+
+menu::~menu()
+{
+ /*
+ wborder(win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
+ wrefresh(win);
+ delwin(win);
+ */
+}
+
+void
+menu::initialize( const chtype ch )
+{
+ this->i_highlight = 1;
+ this->i_choice = 0;
+
+ win = newwin( i_height, i_width, i_starty, i_startx );
+ wbkgd(win, ch);
+}
+
+void
+menu::display()
+{
+ int x, y, i;
+
+ x = 2;
+ y = 2;
+
+ box( win, 0, 0 );
+ mvwprintw( win, y++, x, "%s", c_header );
+
+ for( i = 0; i < i_numchoices; i++ )
+ {
+ ++y;
+
+ if( i_highlight == i+1 ) // Highlight the current selection.
+ {
+ wattron( win, A_REVERSE);
+ mvwprintw( win, y, x, "%d. %s", i, choices[i]);
+ wattroff( win, A_REVERSE);
+ } else
+ {
+ mvwprintw( win, y, x, "%d. %s", i, choices[i]);
+ }
+ }
+
+ wrefresh( win );
+}
+
+void
+menu::start( void (*swich_case_menu_action)(int) )
+{
+ refresh();
+ bool b_flag = 1;
+
+ while( b_flag )
+ {
+ keypad(win, 1);
+ display();
+ c = wgetch( win );
+
+ switch(c)
+ {
+ case KEY_UP:
+ if( i_highlight == 1 )
+ i_highlight = i_numchoices;
+ else
+ --i_highlight;
+ break;
+
+ case KEY_DOWN:
+ if( i_highlight == i_numchoices )
+ i_highlight = 1;
+ else
+ ++i_highlight;
+ break;
+
+ case 10:
+ i_choice = i_highlight;
+ break;
+
+ default:
+ mvprintw( NCUR_MENU_CHAR_X, NCUR_MENU_CHAR_Y, "%3d %c ", c, c);
+ refresh();
+ break;
+ }
+
+ // Menu action.
+ ( *swich_case_menu_action ) ( i_choice );
+ i_choice = 0;
+ }
+}
+
+#endif
+#endif
diff --git a/src/ncur/menu.h b/src/ncur/menu.h
new file mode 100644
index 0000000..f0dee8b
--- /dev/null
+++ b/src/ncur/menu.h
@@ -0,0 +1,63 @@
+/*:*
+ *: File: ./src/ncur/menu.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifdef NCURSES
+
+#ifndef MENU_H
+#define MENU_H
+
+#include <ncurses.h>
+
+using namespace std;
+
+class menu
+{
+private:
+ char **choices;
+ char *c_header;
+
+ int i_startx, i_starty, i_width, i_height, i_highlight, i_choice,
+ i_numchoices, c;
+
+ WINDOW *win;
+
+ void initialize( const chtype ch );
+
+public:
+ explicit menu( int i_startx, int i_starty, int i_width, int i_height, char *c_header, char **choices, int i_numchoices, const chtype ch );
+ ~menu( );
+
+ void display();
+ void start( void (*swich_case_menu_action)(int) );
+
+ void activate_menu_win()
+ {
+ keypad(win, 1);
+ }
+};
+
+#endif
+#endif
diff --git a/src/ncur/ncur.cpp b/src/ncur/ncur.cpp
new file mode 100644
index 0000000..e97823c
--- /dev/null
+++ b/src/ncur/ncur.cpp
@@ -0,0 +1,314 @@
+/*:*
+ *: File: ./src/ncur/ncur.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef NCUR_CPP
+#define NCUR_CPP
+
+#include "ncur.h"
+
+#ifdef CLI
+#include "../cli/cli.h"
+#endif
+#include "../sign.h"
+
+using namespace std;
+
+#ifdef NCURSES
+
+const string GMAKE_PARAMS[] =
+ { "clean_base", "clean_modules", "all"
+ };
+const int GMAKE_ELEMENTS = 3;
+
+ncur::ncur( )
+{
+ p_messagelist = new list<char*>;
+ pthread_mutex_init( &mut_messages, NULL );
+ pthread_mutex_init( &mut_is_ready, NULL );
+ i_message_length = 45;
+ b_is_ready = false;
+}
+
+ncur::~ncur()
+{
+ pthread_mutex_destroy( &mut_messages );
+ pthread_mutex_destroy( &mut_is_ready );
+}
+
+void
+ncur::start( void *p_void )
+{
+ ncur::init_ncurses();
+
+ char *choices[] = {
+ "Unload all modules ", //<<
+ "Reload all modules ", //<<
+ //>>" ",
+ //>>" ",
+ "Clear template cache ",
+ "Run garbage collector ", //<<
+ //>>" ",
+ "Show max res. set size ",
+ "Compile changed sources ",
+ "Recompile all sources ",
+ "Show source stats ",
+ "Command line interface ",
+ //<<*
+#ifdef DATABASE
+ "Close DB connections ",
+#else
+ " ",
+#endif
+ //*>>
+ //>>" ",
+ "Shut down server"
+ };
+
+ p_serveroutput = newwin( 19, 49, 1, 31 );
+ wbkgd(p_serveroutput, COLOR_PAIR(1));
+
+ box ( p_serveroutput, 0, 0 );
+ mvwprintw( p_serveroutput, 2, 2, NCURMSG );
+ wrefresh ( p_serveroutput );
+
+ print( string("yChat ") + VERSION );
+
+
+ p_menu = new menu( 1, 1, 30, 19, NCURADM, choices, 11, COLOR_PAIR(1));
+
+ mvprintw(NCUR_SERVER_HEADER_X,NCUR_SERVER_HEADER_Y, NCURSE0);
+ mvprintw(NCUR_POOL_HEADER_X,NCUR_POOL_HEADER_Y, NCURSE1);
+ mvprintw(NCUR_DATA_HEADER_X,NCUR_DATA_HEADER_Y, NCURSE2); //<<
+ mvprintw(NCUR_CHAT_HEADER_X,NCUR_CHAT_HEADER_Y, NCURSE3); //<<
+ mvprintw(NCUR_CACHED_HEADER_X,NCUR_CACHED_HEADER_Y, NCURSE4);
+
+ wrap::HTML->print_cached(0);
+
+ is_ready(true);
+ wrap::SMAN->print_init_ncurses(); //<<
+ wrap::STAT->print_num_rooms(); //<<
+
+ p_menu->start( &switch_main_menu_ );
+
+ shutdown();
+}
+
+void
+ncur::shutdown()
+{
+ ncur::close_ncurses();
+}
+
+
+void
+ncur::print( string *p_msg )
+{
+ print( *p_msg );
+}
+
+void
+ncur::print( string s_msg )
+{
+ print( (char*)s_msg.c_str() );
+}
+
+void
+ncur::print( char* c_print )
+{
+ // Removing \n
+ if ( strlen(c_print) > i_message_length )
+ {
+ string s_tmp(c_print);
+ print( s_tmp.substr( 0, i_message_length ) );
+ print( s_tmp.substr( i_message_length, s_tmp.length()-i_message_length ) );
+ return;
+ }
+
+ int i;
+ char* c_temp = new char[i_message_length];
+ memcpy( c_temp, c_print, strlen(c_print) );
+
+ for ( i = strlen(c_print); i < i_message_length; ++i )
+ c_temp[i] = ' ';
+
+ c_temp[i] = '\0';
+
+ pthread_mutex_lock( &mut_messages );
+
+ if ( p_messagelist->size() > 12 )
+ {
+ char* c_front = p_messagelist->front();
+ p_messagelist->pop_front();
+ free(c_front);
+ }
+
+ p_messagelist->push_back( c_temp );
+
+
+ if ( is_ready() )
+ {
+ list<char*>::iterator iter;
+ iter = p_messagelist->begin();
+
+ for ( i = 4; i < 18 && iter != p_messagelist->end(); ++i, ++iter )
+ mvwprintw( p_serveroutput, i, 2, *iter );
+
+ wrefresh ( p_serveroutput );
+ }
+
+ pthread_mutex_unlock( &mut_messages );
+}
+
+void
+ncur::switch_main_menu_( int i_choice )
+{
+ int i;
+
+ if( i_choice != 0 )
+ switch ( i_choice )
+ {
+ //<<*
+ case 1:
+ wrap::MODL->unload_modules();
+ mvprintw( 20,2, "Unloaded all modules ");
+ refresh();
+ break;
+ case 2:
+ wrap::MODL->reload_modules();
+ mvprintw( 20,2, "Reloaded all modules ");
+ refresh();
+ break;
+ //*>>
+ case 3:
+ wrap::HTML->clear_cache();
+ mvprintw( 20,2, "Cleared the template cache ");
+ refresh();
+ break;
+ case 4:
+ //<<*
+ if ( ! wrap::GCOL->remove_garbage() )
+ wrap::NCUR->print( GAROFFNE );
+ mvprintw( 20,2, "Garbage collector activated ");
+ //*>>
+ refresh();
+ break;
+ case 5:
+ mvprintw( 20,2, "Showing max resident set size in memory ");
+ wrap::NCUR->print( STATRSS + string("(") + tool::int2string(
+ wrap::STAT->get_ru_maxrss()) + string(")"));
+ break;
+ case 6:
+ tool::shell_command( string(GMAKE), METH_NCURSES);
+ break;
+ case 7:
+ for ( i = 0; i < GMAKE_ELEMENTS; i++ )
+ tool::shell_command( GMAKE + GMAKE_PARAMS[i], METH_NCURSES);
+ break;
+ case 8:
+ tool::shell_command( string(GMAKE) + " stats", METH_NCURSES);
+ break;
+ case 9:
+#ifdef CLI
+
+ wrap::NCUR->is_ready(false);
+ refresh(); /* Print it on to the real screen */
+
+ def_prog_mode(); /* Save the tty modes */
+ endwin(); /* End curses mode temporarily */
+ delete new cli(); /* Start CLI mode */
+ reset_prog_mode(); /* Return to the previous tty mode*/
+ /* stored by def_prog_mode() */
+ refresh(); /* Do refresh() to restore the */
+ /* Screen contents */
+ wrap::NCUR->is_ready(true);
+ wrap::NCUR->activate_menu_win();
+#else
+
+ mvprintw( 20,2, "CLI mode has not been compiled in! ");
+#endif
+
+ break;
+ case 10:
+#ifdef DATABASE
+
+ wrap::DATA->disconnect_all_connections(); //<<
+#endif
+
+ break;
+
+ case 11: // Shut down server
+ sign::terminate_received(0);
+ break;
+
+ default:
+ mvprintw( 20,2, "Selection # %d not yet implemented!", i_choice-1);
+ wrap::NCUR->print( "Selection not yet implemented!" );
+ refresh();
+ break;
+ }
+}
+
+void
+ncur::init_ncurses()
+{
+ initscr();
+ start_color();
+ clear();
+ noecho();
+ cbreak(); // Line buffering disabled. pass on everything
+ init_pair(1, COLOR_BLACK, COLOR_CYAN);
+ mvprintw( 0,2, (char*)(tool::ychat_version()).c_str());
+ curs_set(0);
+ refresh();
+}
+
+void
+ncur::close_ncurses()
+{
+ refresh();
+ clrtoeol();
+ refresh();
+ endwin();
+}
+
+void
+ncur::is_ready( bool b_is_ready )
+{
+ pthread_mutex_lock( &mut_is_ready );
+ this->b_is_ready = b_is_ready;
+ pthread_mutex_unlock( &mut_is_ready );
+}
+
+bool
+ncur::is_ready()
+{
+ bool b_ret;
+ pthread_mutex_lock( &mut_is_ready );
+ b_ret = b_is_ready;
+ pthread_mutex_unlock( &mut_is_ready );
+ return b_ret;
+}
+
+#endif
+#endif
diff --git a/src/ncur/ncur.h b/src/ncur/ncur.h
new file mode 100644
index 0000000..aa4bba3
--- /dev/null
+++ b/src/ncur/ncur.h
@@ -0,0 +1,75 @@
+/*:*
+ *: File: ./src/ncur/ncur.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifdef NCURSES
+
+#ifndef NCUR_H
+#define NCUR_H
+
+#include <ncurses.h>
+#include <list>
+
+#include "menu.h"
+#include "../thrd/thro.h"
+
+using namespace std;
+
+class ncur : public thro
+{
+private:
+ friend class sign;
+ menu* p_menu;
+ WINDOW* p_serveroutput;
+ list<char*>* p_messagelist; // contains the messages for p_serveroutput!
+ int i_message_length; // the maximum length of a system message!
+ bool b_is_ready; // is set to TRUE if the admin interface is initialized.
+ static void init_ncurses();
+ static void close_ncurses();
+
+ pthread_mutex_t mut_messages;
+ pthread_mutex_t mut_is_ready;
+
+public:
+ ncur();
+ ~ncur();
+
+ void start( void *p_void );
+ void print( char* c_print );
+ void print( string s_msg );
+ void print( string* p_msg );
+ void is_ready( bool b_is_ready );
+ bool is_ready();
+ static void switch_main_menu_( int i_choice );
+ void shutdown();
+
+ void activate_menu_win()
+ {
+ p_menu->activate_menu_win();
+ }
+};
+
+#endif
+#endif
diff --git a/src/reqp.cpp b/src/reqp.cpp
index 583a9aa..ee455e4 100644
--- a/src/reqp.cpp
+++ b/src/reqp.cpp
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/reqp.cpp
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,446 +22,379 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// class reqp implementation.
-
-#ifndef REQP_CXX
-#define REQP_CXX
+#ifndef REQP_CPP
+#define REQP_CPP
#include "reqp.h"
-#include "s_chat.h"
-#include "s_html.h"
-#include "s_mutx.h"
-#include "s_sock.h"
-#include "s_tool.h"
+#include "tool/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 = "Expires: 0\nCache-control: no-cache\nPragma: no-cache\n";
-string reqp::HTTP_CONNEC = "Connection: keep-alive\n";
-string reqp::HTTP_COTYPE = "Content-Type: ";
+#define HEADER HEADER1 HEADER2 HEADER3 HEADER4 HEADER9
+#define STREAM HEADER5 HEADER6
+
+const string reqp::s_http = HEADER;
+const string reqp::s_http_stream = STREAM;
+const string reqp::s_http_colength = HEADER7;
+const string reqp::s_http_cotype = HEADER8;
+const string reqp::s_http_cotype_add = HEADER8b;
reqp::reqp( )
{}
-string
-reqp::get_url( thrd* p_thrd, string s_req, map_string &map_params )
+void
+reqp::get_request_parameters( string s_parameters, map<string,string>& map_params )
{
- int i_sock = p_thrd->get_sock();
- unsigned i_pos, i_pos2;
- string s_vars( "" );
- string s_ret;
- int i_req;
-
- // GET request
- if ( s_req.find("GET") != string::npos)
- {
- // Be sure that the GET request has minimum length
- if ( s_req.length() > 5 )
- {
- // Get rid of "GET /"
- if ( (i_pos = s_req.find("\n")) == string::npos )
- i_pos = s_req.length() - 1;
-
- s_req = s_req.substr(5, i_pos - 5);
-
- // Get HTML site to be displayed
- if ( (i_pos = s_req.find("?")) == string::npos )
- {
- if ( (i_pos2 = s_req.find(" HTTP")) != string::npos )
- s_ret = url_decode( s_req.substr(0, i_pos2));
- }
- else
- {
- s_ret = url_decode( s_req.substr(0, i_pos) );
-
- // Get request parameters:
- if ( (i_pos2 = s_req.find(" HTTP")) != string::npos )
- {
- s_req = url_decode( s_req.substr(i_pos + 1, i_pos2 - i_pos - 1) );
- get_request_parameters( s_req, map_params );
- }
- }
-
- }
- }
-
- // POST request
- else
- {
- if ( (i_pos2 = s_req.find("HTTP")) != string::npos )
- {
- if ( 13 < i_pos2 )
- {
- s_ret = url_decode( s_req.substr(6,i_pos2-7) );
-
- int i_len = s_ret.length();
- int i_len2 = s_req.length()-1;
-
- s_req = s_req.substr( i_len < i_len2 ? i_len : i_len2 );
-
- if ( (i_pos = s_req.find("event=")) == string::npos)
- {
- char c_req[1024];
- i_len = read(i_sock, c_req, 1024);
- s_req = c_req;
- s_req = s_req.substr(0, i_len);
-
- if ( (i_pos = s_req.find("event=")) != string::npos )
- get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params );
- }
- else
- {
- get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params );
- }
- }
- }
- }
+ string s_tmp;
+ unsigned i_pos, i_pos2;
-#ifdef VERBOSE
-
- pthread_mutex_lock ( &s_mutx::get
- ().mut_stdout );
- cout << REQUEST << s_ret << endl;
- pthread_mutex_unlock( &s_mutx::get
- ().mut_stdout );
-#endif
+ while( (i_pos = s_parameters.find("&")) != string::npos )
+ {
+ s_tmp = s_parameters.substr(0, i_pos );
- if ( s_ret.empty() )
- s_ret = s_conf::get
- ().get_val( "STARTMPL" );
+ if ( (i_pos2 = s_tmp.find("=")) != string::npos )
+ map_params[ s_tmp.substr(0, i_pos2) ] = tool::replace( s_tmp.substr( i_pos2+1 ), "\\AND", "&");
- else
- s_ret = remove_dots(s_ret);
+ s_parameters = s_parameters.substr( i_pos + 1 );
+ }
- map_params["request"] = s_ret;
+ // Get the last request parameter, which does not have a "&" on the end!
+ if( (i_pos = s_parameters.find("=")) != string::npos )
+ map_params[ s_parameters.substr(0, i_pos) ] = s_parameters.substr( i_pos+1 );
- return s_ret;
+ //map<string,string>::iterator iter;
+ //for ( iter = map_params.begin(); iter != map_params.end(); ++iter )
+ //cout << ">>>" << iter->first << "=" << iter->second << endl;
}
-/*
string
-reqp::get_url( thrd* p_thrd, string s_req, map_string &map_params )
+reqp::get_url( string s_req, map<string, string> &map_params, int& i_postpayloadoffset )
{
- auto unsigned int pos;
- string s_ret ( "" );
+ unsigned i_pos, i_pos2;
string s_vars( "" );
- auto int i_request;
-
- i_request= ( s_req.find("GET",0) != string::npos ) ? RQ_GET : RQ_POST;
-
- pos = s_req.find( "HTTP", 0 );
+ string s_ret;
+ int i_req;
- if( i_request == RQ_GET )
- s_ret.append( s_req.substr( 5, pos-6 ) );
- else
- s_ret.append( s_req.substr( 6, pos-7 ) );
-
- // remove ".." from the request.
- do
+ // GET request
+ if ( s_req.find("GET") != string::npos)
{
- pos = s_ret.find( "../", 0 );
-
- if ( pos == string::npos )
- break;
+ // Be sure that the GET request has minimum length
+ if ( s_req.length() > 5 )
+ {
+ // Get rid of "GET /"
+ if ( (i_pos = s_req.find("\n")) == string::npos )
+ i_pos = s_req.length() - 1;
+
+ s_req = s_req.substr(5, i_pos - 5);
+
+ // Get HTML site to be displayed
+ if ( (i_pos = s_req.find("?")) == string::npos )
+ {
+ if ( (i_pos2 = s_req.find(" HTTP")) != string::npos )
+ s_ret = url_decode( s_req.substr(0, i_pos2));
+ }
+ else
+ {
+ s_ret = url_decode( s_req.substr(0, i_pos) );
+
+ // Get request parameters:
+ if ( (i_pos2 = s_req.find(" HTTP")) != string::npos )
+ {
+ s_req = url_decode( s_req.substr(i_pos + 1, i_pos2 - i_pos - 1) );
+ get_request_parameters( s_req, map_params );
+ }
+ }
- s_ret.replace( pos, pos+2, "" );
+ }
}
- while( true );
- // do not add the string behind "?" tp s_ret and add all params behind "?" to map_params.
- if( i_request == RQ_GET )
- pos = s_ret.find( "?", 0 );
+ // POST request
else
- pos = s_req.find("\r\n\r\n", 0);
-
- auto string s_params( "" );
- if ( pos != string::npos )
- {
- if( i_request == RQ_GET )
- s_params.append( s_ret.substr( pos+1, s_ret.length() -pos-1 ) );
-
- else
- s_params = s_req.substr( pos+4, s_req.length() -pos-1 );
-
- s_ret = s_ret.substr( 0, pos );
- }
-
- if ( i_request == RQ_POST && s_params.empty() )
- {
- char c_req[READBUF];
-
- if ( read ( p_thrd->get_sock() , c_req, READBUF ) <= 0 )
- return "NOBYTE";
-
- s_params = string( strstr( c_req, "event" ) );
- }
-
- auto unsigned int pos2;
- do
{
- pos = s_params.find( "=", 0 );
- if ( pos == string::npos )
- break;
-
- pos2 = s_params.find( "&", 0 );
- if ( pos2 == string::npos )
+ if ( (i_pos2 = s_req.find("HTTP")) != string::npos )
{
- auto string sValue( s_params.substr(pos+1, s_params.length()-pos-1) );
- auto string tmpstr( url_decode(sValue) );
- map_params[ s_params.substr( 0, pos ) ] = tmpstr;
- break;
+ if (i_pos2 > 13)
+ {
+ s_ret = url_decode( s_req.substr(6,i_pos2-7) );
+
+ //wrap::system_message(s_req);
+ //wrap::system_message(string("data offset=") + tool::int2string(i_postpayloadoffset));
+ i_pos = s_req.find("event=",i_postpayloadoffset );
+ if(i_pos != string::npos)
+ {
+ get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params);
+ }
+ }
}
- auto string s_temp= s_params.substr( pos+1, pos2-pos-1 );
- map_params[ s_params.substr( 0, pos ) ] = url_decode(s_temp);
-
- s_params = s_params.substr( pos2+1, s_params.length()-pos2-1 );
}
- while( true );
#ifdef VERBOSE
-
- pthread_mutex_lock ( &s_mutx::get
- ().mut_stdout );
- cout << REQUEST << s_ret << endl;
- pthread_mutex_unlock( &s_mutx::get
- ().mut_stdout );
+ wrap::system_message( REQUEST + s_ret );
#endif
if ( s_ret.empty() )
- s_ret = s_conf::get
- ().get_val( "STARTMPL" );
+ s_ret = wrap::CONF->get_elem( "httpd.startsite" );
+
+ else
+ s_ret = remove_dots(s_ret);
map_params["request"] = s_ret;
return s_ret;
}
-*/
string
-reqp::get_content_type( string s_file )
+reqp::get_content_type(string &s_file)
{
- string s_ext=s_tool::getExtension( s_file );
+ string s_ext(tool::get_extension( s_file ));
- if(s_ext=="")
- s_ext="DEFAULT";
+ if( s_ext == "" )
+ s_ext = "default";
- return s_conf::get
- ().get_val( "CT_"+s_ext );
+ return wrap::CONF->get_elem( "httpd.contenttypes." + s_ext );
}
+
void
-reqp::parse_headers( string s_req, map_string &map_params )
+reqp::parse_headers( string s_req, map<string,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));
+ int pos = s_req.find("\n");
- 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));
+ if (pos != string::npos)
+ {
+ map_params["QUERY_STRING"] = tool::trim(s_req.substr(0,pos-1));
- map_params[key]=value;
+ int pos2;
+ do
+ {
+ string s_line( s_req.substr(0, pos) );
+ pos2 = s_line.find(":");
+ if (pos2 != string::npos && s_line.length() > pos2+1)
+ map_params[ tool::trim(s_line.substr(0, pos2)) ] = tool::trim(s_line.substr(pos2+1));
- }
- s_req=s_req.substr(s_line.size()+1);
- pos=s_req.find("\n");
+ s_req = s_req.substr( s_line.size() + 1 );
+ pos = s_req.find("\n");
}
-
+ while( pos != string::npos);
+ } // if
}
-
int
-reqp::htoi(string *s)
+reqp::htoi(string *p_str)
{
- int value;
- int c;
+ int value, c;
+ c = p_str->at(0);
- c=s->c_str()[0];
- if(isupper(c))
- c=tolower(c);
+ if( isupper(c) )
+ c = tolower(c);
- value=(c>='0' && c<='9'?c-'0':c-'a'+10)*16;
+ value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16;
- c=s->c_str()[1];
- if(isupper(c))
- c=tolower(c);
+ c = p_str->at(1);
- value+=c>='0' && c<='9'?c-'0':c-'a'+10;
- return value;
+ if( isupper(c) )
+ c = tolower(c);
+
+ value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10;
+
+ return value;
}
string
-reqp::url_decode( string s_str )
+reqp::url_decode( string s_url )
{
- auto string sDest="";
- int len = s_str.size();
+ string s_dest = "";
+ int i_len = s_url.size();
+ int i_prv = i_len - 2;
- for(int i=0;i<len;i++)
+ char c;
+ for( int i = 0; i < i_len; ++i)
+ {
+ c = s_url.at(i);
+ if( c == '+' )
{
- char ch = s_str.at(i);
- if(ch=='+')
- {
- sDest+=" ";
- }
- else if(ch=='%')
- {
- auto string sTmp=s_str.substr(i+1,2);
- ch=(char)htoi(&sTmp);
- sDest+=ch;
- i+=2;
-
- }
- else
-
- sDest+=ch;
+ s_dest += " ";
+ }
+ else if (c == '%' && i < i_prv)
+ {
+ string s_tmp = s_url.substr(i+1, 2);
+ c = (char) htoi(&s_tmp);
+ s_dest += c;
+ i += 2;
+ }
+ else
+ {
+ s_dest += c;
}
- return sDest;
+ }
+
+ return s_dest;
}
string
reqp::get_from_header( string s_req, string s_hdr )
{
- auto unsigned int pos[2];
- pos[0] = s_req.find( s_hdr, 0 );
- pos[1] = s_req.find( "\n", pos[0] );
+ unsigned i_pos[2];
+ if ( (i_pos[0] = s_req.find( s_hdr, 0 )) == string::npos )
+ return "";
+
+ if ( (i_pos[1] = s_req.find( "\n", i_pos[0]) ) == string::npos )
+ return "";
- auto int i_length = s_hdr.length();
- return s_req.substr( pos[0]+i_length, pos[1]-pos[0]-i_length-1 );
+ unsigned i_len = s_hdr.length();
+ return s_req.substr( i_pos[0] + i_len, i_pos[1] - i_pos[0] - i_len - 1 );
}
string
-reqp::parse( thrd* p_thrd, string s_req, map_string &map_params )
+reqp::parse( socketcontainer *p_sock, string s_req, map<string,string> &map_params, int &i_postpayloadoffset )
{
- // store all request informations in map_params. store the url in
- // map_params["request"].
+ // store all request informations in map_params. store the url in
+ // map_params["request"].
+ get_url( s_req, map_params, i_postpayloadoffset );
- 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 );
+ string s_event( map_params["event"] );
- 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 );
- s_rep.append( get_content_type( map_params["request"] ) );
- s_rep.append("\r\n\r\n");
+ map_params["content-type"] = get_content_type( map_params["request"] );
- // check the event variable.
+ string s_rep( "" );
- string s_event( map_params["event"] );
- if ( ! s_event.empty() )
+ //<<*
+ // check the event variable.
+ if ( ! s_event.empty() )
+ {
+ // login procedure.
+ if ( s_event == "login" )
+ {
+ wrap::CHAT->login( map_params );
+ }
+ else if ( s_event == "register" )
{
- // login procedure.
- if ( s_event == "login" )
+ user* p_user = new user;
+ map_params["INFO"] = "";
+ run_html_mod( s_event, map_params, p_user );
+ wrap::GCOL->add_user_to_garbage( p_user );
+ }
+ else
+ {
+ sess *p_sess = wrap::SMAN->get_session( map_params["tmpid"] );
+ user *p_user = NULL;
+
+ if( p_sess != NULL )
+ {
+ p_user = p_sess->get_user();
+ }
+ else
+ {
+ wrap::system_message(SESSERR);
+ return s_rep;
+ }
+
+ if ( ! p_user )
+ {
+ map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.notonline" );
+ map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
+ }
+ else
+ {
+ map_params["nick"] = p_user->get_name().c_str();
+
+ // if a message input.
+ if ( s_event == "input" )
{
- s_chat::get
- ().login( map_params );
+ if ( p_user )
+ {
+ p_user->check_restore_away();
+ wrap::CHAT->post( p_user, map_params );
+ }
}
- else
+ // if a chat stream
+ else if ( s_event == "stream" )
{
- bool 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"] = s_conf::get
- ().get_val( "STARTMPL" ); // redirect to the startpage.
- }
- // if a message post.
- else if ( s_event == "post" )
- 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" )
- s_html::get
- ().online_list( p_user, map_params );
+ string s_msg ( wrap::HTML->parse( map_params ) );
+ p_user->msg_post( &s_msg);
+ wrap::SOCK->chat_stream( p_sock, p_user, map_params );
}
+
+ // if a request for the online list of the active room.
+ else if ( s_event == "online" )
+ {
+ wrap::HTML->online_list( p_user, map_params );
+ }
+ else //if ( s_event != "input" )
+ {
+ run_html_mod( s_event, map_params, p_user );
+ }
+ }
}
+ }
+ //*>>
+ if ( wrap::CONF->get_elem("httpd.enablecgi").compare("true") == 0 &&
+ string::npos != map_params["request"].find(".cgi") )
+ {
+ s_rep.append( tool::shell_command(
+ wrap::CONF->get_elem("httpd.templatedir") + map_params["request"],
+ METH_RETSTRING ) );
+ }
+ else
+ {
// parse and get the requested html-template and also use
// the values stored in map_params for %%KEY%% substituations.
- s_rep.append( s_html::get
- ().parse( map_params ) );
+ s_rep.append( wrap::HTML->parse( map_params ) );
+ }
- // return the parsed html-template.
- return s_rep;
-}
+ // create the http header.
-string
-reqp::remove_dots( string s_ret )
-{
- // remove ".." from the request.
- unsigned pos;
+ string s_resp(s_http);
+ if ( s_event.compare("stream") == 0 )
+ s_resp.append( s_http_stream );
- if( (pos = s_ret.find( ".." )) != string::npos)
- return s_ret.substr(0, pos);
+ s_resp.append( s_http_colength + tool::int2string(s_rep.size()) + "\r\n" +
+ s_http_cotype + map_params["content-type"] +
+ s_http_cotype_add + "\r\n" );
- return s_ret;
+ s_resp.append(s_rep);
+
+
+ // return the parsed html-template.
+ return s_resp;
}
+//<<*
void
-reqp::get_request_parameters( string s_parameters, map<string,string>& map_params )
+reqp::run_html_mod( string s_event, map<string,string> &map_params, user* p_user )
{
- string s_tmp;
- unsigned i_pos, i_pos2;
+ container *c = new container;
- while( (i_pos = s_parameters.find("&")) != string::npos )
- {
- s_tmp = s_parameters.substr(0, i_pos );
+ c->elem[0] = (void*) wrap::WRAP;
+ c->elem[1] = (void*) &map_params;
+ c->elem[2] = (void*) p_user;
- if ( (i_pos2 = s_tmp.find("=")) != string::npos )
- map_params[ s_tmp.substr(0, i_pos2) ] = s_tool::replace( s_tmp.substr( i_pos2+1 ), "\\AND", "&");
+ string s_mod = wrap::CONF->get_elem("httpd.modules.htmldir") + "yc_" + s_event + ".so";
- s_parameters = s_parameters.substr( i_pos + 1 );
- }
+ dynmod* p_module = wrap::MODL->get_module( s_mod, p_user->get_name() );
- // Get the last request parameter, which does not have a "&" on the end!
- if( (i_pos = s_parameters.find("=")) != string::npos )
- map_params[ s_parameters.substr(0, i_pos) ] = s_parameters.substr( i_pos+1 );
+ if ( p_module != NULL )
+ ( *( p_module->the_func ) ) ( static_cast<void*>(c) );
- //map<string,string>::iterator iter;
- //for ( iter = map_params.begin(); iter != map_params.end(); ++iter )
- //cout << ">>>" << iter->first << "=" << iter->second << endl;
+ delete c;
}
+//*>>
+string
+reqp::remove_dots( string s_ret )
+{
+ // remove ".." from the request.
+ unsigned i_pos;
+
+ if ( (i_pos = s_ret.find( ".." )) != string::npos )
+ return remove_dots(s_ret.substr(0, i_pos));
+
+ return s_ret;
+}
#endif
diff --git a/src/reqp.h b/src/reqp.h
index 9aad27a..de49262 100644
--- a/src/reqp.h
+++ b/src/reqp.h
@@ -1,9 +1,10 @@
/*:*
*: File: ./src/reqp.h
*:
- *: yChat; Homepage: www.yChat.org; Version 0.5.6-BASIC
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
*:
- *: Copyright (C) 2003, 2004 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
*: Copyright (C) 2005 EXA Digital Solutions GbR
*:
*: This program is free software; you can redistribute it and/or
@@ -21,52 +22,45 @@
*: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*:*/
-// class reqp declaration. this class parses the client requests.
-
+#include "incl.h"
#ifndef REQP_H
#define REQP_H
-#define RQ_GET 1
-#define RQ_POST 2
-
-#include <map>
-#include "incl.h"
-#include "thrd.h"
+#include "maps/hashmap.h"
using namespace std;
-typedef map<string, string, less<string> > map_string;
-
class reqp
{
private:
- static string HTTP_CODEOK,
- HTTP_CODENF,
- HTTP_SERVER,
- HTTP_CONTAC,
- HTTP_CACHEC,
- HTTP_CONNEC,
- HTTP_COTYPE;
+ static const string s_http;
+ static const string s_http_stream;
+ static const string s_http_colength;
+ static const string s_http_cotype;
+ static const string s_http_cotype_add;
+
+ // returns the request url from thr client's http request header
+ // until the first "?" and stores all request parameter values
+ // ( behind "?" ) into map_params.
+ string get_url( string s_req, map<string,string> &map_params, int& i_postpayloadoffset );
+ // returns a specific value of the client's http request header.
+ // ( s.t. like the User-Agent, Referer etc... ).
+ string get_from_header( string s_req, string s_hdr );
- // returns the request url from thr client's http request header
- // until the first "?" and stores all request parameter values
- // ( behind "?" ) into map_params.
- virtual string get_url( thrd* p_thrd, string s_req, map_string &map_params );
- // returns a specific value of the client's http request header.
- // ( s.t. like the User-Agent, Referer etc... ).
- virtual string get_from_header( string s_req, string s_hdr );
+ int htoi( string *p_str );
+ void run_html_mod( string s_event, map<string,string> &map_params, user* p_user ); //<<
+ // Removes double dots ".."
+ string remove_dots( string s_req );
- virtual int htoi( string *s );
- string remove_dots( string s_ret );
- void get_request_parameters( string s_parameters, map<string,string>& map_params );
+ // Parses "event=bla?blu=bli&sadasda=asddds ..." string and stores them in the map
+ void get_request_parameters( string s_parameters, map<string,string>& map_params );
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 get_content_type( string );
- virtual void parse_headers( string s_req, map_string &map_params );
+ reqp( );
+ string parse( socketcontainer* p_sock, string s_req, map<string,string> &map_params, int &i_postpayloadoffset );
+ string url_decode ( string s_url );
+ string get_content_type( string& s_file );
+ void parse_headers( string s_req, map<string,string> &map_params );
};
#endif
diff --git a/src/sign.cpp b/src/sign.cpp
new file mode 100644
index 0000000..77701e7
--- /dev/null
+++ b/src/sign.cpp
@@ -0,0 +1,92 @@
+/*:*
+ *: File: ./src/sign.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SIGN_CPP
+#define SIGN_CPP
+
+#include "sign.h"
+
+void
+sign::clean_template_cache(int i_param)
+{
+ wrap::HTML->clear_cache();
+}
+
+//<<*
+void
+sign::reload_dlopen_modules(int i_param)
+{
+ wrap::MODL->reload_modules();
+}
+//*>>
+
+#ifdef CTCSEGV
+void
+sign::sigsev_received(int i_param)
+{
+ wrap::system_message(SIGNSEG);
+}
+#endif
+
+void
+sign::terminate_received(int i_param)
+{
+
+#ifdef NCURSES
+ //<<*
+ if ( ! wrap::GCOL->remove_garbage() )
+ wrap::NCUR->print( GAROFFNE );
+ //*>>
+
+ mvprintw( 21,2, "Good bye !");
+ wrap::NCUR->close_ncurses();
+
+ //<<*
+#else
+ wrap::GCOL->remove_garbage();
+ //*>>
+#endif
+
+ exit(0);
+}
+
+void
+sign::init_signal_handlers()
+{
+ // Ignore SIGPIPE. otherwise the server will shut down with "Broken pipe" if
+ // a client unexpected disconnects himself from a SOCK_STREAM.
+ signal(SIGPIPE, SIG_IGN);
+
+ signal(SIGUSR1, clean_template_cache);
+ signal(SIGUSR2, reload_dlopen_modules); //<<
+#ifdef CTCSEGV
+ signal(SIGSEGV, sigsev_received);
+#endif
+ signal(SIGHUP, terminate_received);
+ signal(SIGINT, terminate_received);
+ signal(SIGTERM, terminate_received);
+ //signal(SIGWINCH, );
+}
+
+#endif
diff --git a/src/sign.h b/src/sign.h
new file mode 100644
index 0000000..2dc8e05
--- /dev/null
+++ b/src/sign.h
@@ -0,0 +1,45 @@
+/*:*
+ *: File: ./src/sign.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SIGN_H
+#define SIGN_H
+
+#include "incl.h"
+#include <signal.h>
+
+class sign
+{
+private:
+ static void clean_template_cache(int i_param);
+ static void reload_dlopen_modules(int i_param); //<<
+#ifdef CTCSEGV
+ static void sigsev_received(int i_param);
+#endif
+
+public:
+ static void init_signal_handlers();
+ static void terminate_received(int i_param);
+};
+
+#endif
diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp
new file mode 100644
index 0000000..8a020d7
--- /dev/null
+++ b/src/sock/sock.cpp
@@ -0,0 +1,544 @@
+/*:*
+ *: File: ./src/sock/sock.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef SOCK_CPP
+#define SOCK_CPP
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "sock.h"
+
+using namespace std;
+
+sock::sock()
+{
+ this->b_run = true;
+ this->i_req = 0;
+ this->req_parser = new reqp();
+#ifdef LOGGING
+
+ this->log_daemon = new logd( wrap::CONF->get_elem( "httpd.logging.accessfile" ),
+
+ wrap::CONF->get_elem( "httpd.logging.access_lines" ) );
+#endif
+}
+
+int
+sock::_send(socketcontainer *p_sock, const char *sz, int len)
+{
+
+ return send( p_sock->i_sock, sz, len, 0 );
+}
+
+int
+sock::_read(socketcontainer *p_sock, char *sz, int len)
+{
+
+ return read( p_sock->i_sock, sz, len );
+}
+
+int
+sock::_close(socketcontainer *p_sock)
+{
+ shutdown( p_sock->i_sock, 2 );
+ close ( p_sock->i_sock );
+ delete p_sock;
+}
+
+//<<*
+void
+sock::chat_stream( socketcontainer *p_sock, user *p_user, map<string,string> &map_params )
+{
+ string s_msg( "\n" );
+
+ for ( int i = 0; i < PUSHSTR; i++ )
+ _send(p_sock,s_msg.c_str(), s_msg.size());
+
+ pthread_mutex_t mutex;
+ pthread_mutex_init( &mutex, NULL );
+ pthread_mutex_lock( &mutex );
+
+ do
+ {
+ s_msg = p_user->get_mess( );
+
+ if ( 0 > _send( p_sock, s_msg.c_str(), s_msg.size() ) )
+ {
+ p_user->set_online( false );
+ break;
+ }
+
+ pthread_cond_wait( &(p_user->cond_message), &mutex );
+ }
+ while( p_user->get_online() );
+
+ pthread_mutex_destroy( &mutex );
+
+ // if there is still a message to send:
+ s_msg = p_user->get_mess( );
+
+ if ( ! s_msg.empty() )
+ _send( p_sock, s_msg.c_str(), s_msg.size());
+
+ // remove the user from its room.
+ string s_user( p_user->get_name() );
+ string s_user_lowercase( p_user->get_lowercase_name() );
+
+ p_user->get_room()->del_elem( s_user_lowercase );
+
+ // post the room that the user has left the chat.
+ s_msg = wrap::TIMR->get_time() + " "
+ + p_user->get_colored_bold_name()
+ + wrap::CONF->get_elem( "chat.msgs.userleaveschat" )
+ + "<br>\n";
+
+ p_user->get_room()->msg_post( &s_msg );
+ p_user->get_room()->reload_onlineframe();
+
+#ifdef VERBOSE
+
+ cout << REMUSER << s_user << endl;
+#endif
+
+ wrap::GCOL->add_user_to_garbage( p_user );
+}
+//*>>
+
+int
+sock::_make_server_socket( int i_port )
+{
+ size_t i_sock;
+ struct sockaddr_in name;
+
+ // create the server socket.
+ i_sock = socket (PF_INET, SOCK_STREAM, 0);
+ if (i_sock < 0)
+ {
+ wrap::system_message( SOCKERR );
+
+ if ( ++i_port > MAXPORT )
+ exit(1);
+
+ wrap::system_message( SOCKERR );
+
+ return _make_server_socket( i_port );
+ }
+
+ // give the server socket a name.
+ name.sin_family = AF_INET;
+ name.sin_port = htons(i_port);
+ name.sin_addr.s_addr = htonl(INADDR_ANY);
+ int i_optval = 1;
+
+ setsockopt( i_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&i_optval, sizeof(int) );
+
+ if ( bind(i_sock, (struct sockaddr *) &name, sizeof (name)) < 0 )
+ {
+
+ wrap::system_message( BINDERR );
+
+ if ( ++i_port > MAXPORT )
+ exit(1);
+
+ wrap::system_message( string(SOCKERR) + tool::int2string(i_port) );
+
+ // Rerun recursive.
+ return _make_server_socket( i_port );
+ }
+
+ wrap::system_message( SOCKCRT + string("localhost:") + tool::int2string(i_port) );
+
+ i_server_port = i_port;
+ i_server_sock = i_sock;
+
+ return i_sock;
+}
+
+string
+sock::read_http_line(socketcontainer *p_sock)
+{
+ string s_line;
+ int i_total = 0;
+ int i_read = 0;
+ char ch;
+
+ do
+ {
+ i_read = _read(p_sock, &ch, sizeof(ch));
+
+ if(i_read <= 0)
+ return "";
+
+ s_line += ch;
+ i_total++;
+ }
+ while((ch != '\n') && i_total < MAXLENGTH);
+
+ if(ch != '\n')
+ /*
+ ** the games people play
+ */
+ return "";
+
+ return s_line;
+}
+int
+sock::read_http(socketcontainer *p_sock, char *c_zbuf, int i_buflen, int &i_postpayloadoffset)
+{
+ /*
+ ** 1) Read the first line
+ ** 2) If GET, handle as such
+ ** 3) If POST, handle as such
+ */
+ char ch;
+ int i_read;
+ int i_ret = -1;
+ int x,z;
+
+ string s_content_length;
+ string s_cl;
+ string s_post_return;
+ string s_line = read_http_line(p_sock);
+
+ i_postpayloadoffset = 0;
+ if(s_line.length() <= 0)
+ return -1;
+
+ /*
+ ** GET yada\r\n Followed by stuff we don't care about :) heh.
+ ** 01234
+ */
+ /*
+ ** POST yada\r\n
+ ** xxxxx
+ ** Content-Length: NNN\n
+ ** \n
+ */
+ if(s_line.substr(0,3) == "GET")
+ {
+ if(s_line.length() > i_buflen)
+ {
+ /*
+ ** Buffer overflow
+ */
+ return -1;
+ }
+ else
+ {
+ memcpy(c_zbuf,s_line.c_str(),s_line.length());
+ return s_line.length();
+ }
+ }
+
+ else
+ {
+ /*
+ ** POST yada
+ ** 01234
+ */
+ if(s_line.substr(0,4) != "POST")
+ return -1;
+
+ /*
+ ** Get us to the Content-Length:
+ */
+ s_post_return += s_line;
+ i_postpayloadoffset += s_line.length();
+
+ for(x=0 ;x < MAXLINES; x++)
+ {
+ s_line = read_http_line(p_sock);
+ s_post_return += s_line;
+ i_postpayloadoffset += s_line.length();
+
+ if (s_line.compare(0, 15, "Content-Length:"))
+ continue;
+
+ // Match found on Content-Length:... process, and then break out and get us to the promised land
+ s_content_length = s_line.substr( 16 /*strlen("Content-Length: ")*/,
+ s_line.length() - 16 /*strlen("Content-Length: ")*/);
+
+ /*
+ ** Content-Length: 333\n
+ ** 0123456789abcdefghijklmnopqrstuvwxyzAB
+ */
+
+ z = 0;
+
+ do
+ {
+ ch = s_content_length[z];
+ if(isdigit(ch))
+ s_cl += ch;
+
+ z++;
+
+ }
+ while(ch != '\n');
+
+ break;
+ }
+
+ if(s_cl.length() <= 0)
+ return -1;
+
+ z = atoi(s_cl.c_str());
+
+ /*
+ ** If we are going to overflow the buffer just by the payload, leave
+ ** of, if z did not convert correctly. (should have been ok by isdigit)
+ */
+ if(z > i_buflen || z < 0)
+ return -1;
+
+ /*
+ ** We have MAXLINES to get to the blank line separating POST data.
+ */
+ for(x=0 ;x < MAXLINES; x++)
+ {
+ s_line = read_http_line(p_sock);
+ s_post_return += s_line;
+
+ i_postpayloadoffset += s_line.length();
+ if(s_line == "\r\n")
+ break;
+ }
+
+ /*
+ ** funny business
+ */
+ if(x == MAXLINES)
+ return -1;
+
+ for(x=0; x < z; x++)
+ {
+ if(_read(p_sock,&ch,sizeof(ch)) != 1)
+ return -1;
+
+ s_post_return += ch;
+ }
+
+ if(s_post_return.length() > i_buflen)
+ return -1;
+
+ memcpy(c_zbuf,s_post_return.c_str(),s_post_return.length());
+ return s_post_return.length();
+ }
+}
+
+int
+sock::read_write(socketcontainer* p_sock)
+{
+ int i_postpayloadoffset;
+ int i_sock = p_sock->i_sock;
+
+ char c_req[READSOCK];
+
+ memset(c_req,0,sizeof(c_req));
+
+ int i_bytes = read_http(p_sock, c_req, READSOCK-1,i_postpayloadoffset);
+
+ if (i_bytes <= 0)
+ {
+ wrap::system_message( READERR );
+ }
+
+ else
+ {
+ // stores the request params.
+ map<string,string> map_params;
+
+ // get the s_rep ( s_html response which will be send imediatly to the client
+ struct sockaddr_in client;
+ size_t size = sizeof(client);
+
+ getpeername(i_sock, (struct sockaddr *)&client, &size);
+
+ uint32_t &s_addr = client.sin_addr.s_addr;
+ if ( (map_params["REMOTE_ADDR"] = get_elem(s_addr)) == "" )
+ {
+ map_params["REMOTE_ADDR"] = string(inet_ntoa(client.sin_addr));
+ set_elem(map_params["REMOTE_ADDR"], s_addr);
+ wrap::system_message(SOCKCAC+map_params["REMOTE_ADDR"]);
+ }
+
+ string s_rep = req_parser->parse(p_sock, string(c_req), map_params, i_postpayloadoffset);
+
+#ifdef LOGGING
+
+ log_daemon->log_access(map_params);
+#endif
+
+ // send s_rep to the client.
+ _send(p_sock, s_rep.c_str(), s_rep.size());
+
+ // dont need those vals anymore.
+ map_params.clear();
+
+ _close(p_sock);
+ return 0;
+ }
+
+ _close(p_sock);
+ return 1;
+}
+
+void
+sock::_main_loop_init()
+{
+ wrap::system_message(SOCKUNS);
+}
+
+socketcontainer*
+sock::_create_container(int &i_sock)
+{
+ socketcontainer* p_sock = new socketcontainer;
+ p_sock->i_sock = i_sock;
+ return p_sock;
+}
+
+int
+sock::start()
+{
+ wrap::system_message( SOCKSRV );
+ pool* p_pool = wrap::POOL;
+ int i_sock = i_server_sock;
+
+#ifdef NCURSES
+
+ print_hits();
+ p_pool->print_pool_size();
+#endif
+
+ int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
+ _main_loop_init();
+
+ int i;
+ fd_set active_fd_set, read_fd_set;
+ struct sockaddr_in clientname;
+ size_t size;
+
+ if (listen (i_sock, 1) < 0)
+ {
+ wrap::system_message( LISTERR );
+ exit( EXIT_FAILURE );
+ }
+
+ wrap::system_message( SOCKRDY );
+
+ // initialize the set of active sockets.
+ FD_ZERO (&active_fd_set);
+ FD_SET (i_sock, &active_fd_set);
+
+ print_server_port();
+
+ while( b_run )
+ {
+ // block until input arrives on one or more active sockets.
+ read_fd_set = active_fd_set;
+ if (select (FD_SETSIZE, &read_fd_set, NULL, NULL, NULL) < 0)
+ {
+ wrap::system_message( SELCERR );
+
+ exit( EXIT_FAILURE );
+ }
+
+ // service all the sockets with input pending.
+ for ( i = 0; i < FD_SETSIZE; i++ )
+ if ( FD_ISSET (i, &read_fd_set) )
+ {
+ if ( i == i_sock )
+ {
+ // connection request on original socket.
+ ++i_req;
+
+#ifdef NCURSES
+
+ print_hits();
+#endif
+
+ int i_new_sock;
+ size = sizeof(clientname);
+ i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, &size);
+
+#ifdef VERBOSE
+
+ wrap::system_message(NEWREQU
+ + tool::int2string(i_req) + " "
+ + string(inet_ntoa( clientname.sin_addr )) + ":"
+ + tool::int2string(ntohs ( clientname.sin_port ))
+ );
+#endif
+
+ FD_SET (i_new_sock, &active_fd_set);
+
+ }
+ else
+ {
+ socketcontainer *p_sock = _create_container(i);
+ p_pool->run( (void*) p_sock );
+ FD_CLR( i, &active_fd_set );
+ }
+ }
+ }
+}
+
+void
+sock::clean_ipcache()
+{
+ int i_ipcachesize = wrap::CONF->get_int("httpd.ipcachesize");
+ int i_currentsize = size();
+
+ if ( i_currentsize > 0 && (i_ipcachesize == 0 || i_ipcachesize <= i_currentsize) )
+ {
+ wrap::system_message(
+ SOCKCA2+tool::int2string(i_currentsize)+","+tool::int2string(i_ipcachesize)+")");
+#ifdef NCURSES
+ clear();
+#endif
+ }
+}
+
+#ifdef NCURSES
+void
+sock::print_server_port() {
+ mvprintw( NCUR_PORT_X,NCUR_PORT_Y, "Port: %d ", i_server_port);
+ refresh();
+}
+
+void
+sock::print_hits()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_HITS_X,NCUR_HITS_Y, "Hits: %d ", i_req);
+ refresh();
+ }
+}
+#endif
+
+#endif
diff --git a/src/sock/sock.h b/src/sock/sock.h
new file mode 100644
index 0000000..914c366
--- /dev/null
+++ b/src/sock/sock.h
@@ -0,0 +1,112 @@
+/*:*
+ *: File: ./src/sock/sock.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef SOCK_H
+#define SOCK_H
+
+#include <queue>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+#include "../reqp.h"
+#include "../chat/user.h"
+
+#include "../thrd/pool.h"
+#include "../maps/shashmap.h"
+
+#ifdef LOGGING
+#include "../logd.h"
+#endif
+
+using namespace std;
+
+class sock : public shashmap
+ < string, uint32_t, self_hash<uint32_t>, equals_allocator<uint32_t> >
+{
+protected:
+#ifdef LOGGING
+
+ logd *log_daemon; // the log daemon
+#endif
+
+ int i_server_sock;
+ int i_server_port;
+
+ // total number of server requests.
+ unsigned long long i_req;
+ bool b_run; // true while socket manager is running.
+ reqp *req_parser; // parses the http requests from clients.
+ char *c_buffer; // char buffer!
+ pthread_mutex_t mut_hits;
+
+ static string inet_ntoa_callback(void* p_void);
+
+public:
+ // creates a server socket.
+ int read_http(socketcontainer *p_sock, char *c_zbuf, int i_buflen, int &i_payloadoffset);
+ string read_http_line(socketcontainer *p_sock);
+
+ // small inline methods:
+ bool get_server_() const
+ {
+ return b_run;
+ }
+ // small inline methods:
+ bool get_run() const
+ {
+ return b_run;
+ }
+ bool set_run( bool b_run )
+ {
+ this->b_run = b_run;
+ }
+
+ sock();
+
+ int read_write( socketcontainer* p_sock );
+
+ int start();
+ void clean_ipcache();
+
+ // the chat stream there all the chat messages will sent through.
+ void chat_stream( socketcontainer* p_sock, user* p_user, map<string,string> &map_params ); //<<
+ virtual inline int _send(socketcontainer *p_sock, const char *sz, int len);
+ virtual inline int _read(socketcontainer *p_sock, char *sz, int len);
+ virtual inline int _close(socketcontainer *p_sock);
+ virtual void _main_loop_init();
+ virtual inline socketcontainer* _create_container(int& i_sock);
+ virtual int _make_server_socket(int i_port);
+
+#ifdef NCURSES
+ void print_server_port();
+ void print_hits();
+#endif
+
+};
+#endif
diff --git a/src/thrd/pool.cpp b/src/thrd/pool.cpp
new file mode 100644
index 0000000..a27beac
--- /dev/null
+++ b/src/thrd/pool.cpp
@@ -0,0 +1,181 @@
+/*:*
+ *: File: ./src/thrd/pool.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef POOL_CPP
+#define POOL_CPP
+
+#include "pool.h"
+
+using namespace std;
+
+pool::pool()
+{
+ pthread_mutex_init(&mut_threads, 0);
+ pthread_mutex_init(&mut_queue_tasks, 0);
+ pthread_mutex_init(&mut_num_avail_threads, 0);
+ pthread_cond_init(&cond_new_task, 0);
+
+ i_num_total_threads = 0;
+ i_num_avail_threads = tool::string2int( wrap::CONF->get_elem( "httpd.thread.initpoolsize" ) );
+ increase_pool(i_num_avail_threads);
+}
+
+pool::~pool()
+{
+ pthread_mutex_lock(&mut_queue_tasks);
+ while (!queue_tasks.empty())
+ {
+ delete queue_tasks.front();
+ queue_tasks.pop();
+ }
+ pthread_mutex_unlock(&mut_queue_tasks);
+
+ pthread_mutex_destroy(&mut_threads);
+ pthread_mutex_destroy(&mut_queue_tasks);
+ pthread_mutex_destroy(&mut_num_avail_threads);
+ pthread_cond_destroy(&cond_new_task);
+}
+
+int
+pool::increase_pool(int i_num)
+{
+ wrap::system_message(POOLFLL + tool::int2string(i_num) +","+tool::int2string(i_num_total_threads)+")");
+ int i_max_pool_size = tool::string2int( wrap::CONF->get_elem( "httpd.thread.maxpoolsize" ) );
+
+ for ( int i = 0; i < i_num; ++i )
+ {
+ if ( i_max_pool_size != 0 && i_num_total_threads >= i_max_pool_size )
+ {
+ wrap::system_message(POOLER2+tool::int2string(i_max_pool_size)+")");
+ wrap::system_message(POOLER1+tool::int2string(i)+")");
+ return i;
+ }
+
+ ++i_num_total_threads;
+ pthread_t p_pthread;
+ pthread_create(&p_pthread, 0, wait_for_task, (void*) this );
+ }
+
+ return i_num;
+}
+
+void
+pool::add_task( void(*p_func)(void*), void* p_void )
+{
+ pthread_mutex_lock(&mut_queue_tasks);
+ queue_tasks.push(new task(p_func, p_void));
+ pthread_mutex_unlock(&mut_queue_tasks);
+
+ pthread_cond_signal(&cond_new_task);
+
+}
+
+void*
+pool::wait_for_task( void* p_void )
+{
+ pool* p_pool = static_cast<pool*>(p_void);
+
+ for (;;)
+ {
+
+#ifdef NCURSES
+ p_pool->print_pool_size();
+#endif
+
+ pthread_mutex_lock(&p_pool->mut_threads);
+ pthread_cond_wait(&p_pool->cond_new_task, &p_pool->mut_threads);
+
+ pthread_mutex_lock(&p_pool->mut_num_avail_threads);
+ if ( --p_pool->i_num_avail_threads < 5 )
+ {
+ int i_size = 9 - p_pool->i_num_avail_threads;
+ i_size = p_pool->increase_pool(i_size);
+ p_pool->i_num_avail_threads += i_size;
+ }
+ pthread_mutex_unlock(&p_pool->mut_num_avail_threads);
+
+ pthread_mutex_lock(&p_pool->mut_queue_tasks);
+ task* p_task = p_pool->queue_tasks.front();
+ p_pool->queue_tasks.pop();
+ pthread_mutex_unlock(&p_pool->mut_queue_tasks);
+
+ pthread_mutex_unlock(&p_pool->mut_threads);
+
+ (*(p_task->p_func))(p_task->p_void);
+ delete p_task;
+
+ pthread_mutex_lock(&p_pool->mut_num_avail_threads);
+ p_pool->i_num_avail_threads++;
+ pthread_mutex_unlock(&p_pool->mut_num_avail_threads);
+ }
+
+ return 0;
+}
+
+void
+pool::run(void* p_void)
+{
+ add_task(run_func, p_void);
+}
+
+void
+pool::run_func(void *p_void)
+{
+ socketcontainer* p_sock = static_cast<socketcontainer*>(p_void);
+ wrap::SOCK->read_write(p_sock);
+}
+
+bool
+pool::allow_user_login()
+{
+ pthread_mutex_lock(&mut_num_avail_threads);
+ if ( i_num_avail_threads < 2 )
+ {
+ int i_max_pool_size = tool::string2int( wrap::CONF->get_elem( "httpd.thread.maxpoolsize" ) );
+ if ( i_max_pool_size != 0 && i_max_pool_size == i_num_total_threads )
+ {
+ pthread_mutex_unlock(&mut_num_avail_threads);
+ return false;
+ }
+ }
+ pthread_mutex_unlock(&mut_num_avail_threads);
+
+ return true;
+}
+
+#ifdef NCURSES
+void
+pool::print_pool_size()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ pthread_mutex_lock(&mut_num_avail_threads);
+ mvprintw( NCUR_POOL_WAIT_X,NCUR_POOL_WAIT_Y, "Wait/Tot: %d/%d ", i_num_avail_threads, i_num_total_threads);
+ mvprintw( NCUR_POOL_RUNNING_X,NCUR_POOL_RUNNING_Y, "Running: %d ", i_num_total_threads-i_num_avail_threads);
+ pthread_mutex_unlock(&mut_num_avail_threads);
+ refresh();
+ }
+}
+#endif
+#endif
diff --git a/src/thrd/pool.h b/src/thrd/pool.h
new file mode 100644
index 0000000..0fe97f3
--- /dev/null
+++ b/src/thrd/pool.h
@@ -0,0 +1,79 @@
+/*:*
+ *: File: ./src/thrd/pool.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef POOL_H
+#define POOL_H
+
+#include <queue>
+
+using namespace std;
+
+class pool
+{
+private:
+ friend class thro;
+
+ struct task
+ {
+ void(*p_func)(void*);
+ void *p_void;
+
+ task(void(*p_func)(void*), void *p_void)
+ {
+ this->p_func = p_func;
+ this->p_void = p_void;
+ }
+ };
+
+ pthread_mutex_t mut_threads;
+ pthread_mutex_t mut_queue_tasks;
+ pthread_mutex_t mut_num_avail_threads;
+ pthread_cond_t cond_new_task;
+
+ int i_num_avail_threads;
+ int i_num_total_threads;
+
+ queue<task*> queue_tasks;
+
+ int increase_pool(int i_num);
+ void add_task( void(*p_func)(void*), void* p_void );
+ static void* wait_for_task(void *p_void);
+ static void run_func(void *p_void);
+
+public:
+ pool();
+ ~pool();
+
+ void run(void* p_void);
+ bool allow_user_login();
+
+#ifdef NCURSES
+
+ void print_pool_size();
+#endif
+};
+
+#endif
diff --git a/src/thrd/thro.cpp b/src/thrd/thro.cpp
new file mode 100644
index 0000000..04372b3
--- /dev/null
+++ b/src/thrd/thro.cpp
@@ -0,0 +1,67 @@
+/*:*
+ *: File: ./src/thrd/thro.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef THRO_CPP
+#define THRO_CPP
+
+#include "thro.h"
+
+using namespace std;
+
+thro::thro()
+{}
+
+thro::~thro()
+{}
+
+void
+thro::run()
+{
+ void *p_void;
+ run( p_void );
+}
+
+void
+thro::run( void *p_void )
+{
+ elem.p_thro = this;
+ elem.p_void = p_void;
+ //wrap::POOL->add_task(start_, &elem);
+ pthread_create( &pthread, NULL, start_, &elem );
+}
+
+void*
+thro::start_( void *p_void )
+{
+ elements *e = (elements*) p_void;
+ e->p_thro->start( e->p_void );
+}
+
+void
+thro::start( void *p_void )
+{
+ wrap::system_message( THRDSTR );
+}
+
+#endif
diff --git a/src/thrd/thro.h b/src/thrd/thro.h
new file mode 100644
index 0000000..76e5a51
--- /dev/null
+++ b/src/thrd/thro.h
@@ -0,0 +1,54 @@
+/*:*
+ *: File: ./src/thrd/thro.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef THRO_H
+#define THRO_H
+
+using namespace std;
+
+class thro
+{
+private:
+ pthread_t pthread;
+
+ struct elements
+ {
+ thro *p_thro;
+ void *p_void;
+ }
+ elem;
+
+ static void *start_( void *p_void );
+
+public:
+ thro( );
+ ~thro( );
+ void run();
+ void run( void *p_void );
+ virtual void start( void *p_void );
+};
+
+#endif
diff --git a/src/time/timo.cpp b/src/time/timo.cpp
new file mode 100644
index 0000000..210431b
--- /dev/null
+++ b/src/time/timo.cpp
@@ -0,0 +1,62 @@
+/*:*
+ *: File: ./src/time/timo.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef TIMO_CPP
+#define TIMO_CPP
+
+#include "timo.h"
+
+using namespace std;
+
+timo::timo()
+{
+ pthread_mutex_init( &mut_t_time, NULL );
+}
+
+timo::~timo()
+{
+ pthread_mutex_destroy( &mut_t_time );
+}
+
+double
+timo::get_last_activity( )
+{
+ double d_ret;
+
+ pthread_mutex_lock ( &mut_t_time );
+ d_ret = wrap::TIMR->get_time_diff( t_time );
+ pthread_mutex_unlock( &mut_t_time );
+
+ return d_ret;
+}
+
+void
+timo::renew_timeout( )
+{
+ pthread_mutex_lock ( &mut_t_time );
+ time( &t_time );
+ pthread_mutex_unlock( &mut_t_time );
+}
+
+#endif
diff --git a/src/time/timo.h b/src/time/timo.h
new file mode 100644
index 0000000..b48f5eb
--- /dev/null
+++ b/src/time/timo.h
@@ -0,0 +1,46 @@
+/*:*
+ *: File: ./src/time/timo.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef TIMO_H
+#define TIMO_H
+
+using namespace std;
+
+class timo // timeout class
+{
+protected:
+ time_t t_time; // last activity time.
+ pthread_mutex_t mut_t_time;
+
+public:
+ timo( );
+ ~timo( );
+
+ double get_last_activity();
+ void renew_timeout();
+};
+
+#endif
diff --git a/src/time/timr.cpp b/src/time/timr.cpp
new file mode 100644
index 0000000..c9c82ee
--- /dev/null
+++ b/src/time/timr.cpp
@@ -0,0 +1,218 @@
+/*:*
+ *: File: ./src/time/timr.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef TIMR_CPP
+#define TIMR_CPP
+
+#include <sys/time.h>
+#include "timr.h"
+
+using namespace std;
+
+timr::timr()
+{
+ wrap::system_message( TIMERIN );
+ b_timer_active = true;
+
+ pthread_mutex_init( &mut_s_time, NULL);
+ pthread_mutex_init( &mut_s_uptime, NULL);
+ pthread_mutex_init( &mut_i_offset, NULL);
+
+ i_time_offset = tool::string2int( wrap::CONF->get_elem("chat.timeoffset") );
+ wrap::system_message( TIMEROF + tool::int2string( i_time_offset ) );
+
+ s_time = "00:00:00";
+ s_uptime = "00:00:00";
+}
+
+timr::~timr()
+{
+ pthread_mutex_destroy( &mut_s_time );
+ pthread_mutex_destroy( &mut_s_uptime );
+ pthread_mutex_destroy( &mut_i_offset );
+}
+
+bool
+timr::get_timer_active() const
+{
+ return b_timer_active;
+}
+
+int
+timr::get_offset()
+{
+ pthread_mutex_lock ( &mut_i_offset );
+ int i_ret_val = i_time_offset;
+ pthread_mutex_unlock( &mut_i_offset );
+ return i_ret_val;
+}
+
+void
+timr::start( void *v_ptr )
+{
+ wrap::system_message( TIMERTH );
+
+#ifdef NCURSES
+
+ print_time( );
+#endif
+
+ time_t clock_start;
+ time_t clock_now;
+
+ time( &clock_start );
+ tm time_start = *localtime( &clock_start );
+ tm time_now;
+
+ while ( get_timer_active() )
+ {
+ // sleep a second!
+ usleep( 1000000 );
+
+ // get the current time!
+ time( &clock_now );
+
+ time_now = *localtime( &clock_now );
+
+ // set the current time && the current ychat uptime!
+ set_time( difftime( clock_now, clock_start ),
+ time_now.tm_sec, time_now.tm_min, time_now.tm_hour );
+
+#ifdef NCURSES
+
+ if (wrap::NCUR->is_ready())
+ print_time( );
+#endif
+
+ // run every minute:
+ if ( time_now.tm_sec == 0 )
+ {
+#ifdef SERVMSG
+ cout << TIMERUP << get_uptime() << endl;
+#endif
+ //<<*
+ int* p_timeout_settings = new int[3];
+ p_timeout_settings[0] = tool::string2int(wrap::CONF->get_elem("chat.idle.timeout"));
+ p_timeout_settings[1] = tool::string2int(wrap::CONF->get_elem("chat.idle.awaytimeout"));
+ p_timeout_settings[2] = tool::string2int(wrap::CONF->get_elem("chat.idle.autoawaytimeout"));
+ wrap::CHAT->check_timeout( p_timeout_settings );
+ delete p_timeout_settings;
+
+ string s_ping = "<!-- PING! //-->\n";
+ wrap::CHAT->msg_post( &s_ping );
+
+#ifdef DATABASE
+ // Disconnecting idle database conenction
+ wrap::DATA->check_data_con_timeout();
+#endif
+ //*>>
+ // Run every ten minutes:
+ if ( time_now.tm_min % 10 == 0 )
+ {
+
+ wrap::SOCK->clean_ipcache();
+ // Run every hour
+ if ( time_now.tm_min % 60 == 0 )
+ {
+ wrap::GCOL->remove_garbage(); //<<
+
+ // Run every day
+ if (time_now.tm_min == 0 || time_now.tm_min == 60 )
+ if (time_now.tm_hour == 0 || time_now.tm_hour == 24)
+ wrap::STAT->update_rusage_history();
+ }
+ }
+ }
+ }
+}
+
+#ifdef NCURSES
+void
+timr::print_time( )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_TIME_X, NCUR_TIME_Y, "Time: %s ", get_time().c_str());
+ mvprintw( NCUR_UPTIME_X, NCUR_UPTIME_Y, "Uptime: %s ", get_uptime().c_str());
+ refresh();
+}
+#endif
+
+void
+timr::set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours )
+{
+
+ int i_hours = (int) d_uptime / 3600;
+ int i_minutes = (int) d_uptime / 60;
+
+ while ( i_minutes >= 60 )
+ i_minutes -= 60;
+
+ while ( d_uptime >= 60 )
+ d_uptime -= 60;
+
+ // Calculate offset time
+ i_cur_hours += get_offset();
+
+ for ( int i = 24-i_cur_hours; i < 0; i = 24-i_cur_hours )
+ i_cur_hours =- i;
+
+ if (i_cur_hours == 24)
+ i_cur_hours = 0;
+
+ pthread_mutex_lock ( &mut_s_time );
+ s_time = add_zero_to_front( tool::int2string( i_cur_hours ) ) + ":" +
+ add_zero_to_front( tool::int2string( i_cur_minutes ) ) + ":" +
+ add_zero_to_front( tool::int2string( i_cur_seconds ) );
+ pthread_mutex_unlock( &mut_s_time );
+
+ pthread_mutex_lock ( &mut_s_uptime );
+ s_uptime = add_zero_to_front( tool::int2string( i_hours ) ) + ":" +
+ add_zero_to_front( tool::int2string( i_minutes ) ) + ":" +
+ add_zero_to_front( tool::int2string( (int) d_uptime ) );
+ pthread_mutex_unlock( &mut_s_uptime );
+}
+
+string
+timr::add_zero_to_front( string s_time )
+{
+ if ( s_time.length() == 1 )
+ {
+ string s_new = "0" + s_time;
+ return s_new;
+ }
+
+ return s_time;
+}
+
+double
+timr::get_time_diff( time_t &clock_diff )
+{
+ time_t clock_now;
+ time( &clock_now );
+
+ return difftime(clock_now, clock_diff);
+}
+#endif
diff --git a/src/time/timr.h b/src/time/timr.h
new file mode 100644
index 0000000..d04394b
--- /dev/null
+++ b/src/time/timr.h
@@ -0,0 +1,88 @@
+/*:*
+ *: File: ./src/time/timr.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#include "../incl.h"
+
+#ifndef TIMR_H
+#define TIMR_H
+
+#include "../thrd/thro.h"
+
+#include <unistd.h>
+
+using namespace std;
+
+class timr : public thro
+{
+private:
+ bool b_timer_active;
+ int i_time_offset;
+ string s_uptime;
+ string s_time;
+
+ pthread_mutex_t mut_s_time;
+ pthread_mutex_t mut_s_uptime;
+ pthread_mutex_t mut_i_offset;
+
+public:
+ timr();
+ ~timr();
+
+ bool get_timer_active() const;
+ void start( void *v_ptr );
+
+#ifdef NCURSES
+
+ void print_time();
+#endif
+
+ void set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours );
+ string add_zero_to_front( string s_time );
+
+ // inline for dynamic module access!
+ string
+ get_time( )
+ {
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_time );
+ s_ret = this->s_time;
+ pthread_mutex_unlock( &mut_s_time );
+ return s_ret;
+ }
+
+ string
+ get_uptime( )
+ {
+ string s_ret;
+ pthread_mutex_lock ( &mut_s_uptime );
+ s_ret = this->s_uptime;
+ pthread_mutex_unlock( &mut_s_uptime );
+ return s_ret;
+ }
+
+ int get_offset();
+ double get_time_diff( time_t &clock_diff );
+};
+
+#endif
diff --git a/src/tool/dir.cpp b/src/tool/dir.cpp
new file mode 100644
index 0000000..e91f227
--- /dev/null
+++ b/src/tool/dir.cpp
@@ -0,0 +1,90 @@
+/*:*
+ *: File: ./src/tool/dir.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef DIR_CPP
+#define DIR_CPP
+
+#include "dir.h"
+
+using namespace std;
+
+dir::dir()
+{
+ b_open = false;
+}
+
+dir::~dir()
+{
+ vec_dir.clear();
+ close_dir();
+}
+
+bool
+dir::open_dir( char *c_dir )
+{
+ string s_dir( c_dir );
+ return open_dir( s_dir );
+}
+
+bool
+dir::open_dir( string &s_dir )
+{
+ if ( b_open )
+ return false;
+
+ p_d = opendir( s_dir.c_str() );
+
+ if ( p_d == NULL )
+ return false; // Could not open dir.
+
+ b_open = true;
+
+ return true; // Could open dir with success.
+}
+
+void
+dir::close_dir()
+{
+ if ( b_open && p_d != NULL )
+ {
+ closedir( p_d );
+ b_open = false;
+ }
+}
+
+void
+dir::read_dir()
+{
+ if ( p_d != NULL )
+ while( p_ep = readdir( p_d ) )
+ vec_dir.push_back( string( p_ep->d_name ) );
+}
+
+vector<string>
+dir::get_dir_vec()
+{
+ return vec_dir;
+}
+
+#endif
diff --git a/src/tool/dir.h b/src/tool/dir.h
new file mode 100644
index 0000000..f77839e
--- /dev/null
+++ b/src/tool/dir.h
@@ -0,0 +1,59 @@
+/*:*
+ *: File: ./src/tool/dir.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+
+#ifndef DIR_H
+#define DIR_H
+
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#include <vector>
+
+#include "../incl.h"
+
+using namespace std;
+
+class dir
+{
+private:
+ bool b_open;
+ DIR *p_d;
+ struct dirent *p_ep;
+ vector<string> vec_dir;
+
+public:
+ dir();
+ ~dir();
+
+ bool open_dir( char *c_dir );
+ bool open_dir( string &s_dir );
+ void close_dir();
+ void read_dir();
+ vector<string> get_dir_vec();
+};
+
+#endif
diff --git a/src/tool/tool.cpp b/src/tool/tool.cpp
new file mode 100644
index 0000000..8a470cd
--- /dev/null
+++ b/src/tool/tool.cpp
@@ -0,0 +1,264 @@
+/*:*
+ *: File: ./src/tool/tool.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef TOOL_CPP
+#define TOOL_CPP
+
+#include <ctype.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "tool.h"
+
+bool
+tool::is_alpha_numeric( string &s_digit )
+{
+ const char *p_digit = s_digit.c_str();
+ int i_len = strlen( p_digit );
+
+ for( int i=0; i<i_len; i++ )
+ {
+ if ( ! isalnum( *p_digit ) )
+ return false;
+ p_digit++;
+ }
+
+ return true;
+}
+
+string
+tool::int2string( int i_int )
+{
+ char buf[64];
+ sprintf(buf, "%d", i_int);
+ return buf;
+}
+
+long
+tool::unixtime()
+{
+ time_t clock;
+ return (long) time( &clock );
+}
+
+int
+tool::string2int( string s_digit )
+{
+ const char *p_digit = s_digit.c_str();
+ int i_res = 0;
+
+ // Convert each digit char and add into result.
+ while (*p_digit >= '0' && *p_digit <='9')
+ {
+ i_res = (i_res * 10) + (*p_digit - '0');
+ p_digit++;
+ }
+
+ // Check that there were no non-digits at end.
+ if (*p_digit != 0)
+ {
+ return -1;
+ }
+
+ return i_res;
+}
+
+string
+tool::to_lower( string s_str )
+{
+ string s_tmp("");
+
+ for( int i = 0; i < s_str.size() ;i++ )
+ s_tmp = s_tmp + (char) tolower( s_str.at(i) );
+
+ return s_tmp;
+}
+
+void
+tool::strip_html( string *p_str)
+{
+ int i_pos;
+
+ if( (i_pos=p_str->find("<", 0)) == string::npos )
+ return;
+
+ while(true)
+ {
+ p_str->replace(i_pos, 1, "&lt;");
+
+ if( (i_pos = p_str->find("<", 0)) == string::npos )
+ return;
+ }
+}
+
+string
+tool::ychat_version()
+{
+ return "yChat " + string(VERSION)
+ + "-" + string(BRANCH)
+ + " Build " + int2string(BUILDNR);
+}
+
+list<string>
+tool::split_string(string s_string, string s_split)
+{
+ list<string> list_ret;
+ unsigned i_pos, i_len = s_split.length();
+
+ while ( (i_pos = s_string.find(s_split)) != string::npos )
+ {
+ list_ret.push_back( s_string.substr(0, i_pos) );
+ s_string = s_string.substr( i_pos + i_len );
+ }
+
+ list_ret.push_back( s_string );
+
+ return list_ret;
+}
+
+string
+tool::trim( string s_str )
+{
+ if( s_str.empty() )
+ return s_str;
+
+ char c_cur = s_str[0];
+ int i_pos = 0;
+
+ // left trim
+ while ( c_cur == ' '|| c_cur == '\n' || c_cur == '\r' )
+ {
+ s_str.erase(i_pos,1);
+ c_cur = s_str[++i_pos];
+ }
+
+ // right trim
+ i_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(i_pos, 1);
+ c_cur = s_str[--i_pos];
+ }
+
+ return s_str;
+}
+
+char*
+tool::clean_char( char* c_str )
+{
+ // Ralf:
+ for ( char* c_pos = c_str; *c_pos != '\0'; ++c_pos )
+ if ( iscntrl(*c_pos) )
+ *c_pos = ' ';
+
+ return c_str;
+}
+
+string
+tool::replace( string s_string, string s_search, string s_replace )
+{
+ unsigned i_pos[2];
+
+ for ( i_pos[0] = s_string.find( s_search );
+ i_pos[0] != string::npos;
+ i_pos[0] = s_string.find( s_search, i_pos[1] ) )
+ {
+ s_string.replace( i_pos[0], s_search.length(), s_replace );
+ i_pos[1] = i_pos[0] + s_replace.length();
+ }
+
+ return s_string;
+}
+
+string
+tool::get_extension( string s_file )
+{
+ int i_pos = s_file.find_last_of(".");
+
+ if( i_pos != string::npos )
+ {
+ string s_ext = s_file.substr(i_pos+1, s_file.size()-i_pos-1 );
+ for( int i = 0; i < s_ext.size(); ++i )
+ s_ext[i] = tolower(s_ext[i]);
+
+ return to_lower(s_ext);
+ }
+
+ return "";
+}
+
+char*
+tool::int2char( int i_int )
+{
+ char *buf = new char[64];
+ sprintf(buf, "%d", i_int);
+ return buf;
+}
+
+string
+tool::shell_command( string s_command, method m_method )
+{
+ FILE *file;
+ char buf[READBUF];
+ char *c_pos;
+ string s_ret = "";
+
+ wrap::system_message(SHELLEX);
+ wrap::system_message(s_command);
+
+ if( (file=popen(s_command.c_str(), "r")) == NULL )
+ {
+ wrap::system_message( SHELLER );
+ }
+ else
+ {
+ while(true)
+ {
+ if(fgets(buf, READBUF, file) == NULL)
+ break;
+
+ switch (m_method)
+ {
+ case METH_NCURSES:
+ wrap::system_message( clean_char(buf) );
+ break;
+ default:
+ s_ret.append("\n" + string(buf));
+ } // switch
+ }
+
+ pclose(file);
+ }
+
+ return s_ret;
+}
+
+#endif
+
diff --git a/src/tool/tool.h b/src/tool/tool.h
new file mode 100644
index 0000000..e293e5e
--- /dev/null
+++ b/src/tool/tool.h
@@ -0,0 +1,53 @@
+/*:*
+ *: File: ./src/tool/tool.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef TOOL_H
+#define TOOL_H
+
+#include "../incl.h"
+
+#include <list>
+
+using namespace std;
+
+class tool
+{
+public:
+ static list<string> split_string(string s_string, string s_split);
+ static bool is_alpha_numeric( string &s_digit );
+ static char* int2char( int i_int );
+ static char* clean_char( char* c_str);
+ static string trim( string s_str );
+ static string replace( string s_string, string s_search, string s_replace );
+ static string int2string( int i_int );
+ static long unixtime();
+ static int string2int( string s_digit );
+ static string get_extension( string s_file );
+ static string to_lower( string s_str );
+ static void strip_html( string *p_str );
+ static string shell_command( string s_command, method m_method );
+ static string ychat_version();
+};
+
+#endif
diff --git a/src/wrap.cpp b/src/wrap.cpp
new file mode 100644
index 0000000..3120b70
--- /dev/null
+++ b/src/wrap.cpp
@@ -0,0 +1,169 @@
+/*:*
+ *: File: ./src/wrap.cpp
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef WRAP_CPP
+#define WRAP_CPP
+
+#include "wrap.h"
+
+using namespace std;
+
+//<<*
+chat* wrap::CHAT = NULL;
+#ifdef DATABASE
+data* wrap::DATA = NULL;
+#endif
+gcol* wrap::GCOL = NULL;
+sman* wrap::SMAN = NULL;
+modl* wrap::MODL = NULL;
+//*>>
+
+conf* wrap::CONF = NULL;
+html* wrap::HTML = NULL;
+#ifdef LOGGING
+logd* wrap::LOGD = NULL;
+#endif
+#ifdef NCURSES
+ncur* wrap::NCUR = NULL;
+#endif
+sock* wrap::SOCK = NULL;
+stats* wrap::STAT = NULL;
+timr* wrap::TIMR = NULL;
+pool* wrap::POOL = NULL;
+dynamic_wrap* wrap::WRAP = NULL;
+
+void
+wrap::system_message( string s_message )
+{
+#ifdef NCURSES
+ if(NCUR)
+ {
+ NCUR->print( s_message );
+ }
+
+ else
+ {
+ cout << s_message << endl;
+ }
+#endif
+
+#ifdef SERVMSG
+ cout << s_message << endl;
+#endif
+
+#ifdef LOGGING
+
+ LOGD->log_simple_line( s_message + "\n" );
+#endif
+}
+
+void
+wrap::init_wrapper(map<string,string>* p_main_loop_params)
+{
+ // Init the dynamic wrapper (is needed to pass all wrapped objects through a single pointer).
+ WRAP = new dynamic_wrap;
+
+ // Init the config manager.
+ WRAP->CONF = CONF = new conf( CONFILE, p_main_loop_params );
+ delete p_main_loop_params,
+
+ // Init the statistic manager.
+ WRAP->STAT = STAT = new stats;
+
+ // Init the html-template manager.
+ WRAP->HTML = HTML = new html;
+
+#ifdef LOGGING
+ // Init the system message logd
+ WRAP->LOGD = LOGD = new logd( CONF->get_elem("httpd.logging.systemfile"),
+ CONF->get_elem("httpd.logging.systemlines") );
+#endif
+
+ //<<*
+ // Init the session manager.
+ WRAP->SMAN = SMAN = new sman;
+ //*>>
+ // Init the socket manager.
+ int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
+
+ WRAP->SOCK = SOCK = new sock;
+
+ // create the server socket and set it up to accept connections.
+ if(SOCK->_make_server_socket ( i_port ) <= 0)
+ {
+ system_message(SOCKER1);
+ exit(-1);
+ }
+
+#ifdef NCURSES
+
+ WRAP->NCUR = NCUR = new ncur; // init the ncurses admin interface.
+ NCUR->run(); // run the thread
+
+ // Wait until ncurses interface has been initialized.
+ do
+ {
+ usleep(1000);
+ }
+ while ( ! NCUR->is_ready() );
+
+ HTML->print_cached(0);
+#else
+#ifdef CLI
+
+ cli* p_cli = new cli;
+ p_cli->run();
+#endif
+#endif
+
+ // Init the thread pool
+ WRAP->POOL = POOL = new pool;
+
+ //<<*
+ // Init the chat manager.
+ WRAP->CHAT = CHAT = new chat;
+ //*>>
+
+ // Init the system timer.
+ WRAP->TIMR = TIMR = new timr;
+
+ //<<*
+ // Init the module-loader manager.
+ WRAP->MODL = MODL = new modl;
+
+ // Init the garbage collector
+ WRAP->GCOL = GCOL = new gcol;
+
+ // Init the data manager.
+#ifdef DATABASE
+
+ WRAP->DATA = DATA = new data;
+#endif
+ //*>>
+
+ // Run threads
+ TIMR->run();
+}
+
+#endif
diff --git a/src/wrap.h b/src/wrap.h
new file mode 100644
index 0000000..2b9d1b5
--- /dev/null
+++ b/src/wrap.h
@@ -0,0 +1,154 @@
+/*:*
+ *: File: ./src/wrap.h
+ *:
+ *: yChat; Homepage: www.yChat.org; Version 0.7.9.5-RELEASE
+ *:
+ *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ *: Copyright (C) 2004 Paul C. Buetow
+ *: Copyright (C) 2005 EXA Digital Solutions GbR
+ *:
+ *: This program is free software; you can redistribute it and/or
+ *: modify it under the terms of the GNU General Public License
+ *: as published by the Free Software Foundation; either version 2
+ *: of the License, or (at your option) any later version.
+ *:
+ *: This program is distributed in the hope that it will be useful,
+ *: but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *: GNU General Public License for more details.
+ *:
+ *: You should have received a copy of the GNU General Public License
+ *: along with this program; if not, write to the Free Software
+ *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *:*/
+
+#ifndef WRAP_H
+#define WRAP_H
+
+#include "incl.h"
+
+
+struct socketcontainer
+{
+ int i_sock;
+};
+
+#ifdef DATABASE
+#include "data/data.h"
+#endif
+#include "chat/chat.h"
+#include "conf/conf.h"
+#include "chat/gcol.h"
+#include "html.h"
+#ifdef LOGGING
+#include "logd.h"
+#endif
+//<<*
+#include "modl.h"
+//*>>
+
+#ifdef NCURSES
+#include "ncur/ncur.h"
+#else
+#ifdef CLI
+#include "cli/cli.h"
+#endif
+#endif
+
+#include "chat/sman.h"
+
+#include "sock/sock.h"
+#include "monitor/stats.h"
+#include "time/timr.h"
+#include "thrd/pool.h"
+
+
+using namespace std;
+
+
+class dynamic_wrap
+{
+public:
+ //<<*
+ chat* CHAT;
+#ifdef DATABASE
+
+ data* DATA;
+#endif
+
+ gcol* GCOL;
+ sman* SMAN;
+ modl* MODL;
+ //*>>
+
+ conf* CONF;
+ html* HTML;
+#ifdef LOGGING
+
+ logd* LOGD;
+#endif
+#ifdef NCURSES
+
+ ncur* NCUR;
+#endif
+
+ sock* SOCK;
+ stats* STAT;
+ timr* TIMR;
+ pool* POOL;
+};
+
+class wrap
+{
+public:
+ static void system_message( char* c_message )
+ {
+ wrap::system_message( string(c_message) );
+ }
+
+ static void system_message( string* p_message )
+ {
+ wrap::system_message( *p_message );
+ }
+
+ static void system_message( string s_message );
+
+ static void init_wrapper(map<string,string>* p_main_loop_params);
+
+ //<<*
+ static chat* CHAT;
+#ifdef DATABASE
+
+ static data* DATA;
+#endif
+
+ static gcol* GCOL;
+ static sman* SMAN;
+#ifdef IRCBOT
+
+ static ybot* YBOT;
+#endif
+
+ static modl* MODL;
+ //*>>
+
+ static conf* CONF;
+ static html* HTML;
+#ifdef LOGGING
+
+ static logd* LOGD;
+#endif
+#ifdef NCURSES
+
+ static ncur* NCUR;
+#endif
+
+ static sock* SOCK;
+ static stats* STAT;
+ static timr* TIMR;
+ static pool* POOL;
+ static dynamic_wrap* WRAP;
+};
+
+
+#endif