From 46af16674dcdeaa42e8482e8ef2608bcc7156c3a Mon Sep 17 00:00:00 2001 From: clinton Date: Tue, 11 Nov 2008 20:34:22 +0000 Subject: [PATCH] Update all deprecated/discouraged Guile calls * No longer use GH (removed entirely in Guile 1.9) * Update to more modern API (breaks Guile 1.6) --- source/BotInterp.C | 15 ++-- source/Interp.C | 102 +++++++++++------------ source/Parser.C | 50 ++++++------ source/ScriptCommands.C | 174 ++++++++++++++++++++-------------------- source/ServerQueue.C | 10 +-- source/Utils.C | 6 +- 6 files changed, 178 insertions(+), 179 deletions(-) diff --git a/source/BotInterp.C b/source/BotInterp.C index 5f2d5b3..0a1419c 100644 --- a/source/BotInterp.C +++ b/source/BotInterp.C @@ -1,6 +1,6 @@ // BotInterp.C -*- C++ -*- // Copyright (c) 1998 Etienne BERNARD -// Copyright (C) 2002,2005 Clinton Ebadi +// Copyright (C) 2002,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 @@ -74,9 +74,10 @@ BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall, if (scm_string_p(regex) == SCM_BOOL_F) return false; String rx = Utils::to_upper (Utils::scm2str (regex)); - SCM r = scm_make_regexp(regex, - scm_listify (gh_lookup("regexp/icase"), - SCM_UNDEFINED)); + // fixme: really ought to use scm_c_module_lookup with bot module + SCM r = scm_make_regexp (regex, + scm_list_n (scm_variable_ref (scm_c_lookup ("regexp/icase")), + SCM_UNDEFINED)); scm_gc_protect_object(r); scm_gc_protect_object(function); // First, we check if an hook doesn't exist yet @@ -136,13 +137,13 @@ BotInterp::AddTimer(int delay, SCM function) scm_gc_protect_object(function); Timer *t = new Timer(c, when, function); timersList.push_back(t); - return scm_long2num (c); + return scm_from_int (c); } bool BotInterp::DelTimer(SCM timer) { - int count = scm_num2long(timer, SCM_ARG1, "BotInterp::DelTimer"); + int count = scm_to_int (timer); std::list::iterator it = timersList.begin(); std::list::iterator it2 = timersList.end(); @@ -165,7 +166,7 @@ BotInterp::RunTimers(int now) std::list::iterator it3; struct wrapper_data wd; - wd.args = scm_listify (SCM_UNDEFINED); + wd.args = scm_list_n (SCM_UNDEFINED); while (it != it2) { if ((*it)->when <= now) { diff --git a/source/Interp.C b/source/Interp.C index 70ae595..9f1b805 100644 --- a/source/Interp.C +++ b/source/Interp.C @@ -1,6 +1,6 @@ // Interp.C -*- C++ -*- // Copyright (c) 1998 Etienne BERNARD -// Copyright (C) 2002,2005 Clinton Ebadi +// Copyright (C) 2002,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 @@ -117,71 +117,71 @@ interp_init_helper (void* unused) { scm_c_use_module ("guile-user"); // Hooks - scm_c_define ("bot:exit-hook", scm_make_hook (scm_long2num (0))); + scm_c_define ("bot:exit-hook", scm_make_hook (scm_from_int (0))); // Symbols // bot:user-* - scm_c_define ("bot:user-none", scm_long2num (User::NONE)); - scm_c_define ("bot:user-user", scm_long2num (User::USER)); - scm_c_define ("bot:user-trusted", scm_long2num (User::TRUSTED_USER)); - scm_c_define ("bot:user-friend", scm_long2num (User::FRIEND)); - scm_c_define ("bot:user-master", scm_long2num (User::MASTER)); + scm_c_define ("bot:user-none", scm_from_int (User::NONE)); + scm_c_define ("bot:user-user", scm_from_int (User::USER)); + scm_c_define ("bot:user-trusted", scm_from_int (User::TRUSTED_USER)); + scm_c_define ("bot:user-friend", scm_from_int (User::FRIEND)); + scm_c_define ("bot:user-master", scm_from_int (User::MASTER)); // protection - scm_c_define ("bot:protection/none", scm_long2num (User::NO_PROT)); - scm_c_define ("bot:protection/no-ban", scm_long2num (User::NO_BAN)); - scm_c_define ("bot:protection/no-kick", scm_long2num (User::NO_KICK)); - scm_c_define ("bot:protection/no-deop", scm_long2num (User::NO_DEOP)); + scm_c_define ("bot:protection/none", scm_from_int (User::NO_PROT)); + scm_c_define ("bot:protection/no-ban", scm_from_int (User::NO_BAN)); + scm_c_define ("bot:protection/no-kick", scm_from_int (User::NO_KICK)); + scm_c_define ("bot:protection/no-deop", scm_from_int (User::NO_DEOP)); // auto-op - scm_c_define ("bot:aop/yes", scm_long2num (true)); - scm_c_define ("bot:aop/no", scm_long2num (false)); + scm_c_define ("bot:aop/yes", scm_from_int (true)); + scm_c_define ("bot:aop/no", scm_from_int (false)); // shit-list - scm_c_define ("bot:shit/none", scm_long2num (ShitEntry::SHIT_NOSHIT)); - scm_c_define ("bot:shit/no-op", scm_long2num (ShitEntry::SHIT_NOOP)); - scm_c_define ("bot:shit/no-join", scm_long2num (ShitEntry::SHIT_NOJOIN)); + scm_c_define ("bot:shit/none", scm_from_int (ShitEntry::SHIT_NOSHIT)); + scm_c_define ("bot:shit/no-op", scm_from_int (ShitEntry::SHIT_NOOP)); + scm_c_define ("bot:shit/no-join", scm_from_int (ShitEntry::SHIT_NOJOIN)); scm_c_define ("bot:shit/no-deban", - scm_long2num (ShitEntry::SHIT_NODEBAN)); + scm_from_int (ShitEntry::SHIT_NODEBAN)); // sys-dir scm_c_define ("bot:sys-scripts-dir", - scm_makfrom0str (String(PREFIX) + - "/share/bobotpp/scripts/")); + scm_from_locale_string (String(PREFIX) + + "/share/bobotpp/scripts/")); // Hooks - scm_c_define ("hooks/action", scm_long2num(Hook::ACTION)); - scm_c_define ("hooks/nickname", scm_long2num(Hook::NICKNAME)); - scm_c_define ("hooks/signoff", scm_long2num(Hook::SIGNOFF)); - scm_c_define ("hooks/ctcp", scm_long2num(Hook::CTCP)); - scm_c_define ("hooks/ctcp-reply", scm_long2num(Hook::CTCP_REPLY)); - scm_c_define ("hooks/disconnect", scm_long2num(Hook::DISCONNECT)); - scm_c_define ("hooks/flood", scm_long2num(Hook::FLOOD)); - scm_c_define ("hooks/invite", scm_long2num(Hook::INVITE)); - scm_c_define ("hooks/join", scm_long2num(Hook::JOIN)); - scm_c_define ("hooks/kick", scm_long2num(Hook::KICK)); - scm_c_define ("hooks/mode", scm_long2num(Hook::MODE)); - scm_c_define ("hooks/message", scm_long2num(Hook::MESSAGE)); - scm_c_define ("hooks/notice", scm_long2num(Hook::NOTICE)); - scm_c_define ("hooks/part", scm_long2num(Hook::PART)); - scm_c_define ("hooks/public", scm_long2num(Hook::PUBLIC)); - scm_c_define ("hooks/public-notice", scm_long2num(Hook::PUBLIC_NOTICE)); - scm_c_define ("hooks/raw", scm_long2num(Hook::RAW)); - scm_c_define ("hooks/timer", scm_long2num(Hook::TIMER)); - scm_c_define ("hooks/topic", scm_long2num(Hook::TOPIC)); + scm_c_define ("hooks/action", scm_from_int(Hook::ACTION)); + scm_c_define ("hooks/nickname", scm_from_int(Hook::NICKNAME)); + scm_c_define ("hooks/signoff", scm_from_int(Hook::SIGNOFF)); + scm_c_define ("hooks/ctcp", scm_from_int(Hook::CTCP)); + scm_c_define ("hooks/ctcp-reply", scm_from_int(Hook::CTCP_REPLY)); + scm_c_define ("hooks/disconnect", scm_from_int(Hook::DISCONNECT)); + scm_c_define ("hooks/flood", scm_from_int(Hook::FLOOD)); + scm_c_define ("hooks/invite", scm_from_int(Hook::INVITE)); + scm_c_define ("hooks/join", scm_from_int(Hook::JOIN)); + scm_c_define ("hooks/kick", scm_from_int(Hook::KICK)); + scm_c_define ("hooks/mode", scm_from_int(Hook::MODE)); + scm_c_define ("hooks/message", scm_from_int(Hook::MESSAGE)); + scm_c_define ("hooks/notice", scm_from_int(Hook::NOTICE)); + scm_c_define ("hooks/part", scm_from_int(Hook::PART)); + scm_c_define ("hooks/public", scm_from_int(Hook::PUBLIC)); + scm_c_define ("hooks/public-notice", scm_from_int(Hook::PUBLIC_NOTICE)); + scm_c_define ("hooks/raw", scm_from_int(Hook::RAW)); + scm_c_define ("hooks/timer", scm_from_int(Hook::TIMER)); + scm_c_define ("hooks/topic", scm_from_int(Hook::TOPIC)); // send hooks - scm_c_define ("hooks/send/public", scm_long2num (Hook::SEND_PUBLIC)); - scm_c_define ("hooks/send/message", scm_long2num (Hook::SEND_MESSAGE)); - scm_c_define ("hooks/send/action", scm_long2num (Hook::SEND_ACTION)); - scm_c_define ("hooks/send/ctcp", scm_long2num (Hook::SEND_CTCP)); - scm_c_define ("hooks/send/who", scm_long2num (Hook::SEND_WHO)); - scm_c_define ("hooks/send/whois", scm_long2num (Hook::SEND_WHOIS)); + scm_c_define ("hooks/send/public", scm_from_int (Hook::SEND_PUBLIC)); + scm_c_define ("hooks/send/message", scm_from_int (Hook::SEND_MESSAGE)); + scm_c_define ("hooks/send/action", scm_from_int (Hook::SEND_ACTION)); + scm_c_define ("hooks/send/ctcp", scm_from_int (Hook::SEND_CTCP)); + scm_c_define ("hooks/send/who", scm_from_int (Hook::SEND_WHO)); + scm_c_define ("hooks/send/whois", scm_from_int (Hook::SEND_WHOIS)); // dcc hooks scm_c_define ("hooks/dcc/chat-begin", - scm_long2num (Hook::DCC_CHAT_BEGIN)); + scm_from_int (Hook::DCC_CHAT_BEGIN)); scm_c_define ("hooks/dcc/chat-end", - scm_long2num (Hook::DCC_CHAT_END)); + scm_from_int (Hook::DCC_CHAT_END)); scm_c_define ("hooks/dcc/chat-message", - scm_long2num (Hook::DCC_CHAT_MESSAGE)); + scm_from_int (Hook::DCC_CHAT_MESSAGE)); // procedures bot_new_procedure ("bot:action", (SCMFunc)ScriptCommands::Action, 2, 0, 0); @@ -282,8 +282,8 @@ interp_post_startup_helper (void *bot_module) // load bobot-utils scm_primitive_load - (scm_makfrom0str (String(PREFIX) + - "/share/bobotpp/scripts/bobot-utils.scm")); + (scm_from_locale_string (String(PREFIX) + + "/share/bobotpp/scripts/bobot-utils.scm")); return SCM_UNSPECIFIED; } @@ -307,7 +307,9 @@ void Interp::Startup2 (Bot *b) void Interp::Shutdown() { - scm_c_run_hook (gh_lookup ("bot:exit-hook"), SCM_EOL); + scm_c_run_hook (scm_variable_ref (scm_c_module_lookup (bot_module, + "bot:exit-hook")), + SCM_EOL); } void diff --git a/source/Parser.C b/source/Parser.C index bef907d..021ebf2 100644 --- a/source/Parser.C +++ b/source/Parser.C @@ -81,7 +81,7 @@ Parser::parseLine (ServerConnection * cnx, String line) Person *from = 0; #ifdef USESCRIPTS cnx->bot->botInterp->RunHooks (Hook::RAW, line, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (line), SCM_UNDEFINED)); #endif @@ -359,7 +359,7 @@ Parser::parseInvite (ServerConnection * cnx, Person * from, String rest) #ifdef USESCRIPTS cnx->bot->botInterp->RunHooks (Hook::INVITE, nick + " " + channel, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (nick), Utils:: str2scm @@ -382,7 +382,7 @@ Parser::parseJoin (ServerConnection * cnx, Person * from, String rest) 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)); @@ -452,7 +452,7 @@ Parser::parseKick (ServerConnection * cnx, Person * from, String rest) target + " " + from->getNick () + " " + channel + " " + reason, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (target), Utils:: @@ -510,7 +510,7 @@ Parser::parseMode (ServerConnection * cnx, Person * from, String rest) cnx->bot->botInterp->RunHooks (Hook::MODE, from->getNick () + " " + ch + " " + modes, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (from-> getNick ()), @@ -542,7 +542,7 @@ Parser::parseNick (ServerConnection * cnx, Person * from, String rest) #ifdef USESCRIPTS cnx->bot->botInterp->RunHooks (Hook::NICKNAME, on_orig + " " + nn, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (on_orig), Utils:: @@ -589,7 +589,7 @@ Parser::parseNotice (ServerConnection * cnx, Person * from, String rest) 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), @@ -598,7 +598,7 @@ Parser::parseNotice (ServerConnection * cnx, Person * from, String rest) SCM_UNDEFINED)); else cnx->bot->botInterp->RunHooks (Hook::NOTICE, nick + " " + rest, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (nick), Utils:: str2scm (rest), @@ -615,7 +615,7 @@ Parser::parseNotice (ServerConnection * cnx, Person * from, String rest) cnx->bot->botInterp->RunHooks (Hook::CTCP_REPLY, nick + " " + command + " " + rest, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (nick), Utils:: str2scm @@ -655,7 +655,7 @@ Parser::parsePrivmsg (ServerConnection * cnx, Person * from, String rest) { #ifdef USESCRIPTS cnx->bot->botInterp->RunHooks (Hook::FLOOD, nick, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (nick), SCM_UNDEFINED)); #endif @@ -716,7 +716,7 @@ Parser::parsePart (ServerConnection * cnx, Person * from, String rest) String channel = st.next_token (); #ifdef USESCRIPTS cnx->bot->botInterp->RunHooks (Hook::PART, n + " " + channel, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (n), Utils:: str2scm @@ -761,7 +761,7 @@ Parser::parseQuit (ServerConnection * cnx, Person * from, String rest) 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), @@ -787,7 +787,7 @@ Parser::parseTopic (ServerConnection * cnx, Person * from, String rest) cnx->bot->botInterp->RunHooks (Hook::TOPIC, from->getNick () + " " + channel + " " + newTopic, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (from-> getNick ()), @@ -821,7 +821,7 @@ Parser::parseCTCP (ServerConnection * cnx, cnx->bot->botInterp->RunHooks (Hook::CTCP, nick + " " + to + " " + command + " " + rest, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (nick), Utils:: str2scm (to), @@ -886,7 +886,7 @@ Parser::parseCTCP (ServerConnection * cnx, cnx->bot->botInterp->RunHooks (Hook::ACTION, from->getNick () + " " + to + " " + rest, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (from-> getNick ()), @@ -908,7 +908,7 @@ Parser::parseMessage (ServerConnection * cnx, cnx->bot->botInterp->RunHooks (Hook::PUBLIC, from->getNick () + " " + to + " " + parameters, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (from-> getNick ()), @@ -921,7 +921,7 @@ Parser::parseMessage (ServerConnection * cnx, cnx->bot->botInterp->RunHooks (Hook::MESSAGE, from->getNick () + " " + parameters, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (from-> getNick ()), @@ -1022,13 +1022,13 @@ Parser::parseScriptFunction (ServerConnection * cnx, 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--; } @@ -1039,9 +1039,9 @@ Parser::parseScriptFunction (ServerConnection * cnx, 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; diff --git a/source/ScriptCommands.C b/source/ScriptCommands.C index d03ae76..25fa3bb 100644 --- a/source/ScriptCommands.C +++ b/source/ScriptCommands.C @@ -1,6 +1,6 @@ // ScriptCommands.C -*- C++ -*- // Copyright (c) 1998 Etienne BERNARD -// Copyright (C) 2002,2005 Clinton Ebadi +// Copyright (C) 2002,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 @@ -36,11 +36,11 @@ #include "Message.H" #include -#define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \ - return scm_long2num(-17) +#define VERIFY_STRING(par) if (!scm_is_string((par))) \ + return scm_from_int(-17) #define VERIFY_NUMBER(par) if (!SCM_NUMBERP((par))) \ - return scm_long2num(-17) + return scm_from_int(-17) SCM ScriptCommands::Action(SCM channel, SCM message) @@ -49,7 +49,7 @@ ScriptCommands::Action(SCM channel, SCM message) VERIFY_STRING(message); Message m = Commands::Action(Interp::bot, Utils::scm2str(channel), Utils::scm2str(message)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -82,15 +82,14 @@ ScriptCommands::AddUser(SCM who, SCM maskChannel, SCM level, if (!eexpire) eexpire = -1; } - int protect = scm_num2int (prot, SCM_ARG1, "ScriptCommands::AddUser"); - bool aaop = SCM_NFALSEP (aop); - int llevel = scm_num2int (level, SCM_ARG1, - "ScriptCommands::AddUser"); + int protect = scm_to_int (prot); + bool aaop = scm_is_true (aop); + int llevel = scm_to_int (level); Message m = Commands::AddUser (Interp::bot, wwho, mask, llevel, protect, aaop, eexpire, passwd); - return scm_long2num(m.getCode ()); + return scm_from_int(m.getCode ()); } SCM @@ -98,11 +97,11 @@ ScriptCommands::AddServer(SCM servername, SCM port) { int p = 6667; if (SCM_NUMBERP(port)) - p = scm_num2long(port, SCM_ARG1, "ScriptCommands::AddServer"); + p = scm_to_int (port); Message m = Commands::AddServer(Interp::bot, Utils::scm2str(servername), p); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -115,7 +114,7 @@ ScriptCommands::AddShit(SCM mask, SCM maskChannel, SCM level, VERIFY_NUMBER (level); String mmask = Utils::scm2str (mask); String mmaskChannel = Utils::scm2str (maskChannel); - int llevel = scm_num2int (level, SCM_ARG1, "ScriptCommands::AddShit"); + int llevel = scm_to_int (level); std::time_t expire; String rreason; @@ -137,7 +136,7 @@ ScriptCommands::AddShit(SCM mask, SCM maskChannel, SCM level, Message m = Commands::AddShit (Interp::bot, mmask, mmaskChannel, llevel, expire, rreason); - return scm_long2num(m.getCode ()); + return scm_from_int(m.getCode ()); } SCM @@ -147,7 +146,7 @@ ScriptCommands::Ban(SCM channel, SCM who) VERIFY_STRING(who); Message m = Commands::Ban(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -156,10 +155,8 @@ ScriptCommands::ChangeCommandLevel(SCM command, SCM level) VERIFY_STRING (command); VERIFY_NUMBER (level); - SCM_STRING_COERCE_0TERMINATION_X (command); - std::string ccommand = SCM_STRING_CHARS (command); - unsigned int llevel = scm_num2uint - (level, 0, "ScriptCommands::ChangeCommandLevel"); + std::string ccommand = scm_to_locale_string (command); + unsigned int llevel = scm_to_uint (level); if (llevel > 4) return SCM_BOOL_F; @@ -211,7 +208,7 @@ ScriptCommands::Cycle(SCM channel) { VERIFY_STRING(channel); Message m = Commands::Cycle(Interp::bot, Utils::scm2str(channel)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -221,17 +218,15 @@ ScriptCommands::Deban(SCM channel, SCM who) VERIFY_STRING(who); Message m = Commands::Deban(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM ScriptCommands::DelServer(SCM number) { VERIFY_NUMBER(number); - Message m = Commands::DelServer(Interp::bot, - scm_num2long(number, SCM_ARG1, - "ScriptCommands::DelServer")); - return scm_long2num(m.getCode()); + Message m = Commands::DelServer(Interp::bot, scm_to_int (number)); + return scm_from_int(m.getCode()); } SCM @@ -241,7 +236,7 @@ ScriptCommands::DelUser(SCM who, SCM maskChannel) VERIFY_STRING(maskChannel); Message m = Commands::DelUser(Interp::bot, Utils::scm2str(who), Utils::scm2str(maskChannel)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -251,7 +246,7 @@ ScriptCommands::DelShit(SCM who, SCM maskChannel) VERIFY_STRING(maskChannel); Message m = Commands::DelShit(Interp::bot, Utils::scm2str(who), Utils::scm2str(maskChannel)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -261,17 +256,17 @@ ScriptCommands::Deop(SCM channel, SCM who) VERIFY_STRING(who); Message m = Commands::Deop(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM ScriptCommands::Die(SCM reason) { String r = "Leaving"; - if (SCM_STRINGP(reason)) + if (scm_is_string(reason)) r = Utils::scm2str(reason); Message m = Commands::Die(Interp::bot, r); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -279,7 +274,7 @@ ScriptCommands::Do(SCM command) { VERIFY_STRING(command); Message m = Commands::Do(Interp::bot, Utils::scm2str(command)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -289,7 +284,7 @@ ScriptCommands::Invite(SCM channel, SCM who) VERIFY_STRING(who); Message m = Commands::Invite(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -297,11 +292,11 @@ ScriptCommands::Join(SCM channel, SCM key) { VERIFY_STRING(channel); String k = ""; - if (SCM_STRINGP(key)) + if (scm_is_string(key)) k = Utils::scm2str(key); Message m = Commands::Join(Interp::bot, Utils::scm2str(channel), k); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -311,7 +306,7 @@ ScriptCommands::Keep(SCM channel, SCM modes) VERIFY_STRING(modes); Message m = Commands::Keep(Interp::bot, Utils::scm2str(channel), Utils::scm2str(modes)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -321,12 +316,12 @@ ScriptCommands::Kick(SCM channel, SCM who, SCM reason) VERIFY_STRING(who); String r = ""; - if (SCM_STRINGP(reason)) + if (scm_is_string(reason)) r = Utils::scm2str(reason); Message m = Commands::Kick(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who), r); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -335,11 +330,11 @@ ScriptCommands::KickBan(SCM channel, SCM who, SCM reason) VERIFY_STRING(channel); VERIFY_STRING(who); String r = ""; - if (SCM_STRINGP(reason)) + if (scm_is_string(reason)) r = Utils::scm2str(reason); Message m = Commands::KickBan(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who), r); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -347,7 +342,7 @@ ScriptCommands::Lock(SCM channel) { VERIFY_STRING(channel); Message m = Commands::Lock(Interp::bot, Utils::scm2str(channel)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -363,7 +358,7 @@ ScriptCommands::Mode(SCM channel, SCM mode) VERIFY_STRING(mode); Message m = Commands::Mode(Interp::bot, Utils::scm2str(channel), Utils::scm2str(mode)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -373,7 +368,7 @@ ScriptCommands::Msg(SCM nick, SCM message) VERIFY_STRING(message); Message m = Commands::Msg(Interp::bot, Utils::scm2str(nick), Utils::scm2str(message)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } @@ -381,7 +376,7 @@ SCM ScriptCommands::NextServer(void) { Message m = Commands::NextServer(Interp::bot); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -389,7 +384,7 @@ ScriptCommands::Nick(SCM nick) { VERIFY_STRING(nick); Message m = Commands::Nick(Interp::bot, Utils::scm2str(nick)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -398,7 +393,7 @@ ScriptCommands::Notice (SCM to, SCM message) VERIFY_STRING (to); VERIFY_STRING (message); - return (scm_long2num + return (scm_from_int (Commands::Notice (Interp::bot, Utils::scm2str (to), Utils::scm2str (message)).getCode ())); @@ -412,7 +407,7 @@ ScriptCommands::Op(SCM channel, SCM who) VERIFY_STRING(who); Message m = Commands::Op(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -420,14 +415,14 @@ ScriptCommands::Part(SCM channel) { VERIFY_STRING(channel); Message m = Commands::Part(Interp::bot, Utils::scm2str(channel)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM ScriptCommands::Reconnect(void) { Message m = Commands::Reconnect(Interp::bot); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -437,31 +432,30 @@ ScriptCommands::Say(SCM channel, SCM message) VERIFY_STRING(message); Message m = Commands::Say(Interp::bot, Utils::scm2str(channel), Utils::scm2str(message)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM ScriptCommands::Server(SCM number) { VERIFY_NUMBER(number); - Message m = Commands::Server(Interp::bot, gh_scm2long(number)); - return scm_long2num(m.getCode()); + Message m = Commands::Server(Interp::bot, scm_to_int(number)); + return scm_from_int(m.getCode()); } SCM ScriptCommands::SetFloodRate(SCM rate) { VERIFY_NUMBER(rate); - Message m = Commands::SetFloodRate(Interp::bot, scm_num2uint - (rate, 0, "SetFloodRate")); - return scm_long2num(m.getCode()); + Message m = Commands::SetFloodRate(Interp::bot, scm_to_uint (rate)); + return scm_from_int(m.getCode()); } SCM ScriptCommands::SetVersion(SCM version) { Message m = Commands::SetVersion(Interp::bot, Utils::scm2str(version)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -471,8 +465,8 @@ ScriptCommands::TBan(SCM channel, SCM who, SCM seconds) VERIFY_STRING(who); VERIFY_NUMBER(seconds); Message m = Commands::TBan(Interp::bot, Utils::scm2str(channel), - Utils::scm2str(who), gh_scm2long(seconds)); - return scm_long2num(m.getCode()); + Utils::scm2str(who), scm_to_int(seconds)); + return scm_from_int(m.getCode()); } SCM @@ -482,12 +476,12 @@ ScriptCommands::TKBan(SCM channel, SCM who, SCM seconds, SCM reason) VERIFY_STRING(who); VERIFY_NUMBER(seconds); String r = ""; - if (SCM_STRINGP(reason)) + if (scm_is_string(reason)) r = Utils::scm2str(reason); Message m = Commands::TKBan(Interp::bot, Utils::scm2str(channel), Utils::scm2str(who), - gh_scm2long(seconds), r); - return scm_long2num(m.getCode()); + scm_to_int(seconds), r); + return scm_from_int(m.getCode()); } SCM @@ -497,7 +491,7 @@ ScriptCommands::Topic(SCM channel, SCM topic) VERIFY_STRING(topic); Message m = Commands::Topic(Interp::bot, Utils::scm2str(channel), Utils::scm2str(topic)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -505,7 +499,7 @@ ScriptCommands::Unlock(SCM channel) { VERIFY_STRING(channel); Message m = Commands::Unlock(Interp::bot, Utils::scm2str(channel)); - return scm_long2num(m.getCode()); + return scm_from_int(m.getCode()); } SCM @@ -515,7 +509,7 @@ ScriptCommands::Who (SCM target) Message m = Commands::Who (Interp::bot, Utils::scm2str (target)); - return scm_long2num (m.getCode ()); + return scm_from_int (m.getCode ()); } SCM @@ -525,7 +519,7 @@ ScriptCommands::Whois (SCM nick) Message m = Commands::Whois (Interp::bot, Utils::scm2str (nick)); - return scm_long2num (m.getCode ()); + return scm_from_int (m.getCode ()); } SCM @@ -540,9 +534,9 @@ ScriptCommands::getServer(void) ::Server *serv = Interp::bot->serverList->currentServer(); int serverNumber = Interp::bot->serverList->currentNumber; - return gh_list(scm_long2num(serverNumber), + return scm_list_n(scm_from_int(serverNumber), Utils::str2scm(serv->getHostName()), - scm_long2num(serv->getPort()), + scm_from_int(serv->getPort()), Utils::str2scm(serv->getPassword()), SCM_UNDEFINED); } @@ -550,7 +544,7 @@ ScriptCommands::getServer(void) SCM ScriptCommands::getServerList(void) { - SCM res = gh_list(SCM_UNDEFINED); + SCM res = scm_list_n(SCM_UNDEFINED); ::Server *s; int i = 0; std::vector::iterator it = @@ -558,13 +552,15 @@ ScriptCommands::getServerList(void) for ( ; it != Interp::bot->serverList->end(); ++it) { s = (*it); - res = gh_append2(res, - gh_list(gh_list(scm_long2num(i++), - Utils::str2scm(s->getHostName()), - scm_long2num(s->getPort()), - Utils::str2scm(s->getPassword()), - SCM_UNDEFINED), SCM_UNDEFINED)); - } + res = + scm_append + (scm_list_2 (res, + scm_list_n(scm_list_n(scm_from_int(i++), + Utils::str2scm(s->getHostName()), + scm_from_int(s->getPort()), + Utils::str2scm(s->getPassword()), + SCM_UNDEFINED), SCM_UNDEFINED))); + } return res; } @@ -590,8 +586,8 @@ ScriptCommands::random(SCM scm_max) int max = 0; //srand(time(NULL)); if (SCM_NUMBERP(scm_max)) - max = gh_scm2int(scm_max); - return scm_long2num(max ? rand() % max : 0); + max = scm_to_int(scm_max); + return scm_from_int(max ? rand() % max : 0); } SCM @@ -600,7 +596,7 @@ ScriptCommands::addCommand(SCM scm_commandName, SCM scm_function, SCM scm_minLevel) { // We check that commandName is a string - if (!SCM_STRINGP(scm_commandName)) + if (!scm_is_string(scm_commandName)) return SCM_BOOL_F; // We check that the command does not exist @@ -609,28 +605,28 @@ ScriptCommands::addCommand(SCM scm_commandName, SCM scm_function, return SCM_BOOL_F; // Next we check that needsChannel is a boolean - if (!gh_boolean_p(scm_needsChannel)) + if (!scm_is_bool (scm_needsChannel)) return SCM_BOOL_F; - bool needsChannel = gh_scm2bool(scm_needsChannel); + bool needsChannel = scm_to_bool(scm_needsChannel); // We check that minLevel is an integer and that it's // a valid level if (!SCM_NUMBERP(scm_minLevel)) return SCM_BOOL_F; - int minLevel = gh_scm2long(scm_minLevel); + int minLevel = scm_to_int(scm_minLevel); if (minLevel < User::NONE || minLevel > User::MASTER) return SCM_BOOL_F; // We check that "scm_function" is a Scheme procedure - if (!gh_procedure_p(scm_function)) + if (!scm_is_true (scm_procedure_p(scm_function))) return SCM_BOOL_F; // We check that args is an integer and is between 0 and 20 (arbitrary limit) if (!SCM_NUMBERP(scm_args)) return SCM_BOOL_F; - int args = gh_scm2long(scm_args); + int args = scm_to_int(scm_args); if (args < 0 || args > 20) return SCM_BOOL_F; @@ -645,7 +641,7 @@ SCM ScriptCommands::delCommand(SCM scm_commandName) { // We check that commandName is a string - if (!SCM_STRINGP(scm_commandName)) + if (!scm_is_string(scm_commandName)) return SCM_BOOL_F; // We check that the command does exist @@ -668,12 +664,12 @@ ScriptCommands::AddHook(SCM type, SCM regex, SCM function, SCM pri, SCM fall, String rname = "DEFAULT"; if (!SCM_UNBNDP (pri)) - priority = scm_num2int (pri, SCM_ARG1, "ScriptCommands::AddHook"); + priority = scm_to_int (pri); if (!SCM_UNBNDP (fall)) - fallt = SCM_NFALSEP (fall); + fallt = scm_is_true (fall); if (!SCM_UNBNDP (name)) rname = Utils::scm2str (name); - return SCM_BOOL (Interp::bot->botInterp->AddHook(gh_scm2long(type), + return scm_from_bool (Interp::bot->botInterp->AddHook(scm_to_int(type), regex, function, priority, fallt, rname)); } @@ -681,20 +677,20 @@ ScriptCommands::AddHook(SCM type, SCM regex, SCM function, SCM pri, SCM fall, SCM ScriptCommands::AddTimer(SCM when, SCM function) { - return Interp::bot->botInterp->AddTimer(gh_scm2long(when), function); + return Interp::bot->botInterp->AddTimer(scm_to_int(when), function); } SCM ScriptCommands::DelTimer(SCM timer) { - return SCM_BOOL (Interp::bot->botInterp->DelTimer(timer)); + return scm_from_bool (Interp::bot->botInterp->DelTimer(timer)); } SCM ScriptCommands::sendDCCChatMessage (SCM to, SCM message) { - return SCM_BOOL (Interp::bot->dccConnections->sendMessage + return scm_from_bool (Interp::bot->dccConnections->sendMessage (Utils::scm2str (to), Utils::scm2str (message))); } diff --git a/source/ServerQueue.C b/source/ServerQueue.C index b525747..b701074 100644 --- a/source/ServerQueue.C +++ b/source/ServerQueue.C @@ -1,6 +1,6 @@ // ServerQueue.C -*- C++ -*- // Copyright (c) 1997, 1998 Etienne BERNARD -// Copyright (C) 2002,2005 Clinton Ebadi +// Copyright (C) 2002,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 @@ -115,7 +115,7 @@ ServerQueue::sendCTCP(String to, String command, Interp::bot->botInterp->RunHooks (Hook::SEND_ACTION, MNICK + " " + to + " " + message, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (MNICK), Utils:: str2scm (to), @@ -127,7 +127,7 @@ ServerQueue::sendCTCP(String to, String command, Interp::bot->botInterp->RunHooks (Hook::SEND_CTCP, MNICK + " " + to + " " + command + " " + message, - scm_listify (Utils:: + scm_list_n (Utils:: str2scm (MNICK), Utils:: str2scm (to), @@ -242,7 +242,7 @@ ServerQueue::sendPrivmsg(String dest, String message) Interp::bot->botInterp->RunHooks (Hook::SEND_PUBLIC, Interp::bot->nickName + " " + dest + " " + message, - scm_listify + scm_list_n (Utils::str2scm (Interp::bot->nickName), Utils::str2scm (dest), @@ -253,7 +253,7 @@ ServerQueue::sendPrivmsg(String dest, String message) (Hook::SEND_MESSAGE, Interp::bot->nickName + " " + dest + message, - scm_listify (Utils::str2scm (Interp::bot->nickName), + scm_list_n (Utils::str2scm (Interp::bot->nickName), Utils::str2scm (dest), Utils::str2scm (message), SCM_UNDEFINED)); diff --git a/source/Utils.C b/source/Utils.C index 28530cb..3db5182 100644 --- a/source/Utils.C +++ b/source/Utils.C @@ -1,6 +1,6 @@ // Utils.C -*- C++ -*- // Copyright (c) 1997, 1998 Etienne BERNARD -// Copyright (c) 2005 Clinton Ebadi +// Copyright (c) 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 @@ -306,7 +306,7 @@ std::string Utils::scm2str (SCM s) { // FIXME: uses gh_, replace with scm_ - char *tmp = gh_scm2newstr(s, 0); + char *tmp = scm_to_locale_string (s); std::string temp (tmp); free(tmp); @@ -318,6 +318,6 @@ Utils::scm2str (SCM s) SCM Utils::str2scm (std::string s) { - return gh_str02scm (s.c_str ()); + return scm_from_locale_string (s.c_str ()); } #endif -- 2.20.1