xref: /illumos-gate/usr/src/man/man3sysevent/sysevent_get_vendor_name.3sysevent (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
te
Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
Copyright (c) 2015, Joyent, 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]
SYSEVENT_GET_VENDOR_NAME 3SYSEVENT "Jun 29, 2015"
NAME
sysevent_get_vendor_name, sysevent_get_pub_name, sysevent_get_pid - get vendor name, publisher name or processor ID of event
SYNOPSIS

cc  [flag .\|.\|.] file.\|.\|. -lsysevent [library .\|.\|.]
#include <libsysevent.h>

char *sysevent_get_vendor_name(sysevent_t *ev);

char *sysevent_get_pub_name(sysevent_t *ev);

void sysevent_get_pid(sysevent_t *ev, pid_t *pid);
PARAMETERS
ev

handle to a system event object

DESCRIPTION

The sysevent_get_pub_name() function returns the publisher name for the sysevent handle, ev. The publisher name identifies the name of the publishing application or kernel subsystem of the sysevent.

The sysevent_get_pid() function sets the process ID pid to that of the publishing application or SE_KERN_PID for sysevents originating in the kernel. The publisher name and PID are useful for implementing event acknowledgement.

The sysevent_get_vendor_name() function returns the vendor string for the publishing application or kernel subsystem. A vendor string is the company's stock symbol that provided the application or kernel subsystem that generated the system event. This information is useful for filtering sysevents for one or more vendors.

The interface manages the allocation of the vendor and publisher name strings, but it is the caller's responsibility to free the strings when they are no longer needed by calling free(3MALLOC). If the new vendor and publisher name strings cannot be created, sysevent_get_vendor_name() and sysevent_get_pub_name() return a null pointer and may set errno to ENOMEM to indicate that the storage space available is insufficient.

EXAMPLES

Example 1 Parse sysevent header information.

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

char *vendor;
char *pub;
pid_t pid;

void
event_handler(sysevent_t *ev)
{
 if (strcmp(EC_PRIV, sysevent_get_class_name(ev)) != 0) {
 return;
 }

 vendor = sysevent_get_vendor_name(ev);
 if (strcmp("SUNW", vendor) != 0) {
 free(vendor);
 return;
 }
 pub = sysevent_get_pub_name(ev);
 if (strcmp("test_daemon", pub) != 0) {
 free(vendor);
 free(pub);
 return;
 }
 sysevent_get_pid(ev, &pid);
 (void) kill(pid, SIGUSR1);

 free(vendor);
 free(pub);
}
ATTRIBUTES

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

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Committed
MT-Level MT-Safe
SEE ALSO

malloc (3MALLOC), attributes (7)

NOTES

The libsysevent interfaces do not work at all in non-global zones.