HP-UX Event ManagerProgrammer's Guide

Matching Event Names
The EVM naming policy enables you to extend an event name with any number of trailing
components, yet still match its base name. This means that you cannot depend on an event with
exactly the name you expect it to have, because it may have extra trailing components.
To compare an event's name against a known name, you must not use the usual string comparison
functions because they incorrectly fail to match the name if components are added. Instead, you
must use EVM's name-matching functions. These functions match an event name against the
pattern you supply, ignoring any trailing components in the candidate name. They also enable
you to include wildcard characters in your name pattern.
Example 4-9 introduces the following functions and describes EVM name-matching functions:
EvmEventNameMatch Takes the following input arguments: an event name string (which
may contain wildcard characters) and an event. Returns an indication of whether the event
matches the name string.
EvmEventNameMatchStr Takes an event name in a character string, rather than extracting
it from an event.
The following function uses EvmEventNameMatch API:
Example 4-9 Matching Event Names
#include <stdio.h>
#include <evm/evm.h>
/*===============================================* Function:
main()*===============================================*/
int main()
{ EvmStatus_t status;
EvmEvent_t event;
EvmBoolean_t match;
char buff[80];
/* This section of code reads events from stdin and displays only those events that match the wildcard string
*.msg.
This match will work even though events of this type usually have the name sys.unix.evm.msg.user or
sys.unix.evm.msg.admin. */
while (EvmERROR_NONE ==EvmEventRead(fileno(stdin),&event))
{ EvmEventNameMatch("*.msg",event,&match);
if (match)
{EvmEventFormat(buff,sizeof(buff),event); fprintf(stdout,"%s\n",buff); } }}
Dealing with Missed Events
If you are developing an application that subscribes for a set of events that can be posted in high
volume over a short period, your program may occasionally be notified by the EVM daemon
that it has missed one or more events. This occurs if the program has a significant amount of
processing to do and is unable to handle when a new event arrives immediately, causing
unhandled events to fill the connection buffers. It watches for notification of missed events by
including the EvmREASON_EVENTS_MISSED reason in its callback function and displays a
message that includes the number of events missed. For more information about missed events,
see “Missed Events” (page 35).
Example 4-10 shows how to subscribe for all events and displays each event on stdout as it
arrives.
Dealing with Missed Events 51