+2008-03-11 Ian Jackson <ian@davenant.greenend.org.uk>,
+ Guillem Jover <guillem@debian.org>
+
+ * lib/showcright.c: Rename to ...
+ * lib/myopt-util.c: ... this.
+ * lib/Makefile.am (libdpkg_a_SOURCES): Rename 'showcright.c' to
+ 'myopt-util.c'.
+
+ * lib/dpkg.h (struct cmdinfo): Remove declaration.
+ (showcopyright): Move prototype to ...
+ * lib/myopt-util.c: ... here.
+ (helponly, versiononly): New functions.
+ * lib/myopt.h: Include <dpkg-def.h>.
+ (showcopyright, helponly, versiononly, usage, printversion): New
+ function prototypes.
+ * dpkg-deb/main.c (printversion, usage): Remove static keyword.
+ (helponly, versiononly): Remove function declarations and definitions.
+ * dpkg-split/main.c: Likewise.
+ * dselect/main.cc: Likewise.
+ * src/main.c: Likewise.
+ * src/query.c: Likewise.
+
2008-03-11 Guillem Jover <guillem@debian.org>
* lib/showcright.c (showcopyright): Move function prototype to ...
const char* showformat = "${Package}\t${Version}\n";
-static void printversion(void) {
+void
+printversion(void)
+{
if (printf(_("Debian `%s' package archive backend version %s.\n"),
BACKEND, DPKG_VERSION_ARCH) < 0) werr("stdout");
if (printf(_("This is free software; see the GNU General Public License version 2 or\n"
BACKEND) < 0) werr("stdout");
}
-static void usage(void) {
+void
+usage(void)
+{
if (printf(_(
"Usage: %s [<option> ...] <command>\n"
"\n"), BACKEND) < 0) werr("stdout");
const struct cmdinfo *cipaction = NULL;
dofunction *action = NULL;
-static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void helponly(const struct cmdinfo *cip, const char *value) {
- usage(); exit(0);
-}
-static void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void versiononly(const struct cmdinfo *cip, const char *value) {
- printversion(); exit(0);
-}
-
static void setaction(const struct cmdinfo *cip, const char *value);
static void setcompresstype(const struct cmdinfo *cip, const char *value);
#include "dpkg-split.h"
-static void printversion(void) {
+void
+printversion(void)
+{
if (printf(_("Debian `%s' package split/join tool; version %s.\n"),
SPLITTER, DPKG_VERSION_ARCH) < 0) werr ("stdout");
if (printf(_("Copyright (C) 1994-1996 Ian Jackson.\n")) < 0) werr ("stdout");
SPLITTER) < 0) werr("stdout");
}
-static void usage(void) {
+void
+usage(void)
+{
if (printf(_(
"Usage: %s [<option> ...] <command>\n"
"\n"), SPLITTER) < 0) werr("stdout");
ohshit(_("unexpected end of file in %.250s"),fn);
}
-static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void helponly(const struct cmdinfo *cip, const char *value) {
- usage(); exit(0);
-}
-static void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void versiononly(const struct cmdinfo *cip, const char *value) {
- printversion(); exit(0);
-}
-
static void setaction(const struct cmdinfo *cip, const char *value);
static void setpartsize(const struct cmdinfo *cip, const char *value) {
"later for copying conditions. There is NO warranty.\n"
"See %s --license for copyright and license details.\n");
-static void printversion(void) {
+void
+printversion(void)
+{
if (printf(gettext(programdesc), DSELECT, DPKG_VERSION_ARCH) < 0)
werr("stdout");
if (printf(gettext(copyrightstring)) < 0) werr("stdout");
if (printf(gettext(licensestring), DSELECT) < 0) werr("stdout");
}
-static void usage(void) {
+void
+usage(void)
+{
int i;
if (printf(_(
"Usage: %s [<option> ...] [<action> ...]\n"
/* These are called by C code, so need to have C calling convention */
extern "C" {
- static void helponly(const struct cmdinfo*, const char*) NONRETURNING;
- static void helponly(const struct cmdinfo*, const char*) {
- usage(); exit(0);
- }
- static void versiononly(const struct cmdinfo*, const char*) NONRETURNING;
- static void versiononly(const struct cmdinfo*, const char*) {
- printversion(); exit(0);
- }
-
static void setdebug(const struct cmdinfo*, const char *v) {
debug= fopen(v,"a");
if (!debug) ohshite(_("couldn't open debug file `%.255s'\n"),v);
md5.c md5.h \
mlib.c \
myopt.c myopt.h \
+ myopt-util.c \
nfmalloc.c \
parse.c \
parsehelp.c \
parsedump.h \
- showcright.c \
showpkg.c \
tarfn.c tarfn.h \
utils.c \
extern volatile int onerr_abort;
-/*** from showcright.c ***/
-
-struct cmdinfo;
-void showcopyright(const struct cmdinfo *c, const char *v) NONRETURNING;
-
/*** from utils.c ***/
int cisdigit(int c);
/*
* libdpkg - Debian packaging suite library routines
- * showcright.c - show copyright file routine
+ * myopt-util.c - command line option utilities
*
* Copyright (C) 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
*
#include <dpkg.h>
-void showcopyright(const struct cmdinfo *c, const char *v) {
- int fd;
- fd= open(COPYINGFILE,O_RDONLY);
- if (fd < 0)
- ohshite(_("cannot open GPL file"));
- fd_fd_copy(fd, 1, -1, "showcopyright");
- exit(0);
+void
+helponly(const struct cmdinfo *cip, const char *value)
+{
+ usage();
+ exit(0);
}
+
+void
+versiononly(const struct cmdinfo *cip, const char *value)
+{
+ printversion();
+ exit(0);
+}
+
+void
+showcopyright(const struct cmdinfo *cip, const char *value)
+{
+ int fd;
+
+ fd = open(COPYINGFILE, O_RDONLY);
+ if (fd < 0)
+ ohshite(_("cannot open GPL file"));
+ fd_fd_copy(fd, 1, -1, "showcopyright");
+ exit(0);
+}
+
#ifndef MYOPT_H
#define MYOPT_H
+#include <dpkg-def.h>
+
typedef void (*voidfnp)(void);
struct cmdinfo {
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);
+
+/* Utility functions. */
+void showcopyright(const struct cmdinfo *cip, const char *value) NONRETURNING;
+void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
+void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING;
+
+/* To be defined by callers. */
+void usage(void);
+void printversion(void);
+
#endif /* MYOPT_H */
#include "main.h"
-static void printversion(void) {
+void
+printversion(void)
+{
if (printf(_("Debian `%s' package management program version %s.\n"),
DPKG, DPKG_VERSION_ARCH) < 0) werr("stdout");
if (printf(_("This is free software; see the GNU General Public License version 2 or\n"
options that need fixing:
dpkg --yet-to-unpack \n\
*/
-static void usage(void) {
+void
+usage(void)
+{
if (fprintf (stdout, _(
"Usage: %s [<option> ...] <command>\n"
"\n"), DPKG) < 0) werr ("stdout");
{ NULL }
};
-static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void helponly(const struct cmdinfo *cip, const char *value) {
- usage(); exit(0);
-}
-static void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void versiononly(const struct cmdinfo *cip, const char *value) {
- printversion(); exit(0);
-}
-
static void setaction(const struct cmdinfo *cip, const char *value) {
if (cipaction)
badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),
modstatdb_shutdown();
}
-static void printversion(void) {
+void
+printversion(void)
+{
if (printf(_("Debian `%s' package management program query tool\n"),
DPKGQUERY) < 0) werr("stdout");
if (printf(_("This is free software; see the GNU General Public License version 2 or\n"
options that need fixing:
dpkg --yet-to-unpack \n\
*/
-static void usage(void) {
+void
+usage(void)
+{
if (printf(_(
"Usage: %s [<option> ...] <command>\n"
"\n"), DPKGQUERY) < 0) werr ("stdout");
const char *instdir= "";
struct packageinlist *ignoredependss=0;
-static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void helponly(const struct cmdinfo *cip, const char *value) {
- usage(); exit(0);
-}
-static void versiononly(const struct cmdinfo *cip, const char *value) NONRETURNING;
-static void versiononly(const struct cmdinfo *cip, const char *value) {
- printversion(); exit(0);
-}
-
static void setaction(const struct cmdinfo *cip, const char *value) {
if (cipaction)
badusage(_("conflicting actions -%c (--%s) and -%c (--%s)"),