new: implement check and update functions
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include "../../include/util.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -48,12 +49,39 @@ bool lm_package_remove_download(lm_pkg_t *pkg){
|
||||
}
|
||||
|
||||
bool lm_package_is_same(lm_pkg_t *one, lm_pkg_t *two){
|
||||
if(NULL == one || NULL == two){
|
||||
lm_error_set(LM_ERR_ArgNULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
return eq(one->version, two->version) &&
|
||||
eq(one->name, two->name) &&
|
||||
eq(one->desc, two->desc) &&
|
||||
one->size == two->size;
|
||||
}
|
||||
|
||||
bool lm_package_copy(lm_pkg_t *dst, lm_pkg_t *src){
|
||||
lm_package_init(dst);
|
||||
|
||||
dst->name = strdup(src->name);
|
||||
dst->version = strdup(src->version);
|
||||
dst->desc = strdup(src->desc);
|
||||
dst->size = src->size;
|
||||
dst->pool = src->pool;
|
||||
|
||||
if(NULL != src->keeps){
|
||||
for(int i = 0; src->keeps[i] != NULL; i++)
|
||||
lm_package_keep_add(dst, src->keeps[i]);
|
||||
}
|
||||
|
||||
if(NULL != src->depends){
|
||||
for(int i = 0; src->depends[i] != NULL; i++)
|
||||
lm_package_depend_add(dst, src->depends[i]);
|
||||
}
|
||||
|
||||
return lm_package_path_copy(dst, src);
|
||||
}
|
||||
|
||||
void lm_package_free(lm_pkg_t *pkg){
|
||||
lm_package_data_free(pkg);
|
||||
bzero(pkg, sizeof(lm_pkg_t));
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "../../include/package.h"
|
||||
#include "../../include/error.h"
|
||||
#include "../../include/types.h"
|
||||
#include "../../include/util.h"
|
||||
|
||||
@ -38,6 +39,17 @@ bool lm_package_path_is_empty(lm_pkg_t *pkg){
|
||||
NULL == pkg->paths.archive;
|
||||
}
|
||||
|
||||
bool lm_package_path_copy(lm_pkg_t *dst, lm_pkg_t *src){
|
||||
if(NULL == dst || NULL == src){
|
||||
lm_error_set(LM_ERR_ArgNULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
dst->paths.archive = strdup(src->paths.archive);
|
||||
dst->paths.signature = strdup(src->paths.signature);
|
||||
return true;
|
||||
}
|
||||
|
||||
void lm_package_path_free(lm_pkg_t *pkg){
|
||||
free(pkg->paths.signature);
|
||||
free(pkg->paths.archive);
|
||||
|
Reference in New Issue
Block a user