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_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_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; }
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; }