int mailimap_quota_quota_list_empty_parse(mailstream * fd, MMAPString *buffer, size_t * indx, clist ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; int r; clist * quota_resource_list; cur_token = * indx; r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } quota_resource_list = clist_new(); if (!quota_resource_list) { return MAILIMAP_ERROR_MEMORY; } * result = quota_resource_list; * indx = cur_token; return MAILIMAP_NO_ERROR; }
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 mailimap_xgmlabels_parse(mailstream * fd, MMAPString * buffer, size_t * indx, clist ** result) { size_t cur_token; clist * list; int r; int res; cur_token = * indx; r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, &list, (mailimap_struct_parser * ) mailimap_astring_parse, (mailimap_struct_destructor * ) mailimap_astring_free, 0, NULL); if (r == MAILIMAP_ERROR_PARSE) { list = clist_new(); if (list == NULL) { res = MAILIMAP_ERROR_MEMORY; goto err; } } else if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_list; } * indx = cur_token; * result = list; return MAILIMAP_NO_ERROR; free_list: clist_foreach(list, (clist_func) mailimap_astring_free, NULL); clist_free(list); err: return res; }
int mailimap_quota_quota_list_nonempty_parse(mailstream * fd, MMAPString *buffer, size_t * indx, clist ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; int r; int res; clist * quota_resource_list; cur_token = * indx; r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, "a_resource_list, &mailimap_quota_quota_resource_parse, (mailimap_struct_destructor *) &mailimap_quota_quota_resource_free, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto quota_list_free; } * result = quota_resource_list; * indx = cur_token; return MAILIMAP_NO_ERROR; quota_list_free: clist_foreach(quota_resource_list, (clist_func) &mailimap_quota_quota_resource_free, NULL); clist_free(quota_resource_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 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 mailimap_namespace_response_extension_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_namespace_response_extension ** result, size_t progr_rate, progress_function * progr_fun) { int r; int res; size_t cur_token; char * name; size_t name_len; clist * value_list; struct mailimap_namespace_response_extension * ext; clistiter * cur; cur_token = * indx; r = mailimap_space_parse(fd, buffer, &cur_token); if (r == MAILIMAP_ERROR_PARSE) { /* do nothing */ } r = mailimap_string_parse(fd, buffer, &cur_token, &name, &name_len, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r == MAILIMAP_ERROR_PARSE) { /* do nothing */ } r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_struct_spaced_list_parse(fd, buffer, &cur_token, &value_list, (mailimap_struct_parser *) namespace_extension_value_parse, (mailimap_struct_destructor *) mailimap_string_free, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_name; } r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_value_list; } ext = mailimap_namespace_response_extension_new(name, value_list); if (ext == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_value_list; } * indx = cur_token; * result = ext; return MAILIMAP_NO_ERROR; free_value_list: for(cur = clist_begin(value_list) ; cur != NULL ; cur = clist_next(cur)) { char * value; value = clist_content(cur); mailimap_string_free(value); } clist_free(value_list); free_name: mailimap_string_free(name); err: return res; }
static int mailimap_namespace_item_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_namespace_item ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token = * indx; int r; int res; clist * info_list; clistiter * cur; struct mailimap_namespace_item * item; r = mailimap_nil_parse(fd, buffer, &cur_token); if (r == MAILIMAP_NO_ERROR) { * indx = cur_token; * result = NULL; return MAILIMAP_NO_ERROR; } r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { return r; } r = mailimap_struct_multiple_parse(fd, buffer, &cur_token, &info_list, (mailimap_struct_parser *) mailimap_namespace_info_parse, (mailimap_struct_destructor *) mailimap_namespace_info_free, progr_rate, progr_fun); if (r == MAILIMAP_ERROR_PARSE) { res = r; goto err; } r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_info_list; } item = mailimap_namespace_item_new(info_list); if (item == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_info_list; } * indx = cur_token; * result = item; return MAILIMAP_NO_ERROR; free_info_list: for(cur = clist_begin(info_list) ; cur != NULL ; cur = clist_next(cur)) { struct mailimap_namespace_info * info; info = clist_content(cur); mailimap_namespace_info_free(info); } clist_free(info_list); err: return res; }
static int mailimap_namespace_info_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_namespace_info ** result, size_t progr_rate, progress_function * progr_fun) { size_t cur_token = * indx; int r; int res; char * prefix; size_t prefix_len; clistiter * cur; clist * ext_list; char delimiter; struct mailimap_namespace_info * info; r = mailimap_oparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_string_parse(fd, buffer, &cur_token, &prefix, &prefix_len, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) { res = r; goto err; } r = mailimap_space_parse(fd, buffer, &cur_token); if (r == MAILIMAP_ERROR_PARSE) { /* do nothing */ } r = mailimap_nil_parse(fd, buffer, &cur_token); if (r == MAILIMAP_NO_ERROR) { delimiter = 0; } else { r = mailimap_dquote_parse(fd, buffer, &cur_token); if (r == MAILIMAP_ERROR_PARSE) { res = r; goto free_prefix; } r = mailimap_quoted_char_parse(fd, buffer, &cur_token, &delimiter); if (r == MAILIMAP_ERROR_PARSE) { res = r; goto free_prefix; } r = mailimap_dquote_parse(fd, buffer, &cur_token); if (r == MAILIMAP_ERROR_PARSE) { res = r; goto free_prefix; } } r = mailimap_cparenth_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) { res = r; goto free_ext; } r = mailimap_struct_multiple_parse(fd, buffer, &cur_token, &ext_list, (mailimap_struct_parser *) mailimap_namespace_response_extension_parse, (mailimap_struct_destructor *) mailimap_namespace_response_extension_free, progr_rate, progr_fun); if (r == MAILIMAP_ERROR_PARSE) { ext_list = NULL; } else if (r != MAILIMAP_NO_ERROR) { res = r; goto free_prefix; } info = mailimap_namespace_info_new(prefix, delimiter, ext_list); if (info == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_ext; } * result = info; * indx = cur_token; return MAILIMAP_NO_ERROR; free_ext: if (ext_list != NULL) { for(cur = clist_begin(ext_list) ; cur != NULL ; cur = clist_next(cur)) { struct mailimap_namespace_response_extension * ext; ext = clist_content(cur); mailimap_namespace_response_extension_free(ext); } clist_free(ext_list); } free_prefix: mailimap_string_free(prefix); err: return res; }