1#ifndef HEADER_CURL_IMAP_H
2#define HEADER_CURL_IMAP_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 2009 - 2022, Daniel Stenberg, <[email protected]>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26
27#include "pingpong.h"
28#include "curl_sasl.h"
29
30/****************************************************************************
31 * IMAP unique setup
32 ***************************************************************************/
33typedef enum {
34 IMAP_STOP, /* do nothing state, stops the state machine */
35 IMAP_SERVERGREET, /* waiting for the initial greeting immediately after
36 a connect */
37 IMAP_CAPABILITY,
38 IMAP_STARTTLS,
39 IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
40 (multi mode only) */
41 IMAP_AUTHENTICATE,
42 IMAP_LOGIN,
43 IMAP_LIST,
44 IMAP_SELECT,
45 IMAP_FETCH,
46 IMAP_FETCH_FINAL,
47 IMAP_APPEND,
48 IMAP_APPEND_FINAL,
49 IMAP_SEARCH,
50 IMAP_LOGOUT,
51 IMAP_LAST /* never used */
52} imapstate;
53
54/* This IMAP struct is used in the Curl_easy. All IMAP data that is
55 connection-oriented must be in imap_conn to properly deal with the fact that
56 perhaps the Curl_easy is changed between the times the connection is
57 used. */
58struct IMAP {
59 curl_pp_transfer transfer;
60 char *mailbox; /* Mailbox to select */
61 char *uidvalidity; /* UIDVALIDITY to check in select */
62 char *uid; /* Message UID to fetch */
63 char *mindex; /* Index in mail box of mail to fetch */
64 char *section; /* Message SECTION to fetch */
65 char *partial; /* Message PARTIAL to fetch */
66 char *query; /* Query to search for */
67 char *custom; /* Custom request */
68 char *custom_params; /* Parameters for the custom request */
69};
70
71/* imap_conn is used for struct connection-oriented data in the connectdata
72 struct */
73struct imap_conn {
74 struct pingpong pp;
75 imapstate state; /* Always use imap.c:state() to change state! */
76 bool ssldone; /* Is connect() over SSL done? */
77 bool preauth; /* Is this connection PREAUTH? */
78 struct SASL sasl; /* SASL-related parameters */
79 unsigned int preftype; /* Preferred authentication type */
80 unsigned int cmdid; /* Last used command ID */
81 char resptag[5]; /* Response tag to wait for */
82 bool tls_supported; /* StartTLS capability supported by server */
83 bool login_disabled; /* LOGIN command disabled by server */
84 bool ir_supported; /* Initial response supported by server */
85 char *mailbox; /* The last selected mailbox */
86 char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */
87 struct dynbuf dyn; /* for the IMAP commands */
88};
89
90extern const struct Curl_handler Curl_handler_imap;
91extern const struct Curl_handler Curl_handler_imaps;
92
93/* Authentication type flags */
94#define IMAP_TYPE_CLEARTEXT (1 << 0)
95#define IMAP_TYPE_SASL (1 << 1)
96
97/* Authentication type values */
98#define IMAP_TYPE_NONE 0
99#define IMAP_TYPE_ANY ~0U
100
101#endif /* HEADER_CURL_IMAP_H */
102