コード例 #1
0
ファイル: os_mode.c プロジェクト: Elemental-IRCd/anope
/**
 * The /os mode command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
static int do_os_mode(User * u)
{
    int ac;
    char **av;
    char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
    Channel *c;

    if (!chan || !modes) {
        syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
        return MOD_CONT;
    }

    if (!(c = findchan(chan))) {
        notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (c->bouncy_modes) {
        notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
        return MOD_CONT;
    } else if ((ircd->adminmode) && (!is_services_admin(u))
               && (c->mode & ircd->adminmode)) {
        notice_lang(s_OperServ, u, PERMISSION_DENIED);
        return MOD_CONT;
    } else {
        anope_cmd_mode(s_OperServ, chan, "%s", modes);

        ac = split_buf(modes, &av, 1);
        chan_set_modes(s_OperServ, c, ac, av, -1);
        free(av);

        if (WallOSMode)
            anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
                             modes, chan);
    }
    return MOD_CONT;
}
コード例 #2
0
ファイル: operserv.c プロジェクト: oftc/oftc-blitzed
static void do_os_mode(User * u)
{
	int argc;
	char **argv;
	char *chan, *modes, *s;
	Channel *c;

	s = strtok(NULL, "");

	if (!s) {
		syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
		return;
	}
	
	chan = s;
	s += strcspn(s, " ");

	if (!*s) {
		syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
		return;
	}

	*s = 0;
	modes = (s + 1) + strspn(s + 1, " ");

	if (!*modes) {
		syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
		return;
	}

	if (!(c = findchan(chan))) {
		notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
	} else if (c->bouncy_modes) {
		notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
		return;
	} else {
		send_cmd(s_OperServ, "MODE %s %s", chan, modes);
		if (WallOSMode) {
			wallops(s_OperServ, "%s used MODE %s on %s",
			    u->nick, modes, chan);
		}

		*s = ' ';
		argc = split_buf(chan, &argv, 1);
		do_cmode(s_OperServ, argc, argv);
	}
}
コード例 #3
0
ファイル: events.c プロジェクト: Elemental-IRCd/anope
void event_message_process(char *eventbuf)
{
    int retVal = 0;
    EvtMessage *current = NULL;
    char source[64];
    char cmd[64];
    char buf[512];              /* Longest legal IRC command line */
    char *s;
    int ac;                     /* Parameters for the command */
    char **av;
    EvtMessage *evm;

    /* zero out the buffers before we do much else */
    *buf = '\0';
    *source = '\0';
    *cmd = '\0';

    strscpy(buf, eventbuf, sizeof(buf));

    doCleanBuffer((char *) buf);

    /* Split the buffer into pieces. */
    if (*buf == ':') {
        s = strpbrk(buf, " ");
        if (!s)
            return;
        *s = 0;
        while (isspace(*++s));
        strscpy(source, buf + 1, sizeof(source));
        memmove(buf, s, strlen(s) + 1);
    } else {
        *source = 0;
    }
    if (!*buf)
        return;
    s = strpbrk(buf, " ");
    if (s) {
        *s = 0;
        while (isspace(*++s));
    } else
        s = buf + strlen(buf);
    strscpy(cmd, buf, sizeof(cmd));
    ac = split_buf(s, &av, 1);

    /* Do something with the message. */
    evm = find_event(cmd);
    if (evm) {
        char *mod_current_module_name_save = mod_current_module_name;
        Module *mod_current_module_save = mod_current_module;
        if (evm->func) {
            mod_current_module_name = evm->mod_name;
            mod_current_module = findModule(evm->mod_name);
            retVal = evm->func(source, ac, av);
            if (retVal == MOD_CONT) {
                current = evm->next;
                while (current && current->func && retVal == MOD_CONT) {
                    mod_current_module_name = current->mod_name;
                    mod_current_module = findModule(current->mod_name);
                    retVal = current->func(source, ac, av);
                    current = current->next;
                }
            }
            mod_current_module_name = mod_current_module_name_save;
            mod_current_module = mod_current_module_save;
        }
    }
    /* Free argument list we created */
    free(av);
}
コード例 #4
0
ファイル: process.c プロジェクト: TheKing/xanadu-irc-services
void process()
{
    int retVal = 0;
    Message *current = NULL;
    char source[64];
    char cmd[64];
    char buf[512];              /* Longest legal IRC command line */
    char *s;
    int ac;                     /* Parameters for the command */
    char **av;
    Message *m;

    /* zero out the buffers before we do much else */
    *buf = '\0';
    *source = '\0';
    *cmd = '\0';

    /* If debugging, log the buffer */
    if (debug) {
        alog("debug: Received: %s", inbuf);
    }

    /* First make a copy of the buffer so we have the original in case we
     * crash - in that case, we want to know what we crashed on. */
    strscpy(buf, inbuf, sizeof(buf));

    doCleanBuffer((char *) buf);

    /* Split the buffer into pieces. */
    if (*buf == ':') {
        s = strpbrk(buf, " ");
        if (!s)
            return;
        *s = 0;
        while (isspace(*++s));
        strscpy(source, buf + 1, sizeof(source));
        memmove(buf, s, strlen(s) + 1);
    } else {
        *source = 0;
    }
    if (!*buf)
        return;
    s = strpbrk(buf, " ");
    if (s) {
        *s = 0;
        while (isspace(*++s));
    } else
        s = buf + strlen(buf);
    strscpy(cmd, buf, sizeof(cmd));
    ac = split_buf(s, &av, 1);
    if (protocoldebug) {
        protocol_debug(source, cmd, ac, av);
    }
    if (mod_current_buffer) {
        free(mod_current_buffer);
    }
    /* fix to moduleGetLastBuffer() bug 296 */
    /* old logic was that since its meant for PRIVMSG that we would get
       the NICK as AV[0] and the rest would be in av[1], however on Bahamut
       based systems when you do /cs it assumes we will translate the command
       to the NICK and thus AV[0] is the message. The new logic is to check
       av[0] to see if its a service nick if so assign mod_current_buffer the
       value from AV[1] else just assign av[0] - TSL */
    /* First check if the ircd proto module overrides this -GD */
    /* fix to moduleGetLastBuffer() bug 476:
       fixed in part by adding {} to nickIsServices()
       however if you have a pseudo they could not use moduleGetLastBuffer()
       cause they are not part of nickIsServices, even those the ac count is 2
       that was ignored and only the first param was passed on which is fine for
       Bahmut ircd aliases but not for pseudo clients on. So additional logic is
       that if the ac is greater then 1 copy av[1] else copy av[0] 
       I also changed from if statments, cause attempting to access a array member
       that is not set can lead to odd things - TSL (3/12/06) */
    if (!xanadu_set_mod_current_buffer(ac, av)) {
        if (ac >= 1) {
            if (nickIsServices(av[0], 1)) {
                mod_current_buffer =
                    (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0]));
            } else {
                mod_current_buffer =
                    (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0]));
            }
        } else {
            mod_current_buffer = NULL;
        }
    }
    /* Do something with the message. */
    m = find_message(cmd);
    if (m) {
        if (m->func) {
            mod_current_module_name = m->mod_name;
            retVal = m->func(source, ac, av);
            mod_current_module_name = NULL;
            if (retVal == MOD_CONT) {
                current = m->next;
                while (current && current->func && retVal == MOD_CONT) {
                    mod_current_module_name = current->mod_name;
                    retVal = current->func(source, ac, av);
                    mod_current_module_name = NULL;
                    current = current->next;
                }
            }
        }
    } else {
        if (debug)
            alog("debug: unknown message from server (%s)", inbuf);
    }

    /* Load/unload modules if needed */
    handleModuleOperationQueue();

    /* Free argument list we created */
    free(av);
}