Julian Hall | df86fce | 2020-11-23 18:09:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef PB_HELPER_H |
| 8 | #define PB_HELPER_H |
| 9 | |
| 10 | #include <pb.h> |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
Imre Kis | 1591fae | 2023-07-04 13:30:09 +0200 | [diff] [blame] | 16 | #define PB_PACKET_LENGTH(payload_length) ((payload_length) + 16) |
| 17 | |
Julian Hall | df86fce | 2020-11-23 18:09:55 +0100 | [diff] [blame] | 18 | /* Returns an initialised pb_callback_t structure for encoding a variable length byte array */ |
| 19 | extern pb_callback_t pb_out_byte_array(const pb_bytes_array_t *byte_array); |
| 20 | |
| 21 | /* Returns an initialised pb_callback_t structure for decoding a variable length byte array */ |
| 22 | extern pb_callback_t pb_in_byte_array(pb_bytes_array_t *byte_array); |
| 23 | |
| 24 | /* Malloc space for a pb_bytes_array_t object with space for the requested number of bytes */ |
| 25 | extern pb_bytes_array_t *pb_malloc_byte_array(size_t num_bytes); |
| 26 | |
| 27 | /* Malloc space for a pb_bytes_array_t object containing the given string */ |
| 28 | extern pb_bytes_array_t *pb_malloc_byte_array_containing_string(const char *str); |
| 29 | |
| 30 | /* Malloc space for a pb_bytes_array_t object containing the given bytes */ |
| 31 | extern pb_bytes_array_t *pb_malloc_byte_array_containing_bytes(const uint8_t *buf, size_t num_bytes); |
| 32 | |
| 33 | #ifdef __cplusplus |
| 34 | } /* extern "C" */ |
| 35 | #endif |
| 36 | |
| 37 | #endif /* PB_HELPER_H */ |