new: custom pool dirs and remove ctx path functions

This commit is contained in:
ngn
2024-08-03 22:23:32 +03:00
parent 960596ae3a
commit 7c3d0dc1f8
35 changed files with 346 additions and 356 deletions

View File

@ -27,4 +27,3 @@
#include "ctx.h"
#include "error.h"
#include "pool.h"
#include "util.h"

View File

@ -54,10 +54,7 @@ typedef lm_ctx_remove_callback_t lm_ctx_check_callback_t;
/* ###############
## ctx stuff ##
############### */
void lm_ctx_init(lm_ctx_t *ctx);
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);
bool lm_ctx_init(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir);
void lm_ctx_free(lm_ctx_t *ctx);
/* ####################
@ -87,16 +84,22 @@ size_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callbac
void lm_ctx_ping(lm_ctx_t *ctx, lm_ctx_ping_callback_t callback, void *data); // pings all the pools
bool lm_ctx_serve(
lm_ctx_t *ctx, char *addr, uint8_t threads, lm_ctx_serve_callback_t callback, void *data); // serves all the pools
//
/* ##############################
## temp directory fucntions ##
############################## */
char *lm_ctx_temp_dir(lm_ctx_t *ctx, char *dir);
void lm_ctx_temp_clear(lm_ctx_t *ctx);
/* ####################
## pool fucntions ##
#################### */
lm_pkg_t *lm_ctx_pool_find(lm_ctx_t *ctx, char *name, char *version); // find a package in ctx pool list
lm_pool_t *lm_ctx_pool_add(lm_ctx_t *ctx, char *name, char *url); // add a pool to the ctx pool list
bool lm_ctx_pool_del(lm_ctx_t *ctx, char *name); // remove a pool from the ctx pool list
void lm_ctx_pool_clear(lm_ctx_t *ctx); // clear all the pools in the ctx pool list
lm_pool_t *lm_ctx_pool_by_name(lm_ctx_t *ctx, char *name); // find pool by name
lm_pool_t *lm_ctx_pool_by_url(lm_ctx_t *ctx, char *host, char *path); // find pool by URL
lm_pkg_t *lm_ctx_pool_find(lm_ctx_t *ctx, char *name, char *version); // find a package in ctx pool list
lm_pool_t *lm_ctx_pool_add(lm_ctx_t *ctx, char *name, char *url, char *dir); // add a pool to the ctx pool list
bool lm_ctx_pool_del(lm_ctx_t *ctx, char *name); // remove a pool from the ctx pool list
void lm_ctx_pool_clear(lm_ctx_t *ctx); // clear all the pools in the ctx pool list
lm_pool_t *lm_ctx_pool_by_name(lm_ctx_t *ctx, char *name); // find pool by name
lm_pool_t *lm_ctx_pool_by_url(lm_ctx_t *ctx, char *host, char *path); // find pool by URL
/* ########################
## database fucntions ##

View File

@ -1,6 +1,6 @@
#pragma once
#define lm_strerror_dup() {strdup(lm_strerror())}
#define lm_strerror_dup() strdup(lm_strerror())
typedef enum lm_error {
LM_ERR_NoError = 0,
@ -51,14 +51,8 @@ typedef enum lm_error {
LM_ERR_PkgDataBad = 44,
LM_ERR_CtxDataNULL = 45,
LM_ERR_CtxTempFail = 46,
LM_ERR_CtxTempNotDir = 47,
LM_ERR_CtxTempNoWrite = 48,
LM_ERR_CtxRootFail = 49,
LM_ERR_CtxRootNotDir = 50,
LM_ERR_CtxRootNoWrite = 51,
LM_ERR_CtxDataNotDir = 52,
LM_ERR_CtxDataNoWrite = 53,
LM_ERR_CtxDataFailMkdir = 54,
LM_ERR_CtxDataFail = 54,
LM_ERR_ArcRealpathFail = 55,
LM_ERR_PoolTestNotPong = 56,
LM_ERR_PkgPathsEmpty = 57,
@ -144,6 +138,10 @@ typedef enum lm_error {
LM_ERR_DbChangesChmodFail = 136,
LM_ERR_InstallDirFail = 137,
LM_ERR_InstallSaveFail = 138,
LM_ERR_FailMkdir = 139,
LM_ERR_NotDir = 140,
LM_ERR_NoWrite = 141,
LM_ERR_PoolListBadDir = 142,
} lm_error_t;
typedef struct lm_error_desc {

View File

@ -20,7 +20,6 @@ typedef struct lm_pool {
char *name;
char *info_file;
char *list_file;
char *list_dir;
char *dir;
bool available, loaded;
} lm_pool_t;
@ -43,6 +42,6 @@ bool lm_pool_info_download(lm_pool_t *pool, lm_mptp_transfer_callback_t callback
bool lm_pool_info_load(lm_pool_t *pool);
void lm_pool_info_free(lm_pool_t *pool);
bool lm_pool_list_download(lm_pool_t *pool, lm_mptp_transfer_callback_t callback, void *data);
bool lm_pool_list_load(lm_pool_t *pool);
bool lm_pool_list_download(lm_pool_t *pool, char *dir, lm_mptp_transfer_callback_t callback, void *data);
bool lm_pool_list_load(lm_pool_t *pool, char *dir);
void lm_pool_list_free(lm_pool_t *pool);

View File

@ -25,6 +25,8 @@ bool is_file(char *path);
bool is_dir(char *path);
bool exists(char *path);
bool is_empty(char *p);
bool is_dir_empty(char *p);
bool rmrf(char *p);
bool package_parse(char *package, char *name, char *version);
bool package_version_valid(char *name);