logic.h File Reference


Detailed Description

Implements core logic stored in "logic.txt" file.

Definition in file logic.h.

#include <vector>
#include <map>
#include <list>
#include <string>
#include "shared.h"
#include "win_sock.h"

Include dependency graph for logic.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LOGIC_NO_SERVER   -7
 No irc server in the list.
#define LOGIC_OK   0
 Ok, no error.
#define LOGIC_PROC_BAD_NUM   -3
 Bad number.
#define LOGIC_PROC_BAD_SYNTAX   -4
 Bad syntax.
#define LOGIC_PROC_BAD_TEXT   -2
 Bad text.
#define LOGIC_PROC_NOT_FOUND   -1
 Procedure not found.
#define LOGIC_RESTART   -6
 Bot wants to be restarted ("restart" command).
#define LOGIC_SOCKET_ERROR   -5
 Socket I/O error.

Functions

bool logic_access_to_filesystem (string user)
 Check wheter user has access to the filesystem.
bool logic_access_to_partyline (string nick, string ident, string host, string fullname, bool irc_op, string &user_name_as_in_logic)
 Looks up and find user as specified in logic.txt, and checks if user has access to partyline.
void logic_botnet_backup (string who)
 Writes new "logic.txt" file.
void logic_botnet_rehash (string who)
 Rehashes new backed up configuration (should be called from BOTNET) and performs rollback to old backed up file(s) if parse error occurs.
void logic_botnet_remove_user (string username)
 Removes user.
int logic_call_proc (const char *call_string)
 Calls a procedure.
int logic_call_proc_ex (const char *call_string, map< string, string > vars)
int logic_call_proc_ex2 (const char *call_string, map< string, string > &vrs, list< string > &params, bool from_work=false)
 Calls a procedure.
bool logic_check_mask (string mask1, string mask2, string fnm1, string fnm2)
 Checks mask to match (advanced with DNS resolution).
string logic_eval (string str, map< string, string > &vars)
 Looks up and evalueates variable beginning with '$' sign, if it is possible.
int logic_exec_from_work ()
 Continues execution after "work" command.
void logic_execute (string call_string, map< string, string > &vars)
 Executes procedure as callstring with arguments.
void logic_filesys_got_new (string user_name, string nick, string ident, string host, string internal_name)
 Executes on_filesys_got_new event.
string logic_find_proc_by_name (string name)
 Finds procedure by name (without declatarion).
string logic_find_user (string nick, string ident, string host, string fullname, bool irc_op)
 Looks up and find user as specified in logic.txt.
void logic_fnc (string old_nick, string new_nick)
 Executes on_fnc event.
string logic_get_dcc_host (int dcc_group, string user_name_as_in_logic)
 Retrieves host for DCC by DCC gorup and user's name.
bool logic_is_replication_partner (string user_name_as_in_logic)
 Checks wheter user (the bot) is replication partner.
void logic_list_proc (string proc_name, list< string > &commands, string &declaration, vector< string > &groups)
 Lists procedure's commands.
bool logic_load_conf (const char *filename, int &error_on_line, const char *&error_reason)
 Loads logic.txt file and parses it.
void logic_loop ()
 This should be called in a loop. Executes timers and processes script output with freeing resources.
void logic_loop_identd ()
 Handled IDENT request - this should be called in a loop.
void logic_on_banned (string channel, string ban_mask, vector< string > excepts, vector< string > invites, vector< string > &bans)
 Executes on_banned event (called when bot JOINs the channel and finds out that some user is banned by ban mask) also checks whether user is not +e excepted or +I invited, which overrides the ban mask.
void logic_on_broadcast (string username, string nick, string ident, string host, string bcast_mask, int type, string msg, string server, unsigned short port)
 Raises on_broadcast event.
void logic_on_flood (string channel, string user, string nick, int type, int stat_num, time_t stat_sec, time_t stat_sec_of)
 Executes on_flood event procedure.
void logic_on_internal_event (string type, string flags1, string flags2, string flags3, string flags4, int severity_numeric, string msg1, string msg2)
 Raises on_intenal_event event.
void logic_on_ircop (string channel, string nick, bool on)
 Executes procedure for event on_ircop (when an IRC operator joins / is on after bot's join / left channel).
void logic_on_join (string nick, string ident, string host, string fullname, string channel, bool irc_op)
 Executes on_join event (called when someone JOINs the channel).
void logic_on_nick_change (string nick, string ident, string host, string fullname, string channel, bool irc_op, string old_nick)
 Validates new nick.
void logic_on_nick_validate (string nick, string ident, string host, string fullname, string channel, bool irc_op, bool passive=false)
 Validates user after bot has joined / got +o (op) / rehashed.
void logic_on_not_in_reop (string channel, string mask, string user_name)
 Executes on_not_in_reop event (called when bot JOINs the channel and finds out that some user is not in reop list by +R).
void logic_on_not_invited (string channel, string mask, string user_name)
 Executes on_not_invited event (called when bot JOINs the channel and finds out that some user is not invited by +I).
void logic_on_notice (string channel, string user, string nick, string msg)
 Executes on_notice event procedure.
void logic_on_part (string channel, string nick, string msg, int type)
 Executes on_part event procedure.
void logic_on_privmsg (string channel, string username, string nick, string msg)
 Executes on_privmsg event procedure.
void logic_on_privmsg_query (string user, string nick, string msg)
 Executes on_privmsg event procedure (for query only - not channel).
void logic_on_server_msg (string channel, string source, int type, string msg, string server, unsigned short port)
 Raises on_server_msg event.
void logic_parse_proc (const char *&error_reason, int &error_line, list< string > commands, bool copy_to_r_procedures, string declaration, vector< string > groups)
 Parses and compiles procedure (for partyline).
void logic_partyline_backup (string who)
 Forces to writes all object to logic.txt file.
void logic_partyline_get_channels (vector< string > &channels)
 Retrieves list of known channels (channel must reflect at least one time in logic.txt).
void logic_partyline_get_user (string user_name, s_user &user, vector< s_channel > &channels)
 Retrieves an user with channels.
void logic_partyline_get_user_template (string user_name, s_user &user, vector< s_channel > &channels)
 Retrieves an user template with channels.
string logic_partyline_rehash (string lang, string eol, string who)
 Rehashes new backed up configuration (should be called from DCC / telnet) and performs rollback to old backed up file(s) if parse error occurs.
void logic_partyline_remove_user (string username)
 Removes user or user template defined in logic.txt.
bool logic_partyline_user_exists (string name)
 Checks if such user defined in logic.txt exists.
int logic_partyline_whois (string lang, string param1, list< string > &lines)
 Retrieves full whois list for users of mask param1 (".whois" command on partyline).
unsigned long logic_resolve (string host)
 Resolves DNS hostname to IPv4 addres, if possible, from internal resolve cache.
in_addr6_ logic_resolve6 (string host)
 Resolves DNS hostname to IPv6 addres, if possible, from internal resolve cache.
string logic_script_esc (string script_type, string str)
 Escapes a string.
void logic_set_dynamic (string username, string from_user, char prefix, char mode)
 Adds/remove new dynamic mode for user on channel, but only when group relationship and setting allows it.
void logic_validate (string channel, string source_user, string target_user, string source_nick, string target_nick, char prefix, char action)
 Validates MODE change and, if needed, executes on_XXX event.
void logic_validate_by_mask (string channel, string source_user, string source_nick, string mask, char prefix, char action)
 Validates MODE change and, if needed, executes on_XXX event.
void logic_validate_chan_key (string channel, string source_user, string source_nick, char prefix, string key)
 Validates the key change (+/-k) for the channel and (if needed) calls event, and adds a key to the history.
void logic_validate_chan_limit (string channel, string source_user, string source_nick, char prefix, string limit)
 Validates the limit change (+/-l) for the channel and (if needed) calls event.
void logic_validate_chan_mode (string channel, string source_user, string source_nick, char prefix, char mode)
 Validates the mode change of the channel and (if needed) calls events.
void logic_validate_kick (string channel, string source_user, string target_user, string source_nick, string target_nick)
 Validates KICK and, if needed, executes on_kick event.
void logic_validate_topic (string channel, string source_user, string source_nick, string topic)
 Validates the topic change and (if assigned) calls event.


Define Documentation

#define LOGIC_NO_SERVER   -7
 

No irc server in the list.

Definition at line 78 of file logic.h.

Referenced by logic_call_proc_ex2(), logic_exec(), and main().

#define LOGIC_OK   0
 

Ok, no error.

Definition at line 83 of file logic.h.

Referenced by logic_call_proc_ex().

#define LOGIC_PROC_BAD_NUM   -3
 

Bad number.

Definition at line 58 of file logic.h.

Referenced by logic_call_proc_ex().

#define LOGIC_PROC_BAD_SYNTAX   -4
 

Bad syntax.

Definition at line 63 of file logic.h.

Referenced by logic_call_proc_ex().

#define LOGIC_PROC_BAD_TEXT   -2
 

Bad text.

Definition at line 53 of file logic.h.

Referenced by logic_call_proc_ex().

#define LOGIC_PROC_NOT_FOUND   -1
 

Procedure not found.

Definition at line 48 of file logic.h.

Referenced by logic_call_proc_ex2().

#define LOGIC_RESTART   -6
 

Bot wants to be restarted ("restart" command).

Definition at line 73 of file logic.h.

Referenced by logic_ctcp(), logic_exec(), logic_filesys_got_new(), logic_fnc(), logic_on_banned(), logic_on_broadcast(), logic_on_flood(), logic_on_internal_event(), logic_on_ircop(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), logic_on_not_in_reop(), logic_on_not_invited(), logic_on_notice(), logic_on_part(), logic_on_privmsg(), logic_on_privmsg_query(), logic_on_server_msg(), logic_validate(), logic_validate_by_mask(), logic_validate_chan_key(), logic_validate_chan_limit(), logic_validate_chan_mode(), logic_validate_kick(), logic_validate_topic(), and main().

#define LOGIC_SOCKET_ERROR   -5
 

Socket I/O error.

Definition at line 68 of file logic.h.

Referenced by logic_call_proc_ex(), logic_call_proc_ex2(), logic_ctcp(), logic_filesys_got_new(), logic_fnc(), logic_on_banned(), logic_on_broadcast(), logic_on_flood(), logic_on_internal_event(), logic_on_ircop(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), logic_on_not_in_reop(), logic_on_not_invited(), logic_on_notice(), logic_on_part(), logic_on_privmsg(), logic_on_privmsg_query(), logic_on_server_msg(), logic_validate(), logic_validate_by_mask(), logic_validate_chan_key(), logic_validate_chan_limit(), logic_validate_chan_mode(), logic_validate_kick(), logic_validate_topic(), and main().


Function Documentation

bool logic_access_to_filesystem string  user  ) 
 

Check wheter user has access to the filesystem.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
user User name from "logic.txt"
Returns:
True if user has access to the filesystem

Definition at line 10782 of file logic.cpp.

References r_users.

Referenced by dcc_file_has_been_read(), dcc_loop(), and dcc_send_file().

10783 {
10784     vector<s_user>::iterator i1;
10785     for(i1=r_users.begin(); i1!=r_users.end(); i1++)
10786         if(!(*i1).name.compare(user))
10787             return (*i1).access_to_filesystem;
10788     return false;
10789 }

bool logic_access_to_partyline string  nick,
string  ident,
string  host,
string  fullname,
bool  irc_op,
string &  user_name_as_in_logic
 

Looks up and find user as specified in logic.txt, and checks if user has access to partyline.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
nick Nick name
ident Ident
host Host
fullname Full name
irc_op Pass there true if WHOIS indicates that this is an irc op
user_name_as_in_logic Returns name of user as in logic.txt, or undefined if it was not found
Returns:
Returns true if user has access to partyline; and false if not or user was not found

Definition at line 9206 of file logic.cpp.

References irc_nick, logic_check_mask(), logic_cmp_strings_case_insensitive(), logic_eval(), and r_users.

09207 {
09208     if(!logic_cmp_strings_case_insensitive(nick,irc_nick)) {
09209         return false;
09210     }
09211 
09212     map<string,string> vars;
09213 
09214     vector<s_user>::iterator i;
09215     for(i=r_users.begin(); i!=r_users.end(); i++) {
09216         vector<string>::iterator is, ii;
09217         for(is=(*i).fullname.begin(); is!=(*i).fullname.end(); is++) {
09218             for(ii=(*i).hostmask.begin(); ii!=(*i).hostmask.end(); ii++) {
09219                 if(!(*i).host_unknown && logic_check_mask(logic_eval(*ii,vars),nick+"!"+ident+"@"+host,fullname,logic_eval(*is,vars))) {
09220                     user_name_as_in_logic=(*i).name;
09221                     return (*i).access_to_partyline;
09222                 }
09223             }
09224         }
09225     }
09226 
09227     // try host_unknown
09228     for(i=r_users.begin(); i!=r_users.end(); i++) {
09229         vector<string>::iterator is, ii;
09230         if((*i).host_unknown) {
09231             user_name_as_in_logic=(*i).name;
09232             return (*i).access_to_partyline;
09233         }
09234     }
09235 
09236     return false;
09237 }

Here is the call graph for this function:

void logic_botnet_backup string  who  ) 
 

Writes new "logic.txt" file.

Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 13520 of file logic.cpp.

References logic_partyline_backup().

Referenced by botnet_loop().

13521 {
13522     who+=" (BOTNET)";
13523     logic_partyline_backup(who);
13524 }

Here is the call graph for this function:

void logic_botnet_rehash string  who  ) 
 

Rehashes new backed up configuration (should be called from BOTNET) and performs rollback to old backed up file(s) if parse error occurs.

Parameters:
who This should contain which bot caused rehasing (for log purposes - bot.log)
Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 13729 of file logic.cpp.

References log_bot(), and logic_rehash().

Referenced by botnet_loop().

13730 {
13731     string log;
13732     string eol;
13733     string lang="en";
13734     string who_string=who;
13735     who_string+=" (BOTNET)";
13736     who+=" (BOTNET)";
13737     who_string=(string)"*** Rehash invoked by "+who_string;
13738     log_bot(who_string.c_str());
13739     logic_rehash(log,lang,eol,who_string,who,who);
13740 }

Here is the call graph for this function:

void logic_botnet_remove_user string  username  ) 
 

Removes user.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
username Name of user

Definition at line 13533 of file logic.cpp.

References logic_partyline_remove_user().

Referenced by botnet_loop().

13534 {
13535     logic_partyline_remove_user(username);
13536 }

Here is the call graph for this function:

int logic_call_proc const char *  call_string  ) 
 

Calls a procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
call_string Declaration of procedure with parameters
Returns:
Returns zero for no error, or LOGIC_PROC_BAD_TEXT, LOGIC_PROC_BAD_SYNTAX, LOGIC_PROC_BAD_NUM, for error in call_string, or LOGIC_SOCKET_ERROR for socket I/O error
Return values:
0 No error
LOGIC_PROC_BAD_TEXT Error in call_string
LOGIC_PROC_BAD_SYNTAX Error in call_string
LOGIC_PROC_BAD_NUM Error in call_string (bad number)
LOGIC_SOCKET_ERROR Socket I/O error

Definition at line 8382 of file logic.cpp.

References logic_call_proc_ex().

08383 {
08384     map<string,string> vars;
08385     return logic_call_proc_ex(call_string,vars);
08386 }

Here is the call graph for this function:

int logic_call_proc_ex const char *  call_string,
map< string, string >  vars
 

int logic_call_proc_ex2 const char *  call_string,
map< string, string > &  vrs,
list< string > &  params,
bool  from_work
 

Calls a procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
call_string Declaration of procedure with parameters
vrs Variables for procedure (left unchanged upon return)
params Parameters for procedure
from_work Set this to true if this should continue after "work" command
Returns:
Returns zero for no error, or LOGIC_PROC_BAD_TEXT, LOGIC_PROC_BAD_SYNTAX, LOGIC_PROC_BAD_NUM, for error in call_string, or LOGIC_SOCKET_ERROR for socket error
Return values:
0 No error
LOGIC_PROC_BAD_TEXT Error in call_string
LOGIC_PROC_BAD_SYNTAX Error in call_string
LOGIC_PROC_BAD_NUM Error in call_string (bad number)
LOGIC_SOCKET_ERROR Socket I/O error

Definition at line 8619 of file logic.cpp.

References logic_eval(), logic_exec(), LOGIC_NO_SERVER, LOGIC_PROC_NOT_FOUND, LOGIC_SOCKET_ERROR, and r_procedures.

Referenced by botnet_loop(), logic_ctcp(), logic_execute(), logic_filesys_got_new(), logic_fnc(), logic_loop(), logic_on_banned(), logic_on_broadcast(), logic_on_flood(), logic_on_internal_event(), logic_on_ircop(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), logic_on_not_in_reop(), logic_on_not_invited(), logic_on_notice(), logic_on_part(), logic_on_privmsg(), logic_on_privmsg_query(), logic_on_server_msg(), logic_process_script_output(), logic_validate(), logic_validate_by_mask(), logic_validate_chan_key(), logic_validate_chan_limit(), logic_validate_chan_mode(), logic_validate_kick(), logic_validate_topic(), and main().

08620 {
08621     string cs=call_string;
08622     if(cs.find("(",0)!=string::npos)
08623         cs.erase(cs.find("(",0),cs.length()-cs.find("(",0)); // erase everything after '('
08624     vector<s_procedure>::iterator i3;
08625     for(i3=r_procedures.begin(); i3!=r_procedures.end(); i3++) {
08626         string s=(*i3).name;
08627         if(s.find("(",0)!=string::npos)
08628             s.erase(s.find("(",0),s.length()-s.find("(",0)); // erase everything after '('
08629         if(!s.compare(cs)) {
08630             cs=(*i3).name;
08631             break;
08632         }
08633     }
08634     if(i3==r_procedures.end()) {
08635         return LOGIC_PROC_NOT_FOUND;
08636     }
08637 
08638     map<string,string> vars=vrs;
08639     int pos=0;
08640     string p;
08641     list<string>::iterator i=params.begin();
08642     int num_par=0;
08643     if(i!=params.end()) {
08644         for(unsigned int i1=0; call_string[i1]!=0; i1++) {
08645             if(pos==0 && call_string[i1]=='(') {
08646                 pos++;
08647                 continue;
08648             }
08649             if(pos==1) {
08650                 if(call_string[i1]==',' || call_string[i1]==')') {
08651                     if(i!=params.end()) {
08652                         pair<string,string> pa;
08653                         pa.first=p;
08654                         pa.second=*i;
08655                         map<string,string>::iterator i1;
08656                     again1:
08657                         for(i1=vars.begin(); i1!=vars.end(); i1++)
08658                             if(!(*i1).first.compare(pa.first)) {
08659                                 vars.erase(i1);
08660                                 goto again1;
08661                             }
08662                         vars.insert(pa);
08663                         i++;
08664                     } else {
08665                         cs=(*i3).name;
08666                         if(cs.find("(",0)!=string::npos)
08667                             cs.erase(0,cs.find("(",0)+1);
08668                         for(int i2=0; i2<num_par; i2++)
08669                             if(cs.find(",",0)!=string::npos)
08670                                 cs.erase(0,cs.find(",",0)+1);
08671                         if(cs.find(",",0)!=string::npos)
08672                             cs.erase(cs.find(",",0),cs.length()-cs.find(",",0));
08673                         if(cs.find(")",0)!=string::npos)
08674                             cs.erase(cs.find(")",0),cs.length()-cs.find(")",0));
08675                         pair<string,string> pa;
08676                         pa.first=cs;
08677                         pa.second=logic_eval(p,vars);
08678                         map<string,string>::iterator i1;
08679                     again2:
08680                         for(i1=vars.begin(); i1!=vars.end(); i1++)
08681                             if(!(*i1).first.compare(pa.first)) {
08682                                 vars.erase(i1);
08683                                 goto again2;
08684                             }
08685                         vars.insert(pa);
08686                     }
08687                     num_par++;
08688                     p="";
08689                     if(call_string[i1]==')')
08690                         break;
08691                     continue;
08692                 }
08693                 p+=call_string[i1];
08694                 continue;
08695             }
08696         }
08697     }
08698     switch(logic_exec(*i3,vars,from_work)) {
08699         case LOGIC_SOCKET_ERROR:
08700             return LOGIC_SOCKET_ERROR;
08701         case LOGIC_NO_SERVER:
08702             return LOGIC_NO_SERVER;
08703         default:
08704             break;
08705     }
08706     return 0;
08707 }

Here is the call graph for this function:

bool logic_check_mask string  mask1,
string  mask2,
string  fnm1,
string  fnm2
 

Checks mask to match (advanced with DNS resolution).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
mask1 Mask #1 to compare for match
mask2 Mask #2 to compare for match
fnm1 Full name mask #1 to compare for match
fnm2 Full name mask #2 to compare for match
Return values:
true For full match
false For no match

Definition at line 8903 of file logic.cpp.

References inetpton(), logic_hostmask_ipv6_decompress(), logic_match2(), logic_resolve(), ltoa(), match_ipmask(), and sock_resolve6().

Referenced by irc_check_flood(), logic_access_to_partyline(), logic_exec(), logic_find_user(), logic_on_banned(), and logic_validate_by_mask().

08904 {
08905     mask1=logic_hostmask_ipv6_decompress(mask1);
08906     mask2=logic_hostmask_ipv6_decompress(mask2);
08907 
08908     // match?
08909     if(logic_match2(mask2,fnm2,mask1,fnm1) || logic_match2(mask1,fnm1,mask2,fnm2))
08910         return true;
08911 
08912     // if full name doesn't match, it is all lost = no match
08913     if(!logic_match2("*!*@*",fnm2,"*!*@*",fnm1) && !logic_match2("*!*@*",fnm1,"*!*@*",fnm2))
08914         return false;
08915 
08916     // h_maskX <- host field only
08917     string h_mask1=mask1;
08918     string h_mask2=mask2;
08919     if(h_mask1.find("@",0)!=string::npos)
08920         h_mask1.erase(0,h_mask1.find("@",0)+1);
08921     if(h_mask2.find("@",0)!=string::npos)
08922         h_mask2.erase(0,h_mask2.find("@",0)+1);
08923 
08924     if(h_mask1.length()==0 || h_mask2.length()==0)
08925         return false;
08926 
08927     // unX <- user name only ("nick!ident")
08928     string un1=mask1;
08929     if(un1.find("@",0)!=string::npos)
08930         un1.erase(un1.find("@",0),un1.length()-un1.find("@",0));
08931     string un2=mask2;
08932     if(un2.find("@",0)!=string::npos)
08933         un2.erase(un2.find("@",0),un2.length()-un2.find("@",0));
08934 
08935     // ip_maskX <- try to parse IPv4 dotted, or zero, if zero, ip_maskX <- try to IPv4 resolve, or zero
08936     unsigned long ip_mask1=0;
08937 
08938     // we don't want to resolve it there are wildcards or CIDR
08939     if(h_mask1.find("?",0)==string::npos && h_mask1.find("*",0)==string::npos && h_mask1.find("#",0)==string::npos && h_mask1.find("/",0)==string::npos) {
08940         int i1, i2, i3, i4;
08941 
08942         int x=sscanf(h_mask1.c_str(),"%u.%u.%u.%u", &i1, &i2, &i3, &i4);
08943         if(x==4)
08944             ip_mask1=(i4<<24)|(i3<<16)|(i2<<8)|i1;
08945         else
08946             ip_mask1=0;
08947 
08948         if(ip_mask1==0)
08949             ip_mask1=logic_resolve(h_mask1.c_str());
08950     }
08951 
08952     unsigned long ip_mask2=0;
08953 
08954     if(h_mask2.find("?",0)==string::npos && h_mask2.find("*",0)==string::npos && h_mask2.find("#",0)==string::npos && h_mask2.find("/",0)==string::npos) {
08955         int i1, i2, i3, i4;
08956 
08957         int x=sscanf(h_mask2.c_str(),"%u.%u.%u.%u", &i1, &i2, &i3, &i4);
08958         if(x==4)
08959             ip_mask2=(i4<<24)|(i3<<16)|(i2<<8)|i1;
08960         else
08961             ip_mask2=0;
08962 
08963         if(ip_mask2==0)
08964             ip_mask2=logic_resolve(h_mask2.c_str());
08965     }
08966 
08967     {
08968         {
08969             // h_maskX <- if it is not IPv6, convert it to IPv4-mapped IPv6
08970             int i1, i2, i3, i4;
08971             if(h_mask1.find(":",0)==string::npos) {
08972                 int x=sscanf(h_mask1.c_str(),"%u.%u.%u.%u", &i1, &i2, &i3, &i4);
08973                 if(x==4) {
08974                     h_mask1="0:0:0:0:0:ffff:"+h_mask1;
08975                     string tmp=h_mask1;
08976                     if(h_mask1.find("/",0)!=string::npos) {
08977                         h_mask1.erase(h_mask1.find("/",0),h_mask1.length()-h_mask1.find("/",0));
08978                         tmp.erase(0,tmp.find("/",0)+1);
08979                         int j=atol(tmp.c_str());
08980                         j+=(128-32);
08981                         char tmp2[64];
08982                         ltoa(j,tmp2,10);
08983                         h_mask1+="/";
08984                         h_mask1+=tmp2;
08985                     }
08986                 } else {
08987                     char tmp[128];
08988                     sprintf(tmp,"%u.%u.%u.%u",ip_mask1 & 0xff, (ip_mask1>>8) & 0xff, (ip_mask1>>16) & 0xff, (ip_mask1>>24) & 0xff);
08989                     h_mask1=(string)"0:0:0:0:0:ffff:"+tmp;
08990                 }
08991             }
08992 
08993             if(h_mask2.find(":",0)==string::npos) {
08994                 int x=sscanf(h_mask2.c_str(),"%u.%u.%u.%u", &i1, &i2, &i3, &i4);
08995                 if(x==4) {
08996                     h_mask2="0:0:0:0:0:ffff:"+h_mask2;
08997                     string tmp=h_mask2;
08998                     if(h_mask2.find("/",0)!=string::npos) {
08999                         h_mask2.erase(h_mask2.find("/",0),h_mask2.length()-h_mask2.find("/",0));
09000                         tmp.erase(0,tmp.find("/",0)+1);
09001                         int j=atol(tmp.c_str());
09002                         j+=(128-32);
09003                         char tmp2[64];
09004                         ltoa(j,tmp2,10);
09005                         h_mask2+="/";
09006                         h_mask2+=tmp2;
09007                     }
09008                 } else {
09009                     char tmp[128];
09010                     sprintf(tmp,"%u.%u.%u.%u",ip_mask2 & 0xff, (ip_mask2>>8) & 0xff, (ip_mask2>>16) & 0xff, (ip_mask2>>24) & 0xff);
09011                     h_mask2=(string)"0:0:0:0:0:ffff:"+tmp;
09012                 }
09013             }
09014         }
09015 
09016         // maskX <- build "nick!ident@IPv6"
09017         mask1=un1+"@"+h_mask1;
09018         mask2=un2+"@"+h_mask2;
09019 
09020         in_addr6_ ip_mask6_1, ip_mask6_2;
09021         inetpton(AF_INET6,h_mask1.c_str(),&ip_mask6_1);
09022         inetpton(AF_INET6,h_mask2.c_str(),&ip_mask6_2);
09023 
09024         // still no match?
09025         if(!match_ipmask((char*)(un1+"@"+h_mask1).c_str(),(char*)un2.c_str(),ip_mask6_2,true))
09026             return true;
09027         if(!match_ipmask((char*)(un2+"@"+h_mask2).c_str(),(char*)un1.c_str(),ip_mask6_1,true))
09028             return true;
09029     }
09030 
09031     // ip6_maskX <- try to resolve via IPv6 DNS
09032     in_addr6_ ip6_mask1;
09033     memset(&ip6_mask1,0,sizeof(ip6_mask1));
09034     in_addr6_ ip6_mask2;
09035     memset(&ip6_mask2,0,sizeof(ip6_mask2));
09036     if(h_mask1.find("/",0)==string::npos)
09037         ip6_mask1=sock_resolve6((char*)h_mask1.c_str());
09038     if(h_mask2.find("/",0)==string::npos)
09039         ip6_mask2=sock_resolve6((char*)h_mask2.c_str());
09040 
09041     bool chance=false;
09042 
09043     // if we have at least one successful IPv6 DNS resolution... then continue
09044     if(ip6_mask1.bytes[0] || ip6_mask1.bytes[1] || ip6_mask1.bytes[2] || ip6_mask1.bytes[3] || ip6_mask1.bytes[4] ||
09045        ip6_mask1.bytes[5] || ip6_mask1.bytes[6] || ip6_mask1.bytes[7] || ip6_mask1.bytes[8] || ip6_mask1.bytes[9] ||
09046        ip6_mask1.bytes[10] || ip6_mask1.bytes[11] || ip6_mask1.bytes[12] || ip6_mask1.bytes[13] ||
09047        ip6_mask1.bytes[14] || ip6_mask1.bytes[15]) {
09048         char tmp[256];
09049         // we don't want compressed format
09050         //inet_ntop6((unsigned char*)&ip6_mask1,tmp,sizeof(tmp));
09051         sprintf(tmp,"%x:%x:%x:%x:%x:%x:%x:%x",  ((unsigned int)ip6_mask1.bytes[0])<<8 | ((unsigned int)ip6_mask1.bytes[1]),
09052                                                     ((unsigned int)ip6_mask1.bytes[2])<<8 | ((unsigned int)ip6_mask1.bytes[3]),
09053                                                     ((unsigned int)ip6_mask1.bytes[4])<<8 | ((unsigned int)ip6_mask1.bytes[5]),
09054                                                     ((unsigned int)ip6_mask1.bytes[6])<<8 | ((unsigned int)ip6_mask1.bytes[7]),
09055                                                     ((unsigned int)ip6_mask1.bytes[8])<<8 | ((unsigned int)ip6_mask1.bytes[9]),
09056                                                     ((unsigned int)ip6_mask1.bytes[10])<<8 | ((unsigned int)ip6_mask1.bytes[11]),
09057                                                     ((unsigned int)ip6_mask1.bytes[12])<<8 | ((unsigned int)ip6_mask1.bytes[13]),
09058                                                     ((unsigned int)ip6_mask1.bytes[14])<<8 | ((unsigned int)ip6_mask1.bytes[15]));
09059             h_mask1=tmp;
09060             chance=true;
09061     }
09062     if(ip6_mask2.bytes[0] || ip6_mask2.bytes[1] || ip6_mask2.bytes[2] || ip6_mask2.bytes[3] || ip6_mask2.bytes[4] ||
09063         ip6_mask2.bytes[5] || ip6_mask2.bytes[6] || ip6_mask2.bytes[7] || ip6_mask2.bytes[8] || ip6_mask2.bytes[9] ||
09064         ip6_mask2.bytes[10] || ip6_mask2.bytes[11] || ip6_mask2.bytes[12] || ip6_mask2.bytes[13] ||
09065         ip6_mask2.bytes[14] || ip6_mask2.bytes[15]) {
09066         char tmp[256];
09067         // we don't want compressed format
09068         //inet_ntop6((unsigned char*)&ip6_mask2,tmp,sizeof(tmp));
09069         sprintf(tmp,"%x:%x:%x:%x:%x:%x:%x:%x",  ((unsigned int)ip6_mask2.bytes[0])<<8 | ((unsigned int)ip6_mask2.bytes[1]),
09070                                                     ((unsigned int)ip6_mask2.bytes[2])<<8 | ((unsigned int)ip6_mask2.bytes[3]),
09071                                                     ((unsigned int)ip6_mask2.bytes[4])<<8 | ((unsigned int)ip6_mask2.bytes[5]),
09072                                                     ((unsigned int)ip6_mask2.bytes[6])<<8 | ((unsigned int)ip6_mask2.bytes[7]),
09073                                                     ((unsigned int)ip6_mask2.bytes[8])<<8 | ((unsigned int)ip6_mask2.bytes[9]),
09074                                                     ((unsigned int)ip6_mask2.bytes[10])<<8 | ((unsigned int)ip6_mask2.bytes[11]),
09075                                                     ((unsigned int)ip6_mask2.bytes[12])<<8 | ((unsigned int)ip6_mask2.bytes[13]),
09076                                                     ((unsigned int)ip6_mask2.bytes[14])<<8 | ((unsigned int)ip6_mask2.bytes[15]));
09077         h_mask2=tmp;
09078         chance=true;
09079     }
09080 
09081     // ... then continue, or not
09082     if(!chance)
09083         return false;
09084 
09085     // last chance to match
09086     if(!match_ipmask((char*)(un1+"@"+h_mask1).c_str(),(char*)un2.c_str(),ip6_mask2,true))
09087         return true;
09088     if(!match_ipmask((char*)(un2+"@"+h_mask2).c_str(),(char*)un1.c_str(),ip6_mask1,true))
09089         return true;
09090 
09091     return false;
09092 }

Here is the call graph for this function:

string logic_eval string  str,
map< string, string > &  vars
 

Looks up and evalueates variable beginning with '$' sign, if it is possible.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
str Name of variable beginning with '$' sign
vars Array of variables ant their values
Returns:
Returns evaluated variable, if it wasn't found in vars array, it returns str value

Definition at line 4975 of file logic.cpp.

References log_debug().

Referenced by botnet_loop(), dcc_loop(), dcc_loop_edit_chan(), dcc_loop_edit_dynbans(), dcc_loop_edit_proc(), dcc_loop_edit_user1(), dcc_loop_filesystem(), dcc_loop_msg(), irc_check_flood(), irc_check_for_not_invited(), irc_check_for_not_reopped(), logic_access_to_partyline(), logic_call_proc_ex2(), logic_exec(), logic_exec_script(), logic_execute(), logic_find_user(), logic_get_dcc_host(), logic_get_flood_limits(), logic_on_banned(), logic_on_flood(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), logic_on_not_in_reop(), logic_on_not_invited(), logic_on_notice(), logic_on_privmsg(), logic_partyline_access(), logic_partyline_whois(), logic_process_line(), logic_process_script_output(), logic_validate(), logic_validate_by_mask(), and logic_validate_kick().

04976 {
04977     string res;
04978 
04979     bool b_str=false;
04980 
04981     for(unsigned int i1=0; i1<str.length(); i1++) {
04982         if(str[i1]=='\"') {
04983             b_str=!b_str;
04984             continue;
04985         }
04986         if(b_str && str[i1]=='\\') {
04987             if(i1+1>=str.length()) {
04988                 string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape character '\\' at the end of the string \"";
04989                 d+=str+"\"";
04990                 log_debug(d.c_str());
04991             } else {
04992                 if(i1+1>=str.length()) {
04993                     string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape sequence '\\' at the end of the string \"";
04994                     d+=str+"\"";
04995                     log_debug(d.c_str());
04996                 }
04997                 char x=str[++i1];
04998                 switch(x) {
04999                     case '\\':
05000                         res+="\\";
05001                         break;
05002                     case '\"':
05003                         res+="\"";
05004                         break;
05005                     case 'r':
05006                         res+="\r";
05007                         break;
05008                     case 'n':
05009                         res+="\n";
05010                         break;
05011                     case 't':
05012                         res+="\t";
05013                         break;
05014                     case 'a':
05015                         res+="\a";
05016                         break;
05017                     case 'b':
05018                         res+="\b";
05019                         break;
05020                     case 'f':
05021                         res+="\f";
05022                         break;
05023                     case 'v':
05024                         res+="\v";
05025                         break;
05026                     case '\'':
05027                         res+="\'";
05028                         break;
05029                     case '?':
05030                         res+="\?";
05031                         break;
05032                     case 'x':
05033                         {
05034                             if(i1+1+2>=str.length()) {
05035                                 string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape character '\\x' at the end of the string \"";
05036                                 d+=str+"\"";
05037                                 log_debug(d.c_str());
05038                             } else {
05039                                 char x1[8];
05040                                 x1[0]=str[++i1];
05041                                 x1[1]=str[++i1];
05042                                 unsigned char x2=0;
05043                                 for(int i1=0; i1<2; i1++) {
05044                                     unsigned char nibble=0xff;
05045                                     if(x1[i1]>='0' && x1[i1]<='9')
05046                                         nibble=x1[i1]-'0';
05047                                     if(x1[i1]>='a' && x1[i1]<='f')
05048                                         nibble=x1[i1]+10-'a';
05049                                     if(x1[i1]>='A' && x1[i1]<='F')
05050                                         nibble=x1[i1]+10-'A';
05051                                     if(nibble==0xff) {
05052                                         nibble=0;
05053                                         string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape character '\\x' - character not in HEX family \"";
05054                                         d+=str+"\"";
05055                                         log_debug(d.c_str());
05056                                     }
05057                                     x2|=nibble << (i1==0?4:0);
05058                                 }
05059                                 res.push_back(x2);
05060                             }
05061                         }
05062                         break;
05063                     case '0':
05064                     case '1':
05065                     case '2':
05066                     case '3':
05067                     case '4':
05068                     case '5':
05069                     case '6':
05070                     case '7':
05071                         {
05072                             if(i1+1+3>=str.length()) {
05073                                 string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape character '\\<octal_num>' at the end of the string \"";
05074                                 d+=str+"\"";
05075                                 log_debug(d.c_str());
05076                             } else {
05077                                 char x1[8];
05078                                 x1[0]=x;
05079                                 x1[1]=str[++i1];
05080                                 x1[2]=str[++i1];
05081                                 unsigned char x2=0;
05082                                 for(int i1=0; i1<3; i1++) {
05083                                     unsigned char nibble=0xff;
05084                                     if(x1[i1]>='0' && x1[i1]<='7')
05085                                         nibble=x1[i1]-'0';
05086                                     if(nibble==0xff) {
05087                                         nibble=0;
05088                                         string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape character '\\<octal_num>' - character not in OCTAL family \"";
05089                                         d+=str+"\"";
05090                                         log_debug(d.c_str());
05091                                     }
05092                                     if(i1==0)
05093                                         nibble<<=6;
05094                                     if(i1==1)
05095                                         nibble<<=3;
05096                                     /*if(i1==2)
05097                                         nibble<<=0;*/
05098                                     x2|=nibble;
05099                                 }
05100                                 res.push_back(x2);
05101                             }
05102                         }
05103                         break;
05104                     default:
05105                         {
05106                             string d="in file " __FILE__ " in function " __FUNC__ " occurred error: errorneous escape character '\\' - unknown next character \"";
05107                             d+=str+"\"";
05108                             log_debug(d.c_str());
05109                         }
05110                         break;
05111                 }
05112             }
05113             continue;
05114         }
05115         if(str[i1]=='$') {
05116             string v="$";
05117             for(i1++; i1<str.length(); i1++) {
05118                 if(!((str[i1]>='a' && str[i1]<='z') || (str[i1]>='A' && str[i1]<='Z') || (str[i1]>='0' && str[i1]<='9') || str[i1]=='_'))
05119                     break;
05120                 v+=str[i1];
05121             }
05122             i1--;
05123             map<string,string>::iterator i=vars.begin();
05124             for(; i!=vars.end(); i++)
05125                 if(!(*i).first.compare(v))
05126                     break;
05127             if(i!=vars.end() && !(*i).first.compare(v)) {
05128                 if(!(*i).second.empty() && (*i).second[0]!=0)
05129                     res+=(*i).second;
05130             } else {
05131                 string d="in file " __FILE__ " in function " __FUNC__ " occurred error: unknown variable ";
05132                 d+=v;
05133                 log_debug(d.c_str());
05134 
05135                 res+="";
05136             }
05137             continue;
05138         }
05139         if(b_str) {
05140             res+=str[i1];
05141             continue;
05142         }
05143         if(str[i1]==',') {
05144             res+=",";
05145             continue;
05146         }
05147         if(!b_str) {
05148             if(str[i1]!='.') {
05149                 string d="in file " __FILE__ " in function " __FUNC__ " occurred error: bad syntax in the string: ";
05150                 d+=str;
05151                 log_debug(d.c_str());
05152 
05153                 continue;
05154             }
05155             continue;
05156         }
05157         string d="in file " __FILE__ " in function " __FUNC__ " occurred error: WHY IT GOES HERE?!";
05158         log_debug(d.c_str());
05159     }
05160 
05161     return res;
05162 }

Here is the call graph for this function:

int logic_exec_from_work  ) 
 

Continues execution after "work" command.

Author:
VooDooMan
Version:
1
Date:
2004
Returns:
Returns return value from main procedure in logic.txt

Definition at line 8350 of file logic.cpp.

References logic_exec(), and work_vars.

Referenced by irc_loop_putserv(), and main().

08351 {
08352     return logic_exec(work_proc,work_vars,true);
08353 }

Here is the call graph for this function:

void logic_execute string  call_string,
map< string, string > &  vars
 

Executes procedure as callstring with arguments.

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
call_string name of procedure with arguments
vars Initial variables for procedure

Definition at line 13872 of file logic.cpp.

References logic_call_proc_ex2(), logic_eval(), and r_procedures.

Referenced by dcc_loop(), and logic_exec().

13873 {
13874     string orig_call_string=call_string;
13875     //string call_string=(*i).exec;
13876     string cs=call_string;
13877     unsigned int i2;
13878     for(i2=0; i2<cs.length(); i2++)
13879         if(cs[i2]=='(')
13880             break;
13881     cs.erase(i2,cs.length()-i2); // erase everything after '('
13882     vector<s_procedure>::iterator i1;
13883     for(i1=r_procedures.begin(); i1!=r_procedures.end(); i1++) {
13884         string s=(*i1).name;
13885         unsigned int i2;
13886         for(i2=0; i2<s.length(); i2++)
13887             if(s[i2]=='(')
13888                 break;
13889         s.erase(i2,s.length()-i2); // erase everything after '('
13890         if(!s.compare(cs)) {
13891             call_string=(*i1).name;
13892             break;
13893         }
13894     }
13895     //cs=(*i).exec;
13896     cs=orig_call_string;
13897     for(i2=0; i2<cs.length(); i2++)
13898         if(cs[i2]=='(')
13899             break;
13900     cs.erase(0,i2+1);
13901     if(cs.length()>0 && cs[cs.length()-1]==')')
13902         cs.erase(cs.length()-1,1);
13903     cs+=",";
13904 
13905     list<string> params;
13906     bool str=false;
13907     string p;
13908     for(i2=0; i2<cs.length() && cs.compare(","); i2++) {
13909         if(cs[i2]=='\"') {
13910             p+="\"";
13911 
13912             str=!str;
13913             continue;
13914         }
13915         if(!str && cs[i2]==',') {
13916             /*if(p.length()>0 && p[0]=='$') {
13917                 map<string,string>::iterator i3;
13918                 for(i3=vars.begin(); i3!=vars.end(); i3++) {
13919                     if(!(*i3).first.compare(p)) {
13920                         p=(*i3).second;
13921                         break;
13922                     }
13923                 }
13924             }*/
13925             p=logic_eval(p,vars);
13926             params.push_back(p);
13927             p="";
13928             continue;
13929         }
13930         if(!str && cs[i2]==')') {
13931             if(p.compare("")) {
13932                 /*if(p.length()>0 && p[0]=='$') {
13933                     map<string,string>::iterator i3;
13934                     for(i3=vars.begin(); i3!=vars.end(); i3++) {
13935                         if(!(*i3).first.compare(p)) {
13936                             p=(*i3).second;
13937                             break;
13938                         }
13939                     }
13940                 }*/
13941                 p=logic_eval(p,vars);
13942                 params.push_back(p);
13943             }
13944             break;
13945         }
13946         p+=cs[i2];
13947     }
13948 
13949     logic_call_proc_ex2(call_string.c_str(),vars,params);
13950 }

Here is the call graph for this function:

void logic_filesys_got_new string  user_name,
string  nick,
string  ident,
string  host,
string  internal_name
 

Executes on_filesys_got_new event.

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
user_name User name as in logic.txt
nick Nick name
ident Ident
host Host
internal_name Internal name of file

Definition at line 12936 of file logic.cpp.

References logic_call_proc_ex2(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, and s_private::on_filesys_got_new.

Referenced by dcc_loop(), and dcc_loop_msg().

12937 {
12938     string proc=r_private.on_filesys_got_new;
12939     if(!proc.compare(""))
12940         return;
12941 
12942     map<string,string> vars;
12943 
12944     list<string> params;
12945     params.push_back(user_name); // $user_name
12946     params.push_back(nick); // $nick
12947     params.push_back(ident); // $ident
12948     params.push_back(host); // $host
12949     params.push_back(internal_name); // $internal_name
12950 
12951     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
12952         case LOGIC_SOCKET_ERROR:
12953         case LOGIC_RESTART:
12954             return;
12955         default:
12956             break;
12957     }
12958 }

Here is the call graph for this function:

string logic_find_proc_by_name string  name  ) 
 

Finds procedure by name (without declatarion).

Parameters:
name Procedure name
Returns:
Returns full declaration of procedure
Return values:
"" An empty string, if procedure was not found

Definition at line 13378 of file logic.cpp.

References r_procedures.

Referenced by botnet_loop().

13379 {
13380     vector<s_procedure>::iterator i1;
13381     for(i1=r_procedures.begin(); i1!=r_procedures.end(); i1++) {
13382         string s=(*i1).name;
13383         unsigned int i2;
13384         for(i2=0; i2<s.length(); i2++)
13385             if(s[i2]=='(')
13386                 break;
13387         s.erase(i2,s.length()-i2); // erase everything after '('
13388         if(!s.compare(name))
13389             return (*i1).name;
13390     }
13391     return "";
13392 }

string logic_find_user string  nick,
string  ident,
string  host,
string  fullname,
bool  irc_op
 

Looks up and find user as specified in logic.txt.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
nick Nick name
ident Ident
host Host
fullname Full name
irc_op Pass there true if WHOIS indicates that this is an irc op
Returns:
Returns name of user as in logic.txt, or an empty string if user was not found

Definition at line 9144 of file logic.cpp.

References conf_getvar(), irc_nick, logic_check_mask(), logic_cmp_strings_case_insensitive(), logic_eval(), logic_reverse(), and r_users.

Referenced by dcc_file_has_been_read(), dcc_loop(), dcc_send_file(), irc_kicked(), irc_mode_change_ban(), irc_mode_change_ban_exception(), irc_mode_change_chan_key(), irc_mode_change_chan_limit(), irc_mode_change_chan_status(), irc_mode_change_creator(), irc_mode_change_invitation(), irc_mode_change_op(), irc_mode_change_other(), irc_mode_change_reop(), irc_mode_change_voice(), irc_quoted_callback(), irc_rehashed(), irc_RPL_NAMREPLY(), irc_RPL_TOPIC(), irc_RPL_WHOISUSER(), irc_user_mode_change(), logic_exec(), logic_on_ircop(), logic_on_join(), logic_on_nick_change(), logic_on_nick_validate(), and logic_on_part().

09145 {
09146     if(!logic_cmp_strings_case_insensitive(nick,irc_nick)) {
09147         vector<s_user>::iterator i;
09148         for(i=r_users.begin(); i!=r_users.end(); i++) {
09149             if((*i).host_bot)
09150                 return (*i).name;
09151         }
09152     }
09153 
09154     map<string,string> vars;
09155 
09156     bool trying_reverse=false;
09157 again:
09158 
09159     vector<s_user>::iterator i;
09160     for(i=r_users.begin(); i!=r_users.end(); i++) {
09161         vector<string>::iterator is, ii;
09162         for(is=(*i).fullname.begin(); is!=(*i).fullname.end(); is++) {
09163             for(ii=(*i).hostmask.begin(); ii!=(*i).hostmask.end(); ii++) {
09164                 if(!(*i).host_unknown && logic_check_mask(logic_eval(*ii,vars),nick+"!"+ident+"@"+host,logic_eval(*is,vars),fullname))
09165                     return (*i).name;
09166             }
09167         }
09168     }
09169 
09170     if(!trying_reverse && conf_getvar("try_reverse_lookup").compare("0")) {
09171         if(host.length() && host[0]>='0' && host[0]<='9') {
09172             char name[1024];
09173             logic_reverse((char*)host.c_str(),name,sizeof(name));
09174             if(name[0]!=0) {
09175                 host=name;
09176                 trying_reverse=true;
09177                 goto again;
09178             }
09179         }
09180     }
09181 
09182     // try host_unknown
09183     for(i=r_users.begin(); i!=r_users.end(); i++) {
09184         vector<string>::iterator is, ii;
09185         if((*i).host_unknown) {
09186             return (*i).name;
09187         }
09188     }
09189 
09190     return "";
09191 }

Here is the call graph for this function:

void logic_fnc string  old_nick,
string  new_nick
 

Executes on_fnc event.

Author:
VooDooMan
Version:
1
Date:
2005
Parameters:
old_nick Old nick name
new_nick New nick name

Definition at line 12968 of file logic.cpp.

References logic_call_proc_ex2(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, and s_private::on_fnc.

Referenced by irc_loop_process_input().

12969 {
12970     string proc=r_private.on_fnc;
12971     if(!proc.compare(""))
12972         return;
12973 
12974     map<string,string> vars;
12975 
12976     list<string> params;
12977     params.push_back(old_nick); // $old_nick
12978     params.push_back(new_nick); // $new_nick
12979 
12980     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
12981         case LOGIC_SOCKET_ERROR:
12982         case LOGIC_RESTART:
12983             return;
12984         default:
12985             break;
12986     }
12987 }

Here is the call graph for this function:

string logic_get_dcc_host int  dcc_group,
string  user_name_as_in_logic
 

Retrieves host for DCC by DCC gorup and user's name.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
dcc_group DCC group
user_name_as_in_logic User name as define in logic.txt
Returns:
Returns IPv4/IPv6 address of DCC host, or "0.0.0.0" if dcc_group is invalid for user_name_as_in_logic

Definition at line 10291 of file logic.cpp.

References logic_eval(), and r_users.

Referenced by irc_await_dcc_chat(), irc_loop_process_input(), and irc_RPL_ENDOFWHOIS().

10292 {
10293     vector<s_user>::iterator i;
10294     for(i=r_users.begin(); i!=r_users.end(); i++) {
10295         if(!(*i).name.compare(user_name_as_in_logic)) {
10296             vector<s_dcc_host>::iterator i2;
10297             for(i2=(*i).dcc_hosts.begin(); i2!=(*i).dcc_hosts.end(); i2++) {
10298                 if((*i2).group==dcc_group) {
10299                     map<string,string> vars;
10300                     return logic_eval((*i2).host,vars);
10301                 }
10302             }
10303         }
10304     }
10305     return "0.0.0.0";
10306 }

Here is the call graph for this function:

bool logic_is_replication_partner string  user_name_as_in_logic  ) 
 

Checks wheter user (the bot) is replication partner.

Parameters:
user_name_as_in_logic User name as in logic.txt
Returns:
True, if user (the bot) is replication partner

Definition at line 13349 of file logic.cpp.

References r_users.

Referenced by dcc_loop().

13350 {
13351     map<string,string> vars;
13352 
13353     vector<s_user>::iterator i;
13354     for(i=r_users.begin(); i!=r_users.end(); i++) {
13355         vector<string>::iterator is, ii;
13356         if(!(*i).host_unknown && !(*i).name.compare(user_name_as_in_logic)) {
13357             return (*i).replication_partner;
13358         }
13359     }
13360 
13361     // try host_unknown
13362     for(i=r_users.begin(); i!=r_users.end(); i++) {
13363         vector<string>::iterator is, ii;
13364         if((*i).host_unknown) {
13365             return (*i).replication_partner;
13366         }
13367     }
13368 
13369     return false;
13370 }

void logic_list_proc string  proc_name,
list< string > &  commands,
string &  declaration,
vector< string > &  groups
 

Lists procedure's commands.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
proc_name Name of procedure with full declaration
commands Returns commands
declaration Returns full declaration
groups Returns list of groups which is the procedure member of

Definition at line 11498 of file logic.cpp.

References _admin_msg, _ban_mask, _bot_auth, _bot_fullname, _bot_ident, _bot_ident_ipv6, _bot_nick, _bot_redir, _chan_mode, _change_nick, _check_dynamic_bans, _dcc_server, _dcc_server_ipv6, _delete_irc_servers, _delete_nicks, _deop, _devoice, _disconnect, _dynamic_ban, _end_bracket, _execute, _get_chan_mode, _get_chan_topic, _goto, _host, _ident, _if_error, _if_group, _if_in, _if_match, _if_match_case_insensitive, _if_n_group, _if_n_in, _if_n_match, _if_n_match_case_insensitive, _irc_server, _join, _kick, _kill_timers, _label, _link, _log, _msg, _msgq, _net_send, _notice, _noticeq, _op, _part, _process_on_banned, _raw, _real_goto, _real_label, _remote_execute, _restart, _return, _script, _sleep_, _smtp, _telnet_server, _telnet_server_ipv6, _timer_every, _timer_once, _topic, _try_connect, _unban_mask, _voice, _wait, _work, log_debug(), logic_set_priority(), ltoa(), and r_procedures.

Referenced by botnet_push_proc(), dcc_loop_edit_proc(), and logic_partyline_backup().

11499 {
11500     commands.clear();
11501     groups.clear();
11502 
11503     string ln;
11504     unsigned int ii;
11505     unsigned int indent=4;
11506 
11507     vector<s_procedure>::iterator i2;
11508     for(i2=r_procedures.begin(); i2!=r_procedures.end(); i2++) {
11509         if(!(*i2).name.compare(proc_name)) {
11510             vector<s_group>::iterator i4;
11511             for(i4=(*i2).groups.begin(); i4!=(*i2).groups.end(); i4++)
11512                 groups.push_back((*i4).name);
11513             declaration=(*i2).name;
11514             list<s_command>::iterator i3;
11515             for(i3=(*i2).commands.begin(); i3!=(*i2).commands.end(); i3++) {
11516                 switch((*i3).command) {
11517                     case _op:
11518                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11519                         ln+=(string)"op "+logic_set_priority((*i3).priority)+" "+(*i3).channel+" "+(*i3).whom;
11520                         commands.push_back(ln);
11521                         break;
11522                     case _deop:
11523                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11524                         ln+=(string)"deop "+logic_set_priority((*i3).priority)+" "+(*i3).channel+" "+(*i3).whom;
11525                         commands.push_back(ln);
11526                         break;
11527                     case _voice:
11528                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11529                         ln+=(string)"voice "+logic_set_priority((*i3).priority)+" "+(*i3).channel+" "+(*i3).whom;
11530                         commands.push_back(ln);
11531                         break;
11532                     case _devoice:
11533                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11534                         ln+=(string)"devoice "+logic_set_priority((*i3).priority)+" "+(*i3).channel+" "+(*i3).whom;
11535                         commands.push_back(ln);
11536                         break;
11537                     case _kick:
11538                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11539                         ln+=(string)"kick "+(*i3).channel+" "+(*i3).whom+" "+(*i3).msg_text;
11540                         commands.push_back(ln);
11541                         break;
11542                     case _msg:
11543                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11544                         ln+=(string)"msg "+logic_set_priority((*i3).priority)+" "+(*i3).whom+" "+(*i3).msg_text;
11545                         commands.push_back(ln);
11546                         break;
11547                     case _msgq:
11548                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11549                         ln+=(string)"msgq "+logic_set_priority((*i3).priority)+" "+(*i3).whom+" "+(*i3).msg_text+" "+(*i3).msg_quoted;
11550                         commands.push_back(ln);
11551                         break;
11552                     case _if_in:
11553                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11554                         ln+=(string)"if_in "+(*i3).left+" "+(*i3).right;
11555                         commands.push_back(ln);
11556 
11557                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11558                         ln+="{";
11559                         commands.push_back(ln);
11560                         indent+=4;
11561                         break;
11562                     case _if_n_in:
11563                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11564                         ln+=(string)"!if_in "+(*i3).left+" "+(*i3).right;
11565                         commands.push_back(ln);
11566 
11567                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11568                         ln+="{";
11569                         commands.push_back(ln);
11570                         indent+=4;
11571                         break;
11572                     case _if_match:
11573                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11574                         ln+=(string)"if_match "+(*i3).left+" "+(*i3).right;
11575                         commands.push_back(ln);
11576 
11577                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11578                         ln+="{";
11579                         commands.push_back(ln);
11580                         indent+=4;
11581                         break;
11582                     case _if_match_case_insensitive:
11583                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11584                         ln+=(string)"if_match_case_insensitive "+(*i3).left+" "+(*i3).right;
11585                         commands.push_back(ln);
11586 
11587                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11588                         ln+="{";
11589                         commands.push_back(ln);
11590                         indent+=4;
11591                         break;
11592                     case _if_group:
11593                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11594                         ln+=(string)"if_group "+(*i3).left+" "+(*i3).right;
11595                         commands.push_back(ln);
11596 
11597                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11598                         ln+="{";
11599                         commands.push_back(ln);
11600                         indent+=4;
11601                         break;
11602                     case _if_n_match:
11603                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11604                         ln+=(string)"!if_match "+(*i3).left+" "+(*i3).right;
11605                         commands.push_back(ln);
11606 
11607                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11608                         ln+="{";
11609                         commands.push_back(ln);
11610                         indent+=4;
11611                         break;
11612                     case _if_n_match_case_insensitive:
11613                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11614                         ln+=(string)"!if_match_case_insensitive "+(*i3).left+" "+(*i3).right;
11615                         commands.push_back(ln);
11616 
11617                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11618                         ln+="{";
11619                         commands.push_back(ln);
11620                         indent+=4;
11621                         break;
11622                     case _if_n_group:
11623                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11624                         ln+=(string)"!if_group "+(*i3).left+" "+(*i3).right;
11625                         commands.push_back(ln);
11626 
11627                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11628                         ln+="{";
11629                         commands.push_back(ln);
11630                         indent+=4;
11631                         break;
11632                     case _return:
11633                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11634                         ln+="return";
11635                         commands.push_back(ln);
11636                         break;
11637                     case _work:
11638                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11639                         ln+="work";
11640                         commands.push_back(ln);
11641                         break;
11642                     case _timer_once:
11643                     case _timer_every:
11644                         {
11645                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11646                             if((*i3).command==_timer_once)
11647                                 ln+=(string)"timer_once "+(*i3).timer_name+" ";
11648                                 else
11649                                 ln+=(string)"timer_every "+(*i3).timer_name+" ";
11650                             time_t duration=(*i3).timer_sec;
11651                             string dur="";
11652 
11653                             time_t j;
11654 
11655                             j=duration%60;
11656                             char tmp[64];
11657                             char tmp2[2];
11658                             tmp2[1]=0;
11659                             ltoa((long)j,tmp,10);
11660                             if(j<10)
11661                                 tmp2[0]='0';
11662                                 else
11663                                 tmp2[0]=0;
11664                             dur=(string)":"+(string)tmp2+(string)tmp+dur;
11665 
11666                             duration/=60;
11667                             j=duration%60;
11668                             ltoa((long)j,tmp,10);
11669                             if(j<10)
11670                                 tmp2[0]='0';
11671                                 else
11672                                 tmp2[0]=0;
11673                             dur=(string)":"+(string)tmp2+(string)tmp+dur;
11674 
11675                             duration/=60;
11676                             j=duration%24;
11677                             ltoa((long)j,tmp,10);
11678                             if(j<10)
11679                                 tmp2[0]='0';
11680                                 else
11681                                 tmp2[0]=0;
11682                             dur=(string)":"+(string)tmp2+(string)tmp+dur;
11683 
11684                             duration/=24;
11685                             ltoa((long)j,tmp,10);
11686                             dur=(string)tmp+dur;
11687 
11688                             ln+=dur+" ";
11689                             ln+=(*i3).timer_cmd;
11690 
11691                             commands.push_back(ln);
11692                         }
11693                         break;
11694                     case _kill_timers:
11695                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11696                         ln+=(string)"kill_timers "+(*i3).timer_name;
11697                         commands.push_back(ln);
11698                         break;
11699                     case _execute:
11700                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11701                         ln+=(string)"execute "+(*i3).exec;
11702                         commands.push_back(ln);
11703                         break;
11704                     case _remote_execute:
11705                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11706                         ln+=(*i3).result+"=remote_execute "+(*i3).botname+" "+(*i3).exec;
11707                         commands.push_back(ln);
11708                         break;
11709                     case _smtp:
11710                         {
11711                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11712                             ln+="SMTP";
11713                             commands.push_back(ln);
11714 
11715                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11716                             ln+="{";
11717                             commands.push_back(ln);
11718                             indent+=4;
11719 
11720                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11721                             ln+=(string)"server "+(*i3).smtp.server;
11722                             commands.push_back(ln);
11723 
11724                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11725                             char tmp[64];
11726                             ltoa((*i3).smtp.port,tmp,10);
11727                             ln+=(string)"port "+tmp;
11728                             commands.push_back(ln);
11729 
11730                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11731                             ln+=(string)"HELO "+(*i3).smtp.helo;
11732                             commands.push_back(ln);
11733 
11734                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11735                             ln+=(string)"MAIL_FROM "+(*i3).smtp.mail_from;
11736                             commands.push_back(ln);
11737 
11738                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11739                             ln+=(string)"RCPT_TO "+(*i3).smtp.rcpt_to;
11740                             commands.push_back(ln);
11741 
11742                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11743                             ln+=(string)"DATA";
11744                             commands.push_back(ln);
11745 
11746                             list<string>::iterator i4;
11747                             for(i4=(*i3).smtp.data_lines.begin(); i4!=(*i3).smtp.data_lines.end(); i4++) {
11748                                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11749                                 ln+=*i4;
11750                                 commands.push_back(ln);
11751                             }
11752 
11753                             indent-=4;
11754                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11755                             ln+="}";
11756                             commands.push_back(ln);
11757                         }
11758                         break;
11759                     case _net_send:
11760                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11761                         ln+=(string)"NET_SEND "+(*i3).net_send_host+" "+(*i3).net_send_msg;
11762                         commands.push_back(ln);
11763                         break;
11764                     case _log:
11765                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11766                         ln+=(string)"LOG "+(*i3).log;
11767                         commands.push_back(ln);
11768                         break;
11769                     case _join:
11770                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11771                         ln+=(string)"join "+(*i3).channel+" "+(*i3).channel_key;
11772                         commands.push_back(ln);
11773                         break;
11774                     case _part:
11775                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11776                         ln+=(string)"part "+(*i3).channel+" "+(*i3).msg_text;
11777                         commands.push_back(ln);
11778                         break;
11779                     case _disconnect:
11780                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11781                         ln+="disconnect";
11782                         commands.push_back(ln);
11783                         break;
11784                     case _irc_server:
11785                         {
11786                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11787                             char tmp[64];
11788                             ltoa((*i3).port,tmp,10);
11789                             ln+=(string)"irc_server "+(*i3).server+" "+tmp;
11790                             commands.push_back(ln);
11791                         }
11792                         break;
11793                     case _try_connect:
11794                         {
11795                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11796                             ln+=(string)"try_connect";
11797                             commands.push_back(ln);
11798                         }
11799                         break;
11800                     case _bot_nick:
11801                         {
11802                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11803                             ln+="bot_nick";
11804                             vector<string>::iterator i4;
11805                             for(i4=(*i3).bot_nick.begin(); i4!=(*i3).bot_nick.end(); i4++)
11806                                 ln+=(string)" "+*i4;
11807                             commands.push_back(ln);
11808                         }
11809                         break;
11810                     case _delete_irc_servers:
11811                         {
11812                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11813                             ln+="delete_irc_servers ";
11814                             ln+=(*i3).server;
11815                             commands.push_back(ln);
11816                         }
11817                         break;
11818                     case _delete_nicks:
11819                         {
11820                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11821                             ln+="delete_nicks ";
11822                             ln+=(*i3).nick;
11823                             commands.push_back(ln);
11824                         }
11825                         break;
11826                     case _change_nick:
11827                         {
11828                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11829                             ln+="change_nick ";
11830                             ln+=(*i3).nick;
11831                             commands.push_back(ln);
11832                         }
11833                         break;
11834                     case _bot_ident:
11835                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11836                         ln+=(string)"bot_ident "+(*i3).bot_ident;
11837                         commands.push_back(ln);
11838                         break;
11839                     case _bot_ident_ipv6:
11840                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11841                         ln+=(string)"bot_ident_ipv6 "+(*i3).bot_ident;
11842                         commands.push_back(ln);
11843                         break;
11844                     case _bot_fullname:
11845                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11846                         ln+=(string)"bot_fullname "+(*i3).bot_fullname;
11847                         commands.push_back(ln);
11848                         break;
11849                     case _bot_auth:
11850                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11851                         ln+=(string)"bot_auth";
11852                         commands.push_back(ln);
11853                         break;
11854                     case _bot_redir:
11855                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11856                         ln+=(string)"allow_redirect "+((*i3).bot_redir?"1":"0");
11857                         commands.push_back(ln);
11858                         break;
11859                     case _if_error:
11860                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11861                         ln+=(string)"if_error";
11862                         commands.push_back(ln);
11863 
11864                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11865                         ln+=(string)"{";
11866                         commands.push_back(ln);
11867                         indent+=4;
11868                         break;
11869                     case _wait:
11870                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11871                         ln+=(string)"wait_if_error";
11872                         commands.push_back(ln);
11873 
11874                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11875                         ln+=(string)"{";
11876                         commands.push_back(ln);
11877                         indent+=4;
11878                         break;
11879                     case _label:
11880                         break;
11881                     case _goto:
11882                         break;
11883                     case _real_label:
11884                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11885                         ln+=(string)"label "+(*i3).label;
11886                         commands.push_back(ln);
11887                         break;
11888                     case _real_goto:
11889                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11890                         ln+=(string)"goto "+(*i3).label;
11891                         commands.push_back(ln);
11892                         break;
11893                     case _sleep_:
11894                         {
11895                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11896                             ln+=(string)"sleep ";
11897                             char tmp[64];
11898                             ltoa((*i3).sleep_secs,tmp,10);
11899                             ln+=tmp;
11900                             commands.push_back(ln);
11901                         }
11902                         break;
11903                     case _dynamic_ban:
11904                         {
11905                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11906                             ln+=(string)"dynamic_ban ";
11907                             ln+=(*i3).channel;
11908                             ln+=" ";
11909                             ln+=(*i3).ban_prefix;
11910                             ln+=" ";
11911                             ln+=(*i3).ban_mask;
11912                             ln+=" ";
11913                             ln+=(*i3).ban_reason;
11914                             commands.push_back(ln);
11915                         }
11916                         break;
11917                     case _process_on_banned:
11918                         {
11919                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11920                             ln+=(string)"process_on_banned ";
11921                             ln+=(*i3).channel;
11922                             ln+=" ";
11923                             ln+=(*i3).ban_mask;
11924                             commands.push_back(ln);
11925                         }
11926                         break;
11927                     case _check_dynamic_bans:
11928                         {
11929                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11930                             ln+=(*i3).result;
11931                             ln+="=check_dynamic_bans ";
11932                             ln+=(*i3).channel;
11933                             ln+=" ";
11934                             ln+=(*i3).nick;
11935                             ln+=" ";
11936                             ln+=(*i3).ban_reason;
11937                             commands.push_back(ln);
11938                         }
11939                         break;
11940                     case _restart:
11941                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11942                         ln+=(string)"restart";
11943                         commands.push_back(ln);
11944                         break;
11945                     case _raw:
11946                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11947                         ln+=(string)"raw "+logic_set_priority((*i3).priority)+" "+(*i3).msg_text;
11948                         commands.push_back(ln);
11949                         break;
11950                     case _admin_msg:
11951                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11952                         ln+=(string)"admin_msg "+(*i3).admin_msg_type+" "+(*i3).admin_msg_mask+" "+(*i3).admin_msg_message;
11953                         commands.push_back(ln);
11954                         break;
11955                     case _notice:
11956                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11957                         ln+=(string)"notice "+logic_set_priority((*i3).priority)+" "+(*i3).whom+" "+(*i3).msg_text;
11958                         commands.push_back(ln);
11959                         break;
11960                     case _noticeq:
11961                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11962                         ln+=(string)"noticeq "+logic_set_priority((*i3).priority)+" "+(*i3).whom+" "+(*i3).msg_text+" "+(*i3).msg_quoted;
11963                         commands.push_back(ln);
11964                         break;
11965                     case _unban_mask:
11966                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11967                         ln+=(string)"unban_mask "+(*i3).channel+" "+(*i3).whom;
11968                         commands.push_back(ln);
11969                         break;
11970                     case _ban_mask:
11971                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11972                         ln+=(string)"ban_mask "+(*i3).channel+" "+(*i3).whom;
11973                         commands.push_back(ln);
11974                         break;
11975                     case _dcc_server:
11976                         {
11977                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11978                             ln+=(string)"dcc_server ";
11979                             char tmp[64];
11980                             ltoa((*i3).group,tmp,10);
11981                             ln+=tmp;
11982                             ln+=(string)" "+(*i3).server+" ";
11983                             ltoa((*i3).port,tmp,10);
11984                             ln+=tmp;
11985                             ln+=" ";
11986                             ln+=(*i3).server_type;
11987                             commands.push_back(ln);
11988                         }
11989                         break;
11990                     case _dcc_server_ipv6:
11991                         {
11992                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
11993                             ln+=(string)"dcc_server_ipv6 ";
11994                             char tmp[64];
11995                             ltoa((*i3).group,tmp,10);
11996                             ln+=tmp;
11997                             ln+=(string)" "+(*i3).server+" ";
11998                             ltoa((*i3).port,tmp,10);
11999                             ln+=tmp;
12000                             ln+=" ";
12001                             ln+=(*i3).server_type;
12002                             commands.push_back(ln);
12003                         }
12004                         break;
12005                     case _end_bracket:
12006                         indent-=4;
12007                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12008                         ln+="}";
12009                         commands.push_back(ln);
12010                         break;
12011                     case _ident:
12012                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12013                         ln+=(*i3).result+"=ident "+(*i3).nick;
12014                         commands.push_back(ln);
12015                         break;
12016                     case _host:
12017                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12018                         ln+=(*i3).result+"=host "+(*i3).nick;
12019                         commands.push_back(ln);
12020                         break;
12021                     case _get_chan_mode:
12022                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12023                         ln+=(*i3).result+"=get_chan_mode "+(*i3).channel;
12024                         commands.push_back(ln);
12025                         break;
12026                     case _get_chan_topic:
12027                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12028                         ln+=(*i3).result+"=get_chan_topic "+(*i3).channel;
12029                         commands.push_back(ln);
12030                         break;
12031                     case _topic:
12032                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12033                         ln+="topic "+(*i3).channel+" "+(*i3).msg_text;
12034                         commands.push_back(ln);
12035                         break;
12036                     case _script:
12037                         {
12038                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12039                             ln+="SCRIPT ";
12040                             ln+=(*i3).script_type;
12041                             ln+=" ";
12042                             char tmp[64];
12043                             ltoa((*i3).script_num,tmp,10);
12044                             ln+=tmp;
12045                             ln+=" ";
12046                             ln+=(*i3).script_channel;
12047                             ln+=" ";
12048                             ln+=(*i3).script_params;
12049                             commands.push_back(ln);
12050                         }
12051                         break;
12052                     case _link:
12053                         {
12054                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12055                             char tmp[64];
12056                             ltoa((*i3).botport,tmp,10);
12057                             string port=tmp;
12058                             ln+=(string)"link "+(*i3).botlinktype+" "+(*i3).botname+" "+(*i3).botlocalip+" "+(*i3).botip+" "+port+" "+(*i3).botunlinkproc;
12059                             commands.push_back(ln);
12060                         }
12061                         break;
12062                     case _chan_mode:
12063                         {
12064                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12065                             ln+=(string)"chan_mode "+logic_set_priority((*i3).priority)+" "+(*i3).channel+" "+(*i3).chan_mode;
12066                             commands.push_back(ln);
12067                         }
12068                         break;
12069                     case _telnet_server:
12070                         {
12071                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12072                             char tmp[64];
12073                             ltoa((*i3).port,tmp,10);
12074                             string port=tmp;
12075                             ln+=(string)"telnet_server "+(*i3).server+" "+port;
12076                             commands.push_back(ln);
12077                         }
12078                         break;
12079                     case _telnet_server_ipv6:
12080                         {
12081                             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12082                             char tmp[64];
12083                             ltoa((*i3).port,tmp,10);
12084                             string port=tmp;
12085                             ln+=(string)"telnet_server_ipv6 "+(*i3).server+" "+port;
12086                             commands.push_back(ln);
12087                         }
12088                         break;
12089                     default:
12090                         log_debug("in file " __FILE__ " in function " __FUNC__ " occurred error: unknown command");
12091                         break;
12092                 }
12093             }
12094             while(indent>0) {
12095                 indent-=4;
12096                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
12097                 ln+="}";
12098                 commands.push_back(ln);
12099             }
12100         }
12101     }
12102 }

Here is the call graph for this function:

bool logic_load_conf const char *  filename,
int &  error_on_line,
const char *&  error_reason
 

Loads logic.txt file and parses it.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
filename Should be "logic.txt"
error_on_line If result == true, this contains number of line on which is error
error_reason If result == true, this contains error string
Returns:
Returns true if error occured

Definition at line 4789 of file logic.cpp.

References s_private::clear(), conf_getvar(), logic_process_line(), r_all_groups, r_channel_defs, r_channel_templates, r_channel_terminators, r_channels, r_procedures, r_terminators, r_user_templates, and r_users.

Referenced by logic_rehash(), and main().

04790 {
04791     {
04792         FILE* f=fopen(filename,"rt");
04793         if(f==NULL) {
04794             error_on_line=0;
04795             string err="Cannot open file \"";
04796             err+=filename;
04797             err+="\"!";
04798             static char err_[1024];
04799             strcpy(err_,err.c_str());
04800             error_reason=err_;
04801 
04802             if(f)
04803                 fclose(f);
04804 
04805             return true;
04806         }
04807         fclose(f);
04808     }
04809 
04810     error_on_line=1;
04811     error_reason=NULL;
04812 
04813     bool b_user2=false; // user in bracket
04814     s_user user;
04815     bool b_channel=false; // user in bracket, channel in sub-bracket
04816     s_channel channel;
04817     bool b_user=false; // user token
04818     int i_brackets=0;
04819     bool b_proc=false; // in procedure
04820     s_procedure procedure;
04821     list<s_lines> lines;
04822     bool b_smtp=false;
04823     s_smtp smtp;
04824     bool b_smtp_data=false;
04825     bool b_chan=false;
04826     bool b_groups=false;
04827     bool b_prv=false;
04828 
04829     s_channel_def chan;
04830 
04831     vector<s_procedure> procedures;
04832     vector<s_user> users;
04833     vector<s_channel> channels;
04834     vector<s_channel_def> channel_defs;
04835     vector<s_user> terminators;
04836 
04837     vector<s_group> all_groups;
04838 
04839     s_private prv;
04840 
04841     FILE* f=fopen((char*)filename,"r");
04842     char ln[10240+1];
04843     while(f && !feof(f)) {
04844         if(fgets(ln,1024*10-1,f)==NULL)
04845             break;
04846         ln[10240]=0;
04847         if(ln[strlen(ln)-1]=='\r')
04848             ln[strlen(ln)-1]=0;
04849         if(ln[strlen(ln)-1]=='\n')
04850             ln[strlen(ln)-1]=0;
04851         if(ln[strlen(ln)-1]=='\r')
04852             ln[strlen(ln)-1]=0;
04853         if(ln[strlen(ln)-1]=='\n')
04854             ln[strlen(ln)-1]=0;
04855 
04856         if(ln[0]==0 || ln[0]=='\r' || ln[0]=='\n')
04857             continue;
04858 
04859         if(atol(conf_getvar("log_echo_debug").c_str()))
04860             printf("%s\n",ln);
04861 
04862         string s;
04863         bool space=true;
04864         for(int i1=0; ln[i1]!=0; i1++) {
04865             if(ln[i1]==0x20 || ln[i1]=='\t')
04866                 if(space)
04867                     continue;
04868                     else
04869                     space=true;
04870             if(s.compare("") && space)
04871                 s.append("\x20");
04872             space=false;
04873             if(ln[i1]!=0x20 && ln[i1]!='\t')
04874                 s+=ln[i1];
04875         }
04876         for(size_t i2=s.length()-1; (signed)i2>=0; i2--)
04877             if(s[i2]==0x20 || s[i2]=='\t')
04878                 s=s.erase(i2,1);
04879                 else
04880                 break;
04881         if(logic_process_line(s,error_reason,error_on_line,b_user2,user,b_channel,channel,b_user,i_brackets,b_proc,procedure,lines,b_smtp,smtp,b_smtp_data,procedures,users,channels,chan,channel_defs,b_chan,all_groups,b_groups,b_prv,prv,terminators)) {
04882             if(f)
04883                 fclose(f);
04884             return true;
04885         }
04886         error_on_line++;
04887     }
04888     if(f)
04889         fclose(f);
04890 
04891     // all okay, copy all objects to real variables
04892     {
04893         {
04894             r_procedures.clear();
04895             vector<s_procedure>::iterator i;
04896             for(i=procedures.begin(); i!=procedures.end(); i++)
04897                 r_procedures.push_back(*i);
04898             procedures.clear();
04899         }
04900 
04901         {
04902             r_users.clear();
04903             r_user_templates.clear();
04904             vector<s_user>::iterator i;
04905             for(i=users.begin(); i!=users.end(); i++) {
04906                 if(!(*i).is_template)
04907                     r_users.push_back(*i);
04908                 else
04909                     r_user_templates.push_back(*i);
04910             }
04911             users.clear();
04912         }
04913 
04914         {
04915             r_terminators.clear();
04916             vector<s_user>::iterator i;
04917             for(i=terminators.begin(); i!=terminators.end(); i++) {
04918                 r_terminators.push_back(*i);
04919             }
04920             terminators.clear();
04921         }
04922 
04923         {
04924             r_channels.clear();
04925             r_channel_templates.clear();
04926             r_channel_terminators.clear();
04927             vector<s_channel>::iterator i;
04928             for(i=channels.begin(); i!=channels.end(); i++) {
04929                 if(!(*i).is_template) {
04930                     if(!(*i).terminator)
04931                         r_channels.push_back(*i);
04932                     else
04933                         r_channel_terminators.push_back(*i);
04934                 } else
04935                     r_channel_templates.push_back(*i);
04936             }
04937             channels.clear();
04938         }
04939 
04940         {
04941             r_channel_defs.clear();
04942             vector<s_channel_def>::iterator i;
04943             for(i=channel_defs.begin(); i!=channel_defs.end(); i++)
04944                 r_channel_defs.push_back(*i);
04945             channel_defs.clear();
04946         }
04947 
04948         {
04949             r_all_groups.clear();
04950             vector<s_group>::iterator i;
04951             for(i=all_groups.begin(); i!=all_groups.end(); i++)
04952                 r_all_groups.push_back(*i);
04953             all_groups.clear();
04954         }
04955 
04956         {
04957             r_private.clear();
04958             r_private=prv;
04959         }
04960     }
04961 
04962     error_on_line=0;
04963     return false;
04964 }

Here is the call graph for this function:

void logic_loop  ) 
 

This should be called in a loop. Executes timers and processes script output with freeing resources.

Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 10194 of file logic.cpp.

References conf_getvar(), exec_async_exec(), exec_process_active(), exec_process_end(), exec_terminate_process(), last_autobackup, logic_call_proc_ex2(), logic_partyline_backup(), logic_process_script_output(), r_timers, and tmp_files.

Referenced by main().

10195 {
10196     time_t now;
10197     time(&now);
10198 
10199     {
10200         time_t auto_backup_interval=atol(conf_getvar("auto_backup_interval").c_str());
10201         if(!last_autobackup)
10202             last_autobackup=now;
10203         if(auto_backup_interval!=0 && last_autobackup+auto_backup_interval<=now) {
10204             last_autobackup=now;
10205             logic_partyline_backup("self (autobackup)");
10206         }
10207     }
10208 
10209 l1:
10210     vector<s_timer>::iterator i;
10211     for(i=r_timers.begin(); i!=r_timers.end(); i++) {
10212         if((*i).again_at<=now) {
10213             (*i).set_at=now;
10214             (*i).again_at=now+(*i).duration;
10215 
10216             logic_call_proc_ex2((*i).call_string.c_str(),(*i).vars,(*i).params);
10217 
10218             if((*i).once) {
10219                 r_timers.erase(i);
10220                 goto l1;
10221             }
10222         }
10223     }
10224 
10225 l2:
10226     map<int,int> num_scripts;
10227     vector<s_tmp_file>::iterator i1;
10228     for(i1=tmp_files.begin(); i1!=tmp_files.end(); i1++) {
10229         if(!(*i1).script)
10230             continue;
10231         bool active=(*i1).h && exec_process_active((*i1).h);
10232         if(!(*i1).has_been_run)
10233             active=false;
10234         if(!active)
10235             continue;
10236         bool got=false;
10237         map<int,int>::iterator i2;
10238         for(i2=num_scripts.begin(); i2!=num_scripts.end(); i2++)
10239             if((*i2).first==(*i1).script_num) {
10240                 got=true;
10241                 (*i2).second++;
10242             }
10243         if(!got) {
10244             pair<int,int> p;
10245             p.first=(*i1).script_num;
10246             p.second=1;
10247             num_scripts.insert(p);
10248         }
10249     }
10250     for(i1=tmp_files.begin(); i1!=tmp_files.end(); i1++) {
10251         if((*i1).has_been_run && (*i1).h && !exec_process_active((*i1).h)) {
10252             if((*i1).script)
10253                 logic_process_script_output((*i1).script_type,(*i1).script_num,(*i1).h);
10254             tmp_files.erase(i1);
10255             goto l2;
10256         }
10257         if((*i1).has_been_run && (*i1).start_up_time+10*60<time(NULL)) {
10258             exec_terminate_process((*i1).h,1);
10259             exec_process_end((*i1).h);
10260             delete (*i1).h;
10261             tmp_files.erase(i1);
10262             goto l2;
10263         }
10264         if(!(*i1).script)
10265             continue;
10266         map<int,int>::iterator i2;
10267         int i=0;
10268         for(i2=num_scripts.begin(); i2!=num_scripts.end(); i2++)
10269             if((*i2).first==(*i1).script_num) {
10270                 i=(*i2).second;
10271                 break;
10272             }
10273         if(!i && !(*i1).has_been_run) {
10274             (*i1).h=exec_async_exec((*i1).command_line,(*i1).command_args,(*i1).command_dir);
10275             (*i1).has_been_run=true;
10276             (*i1).start_up_time=time(NULL);
10277             break;
10278         }
10279     }
10280 }

Here is the call graph for this function:

void logic_loop_identd  ) 
 

Handled IDENT request - this should be called in a loop.

Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 8361 of file logic.cpp.

References ident_string, and identd_check().

Referenced by logic_exec(), and main().

08362 {
08363     if(identd_check(ident_string.c_str())) {
08364         //identd_shutdown();
08365         // do not shutdown, we will do it manually after successful auth (for case of identd conflict)
08366     }
08367 }

Here is the call graph for this function:

void logic_on_banned string  channel,
string  ban_mask,
vector< string >  excepts,
vector< string >  invites,
vector< string > &  bans
 

Executes on_banned event (called when bot JOINs the channel and finds out that some user is banned by ban mask) also checks whether user is not +e excepted or +I invited, which overrides the ban mask.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name
ban_mask Ban mask
excepts Array with list of excepts (+e)
invites Array with list of invites (+I)
bans Reference to always-up-to-date ban list

Definition at line 9927 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), logic_check_mask(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_banned(), and logic_exec().

09928 {
09929     bool got_user=false;
09930 
09931     map<string,string> vars;
09932 
09933     vector<s_channel>::iterator i1;
09934     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09935         if(cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel))
09936             continue;
09937         vector<s_user>::iterator i3;
09938         for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
09939             if((*i3).name.compare((*i1).username))
09940                 continue;
09941             map<string,string> vars;
09942             vector<string>::iterator i2;
09943             for(i2=(*i3).hostmask.begin(); i2!=(*i3).hostmask.end(); i2++) {
09944                 if(!(*i3).host_unknown && logic_check_mask(ban_mask,logic_eval(*i2,vars),"*","*") && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09945                     vector<string>::iterator i4;
09946                     bool in_except=false;
09947                     for(i4=excepts.begin(); i4!=excepts.end(); i4++)
09948                         if(logic_check_mask(*i4,logic_eval(*i2,vars),"*","*"))
09949                             in_except=true;
09950                     for(i4=invites.begin(); i4!=invites.end(); i4++)
09951                         if(logic_check_mask(*i4,logic_eval(*i2,vars),"*","*"))
09952                             in_except=true;
09953                     if(!in_except) {
09954                         got_user=true;
09955                         string proc=(*i1).on_banned;
09956                         if(!proc.compare(""))
09957                             continue; // do NOT break; coz we need to track EVERY user!
09958 
09959                         vector<string>::iterator i5;
09960                         bool got=false;
09961                         for(i5=bans.begin(); i5!=bans.end(); i5++)
09962                             if(!(*i5).compare(ban_mask)) {
09963                                 got=true;
09964                                 break;
09965                             }
09966                         if(!got)
09967                             continue;
09968 
09969                         list<string> params;
09970                         params.push_back(channel); // $channel
09971                         params.push_back((*i3).name); // $user
09972                         params.push_back(ban_mask); // $ban_mask
09973 
09974                         map<string,string> vars;
09975                         switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09976                             case LOGIC_SOCKET_ERROR:
09977                             case LOGIC_RESTART:
09978                                 return;
09979                             default:
09980                                 break;
09981                         }
09982                         // do NOT break; coz we need to track EVERY user!
09983                     }
09984                 }
09985             }
09986         }
09987     }
09988 
09989     if(!got_user) {
09990         // try host_unknown
09991         vector<s_channel>::iterator i1;
09992         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09993             vector<s_user>::iterator i3;
09994             for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
09995                 map<string,string> vars;
09996                 if(!(*i1).username.compare((*i3).name) && (*i3).host_unknown && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09997                     string proc=(*i1).on_banned;
09998                     if(!proc.compare(""))
09999                         continue;
10000 
10001                     vector<string>::iterator i5;
10002                     bool got=false;
10003                     for(i5=bans.begin(); i5!=bans.end(); i5++)
10004                         if(!(*i5).compare(ban_mask)) {
10005                             got=true;
10006                             break;
10007                         }
10008                     if(!got)
10009                         continue;
10010 
10011                     list<string> params;
10012                     params.push_back(channel); // $channel
10013                     params.push_back((*i3).name); // $user
10014                     params.push_back(ban_mask); // $ban_mask
10015 
10016                     map<string,string> vars;
10017                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
10018                         case LOGIC_SOCKET_ERROR:
10019                         case LOGIC_RESTART:
10020                             return;
10021                         default:
10022                             break;
10023                     }
10024                 }
10025             }
10026         }
10027     }
10028 }

Here is the call graph for this function:

void logic_on_broadcast string  username,
string  nick,
string  ident,
string  host,
string  bcast_mask,
int  type,
string  msg,
string  server,
unsigned short  port
 

Raises on_broadcast event.

Author:
VooDooMan
Version:
1
Date:
2005-04-22
Parameters:
username Name of user as in logic.txt, or an empty string for "host_unknown" user
nick Nick name of originator
ident Ident of originator
host Host of originator
bcast_mask Broadcast mask ("$$irc.someserver.net")
type Type: TYPE_PRIVMSG, TYPE_NOTICE
msg The message
server IRC server host we are on
port IRC server port we are on

Definition at line 13967 of file logic.cpp.

References logic_call_proc_ex2(), logic_ctcp(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, s_private::on_broadcast, r_users, TYPE_NOTICE, and TYPE_PRIVMSG.

Referenced by irc_on_broadcast().

13970 {
13971     //bool got_user=false;
13972 
13973     if(username.empty()) {
13974         vector<s_user>::iterator i1;
13975         for(i1=r_users.begin(); i1!=r_users.end(); i1++)
13976             if((*i1).host_unknown) {
13977                 username=(*i1).name;
13978                 break;
13979             }
13980     }
13981 
13982     map<string,string> vars;
13983     string proc=r_private.on_broadcast;
13984     if(!proc.compare(""))
13985         return;
13986 
13987     list<string> params;
13988     params.push_back(username); // $source
13989     params.push_back(nick); // $source_nick
13990     params.push_back(ident); // $source_ident
13991     params.push_back(host); // $source_host
13992     params.push_back(bcast_mask); // $bcast_mask
13993     switch(type) {
13994         case TYPE_PRIVMSG:
13995             params.push_back("PRIVMSG"); // $type
13996             break;
13997         case TYPE_NOTICE:
13998             params.push_back("NOTICE"); // $type
13999             break;
14000         default:
14001             // should never occur, if even so, we have somewhere bug!
14002             params.push_back("?"); // $type
14003             break;
14004     }
14005     params.push_back(msg); // $msg
14006     params.push_back(server); // $server
14007     char tmp[512];
14008     sprintf(tmp,"%u",(unsigned)port);
14009     params.push_back(tmp); // $port
14010 
14011     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
14012         case LOGIC_SOCKET_ERROR:
14013         case LOGIC_RESTART:
14014             return;
14015         default:
14016             break;
14017     }
14018 
14019     // only respond to PRIVMSG, NOTICE's are NOT CTCP requests, but rather responses!
14020     if(type==TYPE_PRIVMSG && msg.find("\001",0)!=string::npos) {
14021         if(msg.find("\x01",0)!=string::npos) {
14022             msg.erase(msg.find("\x01",0),1);
14023             if(msg.find("\x01",0)!=string::npos)
14024                 msg.erase(msg.find("\x01",0),1);
14025         }
14026         logic_ctcp(username,nick,"",msg);
14027     }
14028 }

Here is the call graph for this function:

void logic_on_flood string  channel,
string  user,
string  nick,
int  type,
int  stat_num,
time_t  stat_sec,
time_t  stat_sec_of
 

Executes on_flood event procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name
user User name as define in logic.txt
nick Nick name
type Indicates type of flood - one of following: TYPE_PRIVMSG, TYPE_NOTICE, TYPE_NICK, TYPE_MODE, TYPE_JOIN, TYPE_REPEAT
stat_num Number of occurency
stat_sec Number of seconds that flood took
stat_sec_of Maximum number of seconds (defined as flood)

Definition at line 12631 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), logic_cmp_strings_case_insensitive(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, ltoa(), r_channels, TYPE_CTCP, TYPE_JOIN, TYPE_MODE, TYPE_NICK, TYPE_NOTICE, TYPE_PRIVMSG, and TYPE_REPEAT.

Referenced by irc_check_flood().

12632 {
12633     bool got_user=false;
12634 
12635     map<string,string> vars;
12636 
12637     vector<s_channel>::iterator i1;
12638 
12639     if(!user.compare((string)""))
12640         goto unknown;
12641 
12642     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
12643             if(!(*i1).username.compare(user) && !logic_cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
12644                 got_user=true;
12645 
12646                 string proc=(*i1).on_flood;
12647                 if(!proc.compare(""))
12648                     break;
12649 
12650                 list<string> params;
12651                 params.push_back(channel); // $channel
12652                 params.push_back(user); // $source
12653                 params.push_back(nick); // $source_nick
12654                 switch(type) {
12655                     case TYPE_PRIVMSG:
12656                         params.push_back("message");
12657                         break;
12658                     case TYPE_NOTICE:
12659                         params.push_back("notice");
12660                         break;
12661                     case TYPE_NICK:
12662                         params.push_back("nick");
12663                         break;
12664                     case TYPE_MODE:
12665                         params.push_back("mode");
12666                         break;
12667                     case TYPE_JOIN:
12668                         params.push_back("join");
12669                         break;
12670                     case TYPE_REPEAT:
12671                         params.push_back("repeat");
12672                         break;
12673                     case TYPE_CTCP:
12674                         params.push_back("ctcp");
12675                         break;
12676                     default:
12677                         params.push_back("other");
12678                         break;
12679                 }
12680 
12681                 char tmp[64];
12682                 params.push_back(ltoa(stat_num,tmp,10));
12683                 params.push_back(ltoa((long)stat_sec,tmp,10));
12684                 params.push_back(ltoa((long)stat_sec_of,tmp,10));
12685 
12686                 map<string,string> vars;
12687                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
12688                     case LOGIC_SOCKET_ERROR:
12689                     case LOGIC_RESTART:
12690                         return;
12691                     default:
12692                         break;
12693                 }
12694                 break;
12695             }
12696     }
12697 
12698     if(!got_user) {
12699         // try host_unknown
12700     unknown:
12701         vector<s_channel>::iterator i1;
12702         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
12703                 if((*i1).host_unknown && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
12704                     map<string,string> vars;
12705                     string proc=(*i1).on_flood;
12706                     if(!proc.compare(""))
12707                         break;
12708 
12709                     list<string> params;
12710                     params.push_back(channel); // $channel
12711                     params.push_back(user); // $source
12712                     params.push_back(nick); // $source_nick
12713                     switch(type) {
12714                         case TYPE_PRIVMSG:
12715                             params.push_back("message");
12716                             break;
12717                         case TYPE_NOTICE:
12718                             params.push_back("notice");
12719                             break;
12720                         case TYPE_NICK:
12721                             params.push_back("nick");
12722                             break;
12723                         case TYPE_MODE:
12724                             params.push_back("mode");
12725                             break;
12726                         case TYPE_JOIN:
12727                             params.push_back("join");
12728                             break;
12729                         case TYPE_REPEAT:
12730                             params.push_back("repeat");
12731                             break;
12732                         case TYPE_CTCP:
12733                             params.push_back("ctcp");
12734                             break;
12735                         default:
12736                             params.push_back("other");
12737                             break;
12738                     }
12739 
12740                     char tmp[64];
12741                     params.push_back(ltoa(stat_num,tmp,10));
12742                     params.push_back(ltoa((long)stat_sec,tmp,10));
12743                     params.push_back(ltoa((long)stat_sec_of,tmp,10));
12744 
12745                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
12746                         case LOGIC_SOCKET_ERROR:
12747                         case LOGIC_RESTART:
12748                             return;
12749                         default:
12750                             break;
12751                     }
12752                     break;
12753                 }
12754         }
12755     }
12756 }

Here is the call graph for this function:

void logic_on_internal_event string  type,
string  flags1,
string  flags2,
string  flags3,
string  flags4,
int  severity_numeric,
string  msg1,
string  msg2
 

Raises on_intenal_event event.

Author:
VooDooMan
Version:
1
Date:
2005-07-08
Parameters:
type Type of event
flags1 Flags #1
flags2 Flags #2
flags3 Flags #3
flags4 Flags #4
severity_numeric Number of severity
msg1 Message #1
msg2 Message #2

Definition at line 14137 of file logic.cpp.

References irc_server_host, irc_server_port, logic_call_proc_ex2(), logic_get_severity_text(), logic_kill_EOLs(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, ltoa(), and s_private::on_internal_event.

Referenced by botnet_loop(), botnet_push_chan(), botnet_push_proc(), botnet_push_prv(), botnet_push_user(), dcc_loop(), dcc_upgrade(), log_bot(), log_botnet(), log_botnet_debug(), log_broadcast(), log_channel(), log_debug(), log_identd(), log_irc(), log_socket(), log_ssl(), logic_on_ircop(), logic_partyline_backup(), logic_rehash(), logic_rollback(), and main().

14138 {
14139     string proc=r_private.on_internal_event;
14140     
14141     if(proc.empty())
14142         return;
14143 
14144     static bool in_event=false;
14145     if(in_event)
14146         return;
14147     in_event=true;
14148 
14149     type=logic_kill_EOLs(type);
14150     flags1=logic_kill_EOLs(flags1);
14151     flags2=logic_kill_EOLs(flags2);
14152     flags3=logic_kill_EOLs(flags3);
14153     flags4=logic_kill_EOLs(flags4);
14154     msg1=logic_kill_EOLs(msg1);
14155     msg2=logic_kill_EOLs(msg2);
14156 
14157     map<string,string> vars;
14158 
14159     list<string> params;
14160     params.push_back(type); // $type
14161 
14162     time_t now=time(NULL);
14163     char tmp[512];
14164     string time_string=ctime(&now);
14165     if(time_string.find("\n",0)!=string::npos)
14166         time_string.erase(time_string.find("\n",0),1);
14167 
14168     params.push_back(ltoa((long)now,tmp,10)); // $timestamp
14169     params.push_back(time_string); // $time_string
14170     params.push_back(flags1); // $flags1
14171     params.push_back(flags2); // $flags2
14172     params.push_back(flags3); // $flags3
14173     params.push_back(flags4); // $flags4
14174     params.push_back(ltoa((long)severity_numeric,tmp,10)); // $severity_numeric
14175     params.push_back(logic_get_severity_text(severity_numeric)); // $severity_string
14176     params.push_back(msg1); // $msg1
14177     params.push_back(msg2); // $msg2
14178     params.push_back(irc_server_host); // $server
14179     sprintf(tmp,"%u",(unsigned)irc_server_port);
14180     params.push_back(tmp); // $port
14181 
14182     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
14183         case LOGIC_SOCKET_ERROR:
14184         case LOGIC_RESTART:
14185             in_event=false;
14186             return;
14187         default:
14188             break;
14189     }
14190 
14191     in_event=false;
14192 }

Here is the call graph for this function:

void logic_on_ircop string  channel,
string  nick,
bool  on
 

Executes procedure for event on_ircop (when an IRC operator joins / is on after bot's join / left channel).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of channel
nick Nick name of IRC operator
on Set to true if is on channel, to false if it has left the channel

Definition at line 13771 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_get_fullname(), irc_get_host(), irc_get_ident(), irc_is_ircop(), logic_call_proc_ex2(), logic_find_user(), logic_on_internal_event(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, PRIVATE_EVENT_SEVERITY_CODE_WARNING, and r_channel_defs.

Referenced by irc_loop_process_input(), and irc_RPL_WHOISOPERATOR().

13772 {
13773     string user_name=logic_find_user(nick,irc_get_ident(nick),irc_get_host(nick),irc_get_fullname(nick),irc_is_ircop(nick));
13774 
13775     {
13776         string host_mask=nick;
13777         host_mask+="!";
13778         host_mask+=irc_get_ident(nick);
13779         host_mask+="@";
13780         host_mask+=irc_get_host(nick);
13781         string _on=on==true?"ON":"OFF";
13782         logic_on_internal_event("@ircop@",nick,host_mask,channel,_on,PRIVATE_EVENT_SEVERITY_CODE_WARNING,"",irc_get_fullname(nick));
13783     }
13784 
13785     vector<s_channel_def>::iterator i1;
13786     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
13787         if(!cmp_strings_case_insensitive((*i1).channel_name,channel)) {
13788             map<string,string> vars;
13789 
13790             string proc=(*i1).on_ircop;
13791             if(proc.empty())
13792                 break;
13793 
13794             list<string> params;
13795             params.push_back(channel); // $channel
13796             params.push_back(user_name); // $source
13797             params.push_back(nick); // $source_nick
13798             params.push_back(on?"1":"0"); // $on
13799 
13800             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13801                 case LOGIC_SOCKET_ERROR:
13802                 case LOGIC_RESTART:
13803                     return;
13804                 default:
13805                     break;
13806             }
13807             break;
13808         }
13809     }
13810 }

Here is the call graph for this function:

void logic_on_join string  nick,
string  ident,
string  host,
string  fullname,
string  channel,
bool  irc_op
 

Executes on_join event (called when someone JOINs the channel).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
nick Nick name
ident Ident
host Host
fullname Full name
channel Channel name
irc_op Pass there true if WHOIS indicates that this is an irc op

Definition at line 9608 of file logic.cpp.

References cmp_strings_case_insensitive(), dcc_upgrade_bot_join(), dcc_want_to_upgrade, logic_call_proc_ex2(), logic_eval(), logic_find_user(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_loop_process_input(), irc_RPL_WHOISCHANNELS(), and irc_RPL_WHOISUSER().

09609 {
09610     bool got_user=false;
09611 
09612     string user=logic_find_user(nick, ident, host, fullname, irc_op);
09613 
09614     extern bool dcc_want_to_upgrade;
09615     if(dcc_want_to_upgrade) {
09616         vector<s_user>::iterator i1;
09617         for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
09618             if((*i1).host_bot && !(*i1).name.compare(user)) {
09619                 dcc_upgrade_bot_join(nick,ident,host,fullname,channel);
09620                 break;
09621             }
09622         }
09623     }
09624 
09625     map<string,string> vars;
09626 
09627     vector<s_channel>::iterator i1;
09628     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09629         if(!(*i1).username.compare(user) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09630 
09631             string proc=(*i1).on_join;
09632             if(!proc.compare(""))
09633                 break;
09634 
09635             list<string> params;
09636             params.push_back(channel); // $channel
09637             params.push_back(user); // $user
09638             params.push_back(nick); // $nick
09639             params.push_back((*i1).dynamic_plus_modes); // $dynamic1
09640             params.push_back((*i1).dynamic_minus_modes); // $dynamic2
09641             params.push_back("0"); // $passive
09642 
09643             map<string,string> vars;
09644             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09645                 case LOGIC_SOCKET_ERROR:
09646                 case LOGIC_RESTART:
09647                     return;
09648                 default:
09649                     break;
09650             }
09651             got_user=true;
09652             break;
09653         }
09654     }
09655 
09656     if(!got_user) {
09657         // try host_unknown
09658         vector<s_user>::iterator i;
09659         for(i=r_users.begin(); i!=r_users.end(); i++) {
09660             if((*i).host_unknown) {
09661                 got_user=true;
09662                 break;
09663             }
09664         }
09665         if(!got_user)
09666             return;
09667 
09668         vector<s_channel>::iterator i1;
09669         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09670             if(!(*i1).username.compare((*i).name) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09671 
09672                 string proc=(*i1).on_join;
09673                 if(!proc.compare(""))
09674                     break;
09675 
09676                 list<string> params;
09677                 params.push_back(channel); // $channel
09678                 params.push_back(user); // $user
09679                 params.push_back(nick); // $nick
09680                 params.push_back((*i1).dynamic_plus_modes); // $dynamic1
09681                 params.push_back((*i1).dynamic_minus_modes); // $dynamic2
09682                 params.push_back("0"); // $passive
09683 
09684                 map<string,string> vars;
09685                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09686                     case LOGIC_SOCKET_ERROR:
09687                     case LOGIC_RESTART:
09688                         return;
09689                     default:
09690                         break;
09691                 }
09692             }
09693         }
09694     }
09695 }

Here is the call graph for this function:

void logic_on_nick_change string  nick,
string  ident,
string  host,
string  fullname,
string  channel,
bool  irc_op,
string  old_nick
 

Validates new nick.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
nick Nick name
ident Ident
host Host
fullname Full name
channel Channel name
irc_op Pass there true if WHOIS indicates that this is an irc op
old_nick Previous (old) nick name

Definition at line 9710 of file logic.cpp.

References cmp_strings_case_insensitive(), dcc_upgrade_bot_nick(), dcc_want_to_upgrade, irc_get_mode(), logic_call_proc_ex2(), logic_eval(), logic_find_user(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_loop_process_input().

09711 {
09712     string user=logic_find_user(nick, ident, host, fullname, irc_op);
09713 
09714     extern bool dcc_want_to_upgrade;
09715     if(dcc_want_to_upgrade) {
09716         vector<s_user>::iterator i1;
09717         for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
09718             if((*i1).host_bot && !(*i1).name.compare(user)) {
09719                 dcc_upgrade_bot_nick(old_nick,ident,host,fullname,nick);
09720                 break;
09721             }
09722         }
09723     }
09724 
09725     bool got_user=false;
09726 
09727     string old_user=logic_find_user(old_nick, ident, host, fullname, irc_op);
09728 
09729     map<string,string> vars;
09730 
09731     vector<s_channel>::iterator i1;
09732     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09733         if(!(*i1).username.compare(user) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel) && old_user.compare(user)) {
09734 
09735             string proc=(*i1).on_join;
09736             if(!proc.compare(""))
09737                 break;
09738 
09739             list<string> params;
09740             params.push_back(channel); // $channel
09741             params.push_back(user); // $user
09742             params.push_back(nick); // $nick
09743             params.push_back((*i1).dynamic_plus_modes); // $dynamic1
09744             params.push_back((*i1).dynamic_minus_modes); // $dynamic2
09745             params.push_back(irc_get_mode(channel,nick)); // $passive
09746 
09747             map<string,string> vars;
09748             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09749                 case LOGIC_SOCKET_ERROR:
09750                 case LOGIC_RESTART:
09751                     return;
09752                 default:
09753                     break;
09754             }
09755             break;
09756         }
09757     }
09758 
09759     if(!got_user) {
09760         // try host_unknown
09761         vector<s_user>::iterator i;
09762         for(i=r_users.begin(); i!=r_users.end(); i++) {
09763             if((*i).host_unknown) {
09764                 got_user=true;
09765                 break;
09766             }
09767         }
09768         if(!got_user)
09769             return;
09770 
09771         vector<s_channel>::iterator i1;
09772         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09773             if(!(*i1).username.compare((*i).name) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel) && old_user.compare(user)) {
09774 
09775                 string proc=(*i1).on_join;
09776                 if(!proc.compare(""))
09777                     break;
09778 
09779                 list<string> params;
09780                 params.push_back(channel); // $channel
09781                 params.push_back(user); // $user
09782                 params.push_back(nick); // $nick
09783                 params.push_back((*i1).dynamic_plus_modes); // $dynamic1
09784                 params.push_back((*i1).dynamic_minus_modes); // $dynamic2
09785                 params.push_back(irc_get_mode(channel,nick)); // $passive
09786 
09787                 map<string,string> vars;
09788                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09789                     case LOGIC_SOCKET_ERROR:
09790                     case LOGIC_RESTART:
09791                         return;
09792                     default:
09793                         break;
09794                 }
09795             }
09796         }
09797     }
09798 }

Here is the call graph for this function:

void logic_on_nick_validate string  nick,
string  ident,
string  host,
string  fullname,
string  channel,
bool  irc_op,
bool  passive
 

Validates user after bot has joined / got +o (op) / rehashed.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
nick Nick name
ident Ident
host Host
fullname Full name
channel Channel name
irc_op Pass there true if WHOIS indicates that this is an irc op
passive Set to true if this is called after .rehash, or after bot's join - it pass to possibly new user or new host to $passive it's mode as an argument to procedure on_join in "logic.txt" file

Definition at line 9813 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_get_mode(), logic_call_proc_ex2(), logic_eval(), logic_find_user(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_mode_change_op(), irc_rehashed(), irc_RPL_WHOISUSER(), and irc_user_mode_change().

09814 {
09815     bool got_user=false;
09816 
09817     string user=logic_find_user(nick, ident, host, fullname, irc_op);
09818 
09819     map<string,string> vars;
09820 
09821     vector<s_channel>::iterator i1;
09822     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09823         if(!(*i1).username.compare(user) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09824             got_user=true;
09825 
09826             string proc=(*i1).on_join;
09827             if(!proc.compare(""))
09828                 break;
09829 
09830             list<string> params;
09831             params.push_back(channel); // $channel
09832             params.push_back(user); // $user
09833             params.push_back(nick); // $nick
09834             params.push_back((*i1).dynamic_plus_modes); // $dynamic1
09835             params.push_back((*i1).dynamic_minus_modes); // $dynamic2
09836             if(passive)
09837                 params.push_back((string)"1"+irc_get_mode(channel,nick)); // $passive
09838             else
09839                 params.push_back("0"); // $passive
09840 
09841             map<string,string> vars;
09842             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09843                 case LOGIC_SOCKET_ERROR:
09844                 case LOGIC_RESTART:
09845                     return;
09846                 default:
09847                     break;
09848             }
09849             break;
09850         }
09851     }
09852 
09853     if(!got_user) {
09854         // try host_unknown
09855         vector<s_user>::iterator i;
09856         for(i=r_users.begin(); i!=r_users.end(); i++) {
09857             if((*i).host_unknown) {
09858                 got_user=true;
09859                 break;
09860             }
09861         }
09862         if(!got_user)
09863             return;
09864 
09865         vector<s_channel>::iterator i1;
09866         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09867             if(!(*i1).username.compare((*i).name) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09868 
09869                 string proc=(*i1).on_join;
09870                 if(!proc.compare(""))
09871                     break;
09872 
09873                 list<string> params;
09874                 params.push_back(channel); // $channel
09875                 params.push_back(user); // $user
09876                 params.push_back(nick); // $nick
09877                 params.push_back((*i1).dynamic_plus_modes); // $dynamic1
09878                 params.push_back((*i1).dynamic_minus_modes); // $dynamic2
09879                 if(passive)
09880                     params.push_back((string)"1"+irc_get_mode(channel,nick)); // $passive
09881                 else
09882                     params.push_back("0"); // $passive
09883 
09884                 map<string,string> vars;
09885                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09886                     case LOGIC_SOCKET_ERROR:
09887                     case LOGIC_RESTART:
09888                         return;
09889                     default:
09890                         break;
09891                 }
09892             }
09893         }
09894     }
09895 }

Here is the call graph for this function:

void logic_on_not_in_reop string  channel,
string  mask,
string  user_name
 

Executes on_not_in_reop event (called when bot JOINs the channel and finds out that some user is not in reop list by +R).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name
mask Host mask
user_name Name of an user as in logic.txt

Definition at line 10118 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_check_for_not_reopped().

10119 {
10120     bool got_user=false;
10121 
10122     map<string,string> vars;
10123 
10124     vector<s_channel>::iterator i1;
10125     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
10126         vector<s_user>::iterator i3;
10127         if(!cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
10128             if(!(*i1).username.compare(user_name)) {
10129                     got_user=true;
10130 
10131                     map<string,string> vars;
10132                     vector<string>::iterator i2;
10133 
10134                     string proc=(*i1).on_not_in_reop;
10135                     if(!proc.compare(""))
10136                         break;
10137 
10138                     list<string> params;
10139                     params.push_back(channel); // $channel
10140                     params.push_back(user_name); // $user
10141                     params.push_back(mask); // $mask
10142 
10143                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
10144                         case LOGIC_SOCKET_ERROR:
10145                         case LOGIC_RESTART:
10146                             return;
10147                         default:
10148                             break;
10149                     }
10150                     break;
10151             }
10152         }
10153     }
10154 
10155     if(!got_user) {
10156         // try host_unknown
10157         vector<s_channel>::iterator i1;
10158         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
10159             vector<s_user>::iterator i3;
10160             for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
10161                 map<string,string> vars;
10162                 if(!(*i1).username.compare((*i3).name) && (*i3).host_unknown && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
10163                     map<string,string> vars;
10164                     vector<string>::iterator i2;
10165 
10166                     string proc=(*i1).on_not_in_reop;
10167                     if(!proc.compare(""))
10168                         continue; // do NOT break; coz we need to track EVERY user!
10169 
10170                     list<string> params;
10171                     params.push_back(channel); // $channel
10172                     params.push_back((*i1).username); // $user
10173                     params.push_back(mask); // $mask
10174 
10175                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
10176                         case LOGIC_SOCKET_ERROR:
10177                         case LOGIC_RESTART:
10178                             return;
10179                         default:
10180                             break;
10181                     }
10182                 }
10183             }
10184         }
10185     }
10186 }

Here is the call graph for this function:

void logic_on_not_invited string  channel,
string  mask,
string  user_name
 

Executes on_not_invited event (called when bot JOINs the channel and finds out that some user is not invited by +I).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name
mask Host mask
user_name Name of an user as in logic.txt

Definition at line 10039 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_check_for_not_invited().

10040 {
10041     bool got_user=false;
10042 
10043     map<string,string> vars;
10044 
10045     vector<s_channel>::iterator i1;
10046     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
10047         vector<s_user>::iterator i3;
10048         if(!cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
10049             if(!(*i1).username.compare(user_name)) {
10050                     got_user=true;
10051 
10052                     map<string,string> vars;
10053                     vector<string>::iterator i2;
10054 
10055                     string proc=(*i1).on_not_invited;
10056                     if(!proc.compare(""))
10057                         break;
10058 
10059                     list<string> params;
10060                     params.push_back(channel); // $channel
10061                     params.push_back(user_name); // $user
10062                     params.push_back(mask); // $mask
10063 
10064                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
10065                         case LOGIC_SOCKET_ERROR:
10066                         case LOGIC_RESTART:
10067                             return;
10068                         default:
10069                             break;
10070                     }
10071                     break;
10072             }
10073         }
10074     }
10075 
10076     if(!got_user) {
10077         // try host_unknown
10078         vector<s_channel>::iterator i1;
10079         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
10080             vector<s_user>::iterator i3;
10081             for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
10082                 map<string,string> vars;
10083                 if(!(*i1).username.compare((*i3).name) && (*i3).host_unknown && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
10084                     map<string,string> vars;
10085                     vector<string>::iterator i2;
10086 
10087                     string proc=(*i1).on_not_invited;
10088                     if(!proc.compare(""))
10089                         continue; // do NOT break; coz we need to track EVERY user!
10090 
10091                     list<string> params;
10092                     params.push_back(channel); // $channel
10093                     params.push_back((*i1).username); // $user
10094                     params.push_back(mask); // $mask
10095 
10096                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
10097                         case LOGIC_SOCKET_ERROR:
10098                         case LOGIC_RESTART:
10099                             return;
10100                         default:
10101                             break;
10102                     }
10103                 }
10104             }
10105         }
10106     }
10107 }

Here is the call graph for this function:

void logic_on_notice string  channel,
string  user,
string  nick,
string  msg
 

Executes on_notice event procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name, or an empty string for query/private notice
user User name as define in logic.txt
nick Nick name
msg Message (NOTICE parameter)

Definition at line 13110 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), logic_cmp_strings_case_insensitive(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, s_private::on_notice, r_channel_defs, r_channels, and r_users.

Referenced by irc_on_notice().

13111 {
13112     bool got_user=false;
13113 
13114     map<string,string> vars;
13115 
13116     vector<s_channel>::iterator i1;
13117 
13118     if(!user.compare((string)""))
13119         goto unknown;
13120 
13121     if(!channel.empty()) {
13122         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
13123             if(!(*i1).username.compare(user) && !logic_cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
13124                 got_user=true;
13125                 {
13126                     map<string,string> vars;
13127                     string proc=(*i1).on_notice;
13128                     if(!proc.compare(""))
13129                         break;
13130 
13131                     list<string> params;
13132                     params.push_back(channel); // $channel
13133                     params.push_back(user); // $source
13134                     params.push_back(nick); // $source_nick
13135                     params.push_back(msg); // $msg
13136 
13137                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13138                         case LOGIC_SOCKET_ERROR:
13139                         case LOGIC_RESTART:
13140                             return;
13141                         default:
13142                             break;
13143                     }
13144                     break;
13145                 }
13146             }
13147         }
13148 
13149         if(!got_user) {
13150             // try host_unknown
13151         unknown:
13152 
13153             {
13154                 vector<s_user>::iterator i1;
13155                 for(i1=r_users.begin(); i1!=r_users.end(); i1++)
13156                     if((*i1).host_unknown) {
13157                         user=(*i1).name;
13158                         break;
13159                     }
13160             }
13161 
13162             vector<s_channel>::iterator i1;
13163             for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
13164             if((*i1).host_unknown && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
13165                 {
13166                     map<string,string> vars;
13167                     string proc=(*i1).on_notice;
13168                     if(!proc.compare(""))
13169                         break;
13170     
13171                     list<string> params;
13172                     params.push_back(channel); // $channel
13173                     params.push_back(user); // $source
13174                     params.push_back(nick); // $source_nick
13175                     params.push_back(msg); // $msg
13176 
13177                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13178                         case LOGIC_SOCKET_ERROR:
13179                         case LOGIC_RESTART:
13180                             return;
13181                         default:
13182                             break;
13183                     }
13184                     break;
13185                 }
13186             }
13187         }
13188 
13189         vector<s_channel_def>::iterator i2;
13190         for(i2=r_channel_defs.begin(); i2!=r_channel_defs.end(); i2++)
13191             if(!cmp_strings_case_insensitive(channel,(*i2).channel_name)) {
13192                 map<string,string> vars;
13193                 string proc=(*i2).on_notice;
13194                 if(!proc.compare(""))
13195                     break;
13196                 list<string> params;
13197                 params.push_back(channel); // $channel
13198                 params.push_back(user); // $source
13199                 params.push_back(nick); // $source_nick
13200                 params.push_back(msg); // $msg
13201 
13202                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13203                     case LOGIC_SOCKET_ERROR:
13204                     case LOGIC_RESTART:
13205                         return;
13206                     default:
13207                         break;
13208                 }
13209                 break;
13210             }
13211         }
13212         if(channel.empty())
13213             goto private_query;
13214     } else {
13215     private_query:
13216         map<string,string> vars;
13217         string proc=r_private.on_notice;
13218         if(!proc.compare(""))
13219             return;
13220 
13221         list<string> params;
13222         params.push_back(user); // $source
13223         params.push_back(nick); // $source_nick
13224         params.push_back(msg); // $msg
13225 
13226         switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13227             case LOGIC_SOCKET_ERROR:
13228             case LOGIC_RESTART:
13229                 return;
13230             default:
13231                 break;
13232         }
13233     }
13234 
13235     // commented out 2005-04-22 by VooDooMan
13236     // 1) NOTICE's are NOT CTCP requests, but responses, so don't process them here!
13237     // 2) If we would respond to NOTICE, we would violate RFC saying that there
13238     //    MUST NOT be automatic response to NOTICE!
13239     /*
13240     if(msg.find("\001",0)!=string::npos) {
13241         if(msg.find("\x01",0)!=string::npos) {
13242             msg.erase(msg.find("\x01",0),1);
13243             if(msg.find("\x01",0)!=string::npos)
13244                 msg.erase(msg.find("\x01",0),1);
13245         }
13246         logic_ctcp(user,nick,channel,msg);
13247     }
13248     */
13249 }

Here is the call graph for this function:

void logic_on_part string  channel,
string  nick,
string  msg,
int  type
 

Executes on_part event procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name
nick Nick name
msg Reason
type TYPE_PART, TYPE_QUIT, or TYPE_KICK

Definition at line 13822 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_get_fullname(), irc_get_host(), irc_get_ident(), irc_is_ircop(), logic_call_proc_ex2(), logic_find_user(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channel_defs, TYPE_KICK, TYPE_PART, and TYPE_QUIT.

Referenced by irc_loop_process_input().

13823 {
13824     string user=logic_find_user(nick,irc_get_ident(nick),irc_get_host(nick),irc_get_fullname(nick),irc_is_ircop(nick));
13825 
13826     vector<s_channel_def>::iterator i2;
13827     for(i2=r_channel_defs.begin(); i2!=r_channel_defs.end(); i2++)
13828         if(!cmp_strings_case_insensitive(channel,(*i2).channel_name)) {
13829             map<string,string> vars;
13830             string proc=(*i2).on_part;
13831             if(!proc.compare(""))
13832                 break;
13833             list<string> params;
13834             params.push_back(channel); // $channel
13835             params.push_back(user); // $source
13836             params.push_back(nick); // $source_nick
13837             params.push_back(msg); // $msg
13838             switch(type) {
13839                 case TYPE_PART:
13840                     params.push_back("PART");
13841                     break;
13842                 case TYPE_QUIT:
13843                     params.push_back("QUIT");
13844                     break;
13845                 case TYPE_KICK:
13846                     params.push_back("KICK");
13847                     break;
13848                 default:
13849                     params.push_back("");
13850                     break;
13851             }
13852 
13853             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13854                 case LOGIC_SOCKET_ERROR:
13855                 case LOGIC_RESTART:
13856                     return;
13857                 default:
13858                     break;
13859             }
13860             break;
13861         }
13862 }

Here is the call graph for this function:

void logic_on_privmsg string  channel,
string  user,
string  nick,
string  msg
 

Executes on_privmsg event procedure.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Channel name
user User name as define in logic.txt
nick Nick name
msg Message (PRIVMSG parameter)

Definition at line 12999 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), logic_cmp_strings_case_insensitive(), logic_ctcp(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channel_defs, and r_channels.

Referenced by irc_on_privmsg().

13000 {
13001     bool got_user=false;
13002 
13003     map<string,string> vars;
13004 
13005     vector<s_channel>::iterator i1;
13006 
13007     if(!user.compare((string)""))
13008         goto unknown;
13009 
13010     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
13011         if(!(*i1).username.compare(user) && !logic_cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
13012             got_user=true;
13013             {
13014                 map<string,string> vars;
13015                 string proc=(*i1).on_privmsg;
13016                 if(!proc.compare(""))
13017                     break;
13018 
13019                 list<string> params;
13020                 params.push_back(channel); // $channel
13021                 params.push_back(user); // $source
13022                 params.push_back(nick); // $source_nick
13023                 params.push_back(msg); // $msg
13024 
13025                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13026                     case LOGIC_SOCKET_ERROR:
13027                     case LOGIC_RESTART:
13028                         return;
13029                     default:
13030                         break;
13031                 }
13032                 break;
13033             }
13034         }
13035     }
13036 
13037     if(!got_user) {
13038         // try host_unknown
13039     unknown:
13040         vector<s_channel>::iterator i1;
13041         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
13042             if((*i1).host_unknown && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
13043                 {
13044                     map<string,string> vars;
13045                     string proc=(*i1).on_privmsg;
13046                     if(!proc.compare(""))
13047                         break;
13048 
13049                     list<string> params;
13050                     params.push_back(channel); // $channel
13051                     params.push_back(user); // $source
13052                     params.push_back(nick); // $source_nick
13053                     params.push_back(msg); // $msg
13054 
13055                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13056                         case LOGIC_SOCKET_ERROR:
13057                         case LOGIC_RESTART:
13058                             return;
13059                         default:
13060                             break;
13061                     }
13062                     break;
13063                 }
13064             }
13065         }
13066     }
13067 
13068     vector<s_channel_def>::iterator i2;
13069     for(i2=r_channel_defs.begin(); i2!=r_channel_defs.end(); i2++)
13070         if(!cmp_strings_case_insensitive(channel,(*i2).channel_name)) {
13071             map<string,string> vars;
13072             string proc=(*i2).on_privmsg;
13073             if(!proc.compare(""))
13074                 break;
13075             list<string> params;
13076             params.push_back(channel); // $channel
13077             params.push_back(user); // $source
13078             params.push_back(nick); // $source_nick
13079             params.push_back(msg); // $msg
13080 
13081             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13082                 case LOGIC_SOCKET_ERROR:
13083                 case LOGIC_RESTART:
13084                     return;
13085                 default:
13086                     break;
13087             }
13088             break;
13089         }
13090     if(msg.find("\001",0)!=string::npos) {
13091         if(msg.find("\x01",0)!=string::npos) {
13092             msg.erase(msg.find("\x01",0),1);
13093             if(msg.find("\x01",0)!=string::npos)
13094                 msg.erase(msg.find("\x01",0),1);
13095         }
13096         logic_ctcp(user,nick,channel,msg);
13097     }
13098 }

Here is the call graph for this function:

void logic_on_privmsg_query string  user,
string  nick,
string  msg
 

Executes on_privmsg event procedure (for query only - not channel).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
user User name as defined in logic.txt
nick Nick name
msg Message (PRIVMSG parameter)

Definition at line 13260 of file logic.cpp.

References logic_call_proc_ex2(), logic_ctcp(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, s_private::on_privmsg, and r_users.

Referenced by irc_on_privmsg().

13261 {
13262     bool quoted=false;
13263 
13264     if(msg.find("\x01",0)!=string::npos)
13265         quoted=true;
13266 
13267     //bool got_user=false;
13268 
13269     map<string,string> vars;
13270 
13271     vector<s_channel>::iterator i1;
13272 
13273     if(user.empty()) {
13274         vector<s_user>::iterator i1;
13275         for(i1=r_users.begin(); i1!=r_users.end(); i1++)
13276             if((*i1).host_unknown) {
13277                 user=(*i1).name;
13278                 break;
13279             }
13280 
13281         // we don't have "host_unknown" defined!
13282         if(user.empty())
13283             return;
13284     }
13285 
13286     {
13287         map<string,string> vars;
13288         string proc=r_private.on_privmsg;
13289         if(!proc.compare(""))
13290             return;
13291 
13292         list<string> params;
13293         params.push_back(user); // $source
13294         params.push_back(nick); // $source_nick
13295         params.push_back(msg); // $msg
13296 
13297         switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
13298             case LOGIC_SOCKET_ERROR:
13299             case LOGIC_RESTART:
13300                 return;
13301             default:
13302                 break;
13303         }
13304     }
13305     
13306     if(quoted) {
13307         if(msg.find("\x01",0)!=string::npos) {
13308             msg.erase(msg.find("\x01",0),1);
13309             if(msg.find("\x01",0)!=string::npos)
13310                 msg.erase(msg.find("\x01",0),1);
13311         }
13312         logic_ctcp(user,nick,"",msg);
13313     }
13314 }

Here is the call graph for this function:

void logic_on_server_msg string  channel,
string  source,
int  type,
string  msg,
string  server,
unsigned short  port
 

Raises on_server_msg event.

Author:
VooDooMan
Version:
1
Date:
2005-04-25
Parameters:
channel Name of channel, or an empty string for private message
source Name of server
type Type: TYPE_PRIVMSG, TYPE_NOTICE
msg The message
server IRC server host we are on
port IRC server port we are on

Definition at line 14042 of file logic.cpp.

References cmp_strings_case_insensitive(), logic_call_proc_ex2(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, s_private::on_server_msg, r_channel_defs, TYPE_NOTICE, and TYPE_PRIVMSG.

Referenced by irc_loop_process_input().

14043 {
14044     //bool got_user=false;
14045 
14046     string proc;
14047     if(channel.empty())
14048         proc=r_private.on_server_msg;
14049     else {
14050         vector<s_channel_def>::iterator i2;
14051         for(i2=r_channel_defs.begin(); i2!=r_channel_defs.end(); i2++)
14052             if(!cmp_strings_case_insensitive(channel,(*i2).channel_name)) {
14053                 proc=(*i2).on_server_msg;
14054                 break;
14055             }
14056     }
14057     
14058     if(!proc.compare(""))
14059         return;
14060 
14061     map<string,string> vars;
14062 
14063     list<string> params;
14064     if(!channel.empty())
14065         params.push_back(channel); // $channel
14066     else
14067         params.push_back(""); // $channel
14068     params.push_back(source); // $source
14069     switch(type) {
14070         case TYPE_PRIVMSG:
14071             params.push_back("PRIVMSG"); // $type
14072             break;
14073         case TYPE_NOTICE:
14074             params.push_back("NOTICE"); // $type
14075             break;
14076         default:
14077             // should never occur, if even so, we have somewhere bug!
14078             params.push_back("?"); // $type
14079             break;
14080     }
14081     params.push_back(msg); // $msg
14082     params.push_back(server); // $server
14083     char tmp[512];
14084     sprintf(tmp,"%u",(unsigned)port);
14085     params.push_back(tmp); // $port
14086 
14087     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
14088         case LOGIC_SOCKET_ERROR:
14089         case LOGIC_RESTART:
14090             return;
14091         default:
14092             break;
14093     }
14094 }

Here is the call graph for this function:

void logic_parse_proc const char *&  error_reason,
int &  error_line,
list< string >  commands,
bool  copy_to_r_procedures,
string  declaration,
vector< string >  groups
 

Parses and compiles procedure (for partyline).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
error_reason If result == true: Returns addres of string with error description
error_line Line counter. This parameter MUST have the same value as returned on previous call! (for the first time it MUST be initialized to one)
commands Array of lines to parse
copy_to_r_procedures Set tu true if successfuly parsed procedure need to be updated/added in/to r_procedures
declaration Procedure name with full declaration (without "procedure" token!)
groups List of groups which procedure is member of

Definition at line 12345 of file logic.cpp.

References _end_bracket, s_command::command, s_procedure::commands, s_procedure::groups, s_procedure::last_changed, logic_process_line(), s_group::name, and r_procedures.

Referenced by botnet_loop(), and dcc_loop_edit_proc().

12346 {
12347     error_line=0;
12348     error_reason=NULL;
12349 
12350     bool b_user2=false; // user in bracket
12351     s_user user;
12352     bool b_channel=false; // user in bracket, channel in sub-bracket
12353     s_channel channel;
12354     bool b_user=false; // user token
12355     int i_brackets=0;
12356     bool b_proc=false; // in procedure
12357     s_procedure procedure;
12358     list<s_lines> lines;
12359     bool b_smtp=false;
12360     s_smtp smtp;
12361     bool b_smtp_data=false;
12362     bool b_chan=false;
12363     bool b_groups=false;
12364     bool b_prv=false;
12365 
12366     s_channel_def chan;
12367 
12368     vector<s_procedure> procedures;
12369     vector<s_user> users;
12370     vector<s_channel> channels;
12371     vector<s_channel_def> channel_defs;
12372     vector<s_user> terminators;
12373 
12374     vector<s_group> all_groups;
12375 
12376     s_private prv;
12377 
12378     bool error=false;
12379 
12380     error=logic_process_line((string)"procedure "+declaration,error_reason,error_line,b_user2,user,b_channel,channel,b_user,i_brackets,b_proc,procedure,lines,b_smtp,smtp,b_smtp_data,procedures,users,channels,chan,channel_defs,b_chan,all_groups,b_groups,b_prv,prv,terminators);
12381     error=logic_process_line("{",error_reason,error_line,b_user2,user,b_channel,channel,b_user,i_brackets,b_proc,procedure,lines,b_smtp,smtp,b_smtp_data,procedures,users,channels,chan,channel_defs,b_chan,all_groups,b_groups,b_prv,prv,terminators);
12382 
12383     int i3=1;
12384 
12385     list<string>::iterator i1;
12386     for(i1=commands.begin(); i1!=commands.end(); i1++, i3++) {
12387         string s=*i1;
12388         size_t i2;
12389         for(i2=s.length()-1; (signed)i2>=0; i2--)
12390             if(s[i2]==0x20 || s[i2]=='\t')
12391                 s=s.erase(i2,1);
12392                 else
12393                 break;
12394         while(s.length()>0 && (s[0]==0x20 || s[0]=='\t'))
12395             s=s.erase(0,1);
12396         error=logic_process_line(s,error_reason,error_line,b_user2,user,b_channel,channel,b_user,i_brackets,b_proc,procedure,lines,b_smtp,smtp,b_smtp_data,procedures,users,channels,chan,channel_defs,b_chan,all_groups,b_groups,b_prv,prv,terminators);
12397         if(error) {
12398             error_line=i3;
12399             return;
12400         }
12401     }
12402     error_line=0;
12403 
12404     if(i_brackets!=1) {
12405         error_line=i3;
12406         error_reason="Mistake in brackets { }";
12407     }
12408 
12409     if(error_line==0 && copy_to_r_procedures) {
12410         s_command c;
12411         c.command=_end_bracket;
12412         procedure.commands.push_back(c);
12413 
12414         bool got=false;
12415         vector<s_procedure>::iterator i1;
12416         for(i1=r_procedures.begin(); i1!=r_procedures.end(); i1++) {
12417             if(!(*i1).name.compare(declaration)) {
12418                 got=true;
12419                 (*i1).groups.clear();
12420                 vector<string>::iterator i2;
12421                 for(i2=groups.begin(); i2!=groups.end(); i2++) {
12422                     s_group g;
12423                     g.name=*i2;
12424                     (*i1).groups.push_back(g);
12425                 }
12426                 (*i1).commands=procedure.commands;
12427                 (*i1).last_changed=procedure.last_changed;
12428                 break;
12429             }
12430         }
12431         if(!got) {
12432             procedure.groups.clear();
12433             vector<string>::iterator i2;
12434             for(i2=groups.begin(); i2!=groups.end(); i2++) {
12435                 s_group g;
12436                 g.name=*i2;
12437                 procedure.groups.push_back(g);
12438             }
12439             r_procedures.push_back(procedure);
12440         }
12441     }
12442 }

Here is the call graph for this function:

void logic_partyline_backup string  who  ) 
 

Forces to writes all object to logic.txt file.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
who This should contain who caused rehasing (for log purposes - bot.log)

Definition at line 743 of file logic.cpp.

References dcc_want_to_upgrade, filesys_flush(), s_private::groups, s_private::last_changed, log_bot(), logic_list_proc(), logic_on_internal_event(), ltoa(), s_private::on_broadcast, s_private::on_ctcp, s_private::on_filesys_got_new, s_private::on_fnc, s_private::on_internal_event, s_private::on_notice, s_private::on_privmsg, s_private::on_server_msg, PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL, PRIVATE_EVENT_SEVERITY_CODE_WARNING, r_all_groups, r_channel_defs, r_channel_templates, r_channels, r_procedures, r_terminators, r_user_templates, r_users, REPL_PULL, REPL_PUSH, REPL_PUSHPULL, and s_private::replication.

Referenced by dcc_loop(), dcc_upgrade(), handler_sighup(), handler_sigterm(), logic_botnet_backup(), logic_loop(), and main().

00744 {
00745     filesys_flush();
00746 
00747     extern bool dcc_want_to_upgrade;
00748     if(dcc_want_to_upgrade) {
00749         who=(string)"*** ";
00750         string log2="UPGRADE state, ignoring backup request by "+who;
00751         who+=log2;
00752         log_bot(who.c_str());
00753 
00754         logic_on_internal_event("@backup@",who,"","","",PRIVATE_EVENT_SEVERITY_CODE_WARNING,log2,"");
00755         return;
00756     }
00757 
00758     logic_on_internal_event("@backup@",who,"","","",PRIVATE_EVENT_SEVERITY_CODE_INFORMATIONAL,"","");
00759 
00760     who=(string)"*** Backup invoked by "+who;
00761     log_bot(who.c_str());
00762     {
00763         char tmp1[256], tmp2[256];
00764         for(int i1=999; i1>0; i1--) {
00765             sprintf(tmp1,"%s%03d","logic.txt.bak",i1);
00766             sprintf(tmp2,"%s%03d","logic.txt.bak",i1-1);
00767             remove(tmp1);
00768             rename(tmp2,tmp1);
00769         }
00770         remove(tmp2);
00771         rename("logic.txt",tmp2);
00772     }
00773 
00774     FILE* f=fopen("logic.txt","w");
00775     if(!f)
00776         return;
00777     int indent=0;
00778     vector<s_user>::iterator i1;
00779     string ln;
00780     int ii;
00781     for(int iii=0; iii<3; iii++) {
00782         vector<s_user> users;
00783         if(iii==0)
00784             users=r_users;
00785         else
00786             if(iii==1)
00787                 users=r_user_templates;
00788             else
00789                 if(iii==2)
00790                     users=r_terminators;
00791         for(i1=users.begin(); i1!=users.end(); i1++) {
00792             if(!(*i1).is_template) {
00793                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00794                 ln+=(string)"user "+(*i1).name;
00795                 fprintf(f,"%s\n",ln.c_str());
00796             } else {
00797                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00798                 ln+=(string)"user_template "+(*i1).name;
00799                 fprintf(f,"%s\n",ln.c_str());
00800             }
00801 
00802             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00803             ln+="{";
00804             fprintf(f,"%s\n",ln.c_str());
00805             indent+=4;
00806 
00807             if((*i1).host_unknown) {
00808                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00809                 ln+="host_unknown";
00810                 fprintf(f,"%s\n",ln.c_str());
00811             }
00812 
00813             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00814             ln+="terminator ";
00815             fprintf(f,"%s%d\n",ln.c_str(),(*i1).terminator);
00816 
00817             if((*i1).host_bot) {
00818                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00819                 ln+="host_bot";
00820                 fprintf(f,"%s\n",ln.c_str());
00821             }
00822 
00823             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00824             ln+="last_changed ";
00825             char tmp[64];
00826             ltoa((long)(*i1).last_changed,tmp,10);
00827             ln+=tmp;
00828             fprintf(f,"%s\n",ln.c_str());
00829 
00830             vector<string>::iterator i2;
00831             for(i2=(*i1).hostmask.begin(); i2!=(*i1).hostmask.end(); i2++) {
00832                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00833                 ln+=(string)"host "+*i2;
00834                 fprintf(f,"%s\n",ln.c_str());
00835             }
00836 
00837             for(i2=(*i1).fullname.begin(); i2!=(*i1).fullname.end(); i2++) {
00838                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00839                 ln+=(string)"full_name "+*i2;
00840                 fprintf(f,"%s\n",ln.c_str());
00841             }
00842 
00843             vector<s_replication>::iterator i8;
00844             for(i8=(*i1).replication.begin(); i8!=(*i1).replication.end(); i8++) {
00845                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00846                 string type;
00847                 if((*i8).type==REPL_PUSH)
00848                     type="push";
00849                 if((*i8).type==REPL_PULL)
00850                     type="pull";
00851                 if((*i8).type==REPL_PUSHPULL)
00852                     type="pushpull";
00853                 ln+=(string)"replication "+(*i8).partner+" "+type;
00854                 fprintf(f,"%s\n",ln.c_str());
00855             }
00856 
00857             if((*i1).replication_partner) {
00858                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00859                 ln+=(string)"replication_partner";
00860                 fprintf(f,"%s\n",ln.c_str());
00861             }
00862 
00863             for(i2=(*i1).access_to_group.begin(); i2!=(*i1).access_to_group.end(); i2++) {
00864                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00865                 ln+=(string)"access_to_group "+*i2;
00866                 fprintf(f,"%s\n",ln.c_str());
00867             }
00868 
00869             for(i2=(*i1).access_to_proc.begin(); i2!=(*i1).access_to_proc.end(); i2++) {
00870                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00871                 ln+=(string)"access_to_procedure "+*i2;
00872                 fprintf(f,"%s\n",ln.c_str());
00873             }
00874 
00875             for(i2=(*i1).access_grant_procedure.begin(); i2!=(*i1).access_grant_procedure.end(); i2++) {
00876                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00877                 ln+=(string)"access_grant_procedure "+*i2;
00878                 fprintf(f,"%s\n",ln.c_str());
00879             }
00880 
00881             for(i2=(*i1).access_usage_procedure.begin(); i2!=(*i1).access_usage_procedure.end(); i2++) {
00882                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00883                 ln+=(string)"access_usage_procedure "+*i2;
00884                 fprintf(f,"%s\n",ln.c_str());
00885             }
00886 
00887             for(i2=(*i1).access_grant_group.begin(); i2!=(*i1).access_grant_group.end(); i2++) {
00888                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00889                 ln+=(string)"access_grant_group "+*i2;
00890                 fprintf(f,"%s\n",ln.c_str());
00891             }
00892 
00893             for(i2=(*i1).access_to_channel.begin(); i2!=(*i1).access_to_channel.end(); i2++) {
00894                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00895                 ln+=(string)"access_to_channel "+*i2;
00896                 fprintf(f,"%s\n",ln.c_str());
00897             }
00898 
00899             for(i2=(*i1).access_grant_channel.begin(); i2!=(*i1).access_grant_channel.end(); i2++) {
00900                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00901                 ln+=(string)"access_grant_channel "+*i2;
00902                 fprintf(f,"%s\n",ln.c_str());
00903             }
00904 
00905             vector<s_group>::iterator i3;
00906             for(i3=(*i1).groups.begin(); i3!=(*i1).groups.end(); i3++) {
00907                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00908                 ln+=(string)"member_of_group "+(*i3).name;
00909                 fprintf(f,"%s\n",ln.c_str());
00910             }
00911 
00912             vector<s_dcc_host>::iterator i4;
00913             for(i4=(*i1).dcc_hosts.begin(); i4!=(*i1).dcc_hosts.end(); i4++) {
00914                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00915                 char tmp[64];
00916                 ltoa((*i4).group,tmp,10);
00917                 ln+=(string)"dcc_host ";
00918                 ln+=tmp;
00919                 ln+=" "+(*i4).host;
00920                 fprintf(f,"%s\n",ln.c_str());
00921             }
00922 
00923             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00924             ln+=((*i1).access_to_partyline?"access_to_partyline 1":"access_to_partyline 0");
00925             fprintf(f,"%s\n",ln.c_str());
00926 
00927             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00928             ln+=((*i1).access_grant_partyline?"access_grant_partyline 1":"access_grant_partyline 0");
00929             fprintf(f,"%s\n",ln.c_str());
00930 
00931             //---
00932             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00933             ln+=((*i1).access_to_backup?"access_to_backup 1":"access_to_backup 0");
00934             fprintf(f,"%s\n",ln.c_str());
00935 
00936             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00937             ln+=((*i1).access_to_rehash?"access_to_rehash 1":"access_to_rehash 0");
00938             fprintf(f,"%s\n",ln.c_str());
00939 
00940             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00941             ln+=((*i1).access_grant_backup?"access_grant_backup 1":"access_grant_backup 0");
00942             fprintf(f,"%s\n",ln.c_str());
00943 
00944             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00945             ln+=((*i1).access_grant_rehash?"access_grant_rehash 1":"access_grant_rehash 0");
00946             fprintf(f,"%s\n",ln.c_str());
00947 
00948 
00949             //---
00950             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00951             ln+=((*i1).access_to_restart?"access_to_restart 1":"access_to_restart 0");
00952             fprintf(f,"%s\n",ln.c_str());
00953 
00954             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00955             ln+=((*i1).access_grant_restart?"access_grant_restart 1":"access_grant_restart 0");
00956             fprintf(f,"%s\n",ln.c_str());
00957 
00958             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00959             ln+=((*i1).access_to_die?"access_to_die 1":"access_to_die 0");
00960             fprintf(f,"%s\n",ln.c_str());
00961 
00962             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00963             ln+=((*i1).access_grant_die?"access_grant_die 1":"access_grant_die 0");
00964             fprintf(f,"%s\n",ln.c_str());
00965             //---
00966 
00967             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00968             ln+=((*i1).access_to_plususer?"access_to_+user 1":"access_to_+user 0");
00969             fprintf(f,"%s\n",ln.c_str());
00970 
00971             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00972             ln+=((*i1).access_grant_plususer?"access_grant_+user 1":"access_grant_+user 0");
00973             fprintf(f,"%s\n",ln.c_str());
00974 
00975             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00976             ln+=((*i1).access_to_plusproc?"access_to_+proc 1":"access_to_+proc 0");
00977             fprintf(f,"%s\n",ln.c_str());
00978 
00979             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00980             ln+=((*i1).access_grant_plusproc?"access_grant_+proc 1":"access_grant_+proc 0");
00981             fprintf(f,"%s\n",ln.c_str());
00982 
00983             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00984             ln+=((*i1).access_to_replication?"access_to_replication 1":"access_to_replication 0");
00985             fprintf(f,"%s\n",ln.c_str());
00986 
00987             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00988             ln+=((*i1).access_grant_replication?"access_grant_replication 1":"access_grant_replication 0");
00989             fprintf(f,"%s\n",ln.c_str());
00990 
00991             //---
00992             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00993             ln+=((*i1).access_to_filesystem?"access_to_filesystem 1":"access_to_filesystem 0");
00994             fprintf(f,"%s\n",ln.c_str());
00995 
00996             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
00997             ln+=((*i1).access_grant_filesystem?"access_grant_filesystem 1":"access_grant_filesystem 0");
00998             fprintf(f,"%s\n",ln.c_str());        
00999             //---
01000 
01001             //---
01002             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01003             ln+=((*i1).access_to_private?"access_to_private 1":"access_to_private 0");
01004             fprintf(f,"%s\n",ln.c_str());
01005 
01006             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01007             ln+=((*i1).access_grant_private?"access_grant_private 1":"access_grant_private 0");
01008             fprintf(f,"%s\n",ln.c_str());        
01009             //---
01010 
01011             //---
01012             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01013             ln+=((*i1).access_to_upgrade?"access_to_upgrade 1":"access_to_upgrade 0");
01014             fprintf(f,"%s\n",ln.c_str());
01015 
01016             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01017             ln+=((*i1).access_grant_upgrade?"access_grant_upgrade 1":"access_grant_upgrade 0");
01018             fprintf(f,"%s\n",ln.c_str());        
01019             //---
01020 
01021             //---
01022             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01023             ln+=((*i1).access_to_apply?"access_to_apply 1":"access_to_apply 0");
01024             fprintf(f,"%s\n",ln.c_str());
01025 
01026             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01027             ln+=((*i1).access_grant_apply?"access_grant_apply 1":"access_grant_apply 0");
01028             fprintf(f,"%s\n",ln.c_str());        
01029             //---
01030 
01031             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01032             ln+=((*i1).access_to_can_send_all_users?"access_to_can_send_all_users 1":"access_to_can_send_all_users 0");
01033             fprintf(f,"%s\n",ln.c_str());
01034 
01035             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01036             ln+=((*i1).access_grant_can_send_all_users?"access_grant_can_send_all_users 1":"access_grant_can_send_all_users 0");
01037             fprintf(f,"%s\n",ln.c_str());
01038             //---
01039 
01040             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01041             ln+=((*i1).access_to_can_send_unknown_users?"access_to_can_send_unknown_users 1":"access_to_can_send_unknown_users 0");
01042             fprintf(f,"%s\n",ln.c_str());
01043 
01044             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01045             ln+=((*i1).access_grant_can_send_unknown_users?"access_grant_can_send_unknown_users 1":"access_grant_can_send_unknown_users 0");
01046             fprintf(f,"%s\n",ln.c_str());
01047 
01048             //---
01049 
01050             map<string,string>::iterator i6;
01051             for(i6=(*i1).meta.begin(); i6!=(*i1).meta.end(); i6++) {
01052                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01053                 ln+="meta ";
01054                 ln+=(*i6).first;
01055                 ln+=" ";
01056                 ln+=(*i6).second;
01057                 fprintf(f,"%s\n",ln.c_str());
01058             }
01059 
01060             //---
01061 
01062             vector<s_channel> chans;
01063             if(iii==0)
01064                 chans=r_channels;
01065             else
01066                 chans=r_channel_templates;
01067             vector<s_channel>::iterator i5;
01068             for(i5=chans.begin(); i5!=chans.end(); i5++) {
01069                 if(!(*i5).username.compare((*i1).name)) {
01070                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01071                     ln+=(string)"channel "+(*i5).channel_name;
01072                     fprintf(f,"%s\n",ln.c_str());
01073 
01074                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01075                     ln+="{";
01076                     fprintf(f,"%s\n",ln.c_str());
01077                     indent+=4;
01078     
01079                     for(i3=(*i5).groups.begin(); i3!=(*i5).groups.end(); i3++) {
01080                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01081                         ln+=(string)"member_of_group "+(*i3).name;
01082                         fprintf(f,"%s\n",ln.c_str());
01083                     }
01084 
01085                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01086                     ln+="on_deop "+(*i5).on_deop;
01087                     fprintf(f,"%s\n",ln.c_str());
01088 
01089                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01090                     ln+="on_ban "+(*i5).on_ban;
01091                     fprintf(f,"%s\n",ln.c_str());
01092 
01093                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01094                     ln+="on_unban "+(*i5).on_unban;
01095                     fprintf(f,"%s\n",ln.c_str());
01096 
01097                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01098                     ln+="on_kick "+(*i5).on_kick;
01099                     fprintf(f,"%s\n",ln.c_str());
01100 
01101                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01102                     ln+="on_op "+(*i5).on_op;
01103                     fprintf(f,"%s\n",ln.c_str());
01104 
01105                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01106                     ln+="on_voice "+(*i5).on_voice;
01107                     fprintf(f,"%s\n",ln.c_str());
01108 
01109                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01110                     ln+="on_devoice "+(*i5).on_devoice;
01111                     fprintf(f,"%s\n",ln.c_str());
01112 
01113                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01114                     ln+="on_creator "+(*i5).on_creator;
01115                     fprintf(f,"%s\n",ln.c_str());
01116 
01117                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01118                     ln+="on_decreator "+(*i5).on_decreator;
01119                     fprintf(f,"%s\n",ln.c_str());
01120 
01121                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01122                     ln+="on_join "+(*i5).on_join;
01123                     fprintf(f,"%s\n",ln.c_str());
01124 
01125                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01126                     ln+="on_banned "+(*i5).on_banned;
01127                     fprintf(f,"%s\n",ln.c_str());
01128 
01129                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01130                     ln+="on_flood "+(*i5).on_flood;
01131                     fprintf(f,"%s\n",ln.c_str());
01132 
01133                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01134                     ln+="on_privmsg "+(*i5).on_privmsg;
01135                     fprintf(f,"%s\n",ln.c_str());
01136 
01137                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01138                     ln+="on_notice "+(*i5).on_notice;
01139                     fprintf(f,"%s\n",ln.c_str());
01140 
01141                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01142                     ln+="on_except "+(*i5).on_except;
01143                     fprintf(f,"%s\n",ln.c_str());
01144 
01145                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01146                     ln+="on_unexcept "+(*i5).on_unexcept;
01147                     fprintf(f,"%s\n",ln.c_str());
01148 
01149                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01150                     ln+="on_invite "+(*i5).on_invite;
01151                     fprintf(f,"%s\n",ln.c_str());
01152 
01153                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01154                     ln+="on_uninvite "+(*i5).on_uninvite;
01155                     fprintf(f,"%s\n",ln.c_str());
01156 
01157                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01158                     ln+="on_not_invited "+(*i5).on_not_invited;
01159                     fprintf(f,"%s\n",ln.c_str());
01160 
01161                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01162                     ln+="on_not_in_reop "+(*i5).on_not_in_reop;
01163                     fprintf(f,"%s\n",ln.c_str());
01164 
01165                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01166                     ln+="on_reop "+(*i5).on_reop;
01167                     fprintf(f,"%s\n",ln.c_str());
01168 
01169                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01170                     ln+="on_other_mode "+(*i5).on_other_mode;
01171                     fprintf(f,"%s\n",ln.c_str());
01172 
01173                     char tmp1[64], tmp2[64];
01174 
01175                     if((*i5).msg_flood.lines==0)
01176                         (*i5).msg_flood.seconds=0;
01177                     if((*i5).notice_flood.lines==0)
01178                         (*i5).notice_flood.seconds=0;
01179                     if((*i5).repeat_flood.lines==0)
01180                         (*i5).repeat_flood.seconds=0;
01181                     if((*i5).nick_flood.lines==0)
01182                         (*i5).nick_flood.seconds=0;
01183                     if((*i5).join_flood.lines==0)
01184                         (*i5).join_flood.seconds=0;
01185                     if((*i5).mode_flood.lines==0)
01186                         (*i5).mode_flood.seconds=0;
01187                     if((*i5).ctcp_flood.lines==0)
01188                         (*i5).ctcp_flood.seconds=0;
01189 
01190                     ltoa((*i5).msg_flood.lines,tmp1,10);
01191                     ltoa((long)(*i5).msg_flood.seconds,tmp2,10);
01192                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01193                     ln+=(string)"msg_flood "+tmp1+" "+tmp2;
01194                     fprintf(f,"%s\n",ln.c_str());
01195 
01196                     ltoa((*i5).notice_flood.lines,tmp1,10);
01197                     ltoa((long)(*i5).notice_flood.seconds,tmp2,10);
01198                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01199                     ln+=(string)"notice_flood "+tmp1+" "+tmp2;
01200                     fprintf(f,"%s\n",ln.c_str());
01201 
01202                     ltoa((*i5).repeat_flood.lines,tmp1,10);
01203                     ltoa((long)(*i5).repeat_flood.seconds,tmp2,10);
01204                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01205                     ln+=(string)"repeat_flood "+tmp1+" "+tmp2;
01206                     fprintf(f,"%s\n",ln.c_str());
01207 
01208                     ltoa((*i5).nick_flood.lines,tmp1,10);
01209                     ltoa((long)(*i5).nick_flood.seconds,tmp2,10);
01210                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01211                     ln+=(string)"nick_flood "+tmp1+" "+tmp2;
01212                     fprintf(f,"%s\n",ln.c_str());
01213 
01214                     ltoa((*i5).join_flood.lines,tmp1,10);
01215                     ltoa((long)(*i5).join_flood.seconds,tmp2,10);
01216                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01217                     ln+=(string)"join_flood "+tmp1+" "+tmp2;
01218                     fprintf(f,"%s\n",ln.c_str());
01219 
01220                     ltoa((*i5).mode_flood.lines,tmp1,10);
01221                     ltoa((long)(*i5).mode_flood.seconds,tmp2,10);
01222                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01223                     ln+=(string)"mode_flood "+tmp1+" "+tmp2;
01224                     fprintf(f,"%s\n",ln.c_str());
01225 
01226                     ltoa((*i5).ctcp_flood.lines,tmp1,10);
01227                     ltoa((long)(*i5).ctcp_flood.seconds,tmp2,10);
01228                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01229                     ln+=(string)"ctcp_flood "+tmp1+" "+tmp2;
01230                     fprintf(f,"%s\n",ln.c_str());
01231 
01232                     vector<s_dynamic_rule>::iterator i8;
01233                     for(i8=(*i5).allow_dynamic.begin(); i8!=(*i5).allow_dynamic.end(); i8++) {
01234                         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01235                         ln+="allow_dynamic ";
01236                         ln+=(*i8).group;
01237                         ln+=" ";
01238                         ln+=(*i8).plus_modes;
01239                         ln+=" ";
01240                         ln+=(*i8).minus_modes;
01241                         fprintf(f,"%s\n",ln.c_str());
01242                     }
01243 
01244                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01245                     ln+=(string)"dynamic1 "+(*i5).dynamic_plus_modes;
01246                     fprintf(f,"%s\n",ln.c_str());
01247 
01248                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01249                     ln+=(string)"dynamic2 "+(*i5).dynamic_minus_modes;
01250                     fprintf(f,"%s\n",ln.c_str());
01251 
01252                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01253                     ln+=(string)"can_send_unknown_users "+((*i5).can_send_unknown_users?"1":"0");
01254                     fprintf(f,"%s\n",ln.c_str());
01255 
01256                     indent-=4;
01257                     ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01258                     ln+="}";
01259                     fprintf(f,"%s\n",ln.c_str());
01260                 }
01261             }
01262             indent-=4;
01263             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01264             ln+="}";
01265             fprintf(f,"%s\n",ln.c_str());
01266         }
01267     }
01268 
01269     vector<s_channel_def>::iterator i3;
01270     for(i3=r_channel_defs.begin(); i3!=r_channel_defs.end(); i3++) {
01271 
01272         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01273         ln+=(string)"channel \""+(*i3).channel_name+"\"";
01274         fprintf(f,"%s\n",ln.c_str());
01275 
01276         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01277         ln+="{";
01278         fprintf(f,"%s\n",ln.c_str());
01279         indent+=4;
01280 
01281         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01282         ln+="last_changed ";
01283         char tmp[64];
01284         ltoa((long)(*i3).last_changed,tmp,10);
01285         ln+=tmp;
01286         fprintf(f,"%s\n",ln.c_str());
01287 
01288         vector<s_group>::iterator i5;
01289         for(i5=(*i3).groups.begin(); i5!=(*i3).groups.end(); i5++) {
01290             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01291             ln+=(string)"member_of_group "+(*i5).name;
01292             fprintf(f,"%s\n",ln.c_str());
01293         }
01294 
01295         vector<s_replication>::iterator i7;
01296         for(i7=(*i3).replication.begin(); i7!=(*i3).replication.end(); i7++) {
01297             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01298             string type;
01299             if((*i7).type==REPL_PUSH)
01300                 type="push";
01301             if((*i7).type==REPL_PULL)
01302                 type="pull";
01303             if((*i7).type==REPL_PUSHPULL)
01304                 type="pushpull";
01305             ln+=(string)"replication "+(*i7).partner+" "+type;
01306             fprintf(f,"%s\n",ln.c_str());
01307         }
01308 
01309         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01310         ln+="on_mode "+(*i3).on_mode;
01311         fprintf(f,"%s\n",ln.c_str());
01312 
01313         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01314         ln+="on_key "+(*i3).on_key;
01315         fprintf(f,"%s\n",ln.c_str());
01316 
01317         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01318         ln+="on_limit "+(*i3).on_limit;
01319         fprintf(f,"%s\n",ln.c_str());
01320 
01321         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01322         ln+="on_topic "+(*i3).on_topic;
01323         fprintf(f,"%s\n",ln.c_str());
01324 
01325         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01326         ln+="on_ircop "+(*i3).on_ircop;
01327         fprintf(f,"%s\n",ln.c_str());
01328 
01329         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01330         ln+="on_ctcp "+(*i3).on_ctcp;
01331         fprintf(f,"%s\n",ln.c_str());
01332 
01333         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01334         ln+="on_privmsg "+(*i3).on_privmsg;
01335         fprintf(f,"%s\n",ln.c_str());
01336 
01337         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01338         ln+="on_notice "+(*i3).on_notice;
01339         fprintf(f,"%s\n",ln.c_str());
01340 
01341         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01342         ln+="on_part "+(*i3).on_part;
01343         fprintf(f,"%s\n",ln.c_str());
01344 
01345         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01346         ln+="on_dynamic_ban "+(*i3).on_dynamic_ban;
01347         fprintf(f,"%s\n",ln.c_str());
01348 
01349         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01350         ln+="on_server_msg "+(*i3).on_server_msg;
01351         fprintf(f,"%s\n",ln.c_str());
01352 
01353         {
01354             vector<string>::iterator i1;
01355             for(i1=(*i3).keys.begin(); i1!=(*i3).keys.end(); i1++) {
01356                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01357                 ln+=(string)"key "+(*i1);
01358                 fprintf(f,"%s\n",ln.c_str());
01359             }
01360         }
01361 
01362         {
01363             map<string,string>::iterator i1;
01364             for(i1=(*i3).dynamic_bans.begin(); i1!=(*i3).dynamic_bans.end(); i1++) {
01365                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01366                 ln+=(string)"dynamic_ban "+(*i1).first+" "+(*i1).second;
01367                 fprintf(f,"%s\n",ln.c_str());
01368             }
01369         }
01370 
01371         {
01372             vector<string>::iterator i1;
01373             for(i1=(*i3).dynbans_editors.begin(); i1!=(*i3).dynbans_editors.end(); i1++) {
01374                 ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01375                 ln+=(string)"partyline_dynbans_editors "+(*i1);
01376                 fprintf(f,"%s\n",ln.c_str());
01377             }
01378         }
01379 
01380         vector<s_dynamic_rule>::iterator i8;
01381         for(i8=(*i3).allow_dynamic.begin(); i8!=(*i3).allow_dynamic.end(); i8++) {
01382             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01383             ln+="allow_dynamic ";
01384             ln+=(*i8).group;
01385             ln+=" ";
01386             ln+=(*i8).plus_modes;
01387             ln+=" ";
01388             ln+=(*i8).minus_modes;
01389             fprintf(f,"%s\n",ln.c_str());
01390         }
01391 
01392         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01393         ln+=(string)"dynamic1 "+(*i3).dynamic_plus_modes;
01394         fprintf(f,"%s\n",ln.c_str());
01395 
01396         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01397         ln+=(string)"dynamic2 "+(*i3).dynamic_minus_modes;
01398         fprintf(f,"%s\n",ln.c_str());
01399 
01400         indent-=4;
01401         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01402         ln+="}";
01403         fprintf(f,"%s\n",ln.c_str());
01404     }
01405 
01406     {
01407         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01408         ln+=(string)"private";
01409         fprintf(f,"%s\n",ln.c_str());
01410 
01411         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01412         ln+="{";
01413         fprintf(f,"%s\n",ln.c_str());
01414         indent+=4;
01415 
01416         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01417         ln+="last_changed ";
01418         char tmp[64];
01419         ltoa((long)r_private.last_changed,tmp,10);
01420         ln+=tmp;
01421         fprintf(f,"%s\n",ln.c_str());
01422 
01423         vector<s_group>::iterator i5;
01424         for(i5=r_private.groups.begin(); i5!=r_private.groups.end(); i5++) {
01425             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01426             ln+=(string)"member_of_group "+(*i5).name;
01427             fprintf(f,"%s\n",ln.c_str());
01428         }
01429 
01430         vector<s_replication>::iterator i7;
01431         for(i7=r_private.replication.begin(); i7!=r_private.replication.end(); i7++) {
01432             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01433             string type;
01434             if((*i7).type==REPL_PUSH)
01435                 type="push";
01436             if((*i7).type==REPL_PULL)
01437                 type="pull";
01438             if((*i7).type==REPL_PUSHPULL)
01439                 type="pushpull";
01440             ln+=(string)"replication "+(*i7).partner+" "+type;
01441             fprintf(f,"%s\n",ln.c_str());
01442         }
01443 
01444         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01445         ln+="on_privmsg "+r_private.on_privmsg;
01446         fprintf(f,"%s\n",ln.c_str());
01447 
01448         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01449         ln+="on_notice "+r_private.on_notice;
01450         fprintf(f,"%s\n",ln.c_str());
01451 
01452         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01453         ln+="on_ctcp "+r_private.on_ctcp;
01454         fprintf(f,"%s\n",ln.c_str());
01455 
01456         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01457         ln+="on_filesys_got_new "+r_private.on_filesys_got_new;
01458         fprintf(f,"%s\n",ln.c_str());
01459 
01460         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01461         ln+="on_fnc "+r_private.on_fnc;
01462         fprintf(f,"%s\n",ln.c_str());
01463 
01464         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01465         ln+="on_broadcast "+r_private.on_broadcast;
01466         fprintf(f,"%s\n",ln.c_str());
01467 
01468         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01469         ln+="on_server_msg "+r_private.on_server_msg;
01470         fprintf(f,"%s\n",ln.c_str());
01471 
01472         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01473         ln+="on_internal_event "+r_private.on_internal_event;
01474         fprintf(f,"%s\n",ln.c_str());
01475 
01476         indent-=4;
01477         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01478         ln+="}";
01479         fprintf(f,"%s\n",ln.c_str());
01480     }
01481 
01482     vector<s_procedure>::iterator i2;
01483     for(i2=r_procedures.begin(); i2!=r_procedures.end(); i2++) {
01484 
01485         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01486         ln+=(string)"procedure "+(*i2).name;
01487         fprintf(f,"%s\n",ln.c_str());
01488 
01489         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01490         ln+="{";
01491         fprintf(f,"%s\n",ln.c_str());
01492         indent+=4;
01493 
01494         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01495         ln+="last_changed ";
01496         char tmp[64];
01497         ltoa((long)(*i2).last_changed,tmp,10);
01498         ln+=tmp;
01499         fprintf(f,"%s\n",ln.c_str());
01500 
01501         vector<s_group>::iterator i5;
01502         for(i5=(*i2).groups.begin(); i5!=(*i2).groups.end(); i5++) {
01503             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01504             ln+=(string)"member_of_group "+(*i5).name;
01505             fprintf(f,"%s\n",ln.c_str());
01506         }
01507 
01508         vector<s_replication>::iterator i7;
01509         for(i7=(*i2).replication.begin(); i7!=(*i2).replication.end(); i7++) {
01510             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01511             string type;
01512             if((*i7).type==REPL_PUSH)
01513                 type="push";
01514             if((*i7).type==REPL_PULL)
01515                 type="pull";
01516             if((*i7).type==REPL_PUSHPULL)
01517                 type="pushpull";
01518             ln+=(string)"replication "+(*i7).partner+" "+type;
01519             fprintf(f,"%s\n",ln.c_str());
01520         }
01521 
01522         vector<s_rproc>::iterator i_rproc;
01523         for(i_rproc=(*i2).rproc.begin(); i_rproc!=(*i2).rproc.end(); i_rproc++) {
01524             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01525             ln+=(string)"remote_bot_call "+(*i_rproc).remote_bot;
01526             fprintf(f,"%s\n",ln.c_str());
01527         }
01528 
01529         string name;
01530         for(unsigned int i7=0; i7<(*i2).name.length(); i7++) {
01531             if((*i2).name[i7]==0x20)
01532                 break;
01533             name+=(*i2).name[i7];
01534         }
01535 
01536         list<string> commands;
01537         vector<string> groups;
01538         logic_list_proc(name,commands,(*i2).name,groups);
01539         list<string>::iterator i6;
01540         for(i6=commands.begin(); i6!=commands.end(); i6++)
01541             fprintf(f,"%s\n",(*i6).c_str());
01542 
01543         indent-=4;
01544     }
01545 
01546     {
01547         fprintf(f,"groups\n");
01548 
01549         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01550         ln+="{";
01551         fprintf(f,"%s\n",ln.c_str());
01552         indent+=4;
01553 
01554         vector<string> got;
01555 
01556         vector<s_group>::iterator i1;
01557         for(i1=r_all_groups.begin(); i1!=r_all_groups.end(); i1++) {
01558             if((*i1).name.empty())
01559                 continue;
01560             vector<string>::iterator i2;
01561             for(i2=got.begin(); i2!=got.end(); i2++)
01562                 if(!(*i1).name.compare(*i2))
01563                     goto skip;
01564 
01565             got.push_back((*i1).name);
01566 
01567             ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01568             ln+=(*i1).name;
01569             fprintf(f,"%s\n",ln.c_str());
01570 skip:
01571             ;
01572         }
01573 
01574         indent-=4;
01575         ln=""; for(ii=0; ii<indent; ii++) ln+=" ";
01576         ln+="}";
01577         fprintf(f,"%s\n",ln.c_str());
01578     }
01579 
01580     fclose(f);
01581 }

Here is the call graph for this function:

void logic_partyline_get_channels vector< string > &  channels  ) 
 

Retrieves list of known channels (channel must reflect at least one time in logic.txt).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channels Returns channel list

Definition at line 11312 of file logic.cpp.

References r_channel_templates, and r_channels.

Referenced by dcc_loop_new_user().

11313 {
11314     channels.clear();
11315     vector<s_channel>::iterator i;
11316     for(i=r_channels.begin(); i!=r_channels.end(); i++)
11317         channels.push_back((*i).channel_name);
11318     for(i=r_channel_templates.begin(); i!=r_channel_templates.end(); i++)
11319         channels.push_back((*i).channel_name);
11320 }

void logic_partyline_get_user string  user_name,
s_user user,
vector< s_channel > &  channels
 

Retrieves an user with channels.

Author:
VooDooMan
Version:
2
Date:
2005
Parameters:
user_name Name of user as define in logic.txt
user Returns user definition
channels Returns list of channels

Definition at line 12113 of file logic.cpp.

References s_channel::can_send_unknown_users, s_channel::channel_name, s_user::clear(), s_channel::configured, s_channel::ctcp_flood, s_channel::groups, s_channel::host_unknown, s_channel::is_template, s_channel::join_flood, s_flood::lines, logic_cmp_strings_case_insensitive(), s_channel::mode_flood, s_channel::msg_flood, s_channel::nick_flood, s_channel::notice_flood, s_channel::on_ban, s_channel::on_banned, s_channel::on_creator, s_channel::on_decreator, s_channel::on_deop, s_channel::on_devoice, s_channel::on_flood, s_channel::on_join, s_channel::on_kick, s_channel::on_notice, s_channel::on_op, s_channel::on_other_mode, s_channel::on_privmsg, s_channel::on_unban, s_channel::on_voice, r_channel_terminators, r_channels, r_terminators, r_users, s_channel::repeat_flood, s_flood::seconds, s_channel::terminator, and s_channel::username.

12114 {
12115     user.clear();
12116     channels.clear();
12117     vector<s_user>::iterator i;
12118     vector<s_user> usrs;
12119     for(int iii=0; iii<2; iii++) {
12120         switch(iii) {
12121             case 0:
12122                 usrs=r_users;
12123                 break;
12124             case 1:
12125                 usrs=r_terminators;
12126                 break;
12127         }
12128     for(i=usrs.begin(); i!=usrs.end(); i++) {
12129         if(!(*i).name.compare(user_name)) {
12130             user=*i;
12131             vector<string> all_channels;
12132             vector<string>::iterator i4;
12133 
12134             vector<s_channel>::iterator i3;
12135             if(iii==0) {
12136                 for(i3=r_channels.begin(); i3!=r_channels.end(); i3++) {
12137                     bool got_channel=false;
12138                     for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12139                         if(!logic_cmp_strings_case_insensitive((*i4),(*i3).channel_name)) {
12140                             got_channel=true;
12141                             break;
12142                         }
12143                     if(!got_channel)
12144                         all_channels.push_back((*i3).channel_name);
12145     
12146                     if(!(*i3).username.compare((*i).name)) {
12147                         s_channel ch=*i3;
12148                         ch.configured=true;
12149                         channels.push_back(ch);
12150                     }
12151                 }
12152             } else {
12153                 for(i3=r_channel_terminators.begin(); i3!=r_channel_terminators.end(); i3++) {
12154                     bool got_channel=false;
12155                     for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12156                         if(!logic_cmp_strings_case_insensitive((*i4),(*i3).channel_name)) {
12157                             got_channel=true;
12158                             break;
12159                         }
12160                     if(!got_channel)
12161                         all_channels.push_back((*i3).channel_name);
12162     
12163                     if(!(*i3).username.compare((*i).name)) {
12164                         s_channel ch=*i3;
12165                         ch.configured=true;
12166                         channels.push_back(ch);
12167                     }
12168                 }
12169             }
12170         l1:
12171             if(iii==0) {
12172                 for(i3=r_channels.begin(); i3!=r_channels.end(); i3++)
12173                     if(!(*i3).username.compare((*i).name))
12174                         for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12175                             if(!logic_cmp_strings_case_insensitive((*i4),(*i3).channel_name)) {
12176                                 all_channels.erase(i4);
12177                                 goto l1;
12178                             }
12179             } else {
12180                 for(i3=r_channel_terminators.begin(); i3!=r_channel_terminators.end(); i3++)
12181                     if(!(*i3).username.compare((*i).name))
12182                         for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12183                             if(!logic_cmp_strings_case_insensitive((*i4),(*i3).channel_name)) {
12184                                 all_channels.erase(i4);
12185                                 goto l1;
12186                             }
12187             }
12188             vector<string>::iterator i1;
12189             for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12190                 for(i1=(*i).access_to_channel.begin(); i1!=(*i).access_to_channel.end(); i1++)
12191                     if(!(*i4).compare(*i1)) {
12192                         s_channel ch;
12193                         ch.terminator=iii==1;
12194                         ch.is_template=false;
12195                         ch.configured=false;
12196                         ch.can_send_unknown_users=false;
12197                         ch.username=user_name;
12198                         ch.channel_name=*i4;
12199                         ch.host_unknown=false;
12200                         ch.groups.clear();
12201                         ch.on_deop="";
12202                         ch.on_ban="";
12203                         ch.on_unban="";
12204                         ch.on_kick="";
12205                         ch.on_op="";
12206                         ch.on_voice="";
12207                         ch.on_devoice="";
12208                         ch.on_creator="";
12209                         ch.on_decreator="";
12210                         ch.on_join="";
12211                         ch.on_banned="";
12212                         ch.on_flood="";
12213                         ch.on_privmsg="";
12214                         ch.on_notice="";
12215                         ch.on_other_mode="";
12216                         ch.msg_flood.lines=0;
12217                         ch.msg_flood.seconds=0;
12218                         ch.notice_flood.lines=0;
12219                         ch.notice_flood.seconds=0;
12220                         ch.repeat_flood.lines=0;
12221                         ch.repeat_flood.seconds=0;
12222                         ch.nick_flood.lines=0;
12223                         ch.nick_flood.seconds=0;
12224                         ch.join_flood.lines=0;
12225                         ch.join_flood.seconds=0;
12226                         ch.mode_flood.lines=0;
12227                         ch.mode_flood.seconds=0;
12228                         ch.ctcp_flood.lines=0;
12229                         ch.ctcp_flood.seconds=0;
12230                         channels.push_back(ch);
12231                     }
12232         }
12233     }
12234     }
12235 }

Here is the call graph for this function:

void logic_partyline_get_user_template string  user_name,
s_user user,
vector< s_channel > &  channels
 

Retrieves an user template with channels.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
user_name Name of user template as define in logic.txt
user Returns user template definition
channels Returns list of channels

Definition at line 12246 of file logic.cpp.

References s_channel::can_send_unknown_users, s_channel::channel_name, s_channel::configured, s_channel::ctcp_flood, s_channel::groups, s_channel::host_unknown, s_channel::is_template, s_user::is_template, s_channel::join_flood, s_flood::lines, logic_cmp_strings_case_insensitive(), s_channel::mode_flood, s_channel::msg_flood, s_channel::nick_flood, s_channel::notice_flood, s_channel::on_ban, s_channel::on_banned, s_channel::on_creator, s_channel::on_decreator, s_channel::on_deop, s_channel::on_devoice, s_channel::on_flood, s_channel::on_join, s_channel::on_kick, s_channel::on_notice, s_channel::on_op, s_channel::on_other_mode, s_channel::on_privmsg, s_channel::on_unban, s_channel::on_voice, r_channel_templates, r_user_templates, s_channel::repeat_flood, s_flood::seconds, and s_channel::username.

12247 {
12248     channels.clear();
12249     vector<s_user>::iterator i;
12250     for(i=r_user_templates.begin(); i!=r_user_templates.end(); i++) {
12251         if(!(*i).name.compare(user_name)) {
12252             user=*i;
12253             user.is_template=false;
12254             vector<string> all_channels;
12255             vector<string>::iterator i4;
12256 
12257             map<string,string> vars;
12258 
12259             vector<s_channel>::iterator i3;
12260             for(i3=r_channel_templates.begin(); i3!=r_channel_templates.end(); i3++) {
12261                 bool got_channel=false;
12262                 for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12263                     if(!logic_cmp_strings_case_insensitive((*i4),(*i3).channel_name)) {
12264                         got_channel=true;
12265                         break;
12266                     }
12267                 if(!got_channel)
12268                     all_channels.push_back((*i3).channel_name);
12269 
12270                 if(!(*i3).username.compare((*i).name)) {
12271                     s_channel ch=*i3;
12272                     ch.configured=true;
12273                     ch.is_template=false;
12274                     channels.push_back(ch);
12275                 }
12276             }
12277         l1:
12278             for(i3=r_channel_templates.begin(); i3!=r_channel_templates.end(); i3++) {
12279                 if(!(*i3).username.compare((*i).name))
12280                     for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12281                         if(!logic_cmp_strings_case_insensitive((*i4),(*i3).channel_name)) {
12282                             all_channels.erase(i4);
12283                             goto l1;
12284                         }
12285             }
12286             vector<string>::iterator i1;
12287             for(i4=all_channels.begin(); i4!=all_channels.end(); i4++)
12288                 for(i1=(*i).access_to_channel.begin(); i1!=(*i).access_to_channel.end(); i1++)
12289                     if(!(*i4).compare(*i1)) {
12290                         s_channel ch;
12291                         ch.is_template=true;
12292                         ch.configured=false;
12293                         ch.can_send_unknown_users=false;
12294                         ch.username=user_name;
12295                         ch.channel_name=*i4;
12296                         ch.host_unknown=false;
12297                         ch.groups.clear();
12298                         ch.on_deop="";
12299                         ch.on_ban="";
12300                         ch.on_unban="";
12301                         ch.on_kick="";
12302                         ch.on_op="";
12303                         ch.on_voice="";
12304                         ch.on_devoice="";
12305                         ch.on_creator="";
12306                         ch.on_decreator="";
12307                         ch.on_join="";
12308                         ch.on_banned="";
12309                         ch.on_flood="";
12310                         ch.on_privmsg="";
12311                         ch.on_notice="";
12312                         ch.on_other_mode="";
12313                         ch.msg_flood.lines=0;
12314                         ch.msg_flood.seconds=0;
12315                         ch.notice_flood.lines=0;
12316                         ch.notice_flood.seconds=0;
12317                         ch.repeat_flood.lines=0;
12318                         ch.repeat_flood.seconds=0;
12319                         ch.nick_flood.lines=0;
12320                         ch.nick_flood.seconds=0;
12321                         ch.join_flood.lines=0;
12322                         ch.join_flood.seconds=0;
12323                         ch.mode_flood.lines=0;
12324                         ch.mode_flood.seconds=0;
12325                         ch.ctcp_flood.lines=0;
12326                         ch.ctcp_flood.seconds=0;
12327                         channels.push_back(ch);
12328                     }
12329         }
12330     }
12331 }

Here is the call graph for this function:

string logic_partyline_rehash string  lang,
string  eol,
string  who
 

Rehashes new backed up configuration (should be called from DCC / telnet) and performs rollback to old backed up file(s) if parse error occurs.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
lang Language code for user (e.g. "en") for returned log
eol End-of-line sequence (specific and different for DCC and telnet)
who This should contain who caused rehasing (for log purposes - bot.log)
Returns:
Returns log from operation in language provided by lang argument

Definition at line 13752 of file logic.cpp.

References log_bot(), and logic_rehash().

Referenced by dcc_loop().

13753 {
13754     string who_string=who;
13755     who_string=(string)"*** Rehash invoked by "+who_string;
13756     log_bot(who_string.c_str());
13757     string log;
13758     logic_rehash(log,lang,eol,who_string,who,who);
13759     return log;
13760 }

Here is the call graph for this function:

void logic_partyline_remove_user string  username  ) 
 

Removes user or user template defined in logic.txt.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
username Name of user as define in logic.txt

Definition at line 11448 of file logic.cpp.

References r_channel_templates, r_channel_terminators, r_terminators, and r_users.

Referenced by dcc_loop_edit_user1(), dcc_loop_replication(), dcc_loop_terminator(), and logic_botnet_remove_user().

11449 {
11450     vector<s_user>::iterator i1;
11451     bool template_=false;
11452 l1:
11453     for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
11454         if(!(*i1).name.compare(username)) {
11455             if((*i1).is_template)
11456                 template_=true;
11457             r_users.erase(i1);
11458             goto l1;
11459         }
11460     }
11461     if(template_) {
11462         vector<s_channel>::iterator i2;
11463 l2:
11464         for(i2=r_channel_templates.begin(); i2!=r_channel_templates.end(); i2++) {
11465             if(!(*i2).username.compare(username)) {
11466                 r_channel_templates.erase(i2);
11467                 goto l2;
11468             }
11469         }
11470     }
11471 l3:
11472     for(i1=r_terminators.begin(); i1!=r_terminators.end(); i1++) {
11473         if(!(*i1).name.compare(username)) {
11474             r_terminators.erase(i1);
11475             goto l3;
11476         }
11477     }
11478     vector<s_channel>::iterator i2;
11479 l4:
11480     for(i2=r_channel_terminators.begin(); i2!=r_channel_terminators.end(); i2++) {
11481         if(!(*i2).username.compare(username)) {
11482             r_channel_terminators.erase(i2);
11483             goto l4;
11484         }
11485     }
11486 }

bool logic_partyline_user_exists string  name  ) 
 

Checks if such user defined in logic.txt exists.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
name User name as defined in logic.txt
Returns:
Returns true if such user exists

Definition at line 11291 of file logic.cpp.

References logic_to_upper(), and r_users.

Referenced by dcc_loop_new_user().

11292 {
11293     name=logic_to_upper(name);
11294     bool res=false;
11295     vector<s_user>::iterator i;
11296     for(i=r_users.begin(); i!=r_users.end(); i++) {
11297         if(!logic_to_upper((*i).name).compare(name)) {
11298             res=true;
11299             break;
11300         }
11301     }
11302     return res;
11303 }

Here is the call graph for this function:

int logic_partyline_whois string  lang,
string  param1,
list< string > &  lines
 

Retrieves full whois list for users of mask param1 (".whois" command on partyline).

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
lang Language-identification string
param1 Mask (e.g. "Voo*Man") of user as defined in logic.txt, or "*!ident@host" mask
lines Returns user-friendly whois listing
Returns:
Returns number of matching users

Definition at line 10801 of file logic.cpp.

References lang_get_string(), logic_eval(), logic_to_upper(), ltoa(), match(), r_channels, and r_users.

Referenced by dcc_loop().

10802 {
10803     int cnt=0;
10804     map<string,string> vars;
10805     param1=logic_to_upper(param1);
10806     vector<s_user>::iterator i;
10807     for(i=r_users.begin(); i!=r_users.end(); i++) {
10808         bool got=false;
10809         if(!match((char*)param1.c_str(),(char*)logic_to_upper((*i).name).c_str()))
10810             got=true;
10811         vector<string>::iterator i2;
10812         if(!got)
10813             for(i2=(*i).hostmask.begin(); i2!=(*i).hostmask.end(); i2++)
10814                 if(!match((char*)param1.c_str(),(char*)logic_to_upper(logic_eval(*i2,vars)).c_str()))
10815                     got=true;
10816         if(got) {
10817             string l=lang_get_string(1,lang,9)+" "+(*i).name+" "+lang_get_string(1,lang,10)+" ";
10818             if((*i).host_unknown)
10819                 l+=lang_get_string(1,lang,11)+" ";
10820             if((*i).host_bot)
10821                 l+=lang_get_string(1,lang,12)+" ";
10822             l+=lang_get_string(1,lang,13);
10823             lines.push_back(l);
10824             vector<string>::iterator i3;
10825             bool got=false;
10826             for(i3=(*i).hostmask.begin(); i3!=(*i).hostmask.end(); i3++) {
10827                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10828                 got=true;
10829             }
10830             if(!got)
10831                 lines.push_back(lang_get_string(1,lang,14));
10832             l=lang_get_string(1,lang,15);
10833             lines.push_back(l);
10834             got=false;
10835             for(i3=(*i).fullname.begin(); i3!=(*i).fullname.end(); i3++) {
10836                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10837                 got=true;
10838             }
10839             if(!got)
10840                 lines.push_back(lang_get_string(1,lang,14));
10841             l=lang_get_string(1,lang,18);
10842             lines.push_back(l);
10843             vector<s_group>::iterator i4;
10844             got=false;
10845             for(i4=(*i).groups.begin(); i4!=(*i).groups.end(); i4++) {
10846                 lines.push_back((string)"    "+logic_eval((*i4).name,vars));
10847                 got=true;
10848             }
10849             if(!got)
10850                 lines.push_back(lang_get_string(1,lang,14));
10851             l=lang_get_string(1,lang,19);
10852             lines.push_back(l);
10853             vector<s_dcc_host>::iterator i5;
10854             got=false;
10855             for(i5=(*i).dcc_hosts.begin(); i5!=(*i).dcc_hosts.end(); i5++) {
10856                 char tmp[64];
10857                 ltoa((*i5).group,tmp,10);
10858                 lines.push_back((string)"    "+lang_get_string(1,lang,20)+(string)tmp+" "+lang_get_string(1,lang,21)+" "+(*i5).host);
10859                 got=true;
10860             }
10861             if(!got)
10862                 lines.push_back(lang_get_string(1,lang,14));
10863             l=lang_get_string(1,lang,22);
10864             lines.push_back(l);
10865             got=false;
10866             bool all=false;
10867             for(i3=(*i).access_to_group.begin(); i3!=(*i).access_to_group.end(); i3++) {
10868                 if(!(*i3).compare("*")) {
10869                     all=true;
10870                     got=true;
10871                     break;
10872                 }
10873                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10874                 got=true;
10875             }
10876             if(!got)
10877                 lines.push_back(lang_get_string(1,lang,14));
10878             if(all)
10879                 lines.push_back(lang_get_string(1,lang,166));
10880             l=lang_get_string(1,lang,23);
10881             lines.push_back(l);
10882             got=false;
10883             all=false;
10884             for(i3=(*i).access_grant_group.begin(); i3!=(*i).access_grant_group.end(); i3++) {
10885                 if(!(*i3).compare("*")) {
10886                     all=true;
10887                     got=true;
10888                     break;
10889                 }
10890                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10891                 got=true;
10892             }
10893             if(!got)
10894                 lines.push_back(lang_get_string(1,lang,14));
10895             if(all)
10896                 lines.push_back(lang_get_string(1,lang,166));
10897             l=lang_get_string(1,lang,24);
10898             lines.push_back(l);
10899             got=false;
10900             all=false;
10901             for(i3=(*i).access_to_proc.begin(); i3!=(*i).access_to_proc.end(); i3++) {
10902                 if(!(*i3).compare("*")) {
10903                     all=true;
10904                     got=true;
10905                     break;
10906                 }
10907                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10908                 got=true;
10909             }
10910             if(!got)
10911                 lines.push_back(lang_get_string(1,lang,14));
10912             if(all)
10913                 lines.push_back(lang_get_string(1,lang,166));
10914             l=lang_get_string(1,lang,25);
10915             lines.push_back(l);
10916             got=false;
10917             all=false;
10918             for(i3=(*i).access_grant_procedure.begin(); i3!=(*i).access_grant_procedure.end(); i3++) {
10919                 if(!(*i3).compare("*")) {
10920                     all=true;
10921                     got=true;
10922                     break;
10923                 }
10924                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10925                 got=true;
10926             }
10927             if(!got)
10928                 lines.push_back(lang_get_string(1,lang,14));
10929             if(all)
10930                 lines.push_back(lang_get_string(1,lang,166));
10931             l=lang_get_string(1,lang,589);
10932             lines.push_back(l);
10933             got=false;
10934             all=false;
10935             for(i3=(*i).access_usage_procedure.begin(); i3!=(*i).access_usage_procedure.end(); i3++) {
10936                 if(!(*i3).compare("*")) {
10937                     all=true;
10938                     got=true;
10939                     break;
10940                 }
10941                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10942                 got=true;
10943             }
10944             if(!got)
10945                 lines.push_back(lang_get_string(1,lang,14));
10946             if(all)
10947                 lines.push_back(lang_get_string(1,lang,166));
10948             l=lang_get_string(1,lang,30);
10949             lines.push_back(l);
10950             got=false;
10951             all=false;
10952             for(i3=(*i).access_to_channel.begin(); i3!=(*i).access_to_channel.end(); i3++) {
10953                 if(!(*i3).compare("*")) {
10954                     all=true;
10955                     break;
10956                 }
10957                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10958                 got=true;
10959             }
10960             if(!got)
10961                 lines.push_back(lang_get_string(1,lang,14));
10962             if(all)
10963                 lines.push_back(lang_get_string(1,lang,166));
10964             l=lang_get_string(1,lang,31);
10965             lines.push_back(l);
10966             got=false;
10967             all=false;
10968             for(i3=(*i).access_grant_channel.begin(); i3!=(*i).access_grant_channel.end(); i3++) {
10969                 if(!(*i3).compare("*")) {
10970                     all=true;
10971                     got=true;
10972                     break;
10973                 }
10974                 lines.push_back((string)"    "+logic_eval(*i3,vars));
10975                 got=true;
10976             }
10977             if(!got)
10978                 lines.push_back(lang_get_string(1,lang,14));
10979             if(all)
10980                 lines.push_back(lang_get_string(1,lang,166));
10981 
10982             if((*i).access_to_partyline)
10983                 l=lang_get_string(1,lang,16);
10984                 else
10985                 l=lang_get_string(1,lang,17);
10986             lines.push_back(l);
10987 
10988             if((*i).access_grant_partyline)
10989                 l=lang_get_string(1,lang,41);
10990                 else
10991                 l=lang_get_string(1,lang,42);
10992             lines.push_back(l);
10993 
10994             char tmp1[64];
10995             char tmp2[64];
10996 
10997             ltoa((*i).partyline_msg_flood.lines,tmp1,10);
10998             ltoa((long)(*i).partyline_msg_flood.seconds,tmp2,10);
10999             l=lang_get_string(1,lang,202)+" "+tmp1+" "+tmp2;
11000             lines.push_back(l);
11001 
11002             if((*i).access_grant_partyline)
11003                 l=lang_get_string(1,lang,394);
11004                 else
11005                 l=lang_get_string(1,lang,395);
11006             lines.push_back(l);
11007 
11008             if((*i).access_to_backup)
11009                 l=lang_get_string(1,lang,175);
11010                 else
11011                 l=lang_get_string(1,lang,176);
11012             lines.push_back(l);
11013 
11014             if((*i).access_grant_backup)
11015                 l=lang_get_string(1,lang,177);
11016                 else
11017                 l=lang_get_string(1,lang,178);
11018             lines.push_back(l);
11019 
11020             if((*i).access_to_rehash)
11021                 l=lang_get_string(1,lang,179);
11022                 else
11023                 l=lang_get_string(1,lang,180);
11024             lines.push_back(l);
11025 
11026             if((*i).access_grant_rehash)
11027                 l=lang_get_string(1,lang,181);
11028                 else
11029                 l=lang_get_string(1,lang,182);
11030             lines.push_back(l);
11031 
11032             if((*i).access_to_restart)
11033                 l=lang_get_string(1,lang,256);
11034                 else
11035                 l=lang_get_string(1,lang,257);
11036             lines.push_back(l);
11037 
11038             if((*i).access_grant_restart)
11039                 l=lang_get_string(1,lang,258);
11040                 else
11041                 l=lang_get_string(1,lang,259);
11042             lines.push_back(l);
11043 
11044             if((*i).access_to_die)
11045                 l=lang_get_string(1,lang,263);
11046                 else
11047                 l=lang_get_string(1,lang,264);
11048             lines.push_back(l);
11049 
11050             if((*i).access_grant_die)
11051                 l=lang_get_string(1,lang,265);
11052                 else
11053                 l=lang_get_string(1,lang,266);
11054             lines.push_back(l);
11055 
11056             if((*i).access_to_plususer)
11057                 l=lang_get_string(1,lang,185);
11058                 else
11059                 l=lang_get_string(1,lang,184);
11060             lines.push_back(l);
11061 
11062             if((*i).access_grant_plususer)
11063                 l=lang_get_string(1,lang,186);
11064                 else
11065                 l=lang_get_string(1,lang,187);
11066             lines.push_back(l);
11067 
11068             if((*i).access_to_plusproc)
11069                 l=lang_get_string(1,lang,194);
11070                 else
11071                 l=lang_get_string(1,lang,193);
11072             lines.push_back(l);
11073 
11074             if((*i).access_grant_plusproc)
11075                 l=lang_get_string(1,lang,195);
11076                 else
11077                 l=lang_get_string(1,lang,196);
11078             lines.push_back(l);
11079 
11080             if((*i).access_to_replication)
11081                 l=lang_get_string(1,lang,209);
11082                 else
11083                 l=lang_get_string(1,lang,209);
11084             lines.push_back(l);
11085 
11086             if(!(*i).access_grant_replication)
11087                 l=lang_get_string(1,lang,598);
11088                 else
11089                 l=lang_get_string(1,lang,599);
11090             lines.push_back(l);
11091 
11092             if((*i).access_to_filesystem)
11093                 l=lang_get_string(1,lang,390);
11094                 else
11095                 l=lang_get_string(1,lang,391);
11096             lines.push_back(l);
11097 
11098             if((*i).access_grant_filesystem)
11099                 l=lang_get_string(1,lang,392);
11100                 else
11101                 l=lang_get_string(1,lang,393);
11102             lines.push_back(l);
11103 
11104             if(!(*i).access_to_private)
11105                 l=lang_get_string(1,lang,489);
11106                 else
11107                 l=lang_get_string(1,lang,490);
11108             lines.push_back(l);
11109 
11110             if(!(*i).access_grant_private)
11111                 l=lang_get_string(1,lang,491);
11112                 else
11113                 l=lang_get_string(1,lang,492);
11114             lines.push_back(l);
11115 
11116             if((*i).access_to_upgrade)
11117                 l=lang_get_string(1,lang,621);
11118                 else
11119                 l=lang_get_string(1,lang,622);
11120             lines.push_back(l);
11121 
11122             if((*i).access_grant_upgrade)
11123                 l=lang_get_string(1,lang,623);
11124                 else
11125                 l=lang_get_string(1,lang,624);
11126             lines.push_back(l);
11127 
11128             if((*i).access_to_apply)
11129                 l=lang_get_string(1,lang,683);
11130                 else
11131                 l=lang_get_string(1,lang,684);
11132             lines.push_back(l);
11133 
11134             if((*i).access_grant_apply)
11135                 l=lang_get_string(1,lang,685);
11136                 else
11137                 l=lang_get_string(1,lang,686);
11138             lines.push_back(l);
11139 
11140             if(!(*i).access_to_can_send_all_users)
11141                 l=lang_get_string(1,lang,493);
11142                 else
11143                 l=lang_get_string(1,lang,494);
11144             lines.push_back(l);
11145 
11146             if(!(*i).access_grant_can_send_all_users)
11147                 l=lang_get_string(1,lang,495);
11148                 else
11149                 l=lang_get_string(1,lang,496);
11150             lines.push_back(l);
11151 
11152             if(!(*i).access_to_can_send_unknown_users)
11153                 l=lang_get_string(1,lang,497);
11154                 else
11155                 l=lang_get_string(1,lang,498);
11156             lines.push_back(l);
11157 
11158             if(!(*i).access_grant_can_send_unknown_users)
11159                 l=lang_get_string(1,lang,499);
11160                 else
11161                 l=lang_get_string(1,lang,500);
11162             lines.push_back(l);
11163 
11164             vector<s_channel>::iterator i6;
11165             for(i6=r_channels.begin(); i6!=r_channels.end(); i6++) {
11166                 if(!(*i6).username.compare((*i).name)) {
11167                     l=lang_get_string(1,lang,26)+" "+(*i6).channel_name;
11168                     lines.push_back(l);
11169                     l=(string)"    "+lang_get_string(1,lang,27);
11170                     lines.push_back(l);
11171                     got=false;
11172                     for(i4=(*i6).groups.begin(); i4!=(*i6).groups.end(); i4++) {
11173                         l="    ";
11174                         l+=logic_eval((*i4).name,vars);
11175                         lines.push_back(l);
11176                         got=true;
11177                     }
11178                     if(!got)
11179                         lines.push_back(lang_get_string(1,lang,14));
11180                     l=(string)"    "+lang_get_string(1,lang,28)+" on_op = "+(*i6).on_op;
11181                     lines.push_back(l);
11182                     l=(string)"    "+lang_get_string(1,lang,28)+" on_deop = "+(*i6).on_deop;
11183                     lines.push_back(l);
11184                     l=(string)"    "+lang_get_string(1,lang,28)+" on_ban = "+(*i6).on_ban;
11185                     lines.push_back(l);
11186                     l=(string)"    "+lang_get_string(1,lang,28)+" on_unban = "+(*i6).on_unban;
11187                     lines.push_back(l);
11188                     l=(string)"    "+lang_get_string(1,lang,28)+" on_kick = "+(*i6).on_kick;
11189                     lines.push_back(l);
11190                     l=(string)"    "+lang_get_string(1,lang,28)+" on_voice = "+(*i6).on_voice;
11191                     lines.push_back(l);
11192                     l=(string)"    "+lang_get_string(1,lang,28)+" on_devoice = "+(*i6).on_devoice;
11193                     lines.push_back(l);
11194                     l=(string)"    "+lang_get_string(1,lang,28)+" on_creator = "+(*i6).on_creator;
11195                     lines.push_back(l);
11196                     l=(string)"    "+lang_get_string(1,lang,28)+" on_decreator = "+(*i6).on_decreator;
11197                     lines.push_back(l);
11198                     l=(string)"    "+lang_get_string(1,lang,28)+" on_join = "+(*i6).on_join;
11199                     lines.push_back(l);
11200                     l=(string)"    "+lang_get_string(1,lang,28)+" on_banned = "+(*i6).on_banned;
11201                     lines.push_back(l);
11202                     l=(string)"    "+lang_get_string(1,lang,28)+" on_flood = "+(*i6).on_flood;
11203                     lines.push_back(l);
11204                     l=(string)"    "+lang_get_string(1,lang,28)+" on_privmsg = "+(*i6).on_privmsg;
11205                     lines.push_back(l);
11206                     l=(string)"    "+lang_get_string(1,lang,28)+" on_notice = "+(*i6).on_notice;
11207                     lines.push_back(l);
11208                     l=(string)"    "+lang_get_string(1,lang,28)+" on_except = "+(*i6).on_except;
11209                     lines.push_back(l);
11210                     l=(string)"    "+lang_get_string(1,lang,28)+" on_unexcept = "+(*i6).on_unexcept;
11211                     lines.push_back(l);
11212                     l=(string)"    "+lang_get_string(1,lang,28)+" on_invite = "+(*i6).on_invite;
11213                     lines.push_back(l);
11214                     l=(string)"    "+lang_get_string(1,lang,28)+" on_uninvite = "+(*i6).on_uninvite;
11215                     lines.push_back(l);
11216                     l=(string)"    "+lang_get_string(1,lang,28)+" on_not_invited = "+(*i6).on_not_invited;
11217                     lines.push_back(l);
11218                     l=(string)"    "+lang_get_string(1,lang,28)+" on_not_in_reop = "+(*i6).on_not_in_reop;
11219                     lines.push_back(l);
11220                     l=(string)"    "+lang_get_string(1,lang,28)+" on_reop = "+(*i6).on_reop;
11221                     lines.push_back(l);
11222                     l=(string)"    "+lang_get_string(1,lang,28)+" on_other_mode = "+(*i6).on_other_mode;
11223                     lines.push_back(l);
11224 
11225                     char tmp1[64];
11226                     char tmp2[64];
11227 
11228                     ltoa((*i6).msg_flood.lines,tmp1,10);
11229                     ltoa((long)(*i6).msg_flood.seconds,tmp2,10);
11230                     l=(string)"    "+lang_get_string(1,lang,28)+" msg_flood "+tmp1+" "+tmp2;
11231                     lines.push_back(l);
11232 
11233                     ltoa((*i6).notice_flood.lines,tmp1,10);
11234                     ltoa((long)(*i6).notice_flood.seconds,tmp2,10);
11235                     l=(string)"    "+lang_get_string(1,lang,28)+" notice_flood "+tmp1+" "+tmp2;
11236                     lines.push_back(l);
11237 
11238                     ltoa((*i6).repeat_flood.lines,tmp1,10);
11239                     ltoa((long)(*i6).repeat_flood.seconds,tmp2,10);
11240                     l=(string)"    "+lang_get_string(1,lang,28)+" repeat_flood "+tmp1+" "+tmp2;
11241                     lines.push_back(l);
11242 
11243                     ltoa((*i6).nick_flood.lines,tmp1,10);
11244                     ltoa((long)(*i6).nick_flood.seconds,tmp2,10);
11245                     l=(string)"    "+lang_get_string(1,lang,28)+" nick_flood "+tmp1+" "+tmp2;
11246                     lines.push_back(l);
11247 
11248                     ltoa((*i6).join_flood.lines,tmp1,10);
11249                     ltoa((long)(*i6).join_flood.seconds,tmp2,10);
11250                     l=(string)"    "+lang_get_string(1,lang,28)+" join_flood "+tmp1+" "+tmp2;
11251                     lines.push_back(l);
11252 
11253                     ltoa((*i6).mode_flood.lines,tmp1,10);
11254                     ltoa((long)(*i6).mode_flood.seconds,tmp2,10);
11255                     l=(string)"    "+lang_get_string(1,lang,28)+" mode_flood "+tmp1+" "+tmp2;
11256                     lines.push_back(l);
11257 
11258                     ltoa((*i6).ctcp_flood.lines,tmp1,10);
11259                     ltoa((long)(*i6).ctcp_flood.seconds,tmp2,10);
11260                     l=(string)"    "+lang_get_string(1,lang,28)+" ctcp_flood "+tmp1+" "+tmp2;
11261                     lines.push_back(l);
11262 
11263                     l=(string)"    "+lang_get_string(1,lang,28)+" dynamic1 (plus modes)  "+(*i6).dynamic_plus_modes;
11264                     lines.push_back(l);
11265                     l=(string)"    "+lang_get_string(1,lang,28)+" dynamic2 (minus modes) "+(*i6).dynamic_minus_modes;
11266                     lines.push_back(l);
11267 
11268                     if(!(*i6).can_send_unknown_users)
11269                         l=(string)"    "+lang_get_string(1,lang,501);
11270                     else
11271                         l=(string)"    "+lang_get_string(1,lang,502);
11272                     lines.push_back(l);
11273                 }
11274             }
11275 
11276             lines.push_back("----");
11277             cnt++;
11278         }
11279     }
11280     return cnt;
11281 }

Here is the call graph for this function:

unsigned long logic_resolve string  host  ) 
 

Resolves DNS hostname to IPv4 addres, if possible, from internal resolve cache.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
host Host name to resolve
Returns:
Returns 4-byte IP addres, or zero for error while resolution

Definition at line 8805 of file logic.cpp.

References dns_ipv4_cache, and sock_resolve().

Referenced by irc_RPL_WHOISUSER(), logic_check_mask(), logic_exec(), and logic_process_line().

08806 {
08807     int i1, i2, i3, i4;
08808     int x=sscanf(host.c_str(),"%u.%u.%u.%u", &i1, &i2, &i3, &i4);
08809     if(x==4)
08810         return (i4<<24)|(i3<<16)|(i2<<8)|i1;
08811 
08812     multimap<string,unsigned long>::iterator ii;
08813     for(ii=dns_ipv4_cache.begin(); ii!=dns_ipv4_cache.end(); ii++) {
08814         if(!host.compare((*ii).first))
08815             return (*ii).second;
08816     }
08817     pair<string,unsigned long> p;
08818     p.first=host;
08819 #ifdef _WIN32
08820     p.second=sock_resolve(host.c_str(),NULL).S_un.S_addr;
08821 #else
08822     p.second=sock_resolve(host.c_str(),NULL).s_addr;
08823 #endif
08824     dns_ipv4_cache.insert(p);
08825     return p.second;
08826 }

Here is the call graph for this function:

in_addr6_ logic_resolve6 string  host  ) 
 

Resolves DNS hostname to IPv6 addres, if possible, from internal resolve cache.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
host Host name to resolve
Returns:
Returns 16-byte IPv6 addres, or zeros for error while resolution

Definition at line 8836 of file logic.cpp.

References dns_ipv6_cache, and sock_resolve6().

Referenced by irc_RPL_WHOISUSER(), and logic_process_line().

08837 {
08838 #ifdef IPv6
08839     multimap<string,in_addr6_>::iterator ii;
08840     for(ii=dns_ipv6_cache.begin(); ii!=dns_ipv6_cache.end(); ii++) {
08841         if(!host.compare((*ii).first))
08842             return (*ii).second;
08843     }
08844     pair<string,in_addr6_> p;
08845     p.first=host;
08846     p.second=sock_resolve6((char*)host.c_str());
08847     dns_ipv6_cache.insert(p);
08848     return p.second;
08849 #else
08850     in_addr6_ a6;
08851     memset(&a6,0,sizeof(a6));
08852     return a6;
08853 #endif
08854 }

Here is the call graph for this function:

string logic_script_esc string  script_type,
string  str
 

Escapes a string.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
script_type Type of script ("php" and "php_2" supported yet)
str String to escape
Returns:
Returns escaped string

Definition at line 5693 of file logic.cpp.

References ltoa().

Referenced by filesys_get_script(), and logic_exec_script().

05694 {
05695     if(!script_type.compare("php") || !script_type.compare("php_2")) {
05696         string res;
05697         for(unsigned int i1=0; i1<str.length(); i1++) {
05698             if(str[i1]<32 || str[i1]=='$' || str[i1]=='\\' || str[i1]=='\'' || str[i1]=='\"') {
05699                 res+="\\x";
05700                 char tmp[64];
05701                 ltoa((unsigned char)str[i1],tmp,16);
05702                 res+=tmp;
05703                 continue;
05704             }
05705             res+=str[i1];
05706         }
05707         return res;
05708     }
05709     return str;
05710 }

Here is the call graph for this function:

void logic_set_dynamic string  username,
string  from_user,
char  prefix,
char  mode
 

Adds/remove new dynamic mode for user on channel, but only when group relationship and setting allows it.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
username Name of affected user
from_user Name of origin user
prefix '+' to set mode, '-' to clear mode
mode Mode: '+' or '@'

Definition at line 553 of file logic.cpp.

References r_channels, and r_users.

Referenced by irc_user_mode_change().

00554 {
00555     vector<s_channel>::iterator i1;
00556     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
00557         if(!(*i1).username.compare(username)) {
00558             vector<s_dynamic_rule>::iterator i2;
00559             for(i2=(*i1).allow_dynamic.begin(); i2!=(*i1).allow_dynamic.end(); i2++) {
00560                 vector<s_user>::iterator i3;
00561                 for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
00562                     vector<s_group>::iterator i4;
00563                     for(i4=(*i3).groups.begin(); i4!=(*i3).groups.end(); i4++) {
00564                         if(!(*i4).name.compare((*i2).group) && (*i2).plus_modes.find(mode,0)!=string::npos) {
00565                             string mp=(*i1).dynamic_plus_modes;
00566                             while(mp.find(mode,0)!=string::npos)
00567                                 mp.erase(mp.find(mode,0),1);
00568                             if(prefix=='+')
00569                                 mp+=mode;
00570                             (*i1).dynamic_plus_modes=mp;
00571                         }
00572                         if(!(*i4).name.compare((*i2).group) && (*i2).minus_modes.find(mode,0)!=string::npos) {
00573                             string mm=(*i1).dynamic_minus_modes;
00574                             while(mm.find(mode,0)!=string::npos)
00575                                 mm.erase(mm.find(mode,0),1);
00576                             if(prefix=='-')
00577                                 mm+=mode;
00578                             (*i1).dynamic_minus_modes=mm;
00579                         }
00580                         // do NOT break! cycle thru all settings!
00581                     }
00582                 }
00583             }
00584         }
00585     }
00586 }

void logic_validate string  channel,
string  source_user,
string  target_user,
string  source_nick,
string  target_nick,
char  prefix,
char  action
 

Validates MODE change and, if needed, executes on_XXX event.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of channel
source_user Name of user (originator) as in logic.txt
target_user Name of user (victim) as in logic.txt
source_nick Nick name of originator
target_nick Nick name of victim
prefix '+' or '-'
action '@', '+', '&', '' mode chars; or 'O' for creator

Definition at line 9252 of file logic.cpp.

References cmp_strings_case_insensitive(), dcc_upgrade_bot_mode(), dcc_want_to_upgrade, s_005::get_prefix2(), irc_get_fullname(), irc_get_host(), irc_get_ident(), irc_nick, logic_call_proc_ex2(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_mode_change_creator(), irc_mode_change_op(), irc_mode_change_other(), irc_mode_change_voice(), irc_RPL_NAMREPLY(), irc_RPL_WHOISCHANNELS(), and irc_user_mode_change().

09253 {
09254     if(!cmp_strings_case_insensitive(source_nick,irc_nick))
09255         return;
09256 
09257     extern bool dcc_want_to_upgrade;
09258     if(dcc_want_to_upgrade) {
09259         vector<s_user>::iterator i1;
09260         for(i1=r_users.begin(); i1!=r_users.end(); i1++) {
09261             if((*i1).host_bot && !(*i1).name.compare(target_user)) {
09262                 string ident=irc_get_ident(target_nick);
09263                 string host=irc_get_host(target_nick);
09264                 string fullname=irc_get_fullname(target_nick);
09265                 string mode=(string)""+prefix;
09266                 mode+=(string)""+irc_isupport.get_prefix2(action);
09267                 dcc_upgrade_bot_mode(target_nick,ident,host,fullname,channel,mode);
09268                 break;
09269             }
09270         }
09271     }
09272 
09273     vector<s_user>::iterator host_bot;
09274     bool b_host_bot=false;
09275 
09276     bool got_user=false;
09277 
09278     map<string,string> vars;
09279 
09280     vector<s_channel>::iterator i1;
09281 
09282     {
09283         for(host_bot=r_users.begin(); host_bot!=r_users.end(); host_bot++) {
09284             if((*host_bot).host_bot && !(*host_bot).name.compare(target_user)) {
09285                 b_host_bot=true;
09286                 goto l1;
09287             }
09288         }
09289     }
09290 
09291     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09292         if(!(*i1).username.compare(target_user) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09293             if((prefix=='-' || prefix=='+') /*&& (action=='@' || action=='+' || action=='O')*/) {
09294                 string proc="";
09295                 if(prefix=='-' && action=='@')
09296                     proc=(*i1).on_deop;
09297                 if(prefix=='+' && action=='@')
09298                     proc=(*i1).on_op;
09299                 if(prefix=='-' && action=='+')
09300                     proc=(*i1).on_devoice;
09301                 if(prefix=='+' && action=='+')
09302                     proc=(*i1).on_voice;
09303                 if(prefix=='-' && action=='O')
09304                     proc=(*i1).on_decreator;
09305                 if(prefix=='+' && action=='O')
09306                     proc=(*i1).on_creator;
09307                 if(action!='+' && action!='@' && action!='O')
09308                     proc=(*i1).on_other_mode;
09309                 if(!proc.compare((string)""))
09310                     continue;
09311                 /*pair<string,string> p;
09312                 p.first="$channel";
09313                 p.second=logic_eval((*i1).channel_name,vars);
09314                 vars.insert(p);
09315                 p.first="$source";
09316                 p.second=source_user;
09317                 vars.insert(p);
09318                 p.first="$source_nick";
09319                 p.second=source_nick;
09320                 vars.insert(p);
09321                 p.first="$target";
09322                 p.second=target_user;
09323                 vars.insert(p);
09324                 p.first="$target_nick";
09325                 p.second=target_nick;
09326                 vars.insert(p);*/
09327 
09328                 list<string> params;
09329                 params.push_back(channel); // $channel
09330                 params.push_back(source_user); // $source
09331                 params.push_back(target_user); // $target
09332                 params.push_back(source_nick); // $source_nick
09333                 params.push_back(target_nick); // $target_nick
09334 
09335                 if(action!='+' && action!='@' && action!='O') {
09336                     params.push_back((string)""+prefix); // $prefix
09337                     params.push_back((string)""+action); // $mode_char
09338                 }
09339 
09340                 map<string,string> vars;
09341                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09342                     case LOGIC_SOCKET_ERROR:
09343                     case LOGIC_RESTART:
09344                         return;
09345                     default:
09346                         break;
09347                 }
09348                 got_user=true;
09349                 break;
09350             }
09351         }
09352     }
09353 
09354     if(!got_user) {
09355         // try host_unknown
09356     l1:
09357         vector<s_user>::iterator i;
09358         if(b_host_bot)
09359             i=host_bot;
09360             else {
09361                 for(i=r_users.begin(); i!=r_users.end(); i++) {
09362                     if((*i).host_unknown) {
09363                         got_user=true;
09364                         break;
09365                     }
09366                 }
09367                 if(!got_user)
09368                     return;
09369             }
09370 
09371         vector<s_channel>::iterator i1;
09372         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09373             if(cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel))
09374                 continue;
09375             vector<string>::iterator is, ii;
09376             if(!(*i1).username.compare((*i).name)) {
09377                 if((prefix=='-' || prefix=='+') /*&& (action=='@' || action=='+' || action=='O')*/) {
09378                     string proc="";
09379                     if(prefix=='-' && action=='@')
09380                         proc=(*i1).on_deop;
09381                     if(prefix=='+' && action=='@')
09382                         proc=(*i1).on_op;
09383                     if(prefix=='-' && action=='+')
09384                         proc=(*i1).on_devoice;
09385                     if(prefix=='+' && action=='+')
09386                         proc=(*i1).on_voice;
09387                     if(prefix=='-' && action=='O')
09388                         proc=(*i1).on_decreator;
09389                     if(prefix=='+' && action=='O')
09390                         proc=(*i1).on_creator;
09391                     if(action!='+' && action!='@' && action!='O')
09392                         proc=(*i1).on_other_mode;
09393                     if(!proc.compare(""))
09394                         continue;
09395 
09396                     list<string> params;
09397                     params.push_back(channel); // $channel
09398                     params.push_back(source_user); // $source
09399                     params.push_back(target_user); // $target
09400                     params.push_back(source_nick); // $source_nick
09401                     params.push_back(target_nick); // $target_nick
09402 
09403                     if(action!='+' && action!='@' && action!='O') {
09404                         params.push_back((string)""+prefix); // $prefix
09405                         params.push_back((string)""+action); // $mode_char
09406                     }
09407 
09408                     map<string,string> vars;
09409                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09410                         case LOGIC_SOCKET_ERROR:
09411                         case LOGIC_RESTART:
09412                             return;
09413                         default:
09414                             break;
09415                     }
09416                     break;
09417                 }
09418             }
09419         }
09420     }
09421 }

Here is the call graph for this function:

void logic_validate_by_mask string  channel,
string  source_user,
string  source_nick,
string  mask,
char  prefix,
char  action
 

Validates MODE change and, if needed, executes on_XXX event.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of channel
source_user Name of user (originator) as in logic.txt
source_nick Nick name of originator
mask Mask of victim
prefix '+' or '-'
action 'b', 'e', 'I', or 'R'

Definition at line 9435 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_get_nick(), irc_nick, logic_call_proc_ex2(), logic_check_mask(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channel_defs, r_channels, and r_users.

Referenced by irc_mode_change_ban(), irc_mode_change_ban_exception(), irc_mode_change_invitation(), and irc_mode_change_reop().

09436 {
09437     if(!cmp_strings_case_insensitive(source_nick,irc_nick))
09438         return;
09439 
09440     bool got_user=false;
09441 
09442     map<string,string> vars;
09443 
09444     vector<s_channel>::iterator i1;
09445     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09446         vector<s_user>::iterator i3;
09447         for(i3=r_users.begin(); i3!=r_users.end(); i3++) {
09448             if(!(*i3).name.compare((*i1).username)) {
09449                 map<string,string> vars;
09450                 vector<string>::iterator i2;
09451                 for(i2=(*i3).hostmask.begin(); i2!=(*i3).hostmask.end(); i2++) {
09452                     if(!(*i3).host_unknown && logic_check_mask(mask,logic_eval(*i2,vars),"*","*") && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09453                         got_user=true;
09454                         if((prefix=='-' || prefix=='+') && (action=='b' || action=='e' || action=='I' || action=='R')) {
09455                             string proc="";
09456                             if(prefix=='-' && action=='b')
09457                                 proc=(*i1).on_unban;
09458                             if(prefix=='+' && action=='b')
09459                                 proc=(*i1).on_ban;
09460                             if(prefix=='-' && action=='e')
09461                                 proc=(*i1).on_unexcept;
09462                             if(prefix=='+' && action=='e')
09463                                 proc=(*i1).on_except;
09464                             if(prefix=='-' && action=='I')
09465                                 proc=(*i1).on_uninvite;
09466                             if(prefix=='+' && action=='I')
09467                                 proc=(*i1).on_invite;
09468                             if(prefix=='-' && action=='R')
09469                                 proc=(*i1).on_reop;
09470                             if(prefix=='+' && action=='R')
09471                                 proc=(*i1).on_reop;
09472                             if(!proc.compare(""))
09473                                 continue;
09474 
09475                             list<string> params;
09476                             params.push_back(channel); // $channel
09477                             params.push_back(source_user); // $source
09478                             params.push_back((*i3).name); // $target
09479                             params.push_back(source_nick); // $source_nick
09480                             params.push_back(irc_get_nick((*i3).name)); // $target_nick
09481 
09482                             if(action=='b') {
09483                                 params.push_back(mask); // $ban_mask
09484                             }
09485                             if(action=='e' || action=='I' || action=='R') {
09486                                 params.push_back((string)""+prefix); // $prefix
09487                                 params.push_back(mask); // $mask
09488                             }
09489 
09490                             map<string,string> vars;
09491                             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09492                                 case LOGIC_SOCKET_ERROR:
09493                                 case LOGIC_RESTART:
09494                                     return;
09495                                 default:
09496                                     break;
09497                             }
09498                             break;
09499                         }
09500                     }
09501                 }
09502                 // do NOT break; coz we need to track EVERY user!
09503             }
09504         }
09505     }
09506 
09507     if(!got_user) {
09508         // try host_unknown
09509         vector<s_user>::iterator i;
09510         for(i=r_users.begin(); i!=r_users.end(); i++) {
09511             if((*i).host_unknown) {
09512                 vector<s_channel>::iterator i1;
09513                 for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
09514                     if(!(*i1).username.compare((*i).name) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
09515                         got_user=true;
09516                         string proc="";
09517                         if(prefix=='-' && action=='b')
09518                             proc=(*i1).on_unban;
09519                         if(prefix=='+' && action=='b')
09520                             proc=(*i1).on_ban;
09521                         if(prefix=='-' && action=='e')
09522                             proc=(*i1).on_unexcept;
09523                         if(prefix=='+' && action=='e')
09524                             proc=(*i1).on_except;
09525                         if(prefix=='-' && action=='I')
09526                             proc=(*i1).on_uninvite;
09527                         if(prefix=='+' && action=='I')
09528                             proc=(*i1).on_invite;
09529                         if(prefix=='-' && action=='R')
09530                             proc=(*i1).on_reop;
09531                         if(prefix=='+' && action=='R')
09532                             proc=(*i1).on_reop;
09533                         if(!proc.compare(""))
09534                             break;
09535 
09536                         list<string> params;
09537                         params.push_back(channel); // $channel
09538                         params.push_back(source_user); // $source
09539                         params.push_back((*i).name); // $target
09540                         params.push_back(source_nick); // $source_nick
09541                         params.push_back(""); // $target_nick
09542 
09543                         if(action=='b') {
09544                             params.push_back(mask); // $ban_mask
09545                         }
09546                         if(action=='e' || action=='I' || action=='R') {
09547                             params.push_back((string)""+prefix); // $prefix
09548                             params.push_back(mask); // $mask
09549                         }
09550 
09551                         map<string,string> vars;
09552                         switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09553                             case LOGIC_SOCKET_ERROR:
09554                             case LOGIC_RESTART:
09555                                 return;
09556                             default:
09557                                 break;
09558                         }
09559                         break;
09560                     }
09561                 }
09562                 if(got_user)
09563                     break;
09564             }
09565         }
09566     }
09567 
09568     if(action=='b') {
09569         vector<s_channel_def>::iterator i1;
09570         for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
09571             if(!cmp_strings_case_insensitive((*i1).channel_name,channel)) {
09572                 string proc=(*i1).on_dynamic_ban;
09573                 if(proc.empty())
09574                     break;
09575                 list<string> params;
09576                 params.push_back(channel); // $channel
09577                 params.push_back(source_user); // $source
09578                 params.push_back(source_nick); // $source_nick
09579                 params.push_back((string)""+prefix); // $prefix
09580                 params.push_back(mask); // $ban_mask
09581 
09582                 map<string,string> vars;
09583                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
09584                     case LOGIC_SOCKET_ERROR:
09585                     case LOGIC_RESTART:
09586                         return;
09587                     default:
09588                         break;
09589                 }
09590                 break;
09591             }
09592         }
09593     }
09594 }

Here is the call graph for this function:

void logic_validate_chan_key string  channel,
string  source_user,
string  source_nick,
char  prefix,
string  key
 

Validates the key change (+/-k) for the channel and (if needed) calls event, and adds a key to the history.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of the channel
source_user Originator user name from "logic.txt"
source_nick Nick name of originator
prefix '+' or '-'
key Channel key

Definition at line 421 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_nick, logic_call_proc_ex2(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, and r_channel_defs.

Referenced by irc_mode_change_chan_key(), and irc_RPL_324().

00422 {
00423     if(!cmp_strings_case_insensitive(source_nick,irc_nick))
00424         return;
00425 
00426     map<string,string> vars;
00427 
00428     vector<s_channel_def>::iterator i1;
00429 
00430     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
00431         if(!cmp_strings_case_insensitive((*i1).channel_name,channel)) {
00432 
00433             (*i1).keys.push_back(key);
00434 
00435             string proc=(*i1).on_key;
00436 
00437             map<string,string> vars;
00438             list<string> params;
00439             params.push_back(channel); // $channel
00440             params.push_back(source_user); // $source
00441             params.push_back(source_nick); // $source_nick
00442             
00443             params.push_back((string)""+prefix); // $prefix
00444             params.push_back(key); // $key
00445 
00446             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
00447                 case LOGIC_SOCKET_ERROR:
00448                 case LOGIC_RESTART:
00449                     return;
00450                 default:
00451                     break;
00452             }
00453         }
00454     }
00455 }

Here is the call graph for this function:

void logic_validate_chan_limit string  channel,
string  source_user,
string  source_nick,
char  prefix,
string  limit
 

Validates the limit change (+/-l) for the channel and (if needed) calls event.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of the channel
source_user Originator user name from "logic.txt"
source_nick Nick name of originator
prefix '+' or '-'
limit Channel limit

Definition at line 468 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_nick, logic_call_proc_ex2(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, and r_channel_defs.

Referenced by irc_mode_change_chan_limit(), and irc_RPL_324().

00469 {
00470     if(!cmp_strings_case_insensitive(source_nick,irc_nick))
00471         return;
00472 
00473     map<string,string> vars;
00474 
00475     vector<s_channel_def>::iterator i1;
00476 
00477     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
00478         if(!cmp_strings_case_insensitive((*i1).channel_name,channel)) {
00479             string proc=(*i1).on_limit;
00480 
00481             map<string,string> vars;
00482             list<string> params;
00483             params.push_back(channel); // $channel
00484             params.push_back(source_user); // $source
00485             params.push_back(source_nick); // $source_nick
00486             
00487             params.push_back((string)""+prefix); // $limit
00488             params.push_back(limit); // $limit
00489 
00490             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
00491                 case LOGIC_SOCKET_ERROR:
00492                 case LOGIC_RESTART:
00493                     return;
00494                 default:
00495                     break;
00496             }
00497         }
00498     }
00499 }

Here is the call graph for this function:

void logic_validate_chan_mode string  channel,
string  source_user,
string  source_nick,
char  prefix,
char  mode
 

Validates the mode change of the channel and (if needed) calls events.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of the channel
source_user Originator user name from "logic.txt"
source_nick Nick name of originator
prefix '+' or '-'
mode Mode character

Definition at line 339 of file logic.cpp.

References cmp_strings_case_insensitive(), s_user::groups, irc_nick, logic_call_proc_ex2(), logic_partyline_get_user(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, and r_channel_defs.

Referenced by irc_mode_change_chan_status(), and irc_RPL_324().

00340 {
00341     if(!cmp_strings_case_insensitive(source_nick,irc_nick))
00342         return;
00343 
00344     map<string,string> vars;
00345 
00346     vector<s_channel_def>::iterator i1;
00347 
00348     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
00349         if(!cmp_strings_case_insensitive((*i1).channel_name,channel)) {
00350             s_user u;
00351             vector<s_channel> chs;
00352             logic_partyline_get_user(source_user,u,chs);
00353             vector<s_dynamic_rule>::iterator i2;
00354             for(i2=(*i1).allow_dynamic.begin(); i2!=(*i1).allow_dynamic.end(); i2++) {
00355                 vector<s_group>::iterator i3;
00356                 bool got=false;
00357                 for(i3=u.groups.begin(); i3!=u.groups.end(); i3++) {
00358                     if(!(*i2).group.compare((*i3).name)) {
00359                         if((prefix=='-' && (*i2).minus_modes.find((string)""+mode,0)==string::npos))
00360                             continue;
00361                         if((prefix=='+' && (*i2).plus_modes.find((string)""+mode,0)==string::npos))
00362                             continue;
00363                         got=true;
00364                         while((*i1).dynamic_plus_modes.find((string)""+mode,0)!=string::npos)
00365                             (*i1).dynamic_plus_modes.erase((*i1).dynamic_plus_modes.find((string)""+mode,0),1);
00366                         while((*i1).dynamic_minus_modes.find((string)""+mode,0)!=string::npos)
00367                             (*i1).dynamic_minus_modes.erase((*i1).dynamic_minus_modes.find((string)""+mode,0),1);
00368                         if(prefix=='-')
00369                             (*i1).dynamic_minus_modes+=(string)""+mode;
00370                         else
00371                             (*i1).dynamic_plus_modes+=(string)""+mode;
00372                         break;
00373                     }
00374                 }
00375                 if(got)
00376                     break;
00377             }
00378 
00379             string proc=(*i1).on_mode;
00380 
00381             map<string,string> vars;
00382             list<string> params;
00383             params.push_back(channel); // $channel
00384             params.push_back(source_user); // $source
00385             params.push_back(source_nick); // $source_nick
00386             
00387             string str="";
00388             if(prefix=='+')
00389                 str=mode;
00390 
00391             params.push_back(str); // $plus_modes
00392 
00393             str="";
00394             if(prefix=='-')
00395                 str=mode;
00396 
00397             params.push_back(str); // $minus_modes
00398 
00399             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
00400                 case LOGIC_SOCKET_ERROR:
00401                 case LOGIC_RESTART:
00402                     return;
00403                 default:
00404                     break;
00405             }
00406         }
00407     }
00408 }

Here is the call graph for this function:

void logic_validate_kick string  channel,
string  source_user,
string  target_user,
string  source_nick,
string  target_nick
 

Validates KICK and, if needed, executes on_kick event.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of channel
source_user Name of user (originator) as in logic.txt
target_user Name of user (victim) as in logic.txt
source_nick Nick name of originator
target_nick Nick name of victim

Definition at line 12455 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_nick, logic_call_proc_ex2(), logic_eval(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, r_channels, and r_users.

Referenced by irc_kicked().

12456 {
12457     if(!source_nick.compare(irc_nick) && target_nick.compare(irc_nick)) // return only if I AM killing, and only if I am not killing myself
12458         return;
12459 
12460     vector<s_user>::iterator host_bot;
12461     bool b_host_bot=false;
12462 
12463     bool got_user=false;
12464 
12465     map<string,string> vars;
12466 
12467     vector<s_channel>::iterator i1;
12468 
12469     {
12470         for(host_bot=r_users.begin(); host_bot!=r_users.end(); host_bot++) {
12471             if((*host_bot).host_bot && !(*host_bot).name.compare(target_user)) {
12472                 b_host_bot=true;
12473                 goto l1;
12474             }
12475         }
12476     }
12477 
12478     for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
12479         if(!(*i1).username.compare(target_user) && !cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel)) {
12480                 string proc=(*i1).on_kick;
12481                 if(!proc.compare(""))
12482                     continue;
12483                 
12484                 list<string> params;
12485                 params.push_back(channel); // $channel
12486                 params.push_back(source_user); // $source
12487                 params.push_back(target_user); // $target
12488                 params.push_back(source_nick); // $source_nick
12489                 params.push_back(target_nick); // $target_nick
12490 
12491                 map<string,string> vars;
12492                 switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
12493                     case LOGIC_SOCKET_ERROR:
12494                     case LOGIC_RESTART:
12495                         return;
12496                     default:
12497                         break;
12498                 }
12499                 got_user=true;
12500                 break;
12501         }
12502     }
12503 
12504     if(!got_user) {
12505         // try host_unknown
12506     l1:
12507         vector<s_user>::iterator i;
12508         if(b_host_bot)
12509             i=host_bot;
12510             else {
12511                 for(i=r_users.begin(); i!=r_users.end(); i++) {
12512                     if((*i).host_unknown) {
12513                         got_user=true;
12514                         break;
12515                     }
12516                 }
12517                 if(!got_user)
12518                     return;
12519             }
12520 
12521         vector<s_channel>::iterator i1;
12522         for(i1=r_channels.begin(); i1!=r_channels.end(); i1++) {
12523             if(cmp_strings_case_insensitive(logic_eval((*i1).channel_name,vars),channel))
12524                 continue;
12525             vector<string>::iterator is, ii;
12526             if(!(*i1).username.compare((*i).name)) {
12527                     string proc=(*i1).on_kick;
12528                     if(!proc.compare(""))
12529                         continue;
12530 
12531                     list<string> params;
12532                     params.push_back(channel); // $channel
12533                     params.push_back(source_user); // $source
12534                     params.push_back(target_user); // $target
12535                     params.push_back(source_nick); // $source_nick
12536                     params.push_back(target_nick); // $target_nick
12537 
12538                     map<string,string> vars;
12539                     switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
12540                         case LOGIC_SOCKET_ERROR:
12541                         case LOGIC_RESTART:
12542                             return;
12543                         default:
12544                             break;
12545                     }
12546                     break;
12547             }
12548         }
12549     }
12550 }

Here is the call graph for this function:

void logic_validate_topic string  channel,
string  source_user,
string  source_nick,
string  topic
 

Validates the topic change and (if assigned) calls event.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
channel Name of the channel
source_user Originator user name from "logic.txt"
source_nick Nick name of originator
topic New topic

Definition at line 511 of file logic.cpp.

References cmp_strings_case_insensitive(), irc_nick, logic_call_proc_ex2(), LOGIC_RESTART, LOGIC_SOCKET_ERROR, and r_channel_defs.

Referenced by irc_RPL_TOPIC().

00512 {
00513     if(!cmp_strings_case_insensitive(source_nick,irc_nick))
00514         return;
00515 
00516     map<string,string> vars;
00517 
00518     vector<s_channel_def>::iterator i1;
00519 
00520     for(i1=r_channel_defs.begin(); i1!=r_channel_defs.end(); i1++) {
00521         if(!cmp_strings_case_insensitive((*i1).channel_name,channel)) {
00522             string proc=(*i1).on_topic;
00523 
00524             map<string,string> vars;
00525             list<string> params;
00526             params.push_back(channel); // $channel
00527             params.push_back(source_user); // $source
00528             params.push_back(source_nick); // $source_nick
00529             
00530             params.push_back(topic); // $topic
00531 
00532             switch(logic_call_proc_ex2(proc.c_str(),vars,params,false)) {
00533                 case LOGIC_SOCKET_ERROR:
00534                 case LOGIC_RESTART:
00535                     return;
00536                 default:
00537                     break;
00538             }
00539         }
00540     }
00541 }

Here is the call graph for this function:


Generated on Sun Jul 10 05:37:30 2005 for VooDoo cIRCle by doxygen 1.4.3

Hosted by SourceForge.net Logo