From da8cd3de6f2144016e9eeba741a138c6ac2663a7 Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Sun, 20 May 2007 17:48:44 +0200 Subject: [PATCH] Get rid of remaining tabs and replace them with spaces. --- src/chanserv.c | 1492 +++++++++++++++++++++---------------------- src/chanserv.h | 86 +-- src/checkdb.c | 8 +- src/common.h | 14 +- src/compat.c | 130 ++-- src/dict-splay.c | 104 +-- src/getopt.h | 28 +- src/gline.c | 12 +- src/global.c | 292 ++++----- src/global.h | 16 +- src/globtest.c | 30 +- src/hash.c | 210 +++--- src/hash.h | 78 +-- src/heap.c | 38 +- src/helpfile.c | 142 ++-- src/helpfile.h | 4 +- src/ioset.c | 48 +- src/log.c | 14 +- src/main-common.c | 222 +++---- src/main-win32.c | 4 +- src/main.c | 100 +-- src/md5.c | 6 +- src/mod-blacklist.c | 2 +- src/mod-helpserv.c | 14 +- src/mod-sockcheck.c | 306 ++++----- src/modcmd.c | 8 +- src/nickserv.c | 496 +++++++------- src/nickserv.h | 4 +- src/opserv.c | 828 ++++++++++++------------ src/policer.c | 8 +- src/proto-bahamut.c | 132 ++-- src/proto-common.c | 32 +- src/proto-p10.c | 112 ++-- src/proto.h | 44 +- src/recdb.h | 8 +- src/saxdb.c | 2 +- src/timeq.c | 14 +- src/tools.c | 112 ++-- 38 files changed, 2600 insertions(+), 2600 deletions(-) diff --git a/src/chanserv.c b/src/chanserv.c index 4859deb..4f391c5 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -26,94 +26,94 @@ #include "saxdb.h" #include "timeq.h" -#define CHANSERV_CONF_NAME "services/chanserv" +#define CHANSERV_CONF_NAME "services/chanserv" /* ChanServ options */ -#define KEY_SUPPORT_CHANNEL "support_channel" -#define KEY_SUPPORT_CHANNEL_MODES "support_channel_modes" -#define KEY_DB_BACKUP_FREQ "db_backup_freq" -#define KEY_INFO_DELAY "info_delay" -#define KEY_MAX_GREETLEN "max_greetlen" -#define KEY_ADJUST_THRESHOLD "adjust_threshold" -#define KEY_ADJUST_DELAY "adjust_delay" -#define KEY_CHAN_EXPIRE_FREQ "chan_expire_freq" -#define KEY_CHAN_EXPIRE_DELAY "chan_expire_delay" -#define KEY_DNR_EXPIRE_FREQ "dnr_expire_freq" -#define KEY_MAX_CHAN_USERS "max_chan_users" -#define KEY_MAX_CHAN_BANS "max_chan_bans" -#define KEY_NICK "nick" -#define KEY_OLD_CHANSERV_NAME "old_chanserv_name" -#define KEY_8BALL_RESPONSES "8ball" -#define KEY_OLD_BAN_NAMES "old_ban_names" -#define KEY_REFRESH_PERIOD "refresh_period" +#define KEY_SUPPORT_CHANNEL "support_channel" +#define KEY_SUPPORT_CHANNEL_MODES "support_channel_modes" +#define KEY_DB_BACKUP_FREQ "db_backup_freq" +#define KEY_INFO_DELAY "info_delay" +#define KEY_MAX_GREETLEN "max_greetlen" +#define KEY_ADJUST_THRESHOLD "adjust_threshold" +#define KEY_ADJUST_DELAY "adjust_delay" +#define KEY_CHAN_EXPIRE_FREQ "chan_expire_freq" +#define KEY_CHAN_EXPIRE_DELAY "chan_expire_delay" +#define KEY_DNR_EXPIRE_FREQ "dnr_expire_freq" +#define KEY_MAX_CHAN_USERS "max_chan_users" +#define KEY_MAX_CHAN_BANS "max_chan_bans" +#define KEY_NICK "nick" +#define KEY_OLD_CHANSERV_NAME "old_chanserv_name" +#define KEY_8BALL_RESPONSES "8ball" +#define KEY_OLD_BAN_NAMES "old_ban_names" +#define KEY_REFRESH_PERIOD "refresh_period" #define KEY_CTCP_SHORT_BAN_DURATION "ctcp_short_ban_duration" #define KEY_CTCP_LONG_BAN_DURATION "ctcp_long_ban_duration" #define KEY_MAX_OWNED "max_owned" #define KEY_IRC_OPERATOR_EPITHET "irc_operator_epithet" #define KEY_NETWORK_HELPER_EPITHET "network_helper_epithet" #define KEY_SUPPORT_HELPER_EPITHET "support_helper_epithet" -#define KEY_NODELETE_LEVEL "nodelete_level" -#define KEY_MAX_USERINFO_LENGTH "max_userinfo_length" -#define KEY_GIVEOWNERSHIP_PERIOD "giveownership_timeout" +#define KEY_NODELETE_LEVEL "nodelete_level" +#define KEY_MAX_USERINFO_LENGTH "max_userinfo_length" +#define KEY_GIVEOWNERSHIP_PERIOD "giveownership_timeout" /* ChanServ database */ -#define KEY_CHANNELS "channels" -#define KEY_NOTE_TYPES "note_types" +#define KEY_CHANNELS "channels" +#define KEY_NOTE_TYPES "note_types" /* Note type parameters */ -#define KEY_NOTE_OPSERV_ACCESS "opserv_access" -#define KEY_NOTE_CHANNEL_ACCESS "channel_access" -#define KEY_NOTE_SETTER_ACCESS "setter_access" -#define KEY_NOTE_VISIBILITY "visibility" -#define KEY_NOTE_VIS_PRIVILEGED "privileged" -#define KEY_NOTE_VIS_CHANNEL_USERS "channel_users" -#define KEY_NOTE_VIS_ALL "all" -#define KEY_NOTE_MAX_LENGTH "max_length" -#define KEY_NOTE_SETTER "setter" -#define KEY_NOTE_NOTE "note" +#define KEY_NOTE_OPSERV_ACCESS "opserv_access" +#define KEY_NOTE_CHANNEL_ACCESS "channel_access" +#define KEY_NOTE_SETTER_ACCESS "setter_access" +#define KEY_NOTE_VISIBILITY "visibility" +#define KEY_NOTE_VIS_PRIVILEGED "privileged" +#define KEY_NOTE_VIS_CHANNEL_USERS "channel_users" +#define KEY_NOTE_VIS_ALL "all" +#define KEY_NOTE_MAX_LENGTH "max_length" +#define KEY_NOTE_SETTER "setter" +#define KEY_NOTE_NOTE "note" /* Do-not-register channels */ -#define KEY_DNR "dnr" -#define KEY_DNR_SET "set" -#define KEY_DNR_SETTER "setter" -#define KEY_DNR_REASON "reason" +#define KEY_DNR "dnr" +#define KEY_DNR_SET "set" +#define KEY_DNR_SETTER "setter" +#define KEY_DNR_REASON "reason" /* Channel data */ -#define KEY_REGISTERED "registered" -#define KEY_REGISTRAR "registrar" -#define KEY_SUSPENDED "suspended" -#define KEY_PREVIOUS "previous" -#define KEY_SUSPENDER "suspender" -#define KEY_ISSUED "issued" -#define KEY_REVOKED "revoked" -#define KEY_SUSPEND_EXPIRES "suspend_expires" -#define KEY_SUSPEND_REASON "suspend_reason" -#define KEY_VISITED "visited" -#define KEY_TOPIC "topic" -#define KEY_GREETING "greeting" -#define KEY_USER_GREETING "user_greeting" -#define KEY_MODES "modes" -#define KEY_FLAGS "flags" -#define KEY_OPTIONS "options" -#define KEY_USERS "users" -#define KEY_BANS "bans" -#define KEY_MAX "max" -#define KEY_NOTES "notes" -#define KEY_TOPIC_MASK "topic_mask" -#define KEY_OWNER_TRANSFER "owner_transfer" +#define KEY_REGISTERED "registered" +#define KEY_REGISTRAR "registrar" +#define KEY_SUSPENDED "suspended" +#define KEY_PREVIOUS "previous" +#define KEY_SUSPENDER "suspender" +#define KEY_ISSUED "issued" +#define KEY_REVOKED "revoked" +#define KEY_SUSPEND_EXPIRES "suspend_expires" +#define KEY_SUSPEND_REASON "suspend_reason" +#define KEY_VISITED "visited" +#define KEY_TOPIC "topic" +#define KEY_GREETING "greeting" +#define KEY_USER_GREETING "user_greeting" +#define KEY_MODES "modes" +#define KEY_FLAGS "flags" +#define KEY_OPTIONS "options" +#define KEY_USERS "users" +#define KEY_BANS "bans" +#define KEY_MAX "max" +#define KEY_NOTES "notes" +#define KEY_TOPIC_MASK "topic_mask" +#define KEY_OWNER_TRANSFER "owner_transfer" /* User data */ -#define KEY_LEVEL "level" -#define KEY_INFO "info" -#define KEY_SEEN "seen" +#define KEY_LEVEL "level" +#define KEY_INFO "info" +#define KEY_SEEN "seen" /* Ban data */ -#define KEY_OWNER "owner" -#define KEY_REASON "reason" -#define KEY_SET "set" -#define KEY_DURATION "duration" -#define KEY_EXPIRES "expires" -#define KEY_TRIGGERED "triggered" +#define KEY_OWNER "owner" +#define KEY_REASON "reason" +#define KEY_SET "set" +#define KEY_DURATION "duration" +#define KEY_EXPIRES "expires" +#define KEY_TRIGGERED "triggered" #define CHANNEL_DEFAULT_FLAGS (CHANNEL_OFFCHANNEL | CHANNEL_UNREVIEWED) #define CHANNEL_PRESERVED_FLAGS (CHANNEL_UNREVIEWED) @@ -456,26 +456,26 @@ static const struct message_entry msgtab[] = { }; /* eject_user and unban_user flags */ -#define ACTION_KICK 0x0001 -#define ACTION_BAN 0x0002 -#define ACTION_ADD_BAN 0x0004 -#define ACTION_ADD_TIMED_BAN 0x0008 -#define ACTION_UNBAN 0x0010 -#define ACTION_DEL_BAN 0x0020 +#define ACTION_KICK 0x0001 +#define ACTION_BAN 0x0002 +#define ACTION_ADD_BAN 0x0004 +#define ACTION_ADD_TIMED_BAN 0x0008 +#define ACTION_UNBAN 0x0010 +#define ACTION_DEL_BAN 0x0020 /* The 40 allows for [+-ntlksimprD] and lots of fudge factor. */ -#define MODELEN 40 + KEYLEN -#define PADLEN 21 -#define ACCESSLEN 10 +#define MODELEN 40 + KEYLEN +#define PADLEN 21 +#define ACCESSLEN 10 -#define CSFUNC_ARGS user, channel, argc, argv, cmd +#define CSFUNC_ARGS user, channel, argc, argv, cmd #define CHANSERV_FUNC(NAME) MODCMD_FUNC(NAME) -#define CHANSERV_SYNTAX() svccmd_send_help(user, chanserv, cmd) -#define REQUIRE_PARAMS(N) if(argc < (N)) { \ - reply("MSG_MISSING_PARAMS", argv[0]); \ - CHANSERV_SYNTAX(); \ - return 0; } +#define CHANSERV_SYNTAX() svccmd_send_help(user, chanserv, cmd) +#define REQUIRE_PARAMS(N) if(argc < (N)) { \ + reply("MSG_MISSING_PARAMS", argv[0]); \ + CHANSERV_SYNTAX(); \ + return 0; } DECLARE_LIST(dnrList, struct do_not_register *); DEFINE_LIST(dnrList, struct do_not_register *); @@ -493,26 +493,26 @@ static struct struct channelList support_channels; struct mod_chanmode default_modes; - unsigned long db_backup_frequency; - unsigned long channel_expire_frequency; - unsigned long dnr_expire_frequency; + unsigned long db_backup_frequency; + unsigned long channel_expire_frequency; + unsigned long dnr_expire_frequency; - long info_delay; - unsigned int adjust_delay; - long channel_expire_delay; - unsigned int nodelete_level; + long info_delay; + unsigned int adjust_delay; + long channel_expire_delay; + unsigned int nodelete_level; - unsigned int adjust_threshold; - int join_flood_threshold; + unsigned int adjust_threshold; + int join_flood_threshold; - unsigned int greeting_length; - unsigned int refresh_period; - unsigned int giveownership_period; + unsigned int greeting_length; + unsigned int refresh_period; + unsigned int giveownership_period; - unsigned int max_owned; - unsigned int max_chan_users; - unsigned int max_chan_bans; - unsigned int max_userinfo_length; + unsigned int max_owned; + unsigned int max_chan_users; + unsigned int max_chan_bans; + unsigned int max_userinfo_length; struct string_list *set_shows; struct string_list *eightball; @@ -702,52 +702,52 @@ _GetChannelUser(struct chanData *channel, struct handle_info *handle, int overri if(override && HANDLE_FLAGGED(handle, HELPING) && ((handle->opserv_level >= chanserv_conf.nodelete_level) || !IsProtected(channel))) { - for(uData = helperList; - uData && uData->handle != handle; - uData = uData->next); + for(uData = helperList; + uData && uData->handle != handle; + uData = uData->next); - if(!uData) - { - uData = calloc(1, sizeof(struct userData)); - uData->handle = handle; + if(!uData) + { + uData = calloc(1, sizeof(struct userData)); + uData->handle = handle; - uData->access = UL_HELPER; - uData->seen = 0; + uData->access = UL_HELPER; + uData->seen = 0; - uData->info = NULL; + uData->info = NULL; - uData->prev = NULL; - uData->next = helperList; - if(helperList) - helperList->prev = uData; - helperList = uData; - } + uData->prev = NULL; + uData->next = helperList; + if(helperList) + helperList->prev = uData; + helperList = uData; + } - head = &helperList; + head = &helperList; } else { - for(uData = channel->users; uData; uData = uData->next) + for(uData = channel->users; uData; uData = uData->next) if((uData->handle == handle) && (allow_suspended || !IsUserSuspended(uData))) break; - head = &(channel->users); + head = &(channel->users); } if(uData && (uData != *head)) { - /* Shuffle the user to the head of whatever list he was in. */ - if(uData->next) + /* Shuffle the user to the head of whatever list he was in. */ + if(uData->next) uData->next->prev = uData->prev; - if(uData->prev) + if(uData->prev) uData->prev->next = uData->next; - uData->prev = NULL; - uData->next = *head; + uData->prev = NULL; + uData->next = *head; - if(*head) - (**head).prev = uData; - *head = uData; + if(*head) + (**head).prev = uData; + *head = uData; } return uData; @@ -854,7 +854,7 @@ chanserv_deref_note_type(void *data) struct note_type *ntype = data; if(--ntype->refs > 0) - return; + return; free(ntype); } @@ -872,12 +872,12 @@ chanserv_truncate_notes(struct note_type *ntype) struct chanData *cData; struct note *note; unsigned int size = sizeof(*note) + ntype->max_length; - + for(cData = channelList; cData; cData = cData->next) { note = dict_find(cData->notes, ntype->name, NULL); if(!note) continue; - if(strlen(note->note) <= ntype->max_length) + if(strlen(note->note) <= ntype->max_length) continue; dict_remove2(cData->notes, ntype->name, 1); note = realloc(note, size); @@ -922,7 +922,7 @@ static MODCMD_FUNC(cmd_createnote) { if((ntype = dict_find(note_types, argv[1], NULL))) existed = 1; else - ntype = chanserv_create_note_type(argv[arg]); + ntype = chanserv_create_note_type(argv[arg]); if(!irccasecmp(argv[++arg], "privileged")) { arg++; @@ -935,7 +935,7 @@ static MODCMD_FUNC(cmd_createnote) { if(!ulvl) { reply("CSMSG_INVALID_ACCESS", argv[arg]); - goto fail; + goto fail; } ntype->set_access_type = NOTE_SET_CHANNEL_ACCESS; ntype->set_access.min_ulevel = ulvl; @@ -947,7 +947,7 @@ static MODCMD_FUNC(cmd_createnote) { else { reply("CSMSG_BAD_NOTE_ACCESS", argv[arg]); - goto fail; + goto fail; } if(!irccasecmp(argv[++arg], "privileged")) @@ -958,35 +958,35 @@ static MODCMD_FUNC(cmd_createnote) { ntype->visible_type = NOTE_VIS_ALL; else { reply("CSMSG_BAD_NOTE_ACCESS", argv[arg]); - goto fail; + goto fail; } if((arg+1) >= argc) { reply("MSG_MISSING_PARAMS", argv[0]); - goto fail; + goto fail; } max_length = strtoul(argv[++arg], NULL, 0); if(max_length < 20 || max_length > 450) { reply("CSMSG_BAD_MAX_LENGTH", argv[arg]); - goto fail; + goto fail; } if(existed && (max_length < ntype->max_length)) { - ntype->max_length = max_length; - chanserv_truncate_notes(ntype); + ntype->max_length = max_length; + chanserv_truncate_notes(ntype); } ntype->max_length = max_length; if(existed) - reply("CSMSG_NOTE_MODIFIED", ntype->name); + reply("CSMSG_NOTE_MODIFIED", ntype->name); else reply("CSMSG_NOTE_CREATED", ntype->name); return 1; fail: if(!existed) - dict_remove(note_types, ntype->name); + dict_remove(note_types, ntype->name); return 0; } @@ -1103,7 +1103,7 @@ register_channel(struct chanNode *cNode, char *registrar) channel->next = channelList; if(channelList) - channelList->prev = channel; + channelList->prev = channel; channelList = channel; registered_channels++; @@ -1120,7 +1120,7 @@ add_channel_user(struct chanData *channel, struct handle_info *handle, unsigned struct userData *ud; if(access > UL_OWNER) - return NULL; + return NULL; ud = calloc(1, sizeof(*ud)); ud->channel = channel; @@ -1132,7 +1132,7 @@ add_channel_user(struct chanData *channel, struct handle_info *handle, unsigned ud->prev = NULL; ud->next = channel->users; if(channel->users) - channel->users->prev = ud; + channel->users->prev = ud; channel->users = ud; channel->userCount++; @@ -1217,12 +1217,12 @@ add_channel_ban(struct chanData *channel, const char *mask, char *owner, time_t bd->reason = strdup(reason); if(expires) - timeq_add(expires, expire_ban, bd); + timeq_add(expires, expire_ban, bd); bd->prev = NULL; bd->next = channel->bans; if(channel->bans) - channel->bans->prev = bd; + channel->bans->prev = bd; channel->bans = bd; channel->banCount++; banCount++; @@ -1245,7 +1245,7 @@ del_channel_ban(struct banData *ban) ban->next->prev = ban->prev; if(ban->expires) - timeq_del(0, expire_ban, ban, TIMEQ_IGNORE_WHEN); + timeq_del(0, expire_ban, ban, TIMEQ_IGNORE_WHEN); if(ban->reason) free(ban->reason); @@ -1267,7 +1267,7 @@ expire_ban(void *data) for(ii=0; iiban, bd->mask)) - { + { change.argc = 1; change.args[0].mode = MODE_REMOVE|MODE_BAN; change.args[0].u.hostmask = bd->mask; @@ -1298,7 +1298,7 @@ unregister_channel(struct chanData *channel, const char *reason) */ if(!channel) - return; + return; timeq_del(0, NULL, channel, TIMEQ_IGNORE_FUNC | TIMEQ_IGNORE_WHEN); @@ -1310,10 +1310,10 @@ unregister_channel(struct chanData *channel, const char *reason) } while(channel->users) - del_channel_user(channel->users, 0); + del_channel_user(channel->users, 0); while(channel->bans) - del_channel_ban(channel->bans); + del_channel_ban(channel->bans); free(channel->topic); free(channel->registrar); @@ -1331,8 +1331,8 @@ unregister_channel(struct chanData *channel, const char *reason) if(channel->suspended) { - struct chanNode *cNode = channel->channel; - struct suspended *suspended, *next_suspended; + struct chanNode *cNode = channel->channel; + struct suspended *suspended, *next_suspended; for(suspended = channel->suspended; suspended; suspended = next_suspended) { @@ -1344,8 +1344,8 @@ unregister_channel(struct chanData *channel, const char *reason) free(suspended); } - if(cNode) - cNode->channel_info = NULL; + if(cNode) + cNode->channel_info = NULL; } channel->channel->channel_info = NULL; @@ -1371,7 +1371,7 @@ expire_channels(UNUSED_ARG(void *data)) for(channel = channelList; channel; channel = next) { - next = channel->next; + next = channel->next; /* See if the channel can be expired. */ if(((now - channel->visited) <= chanserv_conf.channel_expire_delay) @@ -1391,7 +1391,7 @@ expire_channels(UNUSED_ARG(void *data)) } if(chanserv_conf.channel_expire_frequency) - timeq_add(now + chanserv_conf.channel_expire_frequency, expire_channels, NULL); + timeq_add(now + chanserv_conf.channel_expire_frequency, expire_channels, NULL); } static void @@ -1435,7 +1435,7 @@ protect_user(const struct userNode *victim, const struct userNode *aggressor, st /* Don't protect if no one is to be protected, someone is attacking himself, or if the aggressor is an IRC Operator. */ if(protect == 'n' || victim == aggressor || IsOper(aggressor)) - return 0; + return 0; /* Don't protect if the victim isn't authenticated (because they can't be a channel user), unless we are to protect non-users @@ -1457,14 +1457,14 @@ protect_user(const struct userNode *victim, const struct userNode *aggressor, st switch(protect) { case 'l': - if(cs_victim->access > cs_aggressor->access) + if(cs_victim->access > cs_aggressor->access) return 1; - break; + break; case 'a': case 'e': - if(cs_victim->access >= cs_aggressor->access) + if(cs_victim->access >= cs_aggressor->access) return 1; - break; + break; } return 0; @@ -1480,8 +1480,8 @@ validate_op(struct userNode *user, struct chanNode *channel, struct userNode *vi || (cs_victim->access < cData->lvlOpts[lvlGiveOps])) && !check_user_level(channel, user, lvlEnfOps, 0, 0)) { - send_message(user, chanserv, "CSMSG_OPBY_LOCKED"); - return 0; + send_message(user, chanserv, "CSMSG_OPBY_LOCKED"); + return 0; } return 1; @@ -1492,14 +1492,14 @@ validate_deop(struct userNode *user, struct chanNode *channel, struct userNode * { if(IsService(victim)) { - send_message(user, chanserv, "MSG_SERVICE_IMMUNE", victim->nick); - return 0; + send_message(user, chanserv, "MSG_SERVICE_IMMUNE", victim->nick); + return 0; } if(protect_user(victim, user, channel->channel_info)) { - send_message(user, chanserv, "CSMSG_USER_PROTECTED", victim->nick); - return 0; + send_message(user, chanserv, "CSMSG_USER_PROTECTED", victim->nick); + return 0; } return 1; @@ -2034,20 +2034,20 @@ static CHANSERV_FUNC(cmd_register) if(argc >= (new_channel+2)) { - if(!IsHelping(user)) - { - reply("CSMSG_PROXY_FORBIDDEN"); - return 0; - } + if(!IsHelping(user)) + { + reply("CSMSG_PROXY_FORBIDDEN"); + return 0; + } - if(!(handle = modcmd_get_handle_info(user, argv[new_channel+1]))) + if(!(handle = modcmd_get_handle_info(user, argv[new_channel+1]))) return 0; force = (argc > (new_channel+2)) && !irccasecmp(argv[new_channel+2], "force"); dnr = chanserv_is_dnr(chan_name, handle); } else { - handle = user->handle_info; + handle = user->handle_info; dnr = chanserv_is_dnr(chan_name, handle); } if(dnr && !force) @@ -2153,11 +2153,11 @@ static CHANSERV_FUNC(cmd_unregister) return 0; } confirm_string = make_confirmation_string(uData); - if((argc < 2) || strcmp(argv[1], confirm_string)) - { - reply("CSMSG_CONFIRM_UNREG", confirm_string); - return 0; - } + if((argc < 2) || strcmp(argv[1], confirm_string)) + { + reply("CSMSG_CONFIRM_UNREG", confirm_string); + return 0; + } } sprintf(reason, "unregistered by %s.", user->handle_info->handle); @@ -2181,8 +2181,8 @@ static CHANSERV_FUNC(cmd_move) if(IsProtected(channel->channel_info)) { - reply("CSMSG_MOVE_NODELETE", channel->name); - return 0; + reply("CSMSG_MOVE_NODELETE", channel->name); + return 0; } if(!IsChannelName(argv[1])) @@ -2221,8 +2221,8 @@ static CHANSERV_FUNC(cmd_move) } else if(target->channel_info) { - reply("CSMSG_ALREADY_REGGED", target->name); - return 0; + reply("CSMSG_ALREADY_REGGED", target->name); + return 0; } else if((!(mn = GetUserMode(target, user)) || !(mn->modes && MODE_CHANOP)) && !IsHelping(user)) @@ -2262,8 +2262,8 @@ static CHANSERV_FUNC(cmd_move) if(!IsSuspended(target->channel_info)) { char reason2[MAXLEN]; - sprintf(reason2, "Channel moved to %s by %s.", target->name, user->handle_info->handle); - DelChannelUser(chanserv, channel, reason2, 0); + sprintf(reason2, "Channel moved to %s by %s.", target->name, user->handle_info->handle); + DelChannelUser(chanserv, channel, reason2, 0); } UnlockChannel(channel); LockChannel(target); @@ -2282,7 +2282,7 @@ merge_users(struct chanData *source, struct chanData *target) /* Insert the source's users into the scratch area. */ for(suData = source->users; suData; suData = suData->next) - dict_insert(merge, suData->handle->handle, suData); + dict_insert(merge, suData->handle->handle, suData); /* Iterate through the target's users, looking for users common to both channels. The lower access is @@ -2290,50 +2290,50 @@ merge_users(struct chanData *source, struct chanData *target) list. */ for(tuData = target->users; tuData; tuData = next) { - struct userData *choice; + struct userData *choice; - next = tuData->next; + next = tuData->next; - /* If a source user exists with the same handle as a target - channel's user, resolve the conflict by removing one. */ - suData = dict_find(merge, tuData->handle->handle, NULL); - if(!suData) - continue; + /* If a source user exists with the same handle as a target + channel's user, resolve the conflict by removing one. */ + suData = dict_find(merge, tuData->handle->handle, NULL); + if(!suData) + continue; - /* Pick the data we want to keep. */ + /* Pick the data we want to keep. */ /* If the access is the same, use the later seen time. */ - if(suData->access == tuData->access) - choice = (suData->seen > tuData->seen) ? suData : tuData; - else /* Otherwise, keep the higher access level. */ - choice = (suData->access > tuData->access) ? suData : tuData; + if(suData->access == tuData->access) + choice = (suData->seen > tuData->seen) ? suData : tuData; + else /* Otherwise, keep the higher access level. */ + choice = (suData->access > tuData->access) ? suData : tuData; - /* Remove the user that wasn't picked. */ - if(choice == tuData) - { - dict_remove(merge, suData->handle->handle); - del_channel_user(suData, 0); - } - else - del_channel_user(tuData, 0); + /* Remove the user that wasn't picked. */ + if(choice == tuData) + { + dict_remove(merge, suData->handle->handle); + del_channel_user(suData, 0); + } + else + del_channel_user(tuData, 0); } /* Move the remaining users to the target channel. */ for(it = dict_first(merge); it; it = iter_next(it)) { - suData = iter_data(it); + suData = iter_data(it); - /* Insert the user into the target channel's linked list. */ - suData->prev = NULL; - suData->next = target->users; + /* Insert the user into the target channel's linked list. */ + suData->prev = NULL; + suData->next = target->users; suData->channel = target; - if(target->users) - target->users->prev = suData; - target->users = suData; + if(target->users) + target->users->prev = suData; + target->users = suData; - /* Update the user counts for the target channel; the - source counts are left alone. */ - target->userCount++; + /* Update the user counts for the target channel; the + source counts are left alone. */ + target->userCount++; } /* Possible to assert (source->users == NULL) here. */ @@ -2353,72 +2353,72 @@ merge_bans(struct chanData *source, struct chanData *target) /* Perform a totally expensive O(n*m) merge, ick. */ for(sbData = source->bans; sbData; sbData = sNext) { - /* Flag to track whether the ban's been moved - to the destination yet. */ - int moved = 0; - - /* Possible to assert (sbData->prev == NULL) here. */ - sNext = sbData->next; - - for(tbData = tFront; tbData; tbData = tNext) - { - tNext = tbData->next; - - /* Perform two comparisons between each source - and target ban, conflicts are resolved by - keeping the broader ban and copying the later - expiration and triggered time. */ - if(match_ircglobs(tbData->mask, sbData->mask)) - { - /* There is a broader ban in the target channel that - overrides one in the source channel; remove the - source ban and break. */ - if(sbData->expires > tbData->expires) - tbData->expires = sbData->expires; - if(sbData->triggered > tbData->triggered) - tbData->triggered = sbData->triggered; - del_channel_ban(sbData); - break; - } - else if(match_ircglobs(sbData->mask, tbData->mask)) - { - /* There is a broader ban in the source channel that - overrides one in the target channel; remove the - target ban, fall through and move the source over. */ - if(tbData->expires > sbData->expires) - sbData->expires = tbData->expires; - if(tbData->triggered > sbData->triggered) - sbData->triggered = tbData->triggered; - if(tbData == tFront) - tFront = tNext; - del_channel_ban(tbData); - } - - /* Source bans can override multiple target bans, so - we allow a source to run through this loop multiple - times, but we can only move it once. */ - if(moved) - continue; - moved = 1; - - /* Remove the source ban from the source ban list. */ - if(sbData->next) - sbData->next->prev = sbData->prev; - - /* Modify the source ban's associated channel. */ - sbData->channel = target; - - /* Insert the ban into the target channel's linked list. */ - sbData->prev = NULL; - sbData->next = target->bans; - - if(target->bans) - target->bans->prev = sbData; - target->bans = sbData; - - /* Update the user counts for the target channel. */ - target->banCount++; - } + /* Flag to track whether the ban's been moved + to the destination yet. */ + int moved = 0; + + /* Possible to assert (sbData->prev == NULL) here. */ + sNext = sbData->next; + + for(tbData = tFront; tbData; tbData = tNext) + { + tNext = tbData->next; + + /* Perform two comparisons between each source + and target ban, conflicts are resolved by + keeping the broader ban and copying the later + expiration and triggered time. */ + if(match_ircglobs(tbData->mask, sbData->mask)) + { + /* There is a broader ban in the target channel that + overrides one in the source channel; remove the + source ban and break. */ + if(sbData->expires > tbData->expires) + tbData->expires = sbData->expires; + if(sbData->triggered > tbData->triggered) + tbData->triggered = sbData->triggered; + del_channel_ban(sbData); + break; + } + else if(match_ircglobs(sbData->mask, tbData->mask)) + { + /* There is a broader ban in the source channel that + overrides one in the target channel; remove the + target ban, fall through and move the source over. */ + if(tbData->expires > sbData->expires) + sbData->expires = tbData->expires; + if(tbData->triggered > sbData->triggered) + sbData->triggered = tbData->triggered; + if(tbData == tFront) + tFront = tNext; + del_channel_ban(tbData); + } + + /* Source bans can override multiple target bans, so + we allow a source to run through this loop multiple + times, but we can only move it once. */ + if(moved) + continue; + moved = 1; + + /* Remove the source ban from the source ban list. */ + if(sbData->next) + sbData->next->prev = sbData->prev; + + /* Modify the source ban's associated channel. */ + sbData->channel = target; + + /* Insert the ban into the target channel's linked list. */ + sbData->prev = NULL; + sbData->next = target->bans; + + if(target->bans) + target->bans->prev = sbData; + target->bans = sbData; + + /* Update the user counts for the target channel. */ + target->banCount++; + } } /* Possible to assert (source->bans == NULL) here. */ @@ -2433,7 +2433,7 @@ merge_data(struct chanData *source, struct chanData *target) * Do not touch last_refresh, ban count or user counts. */ if(source->visited > target->visited) - target->visited = source->visited; + target->visited = source->visited; if(source->registered < target->registered) target->registered = source->registered; if(source->ownerTransfer > target->ownerTransfer) @@ -2536,15 +2536,15 @@ static CHANSERV_FUNC(cmd_adduser) if(channel->channel_info->userCount >= chanserv_conf.max_chan_users) { - reply("CSMSG_MAXIMUM_USERS", chanserv_conf.max_chan_users); - return 0; + reply("CSMSG_MAXIMUM_USERS", chanserv_conf.max_chan_users); + return 0; } access = user_level_from_name(argv[2], UL_OWNER); if(!access) { - reply("CSMSG_INVALID_ACCESS", argv[2]); - return 0; + reply("CSMSG_INVALID_ACCESS", argv[2]); + return 0; } actor = GetChannelUser(channel->channel_info, user->handle_info); @@ -2552,8 +2552,8 @@ static CHANSERV_FUNC(cmd_adduser) if(actor->access <= access) { - reply("CSMSG_NO_BUMP_ACCESS"); - return 0; + reply("CSMSG_NO_BUMP_ACCESS"); + return 0; } /* Trying to add someone with equal/more access? */ @@ -2565,8 +2565,8 @@ static CHANSERV_FUNC(cmd_adduser) if((actee = GetTrueChannelAccess(channel->channel_info, handle))) { - reply("CSMSG_USER_EXISTS", handle->handle, channel->name, actee->access); - return 0; + reply("CSMSG_USER_EXISTS", handle->handle, channel->name, actee->access); + return 0; } actee = add_channel_user(channel->channel_info, handle, access, 0, NULL); @@ -2593,34 +2593,34 @@ static CHANSERV_FUNC(cmd_clvl) if(handle == user->handle_info && !privileged) { - reply("CSMSG_NO_SELF_CLVL"); - return 0; + reply("CSMSG_NO_SELF_CLVL"); + return 0; } if(!(victim = GetTrueChannelAccess(channel->channel_info, handle))) { - reply("CSMSG_NO_CHAN_USER", handle->handle, channel->name); - return 0; + reply("CSMSG_NO_CHAN_USER", handle->handle, channel->name); + return 0; } if(actor->access <= victim->access && !privileged) { - reply("MSG_USER_OUTRANKED", handle->handle); - return 0; + reply("MSG_USER_OUTRANKED", handle->handle); + return 0; } new_access = user_level_from_name(argv[2], UL_OWNER); if(!new_access) { - reply("CSMSG_INVALID_ACCESS", argv[2]); - return 0; + reply("CSMSG_INVALID_ACCESS", argv[2]); + return 0; } if(new_access >= actor->access && !privileged) { - reply("CSMSG_NO_BUMP_ACCESS"); - return 0; + reply("CSMSG_NO_BUMP_ACCESS"); + return 0; } /* Trying to clvl a equal/higher user? */ @@ -2656,8 +2656,8 @@ static CHANSERV_FUNC(cmd_deluser) if(!(victim = GetTrueChannelAccess(channel->channel_info, handle))) { - reply("CSMSG_NO_CHAN_USER", handle->handle, channel->name); - return 0; + reply("CSMSG_NO_CHAN_USER", handle->handle, channel->name); + return 0; } if(argc > 2) @@ -2668,11 +2668,11 @@ static CHANSERV_FUNC(cmd_deluser) reply("CSMSG_INVALID_ACCESS", argv[1]); return 0; } - if(access != victim->access) - { - reply("CSMSG_INCORRECT_ACCESS", handle->handle, victim->access, argv[1]); - return 0; - } + if(access != victim->access) + { + reply("CSMSG_INCORRECT_ACCESS", handle->handle, victim->access, argv[1]); + return 0; + } } else { @@ -2681,8 +2681,8 @@ static CHANSERV_FUNC(cmd_deluser) if((actor->access <= victim->access) && !IsHelping(user)) { - reply("MSG_USER_OUTRANKED", victim->handle->handle); - return 0; + reply("MSG_USER_OUTRANKED", victim->handle->handle); + return 0; } /* If people delete themselves it is an override, but they @@ -2715,8 +2715,8 @@ cmd_mdel_user(struct userNode *user, struct chanNode *channel, unsigned short mi if((actor->access <= max_access) && !IsHelping(user)) { - reply("CSMSG_NO_ACCESS"); - return 0; + reply("CSMSG_NO_ACCESS"); + return 0; } if(!real_actor || real_actor->access <= max_access) @@ -2724,12 +2724,12 @@ cmd_mdel_user(struct userNode *user, struct chanNode *channel, unsigned short mi for(uData = channel->channel_info->users; uData; uData = next) { - next = uData->next; + next = uData->next; - if((uData->access >= min_access) + if((uData->access >= min_access) && (uData->access <= max_access) && match_ircglob(uData->handle->handle, mask)) - del_channel_user(uData, 1); + del_channel_user(uData, 1); } reply("CSMSG_DELETED_USERS", mask, min_access, max_access, channel->name); @@ -2773,7 +2773,7 @@ cmd_trim_bans(struct userNode *user, struct chanNode *channel, unsigned long dur limit = now - duration; for(bData = channel->channel_info->bans; bData; bData = next) { - next = bData->next; + next = bData->next; if((bData->triggered && bData->triggered >= limit) || (bData->set && bData->set >= limit)) continue; @@ -2804,27 +2804,27 @@ cmd_trim_users(struct userNode *user, struct chanNode *channel, unsigned short m if(!actor || actor->access <= max_access) { - send_message(user, chanserv, "CSMSG_NO_ACCESS"); - return 0; + send_message(user, chanserv, "CSMSG_NO_ACCESS"); + return 0; } count = 0; limit = now - duration; for(uData = channel->channel_info->users; uData; uData = next) { - next = uData->next; + next = uData->next; - if((uData->seen > limit) + if((uData->seen > limit) || uData->present || (HANDLE_FLAGGED(uData->handle, FROZEN) && !vacation)) - continue; + continue; - if(((uData->access >= min_access) && (uData->access <= max_access)) + if(((uData->access >= min_access) && (uData->access <= max_access)) || (!max_access && (uData->access < actor->access))) - { - del_channel_user(uData, 1); - count++; - } + { + del_channel_user(uData, 1); + count++; + } } if(!max_access) @@ -2848,29 +2848,29 @@ static CHANSERV_FUNC(cmd_trim) duration = ParseInterval(argv[2]); if(duration < 60) { - reply("CSMSG_CANNOT_TRIM"); - return 0; + reply("CSMSG_CANNOT_TRIM"); + return 0; } if(!irccasecmp(argv[1], "bans")) { - cmd_trim_bans(user, channel, duration); - return 1; + cmd_trim_bans(user, channel, duration); + return 1; } else if(!irccasecmp(argv[1], "users")) { - cmd_trim_users(user, channel, 0, 0, duration, vacation); - return 1; + cmd_trim_users(user, channel, 0, 0, duration, vacation); + return 1; } else if(parse_level_range(&min_level, &max_level, argv[1])) { - cmd_trim_users(user, channel, min_level, max_level, duration, vacation); - return 1; + cmd_trim_users(user, channel, min_level, max_level, duration, vacation); + return 1; } else if((min_level = user_level_from_name(argv[1], UL_OWNER))) { - cmd_trim_users(user, channel, min_level, min_level, duration, vacation); - return 1; + cmd_trim_users(user, channel, min_level, min_level, duration, vacation); + return 1; } else { @@ -2894,7 +2894,7 @@ static CHANSERV_FUNC(cmd_up) { if(argc) reply("MSG_CHANNEL_ABSENT", channel->name); - return 0; + return 0; } uData = GetChannelAccess(channel->channel_info, user->handle_info); @@ -2942,14 +2942,14 @@ static CHANSERV_FUNC(cmd_down) { if(argc) reply("MSG_CHANNEL_ABSENT", channel->name); - return 0; + return 0; } if(!change.args[0].u.member->modes) { if(argc) reply("CSMSG_ALREADY_DOWN", channel->name); - return 0; + return 0; } change.args[0].mode = MODE_REMOVE | change.args[0].u.member->modes; @@ -2963,12 +2963,12 @@ static int cmd_all(struct userNode *user, UNUSED_ARG(struct chanNode *channel), for(cList = user->handle_info->channels; cList; cList = cList->u_next) { - if(IsSuspended(cList->channel) + if(IsSuspended(cList->channel) || IsUserSuspended(cList) || !GetUserMode(cList->channel->channel, user)) - continue; + continue; - mcmd(user, cList->channel->channel, 0, NULL, cmd); + mcmd(user, cList->channel->channel, 0, NULL, cmd); } return 1; @@ -2998,20 +2998,20 @@ modify_users(struct userNode *user, struct chanNode *channel, unsigned int argc, for(ii=valid=0; ++ii < argc; ) { - if(!(victim = GetUserH(argv[ii]))) + if(!(victim = GetUserH(argv[ii]))) continue; change->args[valid].mode = mode; change->args[valid].u.member = GetUserMode(channel, victim); if(!change->args[valid].u.member) continue; if(validate && !validate(user, channel, victim)) - continue; + continue; valid++; } change->argc = valid; if(valid < (argc-1)) - reply("CSMSG_PROCESS_FAILED"); + reply("CSMSG_PROCESS_FAILED"); if(valid) { modcmd_chanmode_announce(change); @@ -3080,7 +3080,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c REQUIRE_PARAMS(offset); if(argc > offset) { - reason = unsplit_string(argv + offset, argc - offset, NULL); + reason = unsplit_string(argv + offset, argc - offset, NULL); if(strlen(reason) > (TOPICLEN - (NICKLEN + 3))) { /* Truncate the reason to a length of TOPICLEN, as @@ -3099,13 +3099,13 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c * want to allow those (e.g. unbans) in that case. If we add * some other ejection action for in-channel users, change * this too. */ - victimCount = victims[0] ? 1 : 0; + victimCount = victims[0] ? 1 : 0; - if(IsService(victim)) - { - reply("MSG_SERVICE_IMMUNE", victim->nick); - return 0; - } + if(IsService(victim)) + { + reply("MSG_SERVICE_IMMUNE", victim->nick); + return 0; + } if((action == ACTION_KICK) && !victimCount) { @@ -3113,30 +3113,30 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c return 0; } - if(protect_user(victim, user, channel->channel_info)) - { - reply("CSMSG_USER_PROTECTED", victim->nick); - return 0; - } + if(protect_user(victim, user, channel->channel_info)) + { + reply("CSMSG_USER_PROTECTED", victim->nick); + return 0; + } - ban = generate_hostmask(victim, GENMASK_STRICT_HOST|GENMASK_ANY_IDENT); - name = victim->nick; + ban = generate_hostmask(victim, GENMASK_STRICT_HOST|GENMASK_ANY_IDENT); + name = victim->nick; } else { - if(!is_ircmask(argv[1])) - { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; - } + if(!is_ircmask(argv[1])) + { + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; + } - victims = alloca(sizeof(victims[0]) * channel->members.used); + victims = alloca(sizeof(victims[0]) * channel->members.used); if(bad_channel_ban(channel, user, argv[1], &victimCount, victims)) { - reply("CSMSG_MASK_PROTECTED", argv[1]); - return 0; - } + reply("CSMSG_MASK_PROTECTED", argv[1]); + return 0; + } if((victimCount > 4) && ((victimCount * 3) > channel->members.used) && !IsOper(user)) { @@ -3150,7 +3150,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c return 0; } - name = ban = strdup(argv[1]); + name = ban = strdup(argv[1]); } /* Truncate the ban in place if necessary; we must ensure @@ -3159,108 +3159,108 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c if(action & ACTION_ADD_BAN) { - struct banData *bData, *next; - - if(channel->channel_info->banCount >= chanserv_conf.max_chan_bans) - { - reply("CSMSG_MAXIMUM_BANS", chanserv_conf.max_chan_bans); - free(ban); - return 0; - } - - if(action & ACTION_ADD_TIMED_BAN) - { - duration = ParseInterval(argv[2]); - - if(duration < 15) - { - reply("CSMSG_DURATION_TOO_LOW"); - free(ban); - return 0; - } - else if(duration > (86400 * 365 * 2)) - { - reply("CSMSG_DURATION_TOO_HIGH"); - free(ban); - return 0; - } - } - - for(bData = channel->channel_info->bans; bData; bData = next) - { - if(match_ircglobs(bData->mask, ban)) - { - int exact = !irccasecmp(bData->mask, ban); - - /* The ban is redundant; there is already a ban - with the same effect in place. */ - if(exact) - { - if(bData->reason) + struct banData *bData, *next; + + if(channel->channel_info->banCount >= chanserv_conf.max_chan_bans) + { + reply("CSMSG_MAXIMUM_BANS", chanserv_conf.max_chan_bans); + free(ban); + return 0; + } + + if(action & ACTION_ADD_TIMED_BAN) + { + duration = ParseInterval(argv[2]); + + if(duration < 15) + { + reply("CSMSG_DURATION_TOO_LOW"); + free(ban); + return 0; + } + else if(duration > (86400 * 365 * 2)) + { + reply("CSMSG_DURATION_TOO_HIGH"); + free(ban); + return 0; + } + } + + for(bData = channel->channel_info->bans; bData; bData = next) + { + if(match_ircglobs(bData->mask, ban)) + { + int exact = !irccasecmp(bData->mask, ban); + + /* The ban is redundant; there is already a ban + with the same effect in place. */ + if(exact) + { + if(bData->reason) free(bData->reason); - bData->reason = strdup(reason); + bData->reason = strdup(reason); safestrncpy(bData->owner, (user->handle_info ? user->handle_info->handle : user->nick), sizeof(bData->owner)); if(cmd) reply("CSMSG_REASON_CHANGE", ban); - if(!bData->expires) + if(!bData->expires) goto post_add_ban; - } - if(exact && bData->expires) - { - int reset = 0; - - /* If the ban matches an existing one exactly, - extend the expiration time if the provided - duration is longer. */ - if(duration && ((time_t)(now + duration) > bData->expires)) - { - bData->expires = now + duration; - reset = 1; - } - else if(!duration) - { - bData->expires = 0; - reset = 1; - } - - if(reset) - { - /* Delete the expiration timeq entry and - requeue if necessary. */ - timeq_del(0, expire_ban, bData, TIMEQ_IGNORE_WHEN); - - if(bData->expires) - timeq_add(bData->expires, expire_ban, bData); + } + if(exact && bData->expires) + { + int reset = 0; + + /* If the ban matches an existing one exactly, + extend the expiration time if the provided + duration is longer. */ + if(duration && ((time_t)(now + duration) > bData->expires)) + { + bData->expires = now + duration; + reset = 1; + } + else if(!duration) + { + bData->expires = 0; + reset = 1; + } + + if(reset) + { + /* Delete the expiration timeq entry and + requeue if necessary. */ + timeq_del(0, expire_ban, bData, TIMEQ_IGNORE_WHEN); + + if(bData->expires) + timeq_add(bData->expires, expire_ban, bData); if(!cmd) { /* automated kickban */ } - else if(duration) - reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration, user->handle_info)); - else - reply("CSMSG_BAN_ADDED", name, channel->name); - - goto post_add_ban; - } - } + else if(duration) + reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration, user->handle_info)); + else + reply("CSMSG_BAN_ADDED", name, channel->name); + + goto post_add_ban; + } + } if(cmd) reply("CSMSG_REDUNDANT_BAN", name, channel->name); - free(ban); - return 0; - } + free(ban); + return 0; + } - next = bData->next; - if(match_ircglobs(ban, bData->mask)) - { - /* The ban we are adding makes previously existing - bans redundant; silently remove them. */ - del_channel_ban(bData); - } - } + next = bData->next; + if(match_ircglobs(ban, bData->mask)) + { + /* The ban we are adding makes previously existing + bans redundant; silently remove them. */ + del_channel_ban(bData); + } + } - bData = add_channel_ban(channel->channel_info, ban, (user->handle_info ? user->handle_info->handle : user->nick), now, (victimCount ? now : 0), (duration ? now + duration : 0), reason); + bData = add_channel_ban(channel->channel_info, ban, (user->handle_info ? user->handle_info->handle : user->nick), now, (victimCount ? now : 0), (duration ? now + duration : 0), reason); free(ban); name = ban = strdup(bData->mask); } @@ -3286,19 +3286,19 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c } } - post_add_ban: + post_add_ban: if(action & ACTION_BAN) { - unsigned int exists; + unsigned int exists; struct mod_chanmode *change; - if(channel->banlist.used >= MAXBANS) - { + if(channel->banlist.used >= MAXBANS) + { if(cmd) reply("CSMSG_BANLIST_FULL", channel->name); - free(ban); - return 0; - } + free(ban); + return 0; + } exists = ChannelBanExists(channel, ban); change = mod_chanmode_alloc(victimCount + 1); @@ -3320,7 +3320,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c mod_chanmode_free(change); if(exists && (action == ACTION_BAN)) - { + { if(cmd) reply("CSMSG_REDUNDANT_BAN", name, channel->name); free(ban); @@ -3331,10 +3331,10 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c if(action & ACTION_KICK) { char kick_reason[MAXLEN]; - sprintf(kick_reason, "(%s) %s", user->nick, reason); + sprintf(kick_reason, "(%s) %s", user->nick, reason); - for(n = 0; n < victimCount; n++) - KickChannelUser(victims[n]->user, channel, chanserv, kick_reason); + for(n = 0; n < victimCount; n++) + KickChannelUser(victims[n]->user, channel, chanserv, kick_reason); } if(!cmd) @@ -3343,17 +3343,17 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c } else if(action & ACTION_ADD_BAN) { - if(duration) - reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration, user->handle_info)); - else - reply("CSMSG_BAN_ADDED", name, channel->name); + if(duration) + reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration, user->handle_info)); + else + reply("CSMSG_BAN_ADDED", name, channel->name); } else if((action & (ACTION_BAN | ACTION_KICK)) == (ACTION_BAN | ACTION_KICK)) - reply("CSMSG_KICK_BAN_DONE", name, channel->name); + reply("CSMSG_KICK_BAN_DONE", name, channel->name); else if(action & ACTION_BAN) - reply("CSMSG_BAN_DONE", name, channel->name); + reply("CSMSG_BAN_DONE", name, channel->name); else if(action & ACTION_KICK && victimCount) - reply("CSMSG_KICK_DONE", name, channel->name); + reply("CSMSG_KICK_DONE", name, channel->name); free(ban); return 1; @@ -3437,13 +3437,13 @@ unban_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c /* may want to allow a comma delimited list of users... */ if(!(actee = GetUserH(argv[1]))) { - if(!is_ircmask(argv[1])) - { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; - } + if(!is_ircmask(argv[1])) + { + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; + } - mask = strdup(argv[1]); + mask = strdup(argv[1]); } /* We don't sanitize the mask here because ircu @@ -3466,31 +3466,31 @@ unban_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c if(action & ACTION_DEL_BAN) { - struct banData *ban, *next; + struct banData *ban, *next; - ban = channel->channel_info->bans; - while(ban) - { - if(actee) - for( ; ban && !user_matches_glob(actee, ban->mask, + ban = channel->channel_info->bans; + while(ban) + { + if(actee) + for( ; ban && !user_matches_glob(actee, ban->mask, MATCH_USENICK | MATCH_VISIBLE); - ban = ban->next); - else - for( ; ban && !match_ircglobs(mask, ban->mask); - ban = ban->next); - if(!ban) + ban = ban->next); + else + for( ; ban && !match_ircglobs(mask, ban->mask); + ban = ban->next); + if(!ban) break; - next = ban->next; - del_channel_ban(ban); - ban = next; - acted = 1; - } + next = ban->next; + del_channel_ban(ban); + ban = next; + acted = 1; + } } if(!acted) - reply("CSMSG_BAN_NOT_FOUND", actee ? actee->nick : mask); + reply("CSMSG_BAN_NOT_FOUND", actee ? actee->nick : mask); else - reply("CSMSG_BAN_REMOVED", actee ? actee->nick : mask); + reply("CSMSG_BAN_REMOVED", actee ? actee->nick : mask); if(mask) free(mask); return 1; @@ -3515,7 +3515,7 @@ static CHANSERV_FUNC(cmd_unbanme) /* remove permanent bans if the user has the proper access. */ if(uData->access >= UL_MASTER) - flags |= ACTION_DEL_BAN; + flags |= ACTION_DEL_BAN; argv[1] = user->nick; return unban_user(user, channel, 2, argv, cmd, flags); @@ -3528,8 +3528,8 @@ static CHANSERV_FUNC(cmd_unbanall) if(!channel->banlist.used) { - reply("CSMSG_NO_BANS", channel->name); - return 0; + reply("CSMSG_NO_BANS", channel->name); + return 0; } change = mod_chanmode_alloc(channel->banlist.used); @@ -3635,7 +3635,7 @@ static CHANSERV_FUNC(cmd_access) if(argc < 2) { - target = user; + target = user; target_handle = target->handle_info; } else if((target = GetUserH(argv[1]))) @@ -3660,8 +3660,8 @@ static CHANSERV_FUNC(cmd_access) if(target == chanserv) { - reply("CSMSG_IS_CHANSERV"); - return 1; + reply("CSMSG_IS_CHANSERV"); + return 1; } if(!target_handle) @@ -3671,11 +3671,11 @@ static CHANSERV_FUNC(cmd_access) reply("CSMSG_LAZY_SMURF_TARGET", target->nick, chanserv_conf.irc_operator_epithet); return 0; } - if(target != user) - { - reply("MSG_USER_AUTHENTICATE", target->nick); - return 0; - } + if(target != user) + { + reply("MSG_USER_AUTHENTICATE", target->nick); + return 0; + } reply("MSG_AUTHENTICATE"); return 0; } @@ -3846,22 +3846,22 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg if(user->handle_info) { - switch(user->handle_info->userlist_style) - { - case HI_STYLE_DEF: send_list = def_list; break; + switch(user->handle_info->userlist_style) + { + case HI_STYLE_DEF: send_list = def_list; break; case HI_STYLE_ZOOT: send_list = def_list; break; - } + } } lData.users = alloca(channel->channel_info->userCount * sizeof(struct userData *)); matches = 0; for(uData = channel->channel_info->users; uData; uData = uData->next) { - if((uData->access < lowest) + if((uData->access < lowest) || (uData->access > highest) || (lData.search && !match_ircglob(uData->handle->handle, lData.search))) - continue; - lData.users[matches++] = uData; + continue; + lData.users[matches++] = uData; } qsort(lData.users, matches, sizeof(lData.users[0]), userData_access_comp); @@ -3952,7 +3952,7 @@ static CHANSERV_FUNC(cmd_bans) search = NULL; else if(strchr(search = argv[1], '!')) { - search = argv[1]; + search = argv[1]; search_wilds = search[strcspn(search, "?*")]; } else if(!(search_u = GetUserH(search))) @@ -3967,13 +3967,13 @@ static CHANSERV_FUNC(cmd_bans) if(!user_matches_glob(search_u, ban->mask, MATCH_USENICK | MATCH_VISIBLE)) continue; } - else if(search) + else if(search) { if(search_wilds ? !match_ircglobs(search, ban->mask) : !match_ircglob(search, ban->mask)) continue; } - bans[matches++] = ban; - if(ban->expires) + bans[matches++] = ban; + if(ban->expires) timed = 1; } @@ -3996,28 +3996,28 @@ static CHANSERV_FUNC(cmd_bans) if(!matches) { table_send(cmd->parent->bot, user->nick, 0, NULL, tbl); - reply("MSG_NONE"); + reply("MSG_NONE"); free(tbl.contents[0]); free(tbl.contents); - return 0; + return 0; } msg_never = user_find_message(user, "MSG_NEVER"); for(ii = 0; ii < matches; ) { - ban = bans[ii]; + ban = bans[ii]; - if(!timed) - expires = ""; - else if(ban->expires) - expires = intervalString(e_buffer, ban->expires - now, user->handle_info); - else - expires = msg_never; + if(!timed) + expires = ""; + else if(ban->expires) + expires = intervalString(e_buffer, ban->expires - now, user->handle_info); + else + expires = msg_never; - if(ban->triggered) - triggered = intervalString(t_buffer, now - ban->triggered, user->handle_info); - else - triggered = msg_never; + if(ban->triggered) + triggered = intervalString(t_buffer, now - ban->triggered, user->handle_info); + else + triggered = msg_never; tbl.contents[++ii] = malloc(tbl.width * sizeof(tbl.contents[0][0])); tbl.contents[ii][0] = ban->mask; @@ -4067,12 +4067,12 @@ static CHANSERV_FUNC(cmd_topic) cData = channel->channel_info; if(argc < 2) { - if(cData->topic) - { - SetChannelTopic(channel, chanserv, cData->topic, 1); - reply("CSMSG_TOPIC_SET", cData->topic); + if(cData->topic) + { + SetChannelTopic(channel, chanserv, cData->topic, 1); + reply("CSMSG_TOPIC_SET", cData->topic); return 1; - } + } reply("CSMSG_NO_TOPIC", channel->name); return 0; @@ -4144,12 +4144,12 @@ static CHANSERV_FUNC(cmd_mode) if(argc < 2) { change = &channel->channel_info->modes; - if(change->modes_set || change->modes_clear) { + if(change->modes_set || change->modes_clear) { modcmd_chanmode_announce(change); reply("CSMSG_DEFAULTED_MODES", channel->name); - } else - reply("CSMSG_NO_MODES", channel->name); - return 1; + } else + reply("CSMSG_NO_MODES", channel->name); + return 1; } uData = GetChannelUser(channel->channel_info, user->handle_info); @@ -4162,8 +4162,8 @@ static CHANSERV_FUNC(cmd_mode) change = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED, base_oplevel); if(!change) { - reply("MSG_INVALID_MODES", unsplit_string(argv+1, argc-1, NULL)); - return 0; + reply("MSG_INVALID_MODES", unsplit_string(argv+1, argc-1, NULL)); + return 0; } if(!check_user_level(channel, user, lvlEnfModes, 1, 0) @@ -4191,7 +4191,7 @@ static CHANSERV_FUNC(cmd_invite) if(argc > 1) { if(!(invite = GetUserH(argv[1]))) - { + { reply("MSG_NICK_UNKNOWN", argv[1]); return 0; } @@ -4201,8 +4201,8 @@ static CHANSERV_FUNC(cmd_invite) if(GetUserMode(channel, invite)) { - reply("CSMSG_ALREADY_PRESENT", invite->nick, channel->name); - return 0; + reply("CSMSG_ALREADY_PRESENT", invite->nick, channel->name); + return 0; } if(user != invite) @@ -4217,7 +4217,7 @@ static CHANSERV_FUNC(cmd_invite) } irc_invite(chanserv, invite, channel); if(argc > 1) - reply("CSMSG_INVITED_USER", argv[1], channel->name); + reply("CSMSG_INVITED_USER", argv[1], channel->name); return 1; } @@ -4226,8 +4226,8 @@ static CHANSERV_FUNC(cmd_inviteme) { if(GetUserMode(channel, user)) { - reply("CSMSG_YOU_ALREADY_PRESENT", channel->name); - return 0; + reply("CSMSG_YOU_ALREADY_PRESENT", channel->name); + return 0; } if(channel->channel_info && !check_user_level(channel, user, lvlInviteMe, 1, 0)) @@ -4311,8 +4311,8 @@ static CHANSERV_FUNC(cmd_info) if(uData && (uData->access >= cData->lvlOpts[lvlGiveOps])) { mod_chanmode_format(&cData->modes, modes); - reply("CSMSG_CHANNEL_TOPIC", cData->topic); - reply("CSMSG_CHANNEL_MODES", modes[0] ? modes : user_find_message(user, "MSG_NONE")); + reply("CSMSG_CHANNEL_TOPIC", cData->topic); + reply("CSMSG_CHANNEL_MODES", modes[0] ? modes : user_find_message(user, "MSG_NONE")); } for(it = dict_first(cData->notes); it; it = iter_next(it)) @@ -4452,8 +4452,8 @@ static CHANSERV_FUNC(cmd_peek) table.contents = alloca(channel->members.used*sizeof(*table.contents)); for(n = 0; n < channel->members.used; n++) { - mn = channel->members.list[n]; - if(!(mn->modes & MODE_CHANOP) || IsLocal(mn->user)) + mn = channel->members.list[n]; + if(!(mn->modes & MODE_CHANOP) || IsLocal(mn->user)) continue; table.contents[table.length] = alloca(sizeof(**table.contents)); table.contents[table.length][0] = mn->user->nick; @@ -4564,24 +4564,24 @@ static CHANSERV_FUNC(cmd_seen) if(!irccasecmp(argv[1], chanserv->nick)) { - reply("CSMSG_IS_CHANSERV"); - return 1; + reply("CSMSG_IS_CHANSERV"); + return 1; } if(!(handle = get_handle_info(argv[1]))) { - reply("MSG_HANDLE_UNKNOWN", argv[1]); - return 0; + reply("MSG_HANDLE_UNKNOWN", argv[1]); + return 0; } if(!(uData = GetTrueChannelAccess(channel->channel_info, handle))) { - reply("CSMSG_NO_CHAN_USER", handle->handle, channel->name); - return 0; + reply("CSMSG_NO_CHAN_USER", handle->handle, channel->name); + return 0; } if(uData->present) - reply("CSMSG_USER_PRESENT", handle->handle); + reply("CSMSG_USER_PRESENT", handle->handle); else if(uData->seen) reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen, user->handle_info)); else @@ -4781,9 +4781,9 @@ static CHANSERV_FUNC(cmd_events) reply("CSMSG_EVENT_SEARCH_RESULTS"); matches = log_entry_search(&discrim, log_report_entry, &report); if(matches) - reply("MSG_MATCH_COUNT", matches); + reply("MSG_MATCH_COUNT", matches); else - reply("MSG_NO_MATCHES"); + reply("MSG_NO_MATCHES"); return 1; } @@ -4888,9 +4888,9 @@ static CHANSERV_FUNC(cmd_csuspend) argv[1]++; else if(IsSuspended(channel->channel_info)) { - reply("CSMSG_ALREADY_SUSPENDED", channel->name); + reply("CSMSG_ALREADY_SUSPENDED", channel->name); show_suspension_info(cmd, user, channel->channel_info->suspended); - return 0; + return 0; } if(!strcmp(argv[1], "0")) @@ -4996,49 +4996,49 @@ chanserv_search_create(struct userNode *user, unsigned int argc, char *argv[]) for(i = 0; i < argc; i++) { - /* Assume all criteria require arguments. */ - if(i == (argc - 1)) - { - send_message(user, chanserv, "MSG_MISSING_PARAMS", argv[i]); + /* Assume all criteria require arguments. */ + if(i == (argc - 1)) + { + send_message(user, chanserv, "MSG_MISSING_PARAMS", argv[i]); goto fail; - } - - if(!irccasecmp(argv[i], "name")) - search->name = argv[++i]; - else if(!irccasecmp(argv[i], "registrar")) - search->registrar = argv[++i]; - else if(!irccasecmp(argv[i], "unvisited")) - search->unvisited = ParseInterval(argv[++i]); - else if(!irccasecmp(argv[i], "registered")) - search->registered = ParseInterval(argv[++i]); - else if(!irccasecmp(argv[i], "flags")) - { - i++; - if(!irccasecmp(argv[i], "nodelete")) - search->flags |= CHANNEL_NODELETE; - else if(!irccasecmp(argv[i], "suspended")) - search->flags |= CHANNEL_SUSPENDED; + } + + if(!irccasecmp(argv[i], "name")) + search->name = argv[++i]; + else if(!irccasecmp(argv[i], "registrar")) + search->registrar = argv[++i]; + else if(!irccasecmp(argv[i], "unvisited")) + search->unvisited = ParseInterval(argv[++i]); + else if(!irccasecmp(argv[i], "registered")) + search->registered = ParseInterval(argv[++i]); + else if(!irccasecmp(argv[i], "flags")) + { + i++; + if(!irccasecmp(argv[i], "nodelete")) + search->flags |= CHANNEL_NODELETE; + else if(!irccasecmp(argv[i], "suspended")) + search->flags |= CHANNEL_SUSPENDED; else if(!irccasecmp(argv[i], "unreviewed")) search->flags |= CHANNEL_UNREVIEWED; - else - { - send_message(user, chanserv, "CSMSG_INVALID_CFLAG", argv[i]); - goto fail; - } - } - else if(!irccasecmp(argv[i], "limit")) - search->limit = strtoul(argv[++i], NULL, 10); - else - { - send_message(user, chanserv, "MSG_INVALID_CRITERIA", argv[i]); - goto fail; - } + else + { + send_message(user, chanserv, "CSMSG_INVALID_CFLAG", argv[i]); + goto fail; + } + } + else if(!irccasecmp(argv[i], "limit")) + search->limit = strtoul(argv[++i], NULL, 10); + else + { + send_message(user, chanserv, "MSG_INVALID_CRITERIA", argv[i]); + goto fail; + } } if(search->name && !strcmp(search->name, "*")) - search->name = 0; + search->name = 0; if(search->registrar && !strcmp(search->registrar, "*")) - search->registrar = 0; + search->registrar = 0; return search; fail: @@ -5056,7 +5056,7 @@ chanserv_channel_match(struct chanData *channel, search_t search) (search->unvisited && (now - channel->visited) < search->unvisited) || (search->registered && (now - channel->registered) > search->registered) || (search->flags && ((search->flags & channel->flags) != search->flags))) - return 0; + return 0; return 1; } @@ -5069,10 +5069,10 @@ chanserv_channel_search(search_t search, channel_search_func smf, void *data) for(channel = channelList; channel && matches < search->limit; channel = channel->next) { - if(!chanserv_channel_match(channel, search)) + if(!chanserv_channel_match(channel, search)) continue; - matches++; - smf(channel, data); + matches++; + smf(channel, data); } return matches; @@ -5098,13 +5098,13 @@ static CHANSERV_FUNC(cmd_search) REQUIRE_PARAMS(3); if(!irccasecmp(argv[1], "count")) - action = search_count; + action = search_count; else if(!irccasecmp(argv[1], "print")) - action = search_print; + action = search_print; else { - reply("CSMSG_ACTION_INVALID", argv[1]); - return 0; + reply("CSMSG_ACTION_INVALID", argv[1]); + return 0; } search = chanserv_search_create(user, argc - 2, argv + 2); @@ -5112,17 +5112,17 @@ static CHANSERV_FUNC(cmd_search) return 0; if(action == search_count) - search->limit = INT_MAX; + search->limit = INT_MAX; if(action == search_print) - reply("CSMSG_CHANNEL_SEARCH_RESULTS"); + reply("CSMSG_CHANNEL_SEARCH_RESULTS"); matches = chanserv_channel_search(search, action, user); if(matches) - reply("MSG_MATCH_COUNT", matches); + reply("MSG_MATCH_COUNT", matches); else - reply("MSG_NO_MATCHES"); + reply("MSG_NO_MATCHES"); free(search); return 1; @@ -5137,8 +5137,8 @@ static CHANSERV_FUNC(cmd_unvisited) if(argc > 1) { - interval = ParseInterval(argv[1]); - if(argc > 2) + interval = ParseInterval(argv[1]); + if(argc > 2) limit = atoi(argv[2]); } @@ -5147,12 +5147,12 @@ static CHANSERV_FUNC(cmd_unvisited) for(cData = channelList; cData && matches < limit; cData = cData->next) { - if((now - cData->visited) < interval) + if((now - cData->visited) < interval) continue; - intervalString(buffer, now - cData->visited, user->handle_info); - reply("CSMSG_UNVISITED_DATA", cData->channel->name, buffer); - matches++; + intervalString(buffer, now - cData->visited, user->handle_info); + reply("CSMSG_UNVISITED_DATA", cData->channel->name, buffer); + matches++; } return 1; @@ -5170,20 +5170,20 @@ static MODCMD_FUNC(chan_opt_defaulttopic) return 0; } - topic = unsplit_string(argv+1, argc-1, NULL); + topic = unsplit_string(argv+1, argc-1, NULL); free(channel->channel_info->topic); - if(topic[0] == '*' && topic[1] == 0) - { + if(topic[0] == '*' && topic[1] == 0) + { topic = channel->channel_info->topic = NULL; - } - else - { - topic = channel->channel_info->topic = strdup(topic); + } + else + { + topic = channel->channel_info->topic = strdup(topic); if(channel->channel_info->topic_mask && !match_ircglob(channel->channel_info->topic, channel->channel_info->topic_mask)) reply("CSMSG_TOPIC_MISMATCH", channel->name); - } + } SetChannelTopic(channel, chanserv, topic ? topic : "", 1); } @@ -5207,22 +5207,22 @@ static MODCMD_FUNC(chan_opt_topicmask) return 0; } - mask = unsplit_string(argv+1, argc-1, NULL); + mask = unsplit_string(argv+1, argc-1, NULL); if(cData->topic_mask) free(cData->topic_mask); - if(mask[0] == '*' && mask[1] == 0) - { - cData->topic_mask = 0; - } - else - { + if(mask[0] == '*' && mask[1] == 0) + { + cData->topic_mask = 0; + } + else + { cData->topic_mask = strdup(mask); if(!cData->topic) reply("CSMSG_MASK_BUT_NO_TOPIC", channel->name); else if(!match_ircglob(cData->topic, cData->topic_mask)) reply("CSMSG_TOPIC_MISMATCH", channel->name); - } + } } if(channel->channel_info->topic_mask) @@ -5240,18 +5240,18 @@ int opt_greeting_common(struct userNode *user, struct svccmd *cmd, int argc, cha char *previous; previous = *data; - if(greeting[0] == '*' && greeting[1] == 0) - *data = NULL; - else - { - unsigned int length = strlen(greeting); - if(length > chanserv_conf.greeting_length) - { - reply("CSMSG_GREETING_TOO_LONG", length, chanserv_conf.greeting_length); - return 0; - } - *data = strdup(greeting); - } + if(greeting[0] == '*' && greeting[1] == 0) + *data = NULL; + else + { + unsigned int length = strlen(greeting); + if(length > chanserv_conf.greeting_length) + { + reply("CSMSG_GREETING_TOO_LONG", length, chanserv_conf.greeting_length); + return 0; + } + *data = strdup(greeting); + } if(previous) free(previous); } @@ -5285,12 +5285,12 @@ static MODCMD_FUNC(chan_opt_modes) reply("CSMSG_NO_ACCESS"); return 0; } - if(argv[1][0] == '*' && argv[1][1] == 0) - { + if(argv[1][0] == '*' && argv[1][1] == 0) + { memset(&channel->channel_info->modes, 0, sizeof(channel->channel_info->modes)); - } - else if(!(new_modes = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED, 0))) - { + } + else if(!(new_modes = mod_chanmode_parse(channel, argv+1, argc-1, MCP_KEY_FREE|MCP_REGISTERED, 0))) + { reply("CSMSG_INVALID_MODE_LOCK", unsplit_string(argv+1, argc-1, NULL)); return 0; } @@ -5325,27 +5325,27 @@ channel_binary_option(char *name, unsigned long mask, struct userNode *user, str if(argc > 1) { - /* Set flag according to value. */ - if(enabled_string(argv[1])) - { - cData->flags |= mask; - value = 1; - } - else if(disabled_string(argv[1])) - { - cData->flags &= ~mask; - value = 0; - } - else - { - reply("MSG_INVALID_BINARY", argv[1]); - return 0; - } + /* Set flag according to value. */ + if(enabled_string(argv[1])) + { + cData->flags |= mask; + value = 1; + } + else if(disabled_string(argv[1])) + { + cData->flags &= ~mask; + value = 0; + } + else + { + reply("MSG_INVALID_BINARY", argv[1]); + return 0; + } } else { - /* Find current option value. */ - value = (cData->flags & mask) ? 1 : 0; + /* Find current option value. */ + value = (cData->flags & mask) ? 1 : 0; } if(value) @@ -5359,8 +5359,8 @@ static MODCMD_FUNC(chan_opt_nodelete) { if((argc > 1) && (!IsOper(user) || !user->handle_info || (user->handle_info->opserv_level < chanserv_conf.nodelete_level))) { - reply("MSG_SETTING_PRIVILEGED", argv[0]); - return 0; + reply("MSG_SETTING_PRIVILEGED", argv[0]); + return 0; } CHANNEL_BINARY_OPTION("CSMSG_SET_NODELETE", CHANNEL_NODELETE); @@ -5378,16 +5378,16 @@ static MODCMD_FUNC(chan_opt_offchannel) if(argc > 1) { - /* Set flag according to value. */ - if(enabled_string(argv[1])) - { + /* Set flag according to value. */ + if(enabled_string(argv[1])) + { if(!IsOffChannel(cData)) DelChannelUser(chanserv, channel, "Going off-channel.", 0); - cData->flags |= CHANNEL_OFFCHANNEL; - value = 1; - } - else if(disabled_string(argv[1])) - { + cData->flags |= CHANNEL_OFFCHANNEL; + value = 1; + } + else if(disabled_string(argv[1])) + { if(IsOffChannel(cData)) { struct mod_chanmode change; @@ -5397,19 +5397,19 @@ static MODCMD_FUNC(chan_opt_offchannel) change.args[0].u.member = AddChannelUser(chanserv, channel); mod_chanmode_announce(chanserv, channel, &change); } - cData->flags &= ~CHANNEL_OFFCHANNEL; - value = 0; - } - else - { - reply("MSG_INVALID_BINARY", argv[1]); - return 0; - } + cData->flags &= ~CHANNEL_OFFCHANNEL; + value = 0; + } + else + { + reply("MSG_INVALID_BINARY", argv[1]); + return 0; + } } else { - /* Find current option value. */ - value = (cData->flags & CHANNEL_OFFCHANNEL) ? 1 : 0; + /* Find current option value. */ + value = (cData->flags & CHANNEL_OFFCHANNEL) ? 1 : 0; } if(value) @@ -5434,10 +5434,10 @@ static MODCMD_FUNC(chan_opt_unreviewed) else if(disabled_string(argv[1])) new_value = 0; else - { - reply("MSG_INVALID_BINARY", argv[1]); - return 0; - } + { + reply("MSG_INVALID_BINARY", argv[1]); + return 0; + } if (new_value != value) { @@ -5521,8 +5521,8 @@ channel_level_option(enum levelOption option, struct userNode *user, struct chan } value = user_level_from_name(argv[1], UL_OWNER+1); if(!value && strcmp(argv[1], "0")) - { - reply("CSMSG_INVALID_ACCESS", argv[1]); + { + reply("CSMSG_INVALID_ACCESS", argv[1]); return 0; } uData = GetChannelUser(cData, user->handle_info); @@ -5632,22 +5632,22 @@ channel_multiple_option(enum charOption option, struct userNode *user, struct ch { index = atoi(argv[1]); - if(!isdigit(argv[1][0]) || (index < 0) || (index >= count)) - { - reply("CSMSG_INVALID_NUMERIC", index); + if(!isdigit(argv[1][0]) || (index < 0) || (index >= count)) + { + reply("CSMSG_INVALID_NUMERIC", index); /* Show possible values. */ for(index = 0; index < count; index++) reply(charOptions[option].format_name, index, user_find_message(user, charOptions[option].values[index].format_name)); - return 0; - } + return 0; + } - cData->chOpts[option] = charOptions[option].values[index].value; + cData->chOpts[option] = charOptions[option].values[index].value; } else { - /* Find current option value. */ + /* Find current option value. */ find_value: - for(index = 0; + for(index = 0; (index < count) && (cData->chOpts[option] != charOptions[option].values[index].value); index++); if(index == count) @@ -5722,13 +5722,13 @@ static CHANSERV_FUNC(cmd_set) if(argc < 2) { - reply("CSMSG_CHANNEL_OPTIONS"); + reply("CSMSG_CHANNEL_OPTIONS"); for(ii = 0; ii < set_shows_list.used; ii++) { subcmd = set_shows_list.list[ii]; subcmd->command->func(user, channel, 1, argv+1, subcmd); } - return 1; + return 1; } sprintf(buf, "%s %s", argv[0], argv[1]); @@ -5763,7 +5763,7 @@ user_binary_option(char *name, unsigned long mask, struct userNode *user, struct if(argc < 2) { - /* Just show current option value. */ + /* Just show current option value. */ } else if(enabled_string(argv[1])) { @@ -5813,11 +5813,11 @@ static MODCMD_FUNC(user_opt_info) if(!uData) { - /* If they got past the command restrictions (which require access) + /* If they got past the command restrictions (which require access) * but fail this test, we have some fool with security override on. */ - reply("CSMSG_NOT_USER", channel->name); - return 0; + reply("CSMSG_NOT_USER", channel->name); + return 0; } if(argc > 1) @@ -5886,11 +5886,11 @@ static CHANSERV_FUNC(cmd_uset) if(argc < 2) { - /* Do this so options are presented in a consistent order. */ - reply("CSMSG_USER_OPTIONS"); + /* Do this so options are presented in a consistent order. */ + reply("CSMSG_USER_OPTIONS"); for(ii = 0; ii < uset_shows_list.used; ii++) uset_shows_list.list[ii]->command->func(user, channel, 1, argv+1, uset_shows_list.list[ii]); - return 1; + return 1; } sprintf(buf, "%s %s", argv[0], argv[1]); @@ -6487,7 +6487,7 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) unsigned int ii, jj; if(!user->handle_info) - return; + return; mod_chanmode_init(&change); change.argc = 1; @@ -6512,8 +6512,8 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) continue; } - if(channel->access >= UL_PRESENT) - channel->channel->visited = now; + if(channel->access >= UL_PRESENT) + channel->channel->visited = now; if(IsUserAutoOp(channel)) { @@ -6528,8 +6528,8 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) mod_chanmode_announce(chanserv, cn, &change); } - channel->seen = now; - channel->present = 1; + channel->seen = now; + channel->present = 1; } for(ii = 0; ii < user->channels.used; ++ii) @@ -6586,18 +6586,18 @@ handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !mn->channel->join_flooded) { - /* Allow for a bit of padding so that the limit doesn't - track the user count exactly, which could get annoying. */ - if((mn->channel->limit - mn->channel->members.used) > chanserv_conf.adjust_threshold + 5) - { - timeq_del(0, chanserv_adjust_limit, cData, TIMEQ_IGNORE_WHEN); - timeq_add(now + chanserv_conf.adjust_delay, chanserv_adjust_limit, cData); - } + /* Allow for a bit of padding so that the limit doesn't + track the user count exactly, which could get annoying. */ + if((mn->channel->limit - mn->channel->members.used) > chanserv_conf.adjust_threshold + 5) + { + timeq_del(0, chanserv_adjust_limit, cData, TIMEQ_IGNORE_WHEN); + timeq_add(now + chanserv_conf.adjust_delay, chanserv_adjust_limit, cData); + } } if((uData = GetTrueChannelAccess(cData, mn->user->handle_info))) { - scan_user_presence(uData, mn->user); + scan_user_presence(uData, mn->user); uData->seen = now; if (uData->access >= UL_PRESENT) cData->visited = now; @@ -6632,7 +6632,7 @@ handle_kick(struct userNode *kicker, struct userNode *victim, struct chanNode *c if(protect_user(victim, kicker, channel->channel_info)) { const char *reason = user_find_message(kicker, "CSMSG_USER_PROTECTED"); - KickChannelUser(kicker, channel, chanserv, reason); + KickChannelUser(kicker, channel, chanserv, reason); } if((uData = GetTrueChannelAccess(channel->channel_info, victim->handle_info))) @@ -6844,8 +6844,8 @@ chanserv_conf_read(void) if(!(conf_node = conf_get_data(CHANSERV_CONF_NAME, RECDB_OBJECT))) { - log_module(CS_LOG, LOG_ERROR, "Invalid config node `%s'.", CHANSERV_CONF_NAME); - return; + log_module(CS_LOG, LOG_ERROR, "Invalid config node `%s'.", CHANSERV_CONF_NAME); + return; } for(ii = 0; ii < chanserv_conf.support_channels.used; ++ii) UnlockChannel(chanserv_conf.support_channels.list[ii]); @@ -7048,15 +7048,15 @@ user_read_helper(const char *key, struct record_data *rd, struct chanData *chan) if(rd->type != RECDB_OBJECT || !dict_size(rd->d.object)) { - log_module(CS_LOG, LOG_ERROR, "Invalid user in %s.", chan->channel->name); - return; + log_module(CS_LOG, LOG_ERROR, "Invalid user in %s.", chan->channel->name); + return; } access = atoi(database_get_data(rd->d.object, KEY_LEVEL, RECDB_QSTRING)); if(access > UL_OWNER) { - log_module(CS_LOG, LOG_ERROR, "Invalid access level for %s in %s.", key, chan->channel->name); - return; + log_module(CS_LOG, LOG_ERROR, "Invalid access level for %s in %s.", key, chan->channel->name); + return; } inf = database_get_data(rd->d.object, KEY_INFO, RECDB_QSTRING); @@ -7083,8 +7083,8 @@ ban_read_helper(const char *key, struct record_data *rd, struct chanData *chan) if(rd->type != RECDB_OBJECT || !dict_size(rd->d.object)) { - log_module(CS_LOG, LOG_ERROR, "Invalid ban in %s.", chan->channel->name); - return; + log_module(CS_LOG, LOG_ERROR, "Invalid ban in %s.", chan->channel->name); + return; } set = database_get_data(rd->d.object, KEY_SET, RECDB_QSTRING); @@ -7158,7 +7158,7 @@ chanserv_channel_read(const char *key, struct record_data *hir) if(!cData) { log_module(CS_LOG, LOG_ERROR, "Unable to register channel %s from database.", key); - return 0; + return 0; } if((obj = database_get_data(channel, KEY_OPTIONS, RECDB_OBJECT))) @@ -7196,7 +7196,7 @@ chanserv_channel_read(const char *key, struct record_data *hir) enum charOption chOpt; unsigned int count; - cData->flags = base64toint(str, 5); + cData->flags = base64toint(str, 5); count = strlen(str += 5); for(lvlOpt = 0; lvlOpt < NUM_LEVEL_OPTIONS; ++lvlOpt) { @@ -7223,7 +7223,7 @@ chanserv_channel_read(const char *key, struct record_data *hir) for(chOpt = 0; chOpt < NUM_CHAR_OPTIONS; ++chOpt) cData->chOpts[chOpt] = ((count <= charOptions[chOpt].old_idx) ? str : CHANNEL_DEFAULT_OPTIONS)[charOptions[chOpt].old_idx]; } - + if((obj = database_get_data(hir->d.object, KEY_SUSPENDED, RECDB_OBJECT))) { suspended = chanserv_read_suspended(obj); @@ -7290,7 +7290,7 @@ chanserv_channel_read(const char *key, struct record_data *hir) && (argc = split_line(str, 0, ArrayLength(argv), argv)) && (modes = mod_chanmode_parse(cNode, argv, argc, MCP_KEY_FREE, 0))) { cData->modes = *modes; - if(off_channel > 0) + if(off_channel > 0) cData->modes.modes_set |= MODE_REGISTERED; if(cData->modes.argc > 1) cData->modes.argc = 1; @@ -7300,12 +7300,12 @@ chanserv_channel_read(const char *key, struct record_data *hir) obj = database_get_data(channel, KEY_USERS, RECDB_OBJECT); for(it = dict_first(obj); it; it = iter_next(it)) - user_read_helper(iter_key(it), iter_data(it), cData); + user_read_helper(iter_key(it), iter_data(it), cData); if(!cData->users && !IsProtected(cData)) { log_module(CS_LOG, LOG_ERROR, "Channel %s had no users in database, unregistering it.", key); - unregister_channel(cData, "has empty user list."); + unregister_channel(cData, "has empty user list."); return 0; } @@ -7387,8 +7387,8 @@ chanserv_saxdb_read(struct dict *database) chanserv_note_type_read(iter_key(it), iter_data(it)); if((section = database_get_data(database, KEY_CHANNELS, RECDB_OBJECT))) - for(it = dict_first(section); it; it = iter_next(it)) - chanserv_channel_read(iter_key(it), iter_data(it)); + for(it = dict_first(section); it; it = iter_next(it)) + chanserv_channel_read(iter_key(it), iter_data(it)); if((section = database_get_data(database, KEY_DNR, RECDB_OBJECT))) for(it = dict_first(section); it; it = iter_next(it)) @@ -7411,7 +7411,7 @@ chanserv_write_users(struct saxdb_context *ctx, struct userData *uData) saxdb_write_int(ctx, KEY_SEEN, uData->seen); if(uData->flags) saxdb_write_int(ctx, KEY_FLAGS, uData->flags); - if(uData->info) + if(uData->info) saxdb_write_string(ctx, KEY_INFO, uData->info); saxdb_end_record(ctx); } @@ -7498,7 +7498,7 @@ chanserv_write_channel(struct saxdb_context *ctx, struct chanData *channel) if(channel->modes.modes_set || channel->modes.modes_clear) { - mod_chanmode_format(&channel->modes, buf); + mod_chanmode_format(&channel->modes, buf); saxdb_write_string(ctx, KEY_MODES, buf); } @@ -7512,7 +7512,7 @@ chanserv_write_channel(struct saxdb_context *ctx, struct chanData *channel) saxdb_start_record(ctx, KEY_NOTES, 1); for(it = dict_first(channel->notes); it; it = iter_next(it)) { - struct note *note = iter_data(it); + struct note *note = iter_data(it); saxdb_start_record(ctx, iter_key(it), 0); saxdb_write_string(ctx, KEY_NOTE_SETTER, note->setter); saxdb_write_string(ctx, KEY_NOTE_NOTE, note->note); @@ -7823,7 +7823,7 @@ init_chanserv(const char *nick) saxdb_register("ChanServ", chanserv_saxdb_read, chanserv_saxdb_write); if(chanserv_conf.channel_expire_frequency) - timeq_add(now + chanserv_conf.channel_expire_frequency, expire_channels, NULL); + timeq_add(now + chanserv_conf.channel_expire_frequency, expire_channels, NULL); if(chanserv_conf.dnr_expire_frequency) timeq_add(now + chanserv_conf.dnr_expire_frequency, expire_dnrs, NULL); diff --git a/src/chanserv.h b/src/chanserv.h index 83f310e..dddc712 100644 --- a/src/chanserv.h +++ b/src/chanserv.h @@ -56,13 +56,13 @@ enum charOption { NUM_CHAR_OPTIONS }; -#define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */ -#define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */ -#define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */ -#define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */ +#define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */ +#define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */ +#define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */ +#define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */ /* No longer used. */ /* (1 << 4) */ -#define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */ -#define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */ +#define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */ +#define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */ #define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */ #define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */ #define CHANNEL_UNREVIEWED 0x00000200 /* (1 << 9) */ @@ -70,27 +70,27 @@ enum charOption { * because chanData.flags is a 30-bit field. */ -#define IsProtected(x) ((x)->flags & CHANNEL_NODELETE) -#define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED) -#define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1)) +#define IsProtected(x) ((x)->flags & CHANNEL_NODELETE) +#define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED) +#define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1)) struct chanData { - struct chanNode *channel; + struct chanNode *channel; struct mod_chanmode modes; - time_t registered; - time_t visited; - time_t limitAdjusted; - time_t ownerTransfer; + time_t registered; + time_t visited; + time_t limitAdjusted; + time_t ownerTransfer; - char *topic; - char *greeting; - char *user_greeting; - char *registrar; - char *topic_mask; + char *topic; + char *greeting; + char *user_greeting; + char *registrar; + char *topic_mask; - unsigned int flags : 30; + unsigned int flags : 30; unsigned int may_opchan : 1; unsigned int max; unsigned int last_refresh; @@ -99,12 +99,12 @@ struct chanData unsigned short lvlOpts[NUM_LEVEL_OPTIONS]; unsigned char chOpts[NUM_CHAR_OPTIONS]; - struct userData *users; - struct banData *bans; + struct userData *users; + struct banData *bans; struct dict *notes; - struct suspended *suspended; - struct chanData *prev; - struct chanData *next; + struct suspended *suspended; + struct chanData *prev; + struct chanData *next; }; #define USER_AUTO_OP 0x00000001 @@ -118,18 +118,18 @@ struct chanData struct userData { - struct handle_info *handle; - struct chanData *channel; + struct handle_info *handle; + struct chanData *channel; - char *info; - time_t seen; + char *info; + time_t seen; unsigned short access; - unsigned int present : 1; + unsigned int present : 1; unsigned int flags : USER_FLAGS_SIZE; /* linked list of userDatas for a chanData */ - struct userData *prev; - struct userData *next; + struct userData *prev; + struct userData *next; /* linked list of userDatas for a handle_info */ struct userData *u_prev; struct userData *u_next; @@ -137,24 +137,24 @@ struct userData struct banData { - char mask[NICKLEN + USERLEN + HOSTLEN + 3]; - char owner[NICKLEN+1]; - struct chanData *channel; + char mask[NICKLEN + USERLEN + HOSTLEN + 3]; + char owner[NICKLEN+1]; + struct chanData *channel; - time_t set; - time_t triggered; - time_t expires; + time_t set; + time_t triggered; + time_t expires; - char *reason; + char *reason; - struct banData *prev; - struct banData *next; + struct banData *prev; + struct banData *next; }; struct suspended { - struct chanData *cData; - char *suspender; + struct chanData *cData; + char *suspender; char *reason; time_t issued, expires, revoked; struct suspended *previous; diff --git a/src/checkdb.c b/src/checkdb.c index 45ef136..87e38d4 100644 --- a/src/checkdb.c +++ b/src/checkdb.c @@ -58,13 +58,13 @@ int check_record(const char *key, void *data, UNUSED_ARG(void *extra)) struct record_data *rd = data; switch (rd->type) { case RECDB_INVALID: - fprintf(stdout, "Invalid database record type for key %s\n", key); - return 1; + fprintf(stdout, "Invalid database record type for key %s\n", key); + return 1; case RECDB_QSTRING: case RECDB_STRING_LIST: - return 0; + return 0; case RECDB_OBJECT: - return dict_foreach(rd->d.object, check_record, NULL) ? 1 : 0; + return dict_foreach(rd->d.object, check_record, NULL) ? 1 : 0; } return 0; } diff --git a/src/common.h b/src/common.h index 694df8a..b979aa1 100644 --- a/src/common.h +++ b/src/common.h @@ -38,7 +38,7 @@ extern struct tm *localtime_r(const time_t *clock, struct tm *res); #define false 0 #endif -#define ArrayLength(x) (sizeof(x)/sizeof(x[0])) +#define ArrayLength(x) (sizeof(x)/sizeof(x[0])) #define safestrncpy(dest, src, len) do { char *d = (dest); const char *s = (src); size_t l = strlen(s)+1; if ((len) < l) l = (len); memmove(d, s, l); d[l-1] = 0; } while (0) #ifdef __GNUC__ @@ -217,11 +217,11 @@ int STRUCTNAME##_remove(struct STRUCTNAME *list, ITEMTYPE new_item) {\ unsigned int n, found;\ verify(list->list);\ for (found=n=0; nused; n++) {\ - if (list->list[n] == new_item) {\ - memmove(list->list+n, list->list+n+1, (list->used-n-1)*sizeof(list->list[n]));\ - found = 1;\ - list->used--;\ - }\ + if (list->list[n] == new_item) {\ + memmove(list->list+n, list->list+n+1, (list->used-n-1)*sizeof(list->list[n]));\ + found = 1;\ + list->used--;\ + }\ }\ return found;\ }\ @@ -235,7 +235,7 @@ void STRUCTNAME##_clean(struct STRUCTNAME *list) {\ * minutes, and 10 seconds" (27 characters). Other languages will * vary, so there's plenty of leeway. */ -#define INTERVALLEN 50 +#define INTERVALLEN 50 struct handle_info; char *intervalString(char *output, time_t interval, struct handle_info *hi); diff --git a/src/compat.c b/src/compat.c index cc31324..2035b85 100644 --- a/src/compat.c +++ b/src/compat.c @@ -94,262 +94,262 @@ extern char * strdup(char const * str) extern char const * strerror(int errornum) { if (errornum==0) - return "No error"; + return "No error"; #ifdef EPERM if (errornum==EPERM) - return "Operation not permitted"; + return "Operation not permitted"; #endif #ifdef ENOENT if (errornum==ENOENT) - return "No such file or directory"; + return "No such file or directory"; #endif #ifdef ESRCH if (errornum==ESRCH) - return "No such process"; + return "No such process"; #endif #ifdef EINTR if (errornum==EINTR) - return "Interrupted system call"; + return "Interrupted system call"; #endif #ifdef EIO if (errornum==EIO) - return "I/O error"; + return "I/O error"; #endif #ifdef ENXIO if (errornum==EIO) - return "No such device or address"; + return "No such device or address"; #endif #ifdef EBADF if (errornum==EBADF) - return "Bad file number"; + return "Bad file number"; #endif #ifdef EAGAIN if (errornum==EAGAIN) - return "Try again"; + return "Try again"; #endif #ifdef ENOMEM if (errornum==ENOMEM) - return "Out of memory"; + return "Out of memory"; #endif #ifdef EACCES if (errornum==EACCES) - return "Permission denied"; + return "Permission denied"; #endif #ifdef EFAULT if (errornum==EFAULT) - return "Bad address"; + return "Bad address"; #endif #ifdef EBUSY if (errornum==EBUSY) - return "Device or resource busy"; + return "Device or resource busy"; #endif #ifdef EEXIST if (errornum==EEXIST) - return "File exists"; + return "File exists"; #endif #ifdef EXDEV if (errornum==EXDEV) - return "Cross-device link"; + return "Cross-device link"; #endif #ifdef EDEADLK if (errornum==EXDEV) - return "Resource deadlock would occur"; + return "Resource deadlock would occur"; #endif #ifdef EDEADLOCK if (errornum==EDEADLOCK) - return "Resource deadlock would occur"; + return "Resource deadlock would occur"; #endif #ifdef ENODEV if (errornum==ENODEV) - return "No such device"; + return "No such device"; #endif #ifdef ENOTDIR if (errornum==ENOTDIR) - return "Not a directory"; + return "Not a directory"; #endif #ifdef EISDIR if (errornum==EISDIR) - return "Is a directory"; + return "Is a directory"; #endif #ifdef EINVAL if (errornum==EINVAL) - return "Invalid argument"; + return "Invalid argument"; #endif #ifdef ENFILE if (errornum==ENFILE) - return "Too many open files in system"; + return "Too many open files in system"; #endif #ifdef EMFILE if (errornum==EMFILE) - return "Too many open files"; + return "Too many open files"; #endif #ifdef ENOTTY if (errornum==ENOTTY) - return "Not a typewriter"; + return "Not a typewriter"; #endif #ifdef ETXTBSY if (errornum==ETXTBSY) - return "Text file busy"; + return "Text file busy"; #endif #ifdef EFBIG if (errornum==EFBIG) - return "File too large"; + return "File too large"; #endif #ifdef ENOSPC if (errornum==ENOSPC) - return "No space left on device"; + return "No space left on device"; #endif #ifdef ESPIPE if (errornum==ESPIPE) - return "Illegal seek"; + return "Illegal seek"; #endif #ifdef EROFS if (errornum==EROFS) - return "Read-only file system"; + return "Read-only file system"; #endif #ifdef EMLINK if (errornum==EMLINK) - return "Too many links"; + return "Too many links"; #endif #ifdef EPIPE if (errornum==EPIPE) - return "Broken pipe"; + return "Broken pipe"; #endif #ifdef EDOM if (errornum==EDOM) - return "Math argument out of domain of func"; + return "Math argument out of domain of func"; #endif #ifdef ERANGE if (errornum==ERANGE) - return "Math result not representable"; + return "Math result not representable"; #endif #ifdef ENAMETOOLONG if (errornum==ENAMETOOLONG) - return "File name too long"; + return "File name too long"; #endif #ifdef ENOLCK if (errornum==ENOLCK) - return "No record locks avaliable"; + return "No record locks avaliable"; #endif #ifdef ENOSYS if (errornum==ENOSYS) - return "Function not implemented"; + return "Function not implemented"; #endif #ifdef ENOTEMPTY if (errornum==ENOTEMPTY) - return "Directory not empty"; + return "Directory not empty"; #endif #ifdef ELOOP if (errornum==ELOOP) - return "Too many symbolic links encountered"; + return "Too many symbolic links encountered"; #endif #ifdef EHOSTDOWN if (errornum==EHOSTDOWN) - return "Host is down"; + return "Host is down"; #endif #ifdef EHOSTUNREACH if (errornum==EHOSTUNREACH) - return "No route to host"; + return "No route to host"; #endif #ifdef EALREADY if (errornum==EALREADY) - return "Operation already in progress"; + return "Operation already in progress"; #endif #ifdef EINPROGRESS if (errornum==EINPROGRESS) - return "Operation now in progress"; + return "Operation now in progress"; #endif #ifdef ESTALE if (errornum==ESTALE) - return "Stale NFS filehandle"; + return "Stale NFS filehandle"; #endif #ifdef EDQUOT if (errornum==EDQUOT) - return "Quota exceeded"; + return "Quota exceeded"; #endif #ifdef EWOULDBLOCK if (errornum==EWOULDBLOCK) - return "Operation would block"; + return "Operation would block"; #endif #ifdef ECOMM if (errornum==ECOMM) - return "Communication error on send"; + return "Communication error on send"; #endif #ifdef EPROTO if (errornum==EPROTO) - return "Protocol error"; + return "Protocol error"; #endif #ifdef EPROTONOSUPPORT if (errornum==EPROTONOSUPPORT) - return "Protocol not supported"; + return "Protocol not supported"; #endif #ifdef ESOCKTNOSUPPORT if (errornum==ESOCKTNOSUPPORT) - return "Socket type not supported"; + return "Socket type not supported"; #endif #ifdef ESOCKTNOSUPPORT if (errornum==EOPNOTSUPP) - return "Operation not supported"; + return "Operation not supported"; #endif #ifdef EPFNOSUPPORT if (errornum==EPFNOSUPPORT) - return "Protocol family not supported"; + return "Protocol family not supported"; #endif #ifdef EAFNOSUPPORT if (errornum==EAFNOSUPPORT) - return "Address family not supported by protocol family"; + return "Address family not supported by protocol family"; #endif #ifdef EADDRINUSE if (errornum==EADDRINUSE) - return "Address already in use"; + return "Address already in use"; #endif #ifdef EADDRNOTAVAIL if (errornum==EADDRNOTAVAIL) - return "Cannot assign requested address"; + return "Cannot assign requested address"; #endif #ifdef ENETDOWN if (errornum==ENETDOWN) - return "Network is down"; + return "Network is down"; #endif #ifdef ENETUNREACH if (errornum==ENETUNREACH) - return "Network is unreachable"; + return "Network is unreachable"; #endif #ifdef ENETRESET if (errornum==ENETRESET) - return "Network dropped connection on reset"; + return "Network dropped connection on reset"; #endif #ifdef ECONNABORTED if (errornum==ECONNABORTED) - return "Software caused connection abort"; + return "Software caused connection abort"; #endif #ifdef ECONNRESET if (errornum==ECONNRESET) - return " Connection reset by peer"; + return " Connection reset by peer"; #endif #ifdef ENOBUFS if (errornum==ENOBUFS) - return "No buffer space available"; + return "No buffer space available"; #endif #ifdef EISCONN if (errornum==EISCONN) - return "Socket is already connected"; + return "Socket is already connected"; #endif #ifdef ENOTCONN if (errornum==ENOTCONN) - return "Socket is not connected"; + return "Socket is not connected"; #endif #ifdef ESHUTDOWN if (errornum==ESHUTDOWN) - return " Cannot send after socket shutdown"; + return " Cannot send after socket shutdown"; #endif #ifdef ETIMEDOUT if (errornum==ETIMEDOUT) - return "Connection timed out"; + return "Connection timed out"; #endif #ifdef ECONNREFUSED if (errornum==ECONNREFUSED) - return "Connection refused"; + return "Connection refused"; #endif return "Unknown error"; } diff --git a/src/dict-splay.c b/src/dict-splay.c index 25e7a05..fd72965 100644 --- a/src/dict-splay.c +++ b/src/dict-splay.c @@ -84,34 +84,34 @@ dict_splay(struct dict_node *node, const char *key) while (1) { verify(node); res = irccasecmp(key, node->key); - if (!res) break; - if (res < 0) { - if (!node->l) break; - res = irccasecmp(key, node->l->key); - if (res < 0) { - y = node->l; - node->l = y->r; - y->r = node; - node = y; - if (!node->l) break; - } - r->l = node; - r = node; - node = node->l; - } else { /* res > 0 */ - if (!node->r) break; - res = irccasecmp(key, node->r->key); - if (res > 0) { - y = node->r; - node->r = y->l; - y->l = node; - node = y; - if (!node->r) break; - } - l->r = node; - l = node; - node = node->r; - } + if (!res) break; + if (res < 0) { + if (!node->l) break; + res = irccasecmp(key, node->l->key); + if (res < 0) { + y = node->l; + node->l = y->r; + y->r = node; + node = y; + if (!node->l) break; + } + r->l = node; + r = node; + node = node->l; + } else { /* res > 0 */ + if (!node->r) break; + res = irccasecmp(key, node->r->key); + if (res > 0) { + y = node->r; + node->r = y->l; + y->l = node; + node = y; + if (!node->r) break; + } + l->r = node; + l = node; + node = node->r; + } } l->r = node->l; r->l = node->r; @@ -157,14 +157,14 @@ dict_insert(dict_t dict, const char *key, void *data) new_node->key = key; new_node->data = data; if (dict->root) { - int res; - dict->root = dict_splay(dict->root, key); - res = irccasecmp(key, dict->root->key); - if (res < 0) { + int res; + dict->root = dict_splay(dict->root, key); + res = irccasecmp(key, dict->root->key); + if (res < 0) { /* insert just "before" current root */ - new_node->l = dict->root->l; - new_node->r = dict->root; - dict->root->l = NULL; + new_node->l = dict->root->l; + new_node->r = dict->root; + dict->root->l = NULL; if (dict->root->prev) { dict->root->prev->next = new_node; } else { @@ -173,12 +173,12 @@ dict_insert(dict_t dict, const char *key, void *data) new_node->prev = dict->root->prev; new_node->next = dict->root; dict->root->prev = new_node; - dict->root = new_node; - } else if (res > 0) { + dict->root = new_node; + } else if (res > 0) { /* insert just "after" current root */ - new_node->r = dict->root->r; - new_node->l = dict->root; - dict->root->r = NULL; + new_node->r = dict->root->r; + new_node->l = dict->root; + dict->root->r = NULL; if (dict->root->next) { dict->root->next->prev = new_node; } else { @@ -187,10 +187,10 @@ dict_insert(dict_t dict, const char *key, void *data) new_node->next = dict->root->next; new_node->prev = dict->root; dict->root->next = new_node; - dict->root = new_node; - } else { - /* maybe we don't want to overwrite it .. oh well */ - if (dict->free_data) { + dict->root = new_node; + } else { + /* maybe we don't want to overwrite it .. oh well */ + if (dict->free_data) { if (dict->free_data == free) free(dict->root->data); else @@ -204,14 +204,14 @@ dict_insert(dict_t dict, const char *key, void *data) } free(new_node); dict->root->key = key; - dict->root->data = data; - /* decrement the count since we dropped the node */ - dict->count--; - } + dict->root->data = data; + /* decrement the count since we dropped the node */ + dict->count--; + } } else { - new_node->l = new_node->r = NULL; + new_node->l = new_node->r = NULL; new_node->next = new_node->prev = NULL; - dict->root = dict->first = dict->last = new_node; + dict->root = dict->first = dict->last = new_node; } dict->count++; } @@ -265,9 +265,9 @@ dict_find(dict_t dict, const char *key, int *found) { int was_found; if (!dict || !dict->root || !key) { - if (found) + if (found) *found = 0; - return NULL; + return NULL; } verify(dict); dict->root = dict_splay(dict->root, key); diff --git a/src/getopt.h b/src/getopt.h index 7dad11b..75f5761 100644 --- a/src/getopt.h +++ b/src/getopt.h @@ -22,7 +22,7 @@ #ifndef _GETOPT_H #define _GETOPT_H 1 -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -63,9 +63,9 @@ extern int optopt; zero. The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but @@ -94,9 +94,9 @@ struct option /* Names for the values of the `has_arg' field of `struct option'. */ -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ @@ -108,16 +108,16 @@ extern int getopt (int argc, char *const *argv, const char *shortopts); extern int getopt (); #endif /* __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); + const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); + const char *shortopts, + const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); #else /* not __STDC__ */ extern int getopt (); extern int getopt_long (); @@ -126,7 +126,7 @@ extern int getopt_long_only (); extern int _getopt_internal (); #endif /* __STDC__ */ -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/src/gline.c b/src/gline.c index dab6954..d9a99c5 100644 --- a/src/gline.c +++ b/src/gline.c @@ -162,8 +162,8 @@ gline_add(const char *issuer, const char *target, unsigned long duration, const } heap_insert(gline_heap, ent, ent); if (!prev_first || (ent->expires < prev_first->expires)) { - timeq_del(0, gline_expire, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); - timeq_add(ent->expires, gline_expire, 0); + timeq_del(0, gline_expire, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); + timeq_add(ent->expires, gline_expire, 0); } if (announce) irc_gline(NULL, ent); @@ -258,12 +258,12 @@ gline_add_record(const char *key, void *data, UNUSED_ARG(void *extra)) time_t issued, expiration, lastmod; if (!(reason = database_get_data(rd->d.object, KEY_REASON, RECDB_QSTRING))) { - log_module(MAIN_LOG, LOG_ERROR, "Missing reason for gline %s", key); - return 0; + log_module(MAIN_LOG, LOG_ERROR, "Missing reason for gline %s", key); + return 0; } if (!(dstr = database_get_data(rd->d.object, KEY_EXPIRES, RECDB_QSTRING))) { - log_module(MAIN_LOG, LOG_ERROR, "Missing expiration for gline %s", key); - return 0; + log_module(MAIN_LOG, LOG_ERROR, "Missing expiration for gline %s", key); + return 0; } expiration = strtoul(dstr, NULL, 0); dstr = database_get_data(rd->d.object, KEY_LASTMOD, RECDB_QSTRING); diff --git a/src/global.c b/src/global.c index c749414..d904b08 100644 --- a/src/global.c +++ b/src/global.c @@ -25,21 +25,21 @@ #include "saxdb.h" #include "timeq.h" -#define GLOBAL_CONF_NAME "services/global" +#define GLOBAL_CONF_NAME "services/global" -#define GLOBAL_DB "global.db" -#define GLOBAL_TEMP_DB "global.db.new" +#define GLOBAL_DB "global.db" +#define GLOBAL_TEMP_DB "global.db.new" /* Global options */ -#define KEY_DB_BACKUP_FREQ "db_backup_freq" -#define KEY_NICK "nick" +#define KEY_DB_BACKUP_FREQ "db_backup_freq" +#define KEY_NICK "nick" /* Message data */ -#define KEY_FLAGS "flags" -#define KEY_POSTED "posted" -#define KEY_DURATION "duration" -#define KEY_FROM "from" -#define KEY_MESSAGE "message" +#define KEY_FLAGS "flags" +#define KEY_POSTED "posted" +#define KEY_DURATION "duration" +#define KEY_FROM "from" +#define KEY_MESSAGE "message" /* Clarification: Notices are immediate, they are sent to matching users _once_, then forgotten. Messages are stored in Global's database and @@ -66,18 +66,18 @@ static const struct message_entry msgtab[] = { struct globalMessage { - unsigned long id; - long flags; + unsigned long id; + long flags; - time_t posted; - char posted_s[24]; - unsigned long duration; + time_t posted; + char posted_s[24]; + unsigned long duration; - char *from; - char *message; + char *from; + char *message; - struct globalMessage *prev; - struct globalMessage *next; + struct globalMessage *prev; + struct globalMessage *next; }; struct userNode *global; @@ -107,7 +107,7 @@ message_add(long flags, time_t posted, unsigned long duration, char *from, const message = malloc(sizeof(struct globalMessage)); if(!message) { - return NULL; + return NULL; } message->id = messageCount++; @@ -125,7 +125,7 @@ message_add(long flags, time_t posted, unsigned long duration, char *from, const if(messageList) { - messageList->prev = message; + messageList->prev = message; } message->prev = NULL; message->next = messageList; @@ -134,7 +134,7 @@ message_add(long flags, time_t posted, unsigned long duration, char *from, const if(duration) { - timeq_add(now + duration, message_expire, message); + timeq_add(now + duration, message_expire, message); } return message; @@ -145,7 +145,7 @@ message_del(struct globalMessage *message) { if(message->duration) { - timeq_del(0, NULL, message, TIMEQ_IGNORE_FUNC | TIMEQ_IGNORE_WHEN); + timeq_del(0, NULL, message, TIMEQ_IGNORE_FUNC | TIMEQ_IGNORE_WHEN); } if(message->prev) message->prev->next = message->next; @@ -176,60 +176,60 @@ message_create(struct userNode *user, unsigned int argc, char *argv[]) unsigned int i; sender = user->handle_info->handle; - + for(i = 0; i < argc; i++) { - if((i + 1) > argc) - { - global_notice(user, "MSG_MISSING_PARAMS", argv[argc]); - return NULL; - } - - if(!irccasecmp(argv[i], "text")) - { - i++; - text = unsplit_string(argv + i, argc - i, NULL); - break; - } else if (!irccasecmp(argv[i], "sourceless")) { - i++; - flags |= MESSAGE_OPTION_SOURCELESS; - } else if (!irccasecmp(argv[i], "target")) { - i++; - - if(!irccasecmp(argv[i], "all")) { - flags |= MESSAGE_RECIPIENT_ALL; - } else if(!irccasecmp(argv[i], "users")) { - flags |= MESSAGE_RECIPIENT_LUSERS; - } else if(!irccasecmp(argv[i], "helpers")) { - flags |= MESSAGE_RECIPIENT_HELPERS; - } else if(!irccasecmp(argv[i], "opers")) { - flags |= MESSAGE_RECIPIENT_OPERS; - } else if(!irccasecmp(argv[i], "staff") || !irccasecmp(argv[i], "privileged")) { - flags |= MESSAGE_RECIPIENT_STAFF; - } else if(!irccasecmp(argv[i], "channels")) { - flags |= MESSAGE_RECIPIENT_CHANNELS; - } else { - global_notice(user, "GMSG_INVALID_TARGET", argv[i]); - return NULL; - } - } else if (irccasecmp(argv[i], "duration") == 0) { - duration = ParseInterval(argv[++i]); + if((i + 1) > argc) + { + global_notice(user, "MSG_MISSING_PARAMS", argv[argc]); + return NULL; + } + + if(!irccasecmp(argv[i], "text")) + { + i++; + text = unsplit_string(argv + i, argc - i, NULL); + break; + } else if (!irccasecmp(argv[i], "sourceless")) { + i++; + flags |= MESSAGE_OPTION_SOURCELESS; + } else if (!irccasecmp(argv[i], "target")) { + i++; + + if(!irccasecmp(argv[i], "all")) { + flags |= MESSAGE_RECIPIENT_ALL; + } else if(!irccasecmp(argv[i], "users")) { + flags |= MESSAGE_RECIPIENT_LUSERS; + } else if(!irccasecmp(argv[i], "helpers")) { + flags |= MESSAGE_RECIPIENT_HELPERS; + } else if(!irccasecmp(argv[i], "opers")) { + flags |= MESSAGE_RECIPIENT_OPERS; + } else if(!irccasecmp(argv[i], "staff") || !irccasecmp(argv[i], "privileged")) { + flags |= MESSAGE_RECIPIENT_STAFF; + } else if(!irccasecmp(argv[i], "channels")) { + flags |= MESSAGE_RECIPIENT_CHANNELS; + } else { + global_notice(user, "GMSG_INVALID_TARGET", argv[i]); + return NULL; + } + } else if (irccasecmp(argv[i], "duration") == 0) { + duration = ParseInterval(argv[++i]); } else if (irccasecmp(argv[i], "from") == 0) { sender = argv[++i]; - } else { - global_notice(user, "MSG_INVALID_CRITERIA", argv[i]); - return NULL; - } + } else { + global_notice(user, "MSG_INVALID_CRITERIA", argv[i]); + return NULL; + } } if(!flags) { - flags = MESSAGE_RECIPIENT_LUSERS; + flags = MESSAGE_RECIPIENT_LUSERS; } if(!text) { - global_notice(user, "GMSG_MESSAGE_REQUIRED"); - return NULL; + global_notice(user, "GMSG_MESSAGE_REQUIRED"); + return NULL; } return message_add(flags, now, duration, sender, text); @@ -240,27 +240,27 @@ messageType(const struct globalMessage *message) { if((message->flags & MESSAGE_RECIPIENT_ALL) == MESSAGE_RECIPIENT_ALL) { - return "all"; + return "all"; } if((message->flags & MESSAGE_RECIPIENT_STAFF) == MESSAGE_RECIPIENT_STAFF) { - return "staff"; + return "staff"; } else if(message->flags & MESSAGE_RECIPIENT_OPERS) { - return "opers"; + return "opers"; } else if(message->flags & MESSAGE_RECIPIENT_HELPERS) { - return "helpers"; + return "helpers"; } else if(message->flags & MESSAGE_RECIPIENT_LUSERS) { - return "users"; + return "users"; } else { - return "channels"; + return "channels"; } } @@ -269,14 +269,14 @@ notice_target(const char *target, struct globalMessage *message) { if(!(message->flags & MESSAGE_OPTION_SOURCELESS)) { - if(message->flags & MESSAGE_OPTION_IMMEDIATE) - { - send_target_message(0, target, global, "GMSG_NOTICE_SOURCE", messageType(message), message->from); - } - else - { - send_target_message(0, target, global, "GMSG_MESSAGE_SOURCE", messageType(message), message->from, message->posted_s); - } + if(message->flags & MESSAGE_OPTION_IMMEDIATE) + { + send_target_message(0, target, global, "GMSG_NOTICE_SOURCE", messageType(message), message->from); + } + else + { + send_target_message(0, target, global, "GMSG_MESSAGE_SOURCE", messageType(message), message->from, message->posted_s); + } } send_target_message(4, target, global, "%s", message->message); @@ -288,7 +288,7 @@ notice_channel(const char *key, void *data, void *extra) struct chanNode *channel = data; /* It should be safe to assume channel is not NULL. */ if(channel->channel_info) - notice_target(key, extra); + notice_target(key, extra); return 0; } @@ -300,37 +300,37 @@ message_send(struct globalMessage *message) if(message->flags & MESSAGE_RECIPIENT_CHANNELS) { - dict_foreach(channels, notice_channel, message); + dict_foreach(channels, notice_channel, message); } if(message->flags & MESSAGE_RECIPIENT_LUSERS) { - notice_target("$*", message); - return; + notice_target("$*", message); + return; } if(message->flags & MESSAGE_RECIPIENT_OPERS) { - for(n = 0; n < curr_opers.used; n++) - { - user = curr_opers.list[n]; - - if(user->uplink != self) - { - notice_target(user->nick, message); - } - } + for(n = 0; n < curr_opers.used; n++) + { + user = curr_opers.list[n]; + + if(user->uplink != self) + { + notice_target(user->nick, message); + } + } } if(message->flags & MESSAGE_RECIPIENT_HELPERS) { - for(n = 0; n < curr_helpers.used; n++) - { - user = curr_helpers.list[n]; + for(n = 0; n < curr_helpers.used; n++) + { + user = curr_helpers.list[n]; if (IsOper(user)) continue; - notice_target(user->nick, message); - } + notice_target(user->nick, message); + } } } @@ -340,11 +340,11 @@ global_message(long targets, char *text) struct globalMessage *message; if(!targets || !global) - return; + return; message = message_add(targets | MESSAGE_OPTION_SOURCELESS, now, 0, "", text); if(!message) - return; + return; message_send(message); message_del(message); @@ -360,20 +360,20 @@ static GLOBAL_FUNC(cmd_notice) assert(argc >= 3); sender = user->handle_info->handle; if(!irccasecmp(argv[1], "all")) { - target = MESSAGE_RECIPIENT_ALL; + target = MESSAGE_RECIPIENT_ALL; } else if(!irccasecmp(argv[1], "users")) { - target = MESSAGE_RECIPIENT_LUSERS; + target = MESSAGE_RECIPIENT_LUSERS; } else if(!irccasecmp(argv[1], "helpers")) { - target = MESSAGE_RECIPIENT_HELPERS; + target = MESSAGE_RECIPIENT_HELPERS; } else if(!irccasecmp(argv[1], "opers")) { - target = MESSAGE_RECIPIENT_OPERS; + target = MESSAGE_RECIPIENT_OPERS; } else if(!irccasecmp(argv[1], "staff") || !irccasecmp(argv[1], "privileged")) { - target |= MESSAGE_RECIPIENT_HELPERS | MESSAGE_RECIPIENT_OPERS; + target |= MESSAGE_RECIPIENT_HELPERS | MESSAGE_RECIPIENT_OPERS; } else if(!irccasecmp(argv[1], "channels")) { - target = MESSAGE_RECIPIENT_CHANNELS; + target = MESSAGE_RECIPIENT_CHANNELS; } else { - global_notice(user, "GMSG_INVALID_TARGET", argv[1]); - return 0; + global_notice(user, "GMSG_INVALID_TARGET", argv[1]); + return 0; } if(!irccasecmp(argv[2], "from")) { if (argc < 5) { @@ -389,7 +389,7 @@ static GLOBAL_FUNC(cmd_notice) message = message_add(target | MESSAGE_OPTION_IMMEDIATE, now, 0, sender, text); if(!message) - return 0; + return 0; recipient = messageType(message); message_send(message); @@ -421,7 +421,7 @@ static GLOBAL_FUNC(cmd_list) if(!messageList) { - global_notice(user, "GMSG_NO_MESSAGES"); + global_notice(user, "GMSG_NO_MESSAGES"); return 1; } @@ -451,13 +451,13 @@ static GLOBAL_FUNC(cmd_list) strcpy(buffer, "Never."); table.contents[nn][2] = strdup(buffer); table.contents[nn][3] = message->from; - length = strlen(message->message); - safestrncpy(buffer, message->message, sizeof(buffer)); - if(length > (sizeof(buffer) - 4)) - { - buffer[sizeof(buffer) - 1] = 0; - buffer[sizeof(buffer) - 2] = buffer[sizeof(buffer) - 3] = buffer[sizeof(buffer) - 4] = '.'; - } + length = strlen(message->message); + safestrncpy(buffer, message->message, sizeof(buffer)); + if(length > (sizeof(buffer) - 4)) + { + buffer[sizeof(buffer) - 1] = 0; + buffer[sizeof(buffer) - 2] = buffer[sizeof(buffer) - 3] = buffer[sizeof(buffer) - 4] = '.'; + } table.contents[nn][4] = strdup(buffer); } table_send(global, user->nick, 0, NULL, table); @@ -484,12 +484,12 @@ static GLOBAL_FUNC(cmd_remove) for(message = messageList; message; message = message->next) { - if(message->id == id) - { - message_del(message); - global_notice(user, "GMSG_MESSAGE_DELETED", argv[1]); - return 1; - } + if(message->id == id) + { + message_del(message); + global_notice(user, "GMSG_MESSAGE_DELETED", argv[1]); + return 1; + } } global_notice(user, "GMSG_ID_INVALID", argv[1]); @@ -504,15 +504,15 @@ send_messages(struct userNode *user, long mask, int obstreperize) while(message) { - if(message->flags & mask) - { + if(message->flags & mask) + { if (obstreperize && !count) send_target_message(0, user->nick, global, "GMSG_MOTD_HEADER"); - notice_target(user->nick, message); - count++; - } + notice_target(user->nick, message); + count++; + } - message = message->next; + message = message->next; } if (obstreperize && count) send_target_message(0, user->nick, global, "GMSG_MOTD_FOOTER"); @@ -525,16 +525,16 @@ static GLOBAL_FUNC(cmd_messages) unsigned int count; if(IsOper(user)) - mask |= MESSAGE_RECIPIENT_OPERS; + mask |= MESSAGE_RECIPIENT_OPERS; if(IsHelper(user)) - mask |= MESSAGE_RECIPIENT_HELPERS; + mask |= MESSAGE_RECIPIENT_HELPERS; count = send_messages(user, mask, 0); if(count) - global_notice(user, "GMSG_MESSAGE_COUNT", count); + global_notice(user, "GMSG_MESSAGE_COUNT", count); else - global_notice(user, "GMSG_NO_MESSAGES"); + global_notice(user, "GMSG_NO_MESSAGES"); return 1; } @@ -551,11 +551,11 @@ global_process_user(struct userNode *user) */ if((now - max_clients_time) <= 30 && (now - last_max_alert) > 30) { - char *message; - message = alloca(36); - sprintf(message, "New user count record: %d", max_clients); - global_message(MESSAGE_RECIPIENT_OPERS, message); - last_max_alert = now; + char *message; + message = alloca(36); + sprintf(message, "New user count record: %d", max_clients); + global_message(MESSAGE_RECIPIENT_OPERS, message); + last_max_alert = now; } return 0; @@ -565,7 +565,7 @@ static void global_process_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) { if(IsHelper(user)) - send_messages(user, MESSAGE_RECIPIENT_HELPERS, 0); + send_messages(user, MESSAGE_RECIPIENT_HELPERS, 0); } static void @@ -583,8 +583,8 @@ global_conf_read(void) const char *str; if (!(conf_node = conf_get_data(GLOBAL_CONF_NAME, RECDB_OBJECT))) { - log_module(G_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", GLOBAL_CONF_NAME); - return; + log_module(G_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", GLOBAL_CONF_NAME); + return; } str = database_get_data(conf_node, KEY_DB_BACKUP_FREQ, RECDB_QSTRING); @@ -608,11 +608,11 @@ global_saxdb_read(struct dict *db) for(it=dict_first(db); it; it=iter_next(it)) { hir = iter_data(it); - if(hir->type != RECDB_OBJECT) - { - log_module(G_LOG, LOG_WARNING, "Unexpected rectype %d for %s.", hir->type, iter_key(it)); + if(hir->type != RECDB_OBJECT) + { + log_module(G_LOG, LOG_WARNING, "Unexpected rectype %d for %s.", hir->type, iter_key(it)); continue; - } + } str = database_get_data(hir->d.object, KEY_FLAGS, RECDB_QSTRING); flags = str ? strtoul(str, NULL, 0) : 0; @@ -626,7 +626,7 @@ global_saxdb_read(struct dict *db) from = database_get_data(hir->d.object, KEY_FROM, RECDB_QSTRING); message = database_get_data(hir->d.object, KEY_MESSAGE, RECDB_QSTRING); - message_add(flags, posted, duration, from, message); + message_add(flags, posted, duration, from, message); } return 0; } diff --git a/src/global.h b/src/global.h index ecd753a..b0473f9 100644 --- a/src/global.h +++ b/src/global.h @@ -21,16 +21,16 @@ #ifndef _global_h #define _global_h -#define MESSAGE_RECIPIENT_LUSERS 0x001 -#define MESSAGE_RECIPIENT_HELPERS 0x002 -#define MESSAGE_RECIPIENT_OPERS 0x004 -#define MESSAGE_RECIPIENT_CHANNELS 0x008 +#define MESSAGE_RECIPIENT_LUSERS 0x001 +#define MESSAGE_RECIPIENT_HELPERS 0x002 +#define MESSAGE_RECIPIENT_OPERS 0x004 +#define MESSAGE_RECIPIENT_CHANNELS 0x008 -#define MESSAGE_OPTION_SOURCELESS 0x010 -#define MESSAGE_OPTION_IMMEDIATE 0x020 +#define MESSAGE_OPTION_SOURCELESS 0x010 +#define MESSAGE_OPTION_IMMEDIATE 0x020 -#define MESSAGE_RECIPIENT_STAFF (MESSAGE_RECIPIENT_HELPERS | MESSAGE_RECIPIENT_OPERS) -#define MESSAGE_RECIPIENT_ALL (MESSAGE_RECIPIENT_LUSERS | MESSAGE_RECIPIENT_CHANNELS) +#define MESSAGE_RECIPIENT_STAFF (MESSAGE_RECIPIENT_HELPERS | MESSAGE_RECIPIENT_OPERS) +#define MESSAGE_RECIPIENT_ALL (MESSAGE_RECIPIENT_LUSERS | MESSAGE_RECIPIENT_CHANNELS) void init_global(const char *nick); diff --git a/src/globtest.c b/src/globtest.c index 9249f87..764590c 100644 --- a/src/globtest.c +++ b/src/globtest.c @@ -9,12 +9,12 @@ struct glob_test { struct glob_test glob_yes[] = { { "*Zoot*!*@*.org", { "Zoot!Zoot@services.org", - "zoot!bleh@j00.are.r00t3d.org", + "zoot!bleh@j00.are.r00t3d.org", 0 } }, { "*!*@*", { "DK-Entrope!entrope@clan-dk.dyndns.org", 0 } }, { "*", { "anything at all!", - 0 } }, + 0 } }, { 0, { 0 } } }; @@ -22,7 +22,7 @@ struct glob_test glob_no[] = { { "*Zoot*!*@*.org", { "Zoot!Zoot@services.net", 0 } }, { "*!*@*", { "luser@host.com", - 0 } }, + 0 } }, { 0, { 0 } } }; @@ -44,21 +44,21 @@ main(UNUSED_ARG(int argc), UNUSED_ARG(char *argv[])) tools_init(); for (i = 0; glob_yes[i].glob; i++) { - for (j=0; glob_yes[i].texts[j]; j++) { - if (!match_ircglob(glob_yes[i].texts[j], glob_yes[i].glob)) { - fprintf(stderr, "%s did not match glob %s!\n", - glob_yes[i].texts[j], glob_yes[i].glob); - } - } + for (j=0; glob_yes[i].texts[j]; j++) { + if (!match_ircglob(glob_yes[i].texts[j], glob_yes[i].glob)) { + fprintf(stderr, "%s did not match glob %s!\n", + glob_yes[i].texts[j], glob_yes[i].glob); + } + } } for (i = 0; glob_no[i].glob; i++) { - for (j=0; glob_no[i].texts[j]; j++) { - if (match_ircglob(glob_no[i].texts[j], glob_no[i].glob)) { - fprintf(stderr, "%s matched glob %s!\n", - glob_no[i].texts[j], glob_no[i].glob); - } - } + for (j=0; glob_no[i].texts[j]; j++) { + if (match_ircglob(glob_no[i].texts[j], glob_no[i].glob)) { + fprintf(stderr, "%s matched glob %s!\n", + glob_no[i].texts[j], glob_no[i].glob); + } + } } for (i=0; glob_globs[i].glob; i++) { diff --git a/src/hash.c b/src/hash.c index f08a3c5..d806c27 100644 --- a/src/hash.c +++ b/src/hash.c @@ -49,13 +49,13 @@ void reg_server_link_func(server_link_func_t handler) { if (slf_used == slf_size) { - if (slf_size) { - slf_size <<= 1; - slf_list = realloc(slf_list, slf_size*sizeof(server_link_func_t)); - } else { - slf_size = 8; - slf_list = malloc(slf_size*sizeof(server_link_func_t)); - } + if (slf_size) { + slf_size <<= 1; + slf_list = realloc(slf_list, slf_size*sizeof(server_link_func_t)); + } else { + slf_size = 8; + slf_list = malloc(slf_size*sizeof(server_link_func_t)); + } } slf_list[slf_used++] = handler; } @@ -73,13 +73,13 @@ void reg_new_user_func(new_user_func_t handler) { if (nuf_used == nuf_size) { - if (nuf_size) { - nuf_size <<= 1; - nuf_list = realloc(nuf_list, nuf_size*sizeof(new_user_func_t)); - } else { - nuf_size = 8; - nuf_list = malloc(nuf_size*sizeof(new_user_func_t)); - } + if (nuf_size) { + nuf_size <<= 1; + nuf_list = realloc(nuf_list, nuf_size*sizeof(new_user_func_t)); + } else { + nuf_size = 8; + nuf_list = malloc(nuf_size*sizeof(new_user_func_t)); + } } nuf_list[nuf_used++] = handler; } @@ -110,13 +110,13 @@ void reg_del_user_func(del_user_func_t handler) { if (duf_used == duf_size) { - if (duf_size) { - duf_size <<= 1; - duf_list = realloc(duf_list, duf_size*sizeof(del_user_func_t)); - } else { - duf_size = 8; - duf_list = malloc(duf_size*sizeof(del_user_func_t)); - } + if (duf_size) { + duf_size <<= 1; + duf_list = realloc(duf_list, duf_size*sizeof(del_user_func_t)); + } else { + duf_size = 8; + duf_list = malloc(duf_size*sizeof(del_user_func_t)); + } } duf_list[duf_used++] = handler; } @@ -139,13 +139,13 @@ ReintroduceUser(struct userNode *user) { struct mod_chanmode change; unsigned int n; - + irc_user(user); mod_chanmode_init(&change); change.argc = 1; for (n = 0; n < user->channels.used; n++) { struct modeNode *mn = user->channels.list[n]; - irc_join(user, mn->channel); + irc_join(user, mn->channel); if (mn->modes) { change.args[0].mode = mn->modes; change.args[0].u.member = mn; @@ -253,13 +253,13 @@ void reg_new_channel_func(new_channel_func_t handler) { if (ncf_used == ncf_size) { - if (ncf_size) { - ncf_size <<= 1; - ncf_list = realloc(ncf_list, ncf_size*sizeof(ncf_list[0])); - } else { - ncf_size = 8; - ncf_list = malloc(ncf_size*sizeof(ncf_list[0])); - } + if (ncf_size) { + ncf_size <<= 1; + ncf_list = realloc(ncf_list, ncf_size*sizeof(ncf_list[0])); + } else { + ncf_size = 8; + ncf_list = malloc(ncf_size*sizeof(ncf_list[0])); + } } ncf_list[ncf_used++] = handler; } @@ -271,13 +271,13 @@ void reg_join_func(join_func_t handler) { if (jf_used == jf_size) { - if (jf_size) { - jf_size <<= 1; - jf_list = realloc(jf_list, jf_size*sizeof(join_func_t)); - } else { - jf_size = 8; - jf_list = malloc(jf_size*sizeof(join_func_t)); - } + if (jf_size) { + jf_size <<= 1; + jf_list = realloc(jf_list, jf_size*sizeof(join_func_t)); + } else { + jf_size = 8; + jf_list = malloc(jf_size*sizeof(join_func_t)); + } } jf_list[jf_used++] = handler; } @@ -415,13 +415,13 @@ void reg_del_channel_func(del_channel_func_t handler) { if (dcf_used == dcf_size) { - if (dcf_size) { - dcf_size <<= 1; - dcf_list = realloc(dcf_list, dcf_size*sizeof(dcf_list[0])); - } else { - dcf_size = 8; - dcf_list = malloc(dcf_size*sizeof(dcf_list[0])); - } + if (dcf_size) { + dcf_size <<= 1; + dcf_list = realloc(dcf_list, dcf_size*sizeof(dcf_list[0])); + } else { + dcf_size = 8; + dcf_list = malloc(dcf_size*sizeof(dcf_list[0])); + } } dcf_list[dcf_used++] = handler; } @@ -440,7 +440,7 @@ DelChannel(struct chanNode *channel) /* go through all channel members and delete them from the channel */ for (n=channel->members.used; n>0; ) - DelChannelUser(channel->members.list[--n]->user, channel, NULL, 1); + DelChannelUser(channel->members.list[--n]->user, channel, NULL, 1); /* delete all channel bans */ for (n=channel->banlist.used; n>0; ) @@ -458,28 +458,28 @@ DelChannel(struct chanNode *channel) struct modeNode * AddChannelUser(struct userNode *user, struct chanNode* channel) { - struct modeNode *mNode; - unsigned int n; + struct modeNode *mNode; + unsigned int n; - mNode = GetUserMode(channel, user); - if (mNode) + mNode = GetUserMode(channel, user); + if (mNode) return mNode; - mNode = malloc(sizeof(*mNode)); + mNode = malloc(sizeof(*mNode)); - /* set up modeNode */ - mNode->channel = channel; - mNode->user = user; - mNode->modes = 0; + /* set up modeNode */ + mNode->channel = channel; + mNode->user = user; + mNode->modes = 0; mNode->oplevel = -1; mNode->idle_since = now; - /* Add modeNode to channel and to user. + /* Add modeNode to channel and to user. * We have to do this before calling join funcs in case the * modeNode is manipulated (e.g. chanserv ops the user). */ - modeList_append(&channel->members, mNode); - modeList_append(&user->channels, mNode); + modeList_append(&channel->members, mNode); + modeList_append(&user->channels, mNode); if (channel->members.used == 1 && !(channel->modes & MODE_REGISTERED) @@ -493,10 +493,10 @@ AddChannelUser(struct userNode *user, struct chanNode* channel) return NULL; } - if (IsLocal(user)) + if (IsLocal(user)) irc_join(user, channel); - return mNode; + return mNode; } static part_func_t *pf_list; @@ -506,13 +506,13 @@ void reg_part_func(part_func_t handler) { if (pf_used == pf_size) { - if (pf_size) { - pf_size <<= 1; - pf_list = realloc(pf_list, pf_size*sizeof(part_func_t)); - } else { - pf_size = 8; - pf_list = malloc(pf_size*sizeof(part_func_t)); - } + if (pf_size) { + pf_size <<= 1; + pf_list = realloc(pf_list, pf_size*sizeof(part_func_t)); + } else { + pf_size = 8; + pf_list = malloc(pf_size*sizeof(part_func_t)); + } } pf_list[pf_used++] = handler; } @@ -567,13 +567,13 @@ DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reas /* make callbacks */ for (n=0; nmembers.used && !channel->locks + if (!deleting && !channel->members.used && !channel->locks && !(channel->modes & MODE_REGISTERED) && !(channel->modes & MODE_APASS)) DelChannel(channel); } @@ -588,9 +588,9 @@ KickChannelUser(struct userNode* target, struct chanNode* channel, struct userNo if (IsLocal(target)) { - /* NULL reason because we don't want a PART message to be - sent by DelChannelUser. */ - DelChannelUser(target, channel, NULL, 0); + /* NULL reason because we don't want a PART message to be + sent by DelChannelUser. */ + DelChannelUser(target, channel, NULL, 0); } } @@ -601,13 +601,13 @@ void reg_kick_func(kick_func_t handler) { if (kf_used == kf_size) { - if (kf_size) { - kf_size <<= 1; - kf_list = realloc(kf_list, kf_size*sizeof(kick_func_t)); - } else { - kf_size = 8; - kf_list = malloc(kf_size*sizeof(kick_func_t)); - } + if (kf_size) { + kf_size <<= 1; + kf_list = realloc(kf_list, kf_size*sizeof(kick_func_t)); + } else { + kf_size = 8; + kf_list = malloc(kf_size*sizeof(kick_func_t)); + } } kf_list[kf_used++] = handler; } @@ -626,12 +626,12 @@ ChannelUserKicked(struct userNode* kicker, struct userNode* victim, struct chanN mn->idle_since = now; for (n=0; nbanlist.used; n++) - if (match_ircglobs(channel->banlist.list[n]->ban, ban)) - return 1; + if (match_ircglobs(channel->banlist.list[n]->ban, ban)) + return 1; return 0; } @@ -651,13 +651,13 @@ void reg_topic_func(topic_func_t handler) { if (tf_used == tf_size) { - if (tf_size) { - tf_size <<= 1; - tf_list = realloc(tf_list, tf_size*sizeof(topic_func_t)); - } else { - tf_size = 8; - tf_list = malloc(tf_size*sizeof(topic_func_t)); - } + if (tf_size) { + tf_size <<= 1; + tf_list = realloc(tf_list, tf_size*sizeof(topic_func_t)); + } else { + tf_size = 8; + tf_list = malloc(tf_size*sizeof(topic_func_t)); + } } tf_list[tf_used++] = handler; } @@ -682,12 +682,12 @@ SetChannelTopic(struct chanNode *channel, struct userNode *user, const char *top } if (announce) { - /* We don't really care if a local user messes with the topic, + /* We don't really care if a local user messes with the topic, * so don't call the tf_list functions. */ - irc_topic(user, channel, topic); + irc_topic(user, channel, topic); } else { - for (n=0; nchannels.list); if (channel->members.used < user->channels.used) { - for (n=0; nmembers.used; n++) { + for (n=0; nmembers.used; n++) { verify(channel->members.list[n]); - if (user == channel->members.list[n]->user) { - mn = channel->members.list[n]; - break; - } - } + if (user == channel->members.list[n]->user) { + mn = channel->members.list[n]; + break; + } + } } else { - for (n=0; nchannels.used; n++) { + for (n=0; nchannels.used; n++) { verify(user->channels.list[n]); - if (channel == user->channels.list[n]->channel) { - mn = user->channels.list[n]; - break; - } - } + if (channel == user->channels.list[n]->channel) { + mn = user->channels.list[n]; + break; + } + } } return mn; } diff --git a/src/hash.h b/src/hash.h index a87956c..1da8758 100644 --- a/src/hash.h +++ b/src/hash.h @@ -25,42 +25,42 @@ #include "dict.h" #include "policer.h" -#define MODE_CHANOP 0x0001 /* +o USER */ -#define MODE_VOICE 0x0002 /* +v USER */ -#define MODE_PRIVATE 0x0004 /* +p */ -#define MODE_SECRET 0x0008 /* +s */ -#define MODE_MODERATED 0x0010 /* +m */ -#define MODE_TOPICLIMIT 0x0020 /* +t */ -#define MODE_INVITEONLY 0x0040 /* +i */ -#define MODE_NOPRIVMSGS 0x0080 /* +n */ -#define MODE_KEY 0x0100 /* +k KEY */ -#define MODE_BAN 0x0200 /* +b BAN */ -#define MODE_LIMIT 0x0400 /* +l LIMIT */ -#define MODE_DELAYJOINS 0x0800 /* +D */ -#define MODE_REGONLY 0x1000 /* ircu +r, Bahamut +R */ -#define MODE_NOCOLORS 0x2000 /* +c */ -#define MODE_NOCTCPS 0x4000 /* +C */ -#define MODE_REGISTERED 0x8000 /* Bahamut +r */ -#define MODE_APASS 0x10000 /* +A adminpass */ -#define MODE_UPASS 0x20000 /* +U userpass */ -#define MODE_REMOVE 0x80000000 - -#define FLAGS_OPER 0x0001 /* global operator +o */ -#define FLAGS_INVISIBLE 0x0004 /* invisible +i */ -#define FLAGS_WALLOP 0x0008 /* receives wallops +w */ -#define FLAGS_DEAF 0x0020 /* deaf +d */ -#define FLAGS_SERVICE 0x0040 /* cannot be kicked, killed or deoped +k */ -#define FLAGS_GLOBAL 0x0080 /* receives global messages +g */ -#define FLAGS_NOCHAN 0x0100 /* hide channels in whois +n */ -#define FLAGS_PERSISTENT 0x0200 /* for reserved nicks, this isn't just one-shot */ -#define FLAGS_GAGGED 0x0400 /* for gagged users */ -#define FLAGS_AWAY 0x0800 /* for away users */ -#define FLAGS_STAMPED 0x1000 /* for users who have been stamped */ -#define FLAGS_HIDDEN_HOST 0x2000 /* user's host is masked by their account */ -#define FLAGS_REGNICK 0x4000 /* user owns their current nick */ -#define FLAGS_REGISTERING 0x8000 /* user has issued account register command, is waiting for email cookie */ -#define FLAGS_DUMMY 0x10000 /* user is not announced to other servers */ -#define FLAGS_NOIDLE 0x20000 /* hide idle time in whois +I */ +#define MODE_CHANOP 0x0001 /* +o USER */ +#define MODE_VOICE 0x0002 /* +v USER */ +#define MODE_PRIVATE 0x0004 /* +p */ +#define MODE_SECRET 0x0008 /* +s */ +#define MODE_MODERATED 0x0010 /* +m */ +#define MODE_TOPICLIMIT 0x0020 /* +t */ +#define MODE_INVITEONLY 0x0040 /* +i */ +#define MODE_NOPRIVMSGS 0x0080 /* +n */ +#define MODE_KEY 0x0100 /* +k KEY */ +#define MODE_BAN 0x0200 /* +b BAN */ +#define MODE_LIMIT 0x0400 /* +l LIMIT */ +#define MODE_DELAYJOINS 0x0800 /* +D */ +#define MODE_REGONLY 0x1000 /* ircu +r, Bahamut +R */ +#define MODE_NOCOLORS 0x2000 /* +c */ +#define MODE_NOCTCPS 0x4000 /* +C */ +#define MODE_REGISTERED 0x8000 /* Bahamut +r */ +#define MODE_APASS 0x10000 /* +A adminpass */ +#define MODE_UPASS 0x20000 /* +U userpass */ +#define MODE_REMOVE 0x80000000 + +#define FLAGS_OPER 0x0001 /* global operator +o */ +#define FLAGS_INVISIBLE 0x0004 /* invisible +i */ +#define FLAGS_WALLOP 0x0008 /* receives wallops +w */ +#define FLAGS_DEAF 0x0020 /* deaf +d */ +#define FLAGS_SERVICE 0x0040 /* cannot be kicked, killed or deoped +k */ +#define FLAGS_GLOBAL 0x0080 /* receives global messages +g */ +#define FLAGS_NOCHAN 0x0100 /* hide channels in whois +n */ +#define FLAGS_PERSISTENT 0x0200 /* for reserved nicks, this isn't just one-shot */ +#define FLAGS_GAGGED 0x0400 /* for gagged users */ +#define FLAGS_AWAY 0x0800 /* for away users */ +#define FLAGS_STAMPED 0x1000 /* for users who have been stamped */ +#define FLAGS_HIDDEN_HOST 0x2000 /* user's host is masked by their account */ +#define FLAGS_REGNICK 0x4000 /* user owns their current nick */ +#define FLAGS_REGISTERING 0x8000 /* user has issued account register command, is waiting for email cookie */ +#define FLAGS_DUMMY 0x10000 /* user is not announced to other servers */ +#define FLAGS_NOIDLE 0x20000 /* hide idle time in whois +I */ #define IsOper(x) ((x)->modes & FLAGS_OPER) #define IsService(x) ((x)->modes & FLAGS_SERVICE) @@ -75,7 +75,7 @@ #define IsStamped(x) ((x)->modes & FLAGS_STAMPED) #define IsHiddenHost(x) ((x)->modes & FLAGS_HIDDEN_HOST) #define IsReggedNick(x) ((x)->modes & FLAGS_REGNICK) -#define IsRegistering(x) ((x)->modes & FLAGS_REGISTERING) +#define IsRegistering(x) ((x)->modes & FLAGS_REGISTERING) #define IsDummy(x) ((x)->modes & FLAGS_DUMMY) #define IsNoIdle(x) ((x)->modes & FLAGS_NOIDLE) #define IsFakeHost(x) ((x)->fakehost[0] != '\0') @@ -89,8 +89,8 @@ #define CHANNELLEN 200 #define MAXOPLEVEL 999 -#define MAXMODEPARAMS 6 -#define MAXBANS 45 +#define MAXMODEPARAMS 6 +#define MAXBANS 45 /* IDLEN is 6 because it takes 5.33 Base64 digits to store 32 bytes. */ #define IDLEN 6 diff --git a/src/heap.c b/src/heap.c index e1c7f8c..28ed962 100644 --- a/src/heap.c +++ b/src/heap.c @@ -63,12 +63,12 @@ heap_heapify_up(heap_t heap, unsigned int index) last_key = heap->data[index*2]; last_data = heap->data[index*2+1]; while (index > 0) { - parent = (index - 1) >> 1; - res = heap->comparator(last_key, heap->data[parent*2]); - if (res > 0) break; - heap->data[index*2] = heap->data[parent*2]; - heap->data[index*2+1] = heap->data[parent*2+1]; - index = parent; + parent = (index - 1) >> 1; + res = heap->comparator(last_key, heap->data[parent*2]); + if (res > 0) break; + heap->data[index*2] = heap->data[parent*2]; + heap->data[index*2+1] = heap->data[parent*2+1]; + index = parent; } heap->data[index*2] = last_key; heap->data[index*2+1] = last_data; @@ -81,8 +81,8 @@ void heap_insert(heap_t heap, void *key, void *data) { if (heap->data_used == heap->data_alloc) { - heap->data_alloc *= 2; - heap->data = realloc(heap->data, 2*heap->data_alloc*sizeof(void*)); + heap->data_alloc *= 2; + heap->data = realloc(heap->data, 2*heap->data_alloc*sizeof(void*)); } heap->data[heap->data_used*2] = key; heap->data[heap->data_used*2+1] = data; @@ -115,16 +115,16 @@ heap_heapify_down(heap_t heap, int pos) last_data = heap->data[pos*2+1]; /* start at left child */ while ((child=pos*2+1) < heap->data_used) { - /* use right child if it exists and is smaller */ - if (child+1 < heap->data_used) { - res = heap->comparator(heap->data[(child+1)*2], heap->data[child*2]); - if (res < 0) child = child+1; - } - res = heap->comparator(last_key, heap->data[child*2]); - if (res <= 0) break; - heap->data[pos*2] = heap->data[child*2]; - heap->data[pos*2+1] = heap->data[child*2+1]; - pos = child; + /* use right child if it exists and is smaller */ + if (child+1 < heap->data_used) { + res = heap->comparator(heap->data[(child+1)*2], heap->data[child*2]); + if (res < 0) child = child+1; + } + res = heap->comparator(last_key, heap->data[child*2]); + if (res <= 0) break; + heap->data[pos*2] = heap->data[child*2]; + heap->data[pos*2+1] = heap->data[child*2+1]; + pos = child; } heap->data[pos*2] = last_key; heap->data[pos*2+1] = last_data; @@ -179,7 +179,7 @@ heap_remove_pred(heap_t heap, int (*pred)(void *key, void *data, void *extra), v pos = 1; } while (pos < heap->data_used) { - if (pred(heap->data[pos*2], heap->data[pos*2+1], extra)) { + if (pred(heap->data[pos*2], heap->data[pos*2+1], extra)) { heap_remove(heap, pos); pos = 0; } else { diff --git a/src/helpfile.c b/src/helpfile.c index 532bcb8..d090a4c 100644 --- a/src/helpfile.c +++ b/src/helpfile.c @@ -38,7 +38,7 @@ static const struct message_entry msgtab[] = { { NULL, NULL } }; -#define DEFAULT_LINE_SIZE MAX_LINE_SIZE +#define DEFAULT_LINE_SIZE MAX_LINE_SIZE #define DEFAULT_TABLE_SIZE 80 extern struct userNode *global, *chanserv, *opserv, *nickserv; @@ -419,8 +419,8 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle /* figure out how to send the messages */ if (handle) { - msg_type |= (HANDLE_FLAGGED(handle, USE_PRIVMSG) ? 1 : 0); - use_color = HANDLE_FLAGGED(handle, MIRC_COLOR); + msg_type |= (HANDLE_FLAGGED(handle, USE_PRIVMSG) ? 1 : 0); + use_color = HANDLE_FLAGGED(handle, MIRC_COLOR); size = handle->screen_width; if (size > sizeof(line)) size = sizeof(line); @@ -450,20 +450,20 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle expand_pos = pos = 0; chars_sent = 0; while (input.list[ipos]) { - char ch, *value, *free_value; + char ch, *value, *free_value; while ((ch = input.list[ipos]) && (ch != '$') && (ch != '\n') && (pos < size)) { - line[pos++] = ch; + line[pos++] = ch; ipos++; - } + } - if (!input.list[ipos]) + if (!input.list[ipos]) goto send_line; if (input.list[ipos] == '\n') { ipos++; goto send_line; } - if (pos == size) { + if (pos == size) { unsigned int new_ipos; /* Scan backwards for a space in the input, until we hit * either the last newline or the last variable expansion. @@ -488,53 +488,53 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle ipos = new_ipos; while (input.list[ipos] == ' ') ipos++; - goto send_line; - } + goto send_line; + } free_value = 0; - switch (input.list[++ipos]) { + switch (input.list[++ipos]) { /* Literal '$' or end of string. */ - case 0: - ipos--; - case '$': - value = "$"; - break; - /* The following two expand to mIRC color codes if enabled - by the user. */ - case 'b': - value = use_color ? "\002" : ""; - break; - case 'o': - value = use_color ? "\017" : ""; - break; + case 0: + ipos--; + case '$': + value = "$"; + break; + /* The following two expand to mIRC color codes if enabled + by the user. */ + case 'b': + value = use_color ? "\002" : ""; + break; + case 'o': + value = use_color ? "\017" : ""; + break; case 'r': value = use_color ? "\026" : ""; break; - case 'u': - value = use_color ? "\037" : ""; - break; - /* Service nicks. */ + case 'u': + value = use_color ? "\037" : ""; + break; + /* Service nicks. */ case 'S': value = src->nick; break; - case 'G': - value = global ? global->nick : "Global"; - break; - case 'C': - value = chanserv ? chanserv->nick : "ChanServ"; - break; - case 'O': - value = opserv ? opserv->nick : "OpServ"; - break; - case 'N': + case 'G': + value = global ? global->nick : "Global"; + break; + case 'C': + value = chanserv ? chanserv->nick : "ChanServ"; + break; + case 'O': + value = opserv ? opserv->nick : "OpServ"; + break; + case 'N': value = nickserv ? nickserv->nick : "NickServ"; break; case 's': value = self->name; break; - case 'H': - value = handle ? handle->handle : "Account"; - break; + case 'H': + value = handle ? handle->handle : "Account"; + break; #define SEND_LINE(TRUNCED) do { \ line[pos] = 0; \ if (pos > 0) { \ @@ -547,9 +547,9 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle newline_ipos = ipos; \ if (!(msg_type & MSG_TYPE_MULTILINE)) return chars_sent; \ } while (0) - /* Custom expansion handled by helpfile-specific function. */ - case '{': - case '(': { + /* Custom expansion handled by helpfile-specific function. */ + case '{': + case '(': { struct helpfile_expansion exp; char *name_end = input.list + ipos + 1, *colon = NULL; @@ -595,14 +595,14 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle ipos = name_end - input.list; break; } - default: + default: fallthrough: value = alloca(3); value[0] = '$'; value[1] = input.list[ipos]; value[2] = 0; - } - ipos++; + } + ipos++; while ((pos + strlen(value) > size) || strchr(value, '\n')) { unsigned int avail; avail = size - pos - 1; @@ -639,10 +639,10 @@ vsend_message(const char *dest, struct userNode *src, struct handle_info *handle } } length = strlen(value); - memcpy(line + pos, value, length); + memcpy(line + pos, value, length); if (free_value) free(free_value); - pos += length; + pos += length; if ((pos < size-1) && input.list[ipos]) { expand_pos = pos; expand_ipos = ipos; @@ -733,7 +733,7 @@ send_help(struct userNode *dest, struct userNode *src, struct helpfile *hf, cons if (!rec) return send_message(dest, src, "MSG_TOPIC_UNKNOWN"); if (rec->type != RECDB_QSTRING) - return send_message(dest, src, "HFMSG_HELP_NOT_STRING"); + return send_message(dest, src, "HFMSG_HELP_NOT_STRING"); return _send_help(dest, src, hf->expand, rec->d.qstring); } @@ -937,25 +937,25 @@ unlistify_help(const char *key, void *data, void *extra) switch (rd->type) { case RECDB_QSTRING: - dict_insert(newdb, strdup(key), alloc_record_data_qstring(GET_RECORD_QSTRING(rd))); - return 0; + dict_insert(newdb, strdup(key), alloc_record_data_qstring(GET_RECORD_QSTRING(rd))); + return 0; case RECDB_STRING_LIST: { - struct string_list *slist = GET_RECORD_STRING_LIST(rd); - char *dest; - unsigned int totlen, len, i; - - for (i=totlen=0; iused; i++) - totlen = totlen + strlen(slist->list[i]) + 1; - dest = alloca(totlen+1); - for (i=totlen=0; iused; i++) { - len = strlen(slist->list[i]); - memcpy(dest+totlen, slist->list[i], len); - dest[totlen+len] = '\n'; - totlen = totlen + len + 1; - } - dest[totlen] = 0; - dict_insert(newdb, strdup(key), alloc_record_data_qstring(dest)); - return 0; + struct string_list *slist = GET_RECORD_STRING_LIST(rd); + char *dest; + unsigned int totlen, len, i; + + for (i=totlen=0; iused; i++) + totlen = totlen + strlen(slist->list[i]) + 1; + dest = alloca(totlen+1); + for (i=totlen=0; iused; i++) { + len = strlen(slist->list[i]); + memcpy(dest+totlen, slist->list[i], len); + dest[totlen+len] = '\n'; + totlen = totlen + len + 1; + } + dest[totlen] = 0; + dict_insert(newdb, strdup(key), alloc_record_data_qstring(dest)); + return 0; } case RECDB_OBJECT: { dict_iterator_t it; @@ -985,7 +985,7 @@ unlistify_help(const char *key, void *data, void *extra) return 0; } default: - return 1; + return 1; } } @@ -1006,8 +1006,8 @@ open_helpfile(const char *fname, expand_func_t expand) dict_insert(language_find("C")->helpfiles, hf->name, hf); } if (db) { - dict_foreach(db, unlistify_help, hf->db); - free_database(db); + dict_foreach(db, unlistify_help, hf->db); + free_database(db); } return hf; } diff --git a/src/helpfile.h b/src/helpfile.h index c547f5e..4833d80 100644 --- a/src/helpfile.h +++ b/src/helpfile.h @@ -29,8 +29,8 @@ struct string_list; extern struct userNode *message_dest; /* message destination; useful in expansion callbacks */ -#define MIN_LINE_SIZE 40 -#define MAX_LINE_SIZE 450 +#define MIN_LINE_SIZE 40 +#define MAX_LINE_SIZE 450 #define TABLE_REPEAT_HEADERS 0x0001 /* repeat the headers for each columnset? */ #define TABLE_PAD_LEFT 0x0002 /* pad cells on the left? */ diff --git a/src/ioset.c b/src/ioset.c index 9cf1c43..861b3ae 100644 --- a/src/ioset.c +++ b/src/ioset.c @@ -98,12 +98,12 @@ ioset_init(void) #if WITH_IOSET_KQUEUE if (!engine && io_engine_kqueue.init()) - engine = &io_engine_kqueue; + engine = &io_engine_kqueue; #endif #if WITH_IOSET_EPOLL if (!engine && io_engine_epoll.init()) - engine = &io_engine_epoll; + engine = &io_engine_epoll; #endif #if WITH_IOSET_WIN32 @@ -114,9 +114,9 @@ ioset_init(void) if (engine) { /* we found one that works */ } else if (io_engine_select.init()) - engine = &io_engine_select; + engine = &io_engine_select; else - log_module(MAIN_LOG, LOG_FATAL, "No usable I/O engine found."); + log_module(MAIN_LOG, LOG_FATAL, "No usable I/O engine found."); log_module(MAIN_LOG, LOG_DEBUG, "Using %s I/O engine.", engine->name); } @@ -166,17 +166,17 @@ struct io_fd *ioset_listen(struct sockaddr *local, unsigned int sa_size, void *d fd = socket(local ? local->sa_family : PF_INET, SOCK_STREAM, 0); if (fd < 0) { - log_module(MAIN_LOG, LOG_ERROR, "Unable to create listening socket: %s", strerror(errno)); - return NULL; + log_module(MAIN_LOG, LOG_ERROR, "Unable to create listening socket: %s", strerror(errno)); + return NULL; } if (local && sa_size) { - res = bind(fd, local, sa_size); - if (res < 0) { - log_module(MAIN_LOG, LOG_ERROR, "Unable to bind listening socket %d: %s", fd, strerror(errno)); - close(fd); - return NULL; - } + res = bind(fd, local, sa_size); + if (res < 0) { + log_module(MAIN_LOG, LOG_ERROR, "Unable to bind listening socket %d: %s", fd, strerror(errno)); + close(fd); + return NULL; + } opt = 1; res = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt, sizeof(opt)); @@ -187,15 +187,15 @@ struct io_fd *ioset_listen(struct sockaddr *local, unsigned int sa_size, void *d res = listen(fd, 1); if (res < 0) { - log_module(MAIN_LOG, LOG_ERROR, "Unable to listen on socket %d: %s", fd, strerror(errno)); - close(fd); - return NULL; + log_module(MAIN_LOG, LOG_ERROR, "Unable to listen on socket %d: %s", fd, strerror(errno)); + close(fd); + return NULL; } io_fd = ioset_add(fd); if (!io_fd) { - close(fd); - return NULL; + close(fd); + return NULL; } io_fd->state = IO_LISTENING; io_fd->data = data; @@ -309,7 +309,7 @@ ioset_try_write(struct io_fd *fd) { void ioset_close(struct io_fd *fdp, int os_close) { if (!fdp) - return; + return; if (active_fd == fdp) active_fd = NULL; if (fdp->destroy_cb) @@ -331,7 +331,7 @@ ioset_close(struct io_fd *fdp, int os_close) { if (fdp->send.get != fdp->send.put && (os_close & 2)) { int flags; - flags = fcntl(fdp->fd, F_GETFL); + flags = fcntl(fdp->fd, F_GETFL); fcntl(fdp->fd, F_SETFL, flags&~O_NONBLOCK); ioset_try_write(fdp); /* it may need to send the beginning of the buffer now.. */ @@ -356,8 +356,8 @@ ioset_accept(struct io_fd *listener) fd = accept(listener->fd, NULL, 0); if (fd < 0) { - log_module(MAIN_LOG, LOG_ERROR, "Unable to accept new connection on listener %d: %s", listener->fd, strerror(errno)); - return; + log_module(MAIN_LOG, LOG_ERROR, "Unable to accept new connection on listener %d: %s", listener->fd, strerror(errno)); + return; } new_fd = ioset_add(fd); @@ -485,7 +485,7 @@ void ioset_events(struct io_fd *fd, int readable, int writable) { if (!fd || (!readable && !writable)) - return; + return; active_fd = fd; switch (fd->state) { case IO_CLOSED: @@ -548,8 +548,8 @@ ioset_run(void) { timeout.tv_sec = wakey - now; timeout.tv_usec = 0; - if (engine->loop(&timeout)) - continue; + if (engine->loop(&timeout)) + continue; /* Call any timeq events we need to call. */ timeq_run(); diff --git a/src/log.c b/src/log.c index 8ac6cfa..ad341b8 100644 --- a/src/log.c +++ b/src/log.c @@ -606,8 +606,8 @@ log_discrim_create(struct userNode *service, struct userNode *user, unsigned int /* Assume all criteria require arguments. */ if((argc - 1) % 2) { - send_message(user, service, "MSG_MISSING_PARAMS", argv[0]); - return NULL; + send_message(user, service, "MSG_MISSING_PARAMS", argv[0]); + return NULL; } discrim = malloc(sizeof(struct logSearch)); @@ -674,10 +674,10 @@ log_discrim_create(struct userNode *service, struct userNode *user, unsigned int send_message(user, service, "MSG_INVALID_FACILITY", argv[ii]); goto fail; } - } else { - send_message(user, service, "MSG_INVALID_CRITERIA", argv[ii]); - goto fail; - } + } else { + send_message(user, service, "MSG_INVALID_CRITERIA", argv[ii]); + goto fail; + } } return discrim; @@ -707,7 +707,7 @@ entry_match(struct logSearch *discrim, struct logEntry *entry) && !match_ircglob(entry->user_hostmask, discrim->masks.user_hostmask)) || (discrim->masks.command && !match_ircglob(entry->command, discrim->masks.command))) { - return 0; + return 0; } return 1; } diff --git a/src/main-common.c b/src/main-common.c index 7ac6dce..e5d6116 100644 --- a/src/main-common.c +++ b/src/main-common.c @@ -91,7 +91,7 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) if(!uplink) { - return 0; + return 0; } uplink->name = (char *)key; @@ -105,7 +105,7 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) str = database_get_data(rd->d.object, "enabled", RECDB_QSTRING); if(str) { - enabled = atoi(str) ? 1 : 0; + enabled = atoi(str) ? 1 : 0; } cManager.enabled += enabled; @@ -123,14 +123,14 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) if (!getaddrinfo(str, NULL, &hints, &ai)) { uplink->bind_addr_len = ai->ai_addrlen; - uplink->bind_addr = calloc(1, ai->ai_addrlen); + uplink->bind_addr = calloc(1, ai->ai_addrlen); memcpy(uplink->bind_addr, ai->ai_addr, ai->ai_addrlen); freeaddrinfo(ai); } else { - uplink->bind_addr = NULL; - uplink->bind_addr_len = 0; + uplink->bind_addr = NULL; + uplink->bind_addr_len = 0; } uplink->next = cManager.uplinks; @@ -138,7 +138,7 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) if(cManager.uplinks) { - cManager.uplinks->prev = uplink; + cManager.uplinks->prev = uplink; } cManager.uplinks = uplink; @@ -150,9 +150,9 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) && !irccasecmp(uplink->host, cManager.uplink->host) && uplink->port == cManager.uplink->port) { - uplink->state = cManager.uplink->state; - uplink->tries = cManager.uplink->tries; - cManager.uplink = uplink; + uplink->state = cManager.uplink->state; + uplink->tries = cManager.uplink->tries; + cManager.uplink = uplink; } return 0; @@ -174,7 +174,7 @@ uplink_compile(void) if(!(conf_node = conf_get_data("uplinks", RECDB_OBJECT))) { log_module(MAIN_LOG, LOG_FATAL, "No uplinks configured; giving up."); - exit(1); + exit(1); } cManager.enabled = 0; @@ -184,29 +184,29 @@ uplink_compile(void) is a reference to one of these, because it won't get dereferenced. */ if(oldUplinks) { - struct uplinkNode *uplink, *next; + struct uplinkNode *uplink, *next; - oldUplinks->prev->next = NULL; + oldUplinks->prev->next = NULL; - for(uplink = oldUplinks; uplink; uplink = next) - { - next = uplink->next; + for(uplink = oldUplinks; uplink; uplink = next) + { + next = uplink->next; free(uplink->bind_addr); - free(uplink); - } + free(uplink); + } } /* If the uplink hasn't changed, it's either NULL or pointing at an uplink that was just deleted, select a new one. */ if(cManager.uplink == oldUplink) { - if(oldUplink) - { - irc_squit(self, "Uplinks updated; selecting new uplink.", NULL); - } + if(oldUplink) + { + irc_squit(self, "Uplinks updated; selecting new uplink.", NULL); + } - cManager.uplink = NULL; - uplink_select(NULL); + cManager.uplink = NULL; + uplink_select(NULL); } } @@ -217,15 +217,15 @@ uplink_find(char *name) if(!cManager.enabled || !cManager.uplinks) { - return NULL; + return NULL; } for(uplink = cManager.uplinks; uplink; uplink = uplink->next) { - if(!strcasecmp(uplink->name, name)) - { - return uplink; - } + if(!strcasecmp(uplink->name, name)) + { + return uplink; + } } return NULL; @@ -239,84 +239,84 @@ uplink_select(char *name) if(!cManager.enabled || !cManager.uplinks) { - log_module(MAIN_LOG, LOG_FATAL, "No uplinks enabled; giving up."); - exit(1); + log_module(MAIN_LOG, LOG_FATAL, "No uplinks enabled; giving up."); + exit(1); } if(!cManager.uplink) { - start = cManager.uplinks; + start = cManager.uplinks; } else { - start = cManager.uplink->next; - if(!start) - { - start = cManager.uplinks; - } + start = cManager.uplink->next; + if(!start) + { + start = cManager.uplinks; + } } stop = 0; for(uplink = start; uplink; uplink = next) { - next = uplink->next ? uplink->next : cManager.uplinks; - - if(stop) - { - uplink = NULL; - break; - } - - /* We've wrapped around the list. */ - if(next == start) - { - sleep((cManager.cycles >> 1) * 5); - cManager.cycles++; - - if(max_cycles && (cManager.cycles >= max_cycles)) - { - log_module(MAIN_LOG, LOG_FATAL, "Maximum uplink list cycles exceeded; giving up."); - exit(1); - } - - /* Give the uplink currently in 'uplink' consideration, - and if not selected, break on the next iteration. */ - stop = 1; - } - - /* Skip bad uplinks. */ - if(uplink->flags & UPLINK_UNAVAILABLE) - { - continue; - } - - if(name && irccasecmp(uplink->name, name)) - { - /* If we were told to connect to a specific uplink, don't stop - until we find it. - */ - continue; - } - - /* It would be possible to track uplink health through a variety - of statistics and only break on the best uplink. For now, break - on the first available one. - */ - - break; + next = uplink->next ? uplink->next : cManager.uplinks; + + if(stop) + { + uplink = NULL; + break; + } + + /* We've wrapped around the list. */ + if(next == start) + { + sleep((cManager.cycles >> 1) * 5); + cManager.cycles++; + + if(max_cycles && (cManager.cycles >= max_cycles)) + { + log_module(MAIN_LOG, LOG_FATAL, "Maximum uplink list cycles exceeded; giving up."); + exit(1); + } + + /* Give the uplink currently in 'uplink' consideration, + and if not selected, break on the next iteration. */ + stop = 1; + } + + /* Skip bad uplinks. */ + if(uplink->flags & UPLINK_UNAVAILABLE) + { + continue; + } + + if(name && irccasecmp(uplink->name, name)) + { + /* If we were told to connect to a specific uplink, don't stop + until we find it. + */ + continue; + } + + /* It would be possible to track uplink health through a variety + of statistics and only break on the best uplink. For now, break + on the first available one. + */ + + break; } if(!uplink) { - /* We are shit outta luck if every single uplink has been passed - over. Use the current uplink if possible. */ - if(!cManager.uplink || cManager.uplink->flags & UPLINK_UNAVAILABLE) - { - log_module(MAIN_LOG, LOG_FATAL, "All available uplinks exhausted; giving up."); - exit(1); - } + /* We are shit outta luck if every single uplink has been passed + over. Use the current uplink if possible. */ + if(!cManager.uplink || cManager.uplink->flags & UPLINK_UNAVAILABLE) + { + log_module(MAIN_LOG, LOG_FATAL, "All available uplinks exhausted; giving up."); + exit(1); + } - return; + return; } cManager.uplink = uplink; @@ -329,36 +329,36 @@ uplink_connect(void) if(uplink->state != DISCONNECTED) { - return 0; + return 0; } if(uplink->flags & UPLINK_UNAVAILABLE) { - uplink_select(NULL); - uplink = cManager.uplink; + uplink_select(NULL); + uplink = cManager.uplink; } if(uplink->tries) { - /* This delay could scale with the number of tries. */ - sleep(2); + /* This delay could scale with the number of tries. */ + sleep(2); } if(!create_socket_client(uplink)) { - if(uplink->max_tries && (uplink->tries >= uplink->max_tries)) - { - /* This is a bad uplink, move on. */ - uplink->flags |= UPLINK_UNAVAILABLE; - uplink_select(NULL); - } + if(uplink->max_tries && (uplink->tries >= uplink->max_tries)) + { + /* This is a bad uplink, move on. */ + uplink->flags |= UPLINK_UNAVAILABLE; + uplink_select(NULL); + } - return 0; + return 0; } else { - uplink->state = AUTHENTICATING; - irc_introduce(uplink->password); + uplink->state = AUTHENTICATING; + irc_introduce(uplink->password); } return 1; @@ -380,13 +380,13 @@ static unsigned int ef_size = 0, ef_used = 0; void reg_exit_func(exit_func_t handler) { if (ef_used == ef_size) { - if (ef_size) { - ef_size <<= 1; - ef_list = realloc(ef_list, ef_size*sizeof(exit_func_t)); - } else { - ef_size = 8; - ef_list = malloc(ef_size*sizeof(exit_func_t)); - } + if (ef_size) { + ef_size <<= 1; + ef_list = realloc(ef_list, ef_size*sizeof(exit_func_t)); + } else { + ef_size = 8; + ef_list = malloc(ef_size*sizeof(exit_func_t)); + } } ef_list[ef_used++] = handler; } @@ -402,7 +402,7 @@ void call_exit_funcs(void) */ while (n > 0) { - ef_list[--n](); + ef_list[--n](); } free(ef_list); ef_used = ef_size = 0; diff --git a/src/main-win32.c b/src/main-win32.c index 03b0036..657f991 100644 --- a/src/main-win32.c +++ b/src/main-win32.c @@ -24,8 +24,8 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int log_module(MAIN_LOG, LOG_INFO, "Initializing daemon..."); if (!conf_read(services_config)) { - log_module(MAIN_LOG, LOG_FATAL, "Unable to read %s.", services_config); - exit(0); + log_module(MAIN_LOG, LOG_FATAL, "Unable to read %s.", services_config); + exit(0); } boot_time = time(&now); diff --git a/src/main.c b/src/main.c index eaa284d..fc890c5 100644 --- a/src/main.c +++ b/src/main.c @@ -172,32 +172,32 @@ int main(int argc, char *argv[]) sigaction(SIGCHLD, &sv, NULL); if (argc > 1) { /* parse command line, if any */ - int c; - struct option options[] = - { - {"config", 1, 0, 'c'}, + int c; + struct option options[] = + { + {"config", 1, 0, 'c'}, {"debug", 0, 0, 'd'}, - {"foreground", 0, 0, 'f'}, - {"help", 0, 0, 'h'}, - {"check", 0, 0, 'k'}, + {"foreground", 0, 0, 'f'}, + {"help", 0, 0, 'h'}, + {"check", 0, 0, 'k'}, {"replay", 1, 0, 'r'}, - {"version", 0, 0, 'v'}, - {"verbose", 0, 0, 'V'}, - {0, 0, 0, 0} - }; + {"version", 0, 0, 'v'}, + {"verbose", 0, 0, 'V'}, + {0, 0, 0, 0} + }; - while ((c = getopt_long(argc, argv, "c:kr:dfvVh", options, NULL)) != -1) { - switch(c) { - case 'c': - services_config = optarg; - break; - case 'k': - if (conf_read(services_config)) { - printf("%s appears to be a valid configuration file.\n", services_config); - } else { - printf("%s is an invalid configuration file.\n", services_config); - } - exit(0); + while ((c = getopt_long(argc, argv, "c:kr:dfvVh", options, NULL)) != -1) { + switch(c) { + case 'c': + services_config = optarg; + break; + case 'k': + if (conf_read(services_config)) { + printf("%s appears to be a valid configuration file.\n", services_config); + } else { + printf("%s is an invalid configuration file.\n", services_config); + } + exit(0); case 'r': replay_file = fopen(optarg, "r"); if (!replay_file) { @@ -209,19 +209,19 @@ int main(int argc, char *argv[]) case 'd': debug = 1; break; - case 'f': - daemon = 0; - break; - case 'v': - version(); - license(); - exit(0); - case 'h': - default: - usage(argv[0]); - exit(0); - } - } + case 'f': + daemon = 0; + break; + case 'v': + version(); + license(); + exit(0); + case 'h': + default: + usage(argv[0]); + exit(0); + } + } } version(); @@ -238,31 +238,31 @@ int main(int argc, char *argv[]) fprintf(stdout, "Initializing daemon...\n"); if (!conf_read(services_config)) { - fprintf(stderr, "Unable to read %s.\n", services_config); - exit(1); + fprintf(stderr, "Unable to read %s.\n", services_config); + exit(1); } conf_register_reload(uplink_compile); if (daemon) { - /* Attempt to fork into the background if daemon mode is on. */ - pid = fork(); - if (pid < 0) { - fprintf(stderr, "Unable to fork: %s\n", strerror(errno)); + /* Attempt to fork into the background if daemon mode is on. */ + pid = fork(); + if (pid < 0) { + fprintf(stderr, "Unable to fork: %s\n", strerror(errno)); } else if (pid > 0) { - fprintf(stdout, "Forking into the background (pid: %d)...\n", pid); - exit(0); - } - setsid(); + fprintf(stdout, "Forking into the background (pid: %d)...\n", pid); + exit(0); + } + setsid(); } file_out = fopen(PID_FILE, "w"); if (file_out == NULL) { - /* Create the main process' pid file */ - fprintf(stderr, "Unable to create PID file: %s", strerror(errno)); + /* Create the main process' pid file */ + fprintf(stderr, "Unable to create PID file: %s", strerror(errno)); } else { - fprintf(file_out, "%i\n", (int)getpid()); - fclose(file_out); + fprintf(file_out, "%i\n", (int)getpid()); + fclose(file_out); } if (daemon) { diff --git a/src/md5.c b/src/md5.c index 189d45d..4f8ce80 100644 --- a/src/md5.c +++ b/src/md5.c @@ -130,7 +130,7 @@ unsigned int inputLen; /* length of input block */ MD5Transform (context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); + MD5Transform (context->state, &input[i]); index = 0; } @@ -338,8 +338,8 @@ cryptpass_real(const char *pass, char *buffer, int seed) j = 0; } for (i=0; i> 4]; - buffer[j++] = hex_digits[buff[i] & 15]; + buffer[j++] = hex_digits[buff[i] >> 4]; + buffer[j++] = hex_digits[buff[i] & 15]; } buffer[j] = 0; return buffer; diff --git a/src/mod-blacklist.c b/src/mod-blacklist.c index a7f4e2b..73d126c 100644 --- a/src/mod-blacklist.c +++ b/src/mod-blacklist.c @@ -203,7 +203,7 @@ blacklist_check_user(struct userNode *user) if (req) { data = (struct dnsbl_data*)(req + 1); strcpy(data->client_ip, ip); - strcpy(data->zone_name, zone); + strcpy(data->zone_name, zone); } } return 0; diff --git a/src/mod-helpserv.c b/src/mod-helpserv.c index 3b8130e..00f2611 100644 --- a/src/mod-helpserv.c +++ b/src/mod-helpserv.c @@ -1236,7 +1236,7 @@ static HELPSERV_USERCMD(usercmd_wait) { return; } - for (other = req->hs->unhandled, pos = -1, count = 0; + for (other = req->hs->unhandled, pos = -1, count = 0; other; other = other->next_unhandled, ++count) { if (other == req) @@ -2298,7 +2298,7 @@ static HELPSERV_FUNC(cmd_bots) { struct helpserv_user *owner=NULL; bot = iter_data(it); - + for (it2=dict_first(bot->users); it2; it2=iter_next(it2)) { if (((struct helpserv_user *)iter_data(it2))->level == HlOwner) { owner = iter_data(it2); @@ -3721,7 +3721,7 @@ static void handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) { } } } - + if (mn->user->handle_info && (userlist = dict_find(helpserv_users_byhand_dict, mn->user->handle_info->handle, NULL))) { for (i=0; i < userlist->used; i++) { struct helpserv_user *hs_user = userlist->list[i]; @@ -3848,7 +3848,7 @@ static void associate_requests_bybot(struct helpserv_bot *hs, struct userNode *u struct helpserv_request *newest=NULL, *nicknewest=NULL; unsigned int i; const int from_opserv = 0; /* For helpserv_notice */ - + if (!(user->handle_info && (hand_reqlist = dict_find(helpserv_reqs_byhand_dict, user->handle_info->handle, NULL))) && !force_greet) { return; } @@ -3940,7 +3940,7 @@ static int handle_join(struct modeNode *mNode) { if (IsLocal(user)) return 0; - + if (!(botlist = dict_find(helpserv_bots_bychan_dict, chan->name, NULL))) return 0; @@ -4033,7 +4033,7 @@ static void handle_nickserv_rename(struct handle_info *handle, const char *old_h for (i=0; i < userlist->used; i++) dict_insert(userlist->list[i]->hs->users, handle->handle, userlist->list[i]); } - + if (reqlist) { for (i=0; i < reqlist->used; i++) { struct helpserv_request *req=reqlist->list[i]; @@ -4531,7 +4531,7 @@ int helpserv_init() { helpserv_bots_dict = dict_new(); dict_set_free_data(helpserv_bots_dict, helpserv_free_bot); - + helpserv_bots_bychan_dict = dict_new(); dict_set_free_data(helpserv_bots_bychan_dict, helpserv_botlist_free); diff --git a/src/mod-sockcheck.c b/src/mod-sockcheck.c index 5b09ff8..35ca27f 100644 --- a/src/mod-sockcheck.c +++ b/src/mod-sockcheck.c @@ -174,8 +174,8 @@ static void sockcheck_list_append(struct sockcheck_list *list, struct sockcheck_state *new_item) { if (list->used == list->size) { - list->size <<= 1; - list->list = realloc(list->list, list->size*sizeof(list->list[0])); + list->size <<= 1; + list->list = realloc(list->list, list->size*sizeof(list->list[0])); } list->list[list->used++] = new_item; } @@ -297,30 +297,30 @@ expand_var(const struct sockcheck_client *client, char var, char **p_expansion, exp_length = strlen(expansion); break; case 'i': - exp4 = client->addr->addr.in6_32[3]; - exp_length = sizeof(exp4); - expansion = (char*)&exp4; - break; + exp4 = client->addr->addr.in6_32[3]; + exp_length = sizeof(exp4); + expansion = (char*)&exp4; + break; case 'p': - exp2 = htons(client->state->port); - exp_length = sizeof(exp2); - expansion = (char*)&exp2; - break; + exp2 = htons(client->state->port); + exp_length = sizeof(exp2); + expansion = (char*)&exp2; + break; case 'u': - expansion = cManager.uplink->host; - exp_length = strlen(expansion); - break; + expansion = cManager.uplink->host; + exp_length = strlen(expansion); + break; default: log_module(PC_LOG, LOG_WARNING, "Request to expand unknown sockcheck variable $%c, using empty expansion.", var); - expansion = ""; - exp_length = 0; + expansion = ""; + exp_length = 0; } if (p_expansion) { - *p_expansion = malloc(exp_length); - memcpy(*p_expansion, expansion, exp_length); + *p_expansion = malloc(exp_length); + memcpy(*p_expansion, expansion, exp_length); } if (p_exp_length) { - *p_exp_length = exp_length; + *p_exp_length = exp_length; } } @@ -402,7 +402,7 @@ sockcheck_elaborate_state(struct sockcheck_client *client) } for (nn=0; nnstate->responses.used; nn++) { /* Set their resp_state to the start of the response. */ - client->resp_state[nn] = client->state->responses.list[nn]->template; + client->resp_state[nn] = client->state->responses.list[nn]->template; /* If it doesn't require reading, take it now. */ if (client->resp_state[nn] && !*client->resp_state[nn]) { if (SOCKCHECK_DEBUG) { @@ -429,32 +429,32 @@ sockcheck_decide(struct sockcheck_client *client, enum sockcheck_decision decisi client->addr->last_touched = now; switch (decision) { case ACCEPT: - /* do nothing */ + /* do nothing */ if (SOCKCHECK_DEBUG) { log_module(PC_LOG, LOG_INFO, "Proxy check passed for client at %s.", client->addr->hostname); } break; case REJECT: - client->addr->reason = client->state->template; - proxies_detected++; - sockcheck_issue_gline(client->addr); + client->addr->reason = client->state->template; + proxies_detected++; + sockcheck_issue_gline(client->addr); if (SOCKCHECK_DEBUG) { log_module(PC_LOG, LOG_INFO, "Proxy check rejects client at %s (%s)", client->addr->hostname, client->addr->reason); } - /* Don't compare test_index != 0 directly, because somebody - * else may have reordered the tests already. */ - if (client->tests->list[client->test_index] != tests->list[0]) { - struct sockcheck_list *new_tests = sockcheck_list_clone(tests); - struct sockcheck_state *new_first = client->tests->list[client->test_index]; + /* Don't compare test_index != 0 directly, because somebody + * else may have reordered the tests already. */ + if (client->tests->list[client->test_index] != tests->list[0]) { + struct sockcheck_list *new_tests = sockcheck_list_clone(tests); + struct sockcheck_state *new_first = client->tests->list[client->test_index]; for (n=0; (nused) && (tests->list[n] != new_first); n++) ; for (; n>0; n--) new_tests->list[n] = new_tests->list[n-1]; - new_tests->list[0] = new_first; - sockcheck_list_unref(tests); - tests = new_tests; - } + new_tests->list[0] = new_first; + sockcheck_list_unref(tests); + tests = new_tests; + } break; default: - log_module(PC_LOG, LOG_ERROR, "BUG: sockcheck_decide(\"%s\", %d): unrecognized decision.", client->addr->hostname, decision); + log_module(PC_LOG, LOG_ERROR, "BUG: sockcheck_decide(\"%s\", %d): unrecognized decision.", client->addr->hostname, decision); } n = client->client_index; sockcheck_free_client(client); @@ -477,16 +477,16 @@ sockcheck_advance(struct sockcheck_client *client, unsigned int next_state) unsigned int n, m; char buffer[201]; static const char *hexmap = "0123456789ABCDEF"; - log_module(PC_LOG, LOG_INFO, "sockcheck_advance(%s) following response %d (type %d) of %d.", client->addr->hostname, next_state, client->state->responses.list[next_state]->next->type, client->state->responses.used); - for (n=0; nread_used; n++) { - for (m=0; (m<(sizeof(buffer)-1)>>1) && ((n+m) < client->read_used); m++) { - buffer[m << 1] = hexmap[client->read[n+m] >> 4]; - buffer[m << 1 | 1] = hexmap[client->read[n+m] & 15]; - } - buffer[m<<1] = 0; - log_module(PC_LOG, LOG_INFO, " .. read data: %s", buffer); - n += m; - } + log_module(PC_LOG, LOG_INFO, "sockcheck_advance(%s) following response %d (type %d) of %d.", client->addr->hostname, next_state, client->state->responses.list[next_state]->next->type, client->state->responses.used); + for (n=0; nread_used; n++) { + for (m=0; (m<(sizeof(buffer)-1)>>1) && ((n+m) < client->read_used); m++) { + buffer[m << 1] = hexmap[client->read[n+m] >> 4]; + buffer[m << 1 | 1] = hexmap[client->read[n+m] & 15]; + } + buffer[m<<1] = 0; + log_module(PC_LOG, LOG_INFO, " .. read data: %s", buffer); + n += m; + } sockcheck_print_client(client); } @@ -527,66 +527,66 @@ sockcheck_readable(struct io_fd *fd) if (res < 0) { switch (res = errno) { default: - log_module(PC_LOG, LOG_ERROR, "BUG: sockcheck_readable(%d/%s): read() returned errno %d (%s)", fd->fd, client->addr->hostname, errno, strerror(errno)); + log_module(PC_LOG, LOG_ERROR, "BUG: sockcheck_readable(%d/%s): read() returned errno %d (%s)", fd->fd, client->addr->hostname, errno, strerror(errno)); case EAGAIN: return; case ECONNRESET: sockcheck_advance(client, client->state->responses.used - 1); return; - } + } } else if (res == 0) { sockcheck_advance(client, client->state->responses.used - 1); return; } else { - client->read_used += res; + client->read_used += res; } if (SOCKCHECK_DEBUG) { unsigned int n, m; char buffer[201]; static const char *hexmap = "0123456789ABCDEF"; - for (n=0; nread_used; n++) { - for (m=0; (m<(sizeof(buffer)-1)>>1) && ((n+m) < client->read_used); m++) { - buffer[m << 1] = hexmap[client->read[n+m] >> 4]; - buffer[m << 1 | 1] = hexmap[client->read[n+m] & 15]; - } - buffer[m<<1] = 0; - log_module(PC_LOG, LOG_INFO, "read %d bytes data: %s", client->read_used, buffer); - n += m; - } + for (n=0; nread_used; n++) { + for (m=0; (m<(sizeof(buffer)-1)>>1) && ((n+m) < client->read_used); m++) { + buffer[m << 1] = hexmap[client->read[n+m] >> 4]; + buffer[m << 1 | 1] = hexmap[client->read[n+m] & 15]; + } + buffer[m<<1] = 0; + log_module(PC_LOG, LOG_INFO, "read %d bytes data: %s", client->read_used, buffer); + n += m; + } } /* See if what's been read matches any of the expected responses */ while (client->read_pos < client->read_used) { unsigned int last_pos = client->read_pos; - char bleh; - const char *resp_state; + char bleh; + const char *resp_state; - for (nn=0; nn<(client->state->responses.used-1); nn++) { + for (nn=0; nn<(client->state->responses.used-1); nn++) { char *expected; unsigned int exp_length = 1, free_exp = 0; - /* compare against possible target */ - resp_state = client->resp_state[nn]; - if (resp_state == NULL) continue; - switch (*resp_state) { - case '=': + /* compare against possible target */ + resp_state = client->resp_state[nn]; + if (resp_state == NULL) continue; + switch (*resp_state) { + case '=': bleh = resp_state[1]; expected = &bleh; break; - case '.': + case '.': /* any character passes */ client->read_pos++; exp_length = 0; break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - bleh = hexvals[(unsigned char)resp_state[0]] << 4 + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + bleh = hexvals[(unsigned char)resp_state[0]] << 4 | hexvals[(unsigned char)resp_state[1]]; expected = &bleh; - break; - case '$': - expand_var(client, resp_state[1], &expected, &exp_length); + break; + case '$': + expand_var(client, resp_state[1], &expected, &exp_length); free_exp = 1; break; } @@ -601,27 +601,27 @@ sockcheck_readable(struct io_fd *fd) resp_state -= 2; } if (free_exp) free(expected); - if (resp_state) { - client->resp_state[nn] = resp_state = resp_state + 2; - if (!*resp_state) { + if (resp_state) { + client->resp_state[nn] = resp_state = resp_state + 2; + if (!*resp_state) { sockcheck_advance(client, nn); - return; - } - } else { - client->resp_state[nn] = NULL; - } - } + return; + } + } else { + client->resp_state[nn] = NULL; + } + } if (last_pos == client->read_pos) break; } /* nothing seemed to match. what now? */ if (client->read_used >= client->read_size) { - /* we got more data than we expected to get .. don't read any more */ + /* we got more data than we expected to get .. don't read any more */ if (SOCKCHECK_DEBUG) { log_module(PC_LOG, LOG_INFO, "Buffer filled (unmatched) for client %s", client->addr->hostname); } sockcheck_advance(client, client->state->responses.used-1); - return; + return; } } @@ -691,7 +691,7 @@ sockcheck_start_client(unsigned int idx) return; } memmove(pending_sci_list.list, pending_sci_list.list+1, - (--pending_sci_list.used)*sizeof(pending_sci_list.list[0])); + (--pending_sci_list.used)*sizeof(pending_sci_list.list[0])); sockcheck_num_clients++; if (!tests) return; client = client_list[idx] = sockcheck_alloc_client(sci); @@ -772,29 +772,29 @@ sockcheck_create_response(const char *key, void *data, void *extra) response_list_append(&parent->responses, resp); /* now figure out how to create resp->next */ if ((str = GET_RECORD_QSTRING(rd))) { - if (!ircncasecmp(str, "reject", 6)) { - resp->next->type = REJECT; - } else if (!ircncasecmp(str, "accept", 6)) { - resp->next->type = ACCEPT; - } else { - log_module(PC_LOG, LOG_ERROR, "Error: unknown sockcheck decision `%s', defaulting to accept.", str); - resp->next->type = ACCEPT; - } - if (str[6]) { - resp->next->template = strdup(str+7); - } else { - resp->next->template = strdup("No explanation given"); - } + if (!ircncasecmp(str, "reject", 6)) { + resp->next->type = REJECT; + } else if (!ircncasecmp(str, "accept", 6)) { + resp->next->type = ACCEPT; + } else { + log_module(PC_LOG, LOG_ERROR, "Error: unknown sockcheck decision `%s', defaulting to accept.", str); + resp->next->type = ACCEPT; + } + if (str[6]) { + resp->next->template = strdup(str+7); + } else { + resp->next->template = strdup("No explanation given"); + } } else if ((resps = GET_RECORD_OBJECT(rd))) { - resp->next->type = CHECKING; - response_list_init(&resp->next->responses); - if (*end == ':') { - resp->next->template = strdup(end+1); + resp->next->type = CHECKING; + response_list_init(&resp->next->responses); + if (*end == ':') { + resp->next->template = strdup(end+1); if (!sockcheck_check_template(resp->next->template, 0)) _exit(1); - } else { - resp->next->template = strdup(""); - } - dict_foreach(resps, sockcheck_create_response, resp->next); + } else { + resp->next->template = strdup(""); + } + dict_foreach(resps, sockcheck_create_response, resp->next); } return 0; } @@ -821,7 +821,7 @@ sockcheck_create_test(const char *key, void *data, void *extra) new_test->type = CHECKING; response_list_init(&new_test->responses); if (!(object = GET_RECORD_OBJECT(rd))) { - log_module(PC_LOG, LOG_ERROR, "Error: misformed sockcheck test `%s', skipping it.", key); + log_module(PC_LOG, LOG_ERROR, "Error: misformed sockcheck test `%s', skipping it.", key); free(new_test); return 1; } @@ -841,29 +841,29 @@ sockcheck_create_test(const char *key, void *data, void *extra) } } if (!new_test->template) { - log_module(PC_LOG, LOG_ERROR, "Error: misformed sockcheck test `%s', skipping it.", key); - free(new_test); - return 1; + log_module(PC_LOG, LOG_ERROR, "Error: misformed sockcheck test `%s', skipping it.", key); + free(new_test); + return 1; } dict_foreach(object, sockcheck_create_response, new_test); /* If none of the responses have template "other", create a * default response that goes to accept. */ for (n=0; nresponses.used; n++) { - if (!strcmp(new_test->responses.list[n]->template, "other")) break; + if (!strcmp(new_test->responses.list[n]->template, "other")) break; } if (n == new_test->responses.used) { - rd = alloc_record_data_qstring("accept"); - sockcheck_create_response("other", rd, new_test); - free_record_data(rd); + rd = alloc_record_data_qstring("accept"); + sockcheck_create_response("other", rd, new_test); + free_record_data(rd); } else if (n != (new_test->responses.used - 1)) { - struct sockcheck_response *tmp; - /* switch the response for "other" to the end */ - tmp = new_test->responses.list[new_test->responses.used - 1]; - new_test->responses.list[new_test->responses.used - 1] = new_test->responses.list[n]; - new_test->responses.list[n] = tmp; + struct sockcheck_response *tmp; + /* switch the response for "other" to the end */ + tmp = new_test->responses.list[new_test->responses.used - 1]; + new_test->responses.list[new_test->responses.used - 1] = new_test->responses.list[n]; + new_test->responses.list[n] = tmp; } if (new_test->responses.used > max_responses) { - max_responses = new_test->responses.used; + max_responses = new_test->responses.used; } sockcheck_list_append(extra, new_test); return 0; @@ -876,14 +876,14 @@ sockcheck_read_tests(void) struct sockcheck_list *new_tests; test_db = parse_database(SOCKCHECK_TEST_DB); if (!test_db) - return; + return; if (dict_size(test_db) > 0) { - new_tests = sockcheck_list_alloc(dict_size(test_db)); - dict_foreach(test_db, sockcheck_create_test, new_tests); - if (tests) sockcheck_list_unref(tests); - tests = new_tests; + new_tests = sockcheck_list_alloc(dict_size(test_db)); + dict_foreach(test_db, sockcheck_create_test, new_tests); + if (tests) sockcheck_list_unref(tests); + tests = new_tests; } else { - log_module(PC_LOG, LOG_ERROR, "%s was empty - disabling sockcheck.", SOCKCHECK_TEST_DB); + log_module(PC_LOG, LOG_ERROR, "%s was empty - disabling sockcheck.", SOCKCHECK_TEST_DB); } free_database(test_db); } @@ -893,12 +893,12 @@ sockcheck_free_state(struct sockcheck_state *state) { unsigned int n; if (state->type == CHECKING) { - for (n=0; nresponses.used; n++) { - free((char*)state->responses.list[n]->template); - sockcheck_free_state(state->responses.list[n]->next); - free(state->responses.list[n]); - } - response_list_clean(&state->responses); + for (n=0; nresponses.used; n++) { + free((char*)state->responses.list[n]->template); + sockcheck_free_state(state->responses.list[n]->next); + free(state->responses.list[n]); + } + response_list_clean(&state->responses); } free((char*)state->template); free(state); @@ -916,8 +916,8 @@ sockcheck_add_test(const char *desc) return reason; new_tests = sockcheck_list_clone(tests); if (sockcheck_create_test(name, rd, new_tests)) { - sockcheck_list_unref(new_tests); - return "Sockcheck test parse error"; + sockcheck_list_unref(new_tests); + return "Sockcheck test parse error"; } sockcheck_list_unref(tests); tests = new_tests; @@ -940,12 +940,12 @@ sockcheck_shutdown(void) dict_delete(checked_ip_dict); sci_list_clean(&pending_sci_list); if (tests) - for (n=0; nused; n++) - sockcheck_free_state(tests->list[n]); + for (n=0; nused; n++) + sockcheck_free_state(tests->list[n]); sockcheck_list_unref(tests); if (sockcheck_conf.local_addr) { - free(sockcheck_conf.local_addr); - sockcheck_conf.local_addr_len = 0; + free(sockcheck_conf.local_addr); + sockcheck_conf.local_addr_len = 0; } } @@ -1001,8 +1001,8 @@ static MODCMD_FUNC(cmd_defproxy) const char *reason; if ((reason = sockcheck_add_test(unsplit_string(argv+1, argc-1, NULL)))) { - reply("PCMSG_PROXY_DEFINITION_FAILED", reason); - return 0; + reply("PCMSG_PROXY_DEFINITION_FAILED", reason); + return 0; } reply("PCMSG_PROXY_DEFINITION_SUCCEEDED"); return 1; @@ -1015,7 +1015,7 @@ static MODCMD_FUNC(cmd_hostscan) char hnamebuf[IRC_NTOP_MAX_SIZE]; for (n=1; nip) @@ -1056,10 +1056,10 @@ static MODCMD_FUNC(cmd_clearhost) } switch (sockcheck_uncache_host(scanhost)) { case -1: - reply("PCMSG_CHECKING_ADDRESS", scanhost); + reply("PCMSG_CHECKING_ADDRESS", scanhost); break; case 0: - reply("PCMSG_NOT_REMOVED_FROM_CACHE", scanhost); + reply("PCMSG_NOT_REMOVED_FROM_CACHE", scanhost); break; default: reply("PCMSG_REMOVED_FROM_CACHE", scanhost); @@ -1137,19 +1137,19 @@ sockcheck_read_conf(void) } /* now try to read from the conf database */ if ((my_node = conf_get_data("modules/sockcheck", RECDB_OBJECT))) { - str = database_get_data(my_node, "max_sockets", RECDB_QSTRING); - if (str) sockcheck_conf.max_clients = strtoul(str, NULL, 0); - str = database_get_data(my_node, "max_clients", RECDB_QSTRING); - if (str) sockcheck_conf.max_clients = strtoul(str, NULL, 0); - str = database_get_data(my_node, "max_read", RECDB_QSTRING); - if (str) sockcheck_conf.max_read = strtoul(str, NULL, 0); - str = database_get_data(my_node, "max_cache_age", RECDB_QSTRING); - if (str) sockcheck_conf.max_cache_age = ParseInterval(str); + str = database_get_data(my_node, "max_sockets", RECDB_QSTRING); + if (str) sockcheck_conf.max_clients = strtoul(str, NULL, 0); + str = database_get_data(my_node, "max_clients", RECDB_QSTRING); + if (str) sockcheck_conf.max_clients = strtoul(str, NULL, 0); + str = database_get_data(my_node, "max_read", RECDB_QSTRING); + if (str) sockcheck_conf.max_read = strtoul(str, NULL, 0); + str = database_get_data(my_node, "max_cache_age", RECDB_QSTRING); + if (str) sockcheck_conf.max_cache_age = ParseInterval(str); str = database_get_data(my_node, "gline_duration", RECDB_QSTRING); if (str) sockcheck_conf.gline_duration = ParseInterval(str); - str = database_get_data(my_node, "address", RECDB_QSTRING); + str = database_get_data(my_node, "address", RECDB_QSTRING); if (!getaddrinfo(str, NULL, NULL, &ai)) { - sockcheck_conf.local_addr_len = ai->ai_addrlen; + sockcheck_conf.local_addr_len = ai->ai_addrlen; sockcheck_conf.local_addr = calloc(1, ai->ai_addrlen); memcpy(sockcheck_conf.local_addr, ai->ai_addr, ai->ai_addrlen); freeaddrinfo(ai); @@ -1158,7 +1158,7 @@ sockcheck_read_conf(void) sockcheck_conf.local_addr = NULL; if (str) log_module(PC_LOG, LOG_ERROR, "Error: Unable to get host named `%s', not checking a specific address.", str); - } + } } } diff --git a/src/modcmd.c b/src/modcmd.c index 006eb4c..c8e5128 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -1213,8 +1213,8 @@ static MODCMD_FUNC(cmd_readhelp) { stop.tv_sec -= start.tv_sec; stop.tv_usec -= start.tv_usec; if (stop.tv_usec < 0) { - stop.tv_sec -= 1; - stop.tv_usec += 1000000; + stop.tv_sec -= 1; + stop.tv_usec += 1000000; } reply("MCMSG_HELPFILE_READ", module->name, stop.tv_sec, stop.tv_usec/1000); return 1; @@ -1238,8 +1238,8 @@ static MODCMD_FUNC(cmd_timecmd) { stop.tv_sec -= start.tv_sec; stop.tv_usec -= start.tv_usec; if (stop.tv_usec < 0) { - stop.tv_sec -= 1; - stop.tv_usec += 1000000; + stop.tv_sec -= 1; + stop.tv_usec += 1000000; } reply("MCMSG_COMMAND_TIME", cmd_text, stop.tv_sec, stop.tv_usec); return 1; diff --git a/src/nickserv.c b/src/nickserv.c index 12aa5a9..dc6eeb7 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -53,9 +53,9 @@ #define KEY_SET_FAKEHOST_LEVEL "set_fakehost_level" #define KEY_TITLEHOST_SUFFIX "titlehost_suffix" #define KEY_FLAG_LEVELS "flag_levels" -#define KEY_HANDLE_EXPIRE_FREQ "handle_expire_freq" +#define KEY_HANDLE_EXPIRE_FREQ "handle_expire_freq" #define KEY_ACCOUNT_EXPIRE_FREQ "account_expire_freq" -#define KEY_HANDLE_EXPIRE_DELAY "handle_expire_delay" +#define KEY_HANDLE_EXPIRE_DELAY "handle_expire_delay" #define KEY_ACCOUNT_EXPIRE_DELAY "account_expire_delay" #define KEY_NOCHAN_HANDLE_EXPIRE_DELAY "nochan_handle_expire_delay" #define KEY_NOCHAN_ACCOUNT_EXPIRE_DELAY "nochan_account_expire_delay" @@ -107,7 +107,7 @@ #define KEY_NOTE_NOTE "note" #define KEY_KARMA "karma" -#define NICKSERV_VALID_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" +#define NICKSERV_VALID_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" #define NICKSERV_FUNC(NAME) MODCMD_FUNC(NAME) #define OPTION_FUNC(NAME) int NAME(struct userNode *user, struct handle_info *hi, UNUSED_ARG(unsigned int override), unsigned int argc, char *argv[]) @@ -396,9 +396,9 @@ canonicalize_hostmask(char *mask) { char *out = mask, *temp; if ((temp = strchr(mask, '!'))) { - temp++; - while (*temp) *out++ = *temp++; - *out++ = 0; + temp++; + while (*temp) *out++ = *temp++; + *out++ = 0; } return mask; } @@ -473,15 +473,15 @@ delete_nick(struct nick_info *ni) } /* Remove ni from the nick_info linked list. */ if (ni == ni->owner->nicks) { - ni->owner->nicks = ni->next; + ni->owner->nicks = ni->next; } else { - last = ni->owner->nicks; - next = last->next; - while (next != ni) { - last = next; - next = last->next; - } - last->next = next->next; + last = ni->owner->nicks; + next = last->next; + while (next != ni) { + last = next; + next = last->next; + } + last->next = next->next; } dict_remove(nickserv_nick_dict, ni->nick); } @@ -493,13 +493,13 @@ void reg_unreg_func(unreg_func_t func) { if (unreg_func_used == unreg_func_size) { - if (unreg_func_size) { - unreg_func_size <<= 1; - unreg_func_list = realloc(unreg_func_list, unreg_func_size*sizeof(unreg_func_t)); - } else { - unreg_func_size = 8; - unreg_func_list = malloc(unreg_func_size*sizeof(unreg_func_t)); - } + if (unreg_func_size) { + unreg_func_size <<= 1; + unreg_func_list = realloc(unreg_func_list, unreg_func_size*sizeof(unreg_func_t)); + } else { + unreg_func_size = 8; + unreg_func_list = malloc(unreg_func_size*sizeof(unreg_func_t)); + } } unreg_func_list[unreg_func_used++] = func; } @@ -606,21 +606,21 @@ oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_le } if (!IsOper(user) && (!IsHelping(user) || min_level)) { - if (!quiet) + if (!quiet) send_message(user, bot, "NSMSG_NO_ACCESS"); - return 0; + return 0; } if (HANDLE_FLAGGED(user->handle_info, OPER_SUSPENDED)) { - if (!quiet) + if (!quiet) send_message(user, bot, "MSG_OPER_SUSPENDED"); - return 0; + return 0; } if (user->handle_info->opserv_level < min_level) { - if (!quiet) + if (!quiet) send_message(user, bot, "NSMSG_NO_ACCESS"); - return 0; + return 0; } return 1; @@ -636,7 +636,7 @@ is_valid_handle(const char *handle) return 0; /* check against maximum length */ if (strlen(handle) > NICKSERV_HANDLE_LEN) - return 0; + return 0; /* for consistency, only allow account names that could be nicks */ if (!is_valid_nick(handle)) return 0; @@ -718,9 +718,9 @@ smart_get_handle_info(struct userNode *service, struct userNode *user, const cha return 0; } if (IsLocal(target)) { - if (IsService(target)) + if (IsService(target)) send_message(user, service, "NSMSG_USER_IS_SERVICE", target->nick); - else + else send_message(user, service, "MSG_USER_AUTHENTICATE", target->nick); return 0; } @@ -756,8 +756,8 @@ get_victim_oper(struct userNode *user, const char *target) if (!(hi = smart_get_handle_info(nickserv, user, target))) return 0; if (HANDLE_FLAGGED(user->handle_info, OPER_SUSPENDED)) { - send_message(user, nickserv, "MSG_OPER_SUSPENDED"); - return 0; + send_message(user, nickserv, "MSG_OPER_SUSPENDED"); + return 0; } return oper_outranks(user, hi) ? hi : NULL; } @@ -776,8 +776,8 @@ valid_user_for(struct userNode *user, struct handle_info *hi) return 1; /* If they are allowauthed to this account, allow it (removing the aa). */ if (dict_find(nickserv_allow_auth_dict, user->nick, NULL) == hi) { - dict_remove(nickserv_allow_auth_dict, user->nick); - return 2; + dict_remove(nickserv_allow_auth_dict, user->nick); + return 2; } /* The user is not allowed to use this account. */ return 0; @@ -808,16 +808,16 @@ is_secure_password(const char *handle, const char *pass, struct userNode *user) return 0; } for (i=0; ihandle_info) { - struct userNode *other; + struct userNode *other; - if (IsHelper(user)) + if (IsHelper(user)) userList_remove(&curr_helpers, user); - /* remove from next_authed linked list */ - if (user->handle_info->users == user) { - user->handle_info->users = user->next_authed; - } else { - for (other = user->handle_info->users; - other->next_authed != user; - other = other->next_authed) ; - other->next_authed = user->next_authed; - } + /* remove from next_authed linked list */ + if (user->handle_info->users == user) { + user->handle_info->users = user->next_authed; + } else { + for (other = user->handle_info->users; + other->next_authed != user; + other = other->next_authed) ; + other->next_authed = user->next_authed; + } /* if nobody left on old handle, and they're not an oper, remove !god */ if (!user->handle_info->users && !user->handle_info->opserv_level) HANDLE_CLEAR_FLAG(user->handle_info, HELPING); /* record them as being last seen at this time */ - user->handle_info->lastseen = now; + user->handle_info->lastseen = now; /* and record their hostmask */ snprintf(user->handle_info->last_quit_host, sizeof(user->handle_info->last_quit_host), "%s@%s", user->ident, user->hostname); } @@ -941,10 +941,10 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) for (other = hi->users; other; other = other->next_authed) send_message(other, nickserv, "NSMSG_CLONE_AUTH", user->nick, user->ident, user->hostname); } - user->next_authed = hi->users; - hi->users = user; - hi->lastseen = now; - if (IsHelper(user)) + user->next_authed = hi->users; + hi->users = user; + hi->lastseen = now; + if (IsHelper(user)) userList_append(&curr_helpers, user); if (hi->fakehost || old_info) @@ -977,7 +977,7 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp) timeq_del(0, nickserv_reclaim_p, user, TIMEQ_IGNORE_WHEN); } else { /* We cannot clear the user's account ID, unfortunately. */ - user->next_authed = NULL; + user->next_authed = NULL; } } @@ -989,8 +989,8 @@ nickserv_register(struct userNode *user, struct userNode *settee, const char *ha char crypted[MD5_CRYPT_LENGTH]; if ((hi = dict_find(nickserv_handle_dict, handle, NULL))) { - send_message(user, nickserv, "NSMSG_HANDLE_EXISTS", handle); - return 0; + send_message(user, nickserv, "NSMSG_HANDLE_EXISTS", handle); + return 0; } if (!is_secure_password(handle, passwd, user)) @@ -1155,9 +1155,9 @@ static NICKSERV_FUNC(cmd_register) int no_auth; if (!IsOper(user) && !dict_size(nickserv_handle_dict)) { - /* Require the first handle registered to belong to someone +o. */ - reply("NSMSG_REQUIRE_OPER"); - return 0; + /* Require the first handle registered to belong to someone +o. */ + reply("NSMSG_REQUIRE_OPER"); + return 0; } if (user->handle_info) { @@ -1167,7 +1167,7 @@ static NICKSERV_FUNC(cmd_register) if (IsRegistering(user)) { reply("NSMSG_ALREADY_REGISTERING"); - return 0; + return 0; } if (IsStamped(user)) { @@ -1275,22 +1275,22 @@ static NICKSERV_FUNC(cmd_oregister) mask = NULL; settee = NULL; } else if (strchr(argv[3], '@')) { - mask = canonicalize_hostmask(strdup(argv[3])); - if (argc > 4) { - settee = GetUserH(argv[4]); - if (!settee) { - reply("MSG_NICK_UNKNOWN", argv[4]); + mask = canonicalize_hostmask(strdup(argv[3])); + if (argc > 4) { + settee = GetUserH(argv[4]); + if (!settee) { + reply("MSG_NICK_UNKNOWN", argv[4]); free(mask); - return 0; - } - } else { - settee = NULL; - } + return 0; + } + } else { + settee = NULL; + } } else if ((settee = GetUserH(argv[3]))) { - mask = generate_hostmask(settee, GENMASK_OMITNICK|GENMASK_NO_HIDING|GENMASK_ANY_IDENT); + mask = generate_hostmask(settee, GENMASK_OMITNICK|GENMASK_NO_HIDING|GENMASK_ANY_IDENT); } else { - reply("NSMSG_REGISTER_BAD_NICKMASK", argv[3]); - return 0; + reply("NSMSG_REGISTER_BAD_NICKMASK", argv[3]); + return 0; } if (settee && settee->handle_info) { reply("NSMSG_USER_PREV_AUTH", settee->nick); @@ -1331,10 +1331,10 @@ static NICKSERV_FUNC(cmd_handleinfo) reply("NSMSG_HANDLEINFO_REGGED", ctime(&hi->registered)); if (!hi->users) { - intervalString(buff, now - hi->lastseen, user->handle_info); - reply("NSMSG_HANDLEINFO_LASTSEEN", buff); + intervalString(buff, now - hi->lastseen, user->handle_info); + reply("NSMSG_HANDLEINFO_LASTSEEN", buff); } else { - reply("NSMSG_HANDLEINFO_LASTSEEN_NOW"); + reply("NSMSG_HANDLEINFO_LASTSEEN_NOW"); } reply("NSMSG_HANDLEINFO_INFOLINE", (hi->infoline ? hi->infoline : nsmsg_none)); @@ -1389,16 +1389,16 @@ static NICKSERV_FUNC(cmd_handleinfo) } if (hi->flags) { - unsigned long flen = 1; - char flags[34]; /* 32 bits possible plus '+' and '\0' */ - flags[0] = '+'; - for (i=0, flen=1; handle_flags[i]; i++) - if (hi->flags & 1 << i) + unsigned long flen = 1; + char flags[34]; /* 32 bits possible plus '+' and '\0' */ + flags[0] = '+'; + for (i=0, flen=1; handle_flags[i]; i++) + if (hi->flags & 1 << i) flags[flen++] = handle_flags[i]; - flags[flen] = 0; - reply("NSMSG_HANDLEINFO_FLAGS", flags); + flags[flen] = 0; + reply("NSMSG_HANDLEINFO_FLAGS", flags); } else { - reply("NSMSG_HANDLEINFO_FLAGS", nsmsg_none); + reply("NSMSG_HANDLEINFO_FLAGS", nsmsg_none); } if (HANDLE_FLAGGED(hi, SUPPORT_HELPER) @@ -1416,28 +1416,28 @@ static NICKSERV_FUNC(cmd_handleinfo) reply("NSMSG_HANDLEINFO_LAST_HOST_UNKNOWN"); if (nickserv_conf.disable_nicks) { - /* nicks disabled; don't show anything about registered nicks */ + /* nicks disabled; don't show anything about registered nicks */ } else if (hi->nicks) { - struct nick_info *ni, *next_ni; - for (ni = hi->nicks; ni; ni = next_ni) { - herelen = strlen(ni->nick); - if (pos + herelen + 1 > ArrayLength(buff)) { - next_ni = ni; - goto print_nicks_buff; - } else { - next_ni = ni->next; - } - memcpy(buff+pos, ni->nick, herelen); - pos += herelen; buff[pos++] = ' '; - if (!next_ni) { - print_nicks_buff: - buff[pos-1] = 0; - reply("NSMSG_HANDLEINFO_NICKS", buff); - pos = 0; - } - } + struct nick_info *ni, *next_ni; + for (ni = hi->nicks; ni; ni = next_ni) { + herelen = strlen(ni->nick); + if (pos + herelen + 1 > ArrayLength(buff)) { + next_ni = ni; + goto print_nicks_buff; + } else { + next_ni = ni->next; + } + memcpy(buff+pos, ni->nick, herelen); + pos += herelen; buff[pos++] = ' '; + if (!next_ni) { + print_nicks_buff: + buff[pos-1] = 0; + reply("NSMSG_HANDLEINFO_NICKS", buff); + pos = 0; + } + } } else { - reply("NSMSG_HANDLEINFO_NICKS", nsmsg_none); + reply("NSMSG_HANDLEINFO_NICKS", nsmsg_none); } if (hi->masks->used) { @@ -1461,47 +1461,47 @@ static NICKSERV_FUNC(cmd_handleinfo) } if (hi->channels) { - struct userData *channel, *next; - char *name; + struct userData *channel, *next; + char *name; - for (channel = hi->channels; channel; channel = next) { - next = channel->u_next; + for (channel = hi->channels; channel; channel = next) { + next = channel->u_next; name = channel->channel->channel->name; - herelen = strlen(name); - if (pos + herelen + 7 > ArrayLength(buff)) { - next = channel; + herelen = strlen(name); + if (pos + herelen + 7 > ArrayLength(buff)) { + next = channel; goto print_chans_buff; - } + } if (IsUserSuspended(channel)) buff[pos++] = '-'; pos += sprintf(buff+pos, "%d:%s ", channel->access, name); - if (next == NULL) { - print_chans_buff: - buff[pos-1] = 0; - reply("NSMSG_HANDLEINFO_CHANNELS", buff); - pos = 0; - } - } + if (next == NULL) { + print_chans_buff: + buff[pos-1] = 0; + reply("NSMSG_HANDLEINFO_CHANNELS", buff); + pos = 0; + } + } } else { - reply("NSMSG_HANDLEINFO_CHANNELS", nsmsg_none); + reply("NSMSG_HANDLEINFO_CHANNELS", nsmsg_none); } for (target = hi->users; target; target = next_un) { - herelen = strlen(target->nick); - if (pos + herelen + 1 > ArrayLength(buff)) { - next_un = target; - goto print_cnick_buff; - } else { - next_un = target->next_authed; - } - memcpy(buff+pos, target->nick, herelen); - pos += herelen; buff[pos++] = ' '; - if (!next_un) { - print_cnick_buff: - buff[pos-1] = 0; - reply("NSMSG_HANDLEINFO_CURRENT", buff); - pos = 0; - } + herelen = strlen(target->nick); + if (pos + herelen + 1 > ArrayLength(buff)) { + next_un = target; + goto print_cnick_buff; + } else { + next_un = target->next_authed; + } + memcpy(buff+pos, target->nick, herelen); + pos += herelen; buff[pos++] = ' '; + if (!next_un) { + print_cnick_buff: + buff[pos-1] = 0; + reply("NSMSG_HANDLEINFO_CURRENT", buff); + pos = 0; + } } return 1; @@ -1513,13 +1513,13 @@ static NICKSERV_FUNC(cmd_userinfo) NICKSERV_MIN_PARMS(2); if (!(target = GetUserH(argv[1]))) { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; } if (target->handle_info) - reply("NSMSG_USERINFO_AUTHED_AS", target->nick, target->handle_info->handle); + reply("NSMSG_USERINFO_AUTHED_AS", target->nick, target->handle_info->handle); else - reply("NSMSG_USERINFO_NOT_AUTHED", target->nick); + reply("NSMSG_USERINFO_NOT_AUTHED", target->nick); return 1; } @@ -1529,8 +1529,8 @@ static NICKSERV_FUNC(cmd_nickinfo) NICKSERV_MIN_PARMS(2); if (!(ni = get_nick_info(argv[1]))) { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; } reply("NSMSG_NICKINFO_OWNER", ni->nick, ni->owner->handle); return 1; @@ -1971,8 +1971,8 @@ static NICKSERV_FUNC(cmd_oregnick) { } ni = dict_find(nickserv_nick_dict, nick, NULL); if (ni) { - reply("NSMSG_NICK_EXISTS", nick); - return 0; + reply("NSMSG_NICK_EXISTS", nick); + return 0; } register_nick(nick, target); reply("NSMSG_OREGNICK_SUCCESS", nick, target->handle); @@ -1995,8 +1995,8 @@ static NICKSERV_FUNC(cmd_regnick) { } ni = dict_find(nickserv_nick_dict, user->nick, NULL); if (ni) { - reply("NSMSG_NICK_EXISTS", user->nick); - return 0; + reply("NSMSG_NICK_EXISTS", user->nick); + return 0; } register_nick(user->nick, user->handle_info); reply("NSMSG_REGNICK_SUCCESS", user->nick); @@ -2016,8 +2016,8 @@ static NICKSERV_FUNC(cmd_pass) if (!is_secure_password(hi->handle, new_pass, user)) return 0; if (!checkpass(old_pass, hi->passwd)) { argv[1] = "BADPASS"; - reply("NSMSG_PASSWORD_INVALID"); - return 0; + reply("NSMSG_PASSWORD_INVALID"); + return 0; } cryptpass(new_pass, hi->passwd); argv[1] = "****"; @@ -2073,17 +2073,17 @@ nickserv_delmask(struct userNode *user, struct handle_info *hi, const char *del_ { unsigned int i; for (i=0; imasks->used; i++) { - if (!strcmp(del_mask, hi->masks->list[i])) { - char *old_mask = hi->masks->list[i]; - if (hi->masks->used == 1 && !force) { - send_message(user, nickserv, "NSMSG_DELMASK_NOTLAST"); - return 0; - } - hi->masks->list[i] = hi->masks->list[--hi->masks->used]; - send_message(user, nickserv, "NSMSG_DELMASK_SUCCESS", old_mask); - free(old_mask); - return 1; - } + if (!strcmp(del_mask, hi->masks->list[i])) { + char *old_mask = hi->masks->list[i]; + if (hi->masks->used == 1 && !force) { + send_message(user, nickserv, "NSMSG_DELMASK_NOTLAST"); + return 0; + } + hi->masks->list[i] = hi->masks->list[--hi->masks->used]; + send_message(user, nickserv, "NSMSG_DELMASK_SUCCESS", old_mask); + free(old_mask); + return 1; + } } send_message(user, nickserv, "NSMSG_DELMASK_NOT_FOUND"); return 0; @@ -2110,26 +2110,26 @@ nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, const unsigned long added, removed, flag; for (added=removed=nn=0; str[nn]; nn++) { - switch (str[nn]) { - case '+': add = 1; break; - case '-': add = 0; break; - default: - if (!(pos = handle_inverse_flags[(unsigned char)str[nn]])) { - send_message(user, bot, "NSMSG_INVALID_FLAG", str[nn]); - return 0; - } + switch (str[nn]) { + case '+': add = 1; break; + case '-': add = 0; break; + default: + if (!(pos = handle_inverse_flags[(unsigned char)str[nn]])) { + send_message(user, bot, "NSMSG_INVALID_FLAG", str[nn]); + return 0; + } if (user && (user->handle_info->opserv_level < flag_access_levels[pos-1])) { /* cheesy avoidance of looking up the flag name.. */ send_message(user, bot, "NSMSG_FLAG_PRIVILEGED", str[nn]); return 0; } flag = 1 << (pos - 1); - if (add) + if (add) added |= flag, removed &= ~flag; - else + else removed |= flag, added &= ~flag; - break; - } + break; + } } *padded = added; *premoved = removed; @@ -2192,8 +2192,8 @@ set_list(struct userNode *user, struct handle_info *hi, int override) /* Do this so options are presented in a consistent order. */ for (i = 0; i < ArrayLength(set_display); ++i) - if ((opt = dict_find(nickserv_opt_dict, set_display[i], NULL))) - opt(user, hi, override, 0, NULL); + if ((opt = dict_find(nickserv_opt_dict, set_display[i], NULL))) + opt(user, hi, override, 0, NULL); } static NICKSERV_FUNC(cmd_set) @@ -2203,11 +2203,11 @@ static NICKSERV_FUNC(cmd_set) hi = user->handle_info; if (argc < 2) { - set_list(user, hi, 0); - return 1; + set_list(user, hi, 0); + return 1; } if (!(opt = dict_find(nickserv_opt_dict, argv[1], NULL))) { - reply("NSMSG_INVALID_OPTION", argv[1]); + reply("NSMSG_INVALID_OPTION", argv[1]); return 0; } return opt(user, hi, 0, argc-1, argv+1); @@ -2226,12 +2226,12 @@ static NICKSERV_FUNC(cmd_oset) return 0; if (argc < 3) { - set_list(user, hi, 0); - return 1; + set_list(user, hi, 0); + return 1; } if (!(opt = dict_find(nickserv_opt_dict, argv[2], NULL))) { - reply("NSMSG_INVALID_OPTION", argv[2]); + reply("NSMSG_INVALID_OPTION", argv[2]); return 0; } @@ -2247,12 +2247,12 @@ static OPTION_FUNC(opt_info) { const char *info; if (argc > 1) { - if ((argv[1][0] == '*') && (argv[1][1] == 0)) { + if ((argv[1][0] == '*') && (argv[1][1] == 0)) { free(hi->infoline); hi->infoline = NULL; - } else { - hi->infoline = strdup(unsplit_string(argv+1, argc-1, NULL)); - } + } else { + hi->infoline = strdup(unsplit_string(argv+1, argc-1, NULL)); + } } info = hi->infoline ? hi->infoline : user_find_message(user, "MSG_NONE"); @@ -2263,7 +2263,7 @@ static OPTION_FUNC(opt_info) static OPTION_FUNC(opt_width) { if (argc > 1) - hi->screen_width = strtoul(argv[1], NULL, 0); + hi->screen_width = strtoul(argv[1], NULL, 0); if ((hi->screen_width > 0) && (hi->screen_width < MIN_LINE_SIZE)) hi->screen_width = MIN_LINE_SIZE; @@ -2277,7 +2277,7 @@ static OPTION_FUNC(opt_width) static OPTION_FUNC(opt_tablewidth) { if (argc > 1) - hi->table_width = strtoul(argv[1], NULL, 0); + hi->table_width = strtoul(argv[1], NULL, 0); if ((hi->table_width > 0) && (hi->table_width < MIN_LINE_SIZE)) hi->table_width = MIN_LINE_SIZE; @@ -2291,14 +2291,14 @@ static OPTION_FUNC(opt_tablewidth) static OPTION_FUNC(opt_color) { if (argc > 1) { - if (enabled_string(argv[1])) - HANDLE_SET_FLAG(hi, MIRC_COLOR); + if (enabled_string(argv[1])) + HANDLE_SET_FLAG(hi, MIRC_COLOR); else if (disabled_string(argv[1])) - HANDLE_CLEAR_FLAG(hi, MIRC_COLOR); - else { - send_message(user, nickserv, "MSG_INVALID_BINARY", argv[1]); - return 0; - } + HANDLE_CLEAR_FLAG(hi, MIRC_COLOR); + else { + send_message(user, nickserv, "MSG_INVALID_BINARY", argv[1]); + return 0; + } } send_message(user, nickserv, "NSMSG_SET_COLOR", user_find_message(user, HANDLE_FLAGGED(hi, MIRC_COLOR) ? "MSG_ON" : "MSG_OFF")); @@ -2308,14 +2308,14 @@ static OPTION_FUNC(opt_color) static OPTION_FUNC(opt_privmsg) { if (argc > 1) { - if (enabled_string(argv[1])) - HANDLE_SET_FLAG(hi, USE_PRIVMSG); + if (enabled_string(argv[1])) + HANDLE_SET_FLAG(hi, USE_PRIVMSG); else if (disabled_string(argv[1])) - HANDLE_CLEAR_FLAG(hi, USE_PRIVMSG); - else { - send_message(user, nickserv, "MSG_INVALID_BINARY", argv[1]); - return 0; - } + HANDLE_CLEAR_FLAG(hi, USE_PRIVMSG); + else { + send_message(user, nickserv, "MSG_INVALID_BINARY", argv[1]); + return 0; + } } send_message(user, nickserv, "NSMSG_SET_PRIVMSG", user_find_message(user, HANDLE_FLAGGED(hi, USE_PRIVMSG) ? "MSG_ON" : "MSG_OFF")); @@ -2327,19 +2327,19 @@ static OPTION_FUNC(opt_style) char *style; if (argc > 1) { - if (!irccasecmp(argv[1], "Zoot")) - hi->userlist_style = HI_STYLE_ZOOT; - else if (!irccasecmp(argv[1], "def")) - hi->userlist_style = HI_STYLE_DEF; + if (!irccasecmp(argv[1], "Zoot")) + hi->userlist_style = HI_STYLE_ZOOT; + else if (!irccasecmp(argv[1], "def")) + hi->userlist_style = HI_STYLE_DEF; } switch (hi->userlist_style) { case HI_STYLE_DEF: - style = "def"; - break; + style = "def"; + break; case HI_STYLE_ZOOT: default: - style = "Zoot"; + style = "Zoot"; } send_message(user, nickserv, "NSMSG_SET_STYLE", style); @@ -2349,12 +2349,12 @@ static OPTION_FUNC(opt_style) static OPTION_FUNC(opt_password) { if (!override) { - send_message(user, nickserv, "NSMSG_USE_CMD_PASS"); - return 0; + send_message(user, nickserv, "NSMSG_USE_CMD_PASS"); + return 0; } if (argc > 1) - cryptpass(argv[1], hi->passwd); + cryptpass(argv[1], hi->passwd); send_message(user, nickserv, "NSMSG_SET_PASSWORD", "***"); return 1; @@ -2366,12 +2366,12 @@ static OPTION_FUNC(opt_flags) unsigned int ii, flen; if (!override) { - send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]); - return 0; + send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]); + return 0; } if (argc > 1) - nickserv_apply_flags(user, hi, argv[1]); + nickserv_apply_flags(user, hi, argv[1]); for (ii = flen = 0; handle_flags[ii]; ii++) if (hi->flags & (1 << ii)) @@ -2494,8 +2494,8 @@ static OPTION_FUNC(opt_level) int res; if (!override) { - send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]); - return 0; + send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]); + return 0; } res = (argc > 1) ? oper_try_set_access(user, nickserv, hi, strtoul(argv[1], NULL, 0)) : 0; @@ -2643,12 +2643,12 @@ static NICKSERV_FUNC(cmd_unregnick) nick = (argc < 2) ? user->nick : (const char*)argv[1]; ni = dict_find(nickserv_nick_dict, nick, NULL); if (!ni) { - reply("NSMSG_UNKNOWN_NICK", nick); - return 0; + reply("NSMSG_UNKNOWN_NICK", nick); + return 0; } if (hi != ni->owner) { - reply("NSMSG_NOT_YOUR_NICK", nick); - return 0; + reply("NSMSG_NOT_YOUR_NICK", nick); + return 0; } reply("NSMSG_UNREGNICK_SUCCESS", ni->nick); delete_nick(ni); @@ -2661,8 +2661,8 @@ static NICKSERV_FUNC(cmd_ounregnick) NICKSERV_MIN_PARMS(2); if (!(ni = get_nick_info(argv[1]))) { - reply("NSMSG_NICK_NOT_REGISTERED", argv[1]); - return 0; + reply("NSMSG_NICK_NOT_REGISTERED", argv[1]); + return 0; } if (!oper_outranks(user, ni->owner)) return 0; @@ -2684,8 +2684,8 @@ static NICKSERV_FUNC(cmd_unregister) nickserv_unregister_handle(hi, user); return 1; } else { - log_module(NS_LOG, LOG_INFO, "Account '%s' tried to unregister with the wrong password.", hi->handle); - reply("NSMSG_PASSWORD_INVALID"); + log_module(NS_LOG, LOG_INFO, "Account '%s' tried to unregister with the wrong password.", hi->handle); + reply("NSMSG_PASSWORD_INVALID"); return 0; } } @@ -3180,12 +3180,12 @@ nickserv_discrim_create(struct userNode *user, unsigned int argc, char *argv[]) goto fail; } discrim->hostmask_type = SUPERSET; - } else if (!irccasecmp(argv[i], "lastquit") || !irccasecmp(argv[i], "lastauth")) { - if (i == argc - 1) { - send_message(user, nickserv, "MSG_MISSING_PARAMS", argv[i]); - goto fail; - } - discrim->hostmask_type = LASTQUIT; + } else if (!irccasecmp(argv[i], "lastquit") || !irccasecmp(argv[i], "lastauth")) { + if (i == argc - 1) { + send_message(user, nickserv, "MSG_MISSING_PARAMS", argv[i]); + goto fail; + } + discrim->hostmask_type = LASTQUIT; } else { i--; discrim->hostmask_type = SUPERSET; @@ -3290,8 +3290,8 @@ nickserv_discrim_match(struct nickserv_discrim *discrim, struct handle_info *hi) && !irccasecmp(discrim->hostmask, mask)) break; else if ((discrim->hostmask_type == SUPERSET) && (match_ircglobs(mask, discrim->hostmask))) break; - else if ((discrim->hostmask_type == LASTQUIT) - && (match_ircglobs(discrim->hostmask, hi->last_quit_host))) break; + else if ((discrim->hostmask_type == LASTQUIT) + && (match_ircglobs(discrim->hostmask, hi->last_quit_host))) break; } if (i==hi->masks->used) return 0; } @@ -3653,8 +3653,8 @@ static NICKSERV_FUNC(cmd_mergedb) stop.tv_sec -= start.tv_sec; stop.tv_usec -= start.tv_usec; if (stop.tv_usec < 0) { - stop.tv_sec -= 1; - stop.tv_usec += 1000000; + stop.tv_sec -= 1; + stop.tv_usec += 1000000; } reply("NSMSG_DB_MERGED", argv[1], stop.tv_sec, stop.tv_usec/1000); return 1; @@ -3730,8 +3730,8 @@ nickserv_conf_read(void) dict_iterator_t it; if (!(conf_node = conf_get_data(NICKSERV_CONF_NAME, RECDB_OBJECT))) { - log_module(NS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", NICKSERV_CONF_NAME); - return; + log_module(NS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", NICKSERV_CONF_NAME); + return; } str = database_get_data(conf_node, KEY_VALID_HANDLE_REGEX, RECDB_QSTRING); if (!str) @@ -4083,12 +4083,12 @@ init_nickserv(const char *nick) nickserv_define_func("DELNOTE", cmd_delnote, 0, 1, 0); nickserv_define_func("NOTES", cmd_notes, 0, 1, 0); if (!nickserv_conf.disable_nicks) { - /* nick management commands */ - nickserv_define_func("REGNICK", cmd_regnick, -1, 1, 0); - nickserv_define_func("OREGNICK", cmd_oregnick, 0, 1, 0); - nickserv_define_func("UNREGNICK", cmd_unregnick, -1, 1, 0); - nickserv_define_func("OUNREGNICK", cmd_ounregnick, 0, 1, 0); - nickserv_define_func("NICKINFO", cmd_nickinfo, -1, 1, 0); + /* nick management commands */ + nickserv_define_func("REGNICK", cmd_regnick, -1, 1, 0); + nickserv_define_func("OREGNICK", cmd_oregnick, 0, 1, 0); + nickserv_define_func("UNREGNICK", cmd_unregnick, -1, 1, 0); + nickserv_define_func("OUNREGNICK", cmd_ounregnick, 0, 1, 0); + nickserv_define_func("NICKINFO", cmd_nickinfo, -1, 1, 0); nickserv_define_func("RECLAIM", cmd_reclaim, -1, 1, 0); } if (nickserv_conf.email_enabled) { diff --git a/src/nickserv.h b/src/nickserv.h index 9e6ba89..4b75a9e 100644 --- a/src/nickserv.h +++ b/src/nickserv.h @@ -42,8 +42,8 @@ struct svccmd; #define HANDLE_FLAGS "SphgscfnHb" /* HI_STYLE_* go into handle_info.userlist_style */ -#define HI_STYLE_DEF 'd' -#define HI_STYLE_ZOOT 'Z' +#define HI_STYLE_DEF 'd' +#define HI_STYLE_ZOOT 'Z' #define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR) #define HI_DEFAULT_STYLE HI_STYLE_DEF diff --git a/src/opserv.c b/src/opserv.c index 1f51bf5..3eb4403 100644 --- a/src/opserv.c +++ b/src/opserv.c @@ -77,9 +77,9 @@ #define KEY_ISSUER "issuer" #define KEY_ISSUED "issued" -#define IDENT_FORMAT "%s [%s@%s/%s]" -#define IDENT_DATA(user) user->nick, user->ident, user->hostname, irc_ntoa(&user->ip) -#define MAX_CHANNELS_WHOIS 50 +#define IDENT_FORMAT "%s [%s@%s/%s]" +#define IDENT_DATA(user) user->nick, user->ident, user->hostname, irc_ntoa(&user->ip) +#define MAX_CHANNELS_WHOIS 50 #define OSMSG_PART_REASON "%s has no reason." #define OSMSG_KICK_REQUESTED "Kick requested by %s." #define OSMSG_KILL_REQUESTED "Kill requested by %s." @@ -368,8 +368,8 @@ static void opserv_free_user_alert(void *data) { struct opserv_user_alert *alert = data; - unsigned int i; - for(i = 0; i < alert->discrim->channel_count; i++) + unsigned int i; + for(i = 0; i < alert->discrim->channel_count; i++) UnlockChannel(alert->discrim->channels[i]); free(alert->owner); free(alert->text_discrim); @@ -417,8 +417,8 @@ static MODCMD_FUNC(cmd_ban) else if ((victim = GetUserH(argv[1]))) change.args[0].u.hostmask = generate_hostmask(victim, 0); else { - reply("OSMSG_INVALID_IRCMASK", argv[1]); - return 0; + reply("OSMSG_INVALID_IRCMASK", argv[1]); + return 0; } modcmd_chanmode_announce(&change); reply("OSMSG_ADDED_BAN", change.args[0].u.hostmask, channel->name); @@ -448,17 +448,17 @@ static MODCMD_FUNC(cmd_chaninfo) strftime(buffer, sizeof(buffer), fmt, gmtime(&channel->topic_time)); send_message_type(4, user, cmd->parent->bot, buffer, channel->topic_nick, channel->topic); } else { - irc_fetchtopic(cmd->parent->bot, channel->name); - reply("OSMSG_CHANINFO_TOPIC_UNKNOWN"); + irc_fetchtopic(cmd->parent->bot, channel->name); + reply("OSMSG_CHANINFO_TOPIC_UNKNOWN"); } if (channel->banlist.used) { - reply("OSMSG_CHANINFO_BAN_COUNT", channel->banlist.used); + reply("OSMSG_CHANINFO_BAN_COUNT", channel->banlist.used); fmt = user_find_message(user, "OSMSG_CHANINFO_BAN"); - for (n = 0; n < channel->banlist.used; n++) { - ban = channel->banlist.list[n]; - strftime(buffer, sizeof(buffer), fmt, localtime(&ban->set)); - send_message_type(4, user, cmd->parent->bot, buffer, ban->ban, ban->who); - } + for (n = 0; n < channel->banlist.used; n++) { + ban = channel->banlist.list[n]; + strftime(buffer, sizeof(buffer), fmt, localtime(&ban->set)); + send_message_type(4, user, cmd->parent->bot, buffer, ban->ban, ban->who); + } } if ((argc < 2) && (channel->members.used >= 50)) { /* early out unless they ask for users */ @@ -476,13 +476,13 @@ static MODCMD_FUNC(cmd_chaninfo) } } for (n=0; nmembers.used; n++) { - moden = channel->members.list[n]; - if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == MODE_VOICE) + moden = channel->members.list[n]; + if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == MODE_VOICE) send_message_type(4, user, cmd->parent->bot, " +%s (%s@%s)", moden->user->nick, moden->user->ident, moden->user->hostname); } for (n=0; nmembers.used; n++) { - moden = channel->members.list[n]; - if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == 0) + moden = channel->members.list[n]; + if ((moden->modes & (MODE_CHANOP|MODE_VOICE)) == 0) send_message_type(4, user, cmd->parent->bot, " %s (%s@%s)", moden->user->nick, moden->user->ident, moden->user->hostname); } return 1; @@ -493,8 +493,8 @@ static MODCMD_FUNC(cmd_warn) char *reason, *message; if (!IsChannelName(argv[1])) { - reply("OSMSG_NEED_CHANNEL", argv[0]); - return 0; + reply("OSMSG_NEED_CHANNEL", argv[0]); + return 0; } reason = dict_find(opserv_chan_warn, argv[1], NULL); if (reason) { @@ -519,7 +519,7 @@ static MODCMD_FUNC(cmd_unwarn) { if ((argc < 2) || !IsChannelName(argv[1])) { reply("OSMSG_NEED_CHANNEL", argv[0]); - return 0; + return 0; } if (!dict_remove(opserv_chan_warn, argv[1])) { reply("OSMSG_WARN_NOEXIST", argv[1]); @@ -552,7 +552,7 @@ static MODCMD_FUNC(cmd_clearmodes) struct mod_chanmode change; if (!channel->modes) { - reply("OSMSG_NO_CHANNEL_MODES", channel->name); + reply("OSMSG_NO_CHANNEL_MODES", channel->name); return 0; } mod_chanmode_init(&change); @@ -571,7 +571,7 @@ static MODCMD_FUNC(cmd_deop) for (arg = 1, count = 0; arg < argc; ++arg) { struct userNode *victim = GetUserH(argv[arg]); struct modeNode *mn; - if (!victim || IsService(victim) + if (!victim || IsService(victim) || !(mn = GetUserMode(channel, victim)) || !(mn->modes & MODE_CHANOP)) continue; @@ -594,8 +594,8 @@ static MODCMD_FUNC(cmd_deopall) change = mod_chanmode_alloc(channel->members.used); for (ii = count = 0; ii < channel->members.used; ++ii) { - struct modeNode *mn = channel->members.list[ii]; - if (IsService(mn->user) || !(mn->modes & MODE_CHANOP)) + struct modeNode *mn = channel->members.list[ii]; + if (IsService(mn->user) || !(mn->modes & MODE_CHANOP)) continue; change->args[count].mode = MODE_REMOVE | MODE_CHANOP; change->args[count++].u.member = mn; @@ -614,9 +614,9 @@ static MODCMD_FUNC(cmd_rehash) extern char *services_config; if (conf_read(services_config)) - reply("OSMSG_REHASH_COMPLETE"); + reply("OSMSG_REHASH_COMPLETE"); else - reply("OSMSG_REHASH_FAILED"); + reply("OSMSG_REHASH_FAILED"); return 1; } @@ -701,14 +701,14 @@ static MODCMD_FUNC(cmd_jump) target = unsplit_string(argv+1, argc-1, NULL); if (!strcmp(cManager.uplink->name, target)) { - reply("OSMSG_CURRENT_UPLINK", cManager.uplink->name); - return 0; + reply("OSMSG_CURRENT_UPLINK", cManager.uplink->name); + return 0; } uplink = uplink_find(target); if (!uplink) { - reply("OSMSG_INVALID_UPLINK", target); - return 0; + reply("OSMSG_INVALID_UPLINK", target); + return 0; } if (uplink->flags & UPLINK_UNAVAILABLE) { reply("OSMSG_UPLINK_DISABLED", uplink->name); @@ -830,8 +830,8 @@ static MODCMD_FUNC(cmd_gline) reason = unsplit_string(argv+3, argc-3, NULL); if (!is_gline(argv[1]) && !IsChannelName(argv[1]) && (argv[1][0] != '&')) { - reply("MSG_INVALID_GLINE", argv[1]); - return 0; + reply("MSG_INVALID_GLINE", argv[1]); + return 0; } if (!argv[1][strspn(argv[1], "#&*?@.")] && (strlen(argv[1]) < 10)) { reply("OSMSG_STUPID_GLINE", argv[1]); @@ -893,24 +893,24 @@ opserv_ison(struct userNode *tell, struct userNode *target, const char *message) if (!maxlen) maxlen = MAX_LINE_SIZE; for (n=count=0; nchannels.used; n++) { - mn = target->channels.list[n]; - here_len = strlen(mn->channel->name); - if ((count + here_len + 4) > maxlen) { - buff[count] = 0; + mn = target->channels.list[n]; + here_len = strlen(mn->channel->name); + if ((count + here_len + 4) > maxlen) { + buff[count] = 0; send_message(tell, opserv, message, buff); - count = 0; - } - if (mn->modes & MODE_CHANOP) + count = 0; + } + if (mn->modes & MODE_CHANOP) buff[count++] = '@'; - if (mn->modes & MODE_VOICE) + if (mn->modes & MODE_VOICE) buff[count++] = '+'; - memcpy(buff+count, mn->channel->name, here_len); - count += here_len; - buff[count++] = ' '; + memcpy(buff+count, mn->channel->name, here_len); + count += here_len; + buff[count++] = ' '; } if (count) { - buff[count] = 0; - send_message(tell, opserv, message, buff); + buff[count] = 0; + send_message(tell, opserv, message, buff); } } @@ -919,17 +919,17 @@ static MODCMD_FUNC(cmd_inviteme) struct userNode *target; if (argc < 2) { - target = user; + target = user; } else { - target = GetUserH(argv[1]); - if (!target) { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; - } + target = GetUserH(argv[1]); + if (!target) { + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; + } } if (opserv_conf.debug_channel == NULL) { - reply("OSMSG_NO_DEBUG_CHANNEL"); - return 0; + reply("OSMSG_NO_DEBUG_CHANNEL"); + return 0; } if (GetUserMode(opserv_conf.debug_channel, user)) { reply("OSMSG_ALREADY_THERE", opserv_conf.debug_channel->name); @@ -937,7 +937,7 @@ static MODCMD_FUNC(cmd_inviteme) } irc_invite(cmd->parent->bot, target, opserv_conf.debug_channel); if (target != user) - reply("OSMSG_INVITE_DONE", target->nick, opserv_conf.debug_channel->name); + reply("OSMSG_INVITE_DONE", target->nick, opserv_conf.debug_channel->name); return 1; } @@ -987,19 +987,19 @@ static MODCMD_FUNC(cmd_kick) char *reason; if (argc < 3) { - reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); - sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); + reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); + sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); } else { - reason = unsplit_string(argv+2, argc-2, NULL); + reason = unsplit_string(argv+2, argc-2, NULL); } target = GetUserH(argv[1]); if (!target) { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; } if (!GetUserMode(channel, target)) { - reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name); - return 0; + reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name); + return 0; } KickChannelUser(target, channel, cmd->parent->bot, reason); return 1; @@ -1022,20 +1022,20 @@ static MODCMD_FUNC(cmd_kickall) modcmd_chanmode_announce(&change); } if (argc < 2) { - reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); - sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); + reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); + sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); } else { - reason = unsplit_string(argv+1, argc-1, NULL); + reason = unsplit_string(argv+1, argc-1, NULL); } limit = user->handle_info->opserv_level; for (n=channel->members.used; n>0;) { - mn = channel->members.list[--n]; - if (IsService(mn->user) - || (mn->user->handle_info - && (mn->user->handle_info->opserv_level >= limit))) { - continue; - } - KickChannelUser(mn->user, channel, bot, reason); + mn = channel->members.list[--n]; + if (IsService(mn->user) + || (mn->user->handle_info + && (mn->user->handle_info->opserv_level >= limit))) { + continue; + } + KickChannelUser(mn->user, channel, bot, reason); } if (!inchan) DelChannelUser(bot, channel, "My work here is done", 0); @@ -1051,19 +1051,19 @@ static MODCMD_FUNC(cmd_kickban) char *mask; if (argc == 2) { - reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); - sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); + reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); + sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); } else { - reason = unsplit_string(argv+2, argc-2, NULL); + reason = unsplit_string(argv+2, argc-2, NULL); } target = GetUserH(argv[1]); if (!target) { - reply("MSG_NICK_UNKNOWN", argv[1]); - return 0; + reply("MSG_NICK_UNKNOWN", argv[1]); + return 0; } if (!GetUserMode(channel, target)) { - reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name); - return 0; + reply("OSMSG_NOT_ON_CHANNEL", target->nick, channel->name); + return 0; } mod_chanmode_init(&change); change.argc = 1; @@ -1099,21 +1099,21 @@ static MODCMD_FUNC(cmd_kickbanall) modcmd_chanmode_announce(change); mod_chanmode_free(change); if (argc < 2) { - reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); - sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); + reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1); + sprintf(reason, OSMSG_KICK_REQUESTED, user->nick); } else { - reason = unsplit_string(argv+1, argc-1, NULL); + reason = unsplit_string(argv+1, argc-1, NULL); } /* now kick them */ limit = user->handle_info->opserv_level; for (n=channel->members.used; n>0; ) { - mn = channel->members.list[--n]; - if (IsService(mn->user) - || (mn->user->handle_info - && (mn->user->handle_info->opserv_level >= limit))) { - continue; - } - KickChannelUser(mn->user, channel, bot, reason); + mn = channel->members.list[--n]; + if (IsService(mn->user) + || (mn->user->handle_info + && (mn->user->handle_info->opserv_level >= limit))) { + continue; + } + KickChannelUser(mn->user, channel, bot, reason); } if (!inchan) DelChannelUser(bot, channel, "My work here is done", 0); @@ -1179,15 +1179,15 @@ static MODCMD_FUNC(cmd_opall) change = mod_chanmode_alloc(channel->members.used); for (ii = count = 0; ii < channel->members.used; ++ii) { - struct modeNode *mn = channel->members.list[ii]; - if (mn->modes & MODE_CHANOP) + struct modeNode *mn = channel->members.list[ii]; + if (mn->modes & MODE_CHANOP) continue; change->args[count].mode = MODE_CHANOP; change->args[count++].u.member = mn; } if (count) { change->argc = count; - modcmd_chanmode_announce(change); + modcmd_chanmode_announce(change); } mod_chanmode_free(change); reply("OSMSG_OPALL_DONE", channel->name); @@ -1216,21 +1216,21 @@ static MODCMD_FUNC(cmd_whois) reply("OSMSG_WHOIS_FAKEHOST", target->fakehost); reply("OSMSG_WHOIS_IP", irc_ntoa(&target->ip)); if (target->modes) { - bpos = 0; + bpos = 0; #define buffer_cat(str) (herelen = strlen(str), memcpy(buffer+bpos, str, herelen), bpos += herelen) - if (IsInvisible(target)) buffer[bpos++] = 'i'; - if (IsWallOp(target)) buffer[bpos++] = 'w'; - if (IsOper(target)) buffer[bpos++] = 'o'; - if (IsGlobal(target)) buffer[bpos++] = 'g'; - if (IsService(target)) buffer[bpos++] = 'k'; - if (IsDeaf(target)) buffer[bpos++] = 'd'; - if (IsNoChan(target)) buffer[bpos++] = 'n'; + if (IsInvisible(target)) buffer[bpos++] = 'i'; + if (IsWallOp(target)) buffer[bpos++] = 'w'; + if (IsOper(target)) buffer[bpos++] = 'o'; + if (IsGlobal(target)) buffer[bpos++] = 'g'; + if (IsService(target)) buffer[bpos++] = 'k'; + if (IsDeaf(target)) buffer[bpos++] = 'd'; + if (IsNoChan(target)) buffer[bpos++] = 'n'; if (IsHiddenHost(target)) buffer[bpos++] = 'x'; if (IsNoIdle(target)) buffer[bpos++] = 'I'; if (IsGagged(target)) buffer_cat(" (gagged)"); - if (IsRegistering(target)) buffer_cat(" (registered account)"); - buffer[bpos] = 0; - if (bpos > 0) + if (IsRegistering(target)) buffer_cat(" (registered account)"); + buffer[bpos] = 0; + if (bpos > 0) reply("OSMSG_WHOIS_MODES", buffer); } reply("OSMSG_WHOIS_INFO", target->info); @@ -1242,9 +1242,9 @@ static MODCMD_FUNC(cmd_whois) intervalString(buffer, now - target->timestamp, user->handle_info); reply("OSMSG_WHOIS_NICK_AGE", buffer); if (target->channels.used <= MAX_CHANNELS_WHOIS) - opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS"); + opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS"); else - reply("OSMSG_WHOIS_HIDECHANS"); + reply("OSMSG_WHOIS_HIDECHANS"); return 1; } @@ -1267,15 +1267,15 @@ static MODCMD_FUNC(cmd_voiceall) change = mod_chanmode_alloc(channel->members.used); for (ii = count = 0; ii < channel->members.used; ++ii) { - struct modeNode *mn = channel->members.list[ii]; - if (mn->modes & (MODE_CHANOP|MODE_VOICE)) + struct modeNode *mn = channel->members.list[ii]; + if (mn->modes & (MODE_CHANOP|MODE_VOICE)) continue; change->args[count].mode = MODE_VOICE; change->args[count++].u.member = mn; } if (count) { change->argc = count; - modcmd_chanmode_announce(change); + modcmd_chanmode_announce(change); } mod_chanmode_free(change); reply("OSMSG_CHANNEL_VOICED", channel->name); @@ -1289,15 +1289,15 @@ static MODCMD_FUNC(cmd_devoiceall) change = mod_chanmode_alloc(channel->members.used); for (ii = count = 0; ii < channel->members.used; ++ii) { - struct modeNode *mn = channel->members.list[ii]; - if (!(mn->modes & MODE_VOICE)) + struct modeNode *mn = channel->members.list[ii]; + if (!(mn->modes & MODE_VOICE)) continue; change->args[count].mode = MODE_REMOVE | MODE_VOICE; change->args[count++].u.member = mn; } if (count) { change->argc = count; - modcmd_chanmode_announce(change); + modcmd_chanmode_announce(change); } mod_chanmode_free(change); reply("OSMSG_CHANNEL_DEVOICED", channel->name); @@ -1586,7 +1586,7 @@ static MODCMD_FUNC(cmd_stats_gags) { unsigned int nn; if (!gagList) { - reply("OSMSG_NO_GAGS"); + reply("OSMSG_NO_GAGS"); return 1; } for (nn=0, gag=gagList; gag; nn++, gag=gag->next) ; @@ -1666,10 +1666,10 @@ static MODCMD_FUNC(cmd_dump) safestrncpy(linedup, original, sizeof(linedup)); /* assume it's only valid IRC if we can parse it */ if (parse_line(linedup, 1)) { - irc_raw(original); - reply("OSMSG_LINE_DUMPED"); + irc_raw(original); + reply("OSMSG_LINE_DUMPED"); } else - reply("OSMSG_RAW_PARSE_ERROR"); + reply("OSMSG_RAW_PARSE_ERROR"); return 1; } @@ -1692,15 +1692,15 @@ opserv_add_reserve(struct svccmd *cmd, struct userNode *user, const char *nick, { struct userNode *resv = GetUserH(nick); if (resv) { - if (IsService(resv)) { - reply("MSG_SERVICE_IMMUNE", resv->nick); - return NULL; - } - if (resv->handle_info - && resv->handle_info->opserv_level > user->handle_info->opserv_level) { - reply("OSMSG_LEVEL_TOO_LOW"); - return NULL; - } + if (IsService(resv)) { + reply("MSG_SERVICE_IMMUNE", resv->nick); + return NULL; + } + if (resv->handle_info + && resv->handle_info->opserv_level > user->handle_info->opserv_level) { + reply("OSMSG_LEVEL_TOO_LOW"); + return NULL; + } } if ((resv = AddLocalUser(nick, ident, host, desc, "+i"))) { dict_insert(opserv_reserved_nick_dict, resv->nick, resv); @@ -1714,11 +1714,11 @@ static MODCMD_FUNC(cmd_collide) resv = opserv_add_reserve(cmd, user, argv[1], argv[2], argv[3], unsplit_string(argv+4, argc-4, NULL)); if (resv) { - reply("OSMSG_COLLIDED_NICK", resv->nick); - return 1; + reply("OSMSG_COLLIDED_NICK", resv->nick); + return 1; } else { reply("OSMSG_CLONE_FAILED", argv[1]); - return 0; + return 0; } } @@ -1728,12 +1728,12 @@ static MODCMD_FUNC(cmd_reserve) resv = opserv_add_reserve(cmd, user, argv[1], argv[2], argv[3], unsplit_string(argv+4, argc-4, NULL)); if (resv) { - resv->modes |= FLAGS_PERSISTENT; - reply("OSMSG_RESERVED_NICK", resv->nick); - return 1; + resv->modes |= FLAGS_PERSISTENT; + reply("OSMSG_RESERVED_NICK", resv->nick); + return 1; } else { reply("OSMSG_CLONE_FAILED", argv[1]); - return 0; + return 0; } } @@ -1759,9 +1759,9 @@ free_reserve(char *nick) static MODCMD_FUNC(cmd_unreserve) { if (free_reserve(argv[1])) - reply("OSMSG_NICK_UNRESERVED", argv[1]); + reply("OSMSG_NICK_UNRESERVED", argv[1]); else - reply("OSMSG_NOT_RESERVED", argv[1]); + reply("OSMSG_NOT_RESERVED", argv[1]); return 1; } @@ -1966,7 +1966,7 @@ opserv_join_check(struct modeNode *mNode) struct mod_chanmode change; mod_chanmode_init(&change); channel->join_flooded = 1; - if (opserv && opserv_conf.join_flood_moderate && (channel->members.used > opserv_conf.join_flood_moderate_threshold)) { + if (opserv && opserv_conf.join_flood_moderate && (channel->members.used > opserv_conf.join_flood_moderate_threshold)) { if (!GetUserMode(channel, opserv)) { /* If we aren't in the channel, join it. */ change.args[0].mode = MODE_CHANOP; @@ -2282,92 +2282,92 @@ static MODCMD_FUNC(cmd_clone) char *userinfo; char ident[USERLEN+1]; - if (argc < 5) { - reply("MSG_MISSING_PARAMS", argv[1]); - OPSERV_SYNTAX(); - return 0; - } - if (clone) { - reply("OSMSG_CLONE_EXISTS", argv[2]); - return 0; - } - userinfo = unsplit_string(argv+4, argc-4, NULL); - for (i=0; argv[3][i] && (inick); - return 1; + return 1; } if (!clone) { - reply("MSG_NICK_UNKNOWN", argv[2]); - return 0; + reply("MSG_NICK_UNKNOWN", argv[2]); + return 0; } if (clone->uplink != self || IsService(clone)) { - reply("OSMSG_NOT_A_CLONE", clone->nick); - return 0; + reply("OSMSG_NOT_A_CLONE", clone->nick); + return 0; } if (!irccasecmp(argv[1], "REMOVE")) { - const char *reason; - if (argc > 3) { - reason = unsplit_string(argv+3, argc-3, NULL); - } else { - char *tmp; - tmp = alloca(strlen(clone->nick) + strlen(OSMSG_PART_REASON)); - sprintf(tmp, OSMSG_PART_REASON, clone->nick); - reason = tmp; - } - DelUser(clone, NULL, 1, reason); - reply("OSMSG_CLONE_REMOVED", argv[2]); - return 1; + const char *reason; + if (argc > 3) { + reason = unsplit_string(argv+3, argc-3, NULL); + } else { + char *tmp; + tmp = alloca(strlen(clone->nick) + strlen(OSMSG_PART_REASON)); + sprintf(tmp, OSMSG_PART_REASON, clone->nick); + reason = tmp; + } + DelUser(clone, NULL, 1, reason); + reply("OSMSG_CLONE_REMOVED", argv[2]); + return 1; } if (argc < 4) { - reply("MSG_MISSING_PARAMS", argv[1]); - OPSERV_SYNTAX(); - return 0; + reply("MSG_MISSING_PARAMS", argv[1]); + OPSERV_SYNTAX(); + return 0; } channel = GetChannel(argv[3]); if (!irccasecmp(argv[1], "JOIN")) { - if (!channel - && !(channel = AddChannel(argv[3], now, NULL, NULL))) { - reply("MSG_CHANNEL_UNKNOWN", argv[3]); - return 0; - } - AddChannelUser(clone, channel); - reply("OSMSG_CLONE_JOINED", clone->nick, channel->name); - return 1; + if (!channel + && !(channel = AddChannel(argv[3], now, NULL, NULL))) { + reply("MSG_CHANNEL_UNKNOWN", argv[3]); + return 0; + } + AddChannelUser(clone, channel); + reply("OSMSG_CLONE_JOINED", clone->nick, channel->name); + return 1; } if (!irccasecmp(argv[1], "PART")) { - if (!channel) { - reply("MSG_CHANNEL_UNKNOWN", argv[3]); - return 0; - } - if (!GetUserMode(channel, clone)) { - reply("OSMSG_NOT_ON_CHANNEL", clone->nick, channel->name); - return 0; - } - reply("OSMSG_CLONE_PARTED", clone->nick, channel->name); - DelChannelUser(clone, channel, "Leaving.", 0); - return 1; + if (!channel) { + reply("MSG_CHANNEL_UNKNOWN", argv[3]); + return 0; + } + if (!GetUserMode(channel, clone)) { + reply("OSMSG_NOT_ON_CHANNEL", clone->nick, channel->name); + return 0; + } + reply("OSMSG_CLONE_PARTED", clone->nick, channel->name); + DelChannelUser(clone, channel, "Leaving.", 0); + return 1; } if (!irccasecmp(argv[1], "OP")) { struct mod_chanmode change; - if (!channel) { - reply("MSG_CHANNEL_UNKNOWN", argv[3]); - return 0; - } + if (!channel) { + reply("MSG_CHANNEL_UNKNOWN", argv[3]); + return 0; + } mod_chanmode_init(&change); change.argc = 1; change.args[0].mode = MODE_CHANOP; @@ -2375,21 +2375,21 @@ static MODCMD_FUNC(cmd_clone) if (!change.args[0].u.member) { reply("OSMSG_NOT_ON_CHANNEL", clone->nick, channel->name); return 0; - } + } modcmd_chanmode_announce(&change); - reply("OSMSG_OPS_GIVEN", channel->name, clone->nick); - return 1; + reply("OSMSG_OPS_GIVEN", channel->name, clone->nick); + return 1; } if (argc < 5) { - reply("MSG_MISSING_PARAMS", argv[1]); - OPSERV_SYNTAX(); - return 0; + reply("MSG_MISSING_PARAMS", argv[1]); + OPSERV_SYNTAX(); + return 0; } if (!irccasecmp(argv[1], "SAY")) { - char *text = unsplit_string(argv+4, argc-4, NULL); - irc_privmsg(clone, argv[3], text); - reply("OSMSG_CLONE_SAID", clone->nick, argv[3]); - return 1; + char *text = unsplit_string(argv+4, argc-4, NULL); + irc_privmsg(clone, argv[3], text); + reply("OSMSG_CLONE_SAID", clone->nick, argv[3]); + return 1; } reply("OSMSG_UNKNOWN_SUBCOMMAND", argv[1], argv[0]); return 0; @@ -2472,18 +2472,18 @@ int add_reserved(const char *key, void *data, void *extra) struct userNode *reserve; ident = database_get_data(rd->d.object, KEY_IDENT, RECDB_QSTRING); if (!ident) { - log_module(OS_LOG, LOG_ERROR, "Missing ident for reserve of %s", key); - return 0; + log_module(OS_LOG, LOG_ERROR, "Missing ident for reserve of %s", key); + return 0; } hostname = database_get_data(rd->d.object, KEY_HOSTNAME, RECDB_QSTRING); if (!hostname) { - log_module(OS_LOG, LOG_ERROR, "Missing hostname for reserve of %s", key); - return 0; + log_module(OS_LOG, LOG_ERROR, "Missing hostname for reserve of %s", key); + return 0; } desc = database_get_data(rd->d.object, KEY_DESC, RECDB_QSTRING); if (!desc) { - log_module(OS_LOG, LOG_ERROR, "Missing description for reserve of %s", key); - return 0; + log_module(OS_LOG, LOG_ERROR, "Missing description for reserve of %s", key); + return 0; } if ((reserve = AddLocalUser(key, ident, hostname, desc, "+i"))) { reserve->modes |= FLAGS_PERSISTENT; @@ -2513,7 +2513,7 @@ foreach_matching_user(const char *hostmask, discrim_search_func func, void *extr discrim->ip_mask_bits = 0; matched = opserv_discrim_search(discrim, func, extra); } else { - log_module(OS_LOG, LOG_ERROR, "Couldn't split IRC mask for gag %s!", hostmask); + log_module(OS_LOG, LOG_ERROR, "Couldn't split IRC mask for gag %s!", hostmask); matched = 0; } free(discrim); @@ -2597,8 +2597,8 @@ opserv_add_user_alert(struct userNode *req, const char *name, opserv_alert_react char *name_dup; if (dict_find(opserv_user_alerts, name, NULL)) { - send_message(req, opserv, "OSMSG_ALERT_EXISTS", name); - return NULL; + send_message(req, opserv, "OSMSG_ALERT_EXISTS", name); + return NULL; } alert = malloc(sizeof(*alert)); alert->owner = strdup(req->handle_info ? req->handle_info->handle : req->nick); @@ -2881,29 +2881,29 @@ static MODCMD_FUNC(cmd_query) char *nodename; if (argc < 2) { - reply("OSMSG_OPTION_ROOT"); - conf_enum_root(query_keys_helper, user); - return 1; + reply("OSMSG_OPTION_ROOT"); + conf_enum_root(query_keys_helper, user); + return 1; } nodename = unsplit_string(argv+1, argc-1, NULL); if (!(rd = conf_get_node(nodename))) { - reply("OSMSG_UNKNOWN_OPTION", nodename); - return 0; + reply("OSMSG_UNKNOWN_OPTION", nodename); + return 0; } if (rd->type == RECDB_QSTRING) - reply("OSMSG_OPTION_IS", nodename, rd->d.qstring); + reply("OSMSG_OPTION_IS", nodename, rd->d.qstring); else if (rd->type == RECDB_STRING_LIST) { - reply("OSMSG_OPTION_LIST", nodename); - if (rd->d.slist->used) - for (i=0; id.slist->used; i++) - send_message_type(4, user, cmd->parent->bot, "$b%s$b", rd->d.slist->list[i]); - else - reply("OSMSG_OPTION_LIST_EMPTY"); + reply("OSMSG_OPTION_LIST", nodename); + if (rd->d.slist->used) + for (i=0; id.slist->used; i++) + send_message_type(4, user, cmd->parent->bot, "$b%s$b", rd->d.slist->list[i]); + else + reply("OSMSG_OPTION_LIST_EMPTY"); } else if (rd->type == RECDB_OBJECT) { - reply("OSMSG_OPTION_KEYS", nodename); - dict_foreach(rd->d.object, query_keys_helper, user); + reply("OSMSG_OPTION_KEYS", nodename); + dict_foreach(rd->d.object, query_keys_helper, user); } return 1; @@ -2919,13 +2919,13 @@ static MODCMD_FUNC(cmd_set) invent a syntax for it. -Zoot */ if (!(rd = conf_get_node(argv[1]))) { - reply("OSMSG_SET_NOT_SET", argv[1]); - return 0; + reply("OSMSG_SET_NOT_SET", argv[1]); + return 0; } if (rd->type != RECDB_QSTRING) { - reply("OSMSG_SET_BAD_TYPE", argv[1]); - return 0; + reply("OSMSG_SET_BAD_TYPE", argv[1]); + return 0; } free(rd->d.qstring); @@ -2974,113 +2974,113 @@ opserv_discrim_create(struct userNode *user, unsigned int argc, char *argv[], in send_message(user, opserv, "MSG_MISSING_PARAMS", argv[i]); goto fail; } - if (irccasecmp(argv[i], "mask") == 0) { - if (!is_ircmask(argv[++i])) { - send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]); - goto fail; - } - if (!split_ircmask(argv[i], + if (irccasecmp(argv[i], "mask") == 0) { + if (!is_ircmask(argv[++i])) { + send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]); + goto fail; + } + if (!split_ircmask(argv[i], &discrim->mask_nick, &discrim->mask_ident, &discrim->mask_host)) { - send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]); - goto fail; - } - } else if (irccasecmp(argv[i], "nick") == 0) { - discrim->mask_nick = argv[++i]; - } else if (irccasecmp(argv[i], "ident") == 0) { - discrim->mask_ident = argv[++i]; - } else if (irccasecmp(argv[i], "host") == 0) { - discrim->mask_host = argv[++i]; - } else if (irccasecmp(argv[i], "info") == 0) { - discrim->mask_info = argv[++i]; - } else if (irccasecmp(argv[i], "server") == 0) { - discrim->server = argv[++i]; - } else if (irccasecmp(argv[i], "ip") == 0) { + send_message(user, opserv, "OSMSG_INVALID_IRCMASK", argv[i]); + goto fail; + } + } else if (irccasecmp(argv[i], "nick") == 0) { + discrim->mask_nick = argv[++i]; + } else if (irccasecmp(argv[i], "ident") == 0) { + discrim->mask_ident = argv[++i]; + } else if (irccasecmp(argv[i], "host") == 0) { + discrim->mask_host = argv[++i]; + } else if (irccasecmp(argv[i], "info") == 0) { + discrim->mask_info = argv[++i]; + } else if (irccasecmp(argv[i], "server") == 0) { + discrim->server = argv[++i]; + } else if (irccasecmp(argv[i], "ip") == 0) { j = irc_pton(&discrim->ip_mask, &discrim->ip_mask_bits, argv[++i]); if (!j) { send_message(user, opserv, "OSMSG_BAD_IP", argv[i]); goto fail; } - } else if (irccasecmp(argv[i], "account") == 0) { - if (discrim->authed == 0) { - send_message(user, opserv, "OSMSG_ACCOUNTMASK_AUTHED"); - goto fail; - } - discrim->accountmask = argv[++i]; - discrim->authed = 1; - } else if (irccasecmp(argv[i], "authed") == 0) { - i++; /* true_string and false_string are macros! */ - if (true_string(argv[i])) { - discrim->authed = 1; - } else if (false_string(argv[i])) { - if (discrim->accountmask) { + } else if (irccasecmp(argv[i], "account") == 0) { + if (discrim->authed == 0) { send_message(user, opserv, "OSMSG_ACCOUNTMASK_AUTHED"); goto fail; } - discrim->authed = 0; - } else { - send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]); - goto fail; - } - } else if (irccasecmp(argv[i], "info_space") == 0) { - /* XXX: A hack because you can't check explicitly for a space through - * any other means */ - i++; - if (true_string(argv[i])) { - discrim->info_space = 1; - } else if (false_string(argv[i])) { - discrim->info_space = 0; - } else { - send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]); - goto fail; - } - } else if (irccasecmp(argv[i], "duration") == 0) { - discrim->duration = ParseInterval(argv[++i]); - } else if (irccasecmp(argv[i], "channel") == 0) { - if(discrim->channel_count == DISCRIM_MAX_CHANS) - { - send_message(user, opserv, "OSMSG_TRACE_MAX_CHANNELS", DISCRIM_MAX_CHANS); - goto fail; - } - - for (j=0, i++; ; j++) { - switch (argv[i][j]) { - case '#': - goto find_channel; - case '-': - discrim->chan_no_modes[discrim->channel_count] |= MODE_CHANOP | MODE_VOICE; - break; - case '+': - discrim->chan_req_modes[discrim->channel_count] |= MODE_VOICE; - discrim->chan_no_modes[discrim->channel_count] |= MODE_CHANOP; - break; - case '@': - discrim->chan_req_modes[discrim->channel_count] |= MODE_CHANOP; - break; - case '\0': - send_message(user, opserv, "MSG_NOT_CHANNEL_NAME"); + discrim->accountmask = argv[++i]; + discrim->authed = 1; + } else if (irccasecmp(argv[i], "authed") == 0) { + i++; /* true_string and false_string are macros! */ + if (true_string(argv[i])) { + discrim->authed = 1; + } else if (false_string(argv[i])) { + if (discrim->accountmask) { + send_message(user, opserv, "OSMSG_ACCOUNTMASK_AUTHED"); + goto fail; + } + discrim->authed = 0; + } else { + send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]); goto fail; } - } - find_channel: - discrim->chan_no_modes[discrim->channel_count] &= ~discrim->chan_req_modes[discrim->channel_count]; - if (!(discrim->channels[discrim->channel_count] = GetChannel(argv[i]+j))) { - /* secretly "allow_channel" now means "if a channel name is - * specified, require that it currently exist" */ - if (allow_channel) { - send_message(user, opserv, "MSG_CHANNEL_UNKNOWN", argv[i]); - goto fail; + } else if (irccasecmp(argv[i], "info_space") == 0) { + /* XXX: A hack because you can't check explicitly for a space through + * any other means */ + i++; + if (true_string(argv[i])) { + discrim->info_space = 1; + } else if (false_string(argv[i])) { + discrim->info_space = 0; } else { - discrim->channels[discrim->channel_count] = AddChannel(argv[i]+j, now, NULL, NULL); + send_message(user, opserv, "MSG_INVALID_BINARY", argv[i]); + goto fail; } - } - LockChannel(discrim->channels[discrim->channel_count]); - discrim->channel_count++; - } else if (irccasecmp(argv[i], "numchannels") == 0) { - discrim->min_channels = discrim->max_channels = strtoul(argv[++i], NULL, 10); - } else if (irccasecmp(argv[i], "limit") == 0) { - discrim->limit = strtoul(argv[++i], NULL, 10); + } else if (irccasecmp(argv[i], "duration") == 0) { + discrim->duration = ParseInterval(argv[++i]); + } else if (irccasecmp(argv[i], "channel") == 0) { + if(discrim->channel_count == DISCRIM_MAX_CHANS) + { + send_message(user, opserv, "OSMSG_TRACE_MAX_CHANNELS", DISCRIM_MAX_CHANS); + goto fail; + } + + for (j=0, i++; ; j++) { + switch (argv[i][j]) { + case '#': + goto find_channel; + case '-': + discrim->chan_no_modes[discrim->channel_count] |= MODE_CHANOP | MODE_VOICE; + break; + case '+': + discrim->chan_req_modes[discrim->channel_count] |= MODE_VOICE; + discrim->chan_no_modes[discrim->channel_count] |= MODE_CHANOP; + break; + case '@': + discrim->chan_req_modes[discrim->channel_count] |= MODE_CHANOP; + break; + case '\0': + send_message(user, opserv, "MSG_NOT_CHANNEL_NAME"); + goto fail; + } + } + find_channel: + discrim->chan_no_modes[discrim->channel_count] &= ~discrim->chan_req_modes[discrim->channel_count]; + if (!(discrim->channels[discrim->channel_count] = GetChannel(argv[i]+j))) { + /* secretly "allow_channel" now means "if a channel name is + * specified, require that it currently exist" */ + if (allow_channel) { + send_message(user, opserv, "MSG_CHANNEL_UNKNOWN", argv[i]); + goto fail; + } else { + discrim->channels[discrim->channel_count] = AddChannel(argv[i]+j, now, NULL, NULL); + } + } + LockChannel(discrim->channels[discrim->channel_count]); + discrim->channel_count++; + } else if (irccasecmp(argv[i], "numchannels") == 0) { + discrim->min_channels = discrim->max_channels = strtoul(argv[++i], NULL, 10); + } else if (irccasecmp(argv[i], "limit") == 0) { + discrim->limit = strtoul(argv[++i], NULL, 10); } else if (irccasecmp(argv[i], "reason") == 0) { discrim->reason = strdup(unsplit_string(argv+i+1, argc-i-1, NULL)); i = argc; @@ -3142,13 +3142,13 @@ opserv_discrim_create(struct userNode *user, unsigned int argc, char *argv[], in } if (discrim->mask_nick && !strcmp(discrim->mask_nick, "*")) { - discrim->mask_nick = 0; + discrim->mask_nick = 0; } if (discrim->mask_ident && !strcmp(discrim->mask_ident, "*")) { discrim->mask_ident = 0; } if (discrim->mask_info && !strcmp(discrim->mask_info, "*")) { - discrim->mask_info = 0; + discrim->mask_info = 0; } if (discrim->mask_host && !discrim->mask_host[strspn(discrim->mask_host, "*.")]) { discrim->mask_host = 0; @@ -3181,9 +3181,9 @@ discrim_match(discrim_t discrim, struct userNode *user) || (discrim->ip_mask_bits && !irc_check_mask(&user->ip, &discrim->ip_mask, discrim->ip_mask_bits)) ) return 0; - for(i = 0; i < discrim->channel_count; i++) - if (!GetUserMode(discrim->channels[i], user)) - return 0; + for(i = 0; i < discrim->channel_count; i++) + if (!GetUserMode(discrim->channels[i], user)) + return 0; access = user->handle_info ? user->handle_info->opserv_level : 0; if ((access < discrim->min_level) || (access > discrim->max_level)) { @@ -3269,10 +3269,10 @@ opserv_discrim_search(discrim_t discrim, discrim_search_func dsf, void *data) log_module(OS_LOG, LOG_INFO, " %s!%s@%s", user->nick, user->ident, user->hostname); } if (dsf(user, data)) { - /* If a search function returns true, it ran into a - problem. Stop going through the list. */ - break; - } + /* If a search function returns true, it ran into a + problem. Stop going through the list. */ + break; + } } if (discrim->option_log) { log_module(OS_LOG, LOG_INFO, "End of matching users."); @@ -3347,7 +3347,7 @@ trace_kill_func(struct userNode *match, void *extra) struct discrim_and_source *das = extra; if (is_oper_victim(das->source, match, das->discrim->match_opers, 0) && is_trust_victim(match, das->discrim->match_trusted)) { - char *reason; + char *reason; if (das->discrim->reason) { reason = das->discrim->reason; } else { @@ -3385,10 +3385,10 @@ trace_gag_func(struct userNode *match, void *extra) reason = alloca(strlen(OSMSG_GAG_REQUESTED)+strlen(das->source->nick)+1); sprintf(reason, OSMSG_GAG_REQUESTED, das->source->nick); } - masksize = 5+strlen(match->hostname); - mask = alloca(masksize); + masksize = 5+strlen(match->hostname); + mask = alloca(masksize); snprintf(mask, masksize, "*!*@%s", match->hostname); - if (!is_gagged(mask)) { + if (!is_gagged(mask)) { gag_create(mask, das->source->handle_info->handle, reason, das->discrim->duration ? (now + das->discrim->duration) : 0); } @@ -3472,7 +3472,7 @@ static MODCMD_FUNC(cmd_trace) sprintf(buf, "trace %s", argv[1]); if (!(subcmd = dict_find(cmd->parent->commands, buf, NULL))) { - reply("OSMSG_BAD_ACTION", argv[1]); + reply("OSMSG_BAD_ACTION", argv[1]); return 0; } if (!svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, SVCCMD_NOISY)) @@ -3490,8 +3490,8 @@ static MODCMD_FUNC(cmd_trace) else if (!irccasecmp(argv[1], "gag")) action = trace_gag_func; else { - reply("OSMSG_BAD_ACTION", argv[1]); - return 0; + reply("OSMSG_BAD_ACTION", argv[1]); + return 0; } if (user->handle_info->opserv_level < subcmd->min_opserv_level) { @@ -3506,9 +3506,9 @@ static MODCMD_FUNC(cmd_trace) return 0; if (action == trace_print_func) - reply("OSMSG_USER_SEARCH_RESULTS"); + reply("OSMSG_USER_SEARCH_RESULTS"); else if (action == trace_count_func) - das.discrim->limit = INT_MAX; + das.discrim->limit = INT_MAX; else if ((action == trace_gline_func) && !das.discrim->duration) das.discrim->duration = opserv_conf.block_gline_duration; else if (action == trace_domains_func) { @@ -3524,11 +3524,11 @@ static MODCMD_FUNC(cmd_trace) dict_foreach(das.dict, opserv_show_hostinfo, &das); if (matches) - reply("MSG_MATCH_COUNT", matches); + reply("MSG_MATCH_COUNT", matches); else - reply("MSG_NO_MATCHES"); + reply("MSG_NO_MATCHES"); - for (i = 0; i < das.discrim->channel_count; i++) + for (i = 0; i < das.discrim->channel_count; i++) UnlockChannel(das.discrim->channels[i]); free(das.discrim->reason); free(das.discrim); @@ -3569,18 +3569,18 @@ opserv_cdiscrim_create(struct userNode *user, unsigned int argc, char *argv[]) discrim->max_ts = (1ul << (CHAR_BIT * sizeof(time_t) - 1)) - 1; for (i = 0; i < argc; i++) { - /* Assume all criteria require arguments. */ - if (i == (argc - 1)) { - send_message(user, opserv, "MSG_MISSING_PARAMS", argv[i]); - return NULL; - } - - if (!irccasecmp(argv[i], "name")) - discrim->name = argv[++i]; - else if (!irccasecmp(argv[i], "topic")) - discrim->topic = argv[++i]; - else if (!irccasecmp(argv[i], "users")) { - const char *cmp = argv[++i]; + /* Assume all criteria require arguments. */ + if (i == (argc - 1)) { + send_message(user, opserv, "MSG_MISSING_PARAMS", argv[i]); + return NULL; + } + + if (!irccasecmp(argv[i], "name")) + discrim->name = argv[++i]; + else if (!irccasecmp(argv[i], "topic")) + discrim->topic = argv[++i]; + else if (!irccasecmp(argv[i], "users")) { + const char *cmp = argv[++i]; if (cmp[0] == '<') { if (cmp[1] == '=') discrim->max_users = strtoul(cmp+2, NULL, 0); @@ -3596,8 +3596,8 @@ opserv_cdiscrim_create(struct userNode *user, unsigned int argc, char *argv[]) } else { discrim->min_users = strtoul(cmp, NULL, 0); } - } else if (!irccasecmp(argv[i], "timestamp")) { - const char *cmp = argv[++i]; + } else if (!irccasecmp(argv[i], "timestamp")) { + const char *cmp = argv[++i]; if (cmp[0] == '<') { if (cmp[1] == '=') discrim->max_ts = smart_parse_time(cmp+2); @@ -3613,18 +3613,18 @@ opserv_cdiscrim_create(struct userNode *user, unsigned int argc, char *argv[]) } else { discrim->min_ts = smart_parse_time(cmp); } - } else if (!irccasecmp(argv[i], "limit")) { - discrim->limit = strtoul(argv[++i], NULL, 10); - } else { - send_message(user, opserv, "MSG_INVALID_CRITERIA", argv[i]); - goto fail; - } + } else if (!irccasecmp(argv[i], "limit")) { + discrim->limit = strtoul(argv[++i], NULL, 10); + } else { + send_message(user, opserv, "MSG_INVALID_CRITERIA", argv[i]); + goto fail; + } } if (discrim->name && !strcmp(discrim->name, "*")) - discrim->name = 0; + discrim->name = 0; if (discrim->topic && !strcmp(discrim->topic, "*")) - discrim->topic = 0; + discrim->topic = 0; return discrim; fail: @@ -3641,7 +3641,7 @@ cdiscrim_match(cdiscrim_t discrim, struct chanNode *chan) (chan->members.used > discrim->max_users) || (chan->timestamp < discrim->min_ts) || (chan->timestamp > discrim->max_ts)) { - return 0; + return 0; } return 1; } @@ -3652,15 +3652,15 @@ static unsigned int opserv_cdiscrim_search(cdiscrim_t discrim, cdiscrim_search_f dict_iterator_t it, next; for (it = dict_first(channels); it && count < discrim->limit ; it = next) { - struct chanNode *chan = iter_data(it); + struct chanNode *chan = iter_data(it); - /* Hold on to the next channel in case we decide to - add actions that destructively modify the channel. */ - next = iter_next(it); - if ((chan->members.used > 0) && cdiscrim_match(discrim, chan)) { - dsf(chan, data); - count++; - } + /* Hold on to the next channel in case we decide to + add actions that destructively modify the channel. */ + next = iter_next(it); + if ((chan->members.used > 0) && cdiscrim_match(discrim, chan)) { + dsf(chan, data); + count++; + } } return count; @@ -3686,12 +3686,12 @@ static MODCMD_FUNC(cmd_csearch) char buf[MAXLEN]; if (!irccasecmp(argv[1], "count")) - action = channel_count; + action = channel_count; else if (!irccasecmp(argv[1], "print")) - action = channel_print; + action = channel_print; else { - reply("OSMSG_BAD_ACTION", argv[1]); - return 0; + reply("OSMSG_BAD_ACTION", argv[1]); + return 0; } sprintf(buf, "%s %s", argv[0], argv[0]); @@ -3702,19 +3702,19 @@ static MODCMD_FUNC(cmd_csearch) discrim = opserv_cdiscrim_create(user, argc - 2, argv + 2); if (!discrim) - return 0; + return 0; if (action == channel_print) - reply("OSMSG_CHANNEL_SEARCH_RESULTS"); + reply("OSMSG_CHANNEL_SEARCH_RESULTS"); else if (action == channel_count) - discrim->limit = INT_MAX; + discrim->limit = INT_MAX; matches = opserv_cdiscrim_search(discrim, action, user); if (matches) - reply("MSG_MATCH_COUNT", matches); + reply("MSG_MATCH_COUNT", matches); else - reply("MSG_NO_MATCHES"); + reply("MSG_NO_MATCHES"); free(discrim); return 1; @@ -3944,9 +3944,9 @@ static MODCMD_FUNC(cmd_log) matches = log_entry_search(discrim, log_report_entry, &report); if (matches) - reply("MSG_MATCH_COUNT", matches); + reply("MSG_MATCH_COUNT", matches); else - reply("MSG_NO_MATCHES"); + reply("MSG_NO_MATCHES"); free(discrim); return 1; @@ -3971,26 +3971,26 @@ static MODCMD_FUNC(cmd_gag) reason = unsplit_string(argv + 3, argc - 3, NULL); if (!is_ircmask(argv[1])) { - reply("OSMSG_INVALID_IRCMASK", argv[1]); + reply("OSMSG_INVALID_IRCMASK", argv[1]); return 0; } for (gag = gagList; gag; gag = gag->next) - if (match_ircglobs(gag->mask, argv[1])) + if (match_ircglobs(gag->mask, argv[1])) break; if (gag) { - reply("OSMSG_REDUNDANT_GAG", argv[1]); - return 0; + reply("OSMSG_REDUNDANT_GAG", argv[1]); + return 0; } duration = ParseInterval(argv[2]); gagged = gag_create(argv[1], user->handle_info->handle, reason, (duration?now+duration:0)); if (gagged) - reply("OSMSG_GAG_APPLIED", argv[1], gagged); + reply("OSMSG_GAG_APPLIED", argv[1], gagged); else - reply("OSMSG_GAG_ADDED", argv[1]); + reply("OSMSG_GAG_ADDED", argv[1]); return 1; } @@ -4007,21 +4007,21 @@ static MODCMD_FUNC(cmd_ungag) unsigned int ungagged; for (gag = gagList; gag; gag = gag->next) - if (!strcmp(gag->mask, argv[1])) + if (!strcmp(gag->mask, argv[1])) break; if (!gag) { - reply("OSMSG_GAG_NOT_FOUND", argv[1]); - return 0; + reply("OSMSG_GAG_NOT_FOUND", argv[1]); + return 0; } timeq_del(gag->expires, gag_expire, gag, 0); ungagged = gag_free(gag); if (ungagged) - reply("OSMSG_UNGAG_APPLIED", argv[1], ungagged); + reply("OSMSG_UNGAG_APPLIED", argv[1], ungagged); else - reply("OSMSG_UNGAG_ADDED", argv[1]); + reply("OSMSG_UNGAG_ADDED", argv[1]); return 1; } @@ -4035,8 +4035,8 @@ static MODCMD_FUNC(cmd_addalert) name = argv[1]; sprintf(buf, "addalert %s", argv[2]); if (!(subcmd = dict_find(cmd->parent->commands, buf, NULL))) { - reply("OSMSG_UNKNOWN_REACTION", argv[2]); - return 0; + reply("OSMSG_UNKNOWN_REACTION", argv[2]); + return 0; } if (!irccasecmp(argv[2], "notice")) reaction = REACT_NOTICE; @@ -4045,8 +4045,8 @@ static MODCMD_FUNC(cmd_addalert) else if (!irccasecmp(argv[2], "gline")) reaction = REACT_GLINE; else { - reply("OSMSG_UNKNOWN_REACTION", argv[2]); - return 0; + reply("OSMSG_UNKNOWN_REACTION", argv[2]); + return 0; } if (!svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, SVCCMD_NOISY) || !opserv_add_user_alert(user, name, reaction, unsplit_string(argv + 3, argc - 3, NULL))) @@ -4081,8 +4081,8 @@ opserv_conf_read(void) rd = conf_get_node(OPSERV_CONF_NAME); if (!rd || rd->type != RECDB_OBJECT) { - log_module(OS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", OPSERV_CONF_NAME); - return; + log_module(OS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", OPSERV_CONF_NAME); + return; } conf_node = rd->d.object; str = database_get_data(conf_node, KEY_DEBUG_CHANNEL, RECDB_QSTRING); @@ -4090,20 +4090,20 @@ opserv_conf_read(void) str2 = database_get_data(conf_node, KEY_DEBUG_CHANNEL_MODES, RECDB_QSTRING); if (!str2) str2 = "+tinms"; - opserv_conf.debug_channel = AddChannel(str, now, str2, NULL); + opserv_conf.debug_channel = AddChannel(str, now, str2, NULL); AddChannelUser(opserv, opserv_conf.debug_channel)->modes |= MODE_CHANOP; } else { - opserv_conf.debug_channel = NULL; + opserv_conf.debug_channel = NULL; } str = database_get_data(conf_node, KEY_ALERT_CHANNEL, RECDB_QSTRING); if (opserv && str) { str2 = database_get_data(conf_node, KEY_ALERT_CHANNEL_MODES, RECDB_QSTRING); if (!str2) str2 = "+tns"; - opserv_conf.alert_channel = AddChannel(str, now, str2, NULL); + opserv_conf.alert_channel = AddChannel(str, now, str2, NULL); AddChannelUser(opserv, opserv_conf.alert_channel)->modes |= MODE_CHANOP; } else { - opserv_conf.alert_channel = NULL; + opserv_conf.alert_channel = NULL; } str = database_get_data(conf_node, KEY_STAFF_AUTH_CHANNEL, RECDB_QSTRING); if (opserv && str) { @@ -4136,7 +4136,7 @@ opserv_conf_read(void) policer_params_set(opserv_conf.join_policer_params, "size", "20"); policer_params_set(opserv_conf.join_policer_params, "drain-rate", "1"); if ((child = database_get_data(conf_node, KEY_JOIN_POLICER, RECDB_OBJECT))) - dict_foreach(child, set_policer_param, opserv_conf.join_policer_params); + dict_foreach(child, set_policer_param, opserv_conf.join_policer_params); for (it = dict_first(channels); it; it = iter_next(it)) { struct chanNode *cNode = iter_data(it); @@ -4150,7 +4150,7 @@ opserv_conf_read(void) policer_params_set(pp, "size", "200"); policer_params_set(pp, "drain-rate", "3"); if ((child = database_get_data(conf_node, KEY_NEW_USER_POLICER, RECDB_OBJECT))) - dict_foreach(child, set_policer_param, pp); + dict_foreach(child, set_policer_param, pp); } static void diff --git a/src/policer.c b/src/policer.c index 59bd7ed..21257ea 100644 --- a/src/policer.c +++ b/src/policer.c @@ -21,7 +21,7 @@ #include "common.h" #include "policer.h" -/* This policer uses the "leaky bucket" (GCRA) algorithm. */ +/* This policer uses the "leaky bucket" (GCRA) algorithm. */ struct policer_params { double bucket_size; @@ -41,11 +41,11 @@ int policer_params_set(struct policer_params *params, const char *param, const char *value) { if (!irccasecmp(param, "size")) { - params->bucket_size = strtod(value, NULL); + params->bucket_size = strtod(value, NULL); } else if (!irccasecmp(param, "drain-rate")) { - params->drain_rate = strtod(value, NULL); + params->drain_rate = strtod(value, NULL); } else { - return 0; + return 0; } return 1; } diff --git a/src/proto-bahamut.c b/src/proto-bahamut.c index 0e8309f..6483ba3 100644 --- a/src/proto-bahamut.c +++ b/src/proto-bahamut.c @@ -430,9 +430,9 @@ void irc_svsmode(struct userNode *target, char *modes, unsigned long stamp) { extern struct userNode *nickserv; if (stamp) { - putsock(":%s SVSMODE %s "FMT_TIME_T" %s %lu", nickserv->nick, target->nick, target->timestamp, modes, stamp); + putsock(":%s SVSMODE %s "FMT_TIME_T" %s %lu", nickserv->nick, target->nick, target->timestamp, modes, stamp); } else { - putsock(":%s SVSMODE %s "FMT_TIME_T" %s", nickserv->nick, target->nick, target->timestamp, modes); + putsock(":%s SVSMODE %s "FMT_TIME_T" %s", nickserv->nick, target->nick, target->timestamp, modes); } } @@ -550,47 +550,47 @@ static void parse_foreach(char *target_list, foreach_chanfunc cf, foreach_nonchan nc, foreach_userfunc uf, foreach_nonuser nu, void *data) { char *j, old; do { - j = target_list; - while (*j != 0 && *j != ',') j++; - old = *j; + j = target_list; + while (*j != 0 && *j != ',') j++; + old = *j; *j = 0; - if (IsChannelName(target_list)) { - struct chanNode *chan = GetChannel(target_list); + if (IsChannelName(target_list)) { + struct chanNode *chan = GetChannel(target_list); if (chan) { if (cf) cf(chan, data); } else { if (nc) nc(target_list, data); } - } else { - struct userNode *user; + } else { + struct userNode *user; struct privmsg_desc *pd = data; pd->is_qualified = 0; if (*target_list == '@') { user = NULL; } else if (strchr(target_list, '@')) { - struct server *server; + struct server *server; pd->is_qualified = 1; - user = GetUserH(strtok(target_list, "@")); - server = GetServerH(strtok(NULL, "@")); - - if (user && (user->uplink != server)) { - /* Don't attempt to index into any arrays - using a user's numeric on another server. */ - user = NULL; - } - } else { - user = GetUserH(target_list); - } + user = GetUserH(strtok(target_list, "@")); + server = GetServerH(strtok(NULL, "@")); + + if (user && (user->uplink != server)) { + /* Don't attempt to index into any arrays + using a user's numeric on another server. */ + user = NULL; + } + } else { + user = GetUserH(target_list); + } if (user) { if (uf) uf(user, data); } else { if (nu) nu(target_list, data); } - } - target_list = j+1; + } + target_list = j+1; } while (old == ','); } @@ -958,10 +958,10 @@ static CMD_FUNC(cmd_pong) { if (argc < 3) return 0; if (!strcmp(argv[2], self->name)) { - 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); - received_ping(); + 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); + received_ping(); } return 1; } @@ -1138,7 +1138,7 @@ int parse_line(char *line, int recursive) { res = 0; } if (!res) { - log_module(MAIN_LOG, LOG_ERROR, "PARSE ERROR on line: %s", unsplit_string(argv, argc, NULL)); + log_module(MAIN_LOG, LOG_ERROR, "PARSE ERROR on line: %s", unsplit_string(argv, argc, NULL)); } else if (!recursive) { unsigned int i; for (i=0; imodes |= FLAG; else user->modes &= ~FLAG; } while (0) - switch (*mode_change++) { - case 0: return; - case '+': add = 1; break; - case '-': add = 0; break; - case 'o': - do_user_mode(FLAGS_OPER); - if (add) { - userList_append(&curr_opers, user); - call_oper_funcs(user); - } else { - userList_remove(&curr_opers, user); - } - break; - case 'i': do_user_mode(FLAGS_INVISIBLE); - if (add) invis_clients++; else invis_clients--; - break; - case 'w': do_user_mode(FLAGS_WALLOP); break; - case 'd': do_user_mode(FLAGS_DEAF); break; - case 'r': do_user_mode(FLAGS_REGNICK); break; - case 'k': do_user_mode(FLAGS_SERVICE); break; - case 'g': do_user_mode(FLAGS_GLOBAL); break; - } + switch (*mode_change++) { + case 0: return; + case '+': add = 1; break; + case '-': add = 0; break; + case 'o': + do_user_mode(FLAGS_OPER); + if (add) { + userList_append(&curr_opers, user); + call_oper_funcs(user); + } else { + userList_remove(&curr_opers, user); + } + break; + case 'i': do_user_mode(FLAGS_INVISIBLE); + if (add) invis_clients++; else invis_clients--; + break; + case 'w': do_user_mode(FLAGS_WALLOP); break; + case 'd': do_user_mode(FLAGS_DEAF); break; + case 'r': do_user_mode(FLAGS_REGNICK); break; + case 'k': do_user_mode(FLAGS_SERVICE); break; + case 'g': do_user_mode(FLAGS_GLOBAL); break; + } #undef do_user_mode } } @@ -1296,14 +1296,14 @@ mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, un case 'p': do_chan_mode(MODE_PRIVATE); break; case 's': do_chan_mode(MODE_SECRET); break; case 't': do_chan_mode(MODE_TOPICLIMIT); break; - case 'r': - if (!(flags & MCP_REGISTERED)) { - do_chan_mode(MODE_REGISTERED); - } else { - mod_chanmode_free(change); - return NULL; - } - break; + case 'r': + if (!(flags & MCP_REGISTERED)) { + do_chan_mode(MODE_REGISTERED); + } else { + mod_chanmode_free(change); + return NULL; + } + break; #undef do_chan_mode case 'l': if (add) { diff --git a/src/proto-common.c b/src/proto-common.c index a20e674..171da14 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -311,11 +311,11 @@ static CMD_FUNC(cmd_pass) return 0; true_pass = cManager.uplink->their_password; if (true_pass && strcmp(true_pass, argv[1])) { - /* It might be good to mark the uplink as unavailable when - this happens, though there should be a way of resetting - the flag. */ - irc_squit(self, "Incorrect password received.", NULL); - return 1; + /* It might be good to mark the uplink as unavailable when + this happens, though there should be a way of resetting + the flag. */ + irc_squit(self, "Incorrect password received.", NULL); + return 1; } cManager.uplink->state = BURSTING; @@ -334,9 +334,9 @@ static CMD_FUNC(cmd_error) log_module(MAIN_LOG, LOG_ERROR, "Error received from uplink, squitting."); if (cManager.uplink->state != CONNECTED) { - /* Error messages while connected should be fine. */ - cManager.uplink->flags |= UPLINK_UNAVAILABLE; - log_module(MAIN_LOG, LOG_ERROR, "Disabling uplink."); + /* Error messages while connected should be fine. */ + cManager.uplink->flags |= UPLINK_UNAVAILABLE; + log_module(MAIN_LOG, LOG_ERROR, "Disabling uplink."); } close_socket(); @@ -493,7 +493,7 @@ void reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t handler) { if (chanmsg_funcs[prefix].func) - log_module(MAIN_LOG, LOG_WARNING, "Re-registering new chanmsg handler for character `%c'.", prefix); + log_module(MAIN_LOG, LOG_WARNING, "Re-registering new chanmsg handler for character `%c'.", prefix); chanmsg_funcs[prefix].func = handler; chanmsg_funcs[prefix].service = service; } @@ -524,13 +524,13 @@ void reg_mode_change_func(mode_change_func_t handler) { if (mcf_used == mcf_size) { - if (mcf_size) { - mcf_size <<= 1; - mcf_list = realloc(mcf_list, mcf_size*sizeof(mode_change_func_t)); - } else { - mcf_size = 8; - mcf_list = malloc(mcf_size*sizeof(mode_change_func_t)); - } + if (mcf_size) { + mcf_size <<= 1; + mcf_list = realloc(mcf_list, mcf_size*sizeof(mode_change_func_t)); + } else { + mcf_size = 8; + mcf_list = malloc(mcf_size*sizeof(mode_change_func_t)); + } } mcf_list[mcf_used++] = handler; } diff --git a/src/proto-p10.c b/src/proto-p10.c index 003bbe6..8023510 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -21,9 +21,9 @@ #include "proto-common.c" /* Full commands. */ -#define CMD_ACCOUNT "ACCOUNT" +#define CMD_ACCOUNT "ACCOUNT" #define CMD_ADMIN "ADMIN" -#define CMD_ASLL "ASLL" +#define CMD_ASLL "ASLL" #define CMD_AWAY "AWAY" #define CMD_BURST "BURST" #define CMD_CLEARMODE "CLEARMODE" @@ -40,7 +40,7 @@ #define CMD_EOB_ACK "EOB_ACK" #define CMD_ERROR "ERROR" #define CMD_FAKEHOST "FAKE" -#define CMD_GET "GET" +#define CMD_GET "GET" #define CMD_GLINE "GLINE" #define CMD_HASH "HASH" #define CMD_HELP "HELP" @@ -68,18 +68,18 @@ #define CMD_PONG "PONG" #define CMD_POST "POST" #define CMD_PRIVMSG "PRIVMSG" -#define CMD_PRIVS "PRIVS" +#define CMD_PRIVS "PRIVS" #define CMD_PROTO "PROTO" #define CMD_QUIT "QUIT" #define CMD_REHASH "REHASH" -#define CMD_RESET "RESET" +#define CMD_RESET "RESET" #define CMD_RESTART "RESTART" #define CMD_RPING "RPING" #define CMD_RPONG "RPONG" #define CMD_SERVER "SERVER" #define CMD_SERVLIST "SERVLIST" #define CMD_SERVSET "SERVSET" -#define CMD_SET "SET" +#define CMD_SET "SET" #define CMD_SETTIME "SETTIME" #define CMD_SILENCE "SILENCE" #define CMD_SQUERY "SQUERY" @@ -103,9 +103,9 @@ #define CMD_WHOWAS "WHOWAS" /* Tokenized commands. */ -#define TOK_ACCOUNT "AC" +#define TOK_ACCOUNT "AC" #define TOK_ADMIN "AD" -#define TOK_ASLL "LL" +#define TOK_ASLL "LL" #define TOK_AWAY "A" #define TOK_BURST "B" #define TOK_CLEARMODE "CM" @@ -122,7 +122,7 @@ #define TOK_EOB_ACK "EA" #define TOK_ERROR "Y" #define TOK_FAKEHOST "FA" -#define TOK_GET "GET" +#define TOK_GET "GET" #define TOK_GLINE "GL" #define TOK_HASH "HASH" #define TOK_HELP "HELP" @@ -150,18 +150,18 @@ #define TOK_PONG "Z" #define TOK_POST "POST" #define TOK_PRIVMSG "P" -#define TOK_PRIVS "PRIVS" +#define TOK_PRIVS "PRIVS" #define TOK_PROTO "PROTO" #define TOK_QUIT "Q" #define TOK_REHASH "REHASH" -#define TOK_RESET "RESET" +#define TOK_RESET "RESET" #define TOK_RESTART "RESTART" #define TOK_RPING "RI" #define TOK_RPONG "RO" #define TOK_SERVER "S" #define TOK_SERVLIST "SERVSET" #define TOK_SERVSET "SERVSET" -#define TOK_SET "SET" +#define TOK_SET "SET" #define TOK_SETTIME "SE" #define TOK_SILENCE "U" #define TOK_SQUERY "SQUERY" @@ -196,9 +196,9 @@ #define TYPE(NAME) CMD_ ## NAME #endif /* ENABLE_TOKENS */ -#define P10_ACCOUNT TYPE(ACCOUNT) +#define P10_ACCOUNT TYPE(ACCOUNT) #define P10_ADMIN TYPE(ADMIN) -#define P10_ASLL TYPE(ASLL) +#define P10_ASLL TYPE(ASLL) #define P10_AWAY TYPE(AWAY) #define P10_BURST TYPE(BURST) #define P10_CLEARMODE TYPE(CLEARMODE) @@ -215,7 +215,7 @@ #define P10_EOB_ACK TYPE(EOB_ACK) #define P10_ERROR TYPE(ERROR) #define P10_FAKEHOST TYPE(FAKEHOST) -#define P10_GET TYPE(GET) +#define P10_GET TYPE(GET) #define P10_GLINE TYPE(GLINE) #define P10_HASH TYPE(HASH) #define P10_HELP TYPE(HELP) @@ -243,18 +243,18 @@ #define P10_PONG TYPE(PONG) #define P10_POST TYPE(POST) #define P10_PRIVMSG TYPE(PRIVMSG) -#define P10_PRIVS TYPE(PRIVS) +#define P10_PRIVS TYPE(PRIVS) #define P10_PROTO TYPE(PROTO) #define P10_QUIT TYPE(QUIT) #define P10_REHASH TYPE(REHASH) -#define P10_RESET TYPE(RESET) +#define P10_RESET TYPE(RESET) #define P10_RESTART TYPE(RESTART) #define P10_RPING TYPE(RPING) #define P10_RPONG TYPE(RPONG) #define P10_SERVER CMD_SERVER #define P10_SERVLIST TYPE(SERVLIST) #define P10_SERVSET TYPE(SERVSET) -#define P10_SET TYPE(SET) +#define P10_SET TYPE(SET) #define P10_SETTIME TYPE(SETTIME) #define P10_SILENCE TYPE(SILENCE) #define P10_SQUERY TYPE(SQUERY) @@ -2207,30 +2207,30 @@ void mod_usermode(struct userNode *user, const char *mode_change) { while (*word == ' ') word++; while (1) { #define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0) - switch (*mode_change++) { - case 0: case ' ': return; - case '+': add = 1; break; - case '-': add = 0; break; - case 'o': - do_user_mode(FLAGS_OPER); - if (add) { - userList_append(&curr_opers, user); - call_oper_funcs(user); - } else { - userList_remove(&curr_opers, user); - } - break; - case 'i': do_user_mode(FLAGS_INVISIBLE); - if (add) + switch (*mode_change++) { + case 0: case ' ': return; + case '+': add = 1; break; + case '-': add = 0; break; + case 'o': + do_user_mode(FLAGS_OPER); + if (add) { + userList_append(&curr_opers, user); + call_oper_funcs(user); + } else { + userList_remove(&curr_opers, user); + } + break; + case 'i': do_user_mode(FLAGS_INVISIBLE); + if (add) invis_clients++; else invis_clients--; - break; - case 'w': do_user_mode(FLAGS_WALLOP); break; - case 'd': do_user_mode(FLAGS_DEAF); break; - case 'k': do_user_mode(FLAGS_SERVICE); break; - case 'g': do_user_mode(FLAGS_GLOBAL); break; - case 'n': do_user_mode(FLAGS_NOCHAN); break; + break; + case 'w': do_user_mode(FLAGS_WALLOP); break; + case 'd': do_user_mode(FLAGS_DEAF); break; + case 'k': do_user_mode(FLAGS_SERVICE); break; + case 'g': do_user_mode(FLAGS_GLOBAL); break; + case 'n': do_user_mode(FLAGS_NOCHAN); break; case 'I': do_user_mode(FLAGS_NOIDLE); break; case 'x': do_user_mode(FLAGS_HIDDEN_HOST); break; case 'r': @@ -2257,7 +2257,7 @@ void mod_usermode(struct userNode *user, const char *mode_change) { assign_fakehost(user, host, 0); } break; - } + } #undef do_user_mode } } @@ -2294,14 +2294,14 @@ mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, un case 'r': do_chan_mode(MODE_REGONLY); break; case 's': do_chan_mode(MODE_SECRET); break; case 't': do_chan_mode(MODE_TOPICLIMIT); break; - case 'z': - if (!(flags & MCP_REGISTERED)) { - do_chan_mode(MODE_REGISTERED); - } else { - mod_chanmode_free(change); - return NULL; - } - break; + case 'z': + if (!(flags & MCP_REGISTERED)) { + do_chan_mode(MODE_REGISTERED); + } else { + mod_chanmode_free(change); + return NULL; + } + break; #undef do_chan_mode case 'l': if (add) { @@ -2804,13 +2804,13 @@ void reg_oper_func(oper_func_t handler) { if (of_used == of_size) { - if (of_size) { - of_size <<= 1; - of_list = realloc(of_list, of_size*sizeof(oper_func_t)); - } else { - of_size = 8; - of_list = malloc(of_size*sizeof(oper_func_t)); - } + if (of_size) { + of_size <<= 1; + of_list = realloc(of_list, of_size*sizeof(oper_func_t)); + } else { + of_size = 8; + of_list = malloc(of_size*sizeof(oper_func_t)); + } } of_list[of_used++] = handler; } @@ -2822,7 +2822,7 @@ call_oper_funcs(struct userNode *user) if (IsLocal(user)) return; for (n=0; nmask & TIMEQ_IGNORE_WHEN) || ((time_t)key == b->when)) - && ((b->mask & TIMEQ_IGNORE_FUNC) || (a->func == b->func)) - && ((b->mask & TIMEQ_IGNORE_DATA) || (a->data == b->data))) { + && ((b->mask & TIMEQ_IGNORE_FUNC) || (a->func == b->func)) + && ((b->mask & TIMEQ_IGNORE_DATA) || (a->data == b->data))) { free(data); return 1; } else { @@ -114,12 +114,12 @@ timeq_run(void) void *k, *d; struct timeq_entry *ent; while (heap_size(timeq) > 0) { - heap_peek(timeq, &k, &d); - if ((time_t)k > now) + heap_peek(timeq, &k, &d); + if ((time_t)k > now) break; - ent = d; - heap_pop(timeq); - ent->func(ent->data); + ent = d; + heap_pop(timeq); + ent->func(ent->data); free(ent); } } diff --git a/src/tools.c b/src/tools.c index 983fe9f..d8080f4 100644 --- a/src/tools.c +++ b/src/tools.c @@ -391,19 +391,19 @@ split_line(char *line, int irc_colon, int argv_size, char *argv[]) int argc = 0; int n; while (*line && (argc < argv_size)) { - while (*line == ' ') + while (*line == ' ') *line++ = 0; - if (*line == ':' && irc_colon && argc > 0) { - /* the rest is a single parameter */ - argv[argc++] = line + 1; - break; - } + if (*line == ':' && irc_colon && argc > 0) { + /* the rest is a single parameter */ + argv[argc++] = line + 1; + break; + } if (!*line) break; - argv[argc++] = line; - if (argc >= argv_size) + argv[argc++] = line; + if (argc >= argv_size) break; - while (*line != ' ' && *line) + while (*line != ' ' && *line) line++; } #ifdef NDEBUG @@ -430,7 +430,7 @@ int mmatch(const char *old_mask, const char *new_mask) if (*m == '*') { while (*m == '*') - m++; + m++; wild = 1; ma = m; na = n; @@ -439,25 +439,25 @@ int mmatch(const char *old_mask, const char *new_mask) if (!*m) { if (!*n) - return 0; + return 0; for (m--; (m > old_mask) && (*m == '?'); m--) - ; + ; if ((*m == '*') && (m > old_mask) && (m[-1] != '\\')) - return 0; + return 0; if (!wild) - return 1; + return 1; m = ma; /* Added to `mmatch' : Because '\?' and '\*' now is one character: */ if ((*na == '\\') && ((na[1] == '*') || (na[1] == '?'))) - ++na; + ++na; n = ++na; } else if (!*n) { while (*m == '*') - m++; + m++; return (*m != 0); } if ((*m == '\\') && ((m[1] == '*') || (m[1] == '?'))) @@ -494,23 +494,23 @@ int mmatch(const char *old_mask, const char *new_mask) * cases upfront (which took 2 hours!)). */ if ((*m == '*' && !mq) || - ((!mq || nq) && tolower(*m) == tolower(*n)) || - (*m == '?' && !mq && (*n != '*' || nq))) + ((!mq || nq) && tolower(*m) == tolower(*n)) || + (*m == '?' && !mq && (*n != '*' || nq))) { if (*m) - m++; + m++; if (*n) - n++; + n++; } else { if (!wild) - return 1; + return 1; m = ma; /* Added to `mmatch' : Because '\?' and '\*' now is one character: */ if ((*na == '\\') && ((na[1] == '*') || (na[1] == '?'))) - ++na; + ++na; n = ++na; } @@ -703,20 +703,20 @@ sanitize_ircmask(char *input) mask = input; while(*input++ != '!') { - length++; + length++; } if(length > NICKLEN) { - mask += NICKLEN; - *mask++ = '!'; + mask += NICKLEN; + *mask++ = '!'; - /* This flag is used to indicate following parts should - be shifted. */ - flag = 1; + /* This flag is used to indicate following parts should + be shifted. */ + flag = 1; } else { - mask = input; + mask = input; } /* The ident and host must be truncated at the beginning and @@ -725,46 +725,46 @@ sanitize_ircmask(char *input) start = input; while(*input++ != '@') { - length++; + length++; } if(length > USERLEN || flag) { - if(length > USERLEN) - { - start = input - USERLEN; - *mask++ = '*'; - } - while(*start != '@') - { - *mask++ = *start++; - } - *mask++ = '@'; - - flag = 1; + if(length > USERLEN) + { + start = input - USERLEN; + *mask++ = '*'; + } + while(*start != '@') + { + *mask++ = *start++; + } + *mask++ = '@'; + + flag = 1; } else { - mask = input; + mask = input; } length = 0; start = input; while(*input++) { - length++; + length++; } if(length > HOSTLEN || flag) { - if(length > HOSTLEN) - { - start = input - HOSTLEN; - *mask++ = '*'; - } - while(*start) - { - *mask++ = *start++; - } - *mask = '\0'; + if(length > HOSTLEN) + { + start = input - HOSTLEN; + *mask++ = '*'; + } + while(*start) + { + *mask++ = *start++; + } + *mask = '\0'; } return output; @@ -875,13 +875,13 @@ intervalString(char *output, time_t interval, struct handle_info *hi) if(!interval) { msg = language_find_message(lang, "MSG_0_SECONDS"); - return strcpy(output, msg); + return strcpy(output, msg); } for (type = 0, words = pos = 0; interval && (words < 2) && (type < ArrayLength(unit)); type++) { - if (interval < unit[type].length) + if (interval < unit[type].length) continue; count = interval / unit[type].length; interval = interval % unit[type].length; -- 2.20.1