All pastes #17532 Raw Edit

Anonymous

public text v1 · immutable
#17532 ·published 2005-07-12 11:02 UTC
rendered paste body
/* checks if the test_string is contained on the content field */
int IsOnContent(char* header, int size, char* test_string) {
	int pos; 
	char* cstart = NULL;
	char* eoc = NULL;
	char* js = NULL;
	if (	(pos = get_content_field_pos(header,size)) != -1) {
		cstart = header + pos;
		eoc = strchr(cstart,0x0d); // CR
		*eoc = '\0'; // NULL-terminated string to allow strcasestr on content field only
		js = strcasestr(cstart, test_string); // According to RFC 2616, this is case-insensitive
		*eoc = 0x0d; // Restore original header
		if (js!=NULL) {
			// Found
			return TRUE;
		} else {
			return FALSE;
		}
	}
}