~rcr/rirc

0dcaae1ac435b6ebf2d83c535daed6020486ccd1 — Richard Robbins 30 days ago 1cc35bc
fix privmsg channel type terminology
M src/components/channel.h => src/components/channel.h +2 -2
@@ 20,9 20,9 @@ enum channel_type
{
	CHANNEL_T_INVALID,
	CHANNEL_T_RIRC,    /* Default buffer */
	CHANNEL_T_CHANNEL, /* Channel message buffer */
	CHANNEL_T_CHANNEL, /* Channel buffer */
	CHANNEL_T_PRIVMSG, /* Privmsg buffer */
	CHANNEL_T_SERVER,  /* Server message buffer */
	CHANNEL_T_PRIVATE, /* Private message buffer */
	CHANNEL_T_SIZE
};


M src/components/server.c => src/components/server.c +1 -1
@@ 190,7 190,7 @@ server_set_chans(struct server *s, const char *str)
		if (irc_ischan(chan))
			c = channel(chan, CHANNEL_T_CHANNEL);
		else
			c = channel(chan, CHANNEL_T_PRIVATE);
			c = channel(chan, CHANNEL_T_PRIVMSG);

		c->server = s;
		channel_list_add(&s->clist, c);

M src/draw.c => src/draw.c +4 -4
@@ 638,8 638,8 @@ draw_status(struct channel *c)
	/* server buffer:
	 *  -[+usermodes]-(ping)-(scrollback)
	 *
	 * private buffer:
	 *  -[+usermodes]-[priv]-(ping)-(scrollback)
	 * privmsg buffer:
	 *  -[+usermodes]-[privmsg]-(ping)-(scrollback)
	 *
	 * channel buffer:
	 *  -[+usermodes]-[+chanmodes chancount]-(ping)-(scrollback)


@@ 666,10 666,10 @@ draw_status(struct channel *c)
	}

	/* -[priv] */
	if (c->type == CHANNEL_T_PRIVATE) {
	if (c->type == CHANNEL_T_PRIVMSG) {
		if (!drawf(&cols, STATUS_SEP_HORZ))
			return;
		if (!drawf(&cols, "[priv]"))
		if (!drawf(&cols, "[privmsg]"))
			return;
	}


M src/handlers/irc_ctcp.c => src/handlers/irc_ctcp.c +1 -1
@@ 113,7 113,7 @@ ctcp_request_action(struct server *s, const char *from, const char *targ, char *

	if (!irc_strcmp(s->casemapping, targ, s->nick)) {
		if ((c = channel_list_get(&s->clist, from, s->casemapping)) == NULL) {
			c = channel(from, CHANNEL_T_PRIVATE);
			c = channel(from, CHANNEL_T_PRIVMSG);
			c->activity = ACTIVITY_PINGED;
			c->server = s;
			channel_list_add(&s->clist, c);

M src/handlers/irc_recv.c => src/handlers/irc_recv.c +1 -1
@@ 1167,7 1167,7 @@ recv_privmsg(struct server *s, struct irc_message *m)
	if (!strcmp(target, s->nick)) {

		if ((c = channel_list_get(&s->clist, m->from, s->casemapping)) == NULL) {
			c = channel(m->from, CHANNEL_T_PRIVATE);
			c = channel(m->from, CHANNEL_T_PRIVMSG);
			c->server = s;
			channel_list_add(&s->clist, c);
		}

M src/handlers/irc_send.c => src/handlers/irc_send.c +45 -45
@@ 22,7 22,7 @@
	         failf((C), "Send fail: %s", io_err(ret)); \
	} while (0)

static const char* nick_or_priv(struct channel*, char*);
static const char* irc_send_target(struct channel*, char*);

int
irc_send_command(struct server *s, struct channel *c, char *m)


@@ 66,7 66,7 @@ irc_send_privmsg(struct server *s, struct channel *c, char *m)
	if (!s->registered)
		failf(c, "Not registered with server");

	if (!(c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVATE))
	if (!(c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVMSG))
		failf(c, "This is not a channel");

	if (c->type == CHANNEL_T_CHANNEL && (!c->joined || c->parted))


@@ 83,14 83,14 @@ irc_send_privmsg(struct server *s, struct channel *c, char *m)
}

static const char*
nick_or_priv(struct channel *c, char *m)
irc_send_target(struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if ((nick = irc_strsep(&m)))
		return nick;
	if ((target = irc_strsep(&m)))
		return target;

	if (c->type == CHANNEL_T_PRIVATE)
	if (c->type == CHANNEL_T_PRIVMSG)
		return c->name;

	return NULL;


@@ 110,15 110,15 @@ send_away(struct server *s, struct channel *c, char *m)
static int
send_notice(struct server *s, struct channel *c, char *m)
{
	const char *targ;
	const char *target;

	if (!(targ = irc_strsep(&m)))
	if (!(target = irc_strsep(&m)))
		failf(c, "Usage: /notice <target> <message>");

	if (!m || !*m)
		failf(c, "Usage: /notice <target> <message>");

	sendf(s, c, "NOTICE %s :%s", targ, m);
	sendf(s, c, "NOTICE %s :%s", target, m);

	return 0;
}


@@ 140,15 140,15 @@ send_part(struct server *s, struct channel *c, char *m)
static int
send_privmsg(struct server *s, struct channel *c, char *m)
{
	const char *targ;
	const char *target;

	if (!(targ = irc_strsep(&m)))
	if (!(target = irc_strsep(&m)))
		failf(c, "Usage: /privmsg <target> <message>");

	if (!m || !*m)
		failf(c, "Usage: /privmsg <target> <message>");

	sendf(s, c, "PRIVMSG %s :%s", targ, m);
	sendf(s, c, "PRIVMSG %s :%s", target, m);

	return 0;
}


@@ 197,12 197,12 @@ send_topic_unset(struct server *s, struct channel *c, char *m)
static int
send_ctcp_action(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = irc_strsep(&m)) || !irc_strtrim(&m))
		failf(c, "Usage: /ctcp-action <nick> <text>");
	if (!(target = irc_strsep(&m)) || !irc_strtrim(&m))
		failf(c, "Usage: /ctcp-action <target> <text>");

	sendf(s, c, "PRIVMSG %s :\001ACTION %s\001", nick, m);
	sendf(s, c, "PRIVMSG %s :\001ACTION %s\001", target, m);

	return 0;
}


@@ 210,12 210,12 @@ send_ctcp_action(struct server *s, struct channel *c, char *m)
static int
send_ctcp_clientinfo(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-clientinfo <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-clientinfo <target>");

	sendf(s, c, "PRIVMSG %s :\001CLIENTINFO\001", nick);
	sendf(s, c, "PRIVMSG %s :\001CLIENTINFO\001", target);

	return 0;
}


@@ 223,12 223,12 @@ send_ctcp_clientinfo(struct server *s, struct channel *c, char *m)
static int
send_ctcp_finger(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-finger <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-finger <target>");

	sendf(s, c, "PRIVMSG %s :\001FINGER\001", nick);
	sendf(s, c, "PRIVMSG %s :\001FINGER\001", target);

	return 0;
}


@@ 236,15 236,15 @@ send_ctcp_finger(struct server *s, struct channel *c, char *m)
static int
send_ctcp_ping(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;
	struct timeval t;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-ping <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-ping <target>");

	(void) gettimeofday(&t, NULL);

	sendf(s, c, "PRIVMSG %s :\001PING %llu %llu\001", nick,
	sendf(s, c, "PRIVMSG %s :\001PING %llu %llu\001", target,
		(unsigned long long)t.tv_sec,
		(unsigned long long)t.tv_usec);



@@ 254,12 254,12 @@ send_ctcp_ping(struct server *s, struct channel *c, char *m)
static int
send_ctcp_source(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-source <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-source <target>");

	sendf(s, c, "PRIVMSG %s :\001SOURCE\001", nick);
	sendf(s, c, "PRIVMSG %s :\001SOURCE\001", target);

	return 0;
}


@@ 267,12 267,12 @@ send_ctcp_source(struct server *s, struct channel *c, char *m)
static int
send_ctcp_time(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-time <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-time <target>");

	sendf(s, c, "PRIVMSG %s :\001TIME\001", nick);
	sendf(s, c, "PRIVMSG %s :\001TIME\001", target);

	return 0;
}


@@ 280,12 280,12 @@ send_ctcp_time(struct server *s, struct channel *c, char *m)
static int
send_ctcp_userinfo(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-userinfo <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-userinfo <target>");

	sendf(s, c, "PRIVMSG %s :\001USERINFO\001", nick);
	sendf(s, c, "PRIVMSG %s :\001USERINFO\001", target);

	return 0;
}


@@ 293,12 293,12 @@ send_ctcp_userinfo(struct server *s, struct channel *c, char *m)
static int
send_ctcp_version(struct server *s, struct channel *c, char *m)
{
	const char *nick;
	const char *target;

	if (!(nick = nick_or_priv(c, m)))
		failf(c, "Usage: /ctcp-version <nick>");
	if (!(target = irc_send_target(c, m)))
		failf(c, "Usage: /ctcp-version <target>");

	sendf(s, c, "PRIVMSG %s :\001VERSION\001", nick);
	sendf(s, c, "PRIVMSG %s :\001VERSION\001", target);

	return 0;
}

M src/state.c => src/state.c +2 -2
@@ 326,7 326,7 @@ state_channel_close(int action_confirm)

	if (action_confirm) {

		if (c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVATE)
		if (c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVMSG)
			action(action_close, "Close '%s'?   [y/n]", c->name);

		if (c->type == CHANNEL_T_SERVER)


@@ 336,7 336,7 @@ state_channel_close(int action_confirm)
		return;
	}

	if (c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVATE) {
	if (c->type == CHANNEL_T_CHANNEL || c->type == CHANNEL_T_PRIVMSG) {

		if (s->connected && c->type == CHANNEL_T_CHANNEL && !c->parted) {
			if ((ret = io_sendf(s->connection, "PART %s :%s", c->name, DEFAULT_PART_MESG)))

M test/components/server.c => test/components/server.c +2 -2
@@ 146,11 146,11 @@ test_server_set_chans(void)

	if (!(c = channel_list_get(&(s->clist), "b", s->casemapping)))
		test_abort("failed to find channel 'b'");
	assert_eq(c->type, CHANNEL_T_PRIVATE);
	assert_eq(c->type, CHANNEL_T_PRIVMSG);

	if (!(c = channel_list_get(&(s->clist), "c", s->casemapping)))
		test_abort("failed to find channel '#c'");
	assert_eq(c->type, CHANNEL_T_PRIVATE);
	assert_eq(c->type, CHANNEL_T_PRIVMSG);

	if (!(c = channel_list_get(&(s->clist), "#d", s->casemapping)))
		test_abort("failed to find channel 'd'");

M test/handlers/irc_ctcp.c => test/handlers/irc_ctcp.c +1 -1
@@ 484,7 484,7 @@ int
main(void)
{
	c_chan = channel("chan", CHANNEL_T_CHANNEL);
	c_priv = channel("nick", CHANNEL_T_PRIVATE);
	c_priv = channel("nick", CHANNEL_T_PRIVMSG);

	s = server("h1", "p1", NULL, "u1", "r1");


M test/handlers/irc_send.c => test/handlers/irc_send.c +18 -18
@@ 219,9 219,9 @@ test_send_ctcp_action(void)
	char m3[] = "ctcp-action target ";
	char m4[] = "ctcp-action target action message";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-action <nick> <text>", "");
	CHECK_SEND_COMMAND(c_chan, m2, 1, 1, 0, "Usage: /ctcp-action <nick> <text>", "");
	CHECK_SEND_COMMAND(c_chan, m3, 1, 1, 0, "Usage: /ctcp-action <nick> <text>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-action <target> <text>", "");
	CHECK_SEND_COMMAND(c_chan, m2, 1, 1, 0, "Usage: /ctcp-action <target> <text>", "");
	CHECK_SEND_COMMAND(c_chan, m3, 1, 1, 0, "Usage: /ctcp-action <target> <text>", "");
	CHECK_SEND_COMMAND(c_chan, m4, 0, 0, 1, "", "PRIVMSG target :\001ACTION action message\001");
}



@@ 233,8 233,8 @@ test_send_ctcp_clientinfo(void)
	char m3[] = "ctcp-clientinfo";
	char m4[] = "ctcp-clientinfo targ";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-clientinfo <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-clientinfo <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-clientinfo <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-clientinfo <target>", "");
	CHECK_SEND_COMMAND(c_priv, m3, 0, 0, 1, "", "PRIVMSG priv :\001CLIENTINFO\001");
	CHECK_SEND_COMMAND(c_priv, m4, 0, 0, 1, "", "PRIVMSG targ :\001CLIENTINFO\001");
}


@@ 247,8 247,8 @@ test_send_ctcp_finger(void)
	char m3[] = "ctcp-finger";
	char m4[] = "ctcp-finger targ";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-finger <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-finger <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-finger <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-finger <target>", "");
	CHECK_SEND_COMMAND(c_priv, m3, 0, 0, 1, "", "PRIVMSG priv :\001FINGER\001");
	CHECK_SEND_COMMAND(c_priv, m4, 0, 0, 1, "", "PRIVMSG targ :\001FINGER\001");
}


@@ 267,8 267,8 @@ test_send_ctcp_ping(void)
	const char *arg2;
	const char *arg3;

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-ping <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-ping <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-ping <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-ping <target>", "");

	/* test send to channel */
	errno = 0;


@@ 337,8 337,8 @@ test_send_ctcp_source(void)
	char m3[] = "ctcp-source";
	char m4[] = "ctcp-source targ";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-source <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-source <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-source <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-source <target>", "");
	CHECK_SEND_COMMAND(c_priv, m3, 0, 0, 1, "", "PRIVMSG priv :\001SOURCE\001");
	CHECK_SEND_COMMAND(c_priv, m4, 0, 0, 1, "", "PRIVMSG targ :\001SOURCE\001");
}


@@ 351,8 351,8 @@ test_send_ctcp_time(void)
	char m3[] = "ctcp-time";
	char m4[] = "ctcp-time targ";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-time <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-time <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-time <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-time <target>", "");
	CHECK_SEND_COMMAND(c_priv, m3, 0, 0, 1, "", "PRIVMSG priv :\001TIME\001");
	CHECK_SEND_COMMAND(c_priv, m4, 0, 0, 1, "", "PRIVMSG targ :\001TIME\001");
}


@@ 365,8 365,8 @@ test_send_ctcp_userinfo(void)
	char m3[] = "ctcp-userinfo";
	char m4[] = "ctcp-userinfo targ";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-userinfo <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-userinfo <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-userinfo <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-userinfo <target>", "");
	CHECK_SEND_COMMAND(c_priv, m3, 0, 0, 1, "", "PRIVMSG priv :\001USERINFO\001");
	CHECK_SEND_COMMAND(c_priv, m4, 0, 0, 1, "", "PRIVMSG targ :\001USERINFO\001");
}


@@ 379,8 379,8 @@ test_send_ctcp_version(void)
	char m3[] = "ctcp-version";
	char m4[] = "ctcp-version targ";

	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-version <nick>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-version <nick>", "");
	CHECK_SEND_COMMAND(c_chan, m1, 1, 1, 0, "Usage: /ctcp-version <target>", "");
	CHECK_SEND_COMMAND(c_serv, m2, 1, 1, 0, "Usage: /ctcp-version <target>", "");
	CHECK_SEND_COMMAND(c_priv, m3, 0, 0, 1, "", "PRIVMSG priv :\001VERSION\001");
	CHECK_SEND_COMMAND(c_priv, m4, 0, 0, 1, "", "PRIVMSG targ :\001VERSION\001");
}


@@ 409,7 409,7 @@ int
main(void)
{
	c_chan = channel("chan", CHANNEL_T_CHANNEL);
	c_priv = channel("priv", CHANNEL_T_PRIVATE);
	c_priv = channel("priv", CHANNEL_T_PRIVMSG);

	s = server("h1", "p1", NULL, "u1", "r1");