-#ifdef WITH_RD
-static OCStackResult checkResourceExistsAtRD(const char *interfaceType, const char *resourceType,
- OCResource **payload, OCDevAddr *devAddr)
-{
- OCResourceCollectionPayload *repPayload;
- if (!payload)
- {
- return OC_STACK_ERROR;
- }
- if (OCRDCheckPublishedResource(interfaceType, resourceType, &repPayload, devAddr) == OC_STACK_OK)
- {
- if (!repPayload)
- {
- return OC_STACK_ERROR;
- }
- OCResource *ptr = ((OCResource *) OICCalloc(1, sizeof(OCResource)));
- if (!ptr)
- {
- return OC_STACK_NO_MEMORY;
- }
-
- ptr->uri = OICStrdup(repPayload->setLinks->href);
- if (!ptr->uri)
- {
- return OC_STACK_NO_MEMORY;
- }
- OCStringLL *rt = repPayload->setLinks->rt;
- while (rt)
- {
- OCResourceType *temp = (OCResourceType *) OICCalloc(1, sizeof(OCResourceType));
- if(!temp)
- {
- OICFree(ptr->uri);
- return OC_STACK_NO_MEMORY;
- }
- temp->next = NULL;
- temp->resourcetypename = OICStrdup(rt->value);
- if (!ptr->rsrcType)
- {
- ptr->rsrcType = temp;
- }
- else
- {
- OCResourceType *type = ptr->rsrcType;
- while (type->next)
- {
- type = type->next;
- }
- type->next = temp;
- }
- rt = rt->next;
- }
-
- OCStringLL *itf = repPayload->setLinks->itf;
- while (itf)
- {
- OCResourceInterface *temp = (OCResourceInterface *) OICCalloc(1, sizeof(OCResourceInterface));
- if (!temp)
- {
- OICFree(ptr->uri);
-
- return OC_STACK_NO_MEMORY;
- }
- temp->next = NULL;
- temp->name = OICStrdup(itf->value);
- if (!ptr->rsrcInterface)
- {
- ptr->rsrcInterface = temp;
- }
- else
- {
- OCResourceInterface *type = ptr->rsrcInterface;
- while (type->next)
- {
- type = type->next;
- }
- type->next = temp;
- }
- itf = itf->next;
- }
-
- ptr->resourceProperties = (OCResourceProperty) repPayload->tags->bitmap;
-
- OCFreeCollectionResource(repPayload);
- *payload = ptr;
- return OC_STACK_OK;
- }
- else
- {
- OIC_LOG_V(ERROR, TAG, "The resource type or interface type doe not exist \
- on the resource directory");
- }
- return OC_STACK_ERROR;
-}
-#endif
-