Ejemplo n.º 1
0
void print(const CMPIData& data)
{
    if (data.state & CMPI_nullValue)
    {
        printf("null");
        return;
    }

    if (CMIsArray(data))
    {
        printf("{");

        CMPICount n = CMGetArrayCount(data.value.array, NULL);

        for (CMPICount i = 0; i < n; i++)
        {
            CMPIData td = CMGetArrayElementAt(data.value.array, i, NULL);
            print_scalar(td);

            if (i + 1 != n)
                printf(",");
        }

        printf("}");
    }
    else
        print_scalar(data);
}
Ejemplo n.º 2
0
// transforms numerical values into their string counterpart
// utilizing the Values and ValueMap qualifiers
char           *
transformValue(char *cssf, CMPIObjectPath * op, char *propertyName)
// cssf = cimSLPService Field in the struct
{
  CMPIData        qd;
  CMPIStatus      status;
  char           *valuestr;

  _SFCB_ENTER(TRACE_SLP, "transformValue");

  qd = CMGetPropertyQualifier(op, propertyName, "ValueMap", &status);
  if (status.rc) {
    printf("getPropertyQualifier failed ... Status: %d\n", status.rc);
    _SFCB_RETURN(NULL);
  }

  if (CMIsArray(qd)) {
    CMPIArray      *arr = qd.value.array;
    CMPIType        eletyp = qd.type & ~CMPI_ARRAY;
    int             j = 0;
    int             n;
    n = CMGetArrayCount(arr, NULL);
    CMPIData        ele;
    ele = CMGetArrayElementAt(arr, j, NULL);
    valuestr = value2Chars(eletyp, &ele.value);
    j++;
    while (strcmp(valuestr, cssf)) {
      free(valuestr);
      ele = CMGetArrayElementAt(arr, j, NULL);
      valuestr = value2Chars(eletyp, &ele.value);
      if (j == n) {
        free(valuestr);
        _SFCB_RETURN(cssf);     // nothing found, probably "NULL" ->
        // return it
      }
      j++;
    }
    free(valuestr);
    free(cssf);
    if (j - 1 <= n) {
      qd = CMGetPropertyQualifier(op, propertyName, "Values",
                                          &status);
      arr = qd.value.array;
      eletyp = qd.type & ~CMPI_ARRAY;
      ele = CMGetArrayElementAt(arr, j - 1, NULL);
      cssf = value2Chars(eletyp, &ele.value);
      _SFCB_RETURN(cssf);
    } else {
      // printf("No Valuemap Entry for %s in %s. Exiting ...\n", cssf,
      // propertyName);
      _SFCB_RETURN(NULL);
    }
  }

  else {
    // printf("No qualifier found for %s. Exiting ...\n", propertyName);
    _SFCB_RETURN(NULL);
  }
}