All pastes #17531 Raw Edit

Anonymous

public text v1 · immutable
#17531 ·published 2005-07-12 10:57 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 = FALSE; // I know, evil trick.
	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 strstr on content field only
		js = strcasestr(cstart, test_string); // According to RFC 2616, this is case-insensitive
		if (js!=NULL) {
			// Found
			pos = TRUE; // Reusing vars anyone?
		}
		*eoc = 0x0d; // Restore original header
	}
	return pos;
}