17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
217836SJohn.Forte@Sun.COM /*
22*12550SJiri.Svoboda@Sun.COM * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
237836SJohn.Forte@Sun.COM */
247836SJohn.Forte@Sun.COM
257836SJohn.Forte@Sun.COM #include "mp_utils.h"
267836SJohn.Forte@Sun.COM
277836SJohn.Forte@Sun.COM
287836SJohn.Forte@Sun.COM /*
297836SJohn.Forte@Sun.COM * Called by the common layer to request the plugin to call
307836SJohn.Forte@Sun.COM * a client application's callback (pClientFn) when a property change
317836SJohn.Forte@Sun.COM * is detected for the given object type.
327836SJohn.Forte@Sun.COM */
337836SJohn.Forte@Sun.COM
347836SJohn.Forte@Sun.COM MP_STATUS
MP_RegisterForObjectPropertyChangesPlugin(MP_OBJECT_PROPERTY_FN pClientFn,MP_OBJECT_TYPE objectType,void * pCallerData)357836SJohn.Forte@Sun.COM MP_RegisterForObjectPropertyChangesPlugin(MP_OBJECT_PROPERTY_FN pClientFn,
367836SJohn.Forte@Sun.COM MP_OBJECT_TYPE objectType,
377836SJohn.Forte@Sun.COM void *pCallerData)
387836SJohn.Forte@Sun.COM {
397836SJohn.Forte@Sun.COM MP_BOOL hasFunc = MP_FALSE;
407836SJohn.Forte@Sun.COM
417836SJohn.Forte@Sun.COM
427836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
43*12550SJiri.Svoboda@Sun.COM " - enter");
447836SJohn.Forte@Sun.COM
457836SJohn.Forte@Sun.COM
467836SJohn.Forte@Sun.COM /* Validate the object type passes in within range */
477836SJohn.Forte@Sun.COM if (objectType > MP_OBJECT_TYPE_MAX) {
487836SJohn.Forte@Sun.COM
497836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
50*12550SJiri.Svoboda@Sun.COM " - objectType is invalid");
517836SJohn.Forte@Sun.COM
527836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
53*12550SJiri.Svoboda@Sun.COM " - error exit");
547836SJohn.Forte@Sun.COM
557836SJohn.Forte@Sun.COM return (MP_STATUS_INVALID_PARAMETER);
567836SJohn.Forte@Sun.COM }
577836SJohn.Forte@Sun.COM
587836SJohn.Forte@Sun.COM if (objectType < 1) {
597836SJohn.Forte@Sun.COM
607836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
61*12550SJiri.Svoboda@Sun.COM " - objectType is invalid");
627836SJohn.Forte@Sun.COM
637836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
64*12550SJiri.Svoboda@Sun.COM " - error exit");
657836SJohn.Forte@Sun.COM
667836SJohn.Forte@Sun.COM return (MP_STATUS_INVALID_PARAMETER);
677836SJohn.Forte@Sun.COM }
687836SJohn.Forte@Sun.COM
69*12550SJiri.Svoboda@Sun.COM /* Init sysevents if they have not been initialized yet */
70*12550SJiri.Svoboda@Sun.COM if (g_SysEventHandle == NULL) {
71*12550SJiri.Svoboda@Sun.COM if (init_sysevents() != MP_STATUS_SUCCESS)
72*12550SJiri.Svoboda@Sun.COM return (MP_STATUS_FAILED);
73*12550SJiri.Svoboda@Sun.COM }
74*12550SJiri.Svoboda@Sun.COM
75*12550SJiri.Svoboda@Sun.COM /* Check to see if we are going to be replacing */
767836SJohn.Forte@Sun.COM (void) pthread_mutex_lock(&g_prop_mutex);
777836SJohn.Forte@Sun.COM if (g_Property_Callback_List[objectType].pClientFn != NULL) {
787836SJohn.Forte@Sun.COM
797836SJohn.Forte@Sun.COM hasFunc = MP_TRUE;
807836SJohn.Forte@Sun.COM }
817836SJohn.Forte@Sun.COM
82*12550SJiri.Svoboda@Sun.COM /* Add the registration */
837836SJohn.Forte@Sun.COM g_Property_Callback_List[objectType].pClientFn = pClientFn;
847836SJohn.Forte@Sun.COM g_Property_Callback_List[objectType].pCallerData = pCallerData;
857836SJohn.Forte@Sun.COM (void) pthread_mutex_unlock(&g_prop_mutex);
867836SJohn.Forte@Sun.COM
877836SJohn.Forte@Sun.COM if (hasFunc) {
887836SJohn.Forte@Sun.COM
897836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
90*12550SJiri.Svoboda@Sun.COM " - returning MP_STATUS_FN_REPLACED");
917836SJohn.Forte@Sun.COM
927836SJohn.Forte@Sun.COM return (MP_STATUS_FN_REPLACED);
937836SJohn.Forte@Sun.COM }
947836SJohn.Forte@Sun.COM
957836SJohn.Forte@Sun.COM
967836SJohn.Forte@Sun.COM log(LOG_INFO, "MP_RegisterForObjectPropertyChangesPlugin()",
97*12550SJiri.Svoboda@Sun.COM " - exit");
987836SJohn.Forte@Sun.COM
997836SJohn.Forte@Sun.COM return (MP_STATUS_SUCCESS);
1007836SJohn.Forte@Sun.COM }
101