summaryrefslogtreecommitdiff
path: root/yhttpd-0.7.1/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
commit9cd3ccffd5372dfde3af478e3f832f18db4be3f1 (patch)
tree631c295a4a4a16b57502b847626763a279bf6df7 /yhttpd-0.7.1/src
parent13aaf70af703748fe096e0664c305cd202637ad2 (diff)
tagging tags
Diffstat (limited to 'yhttpd-0.7.1/src')
-rwxr-xr-xyhttpd-0.7.1/src/Makefile.in21
-rwxr-xr-xyhttpd-0.7.1/src/cli/cli.cpp265
-rwxr-xr-xyhttpd-0.7.1/src/cli/cli.h54
-rwxr-xr-xyhttpd-0.7.1/src/conf/conf.cpp155
-rwxr-xr-xyhttpd-0.7.1/src/conf/conf.h27
-rwxr-xr-xyhttpd-0.7.1/src/conf/lang.cpp67
-rwxr-xr-xyhttpd-0.7.1/src/conf/lang.h23
-rwxr-xr-xyhttpd-0.7.1/src/configure248
-rw-r--r--yhttpd-0.7.1/src/contrib/README5
-rw-r--r--yhttpd-0.7.1/src/contrib/xml/README504
-rw-r--r--yhttpd-0.7.1/src/contrib/xml/tinyxml.cpp1427
-rw-r--r--yhttpd-0.7.1/src/contrib/xml/tinyxml.h1368
-rw-r--r--yhttpd-0.7.1/src/contrib/xml/tinyxmlerror.cpp51
-rw-r--r--yhttpd-0.7.1/src/contrib/xml/tinyxmlparser.cpp1493
-rwxr-xr-xyhttpd-0.7.1/src/glob.h178
-rwxr-xr-xyhttpd-0.7.1/src/html.cpp129
-rwxr-xr-xyhttpd-0.7.1/src/html.h39
-rwxr-xr-xyhttpd-0.7.1/src/incl.h9
-rwxr-xr-xyhttpd-0.7.1/src/logd.cpp157
-rwxr-xr-xyhttpd-0.7.1/src/logd.h36
-rwxr-xr-xyhttpd-0.7.1/src/main.cpp159
-rw-r--r--yhttpd-0.7.1/src/maps/hmap.h96
-rw-r--r--yhttpd-0.7.1/src/maps/hmap.tmpl293
-rw-r--r--yhttpd-0.7.1/src/maps/mtools.h15
-rw-r--r--yhttpd-0.7.1/src/maps/mtools.tmpl11
-rw-r--r--yhttpd-0.7.1/src/maps/nmap.h25
-rw-r--r--yhttpd-0.7.1/src/maps/nmap.tmpl31
-rw-r--r--yhttpd-0.7.1/src/maps/smap.h57
-rw-r--r--yhttpd-0.7.1/src/maps/smap.tmpl219
-rwxr-xr-xyhttpd-0.7.1/src/modl.cpp161
-rwxr-xr-xyhttpd-0.7.1/src/modl.h37
-rw-r--r--yhttpd-0.7.1/src/msgs.h101
-rwxr-xr-xyhttpd-0.7.1/src/name.cpp51
-rwxr-xr-xyhttpd-0.7.1/src/name.h28
-rwxr-xr-xyhttpd-0.7.1/src/ncur/menu.cpp118
-rwxr-xr-xyhttpd-0.7.1/src/ncur/menu.h34
-rwxr-xr-xyhttpd-0.7.1/src/ncur/ncur.cpp263
-rwxr-xr-xyhttpd-0.7.1/src/ncur/ncur.h44
-rwxr-xr-xyhttpd-0.7.1/src/reqp.cpp297
-rwxr-xr-xyhttpd-0.7.1/src/reqp.h49
-rw-r--r--yhttpd-0.7.1/src/sock/Makefile23
-rw-r--r--yhttpd-0.7.1/src/sock/README1
-rwxr-xr-xyhttpd-0.7.1/src/sock/sock.cpp257
-rwxr-xr-xyhttpd-0.7.1/src/sock/sock.h69
-rw-r--r--yhttpd-0.7.1/src/stats.cpp102
-rw-r--r--yhttpd-0.7.1/src/stats.h36
-rwxr-xr-xyhttpd-0.7.1/src/thrd/pool.cpp206
-rwxr-xr-xyhttpd-0.7.1/src/thrd/pool.h77
-rwxr-xr-xyhttpd-0.7.1/src/thrd/thrd.cpp26
-rwxr-xr-xyhttpd-0.7.1/src/thrd/thrd.h28
-rw-r--r--yhttpd-0.7.1/src/thrd/thro.cpp45
-rw-r--r--yhttpd-0.7.1/src/thrd/thro.h30
-rwxr-xr-xyhttpd-0.7.1/src/time/timo.cpp36
-rwxr-xr-xyhttpd-0.7.1/src/time/timo.h22
-rwxr-xr-xyhttpd-0.7.1/src/time/timr.cpp167
-rwxr-xr-xyhttpd-0.7.1/src/time/timr.h63
-rw-r--r--yhttpd-0.7.1/src/tool/dir.cpp66
-rw-r--r--yhttpd-0.7.1/src/tool/dir.h33
-rw-r--r--yhttpd-0.7.1/src/tool/tool.cpp145
-rw-r--r--yhttpd-0.7.1/src/tool/tool.h97
-rwxr-xr-xyhttpd-0.7.1/src/wrap.cpp32
-rwxr-xr-xyhttpd-0.7.1/src/wrap.h67
62 files changed, 9973 insertions, 0 deletions
diff --git a/yhttpd-0.7.1/src/Makefile.in b/yhttpd-0.7.1/src/Makefile.in
new file mode 100755
index 0000000..262f3a6
--- /dev/null
+++ b/yhttpd-0.7.1/src/Makefile.in
@@ -0,0 +1,21 @@
+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-0.7.1/src/cli/cli.cpp b/yhttpd-0.7.1/src/cli/cli.cpp
new file mode 100755
index 0000000..dd70b4c
--- /dev/null
+++ b/yhttpd-0.7.1/src/cli/cli.cpp
@@ -0,0 +1,265 @@
+#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;
+#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
+ << CLIPRMO << " (m)ysql - Runs MySQL client on yhttpd DB" << endl;
+ cout << 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 (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
+ << CLIPRMO << " (unl)oad - Unloads all loaded modules" << endl
+ << CLIPRMO << " (u)nset VAR - Deltetes configuration value VAR" << endl
+ << CLIPRMO << " (v)ersion - Prints out version" << endl;
+ 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 << CLIWELC << endl;
+ cout << CLIPRMI;
+ }
+#ifdef NCURSES
+ else if( s_input.compare("exit") == 0 || s_input.compare("ex") == 0 )
+ {
+ return 0;
+ }
+#endif
+ else if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 )
+ {
+ cout << CLIPRMO;
+ wrap::MODL->reload_modules();
+ cout << CLIPRMI;
+ }
+#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("unl") == 0 || s_input.compare("unload") == 0 ) {
+ cout << CLIPRMO;
+ wrap::MODL->unload_modules();
+ 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;
+}
+
+#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-0.7.1/src/cli/cli.h b/yhttpd-0.7.1/src/cli/cli.h
new file mode 100755
index 0000000..2c37c17
--- /dev/null
+++ b/yhttpd-0.7.1/src/cli/cli.h
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <iostream>
+#include <vector>
+
+#ifndef RUSAGE_SELF
+#define RUSAGE_SELF 0
+#endif
+#ifndef RUSAGE_CHILDREN
+#define RUSAGE_CHILDREN -1
+#endif
+
+#include "../incl.h"
+
+#ifndef CLI_H
+#define CLI_H
+#ifdef CLI
+
+#ifndef NCURSES
+#include "../thrd/thro.h"
+#endif
+
+using namespace std;
+
+class cli
+#ifndef NCURSES
+: public thro
+#endif
+{
+private:
+ int parse_input( string s_input );
+
+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-0.7.1/src/conf/conf.cpp b/yhttpd-0.7.1/src/conf/conf.cpp
new file mode 100755
index 0000000..99347e9
--- /dev/null
+++ b/yhttpd-0.7.1/src/conf/conf.cpp
@@ -0,0 +1,155 @@
+// class conf implementation.
+
+#ifndef CONF_CPP
+#define CONF_CPP
+
+#include <fstream>
+#include "conf.h"
+
+using namespace std;
+
+conf::conf( string s_conf, map<string,string>* p_start_params ) : nmap<string,string>::nmap(HMAPOCC), 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<string> vec_string;
+ parse_xml(p_xml, &vec_string);
+
+ nmap<string,string>::add_elem_insecure(tool::yhttpd_version(), "yhttpd.version");
+
+ // Overrides yhttpd.conf values with command line options (yhttpd -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;
+}
+
+void
+conf::parse_xml(TiXmlNode* p_node, vector<string>* p_vec)
+{
+ if ( p_node->NoChildren() )
+ return;
+
+ for ( TiXmlNode* p_child = p_node->FirstChild(); p_child; p_child = p_child->NextSibling() )
+ {
+ //cout << p_vec->size() << ": (Value:" << p_child->Value() << ") (Type:" << p_child->Type() << ")" << endl;
+
+ if ( strcmp(p_child->Value(),"category") == 0)
+ {
+ p_vec->push_back(p_child->ToElement()->Attribute("name"));
+ parse_xml(p_child, p_vec);
+ p_vec->pop_back();
+ }
+
+ else if ( strcmp(p_child->Value(),"option") == 0)
+ {
+ string s_option_name = "";
+
+ for ( vector<string>::iterator iter = p_vec->begin(); iter != p_vec->end(); ++iter )
+ s_option_name.append(*iter + ".");
+
+ TiXmlElement* p_element = p_child->ToElement();
+ exit_if_xml_error();
+
+ s_option_name.append(p_element->Attribute("name"));
+
+#ifdef VERBOSE
+ cout << XMLREAD << s_option_name;
+#endif
+
+ TiXmlNode *p_node_value = p_element->FirstChild("value");
+ TiXmlNode *p_node_descr = p_element->FirstChild("descr");
+
+ TiXmlText* p_text_value = NULL;
+ TiXmlText* p_text_descr = NULL;
+
+ if ( p_node_value && p_node_value->FirstChild() )
+ p_text_value = p_node_value->FirstChild()->ToText();
+
+ if ( p_node_descr && p_node_descr->FirstChild() )
+ p_text_descr = p_node_descr->FirstChild()->ToText();
+
+ if ( !p_text_value )
+ continue;
+
+#ifdef VERBOSE
+ cout << " := " << p_text_value->Value() << endl;
+#endif
+
+ nmap<string,string>::add_elem_insecure(p_text_value->Value(), s_option_name);
+
+ if ( !p_text_descr )
+ continue;
+
+ s_option_name.append(".descr");
+#ifdef VERBOSE
+ cout << XMLREAD << s_option_name << endl;
+#endif
+ nmap<string,string>::add_elem_insecure(p_text_descr->Value(), s_option_name);
+ }
+ }
+
+ exit_if_xml_error();
+}
+
+conf::~conf()
+{
+ delete p_xml;
+}
+
+void
+conf::exit_if_xml_error() const
+{
+ if ( p_xml->Error() )
+ {
+ cout << XMLERR << p_xml->ErrorDesc() << endl;
+ exit(1);
+ }
+}
+
+#endif
diff --git a/yhttpd-0.7.1/src/conf/conf.h b/yhttpd-0.7.1/src/conf/conf.h
new file mode 100755
index 0000000..7508872
--- /dev/null
+++ b/yhttpd-0.7.1/src/conf/conf.h
@@ -0,0 +1,27 @@
+// class conf declaration. this class parses the server config file.
+
+#ifndef CONF_H
+#define CONF_H
+
+class conf;
+
+#include "../incl.h"
+#include "../maps/nmap.h"
+#include "../name.h"
+#include "../contrib/xml/tinyxml.h"
+
+using namespace std;
+
+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);
+public:
+ //conf ( string s_conf );
+ conf ( string s_conf, map<string,string>* p_start_params );
+ ~conf();
+};
+
+#endif
diff --git a/yhttpd-0.7.1/src/conf/lang.cpp b/yhttpd-0.7.1/src/conf/lang.cpp
new file mode 100755
index 0000000..04dd13b
--- /dev/null
+++ b/yhttpd-0.7.1/src/conf/lang.cpp
@@ -0,0 +1,67 @@
+#ifndef LANG_CPP
+#define LANG_CPP
+
+#include <fstream>
+#include "lang.h"
+
+using namespace std;
+
+lang::lang( string s_lang = "en" ) : nmap<string,string>::nmap(HMAPOCC), name::name( s_lang )
+{
+ parse( ); // parse the config file.
+}
+
+lang::~lang()
+{}
+
+void
+lang::parse()
+{
+ // wrap::system_message( CFILEOK + get_name() );
+
+ string filename(wrap::CONF->get_elem("LANGUAGE_DIR"));
+ filename.append(get_name()+".txt");
+
+ ifstream fs_conf( filename.c_str() );
+
+ if ( ! fs_conf )
+ {
+ // wrap::system_message( CFILEOFF + get_name() );
+ return;
+ }
+
+ char c_buf[READBUF];
+
+ while( fs_conf.getline( c_buf, READBUF ) )
+ {
+ string s_token( c_buf );
+ unsigned int ui_pos = s_token.find( "#", 0 );
+
+ // if line is commented out:
+ if ( ui_pos == 0 )
+ continue;
+
+ ui_pos = s_token.find( ";", 0 );
+
+ // if token has not been found.
+ if ( ui_pos == string::npos )
+ continue;
+
+ s_token = s_token.substr( 0 , --ui_pos );
+ ui_pos = s_token.find ( "\"", 0 );
+
+ if ( ui_pos == string::npos )
+ continue;
+
+ string s_val = s_token.substr( ui_pos+1, s_token.length() );
+ string s_key = s_token.substr( 0 , --ui_pos );
+
+ // fill the map.
+ nmap<string,string>::add_elem(s_val, s_key );
+ }
+