61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
#pragma once
|
|
#include <stdint.h>
|
|
|
|
/* UInt8 */
|
|
|
|
struct LengthPrefixUInt8Array {
|
|
uint64_t len;
|
|
uint8_t items[];
|
|
};
|
|
|
|
void length_prefix_uint8_array_clear(
|
|
struct LengthPrefixUInt8Array * data
|
|
);
|
|
void length_prefix_uint8_array_push(
|
|
struct LengthPrefixUInt8Array * data,
|
|
uint8_t value
|
|
);
|
|
int length_prefix_uint8_array_reverse(
|
|
struct LengthPrefixUInt8Array const * restrict src,
|
|
struct LengthPrefixUInt8Array * restrict dst
|
|
);
|
|
void length_prefix_uint8_array_dump(
|
|
struct LengthPrefixUInt8Array const * data
|
|
);
|
|
|
|
|
|
/* UInt64 */
|
|
|
|
struct LengthPrefixUInt64Array {
|
|
uint64_t len;
|
|
uint64_t items[];
|
|
};
|
|
|
|
void length_prefix_uint64_array_clear(
|
|
struct LengthPrefixUInt64Array * data
|
|
);
|
|
void length_prefix_uint64_array_push(
|
|
struct LengthPrefixUInt64Array * data,
|
|
uint64_t value
|
|
);
|
|
int length_prefix_uint64_array_reverse(
|
|
struct LengthPrefixUInt64Array const * restrict src,
|
|
struct LengthPrefixUInt64Array * restrict dst
|
|
);
|
|
void length_prefix_uint64_array_dump(
|
|
struct LengthPrefixUInt64Array const * data
|
|
);
|
|
|
|
|
|
/*
|
|
* Morphisms
|
|
*/
|
|
|
|
int morph_string_as_nullterm_to_length_prefix(
|
|
char const * restrict src,
|
|
struct LengthPrefixUInt8Array * restrict dst
|
|
);
|
|
int morph_string_as_length_prefix_to_nullterm(
|
|
struct LengthPrefixUInt8Array const * restrict src,
|
|
char * restrict dst
|
|
);
|