All pastes #166461 Raw Edit

freeone3000

public c v1 · immutable
·published 2006-09-10 22:51 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);	}	int in_channel = 0;	char channum = *msg; //TODO do lookups.	char *chanstr = malloc(sizeof(char)*13);	if(channum>=5 && channum <= 7) {		sprintf(chanstr, " @ %d", cur_chans[channum-5]);		in_channel = 1;	}	if(in_channel) {		channum -= 5;		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);#ifdef ELC_CHAT_DEBUG			char *c = malloc(sizeof(char)*50);			sprintf(c, "Color on %d is %d, which %s the current channel", channum, part1[0], (channum==cur_chan)?"is":"isn't");			add_to_text_log(c);			//free c#endif			add_to_buffer(part1+1, strlen(part1), type, part1[0]);			//Should clean up chanstr, part1, and part2 here.		} else {			add_to_buffer(msg+1, len, type, msg[0]);		}	} else {		add_to_buffer(msg+1, len, type, msg[0]); //To remove the whole junk thinger.	}}