diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | dpkg-deb/dpkg-deb.h | 1 | ||||
-rw-r--r-- | dpkg-deb/main.c | 12 | ||||
-rw-r--r-- | dpkg-split/dpkg-split.h | 1 | ||||
-rw-r--r-- | dpkg-split/main.c | 13 | ||||
-rw-r--r-- | lib/dpkg/libdpkg.Versions | 3 | ||||
-rw-r--r-- | lib/dpkg/myopt.c | 25 | ||||
-rw-r--r-- | lib/dpkg/myopt.h | 13 | ||||
-rw-r--r-- | src/divertcmd.c | 20 | ||||
-rw-r--r-- | src/main.c | 16 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/querycmd.c | 14 | ||||
-rw-r--r-- | src/statcmd.c | 14 |
13 files changed, 41 insertions, 93 deletions
@@ -44,7 +44,6 @@ TODO - Get rid of unuseful "unsigned" modifiers. - Use internerr instead of assert, and print more meaninful messages. - Make actionfunction return int, and avoid global exitcode variables. - - Move ACTION and OBSOLETE, etc to ‘myopt.h’. - Replace raw write and read calls with safe variants (signals etc). - Make deb build version a version instead of doing checks over a string. - Use enums for currently hardcoded literals (tdus, dependtry, etc). diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h index acadbc57c..f3a1d1bd3 100644 --- a/dpkg-deb/dpkg-deb.h +++ b/dpkg-deb/dpkg-deb.h @@ -27,7 +27,6 @@ dofunction do_contents, do_control, do_showinfo; dofunction do_info, do_field, do_extract, do_vextract, do_fsystarfile; extern int debugflag, nocheckflag, oldformatflag; -extern const struct cmdinfo *cipaction; void extracthalf(const char *debar, const char *directory, const char *taroption, int admininfo); diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c index cef1ed91b..a909e39df 100644 --- a/dpkg-deb/main.c +++ b/dpkg-deb/main.c @@ -134,9 +134,7 @@ const char printforhelp[]= int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT; struct compressor *compressor = &compressor_gzip; int compress_level = -1; -const struct cmdinfo *cipaction = NULL; -static void setaction(const struct cmdinfo *cip, const char *value); static void setcompresstype(const struct cmdinfo *cip, const char *value); static void @@ -155,9 +153,6 @@ set_compress_level(const struct cmdinfo *cip, const char *value) compress_level = level; } -#define ACTION(longopt, shortopt, code, function) \ - { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function } - static const struct cmdinfo cmdinfos[]= { ACTION("build", 'b', 0, do_build), ACTION("contents", 'c', 0, do_contents), @@ -181,13 +176,6 @@ static const struct cmdinfo cmdinfos[]= { { NULL, 0, 0, NULL, NULL, NULL } }; -static void setaction(const struct cmdinfo *cip, const char *value) { - if (cipaction) - badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), - cip->oshort, cip->olong, cipaction->oshort, cipaction->olong); - cipaction= cip; -} - static void setcompresstype(const struct cmdinfo *cip, const char *value) { compressor = compressor_find_by_name(value); if (compressor == NULL) diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h index 12830c0dc..5d102ea17 100644 --- a/dpkg-split/dpkg-split.h +++ b/dpkg-split/dpkg-split.h @@ -49,7 +49,6 @@ struct partqueue { */ }; -extern const struct cmdinfo *cipaction; extern struct partqueue *queue; extern long opt_maxpartsize; diff --git a/dpkg-split/main.c b/dpkg-split/main.c index 773f2caa5..8f33ab2ef 100644 --- a/dpkg-split/main.c +++ b/dpkg-split/main.c @@ -96,7 +96,6 @@ usage(const struct cmdinfo *cip, const char *value) const char thisname[]= SPLITTER; const char printforhelp[]= N_("Type dpkg-split --help for help."); -const struct cmdinfo *cipaction=NULL; struct partqueue *queue= NULL; long opt_maxpartsize = SPLITPARTDEFMAX; @@ -114,8 +113,6 @@ void rerreof(FILE *f, const char *fn) { ohshit(_("unexpected end of file in %.250s"),fn); } -static void setaction(const struct cmdinfo *cip, const char *value); - static void setpartsize(const struct cmdinfo *cip, const char *value) { long newpartsize; char *endp; @@ -132,9 +129,6 @@ static void setpartsize(const struct cmdinfo *cip, const char *value) { (HEADERALLOWANCE >> 10) + 1); } -#define ACTION(longopt, shortopt, code, function) \ -{ longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function } - static const struct cmdinfo cmdinfos[]= { ACTION("split", 's', 0, do_split), ACTION("join", 'j', 0, do_join), @@ -153,13 +147,6 @@ static const struct cmdinfo cmdinfos[]= { { NULL, 0 } }; -static void setaction(const struct cmdinfo *cip, const char *value) { - if (cipaction) - badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), - cip->oshort, cip->olong, cipaction->oshort, cipaction->olong); - cipaction= cip; -} - int main(int argc, const char *const *argv) { jmp_buf ejbuf; int l; diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions index 6d6ca1b75..be9ba2200 100644 --- a/lib/dpkg/libdpkg.Versions +++ b/lib/dpkg/libdpkg.Versions @@ -124,6 +124,9 @@ LIBDPKG_PRIVATE { badusage; # printforhelp; # XXX variable, do not require external # thisname; # XXX variable, do not require external + cipaction; # XXX variable, do not export + setaction; + setobsolete; # General logging log_file; # XXX variable, do not export diff --git a/lib/dpkg/myopt.c b/lib/dpkg/myopt.c index dd0ebc872..38da7fa99 100644 --- a/lib/dpkg/myopt.c +++ b/lib/dpkg/myopt.c @@ -263,3 +263,28 @@ void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos) { } } } + +void +setobsolete(const struct cmdinfo *cip, const char *value) +{ + warning(_("obsolete option '--%s'\n"), cip->olong); +} + +const struct cmdinfo *cipaction = NULL; + +/* XXX: This function is a hack. */ +static inline int +option_short(int c) +{ + return c ? c : '\b'; +} + +void +setaction(const struct cmdinfo *cip, const char *value) +{ + if (cipaction) + badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), + option_short(cip->oshort), cip->olong, + option_short(cipaction->oshort), cipaction->olong); + cipaction = cip; +} diff --git a/lib/dpkg/myopt.h b/lib/dpkg/myopt.h index a054a1dd8..e36ddafd5 100644 --- a/lib/dpkg/myopt.h +++ b/lib/dpkg/myopt.h @@ -49,6 +49,19 @@ void myfileopt(const char* fn, const struct cmdinfo* cmdinfos); void myopt(const char *const **argvp, const struct cmdinfo *cmdinfos); void loadcfgfile(const char *prog, const struct cmdinfo *cmdinfos); +/** + * Current cmdinfo action. + */ +extern const struct cmdinfo *cipaction; + +void setaction(const struct cmdinfo *cip, const char *value); +void setobsolete(const struct cmdinfo *cip, const char *value); + +#define ACTION(longopt, shortopt, code, function) \ + { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function } +#define OBSOLETE(longopt, shortopt) \ + { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL } + DPKG_END_DECLS #endif /* MYOPT_H */ diff --git a/src/divertcmd.c b/src/divertcmd.c index ca1793976..4ebaae25c 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -49,7 +49,6 @@ const char thisname[] = "dpkg-divert"; const char printforhelp[] = N_("Use --help for help about querying packages."); -const struct cmdinfo *cipaction = NULL; const char *admindir = ADMINDIR; static bool opt_pkgname_match_any = true; @@ -659,22 +658,6 @@ diversion_listpackage(const char *const *argv) return 0; } -static inline int -option_short(int c) -{ - return c ? c : '\b'; -} - -static void -setaction(const struct cmdinfo *cip, const char *value) -{ - if (cipaction) - badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), - option_short(cip->oshort), cip->olong, - option_short(cipaction->oshort), cipaction->olong); - cipaction = cip; -} - static void setpackage(const struct cmdinfo *cip, const char *value) { @@ -696,9 +679,6 @@ setdivertto(const struct cmdinfo *cip, const char *value) badusage(_("divert-to may not contain newlines")); } -#define ACTION(longopt, shortopt, code, function) \ - { longopt, shortopt, 0, 0, 0, setaction, code, 0, (voidfnp)function } - static const struct cmdinfo cmdinfo_add = ACTION("add", 0, 0, diversion_add); diff --git a/src/main.c b/src/main.c index bdf4029f0..bd330f0ef 100644 --- a/src/main.c +++ b/src/main.c @@ -172,7 +172,6 @@ const char printforhelp[]= N_( "\n" "Options marked [*] produce a lot of output - pipe it through `less' or `more' !"); -const struct cmdinfo *cipaction = NULL; int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0; int f_autodeconf=0, f_nodebsig=0; int f_triggers = 0; @@ -219,17 +218,6 @@ static const struct forceinfo { { NULL } }; -static void setaction(const struct cmdinfo *cip, const char *value) { - if (cipaction) - badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), - cip->oshort, cip->olong, cipaction->oshort, cipaction->olong); - cipaction= cip; -} - -static void setobsolete(const struct cmdinfo *cip, const char *value) { - warning(_("obsolete option '--%s'\n"), cip->olong); -} - static void setdebug(const struct cmdinfo *cpi, const char *value) { char *endp; @@ -464,10 +452,6 @@ static const struct cmdinfo cmdinfos[]= { * The action entries are made with the ACTION macro, as they all * have a very similar structure. */ -#define ACTION(longopt,shortopt,code,function) \ - { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function } -#define OBSOLETE(longopt,shortopt) \ - { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL } #define ACTIONBACKEND(longopt, shortopt, backend) \ { longopt, shortopt, 0, NULL, NULL, setaction, 0, (void *)backend, (voidfnp)execbackend } diff --git a/src/main.h b/src/main.h index 6337191a3..82e6885e9 100644 --- a/src/main.h +++ b/src/main.h @@ -119,7 +119,6 @@ enum conffopt { extern const char *const statusstrings[]; -extern const struct cmdinfo *cipaction; extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact; extern int f_autodeconf, f_nodebsig; extern int f_triggers; diff --git a/src/querycmd.c b/src/querycmd.c index d0cfe86ba..4968b0328 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -642,27 +642,13 @@ usage(const struct cmdinfo *ci, const char *value) const char thisname[]= "dpkg-query"; const char printforhelp[]= N_("Use --help for help about querying packages."); -const struct cmdinfo *cipaction = NULL; - const char *admindir= ADMINDIR; -static void setaction(const struct cmdinfo *cip, const char *value) { - if (cipaction) - badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), - cip->oshort, cip->olong, cipaction->oshort, cipaction->olong); - cipaction= cip; -} - static const struct cmdinfo cmdinfos[]= { /* This table has both the action entries in it and the normal options. * The action entries are made with the ACTION macro, as they all * have a very similar structure. */ -#define ACTION(longopt,shortopt,code,function) \ - { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function } -#define OBSOLETE(longopt,shortopt) \ - { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL } - ACTION( "listfiles", 'L', act_listfiles, enqperpackage ), ACTION( "status", 's', act_status, enqperpackage ), ACTION( "print-avail", 'p', act_printavail, enqperpackage ), diff --git a/src/statcmd.c b/src/statcmd.c index 337e351df..e696458f8 100644 --- a/src/statcmd.c +++ b/src/statcmd.c @@ -99,23 +99,12 @@ usage(const struct cmdinfo *cip, const char *value) exit(0); } -const struct cmdinfo *cipaction = NULL; const char *admindir = ADMINDIR; static int opt_verbose = 1; static int opt_force = 0; static int opt_update = 0; -static void -setaction(const struct cmdinfo *cip, const char *value) -{ - if (cipaction) - badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"), - cip->oshort, cip->olong, - cipaction->oshort, cipaction->olong); - cipaction = cip; -} - static char * path_cleanup(const char *path) { @@ -366,9 +355,6 @@ statoverride_list(const char *const *argv) return ret; } -#define ACTION(longopt, shortopt, code, function) \ - { longopt, shortopt, 0, 0, 0, setaction, code, 0, (voidfnp)function } - static const struct cmdinfo cmdinfos[] = { ACTION("add", 0, act_install, statoverride_add), ACTION("remove", 0, act_remove, statoverride_remove), |