18 |
#endif |
#endif |
19 |
|
|
20 |
|
|
21 |
extern long timeout; |
long timeout = -1; /* Server non-response timeout in seconds. */ |
22 |
|
|
23 |
static int sock; |
static int sock; |
24 |
|
|
33 |
#ifndef SSL_TLS |
#ifndef SSL_TLS |
34 |
int init_connection(char *serv, unsigned short int port) |
int init_connection(char *serv, unsigned short int port) |
35 |
#else |
#else |
36 |
int init_connection(char *serv, unsigned short int port, unsigned int protocol) |
int init_connection(char *serv, unsigned short int port, |
37 |
|
unsigned int protocol) |
38 |
#endif |
#endif |
39 |
{ |
{ |
40 |
struct sockaddr_in sa; |
struct sockaddr_in sa; |
61 |
xstrncpy(serv, he->h_name, SERVER_LEN - 1); |
xstrncpy(serv, he->h_name, SERVER_LEN - 1); |
62 |
|
|
63 |
if (connect(sock, (struct sockaddr *) & sa, sizeof(struct sockaddr))) { |
if (connect(sock, (struct sockaddr *) & sa, sizeof(struct sockaddr))) { |
64 |
error("imapfilter: initiating connection to %s; %s\n", serv, strerror(errno)); |
error("imapfilter: initiating connection to %s; %s\n", serv, |
65 |
|
strerror(errno)); |
66 |
close_connection(); |
close_connection(); |
67 |
return ERROR_NETWORK; |
return ERROR_NETWORK; |
68 |
} |
} |
195 |
|
|
196 |
memset(buf, 0, RESPONSE_BUF); |
memset(buf, 0, RESPONSE_BUF); |
197 |
|
|
198 |
if (timeout) { |
if (timeout >= 0) { |
199 |
tv.tv_sec = timeout; |
tv.tv_sec = timeout; |
200 |
tv.tv_usec = 0; |
tv.tv_usec = 0; |
201 |
tvp = &tv; |
tvp = &tv; |