Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Event Manager Programmer's Guide: HP-UX 11i v3 Edition 1 > Chapter 4 Sample EVM Programming Operations

Using Variable-Length Argument Lists

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

You can reduce the size and improve the efficiency of your code by creating an event and adding items to it in a single step, using the varargs (variable-length argument list) version of the create function. You can add items to an existing event efficiently by using the varargs version of theitem-setfunction.

Example 4-2 introduces the following functions:

  • EvmEventCreateVa — Creates an event, and supplies item names and values in a single call. For more information about this function, see EvmEventCreateVa(3).

  • EvmItemSetVa — Sets data item values in the event. The list of items and variables to be supplied is the same as that supplied for EvmEventCreateVa. For more information about this function, see EvmItemSetVa(3).

Example 4-2 Using Variable-Length Argument Lists

#include <stdio.h>
#include <evm/evm.h>
int main()
{	EvmEvent_t event;
EvmItemValue_t  itemval_name, itemval_priority;			
/* Each item you include in EvmEventCreateVa() function must have an identifier and a value, and the argument list
must be terminated with an EvmITEM_NONE identifier. 
*//* NOTE: To store the values of standard data items in an event, they should first be stored in a variable of type 
EvmItemValue_t which is an union whose definition can be found in /usr/include/evm/evm.h 
*//* NOTE: EvmItemValue_t is an union, so you will have to use different variables to store different items, 
otherwise they will be overwritten */	
itemval_name.NAME = "sys.unix.evm"; 	
itemval_priority.PRIORITY = 200;		
EvmEventCreateVa(&event, EvmITEM_NAME, itemval_name, EvmITEM_PRIORITY, itemval_priority, EvmITEM_NONE);	
/* The varargs version of EvmItemSetva() uses the same style of argument list as EvmEventCreateVa(). In this	example, 
items that are already present in the event are being added, so the new values just replace the old	ones. */	
itemval_name.NAME = "sys.unix.evm.mark"; 	
itemval_priority.PRIORITY = 100;		
EvmItemSetVa(event,EvmITEM_NAME, itemval_name, EvmITEM_PRIORITY, itemval_priority, EvmITEM_NONE);	
/* You can easily include variable data item in a varargs list by using the EvmITEM_VAR_Xxx item identifier, where	
Xxx is the type of the variable. If you include a variable in this way, it is very important that you follow the 
identifier with the correct number of	arguments to describe the variable. You must always supply two further 
arguments: a string containing the name of the variable, and a value argument. The type of	the value argument 
depends on thetype of the variable in this example, the first variable requires a string and the second requires 
an integer. Certain types of variable require an additional argument - see EvmItemSet (3) for	more details.*/	
EvmItemSetVa(event, EvmITEM_VAR_UINT16,"exit_code",17, EvmITEM_VAR_STRING,"progname","my_app", EvmITEM_NONE); 
/* The call to EvmEventDump() displays a formatted dump of the event on stdout, to demonstrate that the 
expected data items and variables have been added correctly. */		
EvmEventDump(event,stdout);
/* When you have finished with the event, free the storage space the event uses. */		
EvmEventDestroy(event);	}
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2007 Hewlett-Packard Development Company, L.P.