MilkeeyCat / ddnet_protocol

DDNet network parsing library in C
GNU Affero General Public License v3.0
0 stars 1 forks source link

DDNet networking library

Build

written in C btw

Installing

cmake -B build/
cmake --build build/
sudo cmake --install build/
// sample.c

#include <stdint.h>
#include <stdio.h>

#include <ddnet_protocol/huffman.h>

int main() {
    uint8_t decompressed[512];
    uint8_t compressed[] = {0x74, 0xde, 0x16, 0xd9, 0xa2, 0x8a, 0x1b};
    huffman_decompress(compressed, sizeof(compressed), decompressed, sizeof(decompressed));
    puts((const char *)decompressed); // foo
}
gcc sample.c -o sample -lddnet_protocol
./sample

Linking the library using CMake

Example's file structure:

.
├── libs
│   └── ddnet_protocol
├── main.c
└── CMakeLists.txt
# CMakeLists.txt

cmake_minimum_required(VERSION 3.16)
project(crocks)

add_executable(crocks
    main.c
)

add_subdirectory(libs/ddnet_protocol)
target_link_libraries(crocks ddnet_protocol)