示例#1
0
int mailimap_ssl_connect_with_callback(mailimap * f, const char * server, uint16_t port,
    void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data)
{
  int s;
  mailstream * stream;

  if (port == 0) {
    port = mail_get_service_port(SERVICE_NAME_IMAPS, SERVICE_TYPE_TCP);
    if (port == 0)
      port = DEFAULT_IMAPS_PORT;
  }

  /* Connection */

  s = mail_tcp_connect(server, port);
  if (s == -1)
    return MAILIMAP_ERROR_CONNECTION_REFUSED;

  stream = mailstream_ssl_open_with_callback(s, callback, data);
  if (stream == NULL) {
#ifdef WIN32
	closesocket(s);
#else
    close(s);
#endif
    return MAILIMAP_ERROR_SSL;
  }

  return mailimap_connect(f, stream);
}
示例#2
0
int newsnntp_ssl_connect_with_callback(newsnntp * 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 newsnntp_cfssl_connect(f, server, port);
    }
  }
#endif

  if (port == 0) {
    port = mail_get_service_port(SERVICE_NAME_NNTPS, SERVICE_TYPE_TCP);
    if (port == 0)
      port = DEFAULT_NNTPS_PORT;
  }

  /* Connection */

  s = mail_tcp_connect(server, port);
  if (s == -1)
    return NEWSNNTP_ERROR_CONNECTION_REFUSED;

  stream = mailstream_ssl_open_with_callback(s, callback, data);
  if (stream == NULL) {
#ifdef WIN32
	closesocket(s);
#else
    close(s);
#endif
    return NEWSNNTP_ERROR_SSL;
  }

  return newsnntp_connect(f, stream);
}
示例#3
0
mailstream * mailstream_ssl_open(int fd)
{
  return mailstream_ssl_open_with_callback(fd, NULL, NULL);
}