bganoush
asked on
Passing var args to another var args...
I have a function that implements a variable argument list and I would like to create an envelope function that would call it...
So on the one hand, I have:
int OriginalFunction(int parm1, int parm2, char *format, ...)
{
va_list ap;
va_start (ap, format);
if (parm1 == 1)
DoVaFunc1 (parm2, format, ap);
else
DoVaFunc2 (parm2, format, ap);
va_end (ap);
return (1);
}
On the other hand, I would like to create a function such as:
int NewFunction (int parm1, int parm2, int parm3, char *format, ...)
{
int ret = 0;
if (parm3 == OK)
ret = OriginalFunction (parm1, parm2, format, ...??...);
return (ret);
}
So what do I need in the "...???..." section? Is this possible without changing the OriginalFunction?
-- Bubba
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
jkr: Why can't I remember the small details....
Thanks.
-- Bubba
1. If you can recognise how many parameters there are without calling the function itself, count them and use assembler to push them.
2. The may be a 'v' version. 'vsprintf' is a good example.
Paul