mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-14 04:09:43 +03:00
moving library related files to new folders
In preparation for changing the make buildsystem to a fully autotools controlled system moving the core libcoap source files to a better logical place. All the library related header files moving to include/coap/ to get all the public and local header files in a separate place. Also moving the C source files of the libcoap library to the folder src/.
This commit is contained in:
1 parent
fd86c02ac4
commit
fc9b47167a
37 files changed
No files matched your search
@@ -0,0 +1,48 @@
|
||||
/* encode.c -- encoding and decoding of CoAP data types
|
||||
*
|
||||
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see
|
||||
* README for terms of use.
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "coap_config.h"
|
||||
#include "encode.h"
|
||||
|
||||
/* Carsten suggested this when fls() is not available: */
|
||||
int coap_fls(unsigned int i) {
|
||||
int n;
|
||||
for (n = 0; i; n++)
|
||||
i >>= 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
coap_decode_var_bytes(unsigned char *buf,unsigned int len) {
|
||||
unsigned int i, n = 0;
|
||||
for (i = 0; i < len; ++i)
|
||||
n = (n << 8) + buf[i];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
coap_encode_var_bytes(unsigned char *buf, unsigned int val) {
|
||||
unsigned int n, i;
|
||||
|
||||
for (n = 0, i = val; i && n < sizeof(val); ++n)
|
||||
i >>= 8;
|
||||
|
||||
i = n;
|
||||
while (i--) {
|
||||
buf[i] = val & 0xff;
|
||||
val >>= 8;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user