From adde37079b0eeccd34a017d885bc91da35a24d8d Mon Sep 17 00:00:00 2001 From: Agustin Isasmendi Date: Fri, 4 Apr 2025 09:11:08 +0200 Subject: [PATCH] contains snippet from LZ4 compression library --- src/snippets/main.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/snippets/main.c diff --git a/src/snippets/main.c b/src/snippets/main.c new file mode 100644 index 0000000..aa53564 --- /dev/null +++ b/src/snippets/main.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include "router.h" +#include "image_processor.h" + + +/********************************************************************/ +/* */ +/* SNIPPET TAKEN FROM LZ4 */ +/* */ +/********************************************************************/ +int function(const char *src, size_t srcLen, char *dst, size_t *dstLen) { + if (_ld == _ld_slow) { + /* Fill hash table with additional references, to improve compression capability */ + p = dict->dictionary; + idx32 = dict->currentOffset - dict->dictSize; + while (p <= dictEnd-HASH_UNIT) { + U32 const h = LZ4_hashPosition(p, tableType); + U32 const limit = dict->currentOffset - 64 KB; + if (LZ4_getIndexOnHash(h, dict->hashTable, tableType) <= limit) { + /* Note: not overwriting => favors positions beginning of dictionary */ + LZ4_putIndexOnHash(idx32, h, dict->hashTable, tableType); + } + p++; idx32++; + } + } +} +/********************************************************************/ +/* */ +/* SNIPPET TAKEN FROM LZ4 */ +/* */ +/********************************************************************/ + + +int main(int argc, char *argv[]) { + printf("Starting image processing server...\n"); + + /* Register available routes */ + register_route("/resize", handle_resize_image); + register_route("/rotate", handle_rotate_image); + register_route("/filter", handle_apply_filter); + + printf("Server started successfully.\n"); + + /* Here would be the main server loop */ + printf("Press Ctrl+C to exit.\n"); + + return 0; +}