#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)
};
/* 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 *);
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;
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;
struct note_type *ntype = data;
if(--ntype->refs > 0)
- return;
+ return;
free(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);
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++;
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;
else
{
reply("CSMSG_BAD_NOTE_ACCESS", argv[arg]);
- goto fail;
+ goto fail;
}
if(!irccasecmp(argv[++arg], "privileged"))
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;
}
channel->next = channelList;
if(channelList)
- channelList->prev = channel;
+ channelList->prev = channel;
channelList = channel;
registered_channels++;
struct userData *ud;
if(access > UL_OWNER)
- return NULL;
+ return NULL;
ud = calloc(1, sizeof(*ud));
ud->channel = channel;
ud->prev = NULL;
ud->next = channel->users;
if(channel->users)
- channel->users->prev = ud;
+ channel->users->prev = ud;
channel->users = ud;
channel->userCount++;
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++;
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);
for(ii=0; ii<bans.used; ii++)
{
if(!strcmp(bans.list[ii]->ban, bd->mask))
- {
+ {
change.argc = 1;
change.args[0].mode = MODE_REMOVE|MODE_BAN;
change.args[0].u.hostmask = bd->mask;
*/
if(!channel)
- return;
+ return;
timeq_del(0, NULL, channel, TIMEQ_IGNORE_FUNC | TIMEQ_IGNORE_WHEN);
}
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);
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)
{
free(suspended);
}
- if(cNode)
- cNode->channel_info = NULL;
+ if(cNode)
+ cNode->channel_info = NULL;
}
channel->channel->channel_info = NULL;
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)
}
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
/* 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
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;
|| (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;
{
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;
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)
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);
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]))
}
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))
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);
/* 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
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. */
/* 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. */
* 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)
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);
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? */
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);
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? */
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)
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
{
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
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)
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);
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;
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)
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
{
{
if(argc)
reply("MSG_CHANNEL_ABSENT", channel->name);
- return 0;
+ return 0;
}
uData = GetChannelAccess(channel->channel_info, user->handle_info);
{
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;
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;
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);
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
* 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)
{
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))
{
return 0;
}
- name = ban = strdup(argv[1]);
+ name = ban = strdup(argv[1]);
}
/* Truncate the ban in place if necessary; we must ensure
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);
}
}
}
- 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);
mod_chanmode_free(change);
if(exists && (action == ACTION_BAN))
- {
+ {
if(cmd)
reply("CSMSG_REDUNDANT_BAN", name, channel->name);
free(ban);
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)
}
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;
/* 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
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;
/* 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);
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);
if(argc < 2)
{
- target = user;
+ target = user;
target_handle = target->handle_info;
}
else if((target = GetUserH(argv[1])))
if(target == chanserv)
{
- reply("CSMSG_IS_CHANSERV");
- return 1;
+ reply("CSMSG_IS_CHANSERV");
+ return 1;
}
if(!target_handle)
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;
}
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);
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)))
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;
}
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;
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;
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);
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)
if(argc > 1)
{
if(!(invite = GetUserH(argv[1])))
- {
+ {
reply("MSG_NICK_UNKNOWN", argv[1]);
return 0;
}
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)
}
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;
}
{
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))
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))
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;
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
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;
}
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"))
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:
(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;
}
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;
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);
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;
if(argc > 1)
{
- interval = ParseInterval(argv[1]);
- if(argc > 2)
+ interval = ParseInterval(argv[1]);
+ if(argc > 2)
limit = atoi(argv[2]);
}
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;
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);
}
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)
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);
}
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;
}
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)
{
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);
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;
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)
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)
{
}
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);
{
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)
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]);
if(argc < 2)
{
- /* Just show current option value. */
+ /* Just show current option value. */
}
else if(enabled_string(argv[1]))
{
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)
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]);
unsigned int ii, jj;
if(!user->handle_info)
- return;
+ return;
mod_chanmode_init(&change);
change.argc = 1;
continue;
}
- if(channel->access >= UL_PRESENT)
- channel->channel->visited = now;
+ if(channel->access >= UL_PRESENT)
+ channel->channel->visited = now;
if(IsUserAutoOp(channel))
{
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)
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;
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)))
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]);
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);
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);
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)))
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)
{
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);
&& (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;
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;
}
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))
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);
}
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);
}
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);
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);
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) */
* 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;
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
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;
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;
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;
}
#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__
unsigned int n, found;\
verify(list->list);\
for (found=n=0; n<list->used; 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;\
}\
* 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);
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";
}
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;
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 {
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 {
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
}
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++;
}
{
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);
#ifndef _GETOPT_H
#define _GETOPT_H 1
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
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
/* 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__
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 ();
extern int _getopt_internal ();
#endif /* __STDC__ */
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
}
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);
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);
#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
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;
message = malloc(sizeof(struct globalMessage));
if(!message)
{
- return NULL;
+ return NULL;
}
message->id = messageCount++;
if(messageList)
{
- messageList->prev = message;
+ messageList->prev = message;
}
message->prev = NULL;
message->next = messageList;
if(duration)
{
- timeq_add(now + duration, message_expire, message);
+ timeq_add(now + duration, message_expire, message);
}
return 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;
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);
{
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";
}
}
{
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);
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;
}
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);
+ }
}
}
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);
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) {
message = message_add(target | MESSAGE_OPTION_IMMEDIATE, now, 0, sender, text);
if(!message)
- return 0;
+ return 0;
recipient = messageType(message);
message_send(message);
if(!messageList)
{
- global_notice(user, "GMSG_NO_MESSAGES");
+ global_notice(user, "GMSG_NO_MESSAGES");
return 1;
}
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);
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]);
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");
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;
}
*/
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;
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
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);
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;
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;
}
#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);
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 } }
};
{ "*Zoot*!*@*.org", { "Zoot!Zoot@services.net",
0 } },
{ "*!*@*", { "luser@host.com",
- 0 } },
+ 0 } },
{ 0, { 0 } }
};
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++) {
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;
}
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;
}
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;
}
{
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;
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;
}
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;
}
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;
}
/* 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; )
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)
return NULL;
}
- if (IsLocal(user))
+ if (IsLocal(user))
irc_join(user, channel);
- return mNode;
+ return mNode;
}
static part_func_t *pf_list;
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;
}
/* make callbacks */
for (n=0; n<pf_used; n++)
- pf_list[n](mNode, reason);
+ pf_list[n](mNode, reason);
/* free memory */
free(mNode);
/* A single check for APASS only should be enough here */
- if (!deleting && !channel->members.used && !channel->locks
+ if (!deleting && !channel->members.used && !channel->locks
&& !(channel->modes & MODE_REGISTERED) && !(channel->modes & MODE_APASS))
DelChannel(channel);
}
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);
}
}
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;
}
mn->idle_since = now;
for (n=0; n<kf_used; n++)
- kf_list[n](kicker, victim, channel);
+ kf_list[n](kicker, victim, channel);
DelChannelUser(victim, channel, 0, 0);
if (IsLocal(victim))
- irc_part(victim, channel, NULL);
+ irc_part(victim, channel, NULL);
}
int ChannelBanExists(struct chanNode *channel, const char *ban)
unsigned int n;
for (n = 0; n < channel->banlist.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;
}
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;
}
}
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; n<tf_used; n++)
- if (tf_list[n](user, channel, old_topic))
+ for (n=0; n<tf_used; n++)
+ if (tf_list[n](user, channel, old_topic))
break;
}
}
verify(user);
verify(user->channels.list);
if (channel->members.used < user->channels.used) {
- for (n=0; n<channel->members.used; n++) {
+ for (n=0; n<channel->members.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; n<user->channels.used; n++) {
+ for (n=0; n<user->channels.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;
}
#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)
#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')
#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
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;
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;
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;
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 {
{ 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;
/* 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);
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.
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) { \
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;
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;
}
}
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;
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);
}
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; i<slist->used; i++)
- totlen = totlen + strlen(slist->list[i]) + 1;
- dest = alloca(totlen+1);
- for (i=totlen=0; i<slist->used; 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; i<slist->used; i++)
+ totlen = totlen + strlen(slist->list[i]) + 1;
+ dest = alloca(totlen+1);
+ for (i=totlen=0; i<slist->used; 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;
return 0;
}
default:
- return 1;
+ return 1;
}
}
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;
}
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? */
#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
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);
}
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));
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;
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)
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.. */
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);
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:
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();
/* 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));
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;
&& !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;
}
if(!uplink)
{
- return 0;
+ return 0;
}
uplink->name = (char *)key;
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;
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;
if(cManager.uplinks)
{
- cManager.uplinks->prev = uplink;
+ cManager.uplinks->prev = uplink;
}
cManager.uplinks = uplink;
&& !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;
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;
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);
}
}
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;
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;
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;
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;
}
*/
while (n > 0) {
- ef_list[--n]();
+ ef_list[--n]();
}
free(ef_list);
ef_used = ef_size = 0;
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);
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) {
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();
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) {
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;
}
j = 0;
}
for (i=0; i<sizeof(buff); i++) {
- buffer[j++] = hex_digits[buff[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;
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;
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)
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);
}
}
}
-
+
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];
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;
}
if (IsLocal(user))
return 0;
-
+
if (!(botlist = dict_find(helpserv_bots_bychan_dict, chan->name, NULL)))
return 0;
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];
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);
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;
}
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;
}
}
}
for (nn=0; nn<client->state->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) {
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; (n<tests->used) && (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);
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; n<client->read_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; n<client->read_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);
}
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; n<client->read_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; n<client->read_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;
}
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;
}
}
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);
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;
}
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;
}
}
}
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; n<new_test->responses.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;
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);
}
{
unsigned int n;
if (state->type == CHECKING) {
- for (n=0; n<state->responses.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; n<state->responses.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);
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;
dict_delete(checked_ip_dict);
sci_list_clean(&pending_sci_list);
if (tests)
- for (n=0; n<tests->used; n++)
- sockcheck_free_state(tests->list[n]);
+ for (n=0; n<tests->used; 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;
}
}
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;
char hnamebuf[IRC_NTOP_MAX_SIZE];
for (n=1; n<argc; n++) {
- struct userNode *un = GetUserH(argv[n]);
+ struct userNode *un = GetUserH(argv[n]);
if (un) {
if (!irc_in_addr_is_valid(un->ip)
}
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);
}
/* 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);
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);
- }
+ }
}
}
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;
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;
#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"
#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[])
{
char *out = mask, *temp;
if ((temp = strchr(mask, '!'))) {
- temp++;
- while (*temp) *out++ = *temp++;
- *out++ = 0;
+ temp++;
+ while (*temp) *out++ = *temp++;
+ *out++ = 0;
}
return mask;
}
}
/* 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);
}
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;
}
}
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;
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;
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;
}
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;
}
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;
return 0;
}
for (i=0; i<len; i++) {
- if (isdigit(pass[i]))
+ if (isdigit(pass[i]))
cnt_digits++;
- if (isupper(pass[i]))
+ if (isupper(pass[i]))
cnt_upper++;
- if (islower(pass[i]))
+ if (islower(pass[i]))
cnt_lower++;
}
if ((cnt_lower < nickserv_conf.password_min_lower)
- || (cnt_upper < nickserv_conf.password_min_upper)
- || (cnt_digits < nickserv_conf.password_min_digits)) {
+ || (cnt_upper < nickserv_conf.password_min_upper)
+ || (cnt_digits < nickserv_conf.password_min_digits)) {
if (user)
send_message(user, nickserv, "NSMSG_PASSWORD_READABLE", nickserv_conf.password_min_digits, nickserv_conf.password_min_upper, nickserv_conf.password_min_lower);
return 0;
reg_auth_func(auth_func_t func)
{
if (auth_func_used == auth_func_size) {
- if (auth_func_size) {
- auth_func_size <<= 1;
- auth_func_list = realloc(auth_func_list, auth_func_size*sizeof(auth_func_t));
- } else {
- auth_func_size = 8;
- auth_func_list = malloc(auth_func_size*sizeof(auth_func_t));
- }
+ if (auth_func_size) {
+ auth_func_size <<= 1;
+ auth_func_list = realloc(auth_func_list, auth_func_size*sizeof(auth_func_t));
+ } else {
+ auth_func_size = 8;
+ auth_func_list = malloc(auth_func_size*sizeof(auth_func_t));
+ }
}
auth_func_list[auth_func_used++] = func;
}
return;
if (user->handle_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);
}
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)
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;
}
}
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))
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) {
if (IsRegistering(user)) {
reply("NSMSG_ALREADY_REGISTERING");
- return 0;
+ return 0;
}
if (IsStamped(user)) {
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);
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));
}
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)
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) {
}
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;
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;
}
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;
}
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);
}
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);
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] = "****";
{
unsigned int i;
for (i=0; i<hi->masks->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;
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;
/* 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)
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);
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;
}
{
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");
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;
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;
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"));
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"));
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);
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;
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))
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;
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);
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;
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;
}
}
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;
&& !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;
}
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;
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)
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) {
#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
#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."
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);
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);
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 */
}
}
for (n=0; n<channel->members.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; n<channel->members.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;
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) {
{
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]);
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);
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;
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;
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;
}
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);
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]);
if (!maxlen)
maxlen = MAX_LINE_SIZE;
for (n=count=0; n<target->channels.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);
}
}
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);
}
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;
}
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;
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);
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;
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);
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);
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);
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;
}
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);
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);
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) ;
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;
}
{
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);
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;
}
}
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;
}
}
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;
}
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;
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] && (i<USERLEN); i++) {
- if (argv[3][i] == '@') {
- ident[i++] = 0;
- break;
- } else {
+ 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] && (i<USERLEN); i++) {
+ if (argv[3][i] == '@') {
+ ident[i++] = 0;
+ break;
+ } else {
ident[i] = argv[3][i];
}
- }
- if (!argv[3][i] || (i==USERLEN)) {
- reply("OSMSG_NOT_A_HOSTMASK");
- return 0;
- }
- if (!(clone = AddLocalUser(argv[2], ident, argv[3]+i, userinfo, "+i"))) {
+ }
+ if (!argv[3][i] || (i==USERLEN)) {
+ reply("OSMSG_NOT_A_HOSTMASK");
+ return 0;
+ }
+ if (!(clone = AddLocalUser(argv[2], ident, argv[3]+i, userinfo, "+i"))) {
reply("OSMSG_CLONE_FAILED", argv[2]);
return 0;
}
reply("OSMSG_CLONE_ADDED", clone->nick);
- 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;
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;
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;
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);
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);
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; i<rd->d.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; i<rd->d.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;
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);
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;
}
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;
|| (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)) {
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.");
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 {
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);
}
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))
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) {
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) {
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);
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);
} 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);
} 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:
(chan->members.used > discrim->max_users) ||
(chan->timestamp < discrim->min_ts) ||
(chan->timestamp > discrim->max_ts)) {
- return 0;
+ return 0;
}
return 1;
}
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;
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]);
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;
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;
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;
}
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;
}
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;
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)))
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);
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) {
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);
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
#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;
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;
}
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);
}
}
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 == ',');
}
{
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;
}
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; i<dead_users.used; i++) {
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;
}
if (IsLocal(user)) return;
for (n=0; n<of_used; n++)
{
- of_list[n](user);
+ of_list[n](user);
}
}
if (!user || !mode_change) return;
while (1) {
#define do_user_mode(FLAG) do { if (add) user->modes |= 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
}
}
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) {
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;
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();
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;
}
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;
}
#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"
#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"
#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"
#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"
#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"
#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"
#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)
#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)
#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)
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':
assign_fakehost(user, host, 0);
}
break;
- }
+ }
#undef do_user_mode
}
}
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) {
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;
}
if (IsLocal(user))
return;
for (n=0; n<of_used; n++)
- of_list[n](user);
+ of_list[n](user);
}
static void
* which has much nicer interfaces that hide most of the ugly
* differences between protocol dialects. */
-#define COMBO_NUMERIC_LEN 5 /* 1/2, 1/3 or 2/3 digits for server/client parts */
-#define MAXLEN 512 /* Maximum IRC line length */
-#define MAXNUMPARAMS 200
+#define COMBO_NUMERIC_LEN 5 /* 1/2, 1/3 or 2/3 digits for server/client parts */
+#define MAXLEN 512 /* Maximum IRC line length */
+#define MAXNUMPARAMS 200
#define ALLCHANMSG_FUNCS_MAX 4 /* +1 == 5 potential 'allchanmsg' funcs */
struct gline;
CONNECTED
};
-#define UPLINK_UNAVAILABLE 0x001
+#define UPLINK_UNAVAILABLE 0x001
struct uplinkNode
{
- char *name;
+ char *name;
- char *host;
- int port;
+ char *host;
+ int port;
- struct sockaddr *bind_addr;
- int bind_addr_len;
+ struct sockaddr *bind_addr;
+ int bind_addr_len;
- char *password;
- char *their_password;
+ char *password;
+ char *their_password;
- enum cState state;
- int tries;
- int max_tries;
- long flags;
+ enum cState state;
+ int tries;
+ int max_tries;
+ long flags;
- struct uplinkNode *prev;
- struct uplinkNode *next;
+ struct uplinkNode *prev;
+ struct uplinkNode *next;
};
struct cManagerNode
{
- struct uplinkNode *uplinks;
- struct uplinkNode *uplink;
+ struct uplinkNode *uplinks;
+ struct uplinkNode *uplink;
- int cycles;
- int enabled;
+ int cycles;
+ int enabled;
};
#ifdef WITH_PROTOCOL_P10
#define MCP_ALLOW_OVB 0x0001 /* allow op, voice, ban manipulation */
#define MCP_FROM_SERVER 0x0002 /* parse as from a server */
#define MCP_KEY_FREE 0x0004 /* -k without a key argument */
-#define MCP_REGISTERED 0x0008 /* chan is already registered; do not allow changes to MODE_REGISTERED */
+#define MCP_REGISTERED 0x0008 /* chan is already registered; do not allow changes to MODE_REGISTERED */
#define MCP_UPASS_FREE 0x0010 /* -U without a key argument */
#define MCP_APASS_FREE 0x0020 /* -A without a key argument */
#define MC_ANNOUNCE 0x0100 /* send a mod_chanmode() change out */
struct record_data {
enum recdb_type type;
union {
- char *qstring;
- dict_t object;
- struct string_list *slist;
- void *whatever;
+ char *qstring;
+ dict_t object;
+ struct string_list *slist;
+ void *whatever;
} d;
};
}
}
#else
-#define saxdb_pre_object(DEST)
+#define saxdb_pre_object(DEST)
#endif
static inline void
struct timeq_entry *a = data;
struct timeq_extra *b = extra;
if (((b->mask & 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 {
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);
}
}
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
if (*m == '*')
{
while (*m == '*')
- m++;
+ m++;
wild = 1;
ma = m;
na = n;
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] == '?')))
* 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;
}
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
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;
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;