1 karl 1.19 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.12 // 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 karl 1.12 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.15 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.19 // 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 karl 1.12 //
|
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: Adrian Schuur, schuur@de.ibm.com
33 //
34 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
|
38 schuur 1.4 #include "CMPI_Version.h"
|
39 schuur 1.1
40 #include "CMPI_Object.h"
41 #include "CMPI_Ftabs.h"
42
|
43 konrad.r 1.16 #include <string.h>
44
|
45 schuur 1.1 PEGASUS_USING_STD;
46 PEGASUS_NAMESPACE_BEGIN
47
|
48 schuur 1.9 extern "C" {
49
|
50 konrad.r 1.18 PEGASUS_STATIC CMPIStatus arrayRelease(CMPIArray* eArray) {
|
51 schuur 1.9 // cout<<"--- arrayRelease()"<<endl;
52 CMPIData *dta=(CMPIData*)eArray->hdl;
53 if (dta) {
54 delete[] dta;
|
55 mreddy 1.20 reinterpret_cast<CMPI_Object*>(eArray)->unlinkAndDelete();
|
56 schuur 1.9 }
57 CMReturn(CMPI_RC_OK);
|
58 schuur 1.1 }
59
|
60 konrad.r 1.18 PEGASUS_STATIC CMPIArray* arrayClone(const CMPIArray* eArray, CMPIStatus* rc) {
|
61 schuur 1.9 CMPIData* dta=(CMPIData*)eArray->hdl;
|
62 konrad.r 1.14
63 if (!dta) {
64 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
65 return NULL;
66 }
|
67 schuur 1.9 CMPIData* nDta=new CMPIData[dta->value.uint32+1];
68 CMPI_Object* obj=new CMPI_Object(nDta);
69 obj->unlink();
|
70 mreddy 1.20 CMPIArray* nArray=reinterpret_cast<CMPIArray*>(obj);
|
71 schuur 1.9 CMPIStatus rrc={CMPI_RC_OK,NULL};
72
73 if (dta->type & CMPI_ENC) for (unsigned int i=1; i<=dta->value.uint32; i++)
74 nDta[i].state=CMPI_nullValue;
75
76 for (unsigned int i=0; i<=dta->value.uint32; i++) {
77 nDta[i]=dta[i];
78 if (dta->type & CMPI_ENC && dta[i].state==CMPI_goodValue) {
|
79 konrad.r 1.13
80 if ((dta[i].type & CMPI_instance) && (dta[i].value.inst))
81 nDta[i].value.inst=
82 (dta[i].value.inst)->ft->clone(dta[i].value.inst,&rrc);
83
84 if ((dta[i].type & CMPI_ref) && (dta[i].value.ref))
85 nDta[i].value.ref=
86 (dta[i].value.ref)->ft->clone(dta[i].value.ref,&rrc);
87
88 if ((dta[i].type & CMPI_args) && (dta[i].value.args))
89 nDta[i].value.args=
90 (dta[i].value.args)->ft->clone(dta[i].value.args,&rrc);
91
92 if ((dta[i].type & CMPI_dateTime) && (dta[i].value.dateTime))
93 nDta[i].value.dateTime=
94 (dta[i].value.dateTime)->ft->clone(dta[i].value.dateTime,&rrc);
95
96 if ((dta[i].type & CMPI_enumeration) && (dta[i].value.Enum))
97 nDta[i].value.Enum=
98 (dta[i].value.Enum)->ft->clone(dta[i].value.Enum,&rrc);
99
100 konrad.r 1.13 if ((dta[i].type & CMPI_filter) && (dta[i].value.filter))
101 nDta[i].value.filter=
102 (dta[i].value.filter)->ft->clone(dta[i].value.filter,&rrc);
103
104 if ((dta[i].type & CMPI_charsptr) && (dta[i].value.dataPtr.length>0)) {
105 nDta[i].value.dataPtr.length=
106 dta[i].value.dataPtr.length;
107 nDta[i].value.dataPtr.ptr = malloc(nDta[i].value.dataPtr.length);
108 if (nDta[i].value.dataPtr.ptr == NULL) {
109 arrayRelease(nArray);
110 if (rc) *rc=rrc;
111 return NULL;
112 }
113 memcpy(nDta[i].value.dataPtr.ptr,
114 dta[i].value.dataPtr.ptr,
115 dta[i].value.dataPtr.length);
116 }
117
|
118 konrad.r 1.11 if ((dta[i].type & CMPI_string) && (dta[i].value.string))
119 nDta[i].value.string=
|
120 konrad.r 1.13 (dta[i].value.string)->ft->clone(dta[i].value.string,&rrc);
121
122 if (rrc.rc) {
|
123 konrad.r 1.11 arrayRelease(nArray);
124 if (rc) *rc=rrc;
125 return NULL;
126 }
127 }
|
128 schuur 1.9 }
129 if (rc) CMSetStatus(rc,CMPI_RC_OK);
130 return nArray;
|
131 schuur 1.1 }
132
|
133 konrad.r 1.18 PEGASUS_STATIC CMPIData arrayGetElementAt(const CMPIArray* eArray, CMPICount pos, CMPIStatus* rc) {
|
134 schuur 1.9 CMPIData *dta=(CMPIData*)eArray->hdl;
|
135 konrad.r 1.14 CMPIData data={0,CMPI_nullValue,{0}};
136 if (!dta) {
137 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
138 return data;
139 }
|
140 schuur 1.9 if (rc) CMSetStatus(rc,CMPI_RC_OK);
141 if (pos<dta->value.uint32) return dta[pos+1];
142
143 if (rc) CMSetStatus(rc,CMPI_RC_ERR_NOT_FOUND);
144 return data;
145 }
|
146 schuur 1.1
|
147 schuur 1.9 CMPIStatus arraySetElementAt(CMPIArray* eArray, CMPICount pos,
|
148 konrad.r 1.17 const CMPIValue *val, CMPIType type) {
|
149 schuur 1.9 CMPIData *dta=(CMPIData*)eArray->hdl;
|
150 konrad.r 1.14 if (!dta)
151 CMReturn( CMPI_RC_ERR_INVALID_PARAMETER);
|
152 schuur 1.9
153 if (pos<dta->value.uint32) {
154 if ((dta->type&~CMPI_ARRAY)==type) {
155 dta[pos+1].state=CMPI_goodValue;
156 dta[pos+1].value=*val;
157 CMReturn(CMPI_RC_OK);
158 }
|
159 schuur 1.10 else {
160 char msg[512];
161 sprintf(msg,"arraySetElementAt(): CMPI_RC_ERR_TYPE_MISMATCH. Is %p - should be %p",
162 (void*)(long)type,(void*)(long)dta->type);
163 CMReturnWithString(CMPI_RC_ERR_TYPE_MISMATCH,
164 reinterpret_cast<CMPIString*>(new CMPI_Object(msg)));
165 }
|
166 schuur 1.1 }
|
167 schuur 1.9 CMReturn(CMPI_RC_ERR_NOT_FOUND);
168 }
169
|
170 konrad.r 1.18 PEGASUS_STATIC CMPICount arrayGetSize(const CMPIArray* eArray, CMPIStatus* rc) {
|
171 schuur 1.9 CMPIData *dta=(CMPIData*)eArray->hdl;
|
172 konrad.r 1.14 if (!dta) {
173 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
174 return 0;
175 }
|
176 schuur 1.9 if (rc) CMSetStatus(rc,CMPI_RC_OK);
177 return dta->value.uint32;
|
178 schuur 1.1 }
179
|
180 konrad.r 1.18 PEGASUS_STATIC CMPIType arrayGetType(const CMPIArray* eArray, CMPIStatus* rc) {
|
181 schuur 1.9 CMPIData *dta=(CMPIData*)eArray->hdl;
|
182 konrad.r 1.14 if (!dta) {
183 if (rc) CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
184 return CMPI_null;
185 }
186 if (rc) CMSetStatus(rc,CMPI_RC_OK);
|
187 schuur 1.9 if (rc) CMSetStatus(rc,CMPI_RC_OK);
188 return dta->type;
189 }
|
190 schuur 1.1
191 }
192 static CMPIArrayFT array_FT={
193 CMPICurrentVersion,
194 arrayRelease,
195 arrayClone,
196 arrayGetSize,
197 arrayGetType,
198 arrayGetElementAt,
199 arraySetElementAt,
200 };
201
202 CMPIArrayFT *CMPI_Array_Ftab=&array_FT;
203
204 PEGASUS_NAMESPACE_END
205
206
207
208
|