summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:45 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:45 +0200
commit5f4e214740242513c837c8a005ca23779bab1d0c (patch)
tree3880f745b0d3376030e3342e60679f25b38bdc4c /src
parent23c5e7d57e1e9216f4da3446656df2dc7202975d (diff)
tagging ychat-0.8.2ychat-0.8.2
Diffstat (limited to 'src')
-rwxr-xr-xsrc/Makefile.in8
-rwxr-xr-xsrc/chat/chat.cpp9
-rwxr-xr-xsrc/chat/user.cpp87
-rwxr-xr-xsrc/chat/user.h35
-rwxr-xr-xsrc/cli/cli.cpp46
-rwxr-xr-xsrc/cli/cli.h16
-rwxr-xr-xsrc/conf/conf.cpp36
-rwxr-xr-xsrc/conf/conf.h6
-rwxr-xr-xsrc/configure154
-rw-r--r--src/contrib/README4
-rw-r--r--src/contrib/xml/README2
-rwxr-xr-xsrc/glob.h55
-rwxr-xr-xsrc/html.cpp16
-rwxr-xr-xsrc/html.h2
-rwxr-xr-xsrc/logd.cpp2
-rwxr-xr-xsrc/main.cpp15
-rw-r--r--src/maps/hashmap.h14
-rw-r--r--src/maps/nhashmap.h8
-rw-r--r--src/maps/shashmap.h12
-rw-r--r--src/maps/shashmap.tmpl8
-rwxr-xr-xsrc/modl.cpp149
-rwxr-xr-xsrc/modl.h30
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_gag.cpp24
-rwxr-xr-xsrc/mods/commands/yc_q.cpp2
-rwxr-xr-x[-rw-r--r--]src/mods/commands/yc_ungag.cpp24
-rw-r--r--src/monitor/dump.cpp38
-rw-r--r--src/monitor/dump.h31
-rw-r--r--src/monitor/stats.cpp48
-rw-r--r--src/monitor/stats.h13
-rw-r--r--[-rwxr-xr-x]src/msgs.h31
-rwxr-xr-xsrc/ncur/ncur.cpp45
-rwxr-xr-xsrc/reqp.cpp91
-rwxr-xr-xsrc/reqp.h1
-rw-r--r--src/sign.cpp21
-rw-r--r--src/sign.h4
-rwxr-xr-xsrc/sock/sock.cpp75
-rwxr-xr-xsrc/sock/sock.h15
-rwxr-xr-xsrc/time/timo.h2
-rwxr-xr-xsrc/time/timr.cpp21
-rw-r--r--src/tool/tool.cpp4
-rw-r--r--src/tool/tool.h2
-rwxr-xr-xsrc/wrap.cpp36
-rwxr-xr-xsrc/wrap.h43
43 files changed, 978 insertions, 307 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 262f3a6..0382389 100755
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -6,16 +6,16 @@ LDFLAGS=$(LIBADD) -lstdc++
LDADD=-pthread -D_THREAD_SAFE -export-dynamic -ldl
INCLUDES=`cat includes.add`
CFLAGS=-fno-inline -fno-default-inline -frepo
-all: yhttpd
+all: ychat
$(SRCS):
$(CC) $(INCLUDES) $(CFLAGS) -c $*.cpp
infotext:
@echo Compiling base
-yhttpd: infotext $(OBJS)
+ychat: infotext $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
- @mv yhttpd ../bin
+ @mv ychat ../bin
@echo -n "Size of linked executable: "
- @du -hc ../bin/yhttpd | tail -n 1
+ @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/chat.cpp b/src/chat/chat.cpp
index e405472..ed8f48d 100755
--- a/src/chat/chat.cpp
+++ b/src/chat/chat.cpp
@@ -170,7 +170,6 @@ chat::login( map<string,string> &map_params )
map_params["tmpid"] = p_sess->get_tmpid();
p_user->set_tmpid( map_params["tmpid"] );
p_user->set_has_sess( true );
- wrap::system_message("New tmpid: " + map_params["tmpid"] );
}
}
else // if ( p_user == NULL ) // If not in garbage create a new user!
@@ -224,7 +223,6 @@ chat::login( map<string,string> &map_params )
sess* p_sess = wrap::SMAN->create_session();
p_sess->set_user(p_user);
map_params["tmpid"] = p_sess->get_tmpid();
- wrap::system_message("New tmpid: " + map_params["tmpid"] );
p_user->set_tmpid( map_params["tmpid"] );
p_user->set_col1( map_params["color1"] );
p_user->set_col2( map_params["color2"] );
@@ -328,6 +326,13 @@ chat::post( user* p_user, map<string,string> &map_params )
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;
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
index 2b76ec8..eb49f8c 100755
--- a/src/chat/user.cpp
+++ b/src/chat/user.cpp
@@ -25,6 +25,7 @@ user::~user()
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 );
@@ -41,11 +42,14 @@ user::~user()
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 = 0;
this -> b_is_reg = false;
+ this -> b_is_gag = false;
this -> b_set_changed_data = false;
this -> b_away = false;
this -> b_fake = false;
@@ -60,6 +64,7 @@ user::initialize()
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 );
@@ -72,7 +77,6 @@ user::initialize()
pthread_cond_init ( &cond_message, NULL);
pthread_mutex_init( &mut_message , NULL);
renew_timeout();
-
}
void
@@ -181,6 +185,16 @@ user::get_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;
+}
+
void
user::set_is_reg( bool b_is_reg )
{
@@ -188,6 +202,14 @@ user::set_is_reg( bool 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 );
+}
+
+void
user::set_online( bool b_online )
{
pthread_mutex_lock ( &mut_b_online );
@@ -489,13 +511,52 @@ user::msg_post( string *p_msg )
}
void
-user::check_timeout( int* i_idle_timeout )
+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");
+}
+
+void
+user::renew_timeout()
{
- int i_user_timeout = (int) get_last_activity();
+ timo::renew_timeout();
+ double d_time_diff = wrap::TIMR->get_time_diff(t_flood_time);
- if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout )
+ if (d_time_diff < static_cast<double>(wrap::CONF->get_int("chat.floodprotection.seconds")))
{
- wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
+ 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;
+ }
+}
+
+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>";
@@ -504,9 +565,9 @@ user::check_timeout( int* i_idle_timeout )
pthread_cond_signal( &cond_message );
}
- else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout )
+ else if ( ! get_away() && i_idle_timeout[2] <= d_user_timeout )
{
- wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_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";
@@ -599,5 +660,17 @@ user::dumpit()
("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 62814b5..06310ca 100755
--- a/src/chat/user.h
+++ b/src/chat/user.h
@@ -23,16 +23,19 @@ 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_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.
+ 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.
@@ -55,6 +58,7 @@ private:
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;
@@ -94,15 +98,14 @@ public:
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_changed_data_on()
- {
- b_set_changed_data = 1;
- }
+ 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 );
@@ -122,7 +125,9 @@ public:
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 );
@@ -142,6 +147,8 @@ public:
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);
};
#endif
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index 0adddb1..0e7b531 100755
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -31,7 +31,7 @@ cli::parse_input( string s_input )
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;
+ << CLIPRMO << " !command - Uses system to run a command" << endl;
#ifdef DEBUG
cout << CLIPRMO << " (d)ebug - Starts debug routine (cli.cpp)" << endl;
@@ -47,17 +47,22 @@ cli::parse_input( string s_input )
#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 (yhttpd needs to run > 1 day)" << 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;
@@ -110,6 +115,19 @@ cli::parse_input( string s_input )
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 )
@@ -118,11 +136,20 @@ cli::parse_input( string s_input )
}
#endif
+ //<<*
+ else if( s_input.compare("reload") == 0 || s_input.compare("rel") == 0 )
+ {
+ cout << CLIPRMO;
+ wrap::MODL->reload_modules();
+ cout << MODRELO << endl;
+ cout << CLIPRMI;
+ }
+ //*>>
#ifdef EXPERIM
else if( s_input.compare("reconf") == 0 || s_input.compare("re") == 0 )
{
- wrap::HTTPD->reconf();
+ wrap::CHAT->reconf();
cout << CLIPRMI;
}
#endif
@@ -183,6 +210,15 @@ cli::parse_input( string s_input )
cout << CLIPRMI;
}
+ //<<*
+ else if( s_input.compare("unl") == 0 || s_input.compare("unload") == 0 )
+ {
+ cout << CLIPRMO;
+ wrap::MODL->unload_modules();
+ cout << MODUNLO << endl;
+ cout << CLIPRMI;
+ }
+ //*>>
else if( s_input.compare("u") == 0 || s_input.compare("unset") == 0 )
{
@@ -203,7 +239,7 @@ cli::parse_input( string s_input )
}
else if( s_input.compare("v") == 0 || s_input.compare("version") == 0 )
{
- cout << CLIPRMO << tool::yhttpd_version() << " " << UNAME << endl;
+ cout << CLIPRMO << tool::ychat_version() << " " << UNAME << endl;
cout << CLIPRMI;
}
else
@@ -259,7 +295,7 @@ cli::print_rusage()
}
vector<string>
-cli::vectorize(string s_param)
+cli::vectorize(string s_param)
{
vector<string> vec_ret;
unsigned i_pos;
diff --git a/src/cli/cli.h b/src/cli/cli.h
index 7d51e3f..8ec75cb 100755
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -30,30 +30,30 @@ using namespace std;
class cli : public thro
{
#else
-class cli
+class cli
{
#endif
private:
int parse_input(string s_input);
vector<string> vectorize(string s_param);
-
+
public:
-cli( );
-~cli( );
+ cli( );
+ ~cli( );
#ifdef DEBUG
-void debug_routine();
+ void debug_routine();
#endif
-void print_rusage();
+ void print_rusage();
#ifndef NCURSES
-void start(void* p_void);
+ void start(void* p_void);
#else
-void start();
+ void start();
#endif
};
diff --git a/src/conf/conf.cpp b/src/conf/conf.cpp
index 5d5a535..a4a2679 100755
--- a/src/conf/conf.cpp
+++ b/src/conf/conf.cpp
@@ -6,11 +6,11 @@
using namespace std;
-conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_conf )
+conf::conf( string s_conf, map<string,string>* p_main_loop_params ) : name::name( s_conf )
{
string s_check[] = {
get_name(),
- string(getenv("HOME"))+string("/.yhttpd/") + get_name(),
+ string(getenv("HOME"))+string("/.ychat/") + get_name(),
string("./etc/") + get_name(),
string("/etc/") + get_name(),
string(PREFIX+string("etc/")+get_name()) };
@@ -54,11 +54,11 @@ conf::conf( string s_conf, map<string,string>* p_start_params ) : name::name( s_
vector<string> vec_string;
parse_xml(p_xml, &vec_string);
- shashmap<string>::add_elem_insecure(tool::yhttpd_version(), "yhttpd.version");
+ shashmap<string>::add_elem_insecure(tool::ychat_version(), "ychat.version");
- // Overrides yhttpd.conf values with command line options (yhttpd -o key1 value1 -o key2 value2 ...)
+ // 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++ )
+ 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);
@@ -161,11 +161,35 @@ conf::exit_if_xml_error() const
}
}
+//<<*
+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";
+}
+//*>>
int
conf::get_int(string s_key)
{
- return tool::string2int(get_elem(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 b385059..7dc779c 100755
--- a/src/conf/conf.h
+++ b/src/conf/conf.h
@@ -19,10 +19,12 @@ private:
void parse_xml( TiXmlNode* p_node, vector<string>* p_vec);
public:
- conf(string s_conf, map<string,string>* p_start_params);
+ conf(string s_conf, map<string,string>* p_main_loop_params);
~conf();
- int get_int(string s_key);
+ string colored_error_msg(string s_key); //<<
+ int get_int(string s_key);
+ vector<string> get_vector(string s_key);
};
#endif
diff --git a/src/configure b/src/configure
index 5577c10..43854d8 100755
--- a/src/configure
+++ b/src/configure
@@ -1,7 +1,7 @@
#!/bin/sh
#
-# The yhttpd Project (2003 - 2005)
+# The yChat Project (2003 - 2005)
#
if ! ../scripts/checkperl.sh
@@ -26,14 +26,19 @@ perl -e '
my @headers = (
"dlfcn.h",
"pthread.h",
+ "mysql/mysql.h", #//<< Not needed for yhttpd
"netinet/in.h",
"time.h",
"ncurses.h",
+ "openssl/ssl.h",
"::test::ext/hash_map"
);
my @libs = (
- "libncurses.so"
+ "libmysqlclient.so", #//<< Not needed for yhttpd
+ "libncurses.so",
+ "libssl.so",
+ "libcrypto.so"
);
my @headerpaths = (
@@ -59,36 +64,76 @@ perl -e '
"/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(<FILE>)
- {
- if ( /\/\/#define DATABASE/ )
- {
+ while(<FILE>) {
+ 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 NCURSES/ )
- {
- remove_from_array("ncurses.h",\@headers);
- remove_from_array("libncurses.so",\@libs);
+ 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{YCHATHEADERPATHS} ) {
+ map { print "Adding $_...\n"; unshift @headerpaths, $_ }
+ split /:/, $ENV{YCHATHEADERPATHS};
}
- if ( defined $ENV{YHTTPDLIBPATHS} )
- {
- map { print "Adding $_...\n";
- unshift @libpaths, $_ } split /:/, $ENV{YHTTPDLIBPATHS};
+ if ( defined $ENV{YCHATLIBPATHS} ) {
+ map { print "Adding $_...\n"; unshift @libpaths, $_ }
+ split /:/, $ENV{YCHATLIBPATHS};
}
-
print "Headers:\n";
my $testit = 0;
@@ -103,10 +148,7 @@ perl -e '
my $incadd = &make_add("-I", \%incadd);
my $libadd = &make_add("-L", \%libadd);
- for ( @libs )
- {
- $libadd .= "-l$_ " if s/^lib// and s/\.so$//;
- }
+ for ( @libs ) { $libadd .= "-l$_ " if s/^lib// and s/\.so$//; }
print "Incadd: $incadd\n";
print "Libadd: $libadd\n";
@@ -133,8 +175,7 @@ perl -e '
chomp $cpp;
chomp $version;
- while (<Fin>)
- {
+ while (<Fin>) {
s/^(CC=).*\n/$1$compiler/;
s/^(SRCS=).*/$1$cpp/;
s/ -frepo//; # unless $version =~ /3\.4/;
@@ -148,8 +189,7 @@ perl -e '
my $args = join(" -",@ARGV);
$args = "-".$args unless $args eq "";
- for my $cppfile (split / /, $cpp)
- {
+ for my $cppfile (split / /, $cpp) {
my $ofile = $cppfile;
$ofile =~ s/\.cpp/\.o/;
print Fout "../obj/$ofile: $cppfile\n";
@@ -158,14 +198,12 @@ perl -e '
$class =~ s/\.o//;
my $text;
- if ( $class =~ /contrib\/.+/ )
- {
+ if ( $class =~ /contrib\/.+/ ) {
my $dirname = `dirname $class`;
$text = "\t\@echo -n \"Contributed class $class \"\n";
}
- else
- {
+ else {
$text = "\t\@echo -n \"Base class $class \"\n";
}
@@ -181,16 +219,14 @@ perl -e '
unlink("msgs.h");
open F, ">msgs.h" or die "msgs.h: $!\n";
- for (@msgs)
- {
+ for (@msgs) {
s/(UNAME)(.+)$/UNAME "$uname"/;
s/(COMPOPT)(.+)$/COMPOPT "$compopt"/;
print F;
}
close F;
- if ( -d "mods" )
- {
+ if ( -d "mods" ) {
chdir("mods");
my $cflags = "-fno-inline -fno-default-inline";
@@ -201,15 +237,12 @@ perl -e '
chdir("..");
}
- sub remove_from_array
- {
+ sub remove_from_array {
my $elem = shift;
my $array = shift;
- for ( my $i = 0; $i <= $#$array; ++$i )
- {
- if ( $$array[$i] eq $elem )
- {
+ for ( my $i = 0; $i <= $#$array; ++$i ) {
+ if ( $$array[$i] eq $elem ) {
splice(@$array,$i,1);
last;
}
@@ -233,24 +266,18 @@ perl -e '
pop(@_);
}
- if ($print)
- {
+ if ($print) {
print "Checking for $check...";
print "\n" if $testit;
}
- for (@_)
- {
- if ( -f "$_/$check" )
- {
- if ($testit)
- {
+ for (@_) {
+ if ( -f "$_/$check" ) {
+ if ($testit) {
return $_ if test_include($_, $check);
return "";
- }
- else
- {
+ } else {
print "OK\n";
return "" if $_ eq "/usr/lib" or $_ eq "/usr/include";
return $_;
@@ -258,28 +285,25 @@ perl -e '
}
}
- for (@_)