Example #1
0
TFingerprint *FingerprintRead(STREAM *S)
{
char *Tempstr=NULL;
TFingerprint *FP;

Tempstr=STREAMReadLine(Tempstr,S);
if (! Tempstr) return(NULL);

FP=TFingerprintParse(Tempstr);

DestroyString(Tempstr);
return(FP);
}
Example #2
0
void *MatchesLoad(int Flags)
{
char *Line=NULL, *Tempstr=NULL, *Type=NULL, *ptr;
TFingerprint *FP;
STREAM *S;
int count=0;


S=STREAMFromFD(0);
STREAMSetTimeout(S,100);
Line=STREAMReadLine(Line,S);
if (! StrValid(Line)) return(NULL);

if (strncasecmp(Line,"<?xml ",6)==0) 
{
	//xml document. Must be an OpenIOC fileq
	while (Line)
	{
	StripTrailingWhitespace(Line);
	Tempstr=CatStr(Tempstr,Line);
	Line=STREAMReadLine(Line,S);
	}
	count=LoadFromIOC(Tempstr,Flags);
}
else
{
	while (Line)
	{
	StripTrailingWhitespace(Line);
	FP=TFingerprintParse(Line);
	if (MatchAdd(FP, "", Flags)) count++;
	Line=STREAMReadLine(Line, S);
	}
}

if (Flags & FLAG_MEMCACHED) printf("Stored %d hashes in memcached server\n", count);

DestroyString(Tempstr);
DestroyString(Line);
DestroyString(Type);

return(Tree);
}