41 |
int check_imap(Port_T p) { |
int check_imap(Port_T p) { |
42 |
|
|
43 |
char buf[STRLEN]; |
char buf[STRLEN]; |
|
const char *command= "001 LOGOUT\r\n"; |
|
44 |
const char *ok= "* OK"; |
const char *ok= "* OK"; |
45 |
const char *bye= "* BYE"; |
const char *bye= "* BYE"; |
46 |
|
const char *command= "001 LOGOUT\r\n"; |
47 |
|
|
48 |
if ( port_recv(p, buf, sizeof(buf), 0) <= 0 ) { |
ASSERT(p); |
49 |
|
|
50 |
|
if(port_recv(p, buf, sizeof(buf), 0) <= 0) { |
51 |
log("IMAP: error receiving data -- %s\n", STRERROR); |
log("IMAP: error receiving data -- %s\n", STRERROR); |
52 |
return FALSE; |
return FALSE; |
53 |
} |
} |
54 |
|
|
55 |
chomp(buf); |
chomp(buf); |
56 |
|
|
57 |
if ( strncasecmp(buf, ok, strlen(ok)) != 0 ) { |
if(strncasecmp(buf, ok, strlen(ok)) != 0) { |
58 |
log("IMAP error: %s\n", buf); |
log("IMAP error: %s\n", buf); |
59 |
return FALSE; |
return FALSE; |
60 |
} |
} |
61 |
|
|
62 |
if ( port_send(p, command, strlen(command), 0) < 0 ) { |
if(port_send(p, command, strlen(command), 0) < 0) { |
63 |
log("IMAP: error sending data -- %s\n", STRERROR); |
log("IMAP: error sending data -- %s\n", STRERROR); |
64 |
return FALSE; |
return FALSE; |
65 |
} |
} |
66 |
|
|
67 |
if ( port_recv(p, buf, sizeof(buf), 0) <= 0 ) { |
if(port_recv(p, buf, sizeof(buf), 0) <= 0) { |
68 |
log("IMAP: error receiving data -- %s\n", STRERROR); |
log("IMAP: error receiving data -- %s\n", STRERROR); |
69 |
return FALSE; |
return FALSE; |
70 |
} |
} |
71 |
|
|
72 |
chomp(buf); |
chomp(buf); |
73 |
|
|
74 |
if ( strncasecmp(buf, bye, strlen(bye)) != 0 ) { |
if(strncasecmp(buf, bye, strlen(bye)) != 0) { |
75 |
log("IMAP error: %s\n", buf); |
log("IMAP error: %s\n", buf); |
76 |
return FALSE; |
return FALSE; |
77 |
} |
} |