summaryrefslogtreecommitdiff
path: root/html.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'html.cpp')
-rw-r--r--[-rwxr-xr-x]html.cpp65
1 files changed, 41 insertions, 24 deletions
diff --git a/html.cpp b/html.cpp
index 3b9ed18..2e6b977 100755..100644
--- a/html.cpp
+++ b/html.cpp
@@ -1,23 +1,36 @@
// class html implementation.
-#ifndef s_html_CXX
-#define s_html_CXX
+#ifndef HTML_CXX
+#define HTML_CXX
#include <fstream>
#include "html.h"
-#include "s_chat.h"
-#include "s_mutx.h"
+#include "CHAT.h"
+#include "MUTX.h"
using namespace std;
html::html( )
{
- set_name( s_conf::get().get_val( "HTMLTEMP" ) );
+#ifdef VERBOSE
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "html::html()" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
+
+ set_name( CONF::get().get_val( "HTMLTEMP" ) );
+
pthread_mutex_init( &mut_map_vals, NULL );
}
html::~html( )
{
+#ifdef VERBOSE
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "html::~html()" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
+
pthread_mutex_destroy( &mut_map_vals );
}
@@ -32,6 +45,13 @@ html::clear_cache( )
string
html::parse( map_string &map_params )
{
+
+#ifdef VERBOSE_
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "html::parse( map_string& )" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
+
string s_file = map_params["request"];
// check if s_file is in the container.
@@ -43,34 +63,25 @@ html::parse( map_string &map_params )
if ( s_templ.empty() )
{
auto string s_path = get_name();
- auto ifstream fs_templ( s_path.append( s_file ).c_str(), ios::binary );
+ auto ifstream fs_templ( s_path.append( s_file ).c_str() );
if ( ! fs_templ )
{
-
- cerr << "File not found: " << s_file << endl;
- if(map_params["request"]==s_conf::get().get_val( "NOTFOUND" ))
- return "";
-
- map_params["request"] = s_conf::get().get_val( "NOTFOUND" );
+ map_params["request"] = CONF::get().get_val( "NOTFOUND" );
return parse( map_params );
-
}
- auto char c_buf;
+ auto char c_buf[READBUF];
+
+ while( fs_templ.getline( c_buf, READBUF ) )
+ s_templ.append( string( c_buf ).append( "\n" ) );
- while( !fs_templ.eof() )
- {
- fs_templ.get( c_buf );
- s_templ+=c_buf;
- }
-
fs_templ.close();
-#ifdef VERBOSE
- pthread_mutex_lock ( &s_mutx::get().mut_stdout );
+#ifdef _VERBOSE
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
cout << TECACHE << s_path << endl;
- pthread_mutex_unlock( &s_mutx::get().mut_stdout );
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
#endif
// cache file.
@@ -98,7 +109,7 @@ html::parse( map_string &map_params )
// get key and val.
auto string s_key = s_templ.substr( pos[0], pos[1]-pos[0] );
- auto string s_val = s_conf::get().get_val( s_key );
+ auto string s_val = CONF::get().get_val( s_key );
// if s_val is empty use map_params.
if ( s_val.empty() )
@@ -121,6 +132,12 @@ html::parse( map_string &map_params )
void
html::online_list( user *p_user, map_string &map_params )
{
+#ifdef VERBOSE_
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "html::online_list( user*, map_string& )" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
+
// prepare user_list.
string s_list ( "" );
string s_seperator( "<br>" );