1 karl 1.18 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.9 // 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.9 // 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.11 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.18 // 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.9 //
|
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 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 schuur 1.5 #include "CMPI_Version.h"
|
35 schuur 1.2
|
36 schuur 1.1 #include "CMPI_DateTime.h"
37 #include "CMPI_Ftabs.h"
38
39 #include <time.h>
|
40 a.dunfey 1.24 #if !defined(PEGASUS_OS_TYPE_WINDOWS)
|
41 schuur 1.1 #include <sys/time.h>
|
42 schuur 1.4 #endif
|
43 schuur 1.1 #include <string.h>
44
45 PEGASUS_USING_STD;
46 PEGASUS_NAMESPACE_BEGIN
47
|
48 schuur 1.8 extern "C" {
49
|
50 mark.hamzy 1.27 // Taken from CIMDateTime.cpp. This, when added to the POSIX 1970
51 // microseconds epoc, produces a 1 BCE epoch as used by CIMDateTime.
52 static const Uint64 POSIX_1970_EPOCH_OFFSET
53 = PEGASUS_UINT64_LITERAL(62167219200000000);
54
|
55 venkat.puvvada 1.25 static CMPIStatus dtRelease(CMPIDateTime* eDt)
56 {
|
57 schuur 1.8 CIMDateTime* dt=(CIMDateTime*)eDt->hdl;
|
58 venkat.puvvada 1.25 if (dt)
59 {
|
60 schuur 1.8 delete dt;
|
61 mreddy 1.23 (reinterpret_cast<CMPI_Object*>(eDt))->unlinkAndDelete();
|
62 venkat.puvvada 1.25 CMReturn(CMPI_RC_OK);
63 }
64 else
65 {
66 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
|
67 schuur 1.8 }
68 }
69
70 CMPIDateTime *newDateTime() {
|
71 dave.sudlik 1.22 CIMDateTime *dt=new CIMDateTime();
72 *dt=CIMDateTime::getCurrentDateTime();
|
73 mreddy 1.23 return reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt));
|
74 schuur 1.8 }
|
75 schuur 1.1
|
76 schuur 1.8 CMPIDateTime *newDateTimeBin(CMPIUint64 tim, CMPIBoolean interval) {
|
77 mark.hamzy 1.27 if (!interval)
78 {
79 tim += POSIX_1970_EPOCH_OFFSET;
80 }
|
81 dave.sudlik 1.22 CIMDateTime *dt=new CIMDateTime(tim, interval);
|
82 mreddy 1.23 return reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt));
|
83 schuur 1.8 }
|
84 schuur 1.1
|
85 konrad.r 1.16 CMPIDateTime *newDateTimeChar(const char *strTime) {
|
86 schuur 1.8 CIMDateTime *dt=new CIMDateTime();
|
87 konrad.r 1.14 try {
88 *dt=String(strTime);
89 } catch ( ... )
90 {
91 delete dt;
92 return NULL;
93 }
|
94 mreddy 1.23 return reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt));
|
95 schuur 1.8 }
|
96 schuur 1.1
|
97 venkat.puvvada 1.26 static CMPIDateTime* dtClone(const CMPIDateTime* eDt, CMPIStatus* rc)
98 {
|
99 schuur 1.8 CIMDateTime* dt=(CIMDateTime*)eDt->hdl;
|
100 venkat.puvvada 1.26 if (!dt)
101 {
102 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
103 return NULL;
|
104 konrad.r 1.10 }
|
105 schuur 1.8 CIMDateTime* cDt=new CIMDateTime(dt->toString());
106 CMPI_Object* obj=new CMPI_Object(cDt);
107 obj->unlink();
|
108 mreddy 1.23 CMPIDateTime* neDt=reinterpret_cast<CMPIDateTime*>(obj);
|
109 venkat.puvvada 1.26 CMSetStatus(rc,CMPI_RC_OK);
|
110 schuur 1.8 return neDt;
|
111 schuur 1.1 }
112
|
113 venkat.puvvada 1.25 static CMPIBoolean dtIsInterval(const CMPIDateTime* eDt, CMPIStatus* rc)
114 {
|
115 schuur 1.8 CIMDateTime* dt=(CIMDateTime*)eDt->hdl;
|
116 venkat.puvvada 1.25 if (!dt)
117 {
118 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
|
119 konrad.r 1.10 return false;
120 }
121
|
122 venkat.puvvada 1.25 CMSetStatus(rc,CMPI_RC_OK);
|
123 schuur 1.8 return dt->isInterval();
124 }
|
125 schuur 1.1
|
126 venkat.puvvada 1.25 static CMPIString *dtGetStringFormat(const CMPIDateTime* eDt, CMPIStatus* rc)
127 {
|
128 schuur 1.8 CIMDateTime* dt=(CIMDateTime*)eDt->hdl;
|
129 venkat.puvvada 1.25 if (!dt)
130 {
131 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
|
132 konrad.r 1.10 return NULL;
133 }
|
134 mreddy 1.23 CMPIString *str=reinterpret_cast<CMPIString*>(new CMPI_Object(dt->toString()));
|
135 schuur 1.8 if (rc) CMSetStatus(rc,CMPI_RC_OK);
136 return str;
137 }
|
138 schuur 1.1
|
139 venkat.puvvada 1.25 static CMPIUint64 dtGetBinaryFormat(const CMPIDateTime* eDt, CMPIStatus* rc)
140 {
|
141 schuur 1.8 CIMDateTime* dt=(CIMDateTime*)eDt->hdl;
|
142 venkat.puvvada 1.25 if (!dt)
143 {
144 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
|
145 konrad.r 1.10 return 0;
146 }
|
147 mark.hamzy 1.27 CMPIUint64 tim = dt->toMicroSeconds ();
148 if (!dt->isInterval()) {
149 tim -= POSIX_1970_EPOCH_OFFSET;
|
150 schuur 1.8 }
|
151 mark.hamzy 1.27 return tim;
|
152 schuur 1.1 }
153
154 }
155
156 static CMPIDateTimeFT dateTime_FT={
157 CMPICurrentVersion,
158 dtRelease,
159 dtClone,
160 dtGetBinaryFormat,
161 dtGetStringFormat,
162 dtIsInterval,
163 };
164
165 CMPIDateTimeFT *CMPI_DateTime_Ftab=&dateTime_FT;
166
167 PEGASUS_NAMESPACE_END
168
169
170
171
172
|