libcoap 4.3.0
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 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 * This file is part of the CoAP library libcoap. Please see README for terms
9 * of use.
10 */
11
12#ifndef COAP_ENCODE_H_
13#define COAP_ENCODE_H_
14
15#if (BSD >= 199103) || defined(WITH_CONTIKI) || defined(_WIN32)
16# include <string.h>
17#else
18# include <strings.h>
19#endif
20
21#include <stdint.h>
22
23#ifndef HAVE_FLS
24/* include this only if fls() is not available */
25extern int coap_fls(unsigned int i);
26#else
27#define coap_fls(i) fls(i)
28#endif
29
30#ifndef HAVE_FLSLL
31 /* include this only if flsll() is not available */
32extern int coap_flsll(long long i);
33#else
34#define coap_flsll(i) flsll(i)
35#endif
36
52unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length);
53
63uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length);
64
77unsigned int coap_encode_var_safe(uint8_t *buf,
78 size_t length,
79 unsigned int value);
80
93unsigned int coap_encode_var_safe8(uint8_t *buf,
94 size_t length,
95 uint64_t value);
96
115coap_encode_var_bytes(uint8_t *buf, unsigned int value
116) {
117 return (int)coap_encode_var_safe(buf, sizeof(value), value);
118}
119
120#endif /* COAP_ENCODE_H_ */
int coap_flsll(long long i)
Definition: encode.c:21
int coap_fls(unsigned int i)
Definition: encode.c:15
COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes(uint8_t *buf, unsigned int value)
Definition: encode.h:115
unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value)
Encodes multiple-length byte sequences.
Definition: encode.c:40
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition: encode.c:31
uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition: encode.c:60
unsigned int coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t value)
Encodes multiple-length byte sequences.
Definition: encode.c:70
#define COAP_DEPRECATED
Definition: libcoap.h:48
#define COAP_STATIC_INLINE
Definition: libcoap.h:40