Esempio n. 1
0
/**
 * Synchronize invite, ban, except, and G-Line lists between servers.
 *
 * @param Client New server.
 * @return CONNECTED or DISCONNECTED.
 */
static bool
Synchronize_Lists(CLIENT * Client)
{
	CHANNEL *c;
	struct list_head *head;
	struct list_elem *elem;
	time_t t;

	assert(Client != NULL);

	/* g-lines */
	head = Class_GetList(CLASS_GLINE);
	elem = Lists_GetFirst(head);
	while (elem) {
		t = Lists_GetValidity(elem) - time(NULL);
		if (!IRC_WriteStrClient(Client, "GLINE %s %ld :%s",
					Lists_GetMask(elem),
					t > 0 ? (long)t : 0,
					Lists_GetReason(elem)))
			return DISCONNECTED;
		elem = Lists_GetNext(elem);
	}

	c = Channel_First();
	while (c) {
		if (!Send_List(Client, c, Channel_GetListExcepts(c), 'e'))
			return DISCONNECTED;
		if (!Send_List(Client, c, Channel_GetListBans(c), 'b'))
			return DISCONNECTED;
		if (!Send_List(Client, c, Channel_GetListInvites(c), 'I'))
			return DISCONNECTED;
		c = Channel_Next(c);
	}
	return CONNECTED;
}
Esempio n. 2
0
static bool
ShowChannelList(struct list_head *head, CLIENT *Client, CHANNEL *Channel,
		char *msg, char *msg_end)
{
	struct list_elem *e;

	assert (Client != NULL);
	assert (Channel != NULL);

	e = Lists_GetFirst(head);
	while (e) {
		if (!IRC_WriteStrClient(Client, msg, Client_ID(Client),
					Channel_Name(Channel),
					Lists_GetMask(e),
					Lists_GetReason(e),
					Lists_GetValidity(e)))
			return DISCONNECTED;
		e = Lists_GetNext(e);
	}

	return IRC_WriteStrClient(Client, msg_end, Client_ID(Client),
				  Channel_Name(Channel));
}