swarmfile.h (1035B)
1 #ifndef _LIBSWARM_FILE 2 #define _LIBSWARM_FILE 3 4 #ifdef LIBSWARM_MALLOC 5 #include "bmt_malloc.h" 6 #else 7 #include "bmt.h" 8 #endif 9 10 #define SWARM_BATCH_SIZE (int)(SWARM_BLOCK_SIZE / SWARM_WORD_SIZE) 11 #define SWARM_LEVELS 9 12 13 typedef struct filehash { 14 unsigned char buf[SWARM_LEVELS * SWARM_BLOCK_SIZE]; 15 unsigned char *ptr[SWARM_LEVELS]; 16 unsigned char *target; 17 long long writes[SWARM_LEVELS]; 18 long long spans[SWARM_LEVELS]; 19 long long length; 20 void (*callback)(const unsigned char*, const unsigned char*, const size_t, void*); 21 void *callback_static; 22 bmt_t bmt_context; 23 } filehash_t; 24 25 void filehash_reset(filehash_t *filehash_context); 26 void filehash_init(filehash_t *filehash_context); 27 void filehash_init_callback(filehash_t *filehash_context, void (*callback)(const unsigned char*, const unsigned char*, const size_t, void*), void *callback_static); 28 int filehash_write(filehash_t *filehash_context, const unsigned char *data, const size_t data_length); 29 bmt_spansize_t filehash_sum(filehash_t *filehash_content); 30 31 #endif // _LIBSWARM_FILE