* dumper.cc (usage) Standardize usage output. Generalize to allow use for
help. (longopts) New struct. Added longopts for all options. (print_version) New function. (main) Change getopt to getopt_long. Accommodate new help and version options.
This commit is contained in:
parent
60b2107cfd
commit
84d06cb64d
|
@ -1,3 +1,12 @@
|
||||||
|
2002-05-07 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
|
||||||
|
|
||||||
|
* dumper.cc (usage) Standardize usage output. Generalize to allow use
|
||||||
|
for help.
|
||||||
|
(longopts) New struct. Added longopts for all options.
|
||||||
|
(print_version) New function.
|
||||||
|
(main) Change getopt to getopt_long. Accommodate new help and version
|
||||||
|
options.
|
||||||
|
|
||||||
2002-03-29 Corinna Vinschen <corinna@vinschen.de>
|
2002-03-29 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* mkgroup.c (main): Change call to exit() to a return statement.
|
* mkgroup.c (main): Change call to exit() to a return statement.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* dumper.cc
|
/* dumper.cc
|
||||||
|
|
||||||
Copyright 1999,2001 Red Hat Inc.
|
Copyright 1999, 2001, 2002 Red Hat Inc.
|
||||||
|
|
||||||
Written by Egor Duda <deo@logos-m.ru>
|
Written by Egor Duda <deo@logos-m.ru>
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ __attribute__ ((packed))
|
||||||
#endif
|
#endif
|
||||||
note_header;
|
note_header;
|
||||||
|
|
||||||
|
static const char version[] = "$Revision$";
|
||||||
|
|
||||||
BOOL verbose = FALSE;
|
BOOL verbose = FALSE;
|
||||||
|
|
||||||
int deb_printf (const char *format,...)
|
int deb_printf (const char *format,...)
|
||||||
|
@ -770,14 +772,46 @@ dumper::write_core_dump ()
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage ()
|
usage (FILE *stream, int status)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Usage: dumper [options] filename pid\n");
|
fprintf (stream, "\
|
||||||
fprintf (stderr, "filename -- dump core to filename.core\n");
|
Usage: dumper [OPTION] FILENAME WIN32PID\n\
|
||||||
fprintf (stderr, "pid -- win32-pid of process to dump\n\n");
|
Dump core from WIN32PID to FILENAME.core\n\
|
||||||
fprintf (stderr, "Possible options are:\n");
|
-d, --verbose be verbose while dumping\n\
|
||||||
fprintf (stderr, "-d -- be verbose while dumping\n");
|
-h, --help output help information and exit\n\
|
||||||
fprintf (stderr, "-q -- be quite while dumping (default)\n");
|
-q, --quiet be quiet while dumping (default)\n\
|
||||||
|
-v, --version output version information and exit\n\
|
||||||
|
");
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct option longopts[] = {
|
||||||
|
{"verbose", no_argument, NULL, 'd'},
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"quiet", no_argument, NULL, 'q'},
|
||||||
|
{"version", no_argument, 0, 'v'},
|
||||||
|
{0, no_argument, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_version ()
|
||||||
|
{
|
||||||
|
const char *v = strchr (version, ':');
|
||||||
|
int len;
|
||||||
|
if (!v)
|
||||||
|
{
|
||||||
|
v = "?";
|
||||||
|
len = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v += 2;
|
||||||
|
len = strchr (v, ' ') - v;
|
||||||
|
}
|
||||||
|
printf ("\
|
||||||
|
dumper (cygwin) %.*s\n\
|
||||||
|
Core Dumper for Cygwin\n\
|
||||||
|
Copyright 1999, 2001, 2002 Red Hat, Inc.\n", len, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -788,7 +822,7 @@ main (int argc, char **argv)
|
||||||
DWORD pid;
|
DWORD pid;
|
||||||
char win32_name [MAX_PATH];
|
char win32_name [MAX_PATH];
|
||||||
|
|
||||||
while ((opt = getopt (argc, argv, "dq")) != EOF)
|
while ((opt = getopt_long (argc, argv, "dqhv", longopts, NULL) ) != EOF)
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -797,8 +831,13 @@ main (int argc, char **argv)
|
||||||
case 'q':
|
case 'q':
|
||||||
verbose = FALSE;
|
verbose = FALSE;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (stdout, 0);
|
||||||
|
case 'v':
|
||||||
|
print_version ();
|
||||||
|
exit (0);
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (stderr, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,7 +853,7 @@ main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usage ();
|
usage (stderr, 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue