29 |
#endif |
#endif |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
/* |
/* |
34 |
* Connect to mail server. |
* Connect to mail server. |
35 |
*/ |
*/ |
170 |
return 0; |
return 0; |
171 |
} |
} |
172 |
|
|
173 |
#endif |
#endif /* SSL_TLS */ |
174 |
|
|
175 |
|
|
176 |
/* |
/* |
243 |
case SSL_ERROR_WANT_READ: |
case SSL_ERROR_WANT_READ: |
244 |
case SSL_ERROR_WANT_WRITE: |
case SSL_ERROR_WANT_WRITE: |
245 |
continue; |
continue; |
246 |
|
case SSL_ERROR_ZERO_RETURN: |
247 |
|
return ERROR_NETWORK; |
248 |
case SSL_ERROR_SYSCALL: |
case SSL_ERROR_SYSCALL: |
249 |
case SSL_ERROR_SSL: |
case SSL_ERROR_SSL: |
250 |
fatal(ERROR_NETWORK, "imapfilter: reading data; %s", |
fatal(ERROR_NETWORK, "imapfilter: reading data; %s", |
256 |
} |
} |
257 |
} else |
} else |
258 |
#endif |
#endif |
259 |
|
{ |
260 |
if ((s = select(*sock + 1, &fds, NULL, NULL, tvp)) > 0 && |
if ((s = select(*sock + 1, &fds, NULL, NULL, tvp)) > 0 && |
261 |
FD_ISSET(*sock, &fds)) |
FD_ISSET(*sock, &fds)) |
262 |
e = read(*sock, buf, RESPONSE_BUF - 1); |
e = read(*sock, buf, RESPONSE_BUF - 1); |
263 |
|
|
264 |
if (e == -1) |
if (e == -1) |
265 |
fatal(ERROR_NETWORK, "imapfilter: reading data; %s", |
fatal(ERROR_NETWORK, "imapfilter: reading data; %s", |
266 |
strerror(errno)); |
strerror(errno)); |
267 |
|
else if (e == 0) |
268 |
|
return ERROR_NETWORK; |
269 |
|
} |
270 |
|
|
271 |
fcntl(*sock, F_SETFL, f); |
fcntl(*sock, F_SETFL, f); |
272 |
|
|
273 |
if (s == -1) |
if (s == -1) |
274 |
fatal(ERROR_NETWORK, "imapfilter: waiting to read from socket; %s\n", |
fatal(ERROR_NETWORK, "imapfilter: waiting to read from socket; %s\n", |
275 |
strerror(errno)); |
strerror(errno)); |
276 |
else if (!s) |
else if (s == 0) |
277 |
fatal(ERROR_NETWORK, |
fatal(ERROR_NETWORK, |
278 |
"imapfilter: timeout period expired while waiting to read " |
"imapfilter: timeout period expired while waiting to read " |
279 |
"data\n"); |
"data\n"); |
323 |
case SSL_ERROR_WANT_READ: |
case SSL_ERROR_WANT_READ: |
324 |
case SSL_ERROR_WANT_WRITE: |
case SSL_ERROR_WANT_WRITE: |
325 |
continue; |
continue; |
326 |
|
case SSL_ERROR_ZERO_RETURN: |
327 |
|
return ERROR_NETWORK; |
328 |
case SSL_ERROR_SYSCALL: |
case SSL_ERROR_SYSCALL: |
329 |
case SSL_ERROR_SSL: |
case SSL_ERROR_SSL: |
330 |
fatal(ERROR_NETWORK, "imapfilter: writing data; %s", |
fatal(ERROR_NETWORK, "imapfilter: writing data; %s", |
336 |
} |
} |
337 |
} else |
} else |
338 |
#endif |
#endif |
339 |
|
{ |
340 |
if ((s = select(*sock + 1, NULL, &fds, NULL, tvp)) > 0 && |
if ((s = select(*sock + 1, NULL, &fds, NULL, tvp)) > 0 && |
341 |
FD_ISSET(*sock, &fds)) |
FD_ISSET(*sock, &fds)) |
342 |
e = write(*sock, data, strlen(data)); |
e = write(*sock, data, strlen(data)); |
343 |
|
|
344 |
if (e == -1) |
if (e == -1) |
345 |
fatal(ERROR_NETWORK, "imapfilter: writing data; %s", |
fatal(ERROR_NETWORK, "imapfilter: writing data; %s", |
346 |
strerror(errno)); |
strerror(errno)); |
347 |
|
} |
348 |
|
|
349 |
fcntl(*sock, F_SETFL, f); |
fcntl(*sock, F_SETFL, f); |
350 |
|
|
351 |
if (s == -1) |
if (s == -1) |
352 |
fatal(ERROR_NETWORK, "imapfilter: waiting to write to socket; %s\n", |
fatal(ERROR_NETWORK, "imapfilter: waiting to write to socket; %s\n", |
353 |
strerror(errno)); |
strerror(errno)); |
354 |
else if (!s) |
else if (s == 0) |
355 |
fatal(ERROR_NETWORK, |
fatal(ERROR_NETWORK, |
356 |
"imapfilter: timeout period expired while waiting to write " |
"imapfilter: timeout period expired while waiting to write " |
357 |
"data\n"); |
"data\n"); |