|
System Event Library Functions | sysevent_get_class_name(3SYSEVENT) |
| 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); |
|
-
eid
- pointer to sysevent_id_t structure
-
ev
- handle to event
|
|
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.
|
| 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);
}
|
|
|
|
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Evolving |
MT-Level | MT-Safe |
|
| |