summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/err.h17
-rw-r--r--include/net.h1
-rw-r--r--include/pkgman.h15
3 files changed, 29 insertions, 4 deletions
diff --git a/include/err.h b/include/err.h
index e377889..cc556fa 100644
--- a/include/err.h
+++ b/include/err.h
@@ -1,6 +1,20 @@
#ifndef ERR_H
#define ERR_H
+#define TRY(cond, err) \
+ do { \
+ if (!(cond)) \
+ return -err; \
+ } while(0)
+
+#define TRY_IFNOT(cond, err, stmt) \
+ do { \
+ if (!(cond)) { \
+ stmt \
+ return -err; \
+ } \
+ } while(0)
+
#define SUCCESS 0
#define ERR 1
@@ -12,8 +26,9 @@
#define USAGE 7 // Usage screen displayed instead of cmd exec.
#define URLINITERR 8 // URL Struct initialization failed
#define URLPATHERR 9 // URL add path operation failed
-#define INTEGRITYERR 10
+#define INTEGRITYERR 10
#define FORKERR 11
+#define PKGCONFERR 12 // Invalid package config error
/**
* Base errors.
diff --git a/include/net.h b/include/net.h
index b2b415f..7cf6b5e 100644
--- a/include/net.h
+++ b/include/net.h
@@ -22,5 +22,6 @@ int net_init();
void net_shutdown();
int net_send_request(char *url, int write_opts, void *userdata);
+int net_download(const char *url, const char *dst);
#endif
diff --git a/include/pkgman.h b/include/pkgman.h
index 0d17622..ad95528 100644
--- a/include/pkgman.h
+++ b/include/pkgman.h
@@ -1,8 +1,17 @@
#ifndef PKGMAN_H
#define PKGMAN_H
-int pkgman_upstream_check(const char *pkg);
-int pkgman_install_pkg(const char *pkg);
-int pkgman_upstream_integrity_download(const char *pkg);
+typedef struct url url;
+
+struct pkgman_config {
+ char *dir_tmp;
+ char *dir_staging;
+ char *upstream;
+};
+
+int pkgman_upstream_check(struct pkgman_config *pc, const char *pkg);
+int pkgman_install_pkg(struct pkgman_config *pc, const char *pkg);
+int pkgman_upstream_integrity_download(struct pkgman_config *pc,
+ const char *pkg);
#endif