2023-12-31 17:49:42 +05:30
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifndef _FWRITE_LE_H
|
|
|
|
#define _FWRITE_LE_H
|
|
|
|
|
|
|
|
#define FWRITE_LE_NO_MODIFICATION 0
|
|
|
|
|
|
|
|
#define DETECTED_LITTLE_ENDIAN 0
|
|
|
|
#define DETECTED_BIG_ENDIAN 1
|
|
|
|
#define UNSUPPORTED_ENDIANNESS -1
|
|
|
|
|
2024-05-19 16:28:26 +05:30
|
|
|
#define ORDER_NATIVE_U32 0x01234567
|
|
|
|
#define ORDER_LITTLE_ENDIAN_S4 "\x67\x45\x23\x01"
|
|
|
|
#define ORDER_BIG_ENDIAN_S4 "\x01\x23\x45\x67"
|
|
|
|
#define ifeq_u32_ret(lhs, rhs, value) if (!memcmp(lhs, rhs, 4)) return value;
|
|
|
|
|
2023-12-31 17:49:42 +05:30
|
|
|
int detect_endianness(void);
|
|
|
|
size_t fwrite_le(void* ptr, size_t size, size_t count, FILE* stream);
|
2024-01-24 22:29:05 +05:30
|
|
|
void reorder_le_be(
|
2024-01-02 02:49:51 +05:30
|
|
|
#if FWRITE_LE_NO_MODIFICATION
|
|
|
|
uint8_t* dest, uint8_t* src,
|
|
|
|
#else
|
|
|
|
uint8_t* bytes,
|
|
|
|
#endif
|
|
|
|
size_t count, size_t step);
|
2023-12-31 17:49:42 +05:30
|
|
|
|
|
|
|
#endif /* _FWRITE_LE_H */
|