61 |
|
|
62 |
receive_response(sock, buf); |
receive_response(sock, buf); |
63 |
|
|
64 |
if (strcasestr(buf, "BYE")) |
if (strcasestr(buf, "* BYE")) |
65 |
return RESPONSE_BYE; |
return RESPONSE_BYE; |
66 |
else if (strcasestr(buf, "PREAUTH")) |
else if (strcasestr(buf, "* PREAUTH")) |
67 |
return RESPONSE_PREAUTH; |
return RESPONSE_PREAUTH; |
68 |
|
|
69 |
return RESPONSE_OK; |
return RESPONSE_OK; |
71 |
|
|
72 |
|
|
73 |
/* |
/* |
74 |
|
* Process the data that server sent due to IMAP LOGOUT client request. |
75 |
|
*/ |
76 |
|
int logout_response(int *sock, unsigned int tag) |
77 |
|
{ |
78 |
|
char buf[RESPONSE_BUF]; |
79 |
|
|
80 |
|
reset_vbuf(); |
81 |
|
|
82 |
|
do { |
83 |
|
receive_response(sock, buf); |
84 |
|
check_vbuf(strlen(buf)); |
85 |
|
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
86 |
|
} while (!strcasestr(buf, ultostr(tag, 16))); |
87 |
|
|
88 |
|
return analyze_response(buf); |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
/* |
93 |
* Process the data that server sent due to IMAP CAPABILITY client request. |
* Process the data that server sent due to IMAP CAPABILITY client request. |
94 |
*/ |
*/ |
95 |
int capability_response(int *sock, unsigned int tag) |
int capability_response(int *sock, unsigned int tag) |
242 |
|
|
243 |
c += 9; |
c += 9; |
244 |
|
|
245 |
while (*c && (isdigit(*c) || *c == ' ')) |
while (*c && (isdigit((unsigned char)(*c)) || *c == ' ')) |
246 |
*(m++) = *(c++); |
*(m++) = *(c++); |
247 |
|
|
248 |
*m = 0; |
*m = 0; |
402 |
*/ |
*/ |
403 |
void init_vbuf(void) |
void init_vbuf(void) |
404 |
{ |
{ |
405 |
vbuf = xmalloc(4096); |
vbuf = xmalloc(VIRTUAL_BUF); |
406 |
*vbuf = 0; |
*vbuf = 0; |
407 |
vbufs = 4096; |
vbufs = VIRTUAL_BUF; |
408 |
} |
} |
409 |
|
|
410 |
|
|
423 |
void check_vbuf(size_t n) |
void check_vbuf(size_t n) |
424 |
{ |
{ |
425 |
if (n + strlen(vbuf) >= vbufs) { |
if (n + strlen(vbuf) >= vbufs) { |
426 |
vbufs += 4096; |
vbufs += VIRTUAL_BUF; |
427 |
vbuf = xrealloc(vbuf, vbufs); |
vbuf = xrealloc(vbuf, vbufs); |
428 |
} |
} |
429 |
} |
} |