enumerated types for irc.c
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Thu, 28 May 2009 14:08:48 +0200
changeset 37 85891f91096c
parent 36 6889aacd038e
child 38 c2f62d1b8d76
enumerated types for irc.c The irc section gets an enumerated type for constant values. This makes the code more readable and less error prone. committer: Markus Bröker <mbroeker@largo.homelinux.org>
src/irc.c
--- a/src/irc.c
+++ b/src/irc.c
@@ -21,7 +21,7 @@
 #include <irc.h>
 #include "common.h"
 
-enum {
+enum command_map {
     NOTICE, MODE, JOIN, PART, TOPIC, PING, ENOMEM, ERROR, VERSION, PRIVMSG, QUIT, NICK, KICK
 };
 
@@ -189,16 +189,16 @@
  */
 char *irc_parsemessage (const char *line, MSG * message)
 {
-    int i;
+    enum command_map map;
     char *command;
     char *ptr;
     int value;
 
-    i = 0;
+    map = 0;
     if ((command = irc_getmessage (line, message)) != NULL) {
-        while (IRC_Commands[i] != NULL) {
-            if (strcmp (IRC_Commands[i], command) == 0) {
-                switch (i) {
+        while (IRC_Commands[map] != NULL) {
+            if (strcmp (IRC_Commands[map], command) == 0) {
+                switch (map) {
                 case NOTICE:
                     if (message->line == NULL) {
                         message->channel = "*";
@@ -270,7 +270,7 @@
                     return command;
                 }
             }
-            i++;
+            map++;
         }
 
         if ((value = atoi (command)) != 0) {