source: npl/mailserver/dspam/dspam-3.10.2/src/util.h @ 26ffad7

Last change on this file since 26ffad7 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.3 KB
Line 
1/* $Id: util.h,v 1.20 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 _UTIL_H
23#  define _UTIL_H
24
25#ifdef HAVE_CONFIG_H
26#include <auto-config.h>
27#endif
28
29#include <sys/types.h>
30#include <sys/socket.h>
31#include <netinet/in.h>
32#include <arpa/inet.h>
33
34#ifndef _WIN32
35#include <pwd.h>
36#endif
37
38void    chomp   (char *string);
39char *  ltrim   (char *str);
40char *  rtrim   (char *str);
41int     lc      (char *buff, const char *string);
42#ifndef HAVE_STRCASESTR
43char *  strcasestr (const char *, const char *);
44#endif
45
46#define ALLTRIM(str)  ltrim(rtrim(str))
47
48#ifndef HAVE_STRSEP
49char *strsep (char **stringp, const char *delim);
50#endif
51
52#ifndef HAVE_STRLCPY
53size_t strlcpy (char *, const char *, size_t);
54size_t strlcat (char *, const char *, size_t);
55#endif
56
57/*
58 * Specialized Functions
59 * Utilities specialized for DSPAM functions.
60 *
61 *  _ds_userdir_path()
62 *    Generates the path for files within DSPAM's filesystem, according to the
63 *    filesystem structure specified at configure time.
64 *
65 *  _ds_prepare_path_for()
66 *    Creates any necessary subdirectories to support the supplied path
67 *
68 *  _ds_get_crc64()
69 *    Generates the CRC of the supplied string, using CRC64
70 *
71 *  _ds_compute_complexity()
72 *    Calculates the complexity of a token based on its nGram depth
73 *
74 *  _ds_compute_sparse()
75 *    Calculates the number of sparse skips in a token
76 *
77 *  _ds_compute_weight()
78 *    Calculates the markovian weight of a token
79 *
80 *  _ds_compute_weight_osb()
81 *    Calculates the OSB/OSBF/WINNOW weight of a token
82 */
83
84#ifndef HAVE_STRTOK_R
85char * strtok_r(char *s1, const char *s2, char **lasts);
86#endif
87
88#ifndef HAVE_INET_NTOA_R
89unsigned int i2a
90  (char* dest,unsigned int x);
91char *inet_ntoa_r
92  (struct in_addr in, char *buf, int len);
93#endif
94
95#ifdef EXT_LOOKUP
96  int verified_user;
97#endif
98
99const char *    _ds_userdir_path (
100  char *buff,
101  const char *home,
102  const char *filename,
103  const char *extension);
104
105int _ds_prepare_path_for   (const char *filename);
106int _ds_compute_complexity (const char *token);
107int _ds_compute_sparse     (const char *token);
108int _ds_compute_weight     (const char *token);
109int _ds_compute_weight_osb (const char *token);
110char *_ds_truncate_token   (const char *token);
111
112int     _ds_extract_address(
113  char *buf,
114  const char *address,
115  size_t len);
116
117double  _ds_gettime(void);
118
119void timeout(void);
120
121int _ds_get_fcntl_lock  (int fd);
122int _ds_free_fcntl_lock (int fd);
123
124unsigned long long _ds_getcrc64
125  (const char *);
126int _ds_pow
127  (int base, unsigned int exp);
128int _ds_pow2
129  (int exp);
130double chi2Q
131  (double x, int v);
132float _ds_round
133  (float n);
134
135int _ds_validate_address
136  (const char *address);
137#endif /* _UTIL_H */
Note: See TracBrowser for help on using the repository browser.