From 853bbb3752a5fa2f58ef456ffb6e3a552e13cb11 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 3 Aug 2025 19:22:36 +0200 Subject: initial commit --- simclist-1.5/regrtest/test3-dump.c | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 simclist-1.5/regrtest/test3-dump.c (limited to 'simclist-1.5/regrtest/test3-dump.c') diff --git a/simclist-1.5/regrtest/test3-dump.c b/simclist-1.5/regrtest/test3-dump.c new file mode 100644 index 0000000..667b119 --- /dev/null +++ b/simclist-1.5/regrtest/test3-dump.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include "../simclist.h" + +#define N 123 + +#define hton64(x) (\ + htons(1) == 1 ? \ + (uint64_t)x /* big endian */ \ + : /* little endian */ \ + ((uint64_t)((((uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \ + (((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \ + (((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \ + (((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \ + (((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \ + (((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \ + (((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \ + (((uint64_t)(x) & 0x00000000000000ffULL) << 56))) \ + ) + + +size_t meter(const void *el) { + return sizeof(unsigned long long int); +} + +void *elserial(const void *el, uint32_t *len) { + unsigned long long *x; + + *len = sizeof(unsigned long long); + x = malloc(*len); + *x = hton64(*(unsigned long long *)el); + + return x; +} + +int main() { + list_t l; + unsigned long long int data; + + list_init(& l); + list_attributes_copy(&l, meter, 1); + list_attributes_serializer(&l, elserial); + + for (data = 1; data < N; data++) { + list_append(& l, & data); + } + if (list_dump_file(&l, "mylistdump.simc") == 0 && errno != 0) { + printf("fuck off\n"); + } + + list_destroy(& l); + + return 0; +} + -- cgit v1.2.3-70-g09d2