#include "oicgroup.h"
#include "cJSON.h"
-#include "ocmalloc.h"
+#include "oic_malloc.h"
#include "occollection.h"
#include "logger.h"
#include "timer.h"
#define ACTIONSET "ActionSet"
#define DELETE_ACTIONSET "DelActionSet"
-#define OIC_ACTION_PREFIX "{\"oc\":[{\"rep\":{"
+#define OIC_ACTION_PREFIX "{\"oic\":[{\"rep\":{"
#define VARIFY_POINTER_NULL(pointer, result, toExit) \
if(pointer == NULL) \
{\
#define OCFREE(pointer) \
{ \
- OCFree(pointer); \
+ OICFree(pointer); \
pointer = NULL; \
}
VARIFY_POINTER_NULL(iterToken, result, exit);
length = strlen(iterToken) + 1;
- *key = (char *) OCMalloc(length);
+ *key = (char *) OICMalloc(length);
VARIFY_POINTER_NULL(*key, result, exit)
strncpy(*key, iterToken + 1, length);
VARIFY_POINTER_NULL(iterToken, result, exit);
length = strlen(iterToken) + 1;
- *value = (char *) OCMalloc(length);
+ *value = (char *) OICMalloc(length);
VARIFY_POINTER_NULL(*value, result, exit)
strncpy(*value, iterToken + 1, length);
OCStackResult result = OC_STACK_OK;
token = (char*) strtok_r(pChar, ACTION_DELIMITER, &tokenPtr);
- *setName = (char *) OCMalloc(strlen(token) + 1);
+ *setName = (char *) OICMalloc(strlen(token) + 1);
VARIFY_POINTER_NULL(*setName, result, exit)
VARIFY_PARAM_NULL(token, result, exit)
strncpy(*setName, token, strlen(token) + 1);
OC_LOG(INFO, TAG, PCF("Build ActionSet Instance."));
- *set = (OCActionSet*) OCMalloc(sizeof(OCActionSet));
+ *set = (OCActionSet*) OICMalloc(sizeof(OCActionSet));
VARIFY_POINTER_NULL(*set, result, exit)
iterToken = (char *) strtok_r(actiondesc, ACTION_DELIMITER, &iterTokenPtr);
// ActionSet Name
memset(*set, 0, sizeof(OCActionSet));
- (*set)->actionsetName = (char *) OCMalloc(strlen(iterToken) + 1);
+ (*set)->actionsetName = (char *) OICMalloc(strlen(iterToken) + 1);
VARIFY_POINTER_NULL((*set)->actionsetName, result, exit)
VARIFY_PARAM_NULL(iterToken, result, exit)
strncpy((*set)->actionsetName, iterToken, strlen(iterToken) + 1);
iterToken = (char *) strtok_r(NULL, ACTION_DELIMITER, &iterTokenPtr);
while (iterToken)
{
- desc = (char *) OCMalloc(strlen(iterToken) + 1);
+ desc = (char *) OICMalloc(strlen(iterToken) + 1);
VARIFY_POINTER_NULL(desc, result, exit)
VARIFY_PARAM_NULL(desc, result, exit)
strncpy(desc, iterToken, strlen(iterToken) + 1);
&descIterTokenPtr);
while (descIterToken)
{
- attr = (char *) OCMalloc(strlen(descIterToken) + 1);
+ attr = (char *) OICMalloc(strlen(descIterToken) + 1);
VARIFY_POINTER_NULL(attr, result, exit)
VARIFY_PARAM_NULL(descIterToken, result, exit)
strncpy(attr, descIterToken, strlen(descIterToken) + 1);
attrIterToken = (char *) strtok_r(attr, ATTR_ASSIGN,
&attrIterTokenPtr);
- key = (char *) OCMalloc(strlen(attrIterToken) + 1);
+ key = (char *) OICMalloc(strlen(attrIterToken) + 1);
VARIFY_POINTER_NULL(key, result, exit)
VARIFY_PARAM_NULL(attrIterToken, result, exit)
strncpy(key, attrIterToken, strlen(attrIterToken) + 1);
attrIterToken = (char *) strtok_r(NULL, ATTR_ASSIGN,
&attrIterTokenPtr);
- value = (char *) OCMalloc(strlen(attrIterToken) + 1);
+ value = (char *) OICMalloc(strlen(attrIterToken) + 1);
VARIFY_POINTER_NULL(value, result, exit)
VARIFY_PARAM_NULL(attrIterToken, result, exit)
strncpy(value, attrIterToken, strlen(attrIterToken) + 1);
{
OC_LOG(INFO, TAG, PCF("Build OCAction Instance."));
- action = (OCAction*) OCMalloc(sizeof(OCAction));
+ action = (OCAction*) OICMalloc(sizeof(OCAction));
VARIFY_POINTER_NULL(action, result, exit)
memset(action, 0, sizeof(OCAction));
- action->resourceUri = (char *) OCMalloc(strlen(value) + 1);
+ action->resourceUri = (char *) OICMalloc(strlen(value) + 1);
VARIFY_POINTER_NULL(action->resourceUri, result, exit)
VARIFY_PARAM_NULL(value, result, exit)
strncpy(action->resourceUri, value, strlen(value) + 1);
{
OC_LOG(INFO, TAG, PCF("Build OCCapability Instance."));
- capa = (OCCapability*) OCMalloc(sizeof(OCCapability));
+ capa = (OCCapability*) OICMalloc(sizeof(OCCapability));
VARIFY_POINTER_NULL(capa, result, exit)
memset(capa, 0, sizeof(OCCapability));
- capa->capability = (char *) OCMalloc(strlen(key) + 1);
+ capa->capability = (char *) OICMalloc(strlen(key) + 1);
VARIFY_POINTER_NULL(capa->capability, result, exit)
VARIFY_PARAM_NULL(key, result, exit)
strncpy(capa->capability, key, strlen(key) + 1);
- capa->status = (char *) OCMalloc(strlen(value) + 1);
+ capa->status = (char *) OICMalloc(strlen(value) + 1);
VARIFY_POINTER_NULL(capa->status, result, exit)
VARIFY_PARAM_NULL(value, result, exit)
strncpy(capa->status, value, strlen(value) + 1);
}
}
- *desc = (char *) OCMalloc(1024 - remaining);
+ *desc = (char *) OICMalloc(1024 - remaining);
VARIFY_POINTER_NULL(*desc, res, exit);
strcpy(*desc, temp);
{
int idx;
- unsigned char *responseJson;
- responseJson = (unsigned char *) OCMalloc(
- (unsigned int) (strlen((char *) clientResponse->resJSONPayload)
- + 1));
+ unsigned char *responseJson = NULL;
+ // TODO: Figure out what this does, change implementation
+ //responseJson = (unsigned char *) OICMalloc(
+ // (unsigned int) (strlen((char *) clientResponse->resJSONPayload)
+ // + 1));
if( responseJson == NULL )
return OC_STACK_DELETE_TRANSACTION;
// We need the body of response.
// Copy the body from the response
- strcpy((char *) responseJson,
- ((char *) clientResponse->resJSONPayload + OC_JSON_PREFIX_LEN));
- idx = strlen((char *) responseJson) - OC_JSON_SUFFIX_LEN;
+ // TODO: Taken out
+ //strcpy((char *) responseJson,
+ // ((char *) clientResponse->resJSONPayload + OC_JSON_PREFIX_LEN));
+ //idx = strlen((char *) responseJson) - OC_JSON_SUFFIX_LEN;
// And insert NULL at the end of body.
(responseJson[idx]) = 0;
OCEntityHandlerResponse response = { 0 };
response.ehResult = OC_EH_OK;
- response.payload = (char*)responseJson;
- response.payloadSize = (unsigned int) strlen((char *) responseJson) + 1;
+ // TODO: Removing payload size, waht goes here?
+ // response.payload = (char*)responseJson;
+ //response.payloadSize = (unsigned int) strlen((char *) responseJson) + 1;
response.persistentBufferFlag = 0;
response.requestHandle = (OCRequestHandle) info->ehRequest;
response.resourceHandle = (OCResourceHandle) info->collResource;
OCStackResult SendAction(OCDoHandle *handle, const char *targetUri,
const unsigned char *action)
{
- OCCallbackData cbdata = { 0 };
+ OCCallbackData cbdata;
cbdata.cb = &ActionSetCB;
cbdata.cd = NULL;
cbdata.context = (void*)DEFAULT_CONTEXT_VALUE;
-// TODO: Selecting OC_IPV4.
-// It is temporary change as OC_ALL is not working currently. Remove this code and use OC_ALL
-// once it is functioning.
-
- return OCDoResource(handle, OC_REST_PUT, targetUri,
- NULL, (char *) action, OC_IPV4, OC_NA_QOS, &cbdata, NULL, 0);
+ // TODO: disabled since this is no longer compatible
+ return OC_STACK_NOTIMPL;
+ //return OCDoResource(handle, OC_REST_PUT, targetUri,
+ // NULL, (char *) action, CT_ADAPTER_IP, OC_NA_QOS, &cbdata, NULL, 0);
}
OCStackResult DoAction(OCResource* resource, OCActionSet* actionset,
strncat((char *) actionDescPtr, (const char *) OC_JSON_SUFFIX,
strlen((const char *) OC_JSON_SUFFIX));
- ClientRequestInfo *info = (ClientRequestInfo *) OCMalloc(
+ ClientRequestInfo *info = (ClientRequestInfo *) OICMalloc(
sizeof(ClientRequestInfo));
if( info == NULL )
actionDescPtr);
if (result != OC_STACK_OK)
{
+ OICFree(info);
return result;
}
if (info->actionset->type == RECURSIVE)
{
ScheduledResourceInfo *schedule;
- schedule = (ScheduledResourceInfo *) OCMalloc(
+ schedule = (ScheduledResourceInfo *) OICMalloc(
sizeof(ScheduledResourceInfo));
if (schedule)
char *jsonResponse;
- stackRet = ExtractKeyValueFromRequest((char *) ehRequest->reqJSONPayload,
- &doWhat, &details);
+ stackRet = OC_STACK_NOTIMPL;
+ // TODO: Fix?
+ //stackRet = ExtractKeyValueFromRequest((char *) ehRequest->reqJSONPayload,
+ // &doWhat, &details);
if(stackRet != OC_STACK_OK)
{
response.ehResult = OC_EH_OK;
else
response.ehResult = OC_EH_ERROR;
- response.payload = (char*)buffer;
- response.payloadSize = bufferLength + 1;
+ // TODO: Fix
+ //response.payload = (char*)buffer;
+ //response.payloadSize = bufferLength + 1;
response.persistentBufferFlag = 0;
response.requestHandle =
(OCRequestHandle) ehRequest->requestHandle;
(delay == -1 ? actionset->timesteps : delay);
ScheduledResourceInfo *schedule;
- schedule = (ScheduledResourceInfo *) OCMalloc(
+ schedule = (ScheduledResourceInfo *) OICMalloc(
sizeof(ScheduledResourceInfo));
if (schedule)
{
cJSON_AddStringToObject(format, ACTIONSET, plainText);
}
- OCFree(plainText);
+ OICFree(plainText);
stackRet = OC_STACK_OK;
}
}
response.ehResult = OC_EH_OK;
else
response.ehResult = OC_EH_ERROR;
- response.payload = (char *)buffer;
- response.payloadSize = bufferLength + 1;
+ // TODO: Implement
+ //response.payload = (char *)buffer;
+ //response.payloadSize = bufferLength + 1;
response.persistentBufferFlag = 0;
response.requestHandle =
(OCRequestHandle) ehRequest->requestHandle;