source: npl/mailserver/dspam/dspam-3.10.2/src/hash_drv.h @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/* $Id: hash_drv.h,v 1.19 2011/06/28 00:13:48 sbajic Exp $ */
2
3/*
4 DSPAM
5 COPYRIGHT (C) 2002-2012 DSPAM PROJECT
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Affero General Public License as
9 published by the Free Software Foundation, either version 3 of the
10 License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Affero General Public License for more details.
16
17 You should have received a copy of the GNU Affero General Public License
18 along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20*/
21
22#ifndef _HASH_DRV_H
23#  define _HASH_DRV_H
24
25#ifdef HAVE_CONFIG_H
26#include <auto-config.h>
27#endif
28
29#include "config.h"
30#include "nodetree.h"
31#include "libdspam.h"
32
33#define HASH_REC_MAX    98317
34#define HASH_EXTENT_MAX 49157
35#define HASH_SEEK_MAX   100
36
37typedef struct _hash_drv_header
38{
39  unsigned long hash_rec_max;
40  struct _ds_spam_totals totals;
41  char padding[4]; /* Keep 8-byte alignment */
42} *hash_drv_header_t;
43
44typedef struct _hash_drv_map
45{
46  void *addr;
47  int fd;
48  size_t file_len;
49  hash_drv_header_t header;
50  char filename[MAX_FILENAME_LENGTH];
51  unsigned long max_seek;
52  unsigned long max_extents;
53  unsigned long extent_size;
54  int pctincrease;
55  int flags;
56} *hash_drv_map_t;
57
58struct _hash_drv_storage
59{
60  hash_drv_map_t map;
61  FILE *lock;
62  int dbh_attached;
63
64  unsigned long offset_nexttoken;
65  hash_drv_header_t offset_header;
66  unsigned long hash_rec_max;
67  unsigned long max_seek;
68  unsigned long max_extents;
69  unsigned long extent_size;
70  int pctincrease;
71  int flags;
72
73  struct nt *dir_handles;
74} *hash_drv_storage_t;
75
76typedef struct _hash_drv_spam_record
77{
78  unsigned long long hashcode;
79  unsigned long nonspam;
80  unsigned long spam;
81} *hash_drv_spam_record_t;
82
83int _hash_drv_get_spamtotals
84  (DSPAM_CTX * CTX);
85
86int _hash_drv_set_spamtotals
87  (DSPAM_CTX * CTX);
88
89int _hash_drv_lock_get (
90  DSPAM_CTX *CTX,
91  struct _hash_drv_storage *s,
92  const char *username);
93
94int _hash_drv_lock_free (
95  struct _hash_drv_storage *s,
96  const char *username);
97
98/* lock variant used by css tools */
99FILE* _hash_tools_lock_get (const char *cssfilename);
100
101int _hash_tools_lock_free (
102  const char *cssfilename,
103  FILE* lockfile);
104
105int _hash_drv_open(
106  const char *filename,
107  hash_drv_map_t map,
108  unsigned long recmaxifnew,
109  unsigned long max_seek,
110  unsigned long max_extents,
111  unsigned long extent_size,
112  int pctincrease,
113  int flags);
114
115int _hash_drv_close
116  (hash_drv_map_t map);
117
118int _hash_drv_autoextend
119  (hash_drv_map_t map, int extents, unsigned long last_extent_size);
120
121unsigned long _hash_drv_seek(
122  hash_drv_map_t map,
123  unsigned long offset,
124  unsigned long long hashcode,
125  int flags);
126
127int
128_hash_drv_set_spamrecord (
129  hash_drv_map_t map,
130  hash_drv_spam_record_t wrec,
131  unsigned long map_offset);
132
133unsigned long
134_hash_drv_get_spamrecord (
135  hash_drv_map_t map,
136  hash_drv_spam_record_t wrec);
137
138#define HSEEK_INSERT    0x01
139
140#define HMAP_AUTOEXTEND 0x01
141
142#endif /* _HASH_DRV_H */
Note: See TracBrowser for help on using the repository browser.