1 karl 1.4 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 martin 1.3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 martin 1.3 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.4 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 schuur 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 martin 1.3 //
|
21 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Frank Scheffler
33 //
34 // Modified By: Adrian Schuur (schuur@de.ibm.com)
|
35 r.kieninger 1.2 // Marek Szermutzky, IBM (mszermutzky@de.ibm.com)
|
36 schuur 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 /*!
40 \file tool.c
41 \brief General tooling facility.
42
43 This module offers general tooling methods that may be used by different
44 components on the CIMOM as well as on the remote side.
45
46 \author Frank Scheffler
47 */
48
49 #include <stdio.h>
|
50 r.kieninger 1.2 #ifdef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
51 #include <dll.h>
52 #include <errno.h>
53 #else
|
54 schuur 1.1 #include <dlfcn.h>
|
55 r.kieninger 1.2 #endif
|
56 schuur 1.1 #include "tool.h"
|
57 r.kieninger 1.2 #include "debug.h"
|
58 schuur 1.1
59 #define GENERIC_ENTRY_POINT(n) \
60 typedef CMPI##n##MI * (* GENERIC_##n##MI) ( CMPIBroker * broker, \
61 CMPIContext * ctx, \
62 const char * provider )
63 #define FIXED_ENTRY_POINT(n) \
64 typedef CMPI##n##MI * (* FIXED_##n##MI) ( CMPIBroker * broker, \
65 CMPIContext * ctx )
66
67 #define LOAD_MI(n) \
68 GENERIC_ENTRY_POINT(n); \
69 FIXED_ENTRY_POINT(n); \
70 \
71 CMPI##n##MI * tool_load_##n##MI ( const char * provider, \
72 void * library, \
73 CMPIBroker * broker, \
74 CMPIContext * ctx ) \
75 { \
76 GENERIC_##n##MI g = \
77 (GENERIC_##n##MI) \
78 __get_generic_entry_point ( library, #n ); \
79 schuur 1.1 \
80 if ( g == NULL ) { \
81 FIXED_##n##MI f = \
82 (FIXED_##n##MI) \
83 __get_fixed_entry_point ( provider, \
84 library, \
85 #n ); \
86 \
87 if ( f == NULL ) return NULL; \
88 return ( f ) ( broker, ctx ); \
89 } \
90 return ( g ) ( broker, ctx, provider ); \
91 }
92
93
94 /*****************************************************************************/
95
96 //! Loads a dynamic load library.
97 /*!
98 Loads the libary named lib<libname>.so using dlopen().
99
100 schuur 1.1 \param libname the library name.
101 \return the library handle.
102 */
103 void * tool_load_lib ( const char * libname )
104 {
105 char filename[255];
|
106 r.kieninger 1.2 void * dllhand;
|
107 schuur 1.1 sprintf ( filename, "lib%s.so", libname );
|
108 r.kieninger 1.2 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
|
109 schuur 1.1 return dlopen ( filename, RTLD_LAZY );
|
110 r.kieninger 1.2 #else
111 dllhand = (void *) dllload ( filename );
112 if (dllhand == 0) TRACE_CRITICAL( ("Trying to load library: %s failed with %s\n", libname, strerror(errno)) );
113 return dllhand;
114 #endif
|
115 schuur 1.1 }
116
117
118 static void * __get_generic_entry_point ( void * library,
119 const char * ptype )
120 {
121 char entry_point[255];
|
122 r.kieninger 1.2 void * dll_entry;
|
123 schuur 1.1 sprintf ( entry_point, "_Generic_Create_%sMI", ptype );
124
|
125 r.kieninger 1.2 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
|
126 schuur 1.1 return dlsym ( library, entry_point );
|
127 r.kieninger 1.2 #else
128 dll_entry = (void*) dllqueryfn ( (dllhandle *) library, entry_point );
129 if (dll_entry == 0) TRACE_CRITICAL((stderr,"Getting generic entry point: %s failed with %s\n", entry_point, strerror(errno)));
130 return dll_entry;
131 #endif
|
132 schuur 1.1 }
133
134
135 static void * __get_fixed_entry_point ( const char * provider,
136 void * library,
137 const char * ptype )
138 {
139 char entry_point[255];
|
140 r.kieninger 1.2 void * dll_entry;
|
141 schuur 1.1 sprintf ( entry_point, "%s_Create_%sMI", provider, ptype );
142
|
143 r.kieninger 1.2 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
|
144 schuur 1.1 return dlsym ( library, entry_point );
|
145 r.kieninger 1.2 #else
146 dll_entry = (void*)dllqueryfn ( (dllhandle*) library, entry_point );
147 if (dll_entry == 0) TRACE_CRITICAL((stderr,"Getting fixed entry point: %s failed with %s\n", entry_point, strerror(errno)));
148 return dll_entry;
149 #endif
|
150 schuur 1.1 }
151
152
153 LOAD_MI(Instance);
154 LOAD_MI(Association);
155 LOAD_MI(Method);
156 LOAD_MI(Property);
157 LOAD_MI(Indication);
158
159
160 /****************************************************************************/
161
162 /*** Local Variables: ***/
163 /*** mode: C ***/
164 /*** c-basic-offset: 8 ***/
165 /*** End: ***/
|