+struct zpm_version_info {
+ const char *verstr;
+ const char *name; int namelen;
+ const char *version; int verlen;
+ const char *relstr; int rellen;
+ int release;
+};
+
+int zpm_parse_version(const char *pstr, struct zpm_version_info *info);
+int zpm_vercmp(const char *a, const char *b);
+
+/* add vercmp collation to db */
+int zpm_addvercmp(struct zpm *pkg);
+
+/* return 1 if database is readonly, 0 if readwrite, or not connected */
+int zpm_readonly(struct zpm *z);
+
+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, char *where,
+int (*callback)(void *f, int ncols, char **vals, char **cols),
+void *data, char **errmsg);
+
+int zpm_foreach_path_ds(struct zpm *zpm, char *pkgid, char *where,
+int (*callback)(struct zpm *, struct zpm_file *, void *), void *cbd);
+
+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);
+int zpm_package_checkhash(struct zpm *zpm, char *pkgid, char *hash);
+char *zpm_package_gethash(struct zpm *zpm, char *pkgid, char *hash);
+int zpm_package_clearhash(struct zpm *zpm, char *pkgid);
+
+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, ...);
+int 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;
+ char *ts; /* applications can parse it if they need to */
+ 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);
+