Skip Navigation Links | |
Exit Print View | |
man pages section 3: Extended Library Functions, Volume 1 Oracle Solaris 11.1 Information Library |
Extended Library Functions, Volume 1
CIRCLEQ_HEAD_INITIALIZER(3EXT)
cpc_walk_generic_events_all(3CPC)
cpc_walk_generic_events_pic(3CPC)
ct_dev_status_get_aset(3CONTRACT)
ct_dev_status_get_dev_state(3CONTRACT)
ct_dev_status_get_minor(3CONTRACT)
ct_dev_status_get_noneg(3CONTRACT)
ct_dev_tmpl_clear_noneg(3CONTRACT)
ct_dev_tmpl_get_aset(3CONTRACT)
ct_dev_tmpl_get_minor(3CONTRACT)
ct_dev_tmpl_get_noneg(3CONTRACT)
ct_dev_tmpl_set_aset(3CONTRACT)
ct_dev_tmpl_set_minor(3CONTRACT)
ct_dev_tmpl_set_noneg(3CONTRACT)
ct_event_read_critical(3CONTRACT)
ct_pr_event_get_exitstatus(3CONTRACT)
ct_pr_event_get_gcorefile(3CONTRACT)
ct_pr_event_get_pcorefile(3CONTRACT)
ct_pr_event_get_pid(3CONTRACT)
ct_pr_event_get_ppid(3CONTRACT)
ct_pr_event_get_sender(3CONTRACT)
ct_pr_event_get_senderct(3CONTRACT)
ct_pr_event_get_signal(3CONTRACT)
ct_pr_event_get_zcorefile(3CONTRACT)
ct_pr_status_get_contracts(3CONTRACT)
ct_pr_status_get_fatal(3CONTRACT)
ct_pr_status_get_members(3CONTRACT)
ct_pr_status_get_param(3CONTRACT)
ct_pr_status_get_svc_aux(3CONTRACT)
ct_pr_status_get_svc_creator(3CONTRACT)
ct_pr_status_get_svc_ctid(3CONTRACT)
ct_pr_status_get_svc_fmri(3CONTRACT)
ct_pr_tmpl_get_fatal(3CONTRACT)
ct_pr_tmpl_get_param(3CONTRACT)
ct_pr_tmpl_get_svc_aux(3CONTRACT)
ct_pr_tmpl_get_svc_fmri(3CONTRACT)
ct_pr_tmpl_get_transfer(3CONTRACT)
ct_pr_tmpl_set_fatal(3CONTRACT)
ct_pr_tmpl_set_param(3CONTRACT)
ct_pr_tmpl_set_svc_aux(3CONTRACT)
ct_pr_tmpl_set_svc_fmri(3CONTRACT)
ct_pr_tmpl_set_transfer(3CONTRACT)
ct_status_get_cookie(3CONTRACT)
ct_status_get_critical(3CONTRACT)
ct_status_get_holder(3CONTRACT)
ct_status_get_informative(3CONTRACT)
ct_status_get_nevents(3CONTRACT)
ct_status_get_nevid(3CONTRACT)
ct_status_get_ntime(3CONTRACT)
ct_status_get_qtime(3CONTRACT)
ct_status_get_state(3CONTRACT)
ct_status_get_zoneid(3CONTRACT)
ct_tmpl_get_critical(3CONTRACT)
ct_tmpl_get_informative(3CONTRACT)
ct_tmpl_set_critical(3CONTRACT)
ct_tmpl_set_informative(3CONTRACT)
dat_evd_clear_unwaitable(3DAT)
dat_get_consumer_context(3DAT)
dat_registry_add_provider(3DAT)
dat_registry_list_providers(3DAT)
dat_registry_remove_provider(3DAT)
dat_set_consumer_context(3DAT)
devid_deviceid_to_nmlist(3DEVID)
di_link_next_by_lnode(3DEVINFO)
di_link_next_by_node(3DEVINFO)
di_lnode_private_get(3DEVINFO)
di_lnode_private_set(3DEVINFO)
di_minor_private_get(3DEVINFO)
di_minor_private_set(3DEVINFO)
di_path_client_devfs_path(3DEVINFO)
di_path_client_next_path(3DEVINFO)
di_path_phci_next_path(3DEVINFO)
di_path_prop_lookup_bytes(3DEVINFO)
di_path_prop_lookup_int64s(3DEVINFO)
di_path_prop_lookup_ints(3DEVINFO)
di_path_prop_lookup_strings(3DEVINFO)
di_path_prop_strings(3DEVINFO)
di_prom_prop_lookup_bytes(3DEVINFO)
di_prom_prop_lookup_ints(3DEVINFO)
di_prom_prop_lookup_strings(3DEVINFO)
di_prop_lookup_bytes(3DEVINFO)
di_prop_lookup_int64(3DEVINFO)
di_prop_lookup_strings(3DEVINFO)
ea_match_object_catalog(3EXACCT)
- handle variable argument list
#include <stdarg.h> va_list pvar; void va_start(va_list pvar, void name);
(type *) va_arg(va_list pvar, type);
void va_copy(va_list dest, va_list src);
void va_end(va_list pvar);
This set of macros allows portable procedures that accept variable numbers of arguments of variable types to be written. Routines that have variable argument lists (such as printf) but do not use stdarg are inherently non-portable, as different machines use different argument-passing conventions.
va_list is a type defined for the variable used to traverse the list.
The va_start macro is invoked before any access to the unnamed arguments and initializes pvar for subsequent use by va_arg() and va_end(). The parameter name is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the , ...). If this parameter is declared with the register storage class or with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined.
The parameter name is required under strict ANSI C compilation. In other compilation modes, name need not be supplied and the second parameter to the va_start() macro can be left empty (for example, va_start(pvar, );). This allows for routines that contain no parameters before the ... in the variable parameter list.
The va_arg() macro expands to an expression that has the type and value of the next argument in the call. The parameter pvar should have been previously initialized by va_start(). Each invocation of va_arg() modifies pvar so that the values of successive arguments are returned in turn. The parameter type is the type name of the next argument to be returned. The type name must be specified in such a way so that the type of a pointer to an object that has the specified type can be obtained simply by postfixing a * to type. If there is no actual next argument, or if type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined.
The va_copy() macro saves the state represented by the va_listsrc in the va_list dest. The va_list passed as dest should not be initialized by a previous call to va_start(), and must be passed to va_end() before being reused as a parameter to va_start() or as the dest parameter of a subsequent call to va_copy(). The behavior is undefined should any of these restrictions not be met.
The va_end() macro is used to clean up.
Multiple traversals, each bracketed by va_start() and va_end(), are possible.
Example 1 A sample program.
This example gathers into an array a list of arguments that are pointers to strings (but not more than MAXARGS arguments) with function f1, then passes the array as a single argument to function f2. The number of pointers is specified by the first argument to f1.
#include <stdarg.h> #define MAXARGS 31 void f1(int n_ptrs, ...) { va_list ap; char *array[MAXARGS]; int ptr_no = 0; if (n_ptrs > MAXARGS) n_ptrs = MAXARGS; va_start(ap, n_ptrs); while (ptr_no < n_ptrs) array[ptr_no++] = va_arg(ap, char*); va_end(ap); f2(n_ptrs, array); }
Each call to f1 shall have visible the definition of the function or a declaration such as
void f1(int, ...)
See attributes(5) for descriptions of the following attributes:
|
vprintf(3C), attributes(5), standards(5)
It is the responsibility of the calling routine to specify in some manner how many arguments there are, since it is not always possible to determine the number of arguments from the stack frame. For example, execl is passed a zero pointer to signal the end of the list. The printf function can determine the number of arguments by the format. It is non-portable to specify a second argument of char, short, or float to va_arg(), because arguments seen by the called function are not char, short, or float. C converts char and short arguments to int and converts float arguments to double before passing them to a function.