IRC: fill required command parameter counts (part 3) release-2.x.y
authorTomasz Wasilczyk <twasilczyk@pidgin.im>
Thu, 16 Jan 2014 12:11:19 +0100
branchrelease-2.x.y
changeset6b0e0566af20 pushlog
parent 5845d9fa7084
child 07e827917960
IRC: fill required command parameter counts (part 3)
libpurple/protocols/irc/msgs.c
libpurple/protocols/irc/parse.c
     1.1 --- a/libpurple/protocols/irc/msgs.c
     1.2 +++ b/libpurple/protocols/irc/msgs.c
     1.3 @@ -203,9 +203,6 @@
     1.4  	gchar **features;
     1.5  	int i;
     1.6  
     1.7 -	if (!args || !args[0] || !args[1])
     1.8 -		return;
     1.9 -
    1.10  	features = g_strsplit(args[1], " ", -1);
    1.11  	for (i = 0; features[i]; i++) {
    1.12  		char *val;
    1.13 @@ -220,9 +217,6 @@
    1.14  
    1.15  void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args)
    1.16  {
    1.17 -	if (!args || !args[0])
    1.18 -		return;
    1.19 -
    1.20  	if (!strcmp(name, "251")) {
    1.21  		/* 251 is required, so we pluck our nick from here and
    1.22  		 * finalize connection */
    1.23 @@ -238,9 +232,6 @@
    1.24  	PurpleConnection *gc;
    1.25  	char *msg;
    1.26  
    1.27 -	if (!args || !args[1])
    1.28 -		return;
    1.29 -
    1.30  	if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
    1.31  		/* We're doing a whois, show this in the whois dialog */
    1.32  		irc_msg_whois(irc, name, from, args);
    1.33 @@ -266,17 +257,13 @@
    1.34  {
    1.35  	PurpleConversation *convo;
    1.36  
    1.37 -	if (!args || !args[0] || !args[1])
    1.38 -		return;
    1.39 -
    1.40  	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
    1.41  						      args[1], irc->account);
    1.42  
    1.43  	if (!strcmp(name, "367")) {
    1.44  		char *msg = NULL;
    1.45  		/* Ban list entry */
    1.46 -		if (!args[2])
    1.47 -			return;
    1.48 +		g_return_if_fail(args[2]);
    1.49  		if (args[3] && args[4]) {
    1.50  			/* This is an extended syntax, not in RFC 1459 */
    1.51  			int t1 = atoi(args[4]);
    1.52 @@ -340,9 +327,6 @@
    1.53  	PurpleConversation *convo;
    1.54  	char *buf, *escaped;
    1.55  
    1.56 -	if (!args || !args[1] || !args[2])
    1.57 -		return;
    1.58 -
    1.59  	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
    1.60  	if (!convo)	/* XXX punt on channels we are not in for now */
    1.61  		return;
    1.62 @@ -480,13 +464,6 @@
    1.63  		PurpleConvChatBuddyFlags flags;
    1.64  		GList *keys = NULL, *values = NULL;
    1.65  
    1.66 -		if (!args || !args[0] || !args[1] || !args[2] || !args[3]
    1.67 -		    || !args[4] || !args[5] || !args[6] || !args[7]) {
    1.68 -			purple_debug(PURPLE_DEBUG_ERROR, "irc",
    1.69 -				     "Got a WHO response with not enough arguments\n");
    1.70 -			return;
    1.71 -		}
    1.72 -
    1.73  		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
    1.74  		if (!conv) {
    1.75  			purple_debug(PURPLE_DEBUG_ERROR, "irc","Got a WHO response for %s, which doesn't exist\n", args[1]);
    1.76 @@ -562,9 +539,6 @@
    1.77  		PurpleRoomlistRoom *room;
    1.78  		char *topic;
    1.79  
    1.80 -		if (!args[0] || !args[1] || !args[2] || !args[3])
    1.81 -			return;
    1.82 -
    1.83  		if (!purple_roomlist_get_in_progress(irc->roomlist)) {
    1.84  			purple_debug_warning("irc", "Buggy server didn't send RPL_LISTSTART.\n");
    1.85  			purple_roomlist_set_in_progress(irc->roomlist, TRUE);
    1.86 @@ -643,9 +617,6 @@
    1.87  	struct tm *tm;
    1.88  	time_t t;
    1.89  	char *msg, *timestamp, *datestamp;
    1.90 -	
    1.91 -	if (!args || !args[1] || !args[2] || !args[3])
    1.92 -		return;
    1.93  
    1.94  	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
    1.95  	if (!convo) {
    1.96 @@ -910,9 +881,6 @@
    1.97  	struct irc_buddy *ib;
    1.98  	int i;
    1.99  
   1.100 -	if (!args || !args[1])
   1.101 -		return;
   1.102 -
   1.103  	nicks = g_strsplit(args[1], " ", -1);
   1.104  	for (i = 0; nicks[i]; i++) {
   1.105  		if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) {
     2.1 --- a/libpurple/protocols/irc/parse.c
     2.2 +++ b/libpurple/protocols/irc/parse.c
     2.3 @@ -50,36 +50,38 @@
     2.4  static struct _irc_msg {
     2.5  	char *name;
     2.6  	char *format;
     2.7 -	int req_cnt;
     2.8 +	/* The required parameters count, based on values we use, not protocol
     2.9 +	 * specification. */
    2.10 +	int req_cnt; 
    2.11  	void (*cb)(struct irc_conn *irc, const char *name, const char *from, char **args);
    2.12  } _irc_msgs[] = {
    2.13 -	{ "005", "n*", -1, irc_msg_features },		/* Feature list			*/
    2.14 -	{ "251", "n:", -1, irc_msg_luser },		/* Client & Server count	*/
    2.15 -	{ "255", "n:", -1, irc_msg_luser },		/* Client & Server count Mk. II	*/
    2.16 -	{ "301", "nn:", -1, irc_msg_away },		/* User is away			*/
    2.17 -	{ "303", "n:", -1, irc_msg_ison },		/* ISON reply			*/
    2.18 -	{ "311", "nnvvv:", -1, irc_msg_whois },		/* Whois user			*/
    2.19 -	{ "312", "nnv:", -1, irc_msg_whois },		/* Whois server			*/
    2.20 -	{ "313", "nn:", -1, irc_msg_whois },		/* Whois ircop			*/
    2.21 -	{ "317", "nnvv", -1, irc_msg_whois },		/* Whois idle			*/
    2.22 -	{ "318", "nt:", -1, irc_msg_endwhois },		/* End of WHOIS			*/
    2.23 -	{ "319", "nn:", -1, irc_msg_whois },		/* Whois channels		*/
    2.24 -	{ "320", "nn:", -1, irc_msg_whois },		/* Whois (fn ident)		*/
    2.25 -	{ "314", "nnnvv:", -1, irc_msg_whois },		/* Whowas user			*/
    2.26 -	{ "315", "nt:", -1, irc_msg_who },		/* end of WHO channel		*/
    2.27 -	{ "369", "nt:", -1, irc_msg_endwhois },		/* End of WHOWAS		*/
    2.28 -	{ "321", "*", -1, irc_msg_list },		/* Start of list		*/
    2.29 -	{ "322", "ncv:", -1, irc_msg_list },		/* List.			*/
    2.30 -	{ "323", ":", -1, irc_msg_list },		/* End of list.			*/
    2.31 -	{ "324", "ncv:", -1, irc_msg_chanmode },	/* Channel modes		*/
    2.32 +	{ "005", "n*", 2, irc_msg_features },		/* Feature list			*/
    2.33 +	{ "251", "n:", 1, irc_msg_luser },		/* Client & Server count	*/
    2.34 +	{ "255", "n:", 1, irc_msg_luser },		/* Client & Server count Mk. II	*/
    2.35 +	{ "301", "nn:", 3, irc_msg_away },		/* User is away			*/
    2.36 +	{ "303", "n:", 2, irc_msg_ison },		/* ISON reply			*/
    2.37 +	{ "311", "nnvvv:", 6, irc_msg_whois },		/* Whois user			*/
    2.38 +	{ "312", "nnv:", 4, irc_msg_whois },		/* Whois server			*/
    2.39 +	{ "313", "nn:", 2, irc_msg_whois },		/* Whois ircop			*/
    2.40 +	{ "317", "nnvv", 4, irc_msg_whois },		/* Whois idle			*/
    2.41 +	{ "318", "nt:", 2, irc_msg_endwhois },		/* End of WHOIS			*/
    2.42 +	{ "319", "nn:", 3, irc_msg_whois },		/* Whois channels		*/
    2.43 +	{ "320", "nn:", 2, irc_msg_whois },		/* Whois (fn ident)		*/
    2.44 +	{ "314", "nnnvv:", 6, irc_msg_whois },		/* Whowas user			*/
    2.45 +	{ "315", "nt:", 0, irc_msg_who },		/* end of WHO channel		*/
    2.46 +	{ "369", "nt:", 2, irc_msg_endwhois },		/* End of WHOWAS		*/
    2.47 +	{ "321", "*", 0, irc_msg_list },		/* Start of list		*/
    2.48 +	{ "322", "ncv:", 4, irc_msg_list },		/* List.			*/
    2.49 +	{ "323", ":", 0, irc_msg_list },		/* End of list.			*/
    2.50 +	{ "324", "ncv:", 3, irc_msg_chanmode },		/* Channel modes		*/
    2.51  	{ "331", "nc:", 3, irc_msg_topic },		/* No channel topic		*/
    2.52  	{ "332", "nc:", 3, irc_msg_topic },		/* Channel topic		*/
    2.53 -	{ "333", "ncvv", -1, irc_msg_topicinfo },	/* Topic setter stuff		*/
    2.54 -	{ "352", "ncvvvnv:", -1, irc_msg_who },		/* Channel WHO			*/
    2.55 -	{ "353", "nvc:", -1, irc_msg_names },		/* Names list			*/
    2.56 -	{ "366", "nc:", -1, irc_msg_names },		/* End of names			*/
    2.57 -	{ "367", "ncnnv", -1, irc_msg_ban },		/* Ban list			*/
    2.58 -	{ "368", "nc:", -1, irc_msg_ban },		/* End of ban list		*/
    2.59 +	{ "333", "ncvv", 4, irc_msg_topicinfo },	/* Topic setter stuff		*/
    2.60 +	{ "352", "ncvvvnv:", 8, irc_msg_who },		/* Channel WHO			*/
    2.61 +	{ "353", "nvc:", 4, irc_msg_names },		/* Names list			*/
    2.62 +	{ "366", "nc:", 2, irc_msg_names },		/* End of names			*/
    2.63 +	{ "367", "ncnnv", 3, irc_msg_ban },		/* Ban list			*/
    2.64 +	{ "368", "nc:", 2, irc_msg_ban },		/* End of ban list		*/
    2.65  	{ "372", "n:", 1, irc_msg_motd },		/* MOTD				*/
    2.66  	{ "375", "n:", 1, irc_msg_motd },		/* Start MOTD			*/
    2.67  	{ "376", "n:", 1, irc_msg_motd },		/* End of MOTD			*/