new: add remove operation
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
|
||||
#define HASH_LEN 32
|
||||
|
||||
typedef enum lm_query_index {
|
||||
enum lm_query_index {
|
||||
QUERY_CREATE_PACKAGE_TABLE = 0,
|
||||
QUERY_INSERT_PACKAGE_SINGLE = 1,
|
||||
QUERY_SELECT_PACKAGE_SINGLE = 2,
|
||||
@ -17,7 +17,20 @@ typedef enum lm_query_index {
|
||||
QUERY_SELECT_FILE_ALL = 9,
|
||||
QUERY_UPDATE_FILE_1 = 10,
|
||||
QUERY_UPDATE_FILE_2 = 11,
|
||||
} lm_query_index_t;
|
||||
};
|
||||
|
||||
enum lm_columns {
|
||||
FILES_COLUMN_PATH = 1,
|
||||
FILES_COLUMN_HASH = 2,
|
||||
FILES_COLUMN_KEEP = 3,
|
||||
FILES_COLUMN_PACKAGE = 4,
|
||||
|
||||
PACKAGES_COLUMN_NAME = 1,
|
||||
PACKAGES_COLUMN_DESC = 2,
|
||||
PACKAGES_COLUMN_VERSION = 3,
|
||||
PACKAGES_COLUMN_SIZE = 4,
|
||||
PACKAGES_COLUMN_DEPENDS = 5,
|
||||
};
|
||||
|
||||
extern char *queries[];
|
||||
|
||||
@ -34,13 +47,20 @@ typedef struct lm_database {
|
||||
|
||||
lm_database_t *lm_database_new(char *path);
|
||||
void lm_database_free(lm_database_t *db);
|
||||
bool lm_database_step_all(sqlite3_stmt *st);
|
||||
|
||||
bool lm_database_package_find(
|
||||
lm_database_t *db, lm_pkg_t *pkg, char *name); // finds a package by its name, package stored in *pkg
|
||||
bool lm_database_package_next(lm_database_t *db, lm_pkg_t *pkg); // gets the next package in the database
|
||||
bool lm_database_packege_add(lm_database_t *db, lm_pkg_t *pkg); // adds a package to the database
|
||||
bool lm_database_package_add(lm_database_t *db, lm_pkg_t *pkg); // adds a package to the database
|
||||
bool lm_database_package_del(lm_database_t *db, lm_pkg_t *pkg); // delete a package from the database
|
||||
void lm_database_package_next_free(
|
||||
lm_database_t *db, lm_pkg_t *pkg); // frees resources used for lm_database_package_next
|
||||
|
||||
size_t lm_database_files_count(
|
||||
lm_database_t *db, lm_pkg_t *pkg); // returns the count of files associated with a package
|
||||
bool lm_database_files_contains(
|
||||
lm_database_t *db, lm_pkg_t *pkg, char *path); // check if a package contains the given file
|
||||
bool lm_database_files_matches(
|
||||
lm_database_t *db, char *path, char *hash); // checks if the given file matches with the given hash
|
||||
bool lm_database_files_iskeep(lm_database_t *db, char *path); // checks if the given file is marked as keep
|
||||
@ -49,6 +69,8 @@ bool lm_database_files_next(
|
||||
bool lm_database_files_add(
|
||||
lm_database_t *db, lm_pkg_t *pkg, char *path, char *hash); // adds a file to the files database
|
||||
bool lm_database_files_del(lm_database_t *db, lm_pkg_t *pkg); // dels all files of belonging to a package
|
||||
void lm_database_files_next_free(lm_database_t *db, lm_pkg_t *pkg, char **path, char **hash,
|
||||
bool *keep); // frees resources used for lm_database_files_next
|
||||
|
||||
bool lm_database_changes_update(lm_database_t *db, lm_pkg_t *pkg, char *file);
|
||||
char *lm_database_changes_get(lm_database_t *db, lm_pkg_t *pkg);
|
||||
|
@ -1,7 +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,
|
||||
@ -117,7 +116,16 @@ typedef enum lm_error {
|
||||
LM_ERR_RecvNotCompleted = 109,
|
||||
LM_ERR_DbSqlSelectFail = 110,
|
||||
LM_ERR_DbSqlDeleteFail = 111,
|
||||
|
||||
LM_ERR_ExtractStatFail = 112,
|
||||
LM_ERR_PkgFilesAddFail = 113,
|
||||
LM_ERR_PkgExtractFilesFail = 114,
|
||||
LM_ERR_PkgDatabaseAddFail = 115,
|
||||
LM_ERR_PkgAlreadyInstalled = 116,
|
||||
LM_ERR_PkgNotInstalled = 117,
|
||||
LM_ERR_PkgFileUnlinkFail = 118,
|
||||
LM_ERR_PkgDatabaseDelFail = 119,
|
||||
LM_ERR_PkgFilesDelFail = 119,
|
||||
LM_ERR_PkgChangesDelFail = 120,
|
||||
} lm_error_t;
|
||||
|
||||
typedef struct lm_error_desc {
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include <archive.h>
|
||||
#include <libintl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdbool.h>
|
||||
@ -28,6 +29,7 @@ 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 copy_blocks(struct archive *w, struct archive *r);
|
||||
bool extract_archive(char *dst, char *src);
|
||||
bool mkdir_ifnot(char *path);
|
||||
void sockaddr_to_str(struct sockaddr *addr, char *str);
|
||||
|
Reference in New Issue
Block a user