Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-10-10 18:57:48 +0400
committerCorinna Vinschen <corinna@vinschen.de>2011-10-10 18:57:48 +0400
commit92b499acff8a35d64ec0f9b27b5df06209656ca9 (patch)
tree028b13e0eb9c8522daa2a868f0593a76d32e5adb /winsup/utils/setmetamode.c
parent4fc8a5c90acb2501178613b04bca32492953884a (diff)
* Align usage output, version output, as well as usage and version
option handling to use the same style throughout all Cygwin utils. Throughout use program_invocation_short_name to refer to current process name in Cygwin executables. * utils.sgml: Align documentation to above change. Add missing sections for getconf, ldd, and setmetamode. * strace.cc (proc_child): Avoid compiler warning.
Diffstat (limited to 'winsup/utils/setmetamode.c')
-rw-r--r--winsup/utils/setmetamode.c68
1 files changed, 53 insertions, 15 deletions
diff --git a/winsup/utils/setmetamode.c b/winsup/utils/setmetamode.c
index 65bd02b78..de8c45544 100644
--- a/winsup/utils/setmetamode.c
+++ b/winsup/utils/setmetamode.c
@@ -1,6 +1,6 @@
/* setmetamode.c
- Copyright 2006 Red Hat Inc.
+ Copyright 2006, 2011 Red Hat Inc.
Written by Kazuhiro Fujieda <fujieda@jaist.ac.jp>
@@ -10,22 +10,30 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <getopt.h>
#include <sys/ioctl.h>
#include <cygwin/kd.h>
-
-static const char version[] = "$Revision$";
-static char *prog_name;
+#include <cygwin/version.h>
static void
usage (void)
{
fprintf (stderr, "Usage: %s [metabit|escprefix]\n"
+ "\n"
+ "Get or set keyboard meta mode\n"
+ "\n"
" Without argument, it shows the current meta key mode.\n"
" metabit|meta|bit The meta key sets the top bit of the character.\n"
- " escprefix|esc|prefix The meta key sends an escape prefix.\n",
- prog_name);
+ " escprefix|esc|prefix The meta key sends an escape prefix.\n"
+ "\n"
+ "Other options:\n"
+ "\n"
+ " -h, --help This text\n"
+ " -V, --version Print program version and exit\n\n",
+ program_invocation_short_name);
}
static void
@@ -33,21 +41,35 @@ error (void)
{
fprintf (stderr,
"%s: The standard input isn't a console device.\n",
- prog_name);
+ program_invocation_short_name);
}
+void
+print_version ()
+{
+ printf ("setmetamode (cygwin) %d.%d.%d\n"
+ "Get or set keyboard meta mode\n"
+ "Copyright (C) 2006 - %s Red Hat, Inc.\n"
+ "This is free software; see the source for copying conditions. There is NO\n"
+ "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
+ CYGWIN_VERSION_DLL_MAJOR / 1000,
+ CYGWIN_VERSION_DLL_MAJOR % 1000,
+ CYGWIN_VERSION_DLL_MINOR,
+ strrchr (__DATE__, ' ') + 1);
+}
+
+struct option longopts[] = {
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
+ {0, no_argument, NULL, 0}
+};
+const char *opts = "hV";
+
int
main (int ac, char *av[])
{
int param;
-
- prog_name = strrchr (av[0], '/');
- if (!prog_name)
- prog_name = strrchr (av[0], '\\');
- if (!prog_name)
- prog_name = av[0];
- else
- prog_name++;
+ int opt;
if (ac < 2)
{
@@ -62,6 +84,22 @@ main (int ac, char *av[])
puts ("escprefix");
return 0;
}
+
+ while ((opt = getopt_long (ac, av, opts, longopts, NULL)) != -1)
+ switch (opt)
+ {
+ case 'h':
+ usage ();
+ return 0;
+ case 'V':
+ print_version ();
+ return 0;
+ default:
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_invocation_short_name);
+ return 1;
+ }
+
if (!strcmp ("meta", av[1]) || !strcmp ("bit", av[1])
|| !strcmp ("metabit", av[1]))
param = 0x03;