debug("Unparseable IP");
errorf("Bad IPv4 pattern \"%s\" in %s, l.%d", pattern, fname, lineNo);
Rules* parseRulesFromFile(char* fname) {	FILE* f;	char buf[MAX_LINE_LEN];	char* p;	Rules* rules = (Rules*)malloc(sizeof(Rules));	rules->count = 0;	Rule* currentRule = mallocRule();	RuleField* ruleField = mallocRuleField();	f = fopen(fname, "r");	assert(f);	while (fgets(buf, sizeof(buf), f)) {		if (strlen(buf) < 3) continue;		if (*buf == '#') continue;		p = buf;		char* col1 = get_next_token(&p, " \t\n");		char* modifier = get_next_token(&p, " \t\n");		char* field = get_next_token(&p, " \t\n");		get_next_token(&p, " \t\n");		char* pattern = get_next_token(&p, " \t\n");		if (!col1) {			debug("Unparseable line");						continue;			}		if (*col1 != 0) {			/* Start of new Rule */			if (currentRule->fieldCount > 0) {				rules->rule[rules->count++] = currentRule;				currentRule = mallocRule();				}			continue;			}		if (!field) {			debug("Incomplete line");			continue;			}					if (parseModifier(modifier, &ruleField->modifier) != 0) {			debug("Bad modifier");			continue;			}		if ((ruleField->type.id = string2typeid(field)) == 0) {			debug("Bad type");			continue;			}					if ((ruleField->type.length = string2typelength(field)) == 0) {			debug("Bad type");			continue;			}				ruleField->pattern = NULL;		if (pattern) switch (ruleField->type.id) {			case IPFIX_TYPEID_protocolIdentifier:				if (parseProtoPattern(pattern, &ruleField->pattern, &ruleField->type.length) != 0) {					debug("Unparseable Protocol");					continue;					}					break;			case IPFIX_TYPEID_sourceIPv4Address:			case IPFIX_TYPEID_destinationIPv4Address:				if (parseIPv4Pattern(pattern, &ruleField->pattern, &ruleField->type.length) != 0) {					debug("Unparseable IP");					continue;					}					break;							case IPFIX_TYPEID_sourceTransportPort:			case IPFIX_TYPEID_destinationtransportPort:				if (parsePortPattern(pattern, &ruleField->pattern, &ruleField->type.length) != 0) {					debug("Unparseable Port(s)");					continue;					}					break;			default:				debug("This field type cannot be matched against a pattern");				continue;				break;							}		currentRule->field[currentRule->fieldCount++] = ruleField;		ruleField = mallocRuleField();		}	if (currentRule->fieldCount > 0) {		rules->rule[rules->count++] = currentRule;		currentRule = mallocRule();		}	fclose(f);	/* tidy up */	destroyRuleField(ruleField);	destroyRule(currentRule);		return rules;	}