// Parser.C -*- C++ -*-
// Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (C) 2002,2003,2005 Clinton Ebadi
+// Copyright (C) 2002,2003,2005,2008 Clinton Ebadi
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301, USA.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <cstdlib>
#include <sys/types.h>
#include <netinet/in.h>
#include "StringTokenizer.H"
#include "Parser.H"
#include "UserCommands.H"
+#include "Commands.H"
#include "Macros.H"
#include "Utils.H"
#include "ShitList.H"
typedef void (*fptr) (ServerConnection *, Person *, String);
-std::map < std::string, fptr, std::less < std::string > >Parser::functions;
+std::map < std::string, fptr, std::less < std::string > > Parser::functions;
void
Parser::init ()
Person *from = 0;
#ifdef USESCRIPTS
cnx->bot->botInterp->RunHooks (Hook::RAW, line,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (line),
SCM_UNDEFINED));
#endif
#ifdef USESCRIPTS
cnx->bot->botInterp->RunHooks (Hook::INVITE,
nick + " " + channel,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (nick),
Utils::
str2scm
bool joinAndMode = false;
#ifdef USESCRIPTS
cnx->bot->botInterp->RunHooks (Hook::JOIN, n + " " + c,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (n),
Utils::
str2scm (c), SCM_UNDEFINED));
&& !(ch->getUser (n)->mode & User::OP_MODE) && cnx->bot->iAmOp (c))
{
// This is a part of the antispoof code
- ch->getUser (n)->userkey = Utils::get_key ();
- cnx->queue->sendCTCP (n, "PING",
- ch->getUser (n)->userkey + " " + c);
+ ch->getUser(n)->userkey = Utils::get_key ();
+ Commands::CTCP (cnx->bot, n, "PING",
+ ch->getUser(n)->userkey + " " + c);
}
}
target + " " +
from->getNick () + " " +
channel + " " + reason,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm
(target),
Utils::
cnx->bot->botInterp->RunHooks (Hook::MODE,
from->getNick () + " " + ch +
" " + modes,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (from->
getNick
()),
#ifdef USESCRIPTS
cnx->bot->botInterp->RunHooks (Hook::NICKNAME,
on_orig + " " + nn,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm
(on_orig),
Utils::
if (Utils::channel_p (to))
cnx->bot->botInterp->RunHooks (Hook::PUBLIC_NOTICE,
nick + " " + to + " " + rest,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (nick),
Utils::
str2scm (to),
SCM_UNDEFINED));
else
cnx->bot->botInterp->RunHooks (Hook::NOTICE, nick + " " + rest,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (nick),
Utils::
str2scm (rest),
cnx->bot->botInterp->RunHooks (Hook::CTCP_REPLY,
nick + " " + command + " " +
rest,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (nick),
Utils::
str2scm
{
#ifdef USESCRIPTS
cnx->bot->botInterp->RunHooks (Hook::FLOOD, nick,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (nick),
SCM_UNDEFINED));
#endif
StringTokenizer st (rest);
String channel = st.next_token ();
#ifdef USESCRIPTS
- cnx->bot->botInterp->RunHooks (Hook::LEAVE, n + " " + channel,
- scm_listify (Utils::
+ cnx->bot->botInterp->RunHooks (Hook::PART, n + " " + channel,
+ scm_list_n (Utils::
str2scm (n),
Utils::
str2scm
#endif
if (n.toLower () == cnx->bot->nickName.toLower ())
{
- cnx->bot->logLine (String ("Leaved channel ") + channel + ".");
+ cnx->bot->logLine (String ("Left channel ") + channel + ".");
cnx->bot->channelList->delChannel (channel);
}
else
String n = from->getNick ();
#ifdef USESCRIPTS
cnx->bot->botInterp->RunHooks (Hook::SIGNOFF, n + " " + rest,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (n),
Utils::
str2scm (rest),
cnx->bot->botInterp->RunHooks (Hook::TOPIC,
from->getNick () + " " +
channel + " " + newTopic,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (from->
getNick
()),
cnx->bot->botInterp->RunHooks (Hook::CTCP,
nick + " " + to + " " +
command + " " + rest,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (nick),
Utils::
str2scm (to),
SCM_UNDEFINED));
#endif
if (command == "PING")
- cnx->queue->sendCTCPReply (nick, "PING", rest);
+ {
+ Commands::CTCPReply (cnx->bot, nick, "PING", rest);
+ }
else if (command == "VERSION")
- cnx->queue->sendCTCPReply (nick, "VERSION", cnx->bot->versionString);
+ {
+ Commands::CTCPReply (cnx->bot, nick, "VERSION",
+ cnx->bot->versionString);
+ }
else if (command == "CLOCK")
{
time_t diff = time (NULL) - cnx->bot->startTime;
- cnx->queue->sendCTCPReply (nick, "CLOCK",
- String ("elapsed time: ") +
- String ((long) (diff / 86400)) +
- "d" +
- String ((long) (diff % 86400) /
- 3600) + "h" +
- String ((long) (diff % 3600) / 60) +
- "m" + String ((long) (diff % 60)) + "s");
+ Commands::CTCPReply (cnx->bot, nick, "CLOCK",
+ String ("elapsed time: ") +
+ String ((long) (diff / 86400)) +
+ "d" +
+ String ((long) (diff % 86400) /
+ 3600) + "h" +
+ String ((long) (diff % 3600) / 60) +
+ "m" + String ((long) (diff % 60)) + "s");
}
else if (command == "COMMAND")
- cnx->queue->sendCTCPReply (nick,
- "COMMAND", String (cnx->bot->commandChar));
+ {
+ Commands::CTCPReply (cnx->bot, nick,
+ "COMMAND", String (cnx->bot->commandChar));
+ }
else if (command == "LAG")
- cnx->queue->sendCTCPReply (nick, "LAG",
- String ((long) cnx->lag) + " second(s)");
+ {
+ Commands::CTCPReply (cnx->bot, nick, "LAG",
+ String ((long) cnx->lag) + " second(s)");
+ }
else if (command == "DCC")
{
StringTokenizer st2 (rest);
else if (command == "ACTION")
{
cnx->bot->botInterp->RunHooks (Hook::ACTION,
- // FIXME: from->getAddress should
- // be nick. MAYBE, depending on
- // whether this could be
- // considered a bug or a feature
- // change to normalize
- // hooks/action with the other
- // hooks. Maybe a 3.0 change?
- from->getAddress () + " " + to +
+ from->getNick () + " " + to +
" " + rest,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (from->
- getAddress
+ getNick
()),
Utils::
str2scm (to),
cnx->bot->botInterp->RunHooks (Hook::PUBLIC,
from->getNick () + " " + to +
" " + parameters,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (from->
getNick
()),
cnx->bot->botInterp->RunHooks (Hook::MESSAGE,
from->getNick () + " " +
parameters,
- scm_listify (Utils::
+ scm_list_n (Utils::
str2scm (from->
getNick
()),
SCM scmFunc, int argsCount, String parameters)
{
String param;
- SCM args_list = scm_listify (SCM_UNDEFINED);
+ SCM args_list = scm_list_n (SCM_UNDEFINED);
if (needsChannelName)
{
- args_list = gh_append2 (args_list,
- scm_listify (Utils::
- str2scm (channel),
- SCM_UNDEFINED));
+ args_list = scm_append (scm_list_2 (args_list,
+ scm_list_n (Utils::
+ str2scm (channel),
+ SCM_UNDEFINED)));
argsCount--;
}
param = st.rest ();
else
param = st.next_token ();
- args_list = gh_append2 (args_list,
- scm_listify (Utils::str2scm (param),
- SCM_UNDEFINED));
+ args_list = scm_append (scm_list_2 (args_list,
+ scm_list_n (Utils::str2scm (param),
+ SCM_UNDEFINED)));
}
struct wrapper_data wd;
wd.func = scmFunc;
wd.args = args_list;
- gh_catch (SCM_BOOL_T, (scm_t_catch_body) scm_apply_wrapper,
- (void *) &wd, (scm_t_catch_handler) Interp::ErrorHandler, 0);
+ scm_internal_catch (SCM_BOOL_T,
+ (scm_t_catch_body) Interp::LazyApplyWrapper,
+ (void *) &wd,
+ (scm_t_catch_handler) Interp::EmptyHandler, 0);
}
#endif