summaryrefslogtreecommitdiff
path: root/dpkg-deb/extract.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2013-08-07 02:20:11 +0200
committerGuillem Jover <guillem@debian.org>2013-08-10 20:13:08 +0200
commit44489a55437fb007f8b21c4d9345f235f4b289b7 (patch)
treed6b90ea3bbf733c9e430c32b74a4b1b996054d03 /dpkg-deb/extract.c
parentae0e9e05926990db2d7aa22d2bbc20aaaa4c9a3f (diff)
downloaddpkg-44489a55437fb007f8b21c4d9345f235f4b289b7.tar.gz
dpkg-deb: Inline controlextractvextract() into call sites
Although the two call sites are doing almost the same, they need different argument parsing logic, and inlining the code will allow to print more meaningful bad usage messages.
Diffstat (limited to 'dpkg-deb/extract.c')
-rw-r--r--dpkg-deb/extract.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index c800616ce..6c2929d75 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -367,31 +367,6 @@ extracthalf(const char *debar, const char *dir,
}
}
-static int
-controlextractvextract(int admin, enum dpkg_tar_options taroptions,
- const char *const *argv)
-{
- const char *debar, *dir;
-
- debar = *argv++;
- if (debar == NULL)
- badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
- dir = *argv++;
- if (!dir) {
- if (admin)
- dir = EXTRACTCONTROLDIR;
- else
- badusage(_("--%s needs a target directory.\n"
- "Perhaps you should be using dpkg --install ?"),
- cipaction->olong);
- } else if (*argv) {
- badusage(_("--%s takes at most two arguments (.deb and directory)"),cipaction->olong);
- }
- extracthalf(debar, dir, taroptions, admin);
-
- return 0;
-}
-
int
do_fsystarfile(const char *const *argv)
{
@@ -410,18 +385,49 @@ do_fsystarfile(const char *const *argv)
int
do_control(const char *const *argv)
{
- return controlextractvextract(1, DPKG_TAR_EXTRACT, argv);
+ const char *debar, *dir;
+
+ debar = *argv++;
+ if (debar == NULL)
+ badusage(_("--%s needs a .deb filename argument"), cipaction->olong);
+
+ dir = *argv++;
+ if (dir == NULL)
+ dir = EXTRACTCONTROLDIR;
+ else if (*argv)
+ badusage(_("--%s takes at most two arguments (.deb and directory)"),
+ cipaction->olong);
+
+ extracthalf(debar, dir, DPKG_TAR_EXTRACT, 1);
+
+ return 0;
}
int
do_extract(const char *const *argv)
{
+ const char *debar, *dir;
enum dpkg_tar_options options = DPKG_TAR_EXTRACT | DPKG_TAR_PERMS;
if (opt_verbose)
options |= DPKG_TAR_LIST;
- return controlextractvextract(0, options, argv);
+ debar = *argv++;
+ if (debar == NULL)
+ badusage(_("--%s needs a .deb filename argument"), cipaction->olong);
+
+ dir = *argv++;
+ if (dir == NULL)
+ badusage(_("--%s needs a target directory.\n"
+ "Perhaps you should be using dpkg --install ?"),
+ cipaction->olong);
+ else if (*argv)
+ badusage(_("--%s takes at most two arguments (.deb and directory)"),
+ cipaction->olong);
+
+ extracthalf(debar, dir, options, 0);
+
+ return 0;
}
int