summaryrefslogtreecommitdiff
path: root/src/net.c
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 /src/net.c
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 'src/net.c')
-rw-r--r--src/net.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/net.c b/src/net.c
index 6d566f2..bad3b1c 100644
--- a/src/net.c
+++ b/src/net.c
@@ -93,3 +93,19 @@ int net_send_request(char *url, int write_opts, void* userdata)
return SUCCESS;
}
+
+int net_download(const char *url, const char *dst)
+{
+ struct net_file_write_data fwdata;
+
+ fwdata.file = fopen(dst, "w"); // change to tmp dir
+
+ if (!fwdata.file) {
+ return -PKGNOTFND;
+ }
+
+ net_send_request(url, WRITE_OPT_FILE, (void*)&fwdata);
+
+ fclose(fwdata.file);
+ return SUCCESS;
+}