for(i = 0; data[i+5] != ']'; i++) { text[i] = data[i+5]; } text[i] = '\0'; send_pm("%s Guilds protected: %s", chat_name, print_list(&A_guild));
send_pm("%s Guilds protected: %s", chat_name, print_list(&A_guild, buffer));
void process_text_message(const char *msg, char *chat_name, int PM) {     char text[1024];    char *data = malloc(256);    int i=0;        if(PM==1)    {      // tolower' text      while(i < strlen(msg)) {          data[i] = tolower(msg[i]);          i++;      }      data[i] = '\0';      i = 0;            if(debug>=2)log_info("PM: %s\n", data);            // Commands are prefixed by $, admin commands have no prefix      // Help Commands:      if(data[0] == '$') {           data++;  //Skip '$'               if((!strncmp(data, "help", 4))) {                // Dump help info                sprintf(text, "%s%s%s%s", "Help - Commands:\n",                    "\"$Story\" -> List story channel, story, etc.\n",                    "\"$Recite\" -> Read a random story (in ch. 144).\n",                    "\"$Fortune\" -> Read a random quote.\n");                send_pm_enhanced(text, chat_name);                return;                     }          if((!strncmp(data, "admin_help", 10))) {               // Dump admin help info               if(get_string(&admin, chat_name, strlen(chat_name)) != -1) {                    sprintf(text, "%s%s%s%s%s%s%s%s%s%s", "Admin - Commands:\n",                         "\"!Echo <text>\" -> Send raw text <text>.\n",                         "\"!Send <name> <text>\" -> PM <text> to <name>.\n",                         "\"!Die -> Log off.\n",                         "\"!gadd <name> -> Protect the guild <name>.\n",                         "\"!gdel <name> -> Unprotect the guild <name>.\n",                         "\"!glst -> List protected guilds.\n",                         "\"!padd <name> -> Protect the player <name>.\n",                         "\"!pdel <name> -> Unprotect the player <name>.\n",                         "\"!plst -> List protected players.\n");               }               else strcpy(text, "R0fl, slave; U r not ~ admin!!`");               send_pm_enhanced(text, chat_name);               return;                    }                                     // Normal Commands :                if((!strncmp(data,"fortune", 7))) {               get_quote("fortune.dat", chat_name);               return;          }                if((!strncmp(data, "story", 5))) {               // Dump story info               strcpy(text, dump_story());     // A lot of the info is global, or                                                // shouldn't be...               send_pm_enhanced(text, chat_name);               return;          }          if((!strncmp(data, "recite", 6))) {               random_story();               return;          }      }                  // Admin Commands:      // (Players won't know if they actidentally activate them)      if(data[0] == '!') {          data++;      // Skip '!'            if(get_string(&admin, chat_name, strlen(chat_name)) != -1) {                                         if((!strncmp(data,"echo",4)) && data[4] != '\0' && data[5] != '\0' && data[6] != '\0') {                   strncpy(text, data+5, (strlen(data+4))-1);                   strcpy(text+(strlen(data+4)-2), "\0");                    send_raw_text(text);                   return;               }                     if((!strncmp(data,"send",4)) && data[4] != '\0' && data[5] != '\0' && data[6] != '\0') {                   strncpy(text, data+5, (strlen(data+4))-1);                   strcpy(text+(strlen(data+4)-2), "\0");                   send_pm(text);                   return;               }                                  if((!strncmp(data,"die",3))) {                             if (debug >= DEBUG_HIGH) log_info("The boss wants me to quit!\n");                   send_pm ("%s Yes sir, %s\0", chat_name, chat_name);                   send_raw_text ("%s\0", quit_message);                   save_list(&A_player, "players.lst");                   save_list(&A_guild, "guilds.lst");                   exit_connection (EXIT_ALL);                   exit (0);                   return;               }               if((!strncmp(data,"save",4))) {                             send_pm ("%s Yes sir, %s\0", chat_name, chat_name);                   save_list(&A_player, "players.lst");                   save_list(&A_guild, "guilds.lst");                   return;               }               if((!strncmp(data,"padd",4))) {                   for(i = 0; data[i+5] != ']'; i++) {                         text[i] = data[i+5];                   }                   text[i] = '\0';                   if(add_string(&A_player, text, strlen(text)) == 0)                   {                         send_pm("%s List is already full. Maybe you should remove some people?", chat_name);                   }                   return;               }               if((!strncmp(data,"pdel",4))) {                   for(i = 0; data[i+5] != ']'; i++) {                         text[i] = data[i+5];                   }                   text[i] = '\0';                   if(remove_string(&A_player, text, strlen(text)) == -1)                   {                         send_pm("%s Name could not be removed. Maybe you should check your spelling?", chat_name);                   }                   return;               }               if((!strncmp(data,"plst",4))) {                   for(i = 0; data[i+5] != ']'; i++) {                         text[i] = data[i+5];                   }                   text[i] = '\0';                   text[i] = '\0';                   send_pm("%s Players protected: %s", chat_name, print_list(&A_player));                   return;               }               if((!strncmp(data,"gadd",4))) {                   for(i = 0; data[i+5] != ']'; i++) {                         text[i] = data[i+5];                   }                   text[i] = '\0';                   if(add_string(&A_guild, text, strlen(text)) == 0)                   {                         send_pm("%s List is already full. Maybe you should remove some people?", chat_name);                   }                   return;               }               if((!strncmp(data,"gdel",4))) {                   for(i = 0; data[i+5] != ']'; i++) {                         text[i] = data[i+5];                   }                   text[i] = '\0';                   if(remove_string(&A_guild, text, strlen(text)) == -1)                   {                         send_pm("%s Name could not be removed. Maybe you should check your spelling?", chat_name);                   }                   return;               }               if((!strncmp(data,"glst",4))) {                   for(i = 0; data[i+5] != ']'; i++) {                         text[i] = data[i+5];                   }                   text[i] = '\0';                   send_pm("%s Guilds protected: %s", chat_name, print_list(&A_guild));                   return;               }           }                }                     // Don't understand:      send_pm("%s %s", chat_name, "Thanks, your message has been passed to guild chat. For more commands, use $help.");      // Pass it to #gm, after trimming it      for(i = 0; data[i] != ']'; i++) {            text[i] = data[i];      }      text[i] = '\0';      send_raw_text("#gm %s: %s", chat_name, text);    }    else    {        // Local Chat - TODO        data++;  // Skip color    }     free(data);       }