Пример #1
0
void Bio::set(core::data const& da)
{
    clear();
    
    bio = BIO_new(BIO_s_mem());
    BIO_write(bio, da.bytes(), da.length());
}
Пример #2
0
int HttpConnection::read(core::data& da)
{
    if (da.length())
        return 0;
    use<mg_connection> cnt = connection;
    return mg_read(cnt, da.bytes(), da.length());
}
Пример #3
0
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;
}
Пример #4
0
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);
}
Пример #5
0
NNT_BEGIN_HEADER_C

# include <openssl/sha.h>

NNT_END_HEADER_C

NNT_BEGIN_CXX

core::data sha1::digest(core::data const& da)
{
    core::data tmp = da.shadow();
    
    SHA_CTX ctx;
    SHA1_Init(&ctx);
    while (tmp.length())
    {
        SHA1_Update(&ctx, tmp.bytes(), tmp.limit(SHA_DIGEST_LENGTH));
        tmp.offset(tmp.limit(SHA_DIGEST_LENGTH));
    }
    
    core::data ret(SHA_DIGEST_LENGTH);
    SHA1_Final((byte*)ret.bytes(), &ctx);
    
    return ret;
}
Пример #6
0
bool SocketStream::read_all(core::data& da, core::Timeout const& tm)
{
    uint framelen = da.length();
    
    if (read(da, tm))
    {
        uint lst_reader = da.length();
    
        if (framelen == lst_reader)
        {
            core::data tmp(framelen);        
            
            while (framelen == lst_reader)
            {            
                tmp.set_length(framelen);
                
                if (read(tmp, tm))
                {
                    da.append(tmp);
                }
                else
                {
					trace_msg("failed to read next fragment data.");
                    return false;
                }
                
                lst_reader = tmp.length();
            }
        }

        complete();
        
        return true;
    }

    return false;
}
Пример #7
0
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;
}
Пример #8
0
core::data sha2::digest384(core::data const& da)
{
    core::data tmp = da.shadow();
    
    SHA512_CTX ctx;
    SHA384_Init(&ctx);
    
    while (tmp.length())
    {
        SHA384_Update(&ctx, tmp.bytes(), tmp.limit(SHA384_DIGEST_LENGTH));
        tmp.offset(tmp.limit(SHA384_DIGEST_LENGTH));
    }
    
    core::data ret(SHA384_DIGEST_LENGTH);
    SHA384_Final((byte*)ret.bytes(), &ctx);
    
    return ret;
}
Пример #9
0
int HttpConnection::write(core::data const& da)
{
    use<mg_connection> cnt = connection;
    return mg_write(cnt, da.bytes(), da.length());
}
Пример #10
0
core::data md5::hex(core::data const& da)
{
    core::data re(MD5_DIGEST_LENGTH);
    MD5(da.bytes(), da.length(), core::pointer(re));
    return re;
}
Пример #11
0
bool Bdb::del(const core::data &key)
{
    return this->del((void*)key.bytes(), key.length());
}
Пример #12
0
bool Bdb::over(core::data const& data, core::data const& key)
{
    return this->over((void*)data.bytes(), data.length(), (void*)key.bytes(), key.length());
}