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); }
int mailpop3_socket_connect(mailpop3 * f, const char * server, uint16_t port) { int s; mailstream * stream; if (port == 0) { port = mail_get_service_port(SERVICE_NAME_POP3, SERVICE_TYPE_TCP); if (port == 0) port = DEFAULT_POP3_PORT; } /* Connection */ s = mail_tcp_connect(server, port); if (s == -1) return MAILPOP3_ERROR_CONNECTION_REFUSED; stream = mailstream_socket_open(s); if (stream == NULL) { #ifdef WIN32 closesocket(s); #else close(s); #endif return MAILPOP3_ERROR_MEMORY; } return mailpop3_connect(f, stream); }
int mailsmtp_socket_connect(mailsmtp * session, const char * server, uint16_t port) { int s; mailstream * stream; #if HAVE_CFNETWORK return mailsmtp_cfsocket_connect(session, server, port); #endif if (port == 0) { port = mail_get_service_port(SERVICE_NAME_SMTP, SERVICE_TYPE_TCP); if (port == 0) port = DEFAULT_SMTP_PORT; } /* Connection */ s = mail_tcp_connect(server, port); if (s == -1) return MAILSMTP_ERROR_CONNECTION_REFUSED; stream = mailstream_socket_open(s); if (stream == NULL) { #ifdef WIN32 closesocket(s); #else close(s); #endif return MAILSMTP_ERROR_MEMORY; } return mailsmtp_connect(session, stream); }
int mailsmtp_ssl_connect_with_callback(mailsmtp * session, 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 (callback == NULL) { return mailsmtp_cfssl_connect(session, server, port); } #endif if (port == 0) { port = mail_get_service_port(SERVICE_NAME_SMTPS, SERVICE_TYPE_TCP); if (port == 0) port = DEFAULT_SMTPS_PORT; } /* Connection */ s = mail_tcp_connect(server, port); if (s == -1) return MAILSMTP_ERROR_CONNECTION_REFUSED; stream = mailstream_ssl_open(s); if (stream == NULL) { close(s); return MAILSMTP_ERROR_SSL; } return mailsmtp_connect(session, stream); }
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); }
LIBETPAN_EXPORT int mailimap_socket_connect_voip(mailimap * f, const char * server, uint16_t port, int voip_enabled) { int s; mailstream * stream; #if HAVE_CFNETWORK if (mailstream_cfstream_enabled) { return mailimap_cfsocket_connect_voip(f, server, port, voip_enabled); } #else UNUSED(voip_enabled); #endif if (port == 0) { port = mail_get_service_port(SERVICE_NAME_IMAP, SERVICE_TYPE_TCP); if (port == 0) port = DEFAULT_IMAP_PORT; } /* Connection */ s = mail_tcp_connect(server, port); if (s == -1) return MAILIMAP_ERROR_CONNECTION_REFUSED; stream = mailstream_socket_open(s); if (stream == NULL) { #ifdef WIN32 closesocket(s); #else close(s); #endif return MAILIMAP_ERROR_MEMORY; } return mailimap_connect(f, stream); }
int newsnntp_socket_connect(newsnntp * f, const char * server, uint16_t port) { int s; mailstream * stream; #if HAVE_CFNETWORK if (mailstream_cfstream_enabled) { return newsnntp_cfsocket_connect(f, server, port); } #endif if (port == 0) { port = mail_get_service_port(SERVICE_NAME_NNTP, SERVICE_TYPE_TCP); if (port == 0) port = DEFAULT_NNTP_PORT; } /* Connection */ s = mail_tcp_connect_timeout(server, port, f->nntp_timeout); if (s == -1) return NEWSNNTP_ERROR_CONNECTION_REFUSED; stream = mailstream_socket_open_timeout(s, f->nntp_timeout); if (stream == NULL) { #ifdef WIN32 closesocket(s); #else close(s); #endif return NEWSNNTP_ERROR_MEMORY; } return newsnntp_connect(f, stream); }