| 1999 | } |
| 2000 | |
| 2001 | static int |
| 2002 | fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier, |
| 2003 | struct mailimap_fetch_type * fetch_type, |
| 2004 | char ** result, size_t * result_len) |
| 2005 | { |
| 2006 | int r; |
| 2007 | struct mailimap_msg_att * msg_att; |
| 2008 | struct mailimap_msg_att_item * msg_att_item; |
| 2009 | clist * fetch_result; |
| 2010 | struct mailimap_set * set; |
| 2011 | char * text; |
| 2012 | size_t text_length; |
| 2013 | clistiter * cur; |
| 2014 | |
| 2015 | set = mailimap_set_new_single(identifier); |
| 2016 | if (identifier_is_uid) { |
| 2017 | r = mailimap_uid_fetch(imap, set, fetch_type, &fetch_result); |
| 2018 | } |
| 2019 | else { |
| 2020 | r = mailimap_fetch(imap, set, fetch_type, &fetch_result); |
| 2021 | } |
| 2022 | |
| 2023 | mailimap_set_free(set); |
| 2024 | |
| 2025 | switch (r) { |
| 2026 | case MAILIMAP_NO_ERROR: |
| 2027 | break; |
| 2028 | default: |
| 2029 | return r; |
| 2030 | } |
| 2031 | |
| 2032 | if (clist_isempty(fetch_result)) { |
| 2033 | mailimap_fetch_list_free(fetch_result); |
| 2034 | return MAILIMAP_ERROR_FETCH; |
| 2035 | } |
| 2036 | |
| 2037 | msg_att = (struct mailimap_msg_att *) clist_begin(fetch_result)->data; |
| 2038 | |
| 2039 | text = NULL; |
| 2040 | text_length = 0; |
| 2041 | |
| 2042 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; |
| 2043 | cur = clist_next(cur)) { |
| 2044 | msg_att_item = (struct mailimap_msg_att_item *) clist_content(cur); |
| 2045 | |
| 2046 | if (msg_att_item->att_type != MAILIMAP_MSG_ATT_ITEM_STATIC) { |
| 2047 | continue; |
| 2048 | } |
| 2049 | |
| 2050 | if (msg_att_item->att_data.att_static->att_type != |
| 2051 | MAILIMAP_MSG_ATT_BODY_SECTION) { |
| 2052 | continue; |
| 2053 | } |
| 2054 | |
| 2055 | text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
| 2056 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = NULL; |
| 2057 | text_length = msg_att_item->att_data.att_static->att_data.att_body_section->sec_length; |
| 2058 | } |
no outgoing calls
no test coverage detected