libcoap  4.3.0rc2
encode.h
Go to the documentation of this file.
1 /*
2  * encode.h -- encoding and decoding of CoAP data types
3  *
4  * Copyright (C) 2010-2012 Olaf Bergmann <bergmann@tzi.org>
5  *
6  * This file is part of the CoAP library libcoap. Please see README for terms
7  * of use.
8  */
9 
10 #ifndef COAP_ENCODE_H_
11 #define COAP_ENCODE_H_
12 
13 #if (BSD >= 199103) || defined(WITH_CONTIKI) || defined(_WIN32)
14 # include <string.h>
15 #else
16 # include <strings.h>
17 #endif
18 
19 #include <stdint.h>
20 
21 #ifndef HAVE_FLS
22 /* include this only if fls() is not available */
23 extern int coap_fls(unsigned int i);
24 #else
25 #define coap_fls(i) fls(i)
26 #endif
27 
28 #ifndef HAVE_FLSLL
29  /* include this only if flsll() is not available */
30 extern int coap_flsll(long long i);
31 #else
32 #define coap_flsll(i) flsll(i)
33 #endif
34 
50 unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length);
51 
61 uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length);
62 
75 unsigned int coap_encode_var_safe(uint8_t *buf,
76  size_t length,
77  unsigned int value);
78 
91 unsigned int coap_encode_var_safe8(uint8_t *buf,
92  size_t length,
93  uint64_t value);
94 
113 coap_encode_var_bytes(uint8_t *buf, unsigned int value
114 ) {
115  return (int)coap_encode_var_safe(buf, sizeof(value), value);
116 }
117 
118 #endif /* COAP_ENCODE_H_ */
int coap_flsll(long long i)
Definition: encode.c:19
int coap_fls(unsigned int i)
Definition: encode.c:13
COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes(uint8_t *buf, unsigned int value)
Definition: encode.h:113
unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value)
Encodes multiple-length byte sequences.
Definition: encode.c:38
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition: encode.c:29
uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition: encode.c:58
unsigned int coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t value)
Encodes multiple-length byte sequences.
Definition: encode.c:68
#define COAP_DEPRECATED
Definition: libcoap.h:46
#define COAP_STATIC_INLINE
Definition: libcoap.h:38