diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-09 08:35:03 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-09 08:35:03 +0200 |
| commit | 432f24319319fe040e142059eb83279c53f90ab8 (patch) | |
| tree | 5631eb0eb3a46d086070e8398d9080ff681133ac /simclist-1.5/regrtest/test3-restore.c | |
| parent | 5d34aff5888d3f0c624251f15bedb96c347978d6 (diff) | |
refactor 2
Diffstat (limited to 'simclist-1.5/regrtest/test3-restore.c')
| -rw-r--r-- | simclist-1.5/regrtest/test3-restore.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/simclist-1.5/regrtest/test3-restore.c b/simclist-1.5/regrtest/test3-restore.c deleted file mode 100644 index 6e143f6..0000000 --- a/simclist-1.5/regrtest/test3-restore.c +++ /dev/null @@ -1,64 +0,0 @@ -#include <stdio.h> -#include <errno.h> -#include <stdlib.h> -#include <sys/types.h> -#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))) \ - ) - - -void *elunserial(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, val; - unsigned int mem; - - list_init(& l); - list_attributes_unserializer(&l, elunserial); - - mem = list_restore_file(&l, "mylistdump.simc"); - if (mem == 0 && errno != 0) { - perror("open"); - printf("fuck off\n"); - } else { - printf("Restored successfully:\n"); - printf("N els: %u\nmemread: %u\n", list_size(&l), mem); - for (data = 1; data < N; data++) { - val = *(unsigned long long *)list_get_at(&l, (unsigned int)data-1); - if (data != val) { - printf("Wrong data. Pos %llu, expected %llu, got %llu\n", data-1, data, val); - return 0; - } - printf("%lld ", val); - } - printf("\n"); - } - - list_destroy(& l); - - return 0; -} - |
