static int mailimap_id_param_send(mailstream * fd, struct mailimap_id_param * param) { int r; r = mailimap_astring_send(fd, param->idpa_name); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; if (param->idpa_value == NULL) { r = mailimap_token_send(fd, "NIL"); if (r != MAILIMAP_NO_ERROR) return r; } else { r = mailimap_astring_send(fd, param->idpa_value); if (r != MAILIMAP_NO_ERROR) return r; } return MAILIMAP_NO_ERROR; }
int mailimap_sort_send(mailstream * fd, const char * charset, struct mailimap_sort_key * key, struct mailimap_search_key * searchkey) { int r; r = mailimap_token_send(fd, "SORT"); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_oparenth_send(fd); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_sort_key_send(fd, key); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_cparenth_send(fd); if (r != MAILIMAP_NO_ERROR) return r; if (charset != NULL) { r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_astring_send(fd, charset); if (r != MAILIMAP_NO_ERROR) return r; } r = mailimap_space_send(fd); if (r != MAILIMAP_NO_ERROR) return r; if (searchkey != NULL) { r = mailimap_search_key_send(fd, searchkey); if (r != MAILIMAP_NO_ERROR) return r; } return MAILIMAP_NO_ERROR; }
static int mailimap_acl_mod_rights_send(mailstream * fd, const char * mod_rights) { return mailimap_astring_send(fd, mod_rights); }
int mailimap_oauth2_authenticate_send(mailimap * session, const char * auth_user, const char * access_token) { int r; char * ptr; char * full_auth_string; char * full_auth_string_b64; int auth_user_len; int access_token_len; int full_auth_string_len; int res; full_auth_string = NULL; full_auth_string_b64 = NULL; /* Build client response string */ auth_user_len = strlen(auth_user); access_token_len = strlen(access_token); full_auth_string_len = 5 + auth_user_len + 1 + 12 + access_token_len + 2; full_auth_string = malloc(full_auth_string_len + 1); if (full_auth_string == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free; } ptr = memcpy(full_auth_string, "user="******"\1auth=Bearer ", 13); ptr = memcpy(ptr + 13, access_token, access_token_len); ptr = memcpy(ptr + access_token_len, "\1\1\0", 3); /* Convert to base64 */ full_auth_string_b64 = encode_base64(full_auth_string, full_auth_string_len); if (full_auth_string_b64 == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free; } r = mailimap_token_send(session->imap_stream, "AUTHENTICATE"); if (r != MAILIMAP_NO_ERROR) { res = r; goto free; } r = mailimap_space_send(session->imap_stream); if (r != MAILIMAP_NO_ERROR) { res = r; goto free; } r = mailimap_token_send(session->imap_stream, "XOAUTH2"); if (r != MAILIMAP_NO_ERROR) { res = r; goto free; } r = mailimap_space_send(session->imap_stream); if (r != MAILIMAP_NO_ERROR) { res = r; goto free; } r = mailimap_astring_send(session->imap_stream, full_auth_string_b64); if (r != MAILIMAP_NO_ERROR) { res = r; goto free; } res = MAILIMAP_NO_ERROR; free: free(full_auth_string); free(full_auth_string_b64); return res; }
static int mailimap_acl_identifier_send(mailstream * fd, const char * identifier) { return mailimap_astring_send(fd, identifier); }