summaryrefslogtreecommitdiff
path: root/dpkg-deb/main.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2012-05-28 19:03:08 +0200
committerGuillem Jover <guillem@debian.org>2012-06-06 11:13:03 +0200
commitd630b04733ca0a1fb01314668e5812121f7fb496 (patch)
tree35f834af9bb94fec300ad6ca62ecc657676a98b6 /dpkg-deb/main.c
parentb5c0d13c6cc1d16495f2f9b189ef579612d87d3c (diff)
downloaddpkg-d630b04733ca0a1fb01314668e5812121f7fb496.tar.gz
libdpkg: Switch compression strategy code from strings to enums
Make those values global, because they could be shared by different compressors, because for validation purposes there's no point in making them compressor specific as that's too late in case the compressor has not been specified yet. And finally using enums instead of strings allows to more easily handle the different strategy values.
Diffstat (limited to 'dpkg-deb/main.c')
-rw-r--r--dpkg-deb/main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index f56eda279..74da81939 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -142,8 +142,8 @@ int oldformatflag = 0;
int opt_verbose = 0;
struct compress_params compress_params = {
.type = compressor_type_gzip,
+ .strategy = compressor_strategy_none,
.level = -1,
- .strategy = NULL,
};
static void
@@ -164,6 +164,14 @@ set_compress_level(const struct cmdinfo *cip, const char *value)
}
static void
+set_compress_strategy(const struct cmdinfo *cip, const char *value)
+{
+ compress_params.strategy = compressor_get_strategy(value);
+ if (compress_params.strategy == compressor_strategy_unknown)
+ ohshit(_("unknown compression strategy '%s'!"), value);
+}
+
+static void
setcompresstype(const struct cmdinfo *cip, const char *value)
{
compress_params.type = compressor_find_by_name(value);
@@ -192,7 +200,7 @@ static const struct cmdinfo cmdinfos[]= {
{ "nocheck", 0, 0, &nocheckflag, NULL, NULL, 1 },
{ NULL, 'z', 1, NULL, NULL, set_compress_level },
{ NULL, 'Z', 1, NULL, NULL, setcompresstype },
- { NULL, 'S', 1, NULL, &compress_params.strategy, NULL },
+ { NULL, 'S', 1, NULL, NULL, set_compress_strategy },
{ "showformat", 0, 1, NULL, &showformat, NULL },
{ "help", 'h', 0, NULL, NULL, usage },
{ "version", 0, 0, NULL, NULL, printversion },