blob: 2c2d365f61428987bce4e98d6a18f8c43eb9f55c [file] [log] [blame]
John Wangd8702f62019-10-31 10:06:35 +08001#ifndef UTILS_H__
2#define UTILS_H__
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
John Wang72136232019-11-14 15:33:42 +08008#include "pldm_types.h"
John Wangd8702f62019-10-31 10:06:35 +08009#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 */
18uint32_t crc32(const void *data, size_t size);
19
John Wang72136232019-11-14 15:33:42 +080020/** @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 */
27int ver2str(const ver32_t *version, char *buffer, size_t buffer_size);
28
John Wangd8702f62019-10-31 10:06:35 +080029#ifdef __cplusplus
30}
31#endif
32
John Wang72136232019-11-14 15:33:42 +080033#endif