MY_SUBDIRS="$MY_SUBDIRS src"
CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
if test "z$USE_MAINTAINER_MODE" = zyes ; then
- CFLAGS="$CFLAGS -Werror -ansi"
+ CFLAGS="$CFLAGS -Werror -Wshadow -ansi"
fi
AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
}
static struct userData*
-add_channel_user(struct chanData *channel, struct handle_info *handle, unsigned short access, unsigned long seen, const char *info)
+add_channel_user(struct chanData *channel, struct handle_info *handle, unsigned short access_level, unsigned long seen, const char *info)
{
struct userData *ud;
- if(access > UL_OWNER)
+ if(access_level > UL_OWNER)
return NULL;
ud = calloc(1, sizeof(*ud));
ud->channel = channel;
ud->handle = handle;
ud->seen = seen;
- ud->access = access;
+ ud->access = access_level;
ud->info = info ? strdup(info) : NULL;
ud->prev = NULL;
struct userData *actee;
struct userData *actor, *real_actor;
struct handle_info *handle;
- unsigned short access, override = 0;
+ unsigned short access_level, override = 0;
REQUIRE_PARAMS(3);
return 0;
}
- access = user_level_from_name(argv[2], UL_OWNER);
- if(!access)
+ access_level = user_level_from_name(argv[2], UL_OWNER);
+ if(!access_level)
{
reply("CSMSG_INVALID_ACCESS", argv[2]);
return 0;
actor = GetChannelUser(channel->channel_info, user->handle_info);
real_actor = GetChannelAccess(channel->channel_info, user->handle_info);
- if(actor->access <= access)
+ if(actor->access <= access_level)
{
reply("CSMSG_NO_BUMP_ACCESS");
return 0;
}
/* Trying to add someone with equal/more access? */
- if (!real_actor || real_actor->access <= access)
+ if (!real_actor || real_actor->access <= access_level)
override = CMD_LOG_OVERRIDE;
if(!(handle = modcmd_get_handle_info(user, argv[1])))
return 0;
}
- actee = add_channel_user(channel->channel_info, handle, access, 0, NULL);
+ actee = add_channel_user(channel->channel_info, handle, access_level, 0, NULL);
scan_user_presence(actee, NULL);
- reply("CSMSG_ADDED_USER", handle->handle, channel->name, access);
+ reply("CSMSG_ADDED_USER", handle->handle, channel->name, access_level);
return 1 | override;
}
struct handle_info *handle;
struct userData *victim;
struct userData *actor, *real_actor;
- unsigned short access, override = 0;
+ unsigned short access_level, override = 0;
char *chan_name;
REQUIRE_PARAMS(2);
if(argc > 2)
{
- access = user_level_from_name(argv[1], UL_OWNER);
- if(!access)
+ access_level = user_level_from_name(argv[1], UL_OWNER);
+ if(!access_level)
{
reply("CSMSG_INVALID_ACCESS", argv[1]);
return 0;
}
- if(access != victim->access)
+ if(access_level != victim->access)
{
reply("CSMSG_INCORRECT_ACCESS", handle->handle, victim->access, argv[1]);
return 0;
}
else
{
- access = victim->access;
+ access_level = victim->access;
}
if((actor->access <= victim->access) && !IsHelping(user))
chan_name = strdup(channel->name);
del_channel_user(victim, 1);
- reply("CSMSG_DELETED_USER", handle->handle, access, chan_name);
+ reply("CSMSG_DELETED_USER", handle->handle, access_level, chan_name);
free(chan_name);
return 1 | override;
}
ary[3] = "Status";
for(matches = 1; matches < lData.table.length; ++matches)
{
- struct userData *uData = lData.users[matches-1];
char seen[INTERVALLEN];
+ uData = lData.users[matches-1];
ary = malloc(lData.table.width*sizeof(**lData.table.contents));
lData.table.contents[matches] = ary;
ary[0] = strtab(uData->access);
channel_multiple_option(enum charOption option, struct userNode *user, struct chanNode *channel, int argc, char *argv[], struct svccmd *cmd)
{
struct chanData *cData = channel->channel_info;
- int count = charOptions[option].count, index;
+ int count = charOptions[option].count, idx;
if(argc > 1)
{
- index = atoi(argv[1]);
+ idx = atoi(argv[1]);
- if(!isdigit(argv[1][0]) || (index < 0) || (index >= count))
+ if(!isdigit(argv[1][0]) || (idx < 0) || (idx >= count))
{
- reply("CSMSG_INVALID_NUMERIC", index);
+ reply("CSMSG_INVALID_NUMERIC", idx);
/* 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));
+ for(idx = 0; idx < count; idx++)
+ reply(charOptions[option].format_name, idx, user_find_message(user, charOptions[option].values[idx].format_name));
return 0;
}
- cData->chOpts[option] = charOptions[option].values[index].value;
+ cData->chOpts[option] = charOptions[option].values[idx].value;
}
else
{
/* Find current option value. */
find_value:
- for(index = 0;
- (index < count) && (cData->chOpts[option] != charOptions[option].values[index].value);
- index++);
- if(index == count)
+ for(idx = 0;
+ (idx < count) && (cData->chOpts[option] != charOptions[option].values[idx].value);
+ idx++);
+ if(idx == count)
{
/* Somehow, the option value is corrupt; reset it to the default. */
cData->chOpts[option] = charOptions[option].default_value;
}
}
- reply(charOptions[option].format_name, index, user_find_message(user, charOptions[option].values[index].format_name));
+ reply(charOptions[option].format_name, idx, user_find_message(user, charOptions[option].values[idx].format_name));
return 1;
}
static CHANSERV_FUNC(cmd_suspend)
{
struct handle_info *hi;
- struct userData *self, *real_self, *target;
+ struct userData *actor, *real_actor, *target;
unsigned int override = 0;
REQUIRE_PARAMS(2);
if(!(hi = modcmd_get_handle_info(user, argv[1]))) return 0;
- self = GetChannelUser(channel->channel_info, user->handle_info);
- real_self = GetChannelAccess(channel->channel_info, user->handle_info);
+ actor = GetChannelUser(channel->channel_info, user->handle_info);
+ real_actor = GetChannelAccess(channel->channel_info, user->handle_info);
if(!(target = GetTrueChannelAccess(channel->channel_info, hi)))
{
reply("CSMSG_NO_CHAN_USER", hi->handle, channel->name);
return 0;
}
- if(target->access >= self->access)
+ if(target->access >= actor->access)
{
reply("MSG_USER_OUTRANKED", hi->handle);
return 0;
target->present = 0;
target->seen = now;
}
- if(!real_self || target->access >= real_self->access)
+ if(!real_actor || target->access >= real_actor->access)
override = CMD_LOG_OVERRIDE;
target->flags |= USER_SUSPENDED;
reply("CSMSG_USER_SUSPENDED", hi->handle, channel->name);
static CHANSERV_FUNC(cmd_unsuspend)
{
struct handle_info *hi;
- struct userData *self, *real_self, *target;
+ struct userData *actor, *real_actor, *target;
unsigned int override = 0;
REQUIRE_PARAMS(2);
if(!(hi = modcmd_get_handle_info(user, argv[1]))) return 0;
- self = GetChannelUser(channel->channel_info, user->handle_info);
- real_self = GetChannelAccess(channel->channel_info, user->handle_info);
+ actor = GetChannelUser(channel->channel_info, user->handle_info);
+ real_actor = GetChannelAccess(channel->channel_info, user->handle_info);
if(!(target = GetTrueChannelAccess(channel->channel_info, hi)))
{
reply("CSMSG_NO_CHAN_USER", hi->handle, channel->name);
return 0;
}
- if(target->access >= self->access)
+ if(target->access >= actor->access)
{
reply("MSG_USER_OUTRANKED", hi->handle);
return 0;
reply("CSMSG_NOT_SUSPENDED", hi->handle);
return 0;
}
- if(!real_self || target->access >= real_self->access)
+ if(!real_actor || target->access >= real_actor->access)
override = CMD_LOG_OVERRIDE;
target->flags &= ~USER_SUSPENDED;
scan_user_presence(target, NULL);
struct handle_info *hi;
struct userData *target;
const char *confirm_string;
- unsigned short access;
+ unsigned short access_level;
char *channel_name;
hi = user->handle_info;
reply("CSMSG_CONFIRM_DELETEME", confirm_string);
return 0;
}
- access = target->access;
+ access_level = target->access;
channel_name = strdup(channel->name);
del_channel_user(target, 1);
- reply("CSMSG_DELETED_YOU", access, channel_name);
+ reply("CSMSG_DELETED_YOU", access_level, channel_name);
free(channel_name);
return 1;
}
static void
chanserv_refresh_topics(UNUSED_ARG(void *data))
{
- unsigned int refresh_num = (now - self->link) / chanserv_conf.refresh_period;
+ unsigned int refresh_num = (now - self->link_time) / chanserv_conf.refresh_period;
struct chanData *cData;
char opt;
for(ii = 0; ii < user->channels.used; ++ii)
{
- struct chanNode *channel = user->channels.list[ii]->channel;
+ struct chanNode *chan = user->channels.list[ii]->channel;
struct banData *ban;
if((user->channels.list[ii]->modes & (MODE_CHANOP|MODE_VOICE))
- || !channel->channel_info
- || IsSuspended(channel->channel_info))
+ || !chan->channel_info
+ || IsSuspended(chan->channel_info))
continue;
- for(jj = 0; jj < channel->banlist.used; ++jj)
- if(user_matches_glob(user, channel->banlist.list[jj]->ban, MATCH_USENICK))
+ for(jj = 0; jj < chan->banlist.used; ++jj)
+ if(user_matches_glob(user, chan->banlist.list[jj]->ban, MATCH_USENICK))
break;
- if(jj < channel->banlist.used)
+ if(jj < chan->banlist.used)
continue;
- for(ban = channel->channel_info->bans; ban; ban = ban->next)
+ for(ban = chan->channel_info->bans; ban; ban = ban->next)
{
char kick_reason[MAXLEN];
if(!user_matches_glob(user, ban->mask, MATCH_USENICK | MATCH_VISIBLE))
continue;
change.args[0].mode = MODE_BAN;
change.args[0].u.hostmask = ban->mask;
- mod_chanmode_announce(chanserv, channel, &change);
+ mod_chanmode_announce(chanserv, chan, &change);
sprintf(kick_reason, "(%s) %s", ban->owner, ban->reason);
- KickChannelUser(user, channel, chanserv, kick_reason);
+ KickChannelUser(user, chan, chanserv, kick_reason);
ban->triggered = now;
break;
}
/* delimiter */
NULL
};
- unsigned int ii;
strlist = alloc_string_list(ArrayLength(list)-1);
for(ii=0; list[ii]; ii++)
string_list_append(strlist, strdup(list[ii]));
struct userData *uData;
char *seen, *inf, *flags;
unsigned long last_seen;
- unsigned short access;
+ unsigned short access_level;
if(rd->type != RECDB_OBJECT || !dict_size(rd->d.object))
{
return;
}
- access = atoi(database_get_data(rd->d.object, KEY_LEVEL, RECDB_QSTRING));
- if(access > UL_OWNER)
+ access_level = atoi(database_get_data(rd->d.object, KEY_LEVEL, RECDB_QSTRING));
+ if(access_level > UL_OWNER)
{
log_module(CS_LOG, LOG_ERROR, "Invalid access level for %s in %s.", key, chan->channel->name);
return;
return;
}
- uData = add_channel_user(chan, handle, access, last_seen, inf);
+ uData = add_channel_user(chan, handle, access_level, last_seen, inf);
uData->flags = flags ? strtoul(flags, NULL, 0) : 0;
}
struct server {
char name[SERVERNAMEMAX+1];
unsigned long boot;
- unsigned long link;
+ unsigned long link_time;
char description[SERVERDESCRIPTMAX+1];
#ifdef WITH_PROTOCOL_P10
char numeric[COMBO_NUMERIC_LEN+1];
* its value).
*/
static void
-heap_heapify_up(heap_t heap, unsigned int index)
+heap_heapify_up(heap_t heap, unsigned int idx)
{
int res;
unsigned int parent;
void *last_key, *last_data;
- last_key = heap->data[index*2];
- last_data = heap->data[index*2+1];
- while (index > 0) {
- parent = (index - 1) >> 1;
+
+ last_key = heap->data[idx*2];
+ last_data = heap->data[idx*2+1];
+ while (idx > 0) {
+ parent = (idx - 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[idx*2] = heap->data[parent*2];
+ heap->data[idx*2+1] = heap->data[parent*2+1];
+ idx = parent;
}
- heap->data[index*2] = last_key;
- heap->data[index*2+1] = last_data;
+ heap->data[idx*2] = last_key;
+ heap->data[idx*2+1] = last_data;
}
/*
}
/*
- * Remove the element at "index" from the heap (preserving the heap ordering).
+ * Remove the element at "idx" from the heap (preserving the heap ordering).
*/
static void
-heap_remove(heap_t heap, unsigned int index)
+heap_remove(heap_t heap, unsigned int idx)
{
/* sanity check */
- if (heap->data_used <= index) return;
- /* swap index with last element */
+ if (heap->data_used <= idx) return;
+ /* swap idx with last element */
heap->data_used--;
- heap->data[index*2] = heap->data[heap->data_used*2];
- heap->data[index*2+1] = heap->data[heap->data_used*2+1];
- /* heapify down if index has children */
- if (heap->data_used >= 2*index+1) heap_heapify_down(heap, index);
- if ((index > 0) && (index < heap->data_used)) heap_heapify_up(heap, index);
+ heap->data[idx*2] = heap->data[heap->data_used*2];
+ heap->data[idx*2+1] = heap->data[heap->data_used*2+1];
+ /* heapify down if idx has children */
+ if (heap->data_used >= 2*idx+1) heap_heapify_down(heap, idx);
+ if ((idx > 0) && (idx < heap->data_used)) heap_heapify_up(heap, idx);
}
/*
target->size += source->used;
target->list = realloc(target->list, target->size * sizeof(target->list[0]));
for (ii = 0; ii < source->used; ++ii, ++jj) {
- int dup;
- for (dup = 0, kk = 0; kk < jj; kk++) {
+ int is_duplicate;
+ for (is_duplicate = 0, kk = 0; kk < jj; kk++) {
if (target->list[kk] == source->list[ii]) {
- dup = 1;
+ is_duplicate = 1;
break;
}
}
- if (dup) {
+ if (is_duplicate) {
jj--;
target->used--;
continue;
static void
log_parse_cross(const char *buffer, struct string_list *types, char sevset[LOG_NUM_SEVERITIES])
{
- char *dup, *sep;
+ char *buffer_copy, *sep;
- dup = strdup(buffer);
- sep = strchr(dup, '.');
+ buffer_copy = strdup(buffer);
+ sep = strchr(buffer_copy, '.');
*sep++ = 0;
- log_parse_logset(dup, types);
+ log_parse_logset(buffer_copy, types);
log_parse_sevset(sep, sevset);
- free(dup);
+ free(buffer_copy);
}
static void
}
static void
-ldFile_reopen(struct logDestination *self_) {
- struct logDest_file *self = (struct logDest_file*)self_;
- fclose(self->output);
- self->output = fopen(self->fname, "a");
+ldFile_reopen(struct logDestination *dest_) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
+ fclose(dest->output);
+ dest->output = fopen(dest->fname, "a");
}
static void
-ldFile_close(struct logDestination *self_) {
- struct logDest_file *self = (struct logDest_file*)self_;
- fclose(self->output);
- free(self->fname);
- free(self);
+ldFile_close(struct logDestination *dest_) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
+ fclose(dest->output);
+ free(dest->fname);
+ free(dest);
}
static void
-ldFile_audit(struct logDestination *self_, UNUSED_ARG(struct log_type *type), struct logEntry *entry) {
- struct logDest_file *self = (struct logDest_file*)self_;
- fputs(entry->default_desc, self->output);
- fputc('\n', self->output);
- fflush(self->output);
+ldFile_audit(struct logDestination *dest_, UNUSED_ARG(struct log_type *type), struct logEntry *entry) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
+ fputs(entry->default_desc, dest->output);
+ fputc('\n', dest->output);
+ fflush(dest->output);
}
static void
-ldFile_replay(struct logDestination *self_, UNUSED_ARG(struct log_type *type), int is_write, const char *line) {
- struct logDest_file *self = (struct logDest_file*)self_;
+ldFile_replay(struct logDestination *dest_, UNUSED_ARG(struct log_type *type), int is_write, const char *line) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
struct string_buffer sbuf;
memset(&sbuf, 0, sizeof(sbuf));
log_format_timestamp(now, &sbuf);
string_buffer_append_string(&sbuf, is_write ? "W: " : " ");
string_buffer_append_string(&sbuf, line);
- fputs(sbuf.list, self->output);
- fputc('\n', self->output);
+ fputs(sbuf.list, dest->output);
+ fputc('\n', dest->output);
free(sbuf.list);
- fflush(self->output);
+ fflush(dest->output);
}
static void
-ldFile_module(struct logDestination *self_, struct log_type *type, enum log_severity sev, const char *message) {
- struct logDest_file *self = (struct logDest_file*)self_;
+ldFile_module(struct logDestination *dest_, struct log_type *type, enum log_severity sev, const char *message) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
struct string_buffer sbuf;
memset(&sbuf, 0, sizeof(sbuf));
log_format_timestamp(now, &sbuf);
- fprintf(self->output, "%s (%s:%s) %s\n", sbuf.list, type->name, log_severity_names[sev], message);
+ fprintf(dest->output, "%s (%s:%s) %s\n", sbuf.list, type->name, log_severity_names[sev], message);
free(sbuf.list);
- fflush(self->output);
+ fflush(dest->output);
}
static struct logDest_vtable ldFile_vtbl = {
}
static void
-ldStd_close(struct logDestination *self_) {
- struct logDest_file *self = (struct logDest_file*)self_;
- free(self->fname);
- free(self);
+ldStd_close(struct logDestination *dest_) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
+ free(dest->fname);
+ free(dest);
}
static void
-ldStd_replay(struct logDestination *self_, UNUSED_ARG(struct log_type *type), int is_write, const char *line) {
- struct logDest_file *self = (struct logDest_file*)self_;
- fprintf(self->output, "%s%s\n", is_write ? "W: " : " ", line);
+ldStd_replay(struct logDestination *dest_, UNUSED_ARG(struct log_type *type), int is_write, const char *line) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
+ fprintf(dest->output, "%s%s\n", is_write ? "W: " : " ", line);
}
static void
-ldStd_module(struct logDestination *self_, UNUSED_ARG(struct log_type *type), enum log_severity sev, const char *message) {
- struct logDest_file *self = (struct logDest_file*)self_;
- fprintf(self->output, "%s: %s\n", log_severity_names[sev], message);
+ldStd_module(struct logDestination *dest_, UNUSED_ARG(struct log_type *type), enum log_severity sev, const char *message) {
+ struct logDest_file *dest = (struct logDest_file*)dest_;
+ fprintf(dest->output, "%s: %s\n", log_severity_names[sev], message);
}
static struct logDest_vtable ldStd_vtbl = {
}
static void
-ldIrc_close(struct logDestination *self_) {
- struct logDest_irc *self = (struct logDest_irc*)self_;
- free(self->target);
- free(self);
+ldIrc_close(struct logDestination *dest_) {
+ struct logDest_irc *dest = (struct logDest_irc*)dest_;
+ free(dest->target);
+ free(dest);
}
static void
-ldIrc_audit(struct logDestination *self_, UNUSED_ARG(struct log_type *type), struct logEntry *entry) {
- struct logDest_irc *self = (struct logDest_irc*)self_;
+ldIrc_audit(struct logDestination *dest_, UNUSED_ARG(struct log_type *type), struct logEntry *entry) {
+ struct logDest_irc *dest = (struct logDest_irc*)dest_;
if (entry->channel_name) {
- send_target_message(4, self->target, entry->bot, "(%s", strchr(strchr(entry->default_desc, ' '), ':')+1);
+ send_target_message(4, dest->target, entry->bot, "(%s", strchr(strchr(entry->default_desc, ' '), ':')+1);
} else {
- send_target_message(4, self->target, entry->bot, "%s", strchr(entry->default_desc, ')')+2);
+ send_target_message(4, dest->target, entry->bot, "%s", strchr(entry->default_desc, ')')+2);
}
}
static void
-ldIrc_module(struct logDestination *self_, struct log_type *type, enum log_severity sev, const char *message) {
- struct logDest_irc *self = (struct logDest_irc*)self_;
+ldIrc_module(struct logDestination *dest_, struct log_type *type, enum log_severity sev, const char *message) {
+ struct logDest_irc *dest = (struct logDest_irc*)dest_;
extern struct userNode *opserv;
- send_target_message(4, self->target, opserv, "%s %s: %s\n", type->name, log_severity_names[sev], message);
+ send_target_message(4, dest->target, opserv, "%s %s: %s\n", type->name, log_severity_names[sev], message);
}
static struct logDest_vtable ldIrc_vtbl = {
#endif
static void
-usage(char *self)
+usage(char *exe_name)
{
/* We can assume we have getopt_long(). */
printf("Usage: %s [-c config] [-r log] [-d] [-f] [-v|-h]\n"
" -k, --check checks the configuration file's syntax.\n"
" -r, --replay replay a log file (for debugging).\n"
" -v, --version prints this program's version.\n"
- , self);
+ , exe_name);
}
static void
int main(int argc, char *argv[])
{
- int daemon, debug;
+ int run_as_daemon;
+ int debug;
pid_t pid = 0;
FILE *file_out;
struct sigaction sv;
GC_enable_incremental();
#endif
- daemon = 1;
+ run_as_daemon = 1;
debug = 0;
tools_init();
debug = 1;
break;
case 'f':
- daemon = 0;
+ run_as_daemon = 0;
break;
case 'v':
version();
conf_register_reload(uplink_compile);
- if (daemon) {
+ if (run_as_daemon) {
/* Attempt to fork into the background if daemon mode is on. */
pid = fork();
if (pid < 0) {
fclose(file_out);
}
- if (daemon) {
+ if (run_as_daemon) {
/* Close these since we should not use them from now on. */
fclose(stdin);
fclose(stdout);
unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
- unsigned int i, index, partLen;
+ unsigned int i, idx, partLen;
/* Compute number of bytes mod 64 */
- index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+ idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
- partLen = 64 - index;
+ partLen = 64 - idx;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
- memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen);
+ memcpy((POINTER)&context->buffer[idx], (POINTER)input, partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state, &input[i]);
- index = 0;
+ idx = 0;
}
else
i = 0;
/* Buffer remaining input */
- memcpy((POINTER)&context->buffer[index], (POINTER)&input[i],
+ memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i],
inputLen-i);
}
MD5_CTX *context; /* context */
{
unsigned char bits[8];
- unsigned int index, padLen;
+ unsigned int idx, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64. */
- index = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
+ idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ padLen = (idx < 56) ? (56 - idx) : (120 - idx);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
}
int
-checkpass(const char *pass, const char *crypt)
+checkpass(const char *pass, const char *crypted)
{
- char new_crypt[MD5_CRYPT_LENGTH], hseed[9];
+ char new_crypted[MD5_CRYPT_LENGTH], hseed[9];
int seed;
- if (crypt[0] == '$') {
+ if (crypted[0] == '$') {
/* new-style crypt, use "seed" after '$' */
- strncpy(hseed, crypt+1, 8);
+ strncpy(hseed, crypted+1, 8);
hseed[8] = 0;
seed = strtoul(hseed, NULL, 16);
} else {
/* old-style crypt, use "seed" of 0 */
seed = 0;
}
- cryptpass_real(pass, new_crypt, seed);
- return !strcmp(crypt, new_crypt);
+ cryptpass_real(pass, new_crypted, seed);
+ return !strcmp(crypted, new_crypted);
}
static struct helpserv_request * create_request(struct userNode *user, struct helpserv_bot *hs, int from_join) {
struct helpserv_request *req = calloc(1, sizeof(struct helpserv_request));
- char lbuf[3][MAX_LINE_SIZE], unh[INTERVALLEN];
+ char lbuf[3][MAX_LINE_SIZE], req_id[INTERVALLEN];
struct helpserv_reqlist *reqlist, *hand_reqlist;
const unsigned int from_opserv = 0;
const char *fmt;
assert(req);
req->id = ++hs->last_requestid;
- sprintf(unh, "%lu", req->id);
- dict_insert(hs->requests, strdup(unh), req);
+ sprintf(req_id, "%lu", req->id);
+ dict_insert(hs->requests, strdup(req_id), req);
if (hs->id_wrap) {
unsigned long i;
sprintf(lbuf[0], fmt, req->id);
}
if (req != hs->unhandled) {
- intervalString(unh, now - hs->unhandled->opened, user->handle_info);
+ intervalString(req_id, now - hs->unhandled->opened, user->handle_info);
fmt = user_find_message(user, "HSMSG_REQ_UNHANDLED_TIME");
- sprintf(lbuf[1], fmt, unh);
+ sprintf(lbuf[1], fmt, req_id);
} else {
fmt = user_find_message(user, "HSMSG_REQ_NO_UNHANDLED");
sprintf(lbuf[1], "%s", fmt);
}
static struct helpserv_cmd *
-helpserv_define_func(const char *name, helpserv_func_t *func, enum helpserv_level access, long flags) {
+helpserv_define_func(const char *name, helpserv_func_t *func, enum helpserv_level level, long flags) {
struct helpserv_cmd *cmd = calloc(1, sizeof(struct helpserv_cmd));
- cmd->access = access;
+ cmd->access = level;
cmd->weight = 1.0;
cmd->func = func;
cmd->flags = flags;
if ((hs->persist_types[PERSIST_T_HELPER] == PERSIST_PART)
&& (req->helper == hs_user)) {
- char reason[CHANNELLEN + 8];
- sprintf(reason, "parted %s", mn->channel->name);
- helpserv_page_helper_gone(hs, req, reason);
+ char our_reason[CHANNELLEN + 8];
+ sprintf(our_reason, "parted %s", mn->channel->name);
+ helpserv_page_helper_gone(hs, req, our_reason);
}
}
{
dict_iterator_t it;
for (it = dict_first(memos); it; it = iter_next(it)) {
- struct memo_account *acct = iter_data(it);
+ struct memo_account *account = iter_data(it);
unsigned int ii;
- for (ii = 0; ii < acct->sent.used; ++ii) {
- struct memo *memo = acct->sent.list[ii];
+ for (ii = 0; ii < account->sent.used; ++ii) {
+ struct memo *memo = account->sent.list[ii];
if ((now - memo->sent) > memoserv_conf.message_expiry) {
delete_memo(memo);
memosExpired++;
}
static int
-memoserv_can_send(struct userNode *bot, struct userNode *user, struct memo_account *acct)
+memoserv_can_send(struct userNode *bot, struct userNode *user, struct memo_account *account)
{
extern struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended);
struct userData *dest;
if (!user->handle_info)
return 0;
- if (!(acct->flags & MEMO_DENY_NONCHANNEL))
+ if (!(account->flags & MEMO_DENY_NONCHANNEL))
return 1;
- for (dest = acct->handle->channels; dest; dest = dest->u_next)
+ for (dest = account->handle->channels; dest; dest = dest->u_next)
if (_GetChannelUser(dest->channel, user->handle_info, 1, 0))
return 1;
- send_message(user, bot, "MSMSG_CANNOT_SEND", acct->handle->handle);
+ send_message(user, bot, "MSMSG_CANNOT_SEND", account->handle->handle);
return 0;
}
static struct modcmd_flag {
const char *name;
unsigned int flag;
-} flags[] = {
+} modcmd_flags[] = {
{ "acceptchan", MODCMD_ACCEPT_CHANNEL },
{ "acceptpluschan", MODCMD_ACCEPT_PCHANNEL },
{ "authed", MODCMD_REQUIRE_AUTHED },
return 0;
}
value++;
- flag = bsearch(value, flags, ArrayLength(flags)-1, sizeof(flags[0]), flags_bsearch);
+ flag = bsearch(value, modcmd_flags, ArrayLength(modcmd_flags)-1, sizeof(modcmd_flags[0]), flags_bsearch);
if (!flag) {
if (user)
send_message(user, bot, "MCMSG_UNKNOWN_FLAG", end, value);
continue;
} else if (isdigit(argv[arg][1])) {
char *end_num;
- unsigned long arg;
+ unsigned long tmp;
- arg = strtoul(argv[arg]+1, &end_num, 10);
+ tmp = strtoul(argv[arg]+1, &end_num, 10);
switch (end_num[0]) {
case 0:
continue;
snprintf(buf1, sizeof(buf1), "%s.%s", target->command->parent->name, target->command->name);
reply("MCMSG_COMMAND_BINDING", target->name, buf1);
}
- for (ii = buf1_used = buf2_used = 0; flags[ii].name; ++ii) {
- if (target->flags & flags[ii].flag) {
+ for (ii = buf1_used = buf2_used = 0; modcmd_flags[ii].name; ++ii) {
+ const struct modcmd_flag *flag = &modcmd_flags[ii];
+ if (target->flags & flag->flag) {
if (buf1_used)
buf1[buf1_used++] = ',';
- len = strlen(flags[ii].name);
- memcpy(buf1 + buf1_used, flags[ii].name, len);
+ len = strlen(flag->name);
+ memcpy(buf1 + buf1_used, flag->name, len);
buf1_used += len;
- } else if (target->effective_flags & flags[ii].flag) {
+ } else if (target->effective_flags & flag->flag) {
if (buf2_used)
buf2[buf2_used++] = ',';
- len = strlen(flags[ii].name);
- memcpy(buf2 + buf2_used, flags[ii].name, len);
+ len = strlen(flag->name);
+ memcpy(buf2 + buf2_used, flag->name, len);
buf2_used += len;
}
}
if (show_opserv_level)
tbl.contents[ii+1][1] = strtab(svccmd->min_opserv_level);
if (show_channel_access) {
- const char *access;
+ const char *access_name;
int flags = svccmd->effective_flags;
if (flags & MODCMD_REQUIRE_HELPING)
- access = "helping";
+ access_name = "helping";
else if (flags & MODCMD_REQUIRE_STAFF) {
if (flags & MODCMD_REQUIRE_OPER)
- access = "oper";
+ access_name = "oper";
else if (flags & MODCMD_REQUIRE_NETWORK_HELPER)
- access = "net.helper";
+ access_name = "net.helper";
else
- access = "staff";
+ access_name = "staff";
} else
- access = strtab(svccmd->min_channel_access);
- tbl.contents[ii+1][1+show_opserv_level] = access;
+ access_name = strtab(svccmd->min_channel_access);
+ tbl.contents[ii+1][1+show_opserv_level] = access_name;
}
}
svccmd_list_clean(&commands);
saxdb_write_int(ctx, "channel_access", cmd->min_channel_access);
if (cmd->flags != template->flags) {
if (cmd->flags) {
- for (nn=pos=0; flags[nn].name; ++nn) {
- if (cmd->flags & flags[nn].flag) {
+ for (nn=pos=0; modcmd_flags[nn].name; ++nn) {
+ const struct modcmd_flag *flag = &modcmd_flags[nn];
+ if (cmd->flags & flag->flag) {
buf[pos++] = '+';
- len = strlen(flags[nn].name);
- memcpy(buf+pos, flags[nn].name, len);
+ len = strlen(flag->name);
+ memcpy(buf+pos, flag->name, len);
pos += len;
buf[pos++] = ',';
}
void
modcmd_init(void) {
- qsort(flags, ArrayLength(flags)-1, sizeof(flags[0]), flags_qsort);
+ qsort(modcmd_flags, ArrayLength(modcmd_flags)-1, sizeof(modcmd_flags[0]), flags_qsort);
modules = dict_new();
dict_set_free_data(modules, free_module);
services = dict_new();
if (stamp) {
if (!nickserv_conf.disable_nicks) {
- struct nick_info *ni;
- for (ni = hi->nicks; ni; ni = ni->next) {
- if (!irccasecmp(user->nick, ni->nick)) {
+ struct nick_info *ni2;
+ for (ni2 = hi->nicks; ni2; ni2 = ni2->next) {
+ if (!irccasecmp(user->nick, ni2->nick)) {
user->modes |= FLAGS_REGNICK;
break;
}
}
if (hi->channels) {
- struct userData *channel, *next;
+ struct userData *chan, *next;
char *name;
- for (channel = hi->channels; channel; channel = next) {
- next = channel->u_next;
- name = channel->channel->channel->name;
+ for (chan = hi->channels; chan; chan = next) {
+ next = chan->u_next;
+ name = chan->channel->channel->name;
herelen = strlen(name);
if (pos + herelen + 7 > ArrayLength(buff)) {
- next = channel;
+ next = chan;
goto print_chans_buff;
}
- if (IsUserSuspended(channel))
+ if (IsUserSuspended(chan))
buff[pos++] = '-';
- pos += sprintf(buff+pos, "%d:%s ", channel->access, name);
+ pos += sprintf(buff+pos, "%d:%s ", chan->access, name);
if (next == NULL) {
print_chans_buff:
buff[pos-1] = 0;
struct string_list *masks, *slist;
struct handle_info *hi;
struct userNode *authed_users;
- struct userData *channels;
+ struct userData *channel_list;
unsigned long id;
unsigned int ii;
dict_t subdb;
}
if ((hi = get_handle_info(handle))) {
authed_users = hi->users;
- channels = hi->channels;
+ channel_list = hi->channels;
hi->users = NULL;
hi->channels = NULL;
dict_remove(nickserv_handle_dict, hi->handle);
} else {
authed_users = NULL;
- channels = NULL;
+ channel_list = NULL;
}
hi = register_handle(handle, str, id);
if (authed_users) {
authed_users = authed_users->next_authed;
}
}
- hi->channels = channels;
+ hi->channels = channel_list;
masks = database_get_data(obj, KEY_MASKS, RECDB_STRING_LIST);
hi->masks = masks ? string_list_copy(masks) : alloc_string_list(1);
str = database_get_data(obj, KEY_MAXLOGINS, RECDB_QSTRING);
const char *setter;
const char *text;
const char *set;
- const char *id;
+ const char *note_id;
dict_t notedb;
- id = iter_key(it);
+ note_id = iter_key(it);
notedb = GET_RECORD_OBJECT((struct record_data*)iter_data(it));
if (!notedb) {
- log_module(NS_LOG, LOG_ERROR, "Malformed note %s for account %s; ignoring note.", id, hi->handle);
+ log_module(NS_LOG, LOG_ERROR, "Malformed note %s for account %s; ignoring note.", note_id, hi->handle);
continue;
}
expires = database_get_data(notedb, KEY_NOTE_EXPIRES, RECDB_QSTRING);
text = database_get_data(notedb, KEY_NOTE_NOTE, RECDB_QSTRING);
set = database_get_data(notedb, KEY_NOTE_SET, RECDB_QSTRING);
if (!setter || !text || !set) {
- log_module(NS_LOG, LOG_ERROR, "Missing field(s) from note %s for account %s; ignoring note.", id, hi->handle);
+ log_module(NS_LOG, LOG_ERROR, "Missing field(s) from note %s for account %s; ignoring note.", note_id, hi->handle);
continue;
}
note = calloc(1, sizeof(*note) + strlen(text));
note->next = NULL;
note->expires = expires ? strtoul(expires, NULL, 10) : 0;
note->set = strtoul(set, NULL, 10);
- note->id = strtoul(id, NULL, 10);
+ note->id = strtoul(note_id, NULL, 10);
safestrncpy(note->setter, setter, sizeof(note->setter));
strcpy(note->note, text);
if (last_note)
#endif
tbl.contents[nn][1] = buffer;
ofs = strlen(buffer) + 1;
- intervalString(buffer + ofs, now - server->link, user->handle_info);
+ intervalString(buffer + ofs, now - server->link_time, user->handle_info);
if (server->self_burst)
strcat(buffer + ofs, " Bursting");
tbl.contents[nn][2] = buffer + ofs;
/* Scan for existing channels that match the new bad word. */
if (!bad_found) {
for (it = dict_first(channels); it; it = iter_next(it)) {
- struct chanNode *channel = iter_data(it);
+ struct chanNode *chan = iter_data(it);
- if (!opserv_bad_channel(channel->name))
+ if (!opserv_bad_channel(chan->name))
continue;
- channel->bad_channel = 1;
- if (channel->name[0] == '#')
- opserv_shutdown_channel(channel, "OSMSG_ILLEGAL_REASON");
+ chan->bad_channel = 1;
+ if (chan->name[0] == '#')
+ opserv_shutdown_channel(chan, "OSMSG_ILLEGAL_REASON");
else {
unsigned int nn;
- for (nn=0; nn<channel->members.used; nn++) {
- struct userNode *user = channel->members.list[nn]->user;
- DelUser(user, cmd->parent->bot, 1, "OSMSG_ILLEGAL_KILL_REASON");
+ for (nn = 0; nn < chan->members.used; nn++) {
+ struct userNode *victim = chan->members.list[nn]->user;
+ DelUser(victim, cmd->parent->bot, 1, "OSMSG_ILLEGAL_KILL_REASON");
}
}
}
static int
discrim_match(discrim_t discrim, struct userNode *user)
{
- unsigned int access, i;
+ unsigned int level, i;
if ((user->timestamp < discrim->min_ts)
|| (user->timestamp > discrim->max_ts)
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)) {
+ level = user->handle_info ? user->handle_info->opserv_level : 0;
+ if ((level < discrim->min_level)
+ || (level > discrim->max_level)) {
return 0;
}
if (discrim->min_clones > 1) {
void irc_svsmode(struct userNode *target, char *modes, unsigned long stamp);
struct server *
-AddServer(struct server *uplink, const char *name, int hops, unsigned long boot, unsigned long link, UNUSED_ARG(const char *numeric), const char *description) {
+AddServer(struct server *uplink, const char *name, int hops, unsigned long boot, unsigned long link_time, UNUSED_ARG(const char *numeric), const char *description) {
struct server* sNode;
sNode = calloc(1, sizeof(*sNode));
safestrncpy(sNode->name, name, sizeof(sNode->name));
sNode->hops = hops;
sNode->boot = boot;
- sNode->link = link;
+ sNode->link_time = link_time;
sNode->users = dict_new();
safestrncpy(sNode->description, description, sizeof(sNode->description));
serverList_init(&sNode->children);
while (!quit_services) {
if (!replay_connected) {
/* this time fudging is to get some of the logging right */
- self->link = self->boot = now;
+ self->link_time = self->boot = now;
cManager.uplink->state = AUTHENTICATING;
irc_introduce(cManager.uplink->password);
replay_connected = 1;
if (srv == self) {
/* The +s, ignored by Run's ircu, means "service" to Undernet's ircu */
putsock(P10_SERVER " %s %d %lu %lu J10 %s%s +s6 :%s",
- srv->name, srv->hops+1, srv->boot, srv->link, srv->numeric, extranum, srv->description);
+ srv->name, srv->hops+1, srv->boot, srv->link_time, srv->numeric, extranum, srv->description);
} else {
putsock("%s " P10_SERVER " %s %d %lu %lu %c10 %s%s +s6 :%s",
- self->numeric, srv->name, srv->hops+1, srv->boot, srv->link, (srv->self_burst ? 'J' : 'P'), srv->numeric, extranum, srv->description);
+ self->numeric, srv->name, srv->hops+1, srv->boot, srv->link_time, (srv->self_burst ? 'J' : 'P'), srv->numeric, extranum, srv->description);
}
}
{
char *delim;
struct timeval orig;
- struct timeval now;
+ struct timeval sys_now;
int diff;
orig.tv_sec = strtoul(orig_ts, &delim, 10);
orig.tv_usec = (*delim == '.') ? strtoul(delim + 1, NULL, 10) : 0;
- gettimeofday(&now, NULL);
- diff = (now.tv_sec - orig.tv_sec) * 1000 + (now.tv_usec - orig.tv_usec) / 1000;
- putsock("%s " P10_PONG " %s %s %d %lu.%06lu", self->numeric, who, orig_ts, diff, (unsigned long)now.tv_sec, (unsigned long)now.tv_usec);
+ gettimeofday(&sys_now, NULL);
+ diff = (sys_now.tv_sec - orig.tv_sec) * 1000 + (sys_now.tv_usec - orig.tv_usec) / 1000;
+ putsock("%s " P10_PONG " %s %s %d %lu.%06lu", self->numeric, who, orig_ts, diff, (unsigned long)sys_now.tv_sec, (unsigned long)sys_now.tv_usec);
}
void
* Alternately, we are same age, but we accept their time
* since we are linking to them. */
self->boot = srv->boot;
- ioset_set_time(srv->link);
+ ioset_set_time(srv->link_time);
}
}
if (srv == self->uplink) {
}
struct server *
-AddServer(struct server *uplink, const char *name, int hops, unsigned long boot, unsigned long link, const char *numeric, const char *description)
+AddServer(struct server *uplink, const char *name, int hops, unsigned long boot, unsigned long link_time, const char *numeric, const char *description)
{
struct server* sNode;
int slen, mlen;
sNode->num_mask = base64toint(numeric+slen, mlen);
sNode->hops = hops;
sNode->boot = boot;
- sNode->link = link;
+ sNode->link_time = link_time;
strncpy(sNode->numeric, numeric, slen);
safestrncpy(sNode->description, description, sizeof(sNode->description));
sNode->users = calloc(sNode->num_mask+1, sizeof(*sNode->users));
static int
clear_chanmode(struct chanNode *channel, const char *modes)
{
- unsigned int remove;
+ unsigned int cleared;
- for (remove = 0; *modes; modes++) {
+ for (cleared = 0; *modes; modes++) {
switch (*modes) {
- case 'o': remove |= MODE_CHANOP; break;
- case 'v': remove |= MODE_VOICE; break;
- case 'p': remove |= MODE_PRIVATE; break;
- case 's': remove |= MODE_SECRET; break;
- case 'm': remove |= MODE_MODERATED; break;
- case 't': remove |= MODE_TOPICLIMIT; break;
- case 'i': remove |= MODE_INVITEONLY; break;
- case 'n': remove |= MODE_NOPRIVMSGS; break;
+ case 'o': cleared |= MODE_CHANOP; break;
+ case 'v': cleared |= MODE_VOICE; break;
+ case 'p': cleared |= MODE_PRIVATE; break;
+ case 's': cleared |= MODE_SECRET; break;
+ case 'm': cleared |= MODE_MODERATED; break;
+ case 't': cleared |= MODE_TOPICLIMIT; break;
+ case 'i': cleared |= MODE_INVITEONLY; break;
+ case 'n': cleared |= MODE_NOPRIVMSGS; break;
case 'k':
- remove |= MODE_KEY;
+ cleared |= MODE_KEY;
channel->key[0] = '\0';
break;
case 'A':
- remove |= MODE_APASS;
+ cleared |= MODE_APASS;
channel->apass[0] = '\0';
break;
case 'U':
- remove |= MODE_UPASS;
+ cleared |= MODE_UPASS;
channel->upass[0] = '\0';
break;
case 'l':
- remove |= MODE_LIMIT;
+ cleared |= MODE_LIMIT;
channel->limit = 0;
break;
- case 'b': remove |= MODE_BAN; break;
- case 'D': remove |= MODE_DELAYJOINS; break;
- case 'r': remove |= MODE_REGONLY; break;
- case 'c': remove |= MODE_NOCOLORS; break;
- case 'C': remove |= MODE_NOCTCPS; break;
- case 'z': remove |= MODE_REGISTERED; break;
+ case 'b': cleared |= MODE_BAN; break;
+ case 'D': cleared |= MODE_DELAYJOINS; break;
+ case 'r': cleared |= MODE_REGONLY; break;
+ case 'c': cleared |= MODE_NOCOLORS; break;
+ case 'C': cleared |= MODE_NOCTCPS; break;
+ case 'z': cleared |= MODE_REGISTERED; break;
}
}
- if (!remove)
+ if (!cleared)
return 1;
/* Remove simple modes. */
- channel->modes &= ~remove;
+ channel->modes &= ~cleared;
/* If removing bans, kill 'em all. */
- if ((remove & MODE_BAN) && channel->banlist.used) {
+ if ((cleared & MODE_BAN) && channel->banlist.used) {
unsigned int i;
for (i=0; i<channel->banlist.used; i++)
free(channel->banlist.list[i]);
}
/* Remove member modes. */
- if ((remove & (MODE_CHANOP | MODE_VOICE)) && channel->members.used) {
- int mask = ~(remove & (MODE_CHANOP | MODE_VOICE));
+ if ((cleared & (MODE_CHANOP | MODE_VOICE)) && channel->members.used) {
+ int mask = ~(cleared & (MODE_CHANOP | MODE_VOICE));
unsigned int i;
for (i = 0; i < channel->members.used; i++)
if (flags & SNI_NUMERICHOST) {
const char *servname;
- unsigned int len;
char host[SAR_NTOP_MAX], servbuf[16];
/* If appropriate, try to look up service name. */
unsigned long
timeq_next(void)
{
- void *time;
+ void *timep;
if (!timeq)
return ~0;
- heap_peek(timeq, &time, 0);
- return (unsigned long)time;
+ heap_peek(timeq, &timep, 0);
+ return (unsigned long)timep;
}
void
uint32_t ip4;
pos = irc_pton_ip4(input, bits, &ip4);
if (pos) {
+/* glibc's htons() macro is not -Wshadow-safe. */
+#undef htons
addr->in6[5] = htons(65535);
addr->in6[6] = htons(ntohl(ip4) >> 16);
addr->in6[7] = htons(ntohl(ip4) & 65535);