+2005-05-31 Clinton Ebadi <clinton@unknownlamer.org>
+
+ * source/String.C (operator): Made index signed again, it's not
+ worth fixing this warning
+
+ * source/Bot.C: Add casts to make this compile with unsigned int
+ as operator[] in String
+
+ * source/String.C (operator): Made index unsigned
+
+ * source/Utils.C: Made a few things unsigned to kill warnings
+
+ * source/Socket.C (readLine): Made pos unsigned
+
+ * source/Bot.C (Bot): Fixed initializer list order to kill warnings
+
+ * source/BotInterp.C (RunTimers): Removed unused variable (Timer *t)
+
+ * source/StringTokenizer.C (count_tokens): Changed return type to
+ unsigned int
+ (more_tokens_p): Made counter unsigned
+
+ * source/StringTokenizer.H (class StringTokenizer): Made pos
+ std::string::size_type instead of int
+
+ * source/Commands.C (TBan): Returns Ok is the ban is done instead
+ of falling off the end (oops)
+
+ * source/BotInterp.H: Add general catch case (false)
+
2005-03-11 Clinton Ebadi <clinton@unknownlamer.org>
* configure.ac: Release 2.1.6
=====================================================================
Version 2.1.7:
+- Fixed a number of small bugs and corner cases
+- Should compile without warnings (GCC 3.4)
Version 2.1.6:
- The String class has been removed and replaced by std::string
* Wrote config database class
2.2:
+* Compile without warnings
+* Finish Texinfo manual
* Utils::valid_nickname_p should have a configurable max nick length
(now that most networks allow for longer than nine character
nicks). This is dependant upon the new configuration system
(e.g. bot:send-CTCP to send a CTCP message)
* Add util functions for doing stuff like quoting CTCP messages
* Finish adding hooks/send hooks
-* Write Texinfo manual
-* Use configuration database class
-* Improve the help system
* bot:protection/[none|no-ban|no-kick|no-deop] constants
* bot:aop/[no|yes] constants
-* Extend AOP to support +v (0 = no op, 1 = +o, 2 = +v)
* Add DCC_CHAT_END hook for Scheme
+
+2.4:
+* Use configuration database class
+* Extend AOP to support +v (0 = no op, 1 = +o, 2 = +v)
* Add !setcommandlevel (move ScriptCommands implementation to Commands
and add a UserCommands)
+* Improve the help system
2.4/3.0 (2.4 iff backwards compatibility is maintained, 3.0 otherwise):
General:
userHost(""),
localIP(""),
commandChar(DEFAULT_COMMANDCHAR),
- configFileName(filename),
userListFileName(DEFAULT_USERLISTFILENAME),
shitListFileName(DEFAULT_SHITLISTFILENAME),
- logFileName(DEFAULT_LOGFILENAME),
- logs_dir (DEFAULT_LOGDIR),
helpFileName(DEFAULT_HELPFILENAME),
initFileName(DEFAULT_INITFILENAME),
+ connected(false),
+ debug(debug_on),
+ stop(false),
+ sentPing(false),
+ startTime(time(NULL)),
+ currentTime(startTime),
+ lastNickNameChange(startTime),
+ lastChannelJoin(startTime),
+ serverConnection(0),
+ sentUserhostID(0),
+ receivedUserhostID(0),
+ logFileName(DEFAULT_LOGFILENAME),
+ logs_dir (DEFAULT_LOGDIR),
+ configFileName (filename),
#ifdef USESCRIPTS
scriptLogFileName(DEFAULT_SCRIPTLOGFILENAME),
- autoexecFileName(DEFAULT_AUTOEXECFILENAME),
+ autoexecFileName(DEFAULT_AUTOEXECFILENAME)
#endif
- connected(false),
- debug(debug_on), stop(false), sentPing(false),
- startTime(time(NULL)), currentTime(startTime),
- lastNickNameChange(startTime), lastChannelJoin(startTime),
- serverConnection(0), sentUserhostID(0), receivedUserhostID(0)
{
#ifdef HAVE_STL_CLEAR
wantedChannels.clear();
line++;
StringTokenizer st(temp);
temp = Utils::trim_str (temp);
- if (temp[0]=='#') continue;
+ if (temp[(unsigned int)0]=='#') continue;
if (st.count_tokens (' ') != 2) {
std::cerr << "Error when reading alias file (" << initFileName
<< ") line " << line << "...\n";
file >> temp;
- if (temp.length() == 0 || temp[0] == '#') {
+ if (temp.length() == 0 || temp[(unsigned int)0] == '#') {
line++;
continue;
}
else if (command == "IRCNAME" || command == "REALNAME")
ircName = parameters;
else if (command == "CMDCHAR" || command == "COMMAND")
- commandChar = parameters[0];
+ commandChar = parameters[(unsigned int)0];
else if (command == "USERLIST")
userListFileName = parameters;
else if (command == "SHITLIST")
{
if (parameters != logFileName)
{
- if (parameters[0] == '/')
+ if (parameters[(unsigned int)0] == '/')
{
set_log_dir ("/");
set_log_file (parameters.subString (1));
std::list<Timer *>::iterator it = timersList.begin();
std::list<Timer *>::iterator it2 = timersList.end();
std::list<Timer *>::iterator it3;
- Timer *t;
+
struct wrapper_data wd;
wd.args = scm_listify (SCM_UNDEFINED);
bool operator< (const Hook &h) const
{
if (priority < h.priority)
- return true;
+ {
+ return true;
+ }
else if (priority > h.priority)
- return false;
+ {
+ return false;
+ }
else if (fallthru && h.fallthru)
- return false;
+ {
+ return false;
+ }
else if (fallthru && !h.fallthru)
- return false;
+ {
+ return false;
+ }
else if (!fallthru && h.fallthru)
- return true;
+ {
+ return true;
+ }
+ else
+ {
+ // NOTE: This should never be reached
+ return false;
+ }
}
enum {
CHECK_CONNECTION;
Channel *c = CHANNEL(channel);
+ String dest;
+ // Make sure all of the inputs are valid
if (!c)
- return NotOnChannel(channel);
+ {
+ return NotOnChannel(channel);
+ }
if (!bot->iAmOp(channel))
- return NotChannelOp(channel);
+ {
+ return NotChannelOp(channel);
+ }
if (seconds <= 0)
- return InvalidTime(seconds);
-
- String dest;
+ {
+ return InvalidTime(seconds);
+ }
+ // Look for user
if (!Utils::wildcard_p(who))
- dest = bot->getUserhost(channel, who);
+ {
+ dest = bot->getUserhost(channel, who);
+ }
else
- dest = who;
+ {
+ dest = who;
+ }
if (dest.length() == 0)
- return UserNotFound(who, channel);
+ {
+ return UserNotFound(who, channel);
+ }
+
dest = Utils::make_wildcard(dest);
Mask m(dest);
+ // Make sure the user isn't protected from bans
for (std::list<UserListItem *>::iterator it = bot->userList->l.begin();
it != bot->userList->l.end();
it++)
- if (m.matches((*it)->mask) &&
- (*it)->channelMask.matches(channel) &&
- (*it)->prot >= User::NO_BAN)
- return UserProtected(who, channel);
+ {
+ if (m.matches((*it)->mask) &&
+ (*it)->channelMask.matches(channel) &&
+ (*it)->prot >= User::NO_BAN)
+ {
+ return UserProtected(who, channel);
+ }
+ }
+ // Clear existing bans on the user
for (std::vector<BanEntry *>::iterator it = c->channelBanlist.begin();
it != c->channelBanlist.end(); ++it)
- if (m.matches((*it)->banMask))
- QUEUE->sendChannelMode(channel, "-b", (*it)->banMask.getMask());
+ {
+ if (m.matches((*it)->banMask))
+ {
+ QUEUE->sendChannelMode(channel, "-b", (*it)->banMask.getMask());
+ }
+ }
+ // Ban them
CHANNEL(channel)->addBan(dest, seconds);
QUEUE->sendChannelMode(channel, "+b", dest);
bot->todoList->addDeban(channel, dest, seconds);
+
+ return Ok;
}
// that only the line that was just read is returned.
static std::string buf (512, ' ');
- int pos = 0; // pos in buffer
+ std::string::size_type pos = 0; // pos in buffer
int nb; // number of bytes read by ::read
char r; // temp var for storing output of read into
std::string::size_type length = buf.length ();
}
char &
-String::operator[] (int i)
+String::operator[] (int i_)
{
+ unsigned int i = i_;
+
if (i < 0 || my_string.length () < i) {
std::cerr << "String index out of range\n";
std::exit(1);
}
const char &
-String::operator[](int i) const
+String::operator[](int i_) const
{
+ unsigned int i = i_;
+
if (i < 0 || my_string.length () < i) {
std::cerr << "String index out of range\n";
exit(1);
if (pos == st.length())
return false;
- for (int i = pos; i < st.length(); i++)
+ for (std::string::size_type i = pos; i < st.length(); i++)
if (st[i] != ' ' && st[i] != '\t')
return true;
if (pos == st.length())
return false;
- for (int i = pos; i < st.length(); i++)
+ for (std::string::size_type i = pos; i < st.length(); i++)
if (st[i] != c)
return true;
return false;
}
-int
+unsigned int
StringTokenizer::count_tokens ()
{
- int i = 0;
+ unsigned int i = 0;
StringTokenizer s (st);
while (s.more_tokens_p ())
return i;
}
-int
+unsigned int
StringTokenizer::count_tokens (char c)
{
- int i = 0;
+ unsigned int i = 0;
StringTokenizer s(st);
while (s.more_tokens_p (c))
std::string
StringTokenizer::next_token()
{
- int i = pos;
+ std::string::size_type i = pos;
while (i < st.length() && (st[i] == ' ' || st[i] == '\t'))
i++;
- for (int j = i; j < st.length(); j++)
+ for (std::string::size_type j = i; j < st.length(); j++)
if (st[j] == ' ' || st[j] == '\t')
{
pos = j + 1;
std::string
StringTokenizer::next_token (char c, bool empty)
{
- int i = pos;
+ std::string::size_type i = pos;
+ std::string::size_type j = 0;
while (i < st.length() && (st[i] == c))
- i++;
- for (int j = i; j < st.length(); j++)
- if (st[j] == c)
- {
- pos = j + 1;
- return st.substr (i, j - i);
- }
+ {
+ i++;
+ }
+
+ for (j = i; j < st.length(); j++)
+ {
+ if (st[j] == c)
+ {
+ pos = j + 1;
+ return st.substr (i, j - i);
+ }
+ }
if (empty)
return "";
class StringTokenizer
{
std::string st;
- int pos;
+ std::string::size_type pos;
public:
StringTokenizer(std::string);
StringTokenizer(StringTokenizer &);
bool more_tokens_p ();
bool more_tokens_p (char);
- int count_tokens();
- int count_tokens(char);
+ unsigned int count_tokens();
+ unsigned int count_tokens(char);
std::string next_token();
std::string next_token(char, bool = false);
bool
Utils::IP_p (std::string host)
{
- for (int i = 0; i < host.length(); i++)
+ for (std::string::size_type i = 0; i < host.length(); i++)
if (!std::isdigit (host[i]) && host[i] !='.')
return false;
return true;
if (n[0] == '-' || std::isdigit(n[0]) || n.length() > 9)
return false;
- for (int i = 0; i < n.length(); i++)
+ for (std::string::size_type i = 0; i < n.length(); i++)
if (!isvalid(n[i]) || std::isspace (n[i]))
return false;
if (!std::isdigit (str[0]))
return 0;
- num.reserve (512); // reverse a buffer to speed things up
+ num.reserve (64); // reserve a buffer to speed things up
- for (int i = 0; i < str.length(); i++)
+ for (std::string::size_type i = 0; i < str.length(); i++)
{
switch (str[i])
{