Exemplo n.º 1
0
PredicateConjunction *orGetPredicateConjunction(QLOperation *op) 
{
   int rdn=0,i,m,ii,mi;
   PredicateConjunction *lc=op->lhon->ft->getPredicateConjunction(op->lhon);
   if (!op->rhon) return lc;
   
   PredicateConjunction *rc=op->rhon->ft->getPredicateConjunction(op->rhon);
   PredicateConjunction *rd=TrackedCMPIArray(
      CMGetArrayCount(lc,NULL)*CMGetArrayCount(rc,NULL), CMPI_ptr, NULL);
      
   for (i=0, m=CMGetArrayCount(lc,NULL); i<m; i++) {
      PredicateConjunction *lci=CMGetArrayElementAt(lc,i,NULL).value.dataPtr.ptr;
      for (ii=0, mi=CMGetArrayCount(rc,NULL); ii<mi; ii++) {
         PredicateConjunction *rcii=CMGetArrayElementAt(rc,ii,NULL).value.dataPtr.ptr;
         Predicates *tc=TrackedCMPIArray(0, CMPI_ptr, NULL);
         CMPIValuePtr rdv={tc,1};               
         appendArray(tc,lci);
         appendArray(tc,rcii);
         CMSetArrayElementAt(rd,rdn,&rdv,CMPI_ptr); 
         rdn++;
      }
   }
   
   return rd;
}
Exemplo n.º 2
0
static PredicateConjunction* binGetPredicateConjunction(QLOperation* op) 
{
   Predicates *d=TrackedCMPIArray(1, CMPI_ptr, NULL);
   PredicateConjunction *cd=TrackedCMPIArray(1, CMPI_ptr, NULL);
   CMPIValuePtr dv={op,0};
   CMPIValuePtr cdv={d,1};
  
   CMSetArrayElementAt(d,0,&dv,CMPI_ptr);
   CMSetArrayElementAt(cd,0,&cdv,CMPI_ptr);

   return cd;
} 
Exemplo n.º 3
0
static PredicateDisjunction* binGetPredicateDisjunction(QLOperation* op) 
{
   Predicates *c=TrackedCMPIArray(1, CMPI_ptr, NULL);
   PredicateDisjunction *dc=TrackedCMPIArray(1, CMPI_ptr, NULL);
   CMPIValuePtr cv={op,0};
   CMPIValuePtr dcv={c,1};
  
   CMSetArrayElementAt(c,0,&cv,CMPI_ptr);
   CMSetArrayElementAt(dc,0,&dcv,CMPI_ptr);

   return dc;
} 
Exemplo n.º 4
0
static CMPIStatus returnData(const CMPIResult * result,
                                   const CMPIValue * val, CMPIType type)
{
   NativeResult *r = (NativeResult*) result;
   
   if (r->current == 0 && r->array==NULL) {
      CMPIStatus rc;
      r->array = TrackedCMPIArray(1, type, &rc);
      r->current = 0;
      if (rc.rc != CMPI_RC_OK) return rc;
   }
   else sfcb_native_array_increase_size(r->array, 1);

   return CMSetArrayElementAt(r->array, r->current++, val, type); 
}
Exemplo n.º 5
0
static NativeSelectExp *
__new_exp(int mode, const char *queryString,
          const char *language, const char *sns, CMPIArray **projection,
          CMPIStatus *rc)
{
  int             state,
                  irc;
  NativeSelectExp exp,
                 *tExp;

  memset(&exp, 0, sizeof(exp));
  exp.exp = eFt;

  /*
   * fprintf(stderr,"*** new select expression: %s %s\n",queryString,
   * language);
   */
  exp.qs =
      parseQuery(mode, (char *) queryString, (char *) language,
                 (char *) sns, &irc);
  if (irc) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_INVALID_QUERY);
    return NULL;
  }

  exp.queryString = strdup(queryString);
  exp.language = strdup(language);
  if (sns)
    exp.sns = strdup(sns);

  if (projection) {
    char          **list = exp.qs->spNames;
    int             i;
    CMPIArray      *ar =
        *projection = TrackedCMPIArray(exp.qs->spNext, CMPI_string, NULL);
    for (i = 0; *list; list++, i++)
      CMSetArrayElementAt(ar, i, (CMPIValue *) * list, CMPI_chars);
  }

  tExp = memAddEncObj(mode, &exp, sizeof(exp), &state);
  tExp->mem_state = state;

  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return tExp;
}
Exemplo n.º 6
0
CMPIValue
str2CMPIValue(CMPIType type, XtokValue val, XtokValueReference * ref,
              char *ns, CMPIStatus *status)
{
  CMPIValue       value;
  CMPIType        t = 0;
  CMPIStatus rc = {CMPI_RC_OK, NULL};

  if (type == 0) {
    type = guessType(val.value);
  }

  if (type & CMPI_ARRAY) {
    /*
     * array type received -- needs special handling 
     */
    int             i,
                    max;
    CMPIValue       v;
    XtokValueArray *arr = (XtokValueArray *) ref;
    XtokValueRefArray *refarr = (XtokValueRefArray *) arr;
    max = arr->next;
    if ((type & CMPI_ref) == CMPI_ref) {
      t = CMPI_ref;
    } else if (type & ~CMPI_ARRAY) {
      t = type & ~CMPI_ARRAY;
    } else {
      /*
       * the guess type can go wrong 
       */
      if (max > 0) {
        t = guessType(arr->values[0].value);
      }
    }
    /*
     * build an array by looping thru the elements 
     */
    value.array = TrackedCMPIArray(max, t, NULL);
    if (value.array != NULL) {
      for (i = 0; i < max; i++) {
        v = str2CMPIValue(t, arr->values[i], refarr->values + i, ns, &rc);
        CMSetArrayElementAt(value.array, i, &v, t);
      }
      return value;
    }
  }

  /* Feature 75543 - set and return status->rc on failures */
  switch (type) {
  case CMPI_char16:
    value.char16 = *val.value;
    break;
  case CMPI_string:
    value.string = sfcb_native_new_CMPIString(val.value, NULL, 0);
    break;
  case CMPI_sint64:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lld", &value.sint64);
    break;
  case CMPI_uint64:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%llu", &value.uint64);
    break;
  case CMPI_sint32:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%d", &value.sint32);
    break;
  case CMPI_uint32:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%u", &value.uint32);
    break;
  case CMPI_sint16:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hd", &value.sint16);
    break;
  case CMPI_uint16:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hu", &value.uint16);
    break;
  case CMPI_uint8:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%u", &value.uint32);
       value.uint8 = value.uint32;
    }
    break;
  case CMPI_sint8:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%d", &value.sint32);
       value.sint8 = value.sint32;
    }
    break;
  case CMPI_boolean:
    if (invalid_boolean(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       value.boolean = strcasecmp(val.value, "false");
       if (value.boolean)
         value.boolean = 1;
    }
    break;
  case CMPI_real32:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%f", &value.real32);
    break;
  case CMPI_real64:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lf", &value.real64);
    break;
  case CMPI_dateTime:
    value.dateTime =
        sfcb_native_new_CMPIDateTime_fromChars(val.value, NULL);
    break;
  case CMPI_ref:
    getKeyValueTypePtr("ref", NULL, ref, &value, &t, ns);
    break;
  case CMPI_instance:
    value = makeFromEmbeddedObject(val, ns);
    break;
  default:
    mlogf(M_ERROR, M_SHOW, "%s(%d): invalid value %d-%p\n", __FILE__,
          __LINE__, (int) type, val);
    abort();
  }
  return value;
}