356 |
|
|
357 |
|
|
358 |
/* |
/* |
359 |
* Process the data that server sent due to IMAP FETCH RFC822.SIZE client |
* Process the data that server sent due to IMAP FETCH FAST client request. |
|
* request. |
|
360 |
*/ |
*/ |
361 |
int |
int |
362 |
fetchsize_response(conn_t * conn, unsigned int *size, unsigned int tag) |
fetchfast_response(conn_t * conn, char **flags, char **date, |
363 |
|
unsigned int *size, unsigned int tag) |
364 |
{ |
{ |
365 |
char *c; |
char *c, *m; |
366 |
|
unsigned int blen; |
367 |
|
|
368 |
*size = 0; |
*size = 0; |
369 |
|
|
375 |
bye_response(ibuf.data); |
bye_response(ibuf.data); |
376 |
} while (!strcasestr(ibuf.data, ultostr(tag, 16))); |
} while (!strcasestr(ibuf.data, ultostr(tag, 16))); |
377 |
|
|
378 |
if ((c = strcasestr(ibuf.data, "FETCH (RFC822.SIZE "))) { |
if ((c = strcasestr(ibuf.data, "FETCH (FLAGS ("))) { |
379 |
c += 19; |
blen = strlen(ibuf.data); |
380 |
|
|
381 |
|
m = *flags = (char *)xmalloc(blen + 1); |
382 |
|
|
383 |
|
c += 14; |
384 |
|
|
385 |
|
while (*c != '\0' && *c != ')') { |
386 |
|
/* The \Recent flag can not be altered by the client. */ |
387 |
|
if (*c == '\\') { |
388 |
|
if (strcasestr(c - 1, "(\\Recent)") || |
389 |
|
strcasestr(c - 1, " \\Recent)")) |
390 |
|
break; |
391 |
|
else if (strcasestr(c, "\\Recent ")) |
392 |
|
c += 8; |
393 |
|
} |
394 |
|
|
395 |
|
*(m++) = *(c++); |
396 |
|
} |
397 |
|
|
398 |
|
*m = 0; |
399 |
|
} |
400 |
|
|
401 |
|
if ((c = strcasestr(ibuf.data, " INTERNALDATE \""))) { |
402 |
|
blen = strlen(ibuf.data); |
403 |
|
|
404 |
|
m = *date = (char *)xmalloc(blen + 1); |
405 |
|
|
406 |
|
c += 15; |
407 |
|
|
408 |
|
while (*c != '\0' && *c != '"') |
409 |
|
*(m++) = *(c++); |
410 |
|
|
411 |
|
*m = 0; |
412 |
|
} |
413 |
|
|
414 |
|
if ((c = strcasestr(ibuf.data, " RFC822.SIZE "))) { |
415 |
|
c += 13; |
416 |
*size = strtoul(c, NULL, 10); |
*size = strtoul(c, NULL, 10); |
417 |
} |
} |
418 |
return analyze_response(conn, ibuf.data); |
return analyze_response(conn, ibuf.data); |