'\" te .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH SYSEVENT_POST_EVENT 3SYSEVENT "Jul 24, 2009" .SH NAME sysevent_post_event \- post system event for applications .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lsysevent\fR \fB -lnvpair \fR [ \fIlibrary\fR\&.\|.\|. ] #include #include \fBint\fR \fBsysevent_post_event\fR(\fBchar *\fR\fIclass\fR, \fBchar *\fR\fIsubclass\fR, \fBchar *\fR\fIvendor\fR, \fBchar *\fR\fIpublisher\fR, \fBnvlist_t *\fR\fIattr_list\fR, \fBsysevent_id_t *\fR\fIeid\fR); .fi .SH PARAMETERS .sp .ne 2 .na \fB\fIattr_list\fR\fR .ad .RS 13n pointer to an \fBnvlist_t\fR, listing the name-value attributes associated with the event, or \fINULL\fR if there are no such attributes for this event .RE .sp .ne 2 .na \fB\fIclass\fR\fR .ad .RS 13n pointer to a string defining the event class .RE .sp .ne 2 .na \fB\fIeid\fR\fR .ad .RS 13n pointer to a system unique identifier .RE .sp .ne 2 .na \fB\fIpublisher\fR\fR .ad .RS 13n pointer to a string defining the event's publisher nam .RE .sp .ne 2 .na \fB\fIsubclass\fR\fR .ad .RS 13n pointer to a string defining the event subclass .RE .sp .ne 2 .na \fB\fIvendor\fR\fR .ad .RS 13n pointer to a string defining the vendor .RE .SH DESCRIPTION .sp .LP The \fBsysevent_post_event()\fR 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 \fBsyseventd\fR(1M). .sp .LP 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. .sp .LP 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 \fBdevfsadm\fR(1M) has a publisher string of \fBdevfsadm\fR. .sp .LP The publisher information is used by sysevent consumers to filter unwanted event publishers. .sp .LP Upon successful queuing of the system event, a unique identifier is assigned to \fIeid\fR. .SH RETURN VALUES .sp .LP The \fBsysevent_post_event()\fR function returns \fB0\fR if the system event has been queued successfully for delivery. Otherwise it returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error. .SH ERRORS .sp .LP The \fBsysevent_post_event()\fR function will fail if: .sp .ne 2 .na \fB\fBENOMEM\fR\fR .ad .RS 10n Insufficient resources to queue the system event. .RE .sp .ne 2 .na \fB\fBEIO\fR\fR .ad .RS 10n The \fBsyseventd\fR daemon is not responding and events cannot be queued or delivered at this time. .RE .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n Invalid argument. .RE .sp .ne 2 .na \fB\fBEPERM\fR\fR .ad .RS 10n Permission denied. .RE .sp .ne 2 .na \fB\fBEFAULT\fR\fR .ad .RS 10n A copy error occurred. .RE .SH EXAMPLES .LP \fBExample 1 \fRPost a system event event with no attributes. .sp .LP The following example posts a system event event with no attributes. .sp .in +2 .nf if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0], NULL), &eid == -1) { fprintf(stderr, "error logging system event\en"); } .fi .in -2 .LP \fBExample 2 \fRPost a system event with two name-value pair attributes. .sp .LP The following example posts a system event event with two name-value pair attributes, an integer value and a string. .sp .in +2 .nf nvlist_t *attr_list; uint32_t uint32_val = 0XFFFFFFFF; char *string_val = "string value data"; if (nvlist_alloc(&attr_list, 0, 0) == 0) { err = nvlist_add_uint32(attr_list, "uint32 data", uint32_val); if (err == 0) err = nvlist_add_string(attr_list, "str data", string_val); if (err == 0) err = sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0], attr_list, &eid); if (err != 0) fprintf(stderr, "error logging system event\en"); nvlist_free(attr_list); } .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level MT-Safe .TE .SH SEE ALSO .sp .LP \fBdevfsadm\fR(1M), \fBsyseventd\fR(1M), \fBnvlist_add_boolean\fR(3NVPAIR), \fBnvlist_alloc\fR(3NVPAIR), \fBattributes\fR(5) .SH NOTES .sp .LP The \fBlibsysevent\fR interfaces do not work at all in non-global zones.