0
我有,我想用下面的數據來填充輸出evbuffer:C&LIBEVENT:二進制數據添加到輸出緩衝
HTTP/1.1 200 OK
Date: Tue, 06 Dec 2011 10:35:08 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: PHP/5.3.2-1ubuntu4.9
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 48
Content-Type: text/html
��(�ͱ���I�O����H�����ч��
�4�@�
我用evbuffer_add_printf(...)
,
我有下面的C回調功能:
static void echo_read_cb(struct bufferevent *bev, void *ctx){
/* This callback is invoked when there is data to read on bev. */
struct evbuffer *input = bufferevent_get_input(bev);
struct evbuffer *output = bufferevent_get_output(bev);
...
char* response=NULL;
response=applyGetReq(url,data,len);
int contLen=0;
contLen=getContentLength(response);
char* binData=strstr(response,"\r\n\r\n");
binData=binData+strlen("\r\n\r\n");
fwrite(binData,sizeof(char),contLen,stdout);
printf("\n");
evbuffer_add_printf(output,"%s",binData); //I want to print binData as binary, not printf!!!
}
所以我有二進制數據指針(binData),我有一個長度(contLen),我怎麼打印此輸出緩衝區?
提前
真正有用的片段。非常感謝。 – Eamorr
這是'evbuffer_add'本身的源代碼,而不是一個使用示例。閱讀libevent的來源比查找文檔要容易得多。 – osgx
是的,我認爲這是一個片段,但從您的鏈接看,它是源代碼本身。非常感謝。 – Eamorr