コード例 #1
0
ファイル: bufed.c プロジェクト: dgdunix/qemacs-tmp
static void bufed_display_hook(EditState *s)
{
    /* Prevent point from going beyond list */
    if (s->offset && s->offset == s->b->total_size)
        do_up_down(s, -1);

    bufed_select(s, 1);
}
コード例 #2
0
ファイル: misc_cmds.c プロジェクト: Elemental-IRCd/anope
int do_sync(User *u, Channel *c) {
	struct c_userlist *cu, *next;
	/* Variables needed for building the cmd to remove voices.. */
	int count = 0, newac = 0;
	char modes[BUFSIZE], nicks[BUFSIZE], buf[BUFSIZE];
	char *end1, *end2;
	char **newav = scalloc(sizeof(char *) * 13, 1);
	end1 = modes;
	end2 = nicks;
	*end1 = 0;
	*end2 = 0;
	newav[newac] = c->name;
	newac++;

	if (!c->ci) {
		free(newav);
		return MOD_CONT;
	}

	if (ircdcap->tsmode) {
		snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
		newav[newac] = buf;
		newac++;
	}

	cu = c->users;
	while (cu) {
		/* We store the next user just in case current user ends up getting kicked off the channel. */
		next = cu->next;
		do_up_down(cu->user, c, "up", 0);

		/* We have to remove voices manually because the cores function doesn't care about that
		 * as it's not covered by secureops.. */
		if (chan_has_user_status(c, cu->user, CUS_VOICE) && !check_access(cu->user, c->ci, CA_AUTOVOICE)
				&& !check_access(cu->user, c->ci, CA_VOICEME) && !check_access(cu->user, c->ci, CA_VOICE)) {
			/* Add the user to the string to remove his voice.. */
			end1 += snprintf(end1, sizeof(modes) - (end1 - modes), "-v");
			end2 += snprintf(end2, sizeof(nicks) - (end2 - nicks), "%s ", GET_USER(cu->user));
			newav[newac+1] = GET_USER(cu->user);
			newac++;
			count++;

			/* Check whether the command hasn't grown too long yet.
			 * We don't allow more then 10 mode changes per command.. this should keep us safely below the 512 max length per cmd. */
			if (count == 10) {
				/* We've reached the maximum.. send the mode changes. */
				if (ircdcap->tsmode)
					newav[2] = modes;
				else
					newav[1] = modes;
				newac++;

				anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", modes, nicks);
				do_cmode(c->ci->bi->nick, newac, newav);

				/* Reset the buffer for the next set of changes.. */
				if (ircdcap->tsmode)
					newac = 2;
				else
					newac = 1;
				*end1 = 0;
				*end2 = 0;
				count = 0;
			}
		}

		cu = next;
	}

	/* If we still have some mode changes to send, do it now.. */
	if (count > 0) {
		if (ircdcap->tsmode)
			newav[2] = modes;
		else
			newav[1] = modes;
		newac++;

		anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", modes, nicks);
		do_cmode(c->ci->bi->nick, newac, newav);
	}

	noticeLang(c->ci->bi->nick, u, LANG_SYNC_DONE, c->name);

	free(newav);
	return MOD_CONT;
}