* umount.cc (version): New global variable.

(longopts): Accommodate new --version option.
(opts): Ditto.
(usage): Standardize usage output.
(print_version): New function.
(main): Accommodate --help, --version options.
This commit is contained in:
Christopher Faylor 2002-06-04 01:31:28 +00:00
parent 31b98a623c
commit e6cd2312d6
2 changed files with 61 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2002-06-03 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
* umount.cc (version): New global variable.
(longopts): Accommodate new --version option.
(opts): Ditto.
(usage): Standardize usage output.
(print_version): New function.
(main): Accommodate --help, --version options.
2002-06-02 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
* regtool.cc (prog_name): New global variable.
@ -5,7 +14,7 @@
(opts): Ditto.
(usage): Standardize usage output. Rearrange/add descriptions.
(print_version): New function.
(main): Accomodate longopts and new --help, --version options. Add
(main): Accommodate longopts and new --help, --version options. Add
check for (_argv[optind+1] == NULL).
2002-06-02 Christopher Faylor <cgf@redhat.com>
@ -38,9 +47,9 @@
* passwd.c (prog_name): New global variable.
(longopts): Ditto.
(opts): Ditto.
(usage): Standardize output. Accomodate new options.
(usage): Standardize output. Accommodate new options.
(print_version): New function.
(main): Accomodate longopts and new --help, --version options.
(main): Accommodate longopts and new --help, --version options.
2002-05-28 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
@ -53,7 +62,7 @@
(opts): Ditto.
(usage): New function.
(print_version): New function.
(main): Accomodate longopts and new --help, --version options.
(main): Accommodate longopts and new --help, --version options.
2002-05-26 Christopher Faylor <cgf@redhat.com>
@ -82,9 +91,9 @@
2002-05-22 Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
* mount.cc (version): New global variable.
(usage): Standardize usage output. Accomodate new version option.
(usage): Standardize usage output. Accommodate new version option.
(print_version): New function.
(longopts): Accomodate new version option.
(longopts): Accommodate new version option.
(opts): Ditto.
(main): Ditto.
@ -135,7 +144,7 @@
* kill.cc (prog_name): New global variable.
(usage): Standardize usage output. Add descriptions.
(print_version): New function.
(longopts): Accomodate new version option.
(longopts): Accommodate new version option.
(opts): Ditto.
(main): Ditto.

View File

@ -1,6 +1,6 @@
/* umount.cc
Copyright 1996, 1998, 1999, 2000, 2001 Red Hat, Inc.
Copyright 1996, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
@ -21,6 +21,7 @@ static void remove_all_user_mounts ();
static void remove_all_system_mounts ();
static void remove_cygdrive_prefix (int flags);
static const char version[] = "$Revision$";
static const char *progname;
struct option longopts[] =
@ -32,23 +33,27 @@ struct option longopts[] =
{"remove-user-mounts", no_argument, NULL, 'U'},
{"system", no_argument, NULL, 's'},
{"user", no_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
char opts[] = "hASUsuc";
char opts[] = "AchsSuUv";
static void
usage (void)
usage (FILE *where = stderr)
{
fprintf (stderr, "Usage %s [OPTION] [<posixpath>]\n\
fprintf (where, "\
Usage: %s [OPTION] [<posixpath>]\n\
-A, --remove-all-mounts remove all mounts\n\
-c, --remove-cygdrive-prefix remove cygdrive prefix\n\
-h, --help output usage information and exit\n\
-s, --system remove system mount (default)\n\
-S, --remove-system-mounts remove all system mounts\n\
-u, --user remove user mount\n\
-U, --remove-user-mounts remove all user mounts\n\
-v, --version output version information and exit\n\
", progname);
exit (1);
exit (where == stderr ? 1 : 0);
}
static void
@ -58,13 +63,34 @@ error (const char *path)
exit (1);
}
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
%s (cygwin) %.*s\n\
Filesystem Utility\n\
Copyright 1996, 1998, 1999, 2000, 2001, 2002\n\
Compiled on %s", progname, len, v, __DATE__);
}
int
main (int argc, char **argv)
{
int i;
int flags = 0;
int default_flag = MOUNT_SYSTEM;
progname = argv[0];
enum do_what
{
nada,
@ -74,6 +100,14 @@ main (int argc, char **argv)
saw_remove_all_user_mounts
} do_what = nada;
progname = strrchr (argv[0], '/');
if (progname == NULL)
progname = strrchr (argv[0], '\\');
if (progname == NULL)
progname = argv[0];
else
progname++;
if (argc == 1)
usage ();
@ -90,6 +124,8 @@ main (int argc, char **argv)
usage ();
do_what = saw_remove_cygdrive_prefix;
break;
case 'h':
usage (stdout);
case 's':
flags |= MOUNT_SYSTEM;
break;
@ -107,6 +143,9 @@ main (int argc, char **argv)
usage ();
do_what = saw_remove_all_user_mounts;
break;
case 'v':
print_version ();
exit (0);
default:
usage ();
}