From 3a96ab7e91145b367d05e98533b5f426f762f83f Mon Sep 17 00:00:00 2001 From: "Paul Buetow (mars.fritz.box)" Date: Sun, 15 Dec 2013 11:49:02 +0100 Subject: add packages --- yhttpd/src/Makefile.in | 21 - yhttpd/src/cli/cli.cpp | 300 ------ yhttpd/src/cli/cli.h | 61 -- yhttpd/src/conf/conf.cpp | 186 ---- yhttpd/src/conf/conf.h | 29 - yhttpd/src/configure | 350 ------- yhttpd/src/contrib/README | 5 - yhttpd/src/contrib/xml/README | 504 --------- yhttpd/src/contrib/xml/tinyxml.cpp | 1428 -------------------------- yhttpd/src/contrib/xml/tinyxml.h | 1630 ------------------------------ yhttpd/src/contrib/xml/tinyxmlerror.cpp | 51 - yhttpd/src/contrib/xml/tinyxmlparser.cpp | 1553 ---------------------------- yhttpd/src/glob.h | 198 ---- yhttpd/src/html.cpp | 133 --- yhttpd/src/html.h | 38 - yhttpd/src/incl.h | 13 - yhttpd/src/logd.cpp | 175 ---- yhttpd/src/logd.h | 37 - yhttpd/src/main.cpp | 101 -- yhttpd/src/maps/hashmap.h | 53 - yhttpd/src/maps/hashmap.tmpl | 126 --- yhttpd/src/maps/mtools.h | 11 - yhttpd/src/maps/mtools.tmpl | 12 - yhttpd/src/maps/nhashmap.h | 21 - yhttpd/src/maps/nhashmap.tmpl | 11 - yhttpd/src/maps/shashmap.h | 49 - yhttpd/src/maps/shashmap.tmpl | 157 --- yhttpd/src/monitor/dump.cpp | 109 -- yhttpd/src/monitor/dump.h | 62 -- yhttpd/src/monitor/stats.cpp | 102 -- yhttpd/src/monitor/stats.h | 36 - yhttpd/src/msgs.h | 145 --- yhttpd/src/name.cpp | 49 - yhttpd/src/name.h | 24 - yhttpd/src/ncur/menu.cpp | 117 --- yhttpd/src/ncur/menu.h | 39 - yhttpd/src/ncur/ncur.cpp | 259 ----- yhttpd/src/ncur/ncur.h | 51 - yhttpd/src/reqp.cpp | 285 ------ yhttpd/src/reqp.h | 41 - yhttpd/src/sign.cpp | 54 - yhttpd/src/sign.h | 21 - yhttpd/src/sock/sock.cpp | 473 --------- yhttpd/src/sock/sock.h | 91 -- yhttpd/src/sock/sslsock.cpp | 141 --- yhttpd/src/sock/sslsock.h | 41 - yhttpd/src/thrd/pool.cpp | 157 --- yhttpd/src/thrd/pool.h | 55 - yhttpd/src/thrd/thro.cpp | 43 - yhttpd/src/thrd/thro.h | 30 - yhttpd/src/time/timo.cpp | 38 - yhttpd/src/time/timo.h | 22 - yhttpd/src/time/timr.cpp | 177 ---- yhttpd/src/time/timr.h | 64 -- yhttpd/src/tool/dir.cpp | 66 -- yhttpd/src/tool/dir.h | 35 - yhttpd/src/tool/tool.cpp | 240 ----- yhttpd/src/tool/tool.h | 29 - yhttpd/src/wrap.cpp | 121 --- yhttpd/src/wrap.h | 105 -- 60 files changed, 10575 deletions(-) delete mode 100644 yhttpd/src/Makefile.in delete mode 100644 yhttpd/src/cli/cli.cpp delete mode 100644 yhttpd/src/cli/cli.h delete mode 100644 yhttpd/src/conf/conf.cpp delete mode 100644 yhttpd/src/conf/conf.h delete mode 100755 yhttpd/src/configure delete mode 100644 yhttpd/src/contrib/README delete mode 100644 yhttpd/src/contrib/xml/README delete mode 100644 yhttpd/src/contrib/xml/tinyxml.cpp delete mode 100644 yhttpd/src/contrib/xml/tinyxml.h delete mode 100644 yhttpd/src/contrib/xml/tinyxmlerror.cpp delete mode 100644 yhttpd/src/contrib/xml/tinyxmlparser.cpp delete mode 100644 yhttpd/src/glob.h delete mode 100644 yhttpd/src/html.cpp delete mode 100644 yhttpd/src/html.h delete mode 100644 yhttpd/src/incl.h delete mode 100644 yhttpd/src/logd.cpp delete mode 100644 yhttpd/src/logd.h delete mode 100644 yhttpd/src/main.cpp delete mode 100644 yhttpd/src/maps/hashmap.h delete mode 100644 yhttpd/src/maps/hashmap.tmpl delete mode 100644 yhttpd/src/maps/mtools.h delete mode 100644 yhttpd/src/maps/mtools.tmpl delete mode 100644 yhttpd/src/maps/nhashmap.h delete mode 100644 yhttpd/src/maps/nhashmap.tmpl delete mode 100644 yhttpd/src/maps/shashmap.h delete mode 100644 yhttpd/src/maps/shashmap.tmpl delete mode 100644 yhttpd/src/monitor/dump.cpp delete mode 100644 yhttpd/src/monitor/dump.h delete mode 100644 yhttpd/src/monitor/stats.cpp delete mode 100644 yhttpd/src/monitor/stats.h delete mode 100644 yhttpd/src/msgs.h delete mode 100644 yhttpd/src/name.cpp delete mode 100644 yhttpd/src/name.h delete mode 100644 yhttpd/src/ncur/menu.cpp delete mode 100644 yhttpd/src/ncur/menu.h delete mode 100644 yhttpd/src/ncur/ncur.cpp delete mode 100644 yhttpd/src/ncur/ncur.h delete mode 100644 yhttpd/src/reqp.cpp delete mode 100644 yhttpd/src/reqp.h delete mode 100644 yhttpd/src/sign.cpp delete mode 100644 yhttpd/src/sign.h delete mode 100644 yhttpd/src/sock/sock.cpp delete mode 100644 yhttpd/src/sock/sock.h delete mode 100644 yhttpd/src/sock/sslsock.cpp delete mode 100644 yhttpd/src/sock/sslsock.h delete mode 100644 yhttpd/src/thrd/pool.cpp delete mode 100644 yhttpd/src/thrd/pool.h delete mode 100644 yhttpd/src/thrd/thro.cpp delete mode 100644 yhttpd/src/thrd/thro.h delete mode 100644 yhttpd/src/time/timo.cpp delete mode 100644 yhttpd/src/time/timo.h delete mode 100644 yhttpd/src/time/timr.cpp delete mode 100644 yhttpd/src/time/timr.h delete mode 100644 yhttpd/src/tool/dir.cpp delete mode 100644 yhttpd/src/tool/dir.h delete mode 100644 yhttpd/src/tool/tool.cpp delete mode 100644 yhttpd/src/tool/tool.h delete mode 100644 yhttpd/src/wrap.cpp delete mode 100644 yhttpd/src/wrap.h (limited to 'yhttpd/src') diff --git a/yhttpd/src/Makefile.in b/yhttpd/src/Makefile.in deleted file mode 100644 index 262f3a6..0000000 --- a/yhttpd/src/Makefile.in +++ /dev/null @@ -1,21 +0,0 @@ -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: yhttpd -$(SRCS): - $(CC) $(INCLUDES) $(CFLAGS) -c $*.cpp -infotext: - @echo Compiling base -yhttpd: infotext $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD) - @mv yhttpd ../bin - @echo -n "Size of linked executable: " - @du -hc ../bin/yhttpd | tail -n 1 -clean: - @echo Cleaning base obj - @if test -d ../obj; then rm -Rf ../obj; fi diff --git a/yhttpd/src/cli/cli.cpp b/yhttpd/src/cli/cli.cpp deleted file mode 100644 index dbbc729..0000000 --- a/yhttpd/src/cli/cli.cpp +++ /dev/null @@ -1,300 +0,0 @@ -#ifndef CLI_CPP -#define CLI_CPP - -#include "cli.h" - -#ifdef CLI -using namespace std; - -cli::cli( ) -{ -#ifdef NCURSES - start(); -#endif -} - -cli::~cli() -{} - -int -cli::parse_input( string s_input ) -{ - string s_param = ""; - unsigned i_pos = 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 - << CLIPRMO << " !command - Uses system to run a command" << endl; -#ifdef DEBUG - - cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl; -#endif - - cout << CLIPRMO << " (du)mp [part] - Prints out a dump of the data structure" << endl; - cout << CLIPRMO << " (Run without part to list all possibilities)" << endl; - cout << CLIPRMO << " (e)cho VAR - Prints out configuration value of VAR" << endl; - cout << CLIPRMO << " Wildcards can be used too, example: echo http*" << endl; -#ifdef NCURSES - - cout << CLIPRMO << " (ex)it - Quits CLI mode and respawns ncurses mode" << endl; -#endif - - cout << CLIPRMO << " (h)elp - Prints out this help!" << endl; -#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 (yhttpd 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 << " (u)nset VAR - Deletes configuration value VAR" << endl - << CLIPRMO << " (v)ersion - Prints out version" << endl; - cout << CLIPRMI; - } - else if( s_input.at(0) == '!' ) - { - system( s_input.substr(1).c_str() ); - cout << CLIPRMI; - } - -#ifdef DEBUG - else if ( s_input.compare("d") == 0 || s_input.compare("debug") == 0 ) - { - debug_routine(); - cout << CLIPRMI; - } -#endif - else if ( s_input.compare("du") == 0 || s_input.compare("dump") == 0 ) - { - dump d(vectorize(s_param)); - cout << CLIPRMI; - } - else if( s_input.compare("echo") == 0 || s_input.compare("e") == 0 ) - { - string s_val; - - // Check wildcards - unsigned i_pos = s_param.find("*"); - if ( i_pos != string::npos ) - { - s_param = s_param.substr( 0, i_pos ); - vector* p_vec = wrap::CONF->get_key_vector(); - sort(p_vec->begin(), p_vec->end()); - vector::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; - } - - -#ifdef NCURSES - else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 ) - { - return 0; - } -#endif - - -#ifdef EXPERIM - else if( s_input.compare("reconf") == 0 || s_input.compare("re") == 0 ) - { - wrap::HTTPD->reconf(); - cout << CLIPRMI; - } -#endif - - else if( s_input.compare("rusage") == 0 || s_input.compare("r") == 0 ) - { - print_rusage(); - cout << CLIPRMI; - } - else if( s_input.compare("ru") == 0 || s_input.compare("rusageh") == 0 ) - { - cout << wrap::STAT->get_rusage_history( "ru_maxrss", string(CLIPRMO) + " " ); - cout << CLIPRMI; - } - else if( s_input.compare("set") == 0 ) - { - string s_varname = ""; - i_pos = s_param.find_first_of(" "); - - if ( i_pos != string::npos ) - { - s_varname = s_param.substr(0, i_pos); - - if ( s_param.length() > i_pos+1 ) - s_param = s_param.substr(i_pos+1); - - else - s_param = ""; - } - - string s_old_val = wrap::CONF->get_elem(s_varname); - - if ( !s_old_val.empty() ) - { - cout << CLIPRMO << "Old value: " << s_old_val << endl; - wrap::CONF->del_elem(s_varname); - } - - wrap::CONF->add_elem(s_param, s_varname); - cout << CLIPRMO << "New value: " << s_param << endl; - cout << CLIPRMI; - } - else if( s_input.compare("shell") == 0 || s_input.compare("sh") == 0 ) - { - cout << CLIPRMO << CLISHEL << endl; - system(wrap::CONF->get_elem("httpd.system.shell").c_str()); - cout << CLIPRMO << CLIWELC << endl; - cout << CLIPRMI; - } - else if( s_input.compare("shutdown") == 0 || s_input.compare("s") == 0 ) - { - exit(0); - } - else if( s_input.compare("t") == 0 || s_input.compare("time") == 0 ) - { - cout << CLIPRMO << "Time: " << wrap::TIMR->get_time() << endl - << CLIPRMO << "Uptime: " << wrap::TIMR->get_uptime() << endl; - cout << CLIPRMI; - } - - - else if( s_input.compare("u") == 0 || s_input.compare("unset") == 0 ) - { - if (!s_param.empty()) - { - string s_old_val = wrap::CONF->get_elem(s_param); - if ( !s_old_val.empty() ) - { - cout << CLIPRMO << "Deleted variable " << s_param << " with value: " << s_old_val << endl; - wrap::CONF->del_elem(s_param); - } - else - { - cout << CLIPRMO << "Variable " << s_param << " was not set" << endl; - } - cout << CLIPRMI; - } - } - else if( s_input.compare("v") == 0 || s_input.compare("version") == 0 ) - { - cout << CLIPRMO << tool::yhttpd_version() << " " << UNAME << endl; - cout << CLIPRMI; - } - else - { - cout << CLIPRMO << CLIHELP << "\"" << s_input << "\"" << endl; - cout << CLIPRMI; - } - - return 1; -} - -void -#ifndef NCURSES -cli::start(void* p_void) -#else -cli::start() -#endif -{ - cout << CLIPRMO << CLIWELC << endl; - - string s_input; - cout << CLIPRMI; - - do - { - getline(cin, s_input); - } - while( parse_input(s_input) ); -} - -void -cli::print_rusage() -{ - rusage* p_rusage = new rusage; - getrusage( RUSAGE_SELF, p_rusage ); - - cout << CLIPRMO << "ru_maxrss: " << p_rusage->ru_maxrss << "\t(max resident set size)" << endl - << CLIPRMO << "ru_ixrss: " << p_rusage->ru_ixrss << "\t(integral shared text memory size)" << endl - << CLIPRMO << "ru_idrss: " << p_rusage->ru_idrss << "\t(integral unshared data size)" << endl - << CLIPRMO << "ru_isrss: " << p_rusage->ru_isrss << "\t(integral unshared stack size)" << endl - << CLIPRMO << "ru_minflt: " << p_rusage->ru_minflt << "\t(page reclaims)" << endl - << CLIPRMO << "ru_majflt: " << p_rusage->ru_majflt << "\t(page faults)" << endl - << CLIPRMO << "ru_nswap: " << p_rusage->ru_nswap << "\t(swaps)" << endl - << CLIPRMO << "ru_inblock: " << p_rusage->ru_inblock << "\t(block input operations)" << endl - << CLIPRMO << "ru_oublock: " << p_rusage->ru_oublock << "\t(block output operations)" << endl - << CLIPRMO << "ru_msgsnd: " << p_rusage->ru_msgsnd << "\t(messages sent)" << endl - << CLIPRMO << "ru_msgrcv: " << p_rusage->ru_msgrcv << "\t(messages received)" << endl - << CLIPRMO << "ru_nsignals: " << p_rusage->ru_nsignals << "\t(signals received)" << endl - << CLIPRMO << "ru_nvcsw: " << p_rusage->ru_nvcsw << "\t(voluntary context switches)" << endl - << CLIPRMO << "ru_nivcsw: " << p_rusage->ru_nivcsw << "\t(involuntary context switches)" << endl; - - delete p_rusage; -} - -vector -cli::vectorize(string s_param) -{ - vector vec_ret; - unsigned i_pos; - - for (i_pos = s_param.find(" "); - i_pos != string::npos; - i_pos = s_param.find(" ")) - { - vec_ret.push_back(s_param.substr(0, i_pos)); - s_param = s_param.substr(i_pos+1); - } - - if (!s_param.empty()) - vec_ret.push_back(s_param); - - return vec_ret; -} - -#ifdef DEBUG -void -cli::debug_routine() -{ - rusage* p_rusage = new rusage; - for(;;) - { - /* - ossl *p_tmp = new ossl; - getrusage( RUSAGE_SELF, p_rusage ); - cout << CLIPRMO << "ru_maxrss: " << p_rusage->ru_maxrss << "\t(max resident set size)" << endl; - delete p_tmp; - */ - } - delete p_rusage; -} -#endif - -#endif -#endif diff --git a/yhttpd/src/cli/cli.h b/yhttpd/src/cli/cli.h deleted file mode 100644 index 8ec75cb..0000000 --- a/yhttpd/src/cli/cli.h +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#ifndef RUSAGE_SELF -#define RUSAGE_SELF 0 -#endif -#ifndef RUSAGE_CHILDREN -#define RUSAGE_CHILDREN -1 -#endif - -#include "../incl.h" - -#ifndef CLI_H -#define CLI_H -#ifdef CLI - -#ifndef NCURSES -#include "../thrd/thro.h" -#endif - -#include "../monitor/dump.h" - -using namespace std; - -#ifndef NCURSES -class cli : public thro -{ -#else -class cli -{ -#endif -private: - int parse_input(string s_input); - vector vectorize(string s_param); - -public: - cli( ); - ~cli( ); - -#ifdef DEBUG - - void debug_routine(); -#endif - - void print_rusage(); - -#ifndef NCURSES - - void start(void* p_void); -#else - - void start(); -#endif -}; - -#endif -#endif diff --git a/yhttpd/src/conf/conf.cpp b/yhttpd/src/conf/conf.cpp deleted file mode 100644 index 25884ca..0000000 --- a/yhttpd/src/conf/conf.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef CONF_CPP -#define CONF_CPP - -#include -#include "conf.h" - -using namespace std; - -conf::conf( string s_conf, map* p_main_loop_params ) : name::name( s_conf ) -{ - string s_check[] = { - get_name(), - string(getenv("HOME"))+string("/.yhttpd/") + get_name(), - string("./etc/") + get_name(), - string("/etc/") + get_name(), - string(PREFIX+string("etc/")+get_name()) }; - - string s_config; - - for ( int i = 0; i < 4; ++i ) - { - cout << "Checking for " << s_check[i]; - ifstream if_check( s_check[i].c_str() ); - if( if_check ) - { - s_config = s_check[i]; - if_check.close(); - cout << "... ok!" << endl; - break; - } - cout << "... not ok!" << endl; - } - - if ( s_config.empty() ) - { - cout << CFILEFA << endl; - exit(1); - } - - else - { - cout << CFILEOK << "..." << endl; - } - - p_xml = new TiXmlDocument(s_config.c_str()); - TiXmlBase::SetCondenseWhiteSpace( false ); - - if ( !p_xml->LoadFile() ) - { - cout << XMLER1 << endl; - exit(1); - } - - vector vec_string; - parse_xml(p_xml, &vec_string); - - shashmap::add_elem_insecure(tool::yhttpd_version(), "yhttpd.version"); - - // Overrides yhttpd.conf values with command line options (yhttpd -o key1 value1 -o key2 value2 ...) - map::iterator iter; - for ( iter = p_main_loop_params->begin(); iter != p_main_loop_params->end(); iter++ ) - { - shashmap::del_elem_insecure(iter->first); - shashmap::add_elem_insecure(iter->second, iter->first); - } - - delete p_xml; -} - -void -conf::parse_xml(TiXmlNode* p_node, vector* p_vec) -{ - if ( p_node->NoChildren() ) - return; - - for ( TiXmlNode* p_child = p_node->FirstChild(); p_child; p_child = p_child->NextSibling() ) - { - //cout << p_vec->size() << ": (Value:" << p_child->Value() << ") (Type:" << p_child->Type() << ")" << endl; - - if ( strcmp(p_child->Value(),"config") == 0 ) - { - parse_xml(p_child, p_vec); - } - - else if ( strcmp(p_child->Value(),"category") == 0 ) - { - p_vec->push_back(p_child->ToElement()->Attribute("name")); - parse_xml(p_child, p_vec); - p_vec->pop_back(); - } - - else if ( strcmp(p_child->Value(),"option") == 0 ) - { - string s_option_name = ""; - - for ( vector::iterator iter = p_vec-> - begin(); - iter != p_vec->end(); - ++iter ) - s_option_name.append(*iter + "."); - - TiXmlElement* p_element = p_child->ToElement(); - exit_if_xml_error(); - - s_option_name.append(p_element->Attribute("name")); - -#ifdef VERBOSE - cout << XMLREAD << s_option_name; -#endif - - TiXmlNode *p_node_value = p_element->FirstChild("value"); - TiXmlNode *p_node_descr = p_element->FirstChild("descr"); - - TiXmlText* p_text_value = NULL; - TiXmlText* p_text_descr = NULL; - - if ( p_node_value && p_node_value->FirstChild() - ) - p_text_value = p_node_value->FirstChild()->ToText(); - - if ( p_node_descr && p_node_descr->FirstChild() - ) - p_text_descr = p_node_descr->FirstChild()->ToText(); - - if ( !p_text_value ) - continue; - -#ifdef VERBOSE - cout << " := " << p_text_value->Value() << endl; -#endif - - shashmap::add_elem_insecure(p_text_value->Value(), s_option_name); - - if ( !p_text_descr ) - continue; - - s_option_name.append(".descr"); -#ifdef VERBOSE - cout << XMLREAD << s_option_name << endl; -#endif - shashmap::add_elem_insecure(p_text_descr->Value(), s_option_name); - } - } - - exit_if_xml_error() - ; -} - -conf::~conf() -{ - delete p_xml; -} - -void -conf::exit_if_xml_error() const -{ - if ( p_xml->Error() ) - { - cout << XMLERR << p_xml->ErrorDesc() << endl; - exit(1); - } -} - - -int -conf::get_int(string s_key) -{ - return tool::string2int(get_elem(s_key)); -} - -vector -conf::get_vector(string s_key) -{ - vector 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/yhttpd/src/conf/conf.h b/yhttpd/src/conf/conf.h deleted file mode 100644 index b083d8c..0000000 --- a/yhttpd/src/conf/conf.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CONF_H -#define CONF_H - -class conf; // Predefine for nmap.tmpl - -#include -#include "../incl.h" -#include "../maps/shashmap.h" -#include "../name.h" -#include "../contrib/xml/tinyxml.h" - -using namespace std; - -class conf : public shashmap, name -{ -private: - TiXmlDocument* p_xml; - void exit_if_xml_error() const; - void parse_xml( TiXmlNode* p_node, vector* p_vec); - -public: - conf(string s_conf, map* p_main_loop_params); - ~conf(); - - int get_int(string s_key); - vector get_vector(string s_key); -}; - -#endif diff --git a/yhttpd/src/configure b/yhttpd/src/configure deleted file mode 100755 index 54cf650..0000000 --- a/yhttpd/src/configure +++ /dev/null @@ -1,350 +0,0 @@ -#!/bin/sh - -# -# The yhttpd Project (2003 - 2005) -# - -if ! ../scripts/checkperl.sh -then - exit 1 -fi - -if ! test -f ../g++.version -then - echo You need to run ./configure of the top level source dir first - exit 1 -fi - -perl -e ' - use strict; - $|=1; - - my %libadd; - my %incadd; - my $deepness = 500; - - my @headers = ( - "dlfcn.h", - "pthread.h", - "netinet/in.h", - "time.h", - "ncurses.h", - "openssl/ssl.h", - "::test::ext/hash_map" - ); - - my @libs = ( - "libncurses.so", - "libssl.so", - "libcrypto.so" - ); - - my @headerpaths = ( - $ENV{HOME}."/include", - $ENV{HOME}."/usr/include", - "/include", - "/usr/include", - "/usr/local/include", - "/usr/lib/", - "/usr/pkg/include", - "/opt/include", - "/opt/local/include" - ); - - my @libpaths = ( - $ENV{HOME}."/lib", - $ENV{HOME}."/usr/lib", - "/lib", - "/usr/lib", - "/usr/local/lib", - "/usr/pkg/lib", - "/opt/lib", - "/opt/local/lib" - ); - - my %dependfiles = ( - database => ["data"], - ycurses => ["curses", "ycui.cpp", "ycui.h"], - logging => ["logd.cpp", "logd.h"], - cli => ["cli"], - opnssl => ["sock/sslsock.cpp", "sock/sslsock.h"] - ); - - open FILE, "glob.h" or die "glob.h: $!\n"; - while() { - if ( /\/\/#define DATABASE/ ) { - remove_from_array("mysql/mysql.h",\@headers); - remove_from_array("libmysqlclient.so",\@libs); - mkdir "../backuped" unless -d "../backuped"; - `mv $_ ../backuped` for @{$dependfiles{database}}; - } - - elsif ( /^#define DATABASE/ && !-d "data") { - `mv ../backuped/$_ .` for @{$dependfiles{database}}; - } - - if ( /\/\/#define LOGGING/ ) { - mkdir "../backuped" unless -d "../backuped"; - `mv $_ ../backuped` for @{$dependfiles{logging}}; - } - - elsif ( /^#define LOGGING/ && !-f "logd.cpp") { - `mv ../backuped/$_ .` for @{$dependfiles{logging}}; - } - - if ( /\/\/#define CLI/ ) { - mkdir "../backuped" unless -d "../backuped"; - `mv $_ ../backuped` for @{$dependfiles{cli}}; - } - - elsif ( /^#define CLI/ && !-d "cli") { - `mv ../backuped/$_ .` for @{$dependfiles{cli}}; - } - - if ( /\/\/#define YCURSES/ ) { - for ("ncurses", "menu", "panel") { - remove_from_array("$_.h",\@headers); - remove_from_array("lib$_.so",\@libs); - } - - mkdir "../backuped" unless -d "../backuped"; - `mv $_ ../backuped` for @{$dependfiles{ycurses}}; - } - - elsif ( /^#define YCURSES/ && !-d "curses") { - `mv ../backuped/$_ .` for @{$dependfiles{ycurses}}; - } - - if ( /\/\/#define OPENSSL/ ) { - remove_from_array("openssl/ssl.h",\@headers); - remove_from_array("lib$_.so",\@libs) for ("ssl", "crypto"); - } - } - close FILE; - - if ( defined $ENV{YHTTPDHEADERPATHS} ) { - map { print "Adding $_...\n"; unshift @headerpaths, $_ } - split /:/, $ENV{YHTTPDHEADERPATHS}; - } - - if ( defined $ENV{YHTTPDLIBPATHS} ) { - map { print "Adding $_...\n"; unshift @libpaths, $_ } - split /:/, $ENV{YHTTPDLIBPATHS}; - } - - print "Headers:\n"; - - my $testit = 0; - map { $incadd{&check($deepness, $_, @headerpaths)}++ } - @headers; - - $testit = 0; - print "Libraries:\n"; - map { $libadd{&check($deepness, $_, @libpaths)}++ } - @libs; - - my $incadd = &make_add("-I", \%incadd); - my $libadd = &make_add("-L", \%libadd); - - for ( @libs ) { $libadd .= "-l$_ " if s/^lib// and s/\.so$//; } - - print "Incadd: $incadd\n"; - print "Libadd: $libadd\n"; - - `echo $incadd > includes.add`; - `echo $libadd > libs.add`; - - print "Creating new base Makefile...\n"; - unlink("Makefile") if -f "Makefile"; - unlink("../err") if -f "../err"; - open Fin, "Makefile.in" or die "Makefile.in: $!\n"; - open Fout, ">Makefile" or die "Makefile: $!\n"; - - my $cpp = `echo *.cpp */*.cpp contrib/*/*.cpp | sort`; - my $compiler = `tail -n 1 ../g++.version`; - my $version = `tail -n 2 ../g++.version | head -n 1`; - my $uname = `uname -srm`; - my $compopt = join "; ", split /\n/, `cat ../g++.version`; - - chomp $uname; - chomp $compopt; - - print "Configuring for $uname...\n"; - chomp $cpp; - chomp $version; - - while () { - s/^(CC=).*\n/$1$compiler/; - s/^(SRCS=).*/$1$cpp/; - s/ -frepo//; # unless $version =~ /3\.4/; - if ( $uname !~ /Linux/i ) { - print "Disabling -ldl flag...\n" if s/ -ldl//; - } - print Fout; - } - close Fin; - - my $args = join(" -",@ARGV); - $args = "-".$args unless $args eq ""; - - for my $cppfile (split / /, $cpp) { - my $ofile = $cppfile; - $ofile =~ s/\.cpp/\.o/; - print Fout "../obj/$ofile: $cppfile\n"; - print Fout "\t\@if ! test -d `dirname ../obj/$ofile`; then mkdir -p `dirname ../obj/$ofile`; fi\n"; - my $class = $ofile; - $class =~ s/\.o//; - - my $text; - if ( $class =~ /contrib\/.+/ ) { - my $dirname = `dirname $class`; - $text = "\t\@echo -n \"Contributed class $class \"\n"; - } - - else { - $text = "\t\@echo -n \"Base class $class \"\n"; - } - - print Fout "\t\@\$(CC) \$(CFLAGS) \$(INCLUDES) $args -c -o ../obj/$ofile $cppfile\n"; - print Fout $text."\t\@du -hc ../obj/$ofile | tail -n 1 | sed s/total// | sed \"s/ //g\"\n"; - } - - close Fout; - - open F, "msgs.h" or die "msgs.h: $!\n"; - my @msgs = ; - close F; - unlink("msgs.h"); - open F, ">msgs.h" or die "msgs.h: $!\n"; - - for (@msgs) { - s/(UNAME)(.+)$/UNAME "$uname"/; - s/(COMPOPT)(.+)$/COMPOPT "$compopt"/; - print F; - } - close F; - - if ( -d "mods" ) { - chdir("mods"); - my $cflags = "-fno-inline -fno-default-inline"; - - $cflags .= " -nostdlib" if $uname =~ /FreeBSD/i && `uname -r` =~ /^4\./; - - system("echo $cflags > cflags.add"); - system("./configure"); - chdir(".."); - } - - sub remove_from_array { - my $elem = shift; - my $array = shift; - - for ( my $i = 0; $i <= $#$array; ++$i ) { - if ( $$array[$i] eq $elem ) { - splice(@$array,$i,1); - last; - } - } # for - } - - sub check { - my $deep = shift; - - if ($deep == 0) { - print "Looking too deep! ($deepness)\n"; - exit(1); - } - - my $check = shift; - $testit = 1 if $check =~ s/::test:://; - - my $print = 1; - if ( $_[-1] eq "subsearch" ) { - $print = 0; - pop(@_); - } - - if ($print) { - print "Checking for $check..."; - print "\n" if $testit; - } - - for (@_) { - if ( -f "$_/$check" ) { - if ($testit) { - return $_ if test_include($_, $check); - return ""; - - } else { - print "OK\n"; - return "" if $_ eq "/usr/lib" or $_ eq "/usr/include"; - return $_; - } - } - } - - for (@_) { - next unless -d $_; - opendir D, $_ or warn "$_: $!\n"; - my @dir = readdir(D); - closedir D; - - for my $dir ( @dir ) { - next if $dir =~ /^\.+$/ or !-d "$_/$dir"; - my $path = &check($deep-1, $check, "$_/$dir", "subsearch"); - return $path if $path ne ""; - } - } - - if ($print) { - print "NOT OK\n"; - print "Please make sure that you have the needed software installed!\n"; - print "If you have a special path for your includes then edit src/configure!\n"; - print "Or set the environment variables YHTTPDHEADERPATHS and YHTTPDLIBPATHS.\n"; - print " Example: setenv YHTTPDHEADERPATHS \"/your/header/includes:/a/includes\"\n"; - print "(The environment variables have to be seperated by an :)\n"; - print "PS: You may use the locate and/or find command to search for files.\n"; - exit(1); - } - - `touch ../err`; - return ""; - } - - sub make_add { - my $flag = shift; - my $add = shift; - my $ret = ""; - - for (reverse keys %$add) { - next unless /.+/; - $ret .= "$flag$_ "; - } - return $ret; - } - - sub test_include { - my $shift = shift; - my $check = shift; - my $return = 0; - print "Testing $shift/$check..."; - - `echo "\#include \\"maps/hashmap.h\\"" > __test.cpp`; - `echo "int main(void){return 0;}" >> __test.cpp`; - my $cmd = "`tail -n 1 ../g++.version` -I$shift __test.cpp -o /dev/null 2>/dev/null"; - system $cmd; - - unless ($?) { - print "OK\n"; - $return = 1; - - } else { - print "Not OK\n"; - } - - unlink "__test.cpp" if -f "__test.cpp"; - return $return; - } - - exit(0); -' `echo "$*" | sed "s/-//g"` diff --git a/yhttpd/src/contrib/README b/yhttpd/src/contrib/README deleted file mode 100644 index 105f25d..0000000 --- a/yhttpd/src/contrib/README +++ /dev/null @@ -1,5 +0,0 @@ -This directory includes source code which has been included directly into yhttpd but is not -programmed by the yhttpd project explicitly which means the source code here is from extern. - -Used versions: -tinyxml 2.3.2 diff --git a/yhttpd/src/contrib/xml/README b/yhttpd/src/contrib/xml/README deleted file mode 100644 index 7da9dfd..0000000 --- a/yhttpd/src/contrib/xml/README +++ /dev/null @@ -1,504 +0,0 @@ -ATTENTION: - -This version of TinyXML has ben very little modified by -Paul C. Buetow in 2004 to fit the yhttpd project. - -To get the original source go to -http://www.sourceforge.net/projects/tinyxml - -/** @mainpage - -

TinyXml

- -TinyXml is a simple, small, C++ XML parser that can be easily -integrating into other programs. - - -

What it does.

- -In brief, TinyXml parses an XML document, and builds from that a -Document Object Model (DOM) that can be read, modified, and saved. - -XML stands for "eXtensible Markup Language." It allows you to create -your own document markups. Where HTML does a very good job of marking -documents for browsers, XML allows you to define any kind of document -markup, for example a document that describes a "to do" list for an -organizer application. XML is a very structured and convenient format. -All those random file formats created to store application data can -all be replaced with XML. One parser for everything. - -The best place for the complete, correct, and quite frankly hard to -read spec is at -http://www.w3.org/TR/2004/REC-xml-20040204/. An intro to XML -(that I really like) can be found at -http://skew.org/xml/tutorial. - -There are different ways to access and interact with XML data. -TinyXml uses a Document Object Model (DOM), meaning the XML data is parsed -into a C++ objects that can be browsed and manipulated, and then -written to disk or another output stream. You can also construct an XML document from -scratch with C++ objects and write this to disk or another output -stream. - -TinyXml is designed to be easy and fast to learn. It is two headers -and four cpp files. Simply add these to your project and off you go. -There is an example file - xmltest.cpp - to get you started. - -TinyXml is released under the ZLib license, -so you can use it in open source or commercial code. The details -of the license are at the top of every source file. - -TinyXml attempts to be a flexible parser, but with truly correct and -compliant XML output. TinyXml should compile on any reasonably C++ -compliant system. It does not rely on exceptions or RTTI. It can be -compiled with or without STL support. TinyXml fully supports -the UTF-8 encoding, and the first 64k character entities. - - -

What it doesn't do.

- -It doesnt parse or use DTDs (Document Type Definitions) or XSLs -(eXtensible Stylesheet Language.) There are other parsers out there -(check out www.sourceforge.org, search for XML) that are much more fully -featured. But they are also much bigger, take longer to set up in -your project, have a higher learning curve, and often have a more -restrictive license. If you are working with browsers or have more -complete XML needs, TinyXml is not the parser for you. - -The following DTD syntax will not parse at this time in TinyXml: - -@verbatim - - ]> -@endverbatim - -because TinyXml sees this as a !DOCTYPE node with an illegally -embedded !ELEMENT node. This may be addressed in the future. - -

Code Status.

- -TinyXml is mature, tested code. It is very stable. If you find -bugs, please file a bug report is on the sourceforge web site -(www.sourceforge.net/projects/tinyxml). -We'll get them straightened out as soon as possible. - -There are some areas of improvement; please check sourceforge if you are -interested in working on TinyXml. - - -

Features

- -

Using STL

- -TinyXml can be compiled to use or not use STL. When using STL, TinyXml -uses the std::string class, and fully supports std::istream, std::ostream, -operator<<, and operator>>. Many API methods have both 'const char*' and -'const std::string&' forms. - -When STL support is compiled out, no STL files are included whatsover. All -the string classes are implemented by TinyXml itself. API methods -all use the 'const char*' form for input. - -Use the compile time #define: - - TIXML_USE_STL - -to compile one version or the other. This can be passed by the compiler, -or set as the first line of "tinyxml.h". - -Note: If compiling the test code in Linux, setting the environment -variable TINYXML_USE_STL=YES/NO will control STL compilation. In the -Windows project file, STL and non STL targets are provided. In your project, -its probably easiest to add the line "#define TIXML_USE_STL" as the first -line of tinyxml.h. - -

UTF-8

- -TinyXml supports UTF-8 allowing to manipulate XML files in any language. TinyXml -also supports "legacy mode" - the encoding used before UTF-8 support and -probably best described as "extended ascii". - -Normally, TinyXml will try to detect the correct encoding and use it. However, -by setting the value of TIXML_DEFAULT_ENCODING in the header file, TinyXml -can be forced to always use one encoding. - -TinyXml will assume Legacy Mode until one of the following occurs: -
    -
  1. If the non-standard but common "UTF-8 lead bytes" (0xef 0xbb 0xbf) - begin the file or data stream, TinyXml will read it as UTF-8.
  2. -
  3. If the declaration tag is read, and it has an encoding="UTF-8", then - TinyXml will read it as UTF-8.
  4. -
  5. If the declaration tag is read, and it has no encoding specified, then - TinyXml will read it as UTF-8.
  6. -
  7. If the declaration tag is read, and it has an encoding="something else", then - TinyXml will read it as Legacy Mode. In legacy mode, TinyXml will - work as it did before. It's not clear what that mode does exactly, but - old content should keep working.
  8. -
  9. Until one of the above criteria is met, TinyXml runs in Legacy Mode.
  10. -
- -What happens if the encoding is incorrectly set or detected? TinyXml will try -to read and pass through text seen as improperly encoded. You may get some strange -results or mangled characters. You may want to force TinyXml to the correct mode. - - You may force TinyXml to Legacy Mode by using LoadFile( TIXML_ENCODING_LEGACY ) or -LoadFile( filename, TIXML_ENCODING_LEGACY ). You may force it to use legacy mode all -the time by setting TIXML_DEFAULT_ENCODING = TIXML_ENCODING_LEGACY. Likewise, you may -force it to TIXML_ENCODING_UTF8 with the same technique. - -For English users, using English XML, UTF-8 is the same as low-ASCII. You -don't need to be aware of UTF-8 or change your code in any way. You can think -of UTF-8 as a "superset" of ASCII. - -UTF-8 is not a double byte format - but it is a standard encoding of Unicode! -TinyXml does not use or directly support wchar, TCHAR, or Microsofts _UNICODE at this time. -It is common to see the term "Unicode" improperly refer to UTF-16, a wide byte encoding -of unicode. This is a source of confusion. - -For "high-ascii" languages - everything not English, pretty much - TinyXml can -handle all languages, at the same time, as long as the XML is encoded -in UTF-8. That can be a little tricky, older programs and operating systems -tend to use the "default" or "traditional" code page. Many apps (and almost all -modern ones) can output UTF-8, but older or stubborn (or just broken) ones -still output text in the default code page. - -For example, Japanese systems traditionally use SHIFT-JIS encoding. -Text encoded as SHIFT-JIS can not be read by tinyxml. -A good text editor can import SHIFT-JIS and then save as UTF-8. - -The Skew.org link does a great -job covering the encoding issue. - -The test file "utf8test.xml" is an XML containing English, Spanish, Russian, -and Simplified Chinese. (Hopefully they are translated correctly). The file -"utf8test.gif" is a screen capture of the XML file, rendered in IE. Note that -if you don't have the correct fonts (Simplified Chinese or Russian) on your -system, you won't see output that matches the GIF file even if you can parse -it correctly. Also note that (at least on my Windows machine) console output -is in a Western code page, so that Print() or printf() cannot correctly display -the file. This is not a bug in TinyXml - just an OS issue. No data is lost or -destroyed by TinyXml. The console just doesn't render UTF-8. - - -

Entities

-TinyXml recognizes the pre-defined "character entities", meaning special -characters. Namely: - -@verbatim - & & - < < - > > - " " - ' ' -@endverbatim - -These are recognized when the XML document is read, and translated to there -UTF-8 equivalents. For instance, text with the XML of: - -@verbatim - Far & Away -@endverbatim - -will have the Value() of "Far & Away" when queried from the TiXmlText object, -and will be written back to the XML stream/file as an ampersand. Older versions -of TinyXml "preserved" character entities, but the newer versions will translate -them into characters. - -Additionally, any character can be specified by its Unicode code point: -The syntax " " or " " are both to the non-breaking space characher. - - -

Streams

-With TIXML_USE_STL on, -TiXml has been modified to support both C (FILE) and C++ (operator <<,>>) -streams. There are some differences that you may need to be aware of. - -C style output: - - based on FILE* - - the Print() and SaveFile() methods - - Generates formatted output, with plenty of white space, intended to be as - human-readable as possible. They are very fast, and tolerant of ill formed - XML documents. For example, an XML document that contains 2 root elements - and 2 declarations, will still print. - -C style input: - - based on FILE* - - the Parse() and LoadFile() methods - - A fast, tolerant read. Use whenever you don't need the C++ streams. - -C++ style ouput: - - based on std::ostream - - operator<< - - Generates condensed output, intended for network transmission rather than - readability. Depending on your system's implementation of the ostream class, - these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML: - a document should contain the correct one root element. Additional root level - elements will not be streamed out. - -C++ style input: - - based on std::istream - - operator>> - - Reads XML from a stream, making it useful for network transmission. The tricky - part is knowing when the XML document is complete, since there will almost - certainly be other data in the stream. TinyXml will assume the XML data is - complete after it reads the root element. Put another way, documents that - are ill-constructed with more than one root element will not read correctly. - Also note that operator>> is somewhat slower than Parse, due to both - implementation of the STL and limitations of TinyXml. - -

White space

-The world simply does not agree on whether white space should be kept, or condensed. -For example, pretend the '_' is a space, and look at "Hello____world". HTML, and -at least some XML parsers, will interpret this as "Hello_world". They condense white -space. Some XML parsers do not, and will leave it as "Hello____world". (Remember -to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become -Hello___world. - -It's an issue that hasn't been resolved to my satisfaction. TinyXml supports the -first 2 approaches. Call TiXmlBase::SetCondenseWhiteSpace( bool ) to set the desired behavior. -The default is to condense white space. - -If you change the default, you should call TiXmlBase::SetCondenseWhiteSpace( bool ) -before making any calls to Parse XML data, and I don't recommend changing it after -it has been set. - - -

Handles

- -Where browsing an XML document in a robust way, it is important to check -for null returns from method calls. An error safe implementation can -generate a lot of code like: - -@verbatim -TiXmlElement* root = document.FirstChildElement( "Document" ); -if ( root ) -{ - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. -@endverbatim - -Handles have been introduced to clean this up. Using the TiXmlHandle class, -the previous code reduces to: - -@verbatim -TiXmlHandle docHandle( &document ); -TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).Element(); -if ( child2 ) -{ - // do something useful -@endverbatim - -Which is much easier to deal with. See TiXmlHandle for more information. - - -

Row and Column tracking

-Being able to track nodes and attributes back to their origin location -in source files can be very important for some applications. Additionally, -knowing where parsing errors occured in the original source can be very -time saving. - -TinyXml can tracks the row and column origin of all nodes and attributes -in a text file. The TiXmlBase::Row() and TiXmlBase::Column() methods return -the origin of the node in the source text. The correct tabs can be -configured in TiXmlDocument::SetTabSize(). - - -

Using and Installing

- -To Compile and Run xmltest: - -A Linux Makefile and a Windows Visual C++ .dsw file is provided. -Simply compile and run. It will write the file demotest.xml to your -disk and generate output on the screen. It also tests walking the -DOM by printing out the number of nodes found using different -techniques. - -The Linux makefile is very generic and will -probably run on other systems, but is only tested on Linux. You no -longer need to run 'make depend'. The dependecies have been -hard coded. - -

Windows project file for VC6

-
    -
  • tinyxml: tinyxml library, non-STL
  • -
  • tinyxmlSTL: tinyxml library, STL
  • -
  • tinyXmlTest: test app, non-STL
  • -
  • tinyXmlTestSTL: test app, STL
  • -
- -

Linux Make file

-At the top of the makefile you can set: - -PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in -the makefile. - -In the tinyxml directory, type "make clean" then "make". The executable -file 'xmltest' will be created. - - - -

To Use in an Application:

- -Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, and tinystr.cpp to your -project or make file. That's it! It should compile on any reasonably -compliant C++ system. You do not need to enable exceptions or -RTTI for TinyXml. - - -

How TinyXml works.

- -An example is probably the best way to go. Take: -@verbatim - - - - Go to the Toy store! - Do bills - -@endverbatim - -Its not much of a To Do list, but it will do. To read this file -(say "demo.xml") you would create a document, and parse it in: -@verbatim - TiXmlDocument doc( "demo.xml" ); - doc.LoadFile(); -@endverbatim - -And its ready to go. Now lets look at some lines and how they -relate to the DOM. - -@verbatim - -@endverbatim - - The first line is a declaration, and gets turned into the - TiXmlDeclaration class. It will be the first child of the - document node. - - This is the only directive/special tag parsed by by TinyXml. - Generally directive targs are stored in TiXmlUnknown so the - commands wont be lost when it is saved back to disk. - -@verbatim - -@endverbatim - - A comment. Will become a TiXmlComment object. - -@verbatim - -@endverbatim - - The "ToDo" tag defines a TiXmlElement object. This one does not have - any attributes, but does contain 2 other elements. - -@verbatim - -@endverbatim - - Creates another TiXmlElement which is a child of the "ToDo" element. - This element has 1 attribute, with the name "priority" and the value - "1". - -Go to the - - A TiXmlText. This is a leaf node and cannot contain other nodes. - It is a child of the "Item" TiXmlElement. - -@verbatim - -@endverbatim - - - Another TiXmlElement, this one a child of the "Item" element. - -Etc. - -Looking at the entire object tree, you end up with: -@verbatim -TiXmlDocument "demo.xml" - TiXmlDeclaration "version='1.0'" "standalone=no" - TiXmlComment " Our to do list data" - TiXmlElement "ToDo" - TiXmlElement "Item" Attribtutes: priority = 1 - TiXmlText "Go to the " - TiXmlElement "bold" - TiXmlText "Toy store!" - TiXmlElement "Item" Attributes: priority=2 - TiXmlText "bills" -@endverbatim - -

Documentation

- -The documentation is build with Doxygen, using the 'dox' -configuration file. - -

License

- -TinyXml is released under the zlib license: - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. - -

References

- -The World Wide Web Consortium is the definitive standard body for -XML, and there web pages contain huge amounts of information. - -The definitive spec: -http://www.w3.org/TR/2004/REC-xml-20040204/ - -I also recommend "XML Pocket Reference" by Robert Eckstein and published by -OReilly...the book that got the whole thing started. - -

Contributors, Contacts, and a Brief History

- -Thanks very much to everyone who sends suggestions, bugs, ideas, and -encouragement. It all helps, and makes this project fun. A special thanks -to the contributors on the web pages that keep it lively. - -So many people have sent in bugs and ideas, that rather than list here -we try to give credit due in the "changes.txt" file. - -TinyXml was originally written be Lee Thomason. (Often the "I" still -in the documenation.) Lee reviews changes and releases new versions, -with the help of Yves Berquin and the tinyXml community. - -We appreciate your suggestions, and would love to know if you -use TinyXml. Hopefully you will enjoy it and find it useful. -Please post questions, comments, file bugs, or contact us at: - -www.sourceforge.net/projects/tinyxml - -Lee Thomason, -Yves Berquin -*/ diff --git a/yhttpd/src/contrib/xml/tinyxml.cpp b/yhttpd/src/contrib/xml/tinyxml.cpp deleted file mode 100644 index 73e57c2..0000000 --- a/yhttpd/src/contrib/xml/tinyxml.cpp +++ /dev/null @@ -1,1428 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include -#include "tinyxml.h" - -#ifdef TIXML_USE_STL -#include -#endif - - -bool TiXmlBase::condenseWhiteSpace = true; - -void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream ) -{ - TIXML_STRING buffer; - PutString( str, &buffer ); - (*stream) << buffer; -} - -void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - outString->append( buf, strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -// <-- Strange class for a bug fix. Search for STL_STRING_BUG -TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str ) -{ - buffer = new char[ str.length()+1 ]; - if ( buffer ) - { - strcpy( buffer, str.c_str() ); - } -} - - -TiXmlBase::StringToBuffer::~StringToBuffer() -{ - delete [] buffer; -} -// End strange bug fix. --> - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) - return 0; - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) - return 0; - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( replaceThis->parent != this ) - return 0; - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( node->SValue() == TIXML_STRING( _value )) - return node; - } - return 0; -} - -TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( node->SValue() == TIXML_STRING (_value)) - return node; - } - return 0; -} - -TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - -TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - -TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( node->SValue() == TIXML_STRING (_value)) - return node; - } - return 0; -} - - -TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( node->SValue() == TIXML_STRING (_value)) - return node; - } - return 0; -} - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -TiXmlElement* TiXmlNode::FirstChildElement() const -{ - TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - -TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - -TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - - -TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -void TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char * TiXmlElement::Attribute( const char * name ) const -{ - TiXmlAttribute* node = attributeSet.Find( name ); - - if ( node ) - return node->Value(); - - return 0; -} - - -const char * TiXmlElement::Attribute( const char * name, int* i ) const -{ - const char * s = Attribute( name ); - if ( i ) - { - if ( s ) - *i = atoi( s ); - else - *i = 0; - } - return s; -} - - -const char * TiXmlElement::Attribute( const char * name, double* d ) const -{ - const char * s = Attribute( name ); - if ( d ) - { - if ( s ) - *d = atof( s ); - else - *d = 0; - } - return s; -} - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - return node->QueryIntValue( ival ); -} - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - return node->QueryDoubleValue( dval ); -} - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - char buf[64]; - sprintf( buf, "%d", val ); - SetAttribute( name, buf ); -} - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - char buf[128]; - sprintf( buf, "%f", val ); - SetAttribute( name, buf ); -} - - -void TiXmlElement::SetAttribute( const char * name, const char * _value ) -{ - TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - { - node->SetValue( _value ); - return; - } - - TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); - if ( attrib ) - { - attributeSet.Add( attrib ); - } - else - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); - } -} - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 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, "", 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", value.c_str() ); - } -} - -void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const -{ - (*stream) << "<" << value; - - TiXmlAttribute* attrib; - for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) - { - (*stream) << " "; - attrib->StreamOut( stream ); - } - - // If this node has children, give it a closing tag. Else - // make it an empty tag. - TiXmlNode* node; - if ( firstChild ) - { - (*stream) << ">"; - - for ( node = firstChild; node; node=node->NextSibling() ) - { - node->StreamOut( stream ); - } - (*stream) << ""; - } - else - { - (*stream) << " />"; - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNod