new: implement database keeps and files functions
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
#include "package.h"
|
||||
#include <sqlite3.h>
|
||||
|
||||
#define HASH_LEN 32
|
||||
|
||||
typedef enum lm_query_index {
|
||||
QUERY_CREATE_TABLE = 0,
|
||||
QUERY_INSERT_PACKAGE = 1,
|
||||
@ -12,8 +14,8 @@ typedef enum lm_query_index {
|
||||
extern char *queries[];
|
||||
|
||||
typedef struct lm_database {
|
||||
char *dir;
|
||||
lm_pkg_t *pkg;
|
||||
char *path;
|
||||
sqlite3 *sql;
|
||||
} lm_database_t;
|
||||
|
||||
@ -27,12 +29,13 @@ bool lm_database_find(lm_database_t *db, lm_pkg_t *pkg, char *name);
|
||||
bool lm_database_add(lm_database_t *db, lm_pkg_t *pkg);
|
||||
bool lm_database_del(lm_database_t *db, lm_pkg_t *pkg);
|
||||
|
||||
bool lm_database_files_foreach(lm_database_t *db, lm_pkg_t *pkg, lm_database_files_eachfunc_t func);
|
||||
bool lm_database_files_foreach(lm_database_t *db, lm_pkg_t *pkg, lm_database_files_eachfunc_t func, void *data);
|
||||
bool lm_database_files_matches(lm_database_t *db, lm_pkg_t *pkg, char *path, char *hash);
|
||||
bool lm_database_files_add(lm_database_t *db, lm_pkg_t *pkg, char *path, char *hash);
|
||||
bool lm_database_files_get(lm_database_t *db, lm_pkg_t *pkg, char *path, char *hash);
|
||||
bool lm_database_files_del(lm_database_t *db, lm_pkg_t *pkg);
|
||||
|
||||
bool lm_database_keeps_foreach(lm_database_t *db, lm_pkg_t *pkg, lm_database_keeps_eachfunc_t func);
|
||||
bool lm_database_keeps_contains(lm_database_t *db, lm_pkg_t *pkg, char *path);
|
||||
bool lm_database_keeps_add(lm_database_t *db, lm_pkg_t *pkg, char *path);
|
||||
bool lm_database_keeps_foreach(lm_database_t *db, lm_pkg_t *pkg, lm_database_keeps_eachfunc_t func, void *data);
|
||||
bool lm_database_keeps_load(lm_database_t *db, lm_pkg_t *pkg);
|
||||
bool lm_database_keeps_save(lm_database_t *db, lm_pkg_t *pkg);
|
||||
bool lm_database_keeps_del(lm_database_t *db, lm_pkg_t *pkg);
|
||||
|
@ -81,6 +81,16 @@ typedef enum lm_error {
|
||||
LM_ERR_PoolUrlEmpty = 76,
|
||||
LM_ERR_PoolBadDir = 77,
|
||||
LM_ERR_PoolBadPaths = 78,
|
||||
LM_ERR_DbFilesNotFound = 79,
|
||||
LM_ERR_DbFilesOpenFail = 80,
|
||||
LM_ERR_DbFilesDirFail = 81,
|
||||
LM_ERR_DbFilesUnlinkFail = 82,
|
||||
LM_ERR_DbFilesWriteFail = 83,
|
||||
LM_ERR_DbKeepsNotFound = 84,
|
||||
LM_ERR_DbKeepsOpenFail = 85,
|
||||
LM_ERR_DbKeepsDirFail = 86,
|
||||
LM_ERR_DbKeepsUnlinkFail = 87,
|
||||
LM_ERR_DbSqlNotFound = 88,
|
||||
} lm_error_t;
|
||||
|
||||
typedef struct lm_error_desc {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define PKG_DATA_DESC "desc"
|
||||
#define PKG_DATA_VERSION "version"
|
||||
#define PKG_DATA_DEPENDS "depends"
|
||||
#define PKG_DATA_KEEPS "keeps"
|
||||
|
||||
lm_pkg_t *lm_package_new();
|
||||
void lm_package_free(lm_pkg_t *pkg);
|
||||
@ -25,6 +26,7 @@ void lm_package_depend_free(lm_pkg_t *pkg);
|
||||
size_t lm_package_keep_count(lm_pkg_t *pkg);
|
||||
bool lm_package_keep_add(lm_pkg_t *pkg, char *path);
|
||||
bool lm_package_keep_contains(lm_pkg_t *pkg, char *path);
|
||||
void lm_package_keep_free(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);
|
||||
|
Reference in New Issue
Block a user