2024-06-20 00:34:32 +00:00
|
|
|
#pragma once
|
2024-07-02 01:44:07 +00:00
|
|
|
#include "database.h"
|
2024-06-20 00:34:32 +00:00
|
|
|
#include "types.h"
|
2024-06-27 20:05:39 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2024-07-04 00:12:33 +00:00
|
|
|
typedef struct lm_ctx {
|
|
|
|
lm_pool_t *pools; // pool list
|
|
|
|
char *root; // root path for package installtion
|
|
|
|
char *temp; // temp path
|
|
|
|
char *data; // package database path
|
|
|
|
const char *version; // libmp version (read-only)
|
|
|
|
} lm_ctx_t;
|
|
|
|
|
2024-07-02 01:44:07 +00:00
|
|
|
typedef bool (*lm_ctx_pool_callback_t)(lm_ctx_t *ctx, lm_pool_t *pool, bool status, void *data);
|
2024-07-04 00:12:33 +00:00
|
|
|
typedef bool (*lm_ctx_database_callback_t)(lm_ctx_t *ctx, lm_pkg_t *pkg, void *data);
|
2024-06-20 00:34:32 +00:00
|
|
|
|
|
|
|
void lm_ctx_init(lm_ctx_t *ctx);
|
2024-06-27 20:05:39 +00:00
|
|
|
bool lm_ctx_set_data(lm_ctx_t *ctx, char *dir);
|
|
|
|
bool lm_ctx_set_root(lm_ctx_t *ctx, char *dir);
|
|
|
|
bool lm_ctx_set_temp(lm_ctx_t *ctx, char *dir);
|
2024-06-20 00:34:32 +00:00
|
|
|
void lm_ctx_free(lm_ctx_t *ctx);
|
2024-06-22 22:55:01 +00:00
|
|
|
|
2024-07-04 00:12:33 +00:00
|
|
|
lm_pkg_t *lm_ctx_find(lm_ctx_t *ctx, char *name, char *version);
|
|
|
|
bool lm_ctx_install(lm_ctx_t *ctx, char *package);
|
|
|
|
bool lm_ctx_remove(lm_ctx_t *ctx, char *package);
|
|
|
|
bool lm_ctx_verify(lm_ctx_t *ctx, char *package);
|
|
|
|
bool lm_ctx_update(lm_ctx_t *ctx);
|
|
|
|
|
2024-07-01 03:43:20 +00:00
|
|
|
lm_pool_t *lm_ctx_pool_add(lm_ctx_t *ctx, char *name, char *url);
|
|
|
|
bool lm_ctx_pool_del(lm_ctx_t *ctx, char *name);
|
|
|
|
void lm_ctx_pool_clear(lm_ctx_t *ctx);
|
|
|
|
bool lm_ctx_pool_serve(lm_ctx_t *ctx, char *addr, uint8_t threads);
|
|
|
|
void lm_ctx_pool_test(lm_ctx_t *ctx, lm_ctx_pool_callback_t callback, void *data);
|
|
|
|
void lm_ctx_pool_get_info(
|
|
|
|
lm_ctx_t *ctx, bool allow_update, bool force_update, lm_ctx_pool_callback_t callback, void *data);
|
|
|
|
void lm_ctx_pool_get_list(
|
|
|
|
lm_ctx_t *ctx, bool allow_update, bool force_update, lm_ctx_pool_callback_t callback, void *data);
|
|
|
|
|
2024-07-04 00:12:33 +00:00
|
|
|
bool lm_ctx_package_install(lm_ctx_t *ctx, lm_pkg_t *pkg);
|
|
|
|
bool lm_ctx_package_remove(lm_ctx_t *ctx, lm_pkg_t *pkg);
|
|
|
|
bool lm_ctx_package_verify(lm_ctx_t *ctx, lm_pkg_t *pkg);
|
2024-07-02 01:44:07 +00:00
|
|
|
|
|
|
|
lm_database_t *lm_ctx_database_new(lm_ctx_t *ctx);
|
2024-07-04 00:12:33 +00:00
|
|
|
bool lm_ctx_database_is_installed(lm_ctx_t *ctx, lm_pkg_t *pkg, bool check_version);
|
|
|
|
bool lm_ctx_database_find(lm_ctx_t *ctx, lm_pkg_t *pkg, char *name);
|
|
|
|
bool lm_ctx_database_foreach(lm_ctx_t *ctx, lm_ctx_database_callback_t callback, void *data);
|