00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifdef HAVE_CONFIG_H
00014 #include "config.h"
00015 #endif
00016
00017 #include "WordList.h"
00018 #include "WordDBCache.h"
00019
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <ctype.h>
00023 #include <errno.h>
00024
00025 static int word_db_qcmp(WordContext* context, const WordDBCacheEntry *a, const WordDBCacheEntry *b)
00026 {
00027 return WordKey::Compare(context, (const unsigned char*)a->key, a->key_size, (const unsigned char*)b->key, b->key_size);
00028 }
00029
00030
00031 void
00032 WordList::BatchStart()
00033 {
00034 if(caches) BatchEnd();
00035
00036 Configuration& config = context->GetConfiguration();
00037 int cache_size = config.Value("wordlist_cache_size", 0);
00038 if(cache_size < 1 * 1024 * 1024) cache_size = 1 * 1024 * 1024;
00039 int cache_max = config.Value("wordlist_cache_max", 0);
00040
00041 caches = new WordDBCaches(this, 50, cache_size, cache_max);
00042 caches->CacheCompare(word_db_qcmp);
00043 }
00044
00045
00046 void
00047 WordList::BatchEnd()
00048 {
00049 if(caches) {
00050 delete caches;
00051 caches = 0;
00052 }
00053 }