_VAPPLY - call arbitrary function with variable arg list.

(GCOS-8 only)

Usage:

#include <stdarg.h>
retval = _vapply( function_ptr, arglist );

Where:

type (*function_ptr)();
points to the function you want to call. The type of value returned by this function can be up to two machine words long.
va_list arglist;
is a variable argument list containing the arguments that should be passed to the function.
retval;
is the value returned by the function indicated by "function_ptr". This can have a length of up to two machine words.

Description:

"_vapply" constructs and executes a call to the specified function. The arguments in the "arglist" variable argument list are passed to the function and the value which the function returns is returned to "retval".

"_vapply" is particularly useful for routines which are called with a variable number of arguments and which wish to pass these arguments on to another function.

Examples:

#include <stdio.h>
#include <stdarg.h>
#include <time.h>
logmsg( const struct tm *logtime, ...)
{
    /* format message with time, then print out stdout */
    va_list ap;
    va_start(ap,logtime);
    printf("%s:\n",asctime(logtime));
    _vapply(printf,ap);
    va_end(ap);
}

Note: this is just an artificial example. You would normally use the "vprintf" function for this purpose.

See Also:

expl nsc lib apply

Copyright © 1996, Thinkage Ltd.