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