예제 #1
0
static void os_cmd_mode(sourceinfo_t *si, int parc, char *parv[])
{
        char *channel = parv[0];
	char *mode = parv[1];
	channel_t *c;
	int modeparc;
	char *modeparv[256];

        if (!channel || !mode)
        {
                command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MODE");
                command_fail(si, fault_needmoreparams, _("Syntax: MODE <channel> <parameters>"));
                return;
        }

	c = channel_find(channel);
	if (!c)
	{
                command_fail(si, fault_nosuch_target, _("Channel \2%s\2 does not exist."), channel);
                return;
	}

	wallops("\2%s\2 is using MODE on \2%s\2 (set: \2%s\2)",
		get_oper_name(si), channel, mode);
	logcommand(si, CMDLOG_ADMIN, "MODE: \2%s\2 on \2%s\2", mode, channel);

	modeparc = sjtoken(mode, ' ', modeparv);

	channel_mode(si->service->me, c, modeparc, modeparv);
	command_success_nodata(si, _("Set modes \2%s\2 on \2%s\2."), mode, channel);
}
예제 #2
0
파일: inspircd11.c 프로젝트: danopia/denora
/* FJOIN is like SJOIN, but not quite. It doesnt sync
 * simple-modes, or bans/excepts.
 */
int denora_event_fjoin(char *source, int ac, char **av)
{
    char *newav[127];
    char people[1024];
    int i = 0;
    char *userv[256];
    int userc = 0;
    int nlen = 0;
    char prefixandnick[51];

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    if (ac < 3)
        return MOD_CONT;

    newav[0] = av[1];           /* Timestamp */
    newav[1] = av[0];           /* Channel */
    newav[2] = (char *) "+";    /* Mode */
    newav[3] = people;          /* Nickname */

    *people = '\0';

    /*
     * We need to remove the comma and ignore unknown modes.
     * This code is based on work by w00t for atheme.
     */
    userc = sjtoken(av[ac - 1], ' ', userv);

    /* loop over all the users in this fjoin */
    for (i = 0; i < userc; i++) {
        nlen = 0;

        alog(LOG_DEBUG, "denora_event_fjoin(): processing user: %s",
             userv[i]);

        for (; *userv[i]; userv[i]++) {
            /* does this char match a known prefix? */
            if (csmodes[(int) *userv[i]]) {
                prefixandnick[nlen++] = *userv[i];
                continue;
            }

            /* have we reached the end of the prefixes? */
            if (*userv[i] == ',') {
                /* yup, skip over the comma */
                userv[i]++;

                /* create nick with prefixes */
                strlcpy(prefixandnick + nlen, userv[i],
                        sizeof(prefixandnick) - nlen);
                /* add the user */
                strncat(people, prefixandnick, sizeof(people) - 1);
                strncat(people, " ", sizeof(people) - 1);

                /* break out of this loop, which will move us to the next user */
                break;
            }
        }
    }

    do_sjoin(source, 4, newav);

    return MOD_CONT;
}