changeset 10208:cbdce0acbbe6

[gaim-migrate @ 11330] This implements irc_ischannel for HEAD, and fixes /names committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Fri, 19 Nov 2004 16:42:07 +0000
parents 9d03dd6ccc9a
children 9e0b98c458b1
files src/protocols/irc/cmds.c src/protocols/irc/irc.h src/protocols/irc/parse.c
diffstat 3 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/irc/cmds.c	Fri Nov 19 06:24:50 2004 +0000
+++ b/src/protocols/irc/cmds.c	Fri Nov 19 16:42:07 2004 +0000
@@ -197,7 +197,7 @@
 		return 0;
 
 	if (!strcmp(cmd, "mode")) {
-		if (!args[0] && (*target == '#' || *target == '&'))
+		if (!args[0] && irc_ischannel(target))
 			buf = irc_format(irc, "vc", "MODE", target);
 		else if (args[0] && (*args[0] == '+' || *args[0] == '-'))
 			buf = irc_format(irc, "vcv", "MODE", target, args[0]);
@@ -224,7 +224,7 @@
 {
 	char *buf;
 
-	if (!args)
+	if (!args || (!args[0] && !irc_ischannel(target)))
 		return 0;
 
 	buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target);
@@ -317,7 +317,7 @@
 	char *buf;
 
 	if (args && args[0]) {
-		if (*args[0] == '#' || *args[0] == '&')
+		if (irc_ischannel(args[0]))
 			return 0;
 		stamp = g_strdup_printf("\001PING %lu\001", time(NULL));
 		buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp);
@@ -414,7 +414,7 @@
 	if (!args || !args[0])
 		return 0;
 
-	if (*target != '#' && *target != '&') /* not a channel, punt */
+	if (!irc_ischannel(target)) /* not a channel, punt */
 		return 0;
 
 	if (args[1])
--- a/src/protocols/irc/irc.h	Fri Nov 19 06:24:50 2004 +0000
+++ b/src/protocols/irc/irc.h	Fri Nov 19 16:42:07 2004 +0000
@@ -87,6 +87,8 @@
 char *irc_mirc2html(const char *string);
 char *irc_mirc2txt(const char *string);
 
+gboolean irc_ischannel(const char *string);
+
 void irc_register_commands(void);
 void irc_msg_table_build(struct irc_conn *irc);
 void irc_parse_msg(struct irc_conn *irc, char *input);
--- a/src/protocols/irc/parse.c	Fri Nov 19 06:24:50 2004 +0000
+++ b/src/protocols/irc/parse.c	Fri Nov 19 16:42:07 2004 +0000
@@ -366,6 +366,11 @@
         return result;
 }
 
+gboolean irc_ischannel(const char *string)
+{
+	return (string[0] == '#' || string[0] == '&');
+}
+
 char *irc_parse_ctcp(struct irc_conn *irc, const char *from, const char *to, const char *msg, int notice)
 {
 	GaimConnection *gc;