Example #1
0
bool istream::gets_peek(string& buf, bool nonl /* = true */,
	bool clear /* = false */, int max /* = 0 */)
{
	if (clear)
		buf.clear();

	if (max > 0)
		buf.set_max(max);

	int ready, ret;
	ACL_VSTRING *vbf = (ACL_VSTRING*) buf.vstring();
	if (nonl)
		ret = acl_vstream_gets_nonl_peek(stream_, vbf, &ready);
	else
		ret = acl_vstream_gets_peek(stream_, vbf, &ready);
	if (ret == ACL_VSTREAM_EOF)
	{
#if ACL_EWOULDBLOCK == ACL_EAGAIN
		if (stream_->errnum != ACL_EWOULDBLOCK)
#else
		if (stream_->errnum != ACL_EWOULDBLOCK
			&& stream_->errnum != ACL_EAGAIN)
#endif
		{
			eof_ = true;
		}
	}
	return ready ? true : false;
}
Example #2
0
void http_client::sprint_header(string& out, const char* prompt)
{
	ACL_VSTRING* bf = out.vstring();
	if (bf == NULL)
	{
		logger_error("vstring null");
		return;
	}
	if (hdr_res_)
		http_hdr_sprint(bf, &hdr_res_->hdr, prompt ? prompt : "dummy");
	else if (hdr_req_)
		http_hdr_sprint(bf, &hdr_req_->hdr, prompt ? prompt : "dummy");
}
Example #3
0
bool istream::readn_peek(string& buf, size_t cnt, bool clear /* = false */)
{
	if (clear)
		buf.clear();

	int ready;
	if (acl_vstream_readn_peek(stream_, buf.vstring(),
		(int) cnt, &ready) == ACL_VSTREAM_EOF)
	{
		eof_ = true;
	}
	return ready ? true : false;
}
Example #4
0
bool istream::read_peek(string& buf, bool clear /* = false */)
{
	if (clear)
		buf.clear();

	if (acl_vstream_read_peek(stream_, buf.vstring()) == ACL_VSTREAM_EOF)
	{
		eof_ = true;
		return false;
	}
	else
		return true;
}
Example #5
0
bool istream::gets_peek(string& buf, bool nonl /* = true */,
	bool clear /* = false */)
{
	if (clear)
		buf.clear();

	int ready, ret;
	ACL_VSTRING *vbf = (ACL_VSTRING*) buf.vstring();
	if (nonl)
		ret = acl_vstream_gets_nonl_peek(stream_, vbf, &ready);
	else
		ret = acl_vstream_gets_peek(stream_, vbf, &ready);
	if (ret == ACL_VSTREAM_EOF)
		eof_ = true;
	return ready ? true : false;
}
Example #6
0
bool istream::readn_peek(string& buf, size_t cnt, bool clear /* = false */)
{
	if (clear)
		buf.clear();

	int ready;
	if (acl_vstream_readn_peek(stream_, buf.vstring(),
		(int) cnt, &ready) == ACL_VSTREAM_EOF)
	{
#if ACL_EWOULDBLOCK == ACL_EAGAIN
		if (stream_->errnum != ACL_EWOULDBLOCK)
#else
		if (stream_->errnum != ACL_EWOULDBLOCK
			&& stream_->errnum != ACL_EAGAIN)
#endif
		{
			eof_ = true;
		}
	}
	return ready ? true : false;
}
Example #7
0
bool istream::read_peek(string& buf, bool clear /* = false */)
{
    if (clear)
        buf.clear();

    if (acl_vstream_read_peek(stream_, buf.vstring()) == ACL_VSTREAM_EOF)
    {
#if ACL_EWOULDBLOCK == ACL_EAGAIN
        if (stream_->errnum != ACL_EWOULDBLOCK)
#else
        if (stream_->errnum != ACL_EWOULDBLOCK
                && stream_->errnum != ACL_EAGAIN)
#endif
        {
            eof_ = true;
        }
        return false;
    }
    else
        return true;
}