Ejemplo n.º 1
0
int coap_split_path(const unsigned char *s, size_t length, unsigned char *buf, size_t *buflen)
{
	struct cnt_str tmp = { {*buflen, buf}, 0 };
	coap_parse_iterator_t pi;

	coap_parse_iterator_init((unsigned char *)s, length, '/', (unsigned char *)"?#", 2, &pi);
	coap_split_path_impl(&pi, write_option, &tmp);

	*buflen = *buflen - tmp.buf.length;
	return tmp.n;
}
Ejemplo n.º 2
0
/**
 * This method initializes the OicParseQueryIter_t struct
 *
 *@param query     - REST query, to be parsed
 *@param parseIter - OicParseQueryIter_t struct, to be initialized
 *
 */
void ParseQueryIterInit(unsigned char * query, OicParseQueryIter_t * parseIter)
{
    OIC_LOG (INFO, TAG, "Initializing coap iterator");
    if((NULL == query) || (NULL == parseIter))
        return;

    parseIter->attrPos = NULL;
    parseIter->attrLen = 0;
    parseIter->valPos = NULL;
    parseIter->valLen = 0;
    coap_parse_iterator_init(query, strlen((char *)query),
          (unsigned char *)OIC_SEC_REST_QUERY_SEPARATOR, (unsigned char *) "", 0, &parseIter->pi);
}
Ejemplo n.º 3
0
int coap_hash_path(const unsigned char *path, size_t len, coap_key_t key)
{
    coap_parse_iterator_t pi;

    if (!path)
        return 0;

    memset(key, 0, sizeof(coap_key_t));

    coap_parse_iterator_init((unsigned char *) path, len, '/', (unsigned char *) "?#", 2, &pi);
    coap_split_path_impl(&pi, hash_segment, key);

    return 1;
}
Ejemplo n.º 4
0
int coap_split_query(const unsigned char *s, size_t length, unsigned char *buf, size_t *buflen)
{
    struct cnt_str tmp =
    {
    { *buflen, buf }, 0 };
    coap_parse_iterator_t pi;

    coap_parse_iterator_init((unsigned char *) s, length, (unsigned char *)OC_QUERY_SEPARATOR,
                             (unsigned char *) "#", 1, &pi);

    coap_split_path_impl(&pi, write_option, &tmp);

    *buflen = tmp.buf.length;
    return tmp.n;
}