new: implement check and update functions
This commit is contained in:
@ -21,9 +21,9 @@ typedef struct lm_ctx_resolve_list {
|
||||
} lm_ctx_resolve_list_t;
|
||||
|
||||
typedef struct lm_ctx_update_list {
|
||||
lm_pkg_t **packages;
|
||||
size_t count;
|
||||
size_t index;
|
||||
lm_pkg_t *packages;
|
||||
lm_pkg_t *cur;
|
||||
size_t count;
|
||||
} lm_ctx_update_list_t;
|
||||
|
||||
typedef enum lm_ctx_sync_state {
|
||||
@ -35,6 +35,11 @@ typedef enum lm_ctx_sync_state {
|
||||
SYNC_LIST_FAIL = 5,
|
||||
} lm_ctx_sync_state_t;
|
||||
|
||||
typedef enum lm_ctx_update_state {
|
||||
UPDATE_REMOVE = 0,
|
||||
UPDATE_INSTALL = 1,
|
||||
} lm_ctx_update_state_t;
|
||||
|
||||
/* ###################
|
||||
## ctx callbacks ##
|
||||
################### */
|
||||
@ -43,6 +48,8 @@ typedef bool (*lm_ctx_download_callback_t)(
|
||||
lm_ctx_t *ctx, lm_pkg_t *pkg, bool is_archive, size_t current, size_t total, void *data);
|
||||
typedef bool (*lm_ctx_install_callback_t)(
|
||||
lm_ctx_t *ctx, lm_pkg_t *pkg, char *file, size_t current, size_t total, void *data);
|
||||
typedef bool (*lm_ctx_update_callback_t)(
|
||||
lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_update_state_t state, char *file, size_t current, size_t total, void *data);
|
||||
typedef bool (*lm_ctx_sync_callback_t)(
|
||||
lm_ctx_t *ctx, lm_pool_t *pool, lm_ctx_sync_state_t state, size_t current, size_t total, void *data);
|
||||
typedef bool (*lm_ctx_ping_callback_t)(lm_ctx_t *ctx, lm_pool_t *pool, bool status, void *data);
|
||||
@ -66,9 +73,11 @@ lm_ctx_resolve_list_t *lm_ctx_resolve(
|
||||
lm_pkg_t *lm_ctx_resolve_next(lm_ctx_resolve_list_t *list); // returns the next package in the list
|
||||
void lm_ctx_resolve_free(lm_ctx_resolve_list_t *list); // frees the resolved list returned by lm_ctx_resolve
|
||||
|
||||
lm_ctx_update_list_t *lm_ctx_update(lm_ctx_t *ctx); // returns a list of packages to update
|
||||
lm_pkg_t *lm_ctx_update_next(lm_ctx_update_list_t *list); // returns the next package in the list
|
||||
void lm_ctx_update_free(lm_ctx_update_list_t *list); // frees the update list returned by lm_ctx_update
|
||||
lm_ctx_update_list_t *lm_ctx_update_list(lm_ctx_t *ctx); // get a list of packages to update
|
||||
lm_pkg_t *lm_ctx_update_list_next(lm_ctx_update_list_t *list); // get the next package in the update list
|
||||
void lm_ctx_update_list_free(lm_ctx_update_list_t *list); // free the update list
|
||||
bool lm_ctx_update(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_update_callback_t callback,
|
||||
void *data); // returns a list of packages to update
|
||||
|
||||
bool lm_ctx_download(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_download_callback_t callback,
|
||||
void *data); // downloads a single package
|
||||
@ -98,5 +107,5 @@ lm_pool_t *lm_ctx_pool_by_url(lm_ctx_t *ctx, char *host, char *path); // find p
|
||||
bool lm_ctx_database_init(lm_ctx_t *ctx); // init ctx database (if not already present)
|
||||
bool lm_ctx_database_is_installed(lm_ctx_t *ctx, lm_pkg_t *pkg, bool check_version); // check if a package is installed
|
||||
bool lm_ctx_database_find(lm_ctx_t *ctx, lm_pkg_t *pkg, char *name, char *version); // find a package by name
|
||||
bool lm_ctx_database_foreach(
|
||||
lm_ctx_t *ctx, lm_ctx_database_callback_t callback, void *data); // loop for each package in the database
|
||||
bool lm_ctx_database_next(lm_ctx_t *ctx, lm_pkg_t *pkg); // load the next package into pkg pointer
|
||||
bool lm_ctx_database_next_free(lm_ctx_t *ctx, lm_pkg_t *pkg); // free the used next pointers
|
||||
|
@ -133,6 +133,11 @@ typedef enum lm_error {
|
||||
LM_ERR_InstallStatusFail = 125,
|
||||
LM_ERR_InstallScriptFail = 126,
|
||||
LM_ERR_PkgBreaks = 127,
|
||||
LM_ERR_PkgUpToDate = 128,
|
||||
LM_ERR_HashOpenFail = 129,
|
||||
LM_ERR_HashDigestFail = 130,
|
||||
LM_ERR_FileHashFail = 131,
|
||||
LM_ERR_FileHashNoMatch = 132,
|
||||
} lm_error_t;
|
||||
|
||||
typedef struct lm_error_desc {
|
||||
|
@ -12,6 +12,7 @@ lm_pkg_t *lm_package_new();
|
||||
void lm_package_free(lm_pkg_t *pkg);
|
||||
bool lm_package_verify(lm_pkg_t *pkg);
|
||||
void lm_package_init(lm_pkg_t *pkg);
|
||||
bool lm_package_copy(lm_pkg_t *dst, lm_pkg_t *src);
|
||||
|
||||
bool lm_package_data_load(lm_pkg_t *pkg, char *file);
|
||||
void lm_package_data_free(lm_pkg_t *pkg);
|
||||
@ -34,4 +35,5 @@ 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);
|
||||
bool lm_package_path_copy(lm_pkg_t *dst, lm_pkg_t *src);
|
||||
bool lm_package_is_same(lm_pkg_t *one, lm_pkg_t *two);
|
||||
|
@ -16,12 +16,13 @@ bool is_digit(char c);
|
||||
bool copy_from_buffer(void *dst, void *buffer, size_t size, ssize_t *total, ssize_t *used);
|
||||
bool copy_to_buffer(void *buffer, void *src, size_t size, ssize_t *total, ssize_t *used);
|
||||
|
||||
bool copy_file(char *dst, char *src);
|
||||
bool can_write(char *path);
|
||||
bool can_read(char *path);
|
||||
bool is_file(char *path);
|
||||
bool is_dir(char *path);
|
||||
bool exists(char *path);
|
||||
char *get_md5(char *path);
|
||||
bool copy_file(char *dst, char *src);
|
||||
bool can_write(char *path);
|
||||
bool can_read(char *path);
|
||||
bool is_file(char *path);
|
||||
bool is_dir(char *path);
|
||||
bool exists(char *path);
|
||||
|
||||
bool package_parse(char *package, char *name, char *version);
|
||||
bool package_version_valid(char *name);
|
||||
|
Reference in New Issue
Block a user