aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2024-01-24 21:52:41 -0500
committerMike Frysinger <vapier@gentoo.org>2024-01-24 21:52:41 -0500
commit5243cb017a7847f53caaa7c89b8e7f3abf1e5e40 (patch)
tree561a5e6541a217132f473318d0936c087eda8040 /dumpelf.c
parentpspax: switch from fgets to getline (diff)
downloadpax-utils-5243cb017a7847f53caaa7c89b8e7f3abf1e5e40.tar.gz
pax-utils-5243cb017a7847f53caaa7c89b8e7f3abf1e5e40.tar.bz2
pax-utils-5243cb017a7847f53caaa7c89b8e7f3abf1e5e40.zip
unify usage() output across all the tools
The scanelf --help output is the best & most flexible, so move that to common code so the rest of the tools can benefit from it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'dumpelf.c')
-rw-r--r--dumpelf.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/dumpelf.c b/dumpelf.c
index c8f27e4..5b18326 100644
--- a/dumpelf.c
+++ b/dumpelf.c
@@ -507,7 +507,6 @@ static void dump_dyn(const elfobj *elf, const void *dyn_void, size_t dyn_cnt)
/* usage / invocation handling functions */
#define PARSE_FLAGS "vhV"
-#define a_argument required_argument
static struct option const long_opts[] = {
{"verbose", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
@@ -524,18 +523,13 @@ static const char * const opts_help[] = {
/* display usage and exit */
static void usage(int status)
{
- size_t i;
- printf("* Dump internal ELF structure\n\n"
- "Usage: %s <file1> [file2 fileN ...]\n\n", argv0);
- printf("Options:\n");
- for (i = 0; long_opts[i].name; ++i)
- if (long_opts[i].has_arg == no_argument)
- printf(" -%c, --%-13s* %s\n", long_opts[i].val,
- long_opts[i].name, opts_help[i]);
- else
- printf(" -%c, --%-6s <arg> * %s\n", long_opts[i].val,
- long_opts[i].name, opts_help[i]);
- exit(status);
+ pax_usage(
+ "Dump internal ELF structure",
+ "<file1> [file2 fileN ...]",
+ PARSE_FLAGS,
+ long_opts,
+ opts_help,
+ status);
}
/* parse command line arguments and perform needed actions */