summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
commitae4e87df37ed8904de92c7cf2f3a11128cda2a21 (patch)
tree5333f2930165cc6e4083ce15154799626ddb3d03 /src
parent9cd3ccffd5372dfde3af478e3f832f18db4be3f1 (diff)
tagging ychat-0.7.4.1ychat-0.7.4.1
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--]src/Makefile.in54
-rwxr-xr-x[-rw-r--r--]src/chat/base.h182
-rwxr-xr-x[-rw-r--r--]src/chat/base.tmpl73
-rwxr-xr-x[-rw-r--r--]src/chat/chat.cpp543
-rwxr-xr-x[-rw-r--r--]src/chat/chat.h103
-rwxr-xr-x[-rw-r--r--]src/chat/gcol.cpp184
-rwxr-xr-x[-rw-r--r--]src/chat/gcol.h58
-rwxr-xr-x[-rw-r--r--]src/chat/perm.cpp93
-rwxr-xr-x[-rw-r--r--]src/chat/perm.h69
-rwxr-xr-x[-rw-r--r--]src/chat/room.cpp124
-rwxr-xr-x[-rw-r--r--]src/chat/room.h131
-rwxr-xr-x[-rw-r--r--]src/chat/sess.cpp63
-rwxr-xr-x[-rw-r--r--]src/chat/sess.h50
-rwxr-xr-x[-rw-r--r--]src/chat/sman.cpp165
-rwxr-xr-x[-rw-r--r--]src/chat/sman.h56
-rwxr-xr-x[-rw-r--r--]src/chat/user.cpp796
-rwxr-xr-x[-rw-r--r--]src/chat/user.h283
-rwxr-xr-x[-rw-r--r--]src/cli/cli.cpp579
-rwxr-xr-x[-rw-r--r--]src/cli/cli.h52
-rwxr-xr-x[-rw-r--r--]src/conf/conf.cpp242
-rwxr-xr-x[-rw-r--r--]src/conf/conf.h43
-rwxr-xr-xsrc/configure6641
-rw-r--r--src/contrib/crypt/md5.cpp357
-rw-r--r--src/contrib/crypt/md5.h39
-rw-r--r--src/contrib/crypt/md5crypt.cpp257
-rw-r--r--src/contrib/xml/tinyxml.cpp1703
-rw-r--r--src/contrib/xml/tinyxml.h2266
-rw-r--r--src/contrib/xml/tinyxmlerror.cpp68
-rw-r--r--src/contrib/xml/tinyxmlparser.cpp2708
-rwxr-xr-x[-rw-r--r--]src/data/con.cpp26
-rwxr-xr-x[-rw-r--r--]src/data/con.h12
-rwxr-xr-x[-rw-r--r--]src/data/con_base.cpp0
-rwxr-xr-x[-rw-r--r--]src/data/con_base.h10
-rw-r--r--src/data/data.cpp137
-rw-r--r--src/data/data.h26
-rw-r--r--src/data/data_base.cpp151
-rw-r--r--src/data/data_base.h47
-rwxr-xr-x[-rw-r--r--]src/glob.h230
-rwxr-xr-x[-rw-r--r--]src/html.cpp187
-rwxr-xr-x[-rw-r--r--]src/html.h65
-rwxr-xr-x[-rw-r--r--]src/incl.h29
-rwxr-xr-x[-rw-r--r--]src/logd.cpp205
-rwxr-xr-x[-rw-r--r--]src/logd.h58
-rwxr-xr-x[-rw-r--r--]src/main.cpp237
-rw-r--r--src/maps/hmap.h96
-rw-r--r--src/maps/hmap.tmpl289
-rw-r--r--src/maps/mtools.h26
-rw-r--r--src/maps/mtools.tmpl29
-rw-r--r--src/maps/nmap.h22
-rw-r--r--src/maps/nmap.tmpl31
-rw-r--r--src/maps/smap.h55
-rw-r--r--src/maps/smap.tmpl215
-rwxr-xr-x[-rw-r--r--]src/modl.cpp188
-rwxr-xr-x[-rw-r--r--]src/modl.h59
-rwxr-xr-x[-rw-r--r--]src/mods/Makefile12
-rwxr-xr-xsrc/mods/commands/Makefile.in18
-rw-r--r--src/mods/commands/yc_about.cpp98
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_all.cpp101
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_away.cpp150
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_col.cpp167
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_compopt.cpp45
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_exec.cpp108
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_fake.cpp67
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_getroom.cpp94
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_getrusage.cpp93
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_help.cpp106
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_invisible.cpp69
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_j.cpp203
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_ko.cpp112
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_m.cpp89
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_md5.cpp108
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_me.cpp77
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_morph.cpp101
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_msg.cpp128
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_q.cpp51
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_reload.cpp57
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_ren.cpp134
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_s.cpp105
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_set.cpp199
-rwxr-xr-xsrc/mods/commands/yc_template.cpp24
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_time.cpp55
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_topic.cpp162
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_uptime.cpp55
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_version.cpp45
-rwxr-xr-xsrc/mods/configure40
-rwxr-xr-xsrc/mods/html/Makefile.in18
-rw-r--r--src/mods/html/yc_admin.cpp143
-rwxr-xr-x[-rw-r--r--]src/mods/html/yc_colors.cpp76
-rwxr-xr-x[-rw-r--r--]src/mods/html/yc_help.cpp100
-rwxr-xr-x[-rw-r--r--]src/mods/html/yc_options.cpp103
-rwxr-xr-x[-rw-r--r--]src/mods/html/yc_register.cpp189
-rw-r--r--src/msgs.h95
-rwxr-xr-x[-rw-r--r--]src/name.cpp54
-rwxr-xr-x[-rw-r--r--]src/name.h40
-rwxr-xr-xsrc/ncur/menu.cpp119
-rwxr-xr-xsrc/ncur/menu.h39
-rwxr-xr-xsrc/ncur/ncur.cpp284
-rwxr-xr-xsrc/ncur/ncur.h50
-rwxr-xr-x[-rw-r--r--]src/reqp.cpp532
-rwxr-xr-x[-rw-r--r--]src/reqp.h77
-rwxr-xr-x[-rw-r--r--]src/sock/sock.cpp629
-rwxr-xr-x[-rw-r--r--]src/sock/sock.h102
-rw-r--r--src/stats.cpp149
-rw-r--r--src/stats.h48
-rwxr-xr-x[-rw-r--r--]src/thrd/pool.cpp306
-rwxr-xr-x[-rw-r--r--]src/thrd/pool.h98
-rw-r--r--src/thrd/thro.cpp47
-rw-r--r--src/thrd/thro.h48
-rwxr-xr-x[-rw-r--r--]src/time/timo.cpp44
-rwxr-xr-x[-rw-r--r--]src/time/timo.h36
-rwxr-xr-x[-rw-r--r--]src/time/timr.cpp193
-rwxr-xr-x[-rw-r--r--]src/time/timr.h104
-rw-r--r--src/tool/dir.cpp68
-rw-r--r--src/tool/dir.h48
-rw-r--r--src/tool/tool.cpp277
-rw-r--r--src/tool/tool.h52
-rwxr-xr-x[-rw-r--r--]src/wrap.cpp133
-rwxr-xr-x[-rw-r--r--]src/wrap.h147
118 files changed, 10108 insertions, 17625 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 66ab5be..0382389 100644..100755
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,33 +1,21 @@
-BIN=../bin/ychat
-CXX=@CXX@
-#EFLAGS=-frepo
-CXXFLAGS=-fno-inline -fno-default-inline @CXXFLAGS@ ${EFLAGS} ${BOOST_CPPFLAGS}
-LDADD+=@LIBS@-lstdc++ -D_THREAD_SAVE -export-dynamic
-PREFIX=@prefix@
-all: message ${OBJS}
- @dirname=`dirname ${BIN}`; if ! test -d $$dirname; then mkdir -p $$dirname; fi
- @echo; echo "===> Linking base sources"
- @${CXX} -o ${BIN} ${OBJS} ${LDADD}
- @echo "===> LDADD : ${LDADD}"
- @echo "===> CXXFLAGS : ${CXXFLAGS}"
- @echo "===> CXX : ${CXX}"
- @echo "===> Binary size : `du -hs ${BIN} | sed 's/\.\.\/bin\///'`"
- @echo "===> `cd ..; ./scripts/version.sh`"
- @echo
-${OBJS}:
- @dirname=`dirname $@`; if ! test -d $$dirname; then mkdir -p $$dirname; fi
- @${CXX} ${CXXFLAGS} -c -o $@ `echo $@ | \
- sed 's/\.\.\/obj\/\.\/\(.*\)\.o/\.\/\1.cpp/'`
- @echo "base:`echo $@ | sed 's/\.\.\/obj\/\.\/\(.*\)\.o$$/\1/'` (`du \
- -hs $@ | awk '{ print $$1 }'`) "
-message:
- @echo "===> Building base sources"
-clean:
- @echo "===> Cleaning base"
- @find ../obj -name '*.o' | grep -v mods | xargs rm -f
- @if [ -f ${BIN} ]; then rm -f ${BIN}; fi
-mrproper: clean
- @for i in autom4te.cache; \
- do if [ -d $$i ]; then rm -Rf $$i; fi; done
- @for i in Makefile config.h config.log config.status; \
- do if [ -f $$i ]; then rm -f $$i; fi; done
+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) $(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
index 145fb6c..dc44c69 100644..100755
--- a/src/chat/base.h
+++ b/src/chat/base.h
@@ -1,117 +1,89 @@
-/*:*
- *: File: ./src/chat/base.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
+// template class data declaration;
#include "../incl.h"
#ifndef BASE_H
#define BASE_H
-#include <map>
-#include "../maps/nhashmap.h"
+#include "../maps/smap.h"
template<class type>
-class base : public nhashmap<type*>
+class base : public smap<type*,string>
{
-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]) );
- }
+ 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 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 )
+ {
+ smap<type*,string>::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 )
+ {
+ smap<type*,string>::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()
+ {
+ smap<type*,string>::run_func( &base<type>::reconf_ );
+ }
+
+ static void reconf_ ( type* type_obj )
+ {
+ type_obj -> reconf ();
+ }
+
+ void get_data( map<string,string> *p_map_string )
+ {
+ smap<type*,string>::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;
+
+ smap<type*,string>::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"
diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl
index a8db1a0..53b609f 100644..100755
--- a/src/chat/base.tmpl
+++ b/src/chat/base.tmpl
@@ -1,88 +1,33 @@
-/*:*
- *: File: ./src/chat/base.tmpl
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef BASE_CPP
#define BASE_CPP
#include "base.h"
template<class type>
-base<type>::base()
-{}
+base<type>::base() : smap<type*,string>::smap(HMAPOCC)
+{
+}
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)
+base<type>::get_elem( string s_name, bool &b_found )
{
- bool b;
- return get_elem(s_name, b);
+ s_name = to_lower(s_name);
+ type* p_type = smap<type*,string>::get_elem( s_name );
+ b_found = p_type == NULL ? false : true;
+ return p_type;
}
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;
+ smap<type*,string>::add_elem(p_type, p_type->get_lowercase_name());
}
#endif
diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp
index 066bfbc..493c2a5 100644..100755
--- a/src/chat/chat.cpp
+++ b/src/chat/chat.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/chat.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
// class chat implementation.
#ifndef CHAT_CPP
@@ -36,208 +12,190 @@ 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 )
+ { // 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);
- }
- }
+ vec_replace_keys.push_back(s_from);
+ }
+ }
- sort(vec_replace_keys.begin(), vec_replace_keys.end());
- delete p_vec_keys;
- }
+ 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 );
+ // 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 );
+ bool b_flag;
+ return get_user( s_user, b_flag );
}
user*
chat::get_user( string &s_user, bool &b_found )
{
- container param;
+ container param;
- param.elem[0] = (void*) &s_user ;
- param.elem[1] = (void*) &b_found;
+ param.elem[0] = (void*) &s_user ;
+ param.elem[1] = (void*) &b_found;
- b_found = false;
+ b_found = false;
- base<room>::run_func( get_user_, (void*)&param );
+ smap<room*,string>::run_func( get_user_, (void*)&param );
- if ( *( (bool*) param.elem[1] ) )
- return (user*) param.elem[2];
+ 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;
+ container* param = (container*) v_arg;
- if ( *((bool*)param->elem[1]) )
- return;
+ if ( *((bool*)param->elem[1]) )
+ return;
- param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) );
+ 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 ( !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;
- }
-
- // prove if nick is banned from chat
- if (map_banned_nicks.exists(tool::to_lower(s_user))) {
- map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.banned" );
- map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" );
- 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"] )
+ 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.wrongpassword" );
- map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage.
- wrap::system_message( LOGINER + s_user );
- return;
+ 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;
}
- if ( p_user->get_has_sess() )
+ // prove if the nick is alphanumeric:
+ else if ( ! tool::is_alpha_numeric( s_user ) )
{
- map_params["tmpid"] = p_user->get_tmpid();
+ 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;
+ }
+
+ 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;
}
- else
+ // 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_value( string("nick"), (void *) new string(s_user) );
p_sess->set_user(p_user);
map_params["tmpid"] = p_sess->get_tmpid();
p_user->set_tmpid( map_params["tmpid"] );
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
+ else // if ( p_user == NULL ) // If not in garbage create a new user!
+ {
+ p_user = new user( s_user );
- hashmap<string> map_results = wrap::DATA->select_user_data( tool::to_lower(s_user), "selectlogin");
+ // prove if nick is registered, else create a guest chatter.
+#ifdef DATABASE
+ map<string,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 );
+ 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;
+ 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"];
+ 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
+ }
+ else
#endif
-
- { // If not registered prove if guest chatting is enabled.
- if (wrap::CONF->get_elem("chat.enableguest") != "true")
- {
+ { // 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 );
@@ -248,190 +206,147 @@ chat::login( map<string,string> &map_params )
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 );
}
- 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"]));
- }
-
- // 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 )
+ // 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
- {
+ }
+
+ else
+ {
p_room = new room( s_room );
wrap::system_message( NEWROOM + s_room );
- }
+ }
- add_elem( p_room );
- }
+ add_elem( p_room );
+ }
- // add user to the room.
- p_room->add_user( p_user );
+ // add user to the room.
+ p_room->add_user( p_user );
- wrap::system_message( NEWUSER + s_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";
+ // 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 );
+ // 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();
+ p_user->renew_timeout();
- string s_msg( map_params["message"] );
+ string s_msg( map_params["message"] );
- if ( s_msg.empty() )
- return;
+ 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" ) + "\">"
+ 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" ));
+ 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();
+ // 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 )
+ 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.erase( iter );
iter = list_msg.insert( iter, s_tmp[1] );
iter = list_msg.insert( iter, s_tmp[0] );
--iter;
+ }
+ else
+ {
+ s_msg.append(*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 );
-
- if (p_user->get_is_gag())
- {
- p_user->msg_post(wrap::CONF->colored_error_msg("chat.msgs.err.gagged"));
- return;
- }
-
-
- 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 );
+
+ 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();
-}
-
-string
-chat::ban_nick(string &s_nick, string s_reason) {
- string s_lower_nick(tool::to_lower(s_nick));
-
- if (map_banned_nicks.exists(s_lower_nick))
- return map_banned_nicks.get_elem(s_lower_nick);
-
- map_banned_nicks.add_elem(s_reason, s_lower_nick);
- return "";
-}
-
-string
-chat::unban_nick(string &s_nick) {
- string s_lower_nick(tool::to_lower(s_nick));
-
- if (!map_banned_nicks.exists(s_lower_nick))
- return "";
-
- string s_ret(map_banned_nicks.get_elem(s_lower_nick));
- map_banned_nicks.del_elem(s_lower_nick);
-
- return s_ret;
-}
-
-shashmap<string>*
-chat::get_map_banned_nicks() {
- return &map_banned_nicks;
+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]) );
+ }
}
#endif
diff --git a/src/chat/chat.h b/src/chat/chat.h
index 9da40e7..86b7c0b 100644..100755
--- a/src/chat/chat.h
+++ b/src/chat/chat.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/chat.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
// class chat declaration.
class chat;
@@ -37,57 +13,50 @@ class chat;
#include "user.h"
#include "sess.h"
#include "../tool/tool.h"
-#include "../maps/shashmap.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;
- shashmap<string> map_banned_nicks;
- shashmap<string, unsigned, self_hash<unsigned>, equals_allocator<unsigned> > map_banned_ips;
-
- void dumpit();
+ map<string,string> map_replace_strings;
+ vector<string> vec_replace_keys;
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 ) );
- }
-
- void del_elem( string s_name )
- {
- base<room>::del_elem( s_name );
- }
-
- // 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 reconf();
- void string_replacer(string *p_msg);
- string ban_nick(string &s_nick, string s_reason);
- string unban_nick(string &s_nick);
- shashmap<string>* get_map_banned_nicks();
+ 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 )
+ {
+ smap<room*,string>::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
index ffdb8e5..2500b91 100644..100755
--- a/src/chat/gcol.cpp
+++ b/src/chat/gcol.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/gcol.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef GCOL_CPP
#define GCOL_CPP
@@ -31,113 +7,130 @@ using namespace std;
gcol::gcol()
{
- pthread_mutex_init( &mut_vec_rooms , NULL);
+ pthread_mutex_init( &mut_vec_rooms , NULL);
- p_map_users = new shashmap<user*>;
- wrap::system_message( GARBAGE );
+ p_map_users = new smap<user*,string>(HMAPOCC);
+ wrap::system_message( GARBAGE );
+#ifdef NCURSES
+ print_garbage();
+#endif
}
gcol::~gcol()
{
- remove_garbage();
- pthread_mutex_destroy( &mut_vec_rooms );
- delete p_map_users;
+ 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() );
+{
+ 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();
-
+{
+ 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() );
+#ifdef NCURSES
+ print_garbage();
+#endif
}
bool
gcol::remove_garbage()
{
- bool b_empty;
+ 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 );
+ pthread_mutex_lock ( &mut_vec_rooms );
+ b_empty = ( vec_rooms.empty() && p_map_users->get_size() == 0);
+ pthread_mutex_unlock( &mut_vec_rooms );
- if ( b_empty )
- return false;
+ if ( b_empty )
+ return false;
- wrap::system_message( GARBACT );
+ 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 );
+ 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();
+ p_map_users->run_func( delete_users_ );
+ p_map_users->make_empty();
- return true;
+#ifdef NCURSES
+ print_garbage();
+#endif
+ return true;
}
room*
gcol::get_room_from_garbage()
{
- pthread_mutex_lock ( &mut_vec_rooms );
+ pthread_mutex_lock ( &mut_vec_rooms );
- if ( vec_rooms.empty() )
- {
- pthread_mutex_unlock( &mut_vec_rooms );
- return NULL;
- }
+ 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 );
+ room* p_room = vec_rooms.back();
+ vec_rooms.pop_back();
+ pthread_mutex_unlock( &mut_vec_rooms );
- return p_room;
+#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;
+ 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) );
+ user* p_user = p_map_users->get_elem( tool::to_lower(s_user) );;
- if ( p_user != NULL )
+ 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() );
+ 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;
@@ -146,21 +139,36 @@ gcol::get_user_from_garbage( string s_user )
void
gcol::delete_users_( user *user_obj )
{
- wrap::system_message( REMUSER + user_obj->get_name() );
- user_obj->clean();
- delete 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 );
+ pthread_mutex_lock ( &mut_vec_rooms );
}
void
gcol::unlock_mutex()
{
- pthread_mutex_unlock ( &mut_vec_rooms );
+ 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->get_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
index bce0db0..4936ded 100644..100755
--- a/src/chat/gcol.h
+++ b/src/chat/gcol.h
@@ -1,62 +1,42 @@
-/*:*
- *: File: ./src/chat/gcol.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-// garbage collector
+// garbage collector
#include "../incl.h"
#ifndef GCOL_H
#define GCOL_H
-#include <vector>
+#include <vector>
#include "room.h"
#include "user.h"
-#include "../maps/shashmap.h"
+#include "../maps/smap.h"
using namespace std;
class gcol
{
-private:
- vector<room*> vec_rooms;
- shashmap<user*>* p_map_users;
+ private:
+ vector<room*> vec_rooms;
+ smap<user*,string>* p_map_users;
pthread_mutex_t mut_vec_rooms;
static void delete_users_( user* user_obj );
-public:
+#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();
+ 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
index 544d2c0..b862d43 100644..100755
--- a/src/chat/perm.cpp
+++ b/src/chat/perm.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/perm.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef PERM_CPP
#define PERM_CPP
@@ -32,76 +8,73 @@ using namespace std;
perm::perm()
{
- p_command_status = new shashmap< valwrap<int>* >;
- p_command_disabled = new shashmap< valwrap<bool>* >;
+ p_command_status = new smap< valwrap<int>*, string>(HMAPOCC);
+ p_command_disabled = new smap< valwrap<bool>*, string>(HMAPOCC);
- set_standard_command_permissions();
+ 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 );
+ 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;
+ 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;
+ if ( p_command_status->is_avail( s_command ) )
+ return p_command_status->get_elem( s_command )->val;
- return 0;
+ 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 );
+ valwrap<int>* p_val = p_command_status->set_elem( new valwrap<int>(i_int), s_command );
- if ( p_val )
- delete p_val;
+ 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;
+ if ( p_command_disabled->is_avail( 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 );
+ valwrap<bool>* p_val = p_command_disabled->set_elem( new valwrap<bool>(b_bool), s_command );
- if ( p_val )
- delete p_val;
+ 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;
+ 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
index 709b60e..8e08ba2 100644..100755
--- a/src/chat/perm.h
+++ b/src/chat/perm.h
@@ -1,29 +1,5 @@
-/*:*
- *: File: ./src/chat/perm.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
-#include "../maps/shashmap.h"
+#include "../maps/smap.h"
#ifndef PERM_H
#define PERM_H
@@ -31,36 +7,35 @@
using namespace std;
template<class type_>
-struct valwrap
-{
- type_ val;
- valwrap(type_ i)
- {
- val = i;
- }
-
- type_ get_val()
- {
- return val;
- }
+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();
+ smap< valwrap<int>*, string>* p_command_status;
+ smap< valwrap<bool>*, string>* p_command_disabled;
+ void set_standard_command_permissions();
+
public:
- perm( );
- ~perm( );
+ 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 );
+ 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
index a4d6549..c21639a 100644..100755
--- a/src/chat/room.cpp
+++ b/src/chat/room.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/room.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef ROOM_CPP
#define ROOM_CPP
@@ -32,110 +8,94 @@ using namespace std;
room::room( string s_name ) : name( s_name )
{
- pthread_mutex_init( &mut_s_topic, NULL );
+ 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") );
+ 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();
+ wrap::STAT->increment_num_rooms();
}
room::~room()
{
- wrap::STAT->decrement_num_rooms();
+ wrap::STAT->decrement_num_rooms();
- // Delete all user objects
- run_func( mtools<user*>::delete_obj );
+ // Delete all user objects
+ run_func( mtools<user*>::delete_obj );
#ifdef LOGGING
-
- delete p_logd;
+ delete p_logd;
#endif
- pthread_mutex_destroy( &mut_s_topic );
- pthread_mutex_destroy( &mut_s_name );
+ 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;
+ 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();
+ 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>");
+ 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 );
+ 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();");
+ string s_msg = "<script language=\"JavaScript\"> parent.online.location.reload(); </script>\n";
+ msg_post( &s_msg );
}
-void
+void
room::set_name( string s_name )
{
- if ( tool::to_lower(s_name) == get_lowercase_name() )
- {
- name::set_name( s_name );
- return;
- }
+ if ( tool::to_lower(s_name) == get_lowercase_name() )
+ {
+ name::set_name( s_name );
+ return;
+ }
#ifdef LOGGING
- p_logd->flush_logs();
+ p_logd->flush_logs();
#endif
- if ( s_name == "" )
- return;
+ if ( s_name == "" )
+ return;
- name::set_name( s_name );
+ name::set_name( s_name );
#ifdef LOGGING
-
- p_logd->set_logfile( wrap::CONF->get_elem("chat.logging.roomlogdir"), get_lowercase_name() );
+ 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
index 0988fd4..255f90e 100644..100755
--- a/src/chat/room.h
+++ b/src/chat/room.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/room.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
// class room declaration.
#include "../incl.h"
@@ -41,76 +17,63 @@ using namespace std;
class room : public base<user>, public name
{
private:
- string s_topic;
- pthread_mutex_t mut_s_topic;
+ string s_topic;
+ pthread_mutex_t mut_s_topic;
#ifdef LOGGING
-
- logd* p_logd;
+ 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 )
+ 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 )
+ {
+ smap<user*,string>::del_elem( s_name );
+ if ( smap<user*,string>::get_size() == 0 )
clean_room();
-
- else
- reload_onlineframe();
- }
-
- void msg_post( string s_msg )
- {
- msg_post( &s_msg );
- }
-
- void msg_post( string *p_msg )
- {
+ 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) );
+ p_logd->log_simple_line( logd::remove_html_tags(*p_msg) );
#endif
+ base<user>::msg_post( p_msg );
+ }
- 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();
+ 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();
+
};
diff --git a/src/chat/sess.cpp b/src/chat/sess.cpp
index 846876d..801a6bf 100644..100755
--- a/src/chat/sess.cpp
+++ b/src/chat/sess.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/sess.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef SESS_CPP
#define SESS_CPP
@@ -29,62 +5,53 @@
sess::sess( string s_tmpid )
{
- this->p_user = NULL;
- this->s_tmpid = s_tmpid;
+ this->p_user = NULL;
+ this->s_tmpid = s_tmpid;
}
sess::~sess()
-{}
-
-string
-sess::get_tmpid()
{
- return s_tmpid;
}
-void
-sess::set_tmpid(string s_tmpid)
+string
+sess::get_tmpid()
{
- this->s_tmpid = s_tmpid;
+ return s_tmpid;
}
string
sess::get_name()
{
- if ( p_user = NULL )
- return "";
+ if ( p_user = NULL )
+ return "";
- return p_user->get_name();
+ return p_user->get_name();
}
void
sess::set_name(string s_name)
{
- if ( p_user != NULL )
- p_user->set_name(s_name);
+ if ( p_user != NULL )
+ p_user->set_name(s_name);
}
user*
sess::get_user()
{
- return p_user;
+ return p_user;
}
void
sess::set_user(user* p_user)
{
- this->p_user = p_user;
- //p_user->set_sess(this);
+ this->p_user = p_user;
}
-/*
+
void
-sess::invalidate()
+sess::invalidate()
{
- set_user(NULL);
- set_tmpid("!invalidated");
- wrap::system_message(SESSIOI);
+ this->s_tmpid = "0";
}
-*/
#endif
diff --git a/src/chat/sess.h b/src/chat/sess.h
index db4ad11..033e954 100644..100755
--- a/src/chat/sess.h
+++ b/src/chat/sess.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/sess.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef SESS_H
@@ -34,22 +10,22 @@ class cont;
using namespace std;
-class sess
+class sess
{
private:
- string s_tmpid;
- user *p_user;
+ string s_tmpid;
+ user *p_user;
public:
- sess(string s_tmpid);
- ~sess();
-
- string get_tmpid();
- void set_tmpid(string s_tmpid);
- void set_user(user* p_user);
- user* get_user();
- void set_name(string s_name);
- string get_name();
- void invalidate();
+ 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
index 187531d..6ae665f 100644..100755
--- a/src/chat/sman.cpp
+++ b/src/chat/sman.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/sman.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef SMAN_CPP
#define SMAN_CPP
@@ -30,111 +6,110 @@
#include "../maps/mtools.h"
#include "../contrib/crypt/md5.h"
-sman::sman()
+sman::sman() : smap<sess*,string>::smap(HMAPOCC)
{
- i_continous_session_count = i_session_count = 0;
- pthread_mutex_init( &mut_i_session_count, NULL );
+ 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 );
+ // Delete each session object of the smap!
+ smap<sess*,string>::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;
+ string valid_chars = wrap::CONF->get_elem("chat.session.validchars");
+ string s_ret = "";
+
+ srand(time(0)+tool::string2int(wrap::CONF->get_elem("chat.session.kloakkey")));
+ int i_char;
+
+ for (int i = 0; i < i_len; i++)
+ {
+ i_char = rand() % 64;
+ s_ret += valid_chars[i_char];
+ }
+
+ if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" )
+ {
+ string s_salt = wrap::CONF->get_elem("chat.session.md5salt");
+ s_ret = string(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str()));
+ return s_ret.substr(s_ret.find(s_salt) + s_salt.length() + 3);
+ }
+
+ return s_ret;
}
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 );
+ string s_tmpid = generate_id( tool::string2int( wrap::CONF->get_elem( "chat.session.length" ) ) );
- pthread_mutex_lock( &mut_i_session_count );
- i_session_count++;
- wrap::system_message(string(SESSIOC) + "(" +
- tool::int2string(++i_continous_session_count) + "," +
- tool::int2string(reinterpret_cast<int>(p_sess)) + ")" );
+ sess* p_sess = new sess( s_tmpid );
- pthread_mutex_unlock( &mut_i_session_count );
+ 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 );
+ //????
+ add_elem( p_sess, s_tmpid );
- return p_sess;
+ return p_sess;
}
sess *sman::get_session( string s_id )
{
- return get_elem( s_id );
+ return get_elem( s_id );
}
void
sman::destroy_session( string s_id )
{
- sess* p_sess = get_elem(s_id);
-
- pthread_mutex_lock( &mut_i_session_count );
- i_session_count--;
+ pthread_mutex_lock( &mut_i_session_count );
+ i_session_count--;
+#ifdef NCURSES
+ print_sessions();
+#endif
+ pthread_mutex_unlock( &mut_i_session_count );
- wrap::system_message(string(SESSIOD) + "(" +
- tool::int2string(i_continous_session_count) + "," +
- tool::int2string(reinterpret_cast<int>(p_sess)) + ")" );
+ sess* p_sess = get_elem( s_id );
+ del_elem( s_id );
+ delete p_sess;
+}
- pthread_mutex_unlock( &mut_i_session_count );
+#ifdef NCURSES
+void sman::print_sessions()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_SESSION_X,NCUR_SESSION_Y, "Sessions: %d ", i_session_count);
+ refresh();
+ }
+}
- del_elem(s_id);
- delete p_sess;
+#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()
{
- pthread_mutex_lock( &mut_i_session_count );
- int i_ret = i_session_count;
- pthread_mutex_unlock( &mut_i_session_count );
- return i_ret;
+ 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;
}
-/*
-void
-sman::dump() {
- shashmap<sess*>::dump();
- cout << "BLA" << endl;
-}
-*/
-
+#endif
#endif
diff --git a/src/chat/sman.h b/src/chat/sman.h
index 4526ade..20b1a76 100644..100755
--- a/src/chat/sman.h
+++ b/src/chat/sman.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/sman.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef SMAN_H
@@ -30,29 +6,31 @@
#include <cstdlib>
#include "sess.h"
-#include "../maps/shashmap.h"
-#include "../monitor/dump.h"
+#include "../maps/smap.h"
using namespace std;
-class sman : public shashmap<sess*>
+class sman : private smap<sess*,string>
{
private:
- string generate_id( int i_len );
- int i_session_count;
- int i_continous_session_count;
+ string generate_id( int i_len );
+ int i_session_count;
- pthread_mutex_t mut_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 );
-
- //virtual void dump();
+ 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
};
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
index 93dd672..a73a909 100644..100755
--- a/src/chat/user.cpp
+++ b/src/chat/user.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/chat/user.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef USER_CPP
#define USER_CPP
@@ -32,676 +8,574 @@ using namespace std;
user::user() : name( "" )
{
- initialize();
+ initialize();
}
user::user( string s_name ) : name( s_name )
{
- initialize();
+ 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_b_is_gag );
- 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 );
+// 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()
{
- time(&t_flood_time);
- init_strings(wrap::CONF->get_vector("chat.fields.userstrings"));
- init_ints(wrap::CONF->get_vector("chat.fields.userints"));
- init_bools(wrap::CONF->get_vector("chat.fields.userbools"));
-
- this -> p_room = NULL;
- this -> b_is_reg = false;
- this -> b_is_gag = false;
- this -> b_set_changed_data = false;
- this -> b_away = false;
- this -> b_fake = false;
- 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_b_is_gag , 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();
+ 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" );
+ //map_mods = new smap<dynmod*,string>(HMAPOCC);
+
+ // 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;
-
+ // If this user has a session
+ if ( get_has_sess() )
+ {
#ifdef DATABASE
- // Store all changed data into the mysql table if this user is registered:
- if ( b_is_reg )
- wrap::DATA->update_user_data( get_name(), "savechangednick",
- map_changed_data );
+ // Store all changed data into the mysql table if this user is registered:
+ if ( b_is_reg )
+ wrap::DATA->update_user_data( get_name(), "savechangednick", map_changed_data );
+ wrap::SMAN->destroy_session( get_tmpid() );
#endif
+ // wrap::system_message( SESSION + tool::int2string( wrap::SMAN->get_session_count() ) );
+ }
- set_has_sess(false);
- wrap::SMAN->destroy_session(get_tmpid());
- //wrap::system_message(tool::int2string(reinterpret_cast<int>(*p_sess)));
- set_tmpid("");
+ set_fake( false );
+ set_invisible( false );
}
string
user::get_colored_name()
{
- return "<font color=\"#" + get_col1() + "\">" + get_name() + "</font>";
+ 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"];
+ 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();
+ // 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;
+ 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 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 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 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;
+ 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 );
+ 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;
-}
-
-bool
-user::get_is_gag( )
-{
- bool b_ret;
- pthread_mutex_lock ( &mut_b_is_gag );
- b_ret = b_is_gag;
- pthread_mutex_unlock( &mut_b_is_gag );
- return b_ret;
+ 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_is_gag( bool b_is_gag )
-{
- pthread_mutex_lock ( &mut_b_is_gag );
- this -> b_is_gag = b_is_gag;
- pthread_mutex_unlock( &mut_b_is_gag );
+ 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 );
+ 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 );
+ 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 );
+ 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;
+ 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;
+ 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 );
+ 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 );
+ 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;
+ 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 );
-}
-
-/*
-void
-user::set_sess( sess** p_sess )
-{
- this -> p_sess = p_sess;
+ 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 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 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 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 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;
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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;
+ 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 );
+ 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 );
- }
+ 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 );
+ 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)
+ check_restore_away();
+
+ unsigned pos = s_command.find( "/" );
+ unsigned pos2 = s_command.find( " " );
+ if( pos != string::npos )
{
- string sParam = s_command.substr(pos2, pos - pos2);
- params.push_back(sParam);
- pos2 = pos + 1;
- pos = s_command.find(" ", pos2);
+ s_command.replace( pos, 1, "" );
}
+ else
+ return;
- if (pos2 < s_command.size())
- {
- params.push_back(s_command.substr(pos2, s_command.size()-pos2));
+ 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 );
+
+ 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;
+ 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) );
+ ( *(mod->the_func) ) ( (void*) c );
- delete c;
+ delete c;
}
void
user::s_mess_delete( )
{
- pthread_mutex_lock ( &mut_s_mess );
- s_mess = "";
- pthread_mutex_unlock( &mut_s_mess );
+ 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 );
-}
+ pthread_mutex_lock ( &mut_s_mess );
+ s_mess.append( *p_msg );
+ pthread_mutex_unlock( &mut_s_mess );
-void
-user::post_action_msg(string s_msgkey)
-{
- get_room()->msg_post(wrap::TIMR->get_time()+" "+get_colored_bold_name()+wrap::CONF->get_elem(s_msgkey)+"<br>\n");
+ pthread_cond_signal( &cond_message );
}
void
-user::renew_timeout()
+user::check_timeout( int* i_idle_timeout )
{
- timo::renew_timeout();
- double d_time_diff = wrap::TIMR->get_time_diff(t_flood_time);
+ int i_user_timeout = (int) get_last_activity();
- if (d_time_diff < static_cast<double>(wrap::CONF->get_int("chat.floodprotection.seconds")))
- {
- if (++i_flood_messages > static_cast<double>(wrap::CONF->get_int("chat.floodprotection.messages")))
- {
- room* p_room = get_room();
- if (p_room == 0)
- {
- i_flood_messages = 0;
- return;
- }
-
- wrap::system_message(CHATFLO+get_name()+","+p_room->get_name()+","+tool::int2string(i_flood_messages)+")");
- msg_post(wrap::CONF->colored_error_msg("chat.msgs.err.flooding"));
- if (!get_is_gag())
- {
- set_is_gag(true);
- post_action_msg("chat.msgs.floodgag");
- }
- }
- }
-
- else
- {
- time(&t_flood_time);
- i_flood_messages = 0;
- }
-}
+ 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 );
-void
-user::check_timeout( int* i_idle_timeout )
-{
- double d_user_timeout = get_last_activity();
- if ( get_away() ? i_idle_timeout[1] <= d_user_timeout : i_idle_timeout[0] <= d_user_timeout )
- {
- wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string((int)d_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 );
+ }
- pthread_cond_signal( &cond_message );
- }
- else if ( ! get_away() && i_idle_timeout[2] <= d_user_timeout )
- {
- wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string((int)d_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();
- }
+ 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" );
+ 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();
- }
+ 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());
-}
-
-bool
-user::same_rooms(user *p_user)
-{
- return p_user->get_room()->get_lowercase_name()
- .compare(this->get_room()->get_lowercase_name()) == 0;
-}
-
-string
-user::make_colors(string s_msg)
{
- return "<font color=\"#" + get_col1() + "\">" + s_msg + "</font>";
}
#endif
diff --git a/src/chat/user.h b/src/chat/user.h
index cde0729..4acb8f0 100644..100755
--- a/src/chat/user.h
+++ b/src/chat/user.h
@@ -1,181 +1,134 @@
-/*:*
- *: File: ./src/chat/user.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef USER_H
#define USER_H
+#include "../maps/smap.h"
#include "../name.h"
#include "../time/timo.h"
-#include "../memb/memb.h"
-#include "../monitor/dump.h"
-
-using namespace std;
class room;
-//class sess;
-class user :
- public name,
- public timo,
- public dumpable,
- public memb_base
+using namespace std;
+
+class user : public name, public timo
{
private:
- // private members:
- string s_mess; // message string which has to be sent to the user.
-
- 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_is_gag; // true if user is gagged
- 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)
- bool b_set_changed_data; // Only set change data if required!
-
- int i_status; // user's rang ( see enum rang @ globals.h ).
- int i_old_status; // user's previous status.
- int i_flood_messages; // user's message posts (needed for flood protection, does not need to be syncronized)
- time_t t_flood_time; // user's time count (needed for flood protection, does not need to be syncronized)
-
- 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_pass; // password
- room* p_room; // pointer to the user's room.
-// sess** p_sess; // pointer to the pointer to the session object
-
- hashmap<string> map_changed_data; // Needed to tell yChat which data to change after user is removed!
- pthread_mutex_t mut_map_changed_data;
- pthread_mutex_t mut_s_mess;
-
- // 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_b_is_gag;
- 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;
-
- 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();
- bool get_is_gag();
- 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_is_gag( bool b_is_gag );
- 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 );
-// void set_sess(sess** p_sess);
- 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 post_action_msg(string s_msgkey);
- void check_timeout( int* i_idle_timeout );
- void renew_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();
- bool same_rooms(user *p_user);
- string make_colors(string s_msg);
+ // 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.
+
+ map<string,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.
+
+ // smap<dynmod*,string>* map_mods;
+
+ // pthread_mutex_t mut_map_mods;
+ 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 );
+
+ public:
+ pthread_cond_t cond_message;
+ pthread_mutex_t mut_message;
+
+ user();
+ user(string s_name);
+ ~user();
+
+ void clean();
+
+ // 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
index 02e3306..e39275a 100644..100755
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -1,409 +1,304 @@
-/*:*
- *: File: ./src/cli/cli.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef CLI_CPP
#define CLI_CPP
#include "cli.h"
#ifdef CLI
-
-#ifdef READLINE
-#include <readline/readline.h>
-#include <readline/history.h>
-#endif
-
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())
- {
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- 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);
- }
+ string s_param = "";
+ unsigned i_pos = s_input.find_first_of(" ");
+
+ 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;
+ cout << CLIPRMO << " !command - Uses system to run a command" << endl;
+#ifdef DEBUG
+ cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl;
+#endif
+ cout << CLIPRMO << " (e)cho VAR - Prints out configuration value of VAR" << endl
+ << 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;
+ }
- 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;
+ 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("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 << " (d)ebug - Starts debug routine (cli.cpp)" << endl;
+ cout << CLIPRMO << CLIWELC << endl;
+ cout << CLIPRMI;
+ }
+ //*>>
+
+#ifdef NCURSES
+ else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 )
+ {
+ return 0;
+ }
#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;
- 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 << " (shut)down - 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;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- else if( s_input.at(0) == '!' )
- {
- system( s_input.substr(1).c_str() );
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
+ //<<*
+ else if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 )
+ {
+ cout << CLIPRMO;
+ wrap::MODL->reload_modules();
+ cout << CLIPRMI;
+ }
+ //*>>
-#ifdef DEBUG
- else if ( s_input.compare("d") == 0 || s_input.compare("debug") == 0 )
- {
- debug_routine();
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
+#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("du") == 0 || s_input.compare("dump") == 0 )
- {
- dump d(vectorize(s_param));
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- 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;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
+ else if( s_input.compare("rusage") == 0 || s_input.compare("r") == 0 )
+ {
+ print_rusage();
+ cout << CLIPRMI;
+ }
- //<<*
- else if( s_input.compare("mysql") == 0 || s_input.compare("m") == 0 )
- {
- cout << CLIPRMO << CLIMSQL << endl;
+ else if( s_input.compare("ru") == 0 || s_input.compare("rusageh") == 0 )
+ {
+ cout << wrap::STAT->get_rusage_history( "ru_maxrss", string(CLIPRMO) + " " );
+ cout << CLIPRMI;
+ }
- 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());
+ else if( s_input.compare("set") == 0 )
+ {
+ string s_varname = "";
+ i_pos = s_param.find_first_of(" ");
- cout << CLIPRMO << CLIWELC << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- //*>>
+ 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 if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 )
- {
- cout << CLIPRMO;
- wrap::MODL->reload_modules();
- cout << MODRELO << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
+ else
+ s_param = "";
}
- //*>>
-#ifdef EXPERIM
- else if( s_input.compare("reconf") == 0 || s_input.compare("re") == 0 )
- {
- wrap::CHAT->reconf();
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
-#endif
+ string s_old_val = wrap::CONF->get_elem(s_varname);
- else if( s_input.compare("rusage") == 0 || s_input.compare("r") == 0 )
- {
- print_rusage();
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- else if( s_input.compare("ru") == 0 || s_input.compare("rusageh") == 0 )
+ if ( !s_old_val.empty() )
{
- cout << wrap::STAT->get_rusage_history( "ru_maxrss", string(CLIPRMO) + " " );
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
+ cout << CLIPRMO << "Old value: " << s_old_val << endl;
+ wrap::CONF->del_elem(s_varname);
}
- 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);
+ wrap::CONF->add_elem(s_param, s_varname);
+ cout << CLIPRMO << "New value: " << s_param << endl;
+ cout << CLIPRMI;
+ }
- if ( s_param.length() > i_pos+1 )
- s_param = s_param.substr(i_pos+1);
+ 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
- s_param = "";
- }
+ else if( s_input.compare("shutdown") == 0 || s_input.compare("s") == 0 )
+ {
+ exit(0);
+ }
- string s_old_val = wrap::CONF->get_elem(s_varname);
+ 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;
+ }
- if ( !s_old_val.empty() )
- {
- cout << CLIPRMO << "Old value: " << s_old_val << endl;
- wrap::CONF->del_elem(s_varname);
- }
+ //<<*
+ else if( s_input.compare("unl") == 0 || s_input.compare("unload") == 0 ) {
+ cout << CLIPRMO;
+ wrap::MODL->unload_modules();
+ cout << CLIPRMI;
+ }
+ //*>>
- wrap::CONF->add_elem(s_param, s_varname);
- cout << CLIPRMO << "New value: " << s_param << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- 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;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- else if( s_input.compare("shutdown") == 0 || s_input.compare("shut") == 0 )
- {
- exit(0);
- }
- else if( s_input.compare("t") == 0 || s_input.compare("time") == 0 )
+ else if( s_input.compare("u") == 0 || s_input.compare("unset") == 0 )
+ {
+ if (!s_param.empty())
{
- cout << CLIPRMO << "Time: " << wrap::TIMR->get_time() << endl
- << CLIPRMO << "Uptime: " << wrap::TIMR->get_uptime() << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
+ 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("unl") == 0 || s_input.compare("unload") == 0 )
- {
- cout << CLIPRMO;
- wrap::MODL->unload_modules();
- cout << MODUNLO << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- //*>>
+ else if( s_input.compare("v") == 0 || s_input.compare("version") == 0 )
+ {
+ cout << CLIPRMO << tool::ychat_version() << " " << UNAME << 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;
- }
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- }
- else if( s_input.compare("v") == 0 || s_input.compare("version") == 0 )
- {
- cout << CLIPRMO << tool::ychat_version() << " " << UNAME << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
- else
- {
- cout << CLIPRMO << CLIHELP << "\"" << s_input << "\"" << endl;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
- }
+ else
+ {
+ cout << CLIPRMO << CLIHELP << "\"" << s_input << "\"" << endl;
+ cout << CLIPRMI;
+ }
- return 1;
+ return 1;
}
void
+#ifndef NCURSES
cli::start(void* p_void)
+#else
+cli::start()
+#endif
{
- cout << CLIPRMO << CLIWELC << endl;
+ cout << CLIPRMO << CLIWELC << endl;
- string s_input;
+ string s_input;
+ cout << CLIPRMI;
- #ifndef READLINE
- cout << CLIPRMI;
- #endif
-
- while(1)
- {
- #ifndef READLINE
- getline(cin, s_input);
- #else
- char *c_line = readline(CLIPRMI);
- s_input = string(c_line);
- free(c_line);
- #endif
-
- if (!parse_input(s_input))
- break;
- }
+ 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;
+ 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;
}
#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;
+ 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
diff --git a/src/cli/cli.h b/src/cli/cli.h
index 98ecdd4..cc5a5fc 100644..100755
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/cli/cli.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -42,29 +18,35 @@
#define CLI_H
#ifdef CLI
+#ifndef NCURSES
#include "../thrd/thro.h"
-#include "../monitor/dump.h"
+#endif
using namespace std;
-class cli : public thro
+class cli
+#ifndef NCURSES
+: public thro
+#endif
{
private:
- int parse_input(string s_input);
- vector<string> vectorize(string s_param);
+ int parse_input(string s_input);
public:
- cli( );
- ~cli( );
+ cli( );
+ ~cli( );
#ifdef DEBUG
-
- void debug_routine();
+ void debug_routine();
#endif
- void print_rusage();
- void start(void* p_void);
- void start();
+ void print_rusage();
+
+#ifndef NCURSES
+ void start(void* p_void);
+#else
+ void start();
+#endif
};
#endif
diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp
index 14268d1..e54cbd4 100644..100755
--- a/src/conf/conf.cpp
+++ b/src/conf/conf.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/conf/conf.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef CONF_CPP
#define CONF_CPP
@@ -30,147 +6,136 @@
using namespace std;
-conf::conf( string s_conf, map<string,string>* p_main_loop_params ) : name::name( s_conf )
+conf::conf( string s_conf, map<string,string>* p_start_params ) : nmap<string,string>::nmap(HMAPOCC), 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_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;
+ 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 )
+ for ( int i = 0; i < 4; ++i )
{
- s_config = s_check[i];
- if_check.close();
- cout << "... ok!" << endl;
- break;
+ 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;
}
- 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 ( s_config.empty() )
+ {
+ cout << CFILEFA << endl;
+ exit(1);
+ }
- if ( !p_xml->LoadFile() )
- {
- cout << XMLER1 << endl;
- exit(1);
- }
+ else
+ {
+ cout << CFILEOK << "..." << endl;
+ }
- vector<string> vec_string;
- parse_xml(p_xml, &vec_string);
+ p_xml = new TiXmlDocument(s_config.c_str());
+ TiXmlBase::SetCondenseWhiteSpace( false );
+
+ if ( !p_xml->LoadFile() )
+ {
+ cout << XMLER1 << endl;
+ exit(1);
+ }
- shashmap<string>::add_elem_insecure(tool::ychat_version(), "ychat.version");
+ vector<string> vec_string;
+ parse_xml(p_xml, &vec_string);
- // Overrides ychat.conf values with command line options (ychat -o key1 value1 -o key2 value2 ...)
- map<string,string>::iterator iter;
- for ( iter = p_main_loop_params->begin(); iter != p_main_loop_params->end(); iter++ )
- {
- shashmap<string>::del_elem_insecure(iter->first);
- shashmap<string>::add_elem_insecure(iter->second, iter->first);
- }
+ nmap<string,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++ )
+ {
+ nmap<string,string>::del_elem_insecure(iter->first);
+ nmap<string,string>::add_elem_insecure(iter->second, iter->first);
+ }
- delete p_xml;
+ delete p_xml;
}
void
conf::parse_xml(TiXmlNode* p_node, vector<string>* p_vec)
{
if ( p_node->NoChildren() )
- return;
+ 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;
+ //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();
- }
+ 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 = "";
+ 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 + ".");
+ 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();
+ TiXmlElement* p_element = p_child->ToElement();
+ exit_if_xml_error();
- s_option_name.append(p_element->Attribute("name"));
+ s_option_name.append(p_element->Attribute("name"));
#ifdef VERBOSE
- cout << XMLREAD << s_option_name;
+ cout << XMLREAD << s_option_name;
#endif
- TiXmlNode *p_node_value = p_element->FirstChild("value");
- TiXmlNode *p_node_descr = p_element->FirstChild("descr");
+ 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;
+ 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_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_node_descr && p_node_descr->FirstChild() )
+ p_text_descr = p_node_descr->FirstChild()->ToText();
- if ( !p_text_value )
- continue;
+ if ( !p_text_value )
+ continue;
#ifdef VERBOSE
- cout << " := " << p_text_value->Value() << endl;
+ cout << " := " << p_text_value->Value() << endl;
#endif
- shashmap<string>::add_elem_insecure(p_text_value->Value(), s_option_name);
+ nmap<string,string>::add_elem_insecure(p_text_value->Value(), s_option_name);
- if ( !p_text_descr )
- continue;
+ if ( !p_text_descr )
+ continue;
- s_option_name.append(".descr");
+ s_option_name.append(".descr");
#ifdef VERBOSE
- cout << XMLREAD << s_option_name << endl;
+ cout << XMLREAD << s_option_name << endl;
#endif
- shashmap<string>::add_elem_insecure(p_text_descr->Value(), s_option_name);
- }
+ nmap<string,string>::add_elem_insecure(p_text_descr->Value(), s_option_name);
+ }
}
- exit_if_xml_error()
- ;
+ exit_if_xml_error();
}
-conf::~conf()
+conf::~conf()
{
delete p_xml;
}
@@ -178,42 +143,21 @@ conf::~conf()
void
conf::exit_if_xml_error() const
{
- if ( p_xml->Error() )
- {
- cout << XMLERR << p_xml->ErrorDesc() << endl;
- exit(1);
- }
+ 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";
+ return "<font color=\"#"
+ + nmap<string,string>::get_elem("chat.html.errorcolor")
+ + "\">" + nmap<string,string>::get_elem(s_key) + "</font><br>\n";
}
//*>>
-int
-conf::get_int(string s_key)
-{
- return tool::string2int(get_elem(s_key));
-}
-
-vector<string>
-conf::get_vector(string s_key)
-{
- vector<string> vec_ret;
- string s_val = get_elem(s_key);
-
- for (unsigned i_pos = s_val.find(" "); i_pos != string::npos; i_pos = s_val.find(" "))
- {
- vec_ret.push_back(s_val.substr(0, i_pos));
- s_val = s_val.substr(i_pos+1);
- }
-
- vec_ret.push_back(s_val);
- return vec_ret;
-}
#endif
diff --git a/src/conf/conf.h b/src/conf/conf.h
index 3f237ad..3a7d0c6 100644..100755
--- a/src/conf/conf.h
+++ b/src/conf/conf.h
@@ -1,54 +1,27 @@
-/*:*
- *: File: ./src/conf/conf.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef CONF_H
#define CONF_H
class conf; // Predefine for nmap.tmpl
-#include <map>
#include "../incl.h"
-#include "../maps/shashmap.h"
+#include "../maps/nmap.h"
#include "../name.h"
#include "../contrib/xml/tinyxml.h"
using namespace std;
-class conf : public shashmap<string>, name
+class conf : public nmap<string,string>, name
{
private:
- TiXmlDocument* p_xml;
- void exit_if_xml_error() const;
- void parse_xml( TiXmlNode* p_node, vector<string>* p_vec);
+ 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_main_loop_params);
- ~conf();
+ conf(string s_conf, map<string,string>* p_start_params);
+ ~conf();
- string colored_error_msg(string s_key); //<<
- int get_int(string s_key);
- vector<string> get_vector(string s_key);
+ string colored_error_msg( string s_key ); //<<
};
#endif
diff --git a/src/configure b/src/configure
index 4682ef6..64cc404 100755
--- a/src/configure
+++ b/src/configure
@@ -1,6395 +1,256 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59.
+#!/bin/sh
#
-# Copyright (C) 2003 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-exec 6>&1
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_config_libobj_dir=.
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete. It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
-# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-
-ac_unique_file="main.cpp"
-ac_default_prefix=/usr/local
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CPP EGREP efind LIBOBJS LTLIBOBJS'
-ac_subst_files=''
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-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'
-
-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
-
- ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
-
- # 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_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$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 ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval "enable_$ac_feature=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) 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 | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$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 | -n)
- 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_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "with_$ac_package='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- 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 "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; }
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
- { (exit 1); exit 1; }; }
- ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
- eval "$ac_envvar='$ac_optarg'"
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- { echo "$as_me: error: missing argument to $ac_option" >&2
- { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
- localstatedir libdir includedir oldincludedir infodir mandir
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-# 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_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$0" : 'X\(//\)[^/]' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$0" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- 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 "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
- { (exit 1); exit 1; }; }
- else
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
- { (exit 1); exit 1; }; }
- fi
-fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
- { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
- { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-
-#
-# Report the --help message.
+# The yChat Project (2003 - 2004)
#
-if test "$ac_init_help" = "long"; then
- # 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 <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-_ACEOF
-
- cat <<_ACEOF
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --infodir=DIR info documentation [PREFIX/info]
- --mandir=DIR man documentation [PREFIX/man]
-_ACEOF
-
- cat <<\_ACEOF
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-
- cat <<\_ACEOF
-
-Optional Features:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --disable-readline Disables readline support (default=yes)
- --enable-ssl Enable OpenSSL support (default=no)
- --enable-mysql Enable MySQL support (default=no)
-
-Some influential environment variables:
- CXX C++ compiler command
- CXXFLAGS C++ compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
- headers in a nonstandard directory <include dir>
- CC C compiler command
- CFLAGS C compiler flags
- CPP C preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-_ACEOF
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- ac_popdir=`pwd`
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d $ac_dir || continue
- ac_builddir=.
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
- cd $ac_dir
- # Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_srcdir/configure.gnu; then
- echo
- $SHELL $ac_srcdir/configure.gnu --help=recursive
- elif test -f $ac_srcdir/configure; then
- echo
- $SHELL $ac_srcdir/configure --help=recursive
- elif test -f $ac_srcdir/configure.ac ||
- test -f $ac_srcdir/configure.in; then
- echo
- $ac_configure --help
- else
- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi
- cd $ac_popdir
- done
-fi
-
-test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
- cat <<\_ACEOF
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit 0
-fi
-exec 5>config.log
-cat >&5 <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by $as_me, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- echo "PATH: $as_dir"
-done
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_sep=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
- 2)
- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
- # Get rid of the leading space.
- ac_sep=" "
- ;;
- esac
- done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
+if ! which perl >/dev/null
+then
+ echo You need to have Perl in your PATH
+ exit 1
+fi
+
+if ! test -f ../g++.version
+then
+ echo You need to run ./configure of the top level source dir first
+ exit 1
+fi
+
+perl -e '
+ use strict;
+ $|=1;
+
+ my %libadd;
+ my %incadd;
+ my $deepness = 500;
+
+ my @headers = (
+ "dlfcn.h",
+ "pthread.h",
+ "mysql/mysql.h", #//<< Not needed for yhttpd
+ "netinet/in.h",
+ "time.h",
+ "ncurses.h"
+ );
+
+ my @libs = (
+ "libmysqlclient.so", #//<< Not needed for yhttpd
+ "libncurses.so"
+ );
+
+ sub remove_from_array
+ {
+ my $elem = shift;
+ my $array = shift;
+
+ for ( my $i = 0; $i <= $#$array; ++$i )
{
- echo
-
- cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
- echo
- # The following way of writing the cache mishandles newlines in values,
-{
- (set) 2>&1 |
- case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- sed -n \
- "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
- ;;
- *)
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-}
- echo
-
- cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
- echo
- sed "/^$/d" confdefs.h | sort
- echo
- fi
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal"
- echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core &&
- rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
- ' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# 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
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# 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 "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . $cache_file;;
- *) . ./$cache_file;;
- esac
- fi
-else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
- sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val="\$ac_cv_env_${ac_var}_value"
- eval ac_new_val="\$ac_env_${ac_var}_value"
- case $ac_old_set,$ac_new_set in
- set,)
- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
-echo "$as_me: former value: $ac_old_val" >&2;}
- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
-echo "$as_me: current value: $ac_new_val" >&2;}
- ac_cache_corrupted=:
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ac_config_headers="$ac_config_headers config.h"
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
- echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CXX" && break
- done
-fi
-if test -z "$CXX"; then
- ac_ct_CXX=$CXX
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-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 "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CXX"; then
- ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CXX="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
- echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CXX" && break
-done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
-
- CXX=$ac_ct_CXX
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5
-echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
- (eval $ac_link_default) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Find the output, starting from the most likely. This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
- ;;
- conftest.$ac_ext )
- # This is the source file.
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- # FIXME: I believe we export ac_cv_exeext for Libtool,
- # but it would be cool to find out if it's true. Does anybody
- # maintain Libtool? --akim.
- export ac_cv_exeext
- break;;
- * )
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C++ compiler cannot create executables
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
-
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5
-echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
- if { ac_try='./$ac_file'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C++ compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
- fi
- fi
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- export ac_cv_exeext
- break;;
- * ) break;;
- esac
-done
-else
- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
-if test "${ac_cv_objext+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cxx_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&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
-for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-# Check whether --enable-readline or --disable-readline was given.
-if test "${enable_readline+set}" = set; then
- enableval="$enable_readline"
-
-else
- enable_readline=yes
-fi;
-# Check whether --enable-readline or --disable-readline was given.
-if test "${enable_readline+set}" = set; then
- enableval="$enable_readline"
-
-fi;
-# Check whether --enable-ssl or --disable-ssl was given.
-if test "${enable_ssl+set}" = set; then
- enableval="$enable_ssl"
-
-fi;
-# Check whether --enable-mysqlclient or --disable-mysqlclient was given.
-if test "${enable_mysqlclient+set}" = set; then
- enableval="$enable_mysqlclient"
-
-fi;
-
-header_error() { { echo "$as_me:$LINENO: error: Could not find required header, please check the installation of the required header" >&5
-echo "$as_me: error: Could not find required header, please check the installation of the required header" >&2;}
- { (exit 1); exit 1; }; }
-lib_error() { { echo "$as_me:$LINENO: error: Library test failed, please check the installation of the required library" >&5
-echo "$as_me: error: Library test failed, please check the installation of the required library" >&2;}
- { (exit 1); exit 1; }; }
-
-echo "===> Checking for dependencies"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in 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 "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- 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 <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- 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 <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#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);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-for ac_header in dlfcn.h netinet/in.h time.h pthread.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-else
- header_error
-fi
-
-done
-
-
-echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
-echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6
-if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpthread $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char pthread_create ();
-int
-main ()
-{
-pthread_create ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_pthread_pthread_create=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_pthread_pthread_create=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5
-echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6
-if test $ac_cv_lib_pthread_pthread_create = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPTHREAD 1
-_ACEOF
-
- LIBS="-lpthread $LIBS"
-
-else
- lib_error
-fi
-
-
-echo -n "===> Configuring with SSL "
-if test -z $enable_ssl || test $enable_ssl != "yes"; then
- echo disabled
-else
- echo enabled
-
-for ac_header in openssl/ssl.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-else
- header_error
-fi
-
-done
-
-
-echo "$as_me:$LINENO: checking for SSL_write in -lssl" >&5
-echo $ECHO_N "checking for SSL_write in -lssl... $ECHO_C" >&6
-if test "${ac_cv_lib_ssl_SSL_write+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lssl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char SSL_write ();
-int
-main ()
-{
-SSL_write ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_ssl_SSL_write=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_ssl_SSL_write=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_SSL_write" >&5
-echo "${ECHO_T}$ac_cv_lib_ssl_SSL_write" >&6
-if test $ac_cv_lib_ssl_SSL_write = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBSSL 1
-_ACEOF
-
- LIBS="-lssl $LIBS"
-
-else
- lib_error
-fi
-
-fi
-
-echo -n "===> Configuring with MySQL "
-if test -z $enable_mysql || test $enable_mysql != "yes"; then
- echo disabled
-else
- echo enabled
-
-for ac_header in mysql/mysql.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-else
- header_error
-fi
-
-done
-
-
-echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
-echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6
-if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmysqlclient $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char mysql_init ();
-int
-main ()
-{
-mysql_init ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_mysqlclient_mysql_init=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_mysqlclient_mysql_init=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_mysqlclient_mysql_init" >&5
-echo "${ECHO_T}$ac_cv_lib_mysqlclient_mysql_init" >&6
-if test $ac_cv_lib_mysqlclient_mysql_init = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBMYSQLCLIENT 1
-_ACEOF
-
- LIBS="-lmysqlclient $LIBS"
-
-else
- lib_error
-fi
-
-fi
-
-echo -n "===> Configuring with readline "
-if test -z $enable_readline || test $enable_readline != "yes"; then
- echo disabled
-else
- echo enabled
-
-for ac_header in readline/readline.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-else
- header_error
-fi
-
-done
-
-
-echo "$as_me:$LINENO: checking for readline in -lreadline" >&5
-echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6
-if test "${ac_cv_lib_readline_readline+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lreadline $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char readline ();
-int
-main ()
-{
-readline ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_readline_readline=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_readline_readline=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5
-echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6
-if test $ac_cv_lib_readline_readline = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBREADLINE 1
-_ACEOF
-
- LIBS="-lreadline $LIBS"
-
-else
- lib_error
-fi
-
-fi
-
-echo "===> Checking for find with extended regexp "
-
-
-if find -E ./configure >/dev/null; then
- efind='find -E'
-else
- efind='find -regextype posix-extended'
-fi
-
-if test `uname` = "Linux"; then
- echo "===> Configuring with -ldl (Linux)"
-
-echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* 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;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBDL 1
-_ACEOF
-
- LIBS="-ldl $LIBS"
-
-else
- lib_error
-fi
-
-fi
-
-
- ac_config_files="$ac_config_files Makefile"
-cat >confcache <<\_ACEOF
-# 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, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# 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 \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[ ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[ ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
- # 2. Add them.
- ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling. Logging --version etc. is OK.
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by $as_me, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
- echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
- echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
- echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
- echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to <bug-autoconf@gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-config.status
-configured by $0, generated by GNU Autoconf 2.59,
- with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "x$1" : 'x\([^=]*\)='`
- ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- -*)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- *) # This is not an option, so the user has probably given explicit
- # arguments.
- ac_option=$1
- ac_need_defaults=false;;
- esac
-
- case $ac_option in
- # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --vers* | -V )
- echo "$ac_cs_version"; exit 0 ;;
- --he | --h)
- # Conflict between --help and --header
- { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit 0 ;;
- --debug | --d* | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1" ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
- case "$ac_config_target" in
- # Handling of arguments.
- "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
- trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./confstat$$-$RANDOM
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
- # Protect against being on the right side of a sed subst in config.status.
- sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
- s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s,@SHELL@,$SHELL,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s,@exec_prefix@,$exec_prefix,;t t
-s,@prefix@,$prefix,;t t
-s,@program_transform_name@,$program_transform_name,;t t
-s,@bindir@,$bindir,;t t
-s,@sbindir@,$sbindir,;t t
-s,@libexecdir@,$libexecdir,;t t
-s,@datadir@,$datadir,;t t
-s,@sysconfdir@,$sysconfdir,;t t
-s,@sharedstatedir@,$sharedstatedir,;t t
-s,@localstatedir@,$localstatedir,;t t
-s,@libdir@,$libdir,;t t
-s,@includedir@,$includedir,;t t
-s,@oldincludedir@,$oldincludedir,;t t
-s,@infodir@,$infodir,;t t
-s,@mandir@,$mandir,;t t
-s,@build_alias@,$build_alias,;t t
-s,@host_alias@,$host_alias,;t t
-s,@target_alias@,$target_alias,;t t
-s,@DEFS@,$DEFS,;t t
-s,@ECHO_C@,$ECHO_C,;t t
-s,@ECHO_N@,$ECHO_N,;t t
-s,@ECHO_T@,$ECHO_T,;t t
-s,@LIBS@,$LIBS,;t t
-s,@CXX@,$CXX,;t t
-s,@CXXFLAGS@,$CXXFLAGS,;t t
-s,@LDFLAGS@,$LDFLAGS,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@ac_ct_CXX@,$ac_ct_CXX,;t t
-s,@EXEEXT@,$EXEEXT,;t t
-s,@OBJEXT@,$OBJEXT,;t t
-s,@CC@,$CC,;t t
-s,@CFLAGS@,$CFLAGS,;t t
-s,@ac_ct_CC@,$ac_ct_CC,;t t
-s,@CPP@,$CPP,;t t
-s,@EGREP@,$EGREP,;t t
-s,@efind@,$efind,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
-s,@LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF
- # 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_lines=48
- ac_sed_frag=1 # Number of current file.
- ac_beg=1 # First line for current file.
- ac_end=$ac_max_sed_lines # 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" $tmp/subs.sed >$tmp/subs.frag
- else
- sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- fi
- if test ! -s $tmp/subs.frag; then
- ac_more_lines=false
- else
- # The purpose of the label and of the branching condition is to
- # speed up the sed processing (if there are no `@' at all, there
- # is no need to browse any of the substitutions).
- # These are the two extra sed commands mentioned above.
- (echo ':t
- /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
- fi
- ac_sed_frag=`expr $ac_sed_frag + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_lines`
- fi
- done
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
- fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
-
- if test x"$ac_file" != x-; then
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- rm -f "$ac_file"
- fi
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- configure_input=
- else
- configure_input="$ac_file. "
- fi
- configure_input=$configure_input"Generated from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s,@configure_input@,$configure_input,;t t
-s,@srcdir@,$ac_srcdir,;t t
-s,@abs_srcdir@,$ac_abs_srcdir,;t t
-s,@top_srcdir@,$ac_top_srcdir,;t t
-s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s,@builddir@,$ac_builddir,;t t
-s,@abs_builddir@,$ac_abs_builddir,;t t
-s,@top_builddir@,$ac_top_builddir,;t t
-s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
- rm -f $tmp/stdin
- if test x"$ac_file" != x-; then
- mv $tmp/out $ac_file
- else
- cat $tmp/out
- rm -f $tmp/out
- fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='[ ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- # Do quote $f, to prevent DOS paths from being IFS'd.
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
- # Remove the trailing spaces.
- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h. The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status. Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless. Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo ' :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
- # Write a limited-size here document to $tmp/defines.sed.
- echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#define' lines.
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/defines.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo ' fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
- # Write a limited-size here document to $tmp/undefs.sed.
- echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#undef'
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/undefs.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
- rm -f conftest.undefs
- mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- echo "/* Generated by configure. */" >$tmp/config.h
- else
- echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
- fi
- cat $tmp/in >>$tmp/config.h
- rm -f $tmp/in
- if test x"$ac_file" != x-; then
- if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- rm -f $ac_file
- mv $tmp/config.h $ac_file
- fi
- else
- cat $tmp/config.h
- rm -f $tmp/config.h
- fi
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
- ac_config_files="$ac_config_files ../Makefile"
-cat >confcache <<\_ACEOF
-# 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, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# 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 \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[ ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[ ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
- # 2. Add them.
- ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling. Logging --version etc. is OK.
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by $as_me, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
- echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
- echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
- echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
- echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to <bug-autoconf@gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-config.status
-configured by $0, generated by GNU Autoconf 2.59,
- with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "x$1" : 'x\([^=]*\)='`
- ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- -*)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- *) # This is not an option, so the user has probably given explicit
- # arguments.
- ac_option=$1
- ac_need_defaults=false;;
- esac
-
- case $ac_option in
- # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --vers* | -V )
- echo "$ac_cs_version"; exit 0 ;;
- --he | --h)
- # Conflict between --help and --header
- { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit 0 ;;
- --debug | --d* | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1" ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
- case "$ac_config_target" in
- # Handling of arguments.
- "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "../Makefile" ) CONFIG_FILES="$CONFIG_FILES ../Makefile" ;;
- "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
- trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./confstat$$-$RANDOM
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
- # Protect against being on the right side of a sed subst in config.status.
- sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
- s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s,@SHELL@,$SHELL,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s,@exec_prefix@,$exec_prefix,;t t
-s,@prefix@,$prefix,;t t
-s,@program_transform_name@,$program_transform_name,;t t
-s,@bindir@,$bindir,;t t
-s,@sbindir@,$sbindir,;t t
-s,@libexecdir@,$libexecdir,;t t
-s,@datadir@,$datadir,;t t
-s,@sysconfdir@,$sysconfdir,;t t
-s,@sharedstatedir@,$sharedstatedir,;t t
-s,@localstatedir@,$localstatedir,;t t
-s,@libdir@,$libdir,;t t
-s,@includedir@,$includedir,;t t
-s,@oldincludedir@,$oldincludedir,;t t
-s,@infodir@,$infodir,;t t
-s,@mandir@,$mandir,;t t
-s,@build_alias@,$build_alias,;t t
-s,@host_alias@,$host_alias,;t t
-s,@target_alias@,$target_alias,;t t
-s,@DEFS@,$DEFS,;t t
-s,@ECHO_C@,$ECHO_C,;t t
-s,@ECHO_N@,$ECHO_N,;t t
-s,@ECHO_T@,$ECHO_T,;t t
-s,@LIBS@,$LIBS,;t t
-s,@CXX@,$CXX,;t t
-s,@CXXFLAGS@,$CXXFLAGS,;t t
-s,@LDFLAGS@,$LDFLAGS,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@ac_ct_CXX@,$ac_ct_CXX,;t t
-s,@EXEEXT@,$EXEEXT,;t t
-s,@OBJEXT@,$OBJEXT,;t t
-s,@CC@,$CC,;t t
-s,@CFLAGS@,$CFLAGS,;t t
-s,@ac_ct_CC@,$ac_ct_CC,;t t
-s,@CPP@,$CPP,;t t
-s,@EGREP@,$EGREP,;t t
-s,@efind@,$efind,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
-s,@LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF
- # 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_lines=48
- ac_sed_frag=1 # Number of current file.
- ac_beg=1 # First line for current file.
- ac_end=$ac_max_sed_lines # 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" $tmp/subs.sed >$tmp/subs.frag
- else
- sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- fi
- if test ! -s $tmp/subs.frag; then
- ac_more_lines=false
- else
- # The purpose of the label and of the branching condition is to
- # speed up the sed processing (if there are no `@' at all, there
- # is no need to browse any of the substitutions).
- # These are the two extra sed commands mentioned above.
- (echo ':t
- /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
- fi
- ac_sed_frag=`expr $ac_sed_frag + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_lines`
- fi
- done
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
- fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
-
- if test x"$ac_file" != x-; then
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- rm -f "$ac_file"
- fi
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- configure_input=
- else
- configure_input="$ac_file. "
- fi
- configure_input=$configure_input"Generated from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s,@configure_input@,$configure_input,;t t
-s,@srcdir@,$ac_srcdir,;t t
-s,@abs_srcdir@,$ac_abs_srcdir,;t t
-s,@top_srcdir@,$ac_top_srcdir,;t t
-s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s,@builddir@,$ac_builddir,;t t
-s,@abs_builddir@,$ac_abs_builddir,;t t
-s,@top_builddir@,$ac_top_builddir,;t t
-s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
- rm -f $tmp/stdin
- if test x"$ac_file" != x-; then
- mv $tmp/out $ac_file
- else
- cat $tmp/out
- rm -f $tmp/out
- fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='[ ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- # Do quote $f, to prevent DOS paths from being IFS'd.
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
- # Remove the trailing spaces.
- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h. The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status. Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless. Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo ' :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
- # Write a limited-size here document to $tmp/defines.sed.
- echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#define' lines.
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/defines.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo ' fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
- # Write a limited-size here document to $tmp/undefs.sed.
- echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#undef'
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/undefs.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
- rm -f conftest.undefs
- mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- echo "/* Generated by configure. */" >$tmp/config.h
- else
- echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
- fi
- cat $tmp/in >>$tmp/config.h
- rm -f $tmp/in
- if test x"$ac_file" != x-; then
- if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- rm -f $ac_file
- mv $tmp/config.h $ac_file
- fi
- else
- cat $tmp/config.h
- rm -f $tmp/config.h
- fi
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
-
-echo "===> Posttasking Makefile"
-
-SRCS=`find ./ -type f -name '*.cpp' | grep -v ./mods`
-OBJS=''
-
-echo > .Makefile || exit 1
-echo > .Makefile.deps || exit 1
-
-for src in $SRCS; do
- obj=`echo $src | sed 's/\(.*\)\.cpp/\.\.\/obj\/\1\.o/'`
- OBJS="$OBJS $obj"
- echo "$obj: $src" >> .Makefile.deps
-done
-
-echo SRCS=$SRCS >> .Makefile.tmp
-echo OBJS=$OBJS >> .Makefile.tmp
-cat Makefile >> .Makefile.tmp
-cat .Makefile.deps >> .Makefile.tmp
-mv -f .Makefile.tmp Makefile || exit 1
-rm -f .Makefile.deps
-
-echo "===> Posttasking config.h"
-cat << END >> config.h
-
-/* Program prefix. */
-#define PREFIX "$prefix"
-END
+ if ( $$array[$i] eq $elem )
+ {
+ splice(@$array,$i,1);
+ last;
+ }
+ }
+ }
+
+ 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);
+ }
-echo You are ready to run GNU Make now!
+ elsif ( /\/\/#define NCURSES/ )
+ {
+ remove_from_array("ncurses.h",\@headers);
+ remove_from_array("libncurses.so",\@libs);
+ }
+ }
+ close FILE;
+
+ my @headerpaths = (
+ $ENV{HOME}."/include",
+ $ENV{HOME}."/usr/include",
+ "/include",
+ "/usr/include",
+ "/usr/local/include",
+ "/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"
+ );
+
+ 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};
+ }
+
+ sub check {
+ my $deep = shift;
+
+ if ($deep == 0) {
+ print "Looking too deep! ($deepness)\n";
+ exit(1);
+ }
+
+ my $check = shift;
+ my $print = 1;
+ if ( $_[-1] eq "subsearch" ) {
+ $print = 0;
+ pop(@_);
+ }
+
+ print "Checking for $check... " if $print;
+ foreach (@_) {
+ if ( -f "$_/$check" ) {
+ print "OK\n";
+ return "" if $_ eq "/usr/lib" or $_ eq "/usr/include";
+ return $_;
+ }
+ }
+
+ foreach (@_) {
+ next unless -d $_;
+ opendir D, $_ or warn "$_: $!\n"; my @dir = readdir(D);
+ closedir D;
+ foreach 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";
+ exit(1);
+ }
+ `touch ../err`;
+ return "";
+ }
+
+ map { $incadd{&check($deepness, $_, @headerpaths)}++ }
+ @headers;
+
+ map { $libadd{&check($deepness, $_, @libpaths)}++ }
+ @libs;
+
+ sub makeadd {
+ my $flag = shift;
+ my $add = shift;
+ my $ret = "";
+
+ foreach (keys %$add) {
+ next unless /.+/;
+ $ret .= "$flag$_ ";
+ }
+ return $ret;
+ }
+
+ my $incadd = &makeadd("-I", \%incadd);
+ my $libadd = &makeadd("-L", \%libadd);
+
+ foreach ( @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";
+ open Fin, "Makefile.in" or die "Makefile.in: $!\n";
+ open Fout, ">Makefile" or die "Makefile: $!\n";
+
+ my $cpp = `echo *.cpp */*.cpp contrib/*/*.cpp | sort`;
+ my $compiler = `tail -n 1 ../g++.version`;
+ my $version = `tail -n 2 ../g++.version | head -n 1`;
+ my $uname = `uname -srm`;
+ my $compopt = join "; ", split /\n/, `cat ../g++.version`;
+ chomp $uname;
+ chomp $compopt;
+ print "Configuring for $uname...\n";
+ chomp $cpp;
+ chomp $version;
+ while (<Fin>) {
+ s/^(CC=).*\n/$1$compiler/;
+ s/^(SRCS=).*/$1$cpp/;
+ s/ -frepo//; # unless $version =~ /3\.4/;
+ if ( $uname !~ /Linux/i ) {
+ print "Disabling -ldl flag...\n" if s/ -ldl//;
+ }
+ print Fout;
+ }
+ close Fin;
+
+ my $args = join(" -",@ARGV);
+ $args = "-".$args unless $args eq "";
+
+ foreach 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";
+ if ( $ofile =~ /contrib\/.+/ ) {
+ my $dirname = `dirname $ofile`;
+ print Fout "\t\@echo -n \"Compiling contributed class $ofile \"\n";
+ } else {
+ print Fout "\t\@echo -n \"Compiling base class $ofile \"\n";
+ }
+ print Fout "\t\@\$(CC) \$(CFLAGS) \$(INCLUDES) $args -c -o ../obj/$ofile $cppfile\n";
+ print Fout "\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";
+ foreach (@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("..");
+ }
+
+ exit(0);
+
+' `echo "$*" | sed "s/-//g"`
diff --git a/src/contrib/crypt/md5.cpp b/src/contrib/crypt/md5.cpp
index 492f8b6..7023956 100644
--- a/src/contrib/crypt/md5.cpp
+++ b/src/contrib/crypt/md5.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/contrib/crypt/md5.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
@@ -42,8 +18,7 @@
#include <string.h> /* for memcpy() */
#include "md5.h"
-namespace md5
-{
+namespace md5 {
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
@@ -52,20 +27,18 @@ void byteReverse(unsigned char *buf, unsigned longs);
#ifndef ASM_MD5
/*
-* Note: this code is harmless on little-endian machines.
-*/
+ * 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);
+ 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
@@ -77,13 +50,13 @@ byteReverse(unsigned char *buf, unsigned longs)
void
MD5Init(struct MD5Context *ctx)
{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
}
/*
@@ -93,49 +66,46 @@ MD5Init(struct MD5Context *ctx)
void
MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
{
- uint32 t;
+ uint32 t;
- /* Update bitcount */
+ /* 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 = 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 */
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
- /* Handle any leading odd-sized chunks */
+ /* Handle any leading odd-sized chunks */
- if (t)
- {
- unsigned char *p = (unsigned char *) ctx->in + t;
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
- t = 64 - t;
- if (len < t)
- {
- memcpy(p, buf, len);
- return;
+ 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;
}
- 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. */
+ /* Handle any remaining bytes of data. */
- memcpy(ctx->in, buf, len);
+ memcpy(ctx->in, buf, len);
}
/*
@@ -145,46 +115,43 @@ MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
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);
+ 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);
- /* 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 */
+ /* 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
@@ -209,85 +176,85 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
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;
+ 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
index 0681ef4..0b9d532 100644
--- a/src/contrib/crypt/md5.h
+++ b/src/contrib/crypt/md5.h
@@ -1,49 +1,22 @@
-/*:*
- *: File: ./src/contrib/crypt/md5.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef MD5_H
#define MD5_H
-namespace md5
-{
+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];
+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);
+ unsigned len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Transform(uint32 buf[4], uint32 const in[16]);
diff --git a/src/contrib/crypt/md5crypt.cpp b/src/contrib/crypt/md5crypt.cpp
index 90606f1..16b0235 100644
--- a/src/contrib/crypt/md5crypt.cpp
+++ b/src/contrib/crypt/md5crypt.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/contrib/crypt/md5crypt.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
@@ -40,20 +16,18 @@
#include <string.h>
#include "md5.h"
-namespace md5
-{
+namespace md5 {
static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static void
to64(char *s, unsigned long v, int n)
{
- while (--n >= 0)
- {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
+ while (--n >= 0) {
+ *s++ = itoa64[v&0x3f];
+ v >>= 6;
+ }
}
/*
@@ -65,122 +39,109 @@ to64(char *s, unsigned long v, int n)
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;
+ 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/tinyxml.cpp b/src/contrib/xml/tinyxml.cpp
index fe9a616..dd1f471 100644
--- a/src/contrib/xml/tinyxml.cpp
+++ b/src/contrib/xml/tinyxml.cpp
@@ -1,47 +1,23 @@
-/*:*
- *: File: ./src/contrib/xml/tinyxml.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
/*
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.
*/
@@ -58,1395 +34,1394 @@ bool TiXmlBase::condenseWhiteSpace = true;
void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream )
{
- TIXML_STRING buffer;
- PutString( str, &buffer );
- (*stream) << buffer;
+ 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;
- }
- }
+ 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() );
- }
+ buffer = new char[ str.length()+1 ];
+ if ( buffer )
+ {
+ strcpy( buffer, str.c_str() );
+ }
}
TiXmlBase::StringToBuffer::~StringToBuffer()
{
- delete [] buffer;
+ delete [] buffer;
}
// End strange bug fix. -->
TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
{
- parent = 0;
- type = _type;
- firstChild = 0;
- lastChild = 0;
- prev = 0;
- next = 0;
+ parent = 0;
+ type = _type;
+ firstChild = 0;
+ lastChild = 0;
+ prev = 0;
+ next = 0;
}
TiXmlNode::~TiXmlNode()
{
- TiXmlNode* node = firstChild;
- TiXmlNode* temp = 0;
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
- while ( node )
- {
- temp = node;
- node = node->next;
- delete temp;
- }
+ while ( node )
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
}
void TiXmlNode::CopyTo( TiXmlNode* target ) const
{
- target->SetValue (value.c_str() );
- target->userData = userData;
+ target->SetValue (value.c_str() );
+ target->userData = userData;
}
void TiXmlNode::Clear()
{
- TiXmlNode* node = firstChild;
- TiXmlNode* temp = 0;
+ TiXmlNode* node = firstChild;
+ TiXmlNode* temp = 0;
- while ( node )
- {
- temp = node;
- node = node->next;
- delete temp;
- }
+ while ( node )
+ {
+ temp = node;
+ node = node->next;
+ delete temp;
+ }
- firstChild = 0;
- lastChild = 0;
+ firstChild = 0;
+ lastChild = 0;
}
TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
{
- node->parent = this;
+ node->parent = this;
- node->prev = lastChild;
- node->next = 0;
+ node->prev = lastChild;
+ node->next = 0;
- if ( lastChild )
- lastChild->next = node;
- else
- firstChild = node; // it was an empty list.
+ if ( lastChild )
+ lastChild->next = node;
+ else
+ firstChild = node; // it was an empty list.
- lastChild = node;
- return node;
+ lastChild = node;
+ return node;
}
TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
{
- TiXmlNode* node = addThis.Clone();
- if ( !node )
- return 0;
+ TiXmlNode* node = addThis.Clone();
+ if ( !node )
+ return 0;
- return LinkEndChild( node );
+ 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;
+{
+ 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;
+ if ( !afterThis || afterThis->parent != this )
+ return 0;
- TiXmlNode* node = addThis.Clone();
- if ( !node )
- return 0;
- node->parent = this;
+ 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;
+ 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;
+ if ( replaceThis->parent != this )
+ return 0;
- TiXmlNode* node = withThis.Clone();
- if ( !node )
- return 0;
+ TiXmlNode* node = withThis.Clone();
+ if ( !node )
+ return 0;
- node->next = replaceThis->next;
- node->prev = replaceThis->prev;
+ node->next = replaceThis->next;
+ node->prev = replaceThis->prev;
- if ( replaceThis->next )
- replaceThis->next->prev = node;
- else
- lastChild = node;
+ if ( replaceThis->next )
+ replaceThis->next->prev = node;
+ else
+ lastChild = node;
- if ( replaceThis->prev )
- replaceThis->prev->next = node;
- else
- firstChild = node;
+ if ( replaceThis->prev )
+ replaceThis->prev->next = node;
+ else
+ firstChild = node;
- delete replaceThis;
- node->parent = this;
- return node;
+ delete replaceThis;
+ node->parent = this;
+ return node;
}
bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
{
- if ( removeThis->parent != this )
- {
- assert( 0 );
- return false;
- }
+ if ( removeThis->parent != this )
+ {
+ assert( 0 );
+ return false;
+ }
- if ( removeThis->next )
- removeThis->next->prev = removeThis->prev;
- else
- lastChild = removeThis->prev;
+ if ( removeThis->next )
+ removeThis->next->prev = removeThis->prev;
+ else
+ lastChild = removeThis->prev;
- if ( removeThis->prev )
- removeThis->prev->next = removeThis->next;
- else
- firstChild = removeThis->next;
+ if ( removeThis->prev )
+ removeThis->prev->next = removeThis->next;
+ else
+ firstChild = removeThis->next;
- delete removeThis;
- return true;
+ 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* 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* 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();
- }
+ 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 );
- }
+ 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* 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;
+ 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;
- }
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( node )
+ {
+ attributeSet.Remove( node );
+ delete node;
+ }
}
TiXmlElement* TiXmlNode::FirstChildElement() const
{
- TiXmlNode* node;
+ TiXmlNode* node;
- for ( node = FirstChild();
- node;
- node = node->NextSibling() )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
+ for ( node = FirstChild();
+ node;
+ node = node->NextSibling() )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
}
TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
{
- TiXmlNode* node;
+ TiXmlNode* node;
- for ( node = FirstChild( _value );
- node;
- node = node->NextSibling( _value ) )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
+ for ( node = FirstChild( _value );
+ node;
+ node = node->NextSibling( _value ) )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
}
TiXmlElement* TiXmlNode::NextSiblingElement() const
{
- TiXmlNode* node;
+ TiXmlNode* node;
- for ( node = NextSibling();
- node;
- node = node->NextSibling() )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
+ for ( node = NextSibling();
+ node;
+ node = node->NextSibling() )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
}
TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
{
- TiXmlNode* node;
+ TiXmlNode* node;
- for ( node = NextSibling( _value );
- node;
- node = node->NextSibling( _value ) )
- {
- if ( node->ToElement() )
- return node->ToElement();
- }
- return 0;
+ for ( node = NextSibling( _value );
+ node;
+ node = node->NextSibling( _value ) )
+ {
+ if ( node->ToElement() )
+ return node->ToElement();
+ }
+ return 0;
}
TiXmlDocument* TiXmlNode::GetDocument() const
{
- const TiXmlNode* node;
+ const TiXmlNode* node;
- for( node = this; node; node = node->parent )
- {
- if ( node->ToDocument() )
- return node->ToDocument();
- }
- return 0;
+ for( node = this; node; node = node->parent )
+ {
+ if ( node->ToDocument() )
+ return node->ToDocument();
+ }
+ return 0;
}
TiXmlElement::TiXmlElement (const char * _value)
- : TiXmlNode( TiXmlNode::ELEMENT )
+ : TiXmlNode( TiXmlNode::ELEMENT )
{
- firstChild = lastChild = 0;
- value = _value;
+ firstChild = lastChild = 0;
+ value = _value;
}
#ifdef TIXML_USE_STL
-TiXmlElement::TiXmlElement( const std::string& _value )
- : TiXmlNode( TiXmlNode::ELEMENT )
+TiXmlElement::TiXmlElement( const std::string& _value )
+ : TiXmlNode( TiXmlNode::ELEMENT )
{
- firstChild = lastChild = 0;
- value = _value;
+ firstChild = lastChild = 0;
+ value = _value;
}
#endif
TiXmlElement::TiXmlElement( const TiXmlElement& copy)
- : TiXmlNode( TiXmlNode::ELEMENT )
+ : TiXmlNode( TiXmlNode::ELEMENT )
{
- firstChild = lastChild = 0;
- copy.CopyTo( this );
+ firstChild = lastChild = 0;
+ copy.CopyTo( this );
}
void TiXmlElement::operator=( const TiXmlElement& base )
{
- ClearThis();
- base.CopyTo( this );
+ ClearThis();
+ base.CopyTo( this );
}
TiXmlElement::~TiXmlElement()
{
- ClearThis();
+ ClearThis();
}
void TiXmlElement::ClearThis()
{
- Clear();
- while( attributeSet.First() )
- {
- TiXmlAttribute* node = attributeSet.First();
- attributeSet.Remove( node );
- delete node;
- }
+ 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 );
+ TiXmlAttribute* node = attributeSet.Find( name );
- if ( node )
- return node->Value();
+ if ( node )
+ return node->Value();
- return 0;
+ 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 * 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;
+ 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;
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( !node )
+ return TIXML_NO_ATTRIBUTE;
- return node->QueryIntValue( ival );
+ return node->QueryIntValue( ival );
}
int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
{
- TiXmlAttribute* node = attributeSet.Find( name );
- if ( !node )
- return TIXML_NO_ATTRIBUTE;
+ TiXmlAttribute* node = attributeSet.Find( name );
+ if ( !node )
+ return TIXML_NO_ATTRIBUTE;
- return node->QueryDoubleValue( dval );
+ return node->QueryDoubleValue( dval );
}
void TiXmlElement::SetAttribute( const char * name, int val )
-{
- char buf[64];
- sprintf( buf, "%d", val );
- SetAttribute( name, buf );
+{
+ 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 );
+{
+ 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 );
- }
+ 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() );
- }
+ 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;
+ (*stream) << "<" << value;
- TiXmlAttribute* attrib;
- for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
- {
- (*stream) << " ";
- attrib->StreamOut( stream );
- }
+ 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) << ">";
+ // 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) << " />";
- }
+ for ( node = firstChild; node; node=node->NextSibling() )
+ {
+ node->StreamOut( stream );
+ }
+ (*stream) << "</" << value << ">";
+ }
+ else
+ {
+ (*stream) << " />";
+ }
}
void TiXmlElement::CopyTo( TiXmlElement* target ) const
{
- // superclass:
- TiXmlNode::CopyTo( target );
+ // 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() );
- }
+ // 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* 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;
+ TiXmlElement* clone = new TiXmlElement( Value() );
+ if ( !clone )
+ return 0;
- CopyTo( clone );
- return clone;
+ CopyTo( clone );
+ return clone;
}
TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
{
- tabsize = 4;
- ClearError();
+ tabsize = 4;
+ ClearError();
}
TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
{
- tabsize = 4;
- value = documentName;
- ClearError();
+ tabsize = 4;
+ value = documentName;
+ ClearError();
}
#ifdef TIXML_USE_STL
TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
{
- tabsize = 4;
- value = documentName;
- ClearError();
+ tabsize = 4;
+ value = documentName;
+ ClearError();
}
#endif
TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
{
- copy.CopyTo( this );
+ copy.CopyTo( this );
}
void TiXmlDocument::operator=( const TiXmlDocument& copy )
{
- Clear();
- copy.CopyTo( this );
+ Clear();
+ copy.CopyTo( this );
}
bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
{
- // See STL_STRING_BUG below.
- StringToBuffer buf( value );
+ // See STL_STRING_BUG below.
+ StringToBuffer buf( value );
- if ( buf.buffer && LoadFile( buf.buffer, encoding ) )
- return true;
+ if ( buf.buffer && LoadFile( buf.buffer, encoding ) )
+ return true;
- return false;
+ return false;
}
bool TiXmlDocument::SaveFile() const
{
- // See STL_STRING_BUG below.
- StringToBuffer buf( value );
+ // See STL_STRING_BUG below.
+ StringToBuffer buf( value );
- if ( buf.buffer && SaveFile( buf.buffer ) )
- return true;
+ if ( buf.buffer && SaveFile( buf.buffer ) )
+ return true;
- return false;
+ 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;
+ // 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;
+ // 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 );
+ TiXmlNode::CopyTo( target );
- target->error = error;
- target->errorDesc = errorDesc.c_str ();
+ target->error = error;
+ target->errorDesc = errorDesc.c_str ();
- TiXmlNode* node = 0;
- for ( node = firstChild; node; node = node->NextSibling() )
- {
- target->LinkEndChild( node->Clone() );
- }
+ 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;
+ TiXmlDocument* clone = new TiXmlDocument();
+ if ( !clone )
+ return 0;
- CopyTo( clone );
- return clone;
+ 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" );
- }
+ 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 );
+ 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;
- }
+ // 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;
+ // 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;
+ // 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;
+ TIXML_STRING n, v;
- PutString( name, &n );
- PutString( value, &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() );
+ 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) << "\"";
- }
+ 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;
+ 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;
+ 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);
+ char buf [64];
+ sprintf (buf, "%d", _value);
+ SetValue (buf);
}
void TiXmlAttribute::SetDoubleValue( double _value )
{
- char buf [64];
- sprintf (buf, "%lf", _value);
- SetValue (buf);
+ char buf [64];
+ sprintf (buf, "%lf", _value);
+ SetValue (buf);
}
const int TiXmlAttribute::IntValue() const
{
- return atoi (value.c_str ());
+ return atoi (value.c_str ());
}
const double TiXmlAttribute::DoubleValue() const
{
- return atof (value.c_str ());
+ return atof (value.c_str ());
}
TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
{
- copy.CopyTo( this );
+ copy.CopyTo( this );
}
void TiXmlComment::operator=( const TiXmlComment& base )
{
- Clear();
- base.CopyTo( this );
+ 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() );
+ 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) << "-->";
+ (*stream) << "<!--";
+ //PutString( value, stream );
+ (*stream) << value;
+ (*stream) << "-->";
}
void TiXmlComment::CopyTo( TiXmlComment* target ) const
{
- TiXmlNode::CopyTo( target );
+ TiXmlNode::CopyTo( target );
}
TiXmlNode* TiXmlComment::Clone() const
{
- TiXmlComment* clone = new TiXmlComment();
+ TiXmlComment* clone = new TiXmlComment();
- if ( !clone )
- return 0;
+ if ( !clone )
+ return 0;
- CopyTo( clone );
- return clone;
+ CopyTo( clone );
+ return clone;
}
void TiXmlText::Print( FILE* cfile, int /*depth*/ ) const
{
- TIXML_STRING buffer;
- PutString( value, &buffer );
- fprintf( cfile, "%s", buffer.c_str() );
+ TIXML_STRING buffer;
+ PutString( value, &buffer );
+ fprintf( cfile, "%s", buffer.c_str() );
}
void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const
{
- PutString( value, stream );
+ PutString( value, stream );
}
void TiXmlText::CopyTo( TiXmlText* target ) const
{
- TiXmlNode::CopyTo( target );
+ TiXmlNode::CopyTo( target );
}
TiXmlNode* TiXmlText::Clone() const
-{
- TiXmlText* clone = 0;
- clone = new TiXmlText( "" );
+{
+ TiXmlText* clone = 0;
+ clone = new TiXmlText( "" );
- if ( !clone )
- return 0;
+ if ( !clone )
+ return 0;
- CopyTo( clone );
- return clone;
+ CopyTo( clone );
+ return clone;
}
TiXmlDeclaration::TiXmlDeclaration( const char * _version,
- const char * _encoding,
- const char * _standalone )
- : TiXmlNode( TiXmlNode::DECLARATION )
+ const char * _encoding,
+ const char * _standalone )
+ : TiXmlNode( TiXmlNode::DECLARATION )
{
- version = _version;
- encoding = _encoding;
- standalone = _standalone;
+ 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 )
+ const std::string& _encoding,
+ const std::string& _standalone )
+ : TiXmlNode( TiXmlNode::DECLARATION )
{
- version = _version;
- encoding = _encoding;
- standalone = _standalone;
+ version = _version;
+ encoding = _encoding;
+ standalone = _standalone;
}
#endif
TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
- : TiXmlNode( TiXmlNode::DECLARATION )
+ : TiXmlNode( TiXmlNode::DECLARATION )
{
- copy.CopyTo( this );
+ copy.CopyTo( this );
}
void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
{
- Clear();
- copy.CopyTo( this );
+ Clear();
+ copy.CopyTo( this );
}
void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/ ) const
{
- fprintf (cfile, "<?xml ");
+ 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, "?>");
+ 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) << "?>";
+ (*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 );
+ TiXmlNode::CopyTo( target );
- target->version = version;
- target->encoding = encoding;
- target->standalone = standalone;
+ target->version = version;
+ target->encoding = encoding;
+ target->standalone = standalone;
}
TiXmlNode* TiXmlDeclaration::Clone() const
-{
- TiXmlDeclaration* clone = new TiXmlDeclaration();
+{
+ TiXmlDeclaration* clone = new TiXmlDeclaration();
- if ( !clone )
- return 0;
+ if ( !clone )
+ return 0;
- CopyTo( clone );
- return clone;
+ 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() );
+ 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.
+ (*stream) << "<" << value << ">"; // Don't use entities here! It is unknown.
}
void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const
{
- TiXmlNode::CopyTo( target );
+ TiXmlNode::CopyTo( target );
}
TiXmlNode* TiXmlUnknown::Clone() const
{
- TiXmlUnknown* clone = new TiXmlUnknown();
+ TiXmlUnknown* clone = new TiXmlUnknown();
- if ( !clone )
- return 0;
+ if ( !clone )
+ return 0;
- CopyTo( clone );
- return clone;
+ CopyTo( clone );
+ return clone;
}
TiXmlAttributeSet::TiXmlAttributeSet()
{
- sentinel.next = &sentinel;
- sentinel.prev = &sentinel;
+ sentinel.next = &sentinel;
+ sentinel.prev = &sentinel;
}
TiXmlAttributeSet::~TiXmlAttributeSet()
{
- assert( sentinel.next == &sentinel );
- assert( sentinel.prev == &sentinel );
+ 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.
+ assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set.
- addMe->next = &sentinel;
- addMe->prev = sentinel.prev;
+ addMe->next = &sentinel;
+ addMe->prev = sentinel.prev;
- sentinel.prev->next = addMe;
- sentinel.prev = addMe;
+ sentinel.prev->next = addMe;
+ sentinel.prev = addMe;
}
void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
{
- TiXmlAttribute* node;
+ 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.
+ 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;
+ TiXmlAttribute* node;
- for( node = sentinel.next; node != &sentinel; node = node->next )
- {
- if ( node->name == name )
- return node;
- }
- return 0;
+ for( node = sentinel.next; node != &sentinel; node = node->next )
+ {
+ if ( node->name == name )
+ return node;
+ }
+ return 0;
}
-#ifdef TIXML_USE_STL
+#ifdef TIXML_USE_STL
TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base)
{
- TIXML_STRING tag;
- tag.reserve( 8 * 1000 );
- base.StreamIn( &in, &tag );
+ TIXML_STRING tag;
+ tag.reserve( 8 * 1000 );
+ base.StreamIn( &in, &tag );
- base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
- return in;
+ 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;
+ base.StreamOut (& out);
+ return out;
}
-#ifdef TIXML_USE_STL
+#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;
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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
index 88db93e..678bdb9 100644
--- a/src/contrib/xml/tinyxml.h
+++ b/src/contrib/xml/tinyxml.h
@@ -1,50 +1,26 @@
-/*:*
- *: File: ./src/contrib/xml/tinyxml.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
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.
*/
@@ -95,40 +71,34 @@ 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
+/* 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.
+ 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
+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
+ TIXML_ENCODING_UNKNOWN,
+ TIXML_ENCODING_UTF8,
+ TIXML_ENCODING_LEGACY
};
const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
@@ -136,263 +106,241 @@ 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;
+ 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;
+ 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;
- };
+ // 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;
+ }
- static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
- inline static bool IsWhiteSpace( char c )
- {
- return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
- }
+ 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;
+ }
+ }
- virtual void StreamOut (TIXML_OSTREAM *) const = 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 );
-#ifdef TIXML_USE_STL
+ static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
- static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
- static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
-#endif
+ // 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 );
- /* 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 );
+
+ 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;
+ 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;
};
@@ -404,481 +352,383 @@ private:
*/
class TiXmlNode : public TiXmlBase
{
- friend class TiXmlDocument;
- friend class TiXmlElement;
+ 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
+
+ /** 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;
-#ifdef TIXML_USE_STL
+ /** 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; }
- TiXmlElement* FirstChildElement( const std::string& _value ) const
- {
- return FirstChildElement (_value.c_str ());
- } ///< STL std::string form.
-#endif
+ 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.
- /** 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;
+ /** 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 );
+ TiXmlNode( NodeType _type );
- // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
- // and the assignment operator.
- void CopyTo( TiXmlNode* target ) const;
+ // 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
+ #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 );
+ // 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 ;
- }
+ // Internal Value function returning a TIXML_STRING
+ const TIXML_STRING& SValue() const { return value ; }
- TiXmlNode* parent;
- NodeType type;
+ TiXmlNode* parent;
+ NodeType type;
- TiXmlNode* firstChild;
- TiXmlNode* lastChild;
+ TiXmlNode* firstChild;
+ TiXmlNode* lastChild;
- TIXML_STRING value;
+ TIXML_STRING value;
- TiXmlNode* prev;
- TiXmlNode* next;
+ TiXmlNode* prev;
+ TiXmlNode* next;
private:
- TiXmlNode( const TiXmlNode& ); // not implemented.
- void operator=( const TiXmlNode& base ); // not allowed.
+ 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;
+ friend class TiXmlAttributeSet;
public:
- /// Construct an empty attribute.
- TiXmlAttribute() : TiXmlBase()
- {
- document = 0;
- prev = next = 0;
- }
+ /// 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
+ #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.
+ /// Construct an attribute with a name and value.
+ TiXmlAttribute( const char * _name, const char * _value )
+ {
+ name = _name;
+ value = _value;
+ document = 0;
+ prev = next = 0;
+ }
-#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
+ 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;
- /// 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;
- }
+ 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;
+ 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;
};
@@ -889,7 +739,7 @@ private:
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.
@@ -897,24 +747,18 @@ private:
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;
+ 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;
+ TiXmlAttribute sentinel;
};
@@ -925,159 +769,131 @@ private:
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 );
+ /// 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
+ 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
+ // 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;
- 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 );
+ /* [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;
+ TiXmlAttributeSet attributeSet;
};
@@ -1086,35 +902,31 @@ private:
class TiXmlComment : public TiXmlNode
{
public:
- /// Constructs an empty comment.
- TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT )
- {}
- TiXmlComment( const TiXmlComment& );
- void operator=( const TiXmlComment& base );
+ /// Constructs an empty comment.
+ TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
+ TiXmlComment( const TiXmlComment& );
+ void operator=( const TiXmlComment& base );
- virtual ~TiXmlComment()
- {}
+ 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;
+ /// 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 );
+ /* 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
+ void CopyTo( TiXmlComment* target ) const;
- virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
-#endif
-
- virtual void StreamOut( TIXML_OSTREAM * out ) 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:
@@ -1125,50 +937,42 @@ private:
*/
class TiXmlText : public TiXmlNode
{
- friend class TiXmlElement;
+ friend class TiXmlElement;
public:
- /// Constructor.
- TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT)
- {
- SetValue( initValue );
- }
- virtual ~TiXmlText()
- {}
+ /// 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
+ #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 );
- }
+ 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;
+ /// 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 );
+ 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
+ /// [internal use] Creates a new Element and returns it.
+ virtual TiXmlNode* Clone() const;
+ void CopyTo( TiXmlText* target ) const;
- virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
-#endif
+ 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:
};
@@ -1178,11 +982,11 @@ private:
@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.
@@ -1190,66 +994,53 @@ private:
class TiXmlDeclaration : public TiXmlNode
{
public:
- /// Construct an empty declaration.
- TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION )
- {}
+ /// 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 );
+ /// 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 );
+ /// Construct.
+ TiXmlDeclaration( const char* _version,
+ const char* _encoding,
+ const char* _standalone );
-protected:
- void CopyTo( TiXmlDeclaration* target ) const;
- // used to be public
-#ifdef TIXML_USE_STL
+ TiXmlDeclaration( const TiXmlDeclaration& copy );
+ void operator=( const TiXmlDeclaration& copy );
- virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
-#endif
+ virtual ~TiXmlDeclaration() {}
- virtual void StreamOut ( TIXML_OSTREAM * out) const;
+ /// 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;
+ TIXML_STRING version;
+ TIXML_STRING encoding;
+ TIXML_STRING standalone;
};
@@ -1257,42 +1048,32 @@ private:
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 );
+ TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
+ virtual ~TiXmlUnknown() {}
-protected:
- void CopyTo( TiXmlUnknown* target ) const;
+ TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
+ void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
-#ifdef TIXML_USE_STL
+ /// 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 void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
-#endif
+ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
- virtual void StreamOut ( TIXML_OSTREAM * out ) const;
+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:
@@ -1306,173 +1087,141 @@ private:
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 );
+ /// 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
+ 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;
+ void CopyTo( TiXmlDocument* target ) const;
- bool error;
- int errorId;
- TIXML_STRING errorDesc;
- int tabsize;
- TiXmlCursor errorLocation;
+ bool error;
+ int errorId;
+ TIXML_STRING errorDesc;
+ int tabsize;
+ TiXmlCursor errorLocation;
};
@@ -1480,7 +1229,7 @@ private:
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>
@@ -1490,10 +1239,10 @@ private:
</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 )
@@ -1509,11 +1258,11 @@ private:
{
// 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();
@@ -1521,16 +1270,16 @@ private:
{
// 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 )
@@ -1542,14 +1291,14 @@ private:
++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
@@ -1559,94 +1308,59 @@ private:
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 );
- }
+ /// 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;
+ TiXmlNode* node;
};
diff --git a/src/contrib/xml/tinyxmlerror.cpp b/src/contrib/xml/tinyxmlerror.cpp
index 1c27bb2..b04add7 100644
--- a/src/contrib/xml/tinyxmlerror.cpp
+++ b/src/contrib/xml/tinyxmlerror.cpp
@@ -1,47 +1,23 @@
-/*:*
- *: File: ./src/contrib/xml/tinyxmlerror.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
/*
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.
*/
@@ -56,20 +32,20 @@ distribution.
//
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.",
- };
+{
+ "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
index 6879008..f06d1cd 100644
--- a/src/contrib/xml/tinyxmlparser.cpp
+++ b/src/contrib/xml/tinyxmlparser.cpp
@@ -1,47 +1,23 @@
-/*:*
- *: File: ./src/contrib/xml/tinyxmlparser.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
/*
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.
*/
@@ -53,1525 +29,1465 @@ distribution.
// 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, '\'' }
- };
+// 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:
+// 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
- };
+// 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]);
- }
+ 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 );
- // }
+ // 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 );
- // }
+ // 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;
+ 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 );
+ 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;
+ 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
- ();
- }
+ 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;
+ //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;
+ *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;
+ // 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 )
+ 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;
+ 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 )
+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 );
+ *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 );
+ // 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;
- }
+ 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 );
- }
-
- // All is well.
- return p;
+ 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();
- }
+{
+ // 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;
+ 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.
- }
- }
- }
+ // 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;
+ 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;
+ 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;
- }
- }
+ 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;
+ 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;
- }
- }
+ 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;
+ 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;
+ 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
- ();
- }
+ 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;
+ 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;
- }
- }
+ 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;
+ 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;
+ for ( unsigned i=0; i<value.length(); i++ )
+ if ( !IsWhiteSpace( value[i] ) )
+ return false;
+ return true;
}
diff --git a/src/data/con.cpp b/src/data/con.cpp
index b3aebcc..316776b 100644..100755
--- a/src/data/con.cpp
+++ b/src/data/con.cpp
@@ -11,11 +11,11 @@ con::con()
p_mysql = mysql_init(NULL);
while ( !p_mysql )
- {
- wrap::system_message( MYSQLE1 );
- usleep( 30000000 );
- mysql_init(p_mysql);
- }
+ {
+ wrap::system_message( MYSQLE1 );
+ usleep( 30000000 );
+ mysql_init(p_mysql);
+ }
while ( mysql_real_connect(
p_mysql,
@@ -25,19 +25,19 @@ con::con()
(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 );
- }
+ {
+ 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 );
- }
+ {
+ if (mysql_ping( p_mysql ) != 0)
+ mysql_close( p_mysql );
+ }
}
#endif
diff --git a/src/data/con.h b/src/data/con.h
index 9fda07b..5c454f8 100644..100755
--- a/src/data/con.h
+++ b/src/data/con.h
@@ -11,12 +11,12 @@
using namespace std;
class con : public con_base
-{
-public:
- MYSQL* p_mysql;
- con( );
- ~con( );
-};
+ {
+ public:
+ MYSQL* p_mysql;
+ con( );
+ ~con( );
+ };
#endif
#endif
diff --git a/src/data/con_base.cpp b/src/data/con_base.cpp
index 003a376..003a376 100644..100755
--- a/src/data/con_base.cpp
+++ b/src/data/con_base.cpp
diff --git a/src/data/con_base.h b/src/data/con_base.h
index 9ebb89e..16086db 100644..100755
--- a/src/data/con_base.h
+++ b/src/data/con_base.h
@@ -9,11 +9,11 @@
using namespace std;
class con_base : public timo
-{
-public:
- con_base( );
- ~con_base( );
-};
+ {
+ public:
+ con_base( );
+ ~con_base( );
+ };
#endif
#endif
diff --git a/src/data/data.cpp b/src/data/data.cpp
index fa509dd..340883e 100644
--- a/src/data/data.cpp
+++ b/src/data/data.cpp
@@ -12,7 +12,7 @@ data::data()
data::~data()
{}
-hashmap<string>
+map<string,string>
data::select_user_data( string s_user, string s_query)
{
string s_where_rule = " WHERE nick = \"" + s_user + "\"";
@@ -34,11 +34,11 @@ data::select_query( string s_query, string s_where_rule, vector<string>& vec_ele
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( 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 );
@@ -46,36 +46,37 @@ data::select_query( string s_query, string s_where_rule, vector<string>& vec_ele
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 );
- }
+ {
+ 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;
- }
+ {
+ wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
+ if (p_con != NULL)
+ delete p_con;
+ }
return p_result;
}
-hashmap<string>
+map<string,string>
data::parse_result( MYSQL_RES* p_result, vector<string>& vec_elements )
{
- hashmap<string> map_ret;
+ map<string,string> map_ret;
if ( p_result != NULL )
- {
- MYSQL_ROW row;
- vector<string>::iterator vec_iter = vec_elements.begin();
- vec_iter++;
+ {
+ 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]);
+ 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 );
- }
+ mysql_free_result( p_result );
+ }
return map_ret;
}
@@ -96,26 +97,26 @@ data::insert_query( string s_query, map<string,string> map_insert )
string s_mysql_query = "INSERT INTO " + s_table + " (";
while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( *iter );
+ {
+ s_mysql_query.append( *iter );
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- else
- s_mysql_query.append( ") VALUES(" );
- }
+ 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( ")" );
- }
+ {
+ 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 );
@@ -130,7 +131,7 @@ data::insert_query( string s_query, map<string,string> map_insert )
}
void
-data::update_user_data( string s_user, string s_query, hashmap<string> update_map )
+data::update_user_data( string s_user, string s_query, map<string,string> update_map )
{
vector<string> vec_elements = map_queries[s_query];
@@ -147,33 +148,33 @@ data::update_user_data( string s_user, string s_query, hashmap<string> update_ma
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 ( 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( ", " );
+ if ( iter != iter_second && b_flag )
+ s_mysql_query.append( ", " );
- s_mysql_query.append( *iter + "=\"" + secure_query(update_map[*iter]) + "\"" );
- b_flag = 1;
- iter++;
- }
+ 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) + "\"" );
+ {
+ s_mysql_query.append( " WHERE nick=\"" + tool::to_lower(s_user) + "\"" );
- con* p_con = get_con();
- print_query( MYSQLQU + s_mysql_query );
+ 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) ) );
+ 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 );
- }
+ push_con( p_con );
+ }
}
string
@@ -183,18 +184,18 @@ data::secure_query( string s_mysql_query )
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("\\");
- }
+ {
+ 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("\"");
- }
+ {
+ s_mysql_query.replace( i_pos, 1, "'" );
+ i_pos = s_mysql_query.find("\"");
+ }
return s_mysql_query;
}
diff --git a/src/data/data.h b/src/data/data.h
index a6ca90f..21c03d2 100644
--- a/src/data/data.h
+++ b/src/data/data.h
@@ -10,20 +10,20 @@
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( );
+ {
+ private:
+ MYSQL_RES* select_query( string s_query, string s_where_rule, vector<string>& vec_elements );
+ map<string,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 );
-};
+ map<string,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, map<string,string> update_map );
+ };
#endif
#endif
diff --git a/src/data/data_base.cpp b/src/data/data_base.cpp
index 61fc141..2cbe070 100644
--- a/src/data/data_base.cpp
+++ b/src/data/data_base.cpp
@@ -15,39 +15,40 @@ data_base::data_base( )
// 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 )
+ if ( iter->length() > 20
+ && iter->compare(0, 19, "chat.database.mysql") == 0
+ && iter->find(".descr") == string::npos )
{
- vec_tokens.push_back( s_element.substr(0, i_pos) );
- s_element = s_element.substr( i_pos+1 );
+ 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;
}
- 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()
+void data_base::initialize_connections()
{
int i_min_con = tool::string2int( wrap::CONF->get_elem("chat.database.mincon") ),
i_max_con = tool::string2int( wrap::CONF->get_elem("chat.database.maxcon") );
@@ -57,6 +58,11 @@ void data_base::init_connections()
for ( int i = 0; i < i_min_con && i < i_max_con; i++ )
push_back( new con() );
+
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
}
data_base::~data_base()
@@ -64,23 +70,23 @@ data_base::~data_base()
pthread_mutex_destroy ( &mut_con );
}
-hashmap<string>
+map<string,string>
data_base::select_user_data( string s_user, string s_query)
{
print_query( DATAQUE + s_query );
- hashmap<string> map_ret;
+ map<string,string> map_ret;
return map_ret;
}
void
-data_base::insert_user_data( string s_user, string s_query, hashmap<string> insert_map )
+data_base::insert_user_data( string s_user, string s_query, map<string,string> insert_map )
{
print_query( DATAQUE + s_query );
}
void
-data_base::update_user_data( string s_user, string s_query, hashmap<string> update_map )
+data_base::update_user_data( string s_user, string s_query, map<string,string> update_map )
{
print_query( DATAQUE + s_query );
}
@@ -107,23 +113,29 @@ 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;
- }
+ {
+ 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();
- }
+ {
+ 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 );
@@ -136,11 +148,27 @@ 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()
{
@@ -148,13 +176,17 @@ data_base::disconnect_all_connections()
pthread_mutex_lock( &mut_con );
while ( !empty() )
- {
- con* p_con = *begin();
- pop_front();
- delete p_con;
- }
+ {
+ con* p_con = *begin();
+ pop_front();
+ delete p_con;
+ }
pthread_mutex_unlock( &mut_con );
+#ifdef NCURSES
+
+ print_queue_size();
+#endif
}
void
@@ -168,22 +200,27 @@ data_base::check_data_con_timeout()
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) + ")");
+ 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 );
}
diff --git a/src/data/data_base.h b/src/data/data_base.h
index dbad3f0..97ad31e 100644
--- a/src/data/data_base.h
+++ b/src/data/data_base.h
@@ -11,33 +11,38 @@
using namespace std;
class data_base : protected list<con*>
-{
-private:
- pthread_mutex_t mut_con;
- int i_max_con;
-
-protected:
- hashmap< vector<string> > map_queries;
- void print_query( string s_query );
+ {
+ private:
+ pthread_mutex_t mut_con;
+ int i_max_con;
+
+#ifdef NCURSES
+
+ void print_queue_size();
+#endif
+
+ protected:
+ map< string, vector<string> > map_queries;
+ void print_query( string s_query );
#ifdef DATA_PRINT_QUERIES
- virtual void print_query_( string s_query );
+ virtual void print_query_( string s_query );
#endif
- con* get_con();
- void push_con( con* p_con );
+ con* get_con();
+ void push_con( con* p_con );
-public:
- data_base();
- ~data_base();
+ 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();
-};
+ void initialize_connections();
+ virtual map<string,string> select_user_data( string s_user, string s_query );
+ virtual void insert_user_data( string s_user, string s_query, map<string,string> insert_map );
+ virtual void update_user_data( string s_user, string s_query, map<string,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 58ce936..63648f7 100644..100755
--- a/src/glob.h
+++ b/src/glob.h
@@ -1,85 +1,185 @@
-/*:*
- *: File: ./src/glob.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#include "maps/hashmap.h"
+/*
+ Notice:
+
+ All #defines which start with an CONFIG can be edited through
+ gmake config in the main directory!
+*/
+
+#include <map>
// global variables.
#ifndef GLOB_H
#define GLOB_H
-#include "config.h"
-
// Definition of boolean values.
-#ifndef true
#define true 1
-#endif
-#ifndef false
#define false 0
-#endif
-//<<*
-/* FIRST THE YCHAT ONLY OPTIONS */
+/* - CONFIG -
+ What should be the name of the config file?
+*/
+#define CONFILE "ychat.conf"
-#ifdef HAVE_LIBMYSQLCLIENT
-#ifdef HAVE_MYSQL_MYSQL_H
-#define USE_MYSQL
-#define DATABASE
+/* - CONFIG -
+ In which prefix should yChat be installed if typing gmake inst-
+ all?
+*/
+#define PREFIX "/usr/local"
+
+//<<*
+/* - CONFIG -
+ Should yChat get compiled with database support? Currently MyS-
+ QL only is a supported database.
+*/
+//#define DATABASE
+
+#ifdef DATABASE
+/* - CONFIG -
+ Should all database queries printed out at the admin interface?
+ (This option wont take action if database support has not been
+ chosen)
+*/
#define DATA_PRINT_QUERIES
+
+#define USE_MYSQL
#endif
-#endif
+//*>>
+
+/* - 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
-#define PUSHSTR 500
+/* - CONFIG -
+ Please specify the maximum length of a line read from a socket
+ or a file. ( config-file, html-template )
+*/
+#define READSOCK 2048
-#ifdef HAVE_LIBSSL
-#ifdef HAVE_OPENSSL_SSL_H
-#define OPENSSL
-#endif
-#endif
+/* - 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 HTTP post request.
+*/
+#define POSTBUF 512
+
+/* - CONFIG -
+ Please specify the maximum occupancy of the internal hash-map
+ data structures given in percentage. 0.9 means 90% iccupancy.
+*/
+#define HMAPOCC .9
+
+/* - 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
+
+/* - CONFIG -
+ 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 -
+ Should yChat get compiled with ncurses support?
+*/
+#define NCURSES
+
+/* - CONFIG -
+ Should yChat get compiled with comand line interface support?
+*/
#define CLI
-#define CONFILE "ychat.conf"
+
+/* - 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
+
+// Enables debugging options
//#define DEBUG
-//#define EXPERIM
-#define LOGGING
-#define MAXPORT 65535
-#define MAXLINES 30
-#define MAXLENGTH 1024
+//<<*
+/* - 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
+//*>>
+
+
+// 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 18
+#define NCUR_POOL_SIZE_X 22
+#define NCUR_POOL_SIZE_Y 18
+#define NCUR_POOL_RUNNING_X 23
+#define NCUR_POOL_RUNNING_Y 18
+
+#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
-#ifdef HAVE_LIBREADLINE
-#ifdef HAVE_READLINE_READLINE_H
-#define READLINE
-#endif
#endif
-#define POSTBUF 1024
-#define READBUF 2048
-#define READSOCK 2048
-//#define SERVMSG
-//#define CTCSEGV
-//#define VERBOSE
+//////////////////////////////////////////////////////////////////////////////////////////
+// DO NOT CHANGE ANYTHING BEHIND THIS LINE!
+//////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
@@ -87,20 +187,20 @@ typedef int function( void *v_arg );
struct container
{
- void* elem[4];
+ void* elem[4];
};
struct dynmod
{
- function *the_func ;
- void *the_module;
+ function *the_func ;
+ void *the_module;
};
typedef enum method_ {
+ METH_NCURSES,
METH_RETSTRING
} method;
// Define external executables:
-#define GMAKE "/usr/local/bin/gmake "
-
+#define GMAKE "/usr/local/bin/gmake \0"
#endif
diff --git a/src/html.cpp b/src/html.cpp
index f4278ca..3b5f6b0 100644..100755
--- a/src/html.cpp
+++ b/src/html.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/html.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef HTML_CPP
#define HTML_CPP
@@ -30,121 +6,144 @@
using namespace std;
-html::html( )
+html::html( ) : smap<string,string>::smap(HMAPOCC)
{
- set_name( wrap::CONF->get_elem( "httpd.templatedir" ) );
+ set_name( wrap::CONF->get_elem( "httpd.templatedir" ) );
}
html::~html( )
-{}
+{
+}
void
html::clear_cache( )
{
- clear();
- wrap::system_message( CLRHTML );
+ make_empty();
+ wrap::system_message( CLRHTML );
+
+#ifdef NCURSES
+ print_cached( 0 );
+#endif
}
string
html::parse( map<string,string> &map_params )
{
- string s_file = map_params["request"];
-
- // check if s_file is in the container.
- string s_templ;
+ string s_file = map_params["request"];
- // 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 );
+ // check if s_file is in the container.
+ string s_templ;
- if ( ! if_templ )
+ // if not, read file.
+ if ( ! smap<string,string>::is_avail( s_file ) )
{
- wrap::system_message( OFFFOUND + s_path );
- if(map_params["request"] == wrap::CONF->get_elem( "httpd.html.notfound" ))
- return "";
+ string s_path = get_name();
+ ifstream if_templ( s_path.append( s_file ).c_str(), ios::binary );
- map_params["request"] = wrap::CONF->get_elem( "httpd.html.notfound" );
- return parse( map_params );
- }
+ if ( ! if_templ )
+ {
+ wrap::system_message( OFFFOUND + s_path );
+ if(map_params["request"]== wrap::CONF->get_elem( "httpd.html.notfound" ))
+ return "";
- char c_buf;
- while( !if_templ.eof() )
- {
- if_templ.get( c_buf );
- s_templ += c_buf;
- }
+ map_params["request"] = wrap::CONF->get_elem( "httpd.html.notfound" );
+ return parse( map_params );
- if ( map_params["content-type"].compare(0,5,"text/") == 0 )
- s_templ.erase(s_templ.end()-1);
+ }
- if_templ.close();
+ char c_buf;
+ while( !if_templ.eof() )
+ {
+ if_templ.get( c_buf );
+ s_templ += c_buf;
+ }
- wrap::system_message( TECACHE + s_path );
+ if ( map_params["content-type"].compare(0,5,"text/") == 0 )
+ s_templ.erase(s_templ.end()-1);
- // cache file.
- shashmap<string>::add_elem(s_templ, s_file);
- }
- else
- {
- s_templ = shashmap<string>::get_elem( s_file );
- }
+ if_templ.close();
- // find %%KEY%% token and substituate those.
- unsigned pos[2];
- pos[0] = pos[1] = 0;
+ wrap::system_message( TECACHE + s_path );
- for(;;)
- {
- pos[0] = s_templ.find( "%%", pos[1] );
+ // cache file.
+ smap<string,string>::add_elem( s_templ, s_file );
+#ifdef NCURSES
+ print_cached( smap<string,string>::get_size() );
+#endif
+ }
- if ( pos[0] == string::npos )
- break;
+ else
+ {
+ s_templ = smap<string,string>::get_elem( s_file );
+ }
+
+ // find %%KEY%% token and substituate those.
+ unsigned pos[2];
+ pos[0] = pos[1] = 0;
+
+ for(;;)
+ {
+ pos[0] = s_templ.find( "%%", pos[1] );
- pos[0] += 2;
- pos[1] = s_templ.find( "%%", pos[0] );
+ if ( pos[0] == string::npos )
+ break;
- if ( pos[0] == string::npos )
- break;
+ pos[0] += 2;
+ pos[1] = s_templ.find( "%%", pos[0] );
- // 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 ( pos[0] == string::npos )
+ break;
- // if s_val is empty use map_params.
- if ( s_val.empty() )
- s_val = map_params[ 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 );
- // substituate key with val.
- s_templ.replace( pos[0]-2, pos[1]-pos[0]+4, s_val );
+ // 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 );
- // calculate the string displacement.
- int i_diff = 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_diff;
+ pos[1] += 2 + i_diff;
- };
+ };
- return s_templ;
+ return s_templ;
}
//<<*
void
html::online_list( user *p_user, map<string,string> &map_params )
{
- // prepare user_list.
- string s_list;
+ // prepare user_list.
+ string s_list;
- room* p_room = p_user->get_room();
+ room* p_room = p_user->get_room();
- p_room->get_user_list( s_list );
+ p_room->get_user_list( s_list );
- map_params["room"] = p_room->get_name();
- map_params["topic"] = p_room->get_topic();
- map_params["userlist"] = s_list;
+ map_params["ROOMNAME"] = p_room->get_name();
+ map_params["ROOMTOPIC"] = p_room->get_topic();
+ map_params["USERLIST"] = s_list;
}
//*>>
+#ifdef NCURSES
+void
+html::print_cached( int i_docs )
+{
+ if ( !wrap::NCUR->is_ready() )
+ return;
+
+ mvprintw( NCUR_CACHED_DOCS_X, NCUR_CACHED_DOCS_Y, "Docs: %d ", i_docs);
+ refresh();
+}
+
+#endif
+
#endif
diff --git a/src/html.h b/src/html.h
index e14bc55..1bb486a 100644..100755
--- a/src/html.h
+++ b/src/html.h
@@ -1,59 +1,38 @@
-/*:*
- *: File: ./src/html.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
// class html declaration. this class manages the html-template files.
#include "incl.h"
#ifndef HTML_H
#define HTML_H
-#include "maps/shashmap.h"
+#include "maps/smap.h"
#include "chat/user.h"
#include "name.h"
using namespace std;
-class html : public shashmap<string>, name
+class html : public smap<string, string>, name
{
public:
- 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( );
-
- // 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 ); //<<
+ 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( );
+
+ // 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
};
#endif
diff --git a/src/incl.h b/src/incl.h
index aa54d80..e7e9413 100644..100755
--- a/src/incl.h
+++ b/src/incl.h
@@ -1,33 +1,12 @@
-/*:*
- *: File: ./src/incl.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <pthread.h>
#include <iostream>
#include <string>
-#include <map>
#include "glob.h"
+#ifdef NCURSES
+#include <ncurses.h>
+#endif
+
#include "msgs.h"
#include "wrap.h"
diff --git a/src/logd.cpp b/src/logd.cpp
index e67c881..fd78ea2 100644..100755
--- a/src/logd.cpp
+++ b/src/logd.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/logd.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef LOGD_CPP
#define LOGD_CPP
@@ -34,166 +10,163 @@
logd::logd( string s_filename, string s_log_lines )
{
- initialize( s_filename, tool::string2int(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 );
+ initialize( s_filename, i_log_lines );
}
logd::~logd()
{
- flush_logs();
- pthread_mutex_destroy( &mut_s_logging );
+ flush();
+ pthread_mutex_destroy( &mut_s_logging );
}
void
logd::initialize( string s_filename, int i_log_lines )
{
- pthread_mutex_init( &mut_s_logging, NULL );
+ pthread_mutex_init( &mut_s_logging, NULL );
- if( s_filename.empty() )
- {
- wrap::system_message( LOGERR2 );
- exit(1);
- }
+ 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;
+ 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);
+ 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);
+ 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);
+ return string(c_buf);
}
-void
+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();
+ 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 )
+logd::log_access( map<string,string> request )
{
- //static int i_access_lines = wrap::CONF->get_elem("httpd.logging.access_lines");
-
- 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";
+ string s_time = get_time_string();
+ string s_logstr = request["REMOTE_ADDR"] + " - - "+s_time+" \"" + request["QUERY_STRING"]+"\" 200 0 \""+request["request"]+"\" \""+request["User-Agent"]+"\"\n";
- pthread_mutex_lock ( &mut_s_logging );
- s_queue.push(s_logstr);
+ pthread_mutex_lock ( &mut_s_logging );
+ s_queue.push(s_logstr);
- if ( s_queue.size() > i_lines )
- flush();
+ if ( s_queue.size() > i_lines )
+ flush();
- pthread_mutex_unlock( &mut_s_logging );
+ pthread_mutex_unlock( &mut_s_logging );
}
void
logd::log_simple_line( string s_line )
{
- // Dont log empty lines!
- if (s_line.empty())
- return;
+ // Dont log empty lines!
+ if (s_line.empty())
+ return;
- string s_time = get_time_string();
- string s_logstr = s_time + " " + s_line;
+ string s_time = get_time_string();
+ string s_logstr = s_time + " " + s_line;
- pthread_mutex_lock ( &mut_s_logging );
- s_queue.push(s_logstr);
+ pthread_mutex_lock ( &mut_s_logging );
+ s_queue.push(s_logstr);
- if ( s_queue.size() > i_lines )
- flush();
+ if ( s_queue.size() > i_lines )
+ flush();
- pthread_mutex_unlock( &mut_s_logging );
+ 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" );
+ // 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( "\\" );
- }
-
- pthread_mutex_lock ( &mut_s_logging );
- this->s_logfile = s_path + s_filename;
- pthread_mutex_unlock( &mut_s_logging );
+ 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 );
+ pthread_mutex_lock ( &mut_s_logging );
+ flush();
+ pthread_mutex_unlock( &mut_s_logging );
}
string
logd::remove_html_tags( string s_logs )
{
- unsigned pos[2];
+ 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
+ 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 "";
+ if ( s_logs == "\n" )
+ return "";
- return s_logs;
+ return s_logs;
}
void
logd::set_lines( const int i_lines )
{
- this->i_lines = i_lines;
+ this->i_lines = i_lines;
}
#endif
+
#endif
diff --git a/src/logd.h b/src/logd.h
index 2c3c0b8..f799d21 100644..100755
--- a/src/logd.h
+++ b/src/logd.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/logd.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "incl.h"
#ifdef LOGGING
@@ -34,26 +10,26 @@
class logd
{
private:
- string s_logfile;
- queue<string> s_queue;
- pthread_mutex_t mut_s_logging;
- int i_lines;
+ 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();
+ 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 );
+ 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> request );
+ void log_simple_line( string s_line );
+ void flush_logs();
+ static string remove_html_tags( string s_log );
};
#endif
diff --git a/src/main.cpp b/src/main.cpp
index df882a5..26f11c9 100644..100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,118 +1,193 @@
-/*:*
- *: File: ./src/main.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2004, 2006 Paul C. Buetow
- *:
- *: 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.
- *:*/
-
+/*
+ * yChat++; Contact: www.yChat.org; Mail@yChat.org
+ * Copyright (C) 2003 Paul C. Buetow, Volker Richter
+ * Copyright (C) 2004, 2005 Paul C. Buetow
+ * -----------------------------------------------------------------
+ *
+ * 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 MAIN_CPP
+#define MAIN_CPP
+
+#include <unistd.h>
+#include <signal.h>
#include "incl.h"
-#include "sign.h"
-
-#include "maps/hashmap.h"
+#ifndef NCURSES
#ifdef CLI
#include "cli/cli.h"
#endif
+#endif
using namespace std;
map<string,string>*
parse_argc( int argc, char* argv[] )
{
- map<string,string>* start_params = new map<string,string>;
+ map<string,string>* start_params = new map<string,string>;
- string s_output = "";
+ 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;
+ // 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;
+ // Will store the key of an additional option value (see also b_conf)
+ string s_key;
- for (int i=1; argv[i] != 0; i++)
+ for (int i=1; argv[i] != 0; i++)
+ {
+ if ( !s_key.empty() )
{
- 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;
- }
+ (*start_params)[s_key] = string(argv[i]);
+ s_key.clear();
}
- if ( !s_output.empty() )
+ else if ( b_conf )
{
- cout << s_output;
- delete start_params;
- exit(1);
+ s_key = string(argv[i]);
+ b_conf = 0;
}
- return start_params;
+ 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;
}
int
main(int argc, char* argv[])
{
- cout << tool::ychat_version() << endl
- << DESCRIP << endl
- << DESCRI2 << endl
- << DESCRI3 << endl
- << CONTACT << endl
- << SEPERAT << endl;
+ map<string,string>* p_start_params = parse_argc( argc, argv );
- wrap::init_wrapper(parse_argc(argc, argv));
+ cout << tool::ychat_version() << endl
+ << DESCRIP << endl
+ << DESCRI2 << endl
+ << CONTACT << endl
+ << SEPERAT << endl;
- //<<*
- // Initialize database connection queue
-#ifdef DATABASE
+ // 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.
+ // begin to draw the ncurses amdin interface in a new pthread.
+
+ // init the dynamic wrapper (is needed to pass all wrapped objects through a single pointer).
+ wrap::WRAP = new dynamic_wrap;
+
+ // init the config manager.
+ wrap::WRAP->CONF = wrap::CONF = new conf( CONFILE, p_start_params );
+ delete p_start_params,
- wrap::DATA->init_connections();
+
+ // init the statistic manager.
+ wrap::WRAP->STAT = wrap::STAT = new stats;
+
+ // init the html-template manager.
+ wrap::WRAP->HTML = wrap::HTML = new html;
+
+#ifdef LOGGING
+ // init the system message logd
+ wrap::WRAP->LOGD = wrap::LOGD = new logd( wrap::CONF->get_elem("httpd.logging.systemfile"),
+ wrap::CONF->get_elem("httpd.logging.systemlines") );
#endif
- //*>>
+ //<<*
+ // init the session manager.
+ wrap::WRAP->SMAN = wrap::SMAN = new sman;
+ //*>>
+
+
+ // init the socket manager.
+ wrap::WRAP->SOCK = wrap::SOCK = new sock;
- sign::init_signal_handlers();
+#ifdef NCURSES
+ wrap::WRAP->NCUR = wrap::NCUR = new ncur; // init the ncurses admin interface.
+ wrap::NCUR->run(); // run the thread
+ // wait until ncurses interface has been initialized.
+ while ( ! wrap::NCUR->is_ready() )
+ usleep(1000);
+
+ wrap::HTML->print_cached(0);
+#endif
+
+ //<<*
+ // init the chat manager.
+ wrap::WRAP->CHAT = wrap::CHAT = new chat;
+ //*>>
+
+ // init the system timer.
+ wrap::WRAP->TIMR = wrap::TIMR = new timr;
+ wrap::TIMR->run(); // run the thread
+
+ //<<*
+ // init the module-loader manager.
+ wrap::WRAP->MODL = wrap::MODL = new modl;
+
+ // init the garbage collector
+ wrap::WRAP->GCOL = wrap::GCOL = new gcol;
+
+ // init the data manager.
+#ifdef DATABASE
+ wrap::WRAP->DATA = wrap::DATA = new data;
+#endif
+ //*>>
+
+#ifndef NCURSES
#ifdef CLI
- cli _cli;
- _cli.run();
+ cli* p_cli = new cli;
+ p_cli->run();
+#endif
+#endif
+
+ //<<*
+ // Initialize database connection queue
+#ifdef DATABASE
+ wrap::DATA->initialize_connections();
#endif
+ //*>>
- // 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();
+ // 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();
- cout << DOWNMSG << endl;
- return 0;
+ cout << DOWNMSG << endl;
+ return 0;
}
+
+#endif
diff --git a/src/maps/hmap.h b/src/maps/hmap.h
new file mode 100644
index 0000000..38ea2e4
--- /dev/null
+++ b/src/maps/hmap.h
@@ -0,0 +1,96 @@
+#pragma warning(disable:4786)
+
+#include "../incl.h"
+
+#ifndef HMAP_H
+#define HMAP_H
+
+#include <vector>
+
+using namespace std;
+
+template <class obj_type, class key_type>
+class hmap
+{
+protected:
+ enum entry_type
+ {
+ ACTIVE, EMPTY, DELETED
+ };
+
+ struct hash_entry
+ {
+ obj_type element;
+ key_type key;
+ entry_type info;
+ int hits;
+
+ hash_entry( const obj_type &e = obj_type( ), const key_type &k = key_type( ), entry_type i = EMPTY ) : element( e ), key( k ), info( i )
+ { }
+ }
+ ;
+
+ int occupied;
+
+ virtual bool is_active( int i_current_pos ) const;
+ virtual void rehash( );
+ virtual bool is_prime ( int n ) const;
+ virtual int next_prime( int n ) const;
+ double i_max_occupied_percentage;
+
+ int lookups;
+ virtual unsigned int hash( const string &key ) const;
+ vector<hash_entry> array;
+
+ int get_lookups()
+ {
+ return lookups;
+ };
+
+ int get_capacity()
+ {
+ return array.size();
+ };
+
+ double get_lambda()
+ {
+ return static_cast<double>(get_size())/static_cast<double>(get_capacity());
+ }
+
+ obj_type& operator[]( key_type &k )
+ {
+ return get_elem( k );
+ }
+
+ int find_pos ( const key_type &k );
+
+public:
+ hmap( double moc );
+ ~hmap( );
+
+ virtual int get_size();
+ virtual void make_empty( );
+ virtual void make_empty( void (*func)(key_type) );
+ virtual void del_elem ( const key_type &k );
+ virtual void rename_key ( const key_type &k1, const key_type &k2 );
+ virtual obj_type set_elem ( const obj_type &x, const key_type &k );
+
+ virtual void run_func( void (*func)(obj_type) );
+ virtual void run_func( void (*func)(obj_type, void*), void* v_arg );
+ virtual void run_func_on( void (*func)(obj_type), const key_type & k );
+ virtual vector<key_type>* get_key_vector( );
+
+ virtual void add_elem ( const obj_type &x, const key_type &k );
+
+ virtual bool is_avail( const key_type &k );
+ virtual obj_type pop_elem ( const key_type &k );
+ virtual obj_type get_elem ( const key_type &k );
+ virtual obj_type operator[]( const key_type &k ) {
+ return get_elem( k );
+ }
+
+};
+
+#include "hmap.tmpl"
+
+#endif
diff --git a/src/maps/hmap.tmpl b/src/maps/hmap.tmpl
new file mode 100644
index 0000000..cc2ec24
--- /dev/null
+++ b/src/maps/hmap.tmpl
@@ -0,0 +1,289 @@
+#ifndef HMAP_CPP
+#define HMAP_CPP
+
+#include "hmap.h"
+
+using namespace std;
+
+bool is_prime( int n );
+int next_prime( int n );
+
+// Construct the hash table.
+template <class obj_type, class key_type>
+hmap<obj_type, key_type>::hmap( double mop )
+ : i_max_occupied_percentage(mop), array( next_prime( 101 ) )
+{
+ lookups = 0;
+ make_empty( );
+}
+
+template <class obj_type, class key_type>
+hmap<obj_type, key_type>::~hmap( )
+{
+ make_empty( );
+}
+
+// Insert item x into the hash table. If the item is
+// already present, do nothing
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::add_elem( const obj_type &x, const key_type &k )
+{
+ // Insert x as active
+ int i_current_pos = find_pos( k );
+ if( is_active( i_current_pos ) )
+ return;
+
+ array[ i_current_pos ] = hash_entry( x, k, ACTIVE );
+ if( ++occupied > array.size( ) * i_max_occupied_percentage )
+ rehash( );
+}
+
+// Expand the hash table.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::rehash( )
+{
+ vector<hash_entry> old_array = array;
+
+ // Create new double-sized, empty table
+ array.resize( next_prime( 2 * old_array.size( ) ) );
+ for( int j = 0; j < array.size( ); j++ )
+ {
+ array[ j ].info = EMPTY;
+ }
+
+ // Copy table over
+ make_empty( );
+ for( int i = 0; i < old_array.size( ); i++ )
+ if( old_array[ i ].info == ACTIVE )
+ add_elem( old_array[ i ].element, old_array[ i ].key );
+}
+
+// Hash function, can only handle strings.
+// If you want to hash other objects you will have to
+// create a hash table for them
+template <class obj_type, class key_type>
+unsigned int hmap<obj_type, key_type>::hash( const string & key ) const
+{
+ unsigned int hash_value = 0;
+ // cout << key << "%";
+
+ for( size_t i = 0; i < key.size(); i++ )
+ hash_value = ( hash_value << 5 ) ^ key[ i ] ^ hash_value;
+
+ return hash_value;
+}
+
+// Method that performs quadratic probing resolution.
+// Return the position where the search for x terminates.
+template <class obj_type, class key_type>
+int hmap<obj_type, key_type>::find_pos( const key_type &k )
+{
+ int i_collision_num = 0;
+ int i_current_pos = hash( k ) % array.size( );
+ lookups++;
+
+ while( array[ i_current_pos ].info != EMPTY &&
+ array[ i_current_pos ].key != k )
+ {
+ lookups++;
+ i_current_pos += 2 * ++i_collision_num - 1; // Compute ith probe
+
+ if( i_current_pos >= array.size( ) )
+ i_current_pos -= array.size( );
+ }
+
+ return i_current_pos;
+}
+
+// Remove item x from the hash table.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::del_elem( const key_type & k )
+{
+ int i_current_pos = find_pos( k );
+ if( is_active( i_current_pos ) )
+ array[ i_current_pos ].info = DELETED;
+}
+
+// Remove item x from the hash table.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::rename_key( const key_type & k1, const key_type & k2 )
+{
+ int i_current_pos = find_pos( k1 );
+ if( is_active( i_current_pos ) ) {
+ array[ i_current_pos ].info = DELETED;
+ add_elem( array[ i_current_pos ].element, k2 );
+ }
+}
+
+// Finds item x and resets its value.
+template <class obj_type, class key_type>
+obj_type hmap<obj_type, key_type>::set_elem( const obj_type & x, const key_type & k )
+{
+ int i_current_pos = find_pos( k );
+ obj_type ret_elem;
+
+ if( is_active( i_current_pos ) )
+ {
+ ret_elem = array[ i_current_pos ].element;
+ array[ i_current_pos ].element = x;
+ }
+
+ else
+ {
+ add_elem( x, k );
+ }
+
+ return ret_elem;
+}
+
+// Find item x in the hash table.
+// Return a pointer to the matching item or 0 if not found
+template <class obj_type, class key_type>
+obj_type hmap<obj_type, key_type>::get_elem( const key_type &k )
+{
+ int i_current_pos = find_pos( k );
+ if( is_active( i_current_pos ) )
+ {
+ array[i_current_pos ].hits++;
+ return array[i_current_pos].element;
+ }
+
+ return NULL;
+}
+
+template <class obj_type, class key_type>
+obj_type hmap<obj_type, key_type>::pop_elem( const key_type &k )
+{
+ int i_current_pos = find_pos( k );
+ if( is_active( i_current_pos ) )
+ {
+ array[ i_current_pos ].info = DELETED;
+ return array[i_current_pos].element;
+ }
+
+ return NULL;
+}
+
+template <class obj_type, class key_type>
+bool hmap<obj_type, key_type>::is_avail( const key_type &k )
+{
+ int i_current_pos = find_pos( k );
+ if( is_active( i_current_pos ) )
+ return 1;
+ else
+ return 0;
+}
+
+// Make the hash table logically empty.
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::make_empty( )
+{
+ occupied = 0;
+ for( int i = 0; i < array.size( ); i++ )
+ array[i].info = EMPTY;
+}
+
+template <class obj_type, class key_type>
+void hmap<obj_type, key_type>::make_empty( void (*func)(key_type) )
+{
+ occupied = 0;
+ for( int i = 0; i < array.size( ); i++ )
+ if ( array[ i ].info != EMPTY )
+ {
+ array[ i ].info = EMPTY;
+ ( *func ) ( array[ i ].key );
+ }
+}
+
+// Return true if i_current_pos exists and is active.
+template <class obj_type, class key_type>
+bool hmap<obj_type, key_type>::is_active( int i_current_pos ) const
+{
+ return array[ i_current_pos ].info == ACTIVE;
+}
+
+
+// Internal method to test if a positive number is prime.
+// Not an efficient algorithm.
+template <class obj_type, class key_type>
+bool hmap<obj_type, key_type>::is_prime( int n ) const
+{
+ if( n == 2 || n == 3 )
+ return true;
+
+ else if( n == 1 || n % 2 == 0 )
+ return false;
+
+ for( int i = 3; i * i <= n; i += 2 )
+ if( n % i == 0 )
+ return false;
+
+ return true;
+}
+
+// Internal method to return a prime number at least as large as n.
+// Assumes n > 0.
+template <class obj_type, class key_type>
+int hmap<obj_type, key_type>::next_prime( int n ) const
+{
+ if( n % 2 == 0 )
+ n++;
+
+ for( ; !is_prime( n ); n += 2 ) ;
+
+ return n;
+}
+
+template<class obj_type, class key_type>
+void
+hmap<obj_type, key_type>::run_func( void (*func)(obj_type) )
+{
+ for( int i = 0; i < array.size( ); i++ )
+ if ( array[i].info == ACTIVE )
+ ( *func ) ( array[i].element );
+}
+
+template<class obj_type, class key_type>
+void
+hmap<obj_type, key_type>::run_func( void (*func)(obj_type, void*), void* v_arg )
+{
+ for( int i = 0; i < array.size( ); i++ )
+ if ( array[i].info == ACTIVE )
+ ( *func ) ( array[i].element, v_arg );
+}
+
+template<class obj_type, class key_type>
+void
+hmap<obj_type, key_type>::run_func_on( void (*func)(obj_type), const key_type & k )
+{
+ int i_current_pos = find_pos( k );
+ if( is_active( i_current_pos ) )
+ ( *func ) ( array[i_current_pos].element );
+}
+
+
+template<class obj_type, class key_type>
+vector<key_type>*
+hmap<obj_type, key_type>::get_key_vector()
+{
+ vector<key_type>* p_vec = new vector<key_type>;
+ for( int i = 0; i < array.size( ); i++ )
+ if ( array[i].info == ACTIVE )
+ p_vec->push_back( array[i].key );
+
+ return p_vec;
+}
+
+
+template<class obj_type, class key_type> int
+hmap<obj_type, key_type>::get_size()
+{
+ int size = 0;
+ for( int j = 0; j < array.size( ); j++ )
+ if (array[ j ].info == ACTIVE)
+ size++;
+
+ return size;
+}
+
+#endif
diff --git a/src/maps/mtools.h b/src/maps/mtools.h
index 5a2b6bb..6062191 100644
--- a/src/maps/mtools.h
+++ b/src/maps/mtools.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/maps/mtools.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef MTOOLS_H
#define MTOOLS_H
@@ -32,4 +8,4 @@ struct mtools
};
#include "mtools.tmpl"
-#endif
+#endif
diff --git a/src/maps/mtools.tmpl b/src/maps/mtools.tmpl
index dff950f..dd3f89e 100644
--- a/src/maps/mtools.tmpl
+++ b/src/maps/mtools.tmpl
@@ -1,36 +1,11 @@
-/*:*
- *: File: ./src/maps/mtools.tmpl
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef MTOOLS_TMPL
#define MTOOLS_TMPL
template <class type_>
void
-mtools<type_>::delete_obj( type_ type_obj )
-{
+mtools<type_>::delete_obj( type_ type_obj ) {
if ( type_obj )
- delete type_obj;
+ delete type_obj;
}
#endif
diff --git a/src/maps/nmap.h b/src/maps/nmap.h
new file mode 100644
index 0000000..e29da3b
--- /dev/null
+++ b/src/maps/nmap.h
@@ -0,0 +1,22 @@
+#include "../incl.h"
+
+#ifndef NMAP_H
+#define NMAP_H
+
+#include "smap.h"
+
+template <class obj_type, class key_type>
+class nmap : public smap<obj_type, key_type>
+{
+ public:
+ nmap( double moc );
+ ~nmap();
+
+ // Override the get_elem method so that a new object
+ // will be returned if the required element is not in
+ // the map!
+ obj_type get_elem ( const key_type &k );
+};
+
+#include "nmap.tmpl"
+#endif
diff --git a/src/maps/nmap.tmpl b/src/maps/nmap.tmpl
new file mode 100644
index 0000000..6fdea2f
--- /dev/null
+++ b/src/maps/nmap.tmpl
@@ -0,0 +1,31 @@
+#ifndef NMAP_CPP
+#define NMAP_CPP
+
+#include "nmap.h"
+
+template <class obj_type, class key_type>
+nmap<obj_type, key_type>::nmap( double moc ) : smap<obj_type, key_type>::smap(moc)
+{
+}
+
+template <class obj_type, class key_type>
+nmap<obj_type, key_type>::~nmap()
+{
+}
+
+template <class obj_type, class key_type>
+obj_type nmap<obj_type, key_type>::get_elem ( const key_type &k ) {
+ // Create new object;
+ obj_type ret_val;
+
+ smap<obj_type, key_type>::lock_mutex();
+ int i_current_pos = find_pos( k );
+ if( smap<obj_type, key_type>::is_active( i_current_pos ) )
+ ret_val = smap<obj_type, key_type>::array[ i_current_pos ].element;
+ // else
+ // ret_val = new obj_type();
+ smap<obj_type, key_type>::unlock_mutex();
+ return ret_val;
+}
+
+#endif
diff --git a/src/maps/smap.h b/src/maps/smap.h
new file mode 100644
index 0000000..a3ee89d
--- /dev/null
+++ b/src/maps/smap.h
@@ -0,0 +1,55 @@
+// smap := Syncronized hmap
+// nmap := Syncronized hmap which's get_elem returns a new obj_type
+// instance instead of NULL if for a specific key no value has
+// been found
+
+#include "../incl.h"
+
+#ifndef SMAP_H
+#define SMAP_H
+
+#include "hmap.h"
+
+template <class obj_type, class key_type>
+class smap : public hmap<obj_type, key_type>
+{
+ private:
+ pthread_mutex_t mut_smap;
+
+ protected:
+ void lock_mutex();
+ void unlock_mutex();
+
+ public:
+ smap( double moc );
+ ~smap();
+ int get_size();
+ void make_empty();
+ void make_empty( void (*func)(key_type) );
+ void add_elem ( const obj_type &x, const key_type &k );
+ obj_type set_elem ( const obj_type &x, const key_type &k );
+ void del_elem ( const key_type &k );
+ void rename_key ( const key_type &k1, const key_type &k2 );
+ bool is_avail ( const key_type &k );
+ obj_type get_elem ( const key_type &k );
+ obj_type pop_elem ( const key_type &k );
+ void run_func( void (*func)(obj_type) );
+ void run_func( void (*func)(obj_type, void*), void* v_arg );
+ void run_func_on( void (*func)(obj_type), const key_type &k );
+ vector<key_type>* get_key_vector();
+
+ int get_size_insecure();
+ void make_empty_insecure();
+ void make_empty_insecure( void (*func)(key_type) );
+ void add_elem_insecure ( const obj_type &x, const key_type &k );
+ void del_elem_insecure ( const key_type &k );
+ bool is_avail_insecure ( const key_type &k );
+ obj_type get_elem_insecure ( const key_type &k );
+ obj_type pop_elem_insecure ( const key_type &k );
+ void run_func_insecure( void (*func)(obj_type) );
+ void run_func_insecure( void (*func)(obj_type, void*), void* v_arg );
+ vector<key_type>* get_key_vector_insecure();
+};
+
+#include "smap.tmpl"
+#endif
diff --git a/src/maps/smap.tmpl b/src/maps/smap.tmpl
new file mode 100644
index 0000000..670b84d
--- /dev/null
+++ b/src/maps/smap.tmpl
@@ -0,0 +1,215 @@
+#ifndef SMAP_CPP
+#define SMAP_CPP
+
+#include "smap.h"
+
+template <class obj_type, class key_type>
+smap<obj_type, key_type>::smap( double moc ) : hmap<obj_type, key_type>::hmap(moc)
+{
+ pthread_mutex_init( &mut_smap , NULL);
+}
+
+template <class obj_type, class key_type>
+smap<obj_type, key_type>::~smap()
+{
+ pthread_mutex_destroy( &mut_smap );
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::lock_mutex() {
+ pthread_mutex_lock( &mut_smap );
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::unlock_mutex() {
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template <class obj_type, class key_type> int
+smap<obj_type, key_type>::get_size()
+{
+ int i_size;
+ pthread_mutex_lock ( &mut_smap );
+ i_size = hmap<obj_type,key_type>::get_size();
+ pthread_mutex_unlock( &mut_smap );
+ return i_size;
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::make_empty()
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::make_empty();
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template <class obj_type, class key_type>
+void smap<obj_type, key_type>::make_empty( void (*func)(key_type) )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::make_empty( func );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+
+template <class obj_type, class key_type>
+void smap<obj_type, key_type>::add_elem( const obj_type &x, const key_type &k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::add_elem( x, k );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template <class obj_type, class key_type>
+obj_type smap<obj_type, key_type>::set_elem( const obj_type &x, const key_type &k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::set_elem( x, k );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::del_elem( const key_type & k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::del_elem( k );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::rename_key( const key_type & k1, const key_type & k2 )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::rename_key( k1, k2 );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+
+template <class obj_type, class key_type>
+obj_type smap<obj_type, key_type>::get_elem( const key_type &k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ obj_type ret_val = hmap<obj_type,key_type>::get_elem( k );
+ pthread_mutex_unlock( &mut_smap );
+ return ret_val;
+}
+template <class obj_type, class key_type>
+obj_type smap<obj_type, key_type>::pop_elem( const key_type &k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ obj_type ret_val = hmap<obj_type,key_type>::pop_elem( k );
+ pthread_mutex_unlock( &mut_smap );
+ return ret_val;
+}
+
+template <class obj_type, class key_type>
+bool smap<obj_type, key_type>::is_avail( const key_type &k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ bool ret_val = hmap<obj_type,key_type>::is_avail( k );
+ pthread_mutex_unlock( &mut_smap );
+ return ret_val;
+}
+
+template<class obj_type, class key_type> void
+smap<obj_type, key_type>::run_func( void (*func)(obj_type) )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::run_func( func );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template<class obj_type, class key_type> void
+smap<obj_type, key_type>::run_func( void (*func)(obj_type, void*), void* v_arg )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::run_func( func, v_arg );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template<class obj_type, class key_type> void
+smap<obj_type, key_type>::run_func_on( void (*func)(obj_type), const key_type & k )
+{
+ pthread_mutex_lock ( &mut_smap );
+ hmap<obj_type,key_type>::run_func_on( func, k );
+ pthread_mutex_unlock( &mut_smap );
+}
+
+template<class obj_type, class key_type> vector<key_type>*
+smap<obj_type, key_type>::get_key_vector()
+{
+ pthread_mutex_lock ( &mut_smap );
+ vector<key_type>* p_ret_vector = hmap<obj_type,key_type>::get_key_vector();
+ pthread_mutex_unlock( &mut_smap );
+ return p_ret_vector;
+}
+
+// INSECURE METHODS
+
+template <class obj_type, class key_type> int
+smap<obj_type, key_type>::get_size_insecure()
+{
+ return hmap<obj_type,key_type>::get_size();
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::make_empty_insecure()
+{
+ hmap<obj_type,key_type>::make_empty();
+}
+
+template <class obj_type, class key_type>
+void smap<obj_type, key_type>::make_empty_insecure( void (*func)(key_type) )
+{
+ hmap<obj_type,key_type>::make_empty( func );
+}
+
+template <class obj_type, class key_type>
+void smap<obj_type, key_type>::add_elem_insecure( const obj_type &x, const key_type &k )
+{
+ hmap<obj_type,key_type>::add_elem( x, k );
+}
+
+template <class obj_type, class key_type> void
+smap<obj_type, key_type>::del_elem_insecure( const key_type & k )
+{
+ hmap<obj_type,key_type>::del_elem( k );
+}
+
+template <class obj_type, class key_type>
+obj_type smap<obj_type, key_type>::get_elem_insecure( const key_type &k )
+{
+ return hmap<obj_type,key_type>::get_elem( k );
+}
+
+template <class obj_type, class key_type>
+obj_type smap<obj_type, key_type>::pop_elem_insecure( const key_type &k )
+{
+ return hmap<obj_type,key_type>::pop_elem( k );
+}
+
+template <class obj_type, class key_type>
+bool smap<obj_type, key_type>::is_avail_insecure( const key_type &k )
+{
+ return hmap<obj_type,key_type>::is_avail( k );
+}
+
+template<class obj_type, class key_type> void
+smap<obj_type, key_type>::run_func_insecure( void (*func)(obj_type) )
+{
+ hmap<obj_type,key_type>::run_func( func );
+}
+
+template<class obj_type, class key_type> void
+smap<obj_type, key_type>::run_func_insecure( void (*func)(obj_type, void*), void* v_arg )
+{
+ hmap<obj_type,key_type>::run_func( func, v_arg );
+}
+
+template<class obj_type, class key_type> vector<key_type>*
+smap<obj_type, key_type>::get_key_vector_insecure()
+{
+ return hmap<obj_type,key_type>::get_key_vector();
+}
+
+#endif
diff --git a/src/modl.cpp b/src/modl.cpp
index f3b1e74..77e645c 100644..100755
--- a/src/modl.cpp
+++ b/src/modl.cpp
@@ -1,28 +1,4 @@
-/*:*
- *: File: ./src/modl.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
-#ifndef MODL_CPP
+#ifndef MODL_CPP
#define MODL_CPP
#include <limits.h>
@@ -35,135 +11,151 @@
using namespace std;
-modl::modl()
+modl::modl() : smap<dynmod*,string>(HMAPOCC)
{
- if ( wrap::CONF->get_elem( "httpd.modules.preloadcommands" ).compare( "true" ) == 0 )
- preload_modules( wrap::CONF->get_elem("httpd.modules.commandsdir") );
+#ifdef NCURSES
+ print_cached( 0 );
+#endif
- if ( wrap::CONF->get_elem( "httpd.modules.preloadhtml" ).compare( "true" ) == 0 )
- preload_modules( wrap::CONF->get_elem("httpd.modules.htmldir") );
+ 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_ );
+ // dlclose all the_module's first!
+ run_func( &modl::dlclose_ );
- // then clean the hash map.
- unload_modules();
+ // 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 );
+ dir* p_dir = new dir();
+ p_dir->open_dir( s_path );
- p_dir->read_dir();
+ p_dir->read_dir();
+
+ vector<string> dir_vec = p_dir->get_dir_vec();
- vector<string> dir_vec = p_dir->get_dir_vec();
+ if ( ! dir_vec.empty() )
+ {
+ vector<string>::iterator iter = dir_vec.begin();
- if ( ! dir_vec.empty() )
+ do
{
- 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() );
+ 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();
+ dir_vec.clear();
- // This also closes the dir.
- delete p_dir;
+ // This also closes the dir.
+ delete p_dir;
}
void
modl::dlclose_( dynmod* mod )
{
- dlclose( mod->the_module );
- free ( 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;
+ 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 );
+ 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;
- }
+ if ( the_module == NULL )
+ {
+ wrap::system_message( dlerror() );
+ return NULL;
+ }
- the_func = (function*) dlsym( the_module, "extern_function" );
+ 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 ) );
+ if ( the_func == NULL )
+ {
+ wrap::system_message( dlerror() );
+ return NULL;
+ }
- 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
+ if ( b_print_sys_msg )
+ wrap::system_message( MODULEC + s_name.substr( s_name.find_last_of("/")+1 ) );
- // is not needed anymore.
- add_elem( mod, s_name );
+ 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
- // DO NOT CLOSE AS LONG THERE EXIST A POINTER TO THE FUNCTION
- // dlclose( module ); will be called in modl::~modl()!
+ // is not needed anymore.
+ add_elem( mod, s_name );
- return mod;
-}
+ // DO NOT CLOSE AS LONG THERE EXIST A POINTER TO THE FUNCTION
+ // dlclose( module ); will be called in modl::~modl()!
-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;
+#ifdef NCURSES
+ print_cached( get_size() );
+#endif
+
+ return 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;
+ 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_ );
+ wrap::system_message( MODUNLO );
- // then clean the hash map.
- shashmap<dynmod*>::clear();
+ // dlclose all the_module's first!
+ run_func( &modl::dlclose_ );
+
+ // then clean the hash map.
+ make_empty();
+#ifdef NCURSES
+ print_cached( get_size() );
+#endif
+
}
void
modl::reload_modules()
{
- unload_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") );
+ 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
index 2066fa9..a65077d 100644..100755
--- a/src/modl.h
+++ b/src/modl.h
@@ -1,58 +1,37 @@
-/*:*
- *: File: ./src/modl.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "incl.h"
#ifndef MODL_H
#define MODL_H
-#include "maps/shashmap.h"
+#include "maps/smap.h"
using namespace std;
-class modl : public shashmap<dynmod*>
+class modl : private smap<dynmod*,string>
{
private:
- static void dlclose_( dynmod* mod );
- dynmod* cache_module ( string s_name, bool b_print_sys_msg );
- void preload_modules( string s_path );
+ 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();
+ modl();
+ ~modl();
- dynmod* get_module( string s_name );
- dynmod* get_module( string s_name, string s_user );
+ dynmod* get_module( string s_name );
- vector<string>* get_mod_vector()
- {
- vector<string>* p_ret = get_key_vector();
- return p_ret;
- }
+ vector<string>* get_mod_vector()
+ {
+ vector<string>* p_ret = get_key_vector();
+ return p_ret;
+ }
- void unload_modules();
- void reload_modules();
+ void unload_modules();
+ void reload_modules();
};
#endif
diff --git a/src/mods/Makefile b/src/mods/Makefile
index 7486bc5..1b0712b 100644..100755
--- a/src/mods/Makefile
+++ b/src/mods/Makefile
@@ -1,15 +1,9 @@
-MAKE=gmake
+MAKE=`tail -n 1 ../../make.version`
all: mods
mods:
@${MAKE} -C ./commands #//<<
@${MAKE} -C ./html
clean:
- @for i in commands html; do \
- if [ -f $$i/Makefile ]; then ${MAKE} -C ./$$i clean; \
- fi; done
+ @${MAKE} -C ./commands clean #//<<
+ @${MAKE} -C ./html clean
@if test -d ../../mods; then rm -Rf ../../mods; fi
-mrproper: clean
- @for i in commands html; do \
- if [ -f $$i/Makefile ]; then rm -f $$i/Makefile; \
- fi; done
-
diff --git a/src/mods/commands/Makefile.in b/src/mods/commands/Makefile.in
new file mode 100755
index 0000000..ce8c00f
--- /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):
+ @echo -n "Compiling command module `basename $@` "
+ @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
+ @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/`
+ @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
index 5fedb6d..086e126 100644
--- a/src/mods/commands/yc_about.cpp
+++ b/src/mods/commands/yc_about.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_about.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,54 +6,54 @@
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>"
+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>, "
+ + "</b>, "
+ p_conf->get_elem("chat.msgs.userinroom") + "<b>"
- + p_searched_user->get_room()->get_name()
- + "</b><br>\n"
+ + 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=\"#"
+ + "</b><br>\n";
+ p_user->msg_post( &s_msg );
+ }
+
+ else
+ {
+ string s_msg = "<font color=\"#"
+ p_conf->get_elem("chat.html.errorcolor")
- + "\"><b>"
+ + "\"><b>"
+ s_searched_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
+ p_user->msg_post( &s_msg );
- }
- }
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_all.cpp b/src/mods/commands/yc_all.cpp
index 4fae79d..c4c9cdf 100644..100755
--- a/src/mods/commands/yc_all.cpp
+++ b/src/mods/commands/yc_all.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_all.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../chat/chat.h"
/*
@@ -30,44 +6,43 @@
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;
- }
+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
index b66b82c..af4a4a5 100644..100755
--- a/src/mods/commands/yc_away.cpp
+++ b/src/mods/commands/yc_away.cpp
@@ -1,96 +1,70 @@
-/*:*
- *: File: ./src/mods/commands/yc_away.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#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;
- }
+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
index 11f93b6..4449278 100644..100755
--- a/src/mods/commands/yc_col.cpp
+++ b/src/mods/commands/yc_col.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_col.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../wrap.h"
#include "../../chat/room.h"
@@ -34,79 +10,76 @@
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;
- }
+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);
+ }
+
+ 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
index 5850cea..ad6ae99 100644..100755
--- a/src/mods/commands/yc_compopt.cpp
+++ b/src/mods/commands/yc_compopt.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_compopt.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../msgs.h"
#include "../../chat/user.h"
@@ -31,17 +7,16 @@
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");
+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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_exec.cpp b/src/mods/commands/yc_exec.cpp
index 7751566..f912c20 100644..100755
--- a/src/mods/commands/yc_exec.cpp
+++ b/src/mods/commands/yc_exec.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_exec.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#include "../../chat/room.h"
#include "../../chat/user.h"
@@ -33,58 +9,58 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container *c=(container *)v_arg;
+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
- 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;
- 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 );
- vector<string>::iterator iter;
- for ( iter = params->begin(); iter != params->end(); iter++ )
- s_command.append( " " + *iter );
+ s_command.append(" 2>error.log");
- s_command.append(" 2>error.log");
+ s_msg.append( " " + s_command + "<br>\n" );
- s_msg.append( " " + s_command + "<br>\n" );
+ p_user->msg_post( &s_msg );
- p_user->msg_post( &s_msg );
+ FILE *file;
+ char buffer[READBUF];
- 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 );
+ }
- 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;
+ else
+ {
+ s_output.append("<hr>\n");
+ while(true)
+ {
+ if(fgets(buffer, READBUF, file) == NULL)
+ break;
- s_output.append( string(buffer) + "<br>\n" );
- }
+ s_output.append( string(buffer) + "<br>\n" );
+ }
- p_user->msg_post( &s_output );
- pclose(file);
- }
+ p_user->msg_post( &s_output );
+ pclose(file);
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_fake.cpp b/src/mods/commands/yc_fake.cpp
index e8dd230..c708841 100644..100755
--- a/src/mods/commands/yc_fake.cpp
+++ b/src/mods/commands/yc_fake.cpp
@@ -1,54 +1,29 @@
-/*:*
- *: File: ./src/mods/commands/yc_fake.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#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;
- }
+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
index bc0805b..87e2d25 100644..100755
--- a/src/mods/commands/yc_getroom.cpp
+++ b/src/mods/commands/yc_getroom.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_getroom.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,48 +6,48 @@
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>"
+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_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>"
+ + "\"><b>"
+ s_searched_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
+ p_user->msg_post( &s_msg );
- }
- }
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_getrusage.cpp b/src/mods/commands/yc_getrusage.cpp
index ba9d574..83dcbb9 100644..100755
--- a/src/mods/commands/yc_getrusage.cpp
+++ b/src/mods/commands/yc_getrusage.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_getrusage.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -42,40 +18,39 @@
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;
- }
+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
index 7b4ddb9..41899c3 100644..100755
--- a/src/mods/commands/yc_help.cpp
+++ b/src/mods/commands/yc_help.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_help.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#include "../../chat/user.h"
@@ -31,47 +7,45 @@
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;
- }
+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
index a207827..b78d934 100644..100755
--- a/src/mods/commands/yc_invisible.cpp
+++ b/src/mods/commands/yc_invisible.cpp
@@ -1,55 +1,30 @@
-/*:*
- *: File: ./src/mods/commands/yc_invisible.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#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;
- }
+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
index 2800764..903e49b 100644..100755
--- a/src/mods/commands/yc_j.cpp
+++ b/src/mods/commands/yc_j.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_j.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../chat/user.h"
#include "../../chat/room.h"
@@ -31,98 +7,99 @@
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 );
+extern "C" {
+ int extern_function(void *v_arg)
+ {
- p_gcol->lock_mutex();
- if ( p_room_old != NULL )
- p_room_old->msg_post( &s_msg );
- p_gcol->unlock_mutex();
+ 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;
- p_room->add_user( p_user );
- p_chat->add_elem( p_room );
- p_room->msg_post( &s_msg2 );
- }
- else // p_room != NULL
+ if ( ! params->empty() )
{
- 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;
- }
+ 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
index 99e8613..ac32ac7 100644..100755
--- a/src/mods/commands/yc_ko.cpp
+++ b/src/mods/commands/yc_ko.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_ko.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,67 +6,67 @@
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() + " "
+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";
+ + "<br>\n";
- room* p_room1 = p_user->get_room();
- room* p_room2 = p_searched_user->get_room();
+ room* p_room1 = p_user->get_room();
+ room* p_room2 = p_searched_user->get_room();
- p_room1->msg_post( &s_msg );
+ p_room1->msg_post( &s_msg );
- if ( p_room1->get_lowercase_name() !=
- p_room2->get_lowercase_name() )
- p_room2->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='/"
+ 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_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>"
+ + "\"><b>"
+ s_searched_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
- }
- }
+ p_user->msg_post( &s_msg );
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_m.cpp b/src/mods/commands/yc_m.cpp
index 5ef0098..a93cc3b 100644..100755
--- a/src/mods/commands/yc_m.cpp
+++ b/src/mods/commands/yc_m.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_m.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../chat/user.h"
#include "../../chat/room.h"
@@ -31,38 +7,37 @@
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;
- }
+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
index cede991..d79d952 100644..100755
--- a/src/mods/commands/yc_md5.cpp
+++ b/src/mods/commands/yc_md5.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_md5.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#include "../../chat/user.h"
#include "../../contrib/crypt/md5.h"
@@ -32,47 +8,47 @@
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;
- }
+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
index 262ce11..66d54da 100644..100755
--- a/src/mods/commands/yc_me.cpp
+++ b/src/mods/commands/yc_me.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_me.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../chat/user.h"
#include "../../chat/room.h"
@@ -31,39 +7,38 @@
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;
+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 = "";
+ string s_msg = "";
- if ( p_conf->get_elem("chat.printalwaystime") == "true" )
- s_msg = p_timr->get_time() + " ";
+ 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() + " ");
+ 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 + " " );
- }
+ 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 );
+ s_msg.append( "</font></i><br>\n" );
+ p_user->get_room()->msg_post( &s_msg );
- return 0;
+ return 0;
- }
+ }
}
diff --git a/src/mods/commands/yc_morph.cpp b/src/mods/commands/yc_morph.cpp
index 2177a39..cf1f448 100644..100755
--- a/src/mods/commands/yc_morph.cpp
+++ b/src/mods/commands/yc_morph.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_morph.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../chat/user.h"
#include "../../chat/room.h"
#include "../../tool/tool.h"
@@ -32,44 +8,45 @@
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;
- }
+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
index 9f337c3..33beee4 100644..100755
--- a/src/mods/commands/yc_msg.cpp
+++ b/src/mods/commands/yc_msg.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_msg.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../chat/user.h"
#include "../../chat/room.h"
/*
@@ -30,63 +6,63 @@
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=\"#"
+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>"
+ + "\"><b>"
+ s_whisper_user + "</b> "
+ p_conf->get_elem("chat.msgs.err.notavailable")
+ "</font><br>\n";
- p_user->msg_post( &s_msg );
- }
- }
+ p_user->msg_post( &s_msg );
+ }
+ }
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_q.cpp b/src/mods/commands/yc_q.cpp
index 5dba617..4c9584d 100644..100755
--- a/src/mods/commands/yc_q.cpp
+++ b/src/mods/commands/yc_q.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_q.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../chat/user.h"
@@ -32,23 +8,22 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
- container* c = (container*) v_arg;
- user* p_user = (user*)c->elem[1];
+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;
+ conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;
- string s_quit = "<script language='JavaScript'>top.location.href='/"
- + p_conf->get_elem("httpd.startsite")
- + "';</script>";
+ 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);
+ p_user->msg_post( &s_quit );
+ p_user->set_online(false);
- return 0;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_reload.cpp b/src/mods/commands/yc_reload.cpp
index ec94c5b..8b9cd0a 100644..100755
--- a/src/mods/commands/yc_reload.cpp
+++ b/src/mods/commands/yc_reload.cpp
@@ -1,49 +1,24 @@
-/*:*
- *: File: ./src/mods/commands/yc_reload.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#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;
- }
+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
index 672d378..9735d8e 100644..100755
--- a/src/mods/commands/yc_ren.cpp
+++ b/src/mods/commands/yc_ren.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_ren.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../chat/user.h"
#include "../../chat/room.h"
@@ -31,68 +7,68 @@
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=\"#"
+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.us_errorenamesroom" )
+ 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();
- }
- }
+ 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_s.cpp b/src/mods/commands/yc_s.cpp
index daece17..30a6892 100644..100755
--- a/src/mods/commands/yc_s.cpp
+++ b/src/mods/commands/yc_s.cpp
@@ -1,72 +1,47 @@
-/*:*
- *: File: ./src/mods/commands/yc_s.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../chat/user.h"
#include "../../chat/room.h"
using namespace std;
-extern "C"
-{
- 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;
-
- }
+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
index 25bb2b0..a18b5e9 100644..100755
--- a/src/mods/commands/yc_set.cpp
+++ b/src/mods/commands/yc_set.cpp
@@ -1,124 +1,101 @@
-/*:*
- *: File: ./src/mods/commands/yc_set.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#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";
+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;
- p_user->get_room()->msg_post(&s_msg);
- p_chat->set_command_status( s_command_name, i_newval );
+ 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 if ( s_option == "disable" )
- {
- const char* c_newval = s_newval.c_str();
- if ( isdigit( c_newval[0] ) )
+
+ else
{
- 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 );
+ 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 );
}
- }
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/commands/yc_template.cpp b/src/mods/commands/yc_template.cpp
new file mode 100755
index 0000000..e0aa009
--- /dev/null
+++ b/src/mods/commands/yc_template.cpp
@@ -0,0 +1,24 @@
+#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
index 32dc8b1..c22e542 100644..100755
--- a/src/mods/commands/yc_time.cpp
+++ b/src/mods/commands/yc_time.cpp
@@ -1,46 +1,21 @@
-/*:*
- *: File: ./src/mods/commands/yc_time.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
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;
- }
+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
index d02727d..0fd01e9 100644..100755
--- a/src/mods/commands/yc_topic.cpp
+++ b/src/mods/commands/yc_topic.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_topic.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../tool/tool.h"
#include "../../incl.h"
#include "../../chat/room.h"
@@ -29,74 +5,74 @@
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;
- }
+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_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
index f566f73..5fe0929 100644..100755
--- a/src/mods/commands/yc_uptime.cpp
+++ b/src/mods/commands/yc_uptime.cpp
@@ -1,46 +1,21 @@
-/*:*
- *: File: ./src/mods/commands/yc_uptime.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
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;
- }
+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_version.cpp b/src/mods/commands/yc_version.cpp
index 6bbff31..d64fabd 100644..100755
--- a/src/mods/commands/yc_version.cpp
+++ b/src/mods/commands/yc_version.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/commands/yc_version.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include <iostream>
#include "../../msgs.h"
#include "../../chat/user.h"
@@ -31,17 +7,16 @@
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");
+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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/configure b/src/mods/configure
index b90a55a..839380b 100755
--- a/src/mods/configure
+++ b/src/mods/configure
@@ -1,26 +1,26 @@
-#!/bin/sh
-
-if ! test -f ../Makefile; then
- if test $1 != "fromtop"; then
- echo "===> You need to run ./configure of the top level source dir first"
- exit 1
- else
- exit 0
- fi
-fi
+#! /bin/sh
-cxx=`sed -n '/^CXX=/ { s///; p; q; }' ../Makefile`
-cxxflags=`sed -n '/^CXXFLAGS=/ { s///; p; q; }' ../Makefile`
+if ! test -f ../../g++.version
+then
+ echo You need to run ./configure of the top level source dir first
+ exit 1
+fi
+echo Creating module Makefiles...
for dir in commands html
do
- echo "===> Creating $dir module Makefiles"
- cd $dir
- sed -n "s/=@CXXFLAGS@/=$cxxflags/; s/=@CXX@/=$cxx/; s/@CATEGORY@/$dir/g; w Makefile" ../Makefile.mods.in
- for i in *.cpp
- do
- echo "../../../mods/$dir/./`echo $i | sed s/.cpp/.so/`: $i" >> Makefile
- done
- cd ..
+ if test -d $dir
+ then
+ cd $dir &&
+ srcs="SRCS=`ls *.cpp`" &&
+ echo $srcs > Makefile
+ compiler=`tail -n 1 ../../../g++.version`
+ sed s/COMPILER/$compiler/ Makefile.in >> Makefile &&
+ for i in *.cpp
+ do
+ echo "../../../mods/$dir/`echo $i | sed s/.cpp/.so/`: $i" >> Makefile
+ done
+ cd ..
+ fi
done
diff --git a/src/mods/html/Makefile.in b/src/mods/html/Makefile.in
new file mode 100755
index 0000000..30f1782
--- /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):
+ @echo -n "Compiling html module `basename $@` "
+ @if ! test -d `dirname $@`; then mkdir -p `dirname $@`; fi
+ @$(CC) $(CFLAGS) $(INCLUDES) -shared -s -o $@ `echo $(notdir $@) | sed s/.so/.cpp/`
+ @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
index bdf1694..b6b979e 100644
--- a/src/mods/html/yc_admin.cpp
+++ b/src/mods/html/yc_admin.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/html/yc_admin.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
#include "../../tool/tool.h"
@@ -31,66 +7,63 @@
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;
- }
+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
index be87942..6d2c5ab 100644..100755
--- a/src/mods/html/yc_colors.cpp
+++ b/src/mods/html/yc_colors.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/html/yc_colors.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,32 +6,30 @@
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;
- }
+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
index 8b548e5..4d6db03 100644..100755
--- a/src/mods/html/yc_help.cpp
+++ b/src/mods/html/yc_help.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/html/yc_help.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,45 +6,43 @@
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" );
+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++;
}
- }
- p_vec_keys_iter++;
- }
- return 0;
- }
+
+ return 0;
+ }
}
diff --git a/src/mods/html/yc_options.cpp b/src/mods/html/yc_options.cpp
index 502fdfa..47c3153 100644..100755
--- a/src/mods/html/yc_options.cpp
+++ b/src/mods/html/yc_options.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/html/yc_options.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,51 +6,50 @@
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 )
+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" )
{
- p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword" ) );
- return 0;
+ 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" ) );
}
- if ( *p_newpass != *p_newpass2 )
+ else
{
- p_msgs->append( p_conf->get_elem( "chat.msgs.err.changepassword2" ) );
- return 0;
+ p_email->append( p_user->get_email() );
}
- 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;
- }
+ return 0;
+ }
}
diff --git a/src/mods/html/yc_register.cpp b/src/mods/html/yc_register.cpp
index 5ae000c..5d65b50 100644..100755
--- a/src/mods/html/yc_register.cpp
+++ b/src/mods/html/yc_register.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/mods/html/yc_register.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../../incl.h"
/*
@@ -30,91 +6,88 @@
using namespace std;
-extern "C"
-{
- int extern_function(void *v_arg)
- {
+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
+ 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
+ {
+ map<string,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/msgs.h b/src/msgs.h
index 8f64890..bdf2c0c 100644
--- a/src/msgs.h
+++ b/src/msgs.h
@@ -1,42 +1,15 @@
-/*:*
- *: File: ./src/msgs.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef MSGS_H
#define MSGS_H
-#include "build.h"
-
// alphabetical ordered:
#define ACCPERR "Sock: Accept error "
#define BINDERR "Sock: Bind error "
#define CHATREP "Chat: Using replacement strings"
#define CHATDOP "Chat: Default operator login "
-#define CHATFLO "Chat: Flooding ("
#define CFILEOK "Parsing config file"
#define CFILEFA "Failed opening config file!"
#define CONTACT "Contact: http://www.yChat.org, Mail@yChat.org, ICQ: 11655527"
-#define CLRHTML "HTML: Cleared the document cache "
+#define CLRHTML "HTML: Cleared the template cache "
#define CLIWELC "Command Line Interface (type help for a list of all commands)"
#define CLIPRMO ">> "
#define CLIPRMI "<< "
@@ -52,10 +25,9 @@
#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 DATANEW "Data: Creating new database conbbnection "
#define DESCRIP "Copyright (C) 2003 Paul C. Buetow, Volker Richter"
#define DESCRI2 "Copyright (C) 2004, 2005 Paul C. Buetow"
-#define DESCRI3 "Copyright (C) 2005 EXA Digital Solutions GbR"
#define DONEMSG "done"
#define DOWNMSG "Shutting down "
#define GARBAGE "Garbage: Initializing collector "
@@ -64,8 +36,7 @@
#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 LISTERR "Sock: Listen error "
#define LOGERR1 "Logging: Could not open logfile "
#define LOGERR2 "Logging: No filename specified "
#define LOGINER "Chat: Login failed (password), nick: "
@@ -74,28 +45,30 @@
#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 "
#ifdef DATABASE
-#define MYSQLQU "MySQL: "
-#define MYSQLQ2 "MySQL: Adding query "
+#define MYSQLQU "MySQL: "
+#define MYSQLQ2 "MySQL: Adding query "
#define MYSQLE1 "MySQL: Error running mysql_init "
#endif
-#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 POOLERR "Pool: Malloc error "
#define POOLER2 "Pool: Max pool size reached ("
#define POOLFLL "Pool: Allocating new threads ("
#define READERR "Sock: Read error "
@@ -104,16 +77,10 @@
#define REQUEST "Reqp: Request string "
#define SELCERR "Sock: Select error "
#define SEPERAT "-----------------------"
-#define SESSIOC "Session: Create "
-#define SESSIOD "Session: Destroy "
-#define SESSIOI "Session: Invalidated a session "
#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 "
@@ -122,21 +89,10 @@
#define SOCKCRT "Sock: Created socket on "
#define SOCKSRV "Sock: Initializing server socket "
#define SOCKERR "Sock: Can't create socket, trying next port "
-#define SOCKER1 "Sock: Can't create socket, aborting"
#define SOCKER2 "Sock: Unknown hostname "
-#define SOCKER4 "Sock: Incomplete HTTP request"
#define SOCKRDY "Sock: Server socket is ready "
-#define SOCKCAC "Sock: Caching IP "
-#define SOCKCA2 "Sock: Cleaning IP cache ("
-#define SOCKUNS "Sock: Starting unsecure transport [HTTP]"
-#ifdef OPENSSL
-#define SSLERR1 "SSL: Can't create socket"
-#define SSLERR2 "SSL: Private key does not match cert. file"
-#define SSLERR3 "SSL: Can't create new SSL context"
-#define SSLERR4 "SSL: Can't create new SSL socket via accept"
-#define SOCKSEC "SSL: Starting secure transport [HTTPS]"
-#endif
-#define TECACHE "HTML: Caching document "
+#define SSLINIT "SSL: Initializing OpenSSL"
+#define TECACHE "HTML: Caching template "
#define THRDSTR "Thread: Running"
#define TIMERAT "Timer: User autoaway timeout "
#define TIMERIN "Timer: Initializing "
@@ -147,21 +103,20 @@
#define XMLREAD "XML: Reading "
#define XMLERR "XML Error: "
#define XMLER1 "XML Error: Unable to load file "
+#define VERSION "0.7.4.1"
+#define BRANCH "RELEASE"
+#define BUILDNR 3187
+#define UNAME "FreeBSD 5.3-RELEASE-p5 i386"
+#define COMPOPT "Using built-in specs.; Configured with: FreeBSD/i386 system compiler; Thread model: posix; gcc version 3.4.2 [FreeBSD] 20040728; 3.4; g++"
#define YCUSAGE "Usage: ./ychat {h|v}|{o confkey confvalue}\n"
-#define HEADER1 "HTTP/1.1 200 OK\r\n"
-#define HEADER2 "Server: yChat/" VERSION "-" BRANCH "\r\n"
-#define HEADER3 "Cache-Control: no-cache\r\n"
-#define HEADER4 ""
-//#define HEADER4 "Pragma: no-cache\r\n"
+#define HEADER1 "HTTP/1.0 200 OK\r\n"
+#define HEADER2 "Server: yChat/" VERSION "-" BRANCH "\r\n"
+#define HEADER3 "Cache-control: no-cache\r\n"
+#define HEADER4 "Pragma: no-cache\r\n"
#define HEADER5 "Transfer-Encoding: chunked\r\n"
-#define HEADER6 "Connection: keep-alive\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 "";
-//#define HEADER9 "Accept-Ranges: bytes\r\n";
-//#define HEADER9 "Keep-Alive: timeout=15, max=99\r\nLast-Modified: Mon, 19 Dec 2005 23:00:02 GMT\r\nAccept-Ranges: bytes\r\nDate: Tue, 20 Dec 2005 03:30:10 GMT\r\n";
-//#define MEMBERE "Memb: No such member "
#endif
diff --git a/src/name.cpp b/src/name.cpp
index 77c6f9a..fd9f33b 100644..100755
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/name.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef NAME_CPP
#define NAME_CPP
@@ -32,42 +8,42 @@ using namespace std;
name::name()
{
- pthread_mutex_init( &mut_s_name, NULL);
+ pthread_mutex_init( &mut_s_name, NULL);
}
name::name( string s_name )
{
- pthread_mutex_init( &mut_s_name, NULL);
- set_name( s_name );
+ pthread_mutex_init( &mut_s_name, NULL);
+ set_name( s_name );
}
name::~name()
{
- pthread_mutex_destroy( &mut_s_name );
+ pthread_mutex_destroy( &mut_s_name );
}
string
-name::get_name()
+name::get_name()
{
- string s_ret;
- pthread_mutex_lock ( &mut_s_name );
- s_ret = s_name;
- pthread_mutex_unlock( &mut_s_name );
- return s_ret;
+ 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()
+name::get_lowercase_name()
{
- return tool::to_lower( get_name() );
+ return tool::to_lower( get_name() );
}
void
name::set_name( string s_name )
{
- pthread_mutex_lock ( &mut_s_name );
- this->s_name = s_name;
- pthread_mutex_unlock( &mut_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 c3281a9..1e79c0e 100644..100755
--- a/src/name.h
+++ b/src/name.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/name.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "incl.h"
#ifndef NAME_H
@@ -32,17 +8,17 @@ using namespace std;
class name
{
protected:
- string s_name; // object's name.
- pthread_mutex_t mut_s_name;
+ string s_name; // object's name.
+ pthread_mutex_t mut_s_name;
public:
- virtual string get_name ( );
- virtual string get_lowercase_name ( );
- virtual void set_name ( string s_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();
+ 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 100755
index 0000000..3243df9
--- /dev/null
+++ b/src/ncur/menu.cpp
@@ -0,0 +1,119 @@
+
+#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 100755
index 0000000..d931be3
--- /dev/null
+++ b/src/ncur/menu.h
@@ -0,0 +1,39 @@
+#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 100755
index 0000000..cee3d06
--- /dev/null
+++ b/src/ncur/ncur.cpp
@@ -0,0 +1,284 @@
+#ifndef NCUR_CPP
+#define NCUR_CPP
+
+#include "ncur.h"
+
+#ifdef CLI
+#include "../cli/cli.h"
+#endif
+
+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
+ "Disconnect from DB ", //<<
+#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 */
+ 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
+ if ( ! wrap::GCOL->remove_garbage() ) //<<
+ wrap::NCUR->print( GAROFFNE ); //<<
+ mvprintw( 21,2, "Good bye !");
+ close_ncurses();
+ exit(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_WHITE, COLOR_BLUE);
+ mvprintw( 0,2, (char*)(tool::ychat_version()).c_str());
+ 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 100755
index 0000000..53849d0
--- /dev/null
+++ b/src/ncur/ncur.h
@@ -0,0 +1,50 @@
+#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:
+ 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( ); // a standard constructor.
+ ~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 7f5349e..8186764 100644..100755
--- a/src/reqp.cpp
+++ b/src/reqp.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/reqp.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef REQP_CPP
#define REQP_CPP
@@ -30,14 +6,13 @@
using namespace std;
-#define HEADER HEADER1 HEADER2 HEADER3 HEADER4 HEADER9
+#define HEADER HEADER1 HEADER2 HEADER3 HEADER4
#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;
+const string reqp::s_http_stream = STREAM;
+const string reqp::s_http_colength = HEADER7;
+const string reqp::s_http_cotype = HEADER8;
reqp::reqp( )
{}
@@ -45,356 +20,373 @@ reqp::reqp( )
void
reqp::get_request_parameters( string s_parameters, map<string,string>& map_params )
{
- string s_tmp;
- unsigned i_pos, i_pos2;
+ string s_tmp;
+ unsigned i_pos, i_pos2;
- while( (i_pos = s_parameters.find("&")) != string::npos )
- {
- s_tmp = s_parameters.substr(0, i_pos );
+ while( (i_pos = s_parameters.find("&")) != string::npos )
+ {
+ s_tmp = s_parameters.substr(0, i_pos );
- 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", "&");
+ 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", "&");
- s_parameters = s_parameters.substr( i_pos + 1 );
- }
+ s_parameters = s_parameters.substr( i_pos + 1 );
+ }
- // 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 );
+ // 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 );
- //map<string,string>::iterator iter;
- //for ( iter = map_params.begin(); iter != map_params.end(); ++iter )
- //cout << ">>>" << iter->first << "=" << iter->second << endl;
+ //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( string s_req, map<string, string> &map_params, int& i_postpayloadoffset )
+reqp::get_url( int &i_sock, string s_req, map<string,string> &map_params )
{
- unsigned i_pos, i_pos2;
- string s_vars( "" );
- 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 )
+ 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;
+ i_pos = s_req.length() - 1;
- s_req = s_req.substr(5, i_pos - 5);
+ s_req = s_req.substr(5, i_pos - 5);
- // Get HTML site to be displayed
+ // 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));
+ 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 = 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 )
+ // POST request
+ else
{
- 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);
- }
+ 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[POSTBUF];
+ i_len = read(i_sock, c_req, POSTBUF);
+ s_req = c_req;
+ s_req = s_req.substr(0, i_len);
+
+ if ( (i_pos = s_req.find("event=")) != string::npos )
+ get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params );
+ }
+ else
+ {
+ get_request_parameters( url_decode( s_req.substr(i_pos) ), map_params );
+ }
}
+ }
}
- }
-
#ifdef VERBOSE
- wrap::system_message( REQUEST + s_ret );
+ wrap::system_message( REQUEST + s_ret );
#endif
- if ( s_ret.empty() )
- s_ret = wrap::CONF->get_elem( "httpd.startsite" );
-
- else
- s_ret = remove_dots(s_ret);
+ if ( s_ret.empty() )
+ s_ret = wrap::CONF->get_elem( "httpd.startsite" );
- map_params["request"] = s_ret;
+ else
+ s_ret = remove_dots(s_ret);
+
+ map_params["request"] = s_ret;
- return s_ret;
+ return s_ret;
}
string
-reqp::get_content_type(string &s_file)
+reqp::get_content_type( string s_file )
{
- string s_ext(tool::get_extension( s_file ));
+ string s_ext(tool::get_extension( s_file ));
- if( s_ext == "" )
- s_ext = "default";
+ if( s_ext == "" )
+ s_ext = "default";
- return wrap::CONF->get_elem( "httpd.contenttypes." + s_ext );
+ return wrap::CONF->get_elem( "httpd.contenttypes." + s_ext );
}
void
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"] = tool::trim(s_req.substr(0,pos-1));
+ int pos = s_req.find("\n");
- int pos2;
- do
+ if (pos != string::npos)
{
- string s_line( s_req.substr(0, pos) );
- pos2 = s_line.find(":");
+ map_params["QUERY_STRING"] = tool::trim(s_req.substr(0,pos-1));
- if (pos2 != string::npos && s_line.length() > pos2+1)
+ 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");
- }
- while( pos != string::npos);
- } // if
+ s_req = s_req.substr( s_line.size() + 1 );
+ pos = s_req.find("\n");
+ }
+ while( pos != string::npos);
+ } // if
}
int
reqp::htoi(string *p_str)
{
- int value, c;
- c = p_str->at(0);
+ int value, c;
+ c = p_str->at(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 = p_str->at(1);
+ c = p_str->at(1);
- if( isupper(c) )
- c = tolower(c);
+ if( isupper(c) )
+ c = tolower(c);
- value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10;
+ value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10;
- return value;
+ return value;
}
string
reqp::url_decode( string s_url )
{
- string s_dest = "";
- int i_len = s_url.size();
- int i_prv = i_len - 2;
-
- char c;
- for( int i = 0; i < i_len; ++i)
- {
- c = s_url.at(i);
- if( c == '+' )
- {
- 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
+ string s_dest = "";
+ int i_len = s_url.size();
+ int i_prv = i_len - 2;
+
+ char c;
+ for( int i = 0; i < i_len; ++i)
{
- s_dest += c;
+ c = s_url.at(i);
+ if( c == '+' )
+ {
+ 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 s_dest;
+ return s_dest;
}
string
reqp::get_from_header( string s_req, string s_hdr )
{
- unsigned i_pos[2];
- if ( (i_pos[0] = s_req.find( s_hdr, 0 )) == string::npos )
- return "";
+ 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 "";
+ if ( (i_pos[1] = s_req.find( "\n", i_pos[0]) ) == string::npos )
+ return "";
- unsigned i_len = s_hdr.length();
- return s_req.substr( i_pos[0] + i_len, i_pos[1] - i_pos[0] - i_len - 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( _socket *p_sock, string s_req, map<string,string> &map_params, int &i_postpayloadoffset )
+reqp::parse( int &i_sock, string s_req, map<string,string> &map_params )
{
+ // store all request informations in map_params. store the url in
+ // map_params["request"].
+ get_url( i_sock, s_req, map_params );
- // store all request informations in map_params. store the url in
- // map_params["request"].
- get_url( s_req, map_params, i_postpayloadoffset );
-
- parse_headers( s_req, map_params );
- string s_event( map_params["event"] );
-
- map_params["content-type"] = get_content_type( map_params["request"] );
-
- string s_rep( "" );
+ parse_headers( s_req, map_params );
+ string s_event( map_params["event"] );
- //<<*
- // check the event variable.
- if ( ! s_event.empty() )
- {
- // login procedure.
- if ( s_event == "login" )
- {
- wrap::CHAT->login( map_params );
- }
- else if ( s_event == "register" )
- {
- 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;
+ map_params["content-type"] = get_content_type( map_params["request"] );
- if( p_sess != NULL )
- {
- p_user = p_sess->get_user();
- }
- else
- {
- wrap::system_message(SESSERR);
- return s_rep;
- }
+ string 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
+ //<<*
+ // check the event variable.
+ if ( ! s_event.empty() )
{
- map_params["nick"] = p_user->get_name().c_str();
-
- // if a message input.
- if ( s_event == "input" )
+ // login procedure.
+ if ( s_event == "login" )
{
- if ( p_user )
- {
- p_user->check_restore_away();
- wrap::CHAT->post( p_user, map_params );
- }
+ wrap::CHAT->login( map_params );
}
- // if a chat stream
- else if ( s_event == "stream" )
+ else if ( s_event == "register" )
{
- string s_msg ( wrap::HTML->parse( map_params ) );
- p_user->msg_post( &s_msg);
- wrap::SOCK->chat_stream( p_sock, p_user, map_params );
+ 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 );
}
- // if a request for the online list of the active room.
- else if ( s_event == "online" )
+ else
{
- wrap::HTML->online_list( p_user, map_params );
+ 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
+ {
+ 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" )
+ {
+ if ( p_user )
+ {
+ p_user->check_restore_away();
+ wrap::CHAT->post( p_user, map_params );
+ }
+ }
+
+ // if a chat stream
+ else if ( s_event == "stream" )
+ {
+ string s_msg ( wrap::HTML->parse( map_params ) );
+ p_user->msg_post( &s_msg);
+ wrap::SOCK->chat_stream( i_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 );
+ }
+ }
}
- 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( wrap::HTML->parse( map_params ) );
}
- }
- //*>>
-
- 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( wrap::HTML->parse( map_params ) );
- }
-
- // create the http header.
-
- string s_resp(s_http);
- if ( s_event.compare("stream") == 0 )
- s_resp.append( s_http_stream );
-
- s_resp.append( s_http_colength + tool::int2string(s_rep.size()) + "\r\n" +
- s_http_cotype + map_params["content-type"] +
- s_http_cotype_add + "\r\n" );
-
- s_resp.append(s_rep);
-
-
- // return the parsed html-template.
- return s_resp;
+
+ // create the http header.
+
+ string s_resp(s_http);
+ if ( s_event.compare("stream") == 0 )
+ s_resp.append( s_http_stream );
+
+ s_resp.append( s_http_colength + tool::int2string(s_rep.size()) + "\n"
+ + map_params["content-type"] + "\r\n\r\n" );
+
+ s_resp.append(s_rep);
+
+
+ // return the parsed html-template.
+ return s_resp;
}
//<<*
-void
+void
reqp::run_html_mod( string s_event, map<string,string> &map_params, user* p_user )
{
- container *c = new container;
-
- c->elem[0] = (void*) wrap::WRAP;
- c->elem[1] = (void*) &map_params;
- c->elem[2] = (void*) p_user;
+ container *c = new container;
- string s_mod = wrap::CONF->get_elem("httpd.modules.htmldir") + "yc_" + s_event + ".so";
+ c->elem[0] = (void*) wrap::WRAP;
+ c->elem[1] = (void*) &map_params;
+ c->elem[2] = (void*) p_user;
- dynmod* p_module = wrap::MODL->get_module( s_mod, p_user->get_name() );
+ string s_mod = wrap::CONF->get_elem("httpd.modules.htmldir") + "yc_" + s_event + ".so";
- if ( p_module != NULL )
- ( *( p_module->the_func ) ) ( static_cast<void*>(c) );
+ dynmod* p_module = wrap::MODL->get_module( s_mod );
+
+ if ( p_module != NULL )
+ ( *( p_module->the_func ) ) ( (void*) c );
- delete c;
+ delete c;
}
//*>>
string
reqp::remove_dots( string s_ret )
{
- // remove ".." from the request.
- unsigned i_pos;
+ // remove ".." from the request.
+ unsigned pos;
- if ( (i_pos = s_ret.find( ".." )) != string::npos )
- return remove_dots(s_ret.substr(0, i_pos));
+ if( (pos = s_ret.find( ".." )) != string::npos)
+ return s_ret.substr(0, pos);
- return s_ret;
+ return s_ret;
}
#endif
diff --git a/src/reqp.h b/src/reqp.h
index 95024a8..9fec7e2 100644..100755
--- a/src/reqp.h
+++ b/src/reqp.h
@@ -1,66 +1,41 @@
-/*:*
- *: File: ./src/reqp.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "incl.h"
#ifndef REQP_H
#define REQP_H
-#include "maps/hashmap.h"
+#include <map>
using namespace std;
class reqp
{
private:
- 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 );
-
- 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 );
-
- // 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 );
+ static const string s_http;
+ static const string s_http_stream;
+ static const string s_http_colength;
+ static const string s_http_cotype;
+
+ // returns the request url from thr client's http request header
+ // until the first "?" and stores all request parameter values
+ // ( behind "?" ) into map_params.
+ string get_url( int &i_sock, string s_req, map<string,string> &map_params );
+ // returns a specific value of the client's http request header.
+ // ( s.t. like the User-Agent, Referer etc... ).
+ string get_from_header( string s_req, string s_hdr );
+
+ 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 );
+
+ // 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:
- reqp( );
- string parse( _socket* 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 );
+ reqp( );
+ string parse( int &i_sock, string s_req, map<string,string> &map_params );
+ string url_decode ( string s_url );
+ string get_content_type( string s_file );
+ void parse_headers( string s_req, map<string,string> &map_params );
};
#endif
diff --git a/src/sock/sock.cpp b/src/sock/sock.cpp
index 45583e3..bc5eb55 100644..100755
--- a/src/sock/sock.cpp
+++ b/src/sock/sock.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/sock/sock.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef SOCK_CPP
#define SOCK_CPP
@@ -29,521 +5,294 @@
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
-
#include "sock.h"
+#include "../chat/chat.h"
+#include "../chat/user.h"
using namespace std;
sock::sock()
{
- this->b_run = true;
- this->i_req = 0;
- this->req_parser = new reqp();
-
+ this->b_run = true;
+ this->i_req = 0;
+ this->i_threads = 0;
+ this->req_parser = new reqp();
+ this->thrd_pool = new pool();
#ifdef LOGGING
- this->log_daemon = new logd( wrap::CONF->get_elem( "httpd.logging.accessfile" ),
- wrap::CONF->get_elem( "httpd.logging.access_lines" ) );
-#endif
-
- this->ip_cache_map = new shashmap
- < string, unsigned, self_hash<unsigned>, equals_allocator<unsigned> >;
-}
+ this->log_daemon = new logd( wrap::CONF->get_elem( "httpd.logging.accessfile" ),
-int
-sock::_send(_socket *p_sock, const char *sz, int len)
-{
-#ifdef OPENSSL
- return send(p_sock->i_sock, sz, len, 0);
-#else
- return send(*p_sock, sz, len, 0);
+ wrap::CONF->get_elem( "httpd.logging.accesslines" ) );
#endif
}
-int
-sock::_read(_socket *p_sock, char *sz, int len)
+sock::~sock()
{
-#ifdef OPENSSL
- return read(p_sock->i_sock, sz, len);
-#else
- return read(*p_sock, sz, len);
-#endif
-}
-
-int
-sock::_close(_socket *p_sock)
-{
-#ifdef OPENSSL
- shutdown( p_sock->i_sock, 2 );
- close ( p_sock->i_sock );
-#else
- shutdown( *p_sock, 2 );
- close ( *p_sock );
-#endif
- delete p_sock;
}
//<<*
void
-sock::chat_stream( _socket *p_sock, user *p_user, map<string,string> &map_params )
+sock::chat_stream( int i_sock, user *p_user, map<string,string> &map_params )
{
- string s_msg( "\n" );
+ string s_msg( "\n" );
- for ( int i = 0; i < PUSHSTR; i++ )
- _send(p_sock,s_msg.c_str(), s_msg.size());
+ for ( int i = 0; i < PUSHSTR; i++ )
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
- pthread_mutex_t mutex;
- pthread_mutex_init( &mutex, NULL );
- pthread_mutex_lock( &mutex );
+ 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() ) )
+ do
{
- p_user->set_online( false );
- break;
- }
+ s_msg = p_user->get_mess( );
- pthread_cond_wait( &(p_user->cond_message), &mutex );
- }
- while( p_user->get_online() );
+ if ( 0 > send( i_sock, s_msg.c_str(), s_msg.size(), 0 ) )
+ p_user->set_online( false );
- pthread_mutex_destroy( &mutex );
+ pthread_cond_wait( &(p_user->cond_message), &mutex );
+ }
+ while( p_user->get_online() );
- // if there is still a message to send:
- s_msg = p_user->get_mess( );
+ 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());
+ if ( ! s_msg.empty() )
+ send( i_sock, s_msg.c_str(), s_msg.size(), 0 );
- // remove the user from its room.
- string s_user( p_user->get_name() );
- string s_user_lowercase( p_user->get_lowercase_name() );
+ // remove the user from its room.
+ string s_user( p_user->get_name() );
+ string s_user_lowercase( p_user->get_lowercase_name() );
- room* p_room = p_user->get_room();
- p_room->del_elem( s_user_lowercase );
+ 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() + " "
+ // 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_room->msg_post( &s_msg );
- p_room->reload_onlineframe();
+ p_user->get_room()->msg_post( &s_msg );
+ p_user->get_room()->reload_onlineframe();
#ifdef VERBOSE
- cout << REMUSER << s_user << endl;
+ cout << REMUSER << s_user << endl;
#endif
- wrap::GCOL->add_user_to_garbage( p_user );
+ wrap::GCOL->add_user_to_garbage( p_user );
}
//*>>
int
-sock::_make_server_socket( int i_port )
+sock::make_server_socket( int i_port )
{
- size_t i_sock;
- struct sockaddr_in name;
+ 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 );
+ // 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);
+ if ( ++i_port > MAXPORT )
+ exit(1);
- wrap::system_message( SOCKERR );
+ wrap::system_message( SOCKERR );
- return _make_server_socket( i_port );
- }
+ 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;
+ // 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) );
+ 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 ( bind(i_sock, (struct sockaddr *) &name, sizeof (name)) < 0 )
+ {
- if ( ++i_port > MAXPORT )
- exit(1);
+ wrap::system_message( BINDERR );
- wrap::system_message( string(SOCKERR) + tool::int2string(i_port) );
+ if ( ++i_port > MAXPORT )
+ exit(1);
- // Rerun recursive.
- return _make_server_socket( i_port );
- }
+ wrap::system_message( string(SOCKERR) + tool::int2string(i_port) );
- wrap::system_message( SOCKCRT + string("localhost:") + tool::int2string(i_port) );
+ // Rerun recursive.
+ return make_server_socket( i_port );
+ }
- i_server_port = i_port;
- i_server_sock = i_sock;
+ wrap::system_message( SOCKCRT + string("localhost:") + tool::int2string(i_port) );
- return i_sock;
-}
+#ifdef NCURSES
+ mvprintw( NCUR_PORT_X,NCUR_PORT_Y, "Port: %d ", i_port);
+ refresh();
+#endif
-string
-sock::read_http_line(_socket *p_sock)
-{
- string s_line;
- int i_total = 0;
- int i_read = 0;
- char ch;
-
- do
- {
- i_read = _read(p_sock, &ch, sizeof(char));
-
- 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;
+ return i_sock;
}
+
int
-sock::read_http(_socket *p_sock, char *c_zbuf, int &i_postpayloadoffset)
+sock::read_write( int* p_sock )
{
- /*
- ** 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.empty()) {
- wrap::system_message(SOCKER4);
- 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() > READSOCK)
- /*
- ** Buffer overflow
- */
- s_line = s_line.substr(0, READSOCK);
-
- 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") {
- wrap::system_message(SOCKER4);
- return -1;
- }
+ int i_sock = *p_sock;
+ char c_req[READSOCK];
+ int i_bytes = read(i_sock, c_req, READSOCK);
- /*
- ** Get us to the Content-Length:
- */
- s_post_return += s_line;
- i_postpayloadoffset += s_line.length();
-
- for(x =0; x < MAXLINES; ++x)
+ if (i_bytes <= 0)
{
- 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.empty()) {
- wrap::system_message(SOCKER4);
- return -1;
+ wrap::system_message( READERR );
}
- 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 > READSOCK || z < 0) {
- wrap::system_message(SOCKER4);
- return -1;
- }
-
- /*
- ** We have MAXLINES to get to the blank line separating POST data.
- */
- for(x = 0; x < MAXLINES; ++x)
+ else
{
- s_line = read_http_line(p_sock);
- s_post_return += s_line;
+ // stores the request params.
+ map<string,string> map_params;
- i_postpayloadoffset += s_line.length();
- if(s_line == "\r\n")
- break;
- }
-
- /*
- ** funny business
- */
- if(x == MAXLINES) {
- wrap::system_message(SOCKER4);
- return -1;
- }
+ // get the s_rep ( s_html response which will be send imediatly to the client
+ struct sockaddr_in client;
+ size_t size = sizeof(client);
- for(x = 0; x < z; ++x)
- {
- if(_read(p_sock,&ch,sizeof(ch)) != 1) {
- wrap::system_message(SOCKER4);
- return -1;
- }
-
- s_post_return += ch;
- }
-
- if(s_post_return.length() > READSOCK) {
- wrap::system_message(SOCKER4);
- return -1;
- }
-
- memcpy(c_zbuf,s_post_return.c_str(),s_post_return.length());
- return s_post_return.length();
- }
-}
-
-int
-sock::read_write(_socket* p_sock)
-{
- int i_postpayloadoffset;
-
-#ifdef OPENSSL
- int i_sock = p_sock->i_sock;
+#ifdef CYGWIN
+ getpeername( i_sock, (struct sockaddr *)&client, (int*)&size);
#else
- int i_sock = *p_sock;
+ getpeername( i_sock, (struct sockaddr *)&client, &size);
#endif
- char c_req[READSOCK+1];
- memset(c_req, 0, sizeof(c_req));
+ map_params["REMOTE_ADDR"] = inet_ntoa(client.sin_addr);
+ //map_params["REMOTE_PORT"] = ntohs(client.sin_port);
- int i_bytes = read_http(p_sock, c_req, i_postpayloadoffset);
+ string s_rep = req_parser->parse( i_sock, string( c_req ), map_params );
- if (i_bytes <= 0)
- {
- wrap::system_message( READERR );
-
- }
+#ifdef LOGGING
+ log_daemon->log_access(map_params);
+#endif
- else
- {
- // stores the request params.
- map<string,string> map_params;
+ // send s_rep to the client.
+ send(i_sock, s_rep.c_str(), s_rep.size(), 0);
- // get the s_rep ( s_html response which will be send imediatly to the client
- struct sockaddr_in client;
- size_t size = sizeof(client);
+ // dont need those vals anymore.
+ map_params.clear();
- getpeername(i_sock, (struct sockaddr *)&client, &size);
+ shutdown( i_sock, 2 );
+ close ( i_sock );
- unsigned &s_addr = client.sin_addr.s_addr;
- if ( (map_params["REMOTE_ADDR"] = ip_cache_map->get_elem(s_addr)) == "" )
- {
- map_params["REMOTE_ADDR"] = string(inet_ntoa(client.sin_addr));
- ip_cache_map->set_elem(map_params["REMOTE_ADDR"], s_addr);
- wrap::system_message(SOCKCAC+map_params["REMOTE_ADDR"]);
+ return 0;
}
- string s_rep = req_parser->parse(p_sock, string(c_req), map_params, i_postpayloadoffset);
+ shutdown( i_sock, 2 );
+ close ( i_sock );
-#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;
+ return 1;
}
-void
-sock::_main_loop_init()
+int
+sock::start()
{
- wrap::system_message(SOCKUNS);
-}
+ wrap::system_message( SOCKSRV );
-#ifdef OPENSSL
-// This method is virtual, and is overloaded by sslsock!
-bool
-sock::_main_loop_do_ssl_stuff(int &i_new_sock)
-{
- return 0;
-}
+#ifdef NCURSES
+ print_hits();
+ thrd_pool->print_pool_size();
#endif
-_socket*
-sock::_create_container(int &i_sock)
-{
- _socket* p_sock = new _socket;
+ int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
+ int i_sock, i;
+ fd_set active_fd_set, read_fd_set;
+ struct sockaddr_in clientname;
+ size_t size;
-#ifdef OPENSSL
- p_sock->i_sock = i_sock;
-#else
- *p_sock = i_sock;
-#endif
- return p_sock;
-}
-int
-sock::start()
-{
- wrap::system_message( SOCKSRV );
- int i_sock = i_server_sock;
-
- 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);
-
- 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)
+ // create the server socket and set it up to accept connections.
+ i_sock = make_server_socket ( i_port );
+
+ if (listen (i_sock, 1) < 0)
{
- wrap::system_message( SELCERR );
- exit(EXIT_FAILURE);
+ wrap::system_message( LISTERR );
+ 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)
+ wrap::system_message( SOCKRDY );
+
+ // initialize the set of active sockets.
+ FD_ZERO (&active_fd_set);
+ FD_SET (i_sock, &active_fd_set);
+
+ while( b_run )
+ {
+ // block until input arrives on one or more active sockets.
+ read_fd_set = active_fd_set;
+ if (select (FD_SETSIZE, &read_fd_set, NULL, NULL, NULL) < 0)
{
- ++i_req; // connection request on original socket.
+ wrap::system_message( SELCERR );
- int i_new_sock;
- size = sizeof(clientname);
- i_new_sock = accept(i_sock, (struct sockaddr *) &clientname, &size);
+ exit( EXIT_FAILURE );
+ }
-#ifdef OPENSSL
- if (_main_loop_do_ssl_stuff(i_new_sock))
- continue;
+ // 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);
+#ifdef CYGWIN
+ i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, (int*)&size);
+#else
+ i_new_sock = accept (i_sock, (struct sockaddr *) &clientname, &size);
#endif
+ if (i_new_sock < 0)
+ {
+ wrap::system_message( ACCPERR );
+ close(i_new_sock);
+ }
+
+ else
+ {
#ifdef VERBOSE
- wrap::system_message(NEWREQU
- + tool::int2string(i_req) + " "
- + string(inet_ntoa( clientname.sin_addr )) + ":"
- + tool::int2string(ntohs ( clientname.sin_port ))
- );
+ 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
- {
- _socket *p_sock = _create_container(i);
- pool::run( (void*) p_sock );
- FD_CLR( i, &active_fd_set );
- }
- }
- }
+ FD_SET (i_new_sock, &active_fd_set);
+ }
+ }
+
+ else
+ {
+ int *p_sock = new int;
+ *p_sock = i;
+ thrd_pool->run( (void*) p_sock );
+ FD_CLR( i, &active_fd_set );
+ }
+ }
+ }
}
+#ifdef NCURSES
void
-sock::clean_ipcache()
+sock::print_hits()
{
- int i_ipcachesize = wrap::CONF->get_int("httpd.ipcachesize");
- int i_currentsize = ip_cache_map->size();
-
- if ( i_currentsize > 0 && (i_ipcachesize == 0 || i_ipcachesize <= i_currentsize) )
- {
- wrap::system_message(
- SOCKCA2+tool::int2string(i_currentsize)+","+tool::int2string(i_ipcachesize)+")");
- }
+ 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
index 5b8db2f..7023be5 100644..100755
--- a/src/sock/sock.h
+++ b/src/sock/sock.h
@@ -1,102 +1,68 @@
-/*:*
- *: File: ./src/sock/sock.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef SOCK_H
#define SOCK_H
#include <queue>
-#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netdb.h>
+#include "../thrd/pool.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
+class sock
{
-protected:
-#ifdef LOGGING
+private:
+ // total number of server requests.
+ unsigned long long i_req;
- logd *log_daemon; // the log daemon
+ bool b_run; // true while socket manager is running.
+ reqp *req_parser; // parses the http requests from clients.
+ pool *thrd_pool; // the thread pool.
+#ifdef LOGGING
+ logd *log_daemon; // the log daemon
#endif
- shashmap< string, unsigned, self_hash<unsigned>, equals_allocator<unsigned> > *ip_cache_map;
-
- int i_server_sock;
- int i_server_port;
-
- unsigned long long i_req; // total number of server requests.
- 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;
+ char *c_buffer; // char buffer!
+ int i_threads; // total amount of threads inside the thread pool.
- static string inet_ntoa_callback(void* p_void);
+ pthread_mutex_t mut_hits;
public:
- // creates a server socket.
- int read_http(_socket *p_sock, char *c_zbuf, int &i_payloadoffset);
- string read_http_line(_socket *p_sock);
+ // creates a server socket.
+ int make_server_socket( int i_port );
- // small inline methods:
+ // small inline methods:
+ bool get_run() const
+ {
+ return b_run;
+ }
- string dump() { return ip_cache_map->dump(); }
- bool get_server_() const { return b_run; }
- bool get_run() const { return b_run; }
- bool set_run( bool b_run ) { this->b_run = b_run; }
+ bool set_run( bool b_run )
+ {
+ this->b_run = b_run;
+ }
- sock();
+ sock( );
+ ~sock( );
- int read_write(_socket* p_sock);
+ int read_write( int* p_sock );
+ int start();
- int start();
- void clean_ipcache();
+ // the chat stream there all the chat messages will sent through.
+ static void chat_stream( int i_sock, user* p_user, map<string,string> &map_params ); //<<
- // the chat stream there all the chat messages will sent through.
- void chat_stream(_socket* p_sock, user* p_user, map<string,string> &map_params); //<<
- virtual int _send(_socket *p_sock, const char *sz, int len);
- virtual int _read(_socket *p_sock, char *sz, int len);
- virtual int _close(_socket *p_sock);
- virtual void _main_loop_init();
-
-#ifdef OPENSSL
- virtual bool _main_loop_do_ssl_stuff(int& i_new_sock);
+#ifdef NCURSES
+ void print_hits();
#endif
-
- virtual _socket* _create_container(int& i_sock);
- virtual int _make_server_socket(int i_port);
};
+
#endif
diff --git a/src/stats.cpp b/src/stats.cpp
new file mode 100644
index 0000000..95d8ab1
--- /dev/null
+++ b/src/stats.cpp
@@ -0,0 +1,149 @@
+#ifndef STATS_CPP
+#define STATS_CPP
+
+#include "stats.h"
+#include "tool/tool.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/stats.h b/src/stats.h
new file mode 100644
index 0000000..608232e
--- /dev/null
+++ b/src/stats.h
@@ -0,0 +1,48 @@
+#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/thrd/pool.cpp b/src/thrd/pool.cpp
index 4574620..efea948 100644..100755
--- a/src/thrd/pool.cpp
+++ b/src/thrd/pool.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/thrd/pool.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef POOL_CPP
#define POOL_CPP
@@ -29,146 +5,224 @@
using namespace std;
-int pool::i_num_avail_threads;
-int pool::i_num_total_threads;
-
-int pool::i_max_queue_size;
-int pool::i_cur_queue_index;
-int pool::i_free_queue_index;
-
-task** pool::queue_tasks;
+int pool::i_thrd_used = 0;
-pthread_mutex_t pool::mut_threads;
-pthread_mutex_t pool::mut_queue_tasks;
-pthread_mutex_t pool::mut_num_avail_threads;
-pthread_cond_t pool::cond_new_task;
+pool::pool()
+{
+ i_thrd_pool_size = tool::string2int( wrap::CONF->get_elem( "httpd.thread.initpoolsize" ) );
+ i_thrd_pool_queue = tool::string2int( wrap::CONF->get_elem( "httpd.thread.queuesize" ) );
+ tpool_init( &thread_pool, i_thrd_pool_size, i_thrd_pool_queue);
+}
void
-pool::init()
+pool::tpool_init( tpool_t *tpoolp, int num_worker_threads, int max_queue_size)
{
- 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);
+ int i, rtn;
+ tpool_t tpool;
- i_num_total_threads = i_cur_queue_index = i_free_queue_index = 0;
- i_num_avail_threads = tool::string2int( wrap::CONF->get_elem( "httpd.thread.initpoolsize" ) );
- i_max_queue_size = tool::string2int( wrap::CONF->get_elem( "httpd.thread.maxqueuesize" ) );
+ // allocate a pool data structure
+ if (( tpool = (tpool_t) malloc( sizeof( struct tpool ) ) ) == 0 )
+ {
+ wrap::system_message( POOLERR );
+ exit(-1);
+ }
- queue_tasks = new task*[i_max_queue_size];
- for (int i = 0; i < i_max_queue_size; ++i)
- queue_tasks[i] = NULL;
+ // initialize th fields
+ tpool->num_threads = num_worker_threads;
+ tpool->max_queue_size = max_queue_size;
- increase_pool(i_num_avail_threads);
-}
+ if ( ( tpool->threads = (pthread_t*) malloc( sizeof(pthread_t)*num_worker_threads ) ) == 0 )
+ {
+ wrap::system_message( POOLERR );
+ exit(-1);
+ }
-void
-pool::destroy()
-{
- pthread_mutex_lock(&mut_queue_tasks);
- delete [] queue_tasks;
- 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);
-}
+ tpool->cur_queue_size = 0;
+ tpool->queue_head = 0;
+ tpool->queue_tail = 0;
-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" ) );
+ if ( ( rtn = pthread_mutex_init( &(tpool->queue_lock), 0 ) ) != 0 )
+ {
+ string s_err( "pthread_mutex_init " );
+ s_err.append( strerror( rtn ) );
- 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( s_err );
+
+ exit(-1);
+ }
+
+ else if ( ( rtn = pthread_cond_init( &(tpool->queue_not_empty), 0 ) ) != 0 )
{
- wrap::system_message(POOLER2+tool::int2string(i_max_pool_size)+")");
- wrap::system_message(POOLER1+tool::int2string(i)+")");
- return i;
+ string s_err( "pthread_cond_init (1): " );
+ s_err.append( strerror( rtn ) );
+
+ wrap::system_message( s_err );
+
+ exit(1);
}
- ++i_num_total_threads;
- pthread_t p_pthread;
- pthread_create(&p_pthread, 0, wait_for_task, (void*) p_pthread );
- }
+ else if ( ( rtn = pthread_cond_init( &(tpool->queue_not_full), 0 ) ) != 0 )
+ {
+ string s_err( "pthread_cond_init (2): " );
+ s_err.append( strerror( rtn ) );
+
+ wrap::system_message( s_err );
+
+ exit(1);
+ }
+
+ else if ( ( rtn = pthread_cond_init( &(tpool->queue_empty), 0 ) ) != 0 )
+ {
+ string s_err( "pthread_mutex_init " );
+ s_err.append( strerror( rtn ) );
- return i_num;
+ wrap::system_message( s_err );
+
+ exit(1);
+ }
+
+ // create threads
+ for ( i = 0; i < num_worker_threads; i++ )
+ pthread_create( &(tpool->threads[i]) , 0, tpool_thread, (void*)tpool );
+
+ *tpoolp = tpool;
}
void*
-pool::wait_for_task( void* p_void )
+pool::tpool_thread( void* p_void )
{
- for (;;)
- {
- pthread_mutex_lock(&mut_threads);
- pthread_cond_wait(&cond_new_task, &mut_threads);
+ tpool_t tpool = (tpool_t) p_void;
+ tpool_work_t *my_workp;
- pthread_mutex_lock(&mut_num_avail_threads);
- if ( --i_num_avail_threads < 5 )
+ for( ;; )
{
- int i_size = 9 - i_num_avail_threads;
- i_size = increase_pool(i_size);
- i_num_avail_threads += i_size;
- }
- pthread_mutex_unlock(&mut_num_avail_threads);
+ pthread_mutex_lock( &(tpool->queue_lock) );
+
+ while ( tpool->cur_queue_size == 0)
+ pthread_cond_wait( &(tpool->queue_not_empty), &(tpool->queue_lock) );
+
+ my_workp = tpool->queue_head;
+ tpool->cur_queue_size--;
+
+ if ( tpool->cur_queue_size == 0)
+ tpool->queue_head = tpool->queue_tail = 0;
- pthread_mutex_lock(&mut_queue_tasks);
- task* p_task = queue_tasks[i_cur_queue_index];
- queue_tasks[i_cur_queue_index++] = NULL;
- i_cur_queue_index %= i_max_queue_size;
- pthread_mutex_unlock(&mut_queue_tasks);
+ else
+ tpool->queue_head = my_workp->next;
- pthread_mutex_unlock(&mut_threads);
+ if ( tpool->cur_queue_size == ( tpool->max_queue_size - 1 ) )
+ pthread_cond_signal( &(tpool->queue_not_full) );
- (*(p_task->p_func))(p_task->p_void);
- delete p_task;
+ if ( tpool->cur_queue_size == 0 )
+ pthread_cond_signal( &(tpool->queue_empty) );
- pthread_mutex_lock(&mut_num_avail_threads);
- i_num_avail_threads++;
- pthread_mutex_unlock(&mut_num_avail_threads);
- }
+ pthread_mutex_unlock( &(tpool->queue_lock) );
- return 0;
+ (*(my_workp->routine))(my_workp->p_void);
+
+ pthread_mutex_lock( &(tpool->queue_lock) );
+ --i_thrd_used;
+#ifdef NCURSES
+ print_threads(i_thrd_used);
+#endif
+ pthread_mutex_unlock( &(tpool->queue_lock) );
+
+ //free( (void*) my_workp );
+ free( my_workp );
+ }
}
-void
-pool::run(void* p_void)
+void pool::run_func( void *p_void )
+{
+ int* p_sock = (int*)p_void;
+ wrap::SOCK->read_write( p_sock );
+ delete p_sock;
+}
+
+int
+pool::tpool_add_work( tpool_t tpool, void(*routine)(void*), void* p_void ) ///
{
- pthread_mutex_lock(&mut_queue_tasks);
- queue_tasks[i_free_queue_index++] = new task(run_func, p_void);
- i_free_queue_index %= i_max_queue_size;
+ tpool_work_t *workp;
+ pthread_mutex_lock( &(tpool->queue_lock) );
+
+ if ( ++i_thrd_used == tpool->num_threads )
+ {
+ int i_max_pool_size = tool::string2int( wrap::CONF->get_elem( "httpd.thread.maxpoolsize" ) );
+ if ( i_max_pool_size != 0 && i_thrd_used > i_max_pool_size )
+ {
+ wrap::system_message(POOLER2+tool::int2string(i_thrd_used)+")");
+ }
+
+ else
+ {
+ int i_size = tpool->num_threads * 2;
+
+ wrap::system_message(POOLFLL+tool::int2string(i_size)+")");
+
+ tpool->threads = (pthread_t*)realloc((void*)tpool->threads, sizeof(pthread_t)*tpool->num_threads);
+
+ for ( int i = tpool->num_threads; i < i_size; ++i )
+ pthread_create( &(tpool->threads[i]) , 0, tpool_thread, (void*)tpool );
+
+ i_thrd_pool_size = tpool->num_threads = i_size;
+#ifdef NCURSES
+ print_pool_size();
+#endif
+ }
+ }
+
+#ifdef NCURSES
+ print_threads(i_thrd_used);
+#endif
+
+ while (tpool->cur_queue_size == tpool->max_queue_size)
+ pthread_cond_wait( &(tpool->queue_not_full), &(tpool->queue_lock) );
+
+ // allocate work structure:
+ workp = (tpool_work_t*) malloc( sizeof( tpool_work_t ) );
- pthread_mutex_unlock(&mut_queue_tasks);
+ workp->routine = routine;
+ workp->p_void = p_void;
+ workp->next = 0;
- pthread_cond_signal(&cond_new_task);
+ if (tpool->cur_queue_size == 0 )
+ {
+ tpool->queue_tail = tpool->queue_head = workp;
+ }
+
+ else
+ {
+ (tpool->queue_tail)->next = workp;
+ tpool->queue_tail = workp;
+ }
+
+ pthread_cond_signal( &tpool->queue_not_empty );
+ tpool->cur_queue_size++;
+ pthread_mutex_unlock( &(tpool->queue_lock) );
+
+ return 0;
}
+#ifdef NCURSES
void
-pool::run_func(void *p_void)
+pool::print_threads(int i_thrd_used)
{
- _socket* p_sock = static_cast<_socket*>(p_void);
- wrap::SOCK->read_write(p_sock);
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_POOL_RUNNING_X,NCUR_POOL_RUNNING_Y, "In use: %d ", i_thrd_used);
+ refresh();
+ }
}
-bool
-pool::allow_user_login()
+void
+pool::print_pool_size()
{
- 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 )
+ if ( wrap::NCUR->is_ready() )
{
- pthread_mutex_unlock(&mut_num_avail_threads);
- return false;
- }
- }
- pthread_mutex_unlock(&mut_num_avail_threads);
-
- return true;
+ mvprintw( NCUR_POOL_SIZE_X,NCUR_POOL_SIZE_Y, "Size: %d %d", i_thrd_pool_size, i_thrd_pool_queue );
+ refresh();
+ }
}
+#endif
#endif
diff --git a/src/thrd/pool.h b/src/thrd/pool.h
index 87b73c2..c4dcd21 100644..100755
--- a/src/thrd/pool.h
+++ b/src/thrd/pool.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/thrd/pool.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef POOL_H
@@ -29,46 +5,60 @@
using namespace std;
-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;
- }
-};
-
class pool
{
private:
- friend class thro;
+ static int i_thrd_used;
+ typedef struct tpool_work {
+ void (*routine)(void*); ///
+ void *p_void;
+ struct tpool_work *next;
+ }
+ tpool_work_t;
- static pthread_mutex_t mut_threads;
- static pthread_mutex_t mut_queue_tasks;
- static pthread_mutex_t mut_num_avail_threads;
- static pthread_cond_t cond_new_task;
+ typedef struct tpool
+ {
+ // pool characteristics:
+ int num_threads;
+ int max_queue_size;
- static int i_num_avail_threads;
- static int i_num_total_threads;
+ // pool state
+ pthread_t *threads;
+ int cur_queue_size;
- static int i_max_queue_size;
- static int i_cur_queue_index;
- static int i_free_queue_index;
- static task** queue_tasks;
+ tpool_work_t *queue_head;
+ tpool_work_t *queue_tail;
- static int increase_pool(int i_num);
- static void* wait_for_task(void *p_void);
- static void run_func(void *p_void);
+ pthread_mutex_t queue_lock;
+ pthread_cond_t queue_not_empty;
+ pthread_cond_t queue_not_full;
+ pthread_cond_t queue_empty;
+ }
+ *tpool_t;
+
+ int i_thrd_pool_size;
+ int i_thrd_pool_queue;
+
+ tpool_t thread_pool;
+
+ void tpool_init( tpool_t *tpoolp, int num_worker_threads, int max_queue_size);
+ int tpool_add_work( tpool_t tpool, void(*routine)(void*), void* p_void );
+ static void* tpool_thread( void *p_void);
+ static void run_func( void *p_void );
public:
- static void init();
- static void destroy();
+ pool();
- static void run(void* p_void);
- static bool allow_user_login();
+ // inline (speed)!
+ void run( void *p_void )
+ {
+ tpool_add_work( thread_pool, run_func, p_void );
+ }
+
+#ifdef NCURSES
+ void print_pool_size();
+ static void print_threads(int i_thrd_used);
+#endif
};
#endif
diff --git a/src/thrd/thro.cpp b/src/thrd/thro.cpp
index 1d94540..739ba0e 100644
--- a/src/thrd/thro.cpp
+++ b/src/thrd/thro.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/thrd/thro.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef THRO_CPP
#define THRO_CPP
@@ -30,38 +6,39 @@
using namespace std;
thro::thro()
-{}
+{
+}
thro::~thro()
-{}
+{
+}
void
thro::run()
{
- void *p_void;
- run( p_void );
+ 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 );
+ elem.p_thro = this;
+ elem.p_void = p_void;
+ pthread_create( &pthread, NULL, start_, &elem );
}
void*
thro::start_( void *p_void )
{
- elements *e = (elements*) p_void;
- e->p_thro->start( e->p_void );
+ elements *e = (elements*) p_void;
+ e->p_thro->start( e->p_void );
}
void
thro::start( void *p_void )
{
- wrap::system_message( THRDSTR );
+ wrap::system_message( THRDSTR );
}
#endif
diff --git a/src/thrd/thro.h b/src/thrd/thro.h
index b7dbe1d..9ad1e3e 100644
--- a/src/thrd/thro.h
+++ b/src/thrd/thro.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/thrd/thro.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef THRO_H
@@ -32,23 +8,21 @@ using namespace std;
class thro
{
private:
- pthread_t pthread;
+ pthread_t pthread;
- struct elements
- {
- thro *p_thro;
- void *p_void;
- }
- elem;
+ struct elements {
+ thro *p_thro;
+ void *p_void;
+ } elem;
- static void *start_( void *p_void );
+ static void* start_( void *p_void );
public:
- thro( );
- ~thro( );
- void run();
- void run( void *p_void );
- virtual void start( void *p_void );
+ 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
index 0a923f1..d00bafe 100644..100755
--- a/src/time/timo.cpp
+++ b/src/time/timo.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/time/timo.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef TIMO_CPP
#define TIMO_CPP
@@ -31,32 +7,32 @@ using namespace std;
timo::timo()
{
- pthread_mutex_init( &mut_t_time, NULL );
+ pthread_mutex_init( &mut_t_time, NULL );
}
timo::~timo()
{
- pthread_mutex_destroy( &mut_t_time );
+ pthread_mutex_destroy( &mut_t_time );
}
double
timo::get_last_activity( )
{
- double d_ret;
+ double d_ret;
- pthread_mutex_lock ( &mut_t_time );
- d_ret = wrap::TIMR->get_time_diff( t_time );
- pthread_mutex_unlock( &mut_t_time );
+ pthread_mutex_lock ( &mut_t_time );
+ d_ret = wrap::TIMR->get_time_diff( t_time );
+ pthread_mutex_unlock( &mut_t_time );
- return d_ret;
+ return d_ret;
}
void
timo::renew_timeout( )
{
- pthread_mutex_lock ( &mut_t_time );
- time( &t_time );
- pthread_mutex_unlock( &mut_t_time );
+ 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
index ad4012e..4eaecf8 100644..100755
--- a/src/time/timo.h
+++ b/src/time/timo.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/time/timo.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef TIMO_H
@@ -32,15 +8,15 @@ using namespace std;
class timo // timeout class
{
protected:
- time_t t_time; // last activity time.
- pthread_mutex_t mut_t_time;
+ time_t t_time; // last activity time.
+ pthread_mutex_t mut_t_time;
public:
- timo( );
- ~timo( );
+ timo( );
+ ~timo( );
- double get_last_activity();
- virtual void renew_timeout();
+ double get_last_activity();
+ void renew_timeout();
};
#endif
diff --git a/src/time/timr.cpp b/src/time/timr.cpp
index 65ba780..40240c3 100644..100755
--- a/src/time/timr.cpp
+++ b/src/time/timr.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/time/timr.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef TIMR_CPP
#define TIMR_CPP
@@ -39,7 +15,7 @@ timr::timr()
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") );
+ 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";
@@ -56,47 +32,56 @@ timr::~timr()
bool
timr::get_timer_active() const
{
- return b_timer_active;
+ return b_timer_active;
}
int
-timr::get_offset()
+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;
+ 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 );
+ wrap::system_message( TIMERTH );
- time_t clock_start;
- time_t clock_now;
+#ifdef NCURSES
+ print_time( );
+#endif
- time( &clock_start );
- tm time_start = *localtime( &clock_start );
- tm time_now;
+ time_t clock_start;
+ time_t clock_now;
- while ( get_timer_active() )
- {
- // sleep a second!
- usleep( 1000000 );
+ time( &clock_start );
+ tm time_start = *localtime( &clock_start );
+ tm time_now;
- // get the current time!
- time( &clock_now );
+ while ( get_timer_active() )
+ {
+ // sleep a second!
+ usleep( 1000000 );
- time_now = *localtime( &clock_now );
+ // get the current time!
+ time( &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 );
+ time_now = *localtime( &clock_now );
- // run every minute:
- if ( time_now.tm_sec == 0 )
- {
+ // 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
@@ -108,87 +93,99 @@ timr::start( void *v_ptr )
wrap::CHAT->check_timeout( p_timeout_settings );
delete p_timeout_settings;
- string s_ping = "<!-- PING! //-->\n";
+ 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:
+ //*>>
+
+ // 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();
- }
+ wrap::GCOL->remove_garbage(); //<<
+
+ // run every hour
+ if ( time_now.tm_hour % 60 == 0 )
+ {
+ // 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::set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours )
+timr::print_time( )
{
+ if ( !wrap::NCUR->is_ready() )
+ return;
- int i_hours = (int) d_uptime / 3600;
- int i_minutes = (int) d_uptime / 60;
+ 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
- while ( i_minutes >= 60 )
- i_minutes -= 60;
+void
+timr::set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours )
+{
- while ( d_uptime >= 60 )
- d_uptime -= 60;
+ int i_hours = (int) d_uptime / 3600;
+ int i_minutes = (int) d_uptime / 60;
- // Calculate offset time
- i_cur_hours += get_offset();
+ while ( i_minutes >= 60 )
+ i_minutes -= 60;
- for ( int i = 24-i_cur_hours; i < 0; i = 24-i_cur_hours )
- i_cur_hours =- i;
+ while ( d_uptime >= 60 )
+ d_uptime -= 60;
- if (i_cur_hours == 24)
- i_cur_hours = 0;
+ // Calculate offset time
+ i_cur_hours += get_offset();
- 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 );
+ for ( int i = 24-i_cur_hours; i < 0; i = 24-i_cur_hours )
+ i_cur_hours =- i;
- 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 );
+ 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;
- }
+ if ( s_time.length() == 1 )
+ {
+ string s_new = "0" + s_time;
+ return s_new;
+ }
- return s_time;
+ return s_time;
}
double
timr::get_time_diff( time_t &clock_diff )
{
- time_t clock_now;
- time( &clock_now );
+ time_t clock_now;
+ time( &clock_now );
- return difftime(clock_now, clock_diff);
+ return difftime(clock_now, clock_diff);
}
#endif
diff --git a/src/time/timr.h b/src/time/timr.h
index 0460cba..46234b3 100644..100755
--- a/src/time/timr.h
+++ b/src/time/timr.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/time/timr.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#include "../incl.h"
#ifndef TIMR_H
@@ -36,48 +12,52 @@ 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;
-
+ 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();
+ timr();
+ ~timr();
- bool get_timer_active() const;
- void start( void *v_ptr );
+ bool get_timer_active() const;
+ void start( void *v_ptr );
- 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;
- }
+#ifdef NCURSES
+ void print_time();
+#endif
- int get_offset();
- double get_time_diff( time_t &clock_diff );
+ 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
index 13feaff..ae48d5f 100644
--- a/src/tool/dir.cpp
+++ b/src/tool/dir.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/tool/dir.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef DIR_CPP
#define DIR_CPP
@@ -31,60 +7,60 @@ using namespace std;
dir::dir()
{
- b_open = false;
+ b_open = false;
}
dir::~dir()
{
- vec_dir.clear();
- close_dir();
+ vec_dir.clear();
+ close_dir();
}
bool
dir::open_dir( char *c_dir )
{
- string s_dir( c_dir );
- return open_dir( s_dir );
+ string s_dir( c_dir );
+ return open_dir( s_dir );
}
bool
dir::open_dir( string &s_dir )
{
- if ( b_open )
- return false;
+ if ( b_open )
+ return false;
- p_d = opendir( s_dir.c_str() );
+ p_d = opendir( s_dir.c_str() );
- if ( p_d == NULL )
- return false; // Could not open dir.
+ if ( p_d == NULL )
+ return false; // Could not open dir.
- b_open = true;
+ b_open = true;
- return true; // Could open dir with success.
+ return true; // Could open dir with success.
}
void
dir::close_dir()
{
- if ( b_open && p_d != NULL )
- {
- closedir( p_d );
- b_open = false;
- }
+ 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 ) );
+ if ( p_d != NULL )
+ while( p_ep = readdir( p_d ) )
+ vec_dir.push_back( string( p_ep->d_name ) );
}
-vector<string>
+vector<string>
dir::get_dir_vec()
{
- return vec_dir;
+ return vec_dir;
}
#endif
diff --git a/src/tool/dir.h b/src/tool/dir.h
index 144404d..22ec510 100644
--- a/src/tool/dir.h
+++ b/src/tool/dir.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/tool/dir.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef DIR_H
#define DIR_H
@@ -40,20 +16,20 @@ using namespace std;
class dir
{
private:
- bool b_open;
- DIR *p_d;
- struct dirent *p_ep;
- vector<string> vec_dir;
+ 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();
+ 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
index 7e793bf..dec9bdb 100644
--- a/src/tool/tool.cpp
+++ b/src/tool/tool.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/tool/tool.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef TOOL_CPP
#define TOOL_CPP
@@ -38,136 +14,135 @@
bool
tool::is_alpha_numeric( string &s_digit )
{
- const char *p_digit = s_digit.c_str();
- int i_len = strlen( p_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++;
- }
+ for( int i=0; i<i_len; i++ )
+ {
+ if ( ! isalnum( *p_digit ) )
+ return false;
+ p_digit++;
+ }
- return true;
+ return true;
}
string
tool::int2string( int i_int )
{
- char buf[64];
- sprintf(buf, "%d", i_int);
- return buf;
+ char buf[64];
+ sprintf(buf, "%d", i_int);
+ return buf;
}
long
tool::unixtime()
{
- time_t clock;
- return (long) time( &clock );
+ 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;
+ 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("");
+ string s_tmp("");
- for( int i = 0; i < s_str.size() ;i++ )
- s_tmp = s_tmp + (char) tolower( s_str.at(i) );
+ for( int i = 0; i < s_str.size() ;i++ )
+ s_tmp = s_tmp + (char) tolower( s_str.at(i) );
- return s_tmp;
+ 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;");
+ int i_pos;
- if( (i_pos = p_str->find("<", 0)) == string::npos )
+ 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);
+ 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();
+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 );
- }
+ 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 );
+ list_ret.push_back( s_string );
- return list_ret;
+ return list_ret;
}
string
tool::trim( string s_str )
{
- if( s_str.empty() )
- return s_str;
+ if( s_str.empty() )
+ return s_str;
- char c_cur = s_str[0];
- int i_pos = 0;
+ 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];
- }
+ // 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()];
+ // 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];
- }
+ 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;
+ return s_str;
}
char*
@@ -175,8 +150,7 @@ tool::clean_char( char* c_str )
{
// Ralf:
for ( char* c_pos = c_str; *c_pos != '\0'; ++c_pos )
- if ( iscntrl(*c_pos) )
- *c_pos = ' ';
+ if ( iscntrl(*c_pos) ) *c_pos = ' ';
return c_str;
}
@@ -184,77 +158,80 @@ tool::clean_char( char* c_str )
string
tool::replace( string s_string, string s_search, string s_replace )
{
- unsigned i_pos[2];
+ 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();
- }
+ 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;
+ return s_string;
}
string
tool::get_extension( string s_file )
{
- int i_pos = s_file.find_last_of(".");
+ 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]);
+ 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 to_lower(s_ext);
+ }
- return "";
+ return "";
}
char*
tool::int2char( int i_int )
{
- char *buf = new char[64];
- sprintf(buf, "%d", i_int);
- return buf;
+ 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)
+ 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 )
{
- if(fgets(buf, READBUF, file) == NULL)
- break;
+ wrap::system_message( SHELLER );
+ }
- switch (m_method)
- {
- default:
- s_ret.append("\n" + string(buf));
+ 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);
- }
+ pclose(file);
+ }
- return s_ret;
+ return s_ret;
}
#endif
diff --git a/src/tool/tool.h b/src/tool/tool.h
index df8c3f7..b296514 100644
--- a/src/tool/tool.h
+++ b/src/tool/tool.h
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/tool/tool.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef TOOL_H
#define TOOL_H
@@ -34,20 +10,20 @@ 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();
+ 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
index c9f0ea8..a0e1443 100644..100755
--- a/src/wrap.cpp
+++ b/src/wrap.cpp
@@ -1,27 +1,3 @@
-/*:*
- *: File: ./src/wrap.cpp
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef WRAP_CPP
#define WRAP_CPP
@@ -30,108 +6,39 @@
using namespace std;
//<<*
-chat* wrap::CHAT = NULL;
+chat* wrap::CHAT;
#ifdef DATABASE
-data* wrap::DATA = NULL;
+data* wrap::DATA;
#endif
-gcol* wrap::GCOL = NULL;
-sman* wrap::SMAN = NULL;
-modl* wrap::MODL = NULL;
+gcol* wrap::GCOL;
+sman* wrap::SMAN;
+modl* wrap::MODL;
//*>>
-conf* wrap::CONF = NULL;
-html* wrap::HTML = NULL;
+conf* wrap::CONF;
+html* wrap::HTML;
#ifdef LOGGING
-logd* wrap::LOGD = NULL;
+logd* wrap::LOGD;
+#endif
+#ifdef NCURSES
+ncur* wrap::NCUR;
#endif
-sock* wrap::SOCK = NULL;
-stats* wrap::STAT = NULL;
-timr* wrap::TIMR = NULL;
-dynamic_wrap* wrap::WRAP = NULL;
+sock* wrap::SOCK;
+stats* wrap::STAT;
+timr* wrap::TIMR;
+dynamic_wrap* wrap::WRAP;
void
wrap::system_message( string s_message )
{
-#ifdef SERVMSG
- cout << s_message << endl;
+#ifdef NCURSES
+ wrap::NCUR->print( s_message );
#endif
-
-#ifdef LOGGING
-
- LOGD->log_simple_line( s_message + "\n" );
+#ifdef SERVMSG
+ cout << s_message << endl;
#endif
-}
-
-void
-wrap::init_wrapper(map<string,string>* p_main_loop_params)
-{
- // Init the dynamic wrapper (is needed to pass all wrapped objects through a single pointer).
- WRAP = new dynamic_wrap;
-
- // Init the config manager.
- WRAP->CONF = CONF = new conf( CONFILE, p_main_loop_params );
- delete p_main_loop_params,
-
- // Init the statistic manager.
- WRAP->STAT = STAT = new stats;
-
- // Init the html-template manager.
- WRAP->HTML = HTML = new html;
-
#ifdef LOGGING
- // Init the system message logd
- WRAP->LOGD = LOGD = new logd( CONF->get_elem("httpd.logging.systemfile"),
- CONF->get_elem("httpd.logging.systemlines") );
-#endif
-
- //<<*
- // Init the session manager.
- WRAP->SMAN = SMAN = new sman;
- //*>>
- // Init the socket manager.
- int i_port = tool::string2int( wrap::CONF->get_elem( "httpd.serverport" ) );
-
-#ifndef OPENSSL
-
- WRAP->SOCK = SOCK = new sock;
-#else
-
- WRAP->SOCK = SOCK = new sslsock;
-#endif
-
- // create the server socket and set it up to accept connections.
- if(SOCK->_make_server_socket ( i_port ) <= 0)
- {
- system_message(SOCKER1);
- exit(-1);
- }
-
- pool::init();
-
- //<<*
- // Init the chat manager.
- WRAP->CHAT = CHAT = new chat;
- //*>>
-
- // Init the system timer.
- WRAP->TIMR = TIMR = new timr;
-
- //<<*
- // Init the module-loader manager.
- WRAP->MODL = MODL = new modl;
-
- // Init the garbage collector
- WRAP->GCOL = GCOL = new gcol;
-
- // Init the data manager.
-#ifdef DATABASE
-
- WRAP->DATA = DATA = new data;
+ wrap::LOGD->log_simple_line( s_message + "\n" );
#endif
- //*>>
-
- // Run threads
- TIMR->run();
}
-
#endif
diff --git a/src/wrap.h b/src/wrap.h
index 6ddd3c7..214227e 100644..100755
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -1,43 +1,7 @@
-/*:*
- *: File: ./src/wrap.h
- *:
- *: yChat; Homepage: www.yChat.org; Version 0.8.3-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *:
- *: This program is free software; you can redistribute it and/or
- *: modify it under the terms of the GNU General Public License
- *: as published by the Free Software Foundation; either version 2
- *: of the License, or (at your option) any later version.
- *:
- *: This program is distributed in the hope that it will be useful,
- *: but WITHOUT ANY WARRANTY; without even the implied warranty of
- *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *: GNU General Public License for more details.
- *:
- *: You should have received a copy of the GNU General Public License
- *: along with this program; if not, write to the Free Software
- *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *:*/
-
#ifndef WRAP_H
#define WRAP_H
#include "incl.h"
-
-#ifdef OPENSSL
-struct socketcontainer
-{
- int i_sock;
- void *p_ssl_context;
-};
-#define _socket socketcontainer
-#else
-#define _socket int
-#endif
-
#ifdef DATABASE
#include "data/data.h"
#endif
@@ -51,97 +15,82 @@ struct socketcontainer
//<<*
#include "modl.h"
//*>>
-
-#ifdef CLI
-#include "cli/cli.h"
+#ifdef NCURSES
+#include "ncur/ncur.h"
#endif
-
#include "chat/sman.h"
-
-#ifndef OPENSSL
#include "sock/sock.h"
-#else
-#include "sock/sslsock.h"
-#endif
-
-#include "monitor/stats.h"
+#include "stats.h"
#include "time/timr.h"
-#include "thrd/pool.h"
using namespace std;
-class dynamic_wrap
+class dynamic_wrap
{
-public:
- //<<*
- chat* CHAT;
+ public:
+ //<<*
+ chat* CHAT;
#ifdef DATABASE
-
- data* DATA;
+ data* DATA;
#endif
+ gcol* GCOL;
+ sman* SMAN;
+ modl* MODL;
+ //*>>
- gcol* GCOL;
- sman* SMAN;
- modl* MODL;
- //*>>
-
- conf* CONF;
- html* HTML;
+ conf* CONF;
+ html* HTML;
#ifdef LOGGING
-
- logd* LOGD;
+ logd* LOGD;
#endif
-
- sock* SOCK;
- stats* STAT;
- timr* TIMR;
+#ifdef NCURSES
+ ncur* NCUR;
+#endif
+ sock* SOCK;
+ stats* STAT;
+ timr* TIMR;
};
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( char* c_message )
+ {
+ wrap::system_message( string(c_message) );
+ }
- static void system_message( string s_message );
+ static void system_message( string* p_message )
+ {
+ wrap::system_message( *p_message );
+ }
- static void init_wrapper(map<string,string>* p_main_loop_params);
+ static void system_message( string s_message );
- //<<*
- static chat* CHAT;
+ //<<*
+ static chat* CHAT;
#ifdef DATABASE
-
- static data* DATA;
+ static data* DATA;
#endif
-
- static gcol* GCOL;
- static sman* SMAN;
+ static gcol* GCOL;
+ static sman* SMAN;
#ifdef IRCBOT
-
- static ybot* YBOT;
+ static ybot* YBOT;
#endif
+ static modl* MODL;
+ //*>>
- static modl* MODL;
- //*>>
-
- static conf* CONF;
- static html* HTML;
+ static conf* CONF;
+ static html* HTML;
#ifdef LOGGING
-
- static logd* LOGD;
+ static logd* LOGD;
+#endif
+#ifdef NCURSES
+ static ncur* NCUR;
#endif
- static sock* SOCK;
- static stats* STAT;
- static timr* TIMR;
- static dynamic_wrap* WRAP;
+ static sock* SOCK;
+ static stats* STAT;
+ static timr* TIMR;
+ static dynamic_wrap* WRAP;
};
-
#endif