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

View File

@ -1,6 +1,6 @@
/* umount.cc /* 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. 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_all_system_mounts ();
static void remove_cygdrive_prefix (int flags); static void remove_cygdrive_prefix (int flags);
static const char version[] = "$Revision$";
static const char *progname; static const char *progname;
struct option longopts[] = struct option longopts[] =
@ -32,23 +33,27 @@ struct option longopts[] =
{"remove-user-mounts", no_argument, NULL, 'U'}, {"remove-user-mounts", no_argument, NULL, 'U'},
{"system", no_argument, NULL, 's'}, {"system", no_argument, NULL, 's'},
{"user", no_argument, NULL, 'u'}, {"user", no_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
char opts[] = "hASUsuc"; char opts[] = "AchsSuUv";
static void 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\ -A, --remove-all-mounts remove all mounts\n\
-c, --remove-cygdrive-prefix remove cygdrive prefix\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, --system remove system mount (default)\n\
-S, --remove-system-mounts remove all system mounts\n\ -S, --remove-system-mounts remove all system mounts\n\
-u, --user remove user mount\n\ -u, --user remove user mount\n\
-U, --remove-user-mounts remove all user mounts\n\ -U, --remove-user-mounts remove all user mounts\n\
-v, --version output version information and exit\n\
", progname); ", progname);
exit (1); exit (where == stderr ? 1 : 0);
} }
static void static void
@ -58,13 +63,34 @@ error (const char *path)
exit (1); 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 int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int i; int i;
int flags = 0; int flags = 0;
int default_flag = MOUNT_SYSTEM; int default_flag = MOUNT_SYSTEM;
progname = argv[0];
enum do_what enum do_what
{ {
nada, nada,
@ -74,6 +100,14 @@ main (int argc, char **argv)
saw_remove_all_user_mounts saw_remove_all_user_mounts
} do_what = nada; } 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) if (argc == 1)
usage (); usage ();
@ -90,6 +124,8 @@ main (int argc, char **argv)
usage (); usage ();
do_what = saw_remove_cygdrive_prefix; do_what = saw_remove_cygdrive_prefix;
break; break;
case 'h':
usage (stdout);
case 's': case 's':
flags |= MOUNT_SYSTEM; flags |= MOUNT_SYSTEM;
break; break;
@ -107,6 +143,9 @@ main (int argc, char **argv)
usage (); usage ();
do_what = saw_remove_all_user_mounts; do_what = saw_remove_all_user_mounts;
break; break;
case 'v':
print_version ();
exit (0);
default: default:
usage (); usage ();
} }