aboutsummaryrefslogtreecommitdiff
path: root/snag/src/source_db.c
diff options
context:
space:
mode:
Diffstat (limited to 'snag/src/source_db.c')
-rw-r--r--snag/src/source_db.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/snag/src/source_db.c b/snag/src/source_db.c
index ab7ec99..86bab8b 100644
--- a/snag/src/source_db.c
+++ b/snag/src/source_db.c
@@ -9,6 +9,8 @@
#include <unistd.h>
#include <errno.h>
+#define EXTRACT_TAR_SCRIPT "./scripts/extract_tar_contents.sh"
+
// libcrpyto context
EVP_MD_CTX *mdctx = NULL;
const EVP_MD *md = NULL;
@@ -101,6 +103,28 @@ static size_t download_write_callback(char* ptr, size_t size, size_t nmemb, void
return written;
}
+bool unpack_source(source_info_t* source, char* dest_path) {
+
+ char* source_path = get_source_path(source);
+ char* command = vastrcat(EXTRACT_TAR_SCRIPT, " ", source_path, " ", dest_path);
+
+ // just run the unpack script. we can rewrite in c in the future
+ int ret = system(command);
+ if (ret == -1) {
+ die("failed to execute unpack command '%s': %s", command, strerror(errno));
+ } else if (!WIFEXITED(ret)) {
+ die("failed to execute unpack command '%s' (didn't exit)", command);
+ } else if (WEXITSTATUS(ret) != 0) {
+ die("unpack command '%s' failed: exit status %d", command, WEXITSTATUS(ret));
+ }
+
+ free(command);
+ free(source_path);
+
+ return true;
+}
+
+
void ensure_libcrypto() {
if (mdctx == NULL) {
mdctx = EVP_MD_CTX_new();