* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "../ChangeLog"
#include "chanserv.h"
#include "conf.h"
#include "compat.h"
#include "opserv.h"
#include "saxdb.h"
#include "timeq.h"
+#include "version.h"
struct pending_template {
static int
svccmd_expand_alias(struct svccmd *cmd, struct userNode *user, unsigned int old_argc, char *old_argv[], char *new_argv[]) {
unsigned int ii, new_argc;
- char *arg;
+ char *arg, *altarg;
for (ii=new_argc=0; ii<cmd->alias.used; ++ii) {
+ altarg = NULL;
arg = cmd->alias.list[ii];
if (arg[0] != '$') {
new_argv[new_argc++] = arg;
if (arg[1] == '$') {
new_argv[new_argc++] = arg + 1;
} else if (isdigit(arg[1])) {
- unsigned int lbound, ubound, jj;
+ unsigned int lbound = 0;
+ unsigned int ubound = 0;
+ unsigned int jj = 0;
char *end_num;
lbound = strtoul(arg+1, &end_num, 10);
switch (end_num[0]) {
case 0: ubound = lbound; break;
+ case 'a':
+ altarg = (user && user->handle_info) ? user->handle_info->handle : "(account)";
+ break;
+ case 'n':
+ altarg = user ? user->nick : "(nick)";
+ break;
+ case 'm':
+#ifdef WITH_PROTOCOL_P10
+ altarg = user ? user->numeric : "(numnick)";
+#else
+ altarg = "(This ircd protocol has no numnicks!)";
+#endif
+ break;
case '-':
if (end_num[1] == 0) {
ubound = old_argc - 1;
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 (altarg != NULL) {
+ if (end_num[1] != 0) {
+ if ((end_num[1] == '-') && (end_num[2] == 0))
+ ubound = old_argc - 1;
+ else if ((end_num[1] == '-') && (isdigit(end_num[2])))
+ ubound = strtoul(end_num+2, NULL, 10);
+ else {
+ 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;
+ }
+ } else {
+ ubound = lbound;
+ }
+ if (lbound >= old_argc)
+ new_argv[new_argc++] = altarg;
+ }
if (ubound >= old_argc)
ubound = old_argc - 1;
if (lbound < old_argc)
struct svccmd *cmd;
unsigned int cmd_arg, perms, flags, options, result;
char channel_name[CHANNELLEN+1];
+ char *new_argv[MAXNUMPARAMS]; /* for aliases */
options = (server_qualified ? SVCCMD_QUALIFIED : 0) | SVCCMD_DEBIT | SVCCMD_NOISY;
/* Find the command argument. */
/* Expand the alias arguments, if there are any. */
if (cmd->alias.used) {
- char *new_argv[MAXNUMPARAMS];
int res;
res = svccmd_expand_alias(cmd, user, argc, argv, new_argv);
safestrncpy(channel_name, channel->name, sizeof(channel_name));
else
channel_name[0] = 0;
- if (!(result = cmd->command->func(user, channel, argc, argv, cmd)))
+
+ /* Call the function here */
+ if (!(result = cmd->command->func(user, channel, argc, argv, cmd)))
return 0;
+
if (!(flags & MODCMD_NO_LOG)) {
enum log_severity slvl;
if (result & CMD_LOG_OVERRIDE)
return argc ? svccmd_invoke_argv(user, service, channel, argc, argv, server_qualified) : 0;
}
-char *cvs_verstring() {
- static char verstring[MAXLEN] = { 0 };
-
- if(!*verstring) {
- char *svn = NULL, *svnver = NULL, *svndate = NULL, *v = 0, ver[MAXLEN];
- int vc = 0;
-
- strcpy(ver, CVS_VERSION);
- for (svn = x3_strtok(&v, ver, " "); svn;
- svn = x3_strtok(&v, 0, " ")) {
- if (vc == 2)
- svnver = svn;
- else if (vc == 3)
- svndate = svn;
- vc++;
- }
- sprintf(verstring, "%s %s", svnver, svndate);
- }
- return verstring;
-}
-
-
void
modcmd_privmsg(struct userNode *user, struct userNode *bot, const char *text, int server_qualified) {
struct service *service;
snprintf(response, sizeof(response), "\x01USERINFO %s\x01", bot->info);
irc_notice_user(bot, user, response);
} else if (!irccasecmp(text, "VERSION")) {
- snprintf(response, sizeof(response), "\x01VERSION %s+[%s]\x01", PACKAGE_STRING, cvs_verstring());
+ snprintf(response, sizeof(response), "\x01VERSION %s+[%s]\x01", PACKAGE_STRING, cvs_version);
irc_notice_user(bot, user, response);
} else if (!irccasecmp(text, "GENDER")) {
snprintf(response, sizeof(response), "\x01GENDER ummm im still deciding\x01");
switch (end_num[0]) {
case 0:
continue;
+ case 'a':
+ case 'n':
+ case 'm':
+ if (end_num[1] == 0)
+ continue;
+ else if (end_num[1] == '-')
+ end_num++;
+ else
+ return arg;
case '-':
if (end_num[1] == 0)
continue;
}
static MODCMD_FUNC(cmd_version) {
- send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", cvs_verstring());
+ send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"+[%s]$b (Based on srvx 1.3.x), Built: "__DATE__", "__TIME__".", cvs_version);
send_message_type(4, user, cmd->parent->bot, "See $bCREDITS$b for more information.");
return 1;
}
}
void
-modcmd_cleanup(void) {
+modcmd_cleanup(UNUSED_ARG(void* extra)) {
dict_delete(services);
dict_delete(modules);
if (suf_list)
services = dict_new();
dict_set_free_data(services, free_service);
reg_nick_change_func(modcmd_nick_change, NULL);
- reg_exit_func(modcmd_cleanup);
+ reg_exit_func(modcmd_cleanup, NULL);
conf_register_reload(modcmd_conf_read);
modcmd_module = module_register("modcmd", MAIN_LOG, "modcmd.help", modcmd_expand);