comparison dcclib/tgts2str.c @ 0:c7f6b056b673

First import of vendor version
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 13:49:58 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c7f6b056b673
1 /* Distributed Checksum Clearinghouse
2 *
3 * Copyright (c) 2008 by Rhyolite Software, LLC
4 *
5 * This agreement is not applicable to any entity which sells anti-spam
6 * solutions to others or provides an anti-spam solution as part of a
7 * security solution sold to other entities, or to a private network
8 * which employs the DCC or uses data provided by operation of the DCC
9 * but does not provide corresponding data to other users.
10 *
11 * Permission to use, copy, modify, and distribute this software without
12 * changes for any purpose with or without fee is hereby granted, provided
13 * that the above copyright notice and this permission notice appear in all
14 * copies and any distributed versions or copies are either unchanged
15 * or not called anything similar to "DCC" or "Distributed Checksum
16 * Clearinghouse".
17 *
18 * Parties not eligible to receive a license under this agreement can
19 * obtain a commercial license to use DCC by contacting Rhyolite Software
20 * at sales@rhyolite.com.
21 *
22 * A commercial license would be for Distributed Checksum and Reputation
23 * Clearinghouse software. That software includes additional features. This
24 * free license for Distributed ChecksumClearinghouse Software does not in any
25 * way grant permision to use Distributed Checksum and Reputation Clearinghouse
26 * software
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL
29 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
30 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC
31 * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
32 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
33 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
34 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
35 * SOFTWARE.
36 *
37 * Rhyolite Software DCC 1.3.103-1.23 $Revision$
38 */
39
40 #include "dcc_ck.h"
41 #include "dcc_xhdr.h"
42
43
44 char *
45 dcc_tgts2str(char *buf, u_int buf_len, DCC_TGTS tgts, u_char grey)
46 {
47 switch (tgts) {
48 case DCC_TGTS_TOO_MANY:
49 if (grey)
50 STRLCPY(buf, DCC_XHDR_GREY_PASS, buf_len);
51 else
52 STRLCPY(buf, DCC_XHDR_TOO_MANY, buf_len);
53 break;
54 case DCC_TGTS_OK:
55 STRLCPY(buf, DCC_XHDR_OK, buf_len);
56 break;
57 case DCC_TGTS_OK2:
58 if (grey) /* DCC_TGTS_GREY_WHITE */
59 STRLCPY(buf, DCC_XHDR_OK, buf_len);
60 else
61 STRLCPY(buf, DCC_XHDR_OK2, buf_len);
62 break;
63 case DCC_TGTS_DEL:
64 STRLCPY(buf, DCC_XHDR_DEL, buf_len);
65 break;
66 case DCC_TGTS_REP_ADJ:
67 STRLCPY(buf, DCC_XHDR_TGTS_REP_ADJ, buf_len);
68 break;
69 case DCC_TGTS_OK_MX:
70 STRLCPY(buf, DCC_XHDR_OK_MX, buf_len);
71 break;
72 case DCC_TGTS_OK_MXDCC:
73 STRLCPY(buf, DCC_XHDR_OK_MXDCC, buf_len);
74 break;
75 case DCC_TGTS_SUBMIT_CLIENT:
76 STRLCPY(buf, DCC_XHDR_SUBMIT_CLIENT, buf_len);
77 break;
78 case DCC_TGTS_INVALID:
79 STRLCPY(buf, DCC_XHDR_INVALID, buf_len);
80 break;
81 default:
82 if (tgts & DCC_TGTS_SPAM)
83 snprintf(buf, buf_len, "%d spam",
84 tgts & ~DCC_TGTS_SPAM);
85 else
86 snprintf(buf, buf_len, "%d",
87 tgts);
88 break;
89 }
90
91 return buf;
92 }
93
94
95
96 char *
97 dcc_thold2str(char *buf, u_int buf_len, DCC_CK_TYPES type, DCC_TGTS tgts)
98 {
99 if (tgts == DCC_THOLD_NEVER) {
100 STRLCPY(buf, DCC_XHDR_THOLD_NEVER, buf_len);
101 return buf;
102 }
103
104 if (type == DCC_CK_REP_BULK) {
105 snprintf(buf, buf_len, "%u%%", tgts);
106 return buf;
107 }
108
109 return dcc_tgts2str(buf, buf_len, tgts, 0);
110 }