]> pd.if.org Git - zpackage/blob - zpm.h
add better error reporting for invalid import file types
[zpackage] / zpm.h
1 #ifndef ZPM_H_
2 #define ZPM_H_ 1
3
4 #include <stdint.h>
5 #include <time.h>
6 #include <sqlite3.h>
7
8 struct zpm {
9         sqlite3 *db;
10         char *path; /* path to package file */
11         char *version;
12         int release;
13         char *pkgname;
14         int error; /* internal error number */
15         time_t installed; /* install time, 0 for not installed */
16 };
17
18 struct zpm_file {
19         char *path;
20         int mode;
21         char *tags;
22         char *owner;
23         char *group;
24         time_t mtime;
25         struct zpm_file *next; /* so you can make a linked list */
26 };
27
28 /* NULL?  Create? */
29 int zpm_open(struct zpm *pkg, char *path);
30 int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */
31
32 /* flags for preserving mode, owner, etc */
33 /* puts hash of import in hash */
34 /* path can be a hash, with an "INTERNAL" flag, i.e. internally import */
35 #define ZPM_MODE 0x1
36 #define ZPM_OWNER 0x2
37 #define ZPM_MTIME 0x4
38 #define ZPM_INTERNAL 0x8
39 #define ZPM_NOBLOB 0x10
40 /* don't run scripts on install */
41 #define ZPM_NOSCRIPTS 0x10
42 /* don't import file to a particular package */
43 #define ZPM_NOPACKAGE 0x20
44
45 int zpm_import(struct zpm *zp, char *path, uint32_t flags, char *hash);
46
47 /* tag a file.  relative to "current package" */
48 int zpm_tag(struct zpm *zp, char *path, char *tags);
49 /* should this be broken up into separage functions ? */
50 int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime);
51
52 /* export hash to dest */
53 int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode);
54
55 /* export path to dest */
56 int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest);
57
58 int zpm_close(struct zpm *zp);
59
60 /* attach a signature to a package */
61 int zpm_sign(struct zpm *z, size_t s, void *signature);
62
63 /* set the package info to the nth package, -1 to return count? */
64 /* further import/exports and such will be relative to this package */
65 int zpm_package(struct zpm *zp, int n);
66
67 /* get file information */
68 int zpm_stat(struct zpm *z, struct zpm_file *f, int n);
69
70 /* will also set the package context to the new package */
71 int zpm_newpkg(struct zpm *z, char *base, char *version, int release);
72
73 /* transactions */
74 int zpm_begin(struct zpm *z);
75 int zpm_commit(struct zpm *z);
76 int zpm_rollback(struct zpm *z);
77
78 /* higher level operations */
79
80 /* install or uninstall the package */
81 /* flag for keeping the blobs in local */
82 /* what about tag filtering */
83 int zpm_install(struct zpm *z, struct zpm *local, uint32_t flags);
84 int zpm_uninstall(struct zpm *local);
85
86 /* slurp up the actual blobs */
87 /* what about versioning them if they change */
88 int zpm_preserve(struct zpm *local);
89
90 /* check file integrity */
91 int zpm_checkinstall(struct zpm *local);
92
93 int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags);
94
95 void uncompresslzma(void *buf, size_t bufsize, FILE *out);
96 void *compresslzma(void *buf, size_t bufsize, size_t *len);
97 #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x))
98 int zpm_hash(char *path, char *hash, uint32_t flags);
99 int zpm_readopts(struct zpm *pkg, int ac, char **av);
100
101 #endif