2
0

imap.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef HEADER_CURL_IMAP_H
  2. #define HEADER_CURL_IMAP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2009 - 2014, 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 http://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. /****************************************************************************
  26. * IMAP unique setup
  27. ***************************************************************************/
  28. typedef enum {
  29. IMAP_STOP, /* do nothing state, stops the state machine */
  30. IMAP_SERVERGREET, /* waiting for the initial greeting immediately after
  31. a connect */
  32. IMAP_CAPABILITY,
  33. IMAP_STARTTLS,
  34. IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
  35. (multi mode only) */
  36. IMAP_AUTHENTICATE_PLAIN,
  37. IMAP_AUTHENTICATE_LOGIN,
  38. IMAP_AUTHENTICATE_LOGIN_PASSWD,
  39. IMAP_AUTHENTICATE_CRAMMD5,
  40. IMAP_AUTHENTICATE_DIGESTMD5,
  41. IMAP_AUTHENTICATE_DIGESTMD5_RESP,
  42. IMAP_AUTHENTICATE_NTLM,
  43. IMAP_AUTHENTICATE_NTLM_TYPE2MSG,
  44. IMAP_AUTHENTICATE_GSSAPI,
  45. IMAP_AUTHENTICATE_GSSAPI_TOKEN,
  46. IMAP_AUTHENTICATE_GSSAPI_NO_DATA,
  47. IMAP_AUTHENTICATE_XOAUTH2,
  48. IMAP_AUTHENTICATE_CANCEL,
  49. IMAP_AUTHENTICATE_FINAL,
  50. IMAP_LOGIN,
  51. IMAP_LIST,
  52. IMAP_SELECT,
  53. IMAP_FETCH,
  54. IMAP_FETCH_FINAL,
  55. IMAP_APPEND,
  56. IMAP_APPEND_FINAL,
  57. IMAP_SEARCH,
  58. IMAP_LOGOUT,
  59. IMAP_LAST /* never used */
  60. } imapstate;
  61. /* This IMAP struct is used in the SessionHandle. All IMAP data that is
  62. connection-oriented must be in imap_conn to properly deal with the fact that
  63. perhaps the SessionHandle is changed between the times the connection is
  64. used. */
  65. struct IMAP {
  66. curl_pp_transfer transfer;
  67. char *mailbox; /* Mailbox to select */
  68. char *uidvalidity; /* UIDVALIDITY to check in select */
  69. char *uid; /* Message UID to fetch */
  70. char *section; /* Message SECTION to fetch */
  71. char *partial; /* Message PARTIAL to fetch */
  72. char *query; /* Query to search for */
  73. char *custom; /* Custom request */
  74. char *custom_params; /* Parameters for the custom request */
  75. };
  76. /* imap_conn is used for struct connection-oriented data in the connectdata
  77. struct */
  78. struct imap_conn {
  79. struct pingpong pp;
  80. imapstate state; /* Always use imap.c:state() to change state! */
  81. bool ssldone; /* Is connect() over SSL done? */
  82. unsigned int authmechs; /* Accepted authentication mechanisms */
  83. unsigned int preftype; /* Preferred authentication type */
  84. unsigned int prefmech; /* Preferred authentication mechanism */
  85. unsigned int authused; /* Auth mechanism used for the connection */
  86. int cmdid; /* Last used command ID */
  87. char resptag[5]; /* Response tag to wait for */
  88. bool tls_supported; /* StartTLS capability supported by server */
  89. bool login_disabled; /* LOGIN command disabled by server */
  90. bool ir_supported; /* Initial response supported by server */
  91. bool mutual_auth; /* Mutual authentication enabled (GSSAPI only) */
  92. char *mailbox; /* The last selected mailbox */
  93. char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */
  94. };
  95. extern const struct Curl_handler Curl_handler_imap;
  96. extern const struct Curl_handler Curl_handler_imaps;
  97. /* Authentication type flags */
  98. #define IMAP_TYPE_CLEARTEXT (1 << 0)
  99. #define IMAP_TYPE_SASL (1 << 1)
  100. /* Authentication type values */
  101. #define IMAP_TYPE_NONE 0
  102. #define IMAP_TYPE_ANY ~0U
  103. #endif /* HEADER_CURL_IMAP_H */