HP-UX Event ManagerProgrammer's Guide
Example 4-1 Performing Simple Event Manipulations
#include <stdio.h>
#include <evm/evm.h>
int main()
{
EvmEvent_t event;
EvmItemValue_t itemval,itemval_local;
EvmStatus_t status;
/* You can create an empty event with EvmEventCreate()
function. When you use this function, you supply a
pointer to the event handle, and you receive an event
that contains no standard data items. Even though the
event is empty, it does take up memory, and you must
eventually use EvmEventDestroy() to free the space. */
EvmEventCreate(&event);
/* You can add any of the standard data items to the
events using EvmItemSet() function. In most cases,
however, the only item you will want to add in your
program is the name of the event - other standard items
will be automatically added when you post the event, or
are better included in the event template. For more
information see EvmItemSet(3) man page.*/
/* 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 */
itemval_local.NAME = "sys.unix.evm";
EvmItemSet(event, EvmITEM_NAME, itemval_local);
itemval_local.PRIORITY = 200;
EvmItemSet(event, EvmITEM_PRIORITY, itemval_local);
/* You can retrieve any item from the event using
EvmItemGet() function. The value is copied from the event
into storage referenced through your EvmItemValue_t
structure. So you must use EvmItemRelease() function to
release the referenced storage when you have finished
using the items. Retrieving the item does not remove it
from the event; you receive a copy and you can get it as
many times as you want.*/
status = EvmItemGet(event, EvmITEM_NAME, &itemval);
if (status == EvmERROR_NONE)
{
fprintf(stdout, "Event name: %s\n", itemval.NAME);
EvmItemRelease(EvmITEM_NAME, itemval);
}
/* When you have finished with the event, free the
storage space used by the event.*/
EvmEventDestroy(event);
}
Using Variable-Length Argument Lists
38 Sample EVM Programming Operations