Exemplo n.º 1
0
struct Matcher * new_matcher(const char* signature_directory){
	int j,i;
	/* Read in the signatures of the signature directory */
	int numOf_SignatureClasses = 0;
	struct BayesSignature ** signatures = read_signature_files(signature_directory, &numOf_SignatureClasses);
	/* Initialize the matcher with those read-in signatures */
	struct Matcher * matcher;
	matcher = malloc(sizeof(struct Matcher));

	/* Add to matcher->signatures */
	matcher->signatures = signatures;

	/*  Add to matcher->ktree */
	matcher->ktree = new_KTree();

	for (j = 0; j < numOf_SignatureClasses; ++j){
		for (i = 0; i < matcher->signatures[j]->numOfTokens; ++i){
			//printf("j = %i, Token = \"%s\"\n", j, matcher->signatures[j]->tokens[i]->tokenstring);
			add_keyword(matcher->ktree, matcher->signatures[j]->tokens[i]->tokenstring, matcher->signatures[j]->tokens[i]->tokenlength);
		}
	}

	/* Finally set the integer values */
	matcher->numOfClasses = numOf_SignatureClasses;

	/* Now initialize the matcher->mapper with the subsumed informations from above */
	matcher->mapper = new_mapper(matcher);

	return matcher;
}
Exemplo n.º 2
0
void Extract(){
  int   d = 0 , FileCount = 0, BufLen = 0;
  char* alg_id;
  FILE  *fin;

  fin = fopen(ArchiveName, "rb");
  alg_id = malloc(sizeof(char) * 5);

  time_t t = time(NULL);
  struct tm* ctme = localtime(&t);
  printf("%02d:%02d:%02d extracting...\n", ctme->tm_hour, ctme->tm_min, ctme->tm_sec);

  alg_id = read_signature_files(fin, &FileCount, &BufLen, &d);
  extract(alg_id, d, fin, FileCount, BufLen);

  t = time(NULL);
  ctme = localtime(&t);
  printf("%02d:%02d:%02d complete\n", ctme->tm_hour, ctme->tm_min, ctme->tm_sec);
}