cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CURL and CULM data structure

From: bch <brad.harder_at_gmail.com>
Date: Fri, 28 Oct 2016 07:59:38 -0700

On Oct 28, 2016 7:38 AM, "Ramachandran, Agalya (Contractor)" <
Agalya_Ramachandran_at_comcast.com> wrote:
>
> Hi,
>
> Am using "%p", to print the handle pointer, and I could able to see the
pointer value in handle.
> But am trying to print the actual value in handle. (i.e data in the
pointer)
> How this can be achieved?

You need to dereference the pointer(s) to whatever final value you want.
Eg: if you have a Curl_easy *p pointer properly initialized:

if(p->cookies) {
  printf(" cookie filename: %s\n", p->cookies->filename);
}

Will print out the string rep of (presumably) the file holding cookies for
this easy session. Note that we test that "cookies" is set at all before we
try to deference ("if(p->cookies)"), because of you try to deference a NULL
pointer (or indeed any "garbage" value), you will have problems.

You can find out what you need by reading up on pointers, memory allocation
(malloc() and free()), structures, and pointer arithmetic.

Note to - my example was of the top of my head, and curl has a tremendous
amount of introspective accessor functions purpose-built to retrieve
information; your use case my already be expertly solved in the project.

-bch

> Regards,
> Agalya
> -----Original Message-----
> From: curl-library [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf
Of Rich Gray
> Sent: Friday, October 28, 2016 9:55 AM
> To: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: CURL and CULM data structure
>
> Ramachandran, Agalya (Contractor) wrote:
> > Hi team,
> >
> > I have a query with respect to CURL and CURLM data structure.
> >
> > For debugging purpose, I want to print the actual value in the
> > following handles.
> >
> > ·CURL *handle;
> >
> > ·CURLM *multi_handle;
> >
> > Can you please guide me what is the data structure for CURL, and how
> > can I print it in ‘C’ language?
> >
> > Regards,
> >
> > Agalya
>
> Use %p to format pointers. It formats addresses as hex.
>
> printf("curl handle %p", handle);
>
> - Rich
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html
>
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-10-28