void Bio::set(core::data const& da) { clear(); bio = BIO_new(BIO_s_mem()); BIO_write(bio, da.bytes(), da.length()); }
int HttpConnection::read(core::data& da) { if (da.length()) return 0; use<mg_connection> cnt = connection; return mg_read(cnt, da.bytes(), da.length()); }
bool Bdb::get(core::data const& key, core::data& data) { void* rda = NULL; uint rsz = 0; if (!this->get((void*)key.bytes(), key.length(), &rda, &rsz)) return false; data = core::data((byte*)rda, rsz); data.set_release(true); return true; }
NNT_BEGIN_HEADER_C # include <openssl/md5.h> NNT_END_HEADER_C NNT_BEGIN_CXX core::string md5::digest(const core::data &data) { core::data re(MD5_DIGEST_LENGTH); MD5(data.bytes(), data.length(), core::pointer(re)); return core::present_cast<core::string>(re); }
bool PlayBuffer::read(core::data &da) { # ifdef NNT_MACH AudioBufferList buf; buf.mNumberBuffers = 1; buf.mBuffers[0].mDataByteSize = da.length(); buf.mBuffers[0].mNumberChannels = d_ptr->ofmt.mChannelsPerFrame; buf.mBuffers[0].mData = da.bytes(); UInt32 frames = da.length() / d_ptr->ofmt.mBytesPerFrame; OSStatus sta = ExtAudioFileRead(d_ptr->extstm, &frames, &buf); usize readed = frames * d_ptr->ofmt.mBytesPerFrame; da.set_length(readed); return sta == 0; # endif return false; }
int HttpConnection::write(core::data const& da) { use<mg_connection> cnt = connection; return mg_write(cnt, da.bytes(), da.length()); }
core::data md5::hex(core::data const& da) { core::data re(MD5_DIGEST_LENGTH); MD5(da.bytes(), da.length(), core::pointer(re)); return re; }
bool Bdb::del(const core::data &key) { return this->del((void*)key.bytes(), key.length()); }
bool Bdb::over(core::data const& data, core::data const& key) { return this->over((void*)data.bytes(), data.length(), (void*)key.bytes(), key.length()); }