#include "cainterface.h"
#define TAG "OIC_RI_COLLECTION"
-static bool AddRTSBaselinePayload(OCRepPayload **linkArray, int size, OCRepPayload **colPayload)
+static bool AddRTSBaselinePayload(const OCResource* collResource, OCRepPayload **colPayload)
{
size_t arraySize = 0;
- for (int j = 0; j < size; j++)
+ for (OCChildResource *tempChildResource = collResource->rsrcChildResourcesHead;
+ tempChildResource; tempChildResource = tempChildResource->next)
{
- size_t rtDim[MAX_REP_ARRAY_DEPTH] = {0};
- char **rt = NULL;
- OCRepPayloadGetStringArray(linkArray[j], OC_RSRVD_RESOURCE_TYPE, &rt, rtDim);
- arraySize += rtDim[0];
- for (size_t l = 0; l < rtDim[0]; l++)
+ OCResource* currentResource = tempChildResource->rsrcResource;
+ OCResourceType* currentType = currentResource->rsrcType;
+ while(currentType)
{
- OICFree(rt[l]);
+ arraySize++;
+ currentType = currentType->next;
}
- OICFree(rt);
}
- for (OCStringLL *rsrcType = (*colPayload)->types; rsrcType; rsrcType = rsrcType->next, arraySize++);
-
OIC_LOG_V(DEBUG, TAG, "Number of RTS elements : %zd", arraySize);
size_t dim[MAX_REP_ARRAY_DEPTH] = {arraySize, 0, 0};
char **rts = (char **)OICMalloc(sizeof(char *) * arraySize);
return OC_STACK_NO_MEMORY;
}
int k = 0;
- for (int j = 0; j < size; j++)
+ for (OCChildResource *tempChildResource = collResource->rsrcChildResourcesHead;
+ tempChildResource; tempChildResource = tempChildResource->next)
{
- size_t rtDim[MAX_REP_ARRAY_DEPTH] = {0};
- char **rt = NULL;
- OCRepPayloadGetStringArray(linkArray[j], OC_RSRVD_RESOURCE_TYPE, &rt, rtDim);
- for (size_t l = 0; l < rtDim[0]; l++)
+ OCResource* currentResource = tempChildResource->rsrcResource;
+ OCResourceType* currentType = currentResource->rsrcType;
+ while(currentType)
{
- rts[k++] = OICStrdup(rt[l]);
- OICFree(rt[l]);
+ rts[k++] = OICStrdup(currentType->resourcetypename);
+ currentType = currentType->next;
}
- OICFree(rt);
- }
- for (OCStringLL *rsrcType = (*colPayload)->types; rsrcType; rsrcType = rsrcType->next, size++)
- {
- rts[k++] = OICStrdup(rsrcType->value);
}
bool b = OCRepPayloadSetStringArrayAsOwner(*colPayload, OC_RSRVD_RTS, rts, dim);
{
OCRepPayloadAddInterface(colPayload, itf->name);
}
- AddRTSBaselinePayload(linkArr, size, &colPayload);
+ AddRTSBaselinePayload(collResource, &colPayload);
}
OCRepPayloadSetPropObjectArrayAsOwner(colPayload, OC_RSRVD_LINKS, linkArr, dim);
ret = OC_STACK_OK;