class cmpi
Public Instance Methods
_clr_raised()
click to toggle source
static void _clr_raised()
{
pthread_once(&_once, _init_key);
pthread_setspecific(_key, NULL);
}
_get_raised()
click to toggle source
static void* _get_raised()
{
pthread_once(&_once, _init_key);
return pthread_getspecific(_key);
}
_init_key()
click to toggle source
static void _init_key()
{
pthread_key_create(&_key, NULL);
}
_raise_ex(p1)
click to toggle source
static void _raise_ex(const CMPIStatus* st)
{
char* msg = NULL;
if (st->msg) {
msg = strdup(CMGetCharsPtr(st->msg, NULL));
}
#ifdef SWIGPYTHON
PyObject* obj;
CMPIException* ex;
ex = (CMPIException*)malloc(sizeof(CMPIException));
ex->error_code = st->rc;
ex->description = msg;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
obj = SWIG_NewPointerObj(ex, SWIGTYPE_p__CMPIException, SWIG_POINTER_OWN);
PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p__CMPIException), obj);
SWIG_PYTHON_THREAD_END_BLOCK;
_set_raised();
if (msg)
free(msg);
#endif
#ifdef SWIGRUBY
VALUE exception_klass = rb_funcall(mCmpi, rb_intern("rc_to_exception"), 1, Target_Int(st->rc));
VALUE exception;
if (NIL_P(exception_klass)) {
/* no error */
return;
}
exception = rb_funcall(exception_klass, rb_intern("new"), 2, Target_Int(st->rc), Target_String(msg ? msg : ""));
if (msg)
free(msg);
rb_exc_raise(exception);
#endif
#if !defined(SWIGPYTHON) && !defined(SWIGRUBY)
/* default implementation */
if (msg == NULL) {
msg = (char *)malloc(16);
snprintf(msg, 15, "Cmpi rc %d", st->rc);
}
SWIG_exception(SWIG_RuntimeError, msg);
if (msg)
free(msg);
#endif
#if !defined (SWIGRUBY)
fail:
#endif
return;
}
_set_raised()
click to toggle source
static void _set_raised()
{
pthread_once(&_once, _init_key);
pthread_setspecific(_key, (void*)1);
}
if(p1)
click to toggle source
else if (dp->state & (unsigned short)CMPI_badValue) {
SWIG_exception(SWIG_ValueError, "bad value");
}
else if (dp->type & CMPI_ARRAY) {
int size = CMGetArrayCount(dp->value.array, NULL);
int i;
result = Target_SizedArray(size);
for (i = 0; i < size; ++i) {
CMPIData data = CMGetArrayElementAt(dp->value.array, i, NULL);
Target_Type value = data_value(&data);
Target_ListSet(result, i, value);
}
}
else {
result = value_value(&(dp->value), dp->type);
}
#if !defined (SWIGRUBY)
fail:
#endif
return result;
}
log_message(p1, p2, p3, p4)
click to toggle source
Called by LogMessage and TraceMessage
static void log_message(
const CMPIBroker *broker,
int severity,
const char *id,
const char *text)
{
CMPIStatus st = CMLogMessage(broker, severity, id, text, NULL);
if (st.rc == CMPI_RC_ERR_NOT_SUPPORTED) {
int priority = LOG_DAEMON;
openlog("cmpi-bindings", LOG_CONS|LOG_PID, LOG_DAEMON);
switch(severity) {
case CMPI_SEV_ERROR: priority |= LOG_ERR; break;
case CMPI_SEV_INFO: priority |= LOG_INFO; break;
case CMPI_SEV_WARNING: priority |= LOG_WARNING; break;
case CMPI_DEV_DEBUG: priority |= LOG_DEBUG; break;
default: priority |= LOG_NOTICE;
}
syslog(priority, "%s: %s", id, text);
}
else {
RAISE_IF(st);
}
}