-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrokerEnc.c
282 lines (251 loc) · 8.2 KB
/
brokerEnc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
* brokerEnc.c
*
* (C) Copyright IBM Corp. 2005
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
* CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
*
* You can obtain a current copy of the Eclipse Public License from
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* Author: Frank Scheffler
* Contributors: Adrian Schuur <[email protected]>
*
* Description:
*
* This module implements CMPI broker encapsulated functions.
*
*/
#include "native.h"
#include "trace.h"
#include "constClass.h"
#include <sfcCommon/utilft.h>
extern const char *opGetClassNameChars(const CMPIObjectPath * cop);
extern const char *opGetNameSpaceChars(const CMPIObjectPath * cop);
extern CMPIConstClass *getConstClass(const char *ns, const char *cn);
extern CMPIObjectPathFT *CMPI_ObjectPath_FT;
extern CMPIInstanceFT *CMPI_Instance_FT;
extern CMPIString *instance2String(CMPIInstance *inst, CMPIStatus *rc);
extern int verifyPropertyList(CMPIConstClass * cls, char **list);
extern CMPISelectExp *TrackedCMPISelectExp(const char *queryString,
const char *language,
CMPIArray **projection,
CMPIStatus *rc);
static CMPIInstance *
__beft_newInstance(const CMPIBroker * broker,
const CMPIObjectPath * cop, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newInstance");
CMPIInstance *inst = TrackedCMPIInstance(cop, rc);
_SFCB_RETURN(inst);
}
static CMPIObjectPath *
__beft_newObjectPath(const CMPIBroker * broker,
const char *namespace,
const char *classname, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newObjectPath");
CMPIObjectPath *path = TrackedCMPIObjectPath(namespace, classname, rc);
_SFCB_RETURN(path);
}
static CMPIArgs *
__beft_newArgs(const CMPIBroker * broker, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newArgs");
CMPIArgs *args = TrackedCMPIArgs(rc);
_SFCB_RETURN(args);
}
static CMPIString *
__beft_newString(const CMPIBroker * broker,
const char *str, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newString");
CMPIString *s = sfcb_native_new_CMPIString(str, rc, 0);
_SFCB_RETURN(s);
}
static CMPIArray *
__beft_newArray(const CMPIBroker * broker,
CMPICount size, CMPIType type, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newArray");
CMPIArray *ar = TrackedCMPIArray(size, type, rc);
_SFCB_RETURN(ar);
}
static CMPIDateTime *
__beft_newDateTime(const CMPIBroker * broker, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newDateTime");
CMPIDateTime *dt = sfcb_native_new_CMPIDateTime(rc);
_SFCB_RETURN(dt);
}
static CMPIDateTime *
__beft_newDateTimeFromBinary(const CMPIBroker * broker,
CMPIUint64 time,
CMPIBoolean interval, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newDateTimeFromBinary");
CMPIDateTime *dt =
sfcb_native_new_CMPIDateTime_fromBinary(time, interval, rc);
_SFCB_RETURN(dt);
}
static CMPIDateTime *
__beft_newDateTimeFromChars(const CMPIBroker * broker,
const char *string, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newDateTimeFromChars");
CMPIDateTime *dt = sfcb_native_new_CMPIDateTime_fromChars(string, rc);
_SFCB_RETURN(dt);
}
static CMPISelectExp *
__beft_newSelectExp(const CMPIBroker * broker,
const char *queryString,
const char *language,
CMPIArray **projection, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "newSelectExp");
CMPISelectExp *sx =
TrackedCMPISelectExp(queryString, language, projection, rc);
_SFCB_RETURN(sx);
}
static CMPIBoolean
__beft_classPathIsA(const CMPIBroker * broker,
const CMPIObjectPath * cop,
const char *type, CMPIStatus *rc)
{
CMPIConstClass *cc;
char *scn,
*ns;
if (rc)
CMSetStatus(rc, CMPI_RC_OK);
CMPIString *clsn = CMGetClassName(cop, NULL);
_SFCB_ENTER(TRACE_ENCCALLS, "classPathIsA");
if (clsn && clsn->hdl && type) {
if (strcasecmp(type, (char *) clsn->hdl) == 0)
_SFCB_RETURN(1);
} else
_SFCB_RETURN(0);
ns = (char *) opGetNameSpaceChars(cop);
cc = (CMPIConstClass *) getConstClass(ns, opGetClassNameChars(cop));
if (cc && type)
for (; (scn = (char *) cc->ft->getCharSuperClassName(cc)) != NULL;) {
if (strcasecmp(scn, type) == 0)
return 1;
cc = (CMPIConstClass *) getConstClass(ns, scn);
if (cc == NULL)
break;
}
_SFCB_RETURN(0);
}
static CMPIString *
__beft_toString(const CMPIBroker * broker,
const void *object, CMPIStatus *rc)
{
CMPIString *str;
_SFCB_ENTER(TRACE_ENCCALLS, "toString");
if (object) {
if (((CMPIInstance *) object)->ft) {
if (((CMPIObjectPath *) object)->ft == CMPI_ObjectPath_FT) {
// str=__oft_toString((CMPIObjectPath *) object, rc);
str =
((CMPIObjectPath *) object)->ft->
toString((CMPIObjectPath *) object, rc);
_SFCB_RETURN(str);
}
if (((CMPIInstance *) object)->ft == CMPI_Instance_FT) {
str = instance2String((CMPIInstance *) object, rc);
_SFCB_RETURN(str);
}
}
}
_SFCB_TRACE(1, ("This operation is not yet supported."));
if (rc)
CMSetStatus(rc, CMPI_RC_ERR_NOT_SUPPORTED);
_SFCB_RETURN(NULL);
}
static CMPIBoolean
__beft_isOfType(const CMPIBroker * broker,
const void *object, const char *type, CMPIStatus *rc)
{
char *t = *((char **) object);
_SFCB_ENTER(TRACE_ENCCALLS, "isOfType");
if (rc)
CMSetStatus(rc, CMPI_RC_OK);
_SFCB_RETURN(strcmp(t, type) == 0);
}
static CMPIString *
__beft_getType(const CMPIBroker * broker,
const void *object, CMPIStatus *rc)
{
_SFCB_ENTER(TRACE_ENCCALLS, "getType");
_SFCB_RETURN(__beft_newString(broker, *((char **) object), rc));
}
static CMPIString *
__beft_getMessage(const CMPIBroker * broker,
const char *msgId, const char *defMsg,
CMPIStatus *rc, unsigned int count, ...)
{
if (rc)
CMSetStatus(rc, CMPI_RC_ERR_NOT_SUPPORTED);
_SFCB_ENTER(TRACE_ENCCALLS, "getMessage");
_SFCB_TRACE(1, ("This operation is not yet supported."));
_SFCB_RETURN(__beft_newString(broker, defMsg, NULL));
}
static CMPIStatus __beft_logMessage
(const CMPIBroker * broker, int severity, const char *id,
const char *text, const CMPIString *string) {
CMPIStatus rc = { CMPI_RC_ERR_NOT_SUPPORTED, NULL };
_SFCB_ENTER(TRACE_ENCCALLS, "logMessage");
_SFCB_TRACE(1, ("This operation is not yet supported."));
_SFCB_RETURN(rc);
}
static CMPIStatus __beft_trace
(const CMPIBroker * broker, int level, const char *component,
const char *text, const CMPIString *string) {
CMPIStatus rc = { CMPI_RC_ERR_NOT_SUPPORTED, NULL };
_SFCB_ENTER(TRACE_ENCCALLS, "trace");
_SFCB_TRACE(1, ("This operation is not yet supported."));
_SFCB_RETURN(rc);
}
CMPIArray *
getKeyListAndVerifyPropertyList(CMPIObjectPath * cop,
char **props, int *ok, CMPIStatus *rc)
{
CMPIArray *ar;
CMPIConstClass *cc;
cc = (CMPIConstClass *)
getConstClass(opGetNameSpaceChars(cop), opGetClassNameChars(cop));
if (cc) {
ar = cc->ft->getKeyList(cc);
*ok = verifyPropertyList(cc, props);
return ar;
} else
return NewCMPIArray(0, CMPI_string, NULL);
}
/****************************************************************************/
CMPIBrokerEncFT native_brokerEncFT = {
NATIVE_FT_VERSION,
__beft_newInstance,
__beft_newObjectPath,
__beft_newArgs,
__beft_newString,
__beft_newArray,
__beft_newDateTime,
__beft_newDateTimeFromBinary,
__beft_newDateTimeFromChars,
__beft_newSelectExp,
__beft_classPathIsA,
__beft_toString,
__beft_isOfType,
__beft_getType,
__beft_getMessage,
__beft_logMessage,
__beft_trace
};
CMPIBrokerEncFT *BrokerEncFT = &native_brokerEncFT;
/* MODELINES */
/* DO NOT EDIT BELOW THIS COMMENT */
/* Modelines are added by 'make pretty' */
/* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
/* vi:set ts=2 sts=2 sw=2 expandtab: */