version 1.29, 2007/07/25 07:16:00
|
version 1.30, 2007/09/02 16:41:52
|
|
|
#include <sys/time.h> | #include <sys/time.h> |
#endif | #endif |
#include <string.h> | #include <string.h> |
|
#include <Pegasus/Common/Tracer.h> |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
| |
static CMPIStatus dtRelease(CMPIDateTime* eDt) | static CMPIStatus dtRelease(CMPIDateTime* eDt) |
{ | { |
|
PEG_METHOD_ENTER( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
"CMPI_DateTime:dtRelease()"); |
CIMDateTime* dt = (CIMDateTime*)eDt->hdl; | CIMDateTime* dt = (CIMDateTime*)eDt->hdl; |
if (dt) | if (dt) |
{ | { |
delete dt; | delete dt; |
(reinterpret_cast<CMPI_Object*>(eDt))->unlinkAndDelete(); | (reinterpret_cast<CMPI_Object*>(eDt))->unlinkAndDelete(); |
|
PEG_METHOD_EXIT(); |
CMReturn(CMPI_RC_OK); | CMReturn(CMPI_RC_OK); |
} | } |
else | else |
{ | { |
|
PEG_METHOD_EXIT(); |
CMReturn(CMPI_RC_ERR_INVALID_HANDLE); | CMReturn(CMPI_RC_ERR_INVALID_HANDLE); |
} | } |
} | } |
| |
CMPIDateTime *newDateTime() | CMPIDateTime *newDateTime() |
{ | { |
|
PEG_METHOD_ENTER( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
"CMPI_DateTime:newDateTime()"); |
CIMDateTime *dt = new CIMDateTime(); | CIMDateTime *dt = new CIMDateTime(); |
*dt = CIMDateTime::getCurrentDateTime(); | *dt = CIMDateTime::getCurrentDateTime(); |
return reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt)); |
CMPIDateTime* cmpiDateTime = |
|
reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt)); |
|
PEG_METHOD_EXIT(); |
|
return cmpiDateTime; |
} | } |
| |
CMPIDateTime *newDateTimeBin(CMPIUint64 tim, CMPIBoolean interval) | CMPIDateTime *newDateTimeBin(CMPIUint64 tim, CMPIBoolean interval) |
{ | { |
|
PEG_METHOD_ENTER( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
"CMPI_DateTime:newDateTimeBin()"); |
if (!interval) | if (!interval) |
{ | { |
tim += POSIX_1970_EPOCH_OFFSET; | tim += POSIX_1970_EPOCH_OFFSET; |
} | } |
CIMDateTime *dt = new CIMDateTime(tim, interval); | CIMDateTime *dt = new CIMDateTime(tim, interval); |
return reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt)); |
CMPIDateTime* cmpiDateTime = |
|
reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt)); |
|
PEG_METHOD_EXIT(); |
|
return cmpiDateTime; |
} | } |
| |
CMPIDateTime *newDateTimeChar(const char *strTime) | CMPIDateTime *newDateTimeChar(const char *strTime) |
{ | { |
|
PEG_METHOD_ENTER( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
"CMPI_DateTime:newDateTimeChar()"); |
CIMDateTime *dt = new CIMDateTime(); | CIMDateTime *dt = new CIMDateTime(); |
try | try |
{ | { |
|
|
} | } |
catch ( ... ) | catch ( ... ) |
{ | { |
|
PEG_TRACE_CSTRING( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
Tracer::LEVEL2, |
|
"Exception: Unknown Exception in newDateTimeChar()"); |
delete dt; | delete dt; |
|
PEG_METHOD_EXIT(); |
return NULL; | return NULL; |
} | } |
return reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt)); |
CMPIDateTime* cmpiDateTime = |
|
reinterpret_cast<CMPIDateTime*>(new CMPI_Object(dt)); |
|
PEG_METHOD_EXIT(); |
|
return cmpiDateTime; |
} | } |
| |
static CMPIDateTime* dtClone(const CMPIDateTime* eDt, CMPIStatus* rc) | static CMPIDateTime* dtClone(const CMPIDateTime* eDt, CMPIStatus* rc) |
{ | { |
|
PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_DateTime:dtClone()"); |
CIMDateTime* dt = (CIMDateTime*)eDt->hdl; | CIMDateTime* dt = (CIMDateTime*)eDt->hdl; |
if (!dt) | if (!dt) |
{ | { |
|
PEG_TRACE_CSTRING( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
Tracer::LEVEL2, |
|
"Received invalid Handle - eDt->hdl..."); |
CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); | CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); |
|
PEG_METHOD_EXIT(); |
return NULL; | return NULL; |
} | } |
CIMDateTime* cDt = new CIMDateTime(dt->toString()); | CIMDateTime* cDt = new CIMDateTime(dt->toString()); |
|
|
obj->unlink(); | obj->unlink(); |
CMPIDateTime* neDt = reinterpret_cast<CMPIDateTime*>(obj); | CMPIDateTime* neDt = reinterpret_cast<CMPIDateTime*>(obj); |
CMSetStatus(rc, CMPI_RC_OK); | CMSetStatus(rc, CMPI_RC_OK); |
|
PEG_METHOD_EXIT(); |
return neDt; | return neDt; |
} | } |
| |
|
|
CIMDateTime* dt = (CIMDateTime*)eDt->hdl; | CIMDateTime* dt = (CIMDateTime*)eDt->hdl; |
if (!dt) | if (!dt) |
{ | { |
|
PEG_TRACE_CSTRING( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
Tracer::LEVEL2, |
|
"Received invalid Handle in CMPI_DateTime:dtIsInterval"); |
CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); | CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); |
return false; | return false; |
} | } |
|
|
const CMPIDateTime* eDt, | const CMPIDateTime* eDt, |
CMPIStatus* rc) | CMPIStatus* rc) |
{ | { |
|
PEG_METHOD_ENTER( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
"CMPI_DateTime:dtGetStringFormat()"); |
CIMDateTime* dt = (CIMDateTime*)eDt->hdl; | CIMDateTime* dt = (CIMDateTime*)eDt->hdl; |
if (!dt) | if (!dt) |
{ | { |
|
PEG_TRACE_CSTRING( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
Tracer::LEVEL2, |
|
"Received invalid Handle eDt->hdl in \ |
|
CMPI_DateTime:dtGetStringFormat"); |
CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); | CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); |
|
PEG_METHOD_EXIT(); |
return NULL; | return NULL; |
} | } |
CMPIString *str = | CMPIString *str = |
reinterpret_cast<CMPIString*>(new CMPI_Object(dt->toString())); | reinterpret_cast<CMPIString*>(new CMPI_Object(dt->toString())); |
CMSetStatus(rc,CMPI_RC_OK); | CMSetStatus(rc,CMPI_RC_OK); |
|
PEG_METHOD_EXIT(); |
return str; | return str; |
} | } |
| |
|
|
const CMPIDateTime* eDt, | const CMPIDateTime* eDt, |
CMPIStatus* rc) | CMPIStatus* rc) |
{ | { |
|
PEG_METHOD_ENTER( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
"CMPI_DateTime:dtGetBinaryFormat()"); |
CIMDateTime* dt = (CIMDateTime*)eDt->hdl; | CIMDateTime* dt = (CIMDateTime*)eDt->hdl; |
if (!dt) | if (!dt) |
{ | { |
|
PEG_TRACE_CSTRING( |
|
TRC_CMPIPROVIDERINTERFACE, |
|
Tracer::LEVEL2, |
|
"Received invalid Handle eDt->hdl in \ |
|
CMPI_DateTime:dtGetBinaryFormat"); |
CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); | CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE); |
|
PEG_METHOD_EXIT(); |
return 0; | return 0; |
} | } |
CMPIUint64 tim = dt->toMicroSeconds(); | CMPIUint64 tim = dt->toMicroSeconds(); |
|
|
{ | { |
tim -= POSIX_1970_EPOCH_OFFSET; | tim -= POSIX_1970_EPOCH_OFFSET; |
} | } |
|
PEG_METHOD_EXIT(); |
return tim; | return tim; |
} | } |
} | } |