src/irc.c
changeset 37 85891f91096c
parent 34 900bc2a53fd7
child 41 7260f61566b5
equal deleted inserted replaced
36:6889aacd038e 37:85891f91096c
    19 
    19 
    20 #include <compat.h>
    20 #include <compat.h>
    21 #include <irc.h>
    21 #include <irc.h>
    22 #include "common.h"
    22 #include "common.h"
    23 
    23 
    24 enum {
    24 enum command_map {
    25     NOTICE, MODE, JOIN, PART, TOPIC, PING, ENOMEM, ERROR, VERSION, PRIVMSG, QUIT, NICK, KICK
    25     NOTICE, MODE, JOIN, PART, TOPIC, PING, ENOMEM, ERROR, VERSION, PRIVMSG, QUIT, NICK, KICK
    26 };
    26 };
    27 
    27 
    28 #define VERSION_STRING "MCBOT on GNU/LINUX"
    28 #define VERSION_STRING "MCBOT on GNU/LINUX"
    29 
    29 
   187  * Main prints ("%10s %s %s\n", MSG->command MSG->channel MSG->line).
   187  * Main prints ("%10s %s %s\n", MSG->command MSG->channel MSG->line).
   188  * This functions makes sure, that there will be someting to print...
   188  * This functions makes sure, that there will be someting to print...
   189  */
   189  */
   190 char *irc_parsemessage (const char *line, MSG * message)
   190 char *irc_parsemessage (const char *line, MSG * message)
   191 {
   191 {
   192     int i;
   192     enum command_map map;
   193     char *command;
   193     char *command;
   194     char *ptr;
   194     char *ptr;
   195     int value;
   195     int value;
   196 
   196 
   197     i = 0;
   197     map = 0;
   198     if ((command = irc_getmessage (line, message)) != NULL) {
   198     if ((command = irc_getmessage (line, message)) != NULL) {
   199         while (IRC_Commands[i] != NULL) {
   199         while (IRC_Commands[map] != NULL) {
   200             if (strcmp (IRC_Commands[i], command) == 0) {
   200             if (strcmp (IRC_Commands[map], command) == 0) {
   201                 switch (i) {
   201                 switch (map) {
   202                 case NOTICE:
   202                 case NOTICE:
   203                     if (message->line == NULL) {
   203                     if (message->line == NULL) {
   204                         message->channel = "*";
   204                         message->channel = "*";
   205                         message->line = "*";
   205                         message->line = "*";
   206                     } else {
   206                     } else {
   268                 case KICK:
   268                 case KICK:
   269                     message->channel = message->user;
   269                     message->channel = message->user;
   270                     return command;
   270                     return command;
   271                 }
   271                 }
   272             }
   272             }
   273             i++;
   273             map++;
   274         }
   274         }
   275 
   275 
   276         if ((value = atoi (command)) != 0) {
   276         if ((value = atoi (command)) != 0) {
   277             switch (value) {
   277             switch (value) {
   278             case 1:            /* CONNECTION INFOS */
   278             case 1:            /* CONNECTION INFOS */