xref: /third_party/curl/lib/imap.h (revision 13498266)
113498266Sopenharmony_ci#ifndef HEADER_CURL_IMAP_H
213498266Sopenharmony_ci#define HEADER_CURL_IMAP_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci
2713498266Sopenharmony_ci#include "pingpong.h"
2813498266Sopenharmony_ci#include "curl_sasl.h"
2913498266Sopenharmony_ci
3013498266Sopenharmony_ci/****************************************************************************
3113498266Sopenharmony_ci * IMAP unique setup
3213498266Sopenharmony_ci ***************************************************************************/
3313498266Sopenharmony_citypedef enum {
3413498266Sopenharmony_ci  IMAP_STOP,         /* do nothing state, stops the state machine */
3513498266Sopenharmony_ci  IMAP_SERVERGREET,  /* waiting for the initial greeting immediately after
3613498266Sopenharmony_ci                        a connect */
3713498266Sopenharmony_ci  IMAP_CAPABILITY,
3813498266Sopenharmony_ci  IMAP_STARTTLS,
3913498266Sopenharmony_ci  IMAP_UPGRADETLS,   /* asynchronously upgrade the connection to SSL/TLS
4013498266Sopenharmony_ci                       (multi mode only) */
4113498266Sopenharmony_ci  IMAP_AUTHENTICATE,
4213498266Sopenharmony_ci  IMAP_LOGIN,
4313498266Sopenharmony_ci  IMAP_LIST,
4413498266Sopenharmony_ci  IMAP_SELECT,
4513498266Sopenharmony_ci  IMAP_FETCH,
4613498266Sopenharmony_ci  IMAP_FETCH_FINAL,
4713498266Sopenharmony_ci  IMAP_APPEND,
4813498266Sopenharmony_ci  IMAP_APPEND_FINAL,
4913498266Sopenharmony_ci  IMAP_SEARCH,
5013498266Sopenharmony_ci  IMAP_LOGOUT,
5113498266Sopenharmony_ci  IMAP_LAST          /* never used */
5213498266Sopenharmony_ci} imapstate;
5313498266Sopenharmony_ci
5413498266Sopenharmony_ci/* This IMAP struct is used in the Curl_easy. All IMAP data that is
5513498266Sopenharmony_ci   connection-oriented must be in imap_conn to properly deal with the fact that
5613498266Sopenharmony_ci   perhaps the Curl_easy is changed between the times the connection is
5713498266Sopenharmony_ci   used. */
5813498266Sopenharmony_cistruct IMAP {
5913498266Sopenharmony_ci  curl_pp_transfer transfer;
6013498266Sopenharmony_ci  char *mailbox;          /* Mailbox to select */
6113498266Sopenharmony_ci  char *uidvalidity;      /* UIDVALIDITY to check in select */
6213498266Sopenharmony_ci  char *uid;              /* Message UID to fetch */
6313498266Sopenharmony_ci  char *mindex;           /* Index in mail box of mail to fetch */
6413498266Sopenharmony_ci  char *section;          /* Message SECTION to fetch */
6513498266Sopenharmony_ci  char *partial;          /* Message PARTIAL to fetch */
6613498266Sopenharmony_ci  char *query;            /* Query to search for */
6713498266Sopenharmony_ci  char *custom;           /* Custom request */
6813498266Sopenharmony_ci  char *custom_params;    /* Parameters for the custom request */
6913498266Sopenharmony_ci};
7013498266Sopenharmony_ci
7113498266Sopenharmony_ci/* imap_conn is used for struct connection-oriented data in the connectdata
7213498266Sopenharmony_ci   struct */
7313498266Sopenharmony_cistruct imap_conn {
7413498266Sopenharmony_ci  struct pingpong pp;
7513498266Sopenharmony_ci  struct SASL sasl;           /* SASL-related parameters */
7613498266Sopenharmony_ci  struct dynbuf dyn;          /* for the IMAP commands */
7713498266Sopenharmony_ci  char *mailbox;              /* The last selected mailbox */
7813498266Sopenharmony_ci  char *mailbox_uidvalidity;  /* UIDVALIDITY parsed from select response */
7913498266Sopenharmony_ci  imapstate state;            /* Always use imap.c:state() to change state! */
8013498266Sopenharmony_ci  char resptag[5];            /* Response tag to wait for */
8113498266Sopenharmony_ci  unsigned char preftype;     /* Preferred authentication type */
8213498266Sopenharmony_ci  unsigned char cmdid;        /* Last used command ID */
8313498266Sopenharmony_ci  BIT(ssldone);               /* Is connect() over SSL done? */
8413498266Sopenharmony_ci  BIT(preauth);               /* Is this connection PREAUTH? */
8513498266Sopenharmony_ci  BIT(tls_supported);         /* StartTLS capability supported by server */
8613498266Sopenharmony_ci  BIT(login_disabled);        /* LOGIN command disabled by server */
8713498266Sopenharmony_ci  BIT(ir_supported);          /* Initial response supported by server */
8813498266Sopenharmony_ci};
8913498266Sopenharmony_ci
9013498266Sopenharmony_ciextern const struct Curl_handler Curl_handler_imap;
9113498266Sopenharmony_ciextern const struct Curl_handler Curl_handler_imaps;
9213498266Sopenharmony_ci
9313498266Sopenharmony_ci/* Authentication type flags */
9413498266Sopenharmony_ci#define IMAP_TYPE_CLEARTEXT (1 << 0)
9513498266Sopenharmony_ci#define IMAP_TYPE_SASL      (1 << 1)
9613498266Sopenharmony_ci
9713498266Sopenharmony_ci/* Authentication type values */
9813498266Sopenharmony_ci#define IMAP_TYPE_NONE      0
9913498266Sopenharmony_ci#define IMAP_TYPE_ANY       (IMAP_TYPE_CLEARTEXT|IMAP_TYPE_SASL)
10013498266Sopenharmony_ci
10113498266Sopenharmony_ci#endif /* HEADER_CURL_IMAP_H */
102