39 #ifndef CURL_DISABLE_POP3 41 #ifdef HAVE_NETINET_IN_H 42 #include <netinet/in.h> 44 #ifdef HAVE_ARPA_INET_H 45 #include <arpa/inet.h> 48 #include <sys/utsname.h> 58 #if (defined(NETWARE) && defined(__NOVELL_LIBC__)) 60 #define in_addr_t unsigned long 105 const char *initresp);
184 #define pop3_to_pop3s(x) Curl_nop_stmt 202 if(len >= 4 && !memcmp(
"-ERR", line, 4)) {
211 if(len >= 1 && !memcmp(line,
".", 1))
222 if(len >= 3 && !memcmp(
"+OK", line, 3)) {
229 if(len >= 1 && !memcmp(
"+", line, 1)) {
247 char *message = NULL;
250 for(message = buffer + 2; *message ==
' ' || *message ==
'\t'; message++)
254 for(len = strlen(message); len--;)
255 if(message[len] !=
'\r' && message[len] !=
'\n' && message[len] !=
' ' &&
256 message[len] !=
'\t')
276 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) 278 static const char *
const names[] = {
293 if(pop3c->
state != newstate)
294 infof(conn->
data,
"POP3 %p state change from %s to %s\n",
295 (
void *)pop3c, names[pop3c->
state], names[newstate]);
298 pop3c->
state = newstate;
399 #ifndef CURL_DISABLE_CRYPTO_AUTH 439 snprintf(&secret[2 * i], 3,
"%02x", digest[i]);
459 const char *initresp)
521 #ifndef CURL_DISABLE_CRYPTO_AUTH 532 infof(conn->
data,
"No known authentication mechanisms supported!\n");
557 if(pop3->
id[0] !=
'\0')
565 if(pop3->
id[0] !=
'\0')
608 size_t len = strlen(line);
613 if(pop3code !=
'+') {
614 failf(data,
"Got unexpected pop3-server response");
619 if(len >= 4 && line[len - 2] ==
'>') {
621 for(i = 3; i < len - 2; ++
i) {
624 size_t timestamplen = len - 1 -
i;
659 size_t len = strlen(line);
665 if(pop3code ==
'*') {
667 if(len >= 4 && !memcmp(line,
"STLS", 4))
671 else if(len >= 4 && !memcmp(line,
"USER", 4))
675 else if(len >= 5 && !memcmp(line,
"SASL ", 5)) {
685 unsigned int mechbit;
688 (*line ==
' ' || *line ==
'\t' ||
689 *line ==
'\r' || *line ==
'\n')) {
699 for(wordlen = 0; wordlen < len && line[wordlen] !=
' ' &&
700 line[wordlen] !=
'\t' && line[wordlen] !=
'\r' &&
701 line[wordlen] !=
'\n';)
706 if(mechbit && llen == wordlen)
714 else if(pop3code ==
'+') {
724 failf(data,
"STLS not supported.");
751 if(pop3code !=
'+') {
753 failf(data,
"STARTTLS denied");
784 #ifndef CURL_DISABLE_CRYPTO_AUTH 794 failf(data,
"Authentication cancelled");
805 #ifndef CURL_DISABLE_CRYPTO_AUTH 815 if(pop3code !=
'+') {
816 failf(data,
"Authentication failed: %d", pop3code);
836 if(pop3code !=
'+') {
837 failf(data,
"Access denied. %c", pop3code);
859 if(pop3code !=
'+') {
860 failf(data,
"Access denied. %c", pop3code);
883 if(pop3code !=
'+') {
954 switch(pop3c->
state) {
971 #ifndef CURL_DISABLE_CRYPTO_AUTH 1121 connclose(conn,
"POP3 done with bad status");
1156 *dophase_done =
FALSE;
1253 else if(*dophase_done) {
1275 bool connected =
FALSE;
1291 if(!result && *dophase_done)
1327 while(!result && ptr && *ptr) {
1331 while(*ptr && *ptr !=
'=')
1336 while(*ptr && *ptr !=
';')
1341 value, ptr - value);
1424 bool strip_dot =
FALSE;
1433 for(i = 0; i < nread; i++) {
1434 size_t prev = pop3c->
eob;
1438 if(pop3c->
eob == 0) {
1452 else if(pop3c->
eob == 3)
1461 if(pop3c->
eob == 1 || pop3c->
eob == 4)
1472 else if(pop3c->
eob == 3) {
1489 if(prev && prev >= pop3c->
eob) {
1493 while(prev && pop3c->
strip) {
1502 strip_dot ? prev - 1 : prev);
struct ssl_connect_data ssl[2]
CURLcode Curl_pop3_write(struct connectdata *conn, char *str, size_t nread)
static CURLcode pop3_perform_apop(struct connectdata *conn)
CURLcode Curl_urldecode(struct Curl_easy *data, const char *string, size_t length, char **ostring, size_t *olen, bool reject_ctrl)
static CURLcode pop3_done(struct connectdata *conn, CURLcode status, bool premature)
static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done)
const MD5_params Curl_DIGEST_MD5[1]
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
static CURLcode pop3_perform_command(struct connectdata *conn)
static CURLcode pop3_regular_transfer(struct connectdata *conn, bool *done)
#define PROTOPT_NOURLQUERY
int Curl_MD5_update(MD5_context *context, const unsigned char *data, unsigned int len)
CURLcode Curl_pp_disconnect(struct pingpong *pp)
void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused)
MD5_context * Curl_MD5_init(const MD5_params *md5params)
#define POP3_TYPE_CLEARTEXT
const struct Curl_handler * handler
UNITTEST_START char * ptr
curl_pp_transfer transfer
static CURLcode pop3_parse_url_path(struct connectdata *conn)
static CURLcode pop3_perform_authentication(struct connectdata *conn)
CURLcode Curl_pp_flushsend(struct pingpong *pp)
static CURLcode pop3_parse_url_options(struct connectdata *conn)
static CURLcode pop3_perform_upgrade_tls(struct connectdata *conn)
#define Curl_ssl_connect_nonblocking(x, y, z)
void Curl_sasl_init(struct SASL *sasl, const struct SASLproto *params)
static const struct SASLproto saslpop3
#define SASL_AUTH_DEFAULT
UNITTEST_START int result
static CURLcode pop3_statemach_act(struct connectdata *conn)
CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn, bool force_ir, saslprogress *progress)
static CURLcode pop3_state_starttls_resp(struct connectdata *conn, int pop3code, pop3state instate)
static CURLcode pop3_perform(struct connectdata *conn, bool *connected, bool *dophase_done)
static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code, pop3state instate)
CURLcode(* statemach_act)(struct connectdata *conn)
memcpy(filename, filename1, strlen(filename1))
static CURLcode pop3_parse_custom_request(struct connectdata *conn)
struct curl_httppost * last
void Curl_setup_transfer(struct connectdata *conn, int sockindex, curl_off_t size, bool getheader, curl_off_t *bytecountp, int writesockindex, curl_off_t *writecountp)
static CURLcode pop3_state_auth_resp(struct connectdata *conn, int pop3code, pop3state instate)
bool(* endofresp)(struct connectdata *conn, char *ptr, size_t len, int *code)
ROSLIB_DECL std::string command(const std::string &cmd)
CURLcode Curl_pp_statemach(struct pingpong *pp, bool block)
CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn, int code, saslprogress *progress)
static CURLcode pop3_connect(struct connectdata *conn, bool *done)
static CURLcode pop3_doing(struct connectdata *conn, bool *dophase_done)
bool Curl_sasl_can_authenticate(struct SASL *sasl, struct connectdata *conn)
unsigned int Curl_sasl_decode_mech(const char *ptr, size_t maxlen, size_t *len)
#define strncasecompare(a, b, c)
static CURLcode pop3_perform_auth(struct connectdata *conn, const char *mech, const char *initresp)
int Curl_MD5_final(MD5_context *context, unsigned char *result)
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
unsigned int curlx_uztoui(size_t uznum)
static void state(struct connectdata *conn, pop3state newstate)
static CURLcode pop3_block_statemach(struct connectdata *conn)
CURLcode Curl_client_write(struct connectdata *conn, int type, char *ptr, size_t len)
#define Curl_safefree(ptr)
static CURLcode pop3_setup_connection(struct connectdata *conn)
static CURLcode pop3_do(struct connectdata *conn, bool *done)
int Curl_pp_getsock(struct pingpong *pp, curl_socket_t *socks, int numsocks)
bool Curl_pp_moredata(struct pingpong *pp)
static int pop3_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks)
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
void Curl_pp_init(struct pingpong *pp)
static CURLcode pop3_state_command_resp(struct connectdata *conn, int pop3code, pop3state instate)
static CURLcode pop3_state_pass_resp(struct connectdata *conn, int pop3code, pop3state instate)
struct connectdata * conn
static CURLcode pop3_perform_quit(struct connectdata *conn)
CURLcode Curl_pp_sendf(struct pingpong *pp, const char *fmt,...)
UNITTEST_START int * value
static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len, int *resp)
static CURLcode pop3_perform_starttls(struct connectdata *conn)
static CURLcode pop3_perform_capa(struct connectdata *conn)
#define PROTOPT_URLOPTIONS
CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl, const char *value, size_t len)
static CURLcode pop3_disconnect(struct connectdata *conn, bool dead)
static CURLcode pop3_init(struct connectdata *conn)
union connectdata::@34 proto
CURLcode Curl_pp_readresp(curl_socket_t sockfd, struct pingpong *pp, int *code, size_t *size)
static void pop3_get_message(char *buffer, char **outptr)
static CURLcode pop3_dophase_done(struct connectdata *conn, bool connected)
#define PROTOPT_CLOSEACTION
static CURLcode pop3_state_user_resp(struct connectdata *conn, int pop3code, pop3state instate)
const struct Curl_handler Curl_handler_pop3
const struct Curl_handler Curl_handler_pop3s
#define calloc(nbelem, size)
static CURLcode pop3_state_servergreet_resp(struct connectdata *conn, int pop3code, pop3state instate)
static CURLcode pop3_continue_auth(struct connectdata *conn, const char *resp)
static CURLcode pop3_state_apop_resp(struct connectdata *conn, int pop3code, pop3state instate)
static CURLcode pop3_perform_user(struct connectdata *conn)