# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205173351 25200
# Node ID e7d4d1f30118bbc0e484fd4f4fd80747b63435d5
# Parent d93bb8c00423a88f1c9475a8e6076b1945e1dd01
[CU] Add cu_get_array_prop()
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r d93bb8c00423 -r e7d4d1f30118 args_util.c
--- a/args_util.c Mon Mar 03 06:48:26 2008 -0800
+++ b/args_util.c Mon Mar 10 11:22:31 2008 -0700
@@ -192,6 +192,27 @@ CMPIrc cu_get_u16_arg(const CMPIArgs *ar
pv = CMGetProperty(i, p, s); \
if ((s)->rc != CMPI_RC_OK || CMIsNullValue(pv)) \
return CMPI_RC_ERR_NO_SUCH_PROPERTY;
+
+CMPIrc cu_get_array_prop(const CMPIInstance *inst,
+ const char *prop,
+ CMPIArray **array)
+{
+ CMPIData value;
+ CMPIStatus s;
+
+ REQUIRE_PROPERTY_DEFINED(inst, prop, value, &s);
+
+ value = CMGetProperty(inst, prop, &s);
+ if ((s.rc != CMPI_RC_OK) || CMIsNullValue(value))
+ return s.rc;
+
+ if (!CMIsArray(value) || CMIsNullObject(value.value.array))
+ return CMPI_RC_ERR_TYPE_MISMATCH;
+
+ *array = value.value.array;
+
+ return CMPI_RC_OK;
+}
CMPIrc cu_get_str_prop(const CMPIInstance *inst,
const char *prop,
diff -r d93bb8c00423 -r e7d4d1f30118 libcmpiutil.h
--- a/libcmpiutil.h Mon Mar 03 06:48:26 2008 -0800
+++ b/libcmpiutil.h Mon Mar 10 11:22:31 2008 -0700
@@ -211,6 +211,23 @@ bool cu_return_instance_name(const CMPIR
*/
unsigned int cu_return_instance_names(const CMPIResult *results,
const struct inst_list *list);
+
+/**
+ * Get an array property of an instance
+ *
+ * @param inst The instance
+ * @param prop The property name
+ * @param target A pointer to a CMPIarray that will be set
+ * if successful
+ * @returns
+ * - CMPI_RC_OK on success,
+ * - CMPI_RC_ERR_NO_SUCH_PROPERTY if prop is not present,
+ * - CMPI_RC_ERR_TYPE_MISMATCH if prop is not an array,
+ * - CMPI_RC_ERROR otherwise
+ */
+CMPIrc cu_get_array_prop(const CMPIInstance *inst,
+ const char *prop,
+ CMPIArray **array);
/**
* Get a string property of an instance