diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:42 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:42 +0200 |
| commit | 98eac951f8087b213f5850bd126dcb279db360a8 (patch) | |
| tree | c121f5c4df1aab847defa539990c1315bd5ba4a8 /mods | |
| parent | 0537da9d1e0f593130fc3967befb71e673b016bc (diff) | |
tagging ychat-0.6ychat-0.6
Diffstat (limited to 'mods')
| -rw-r--r-- | mods/commands/yc_col.cpp | 84 | ||||
| -rw-r--r-- | mods/commands/yc_m.cpp | 38 | ||||
| -rw-r--r-- | mods/commands/yc_me.cpp | 38 | ||||
| -rw-r--r-- | mods/commands/yc_q.cpp | 25 | ||||
| -rw-r--r-- | mods/commands/yc_template.cpp | 29 | ||||
| -rw-r--r-- | mods/commands/yc_test.cpp | 12 | ||||
| -rw-r--r-- | mods/commands/yc_version.cpp | 22 | ||||
| -rwxr-xr-x | mods/compile.sh | 9 | ||||
| -rw-r--r-- | mods/html/yc_help.cpp | 45 |
9 files changed, 302 insertions, 0 deletions
diff --git a/mods/commands/yc_col.cpp b/mods/commands/yc_col.cpp new file mode 100644 index 0000000..5b07c8b --- /dev/null +++ b/mods/commands/yc_col.cpp @@ -0,0 +1,84 @@ +#include <iostream> +#include "../../conf.h" +#include "../../room.h" +#include "../../user.h" +#include "../../s_tool.cpp" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +typedef vector<string> str_vector; + +extern "C" { + export int extern_function(void *v_arg); + int valid_color( string ); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + +// string *s_command_line=(string *)c->elem[0]; // contains the whole line + user *p_user = (user*)c->elem[1]; // the corresponding user + str_vector *params= (str_vector*) c->elem[2]; // param array + + string s_color; + string s_color2; + + conf* p_conf = (conf*) c->elem[3]; + + if ( params->empty() ) + { + s_color = p_conf->get_val( "USERCOL1" ); + s_color2 = p_conf->get_val( "USERCOL2" ); + } + + else + { + s_color = (string) params->front(); + params->erase( params->begin() ); + if ( ! params->empty() ) + s_color2 = (string) params->front(); + else + s_color2 = p_conf->get_val( "USERCOL2" ); + } + + s_color = s_tool::to_lower( s_color ); + s_color2 = s_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_user->get_colored_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); + } + } + 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/mods/commands/yc_m.cpp b/mods/commands/yc_m.cpp new file mode 100644 index 0000000..46b158f --- /dev/null +++ b/mods/commands/yc_m.cpp @@ -0,0 +1,38 @@ +#include <iostream> +#include "../../user.h" +#include "../../room.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +typedef vector<string> str_vector; + +extern "C" { + export int extern_function(void *v_arg); + 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 + str_vector *params= (str_vector*) c->elem[2]; // param array + + string s_msg = "<i>" + p_user->get_colored_name() + + " <font color=\"#" + p_user->get_col2() + + "\">"; + if ( ! params->empty() ) + { + str_vector::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 ); + + } +} + diff --git a/mods/commands/yc_me.cpp b/mods/commands/yc_me.cpp new file mode 100644 index 0000000..5ba5298 --- /dev/null +++ b/mods/commands/yc_me.cpp @@ -0,0 +1,38 @@ +#include <iostream> +#include "../../user.h" +#include "../../room.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +typedef vector<string> str_vector; + +extern "C" { + export int extern_function(void *v_arg); + 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 + str_vector *params= (str_vector*) c->elem[2]; // param array + + string s_msg = "<i><font color=\"#" +p_user->get_col1() + "\">" + + p_user->get_name() + " "; + + if ( ! params->empty() ) + { + str_vector::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 ); + + } +} + diff --git a/mods/commands/yc_q.cpp b/mods/commands/yc_q.cpp new file mode 100644 index 0000000..5776522 --- /dev/null +++ b/mods/commands/yc_q.cpp @@ -0,0 +1,25 @@ +#include <iostream> +#include "../../user.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + + +extern "C" { + export int extern_function(void *v_arg); + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + string *sCommandLine=(string *)c->elem[0]; + user *p_user = (user*)c->elem[1]; + + string *quitstring=new string("<script language=JavaScript>top.location.href='/index.html';</script>"); + p_user->msg_post( quitstring ); + p_user->set_online(false); + } +} + diff --git a/mods/commands/yc_template.cpp b/mods/commands/yc_template.cpp new file mode 100644 index 0000000..13be617 --- /dev/null +++ b/mods/commands/yc_template.cpp @@ -0,0 +1,29 @@ +#include <iostream> +#include "../../user.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +typedef vector<string> str_vector; + +extern "C" { + export int extern_function(void *v_arg); + + + int extern_function(void *v_arg) + { + container *c=(container *)v_arg; + + string *sCommandLine=(string *)c->elem[0]; // contains the whole line + user *p_user = (user*)c->elem[1]; // the corresponding user + str_vector *params=(str_vector*)c->elem[2]; // param array + + + string *quitstring=new string("Text to send<br>"); + p_user->msg_post( quitstring ); + } +} + diff --git a/mods/commands/yc_test.cpp b/mods/commands/yc_test.cpp new file mode 100644 index 0000000..deb3e54 --- /dev/null +++ b/mods/commands/yc_test.cpp @@ -0,0 +1,12 @@ +#include <iostream> + +using namespace std; + +extern "C" { + export int function(void *v_arg); + + int function(void *v_arg) + { + cout << "Hallo " << (char*)v_arg << endl; + } +} diff --git a/mods/commands/yc_version.cpp b/mods/commands/yc_version.cpp new file mode 100644 index 0000000..4ab7673 --- /dev/null +++ b/mods/commands/yc_version.cpp @@ -0,0 +1,22 @@ +#include <iostream> +#include "../../msgs.h" +#include "../../user.h" +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" { + export int extern_function(void *v_arg); + 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( new string( *new string(VERSION) + "<br>\n") ); + } +} + diff --git a/mods/compile.sh b/mods/compile.sh new file mode 100755 index 0000000..2d2bd6f --- /dev/null +++ b/mods/compile.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +rm */*.so 2> /dev/null + +for i in */*cpp +do + echo Compiling $i + gcc -shared -o $(echo $i | sed s/cpp$/so/) $i +done diff --git a/mods/html/yc_help.cpp b/mods/html/yc_help.cpp new file mode 100644 index 0000000..a746004 --- /dev/null +++ b/mods/html/yc_help.cpp @@ -0,0 +1,45 @@ +#include <iostream> +#include <string> +#include "../../glob.h" +#include "../../hmap.h" +#include "../../lang.h" + +/* + gcc -shared -o yc_name.so yc_name.cpp +*/ + +using namespace std; + +extern "C" { + export int extern_function(void *v_arg); + + int extern_function(void *v_arg) + { + container* c = (container*) v_arg; + string* s_content = &(*((map_string*) c->elem[2]))["content"]; + lang* p_lang = (lang*) c->elem[0]; + + vector<string>* p_vec_keys = + ((hmap<dynmod*,string>*) c->elem[1])->get_key_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 ) + { + s_content->append( "<tr><td>" ); + string s_helptext = p_lang->get_val( *p_vec_keys_iter ) ; + + unsigned int i_pos = s_helptext.find( "||", 0 ); + if ( i_pos != string::npos ) + s_helptext.replace( i_pos, 2, "</td><td>" ); + + s_content->append( s_helptext ); + s_content->append( "</td></tr>\n" ); + } + p_vec_keys_iter++; + } + } +} + |
