Monday, March 19, 2007

Wrap Vararg Functions

In my mind to wrap a vararg function I have to call its corresponding v-function (e.g. printf and vprintf). For those functions that do not have such counterparts, I intended to use Zhenyu's assembly code to inspect the stack. Last weekend when looking into cURL's source code, I found out that using the va_arg macro and passing the resulting pointer directly to vararg functions worked quite well. It's so easy! Phew!

1 comment:

Jeff said...

I'd love to see a C code example. Also are you using the C99 varargs, or the older POSIX varargs?

Finally, do you think there is any chance of intercepting a call to a non-vararg function with a vararg warpper?