|
|
@@ -135,7 +135,6 @@ int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
|
|
|
struct compressor *compressor = &compressor_gzip;
|
|
|
int compress_level = -1;
|
|
|
const struct cmdinfo *cipaction = NULL;
|
|
|
-dofunction *action = NULL;
|
|
|
|
|
|
static void setaction(const struct cmdinfo *cip, const char *value);
|
|
|
static void setcompresstype(const struct cmdinfo *cip, const char *value);
|
|
|
@@ -156,31 +155,20 @@ set_compress_level(const struct cmdinfo *cip, const char *value)
|
|
|
compress_level = level;
|
|
|
}
|
|
|
|
|
|
-static dofunction *const dofunctions[]= {
|
|
|
- do_build,
|
|
|
- do_contents,
|
|
|
- do_control,
|
|
|
- do_info,
|
|
|
- do_field,
|
|
|
- do_extract,
|
|
|
- do_vextract,
|
|
|
- do_fsystarfile,
|
|
|
- do_showinfo
|
|
|
-};
|
|
|
+#define ACTION(longopt, shortopt, code, function) \
|
|
|
+ { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function }
|
|
|
|
|
|
-/* NB: the entries using setaction must appear first and be in the
|
|
|
- * same order as dofunctions:
|
|
|
- */
|
|
|
static const struct cmdinfo cmdinfos[]= {
|
|
|
- { "build", 'b', 0, NULL, NULL, setaction },
|
|
|
- { "contents", 'c', 0, NULL, NULL, setaction },
|
|
|
- { "control", 'e', 0, NULL, NULL, setaction },
|
|
|
- { "info", 'I', 0, NULL, NULL, setaction },
|
|
|
- { "field", 'f', 0, NULL, NULL, setaction },
|
|
|
- { "extract", 'x', 0, NULL, NULL, setaction },
|
|
|
- { "vextract", 'X', 0, NULL, NULL, setaction },
|
|
|
- { "fsys-tarfile", 0, 0, NULL, NULL, setaction },
|
|
|
- { "show", 'W', 0, NULL, NULL, setaction },
|
|
|
+ ACTION("build", 'b', 0, do_build),
|
|
|
+ ACTION("contents", 'c', 0, do_contents),
|
|
|
+ ACTION("control", 'e', 0, do_control),
|
|
|
+ ACTION("info", 'I', 0, do_info),
|
|
|
+ ACTION("field", 'f', 0, do_field),
|
|
|
+ ACTION("extract", 'x', 0, do_extract),
|
|
|
+ ACTION("vextract", 'X', 0, do_vextract),
|
|
|
+ ACTION("fsys-tarfile", 0, 0, do_fsystarfile),
|
|
|
+ ACTION("show", 'W', 0, do_showinfo),
|
|
|
+
|
|
|
{ "new", 0, 0, &oldformatflag, NULL, NULL, 0 },
|
|
|
{ "old", 0, 0, &oldformatflag, NULL, NULL, 1 },
|
|
|
{ "debug", 'D', 0, &debugflag, NULL, NULL, 1 },
|
|
|
@@ -198,8 +186,6 @@ static void setaction(const struct cmdinfo *cip, const char *value) {
|
|
|
badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),
|
|
|
cip->oshort, cip->olong, cipaction->oshort, cipaction->olong);
|
|
|
cipaction= cip;
|
|
|
- assert((int)(cip - cmdinfos) < (int)(array_count(dofunctions)));
|
|
|
- action= dofunctions[cip-cmdinfos];
|
|
|
}
|
|
|
|
|
|
static void setcompresstype(const struct cmdinfo *cip, const char *value) {
|
|
|
@@ -210,6 +196,7 @@ static void setcompresstype(const struct cmdinfo *cip, const char *value) {
|
|
|
|
|
|
int main(int argc, const char *const *argv) {
|
|
|
jmp_buf ejbuf;
|
|
|
+ dofunction *action;
|
|
|
|
|
|
setlocale(LC_NUMERIC, "POSIX");
|
|
|
setlocale(LC_ALL, "");
|
|
|
@@ -222,6 +209,7 @@ int main(int argc, const char *const *argv) {
|
|
|
if (!cipaction) badusage(_("need an action option"));
|
|
|
|
|
|
unsetenv("GZIP");
|
|
|
+ action = (dofunction *)cipaction->farg;
|
|
|
action(argv);
|
|
|
standard_shutdown();
|
|
|
exit(0);
|