00001 #ifndef HEADER_CURL_POP3_H 00002 #define HEADER_CURL_POP3_H 00003 /*************************************************************************** 00004 * _ _ ____ _ 00005 * Project ___| | | | _ \| | 00006 * / __| | | | |_) | | 00007 * | (__| |_| | _ <| |___ 00008 * \___|\___/|_| \_\_____| 00009 * 00010 * Copyright (C) 2009 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. 00011 * 00012 * This software is licensed as described in the file COPYING, which 00013 * you should have received as part of this distribution. The terms 00014 * are also available at https://curl.haxx.se/docs/copyright.html. 00015 * 00016 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 00017 * copies of the Software, and permit persons to whom the Software is 00018 * furnished to do so, under the terms of the COPYING file. 00019 * 00020 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 00021 * KIND, either express or implied. 00022 * 00023 ***************************************************************************/ 00024 00025 #include "pingpong.h" 00026 #include "curl_sasl.h" 00027 00028 /**************************************************************************** 00029 * POP3 unique setup 00030 ***************************************************************************/ 00031 typedef enum { 00032 POP3_STOP, /* do nothing state, stops the state machine */ 00033 POP3_SERVERGREET, /* waiting for the initial greeting immediately after 00034 a connect */ 00035 POP3_CAPA, 00036 POP3_STARTTLS, 00037 POP3_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS 00038 (multi mode only) */ 00039 POP3_AUTH, 00040 POP3_APOP, 00041 POP3_USER, 00042 POP3_PASS, 00043 POP3_COMMAND, 00044 POP3_QUIT, 00045 POP3_LAST /* never used */ 00046 } pop3state; 00047 00048 /* This POP3 struct is used in the Curl_easy. All POP3 data that is 00049 connection-oriented must be in pop3_conn to properly deal with the fact that 00050 perhaps the Curl_easy is changed between the times the connection is 00051 used. */ 00052 struct POP3 { 00053 curl_pp_transfer transfer; 00054 char *id; /* Message ID */ 00055 char *custom; /* Custom Request */ 00056 }; 00057 00058 /* pop3_conn is used for struct connection-oriented data in the connectdata 00059 struct */ 00060 struct pop3_conn { 00061 struct pingpong pp; 00062 pop3state state; /* Always use pop3.c:state() to change state! */ 00063 bool ssldone; /* Is connect() over SSL done? */ 00064 size_t eob; /* Number of bytes of the EOB (End Of Body) that 00065 have been received so far */ 00066 size_t strip; /* Number of bytes from the start to ignore as 00067 non-body */ 00068 struct SASL sasl; /* SASL-related storage */ 00069 unsigned int authtypes; /* Accepted authentication types */ 00070 unsigned int preftype; /* Preferred authentication type */ 00071 char *apoptimestamp; /* APOP timestamp from the server greeting */ 00072 bool tls_supported; /* StartTLS capability supported by server */ 00073 }; 00074 00075 extern const struct Curl_handler Curl_handler_pop3; 00076 extern const struct Curl_handler Curl_handler_pop3s; 00077 00078 /* Authentication type flags */ 00079 #define POP3_TYPE_CLEARTEXT (1 << 0) 00080 #define POP3_TYPE_APOP (1 << 1) 00081 #define POP3_TYPE_SASL (1 << 2) 00082 00083 /* Authentication type values */ 00084 #define POP3_TYPE_NONE 0 00085 #define POP3_TYPE_ANY ~0U 00086 00087 /* This is the 5-bytes End-Of-Body marker for POP3 */ 00088 #define POP3_EOB "\x0d\x0a\x2e\x0d\x0a" 00089 #define POP3_EOB_LEN 5 00090 00091 /* This function scans the body after the end-of-body and writes everything 00092 * until the end is found */ 00093 CURLcode Curl_pop3_write(struct connectdata *conn, char *str, size_t nread); 00094 00095 #endif /* HEADER_CURL_POP3_H */