Skip to content

Commit

Permalink
Adjust implementation for "alt path" and "delete all.
Browse files Browse the repository at this point in the history
Signed-off-by: Achim Kraus <achim.kraus@bosch-si.com>
  • Loading branch information
Achim Kraus committed Apr 17, 2015
1 parent 54eafc3 commit 9bb25bf
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions core/uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,15 @@ lwm2m_uri_t * lwm2m_decode_uri(char * altPath,

memset(uriP, 0, sizeof(lwm2m_uri_t));

if (uriPath->len == 0)
{
uriP->flag |= LWM2M_URI_FLAG_DELETE_ALL;
return uriP;
}

// Read object ID
if (URI_REGISTRATION_SEGMENT_LEN == uriPath->len
if (NULL != uriPath && URI_REGISTRATION_SEGMENT_LEN == uriPath->len
&& 0 == strncmp(URI_REGISTRATION_SEGMENT, uriPath->data, uriPath->len))
{
uriP->flag |= LWM2M_URI_FLAG_REGISTRATION;
uriPath = uriPath->next;
if (uriPath == NULL) return uriP;
}
else if (URI_BOOTSTRAP_SEGMENT_LEN == uriPath->len
else if (NULL != uriPath && URI_BOOTSTRAP_SEGMENT_LEN == uriPath->len
&& 0 == strncmp(URI_BOOTSTRAP_SEGMENT, uriPath->data, uriPath->len))
{
uriP->flag |= LWM2M_URI_FLAG_BOOTSTRAP;
Expand All @@ -128,20 +122,32 @@ lwm2m_uri_t * lwm2m_decode_uri(char * altPath,
return uriP;
}

// Read altPath if any
if (altPath != NULL)
if ((uriP->flag & LWM2M_URI_MASK_TYPE) != LWM2M_URI_FLAG_REGISTRATION)
{
int i;

for (i = 0 ; i < uriPath->len ; i++)
// Read altPath if any
if (altPath != NULL)
{
if (uriPath->data[i] != altPath[i+1])
int i;
if (NULL == uriPath)
{
lwm2m_free(uriP);
return NULL;
}
for (i = 0 ; i < uriPath->len ; i++)
{
if (uriPath->data[i] != altPath[i+1])
{
lwm2m_free(uriP);
return NULL;
}
}
uriPath = uriPath->next;
}
if (NULL == uriPath || uriPath->len == 0)
{
uriP->flag |= LWM2M_URI_FLAG_DELETE_ALL;
return uriP;
}
uriPath = uriPath->next;
}

readNum = prv_get_number(uriPath->data, uriPath->len);
Expand Down

0 comments on commit 9bb25bf

Please sign in to comment.