pop3.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef HEADER_CURL_POP3_H
  2. #define HEADER_CURL_POP3_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2009 - 2020, 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.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. * POP3 unique setup
  28. ***************************************************************************/
  29. typedef enum {
  30. POP3_STOP, /* do nothing state, stops the state machine */
  31. POP3_SERVERGREET, /* waiting for the initial greeting immediately after
  32. a connect */
  33. POP3_CAPA,
  34. POP3_STARTTLS,
  35. POP3_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
  36. (multi mode only) */
  37. POP3_AUTH,
  38. POP3_APOP,
  39. POP3_USER,
  40. POP3_PASS,
  41. POP3_COMMAND,
  42. POP3_QUIT,
  43. POP3_LAST /* never used */
  44. } pop3state;
  45. /* This POP3 struct is used in the Curl_easy. All POP3 data that is
  46. connection-oriented must be in pop3_conn to properly deal with the fact that
  47. perhaps the Curl_easy is changed between the times the connection is
  48. used. */
  49. struct POP3 {
  50. curl_pp_transfer transfer;
  51. char *id; /* Message ID */
  52. char *custom; /* Custom Request */
  53. };
  54. /* pop3_conn is used for struct connection-oriented data in the connectdata
  55. struct */
  56. struct pop3_conn {
  57. struct pingpong pp;
  58. pop3state state; /* Always use pop3.c:state() to change state! */
  59. bool ssldone; /* Is connect() over SSL done? */
  60. size_t eob; /* Number of bytes of the EOB (End Of Body) that
  61. have been received so far */
  62. size_t strip; /* Number of bytes from the start to ignore as
  63. non-body */
  64. struct SASL sasl; /* SASL-related storage */
  65. unsigned int authtypes; /* Accepted authentication types */
  66. unsigned int preftype; /* Preferred authentication type */
  67. char *apoptimestamp; /* APOP timestamp from the server greeting */
  68. bool tls_supported; /* StartTLS capability supported by server */
  69. };
  70. extern const struct Curl_handler Curl_handler_pop3;
  71. extern const struct Curl_handler Curl_handler_pop3s;
  72. /* Authentication type flags */
  73. #define POP3_TYPE_CLEARTEXT (1 << 0)
  74. #define POP3_TYPE_APOP (1 << 1)
  75. #define POP3_TYPE_SASL (1 << 2)
  76. /* Authentication type values */
  77. #define POP3_TYPE_NONE 0
  78. #define POP3_TYPE_ANY ~0U
  79. /* This is the 5-bytes End-Of-Body marker for POP3 */
  80. #define POP3_EOB "\x0d\x0a\x2e\x0d\x0a"
  81. #define POP3_EOB_LEN 5
  82. /* This function scans the body after the end-of-body and writes everything
  83. * until the end is found */
  84. CURLcode Curl_pop3_write(struct connectdata *conn, char *str, size_t nread);
  85. #endif /* HEADER_CURL_POP3_H */