| 1 |
// For all support, instructions and copyright go to: |
| 2 |
// http://e2guardian.org/ |
| 3 |
// Released under the GPL v2, with the OpenSSL exception described in the README file. |
| 4 |
|
| 5 |
#ifndef __HPP_DYNAMICURLLIST |
| 6 |
#define __HPP_DYNAMICURLLIST |
| 7 |
|
| 8 |
// dynamic URL lists - used to cache known clean URLs so filtering can be bypassed |
| 9 |
class DynamicURLList |
| 10 |
{ |
| 11 |
public: |
| 12 |
DynamicURLList(); |
| 13 |
~DynamicURLList(); |
| 14 |
|
| 15 |
// set list size and timeout on entries (old entries aren't deleted, simply overwritten) |
| 16 |
bool setListSize(unsigned int s, unsigned int t); |
| 17 |
// flush the list (set all entries to old) |
| 18 |
void flush(); |
| 19 |
// is an entry in the list? |
| 20 |
bool inURLList(const char *url, const int fg); |
| 21 |
// add a URL - if it's already there but marked as too old, simply rejuvenate it |
| 22 |
void addEntry(const char *url, const int fg); |
| 23 |
|
| 24 |
private: |
| 25 |
// index list - points to URL list entries in alphabetical order |
| 26 |
unsigned int *index; |
| 27 |
// age list, sorted in the same order as index |
| 28 |
unsigned long int *urlreftime; |
| 29 |
// actual URL list |
| 30 |
char *urls; |
| 31 |
// group list - which group(s) is this URL clean for? |
| 32 |
std::string *groups; |
| 33 |
|
| 34 |
// size of list |
| 35 |
int size; |
| 36 |
// pointer to oldest entry (real entry, not sorted index) |
| 37 |
int agepos; |
| 38 |
unsigned int timeout; |
| 39 |
int items; |
| 40 |
|
| 41 |
// binary search for the pos of the given url in the sorted index |
| 42 |
// returns 0-(pos+1) on failure, where pos is where the entry would be inserted to retain sorting |
| 43 |
int search(int a, int s, const char *url); |
| 44 |
// find the index for the given url - makes use of the above search func |
| 45 |
int posInList(const char *url); |
| 46 |
}; |
| 47 |
|
| 48 |
#endif |