Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6897127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:07:49+00:00 2026-05-27T07:07:49+00:00

I have an output evbuffer that I want to populate with the following data:

  • 0

I have an output evbuffer that I want to populate with the following data:

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�@�

I was using evbuffer_add_printf(...),

I have the following C callback function:

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!!!
}

So I have the binary data pointer (binData) and I have a length (contLen), how do I print this to the output buffer?

Many thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:07:49+00:00Added an answer on May 27, 2026 at 7:07 am

    You can’t add binary data in safe way using evbuffer_add_printf. Try evbuffer_add function:

    int
    evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen)
    {
        size_t need = buf->misalign + buf->off + datlen;
        size_t oldoff = buf->off;
    
        if (buf->totallen < need) {
                if (evbuffer_expand(buf, datlen) == -1)
                        return (-1);
        }
    
        memcpy(buf->buffer + buf->off, data, datlen);
        buf->off += datlen;
    
        if (datlen && buf->cb != NULL)
                (*buf->cb)(buf, oldoff, buf->off, buf->cbarg);
    
        return (0);
    }
    

    Can’t find good documentation, the best I’ve seen except for source code is:

    http://transmission.sourcearchive.com/documentation/1.75/event_8h_b652a2f82d23509713258a6e44697164.html#b652a2f82d23509713258a6e44697164

     int evbuffer_add   (   struct evbuffer *   ,
        const void *    ,
        size_t           
    )           
    

    Append data to the end of an evbuffer.

    Parameters:

        buf     the event buffer to be appended to
        data    pointer to the beginning of the data buffer
        datlen  the number of bytes to be copied from the data buffer 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have output from two sources that I want to put together on
I want to read multiple objects (my own class Term) that I have output
I have html output in paging section like this; <p>&nbsp;<strong class=active>1</strong>&nbsp;<a href=http://localhost/project/report_nc/search_now/1>2</a>&nbsp;<a href=http://localhost/project/report_nc/search_now/2>3</a>&nbsp;<a href=http://localhost/project/report_nc/search_now/1>Next
I have output with this format: /ignore-this/^/../I/want/this@ignore-this I am trying to use an awk
I have output in a list of values. Name Date of Entry C1 -
I have program output that looks like this (tab delim): $ ./mycode somefile 0000000000000000000000000000000000
I have several output listeners that are implementing OutputStream . It can be either
I want to have output of Windows command-line program (say, powercfg -l ) written
I have created a C# console application that contains the namespaces System and System.Data
Currently I have a the following way of retrieving data from my DB: $school->get('studentCount');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.