ext/sfcc/cim_client.c in sfcc-0.1.0 vs ext/sfcc/cim_client.c in sfcc-0.1.1
- old
+ new
@@ -30,34 +30,35 @@
{
VALUE object_path;
VALUE flags;
VALUE properties;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
CMPIConstClass *cimclass = NULL;
CMPIConstClass *cimclassnew = NULL;
char **props;
rb_scan_args(argc, argv, "12", &object_path, &flags, &properties);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
props = sfcc_value_array_to_string_array(properties);
cimclass = client->ft->getClass(client, op, NUM2INT(flags), props, &status);
free(props);
- cimclassnew = cimclass->ft->clone(cimclass, NULL);
- cimclass->ft->release(cimclass);
-
- sfcc_rb_raise_if_error(status, "Can't get class");
- return Sfcc_wrap_cim_class(cimclassnew);
+ if (!status.rc) {
+ cimclassnew = cimclass->ft->clone(cimclass, NULL);
+ cimclass->ft->release(cimclass);
+ return Sfcc_wrap_cim_class(cimclassnew);
+ }
+ sfcc_rb_raise_if_error(status, "Can't get class at %s", CMGetCharsPtr(CMObjectPathToString(op, NULL), NULL));
+ return Qnil;
}
/**
* call-seq:
* class_names(object_path, flags=0)
@@ -68,19 +69,18 @@
static VALUE class_names(int argc, VALUE *argv, VALUE self)
{
VALUE object_path;
VALUE flags;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
VALUE rbenm = Qnil;
rb_scan_args(argc, argv, "11", &object_path, &flags);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
CMPIEnumeration *enm = client->ft->enumClassNames(client, op, NUM2INT(flags), &status);
if (enm && !status.rc ) {
@@ -106,19 +106,18 @@
static VALUE classes(int argc, VALUE *argv, VALUE self)
{
VALUE object_path;
VALUE flags;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
VALUE rbenm = Qnil;
rb_scan_args(argc, argv, "11", &object_path, &flags);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
CMPIEnumeration *enm = client->ft->enumClasses(client, op, NUM2INT(flags), &status);
if (enm && !status.rc ) {
@@ -152,20 +151,19 @@
{
VALUE object_path;
VALUE flags;
VALUE properties;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
CMPIInstance *ciminstance = NULL;
char **props;
rb_scan_args(argc, argv, "12", &object_path, &flags, &properties);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
props = sfcc_value_array_to_string_array(properties);
@@ -191,11 +189,11 @@
*
* returns the assigned instance reference (object path)
*/
static VALUE create_instance(VALUE self, VALUE object_path, VALUE instance)
{
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMCIClient *ptr = NULL;
CMPIObjectPath *op = NULL;
CMPIObjectPath *new_op = NULL;
CMPIInstance *inst = NULL;
@@ -231,11 +229,11 @@
VALUE object_path;
VALUE instance;
VALUE flags;
VALUE properties;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMPIInstance *inst = NULL;
CMCIClient *client = NULL;
char **props;
@@ -262,11 +260,11 @@
* Delete an existing Instance using +object_path+ as reference.
* +object_path+ ObjectPath containing nameSpace, classname and key components.
*/
static VALUE delete_instance(VALUE self, VALUE object_path)
{
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
@@ -294,15 +292,14 @@
static VALUE query(VALUE self,
VALUE object_path,
VALUE query,
VALUE lang)
{
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
VALUE rbenm = Qnil;
CMPIEnumeration *enm = client->ft->execQuery(client,
@@ -326,16 +323,15 @@
*
* instance names of the class defined by +object_path+
*/
static VALUE instance_names(VALUE self, VALUE object_path)
{
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
VALUE rbenm = Qnil;
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
CMPIEnumeration *enm = client->ft->enumInstanceNames(client, op, &status);
@@ -370,20 +366,19 @@
{
VALUE object_path;
VALUE flags;
VALUE properties;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
char **props;
VALUE rbenm = Qnil;
rb_scan_args(argc, argv, "12", &object_path, &flags, &properties);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
props = sfcc_value_array_to_string_array(properties);
@@ -453,11 +448,11 @@
VALUE role;
VALUE result_role;
VALUE flags;
VALUE properties;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
char **props;
CMPIEnumeration *enm = NULL;
VALUE rbenm = Qnil;
@@ -465,11 +460,10 @@
rb_scan_args(argc, argv, "16", &object_path,
&assoc_class, &result_class,
&role, &result_role, &flags, &properties);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
props = sfcc_value_array_to_string_array(properties);
@@ -535,21 +529,20 @@
VALUE assoc_class;
VALUE result_class;
VALUE role;
VALUE result_role;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
CMPIEnumeration *enm = NULL;
VALUE rbenm = Qnil;
rb_scan_args(argc, argv, "14", &object_path,
&assoc_class, &result_class,
&role, &result_role);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
enm = client->ft->associatorNames(client,
op,
@@ -603,11 +596,11 @@
VALUE result_class;
VALUE role;
VALUE flags;
VALUE properties;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
char **props;
CMPIEnumeration *enm = NULL;
VALUE rbenm = Qnil;
@@ -615,11 +608,10 @@
rb_scan_args(argc, argv, "14", &object_path,
&result_class, &role,
&flags, &properties);
if (NIL_P(flags)) flags = INT2NUM(0);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
props = sfcc_value_array_to_string_array(properties);
@@ -664,21 +656,20 @@
static VALUE reference_names(int argc, VALUE *argv, VALUE self)
{
VALUE object_path = Qnil;
VALUE result_class = Qnil;
VALUE role = Qnil;
-
- CMPIStatus status;
+
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIObjectPath *op = NULL;
CMCIClient *client = NULL;
CMPIEnumeration *enm = NULL;
VALUE rbenm = Qnil;
- rb_scan_args(argc, argv, "14", &object_path,
+ rb_scan_args(argc, argv, "12", &object_path,
&result_class, &role);
- memset(&status, 0, sizeof(CMPIStatus));
Data_Get_Struct(self, CMCIClient, client);
Data_Get_Struct(object_path, CMPIObjectPath, op);
enm = client->ft->referenceNames(client,
op,
@@ -712,19 +703,18 @@
VALUE object_path,
VALUE method_name,
VALUE argin,
VALUE argout)
{
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMCIClient *ptr = NULL;
CMPIObjectPath *op = NULL;
CMPIArgs *cmpiargsout;
VALUE method_name_str;
char *method_name_cstr;
CMPIData ret;
Check_Type(argin, T_HASH);
- memset(&status, 0, sizeof(CMPIStatus));
cmpiargsout = newCMPIArgs(NULL);
Data_Get_Struct(self, CMCIClient, ptr);
Data_Get_Struct(object_path, CMPIObjectPath, op);
@@ -761,11 +751,11 @@
static VALUE set_property(VALUE self,
VALUE object_path,
VALUE name,
VALUE value)
{
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMCIClient *ptr = NULL;
CMPIObjectPath *op = NULL;
CMPIData data;
Data_Get_Struct(self, CMCIClient, ptr);
Data_Get_Struct(object_path, CMPIObjectPath, op);
@@ -790,13 +780,13 @@
*/
static VALUE property(VALUE self, VALUE object_path, VALUE name)
{
CMCIClient *ptr = NULL;
CMPIObjectPath *op = NULL;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
CMPIData data;
- memset(&status, 0, sizeof(CMPIStatus));
+
Data_Get_Struct(self, CMCIClient, ptr);
Data_Get_Struct(object_path, CMPIObjectPath, op);
data = ptr->ft->getProperty(ptr, op, StringValuePtr(name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
@@ -806,10 +796,10 @@
}
static VALUE connect(VALUE klass, VALUE host, VALUE scheme, VALUE port, VALUE user, VALUE pwd)
{
CMCIClient *client = NULL;
- CMPIStatus status;
+ CMPIStatus status = {CMPI_RC_OK, NULL};
client = cmciConnect(NIL_P(host) ? NULL : StringValuePtr(host),
NIL_P(scheme) ? NULL : StringValuePtr(scheme),
NIL_P(port) ? NULL : StringValuePtr(port),
NIL_P(user) ? NULL : StringValuePtr(user),
NIL_P(pwd) ? NULL : StringValuePtr(pwd),