System Event Library Functions syseventpostevent(3SYSEVENT)
NAME
syseventpostevent - post system event for applications
SYNOPSIS
cc [ flag... ] file... -lsysevent -lnvpair [ library... ]
#include
#include
int syseventpostevent(char *class, char *subclass, char *vendor,
char *publisher, nvlistt *attrlist, syseventidt *eid);
PARAMETERS
attrlist pointer to an nvlistt, listing the name-value
attributes associated with the event, or NUL
if there are no such attributes for this event
class pointer to a string defining the event class
eid pointer to a system unique identifier
publisher pointer to a string defining the event's pub-
lisher nam
subclass pointer to a string defining the event subclass
vendor pointer to a string defining the vendor
DESCRIPTION
The syseventpostevent() function causes a system event of
the specified class, subclass, vendor, and publisher to be
generated on behalf of the caller and queued for delivery to
the sysevent daemon syseventd(1M).
The vendor should be the company stock symbol (or similarly
enduring identifier) of the event posting application. The
publisher should be the name of the application generating
the event.
For example, all events posted by Sun applications begin
with the company's stock symbol, "SUNW". The publisher is
usually the name of the application generating the system
event. A system event generated by devfsadm(1M) has a pub-
lisher string of devfsadm.
SunOS 5.11 Last change: 26 May 2004 1
System Event Library Functions syseventpostevent(3SYSEVENT)
The publisher information is used by sysevent consumers to
filter unwanted event publishers.
Upon successful queuing of the system event, a unique iden-
tifier is assigned to eid.
RETURN VALUES
The syseventpostevent() function returns 0 if the system
event has been queued successfully for delivery. Otherwise
it returns -1 and sets errno to indicate the error.
ERORS
The syseventpostevent() function will fail if:
ENOMEM Insufficient resources to queue the system event.
EIO The syseventd daemon is not responding and events
cannot be queued or delivered at this time.
EINVAL Invalid argument.
EPERM Permission denied.
EFAULT A copy error occurred.
EXAMPLES
Example 1 Post a system event event with no attributes.
The following example posts a system event event with no
attributes.
if (syseventpostevent(ECPRIV, "ESCMYSUBCLAS", "SUNW", argv[0],
NUL), &eid == -1) {
fprintf(stderr, "error logging system event\n");
}
Example 2 Post a system event with two name-value pair
attributes.
The following example posts a system event event with two
name-value pair attributes, an integer value and a string.
SunOS 5.11 Last change: 26 May 2004 2
System Event Library Functions syseventpostevent(3SYSEVENT)
nvlistt *attrlist;
uint32t uint32val = 0XF;
char *stringval = "string value data";
if (nvlistalloc(&attrlist, 0, 0) == 0) {
err = nvlistadduint32(attrlist, "uint32 data", uint32val);
if (err == 0)
err = nvlistaddstring(attrlist, "str data",
stringval);
if (err == 0)
err = syseventpostevent(ECPRIV, "ESCMYSUBCLAS",
"SUNW", argv[0], attrlist, &eid);
if (err != 0)
fprintf(stderr, "error logging system event\n");
nvlistfree(attrlist);
}
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Evolving
MT-Level MT-Safe
SEE ALSO
devfsadm(1M), syseventd(1M), nvlistaddboolean(3NVPAIR),
nvlistalloc(3NVPAIR), attributes(5)
SunOS 5.11 Last change: 26 May 2004 3
|