mirror of
https://github.com/logos-storage/easylibstorage.git
synced 2026-02-09 11:23:06 +00:00
1.7 KiB
1.7 KiB
libeasystorage
A simplified, higher level C wrapper around libstorage. Includes examples showing how to implement simple filesharing apps.
Prerequisites
- CMake 3.14+
- C11 compiler
- libstorage (build or get binary from logos-storage-nim)
Building
cmake -B build -DLOGOS_STORAGE_NIM_ROOT=/path/to/logos-storage-nim
cmake --build build
This produces:
libeasystorage.so— the shared librarystorageconsole— an example CLI application
API
#include "easystorage.h"
// Create and start a node
node_config cfg = {
.api_port = 8080,
.disc_port = 9090,
.data_dir = "./data",
.log_level = "INFO",
.bootstrap_node = "<SPR>"
};
STORAGE_NODE node = e_storage_new(cfg);
e_storage_start(node);
// Upload a file
char *cid = e_storage_upload(node, "/path/to/file.txt", progress_cb);
// Download a file
e_storage_download(node, cid, "/path/to/output.txt", progress_cb);
free(cid);
// Cleanup
e_storage_stop(node);
e_storage_destroy(node);
Example: storageconsole
An interactive CLI is included in examples/storageconsole.c:
./build/storageconsole
Commands: help, start, stop, upload, download, quit.
Testing
cmake --build build
./build/test_runner
Project Structure
easystorage/
├── easystorage.h # Public API
├── easystorage.c # Implementation
├── examples/
│ └── storageconsole.c # CLI example
├── tests/
│ ├── test_runner.c
│ └── mock_libstorage.c
└── CMakeLists.txt
License
Dual-licensed under Apache 2.0 and MIT.