1

Any libcurl expert who might knows something about it?

I notice this because I cannot turn libcurl VERBOSE off:

curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);

When I trace thru the call into libcurl, I found that 0L (long) is converted into a non-zero number, causing the VERBOSE to be always on. I haven't tried but I am pretty sure any long param will not be passed correctly.

data->set.verbose = (0 != va_arg(param, long))?TRUE:FALSE;

where

#define va_arg _crt_va_arg
#define _crt_va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define _INTSIZEOF(n)   ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )

But I am not sure what these are doing.
Why it this occuring and how to fix it?

I am using Visual Studio 2010 C++ with libcurl 7.27.0

M W
  • 1,269
  • 5
  • 21
  • 31

1 Answers1

1

va_arg() is using pointer arithmetic to extract the 0L from your va_list param. You can read more on the va_list type here or here. It is not converting your 0L to a non-zero number.

Try calling curl_easy_setopt() before opening your connection. The documentation states that your verbose setting is "set once to go for many independent connections" (urldata.h ln 1537).

If you still don't believe it's working, you can cast your CURL* into a SessionHandle* and inspect it in the debugger, eg:

struct SessionHandle *data = reinterpret_cast<SessionHandle*>(curl);
// Inspect data->set.verbose

You'll find the definition of SessionHandle in urldata.h.

Community
  • 1
  • 1
Scotty
  • 2,480
  • 2
  • 16
  • 20
  • Thanks Scotty! Very helpful posts on va_last and va_args. The SessionHandle thing is a good tip so I can now check out curl's state. I still can't turn off Verbose but maybe that is another question. I did move the call around (right after creation of CURL handle) but still no luck. Wonder if that's because I didn't call global_cleanup every time as I am debugging. – M W Aug 30 '12 at 15:23