summaryrefslogtreecommitdiff
path: root/lib/fstream/compressor.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-14 16:17:15 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-16 09:34:35 +0200
commit5f637f97c3427dc6e1a68678aefee1f62ca34d62 (patch)
tree75254191b93adce81e188069d54de383c0123984 /lib/fstream/compressor.c
parent0a0cbefc6ebb6174aad3e6f0b8a6dea87aed49da (diff)
Implement ostream compressor wrapper
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstream/compressor.c')
-rw-r--r--lib/fstream/compressor.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/fstream/compressor.c b/lib/fstream/compressor.c
new file mode 100644
index 0000000..b8f9c6b
--- /dev/null
+++ b/lib/fstream/compressor.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * compressor.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "internal.h"
+
+int fstream_compressor_id_from_name(const char *name)
+{
+ if (strcmp(name, "gzip") == 0)
+ return FSTREAM_COMPRESSOR_GZIP;
+
+ if (strcmp(name, "xz") == 0)
+ return FSTREAM_COMPRESSOR_XZ;
+
+ return -1;
+}
+
+const char *fstream_compressor_name_from_id(int id)
+{
+ if (id == FSTREAM_COMPRESSOR_GZIP)
+ return "gzip";
+
+ if (id == FSTREAM_COMPRESSOR_XZ)
+ return "xz";
+
+ return NULL;
+}
+
+bool fstream_compressor_exists(int id)
+{
+ switch (id) {
+#ifdef WITH_GZIP
+ case FSTREAM_COMPRESSOR_GZIP:
+ return true;
+#endif
+#ifdef WITH_XZ
+ case FSTREAM_COMPRESSOR_XZ:
+ return true;
+#endif
+ default:
+ break;
+ }
+
+ return false;
+}