Mercurial > dnsbl
comparison src/dccifd.cpp @ 214:82886d4dd71f stable-6-0-19
Fixes to compile on Fedora 9 and for const correctness.
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 10 Jun 2008 08:58:42 -0700 |
parents | 92a5c866bdfa |
children | 3fee608becbc |
comparison
equal
deleted
inserted
replaced
213:44ffef730bc4 | 214:82886d4dd71f |
---|---|
50 } | 50 } |
51 return string(buf, n); | 51 return string(buf, n); |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 DccInterface::DccInterface(char *port_, mlfiPriv *priv_, int ip, char *helo_, char *from) | 55 DccInterface::DccInterface(const char *port_, mlfiPriv *priv_, int ip, const char *helo_, const char *from) |
56 { | 56 { |
57 err = false; | 57 err = false; |
58 first_recipient = true; | 58 first_recipient = true; |
59 first_header = true; | 59 first_header = true; |
60 priv = priv_; | 60 priv = priv_; |
70 { | 70 { |
71 my_disconnect(); | 71 my_disconnect(); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 void DccInterface::mlfi_envrcpt(SMFICTX *ctx, char *envrcpt, bool grey) | 75 void DccInterface::mlfi_envrcpt(SMFICTX *ctx, const char *envrcpt, bool grey) |
76 { | 76 { |
77 if (first_recipient) { | 77 if (first_recipient) { |
78 first_recipient = false; | 78 first_recipient = false; |
79 char adr[sizeof "255.255.255.255 "]; | 79 char adr[sizeof "255.255.255.255 "]; |
80 adr[0] = '\0'; | 80 adr[0] = '\0'; |
81 inet_ntop(AF_INET, (const u_char *)&ip4, adr, sizeof(adr)); | 81 inet_ntop(AF_INET, (const u_char *)&ip4, adr, sizeof(adr)); |
82 // Validated sending site's address | 82 // Validated sending site's address |
83 char *rdns = getmacro(ctx, "_", ""); | 83 const char *rdns = getmacro(ctx, "_", ""); |
84 char buf[maxlen+1]; | 84 char buf[maxlen+1]; |
85 if (*rdns == '[') rdns = ""; | 85 if (*rdns == '[') rdns = ""; |
86 else { | 86 else { |
87 int n = 0; | 87 int n = 0; |
88 while ((n < maxlen) && rdns[n] && (rdns[n] != ' ')) n++; | 88 while ((n < maxlen) && rdns[n] && (rdns[n] != ' ')) n++; |
91 rdns = buf; | 91 rdns = buf; |
92 } | 92 } |
93 output(options); | 93 output(options); |
94 output(adr); output("\r"); | 94 output(adr); output("\r"); |
95 output(rdns); output("\n"); | 95 output(rdns); output("\n"); |
96 //output("4.3.2.1\r\n"); // !! not local whitelisting | |
97 output(helo); output("\n"); | 96 output(helo); output("\n"); |
98 output(envfrom); output("\n"); | 97 output(envfrom); output("\n"); |
99 } | 98 } |
100 output(envrcpt); | 99 output(envrcpt); |
101 if (grey) output("\r\n"); | 100 if (grey) output("\r\n"); |
102 else output("\rdnsblnogrey\n"); | 101 else output("\rdnsblnogrey\n"); |
103 } | 102 } |
104 | 103 |
105 | 104 |
106 void DccInterface::mlfi_header(SMFICTX *ctx, char* headerf, char* headerv) | 105 void DccInterface::mlfi_header(SMFICTX *ctx, const char *headerf, const char *headerv) |
107 { | 106 { |
108 if (dccifd_socket == NULL_SOCKET) Connect(); | 107 if (dccifd_socket == NULL_SOCKET) Connect(); |
109 if ((dccifd_socket != NULL_SOCKET) && (!dccifd_input.empty())) { | 108 if ((dccifd_socket != NULL_SOCKET) && (!dccifd_input.empty())) { |
110 output(dccifd_input); | 109 output(dccifd_input); |
111 dccifd_input.clear(); | 110 dccifd_input.clear(); |
127 { | 126 { |
128 output("\r\n"); | 127 output("\r\n"); |
129 } | 128 } |
130 | 129 |
131 | 130 |
132 void DccInterface::mlfi_body(u_char *bodyp, size_t bodylen) | 131 void DccInterface::mlfi_body(const u_char *bodyp, size_t bodylen) |
133 { | 132 { |
134 output((char *)bodyp, bodylen); | 133 output((const char *)bodyp, bodylen); |
135 } | 134 } |
136 | 135 |
137 | 136 |
138 void DccInterface::mlfi_eom(bool &grey, int &bulk) | 137 void DccInterface::mlfi_eom(bool &grey, int &bulk) |
139 { | 138 { |
315 void DccInterface::input() | 314 void DccInterface::input() |
316 { | 315 { |
317 if ((dccifd_socket == NULL_SOCKET) || err) return; | 316 if ((dccifd_socket == NULL_SOCKET) || err) return; |
318 char buf[maxlen]; | 317 char buf[maxlen]; |
319 int rs; | 318 int rs; |
320 while (rs = my_read(buf, maxlen)) { | 319 while ((rs = my_read(buf, maxlen))) { |
321 //my_syslog(priv, string("dcc read ") + escaper(string(buf, rs))); | 320 //my_syslog(priv, string("dcc read ") + escaper(string(buf, rs))); |
322 dccifd_output.append(buf, rs); | 321 dccifd_output.append(buf, rs); |
323 } | 322 } |
324 my_disconnect(); | 323 my_disconnect(); |
325 } | 324 } |
326 | 325 |
327 | 326 |
328 char *DccInterface::getmacro(SMFICTX *ctx, char *macro, char *def) | 327 const char *DccInterface::getmacro(SMFICTX *ctx, const char *macro, const char *def) |
329 { | 328 { |
330 char *rc = smfi_getsymval(ctx, macro); | 329 const char *rc = smfi_getsymval(ctx, (char*)macro); |
331 if (!rc) rc = def; | 330 if (!rc) rc = def; |
332 return rc; | 331 return rc; |
333 } | 332 } |
334 | 333 |
335 | 334 |