X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm.h;h=9be5f60aaffbf17c1e334b11a2896db6107417d6;hb=08117db1ca1b5789ce4b27025e133eb4bc56f397;hp=43d394cdc11affde6911744a54a410bf6106415c;hpb=9dcf3393d1ee93a26ceeccc8a62ffde8e736a51f;p=zpackage diff --git a/zpm.h b/zpm.h index 43d394c..9be5f60 100644 --- a/zpm.h +++ b/zpm.h @@ -5,8 +5,11 @@ #include #include #include +#include +#include #include +#include #define ZPM_HASH_STRLEN 64 @@ -16,6 +19,8 @@ #define ZPM_PATH_MAX 256 #endif +#define ZPM_LOCAL_DB "/var/lib/zpm/local.db" + #define ZPM_PACKAGE_NAME_MAX 191 #define ZPM_PACKAGE_VERSION_MAX 58 #define ZPM_PACKAGE_RELEASE_MAX 4 @@ -29,6 +34,10 @@ struct zpm { sqlite3 *db; char *path; /* path to db file */ int error; + int dbresult; + char *dberrmsg; + char *errmsg; + char *pkgid; struct zpm_package *current_package; }; @@ -45,26 +54,39 @@ struct zpm_tag { struct zpm_package { struct zpm *zpm; + struct jsw_hash_t *ht; + + /* char pointers are just pointers into the hash table */ + /* integers/times and such are passed through atoi */ + /* tags and licenses are trees, NULL if not fetched */ char *name; char *version; int release; char *id; - char *tags; + /* null if tags not collected */ + //struct zpm_tree *tags; char *description; char *architecture; char *url; - char *status; - char *licenses; - char *package; + char *status; /* integer code ? */ + //struct zpm_tree *licenses; time_t build_time; time_t install_time; char checksum[ZPM_HASH_STRLEN+1]; + struct zpm_package *next; }; +int zpm_parse_package(char *pstr, char *name, char *ver, int *rel); +char *zpm_findpkg(struct zpm *zpm, char *pkgstr, char *where); +int zpm_findhash(struct zpm *zpm, char *find, char *dest); +char *zpm_findlib(struct zpm *zpm, char *soname, char *where); +int zpm_libraries_needed(struct zpm *zpm, char *pkgid, jsw_atree_t *list); +int zpm_quote(char *value, char *dest, size_t n); + struct zpm_file { char path[ZPM_PATH_MAX]; int mode; - char tags[64]; + //struct zpm_tree *tags; char owner[32]; char group[32]; time_t mtime; @@ -72,9 +94,8 @@ struct zpm_file { struct zpm_file *next; /* so you can make a linked list */ }; - -/* NULL? Create? */ int zpm_open(struct zpm *pkg, char *path); +int zpm_init(struct zpm *pkg, char *path); int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */ /* flags for preserving mode, owner, etc */ @@ -98,7 +119,7 @@ int zpm_tag(struct zpm *zp, char *path, char *tags); int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime); /* export hash to dest */ -int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode); +int zpm_extract(struct zpm *pkg, char *hash, char *path, mode_t mode); /* export path to dest */ int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest); @@ -140,10 +161,8 @@ int zpm_checkinstall(struct zpm *local); int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags); -#if 1 -void uncompresslzma(void *buf, size_t bufsize, FILE *out); +ssize_t uncompresslzma(void *buf, size_t bufsize, int outfd); void *compresslzma(void *buf, size_t bufsize, size_t *len); -#endif #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x)) int zpm_hash(char *path, char *hash, uint32_t flags); @@ -156,9 +175,50 @@ int zpm_addvercmp(struct zpm *pkg); int zpm_exec(struct zpm *z, const char *sql, int(*callback)(void *, int, char **, char**), void *arg, char **errmsg); -int zpm_foreach_path(struct zpm *zpm, char *pkgid, +int zpm_foreach_path(struct zpm *zpm, char *pkgid, char *where, int (*callback)(void *f, int ncols, char **vals, char **cols), void *data, char **errmsg); +int zpm_foreach_package(struct zpm *zpm, char *where, +int (*callback)(void *cbdata, int ncols, char **vals, char **cols), +void *data, char **errmsg); + +int zpm_script_hash(struct zpm *zpm, char *pkgstr, char *phase, char *hash); +int zpm_script_set(struct zpm *zpm, char *pkgstr, char *phase, char *hash); +int zpm_foreach_script(struct zpm *zpm, char *pkgstr, char *stage, void *cbd, + int (*cb)(void *ud, const char *pkg, const char *stage, const char *hash)); + +int zpm_package_hash(struct zpm *zpm, char *pkgid, char *hash); +int zpm_package_sethash(struct zpm *zpm, char *pkgid, char *hash); + +sqlite3_stmt *zpm_dbqueryv(struct zpm *zpm, char *query, va_list args); +sqlite3_stmt *zpm_dbquery(struct zpm *zpm, char *query, ...); +char *zpm_db_string(struct zpm *zpm, char *query, ...); +int zpm_db_int(struct zpm *zpm, char *query, ...); +void zpm_db_run(struct zpm *zpm, char *query, ...); +void zpm_seterror(struct zpm *zpm, char *msgfmt, ...); + +struct zpm *zpm_clearmem(struct zpm *zpm); + +struct zpm_note { + int64_t id; + time_t ts; /* or timespec */ + char *note; + char *pkgid; + char *path; + char *file; + char *hash; + int ack; +}; +void zpm_note_ack(struct zpm *zpm, int64_t note); +void zpm_note_unack(struct zpm *zpm, int64_t note); +void zpm_note_del(struct zpm *zpm, int64_t note); +int64_t zpm_note(struct zpm *zpm, struct zpm_note *n, unsigned int flags); +void zpm_note_free(struct zpm_note *n); +int zpm_notes(struct zpm *zpm, int n, struct zpm_note *note); +int64_t zpm_note_next(struct zpm *zpm, struct zpm_note *n); +int64_t zpm_note_add(struct zpm *zpm, char *pkgid, char *path, char *filehash, + char *notefmt, ...); +int zpm_notes_available(struct zpm *zpm, int flags); #endif