45 |
int |
int |
46 |
server_response(int *sock, unsigned int tag) |
server_response(int *sock, unsigned int tag) |
47 |
{ |
{ |
48 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
49 |
|
|
50 |
reset_vbuf(); |
reset_vbuf(); |
51 |
|
|
56 |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
57 |
} while (!strcasestr(buf, ultostr(tag, 16))); |
} while (!strcasestr(buf, ultostr(tag, 16))); |
58 |
|
|
59 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
60 |
} |
} |
61 |
|
|
62 |
|
|
77 |
int |
int |
78 |
greeting_response(int *sock) |
greeting_response(int *sock) |
79 |
{ |
{ |
80 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
81 |
|
|
82 |
receive_response(sock, buf); |
receive_response(sock, buf); |
83 |
|
|
84 |
|
verbose("%s: %s", (sock == &sockpri ? "S" : "s"), buf); |
85 |
|
|
86 |
bye_response(buf); |
bye_response(buf); |
87 |
|
|
88 |
if (strcasestr(buf, "* PREAUTH")) |
if (strcasestr(buf, "* PREAUTH")) |
98 |
int |
int |
99 |
logout_response(int *sock, unsigned int tag) |
logout_response(int *sock, unsigned int tag) |
100 |
{ |
{ |
101 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
102 |
|
|
103 |
reset_vbuf(); |
reset_vbuf(); |
104 |
|
|
108 |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
109 |
} while (!strcasestr(buf, ultostr(tag, 16))); |
} while (!strcasestr(buf, ultostr(tag, 16))); |
110 |
|
|
111 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
112 |
} |
} |
113 |
|
|
114 |
|
|
118 |
int |
int |
119 |
capability_response(int *sock, unsigned int tag) |
capability_response(int *sock, unsigned int tag) |
120 |
{ |
{ |
121 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
122 |
|
|
123 |
reset_vbuf(); |
reset_vbuf(); |
124 |
|
|
138 |
|
|
139 |
auth_mechanisms(); |
auth_mechanisms(); |
140 |
|
|
141 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
142 |
} |
} |
143 |
|
|
144 |
|
|
184 |
int |
int |
185 |
namespace_response(int *sock, unsigned int tag, namesp_t * nsp) |
namespace_response(int *sock, unsigned int tag, namesp_t * nsp) |
186 |
{ |
{ |
187 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
188 |
char *c, *d; |
char *c, *d; |
189 |
|
|
190 |
reset_vbuf(); |
reset_vbuf(); |
211 |
(sock == &sockpri ? "primary" : "auxiliary"), nsp->prefix, |
(sock == &sockpri ? "primary" : "auxiliary"), nsp->prefix, |
212 |
nsp->delim); |
nsp->delim); |
213 |
#endif |
#endif |
214 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
215 |
} |
} |
216 |
|
|
217 |
|
|
222 |
status_response(int *sock, unsigned int tag, char *mbox) |
status_response(int *sock, unsigned int tag, char *mbox) |
223 |
{ |
{ |
224 |
int r; |
int r; |
225 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
226 |
unsigned int exist, recent, unseen; |
unsigned int exist, recent, unseen; |
227 |
char *c; |
char *c; |
228 |
|
|
237 |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
238 |
} while (!strcasestr(buf, ultostr(tag, 16))); |
} while (!strcasestr(buf, ultostr(tag, 16))); |
239 |
|
|
240 |
r = analyze_response(buf); |
r = analyze_response(sock, buf); |
241 |
|
|
242 |
if (r == RESPONSE_NO) |
if (r == RESPONSE_NO) |
243 |
return -2; |
return -2; |
271 |
int |
int |
272 |
select_response(int *sock, unsigned int tag) |
select_response(int *sock, unsigned int tag) |
273 |
{ |
{ |
274 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
275 |
|
|
276 |
reset_vbuf(); |
reset_vbuf(); |
277 |
|
|
285 |
if (strcasestr(vbuf, "[READ-ONLY]")) |
if (strcasestr(vbuf, "[READ-ONLY]")) |
286 |
return RESPONSE_READONLY; |
return RESPONSE_READONLY; |
287 |
|
|
288 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
289 |
} |
} |
290 |
|
|
291 |
|
|
295 |
int |
int |
296 |
search_response(int *sock, unsigned int tag, char **mesgs) |
search_response(int *sock, unsigned int tag, char **mesgs) |
297 |
{ |
{ |
298 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
299 |
char *c, *m; |
char *c, *m; |
300 |
unsigned int blen; |
unsigned int blen; |
301 |
|
|
320 |
|
|
321 |
*m = 0; |
*m = 0; |
322 |
} |
} |
323 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
324 |
} |
} |
325 |
|
|
326 |
|
|
330 |
int |
int |
331 |
fetch_response(int *sock, unsigned int tag, int reset, char *fetch) |
fetch_response(int *sock, unsigned int tag, int reset, char *fetch) |
332 |
{ |
{ |
333 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
334 |
unsigned int i; |
unsigned int i; |
335 |
static unsigned int s; |
static unsigned int s; |
336 |
char *b; |
char *b; |
370 |
|
|
371 |
fetch[i] = '\0'; |
fetch[i] = '\0'; |
372 |
|
|
373 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
374 |
} |
} |
375 |
|
|
376 |
|
|
381 |
int |
int |
382 |
fetchsize_response(int *sock, unsigned int *size, unsigned int tag) |
fetchsize_response(int *sock, unsigned int *size, unsigned int tag) |
383 |
{ |
{ |
384 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
385 |
char *c; |
char *c; |
386 |
|
|
387 |
*size = 0; |
*size = 0; |
399 |
c += 19; |
c += 19; |
400 |
*size = strtoul(c, NULL, 10); |
*size = strtoul(c, NULL, 10); |
401 |
} |
} |
402 |
return analyze_response(buf); |
return analyze_response(sock, buf); |
403 |
} |
} |
404 |
|
|
405 |
|
|
410 |
append_response(int *sock, unsigned int tag) |
append_response(int *sock, unsigned int tag) |
411 |
{ |
{ |
412 |
int r; |
int r; |
413 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
414 |
|
|
415 |
r = RESPONSE_OK; |
r = RESPONSE_OK; |
416 |
|
|
423 |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
424 |
} while (!strcasestr(buf, ultostr(tag, 16))); |
} while (!strcasestr(buf, ultostr(tag, 16))); |
425 |
|
|
426 |
if ((r = analyze_response(buf)) == RESPONSE_NO && |
if ((r = analyze_response(sock, buf)) == RESPONSE_NO && |
427 |
strcasestr(vbuf, "[TRYCREATE]")) |
strcasestr(vbuf, "[TRYCREATE]")) |
428 |
return RESPONSE_TRYCREATE; |
return RESPONSE_TRYCREATE; |
429 |
|
|
438 |
copy_response(int *sock, unsigned int tag) |
copy_response(int *sock, unsigned int tag) |
439 |
{ |
{ |
440 |
int r; |
int r; |
441 |
char buf[RESPONSE_BUF]; |
char buf[RESPONSE_BUF + 1]; |
442 |
|
|
443 |
r = RESPONSE_OK; |
r = RESPONSE_OK; |
444 |
|
|
451 |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
strncat(vbuf, buf, vbufs - strlen(vbuf)); |
452 |
} while (!strcasestr(buf, ultostr(tag, 16))); |
} while (!strcasestr(buf, ultostr(tag, 16))); |
453 |
|
|
454 |
if ((r = analyze_response(buf)) == RESPONSE_NO && |
if ((r = analyze_response(sock, buf)) == RESPONSE_NO && |
455 |
strcasestr(vbuf, "[TRYCREATE]")) |
strcasestr(vbuf, "[TRYCREATE]")) |
456 |
return RESPONSE_TRYCREATE; |
return RESPONSE_TRYCREATE; |
457 |
|
|
464 |
* delivered or there was some kind of error. |
* delivered or there was some kind of error. |
465 |
*/ |
*/ |
466 |
int |
int |
467 |
analyze_response(char *buf) |
analyze_response(int *sock, char *buf) |
468 |
{ |
{ |
469 |
int r; |
int r; |
470 |
regex_t creg; |
regex_t creg; |
487 |
else if (!strncasecmp(buf + match[2].rm_so, "BAD", 3)) |
else if (!strncasecmp(buf + match[2].rm_so, "BAD", 3)) |
488 |
r = RESPONSE_BAD; |
r = RESPONSE_BAD; |
489 |
|
|
490 |
verbose("Server response: %s\n", result); |
verbose("%s: %s", (sock == &sockpri ? "S" : "s"), |
491 |
|
buf + match[0].rm_so); |
492 |
} else |
} else |
493 |
r = RESPONSE_NONE; |
r = RESPONSE_NONE; |
494 |
|
|