Exemple #1
0
int mailpop3_ssl_connect_with_callback(mailpop3 * f, const char * server, uint16_t port,
    void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data)
{
  int s;
  mailstream * stream;

#if HAVE_CFNETWORK
  if (mailstream_cfstream_enabled) {
    if (callback == NULL) {
      return mailpop3_cfssl_connect(f, server, port);
    }
  }
#endif
  
  if (port == 0) {
    port = mail_get_service_port(SERVICE_NAME_POP3S, SERVICE_TYPE_TCP);
    if (port == 0)
      port = DEFAULT_POP3S_PORT;
  }

  /* Connection */

  s = mail_tcp_connect_timeout(server, port, f->pop3_timeout);
  if (s == -1)
    return MAILPOP3_ERROR_CONNECTION_REFUSED;

  stream = mailstream_ssl_open_with_callback_timeout(s, f->pop3_timeout, callback, data);
  if (stream == NULL) {
#ifdef WIN32
	closesocket(s);
#else
    close(s);
#endif
    return MAILPOP3_ERROR_SSL;
  }

  return mailpop3_connect(f, stream);
}
Exemple #2
0
mailstream * mailstream_ssl_open_with_callback(int fd,
    void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data)
{
	return mailstream_ssl_open_with_callback_timeout(fd, 0, callback, data);
}
Exemple #3
0
mailstream * mailstream_ssl_open_timeout(int fd, time_t timeout)
{
  return mailstream_ssl_open_with_callback_timeout(fd, timeout, NULL, NULL);
}