static int vanished_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_qresync_vanished ** result) { int r; struct mailimap_set * set; int earlier; struct mailimap_qresync_vanished * vanished; size_t cur_token; int res; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "VANISHED"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } earlier = 0; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "(EARLIER)"); if (r == MAILIMAP_NO_ERROR) { earlier = 1; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } } r = mailimap_set_parse(fd, buffer, parser_ctx, &cur_token, &set); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } vanished = mailimap_qresync_vanished_new(earlier, set); if (vanished == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_set; } * indx = cur_token; * result = vanished; return MAILIMAP_NO_ERROR; free_set: mailimap_set_free(set); err: return res; }
static int fetch_data_xgmmsgid_parse(mailstream * fd, MMAPString * buffer, size_t * indx, uint64_t * result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; uint64_t msgid; uint32_t uid; char *msgid_str; int r; cur_token = * indx; r = mailimap_number_parse(fd, buffer, &cur_token, &uid); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "FETCH"); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "X-GM-MSGID"); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_astring_parse(fd, buffer, &cur_token, &msgid_str, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) return r; msgid = atol(msgid_str); r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; * indx = cur_token; * result = msgid; return MAILIMAP_NO_ERROR; }
static int fetch_data_xgmthrid_parse(mailstream * fd, MMAPString * buffer, size_t * indx, uint64_t * result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; uint64_t thrid; uint32_t uid; int r; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "X-GM-THRID"); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_uint64_parse(fd, buffer, &cur_token, &thrid); if (r != MAILIMAP_NO_ERROR) return r; * indx = cur_token; * result = thrid; return MAILIMAP_NO_ERROR; }
static int resp_text_code_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_qresync_resptextcode ** result) { int r; size_t cur_token; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "CLOSED"); if (r == MAILIMAP_NO_ERROR) { struct mailimap_qresync_resptextcode * resptextcode; resptextcode = mailimap_qresync_resptextcode_new(MAILIMAP_QRESYNC_RESPTEXTCODE_CLOSED); if (resptextcode == NULL) return MAILIMAP_ERROR_MEMORY; * indx = cur_token; * result = resptextcode; return MAILIMAP_NO_ERROR; } return MAILIMAP_ERROR_PARSE; }
static int mailimap_enable_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_capability_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; int r; int res; struct mailimap_capability_data * capabilities; clist * cap_list; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "ENABLED"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_capability_list_parse(fd, buffer, &cur_token, &cap_list, progr_rate, progr_fun); if (r == MAILIMAP_ERROR_PARSE) { cap_list = clist_new(); if (cap_list == NULL) { res = MAILIMAP_ERROR_MEMORY; goto err; } r = MAILIMAP_NO_ERROR; } if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } capabilities = mailimap_capability_data_new(cap_list); if (capabilities == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_list; } * result = capabilities; * indx = cur_token; return MAILIMAP_NO_ERROR; free_list: if (cap_list) { clist_foreach(cap_list, (clist_func) mailimap_capability_free, NULL); clist_free(cap_list); } err: return res; }
static int fetch_data_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_condstore_fetch_mod_resp ** result) { int r; size_t cur_token; struct mailimap_condstore_fetch_mod_resp * fetch_data; uint64_t value; /* fetch-mod-resp = "MODSEQ" SP "(" permsg-modsequence ")" permsg-modsequence = mod-sequence-value */ cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "MODSEQ"); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_oparenth_parse(fd, buffer, parser_ctx, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_mod_sequence_value_parse(fd, buffer, parser_ctx, &cur_token, &value); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_cparenth_parse(fd, buffer, parser_ctx, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } fetch_data = mailimap_condstore_fetch_mod_resp_new(value); if (fetch_data == NULL) { return MAILIMAP_ERROR_MEMORY; } * indx = cur_token; * result = fetch_data; return MAILIMAP_NO_ERROR; }
static int mailimap_number_list_data_sort_parse(mailstream * fd, MMAPString * buffer, size_t * indx, clist ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; clist * number_list; int r; size_t final_token; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "SORT"); if (r != MAILIMAP_NO_ERROR) { return r; } final_token = cur_token; number_list = NULL; r = mailimap_space_parse(fd, buffer, &cur_token); if (r == MAILIMAP_NO_ERROR) { r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, &number_list, (mailimap_struct_parser *) mailimap_nz_number_alloc_parse, (mailimap_struct_destructor *) mailimap_number_alloc_free, progr_rate, progr_fun); if (r == MAILIMAP_NO_ERROR) { final_token = cur_token; } } * result = number_list; * indx = final_token; return MAILIMAP_NO_ERROR; }
static int mailimap_mailbox_data_xlist_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_mailbox_list ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; struct mailimap_mailbox_list * mb_list; int r; int res; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "XLIST"); if (r != MAILIMAP_NO_ERROR) { res = r; return r; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; return r; } r = mailimap_mailbox_list_parse(fd, buffer, &cur_token, &mb_list, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; return r; } * result = mb_list; * indx = cur_token; return MAILIMAP_NO_ERROR; }
static int mailimap_get_token_value_size(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_token_value * tab, size_t size) { size_t i; int r; #ifdef UNSTRICT_SYNTAX /* can accept unstrict syntax */ r = mailimap_space_parse(fd, buffer, indx); if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) return r; #endif for(i = 0 ; i < size ; i++) { r = mailimap_token_case_insensitive_parse(fd, buffer, indx, tab[i].str); if (r == MAILIMAP_NO_ERROR) return tab[i].value; } return -1; }
static int fetch_data_xgmlabels_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_msg_att_xgmlabels ** result) { size_t cur_token; struct mailimap_msg_att_xgmlabels * att; clist * label_list; int r; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "X-GM-LABELS"); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_xgmlabels_parse(fd, buffer, &cur_token, &label_list); if (r != MAILIMAP_NO_ERROR) return r; att = mailimap_msg_att_xgmlabels_new(label_list); if (att == NULL) { clist_foreach(label_list, (clist_func) mailimap_astring_free, NULL); clist_free(label_list); return MAILIMAP_ERROR_MEMORY; } * indx = cur_token; * result = att; return MAILIMAP_NO_ERROR; }
static int search_data_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_condstore_search ** result) { int r; clist * number_list; struct mailimap_condstore_search * search_data; size_t cur_token; int res; uint64_t value; cur_token = * indx; /* mailbox-data =/ "SEARCH" [1*(SP nz-number) SP search-sort-mod-seq] search-sort-mod-seq = "(" "MODSEQ" SP mod-sequence-value ")" */ r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "SEARCH"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; return r; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_struct_spaced_list_parse(fd, buffer, parser_ctx, &cur_token, &number_list, (mailimap_struct_parser *) mailimap_nz_number_alloc_parse, (mailimap_struct_destructor *) mailimap_number_alloc_free, 0, NULL); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_number_list; } r = mailimap_oparenth_parse(fd, buffer, parser_ctx, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_number_list; } r = mailimap_mod_sequence_value_parse(fd, buffer, parser_ctx, &cur_token, &value); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_number_list; } r = mailimap_cparenth_parse(fd, buffer, parser_ctx, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_number_list; } search_data = mailimap_condstore_search_new(number_list, value); if (search_data == NULL) { res = r; goto free_number_list; } * indx = cur_token; * result = search_data; return MAILIMAP_NO_ERROR; free_number_list: clist_foreach(number_list, (clist_func) free, NULL); clist_free(number_list); err: return res; }
static int resp_text_code_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_condstore_resptextcode ** result) { size_t cur_token; struct mailimap_condstore_resptextcode * resptextcode; int r; cur_token = * indx; /* resp-text-code =/ "HIGHESTMODSEQ" SP mod-sequence-value / "NOMODSEQ" / "MODIFIED" SP set */ r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "HIGHESTMODSEQ"); if (r == MAILIMAP_NO_ERROR) { uint64_t value; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_mod_sequence_value_parse(fd, buffer, parser_ctx, &cur_token, &value); if (r != MAILIMAP_NO_ERROR) { return r; } resptextcode = mailimap_condstore_resptextcode_new(MAILIMAP_CONDSTORE_RESPTEXTCODE_HIGHESTMODSEQ, value, NULL); if (resptextcode == NULL) return MAILIMAP_ERROR_MEMORY; * indx = cur_token; * result = resptextcode; return MAILIMAP_NO_ERROR; } r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "NOMODSEQ"); if (r == MAILIMAP_NO_ERROR) { resptextcode = mailimap_condstore_resptextcode_new(MAILIMAP_CONDSTORE_RESPTEXTCODE_NOMODSEQ, 0, NULL); if (resptextcode == NULL) return MAILIMAP_ERROR_MEMORY; * indx = cur_token; * result = resptextcode; return MAILIMAP_NO_ERROR; } r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "MODIFIED"); if (r == MAILIMAP_NO_ERROR) { struct mailimap_set * set; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_set_parse(fd, buffer, parser_ctx, &cur_token, &set); if (r != MAILIMAP_NO_ERROR) { return r; } resptextcode = mailimap_condstore_resptextcode_new(MAILIMAP_CONDSTORE_RESPTEXTCODE_MODIFIED, 0, set); if (resptextcode == NULL) { mailimap_set_free(set); return MAILIMAP_ERROR_MEMORY; } * indx = cur_token; * result = resptextcode; return MAILIMAP_NO_ERROR; } return MAILIMAP_ERROR_PARSE; }
int mailimap_acl_acl_data_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_acl_acl_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; char * mailbox; clist * ir_list; struct mailimap_acl_acl_data * acl_data; int r; int res; cur_token = * indx; mailbox = NULL; /* XXX - removes a gcc warning */ r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "ACL"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_mailbox_parse(fd, buffer, parser_ctx, &cur_token, &mailbox, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto mailbox_free; } r = mailimap_struct_spaced_list_parse(fd, buffer, parser_ctx, &cur_token, &ir_list, (mailimap_struct_parser * ) mailimap_acl_identifier_rights_parse, (mailimap_struct_destructor * ) mailimap_acl_identifier_rights_free, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto mailbox_free; } acl_data = mailimap_acl_acl_data_new(mailbox, ir_list); if (acl_data == NULL) { res = MAILIMAP_ERROR_MEMORY; goto ir_list_free; } * result = acl_data; * indx = cur_token; return MAILIMAP_NO_ERROR; ir_list_free: if (ir_list != NULL) { clist_foreach(ir_list, (clist_func) mailimap_acl_identifier_rights_free, NULL); clist_free(ir_list); } mailbox_free: mailimap_mailbox_free(mailbox); err: return res; }
int mailimap_acl_myrights_data_parse(mailstream * fd, MMAPString * buffer, struct mailimap_parser_context * parser_ctx, size_t * indx, struct mailimap_acl_myrights_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; char * mailbox; char * rights; struct mailimap_acl_myrights_data * mr_data; int r; int res; cur_token = * indx; mailbox = NULL; /* XXX - removes a gcc warning */ rights = NULL; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "MYRIGHTS"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_mailbox_parse(fd, buffer, parser_ctx, &cur_token, &mailbox, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto mailbox_free; } r = mailimap_acl_rights_parse(fd, buffer, parser_ctx, &cur_token, &rights, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto mailbox_free; } mr_data = mailimap_acl_myrights_data_new(mailbox, rights); if (mr_data == NULL) { res = MAILIMAP_ERROR_MEMORY; goto rights_free; } * result = mr_data; * indx = cur_token; return MAILIMAP_NO_ERROR; rights_free: mailimap_acl_rights_free(rights); mailbox_free: mailimap_mailbox_free(mailbox); err: return res; }
static int mailimap_namespace_data_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_namespace_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; int r; int res; struct mailimap_namespace_item * personal_namespace; struct mailimap_namespace_item * other_namespace; struct mailimap_namespace_item * shared_namespace; struct mailimap_namespace_data * ns; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "NAMESPACE"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_namespace_item_parse(fd, buffer, &cur_token, &personal_namespace, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_namespace_item_parse(fd, buffer, &cur_token, &other_namespace, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_personal; } r = mailimap_namespace_item_parse(fd, buffer, &cur_token, &shared_namespace, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_other; } ns = mailimap_namespace_data_new(personal_namespace, other_namespace, shared_namespace); if (ns == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_shared; } * result = ns; * indx = cur_token; return MAILIMAP_NO_ERROR; free_shared: mailimap_namespace_item_free(shared_namespace); free_other: mailimap_namespace_item_free(other_namespace); free_personal: mailimap_namespace_item_free(personal_namespace); err: return res; }
int mailimap_quota_quota_response_parse(mailstream * fd, MMAPString *buffer, size_t * indx, struct mailimap_quota_quota_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; char * quotaroot; clist * quota_list; struct mailimap_quota_quota_data * quota_data; int r; int res; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "QUOTA"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_astring_parse(fd, buffer, &cur_token, "aroot, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto quotaroot_free; } r = mailimap_quota_quota_list_parse(fd, buffer, &cur_token, "a_list, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto quotaroot_free; } quota_data = mailimap_quota_quota_data_new(quotaroot, quota_list); if (quota_data == NULL) { res = MAILIMAP_ERROR_MEMORY; goto quota_list_free; } * result = quota_data; * indx = cur_token; return MAILIMAP_NO_ERROR; quota_list_free: clist_foreach(quota_list, (clist_func) &mailimap_quota_quota_resource_free, NULL); clist_free(quota_list); quotaroot_free: mailimap_astring_free(quotaroot); err: return res; }
int mailimap_acl_listrights_data_parse(mailstream * fd, MMAPString *buffer, size_t * indx, struct mailimap_acl_listrights_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; char * mailbox; char * identifier; clist * rights_list; struct mailimap_acl_listrights_data * lr_data; int r; int res; cur_token = * indx; mailbox = NULL; /* XXX - removes a gcc warning */ identifier = NULL; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "LISTRIGHTS"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_mailbox_parse(fd, buffer, &cur_token, &mailbox, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto mailbox_free; } r = mailimap_acl_identifier_parse(fd, buffer, &cur_token, &identifier, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto mailbox_free; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto identifier_free; } r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, &rights_list, (mailimap_struct_parser * ) mailimap_acl_rights_parse, (mailimap_struct_destructor * ) mailimap_acl_rights_free, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto identifier_free; } lr_data = mailimap_acl_listrights_data_new(mailbox, identifier, rights_list); if (lr_data == NULL) { res = MAILIMAP_ERROR_MEMORY; goto rights_list_free; } * result = lr_data; * indx = cur_token; return MAILIMAP_NO_ERROR; rights_list_free: if (rights_list != NULL) { clist_foreach(rights_list, (clist_func) mailimap_acl_rights_free, NULL); clist_free(rights_list); } identifier_free: mailimap_acl_identifier_free(identifier); mailbox_free: mailimap_mailbox_free(mailbox); err: return res; }
int mailimap_quota_quotaroot_response_parse(mailstream * fd, MMAPString *buffer, size_t * indx, struct mailimap_quota_quotaroot_data ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; char * mailbox; char * quotaroot; clist * quotaroot_list; struct mailimap_quota_quotaroot_data * quotaroot_data; int r; int res; cur_token = * indx; r = mailimap_token_case_insensitive_parse(fd, buffer, &cur_token, "QUOTAROOT"); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_mailbox_parse(fd, buffer, &cur_token, &mailbox, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } quotaroot_list = clist_new(); if (!quotaroot_list) { res = MAILIMAP_ERROR_MEMORY; goto mailbox_free; } for (;;) { r = mailimap_space_parse(fd, buffer, &cur_token); if (r == MAILIMAP_ERROR_PARSE) { break; } else if (r != MAILIMAP_NO_ERROR) { res = r; goto quotaroot_list_free; } r = mailimap_astring_parse(fd, buffer, &cur_token, "aroot, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto quotaroot_list_free; } if (clist_append(quotaroot_list, quotaroot) < 0) { mailimap_astring_free(quotaroot); res = MAILIMAP_ERROR_MEMORY; goto quotaroot_list_free; } } quotaroot_data = mailimap_quota_quotaroot_data_new(mailbox, quotaroot_list); if (quotaroot_data == NULL) { res = MAILIMAP_ERROR_MEMORY; goto quotaroot_list_free; } * result = quotaroot_data; * indx = cur_token; return MAILIMAP_NO_ERROR; quotaroot_list_free: clist_foreach(quotaroot_list, (clist_func) &mailimap_astring_free, NULL); clist_free(quotaroot_list); mailbox_free: mailimap_mailbox_free(mailbox); err: return res; }