gmega d8cc33e2bf
Reorganize as easystorage library with storageconsole example
- Rename easylibstorage to easystorage
- Build libeasystorage.so as shared library
- Move main.c to examples/storageconsole.c
- Update README to focus on library usage

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-30 12:48:51 -03:00
2026-01-30 10:30:16 -03:00
2026-01-30 10:30:16 -03:00
2026-01-30 10:30:16 -03:00

easystorage

A simplified C wrapper around libstorage, providing an easy-to-use API for distributed file storage operations.

Features

  • Simple node lifecycle management (create, start, stop, destroy)
  • File upload with progress callback
  • File download by CID with progress callback

Prerequisites

Building

cmake -B build -DLOGOS_STORAGE_NIM_ROOT=/path/to/logos-storage-nim
cmake --build build

This produces:

  • libeasystorage.so — the shared library
  • storageconsole — 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);
free(cid);

// Download a file
e_storage_download(node, cid, "/path/to/output.txt", progress_cb);

// 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.

Description
Example app and wrapper on top of libstorage.
Readme
Languages
C 84.1%
CMake 8.7%
Shell 7.2%