summaryrefslogtreecommitdiff
path: root/include/err.h
diff options
context:
space:
mode:
author0x221E <0x221E@0xinfinity.dev>2026-05-13 16:50:15 +0200
committer0x221E <0x221E@0xinfinity.dev>2026-05-13 16:52:52 +0200
commita532b3eb7e8610fb51cc703c9634532704e9b381 (patch)
tree7ad12176952943f39dfb3e2d38a6243e2f3ea807 /include/err.h
parent922d616c65573bdbbb52f1e2fa663d283d0fbd35 (diff)
downloadpkgman-dev.tar.gz
refactor: add pkgman_config struct and move download to net.cHEADdev
Added option to change mirror, tmp, staging directoryfrom the user interface of the pkgman library. Added TRY and TRY_IFNOT macros for better code readability.
Diffstat (limited to 'include/err.h')
-rw-r--r--include/err.h17
1 files changed, 16 insertions, 1 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.