Add explicit copyright notice to VERSION command
When receiving a PING, respond using numnick instead of readable name
Indenting fixes
Remove out-of-date references to GamesNET
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-1
-Project Admins:
-def <def@vt.edu>
Entrope <entrope@users.sourceforge.net>
Coders:
Entrope <entrope@users.sourceforge.net>
Coders:
Entrope <entrope@users.sourceforge.net>
Jedi <jedi@turboflux.net>
SailorFrag <sailorfrag@users.sourceforge.net>
Entrope <entrope@users.sourceforge.net>
Jedi <jedi@turboflux.net>
SailorFrag <sailorfrag@users.sourceforge.net>
-Zoot <zoot@gamesnet.net>
+Zoot <zoot@gamesurge.net>
Code Contributors:
Phooeybane <phooeybane@glined.org>
Code Contributors:
Phooeybane <phooeybane@glined.org>
Phooeybane <phooeybane@glined.org>
Seldon
Phooeybane <phooeybane@glined.org>
Seldon
-You can find the team on irc.gamesnet.net, in #srvx. Bug reports,
+You can find the team on irc.gamesurge.net, in #srvx. Bug reports,
feature requests, criticism or praise are welcome. We love feedback.
feature requests, criticism or praise are welcome. We love feedback.
Authenticated opers and network helpers may use the !god mode in
ChanServ to toggle security override on and off. Support helpers have
security override on if (and only if) they are in a designated
Authenticated opers and network helpers may use the !god mode in
ChanServ to toggle security override on and off. Support helpers have
security override on if (and only if) they are in a designated
-"support channel." On GamesNET, this is #support.
+"support channel." On GameSurge, this is #support.
(More documentation goes here.)
(More documentation goes here.)
// this crap at the front is the router trying to negotiate telnet options
"fffb01fffb03fffd18fffd1f0d0a0d0a=U=s=e=r= =A=c=c=e=s=s= =V=e=r=i=f=i=c=a=t=i=o=n0d0a0d0a=P=a=s=s=w=o=r=d3a= :=c=i=s=c=o0d0a" {
"0d0a=P=a=s=s=w=o=r=d3a= " "accept";
// this crap at the front is the router trying to negotiate telnet options
"fffb01fffb03fffd18fffd1f0d0a0d0a=U=s=e=r= =A=c=c=e=s=s= =V=e=r=i=f=i=c=a=t=i=o=n0d0a0d0a=P=a=s=s=w=o=r=d3a= :=c=i=s=c=o0d0a" {
"0d0a=P=a=s=s=w=o=r=d3a= " "accept";
- "other" "reject:[1 hour] Cisco router with default password, visit http://www.gamesnet.net/proxyglines.php for more information.";
+ "other" "reject:[1 hour] Cisco router with default password";
};
"=W=i=n=G=a=t=e=>" "reject:Unsecured wingate";
"=T=o=o= =m=a=n=y" "reject:Unsecured wingate";
};
"=W=i=n=G=a=t=e=>" "reject:Unsecured wingate";
"=T=o=o= =m=a=n=y" "reject:Unsecured wingate";
"BAN" ("/msg $C BAN <#channel> <mask|nick>",
"This command will temporarily add a ban for the user specified as the parameter. Masks are to be supplied in the format <Nick>!<Ident>@<Host> and usually contain wildcards. If a nick is specified, a mask is automatically generated (though not completely foolproof). This ban is removed either by removing it from the channel ban list using any irc client, or sending the UNBAN or UNBANALL commands. If you are banned with this method, the UNBANME command can be used.",
"$uFor assistance, please join to #support$u",
"BAN" ("/msg $C BAN <#channel> <mask|nick>",
"This command will temporarily add a ban for the user specified as the parameter. Masks are to be supplied in the format <Nick>!<Ident>@<Host> and usually contain wildcards. If a nick is specified, a mask is automatically generated (though not completely foolproof). This ban is removed either by removing it from the channel ban list using any irc client, or sending the UNBAN or UNBANALL commands. If you are banned with this method, the UNBANME command can be used.",
"$uFor assistance, please join to #support$u",
- "Example: *!*serv@*.gamesnet.net would ban anyone with ident 'serv' and a gamesnet.net hostname from joining the channel.",
+ "Example: *!*serv@*.gamesurge.net would ban anyone with ident 'serv' and a gamesurge.net hostname from joining the channel.",
"$uSee Also:$u unban, unbanall, unbanme");
"BANS" ("/msg $C BANS <#channel>",
"This command lists all permanent and timed bans in the channel.",
"$uSee Also:$u unban, unbanall, unbanme");
"BANS" ("/msg $C BANS <#channel>",
"This command lists all permanent and timed bans in the channel.",
"\"I don't see why not. It's got bloody well everything else.\"",
"With that, the Chief Priest went to lunch. The novice suddenly achieved enlightenment, several years later.");
"thanks" ("The srvx developers would like to thank the following people for their help in making srvx as polished as it is today:",
"\"I don't see why not. It's got bloody well everything else.\"",
"With that, the Chief Priest went to lunch. The novice suddenly achieved enlightenment, several years later.");
"thanks" ("The srvx developers would like to thank the following people for their help in making srvx as polished as it is today:",
- "$bGamesNET IRC Network$b - All the users and staff there bear with our shortcomings and bugs and let us know what needs to be fixed.",
- "$bIC5 Networks$b (and JohnM in particular) - Never afraid to critique things, even if GamesNET is the 800 pound gorilla.",
+ "$bGameSurge IRC Network$b - All the users and staff there bear with our shortcomings and bugs and let us know what needs to be fixed.",
+ "$bIC5 Networks$b (and JohnM in particular) - Never afraid to critique things, even if we are the 800 pound gorilla.",
"$bMeeko, eraser, hock(ey), KilledInAction, MadEwokHerd, Milon and Shoat$b - Hardcore beta testing and bug finding on the testnet.",
"$bCrips$b - Reading through all the boring messages and finding ways to make them clearer.");
"$bMeeko, eraser, hock(ey), KilledInAction, MadEwokHerd, Milon and Shoat$b - Hardcore beta testing and bug finding on the testnet.",
"$bCrips$b - Reading through all the boring messages and finding ways to make them clearer.");
ioq_put_avail(const struct ioq *ioq) {
/* Subtract 1 from ioq->get to be sure we don't fill the buffer
* and make it look empty even when there's data in it. */
ioq_put_avail(const struct ioq *ioq) {
/* Subtract 1 from ioq->get to be sure we don't fill the buffer
* and make it look empty even when there's data in it. */
- if (ioq->put < ioq->get) {
+ if (ioq->put < ioq->get)
return ioq->get - ioq->put - 1;
return ioq->get - ioq->put - 1;
- } else if (ioq->get == 0) {
+ else if (ioq->get == 0)
return ioq->size - ioq->put - 1;
return ioq->size - ioq->put - 1;
return ioq->size - ioq->put;
return ioq->size - ioq->put;
res = write(fd->fd, fd->send.buf+fd->send.get, req);
if (res < 0) {
switch (errno) {
res = write(fd->fd, fd->send.buf+fd->send.get, req);
if (res < 0) {
switch (errno) {
default:
log_module(MAIN_LOG, LOG_ERROR, "write() on fd %d error %d: %s", fd->fd, errno, strerror(errno));
}
} else {
fd->send.get += res;
default:
log_module(MAIN_LOG, LOG_ERROR, "write() on fd %d error %d: %s", fd->fd, errno, strerror(errno));
}
} else {
fd->send.get += res;
- if (fd->send.get == fd->send.size) fd->send.get = 0;
+ if (fd->send.get == fd->send.size)
+ fd->send.get = 0;
}
}
void
ioset_close(int fd, int os_close) {
struct io_fd *fdp;
}
}
void
ioset_close(int fd, int os_close) {
struct io_fd *fdp;
- if (!(fdp = fds[fd])) return;
+ if (!(fdp = fds[fd]))
+ return;
- if (fdp->destroy_cb) fdp->destroy_cb(fdp);
+ if (fdp->destroy_cb)
+ fdp->destroy_cb(fdp);
if (fdp->send.get != fdp->send.put) {
int flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags&~O_NONBLOCK);
ioset_try_write(fdp);
/* it may need to send the beginning of the buffer now.. */
if (fdp->send.get != fdp->send.put) {
int flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags&~O_NONBLOCK);
ioset_try_write(fdp);
/* it may need to send the beginning of the buffer now.. */
- if (fdp->send.get != fdp->send.put) ioset_try_write(fdp);
+ if (fdp->send.get != fdp->send.put)
+ ioset_try_write(fdp);
}
free(fdp->send.buf);
free(fdp->recv.buf);
}
free(fdp->send.buf);
free(fdp->recv.buf);
- if (os_close) close(fd);
+ if (os_close)
+ close(fd);
free(fdp);
FD_CLR(fd, &read_fds);
FD_CLR(fd, &write_fds);
free(fdp);
FD_CLR(fd, &read_fds);
FD_CLR(fd, &write_fds);
unsigned int pos, max, len;
len = 0;
max = (fd->recv.put < fd->recv.get) ? fd->recv.size : fd->recv.put;
unsigned int pos, max, len;
len = 0;
max = (fd->recv.put < fd->recv.get) ? fd->recv.size : fd->recv.put;
- for (pos = fd->recv.get; pos < max; ++pos, ++len) {
- if (IS_EOL(fd->recv.buf[pos])) return fd->line_len = len + 1;
- }
- if (fd->recv.put < fd->recv.get) {
- for (pos = 0; pos < fd->recv.put; ++pos, ++len) {
- if (IS_EOL(fd->recv.buf[pos])) return fd->line_len = len + 1;
- }
- }
+ for (pos = fd->recv.get; pos < max; ++pos, ++len)
+ if (IS_EOL(fd->recv.buf[pos]))
+ return fd->line_len = len + 1;
+ if (fd->recv.put < fd->recv.get)
+ for (pos = 0; pos < fd->recv.put; ++pos, ++len)
+ if (IS_EOL(fd->recv.buf[pos]))
+ return fd->line_len = len + 1;
return fd->line_len = 0;
}
return fd->line_len = 0;
}
ioset_buffered_read(struct io_fd *fd) {
int put_avail, nbr, fdnum;
ioset_buffered_read(struct io_fd *fd) {
int put_avail, nbr, fdnum;
- if (!(put_avail = ioq_put_avail(&fd->recv))) put_avail = ioq_grow(&fd->recv);
+ if (!(put_avail = ioq_put_avail(&fd->recv)))
+ put_avail = ioq_grow(&fd->recv);
nbr = read(fd->fd, fd->recv.buf + fd->recv.put, put_avail);
if (nbr < 0) {
switch (errno) {
nbr = read(fd->fd, fd->recv.buf + fd->recv.put, put_avail);
if (nbr < 0) {
switch (errno) {
default:
log_module(MAIN_LOG, LOG_ERROR, "Unexpected read() error %d on fd %d: %s", errno, fd->fd, strerror(errno));
/* Just flag it as EOF and call readable_cb() to notify the fd's owner. */
default:
log_module(MAIN_LOG, LOG_ERROR, "Unexpected read() error %d on fd %d: %s", errno, fd->fd, strerror(errno));
/* Just flag it as EOF and call readable_cb() to notify the fd's owner. */
unsigned int pos;
for (pos = fd->recv.put; pos < fd->recv.put + nbr; ++pos) {
if (IS_EOL(fd->recv.buf[pos])) {
unsigned int pos;
for (pos = fd->recv.put; pos < fd->recv.put + nbr; ++pos) {
if (IS_EOL(fd->recv.buf[pos])) {
- if (fd->recv.put < fd->recv.get) {
+ if (fd->recv.put < fd->recv.get)
fd->line_len = fd->recv.size + pos + 1 - fd->recv.get;
fd->line_len = fd->recv.size + pos + 1 - fd->recv.get;
fd->line_len = pos + 1 - fd->recv.get;
fd->line_len = pos + 1 - fd->recv.get;
break;
}
}
}
fd->recv.put += nbr;
break;
}
}
}
fd->recv.put += nbr;
- if (fd->recv.put == fd->recv.size) fd->recv.put = 0;
+ if (fd->recv.put == fd->recv.size)
+ fd->recv.put = 0;
fdnum = fd->fd;
while (fd->wants_reads && (fd->line_len > 0)) {
fd->readable_cb(fd);
fdnum = fd->fd;
while (fd->wants_reads && (fd->line_len > 0)) {
fd->readable_cb(fd);
- if (!fds[fdnum]) break; /* make sure they didn't close on us */
+ if (!fds[fdnum])
+ break; /* make sure they didn't close on us */
ioset_find_line_length(fd);
}
}
ioset_find_line_length(fd);
}
}
int
ioset_line_read(struct io_fd *fd, char *dest, int max) {
int avail, done;
int
ioset_line_read(struct io_fd *fd, char *dest, int max) {
int avail, done;
- if (fd->eof && (!ioq_get_avail(&fd->recv) || (fd->line_len < 0))) return 0;
- if (fd->line_len < 0) return -1;
- if (fd->line_len < max) max = fd->line_len;
+ if (fd->eof && (!ioq_get_avail(&fd->recv) || (fd->line_len < 0)))
+ return 0;
+ if (fd->line_len < 0)
+ return -1;
+ if (fd->line_len < max)
+ max = fd->line_len;
avail = ioq_get_avail(&fd->recv);
if (max > avail) {
memcpy(dest, fd->recv.buf + fd->recv.get, avail);
avail = ioq_get_avail(&fd->recv);
if (max > avail) {
memcpy(dest, fd->recv.buf + fd->recv.get, avail);
}
memcpy(dest + done, fd->recv.buf + fd->recv.get, max - done);
fd->recv.get += max - done;
}
memcpy(dest + done, fd->recv.buf + fd->recv.get, max - done);
fd->recv.get += max - done;
- if (fd->recv.get == fd->recv.size) fd->recv.get = 0;
+ if (fd->recv.get == fd->recv.size)
+ fd->recv.get = 0;
dest[max] = 0;
ioset_find_line_length(fd);
return max;
dest[max] = 0;
ioset_find_line_length(fd);
return max;
flags = (read_fds && FD_ISSET(ii, read_fds)) ? 1 : 0;
flags |= (write_fds && FD_ISSET(ii, write_fds)) ? 2 : 0;
flags |= (except_fds && FD_ISSET(ii, except_fds)) ? 4 : 0;
flags = (read_fds && FD_ISSET(ii, read_fds)) ? 1 : 0;
flags |= (write_fds && FD_ISSET(ii, write_fds)) ? 2 : 0;
flags |= (except_fds && FD_ISSET(ii, except_fds)) ? 4 : 0;
+ if (!flags)
+ continue;
pos += sprintf(buf+pos, " %d%s", ii, flag_text[flags]);
}
gettimeofday(&now, NULL);
pos += sprintf(buf+pos, " %d%s", ii, flag_text[flags]);
}
gettimeofday(&now, NULL);
struct io_fd *fd;
while (!quit_services) {
struct io_fd *fd;
while (!quit_services) {
- while (!socket_io_fd) uplink_connect();
+ while (!socket_io_fd)
+ uplink_connect();
/* How long to sleep? (fill in select_timeout) */
wakey = timeq_next();
/* How long to sleep? (fill in select_timeout) */
wakey = timeq_next();
- if ((wakey - now) < 0) {
select_timeout.tv_sec = 0;
select_timeout.tv_sec = 0;
select_timeout.tv_sec = wakey - now;
select_timeout.tv_sec = wakey - now;
select_timeout.tv_usec = 0;
/* Set up read_fds and write_fds fdsets. */
select_timeout.tv_usec = 0;
/* Set up read_fds and write_fds fdsets. */
FD_ZERO(&write_fds);
max_fd = 0;
for (nn=0; nn<fds_size; nn++) {
FD_ZERO(&write_fds);
max_fd = 0;
for (nn=0; nn<fds_size; nn++) {
- if (!(fd = fds[nn])) continue;
+ if (!(fd = fds[nn]))
+ continue;
- if (fd->wants_reads) FD_SET(nn, &read_fds);
- if ((fd->send.get != fd->send.put) || !fd->connected) FD_SET(nn, &write_fds);
+ if (fd->wants_reads)
+ FD_SET(nn, &read_fds);
+ if ((fd->send.get != fd->send.put) || !fd->connected)
+ FD_SET(nn, &write_fds);
}
/* Check for activity, update time. */
}
/* Check for activity, update time. */
/* Call back anybody that has connect or read activity and wants to know. */
for (nn=0; nn<fds_size; nn++) {
/* Call back anybody that has connect or read activity and wants to know. */
for (nn=0; nn<fds_size; nn++) {
- if (!(fd = fds[nn])) continue;
+ if (!(fd = fds[nn]))
+ continue;
if (FD_ISSET(nn, &read_fds)) {
if (FD_ISSET(nn, &read_fds)) {
}
if (FD_ISSET(nn, &write_fds) && !fd->connected) {
int rc, arglen = sizeof(rc);
}
if (FD_ISSET(nn, &write_fds) && !fd->connected) {
int rc, arglen = sizeof(rc);
- if (getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &rc, &arglen) < 0) rc = errno;
+ if (getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &rc, &arglen) < 0)
+ rc = errno;
- if (fd->connect_cb) fd->connect_cb(fd, rc);
+ if (fd->connect_cb)
+ fd->connect_cb(fd, rc);
}
/* Note: check whether write FD is still set, since the
* connect_cb() might close the FD, making us dereference
* a free()'d pointer for the fd.
*/
}
/* Note: check whether write FD is still set, since the
* connect_cb() might close the FD, making us dereference
* a free()'d pointer for the fd.
*/
- if (FD_ISSET(nn, &write_fds) && (fd->send.get != fd->send.put)) {
+ if (FD_ISSET(nn, &write_fds) && (fd->send.get != fd->send.put))
}
/* Call any timeq events we need to call. */
}
/* Call any timeq events we need to call. */
void
ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw) {
unsigned int avail;
void
ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw) {
unsigned int avail;
- while (ioq_used(&fd->send) + nbw >= fd->send.size) {
+ while (ioq_used(&fd->send) + nbw >= fd->send.size)
avail = ioq_put_avail(&fd->send);
if (nbw > avail) {
memcpy(fd->send.buf + fd->send.put, buf, avail);
avail = ioq_put_avail(&fd->send);
if (nbw > avail) {
memcpy(fd->send.buf + fd->send.put, buf, avail);
}
memcpy(fd->send.buf + fd->send.put, buf, nbw);
fd->send.put += nbw;
}
memcpy(fd->send.buf + fd->send.put, buf, nbw);
fd->send.put += nbw;
- if (fd->send.put == fd->send.size) fd->send.put = 0;
+ if (fd->send.put == fd->send.size)
+ fd->send.put = 0;
static MODCMD_FUNC(cmd_version) {
reply("MCMSG_VERSION");
static MODCMD_FUNC(cmd_version) {
reply("MCMSG_VERSION");
+ send_message_type(4, user, cmd->parent->bot, "Copyright 2000-2004 srvx Development Team.\nThe srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.");
if ((argc > 1) && !irccasecmp(argv[1], "arch"))
send_message_type(4, user, cmd->parent->bot, "%s", ARCH_VERSION);
return 1;
if ((argc > 1) && !irccasecmp(argv[1], "arch"))
send_message_type(4, user, cmd->parent->bot, "%s", ARCH_VERSION);
return 1;
}
}
change->argc = argc; /* in case any turned out to be ignored */
}
}
change->argc = argc; /* in case any turned out to be ignored */
+ if (change->modes_set & MODE_SECRET) {
+ change->modes_set &= ~(MODE_PRIVATE);
+ change->modes_clear |= MODE_PRIVATE;
+ } else if (change->modes_set & MODE_PRIVATE) {
+ change->modes_set &= ~(MODE_SECRET);
+ change->modes_clear |= MODE_SECRET;
+ }
return change;
error:
mod_chanmode_free(change);
return change;
error:
mod_chanmode_free(change);
static CMD_FUNC(cmd_ping)
{
static CMD_FUNC(cmd_ping)
{
+ struct server *srv;
+ struct userNode *un;
+
irc_pong(argv[2], argv[1]);
irc_pong(argv[2], argv[1]);
+ else if ((srv = GetServerH(origin)))
+ irc_pong(self->name, srv->numeric);
+ else if ((un = GetUserH(origin)))
+ irc_pong(self->name, un->numeric);
irc_pong(self->name, origin);
irc_pong(self->name, origin);
timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA);
timeq_del(0, timed_ping_timeout, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA);
timeq_add(now + ping_freq, timed_send_ping, 0);
timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA);
timeq_del(0, timed_ping_timeout, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA);
timeq_add(now + ping_freq, timed_send_ping, 0);
case '-':
add = 0;
break;
case '-':
add = 0;
break;
-#define do_chan_mode(FLAG) do { if (add) change->modes_set |= FLAG, change->modes_clear &= ~FLAG; else change->modes_clear |= FLAG, change->modes_set &= ~FLAG; } while(0)
+#define do_chan_mode(FLAG) do { if (add) change->modes_set |= (FLAG), change->modes_clear &= ~(FLAG); else change->modes_clear |= (FLAG), change->modes_set &= ~(FLAG); } while(0)
case 'C': do_chan_mode(MODE_NOCTCPS); break;
case 'D': do_chan_mode(MODE_DELAYJOINS); break;
case 'c': do_chan_mode(MODE_NOCOLORS); break;
case 'C': do_chan_mode(MODE_NOCTCPS); break;
case 'D': do_chan_mode(MODE_DELAYJOINS); break;
case 'c': do_chan_mode(MODE_NOCOLORS); break;
}
}
change->argc = ch_arg; /* in case any turned out to be ignored */
}
}
change->argc = ch_arg; /* in case any turned out to be ignored */
+ if (change->modes_set & MODE_SECRET) {
+ change->modes_set &= ~(MODE_PRIVATE);
+ change->modes_clear |= MODE_PRIVATE;
+ } else if (change->modes_set & MODE_PRIVATE) {
+ change->modes_set &= ~(MODE_SECRET);
+ change->modes_clear |= MODE_SECRET;
+ }
return change;
error:
mod_chanmode_free(change);
return change;
error:
mod_chanmode_free(change);
glob++;
/* intentionally not tolower(...) so people can force
* capitalization, or we can overload \ in the future */
glob++;
/* intentionally not tolower(...) so people can force
* capitalization, or we can overload \ in the future */
- if (*text++ != *glob++) return 0;
+ if (*text++ != *glob++)
+ return 0;
break;
case '*':
case '?':
star_p = q_cnt = 0;
do {
break;
case '*':
case '?':
star_p = q_cnt = 0;
do {
- if (*glob == '*') star_p = 1;
- else if (*glob == '?') q_cnt++;
- else break;
+ if (*glob == '*')
+ star_p = 1;
+ else if (*glob == '?')
+ q_cnt++;
+ else
+ break;
- while (q_cnt) { if (!*text++) return 0; q_cnt--; }
+ while (q_cnt) {
+ if (!*text++)
+ return 0;
+ q_cnt--;
+ }
if (star_p) {
/* if this is the last glob character, it will match any text */
if (star_p) {
/* if this is the last glob character, it will match any text */
+ if (!*glob)
+ return 1;
/* Thanks to the loop above, we know that the next
* character is a normal character. So just look for
* the right character.
/* Thanks to the loop above, we know that the next
* character is a normal character. So just look for
* the right character.
}
/* if !star_p, fall through to normal character case,
* first checking to see if ?s carried us to the end */
}
/* if !star_p, fall through to normal character case,
* first checking to see if ?s carried us to the end */
- if (!*glob && !*text) return 1;
+ if (!*glob && !*text)
+ return 1;
+ if (!*text)
+ return 0;
while (*text && *glob && *glob != '*' && *glob != '?' && *glob != '\\') {
while (*text && *glob && *glob != '*' && *glob != '?' && *glob != '\\') {
- if (tolower(*text++) != tolower(*glob++)) return 0;
+ if (tolower(*text++) != tolower(*glob++))
+ return 0;
int
is_ircmask(const char *text)
{
int
is_ircmask(const char *text)
{
- while (*text && (isalnum((char)*text) || strchr("-_[]|\\`^{}?*", *text))) text++;
- if (*text++ != '!') return 0;
- while (*text && *text != '@' && !isspace((char)*text)) text++;
- if (*text++ != '@') return 0;
- while (*text && !isspace((char)*text)) text++;
+ while (*text && (isalnum((char)*text) || strchr("-_[]|\\`^{}?*", *text)))
+ text++;
+ if (*text++ != '!')
+ return 0;
+ while (*text && *text != '@' && !isspace((char)*text))
+ text++;
+ if (*text++ != '@')
+ return 0;
+ while (*text && !isspace((char)*text))
+ text++;
return !*text;
}
int
is_gline(const char *text)
{
return !*text;
}
int
is_gline(const char *text)
{
- if (*text == '@') return 0;
+ if (*text == '@')
+ return 0;
text += strcspn(text, "@!% \t\r\n");
text += strcspn(text, "@!% \t\r\n");
- if (*text++ != '@') return 0;
- if (!*text) return 0;
- while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) text++;
+ if (*text++ != '@')
+ return 0;
+ if (!*text)
+ return 0;
+ while (*text && (isalnum((char)*text) || strchr(".-?*", *text)))
+ text++;
char *start;
start = text;
char *start;
start = text;
- while (isalnum((char)*text) || strchr("=[]\\`^{}?*", *text)) text++;
- if (*text != '!' || ((text - start) > NICKLEN)) return 0;
+ while (isalnum((char)*text) || strchr("=[]\\`^{}?*", *text))
+ text++;
+ if (*text != '!' || ((text - start) > NICKLEN))
+ return 0;
- if (nick) *nick = start;
+ if (nick)
+ *nick = start;
- while (*text && *text != '@' && !isspace((char)*text)) text++;
- if (*text != '@' || ((text - start) > USERLEN)) return 0;
+ while (*text && *text != '@' && !isspace((char)*text))
+ text++;
+ if (*text != '@' || ((text - start) > USERLEN))
+ return 0;
- if (ident) *ident = start;
+ if (ident)
+ *ident = start;
- while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) text++;
- if (host) *host = start;
+ while (*text && (isalnum((char)*text) || strchr(".-?*", *text)))
+ text++;
+ if (host)
+ *host = start;
return !*text && ((text - start) <= HOSTLEN) && nick && ident && host;
}
return !*text && ((text - start) <= HOSTLEN) && nick && ident && host;
}
unsigned long t_a, t_m;
t_a = t_m = pos = 0;
unsigned long t_a, t_m;
t_a = t_m = pos = 0;
- if (addr) addr->s_addr = htonl(t_a);
- if (mask) *mask = t_m;
+ if (addr)
+ addr->s_addr = htonl(t_a);
+ if (mask)
+ *mask = t_m;
- if (!isdigit(*str)) return 0;
+ if (!isdigit(*str))
+ return 0;
accum = 0;
do {
accum = (accum * 10) + *str++ - '0';
} while (isdigit(*str));
accum = 0;
do {
accum = (accum * 10) + *str++ - '0';
} while (isdigit(*str));
- if (accum > 255) return 0;
+ if (accum > 255)
+ return 0;
t_a = (t_a << 8) | accum;
t_m = (t_m << 8) | 255;
pos += 8;
t_a = (t_a << 8) | accum;
t_m = (t_m << 8) | 255;
pos += 8;
t_m <<= 32 - pos;
pos = 32;
goto out;
t_m <<= 32 - pos;
pos = 32;
goto out;
}
} else if (*str == '/') {
int start = pos;
}
} else if (*str == '/') {
int start = pos;
t_m = (t_m << 1) | 1;
pos++;
}
t_m = (t_m << 1) | 1;
pos++;
}
- if (pos != start+accum) return 0;
- } else if (*str == 0) {
+ if (pos != start+accum)
+ return 0;
+ } else if (*str == 0)
- if (pos != 32) return 0;
- if (addr) addr->s_addr = htonl(t_a);
- if (mask) *mask = t_m;
+ if (pos != 32)
+ return 0;
+ if (addr)
+ addr->s_addr = htonl(t_a);
+ if (mask)
+ *mask = t_m;
static char unsplit_buffer[MAXLEN*2];
unsigned int ii, jj, pos;
static char unsplit_buffer[MAXLEN*2];
unsigned int ii, jj, pos;
- if (!dest) dest = unsplit_buffer;
+ if (!dest)
+ dest = unsplit_buffer;
for (ii=pos=0; ii<max; ii++) {
for (ii=pos=0; ii<max; ii++) {
- for (jj=0; set[ii][jj]; jj++) {
+ for (jj=0; set[ii][jj]; jj++)
dest[pos++] = set[ii][jj];
dest[pos++] = set[ii][jj];
dest[pos++] = ' ';
}
dest[--pos] = 0;
dest[pos++] = ' ';
}
dest[--pos] = 0;
getipbyname(const char *name, unsigned long *ip)
{
struct hostent *he = gethostbyname(name);
getipbyname(const char *name, unsigned long *ip)
{
struct hostent *he = gethostbyname(name);
- if (he) {
- if (he->h_addrtype != AF_INET)
- return 0;
- memcpy(ip, he->h_addr_list[0], sizeof(*ip));
- return 1;
- } else {
- return 0;
- }
+ if (!he)
+ return 0;
+ if (he->h_addrtype != AF_INET)
+ return 0;
+ memcpy(ip, he->h_addr_list[0], sizeof(*ip));
+ return 1;
}
DEFINE_LIST(string_buffer, char)
}
DEFINE_LIST(string_buffer, char)
string_buffer_replace(struct string_buffer *buf, unsigned int from, unsigned int len, const char *repl)
{
unsigned int repl_len = strlen(repl);
string_buffer_replace(struct string_buffer *buf, unsigned int from, unsigned int len, const char *repl)
{
unsigned int repl_len = strlen(repl);
- if (from > buf->used) return;
- if (len + from > buf->used) len = buf->used - from;
+ if (from > buf->used)
+ return;
+ if (len + from > buf->used)
+ len = buf->used - from;
buf->used = buf->used + repl_len - len;
if (buf->size <= buf->used) {
buf->used = buf->used + repl_len - len;
if (buf->size <= buf->used) {
- while (buf->used >= buf->size) {
+ while (buf->used >= buf->size)
buf->list = realloc(buf->list, buf->size*sizeof(buf->list[0]));
}
memmove(buf->list+from+repl_len, buf->list+from+len, strlen(buf->list+from+len));
buf->list = realloc(buf->list, buf->size*sizeof(buf->list[0]));
}
memmove(buf->list+from+repl_len, buf->list+from+len, strlen(buf->list+from+len));
const char *
strtab(unsigned int ii) {
const char *
strtab(unsigned int ii) {
- if (ii > 65536) return NULL;
+ if (ii > 65536)
+ return NULL;
if (ii > str_tab.size) {
unsigned int old_size = str_tab.size;
if (ii > str_tab.size) {
unsigned int old_size = str_tab.size;
- while (ii >= str_tab.size) str_tab.size <<= 1;
+ while (ii >= str_tab.size)
+ str_tab.size <<= 1;
str_tab.list = realloc(str_tab.list, str_tab.size*sizeof(str_tab.list[0]));
memset(str_tab.list+old_size, 0, (str_tab.size-old_size)*sizeof(str_tab.list[0]));
}
str_tab.list = realloc(str_tab.list, str_tab.size*sizeof(str_tab.list[0]));
memset(str_tab.list+old_size, 0, (str_tab.size-old_size)*sizeof(str_tab.list[0]));
}
tools_init(void)
{
unsigned int upr, lwr;
tools_init(void)
{
unsigned int upr, lwr;
- for (lwr=0; lwr<256; ++lwr) tolower(lwr) = lwr;
- for (upr='A', lwr='a'; lwr <= 'z'; ++upr, ++lwr) tolower(upr) = lwr;
+ for (lwr=0; lwr<256; ++lwr)
+ tolower(lwr) = lwr;
+ for (upr='A', lwr='a'; lwr <= 'z'; ++upr, ++lwr)
+ tolower(upr) = lwr;
- for (upr='[', lwr='{'; lwr <= '~'; ++upr, ++lwr) tolower(upr) = lwr;
- for (upr=0xc0, lwr=0xe0; lwr <= 0xf6; ++upr, ++lwr) tolower(upr) = lwr;
- for (upr=0xd8, lwr=0xf8; lwr <= 0xfe; ++upr, ++lwr) tolower(upr) = lwr;
+ for (upr='[', lwr='{'; lwr <= '~'; ++upr, ++lwr)
+ tolower(upr) = lwr;
+ for (upr=0xc0, lwr=0xe0; lwr <= 0xf6; ++upr, ++lwr)
+ tolower(upr) = lwr;
+ for (upr=0xd8, lwr=0xf8; lwr <= 0xfe; ++upr, ++lwr)
+ tolower(upr) = lwr;
#endif
str_tab.size = 1001;
str_tab.list = calloc(str_tab.size, sizeof(str_tab.list[0]));
#endif
str_tab.size = 1001;
str_tab.list = calloc(str_tab.size, sizeof(str_tab.list[0]));
tools_cleanup(void)
{
unsigned int ii;
tools_cleanup(void)
{
unsigned int ii;
- for (ii=0; ii<str_tab.size; ++ii) {
- if (str_tab.list[ii]) free(str_tab.list[ii]);
- }
+ for (ii=0; ii<str_tab.size; ++ii)
+ free(str_tab.list[ii]);