From c32c3c99a1e1d395c88e901de200c21b9ca1e84f Mon Sep 17 00:00:00 2001 From: "Robin Burchell w00t@inspircd.org" Date: Tue, 30 Sep 2008 18:45:10 +0000 Subject: Made all protocol modules able to be compiled via mostly constifying strings. Due to the above, also had to constify strings in many other areas. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1202 5417fbe8-f217-4b02-8779-1006273d7864 --- src/actions.c | 17 +-- src/base64.c | 18 +-- src/botserv.c | 41 ++---- src/channels.c | 72 +++++----- src/chanserv.c | 41 +++--- src/core/cs_ban.c | 14 +- src/core/cs_clear.c | 96 +++++--------- src/core/cs_modes.c | 22 ++- src/core/os_clearmodes.c | 66 ++++----- src/core/os_mode.c | 6 +- src/events.c | 22 +-- src/messages.c | 38 +++--- src/misc.c | 18 +-- src/modules.c | 98 +++++++------- src/operserv.c | 16 +-- src/process.c | 332 ++++++++++++++++++++++------------------------ src/protocol/bahamut.c | 222 +++++++++++++++---------------- src/protocol/bahamut.h | 128 +++++++++--------- src/protocol/charybdis.c | 230 ++++++++++++++++---------------- src/protocol/charybdis.h | 128 +++++++++--------- src/protocol/dreamforge.c | 192 +++++++++++++-------------- src/protocol/dreamforge.h | 128 +++++++++--------- src/protocol/hybrid.c | 214 +++++++++++++++--------------- src/protocol/hybrid.h | 128 +++++++++--------- src/protocol/inspircd10.c | 250 +++++++++++++++++----------------- src/protocol/inspircd10.h | 148 ++++++++++----------- src/protocol/inspircd11.c | 253 +++++++++++++++++------------------ src/protocol/inspircd11.h | 150 ++++++++++----------- src/protocol/plexus2.c | 218 +++++++++++++++--------------- src/protocol/plexus2.h | 128 +++++++++--------- src/protocol/plexus3.c | 218 +++++++++++++++--------------- src/protocol/plexus3.h | 128 +++++++++--------- src/protocol/ptlink.c | 216 +++++++++++++++--------------- src/protocol/ptlink.h | 128 +++++++++--------- src/protocol/rageircd.c | 234 ++++++++++++++++---------------- src/protocol/rageircd.h | 128 +++++++++--------- src/protocol/ratbox.c | 223 ++++++++++++++++--------------- src/protocol/ratbox.h | 128 +++++++++--------- src/protocol/shadowircd.c | 219 +++++++++++++++--------------- src/protocol/shadowircd.h | 128 +++++++++--------- src/protocol/solidircd.c | 226 +++++++++++++++---------------- src/protocol/solidircd.h | 128 +++++++++--------- src/protocol/ultimate2.c | 232 ++++++++++++++++---------------- src/protocol/ultimate2.h | 128 +++++++++--------- src/protocol/ultimate3.c | 250 +++++++++++++++++----------------- src/protocol/ultimate3.h | 128 +++++++++--------- src/protocol/unreal31.c | 220 +++++++++++++++--------------- src/protocol/unreal31.h | 128 +++++++++--------- src/protocol/unreal32.c | 256 +++++++++++++++++------------------ src/protocol/unreal32.h | 128 +++++++++--------- src/protocol/viagra.c | 252 +++++++++++++++++------------------ src/protocol/viagra.h | 128 +++++++++--------- src/send.c | 8 +- src/servers.c | 20 +-- src/sessions.c | 50 +++---- src/users.c | 12 +- 56 files changed, 3688 insertions(+), 3790 deletions(-) (limited to 'src') diff --git a/src/actions.c b/src/actions.c index 9da4f60d4..dcccf0131 100644 --- a/src/actions.c +++ b/src/actions.c @@ -6,9 +6,9 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * $Id$ + * Based on the original code of Services by Andy Church. + * + * $Id$ * */ @@ -130,7 +130,7 @@ void sqline(char *mask, char *reason) */ void common_unban(ChannelInfo * ci, char *nick) { - char *av[4]; + const char *av[4]; char *host = NULL; char buf[BUFSIZE]; int ac; @@ -170,11 +170,11 @@ void common_unban(ChannelInfo * ci, char *nick) snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); av[0] = ci->name; av[1] = buf; - av[2] = sstrdup("-b"); + av[2] = "-b"; ac = 4; } else { av[0] = ci->name; - av[1] = sstrdup("-b"); + av[1] = "-b"; ac = 3; } @@ -191,11 +191,6 @@ void common_unban(ChannelInfo * ci, char *nick) do_cmode(whosends(ci), ac, av); } } - - if (ircdcap->tsmode) - free(av[2]); - else - free(av[1]); } /* host_resolve() sstrdup us this info so we gotta free it */ if (host) { diff --git a/src/base64.c b/src/base64.c index 10b2f0254..2c78a9703 100644 --- a/src/base64.c +++ b/src/base64.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * */ @@ -88,9 +88,9 @@ static const char Pad64 = '='; end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the - ------------------------------------------------- + ------------------------------------------------- following cases can arise: - + (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters @@ -162,7 +162,7 @@ int b64_encode(char *src, size_t srclength, char *target, size_t targsize) it returns the number of data bytes stored at the target, or -1 on error. */ -int b64_decode(char *src, char *target, size_t targsize) +int b64_decode(const char *src, char *target, size_t targsize) { int tarindex, state, ch; char *pos; @@ -301,7 +301,7 @@ char *encode_ip(unsigned char *ip) return buf; } -int decode_ip(char *buf) +int decode_ip(const char *buf) { int len = strlen(buf); char targ[25]; @@ -351,8 +351,8 @@ char base64_to_int6_map[] = { static char *int_to_base64(long val) { - /* 32/6 == max 6 bytes for representation, - * +1 for the null, +1 for byte boundaries + /* 32/6 == max 6 bytes for representation, + * +1 for the null, +1 for byte boundaries */ static char base64buf[8]; long i = 7; @@ -391,7 +391,7 @@ static long base64_to_int(char *b64) return v; } -long base64dects(char *ts) +long base64dects(const char *ts) { char *token; long value; diff --git a/src/botserv.c b/src/botserv.c index 556994b0e..19fff43e7 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -7,7 +7,7 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * + * * $Id$ * */ @@ -613,7 +613,7 @@ BotInfo *makebot(char *nick) /*************************************************************************/ -BotInfo *findbot(char *nick) +BotInfo *findbot(const char *nick) { BotInfo *bi; Uid *ud; @@ -762,7 +762,7 @@ void bot_join(ChannelInfo * ci) /* We check for bans */ if (ci->c->bans && ci->c->bans->count) { char buf[BUFSIZE]; - char *av[4]; + const char *av[4]; Entry *ban, *next; int ac; @@ -770,11 +770,11 @@ void bot_join(ChannelInfo * ci) snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); av[0] = ci->c->name; av[1] = buf; - av[2] = sstrdup("-b"); + av[2] = "-b"; ac = 4; } else { av[0] = ci->c->name; - av[1] = sstrdup("-b"); + av[1] = "-b"; ac = 3; } @@ -792,11 +792,6 @@ void bot_join(ChannelInfo * ci) do_cmode(whosends(ci), ac, av); } } - - if (ircdcap->tsmode) - free(av[2]); - else - free(av[1]); } /* Should we be invited? */ @@ -842,7 +837,7 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) bd->ttb[ttbtype]++; if (bd->ttb[ttbtype] == ci->ttb[ttbtype]) { - char *av[4]; + const char *av[4]; int ac; char mask[BUFSIZE]; char buf[BUFSIZE]; @@ -855,12 +850,12 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); av[0] = ci->name; av[1] = buf; - av[2] = sstrdup("+b"); + av[2] = "+b"; av[3] = mask; ac = 4; } else { av[0] = ci->name; - av[1] = sstrdup("+b"); + av[1] = "+b"; av[2] = mask; ac = 3; } @@ -868,10 +863,6 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) anope_cmd_mode(ci->bi->nick, ci->name, "+b %s", mask); do_cmode(ci->bi->nick, ac, av); send_event(EVENT_BOT_BAN, 3, u->nick, ci->name, mask); - if (ircdcap->tsmode) - free(av[2]); - else - free(av[1]); } } @@ -912,7 +903,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, char *reason) { int ac; - char *av[4]; + const char *av[4]; const char *kav[4]; // seperate as not everything is constified XXX -- w00t char mask[BUFSIZE]; char buf[BUFSIZE]; @@ -947,12 +938,12 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); av[0] = ci->name; av[1] = buf; - av[2] = sstrdup("+b"); + av[2] = "+b"; av[3] = mask; ac = 4; } else { av[0] = ci->name; - av[1] = sstrdup("+b"); + av[1] = "+b"; av[2] = mask; ac = 3; } @@ -960,12 +951,6 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, anope_cmd_mode(ci->bi->nick, ci->name, "+b %s", mask); do_cmode(ci->bi->nick, ac, av); - /* We need to free our sstrdup'd "+b" -GD */ - if (ircdcap->tsmode) - free(av[2]); - else - free(av[1]); - kav[0] = ci->name; kav[1] = nick; @@ -1044,7 +1029,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode, char *nick) { - char *av[4]; + const char *av[4]; int ac; char buf[BUFSIZE]; User *u; @@ -1094,7 +1079,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode, * @param A string to be parsed for control and color codes * @return A string stripped of control and color codes */ -char *normalizeBuffer(char *buf) +char *normalizeBuffer(const char *buf) { char *newbuf; int i, len, j = 0; diff --git a/src/channels.c b/src/channels.c index 41909c1ba..e7ac7940d 100644 --- a/src/channels.c +++ b/src/channels.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -155,11 +155,12 @@ void chan_remove_user_status(Channel * chan, User * user, int16 status) /*************************************************************************/ -void chan_set_modes(const char *source, Channel * chan, int ac, char **av, +void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, int check) { int add = 1; - char *modes = av[0], mode; + const char *modes = av[0]; + char mode; CBMode *cbm; CMMode *cmm; CUMode *cum; @@ -167,7 +168,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av, BotInfo *bi; User *u, *user; int i, real_ac = ac; - char **real_av = av; + const char **real_av = av; if (debug) alog("debug: Changing modes for %s to %s", chan->name, @@ -181,7 +182,7 @@ void chan_set_modes(const char *source, Channel * chan, int ac, char **av, alog("debug: Removing instead of setting due to DEOPPED flag"); /* Swap adding and removing of the modes */ - for (s = av[0]; *s; s++) { + for (s = (char *)av[0]; *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX if (*s == '+') *s = '-'; else if (*s == '-') @@ -514,7 +515,7 @@ User *nc_on_chan(Channel * c, NickCore * nc) * av[0] = channels to join */ -void do_join(const char *source, int ac, char **av) +void do_join(const char *source, int ac, const char **av) { User *user; Channel *chan; @@ -538,7 +539,7 @@ void do_join(const char *source, int ac, char **av) return; } - t = av[0]; + t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX while (*(s = t)) { t = s + strcspn(s, ","); if (*t) @@ -660,7 +661,7 @@ void do_kick(const char *source, int ac, const char **av) * av[1] = reason (optional) */ -void do_part(const char *source, int ac, char **av) +void do_part(const char *source, int ac, const char **av) { User *user; char *s, *t; @@ -681,7 +682,7 @@ void do_part(const char *source, int ac, char **av) } return; } - t = av[0]; + t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX while (*(s = t)) { t = s + strcspn(s, ","); if (*t) @@ -753,14 +754,15 @@ void do_part(const char *source, int ac, char **av) */ -void do_sjoin(const char *source, int ac, char **av) +void do_sjoin(const char *source, int ac, const char **av) { Channel *c; User *user; Server *serv; struct c_userlist *cu; - char *s = NULL; - char *end, cubuf[7], *end2, *cumodes[6]; + const char *s = NULL; + char *end, cubuf[7], *end2; + const char *cumodes[6]; int is_sqlined = 0; int ts = 0; int is_created = 0; @@ -1025,7 +1027,7 @@ void do_sjoin(const char *source, int ac, char **av) alog("debug: SJOIN for nonexistent user %s on %s", s, av[1]); } - free(s); + free((char *)s); return; } @@ -1065,7 +1067,7 @@ void do_sjoin(const char *source, int ac, char **av) break; s = end + 1; } - free(s); + free((char *)s); } else if (ac == 2) { if (UseTS6 && ircd->ts6) { user = find_byuid(source); @@ -1112,12 +1114,12 @@ void do_sjoin(const char *source, int ac, char **av) /* Handle a channel MODE command. */ -void do_cmode(const char *source, int ac, char **av) +void do_cmode(const char *source, int ac, const char **av) { Channel *chan; ChannelInfo *ci = NULL; int i; - char *t; + const char *t; if (ircdcap->tsmode) { /* TSMODE for bahamut - leave this code out to break MODEs. -GD */ @@ -1178,7 +1180,7 @@ void do_cmode(const char *source, int ac, char **av) /* Handle a TOPIC command. */ -void do_topic(const char *source, int ac, char **av) +void do_topic(const char *source, int ac, const char **av) { Channel *c = findchan(av[0]); ChannelInfo *ci; @@ -1256,7 +1258,7 @@ void do_topic(const char *source, int ac, char **av) /**************************** Internal Calls *****************************/ /*************************************************************************/ -void add_ban(Channel * chan, char *mask) +void add_ban(Channel * chan, const char *mask) { Entry *ban; /* check for NULL values otherwise we will segfault */ @@ -1295,7 +1297,7 @@ void add_ban(Channel * chan, char *mask) /*************************************************************************/ -void add_exception(Channel * chan, char *mask) +void add_exception(Channel * chan, const char *mask) { Entry *exception; @@ -1320,7 +1322,7 @@ void add_exception(Channel * chan, char *mask) /*************************************************************************/ -void add_invite(Channel * chan, char *mask) +void add_invite(Channel * chan, const char *mask) { Entry *invite; @@ -1551,9 +1553,9 @@ void chan_adduser2(User * user, Channel * c) } /** - * We let the bot join even if it was an ignored user, as if we don't, + * We let the bot join even if it was an ignored user, as if we don't, * and the ignored user dosnt just leave, the bot will never - * make it into the channel, leaving the channel botless even for + * make it into the channel, leaving the channel botless even for * legit users - Rob **/ if (s_BotServ && c->ci && c->ci->bi) { @@ -1581,7 +1583,7 @@ void chan_adduser2(User * user, Channel * c) chan_adduser, but splitted to make it more efficient to use for SJOINs). */ -Channel *chan_create(char *chan, time_t ts) +Channel *chan_create(const char *chan, time_t ts) { Channel *c; Channel **list; @@ -1683,7 +1685,7 @@ void chan_delete(Channel * c) /*************************************************************************/ -void del_ban(Channel * chan, char *mask) +void del_ban(Channel * chan, const char *mask) { AutoKick *akick; Entry *ban; @@ -1708,7 +1710,7 @@ void del_ban(Channel * chan, char *mask) /*************************************************************************/ -void del_exception(Channel * chan, char *mask) +void del_exception(Channel * chan, const char *mask) { Entry *exception; @@ -1729,7 +1731,7 @@ void del_exception(Channel * chan, char *mask) /*************************************************************************/ -void del_invite(Channel * chan, char *mask) +void del_invite(Channel * chan, const char *mask) { Entry *invite; @@ -1786,7 +1788,7 @@ char *get_redirect(Channel * chan) /*************************************************************************/ -Channel *join_user_update(User * user, Channel * chan, char *name, +Channel *join_user_update(User * user, Channel * chan, const char *name, time_t chants) { struct u_chanlist *c; @@ -1812,7 +1814,7 @@ Channel *join_user_update(User * user, Channel * chan, char *name, /*************************************************************************/ -void set_flood(Channel * chan, char *value) +void set_flood(Channel * chan, const char *value) { if (chan->flood) free(chan->flood); @@ -1825,7 +1827,7 @@ void set_flood(Channel * chan, char *value) /*************************************************************************/ -void chan_set_key(Channel * chan, char *value) +void chan_set_key(Channel * chan, const char *value) { if (chan->key) free(chan->key); @@ -1838,7 +1840,7 @@ void chan_set_key(Channel * chan, char *value) /*************************************************************************/ -void set_limit(Channel * chan, char *value) +void set_limit(Channel * chan, const char *value) { chan->limit = value ? strtoul(value, NULL, 10) : 0; @@ -1849,7 +1851,7 @@ void set_limit(Channel * chan, char *value) /*************************************************************************/ -void set_redirect(Channel * chan, char *value) +void set_redirect(Channel * chan, const char *value) { if (chan->redirect) free(chan->redirect); @@ -1863,7 +1865,7 @@ void set_redirect(Channel * chan, char *value) void do_mass_mode(char *modes) { int ac; - char **av; + const char **av; Channel *c; char *myModes; @@ -2011,7 +2013,7 @@ Entry *entry_create(char *mask) * @param mask The mask to parse and add to the list * @return Pointer to newly added entry. NULL if it fails. */ -Entry *entry_add(EList * list, char *mask) +Entry *entry_add(EList * list, const char *mask) { Entry *e; char *hostmask; @@ -2275,7 +2277,7 @@ Entry *elist_match_user(EList * list, User * u) * @param mask The *!*@* mask to match * @return Returns the first matching entry, if none, NULL is returned. */ -Entry *elist_find_mask(EList * list, char *mask) +Entry *elist_find_mask(EList * list, const char *mask) { Entry *e; diff --git a/src/chanserv.c b/src/chanserv.c index 4c64dd64e..8e700077b 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -6,9 +6,9 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * $Id$ + * Based on the original code of Services by Andy Church. + * + * $Id$ * */ @@ -1368,14 +1368,14 @@ static void timeout_leave(Timeout * to) * not called). The channel TS must be given for a new channel. */ -int check_kick(User * user, char *chan, time_t chants) +int check_kick(User * user, const char *chan, time_t chants) { ChannelInfo *ci = cs_findchan(chan); Channel *c; AutoKick *akick; int i; NickCore *nc; - char *av[4]; + const char *av[4]; int ac; char buf[BUFSIZE]; char mask[BUFSIZE]; @@ -1479,22 +1479,17 @@ int check_kick(User * user, char *chan, time_t chants) snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); av[0] = chan; av[1] = buf; - av[2] = sstrdup("+b"); + av[2] = "+b"; av[3] = mask; ac = 4; } else { av[0] = chan; - av[1] = sstrdup("+b"); + av[1] = "+b"; av[2] = mask; ac = 3; } do_cmode(whosends(ci), ac, av); - - if (ircdcap->tsmode) - free(av[2]); - else - free(av[1]); } anope_cmd_mode(whosends(ci), chan, "+b %s", mask); @@ -1535,7 +1530,7 @@ void record_topic(const char *chan) /* Restore the topic in a channel when it's created, if we should. */ -void restore_topic(char *chan) +void restore_topic(const char *chan) { Channel *c = findchan(chan); ChannelInfo *ci; @@ -2282,7 +2277,7 @@ char *cs_get_redirect(ChannelInfo * ci) /*************************************************************************/ -void cs_set_flood(ChannelInfo * ci, char *value) +void cs_set_flood(ChannelInfo * ci, const char *value) { if (!ci) { return; @@ -2302,7 +2297,7 @@ void cs_set_flood(ChannelInfo * ci, char *value) /*************************************************************************/ -void cs_set_key(ChannelInfo * ci, char *value) +void cs_set_key(ChannelInfo * ci, const char *value) { if (!ci) { return; @@ -2322,7 +2317,7 @@ void cs_set_key(ChannelInfo * ci, char *value) /*************************************************************************/ -void cs_set_limit(ChannelInfo * ci, char *value) +void cs_set_limit(ChannelInfo * ci, const char *value) { if (!ci) { return; @@ -2336,7 +2331,7 @@ void cs_set_limit(ChannelInfo * ci, char *value) /*************************************************************************/ -void cs_set_redirect(ChannelInfo * ci, char *value) +void cs_set_redirect(ChannelInfo * ci, const char *value) { if (!ci) { return; @@ -2419,7 +2414,7 @@ const char *get_xop_level(int level) /* Is the mask stuck? */ -AutoKick *is_stuck(ChannelInfo * ci, char *mask) +AutoKick *is_stuck(ChannelInfo * ci, const char *mask) { int i; AutoKick *akick; @@ -2449,7 +2444,7 @@ AutoKick *is_stuck(ChannelInfo * ci, char *mask) void stick_mask(ChannelInfo * ci, AutoKick * akick) { - char *av[2]; + const char *av[2]; Entry *ban; if (!ci) { @@ -2473,11 +2468,10 @@ void stick_mask(ChannelInfo * ci, AutoKick * akick) } /* Falling there means set the ban */ - av[0] = sstrdup("+b"); + av[0] = "+b"; av[1] = akick->u.mask; anope_cmd_mode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); chan_set_modes(s_ChanServ, ci->c, 2, av, 1); - free(av[0]); } /* Ban the stuck mask in a safe manner. */ @@ -2485,7 +2479,7 @@ void stick_mask(ChannelInfo * ci, AutoKick * akick) void stick_all(ChannelInfo * ci) { int i; - char *av[2]; + const char *av[2]; AutoKick *akick; if (!ci) { @@ -2497,10 +2491,9 @@ void stick_all(ChannelInfo * ci) || !(akick->flags & AK_STUCK)) continue; - av[0] = sstrdup("+b"); + av[0] = "+b"; av[1] = akick->u.mask; anope_cmd_mode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); chan_set_modes(s_ChanServ, ci->c, 2, av, 1); - free(av[0]); } } diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index 509790c0e..3031d461e 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -97,7 +97,7 @@ int do_ban(User * u) next = uc->next; if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) && check_access(u, ci, CA_BANME)) { - char *av[3]; + const char *av[3]; char mask[BUFSIZE]; /* @@ -115,13 +115,12 @@ int do_ban(User * u) continue; } - av[0] = sstrdup("+b"); + av[0] = "+b"; get_idealban(ci, u, mask, sizeof(mask)); av[1] = mask; anope_cmd_mode(whosends(ci), uc->chan->name, "+b %s", av[1]); chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); - free(av[0]); if ((ci->flags & CI_SIGNKICK) || ((ci->flags & CI_SIGNKICK_LEVEL) @@ -170,15 +169,14 @@ int do_ban(User * u) } else if (ircd->protectedumode && is_protected(u2)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else { - char *av[3]; + const char *av[3]; char mask[BUFSIZE]; - av[0] = sstrdup("+b"); + av[0] = "+b"; get_idealban(ci, u2, mask, sizeof(mask)); av[1] = mask; anope_cmd_mode(whosends(ci), c->name, "+b %s", av[1]); chan_set_modes(s_ChanServ, c, 2, av, 1); - free(av[0]); /* We still allow host banning while not allowing to kick */ if (!is_on_chan(c, u2)) diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index 8d3556428..4d7cb56da 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -83,92 +83,82 @@ int do_clear(User * u) } else if (!u || !check_access(u, ci, CA_CLEAR)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); } else if (stricmp(what, "bans") == 0) { - char *av[2]; + const char *av[2]; Entry *ban, *next; if (c->bans && c->bans->count) { for (ban = c->bans->entries; ban; ban = next) { next = ban->next; - av[0] = sstrdup("-b"); - av[1] = sstrdup(ban->mask); + av[0] = "-b"; + av[1] = ban->mask; anope_cmd_mode(whosends(ci), chan, "-b %s", ban->mask); chan_set_modes(whosends(ci), c, 2, av, 0); - free(av[0]); - free(av[1]); } } notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan); } else if (ircd->except && stricmp(what, "excepts") == 0) { - char *av[2]; + const char *av[2]; Entry *except, *next; if (c->excepts && c->excepts->count) { for (except = c->excepts->entries; except; except = next) { next = except->next; - av[0] = sstrdup("-e"); - av[1] = sstrdup(except->mask); + av[0] = "-e"; + av[1] = except->mask; anope_cmd_mode(whosends(ci), chan, "-e %s", except->mask); chan_set_modes(whosends(ci), c, 2, av, 0); - free(av[0]); - free(av[1]); } } notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); } else if (ircd->invitemode && stricmp(what, "invites") == 0) { - char *av[2]; + const char *av[2]; Entry *invite, *next; if (c->invites && c->invites->count) { for (invite = c->invites->entries; invite; invite = next) { next = invite->next; - av[0] = sstrdup("-I"); - av[1] = sstrdup(invite->mask); + av[0] = "-I"; + av[1] = invite->mask; anope_cmd_mode(whosends(ci), chan, "-I %s", invite->mask); chan_set_modes(whosends(ci), c, 2, av, 0); - free(av[0]); - free(av[1]); } } notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan); } else if (stricmp(what, "modes") == 0) { - char *argv[2]; + const char *argv[2]; if (c->mode) { /* Clear modes the bulk of the modes */ anope_cmd_mode(whosends(ci), c->name, "%s", ircd->modestoremove); - argv[0] = sstrdup(ircd->modestoremove); + argv[0] = ircd->modestoremove; chan_set_modes(whosends(ci), c, 1, argv, 0); - free(argv[0]); /* to prevent the internals from complaining send -k, -L, -f by themselves if we need to send them - TSL */ if (c->key) { anope_cmd_mode(whosends(ci), c->name, "-k %s", c->key); - argv[0] = sstrdup("-k"); + argv[0] = "-k"; argv[1] = c->key; chan_set_modes(whosends(ci), c, 2, argv, 0); - free(argv[0]); } if (ircd->Lmode && c->redirect) { anope_cmd_mode(whosends(ci), c->name, "-L %s", c->redirect); - argv[0] = sstrdup("-L"); + argv[0] = "-L"; argv[1] = c->redirect; chan_set_modes(whosends(ci), c, 2, argv, 0); - free(argv[0]); } if (ircd->fmode && c->flood) { if (flood_mode_char_remove) { anope_cmd_mode(whosends(ci), c->name, "%s %s", flood_mode_char_remove, c->flood); - argv[0] = sstrdup(flood_mode_char_remove); + argv[0] = flood_mode_char_remove; argv[1] = c->flood; chan_set_modes(whosends(ci), c, 2, argv, 0); - free(argv[0]); } else { if (debug) { alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes"); @@ -180,7 +170,7 @@ int do_clear(User * u) notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan); } else if (stricmp(what, "ops") == 0) { - char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ + const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ int ac, isop, isadmin, isown, count, i; char buf[BUFSIZE], tmp[BUFSIZE], tmp2[BUFSIZE]; struct c_userlist *cu, *next; @@ -237,10 +227,10 @@ int do_clear(User * u) if (!isop && !isadmin && !isown) continue; - snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? + snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : "")); /* We need to send the IRCd a nick for every mode.. - Viper */ - snprintf(tmp2, BUFSIZE, "%s %s %s", (isop ? cu->user->nick : ""), + snprintf(tmp2, BUFSIZE, "%s %s %s", (isop ? cu->user->nick : ""), (isadmin ? cu->user->nick : ""), (isown ? cu->user->nick : "")); if (ircdcap->tsmode) { @@ -268,7 +258,7 @@ int do_clear(User * u) } notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan); } else if (ircd->halfop && stricmp(what, "hops") == 0) { - char *av[4]; + const char *av[4]; int ac; char buf[BUFSIZE]; struct c_userlist *cu, *next; @@ -280,15 +270,15 @@ int do_clear(User * u) if (ircdcap->tsmode) { snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = sstrdup(chan); + av[0] = chan; av[1] = buf; - av[2] = sstrdup("-h"); - av[3] = sstrdup(cu->user->nick); + av[2] = "-h"; + av[3] = cu->user->nick; ac = 4; } else { - av[0] = sstrdup(chan); - av[1] = sstrdup("-h"); - av[2] = sstrdup(cu->user->nick); + av[0] = chan; + av[1] = "-h"; + av[2] = cu->user->nick; ac = 3; } @@ -309,20 +299,10 @@ int do_clear(User * u) av[2]); } do_cmode(s_ChanServ, ac, av); - - if (ircdcap->tsmode) { - free(av[3]); - free(av[2]); - free(av[0]); - } else { - free(av[2]); - free(av[1]); - free(av[0]); - } } notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan); } else if (stricmp(what, "voices") == 0) { - char *av[4]; + const char *av[4]; int ac; char buf[BUFSIZE]; struct c_userlist *cu, *next; @@ -334,15 +314,15 @@ int do_clear(User * u) if (ircdcap->tsmode) { snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = sstrdup(chan); + av[0] = chan; av[1] = buf; - av[2] = sstrdup("-v"); - av[3] = sstrdup(cu->user->nick); + av[2] = "-v"; + av[3] = cu->user->nick; ac = 4; } else { - av[0] = sstrdup(chan); - av[1] = sstrdup("-v"); - av[2] = sstrdup(cu->user->nick); + av[0] = chan; + av[1] = "-v"; + av[2] = cu->user->nick; ac = 3; } @@ -364,16 +344,6 @@ int do_clear(User * u) } } do_cmode(s_ChanServ, ac, av); - - if (ircdcap->tsmode) { - free(av[3]); - free(av[2]); - free(av[0]); - } else { - free(av[2]); - free(av[1]); - free(av[0]); - } } notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan); } else if (stricmp(what, "users") == 0) { diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index 824764941..7d3800ba4 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -207,7 +207,7 @@ int do_deprotect(User * u) int do_owner(User * u) { - char *av[2]; + const char *av[2]; char *chan = strtok(NULL, " "); Channel *c; @@ -219,7 +219,7 @@ int do_owner(User * u) } if (!chan) { - av[0] = sstrdup(ircd->ownerset); + av[0] = ircd->ownerset; av[1] = u->nick; /* Sets the mode to the user on every channels he is on. */ @@ -233,7 +233,6 @@ int do_owner(User * u) } } - free(av[0]); return MOD_CONT; } @@ -251,10 +250,9 @@ int do_owner(User * u) anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerset, u->nick); - av[0] = sstrdup(ircd->ownerset); + av[0] = ircd->ownerset; av[1] = u->nick; chan_set_modes(s_ChanServ, c, 2, av, 1); - free(av[0]); } return MOD_CONT; } @@ -263,7 +261,7 @@ int do_owner(User * u) int do_deowner(User * u) { - char *av[2]; + const char *av[2]; char *chan = strtok(NULL, " "); Channel *c; @@ -275,7 +273,7 @@ int do_deowner(User * u) } if (!chan) { - av[0] = sstrdup(ircd->ownerunset); + av[0] = ircd->ownerunset; av[1] = u->nick; /* Sets the mode to the user on every channels he is on. */ @@ -289,7 +287,6 @@ int do_deowner(User * u) } } - free(av[0]); return MOD_CONT; } @@ -307,10 +304,9 @@ int do_deowner(User * u) anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerunset, u->nick); - av[0] = sstrdup(ircd->ownerunset); + av[0] = ircd->ownerunset; av[1] = u->nick; chan_set_modes(s_ChanServ, c, 2, av, 1); - free(av[0]); } return MOD_CONT; } @@ -319,7 +315,7 @@ int do_deowner(User * u) int do_util(User * u, CSModeUtil * util) { - char *av[2]; + const char *av[2]; char *chan = strtok(NULL, " "); char *nick = strtok(NULL, " "); diff --git a/src/core/os_clearmodes.c b/src/core/os_clearmodes.c index d6a896166..aee4ebd34 100644 --- a/src/core/os_clearmodes.c +++ b/src/core/os_clearmodes.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -70,7 +70,7 @@ void myOperServHelp(User * u) int do_clearmodes(User * u) { char *s; - char *argv[2]; + const char *argv[2]; char *chan = strtok(NULL, " "); Channel *c; int all = 0; @@ -111,22 +111,20 @@ int do_clearmodes(User * u) if (!chan_has_user_status(c, cu->user, CUS_OP)) { continue; } - argv[0] = sstrdup("-o"); + argv[0] = "-o"; argv[1] = cu->user->nick; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } else { for (cu = c->users; cu; cu = next) { next = cu->next; if (!chan_has_user_status(c, cu->user, CUS_OP)) continue; - argv[0] = sstrdup("-o"); + argv[0] = "-o"; argv[1] = cu->user->nick; anope_cmd_mode(s_OperServ, c->name, "-o %s", cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } @@ -137,10 +135,9 @@ int do_clearmodes(User * u) if (!chan_has_user_status(c, cu->user, CUS_VOICE)) { continue; } - argv[0] = sstrdup("-v"); + argv[0] = "-v"; argv[1] = cu->user->nick; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } else { /* Clear mode +v */ @@ -148,12 +145,11 @@ int do_clearmodes(User * u) next = cu->next; if (!chan_has_user_status(c, cu->user, CUS_VOICE)) continue; - argv[0] = sstrdup("-v"); + argv[0] = "-v"; argv[1] = cu->user->nick; anope_cmd_mode(s_OperServ, c->name, "-v %s", cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } @@ -165,22 +161,20 @@ int do_clearmodes(User * u) if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { continue; } - argv[0] = sstrdup("-h"); + argv[0] = "-h"; argv[1] = cu->user->nick; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } else { for (cu = c->users; cu; cu = next) { next = cu->next; if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) continue; - argv[0] = sstrdup("-h"); + argv[0] = "-h"; argv[1] = cu->user->nick; anope_cmd_mode(s_OperServ, c->name, "-h %s", cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } /* Clear mode Owners */ @@ -191,22 +185,20 @@ int do_clearmodes(User * u) if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { continue; } - argv[0] = sstrdup(ircd->ownerunset); + argv[0] = ircd->ownerunset; argv[1] = cu->user->nick; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } else { for (cu = c->users; cu; cu = next) { next = cu->next; if (!chan_has_user_status(c, cu->user, CUS_OWNER)) continue; - argv[0] = sstrdup(ircd->ownerunset); + argv[0] = ircd->ownerunset; argv[1] = cu->user->nick; anope_cmd_mode(s_OperServ, c->name, "%s %s", ircd->ownerunset, cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } /* Clear mode protected or admins */ @@ -218,22 +210,20 @@ int do_clearmodes(User * u) if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { continue; } - argv[0] = sstrdup(ircd->adminunset); + argv[0] = ircd->adminunset; argv[1] = cu->user->nick; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } else { for (cu = c->users; cu; cu = next) { next = cu->next; if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) continue; - argv[0] = sstrdup(ircd->adminunset); + argv[0] = ircd->adminunset; argv[1] = cu->user->nick; anope_cmd_mode(s_OperServ, c->name, "%s %s", ircd->adminunset, cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } @@ -243,34 +233,30 @@ int do_clearmodes(User * u) if (c->mode) { /* Clear modes the bulk of the modes */ anope_cmd_mode(s_OperServ, c->name, "%s", ircd->modestoremove); - argv[0] = sstrdup(ircd->modestoremove); + argv[0] = ircd->modestoremove; chan_set_modes(s_OperServ, c, 1, argv, 0); - free(argv[0]); /* to prevent the internals from complaining send -k, -L, -f by themselves if we need to send them - TSL */ if (c->key) { anope_cmd_mode(s_OperServ, c->name, "-k %s", c->key); - argv[0] = sstrdup("-k"); + argv[0] = "-k"; argv[1] = c->key; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } if (ircd->Lmode && c->redirect) { anope_cmd_mode(s_OperServ, c->name, "-L %s", c->redirect); - argv[0] = sstrdup("-L"); + argv[0] = "-L"; argv[1] = c->redirect; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } if (ircd->fmode && c->flood) { if (flood_mode_char_remove) { anope_cmd_mode(s_OperServ, c->name, "%s %s", flood_mode_char_remove, c->flood); - argv[0] = sstrdup(flood_mode_char_remove); + argv[0] = flood_mode_char_remove; argv[1] = c->flood; chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } else { if (debug) { alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes"); @@ -283,12 +269,10 @@ int do_clearmodes(User * u) if (c->bans && c->bans->count) { for (entry = c->bans->entries; entry; entry = nexte) { nexte = entry->next; - argv[0] = sstrdup("-b"); - argv[1] = sstrdup(entry->mask); + argv[0] = "-b"; + argv[1] = entry->mask; anope_cmd_mode(s_OperServ, c->name, "-b %s", entry->mask); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); - free(argv[1]); } } @@ -296,12 +280,10 @@ int do_clearmodes(User * u) if (ircd->except && c->excepts && c->excepts->count) { for (entry = c->excepts->entries; entry; entry = nexte) { nexte = entry->next; - argv[0] = sstrdup("-e"); - argv[1] = sstrdup(entry->mask); + argv[0] = "-e"; + argv[1] = entry->mask; anope_cmd_mode(s_OperServ, c->name, "-e %s", entry->mask); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); - free(argv[1]); } } @@ -309,12 +291,10 @@ int do_clearmodes(User * u) if (ircd->invitemode && c->invites && c->invites->count) { for (entry = c->invites->entries; entry; entry = nexte) { nexte = entry->next; - argv[0] = sstrdup("-I"); - argv[1] = sstrdup(entry->mask); + argv[0] = "-I"; + argv[1] = entry->mask; anope_cmd_mode(s_OperServ, c->name, "-I %s", entry->mask); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); - free(argv[1]); } } } diff --git a/src/core/os_mode.c b/src/core/os_mode.c index c3d5c6624..53729b2ff 100644 --- a/src/core/os_mode.c +++ b/src/core/os_mode.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * $Id$ * */ @@ -69,7 +69,7 @@ void myOperServHelp(User * u) int do_os_mode(User * u) { int ac; - char **av; + const char **av; char *chan = strtok(NULL, " "), *modes = strtok(NULL, ""); Channel *c; diff --git a/src/events.c b/src/events.c index 5a3ef8450..ff20f8ced 100644 --- a/src/events.c +++ b/src/events.c @@ -6,8 +6,8 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * + * Based on the original code of Services by Andy Church. + * * */ @@ -89,7 +89,7 @@ void event_message_process(char *eventbuf) char buf[512]; /* Longest legal IRC command line */ char *s; int ac; /* Parameters for the command */ - char **av; + const char **av; EvtMessage *evm; /* zero out the buffers before we do much else */ @@ -178,7 +178,7 @@ void event_process_hook(const char *name, int argc, char **argv) * Displays a message list for a given message. * Again this is of little use other than debugging. * @param m the message to display - * @return 0 is returned and has no meaning + * @return 0 is returned and has no meaning */ int displayEventMessage(EvtMessage * evm) { @@ -196,7 +196,7 @@ int displayEventMessage(EvtMessage * evm) * Displays a message list for a given message. * Again this is of little use other than debugging. * @param m the message to display - * @return 0 is returned and has no meaning + * @return 0 is returned and has no meaning */ int displayEventHook(EvtHook * evh) { @@ -271,8 +271,8 @@ int displayEvtMessageFromHash(char *name) * @return a new Message object **/ EvtMessage *createEventHandler(char *name, - int (*func) (char *source, int ac, - char **av)) + int (*func) (const char *source, int ac, + const char **av)) { EvtMessage *evm = NULL; if (!func) { @@ -310,8 +310,8 @@ EvtHook *createEventHook(char *name, int (*func) (int argc, char **argv)) return evh; } -/** - * find a message in the given table. +/** + * find a message in the given table. * Looks up the message in the MessageHash given * @param MessageHash the message table to search for this command, will almost always be IRCD * @param name the name of the command were looking for @@ -335,8 +335,8 @@ EvtMessage *findEventHandler(EvtMessageHash * msgEvtTable[], return NULL; } -/** - * find a message in the given table. +/** + * find a message in the given table. * Looks up the message in the MessageHash given * @param MessageHash the message table to search for this command, will almost always be IRCD * @param name the name of the command were looking for diff --git a/src/messages.c b/src/messages.c index 3176040fc..eca2d07ca 100644 --- a/src/messages.c +++ b/src/messages.c @@ -18,7 +18,7 @@ /*************************************************************************/ -int m_nickcoll(char *user) +int m_nickcoll(const char *user) { introduce_user(user); return MOD_CONT; @@ -26,7 +26,7 @@ int m_nickcoll(char *user) /*************************************************************************/ -int m_away(char *source, char *msg) +int m_away(const char *source, const char *msg) { User *u; @@ -39,7 +39,7 @@ int m_away(char *source, char *msg) /*************************************************************************/ -int m_kill(char *nick, char *msg) +int m_kill(const char *nick, const char *msg) { BotInfo *bi; @@ -58,7 +58,7 @@ int m_kill(char *nick, char *msg) /*************************************************************************/ -int m_time(char *source, int ac, char **av) +int m_time(const char *source, int ac, const char **av) { time_t t; struct tm *tm; @@ -77,7 +77,7 @@ int m_time(char *source, int ac, char **av) /*************************************************************************/ -int m_motd(char *source) +int m_motd(const char *source) { FILE *f; char buf[BUFSIZE]; @@ -103,7 +103,7 @@ int m_motd(char *source) /*************************************************************************/ -int m_privmsg(char *source, char *receiver, char *msg) +int m_privmsg(const char *source, const char *receiver, const char *msg) { char *s; time_t starttime, stoptime; /* When processing started and finished */ @@ -129,7 +129,7 @@ int m_privmsg(char *source, char *receiver, char *msg) if (s_BotServ && (ci = cs_findchan(receiver))) { /* Some paranoia checks */ if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) { - botchanmsgs(u, ci, msg); + botchanmsgs(u, ci, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } } } else { @@ -171,42 +171,42 @@ int m_privmsg(char *source, char *receiver, char *msg) s_OperServ, u->nick, u->username, u->host); } else { - operserv(u, msg); + operserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } } else if ((stricmp(receiver, s_NickServ) == 0) || (s_NickServAlias && (stricmp(receiver, s_NickServAlias) == 0))) { - nickserv(u, msg); + nickserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if ((stricmp(receiver, s_ChanServ) == 0) || (s_ChanServAlias && (stricmp(receiver, s_ChanServAlias) == 0))) { if (!is_oper(u) && CSOpersOnly) notice_lang(s_ChanServ, u, ACCESS_DENIED); else - chanserv(u, msg); + chanserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if ((stricmp(receiver, s_MemoServ) == 0) || (s_MemoServAlias && (stricmp(receiver, s_MemoServAlias) == 0))) { - memoserv(u, msg); + memoserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_HostServ && ((stricmp(receiver, s_HostServ) == 0) || (s_HostServAlias && (stricmp(receiver, s_HostServAlias) == 0)))) { - hostserv(u, msg); + hostserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_HelpServ && ((stricmp(receiver, s_HelpServ) == 0) || (s_HelpServAlias && (stricmp(receiver, s_HelpServAlias) == 0)))) { - helpserv(u, msg); + helpserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_BotServ && ((stricmp(receiver, s_BotServ) == 0) || (s_BotServAlias && (stricmp(receiver, s_BotServAlias) == 0)))) { - botserv(u, msg); + botserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } else if (s_BotServ && (bi = findbot(receiver))) { - botmsgs(u, bi, msg); + botmsgs(u, bi, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX } /* Add to ignore list if the command took a significant amount of time. */ @@ -221,7 +221,7 @@ int m_privmsg(char *source, char *receiver, char *msg) /*************************************************************************/ -int m_stats(char *source, int ac, char **av) +int m_stats(const char *source, int ac, const char **av) { int i; User *u; @@ -309,7 +309,7 @@ int m_stats(char *source, int ac, char **av) /*************************************************************************/ -int m_version(char *source, int ac, char **av) +int m_version(const char *source, int ac, const char **av) { if (source) { anope_cmd_351(source); @@ -320,7 +320,7 @@ int m_version(char *source, int ac, char **av) /*************************************************************************/ -int m_whois(char *source, char *who) +int m_whois(const char *source, const char *who) { BotInfo *bi; NickAlias *na; @@ -384,7 +384,7 @@ int m_whois(char *source, char *who) } /* NULL route messages */ -int anope_event_null(char *source, int ac, char **av) +int anope_event_null(const char *source, int ac, const char **av) { return MOD_CONT; } diff --git a/src/misc.c b/src/misc.c index 24db06728..79182eafb 100644 --- a/src/misc.c +++ b/src/misc.c @@ -7,9 +7,9 @@ * Please read COPYING and README for further details. * * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * $Id$ + * Based on the original code of Services by Andy Church. + * + * $Id$ * */ @@ -300,7 +300,7 @@ int match_wild_nocase(const char *pattern, const char *str) * The callback should be of type range_callback_t, which is defined as: * int (*range_callback_t)(User *u, int num, va_list args) * @param numstr - * @param count_ret + * @param count_ret * @param callback Call back function * @param u User Struct * @param ... various args @@ -787,7 +787,7 @@ char *myStrSubString(const char *src, int start, int end) /*************************************************************************/ -void protocol_debug(char *source, char *cmd, int argc, char **argv) +void protocol_debug(char *source, char *cmd, int argc, const char **argv) { int i; @@ -851,7 +851,7 @@ void doCleanBuffer(char *str) * @param killer whom is doing the killing * @return void */ -void EnforceQlinedNick(char *nick, char *killer) +void EnforceQlinedNick(const char *nick, const char *killer) { User *u2; @@ -871,7 +871,7 @@ void EnforceQlinedNick(char *nick, char *killer) * @param int Check if botserv bots * @return int */ -int nickIsServices(char *tempnick, int bot) +int nickIsServices(const char *tempnick, int bot) { int found = 0; char *s, *nick; @@ -1106,7 +1106,7 @@ u_int32_t getrandom32(void) /** * Determine if we need to send the TOKEN - * @param token1 + * @param token1 * @param token2 * @return token to send */ @@ -1201,7 +1201,7 @@ char *str_signed(unsigned char *str) /** * Strip the mode prefix from the given string. - * Useful for using the modes stored in things like ircd->ownerset etc.. + * Useful for using the modes stored in things like ircd->ownerset etc.. **/ char *stripModePrefix(const char *str) diff --git a/src/modules.c b/src/modules.c index 27cef700f..24e4d7b13 100644 --- a/src/modules.c +++ b/src/modules.c @@ -118,7 +118,7 @@ void modules_init(void) #endif } -/** +/** * Load up a list of core modules from the conf. * @param number The number of modules to load * @param list The list of modules to load @@ -148,12 +148,12 @@ void modules_core_init(int number, char **list) } } /** - * + * **/ int encryption_module_init(void) { int ret = 0; Module *m; - + m = createModule(EncModule); mod_current_module = m; mod_current_user = NULL; @@ -175,7 +175,7 @@ int protocol_module_init(void) { int ret = 0; Module *m; - + m = createModule(IRCDModule); mod_current_module = m; mod_current_user = NULL; @@ -184,7 +184,7 @@ int protocol_module_init(void) moduleSetType(PROTOCOL); alog("status: [%d][%s]", ret, ModuleGetErrStr(ret)); mod_current_module = NULL; - + if (ret == MOD_ERR_OK) { /* This is really NOT the correct place to do config checks, but * as we only have the ircd struct filled here, we have to over @@ -194,12 +194,12 @@ int protocol_module_init(void) alog("Anope does not support TOKENS for this ircd setting; unsetting UseToken"); UseTokens = 0; } - + if (UseTS6 && !(ircd->ts6)) { alog("Chosen IRCd does not support TS6, unsetting UseTS6"); UseTS6 = 0; } - + /* We can assume the ircd supports TS6 here */ if (UseTS6 && !Numeric) { alog("UseTS6 requires the setting of Numeric to be enabled."); @@ -208,7 +208,7 @@ int protocol_module_init(void) } else { destroyModule(m); } - + return ret; } @@ -262,7 +262,7 @@ void modules_unload_all(bool fini, bool unload_proto) int idx; ModuleHash *mh, *next; void (*func) (void); - + for (idx = 0; idx < MAX_CMD_HASH; idx++) { mh = MODULE_HASH[idx]; while (mh) { @@ -276,12 +276,12 @@ void modules_unload_all(bool fini, bool unload_proto) func(); /* exec AnopeFini */ mod_current_module_name = NULL; } - + if (prepForUnload(mh->m) != MOD_ERR_OK) { mh = next; continue; } - + if ((ano_modclose(mh->m->handle)) != 0) alog(ano_moderr()); else @@ -499,10 +499,10 @@ int encryptionModuleLoaded() return 0; } -/** +/** * Copy the module from the modules folder to the runtime folder. * This will prevent module updates while the modules is loaded from - * triggering a segfault, as the actaul file in use will be in the + * triggering a segfault, as the actaul file in use will be in the * runtime folder. * @param name the name of the module to copy * @param output the destination to copy the module to @@ -530,10 +530,10 @@ int moduleCopyFile(char *name, char *output) if (!mktemp(output)) return MOD_ERR_FILE_IO; #endif - + if (debug) alog("Runtime module location: %s", output); - + /* Linux/UNIX should ignore the b param, why do we still have seperate * calls for it here? -GD */ @@ -590,7 +590,7 @@ int loadModule(Module * m, User * u) if ((m2 = findModule(m->name)) != NULL) { return MOD_ERR_EXISTS; } - + /* Generate the filename for the temporary copy of the module */ strncpy(buf, MODULE_PATH, 4095); /* Get full path with module extension */ len = strlen(buf); @@ -754,7 +754,7 @@ int unloadModule(Module * m, User * u) } /** - * Module setType() + * Module setType() * Lets the module set a type, CORE,PROTOCOL,3RD etc.. **/ void moduleSetType(MODType type) @@ -767,7 +767,7 @@ void moduleSetType(MODType type) /** * Prepare a module to be unloaded. - * Remove all commands and messages this module is providing, and delete + * Remove all commands and messages this module is providing, and delete * any callbacks which are still pending. * @param m the module to prepare for unload * @return MOD_ERR_OK on success @@ -1197,7 +1197,7 @@ int displayMessageFromHash(char *name) * Displays a message list for a given message. * Again this is of little use other than debugging. * @param m the message to display - * @return 0 is returned and has no meaning + * @return 0 is returned and has no meaning */ int displayMessage(Message * m) { @@ -1391,7 +1391,7 @@ Command *findCommand(CommandHash * cmdTable[], const char *name) * @return a new Message object **/ Message *createMessage(const char *name, - int (*func) (char *source, int ac, char **av)) + int (*func) (const char *source, int ac, const char **av)) { Message *m = NULL; if (!name || !func) { @@ -1407,8 +1407,8 @@ Message *createMessage(const char *name, return m; } -/** - * find a message in the given table. +/** + * find a message in the given table. * Looks up the message in the MessageHash given * @param MessageHash the message table to search for this command, will almost always be IRCD * @param name the name of the command were looking for @@ -1447,7 +1447,7 @@ Message *findMessage(MessageHash * msgTable[], const char *name) * Add a message to the MessageHash. * @param msgTable the MessageHash we want to add a message to * @param m the Message we want to add - * @param pos the position we want to add the message to, E.G. MOD_HEAD, MOD_TAIL, MOD_UNIQUE + * @param pos the position we want