/** * Encode and send password on a socket */ bool synce_password_send( SynceSocket* socket, const char* asciiPassword, unsigned char key) { bool success = false; unsigned char* encoded_password = NULL; size_t size = 0; uint16_t size_le = 0; if (!synce_password_encode(asciiPassword, key, &encoded_password, &size)) { synce_error("failed to encode password"); } size_le = htole16((uint16_t)size); if ( !synce_socket_write(socket, &size_le, sizeof(uint16_t)) ) { synce_error("failed to write buffer size to socket"); goto exit; } if ( !synce_socket_write(socket, encoded_password, size) ) { synce_error("failed to write encoded password to socket"); goto exit; } success = true; exit: synce_password_free(encoded_password); return success; }
HRESULT IRAPIStream_Write( /*{{{*/ IRAPIStream* stream, void const *pv, ULONG cb, ULONG *pcbWritten) { HRESULT hr = E_FAIL; if (pv && synce_socket_write(stream->context->socket, pv, cb)) { if (pcbWritten) *pcbWritten = cb; hr = S_OK; } return hr; }/*}}}*/