• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ EVBUFFER_LENGTH函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中EVBUFFER_LENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ EVBUFFER_LENGTH函数的具体用法?C++ EVBUFFER_LENGTH怎么用?C++ EVBUFFER_LENGTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了EVBUFFER_LENGTH函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: input_ground

/* Reset for ground state. */
void
input_ground(struct input_ctx *ictx)
{
	evbuffer_drain(ictx->since_ground, EVBUFFER_LENGTH(ictx->since_ground));

	if (ictx->input_space > INPUT_BUF_START) {
		ictx->input_space = INPUT_BUF_START;
		ictx->input_buf = xrealloc(ictx->input_buf, INPUT_BUF_START);
	}
}
开发者ID:ChrisSteinbach,项目名称:tmux-sixel,代码行数:11,代码来源:input.c


示例2: evtag_marshal_msg

void
evtag_marshal_msg(struct evbuffer *evbuf, ev_uint32_t tag, const struct msg *msg)
{
  struct evbuffer *_buf = evbuffer_new();
  assert(_buf != NULL);
  evbuffer_drain(_buf, -1);
  msg_marshal(_buf, msg);
  evtag_marshal(evbuf, tag, EVBUFFER_DATA(_buf), EVBUFFER_LENGTH(_buf));
  evbuffer_free(_buf);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:10,代码来源:regress.gen.c


示例3: tr_peerIoWriteBuf

void
tr_peerIoWriteBuf( tr_peerIo         * io,
                   struct evbuffer   * buf,
                   tr_bool             isPieceData )
{
    /* FIXME(libevent2): loop through calls to evbuffer_get_contiguous_space() + evbuffer_drain() */
    const size_t n = EVBUFFER_LENGTH( buf );
    tr_peerIoWrite( io, EVBUFFER_DATA( buf ), n, isPieceData );
    evbuffer_drain( buf, n );
}
开发者ID:miracle2k,项目名称:transmission,代码行数:10,代码来源:peer-io.c


示例4: auto_event_error

static void auto_event_error(struct bufferevent *buffev, short what, void *_arg)
{
	redsocks_client *client = _arg;
	autoproxy_client * aclient = (void*)(client + 1) + client->instance->relay_ss->payload_len;
	int saved_errno = errno;
	assert(buffev == client->relay || buffev == client->client);
		
	redsocks_touch_client(client);
			
	redsocks_log_errno(client, LOG_DEBUG, "%s errno(%d), State: %d, what: " event_fmt_str, 
							buffev == client->client?"client":"relay",
							saved_errno, aclient->state, event_fmt(what));
	if (buffev == client->relay)
	{
		
		if ( aclient->state == AUTOPROXY_NEW 
		&& what == (EVBUFFER_WRITE|EVBUFFER_TIMEOUT))
		{
			on_connection_blocked(client);	
			/* In case timeout occurs while connecting relay, we try to connect
			to target via SOCKS5 proxy. It is possible that the connection to
			target can be set up a bit longer than the timeout value we set. 
			However, it is still better to make connection via proxy. */
			auto_retry(client, 1);
			return;
		}

		if (aclient->state == AUTOPROXY_NEW  && saved_errno == ECONNRESET)
			if (!auto_retry_or_drop(client))
				return;

		if (aclient->state == AUTOPROXY_CONNECTED && what == (EVBUFFER_READ|EVBUFFER_ERROR) 
				&& saved_errno == ECONNRESET )
		{
			if (!auto_retry_or_drop(client))
				return;
		}
	}	

	if (what == (EVBUFFER_READ|EVBUFFER_EOF)) {
		struct bufferevent *antiev;
		if (buffev == client->relay)
			antiev = client->client;
		else
			antiev = client->relay;
			
		redsocks_shutdown(client, buffev, SHUT_RD);
		
		if (antiev != NULL && EVBUFFER_LENGTH(antiev->output) == 0)
			redsocks_shutdown(client, antiev, SHUT_WR);
	}
	else {
		redsocks_drop_client(client);
	}
}																		
开发者ID:neroanelli,项目名称:redsocks,代码行数:55,代码来源:autoproxy.c


示例5: relay_dns_request

int
relay_dns_request(struct rsession *con)
{
	struct relay		*rlay = con->se_relay;
	struct relay_dns_priv	*priv = con->se_priv;
	u_int8_t		*buf = EVBUFFER_DATA(con->se_out.output);
	size_t			 len = EVBUFFER_LENGTH(con->se_out.output);
	struct relay_dnshdr	*hdr;
	socklen_t		 slen;

	if (buf == NULL || priv == NULL || len < 1)
		return (-1);
	if (debug)
		relay_dns_log(con, buf, len);

	getmonotime(&con->se_tv_start);

	if (!TAILQ_EMPTY(&rlay->rl_tables)) {
		if (relay_from_table(con) != 0)
			return (-1);
	} else if (con->se_out.ss.ss_family == AF_UNSPEC) {
		bcopy(&rlay->rl_conf.dstss, &con->se_out.ss,
		    sizeof(con->se_out.ss));
		con->se_out.port = rlay->rl_conf.dstport;
	}

	if ((con->se_out.s = relay_udp_socket(&con->se_out.ss,
	    con->se_out.port, rlay->rl_proto)) == -1)
		return (-1);
	slen = con->se_out.ss.ss_len;

	hdr = (struct relay_dnshdr *)buf;
	hdr->dns_id = htons(priv->dp_inkey);

 retry:
	if (sendto(con->se_out.s, buf, len, 0,
	    (struct sockaddr *)&con->se_out.ss, slen) == -1) {
		if (con->se_retry) {
			con->se_retry--;
			log_debug("%s: session %d: "
			    "forward failed: %s, %s", __func__,
			    con->se_id, strerror(errno),
			    con->se_retry ? "next retry" : "last retry");
			goto retry;
		}
		log_debug("%s: session %d: forward failed: %s", __func__,
		    con->se_id, strerror(errno));
		return (-1);
	}

	event_again(&con->se_ev, con->se_out.s, EV_TIMEOUT|EV_READ,
	    relay_udp_response, &con->se_tv_start, &env->sc_timeout, con);

	return (0);
}
开发者ID:RobinGeuze,项目名称:relayd,代码行数:55,代码来源:relay_udp.c


示例6: format_window_pane_tabs

/* Add window pane tabs. */
void
format_window_pane_tabs(struct format_tree *ft, struct window_pane *wp)
{
	struct evbuffer	*buffer;
	u_int		 i;

	buffer = evbuffer_new();
	for (i = 0; i < wp->base.grid->sx; i++) {
		if (!bit_test(wp->base.tabs, i))
			continue;

		if (EVBUFFER_LENGTH(buffer) > 0)
			evbuffer_add(buffer, ",", 1);
		evbuffer_add_printf(buffer, "%d", i);
	}

	format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer),
	    EVBUFFER_DATA(buffer));
	evbuffer_free(buffer);
}
开发者ID:FauxFaux,项目名称:tmux,代码行数:21,代码来源:format.c


示例7: on_client_read_stream

static void on_client_read_stream(struct bufferevent *bev, void *ctx)
{
  Client *cl = ctx;
  size_t bytes = EVBUFFER_LENGTH(EVBUFFER_INPUT(bev));
  char *buffer = EVBUFFER_DATA(EVBUFFER_INPUT(bev));

  prcl_trace(cl, "received %d bytes from client", bytes);

  bufferevent_write(cl->server.bufev, buffer, bytes);
  evbuffer_drain(EVBUFFER_INPUT(bev), bytes);
}
开发者ID:iksaif,项目名称:sockslink,代码行数:11,代码来源:client.c


示例8: cob_

void TEvhttpClientChannel::finish(struct evhttp_request* req) {
  if (req == NULL) {
    return cob_();
  } else if (req->response_code != 200) {
    return cob_();
  }
  recvBuf_->resetBuffer(
      EVBUFFER_DATA(req->input_buffer),
      EVBUFFER_LENGTH(req->input_buffer));
  return cob_();
}
开发者ID:armaansarkar,项目名称:thrift,代码行数:11,代码来源:TEvhttpClientChannel.cpp


示例9: direct_relay_readcb_helper

static void direct_relay_readcb_helper(redsocks_client *client, struct bufferevent *from, struct bufferevent *to)
{
	if (EVBUFFER_LENGTH(to->output) < to->wm_write.high) {
		if (bufferevent_write_buffer(to, from->input) == -1)
			redsocks_log_errno(client, LOG_ERR, "bufferevent_write_buffer");
	}
	else {
		if (bufferevent_disable(from, EV_READ) == -1)
			redsocks_log_errno(client, LOG_ERR, "bufferevent_disable");
	}
}
开发者ID:jmttoki,项目名称:redsocks,代码行数:11,代码来源:autosocks.c


示例10: assert

const void *LibEventTransport::getPostData(int &size) {
  if (m_sendEnded) {
    size = 0;
    return 0;
  }
  evbuffer *buf = m_request->input_buffer;

  assert(buf);
  size = EVBUFFER_LENGTH(buf);
  return EVBUFFER_DATA(buf);
}
开发者ID:CyaLiven,项目名称:hiphop-php,代码行数:11,代码来源:libevent_transport.cpp


示例11: copy_evbuffer

/* copy event buffer from source to destination as much as possible. 
 * If parameter skip is not zero, copy will start from the number of skip bytes.
 */
size_t copy_evbuffer(struct bufferevent * dst, const struct bufferevent * src, size_t skip)
{
    int n, i;
    size_t written = 0;
    struct evbuffer_iovec *v;
    struct evbuffer_iovec quick_v[5];/* a vector with 5 elements is usually enough */

    size_t maxlen = dst->wm_write.high - EVBUFFER_LENGTH(dst->output);
    maxlen = EVBUFFER_LENGTH(src->input) - skip> maxlen?maxlen: EVBUFFER_LENGTH(src->input)-skip;

    n = evbuffer_peek(src->input, maxlen+skip, NULL, NULL, 0);
    if (n>sizeof(quick_v)/sizeof(struct evbuffer_iovec))
        v = malloc(sizeof(struct evbuffer_iovec)*n);
    else
        v = quick_v;
    n = evbuffer_peek(src->input, maxlen+skip, NULL, v, n);
    for (i=0; i<n; ++i) {
        size_t len = v[i].iov_len;
        if (skip >= len)
        {
            skip -= len;
            continue;
        }
        else 
        {
            len -= skip;
        }
        if (written + len > maxlen)
            len = maxlen - written;
        if (bufferevent_write(dst, v[i].iov_base+skip, len))
            break;
        skip = 0;
        /* We keep track of the bytes written separately; if we don't,
        *  we may write more than we need if the last chunk puts    
        * us over the limit. */
        written += len;
    }
    if (n>sizeof(quick_v)/sizeof(struct evbuffer_iovec))
        free(v);
    return written;
}
开发者ID:BEA3CCCE,项目名称:redsocks,代码行数:44,代码来源:utils.c


示例12: event_base_free

const void *LibEventTransport::getMorePostData(int &size) {
#ifdef EVHTTP_PORTABLE_READ_LIMITING
  if (m_request->ntoread == 0) {
    if (m_eventBasePostData != nullptr) {
      event_base_free(m_eventBasePostData);
      m_eventBasePostData = nullptr;
    }
    size = 0;
    return nullptr;
  }

  evbuffer *buf = m_request->input_buffer;
  assert(buf);
  evbuffer_drain(buf, EVBUFFER_LENGTH(buf));

  if (evhttp_get_more_post_data(m_request, &m_eventBasePostData,
                                &m_moreDataRead)) {
    buf = m_request->input_buffer;
    assert(buf);
    size = EVBUFFER_LENGTH(buf);
    if (m_request->ntoread == 0) {
      if (m_eventBasePostData != nullptr) {
        event_base_free(m_eventBasePostData);
        m_eventBasePostData = nullptr;
      }
      evhttp_get_post_data_done(m_request);
    }
    return EVBUFFER_DATA(buf);
  }
  if (m_eventBasePostData != nullptr) {
    event_base_free(m_eventBasePostData);
    m_eventBasePostData = nullptr;
  }
  evhttp_get_post_data_done(m_request);
  size = 0;
  return nullptr;
#else
  size = 0;
  return nullptr;
#endif
}
开发者ID:baidu-lamp,项目名称:baidu-hhvm-301,代码行数:41,代码来源:libevent-transport.cpp


示例13: webResponseFunc

static void
webResponseFunc( tr_session    * session,
                 long            response_code,
                 const void    * response,
                 size_t          response_byte_count,
                 void          * vw )
{
    tr_webseed * w = vw;
    tr_torrent * tor = tr_torrentFindFromHash( session, w->hash );
    const int    success = ( response_code == 206 );

/*fprintf( stderr, "server responded with code %ld and %lu bytes\n",
  response_code, (unsigned long)response_byte_count );*/
    if( !success )
    {
        /* FIXME */
    }
    else if( tor != NULL )
    {
        evbuffer_add( w->content, response, response_byte_count );
        if( !w->dead )
        {
            fireClientGotData( w, response_byte_count );
            tr_rcTransferred( &w->rateDown, response_byte_count );
        }

        if( EVBUFFER_LENGTH( w->content ) < w->byteCount )
            requestNextChunk( w );
        else {
            tr_ioWrite( tor, w->pieceIndex, w->pieceOffset, w->byteCount, EVBUFFER_DATA(w->content) );
            evbuffer_drain( w->content, EVBUFFER_LENGTH( w->content ) );
            w->busy = 0;
            if( w->dead )
                tr_webseedFree( w );
            else  {
                fireClientGotBlock( w, w->pieceIndex, w->pieceOffset, w->byteCount );
                fireNeedReq( w );
            }
        }
    }
}
开发者ID:miracle2k,项目名称:transmission,代码行数:41,代码来源:webseed.c


示例14: cmd_run_shell_callback

void
cmd_run_shell_callback(struct job *job)
{
	struct cmd_run_shell_data	*cdata = job->data;
	struct cmd_ctx			*ctx = &cdata->ctx;
	char				*cmd, *msg, *line;
	size_t				 size;
	int				 retcode;
	u_int				 lines;

	if (ctx->cmdclient != NULL && ctx->cmdclient->flags & CLIENT_DEAD)
		return;
	if (ctx->curclient != NULL && ctx->curclient->flags & CLIENT_DEAD)
		return;

	lines = 0;
	do {
		if ((line = evbuffer_readline(job->event->input)) != NULL) {
			ctx->print(ctx, "%s", line);
			lines++;
		}
	} while (line != NULL);

	size = EVBUFFER_LENGTH(job->event->input);
	if (size != 0) {
		line = xmalloc(size + 1);
		memcpy(line, EVBUFFER_DATA(job->event->input), size);
		line[size] = '\0';

		ctx->print(ctx, "%s", line);
		lines++;

		xfree(line);
	}

	cmd = cdata->cmd;

	msg = NULL;
	if (WIFEXITED(job->status)) {
		if ((retcode = WEXITSTATUS(job->status)) != 0)
			xasprintf(&msg, "'%s' returned %d", cmd, retcode);
	} else if (WIFSIGNALED(job->status)) {
		retcode = WTERMSIG(job->status);
		xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
	}
	if (msg != NULL) {
		if (lines != 0)
			ctx->print(ctx, "%s", msg);
		else
			ctx->info(ctx, "%s", msg);
		xfree(msg);
	}
}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:53,代码来源:cmd-run-shell.c


示例15: m_server

LibEventTransport::LibEventTransport(LibEventServer *server,
                                     evhttp_request *request,
                                     int workerId)
  : m_server(server), m_request(request), m_eventBasePostData(nullptr),
    m_workerId(workerId), m_sendStarted(false), m_sendEnded(false) {
  // HttpProtocol::PrepareSystemVariables needs this
  evbuffer *buf = m_request->input_buffer;
  assert(buf);
  m_requestSize = EVBUFFER_LENGTH(buf);
  m_remote_host = m_request->remote_host;
  m_remote_port = m_request->remote_port;

  {
    char buf[6];
    snprintf(buf, 6, "%d.%d", m_request->major, m_request->minor);
    m_http_version = buf;
  }

  switch (m_request->type) {
  case EVHTTP_REQ_GET:
    m_method = Transport::Method::GET;
    m_requestSize += 3;
    break;
  case EVHTTP_REQ_POST:
    m_method = Transport::Method::POST;
    m_requestSize += 4;
    break;
  case EVHTTP_REQ_HEAD:
    m_method = Transport::Method::HEAD;
    m_requestSize += 4;
    break;
  default:
    assert(false);
    m_method = Transport::Method::Unknown;
    break;
  }
  m_extended_method = m_request->ext_method;

  assert(m_request->input_headers);
  for (evkeyval *p = ((m_evkeyvalq*)m_request->input_headers)->tqh_first; p;
       p = p->next.tqe_next) {
    if (p->key && p->value) {
      m_requestHeaders[p->key].push_back(p->value);
      //key, value, ": " and CR/LF
      m_requestSize += strlen(p->key) + strlen(p->value) + 4;
    }
  }

  m_url = m_request->uri;
  m_requestSize += m_url.size();
  m_requestSize += m_http_version.size(); //version number in "HTTP/x.y"
  m_requestSize += 11; // HTTP/=5, 2 spaces for url, and CR/LF x2 (first+last)
}
开发者ID:baidu-lamp,项目名称:baidu-hhvm-301,代码行数:53,代码来源:libevent-transport.cpp


示例16: task_finish

static void
task_finish( struct tr_web_task * task, long response_code )
{
    dbgmsg( "finished a web task... response code is %ld", response_code );
    dbgmsg( "===================================================" );
    task->done_func( task->session,
                     response_code,
                     EVBUFFER_DATA( task->response ),
                     EVBUFFER_LENGTH( task->response ),
                     task->done_func_user_data );
    task_free( task );
}
开发者ID:fangang190,项目名称:canary,代码行数:12,代码来源:web.c


示例17: bufferevent_readcb

static void
bufferevent_readcb(int fd, short event, void *arg)
{
	struct bufferevent *bufev = arg;
	int res = 0;
	short what = EVBUFFER_READ;
	size_t len;

	if (event == EV_TIMEOUT) {
		what |= EVBUFFER_TIMEOUT;
		goto error;
	}

	res = evbuffer_read(bufev->input, fd, -1);
	if (res == -1) {
		if (errno == EAGAIN || errno == EINTR)
			goto reschedule;
		/* error case */
		what |= EVBUFFER_ERROR;
	} else if (res == 0) {
		/* eof case */
		what |= EVBUFFER_EOF;
	}

	if (res <= 0)
		goto error;

	bufferevent_add(&bufev->ev_read, bufev->timeout_read);

	/* See if this callbacks meets the water marks */
	len = EVBUFFER_LENGTH(bufev->input);
	if (bufev->wm_read.low != 0 && len < bufev->wm_read.low)
		return;
	if (bufev->wm_read.high != 0 && len > bufev->wm_read.high) {
		struct evbuffer *buf = bufev->input;
		event_del(&bufev->ev_read);

		/* Now schedule a callback for us */
		evbuffer_setcb(buf, bufferevent_read_pressure_cb, bufev);
		return;
	}

	/* Invoke the user callback - must always be called last */
	(*bufev->readcb)(bufev, bufev->cbarg);
	return;

 reschedule:
	bufferevent_add(&bufev->ev_read, bufev->timeout_read);
	return;

 error:
	(*bufev->errorcb)(bufev, what, bufev->cbarg);
}
开发者ID:MichaelSchmid,项目名称:cisco-vqe-client,代码行数:53,代码来源:evbuffer.c


示例18: tr_peerIoGetWriteBufferSpace

size_t
tr_peerIoGetWriteBufferSpace( const tr_peerIo * io, uint64_t now )
{
    const size_t desiredLen = getDesiredOutputBufferSize( io, now );
    const size_t currentLen = EVBUFFER_LENGTH( io->outbuf );
    size_t freeSpace = 0;

    if( desiredLen > currentLen )
        freeSpace = desiredLen - currentLen;

    return freeSpace;
}
开发者ID:miracle2k,项目名称:transmission,代码行数:12,代码来源:peer-io.c


示例19: on_http_message_chunk

/**
 * Called when a message is sent on the HTTP channel pipe.
 */
void
on_http_message_chunk(struct evhttp_request *req, void *ptr) {

	struct reader_thread *rt = ptr;

	if(req->response_code == HTTP_OK) {
		size_t sz = EVBUFFER_LENGTH(req->input_buffer);
		process_message(rt, sz);
	} else {
		fprintf(stderr, "CHUNK FAIL (ret=%d)\n", req->response_code);
	}
}
开发者ID:hnkien,项目名称:river,代码行数:15,代码来源:bench.c


示例20: task_finish

static void
task_finish( struct tr_web_task * task, long response_code )
{
    dbgmsg( "finished web task %lu; got %ld", task->tag, response_code );

    if( task->done_func != NULL )
        task->done_func( task->session,
                         response_code,
                         EVBUFFER_DATA( task->response ),
                         EVBUFFER_LENGTH( task->response ),
                         task->done_func_user_data );
    task_free( task );
}
开发者ID:ndmsystems,项目名称:transmission,代码行数:13,代码来源:web.c



注:本文中的EVBUFFER_LENGTH函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ EVEN函数代码示例发布时间:2022-05-30
下一篇:
C++ EVBUFFER_DATA函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap