John Wang | d8702f6 | 2019-10-31 10:06:35 +0800 | [diff] [blame] | 1 | #ifndef UTILS_H__ |
| 2 | #define UTILS_H__ |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
John Wang | 7213623 | 2019-11-14 15:33:42 +0800 | [diff] [blame] | 8 | #include "pldm_types.h" |
John Wang | d8702f6 | 2019-10-31 10:06:35 +0800 | [diff] [blame] | 9 | #include <stddef.h> |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | /** @brief Compute Crc32(same as the one used by IEEE802.3) |
| 13 | * |
| 14 | * @param[in] data - Pointer to the target data |
| 15 | * @param[in] size - Size of the data |
| 16 | * @return The checksum |
| 17 | */ |
| 18 | uint32_t crc32(const void *data, size_t size); |
| 19 | |
John Wang | 7213623 | 2019-11-14 15:33:42 +0800 | [diff] [blame] | 20 | /** @brief Convert ver32_t to string |
| 21 | * @param[in] version - Pointer to ver32_t |
| 22 | * @param[out] buffer - Pointer to the buffer |
| 23 | * @param[in] buffer_size - Size of the buffer |
| 24 | * @return The number of characters(excluding the null byte) or negative if |
| 25 | * error is encountered |
| 26 | */ |
| 27 | int ver2str(const ver32_t *version, char *buffer, size_t buffer_size); |
| 28 | |
John Wang | d8702f6 | 2019-10-31 10:06:35 +0800 | [diff] [blame] | 29 | #ifdef __cplusplus |
| 30 | } |
| 31 | #endif |
| 32 | |
John Wang | 7213623 | 2019-11-14 15:33:42 +0800 | [diff] [blame] | 33 | #endif |