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

C++ EVBUFFER_DATA函数代码示例

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

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



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

示例1: tr_deepLog

void
tr_deepLog( const char  * file,
            int           line,
            const char  * name,
            const char  * fmt,
            ... )
{
    FILE * fp = tr_getLog( );
    if( fp || IsDebuggerPresent( ) )
    {
        va_list           args;
        char              timestr[64];
        struct evbuffer * buf = evbuffer_new( );
        char *            base = tr_basename( file );

        evbuffer_add_printf( buf, "[%s] ",
                            tr_getLogTimeStr( timestr, sizeof( timestr ) ) );
        if( name )
            evbuffer_add_printf( buf, "%s ", name );
        va_start( args, fmt );
        evbuffer_add_vprintf( buf, fmt, args );
        va_end( args );
        evbuffer_add_printf( buf, " (%s:%d)\n", base, line );
        /* FIXME(libevent2) ifdef this out for nonwindows platforms */
        OutputDebugString( EVBUFFER_DATA( buf ) );
        if(fp) /* FIXME(libevent2) tr_getLog() should return an fd, then use evbuffer_write() here ) */
            (void) fwrite( EVBUFFER_DATA( buf ), 1, EVBUFFER_LENGTH( buf ), fp );

        tr_free( base );
        evbuffer_free( buf );
    }
}
开发者ID:Longinus00,项目名称:transmission,代码行数:32,代码来源:utils.c


示例2: http_post_cb

void
http_post_cb(struct evhttp_request *req, void *arg)
{
	struct evbuffer *evb;
	event_debug(("%s: called\n", __func__));

	/* Yes, we are expecting a post request */
	if (req->type != EVHTTP_REQ_POST) {
		fprintf(stdout, "FAILED (post type)\n");
		exit(1);
	}

	if (EVBUFFER_LENGTH(req->input_buffer) != strlen(POST_DATA)) {
		fprintf(stdout, "FAILED (length: %zu vs %zu)\n",
		    EVBUFFER_LENGTH(req->input_buffer), strlen(POST_DATA));
		exit(1);
	}

	if (memcmp(EVBUFFER_DATA(req->input_buffer), POST_DATA,
		strlen(POST_DATA))) {
		fprintf(stdout, "FAILED (data)\n");
		fprintf(stdout, "Got :%s\n", EVBUFFER_DATA(req->input_buffer));
		fprintf(stdout, "Want:%s\n", POST_DATA);
		exit(1);
	}
	
	evb = evbuffer_new();
	evbuffer_add_printf(evb, "This is funny");

	evhttp_send_reply(req, HTTP_OK, "Everything is fine", evb);

	evbuffer_free(evb);
}
开发者ID:AllanXiang,项目名称:Source,代码行数:33,代码来源:regress_http.c


示例3: ASSERT

const void *LibEventTransport::getMorePostData(int &size) {
#ifdef EVHTTP_READ_LIMITING
  if (m_request->ntoread == 0) {
    size = 0;
    return NULL;
  }

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

  if (evhttp_get_more_post_data(m_request, &m_epollfd, &m_epollevent)) {
    buf = m_request->input_buffer;
    ASSERT(buf);
    size = EVBUFFER_LENGTH(buf);
    evbuffer_expand(buf, size + 1); // allowing NULL termination
    // EVBUFFER_DATA(buf) might change after evbuffer_expand
    ((char*)EVBUFFER_DATA(buf))[size] = '\0';
    if (m_request->ntoread == 0) {
      evhttp_get_post_data_done(m_request);
    }
    return EVBUFFER_DATA(buf);
  }
  if (m_epollfd != -1) {
    close(m_epollfd);
    m_epollfd = -1;
  }
  evhttp_get_post_data_done(m_request);
  size = 0;
  return NULL;
#else
  size = 0;
  return NULL;
#endif
}
开发者ID:GunioRobot,项目名称:hiphop-php,代码行数:35,代码来源:libevent_transport.cpp


示例4: bufevent_readcb

static void bufevent_readcb(struct bufevent *bufev, void *arg)
{
	struct json_rpc_tt *jt = (struct json_rpc_tt *)arg;
	struct jrpc_bufevent *jb = (struct jrpc_bufevent *)jt->impl;

	struct evbuffer *buf = bufevent_get_input(bufev);
	json_parser_process(jb->jp, (char *)EVBUFFER_DATA(buf), (char *)EVBUFFER_DATA(buf) + EVBUFFER_LENGTH(buf));
}
开发者ID:iantropov,项目名称:libjsonrpc,代码行数:8,代码来源:json_rpc_tt_tcp.c


示例5: RequestSend

void RequestSend(Server *pServer, u32 type, struct evbuffer *evSend) {
    struct Poll *poll = pServer->poll;
    //#define COMPRESS
    struct evbuffer *evReq = evbuffer_new();
    struct Request Req, *pReq;
    bzero((char *) & Req, Size_Request);

    evbuffer_add(evReq, (char *) & Req, Size_Request);

    if (evSend > 0) {
        evbuffer_add_buffer(evReq, evSend);
    }

    debug("len:%d to %s:%d 0x%08x", evbuffer_get_length(evReq), pServer->host, pServer->port, pServer->poll->bev);

    pReq = (struct Request *) (EVBUFFER_DATA(evReq));
    pReq->sizes.UncmprSize = evbuffer_get_length(evReq) - Size_Request_sizes;
    pReq->hdr.TesterId = config.testerid;
    pReq->hdr.ReqType = type;


#ifdef COMPRESS
    if (pReq->sizes.UncmprSize > 200) {
        int lenAlloc = (pReq->sizes.UncmprSize)*1.01 + 12 + Size_Request_sizes;
        int lenCmpr = lenAlloc - Size_Request_sizes;
        char *ptrCmpr;
        ptrCmpr = getNulledMemory(lenAlloc);
        memcpy(ptrCmpr, pReq, Size_Request_sizes);
        compress2((Bytef *) ptrCmpr + Size_Request_sizes, (uLongf *) & lenCmpr, (Bytef *) & pReq->hdr, evbuffer_get_length(evReq) - Size_Request_sizes, Z_DEFAULT_COMPRESSION);
        evbuffer_free(evReq);

        evReq = evbuffer_new();
        evbuffer_add(evReq, ptrCmpr, lenCmpr + Size_Request_sizes);
        free(ptrCmpr);
        pReq = (struct Request *) EVBUFFER_DATA(evReq);
        pReq->sizes.CmprSize = lenCmpr;
    }

#endif
    pReq->sizes.crc = crc32(0xffffffff, (const Bytef *) pReq, evbuffer_get_length(evReq));
    /*
        #ifdef DEBUG
            printf(cBLUE"\treq->sizes.CmprSize=%d"cEND, pReq->sizes.CmprSize);
            printf(cBLUE"\treq->sizes.UncmprSize=%d"cEND, pReq->sizes.UncmprSize);
            printf(cBLUE"\treq->sizes.crc=0x%08x\n"cEND, pReq->sizes.crc);
        #ifdef HEXPRINT
            hexPrint((char *) EVBUFFER_DATA(evReq), evbuffer_get_length(evReq));
        #endif
        #endif
     */

    bufferevent_write_buffer(poll->bev, evReq);
    evbuffer_free(evReq);
}
开发者ID:kalloc,项目名称:tester,代码行数:54,代码来源:process.c


示例6: simplehttp_log

void simplehttp_log(const char *host, struct evhttp_request *req, uint64_t req_time, const char *id, int display_post)
{
    // NOTE: this is localtime not gmtime
    time_t now;
    struct tm *tm_now;
    char datetime_buf[64];
    char code;
    const char *method;
    char *uri;
    int response_code;
    int type;
    
    time(&now);
    tm_now = localtime(&now);
    strftime(datetime_buf, 64, "%y%m%d %H:%M:%S", tm_now);
    
    if (req) {
        if (req->response_code >= 500 && req->response_code < 600) {
            code = 'E';
        } else if (req->response_code >= 400 && req->response_code < 500) {
            code = 'W';
        } else {
            code = 'I';
        }
        response_code = req->response_code;
        method = simplehttp_method(req);
        uri = req->uri;
        type = req->type;
    } else {
        code = 'E';
        response_code = 0;
        method = "NA";
        uri = "";
        type = -1;
    }
    
    fprintf(stdout, "[%c %s %s] %d %s %s%s", code, datetime_buf, id, response_code, method, host, uri);
    
    if (display_post && (type == EVHTTP_REQ_POST)) {
        if (req->input_buffer == NULL || EVBUFFER_DATA(req->input_buffer) == NULL) {
            fprintf(stdout, "<ERROR req->input_buffer=%p, EVBUFFER_DATA=%p>", req->input_buffer, /* must be */ NULL);
        } else {
            fprintf(stdout, "?");
            fwrite(EVBUFFER_DATA(req->input_buffer), EVBUFFER_LENGTH(req->input_buffer), 1, stdout);
        }
    }
    
    fprintf(stdout, " %.3fms\n", req_time / 1000.0);
}
开发者ID:LevinLin,项目名称:simplehttp,代码行数:49,代码来源:log.c


示例7: cmd_capture_pane_pending

char *
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
    size_t *len)
{
	char	*buf, *line, tmp[5];
	size_t	 linelen;
	u_int	 i;

	if (wp->ictx.since_ground == NULL)
		return (xstrdup(""));

	line = EVBUFFER_DATA(wp->ictx.since_ground);
	linelen = EVBUFFER_LENGTH(wp->ictx.since_ground);

	buf = xstrdup("");
	if (args_has(args, 'C')) {
		for (i = 0; i < linelen; i++) {
			if (line[i] >= ' ') {
				tmp[0] = line[i];
				tmp[1] = '\0';
			} else
				xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
			buf = cmd_capture_pane_append(buf, len, tmp,
			    strlen(tmp));
		}
	} else
		buf = cmd_capture_pane_append(buf, len, line, linelen);
	return (buf);
}
开发者ID:danieldc,项目名称:tmux,代码行数:29,代码来源:cmd-capture-pane.c


示例8: announceToScrape

static char *
announceToScrape( const char * announce )
{
    char *       scrape = NULL;
    const char * s;

    /* To derive the scrape URL use the following steps:
     * Begin with the announce URL. Find the last '/' in it.
     * If the text immediately following that '/' isn't 'announce'
     * it will be taken as a sign that that tracker doesn't support
     * the scrape convention. If it does, substitute 'scrape' for
     * 'announce' to find the scrape page.  */
    if( ( ( s =
               strrchr( announce, '/' ) ) ) && !strncmp( ++s, "announce", 8 ) )
    {
        struct evbuffer * buf = tr_getBuffer( );
        evbuffer_add( buf, announce, s - announce );
        evbuffer_add( buf, "scrape", 6 );
        evbuffer_add_printf( buf, "%s", s + 8 );
        scrape = tr_strdup( EVBUFFER_DATA( buf ) );
        tr_releaseBuffer( buf );
    }

    return scrape;
}
开发者ID:liesen,项目名称:transmission-horn,代码行数:25,代码来源:metainfo.c


示例9: rrdtool_evb_readcb

void
rrdtool_evb_readcb(struct bufferevent *bev, void *parameter)
{
	struct rrdtool_drv *req = parameter;

	char *start, *end;

	start = EVBUFFER_DATA(bev->input);
	if ((end = evbuffer_find(bev->input, "OK ", 3)) == NULL)
		return;
	
	/* Find the end of the line */
	if (strchr(end, '\n') == NULL)
		return;

	/* Communicate everything before the OK to the call back */
	*end = '\0';

	rrdtool_command_done(req, start);
	
	/* 
	 * We drain all the input because we do not currently interleave
	 * commands.
	 */
	evbuffer_drain(bev->input, -1);

	return;
}
开发者ID:ChristosKon,项目名称:honeyd-ipv6,代码行数:28,代码来源:rrdtool.c


示例10: evbuffer_readln_crlf

char *
evbuffer_readln_crlf(struct evbuffer *buffer)
{
        u_char *data = EVBUFFER_DATA(buffer);
        size_t len = EVBUFFER_LENGTH(buffer);
        char *line;
        unsigned int i, j;

        for (i = 0; i < len; ++i) {
                if (data[i] == '\n')
                        break;
        }

        if (i == len)
                return NULL;

        j = i;
        if (i != 0 && data[i - 1] == '\r')
                --j;

        line = calloc(j + 1, 1);
        if (line == NULL)
                fatal("calloc");

        if (j != 0)
                memcpy(line, data, j);

        evbuffer_drain(buffer, i + 1);

        return (line);
}
开发者ID:clongeau,项目名称:opensmtpd,代码行数:31,代码来源:smtp_session.c


示例11: inject_control_javascript

void
inject_control_javascript(struct evbuffer *buffer)
{
	struct evbuffer *scratch = evbuffer_new();
	char *data, *p;
	size_t data_len, prefix_len;
	assert(scratch != NULL);

	/* simple swap */
	evbuffer_add_buffer(scratch, buffer);
	
	data = (char *)EVBUFFER_DATA(scratch);
	data_len = EVBUFFER_LENGTH(scratch);

	/* try to find the html tag */
	p = find_pointer(data, data_len);
	if (p == NULL) {
		/* 
		 * although, the content typed said text/html, we can't inject
		 * here.  for example, if the response looks like xml data.
		 */
		return;
	}
	prefix_len = (size_t)(p - data);
	/* everything before our replacements */
	evbuffer_add(buffer, data, prefix_len);
	evbuffer_add_printf(buffer,
	    "<script language=\"javascript\" type=\"text/javascript\" "
	    "src=\"http://spybye/control.js\"></script>");
	evbuffer_add(buffer, data + prefix_len, data_len - prefix_len);
	evbuffer_free(scratch);
}
开发者ID:tomsparrow25,项目名称:spybye,代码行数:32,代码来源:proxy.c


示例12: Request_parse_postvars

static void Request_parse_postvars(T R)
{
	struct evkeyval *val;
	char *post = NULL, *rawpost = NULL;
	rawpost = g_strndup((char *)EVBUFFER_DATA(R->req->input_buffer), EVBUFFER_LENGTH(R->req->input_buffer));
	if (rawpost) {
		post = evhttp_decode_uri(rawpost);
		g_free(rawpost);
	}
	R->POST = g_new0(struct evkeyvalq,1);
	TAILQ_INIT(R->POST);
	if (post) {
		int i = 0;
		char **p = g_strsplit(post,"&",0);
		while (p[i]) {
			struct evkeyval *header = g_new0(struct evkeyval,1);
			char **kv = g_strsplit(p[i],"=",2);
			if (! (kv[0] && kv[1])) break;
			header->key = kv[0];
			header->value = kv[1];
			TAILQ_INSERT_TAIL(R->POST, header, next);
			i++;
		}
		g_strfreev(p);
		g_free(post);
	}

	TAILQ_FOREACH(val, R->POST, next)
		TRACE(TRACE_DEBUG,"POST: [%s]->[%s]", val->key, val->value);

}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:31,代码来源:dm_request.c


示例13: cmd_load_buffer_callback

void
cmd_load_buffer_callback(struct client *c, int closed, void *data)
{
	const char	*bufname = data;
	char		*pdata, *cause;
	size_t		 psize;

	if (!closed)
		return;
	c->stdin_callback = NULL;

	server_client_unref(c);
	if (c->flags & CLIENT_DEAD)
		return;

	psize = EVBUFFER_LENGTH(c->stdin_data);
	if (psize == 0 || (pdata = malloc(psize + 1)) == NULL)
		goto out;

	memcpy(pdata, EVBUFFER_DATA(c->stdin_data), psize);
	pdata[psize] = '\0';
	evbuffer_drain(c->stdin_data, psize);

	if (paste_set(pdata, psize, bufname, &cause) != 0) {
		/* No context so can't use server_client_msg_error. */
		evbuffer_add_printf(c->stderr_data, "%s", cause);
		server_push_stderr(c);
		free(pdata);
		free(cause);
	}

out:
	cmdq_continue(c->cmdq);
}
开发者ID:kylape,项目名称:tmux,代码行数:34,代码来源:cmd-load-buffer.c


示例14: ASSERT

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

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


示例15: tr_peerIoReadBytes

void
tr_peerIoReadBytes( tr_peerIo       * io,
                    struct evbuffer * inbuf,
                    void            * bytes,
                    size_t            byteCount )
{
    assert( tr_isPeerIo( io ) );
    /* FIXME(libevent2): use evbuffer_get_length() */
    assert( EVBUFFER_LENGTH( inbuf ) >= byteCount );

    switch( io->encryptionMode )
    {
        case PEER_ENCRYPTION_NONE:
            evbuffer_remove( inbuf, bytes, byteCount );
            break;

        case PEER_ENCRYPTION_RC4:
            /* FIXME(libevent2): loop through calls to evbuffer_get_contiguous_space() + evbuffer_drain() */
            tr_cryptoDecrypt( io->crypto, byteCount, EVBUFFER_DATA(inbuf), bytes );
            evbuffer_drain(inbuf, byteCount );
            break;

        default:
            assert( 0 );
    }
}
开发者ID:miracle2k,项目名称:transmission,代码行数:26,代码来源:peer-io.c


示例16: OnBufferedRead

void OnBufferedRead(struct bufferevent *bev, void *arg) {
    struct Poll *poll=(struct Poll *)arg;
    struct evbuffer *buffer = EVBUFFER_INPUT(bev);
    u_char *data = EVBUFFER_DATA(buffer);
    u_int len = EVBUFFER_LENGTH(buffer);
    hexPrint(data,len);
}
开发者ID:kalloc,项目名称:tester,代码行数:7,代码来源:ssh4.c


示例17: cmd_capture_pane_pending

static char *
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
    size_t *len)
{
	struct evbuffer	*pending;
	char		*buf, *line, tmp[5];
	size_t		 linelen;
	u_int		 i;

	pending = input_pending(wp);
	if (pending == NULL)
		return (xstrdup(""));

	line = EVBUFFER_DATA(pending);
	linelen = EVBUFFER_LENGTH(pending);

	buf = xstrdup("");
	if (args_has(args, 'C')) {
		for (i = 0; i < linelen; i++) {
			if (line[i] >= ' ') {
				tmp[0] = line[i];
				tmp[1] = '\0';
			} else
				xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]);
			buf = cmd_capture_pane_append(buf, len, tmp,
			    strlen(tmp));
		}
	} else
		buf = cmd_capture_pane_append(buf, len, line, linelen);
	return (buf);
}
开发者ID:east11210,项目名称:tmux,代码行数:31,代码来源:cmd-capture-pane.c


示例18: void

struct StreamRequest *new_stream_request(const char *method, const char *source_address, int source_port, const char *path,
        void (*header_cb)(struct bufferevent *bev, struct evkeyvalq *headers, void *arg),
        void (*read_cb)(struct bufferevent *bev, void *arg),
        void (*error_cb)(struct bufferevent *bev, void *arg),
        void *arg) {
    struct StreamRequest *sr;
    int fd;
    struct evbuffer *http_request;
    
    fd = stream_request_connect(source_address, source_port);
    if (fd == -1) {
        return NULL;
    }
    
    sr = malloc(sizeof(struct StreamRequest));
    sr->fd = fd;
    sr->state = read_firstline;
    sr->header_cb = header_cb;
    sr->read_cb = read_cb;
    sr->error_cb = error_cb;
    sr->arg = arg;
    sr->bev = bufferevent_new(sr->fd, stream_request_readcb, stream_request_writecb, stream_request_errorcb, sr);
    http_request = evbuffer_new();
    evbuffer_add_printf(http_request, "%s %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", method, path, source_address);
    bufferevent_write(sr->bev, (char *)EVBUFFER_DATA(http_request), EVBUFFER_LENGTH(http_request));
    evbuffer_free(http_request);
    
    return sr;
}
开发者ID:jayridge,项目名称:simplehttp,代码行数:29,代码来源:stream_request.c


示例19: cob_

void TEvhttpClientChannel::finish(struct evhttp_request* req) {
  if (req == NULL) {
    try {
      cob_();
    } catch (const TTransportException& e) {
      if (e.getType() == TTransportException::END_OF_FILE)
        throw TException("connect failed");
      else
        throw;
    }
    return;
  } else if (req->response_code != 200) {
    try {
      cob_();
    } catch (const TTransportException& e) {
      std::stringstream ss;
      ss << "server returned code " << req->response_code;
      if (req->response_code_line)
        ss << ": " << req->response_code_line;
      if (e.getType() == TTransportException::END_OF_FILE)
        throw TException(ss.str());
      else
        throw;
    }
    return;
  }
  recvBuf_->resetBuffer(EVBUFFER_DATA(req->input_buffer),
                        static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)));
  cob_();
  return;
}
开发者ID:AltspaceVR,项目名称:thrift,代码行数:31,代码来源:TEvhttpClientChannel.cpp


示例20: http_readcb

static void
http_readcb(struct bufferevent *bev, void *arg)
{
	const char *what = "This is funny";

 	event_debug(("%s: %s\n", __func__, EVBUFFER_DATA(bev->input)));
	
	if (evbuffer_find(bev->input,
		(const unsigned char*) what, strlen(what)) != NULL) {
		struct evhttp_request *req = evhttp_request_new(NULL, NULL);
		enum message_read_status done;

		req->kind = EVHTTP_RESPONSE;
		done = evhttp_parse_firstline(req, bev->input);
		if (done != ALL_DATA_READ)
			goto out;

		done = evhttp_parse_headers(req, bev->input);
		if (done != ALL_DATA_READ)
			goto out;

		if (done == 1 &&
		    evhttp_find_header(req->input_headers,
			"Content-Type") != NULL)
			test_ok++;

	out:
		evhttp_request_free(req);
		bufferevent_disable(bev, EV_READ);
		if (base)
			event_base_loopexit(base, NULL);
		else
			event_loopexit(NULL);
	}
}
开发者ID:AllanXiang,项目名称:Source,代码行数:35,代码来源:regress_http.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ EVBUFFER_LENGTH函数代码示例发布时间:2022-05-30
下一篇:
C++ EVAL_RESULT函数代码示例发布时间: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