I have a third-party function with a signature:
int secretfoo(int numargs, ...);
I can call it directly, but what I really want is to wrap it with my function, which will add additional arguments to it.
Suppose that a simple case of integers: I want to call secretfoo(2, 10, 20)have been translated as follows: when I see the argument 10, to duplicate it and make a call: secretfoo(3, 10, 10, 20). I want to do this in a wrapper:
int foowrapper(int numargs, ...);
This shell parses argumetns and calls secretfooas described above.
Can this be done with the ability to be carried with va_list/ va_argetc? Any other way?
source
share