enumerated types for parse.c
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Sat, 30 May 2009 21:56:21 +0200
changeset 38 c2f62d1b8d76
parent 37 85891f91096c
child 39 0ae006af497e
enumerated types for parse.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/parse.c
--- a/src/parse.c
+++ b/src/parse.c
@@ -24,7 +24,7 @@
 #define SOURCE_URL "http://largo.homelinux.org/cgi-bin/gitweb.cgi?p=net/mcbot.git"
 #endif
 
-enum {
+enum command_map {
     HELP, JOIN, LEAVE, ADD, REPLACE, DELETE, LIST, SEARCH, INFO, PING, ON, OFF, DEBUG,
     VACCUUM, LOGOUT, WHO, WHOIS, TIME, TELL, OP, DEOP, KICK, BAN, UNBAN, KICKBAN, HELLO
 };
@@ -70,7 +70,7 @@
 {
     static char msg[DEFAULT_BUF_SIZE];
     int cmd = -1;
-    int i;
+    enum command_map map;
     char *token;
     char *parameters;
 
@@ -95,11 +95,11 @@
         return NULL;
     }
 
-    i = 0;
+    map = 0;
     token = strtok (message->line, " ");
-    while (Bot_Commands[i]) {
-        if (!strcmp (token, Bot_Commands[i])) {
-            switch (i) {
+    while (Bot_Commands[map]) {
+        if (!strcmp (token, Bot_Commands[map])) {
+            switch (map) {
             case HELP:
                 if ((token = strtok (NULL, "\r\n")))
                     cmd = atoi (token);
@@ -313,7 +313,7 @@
                 return msg;
             }
         }
-        i++;
+        map++;
     }
 
     return NULL;