1 /* encode.c -- encoding and decoding of CoAP data types
3 * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
5 * This file is part of the CoAP library libcoap. Please see
6 * README for terms of use.
16 /* Carsten suggested this when fls() is not available: */
17 int coap_fls(unsigned int i) {
25 coap_decode_var_bytes(unsigned char *buf,unsigned int len) {
26 unsigned int i, n = 0;
27 for (i = 0; i < len; ++i)
28 n = (n << 8) + buf[i];
34 coap_encode_var_bytes(unsigned char *buf, unsigned int val) {
37 for (n = 0, i = val; i && n < sizeof(val); ++n)