{ "MCMSG_HELPFILE_UNBOUND", "Since that was the last command from module %s on the service, the helpfile for %s was removed." },
{ "MCMSG_NO_HELPFILE", "Module %s does not have a help file." },
{ "MCMSG_HELPFILE_ERROR", "Syntax error reading %s; help contents not changed." },
- { "MCMSG_HELPFILE_READ", "Read %s help database in "FMT_TIME_T".%03lu seconds." },
- { "MCMSG_COMMAND_TIME", "Command $b%s$b finished in "FMT_TIME_T".%06lu seconds." },
+ { "MCMSG_HELPFILE_READ", "Read %s help database in %lu.%03lu seconds." },
+ { "MCMSG_COMMAND_TIME", "Command $b%s$b finished in %lu.%06lu seconds." },
{ "MCMSG_NEED_OPSERV_LEVEL", "You must have $O access of at least $b%u$b." },
{ "MCMSG_NEED_CHANSERV_LEVEL", "You must have $C access of at least $b%u$b in the channel." },
{ "MCMSG_NEED_ACCOUNT_FLAGS", "You must have account flags $b%s$b." },
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 irccasecmp(fa->name, fb->name);
}
-DEFINE_LIST(svccmd_list, struct svccmd*);
-DEFINE_LIST(module_list, struct module*);
+DEFINE_LIST(svccmd_list, struct svccmd*)
+DEFINE_LIST(module_list, struct module*)
static void
free_service_command(void *data) {
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);
*/
int
svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cmd, struct chanNode *channel, int options) {
+ extern struct userNode *chanserv;
unsigned int uData_checked = 0;
struct userData *uData = NULL;
int rflags = 0, flags = cmd->effective_flags;
return 0;
}
if (flags & MODCMD_REQUIRE_REGCHAN) {
- if (!channel->channel_info) {
+ if (!chanserv) {
+ /* Just use the inferred MODCMD_REQUIRE_CHANNEL. */
+ } else if (!channel->channel_info) {
if (options & SVCCMD_NOISY)
send_message(user, bot, "MCMSG_CHAN_NOT_REGISTERED", channel->name);
return 0;
} else if (IsSuspended(channel->channel_info) && !(flags & MODCMD_IGNORE_CSUSPEND)) {
- /* allow security-override users to always ignore channel suspensions, but flag it as a staff command */
- if (!user->handle_info
- || !HANDLE_FLAGGED(user->handle_info, HELPING)
- || (flags & MODCMD_NEVER_CSUSPEND)) {
+ /* Allow security-override users to ignore most channel
+ * suspensions, but flag that use as a staff command.
+ */
+ if (!IsHelping(user) || (flags & MODCMD_NEVER_CSUSPEND)) {
if (options & SVCCMD_NOISY)
send_message(user, bot, "MCMSG_CHAN_SUSPENDED", channel->name, channel->channel_info->suspended->reason);
return 0;
if (flags & MODCMD_REQUIRE_CHANUSER) {
if (!uData_checked)
uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1;
- if (!uData) {
+ if (!chanserv) {
+ /* Assume someone knows what they're doing. */
+ } else if (!uData) {
if (options & SVCCMD_NOISY)
send_message(user, bot, "MCMSG_NO_CHANNEL_ACCESS", channel->name);
return 0;
log_module(MAIN_LOG, LOG_ERROR, "Alias expansion parse error in %s (near %s; %s.%s arg %d).", arg, end_num, cmd->parent->bot->nick, cmd->name, ii);
return 0;
}
+ if (lbound >= old_argc)
+ return -1;
if (ubound >= old_argc)
ubound = old_argc - 1;
if (lbound < old_argc)
/* Expand the alias arguments, if there are any. */
if (cmd->alias.used) {
char *new_argv[MAXNUMPARAMS];
- argc = svccmd_expand_alias(cmd, argc, argv, new_argv);
- if (!argc) {
- send_message(service->bot, user, "MCMSG_ALIAS_ERROR", cmd->name);
+ int res;
+
+ res = svccmd_expand_alias(cmd, argc, argv, new_argv);
+ if (res < 0) {
+ send_message(user, service->bot, "MSG_MISSING_PARAMS", cmd->name);
+ return 0;
+ } else if (res == 0) {
+ send_message(user, service->bot, "MCMSG_ALIAS_ERROR", cmd->name);
return 0;
}
+ argc = res;
argv = new_argv;
/* Try again to grab a handle to the channel after alias
irc_notice_user(bot,user, "\x01PING\x01");
}
} else if (!irccasecmp(text, "TIME")) {
- struct tm tm;
- localtime_r(&now, &tm);
- strftime(response, sizeof(response), "\x01TIME %a %b %d %H:%M:%S %Y\x01", &tm);
+ time_t feh;
+ feh = now;
+ strftime(response, sizeof(response), "\x01TIME %a %b %d %H:%M:%S %Y\x01", localtime(&feh));
irc_notice_user(bot, user, response);
} else if (!irccasecmp(text, "USERINFO")) {
snprintf(response, sizeof(response), "\x01USERINFO %s\x01", bot->info);
}
void
-modcmd_chanmsg(struct userNode *user, struct chanNode *chan, const char *text, struct userNode *bot) {
+modcmd_chanmsg(struct userNode *user, struct chanNode *chan, const char *text, struct userNode *bot, unsigned int is_notice) {
struct service *service;
- if (!(service = dict_find(services, bot->nick, NULL))) return;
+ if (!(service = dict_find(services, bot->nick, NULL)))
+ return;
svccmd_invoke(user, service, chan, text, 0);
+ (void)is_notice;
}
struct service *
continue;
} else if (isdigit(argv[arg][1])) {
char *end_num;
+ unsigned long tmp;
- strtoul(argv[arg]+1, &end_num, 10);
+ tmp = strtoul(argv[arg]+1, &end_num, 10);
switch (end_num[0]) {
case 0:
continue;
stop.tv_sec -= 1;
stop.tv_usec += 1000000;
}
- reply("MCMSG_HELPFILE_READ", module->name, stop.tv_sec, stop.tv_usec/1000);
+ reply("MCMSG_HELPFILE_READ", module->name, (unsigned long)stop.tv_sec, (unsigned long)stop.tv_usec/1000);
return 1;
}
stop.tv_sec -= 1;
stop.tv_usec += 1000000;
}
- reply("MCMSG_COMMAND_TIME", cmd_text, stop.tv_sec, stop.tv_usec);
+ reply("MCMSG_COMMAND_TIME", cmd_text, (unsigned long)stop.tv_sec, (unsigned long)stop.tv_usec);
return 1;
}
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);
reply("MSG_INTERNAL_FAILURE");
return 0;
}
- if ((res = setjmp(ctx->jbuf)) != 0) {
- ctx->complex.used = 0; /* to avoid false assert()s in close */
- saxdb_close_context(ctx);
- fclose(pf);
+ if ((res = setjmp(*saxdb_jmp_buf(ctx))) != 0) {
+ saxdb_close_context(ctx, 1);
reply("MCMSG_MESSAGE_DUMP_FAILED", strerror(res));
return 0;
} else {
for (it = dict_first(lang_C->messages); it; it = iter_next(it))
saxdb_write_string(ctx, iter_key(it), iter_data(it));
- saxdb_close_context(ctx);
- fclose(pf);
+ saxdb_close_context(ctx, 1);
reply("MCMSG_MESSAGES_DUMPED", fname);
return 1;
}
* command or its accessibility to normal IRC users, except to add
* copyright information pertaining to changes you make to srvx.
*/
- send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__". Copyright 2000-2007 srvx Development Team.");
+ send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__". Copyright 2000-2008 srvx Development Team.");
if (argc > 1)
send_message_type(4, user, cmd->parent->bot, "%s", git_version);
else
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();