/* schan_push_adapter * Callback registered with SSLSetIOFuncs as the write function for a * session. Writes data to the session connection. Conforms to the * SSLWriteFunc type. * * transport - The session connection * buff - The buffer of data to write. Must be at least *buff_len bytes in length. * *buff_len - On input, the desired length to write. On successful return, * the number of bytes actually written. * * Returns: * noErr on complete or partial success; *buff_len indicates how much data * was actually written, which may be less than requested. * errSSLWouldBlock when no data could be written without blocking. The * caller should try again. * other error code for failure. */ static OSStatus schan_push_adapter(SSLConnectionRef transport, const void *buff, SIZE_T *buff_len) { struct mac_session *s = (struct mac_session*)transport; int status; OSStatus ret; TRACE("(%p/%p, %p, %p/%lu)\n", s, s->transport, buff, buff_len, *buff_len); status = schan_push(s->transport, buff, buff_len); if (status == 0) { TRACE("Pushed %lu bytes\n", *buff_len); ret = noErr; } else if (status == EAGAIN) { TRACE("Would block before being able to push anything\n"); ret = errSSLWouldBlock; } else { FIXME("Unknown status code from schan_push: %d\n", status); ret = ioErr; } return ret; }
static ssize_t schan_push_adapter(gnutls_transport_ptr_t transport, const void *buff, size_t buff_len) { struct schan_transport *t = (struct schan_transport*)transport; gnutls_session_t s = (gnutls_session_t)schan_session_for_transport(t); int ret = schan_push(transport, buff, &buff_len); if (ret) { pgnutls_transport_set_errno(s, ret); return -1; } return buff_len; }