Sun Microsystems, Inc.
spacerspacer
spacer   www.sun.com docs.sun.com | | |  
spacer
black dot
   
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
    
 
System Event Library Functionssysevent_get_class_name(3SYSEVENT)


NAME

 sysevent_get_class_name, sysevent_get_subclass_name, sysevent_get_event_id, sysevent_get_size - get class name, subclass name, ID or buffer size of event

SYNOPSIS

 
cc [flag ...]  file ...-lsysevent [library ...] 
#include <libsysevent.h>
char *sysevent_get_class_name(sysevent_t *ev);
 char *sysevent_get_subclass_name(sysevent_t *ev);
 void sysevent_get_event_id(sysevent_t *ev, sysevent_id_t *eid);
 int sysevent_get_size(sysevent_t *ev);

PARAMETERS

 
eid
pointer to sysevent_id_t structure
ev
handle to event

DESCRIPTION

 

The sysevent_get_class_name() and sysevent_get_subclass_name() functions return, respectively, the class and subclass names for the provided event ev.

The sysevent_get_event_id() function returns the unique event identifier associated with the sysevent handle, ev. The identifier is composed of a relative timestamp issued at the time the event was generated and a sequence number to ensure uniqueness.
 
typedef struct sysevent_id {
        uint64_t        eid_seq;
        hrtime_t        eid_ts;
} sysevent_id_t;

The sysevent_get_size() function returns the size of the event buffer, ev.

EXAMPLES

 Example 1. Parse sysevent header information.
 

The following example parses sysevent header information from an application's event handler.

 
hrtime_t last_ev_time;
unit64_t last_ev_seq;

void
event_handler(sysevent_t *ev)
{
         sysevent_t *new_ev;
         sysevent_id_t eid;
         
         
         /* Filter on class and subclass */
         if (strcmp(EC_PRIV, sysevent_get_class_name(ev)) != 0) {
                 return;
         } else if (strcmp("ESC_MYSUBCLASS,
             sysevent_get_subclass_name(ev)) != 0) {
                 return;
         }
         
         /*
          * Check for replayed sysevent, time must
          * be greater than previously recorded.
          */
         sysevent_get_event_id(ev, &eid);
         if (eid.eid_ts < last_ev_time ||
             (eid.eid_ts == last_ev_time && eid.eid_seq <=
             last_ev_seq)) {
                 return;
         }
          
         last_ev_time = eid.eid_ts;
         last_ev_seq = eid.eid_seq;
          
         /* Store event for later processing */
         ev_sz = sysevent_get_size(ev):
         new_ev (sysevent_t *)malloc(ev_sz);
         bcopy(ev, new_ev, ev_sz);
         queue_event(new_ev);
}

ATTRIBUTES

 

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
Interface StabilityEvolving
MT-LevelMT-Safe

SEE ALSO

 

attributes(5)


SunOS 5.9Go To TopLast Changed 12 Sep 2000

 
      
      
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.