LIBETPAN_EXPORT int mailpop3_socket_starttls_with_callback(mailpop3 * f, void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data) { int r; int fd; mailstream_low * low; mailstream_low * new_low; r = mailpop3_stls(f); switch (r) { case MAILPOP3_NO_ERROR: break; default: return r; } low = mailstream_get_low(f->pop3_stream); fd = mailstream_low_get_fd(low); if (fd == -1) return MAILPOP3_ERROR_STREAM; new_low = mailstream_low_tls_open_with_callback(fd, callback, data); if (new_low == NULL) return MAILPOP3_ERROR_SSL; mailstream_low_free(low); mailstream_set_low(f->pop3_stream, new_low); return MAILPOP3_NO_ERROR; }
int mailsmtp_socket_starttls_with_callback(mailsmtp * session, void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data) { int r; int fd; mailstream_low * low; mailstream_low * new_low; low = mailstream_get_low(session->stream); if (low->driver == mailstream_cfstream_driver) { // won't use callback return mailsmtp_cfsocket_starttls(session); } r = mailesmtp_starttls(session); if (r != MAILSMTP_NO_ERROR) return r; fd = mailstream_low_get_fd(low); if (fd == -1) return MAILSMTP_ERROR_STREAM; new_low = mailstream_low_tls_open_with_callback_timeout(fd, session->smtp_timeout, callback, data); if (new_low == NULL) return MAILSMTP_ERROR_SSL; mailstream_low_free(low); mailstream_set_low(session->stream, new_low); return MAILSMTP_NO_ERROR; }
int mailstream_close(mailstream * s) { mailstream_low_close(s->low); mailstream_low_free(s->low); free(s->read_buffer); free(s->write_buffer); free(s); return 0; }
int mailstream_close(mailstream * s) { if (s->idle != NULL) { mailstream_cancel_free(s->idle); } mailstream_low_close(s->low); mailstream_low_free(s->low); free(s->read_buffer); free(s->write_buffer); free(s); return 0; }
int mailimap_socket_starttls_with_callback(mailimap * f, void (* callback)(struct mailstream_ssl_context * ssl_context, void * data), void * data) { mailstream_low * low; mailstream_low * new_low; int r; int fd; low = mailstream_get_low(f->imap_stream); if (low->driver == mailstream_cfstream_driver) { // won't use callback return mailimap_cfsocket_starttls(f); } r = mailimap_starttls(f); switch (r) { case MAILIMAP_NO_ERROR: break; default: return r; } fd = mailstream_low_get_fd(low); if (fd == -1) return MAILIMAP_ERROR_STREAM; new_low = mailstream_low_tls_open_with_callback_timeout(fd, f->imap_timeout, callback, data); if (new_low == NULL) return MAILIMAP_ERROR_STREAM; mailstream_low_free(low); mailstream_set_low(f->imap_stream, new_low); return MAILIMAP_NO_ERROR; }