summaryrefslogtreecommitdiff
path: root/dpkg-deb/main.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2010-01-27 18:59:22 +0100
committerGuillem Jover <guillem@debian.org>2010-01-28 20:58:08 +0100
commit95b61194f3e3b737c67d91083d1d51bd421a42e8 (patch)
tree761b7ab68be429a6d5c6d7462e97a6bf53b108f9 /dpkg-deb/main.c
parent6a52f13b5ad0b3058eeb46383aeecee38ebc664f (diff)
downloaddpkg-95b61194f3e3b737c67d91083d1d51bd421a42e8.tar.gz
libdpkg: Centralize compressor knowledge into the compress module
Create a new structure to hold the name, extension, and compress and decompress methods for each compressor. Add new functions to find the correct compressor by name and extension. This way we have the information localized in a single place.
Diffstat (limited to 'dpkg-deb/main.c')
-rw-r--r--dpkg-deb/main.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index a9bbc956f..37e42a138 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -134,7 +134,7 @@ const char printforhelp[]=
"Type dpkg --help for help about installing and deinstalling packages.");
int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
-enum compress_type compress_type = compress_type_gzip;
+struct compressor *compressor = &compressor_gzip;
int compress_level = -1;
const struct cmdinfo *cipaction = NULL;
dofunction *action = NULL;
@@ -209,15 +209,8 @@ static void setaction(const struct cmdinfo *cip, const char *value) {
}
static void setcompresstype(const struct cmdinfo *cip, const char *value) {
- if (!strcmp(value, "gzip"))
- compress_type = compress_type_gzip;
- else if (!strcmp(value, "bzip2"))
- compress_type = compress_type_bzip2;
- else if (!strcmp(value, "lzma"))
- compress_type = compress_type_lzma;
- else if (!strcmp(value, "none"))
- compress_type = compress_type_none;
- else
+ compressor = compressor_find_by_name(value);
+ if (compressor == NULL)
ohshit(_("unknown compression type `%s'!"), value);
}