diff --git a/adler32.c b/adler32.c index 78999f5..0e4e5f9 100644 --- a/adler32.c +++ b/adler32.c @@ -22,7 +22,7 @@ #include "library.h" #include "adler32.h" -adler32_ctx* adler32_init() +AARU_EXPORT adler32_ctx* AARU_CALL adler32_init() { adler32_ctx* ctx; @@ -36,7 +36,7 @@ adler32_ctx* adler32_init() return ctx; } -int adler32_update(adler32_ctx* ctx, const uint8_t* data, uint32_t len) +AARU_EXPORT int AARU_CALL adler32_update(adler32_ctx* ctx, const uint8_t* data, uint32_t len) { if(!ctx || !data) return -1; @@ -49,7 +49,7 @@ int adler32_update(adler32_ctx* ctx, const uint8_t* data, uint32_t len) return 0; } -int adler32_final(adler32_ctx* ctx, uint32_t* checksum) +AARU_EXPORT int AARU_CALL adler32_final(adler32_ctx* ctx, uint32_t* checksum) { if(!ctx) return -1; @@ -57,7 +57,7 @@ int adler32_final(adler32_ctx* ctx, uint32_t* checksum) return 0; } -void adler32_free(adler32_ctx* ctx) +AARU_EXPORT void AARU_CALL adler32_free(adler32_ctx* ctx) { if(!ctx) return; diff --git a/adler32.h b/adler32.h index 07d5ed5..ca595c6 100644 --- a/adler32.h +++ b/adler32.h @@ -31,4 +31,4 @@ AARU_EXPORT int AARU_CALL adler32_update(adler32_ctx* ctx, const uint8_t* data, AARU_EXPORT int AARU_CALL adler32_final(adler32_ctx* ctx, uint32_t* checksum); AARU_EXPORT void AARU_CALL adler32_free(adler32_ctx* ctx); -#endif//AARU_CHECKSUMS_NATIVE_LIBRARY_H +#endif //AARU_CHECKSUMS_NATIVE_ADLER32_H diff --git a/crc16.c b/crc16.c index db80c86..a438164 100644 --- a/crc16.c +++ b/crc16.c @@ -19,11 +19,11 @@ #include #include -#include "crc16.h" - #include "library.h" -crc16_ctx* crc16_init(void) +#include "crc16.h" + +AARU_EXPORT crc16_ctx* AARU_CALL crc16_init(void) { crc16_ctx* ctx = (crc16_ctx*)malloc(sizeof(crc16_ctx)); @@ -34,7 +34,7 @@ crc16_ctx* crc16_init(void) return ctx; } -int crc16_update(crc16_ctx* ctx, const uint8_t* data, uint32_t len) +AARU_EXPORT int AARU_CALL crc16_update(crc16_ctx* ctx, const uint8_t* data, uint32_t len) { if(!ctx || !data) return -1; @@ -43,7 +43,7 @@ int crc16_update(crc16_ctx* ctx, const uint8_t* data, uint32_t len) return 0; } -int crc16_final(crc16_ctx* ctx, uint16_t* crc) +AARU_EXPORT int AARU_CALL crc16_final(crc16_ctx* ctx, uint16_t* crc) { if(!ctx) return -1; @@ -52,7 +52,7 @@ int crc16_final(crc16_ctx* ctx, uint16_t* crc) return 0; } -void crc16_free(crc16_ctx* ctx) +AARU_EXPORT void AARU_CALL crc16_free(crc16_ctx* ctx) { if(ctx) free(ctx); } \ No newline at end of file diff --git a/crc16.h b/crc16.h index 9708f9d..89a1eaf 100644 --- a/crc16.h +++ b/crc16.h @@ -45,7 +45,7 @@ static uint16_t crc16_table[256] = 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 }; -crc16_ctx* crc16_init(); -int crc16_update(crc16_ctx* ctx, const uint8_t* data, uint32_t len); -int crc16_final(crc16_ctx* ctx, uint16_t* crc); -void crc16_free(crc16_ctx* ctx); \ No newline at end of file +AARU_EXPORT crc16_ctx* AARU_CALL crc16_init(); +AARU_EXPORT int AARU_CALL crc16_update(crc16_ctx* ctx, const uint8_t* data, uint32_t len); +AARU_EXPORT int AARU_CALL crc16_final(crc16_ctx* ctx, uint16_t* crc); +AARU_EXPORT void AARU_CALL crc16_free(crc16_ctx* ctx); \ No newline at end of file diff --git a/crc16_ccitt.c b/crc16_ccitt.c index af30252..bffaabc 100644 --- a/crc16_ccitt.c +++ b/crc16_ccitt.c @@ -19,11 +19,11 @@ #include #include -#include "crc16_ccitt.h" - #include "library.h" -crc16_ccitt_ctx* crc16_ccitt_init(void) +#include "crc16_ccitt.h" + +AARU_EXPORT crc16_ccitt_ctx* AARU_CALL crc16_ccitt_init(void) { crc16_ccitt_ctx* ctx = (crc16_ccitt_ctx*)malloc(sizeof(crc16_ccitt_ctx)); @@ -34,7 +34,7 @@ crc16_ccitt_ctx* crc16_ccitt_init(void) return ctx; } -int crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len) +AARU_EXPORT int AARU_CALL crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len) { if(!ctx || !data) return -1; @@ -43,7 +43,7 @@ int crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len) return 0; } -int crc16_ccitt_final(crc16_ccitt_ctx* ctx, uint16_t* crc) +AARU_EXPORT int AARU_CALL crc16_ccitt_final(crc16_ccitt_ctx* ctx, uint16_t* crc) { if(!ctx) return -1; @@ -52,7 +52,7 @@ int crc16_ccitt_final(crc16_ccitt_ctx* ctx, uint16_t* crc) return 0; } -void crc16_ccitt_free(crc16_ccitt_ctx* ctx) +AARU_EXPORT void AARU_CALL crc16_ccitt_free(crc16_ccitt_ctx* ctx) { if(ctx) free(ctx); } \ No newline at end of file diff --git a/crc16_ccitt.h b/crc16_ccitt.h index f41b2d2..653fc2e 100644 --- a/crc16_ccitt.h +++ b/crc16_ccitt.h @@ -45,7 +45,7 @@ static uint16_t crc16_ccitt_table[256] = 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; -crc16_ccitt_ctx* crc16_ccitt_init(); -int crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len); -int crc16_ccitt_final(crc16_ccitt_ctx* ctx, uint16_t* crc); -void crc16_ccitt_free(crc16_ccitt_ctx* ctx); \ No newline at end of file +AARU_EXPORT crc16_ccitt_ctx* AARU_CALL crc16_ccitt_init(); +AARU_EXPORT int AARU_CALL crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len); +AARU_EXPORT int AARU_CALL crc16_ccitt_final(crc16_ccitt_ctx* ctx, uint16_t* crc); +AARU_EXPORT void AARU_CALL crc16_ccitt_free(crc16_ccitt_ctx* ctx); \ No newline at end of file diff --git a/crc32.c b/crc32.c index 8aab08a..fcfb640 100644 --- a/crc32.c +++ b/crc32.c @@ -19,11 +19,11 @@ #include #include -#include "crc32.h" - #include "library.h" -crc32_ctx* crc32_init(void) +#include "crc32.h" + +AARU_EXPORT crc32_ctx* AARU_CALL crc32_init(void) { crc32_ctx* ctx = (crc32_ctx*)malloc(sizeof(crc32_ctx)); @@ -44,7 +44,7 @@ crc32_ctx* crc32_init(void) return ctx; } -int crc32_update(crc32_ctx* ctx, const uint8_t* data, uint32_t len) +AARU_EXPORT int AARU_CALL crc32_update(crc32_ctx* ctx, const uint8_t* data, uint32_t len) { if(!ctx || !data) return -1; @@ -53,7 +53,7 @@ int crc32_update(crc32_ctx* ctx, const uint8_t* data, uint32_t len) return 0; } -int crc32_final(crc32_ctx* ctx, uint32_t* crc) +AARU_EXPORT int AARU_CALL crc32_final(crc32_ctx* ctx, uint32_t* crc) { if(!ctx) return -1; @@ -62,7 +62,7 @@ int crc32_final(crc32_ctx* ctx, uint32_t* crc) return 0; } -void crc32_free(crc32_ctx* ctx) +AARU_EXPORT void AARU_CALL crc32_free(crc32_ctx* ctx) { if(ctx) free(ctx); } \ No newline at end of file diff --git a/crc32.h b/crc32.h index 0c6e271..81fe446 100644 --- a/crc32.h +++ b/crc32.h @@ -25,7 +25,7 @@ typedef struct #define CRC32_ISO_POLY 0xEDB88320 #define CRC32_ISO_SEED 0xFFFFFFFF -crc32_ctx* crc32_init(); -int crc32_update(crc32_ctx* ctx, const uint8_t* data, uint32_t len); -int crc32_final(crc32_ctx* ctx, uint32_t* crc); -void crc32_free(crc32_ctx* ctx); \ No newline at end of file +AARU_EXPORT crc32_ctx* AARU_CALL crc32_init(); +AARU_EXPORT int AARU_CALL crc32_update(crc32_ctx* ctx, const uint8_t* data, uint32_t len); +AARU_EXPORT int AARU_CALL crc32_final(crc32_ctx* ctx, uint32_t* crc); +AARU_EXPORT void AARU_CALL crc32_free(crc32_ctx* ctx); \ No newline at end of file diff --git a/crc64.c b/crc64.c index cdeb6c0..39577d0 100644 --- a/crc64.c +++ b/crc64.c @@ -19,11 +19,11 @@ #include #include -#include "crc64.h" - #include "library.h" -crc64_ctx* crc64_init(void) +#include "crc64.h" + +AARU_EXPORT crc64_ctx* AARU_CALL crc64_init(void) { crc64_ctx* ctx = (crc64_ctx*)malloc(sizeof(crc64_ctx)); @@ -44,7 +44,7 @@ crc64_ctx* crc64_init(void) return ctx; } -int crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len) +AARU_EXPORT int AARU_CALL crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len) { if(!ctx || !data) return -1; @@ -53,7 +53,7 @@ int crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len) return 0; } -int crc64_final(crc64_ctx* ctx, uint64_t* crc) +AARU_EXPORT int AARU_CALL crc64_final(crc64_ctx* ctx, uint64_t* crc) { if(!ctx) return -1; @@ -62,7 +62,7 @@ int crc64_final(crc64_ctx* ctx, uint64_t* crc) return 0; } -void crc64_free(crc64_ctx* ctx) +AARU_EXPORT void AARU_CALL crc64_free(crc64_ctx* ctx) { if(ctx) free(ctx); } \ No newline at end of file diff --git a/crc64.h b/crc64.h index 18e4920..3caad5f 100644 --- a/crc64.h +++ b/crc64.h @@ -25,7 +25,7 @@ typedef struct #define CRC64_ECMA_POLY 0xC96C5795D7870F42 #define CRC64_ECMA_SEED 0xFFFFFFFFFFFFFFFF -crc64_ctx* crc64_init(); -int crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len); -int crc64_final(crc64_ctx* ctx, uint64_t* crc); -void crc64_free(crc64_ctx* ctx); \ No newline at end of file +AARU_EXPORT crc64_ctx* AARU_CALL crc64_init(); +AARU_EXPORT int AARU_CALL crc64_update(crc64_ctx* ctx, const uint8_t* data, uint32_t len); +AARU_EXPORT int AARU_CALL crc64_final(crc64_ctx* ctx, uint64_t* crc); +AARU_EXPORT void AARU_CALL crc64_free(crc64_ctx* ctx); \ No newline at end of file diff --git a/spamsum.c b/spamsum.c index 0d16cfb..54ffc5c 100644 --- a/spamsum.c +++ b/spamsum.c @@ -21,17 +21,17 @@ #include #include -#include "spamsum.h" - #include "library.h" +#include "spamsum.h" + static uint8_t _b64[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F}; -spamsum_ctx* spamsum_init(void) +AARU_EXPORT spamsum_ctx* AARU_CALL spamsum_init(void) { spamsum_ctx* ctx = (spamsum_ctx*)malloc(sizeof(spamsum_ctx)); if(!ctx) return NULL; @@ -45,7 +45,7 @@ spamsum_ctx* spamsum_init(void) return ctx; } -int spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len) +AARU_EXPORT int AARU_CALL spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len) { if(!ctx || !data) return -1; @@ -56,7 +56,7 @@ int spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len) return 0; } -void spamsum_free(spamsum_ctx* ctx) +AARU_EXPORT void AARU_CALL spamsum_free(spamsum_ctx* ctx) { if(ctx) free(ctx); } @@ -65,7 +65,7 @@ void spamsum_free(spamsum_ctx* ctx) #define sum_hash(c, h) ((h * HASH_PRIME) ^ c); #define SSDEEP_BS(index) (MIN_BLOCKSIZE << index) -void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c) +AARU_LOCAL void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c) { uint32_t i; /* At each character we update the rolling hash and the normal hashes. @@ -118,7 +118,7 @@ void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c) } } -void roll_hash(spamsum_ctx* ctx, uint8_t c) +AARU_LOCAL void roll_hash(spamsum_ctx* ctx, uint8_t c) { ctx->Roll.H2 -= ctx->Roll.H1; ctx->Roll.H2 += ROLLING_WINDOW * c; @@ -136,7 +136,7 @@ void roll_hash(spamsum_ctx* ctx, uint8_t c) ctx->Roll.H3 ^= c; } -void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx) +AARU_LOCAL void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx) { assert(ctx->Bhstart < ctx->Bhend); @@ -156,7 +156,7 @@ void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx) ++ctx->Bhstart; } -void fuzzy_try_fork_blockhash(spamsum_ctx* ctx) +AARU_LOCAL void fuzzy_try_fork_blockhash(spamsum_ctx* ctx) { if(ctx->Bhend >= NUM_BLOCKHASHES) return; @@ -172,7 +172,7 @@ void fuzzy_try_fork_blockhash(spamsum_ctx* ctx) ++ctx->Bhend; } -uint8_t* spamsum_final(spamsum_ctx* ctx) +AARU_EXPORT uint8_t* AARU_CALL spamsum_final(spamsum_ctx* ctx) { uint32_t bi = ctx->Bhstart; uint32_t h = roll_sum(ctx); diff --git a/spamsum.h b/spamsum.h index 46e8dbb..80c552b 100644 --- a/spamsum.h +++ b/spamsum.h @@ -51,13 +51,13 @@ typedef struct RollState Roll; } spamsum_ctx; -spamsum_ctx* spamsum_init(void); -int spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len); -uint8_t* spamsum_final(spamsum_ctx* ctx); -void spamsum_free(spamsum_ctx* ctx); +AARU_EXPORT spamsum_ctx* AARU_CALL spamsum_init(void); +AARU_EXPORT int AARU_CALL spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len); +AARU_EXPORT uint8_t* AARU_CALL spamsum_final(spamsum_ctx* ctx); +AARU_EXPORT void AARU_CALL spamsum_free(spamsum_ctx* ctx); -void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c); -void roll_hash(spamsum_ctx* ctx, uint8_t c); -void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx); -void fuzzy_try_fork_blockhash(spamsum_ctx* ctx); +AARU_LOCAL void fuzzy_engine_step(spamsum_ctx* ctx, uint8_t c); +AARU_LOCAL void roll_hash(spamsum_ctx* ctx, uint8_t c); +AARU_LOCAL void fuzzy_try_reduce_blockhash(spamsum_ctx* ctx); +AARU_LOCAL void fuzzy_try_fork_blockhash(spamsum_ctx* ctx);