new: implement PULL command, add join functions
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
#include "types.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef void (*lm_ctx_pools_callback_t)(lm_ctx_t *ctx, lm_pool_t *pool, bool status, void *data);
|
||||
typedef void (*lm_ctx_pool_callback_t)(lm_ctx_t *ctx, lm_pool_t *pool, bool status, void *data);
|
||||
|
||||
void lm_ctx_init(lm_ctx_t *ctx);
|
||||
bool lm_ctx_set_data(lm_ctx_t *ctx, char *dir);
|
||||
@ -10,10 +10,15 @@ bool lm_ctx_set_root(lm_ctx_t *ctx, char *dir);
|
||||
bool lm_ctx_set_temp(lm_ctx_t *ctx, char *dir);
|
||||
void lm_ctx_free(lm_ctx_t *ctx);
|
||||
|
||||
lm_pool_t *lm_ctx_pools_add(lm_ctx_t *ctx, char *name, char *url);
|
||||
bool lm_ctx_pools_del(lm_ctx_t *ctx, char *name);
|
||||
void lm_ctx_pools_clear(lm_ctx_t *ctx);
|
||||
bool lm_ctx_pools_serve(lm_ctx_t *ctx, char *addr, uint8_t threads);
|
||||
void lm_ctx_pools_test(lm_ctx_t *ctx, lm_ctx_pools_callback_t callback, void *data);
|
||||
void lm_ctx_pools_get_info(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data);
|
||||
void lm_ctx_pools_get_list(lm_ctx_t *ctx, bool force_update, lm_ctx_pools_callback_t callback, void *data);
|
||||
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);
|
||||
|
||||
lm_pkg_t *lm_ctx_package_install(lm_ctx_t *ctx, char *name, char *version);
|
||||
lm_pkg_t *lm_ctx_package_get(lm_ctx_t *ctx, char *name, char *version);
|
||||
|
@ -59,6 +59,13 @@ typedef enum lm_error {
|
||||
LM_ERR_CtxDataFailMkdir = 54,
|
||||
LM_ERR_ArcRealpathFail = 55,
|
||||
LM_ERR_PoolTestNotPong = 56,
|
||||
LM_ERR_PackagePathsEmpty = 57,
|
||||
LM_ERR_SendOpenFail = 58,
|
||||
LM_ERR_RecvDelFail = 59,
|
||||
LM_ERR_RecvOpenFail = 60,
|
||||
LM_ERR_RecvBadCode = 61,
|
||||
LM_ERR_RecvWriteFail = 62,
|
||||
LM_ERR_PkgNotFound = 63
|
||||
} lm_error_t;
|
||||
|
||||
typedef struct lm_error_desc {
|
||||
|
22
include/package.h
Normal file
22
include/package.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PKG_DATA_SIZE "size"
|
||||
#define PKG_DATA_DESC "desc"
|
||||
#define PKG_DATA_VERSION "version"
|
||||
#define PKG_DATA_DEPENDS "depends"
|
||||
|
||||
lm_pkg_t *lm_package_new();
|
||||
void lm_package_free(lm_pkg_t *pkg);
|
||||
|
||||
bool lm_package_data_load(lm_pkg_t *pkg, char *file);
|
||||
void lm_package_data_free(lm_pkg_t *pkg);
|
||||
|
||||
bool lm_package_depend_add(lm_pkg_t *pkg, char *depend);
|
||||
size_t lm_package_depend_count(lm_pkg_t *pkg);
|
||||
|
||||
bool lm_package_path_set_signature(lm_pkg_t *pkg, char *signature_path);
|
||||
bool lm_package_path_set_archive(lm_pkg_t *pkg, char *archive_path);
|
||||
bool lm_package_path_is_empty(lm_pkg_t *pkg);
|
||||
void lm_package_path_free(lm_pkg_t *pkg);
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PKG_DATA_SIZE "size"
|
||||
#define PKG_DATA_DESC "desc"
|
||||
#define PKG_DATA_VERSION "version"
|
||||
#define PKG_DATA_DEPENDS "depends"
|
||||
|
||||
lm_pkg_t *lm_pkg_new();
|
||||
void lm_pkg_free(lm_pkg_t *pkg);
|
||||
|
||||
bool lm_pkg_data_load(lm_pkg_t *pkg, char *file);
|
||||
void lm_pkg_data_free(lm_pkg_t *pkg);
|
@ -19,12 +19,16 @@ typedef struct lm_pool_thread_arg {
|
||||
lm_pool_t *lm_pool_new(char *name, char *url);
|
||||
void lm_pool_test(lm_pool_t *pool);
|
||||
void lm_pool_free(lm_pool_t *pool);
|
||||
bool lm_pool_add(lm_pool_t *pool, lm_pkg_t *pkg);
|
||||
|
||||
void lm_pool_paths_set_info(lm_pool_t *pool, char *info_path);
|
||||
void lm_pool_paths_set_list(lm_pool_t *pool, char *list_path);
|
||||
bool lm_pool_paths_is_empty(lm_pool_t *pool);
|
||||
void lm_pool_paths_free(lm_pool_t *pool);
|
||||
lm_pkg_t *lm_pool_package_find(lm_pool_t *pool, char *name, char *version);
|
||||
bool lm_pool_package_add(lm_pool_t *pool, lm_pkg_t *pkg);
|
||||
bool lm_pool_package_get(lm_pool_t *pool, lm_pkg_t *pkg);
|
||||
|
||||
bool lm_pool_path_set_info(lm_pool_t *pool, char *info_path);
|
||||
bool lm_pool_path_set_list(lm_pool_t *pool, char *list_path);
|
||||
bool lm_pool_path_set_packages(lm_pool_t *pool, char *packaes_path);
|
||||
bool lm_pool_path_is_empty(lm_pool_t *pool);
|
||||
void lm_pool_path_free(lm_pool_t *pool);
|
||||
|
||||
bool lm_pool_info_load(lm_pool_t *pool);
|
||||
bool lm_pool_info_get(lm_pool_t *pool);
|
||||
|
@ -1,32 +1,41 @@
|
||||
#pragma once
|
||||
#include "url.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct lm_pkg_path {
|
||||
char *archive;
|
||||
char *signature;
|
||||
} lm_pkg_path_t;
|
||||
|
||||
typedef struct lm_pkg {
|
||||
size_t size;
|
||||
struct lm_pkg *next;
|
||||
lm_pkg_path_t paths;
|
||||
char *name;
|
||||
char *desc;
|
||||
char **depends;
|
||||
char *version;
|
||||
size_t size;
|
||||
} lm_pkg_t;
|
||||
|
||||
typedef struct lm_pool_info {
|
||||
char *maintainer;
|
||||
char *pubkey;
|
||||
size_t size;
|
||||
char *maintainer;
|
||||
char *pubkey;
|
||||
ssize_t size;
|
||||
} lm_pool_info_t;
|
||||
|
||||
typedef struct lm_pool_paths {
|
||||
typedef struct lm_pool_path {
|
||||
char *packages;
|
||||
char *list;
|
||||
char *info;
|
||||
} lm_pool_paths_t;
|
||||
} lm_pool_path_t;
|
||||
|
||||
typedef struct lm_pool {
|
||||
struct lm_pool *next;
|
||||
lm_pool_info_t info;
|
||||
lm_pool_paths_t paths;
|
||||
lm_pool_path_t paths;
|
||||
lm_url_t url;
|
||||
lm_pkg_t *pkg;
|
||||
bool available;
|
||||
|
@ -7,20 +7,30 @@
|
||||
|
||||
#define _(x) gettext(x)
|
||||
|
||||
void pdebug(const char *func, const char *fmt, ...);
|
||||
bool parse_host(char *addr, char *host, uint16_t *port);
|
||||
bool contains(char *str, char s);
|
||||
bool eq(char *s1, char *s2);
|
||||
bool is_letter(char c);
|
||||
bool is_digit(char c);
|
||||
bool copy_to_buffer(void *buffer, void *src, size_t size, ssize_t *total, ssize_t *used);
|
||||
|
||||
bool copy_from_buffer(void *dst, void *buffer, size_t size, ssize_t *total, ssize_t *used);
|
||||
bool extract_archive(char *dst, char *src);
|
||||
bool is_pkg_name_valid(char *name);
|
||||
bool exists(char *path);
|
||||
bool copy_to_buffer(void *buffer, void *src, size_t size, ssize_t *total, ssize_t *used);
|
||||
|
||||
bool can_write(char *path);
|
||||
bool can_read(char *path);
|
||||
bool is_file(char *path);
|
||||
bool is_dir(char *path);
|
||||
bool can_read(char *path);
|
||||
bool can_write(char *path);
|
||||
bool exists(char *path);
|
||||
|
||||
bool package_parse(char *package, char *name, char *version);
|
||||
bool package_version_valid(char *name);
|
||||
bool package_name_valid(char *name);
|
||||
|
||||
void pdebug(const char *func, const char *fmt, ...);
|
||||
bool parse_host(char *addr, char *host, uint16_t *port);
|
||||
bool extract_archive(char *dst, char *src);
|
||||
bool mkdir_ifnot(char *path);
|
||||
void sockaddr_to_str(struct sockaddr *addr, char *str);
|
||||
|
||||
int join_multiple(char *res, const char *base, const char *pth, const char *pth2);
|
||||
int join(char *res, const char *base, const char *pth);
|
||||
char *join_alloc(const char *base, const char *pth);
|
||||
|
Reference in New Issue
Block a user