All pastes #107969 Raw Edit

freeone3000

public text v1 · immutable
#107969 ·published 2006-07-31 05:57 UTC
rendered paste body
void check_message_type(char *msg, int len)
{
        int type;
        if (getting_location_str && !strncmp(msg + 1, "You are in ", 11)) {
                get_location_str(msg + 1, len - 1);
                return;
        }
        if ((type = check_if_ignored(msg, len)) < 0)
                return;
        //AFK...
        if (afk) {
                if (type == SEND_PM) {
                        send_afk_message(msg + 1, type); //freeedit
                        add_message_to_pm_log(msg + 1, len - 1);
                } else if (is_talking_about_me(msg + 1, len - 1))
                        send_afk_message(msg + 1, type);
        }
        char channum = *msg;
        char *chanstr = malloc(sizeof(char)*8); //TODO Three overhead + five digits. THIS SHOULD BE BIGGER NOOB.
        sprintf(channum, " @ %d", (int)channum);
        char *part1 = malloc(sizeof(char)*50); //TODO restrict the size of these and the next two.
        char *part2 = malloc(sizeof(char)*120);
        part2 = strchr(msg, ']');
        if(part2!=NULL) {
                strncpy(part1, msg, strlen(msg)-strlen(part2));
                strcat(part1, chanstr);
                strcat(part1, part2);
                add_to_buffer(part1, strlen(part1), type, 1);
                //Should clean up chanstr, part1, and part2 here.
        } else {
                add_to_buffer(msg+1, len, type, 1); //To remove the whole junk thinger.
        }
}