Mercurial > notdcc
comparison dns-helper/dns-helper.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 * talk to DNS resolver libraries that are not thread safe | |
4 * | |
5 * Copyright (c) 2008 by Rhyolite Software, LLC | |
6 * | |
7 * This agreement is not applicable to any entity which sells anti-spam | |
8 * solutions to others or provides an anti-spam solution as part of a | |
9 * security solution sold to other entities, or to a private network | |
10 * which employs the DCC or uses data provided by operation of the DCC | |
11 * but does not provide corresponding data to other users. | |
12 * | |
13 * Permission to use, copy, modify, and distribute this software without | |
14 * changes for any purpose with or without fee is hereby granted, provided | |
15 * that the above copyright notice and this permission notice appear in all | |
16 * copies and any distributed versions or copies are either unchanged | |
17 * or not called anything similar to "DCC" or "Distributed Checksum | |
18 * Clearinghouse". | |
19 * | |
20 * Parties not eligible to receive a license under this agreement can | |
21 * obtain a commercial license to use DCC by contacting Rhyolite Software | |
22 * at sales@rhyolite.com. | |
23 * | |
24 * A commercial license would be for Distributed Checksum and Reputation | |
25 * Clearinghouse software. That software includes additional features. This | |
26 * free license for Distributed ChecksumClearinghouse Software does not in any | |
27 * way grant permision to use Distributed Checksum and Reputation Clearinghouse | |
28 * software | |
29 * | |
30 * THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL | |
31 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES | |
32 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC | |
33 * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES | |
34 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
35 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
36 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
37 * SOFTWARE. | |
38 * | |
39 * Rhyolite Software DCC 1.3.103-1.7 $Revision$ | |
40 */ | |
41 | |
42 #include "dcc_defs.h" | |
43 #include "helper.h" | |
44 | |
45 | |
46 static DCC_EMSG dcc_emsg; | |
47 | |
48 static void NRATTRIB | |
49 usage(void) | |
50 { | |
51 dcc_logbad(EX_USAGE, "usage: [-V] -B..."); | |
52 } | |
53 | |
54 | |
55 | |
56 int NRATTRIB | |
57 main(int argc, char **argv) | |
58 { | |
59 int i; | |
60 | |
61 dcc_syslog_init(1, argv[0], 0); | |
62 | |
63 while ((i = getopt(argc, argv, "VB:L:")) != -1) { | |
64 switch (i) { | |
65 case 'V': | |
66 fprintf(stderr, DCC_VERSION"\n"); | |
67 exit(EX_OK); | |
68 break; | |
69 | |
70 case 'B': | |
71 if (!dcc_parse_dnsbl(dcc_emsg, optarg, 0, 0)) | |
72 dcc_error_msg("%s", dcc_emsg); | |
73 break; | |
74 | |
75 case 'L': | |
76 dcc_parse_log_opt(optarg); | |
77 break; | |
78 | |
79 default: | |
80 usage(); | |
81 } | |
82 } | |
83 usage(); | |
84 } | |
85 | |
86 | |
87 | |
88 int | |
89 thr_error_msg(void *cp UATTRIB, const char *p, ...) | |
90 { | |
91 va_list args; | |
92 int i; | |
93 | |
94 va_start(args, p); | |
95 i = dcc_verror_msg(p, args); | |
96 va_end(args); | |
97 return i; | |
98 } | |
99 | |
100 | |
101 | |
102 void | |
103 thr_trace_msg(void *cp UATTRIB, const char *p, ...) | |
104 { | |
105 va_list args; | |
106 | |
107 va_start(args, p); | |
108 dcc_verror_msg(p, args); | |
109 va_end(args); | |
110 } | |
111 | |
112 | |
113 | |
114 /* DOES append '\n', but since it is ony for errors, do not worry about it */ | |
115 int | |
116 thr_log_print(void *cp UATTRIB, u_char error UATTRIB, const char *p, ...) | |
117 { | |
118 va_list args; | |
119 int i; | |
120 | |
121 va_start(args, p); | |
122 i = dcc_verror_msg(p, args); | |
123 va_end(args); | |
124 return i; | |
125 } |