2025-11-13 11:34:09 +04:00
|
|
|
/**
|
2025-12-18 18:23:09 +01:00
|
|
|
* libstorage.h - C Interface for Example Library
|
2025-11-13 11:34:09 +04:00
|
|
|
*
|
2025-12-18 18:23:09 +01:00
|
|
|
* This header provides the public API for libstorage
|
2025-11-13 11:34:09 +04:00
|
|
|
*
|
2025-12-18 18:23:09 +01:00
|
|
|
* To see the auto-generated header by Nim, run `make libstorage` from the
|
2025-11-13 11:34:09 +04:00
|
|
|
* repository root. The generated file will be created at:
|
2025-12-18 18:23:09 +01:00
|
|
|
* nimcache/release/libstorage/libstorage.h
|
2025-11-13 11:34:09 +04:00
|
|
|
*/
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
#ifndef __libstorage__
|
|
|
|
|
#define __libstorage__
|
2025-11-13 11:34:09 +04:00
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
// The possible returned values for the functions that return int
|
|
|
|
|
#define RET_OK 0
|
|
|
|
|
#define RET_ERR 1
|
|
|
|
|
#define RET_MISSING_CALLBACK 2
|
|
|
|
|
#define RET_PROGRESS 3
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
typedef void (*StorageCallback) (int callerRet, const char* msg, size_t len, void* userData);
|
2025-11-13 11:34:09 +04:00
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
void* storage_new(
|
2025-11-13 11:34:09 +04:00
|
|
|
const char* configJson,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_version(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_revision(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_repo(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_debug(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_spr(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_peer_id(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_log_level(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* logLevel,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_connect(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* peerId,
|
|
|
|
|
const char** peerAddresses,
|
|
|
|
|
size_t peerAddressesSize,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_peer_debug(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* peerId,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_upload_init(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* filepath,
|
|
|
|
|
size_t chunkSize,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_upload_chunk(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* sessionId,
|
|
|
|
|
const uint8_t* chunk,
|
|
|
|
|
size_t len,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_upload_finalize(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* sessionId,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_upload_cancel(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* sessionId,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_upload_file(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* sessionId,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_download_stream(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
|
|
|
|
size_t chunkSize,
|
|
|
|
|
bool local,
|
|
|
|
|
const char* filepath,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_download_init(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
|
|
|
|
size_t chunkSize,
|
|
|
|
|
bool local,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_download_chunk(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_download_cancel(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_download_manifest(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_list(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_space(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_delete(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_fetch(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_exists(
|
2025-11-13 11:34:09 +04:00
|
|
|
void* ctx,
|
|
|
|
|
const char* cid,
|
2025-12-18 18:23:09 +01:00
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_start(void* ctx,
|
|
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_stop(void* ctx,
|
|
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
int storage_close(void* ctx,
|
|
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
// Destroys an instance of a Logos Storage node created with storage_new
|
|
|
|
|
int storage_destroy(void* ctx,
|
|
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
void storage_set_event_callback(void* ctx,
|
|
|
|
|
StorageCallback callback,
|
2025-11-13 11:34:09 +04:00
|
|
|
void* userData);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-12-18 18:23:09 +01:00
|
|
|
#endif /* __libstorage__ */
|