imap.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef HEADER_CURL_IMAP_H
  2. #define HEADER_CURL_IMAP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2009 - 2019, Daniel Stenberg, <daniel@haxx.se>, 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.haxx.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. ***************************************************************************/
  24. #include "pingpong.h"
  25. #include "curl_sasl.h"
  26. /****************************************************************************
  27. * IMAP unique setup
  28. ***************************************************************************/
  29. typedef enum {
  30. IMAP_STOP, /* do nothing state, stops the state machine */
  31. IMAP_SERVERGREET, /* waiting for the initial greeting immediately after
  32. a connect */
  33. IMAP_CAPABILITY,
  34. IMAP_STARTTLS,
  35. IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
  36. (multi mode only) */
  37. IMAP_AUTHENTICATE,
  38. IMAP_LOGIN,
  39. IMAP_LIST,
  40. IMAP_SELECT,
  41. IMAP_FETCH,
  42. IMAP_FETCH_FINAL,
  43. IMAP_APPEND,
  44. IMAP_APPEND_FINAL,
  45. IMAP_SEARCH,
  46. IMAP_LOGOUT,
  47. IMAP_LAST /* never used */
  48. } imapstate;
  49. /* This IMAP struct is used in the Curl_easy. All IMAP data that is
  50. connection-oriented must be in imap_conn to properly deal with the fact that
  51. perhaps the Curl_easy is changed between the times the connection is
  52. used. */
  53. struct IMAP {
  54. curl_pp_transfer transfer;
  55. char *mailbox; /* Mailbox to select */
  56. char *uidvalidity; /* UIDVALIDITY to check in select */
  57. char *uid; /* Message UID to fetch */
  58. char *mindex; /* Index in mail box of mail to fetch */
  59. char *section; /* Message SECTION to fetch */
  60. char *partial; /* Message PARTIAL to fetch */
  61. char *query; /* Query to search for */
  62. char *custom; /* Custom request */
  63. char *custom_params; /* Parameters for the custom request */
  64. };
  65. /* imap_conn is used for struct connection-oriented data in the connectdata
  66. struct */
  67. struct imap_conn {
  68. struct pingpong pp;
  69. imapstate state; /* Always use imap.c:state() to change state! */
  70. bool ssldone; /* Is connect() over SSL done? */
  71. bool preauth; /* Is this connection PREAUTH? */
  72. struct SASL sasl; /* SASL-related parameters */
  73. unsigned int preftype; /* Preferred authentication type */
  74. int cmdid; /* Last used command ID */
  75. char resptag[5]; /* Response tag to wait for */
  76. bool tls_supported; /* StartTLS capability supported by server */
  77. bool login_disabled; /* LOGIN command disabled by server */
  78. bool ir_supported; /* Initial response supported by server */
  79. char *mailbox; /* The last selected mailbox */
  80. char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */
  81. };
  82. extern const struct Curl_handler Curl_handler_imap;
  83. extern const struct Curl_handler Curl_handler_imaps;
  84. /* Authentication type flags */
  85. #define IMAP_TYPE_CLEARTEXT (1 << 0)
  86. #define IMAP_TYPE_SASL (1 << 1)
  87. /* Authentication type values */
  88. #define IMAP_TYPE_NONE 0
  89. #define IMAP_TYPE_ANY ~0U
  90. #endif /* HEADER_CURL_IMAP_H */