00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _DOMAINS_H_
00030 #define _DOMAINS_H_
00031
00032 #include "../../str.h"
00033
00034 #define MAX_HSIZE_TWO_POW 20
00035 #define MAX_HASH_SIZE 1<<MAX_HSIZE_TWO_POW
00036
00037 #define PDT_ADD 1
00038 #define PDT_DELETE 2
00039
00040 #define get_hash_entry(c,s) (c)&((s)-1)
00041
00042 typedef struct _pd
00043 {
00044 str prefix;
00045 str domain;
00046 int flag;
00047 unsigned int dhash;
00048 struct _pd *p;
00049 struct _pd *n;
00050 } pd_t;
00051
00052 typedef struct _pd_entry
00053 {
00054 gen_lock_t lock;
00055 pd_t *e;
00056 } pd_entry_t;
00057
00058 typedef struct _pd_op
00059 {
00060 pd_t *cell;
00061 int op;
00062 int id;
00063 int count;
00064 struct _pd_op *p;
00065 struct _pd_op *n;
00066 } pd_op_t;
00067
00068 typedef struct _pdt_hash
00069 {
00070 pd_entry_t* dhash;
00071 unsigned int hash_size;
00072
00073 pd_op_t *diff;
00074 gen_lock_t diff_lock;
00075 int max_id;
00076 int workers;
00077 } pdt_hash_t;
00078
00079 pd_t* new_cell(str* p, str *d);
00080 void free_cell(pd_t *cell);
00081
00082 pd_op_t* new_pd_op(pd_t *cell, int id, int op);
00083 void free_pd_op(pd_op_t *pdo);
00084
00085 int pdt_add_to_hash(pdt_hash_t *ph, str *sp, str *sd);
00086 int pdt_remove_from_hash(pdt_hash_t *ph, str *sd);
00087
00088 str* pdt_get_prefix(pdt_hash_t *ph, str* sd);
00089 int pdt_check_pd(pdt_hash_t *ph, str *sp, str *sd);
00090
00091 void pdt_print_hash(pdt_hash_t *ph);
00092
00093 pdt_hash_t* pdt_init_hash(int hash_size);
00094 void pdt_free_hash(pdt_hash_t* ph);
00095
00096 unsigned int pdt_compute_hash(char *s);
00097
00098 #endif