* 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.
This commit is contained in:
Corinna Vinschen 2011-10-10 14:57:48 +00:00
parent 4fc8a5c90a
commit 92b499acff
21 changed files with 687 additions and 611 deletions

View File

@ -1,3 +1,13 @@
2011-10-10 Corinna Vinschen <corinna@vinschen.de>
* 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.
2011-10-10 Andy Koppe <andy.koppe@gmail.com>
Corinna Vinschen <corinna@vinschen.de>

View File

@ -22,9 +22,11 @@
#include "path.h"
#include "wide_path.h"
#include <getopt.h>
#include "cygwin/include/cygwin/version.h"
#include "cygwin/include/sys/cygwin.h"
#include "cygwin/include/mntent.h"
#include "cygwin/cygprops.h"
#include "cygwin/version.h"
#undef cygwin_internal
#include "loadlib.h"
@ -64,8 +66,6 @@ void dump_dodgy_apps (int verbose);
/* Forward declaration */
static void usage (FILE *, int);
static const char version[] = "$Revision$";
static const char *known_env_vars[] = {
"c_include_path",
"compiler_path",
@ -2237,24 +2237,15 @@ static char opts[] = "cdsrvkflphV";
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
cygcheck version %.*s\n\
System Checker for Cygwin\n\
Copyright (C) 1998 - 2008 Red Hat, Inc.\n\
Compiled on %s\n\
", len, v, __DATE__);
printf ("cygcheck (cygwin) %d.%d.%d\n"
"System Checker for Cygwin\n"
"Copyright (C) 1998 - %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);
}
void
@ -2376,8 +2367,10 @@ main (int argc, char **argv)
print_version ();
exit (0);
default:
usage (stderr, 1);
/*NOTREACHED*/}
fprintf (stderr, "Try `cygcheck --help' for more information.\n");
exit (1);
/*NOTREACHED*/
}
argc -= optind;
argv += optind;
if (posixly == NULL)

View File

@ -22,6 +22,7 @@ details. */
#include <io.h>
#include <sys/fcntl.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <ctype.h>
#include <errno.h>
#include <ddk/ntddk.h>
@ -30,8 +31,6 @@ details. */
#include "wide_path.h"
#include "loadlib.h"
static const char version[] = "$Revision$";
static char *prog_name;
static char *file_arg, *output_arg;
static int path_flag, unix_flag, windows_flag, absolute_flag;
@ -57,7 +56,7 @@ static struct option long_options[] = {
{(char *) "short-name", no_argument, NULL, 's'},
{(char *) "type", required_argument, NULL, 't'},
{(char *) "unix", no_argument, NULL, 'u'},
{(char *) "version", no_argument, NULL, 'v'},
{(char *) "version", no_argument, NULL, 'V'},
{(char *) "windows", no_argument, NULL, 'w'},
{(char *) "allusers", no_argument, NULL, 'A'},
{(char *) "desktop", no_argument, NULL, 'D'},
@ -71,27 +70,31 @@ static struct option long_options[] = {
{0, no_argument, 0, 0}
};
static char options[] = "ac:df:hilmMopst:uvwAC:DHOPSWF:";
static char options[] = "ac:df:hilmMopst:uVwAC:DHOPSWF:";
static void
usage (FILE * stream, int status)
{
if (!ignore_flag || !status)
fprintf (stream, "\
Usage: %s (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME...\n\
%s [-c HANDLE] \n\
%s [-ADHOPSW] \n\
%s [-F ID] \n\
Usage: %1$s (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME...\n\
%1$s [-c HANDLE] \n\
%1$s [-ADHOPSW] \n\
%1$s [-F ID] \n\
\n\
Convert Unix and Windows format paths, or output system path information\n\
\n\
Output type options:\n\
\n\
-d, --dos print DOS (short) form of NAMEs (C:\\PROGRA~1\\)\n\
-m, --mixed like --windows, but with regular slashes (C:/WINNT)\n\
-M, --mode report on mode of file (binmode or textmode)\n\
-u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt)\n\
-w, --windows print Windows form of NAMEs (C:\\WINNT)\n\
-t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows'\n\
\n\
Path conversion options:\n\
\n\
-a, --absolute output absolute path\n\
-l, --long-name print Windows long form of NAMEs (with -w, -m only)\n\
-p, --path NAME is a PATH list (i.e., '/bin:/usr/bin')\n\
@ -99,9 +102,11 @@ Path conversion options:\n\
-C, --codepage CP print DOS, Windows, or mixed pathname in Windows\n\
codepage CP. CP can be a numeric codepage identifier,\n\
or one of the reserved words ANSI, OEM, or UTF8.\n\
If this option is missing, %s defaults to the\n\
If this option is missing, %1$s defaults to the\n\
character set defined by the current locale.\n\
\n\
System information:\n\
\n\
-A, --allusers use `All Users' instead of current user for -D, -O, -P\n\
-D, --desktop output `Desktop' directory and exit\n\
-H, --homeroot output `Profiles' directory (home root) and exit\n\
@ -110,7 +115,7 @@ System information:\n\
-S, --sysdir output system directory and exit\n\
-W, --windir output `Windows' directory and exit\n\
-F, --folder ID output special folder with numeric ID and exit\n\
", prog_name, prog_name, prog_name, prog_name, prog_name);
", prog_name);
if (ignore_flag)
/* nothing to do */;
else if (stream != stdout)
@ -118,14 +123,16 @@ System information:\n\
else
{
fprintf (stream, "\
\n\
Other options:\n\
\n\
-f, --file FILE read FILE for input; use - to read from STDIN\n\
-o, --option read options from FILE as well (for use with --file)\n\
-c, --close HANDLE close HANDLE (for use in captured process)\n\
-i, --ignore ignore missing argument\n\
-h, --help output usage information and exit\n\
-v, --version output version information and exit\n\
");
-V, --version output version information and exit\n\
\n");
}
exit (ignore_flag ? 0 : status);
}
@ -374,8 +381,8 @@ get_short_paths (char *path)
len = GetShortPathNameW (wpath, NULL, 0);
if (!len)
{
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
next);
fprintf (stderr, "%s: cannot create short name of %s\n",
prog_name, next);
exit (2);
}
acc += len + 1;
@ -393,8 +400,8 @@ get_short_paths (char *path)
len = GetShortPathNameW (wpath, sptr, acc);
if (!len)
{
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
ptr);
fprintf (stderr, "%s: cannot create short name of %s\n",
prog_name, ptr);
exit (2);
}
@ -426,8 +433,8 @@ get_short_name (const char *filename)
DWORD len = GetShortPathNameW (wpath, buf, 32768);
if (!len)
{
fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
filename);
fprintf (stderr, "%s: cannot create short name of %s\n",
prog_name, filename);
exit (2);
}
len = my_wcstombs (NULL, buf, 0) + 1;
@ -515,8 +522,8 @@ get_long_name (const char *filename, DWORD& len)
if (err == ERROR_INVALID_PARAMETER)
{
fprintf (stderr, "%s: cannot create long name of %s\n", prog_name,
filename);
fprintf (stderr, "%s: cannot create long name of %s\n",
prog_name, filename);
exit (2);
}
else if (err == ERROR_FILE_NOT_FOUND)
@ -698,7 +705,8 @@ do_sysfolders (char option)
if (!buf[0])
{
fprintf (stderr, "%s: failed to retrieve special folder path\n", prog_name);
fprintf (stderr, "%s: failed to retrieve special folder path\n",
prog_name);
}
else if (!windows_flag)
{
@ -733,8 +741,8 @@ report_mode (char *filename)
printf ("%s: text\n", filename);
break;
default:
fprintf (stderr, "%s: file '%s' - %s\n", prog_name, filename,
strerror (errno));
fprintf (stderr, "%s: file '%s' - %s\n", prog_name,
filename, strerror (errno));
break;
}
}
@ -762,7 +770,8 @@ do_pathconv (char *filename)
exit (0);
else
{
fprintf (stderr, "%s: can't convert empty path\n", prog_name);
fprintf (stderr, "%s: can't convert empty path\n",
prog_name);
exit (1);
}
}
@ -863,25 +872,15 @@ do_pathconv (char *filename)
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
cygpath (cygwin) %.*s\n\
Path Conversion Utility\n\
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, \n\
2007, 2008, 2009, 2010 Red Hat, Inc.\n\
Compiled on %s\n\
", len, v, __DATE__);
printf ("cygpath (cygwin) %d.%d.%d\n"
"Path Conversion Utility\n"
"Copyright (C) 1998 - %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);
}
static int
@ -1035,13 +1034,14 @@ do_options (int argc, char **argv, int from_file)
usage (stdout, 0);
break;
case 'v':
case 'V':
print_version ();
exit (0);
default:
usage (stderr, 1);
break;
fprintf (stderr, "Try `%s --help' for more information.\n",
prog_name);
exit (1);
}
}
@ -1099,13 +1099,7 @@ main (int argc, char **argv)
int o;
setlocale (LC_CTYPE, "");
prog_name = strrchr (argv[0], '/');
if (!prog_name)
prog_name = strrchr (argv[0], '\\');
if (!prog_name)
prog_name = argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
o = do_options (argc, argv, 0);

View File

@ -1,6 +1,6 @@
/* dumper.cc
Copyright 1999, 2001, 2002, 2004, 2006, 2007 Red Hat Inc.
Copyright 1999, 2001, 2002, 2004, 2006, 2007, 2011 Red Hat Inc.
Written by Egor Duda <deo@logos-m.ru>
@ -26,8 +26,10 @@
#include <elf/external.h>
#include <sys/procfs.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <getopt.h>
#include <stdarg.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -47,8 +49,6 @@ __attribute__ ((packed))
#endif
note_header;
static const char version[] = "$Revision$";
BOOL verbose = FALSE;
int deb_printf (const char *format,...)
@ -842,14 +842,15 @@ static void
usage (FILE *stream, int status)
{
fprintf (stream, "\
Usage: dumper [OPTION] FILENAME WIN32PID\n\
Usage: %s [OPTION] FILENAME WIN32PID\n\
\n\
Dump core from WIN32PID to FILENAME.core\n\
\n\
-d, --verbose be verbose while dumping\n\
-h, --help output help information and exit\n\
-q, --quiet be quiet while dumping (default)\n\
-v, --version output version information and exit\n\
");
-V, --version output version information and exit\n\
\n", program_invocation_short_name);
exit (status);
}
@ -857,29 +858,23 @@ struct option longopts[] = {
{"verbose", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"quiet", no_argument, NULL, 'q'},
{"version", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{0, no_argument, NULL, 0}
};
const char *opts = "dhqV";
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);
printf ("dumper (cygwin) %d.%d.%d\n"
"Core Dumper for Cygwin\n"
"Copyright (C) 1999 - %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);
}
int
@ -889,7 +884,7 @@ main (int argc, char **argv)
const char *p = "";
DWORD pid;
while ((opt = getopt_long (argc, argv, "dqhv", longopts, NULL) ) != EOF)
while ((opt = getopt_long (argc, argv, opts, longopts, NULL) ) != EOF)
switch (opt)
{
case 'd':
@ -900,12 +895,13 @@ main (int argc, char **argv)
break;
case 'h':
usage (stdout, 0);
case 'v':
print_version ();
exit (0);
case 'V':
print_version ();
exit (0);
default:
usage (stderr, 1);
break;
fprintf (stderr, "Try `%s --help' for more information.\n",
program_invocation_short_name);
exit (1);
}
if (argv && *(argv + optind) && *(argv + optind +1))

View File

@ -36,6 +36,8 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <cygwin/version.h>
struct conf_variable
{
@ -467,15 +469,48 @@ printvar (const struct conf_variable *cp, const char *pathname)
}
static void
usage (void)
usage (int ret)
{
fprintf (stderr,
"Usage: %s [-v specification] variable_name [pathname]\n"
" %s -a [pathname]\n",
program_invocation_short_name, program_invocation_short_name);
exit (EXIT_FAILURE);
fprintf (ret ? stderr : stdout,
"Usage: %1$s [-v specification] variable_name [pathname]\n"
" %1$s -a [pathname]\n"
"\n"
"Get configuration values\n"
"\n"
" -v specification Indicate specific version for which configuration\n"
" values shall be fetched.\n"
" -a, --all Print all known configuration values\n"
"\n"
"Other options:\n"
"\n"
" -h, --help This text\n"
" -V, --version Print program version and exit\n"
"\n", program_invocation_short_name);
exit (ret);
}
static void
print_version ()
{
printf ("getconf (cygwin) %d.%d.%d\n"
"Get configuration values\n"
"Copyright (C) 2011 - %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[] = {
{"all", no_argument, NULL, 'a'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{0, no_argument, NULL, 0}
};
const char *opts = "ahvV";
int
main (int argc, char **argv)
{
@ -487,7 +522,7 @@ main (int argc, char **argv)
setlocale (LC_ALL, "");
while ((ch = getopt (argc, argv, "av")) != -1)
while ((ch = getopt_long (argc, argv, opts, longopts, NULL)) != -1)
{
switch (ch)
{
@ -497,9 +532,15 @@ main (int argc, char **argv)
case 'v':
v_flag = 1;
break;
case '?':
case 'h':
usage (0);
case 'V':
print_version ();
return 0;
default:
usage ();
fprintf (stderr, "Try `%s --help' for more information.\n",
program_invocation_short_name);
return 1;
}
}
argc -= optind;
@ -508,7 +549,7 @@ main (int argc, char **argv)
if (v_flag)
{
if (a_flag || argc < 2)
usage ();
usage (1);
for (sp = spec_table; sp->name != NULL; sp++)
{
if (strcmp (argv[0], sp->name) == 0)
@ -527,7 +568,7 @@ main (int argc, char **argv)
if (!a_flag)
{
if (argc == 0)
usage ();
usage (1);
varname = argv[0];
argc--;
argv++;
@ -536,7 +577,7 @@ main (int argc, char **argv)
varname = NULL;
if (argc > 1)
usage ();
usage (1);
pathname = argv[0]; /* may be NULL */
found = 0;
@ -551,7 +592,7 @@ main (int argc, char **argv)
found = 1;
}
else if (!a_flag)
usage ();
usage (1);
}
}

View File

@ -1,6 +1,6 @@
/* getfacl.c
Copyright 2000, 2001, 2002, 2003, 2004, 2009 Red Hat Inc.
Copyright 2000, 2001, 2002, 2003, 2004, 2009, 2011 Red Hat Inc.
Written by Corinna Vinschen <vinschen@redhat.com>
@ -18,10 +18,10 @@ details. */
#include <sys/types.h>
#include <sys/acl.h>
#include <sys/stat.h>
#include <cygwin/version.h>
#include <string.h>
#include <errno.h>
static const char version[] = "$Revision$";
static char *prog_name;
char *
@ -66,6 +66,7 @@ static void
usage (FILE * stream)
{
fprintf (stream, "Usage: %s [-adn] FILE [FILE2...]\n"
"\n"
"Display file and directory access control lists (ACLs).\n"
"\n"
" -a, --all display the filename, the owner, the group, and\n"
@ -74,7 +75,7 @@ usage (FILE * stream)
" the default ACL of the directory, if it exists\n"
" -h, --help output usage information and exit\n"
" -n, --noname display user and group IDs instead of names\n"
" -v, --version output version information and exit\n"
" -V, --version output version information and exit\n"
"\n"
"When multiple files are specified on the command line, a blank\n"
"line separates the ACLs for each file.\n", prog_name);
@ -114,31 +115,23 @@ struct option longopts[] = {
{"dir", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"noname", no_argument, NULL, 'n'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{0, no_argument, NULL, 0}
};
const char *opts = "adhnV";
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
getfacl (cygwin) %.*s\n\
ACL Utility\n\
Copyright (c) 2000, 2001, 2002, 2003, 2004, 2009 Red Hat, Inc.\n\
Compiled on %s\n\
", len, v, __DATE__);
printf ("getfacl (cygwin) %d.%d.%d\n"
"Get POSIX ACL information\n"
"Copyright (C) 2000 - %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);
}
int
@ -152,15 +145,9 @@ main (int argc, char **argv)
struct stat st;
aclent_t acls[MAX_ACL_ENTRIES];
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
while ((c = getopt_long (argc, argv, "adhnv", longopts, NULL)) != EOF)
while ((c = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
switch (c)
{
case 'a':
@ -175,11 +162,11 @@ main (int argc, char **argv)
case 'n':
nopt = 1;
break;
case 'v':
case 'V':
print_version ();
return 0;
default:
usage (stderr);
fprintf (stderr, "Try `%s --help' for more information.\n", prog_name);
return 1;
}
if (optind > argc - 1)

View File

@ -1,6 +1,6 @@
/* kill.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -16,10 +16,10 @@ details. */
#include <errno.h>
#include <windows.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <getopt.h>
#include <limits.h>
static const char version[] = "$Revision$";
static char *prog_name;
static struct option longopts[] =
@ -28,50 +28,42 @@ static struct option longopts[] =
{"list", optional_argument, NULL, 'l'},
{"force", no_argument, NULL, 'f'},
{"signal", required_argument, NULL, 's'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
static char opts[] = "hl::fs:v";
static char opts[] = "hl::fs:V";
static void
usage (FILE *where = stderr)
{
fprintf (where , ""
"Usage: %s [-f] [-signal] [-s signal] pid1 [pid2 ...]\n"
" %s -l [signal]\n"
"Usage: %1$s [-f] [-signal] [-s signal] pid1 [pid2 ...]\n"
" %1$s -l [signal]\n"
"\n"
"Send signals to processes\n"
"\n"
" -f, --force force, using win32 interface if necessary\n"
" -l, --list print a list of signal names\n"
" -s, --signal send signal (use %s --list for a list)\n"
" -s, --signal send signal (use %1$s --list for a list)\n"
" -h, --help output usage information and exit\n"
" -v, --version output version information and exit\n"
"", prog_name, prog_name, prog_name);
" -V, --version output version information and exit\n"
"\n", prog_name);
exit (where == stderr ? 1 : 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 ("\
%s (cygwin) %.*s\n\
Process Signaller\n\
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
Compiled on %s\n\
", prog_name, len, v, __DATE__);
printf ("kill (cygwin) %d.%d.%d\n"
"Process Signaller\n"
"Copyright (C) 1996 - %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);
}
static const char *
@ -110,8 +102,9 @@ test_for_unknown_sig (int sig, const char *sigstr)
{
if (sig < 0 || sig > NSIG)
{
fprintf (stderr, "%s: unknown signal: %s\n", prog_name, sigstr);
usage ();
fprintf (stderr, "%1$s: unknown signal: %2$s\n"
"Try `%1$s --help' for more information.\n",
prog_name, sigstr);
exit (1);
}
}
@ -195,13 +188,7 @@ main (int argc, char **argv)
int ret = 0;
char *gotasig = NULL;
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
if (argc == 1)
usage ();
@ -243,7 +230,7 @@ main (int argc, char **argv)
case 'h':
usage (stdout);
break;
case 'v':
case 'V':
print_version ();
break;
case '?':

View File

@ -33,6 +33,7 @@
#include <wchar.h>
#include <locale.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <unistd.h>
#include <libgen.h>
@ -49,18 +50,20 @@
struct option longopts[] =
{
{"help", no_argument, NULL, 0},
{"version", no_argument, NULL, 0},
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{"data-relocs", no_argument, NULL, 'd'},
{"function-relocs", no_argument, NULL, 'r'},
{"unused", no_argument, NULL, 'u'},
{0, no_argument, NULL, 0}
};
const char *opts = "dhruvV";
static int process_file (const wchar_t *);
static int
usage (const char *fmt, ...)
error (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
@ -70,6 +73,38 @@ usage (const char *fmt, ...)
exit (1);
}
static void
usage ()
{
printf ("Usage: %s [OPTION]... FILE...\n\
\n\
Print shared library dependencies\n\
\n\
-h, --help print this help and exit\n\
-V, --version print version information and exit\n\
-r, --function-relocs process data and function relocations\n\
(currently unimplemented)\n\
-u, --unused print unused direct dependencies\n\
(currently unimplemented)\n\
-v, --verbose print all information\n\
(currently unimplemented)\n",
program_invocation_short_name);
}
static void
print_version ()
{
printf ("ldd (cygwin) %d.%d.%d\n"
"Print shared library dependencies\n"
"Copyright (C) 2009 - %s Chris Faylor\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);
}
#define print_errno_error_and_return(__fn) \
do {\
fprintf (stderr, "ldd: %s: %s\n", (__fn), strerror (errno));\
@ -338,51 +373,37 @@ report (const char *in_fn, bool multiple)
return 0;
}
int
main (int argc, char **argv)
{
int optch;
int index;
/* Use locale from environment. If not set or set to "C", use UTF-8. */
setlocale (LC_CTYPE, "");
if (!strcmp (setlocale (LC_CTYPE, NULL), "C"))
setlocale (LC_CTYPE, "en_US.UTF-8");
while ((optch = getopt_long (argc, argv, "dru", longopts, &index)) != -1)
while ((optch = getopt_long (argc, argv, opts, longopts, NULL)) != -1)
switch (optch)
{
case 'd':
case 'r':
case 'u':
usage ("option not implemented `-%c'", optch);
error ("option not implemented `-%c'", optch);
exit (1);
case 0:
if (index == 1)
{
printf ("ldd (Cygwin) %s\nCopyright (C) 2009 Chris Faylor\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",
VERSION);
exit (0);
}
else
{
puts ("Usage: ldd [OPTION]... FILE...\n\
--help print this help and exit\n\
--version print version information and exit\n\
-r, --function-relocs process data and function relocations\n\
(currently unimplemented)\n\
-u, --unused print unused direct dependencies\n\
(currently unimplemented)\n\
-v, --verbose print all information\n\
(currently unimplemented)");
exit (0);
}
case 'h':
usage ();
exit (0);
case 'V':
print_version ();
return 0;
default:
fprintf (stderr, "Try `%s --help' for more information.\n",
program_invocation_short_name);
return 1;
}
argv += optind;
if (!*argv)
usage("missing file arguments");
error ("missing file arguments");
int ret = 0;
bool multiple = !!argv[1];

View File

@ -23,6 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <getopt.h>
@ -39,8 +40,6 @@
#define LOCALE_ALIAS "/usr/share/locale/locale.alias"
#define LOCALE_ALIAS_LINE_LEN 255
extern char *__progname;
void
usage ()
{
@ -48,6 +47,7 @@ usage ()
"Usage: %1$s [-amvhV]\n"
" or: %1$s [-ck] NAME\n"
" or: %1$s [-usfnU]\n"
"\n"
"Get locale-specific information.\n"
"\n"
"System information:\n"
@ -74,21 +74,21 @@ usage ()
"\n"
" -h, --help This text\n"
" -V, --version Print program version and exit\n\n",
__progname);
program_invocation_short_name);
}
void
print_version ()
{
printf ("%s (cygwin) %d.%d.%d\n"
"Get locale-specific information.\n"
"Copyright 2011 Red Hat, Inc.\n"
"Compiled on %s\n",
__progname,
printf ("locale (cygwin) %d.%d.%d\n"
"Get locale-specific information\n"
"Copyright (C) 2010 - %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,
__DATE__);
strrchr (__DATE__, ' ') + 1);
}
struct option longopts[] = {
@ -785,7 +785,7 @@ main (int argc, char **argv)
char name[32];
setlocale (LC_ALL, "");
while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1)
switch (opt)
{
case 'a':
@ -825,9 +825,8 @@ main (int argc, char **argv)
print_version ();
return 0;
default:
fprintf (stderr,
"Try `%1$s --help' or `%1$s -h' for more information.\n",
__progname);
fprintf (stderr, "Try `%s --help' for more information.\n",
program_invocation_short_name);
return 1;
}
if (all)

View File

@ -1,7 +1,7 @@
/* mkgroup.c:
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010 Red Hat, Inc.
2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -10,6 +10,7 @@
details. */
#define _WIN32_WINNT 0x0600
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <wchar.h>
@ -21,6 +22,7 @@
#include <io.h>
#include <sys/fcntl.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <windows.h>
#include <lm.h>
#include <wininet.h>
@ -34,10 +36,6 @@
#define MAX_SID_LEN 40
static const char version[] = "$Revision$";
extern char *__progname __declspec(dllimport);
SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
@ -230,7 +228,7 @@ enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
if (ret < 1 || ret >= INTERNET_MAX_HOST_NAME_LENGTH + 1)
{
fprintf (stderr, "%s: Invalid machine name '%s'. Skipping...\n",
__progname, d_or_m);
program_invocation_short_name, d_or_m);
return;
}
servername = machine;
@ -252,7 +250,7 @@ enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
ret = mbstowcs (p, gstr, GNLEN + 1);
if (ret < 1 || ret >= GNLEN + 1)
fprintf (stderr, "%s: Invalid group name '%s'. Skipping...\n",
__progname, gstr);
program_invocation_short_name, gstr);
else if (LookupAccountNameW (servername, grp,
psid = (PSID) psid_buffer,
(sidlen = MAX_SID_LEN, &sidlen),
@ -282,7 +280,8 @@ enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|| (stop = strtol (p, &p, 10)) < start || *p)
{
fprintf (stderr, "%s: Malformed unix group list entry '%s'. "
"Skipping...\n", __progname, gstr);
"Skipping...\n",
program_invocation_short_name, gstr);
continue;
}
for (; start <= stop; ++ start)
@ -337,7 +336,7 @@ enum_local_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
if (ret < 1 || ret >= INTERNET_MAX_HOST_NAME_LENGTH + 1)
{
fprintf (stderr, "%s: Invalid machine name '%s'. Skipping...\n",
__progname, d_or_m);
program_invocation_short_name, d_or_m);
return 1;
}
servername = machine;
@ -492,7 +491,7 @@ enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
if (ret < 1 || ret >= INTERNET_MAX_HOST_NAME_LENGTH + 1)
{
fprintf (stderr, "%s: Invalid machine name '%s'. Skipping...\n",
__progname, d_or_m);
program_invocation_short_name, d_or_m);
return;
}
servername = machine;
@ -634,10 +633,12 @@ static int
usage (FILE * stream)
{
fprintf (stream,
"Usage: mkgroup [OPTION]...\n"
"Usage: %s [OPTION]...\n"
"\n"
"Print /etc/group file to stdout\n"
"\n"
"Options:\n"
"\n"
" -l,--local [machine[,offset]]\n"
" print local groups with gid offset offset\n"
" (from local machine if no machine specified)\n"
@ -669,7 +670,8 @@ usage (FILE * stream)
" -v,--version print version information and exit\n"
"\n"
"Default is to print local groups on stand-alone machines, plus domain\n"
"groups on domain controllers and domain member machines.\n");
"groups on domain controllers and domain member machines.\n"
"\n", program_invocation_short_name);
return 1;
}
@ -688,33 +690,24 @@ struct option longopts[] = {
{"separator", required_argument, NULL, 'S'},
{"users", no_argument, NULL, 'u'},
{"unix", required_argument, NULL, 'U'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{0, no_argument, NULL, 0}
};
static char opts[] = "bcCd::D::g:hl::L::o:sS:uU:v";
static char opts[] = "bcCd::D::g:hl::L::o:sS:uU:V";
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
mkgroup (cygwin) %.*s\n\
group File Generator\n\
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.\n\
Compiled on %s\n\
", len, v, __DATE__);
printf ("mkgroup (cygwin) %d.%d.%d\n"
"Group File Generator\n"
"Copyright (C) 1997 - %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);
}
static PPOLICY_PRIMARY_DOMAIN_INFO p_dom;
@ -795,7 +788,8 @@ main (int argc, char **argv)
if (print_domlist >= 32)
{
fprintf (stderr, "%s: Can not enumerate from more than 32 "
"domains and machines.\n", __progname);
"domains and machines.\n",
program_invocation_short_name);
return 1;
}
domlist[print_domlist].domain = (c == 'd' || c == 'D');
@ -812,7 +806,8 @@ main (int argc, char **argv)
&& (!opt[off] || opt[off] == ','))))
{
fprintf (stderr, "%s: Duplicate %s '%s'. Skipping...\n",
__progname, domlist[i].domain ? "domain" : "machine",
program_invocation_short_name,
domlist[i].domain ? "domain" : "machine",
domlist[i].str);
goto skip;
}
@ -827,7 +822,7 @@ main (int argc, char **argv)
, *ep))
{
fprintf (stderr, "%s: Malformed machine,offset string '%s'. "
"Skipping...\n", __progname, opt);
"Skipping...\n", program_invocation_short_name, opt);
break;
}
*p = '\0';
@ -840,13 +835,14 @@ skip:
if (strlen (sep_char) > 1)
{
fprintf (stderr, "%s: Only one character allowed as domain\\user "
"separator character.\n", __progname);
"separator character.\n",
program_invocation_short_name);
return 1;
}
if (*sep_char == ':')
{
fprintf (stderr, "%s: Colon not allowed as domain\\user separator "
"character.\n", __progname);
"character.\n", program_invocation_short_name);
return 1;
}
break;
@ -875,11 +871,11 @@ skip:
case 'h':
usage (stdout);
return 0;
case 'v':
case 'V':
print_version ();
return 0;
default:
fprintf (stderr, "Try '%s --help' for more information.\n", argv[0]);
fprintf (stderr, "Try `%s --help' for more information.\n", argv[0]);
return 1;
}

View File

@ -1,7 +1,7 @@
/* mkpasswd.c:
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
2008, 2009, 2010 Red Hat, Inc.
2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -10,6 +10,7 @@
details. */
#define _WIN32_WINNT 0x0600
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <wchar.h>
@ -21,6 +22,7 @@
#include <io.h>
#include <sys/fcntl.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <windows.h>
#include <lm.h>
#include <iptypes.h>
@ -34,10 +36,6 @@
#define MAX_SID_LEN 40
static const char version[] = "$Revision$";
extern char *__progname __declspec(dllimport);
SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
@ -290,7 +288,7 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
if (ret < 1 || ret >= INTERNET_MAX_HOST_NAME_LENGTH + 1)
{
fprintf (stderr, "%s: Invalid machine name '%s'. Skipping...\n",
__progname, d_or_m);
program_invocation_short_name, d_or_m);
return;
}
servername = machine;
@ -312,7 +310,7 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
ret = mbstowcs (p, ustr, UNLEN + 1);
if (ret < 1 || ret >= UNLEN + 1)
fprintf (stderr, "%s: Invalid user name '%s'. Skipping...\n",
__progname, ustr);
program_invocation_short_name, ustr);
else if (LookupAccountNameW (servername, user,
psid = (PSID) psid_buffer,
(sidlen = MAX_SID_LEN, &sidlen),
@ -342,7 +340,8 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|| (stop = strtol (p, &p, 10)) < start || *p)
{
fprintf (stderr, "%s: Malformed unix user list entry '%s'. "
"Skipping...\n", __progname, ustr);
"Skipping...\n",
program_invocation_short_name, ustr);
continue;
}
for (; start <= stop; ++ start)
@ -396,7 +395,7 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
if (ret < 1 || ret >= INTERNET_MAX_HOST_NAME_LENGTH + 1)
{
fprintf (stderr, "%s: Invalid machine name '%s'. Skipping...\n",
__progname, d_or_m);
program_invocation_short_name, d_or_m);
return 1;
}
servername = machine;
@ -572,10 +571,12 @@ static int
usage (FILE * stream)
{
fprintf (stream,
"Usage: mkpasswd [OPTIONS]...\n"
"Usage: %s [OPTIONS]...\n"
"\n"
"Print /etc/passwd file to stdout\n"
"\n"
"Options:\n"
"\n"
" -l,--local [machine[,offset]]\n"
" print local user accounts with uid offset offset\n"
" (from local machine if no machine specified)\n"
@ -606,10 +607,11 @@ usage (FILE * stream)
" -s,--no-sids (ignored)\n"
" -g,--local-groups (ignored)\n"
" -h,--help displays this message\n"
" -v,--version version information and exit\n"
" -V,--version version information and exit\n"
"\n"
"Default is to print local accounts on stand-alone machines, domain accounts\n"
"on domain controllers and domain member machines.\n");
"on domain controllers and domain member machines.\n"
"\n", program_invocation_short_name);
return 1;
}
@ -629,33 +631,24 @@ static struct option longopts[] = {
{"separator", required_argument, NULL, 'S'},
{"username", required_argument, NULL, 'u'},
{"unix", required_argument, NULL, 'U'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{0, no_argument, NULL, 0}
};
static char opts[] = "cCd::D::ghl::L::mo:sS:p:u:U:v";
static char opts[] = "cCd::D::ghl::L::mo:sS:p:u:U:V";
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
mkpasswd (cygwin) %.*s\n\
passwd File Generator\n\
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008 Red Hat, Inc.\n\
Compiled on %s\n\
", len, v, __DATE__);
printf ("mkpasswd (cygwin) %d.%d.%d\n"
"Passwd File Generator\n"
"Copyright (C) 1997 - %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);
}
static void
@ -745,7 +738,8 @@ main (int argc, char **argv)
if (print_domlist >= 32)
{
fprintf (stderr, "%s: Can not enumerate from more than 32 "
"domains and machines.\n", __progname);
"domains and machines.\n",
program_invocation_short_name);
return 1;
}
domlist[print_domlist].domain = (c == 'd' || c == 'D');
@ -762,7 +756,8 @@ main (int argc, char **argv)
&& (!opt[off] || opt[off] == ','))))
{
fprintf (stderr, "%s: Duplicate %s '%s'. Skipping...\n",
__progname, domlist[i].domain ? "domain" : "machine",
program_invocation_short_name,
domlist[i].domain ? "domain" : "machine",
domlist[i].str);
goto skip;
}
@ -776,7 +771,7 @@ main (int argc, char **argv)
, *ep))
{
fprintf (stderr, "%s: Malformed domain,offset string '%s'. "
"Skipping...\n", __progname, opt);
"Skipping...\n", program_invocation_short_name, opt);
break;
}
*p = '\0';
@ -789,13 +784,14 @@ skip:
if (strlen (sep_char) > 1)
{
fprintf (stderr, "%s: Only one character allowed as domain\\user "
"separator character.\n", __progname);
"separator character.\n",
program_invocation_short_name);
return 1;
}
if (*sep_char == ':')
{
fprintf (stderr, "%s: Colon not allowed as domain\\user separator "
"character.\n", __progname);
"character.\n", program_invocation_short_name);
return 1;
}
break;
@ -813,7 +809,7 @@ skip:
if (*ep)
{
fprintf (stderr, "%s: Malformed offset '%s'. "
"Skipping...\n", __progname, optarg);
"Skipping...\n", program_invocation_short_name, optarg);
return 1;
}
break;
@ -828,7 +824,7 @@ skip:
if (optarg[0] != '/')
{
fprintf (stderr, "%s: '%s' is not a fully qualified path.\n",
__progname, optarg);
program_invocation_short_name, optarg);
return 1;
}
strcpy (passed_home_path, optarg);
@ -841,11 +837,12 @@ skip:
case 'h':
usage (stdout);
return 0;
case 'v':
case 'V':
print_version ();
return 0;
default:
fprintf (stderr, "Try '%s --help' for more information.\n", __progname);
fprintf (stderr, "Try `%s --help' for more information.\n",
program_invocation_short_name);
return 1;
}

View File

@ -1,7 +1,7 @@
/* mount.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005,
2008, 2009, 2010 Red Hat, Inc.
2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -15,6 +15,7 @@ details. */
#include <mntent.h>
#include <windows.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
@ -39,7 +40,6 @@ static int mount_already_exists (const char *posix_path, int flags);
// static short create_missing_dirs = FALSE;
static bool force = false;
static const char version[] = "$Revision$";
static const char *progname;
static void
@ -83,7 +83,8 @@ do_mount (const char *dev, const char *where, int flags)
else if (!(statbuf.st_mode & S_IFDIR))
{
if (!force)
fprintf (stderr, "%s: warning: %s is not a directory.\n", progname, where);
fprintf (stderr, "%s: warning: %s is not a directory.\n",
progname, where);
}
if (!force && !(flags & (EXEC_FLAGS | MOUNT_BIND)) && strlen (dev))
@ -100,9 +101,10 @@ do_mount (const char *dev, const char *where, int flags)
strcat (devtmp, "\\");
if (GetDriveType (devtmp) == DRIVE_REMOTE)
{
fprintf (stderr, "%s: defaulting to 'notexec' mount option for speed since native path\n"
"%*creferences a remote share. Use '-f' option to override.\n", progname,
strlen(progname) + 2, ' ');
fprintf (stderr,
"%s: defaulting to 'notexec' mount option for speed since native path\n"
"%*creferences a remote share. Use '-f' option to override.\n",
progname, strlen(progname) + 2, ' ');
flags |= MOUNT_NOTEXEC;
}
}
@ -201,20 +203,21 @@ static struct option longopts[] =
{"mount-entries", no_argument, NULL, 'm'},
{"options", required_argument, NULL, 'o'},
{"show-cygdrive-prefix", no_argument, NULL, 'p'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
static char opts[] = "acfhmpvo:";
static char opts[] = "acfhmpVo:";
static void
usage (FILE *where = stderr)
{
char *options;
fprintf (where, "Usage: %s [OPTION] [<win32path> <posixpath>]\n\
%s -a\n\
%s <posixpath>\n\
fprintf (where, "Usage: %1$s [OPTION] [<win32path> <posixpath>]\n\
%1$s -a\n\
%1$s <posixpath>\n\
\n\
Display information about mounted filesystems, or mount a filesystem\n\
\n\
-a, --all mount all filesystems mentioned in fstab\n\
@ -226,8 +229,8 @@ Display information about mounted filesystems, or mount a filesystem\n\
and cygdrive prefixes\n\
-o, --options X[,X...] specify mount options\n\
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix\n\
-v, --version output version information and exit\n\n",
progname, progname, progname);
-V, --version output version information and exit\n\n",
progname);
if (!cygwin_internal (CW_LST_MNT_OPTS, &options))
fprintf (where, "Valid options are: %s\n\n", options);
exit (where == stderr ? 1 : 0);
@ -236,24 +239,15 @@ Display information about mounted filesystems, or mount a filesystem\n\
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-2010 Red Hat, Inc.\n\
Compiled on %s\n\
", progname, len, v, __DATE__);
printf ("mount (cygwin) %d.%d.%d\n"
"Mount filesystem utility\n"
"Copyright (C) 1996 - %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);
}
static char *
@ -279,13 +273,7 @@ main (int argc, char **argv)
saw_mount_all,
} do_what = nada;
progname = strrchr (argv[0], '/');
if (progname == NULL)
progname = strrchr (argv[0], '\\');
if (progname == NULL)
progname = argv[0];
else
progname++;
progname = program_invocation_short_name;
if (argc == 1)
{
@ -334,12 +322,13 @@ main (int argc, char **argv)
else
usage ();
break;
case 'v':
case 'V':
print_version ();
return 0;
break;
default:
usage ();
fprintf (stderr, "Try `%s --help' for more information.\n", progname);
return 1;
}
if (cygwin_internal (CW_CVT_MNT_OPTS, &options, &flags))
@ -350,7 +339,8 @@ main (int argc, char **argv)
if (flags & MOUNT_NOTEXEC && flags & (MOUNT_EXEC | MOUNT_CYGWIN_EXEC))
{
fprintf (stderr, "%s: invalid combination of executable options\n", progname);
fprintf (stderr, "%s: invalid combination of executable options\n",
progname);
exit (1);
}
@ -516,13 +506,13 @@ mount_already_exists (const char *posix_path, int flags)
else
fprintf (stderr,
"%s: warning: user mount point of '%s' "
"masks system mount.\n",
progname, posix_path);
"masks system mount.\n", progname, posix_path);
break;
}
else
{
fprintf (stderr, "%s: warning: couldn't determine mount type.\n", progname);
fprintf (stderr, "%s: warning: couldn't determine mount type.\n",
progname);
break;
}
}

View File

@ -24,6 +24,7 @@ details. */
#include <getopt.h>
#include <pwd.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <sys/types.h>
#include <time.h>
#include <errno.h>
@ -32,7 +33,6 @@ details. */
#define USER_PRIV_ADMIN 2
static const char version[] = "$Revision$";
static char *prog_name;
static struct option longopts[] =
@ -49,7 +49,7 @@ static struct option longopts[] =
{"pwd-not-required", no_argument, NULL, 'p'},
{"pwd-required", no_argument, NULL, 'P'},
{"unlock", no_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{"maxage", required_argument, NULL, 'x'},
{"length", required_argument, NULL, 'L'},
{"status", no_argument, NULL, 'S'},
@ -57,7 +57,7 @@ static struct option longopts[] =
{NULL, 0, NULL, 0}
};
static char opts[] = "cCd:eEhi:ln:pPuvx:L:SR";
static char opts[] = "cCd:eEhi:ln:pPuVx:L:SR";
int
eprint (int with_name, const char *fmt, ...)
@ -255,6 +255,7 @@ usage (FILE * stream, int status)
{
fprintf (stream, ""
"Usage: %s [OPTION] [USER]\n"
"\n"
"Change USER's password or password attributes.\n"
"\n"
"User operations:\n"
@ -286,7 +287,7 @@ usage (FILE * stream, int status)
" -S, --status display password status for USER (locked, expired,\n"
" etc.) plus global system password settings.\n"
" -h, --help output usage information and exit.\n"
" -v, --version output version information and exit.\n"
" -V, --version output version information and exit.\n"
"\n"
"If no option is given, change USER's password. If no user name is given,\n"
"operate on current user. System operations must not be mixed with user\n"
@ -299,9 +300,7 @@ usage (FILE * stream, int status)
"secure. Use this feature only if the machine is adequately locked down.\n"
"Don't use this feature if you don't need network access within a remote\n"
"session. You can delete your stored password by using `passwd -R' and\n"
"specifying an empty password.\n"
"\n"
"Report bugs to <cygwin@cygwin.com>\n", prog_name);
"specifying an empty password.\n\n", prog_name);
exit (status);
}
@ -351,30 +350,21 @@ caller_is_admin ()
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\
Password Utility\n\
Copyright 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.\n\
Compiled on %s\n\
", prog_name, len, v, __DATE__);
printf ("passwd (cygwin) %d.%d.%d\n"
"Password Utility\n"
"Copyright (C) 1999 - %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);
}
int
main (int argc, char **argv)
{
char *c, *logonserver;
char *logonserver;
char user[UNLEN + 1], oldpwd[_PASSWORD_LEN + 1], newpwd[_PASSWORD_LEN + 1];
int ret = 0;
int cnt = 0;
@ -397,16 +387,7 @@ main (int argc, char **argv)
int myself = 0;
LPWSTR server = NULL;
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
else
prog_name++;
c = strrchr (prog_name, '.');
if (c)
*c = '\0';
prog_name = program_invocation_short_name;
/* Use locale from environment. If not set or set to "C", use UTF-8. */
setlocale (LC_CTYPE, "");
@ -500,7 +481,7 @@ main (int argc, char **argv)
Popt = 1;
break;
case 'v':
case 'V':
print_version ();
exit (0);
break;
@ -539,7 +520,8 @@ main (int argc, char **argv)
break;
default:
usage (stderr, 1);
fprintf (stderr, "Try `%s --help' for more information.\n", prog_name);
return 1;
}
if (Ropt)

View File

@ -9,6 +9,7 @@ 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 <wchar.h>
#include <windows.h>
@ -19,6 +20,7 @@ details. */
#include <pwd.h>
#include <limits.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <ddk/ntapi.h>
@ -29,7 +31,6 @@ details. */
for that value. Note that PATH_MAX is only 4K. */
#define NT_MAX_PATH 32768
static const char version[] = "$Revision$";
static char *prog_name;
static struct option longopts[] =
@ -42,12 +43,12 @@ static struct option longopts[] =
{"process", required_argument, NULL, 'p'},
{"summary", no_argument, NULL, 's' },
{"user", required_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{"windows", no_argument, NULL, 'W'},
{NULL, 0, NULL, 0}
};
static char opts[] = "aefhlp:su:vW";
static char opts[] = "aefhlp:su:VW";
typedef BOOL (WINAPI *ENUMPROCESSMODULES)(
HANDLE hProcess, // handle to the process
@ -214,7 +215,8 @@ static void
usage (FILE * stream, int status)
{
fprintf (stream, "\
Usage: %s [-aefls] [-u UID] [-p PID]\n\
Usage: %1$s [-aefls] [-u UID] [-p PID]\n\
\n\
Report process status\n\
\n\
-a, --all show processes of all users\n\
@ -225,34 +227,26 @@ Report process status\n\
-p, --process show information for specified PID\n\
-s, --summary show process summary\n\
-u, --user list processes owned by UID\n\
-v, --version output version information and exit\n\
-V, --version output version information and exit\n\
-W, --windows show windows as well as cygwin processes\n\
With no options, %s outputs the long format by default\n",
prog_name, prog_name);
\n\
With no options, %1$s outputs the long format by default\n\n",
prog_name);
exit (status);
}
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\
Process Statistics\n\
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
Compiled on %s\n\
", prog_name, len, v, __DATE__);
printf ("ps (cygwin) %d.%d.%d\n"
"Show process statistics\n"
"Copyright (C) 1996 - %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);
}
char dosdevs[32000];
@ -278,13 +272,7 @@ main (int argc, char *argv[])
proc_id = -1;
lflag = 1;
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
while ((ch = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
switch (ch)
@ -324,7 +312,7 @@ main (int argc, char *argv[])
}
}
break;
case 'v':
case 'V':
print_version ();
exit (0);
break;
@ -334,7 +322,8 @@ main (int argc, char *argv[])
break;
default:
usage (stderr, 1);
fprintf (stderr, "Try `%s --help' for more information.\n", prog_name);
exit (1);
}
if (sflag)

View File

@ -1,7 +1,7 @@
/* regtool.cc
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009, 2010 Red Hat Inc.
2009, 2010, 2011 Red Hat Inc.
This file is part of Cygwin.
@ -19,6 +19,7 @@ details. */
#define WINVER 0x0502
#include <windows.h>
#include <sys/cygwin.h>
#include <cygwin/version.h>
#include "loadlib.h"
#define DEFAULT_KEY_SEPARATOR '\\'
@ -33,7 +34,6 @@ char key_sep = DEFAULT_KEY_SEPARATOR;
#define LIST_VALS 0x02
#define LIST_ALL (LIST_KEYS | LIST_VALS)
static const char version[] = "$Revision$";
static char *prog_name;
static struct option longopts[] =
@ -95,12 +95,14 @@ usage (FILE *where = stderr)
{
fprintf (where, ""
"Usage: %s [OPTION] ACTION KEY [data...]\n"
"\n"
"View or edit the Win32 registry\n"
"\n", prog_name);
if (where == stdout)
{
fprintf (where, ""
"Actions:\n"
"\n"
" add KEY\\SUBKEY add new SUBKEY\n"
" check KEY exit 0 if KEY exists, 1 if not\n"
" get KEY\\VALUE prints VALUE to stdout\n"
@ -114,16 +116,19 @@ usage (FILE *where = stderr)
"\n");
fprintf (where, ""
"Options for 'list' Action:\n"
"\n"
" -k, --keys print only KEYs\n"
" -l, --list print only VALUEs\n"
" -p, --postfix like ls -p, appends '\\' postfix to KEY names\n"
"\n"
"Options for 'get' Action:\n"
"\n"
" -b, --binary print data as printable hex bytes\n"
" -n, --none print data as stream of bytes as stored in registry\n"
" -x, --hex print numerical data as hex numbers\n"
"\n"
"Options for 'set' Action:\n"
"\n"
" -b, --binary set type to REG_BINARY (hex args or '-')\n"
" -d, --dword set type to REG_DWORD\n"
" -D, --dword-be set type to REG_DWORD_BIG_ENDIAN\n"
@ -135,9 +140,11 @@ usage (FILE *where = stderr)
" -s, --string set type to REG_SZ\n"
"\n"
"Options for 'set' and 'unset' Actions:\n"
"\n"
" -K<c>, --key-separator[=]<c> set key-value separator to <c> instead of '\\'\n"
"\n"
"Other Options:\n"
"\n"
" -h, --help output usage information and exit\n"
" -q, --quiet no error output, just nonzero return if KEY/VALUE missing\n"
" -v, --verbose verbose output, including VALUE contents when applicable\n"
@ -158,37 +165,28 @@ usage (FILE *where = stderr)
"as separator and the backslash can be used as escape character.\n");
fprintf (where, ""
"Example:\n"
"%s list '/machine/SOFTWARE/Classes/MIME/Database/Content Type/audio\\/wav'\n", prog_name);
"%s list '/machine/SOFTWARE/Classes/MIME/Database/Content Type/audio\\/wav'\n\n", prog_name);
}
if (where == stderr)
fprintf (where,
"ACTION is one of add, check, get, list, remove, set, unset, load, unload, save\n"
"\n"
"Try '%s --help' for more information.\n", prog_name);
"Try `%s --help' for more information.\n", prog_name);
exit (where == stderr ? 1 : 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 ("\
%s (cygwin) %.*s\n\
Registry Tool\n\
Copyright 2000-2009 Red Hat, Inc.\n\
Compiled on %s\n\
", prog_name, len, v, __DATE__);
printf ("regtool (cygwin) %d.%d.%d\n"
"Registry tool\n"
"Copyright (C) 2000 - %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);
}
void
@ -907,13 +905,8 @@ main (int argc, char **_argv)
int g;
setlocale (LC_ALL, "");
prog_name = strrchr (_argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (_argv[0], '\\');
if (prog_name == NULL)
prog_name = _argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
while ((g = getopt_long (argc, _argv, opts, longopts, NULL)) != EOF)
switch (g)
@ -978,7 +971,9 @@ main (int argc, char **_argv)
key_sep = *optarg;
break;
default :
usage ();
fprintf (stderr, "Try `%s --help' for more information.\n",
prog_name);
return 1;
}
if ((_argv[optind] == NULL) || (_argv[optind+1] == NULL))

View File

@ -10,6 +10,7 @@ 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 <ctype.h>
#include <string.h>
@ -20,6 +21,7 @@ details. */
#include <grp.h>
#include <sys/types.h>
#include <sys/acl.h>
#include <cygwin/version.h>
#ifndef BOOL
#define BOOL int
@ -37,7 +39,6 @@ details. */
#define ILLEGAL_MODE ((mode_t)0xffffffff)
#endif
static const char version[] = "$Revision$";
static char *prog_name;
typedef enum {
@ -291,6 +292,7 @@ usage (FILE * stream)
fprintf (stream, ""
"Usage: %s [-r] (-f ACL_FILE | -s acl_entries) FILE...\n"
" %s [-r] ([-d acl_entries] [-m acl_entries]) FILE...\n"
"\n"
"Modify file and directory access control lists (ACLs)\n"
"\n"
" -d, --delete delete one or more specified ACL entries\n"
@ -302,11 +304,10 @@ usage (FILE * stream)
" -s, --substitute substitute specified ACL entries for the\n"
" ACL of FILE\n"
" -h, --help output usage information and exit\n"
" -v, --version output version information and exit\n"
" -V, --version output version information and exit\n"
"\n"
"At least one of (-d, -f, -m, -s) must be specified\n"
"\n"
"", prog_name, prog_name);
"\n", prog_name, prog_name);
if (stream == stdout)
{
printf(""
@ -387,7 +388,7 @@ usage (FILE * stream)
"permissions according to the combination of the current umask,\n"
"the explicit permissions requested and the default ACL entries\n"
"Note: Under Cygwin, the default ACL entries are not taken into\n"
"account currently.\n", prog_name);
"account currently.\n\n", prog_name);
}
else
fprintf(stream, "Try '%s --help' for more information.\n", prog_name);
@ -400,31 +401,23 @@ struct option longopts[] = {
{"replace", no_argument, NULL, 'r'},
{"substitute", required_argument, NULL, 's'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{0, no_argument, NULL, 0}
};
const char *opts = "d:f:hm:rs:V";
static void
print_version ()
{
const char *v = strchr (version, ':');
int len;
if (!v)
{
v = "?";
len = 1;
}
else
{
v += 2;
len = strchr (v, ' ') - v;
}
printf ("\
setfacl (cygwin) %.*s\n\
ACL Modification Utility\n\
Copyright 2000, 2001, 2002 Red Hat, Inc.\n\
Compiled on %s\n\
", len, v, __DATE__);
printf ("setfacl (cygwin) %d.%d.%d\n"
"POSIX ACL modification utility\n"
"Copyright (C) 2000 - %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);
}
int
@ -437,16 +430,10 @@ main (int argc, char **argv)
int aclidx = 0;
int ret = 0;
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
memset (acls, 0, sizeof acls);
while ((c = getopt_long (argc, argv, "d:f:hm:rs:v", longopts, NULL)) != EOF)
while ((c = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
switch (c)
{
case 'd':
@ -521,11 +508,11 @@ main (int argc, char **argv)
return 2;
}
break;
case 'v':
case 'V':
print_version ();
return 0;
default:
usage (stderr);
fprintf (stderr, "Try `%s --help' for more information.\n", prog_name);
return 1;
}
if (action == NoAction)

View File

@ -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;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2001, 2002, 2009 Red Hat, Inc.
* Copyright (c) 2000, 2001, 2002, 2009, 2011 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -13,6 +13,7 @@
*
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -21,8 +22,8 @@
#include <ctype.h>
#include <windows.h>
#include <getopt.h>
#include <cygwin/version.h>
static const char version[] = "$Revision$";
static char *prog_name;
static struct option longopts[] =
@ -650,6 +651,7 @@ usage (FILE * stream)
{
fprintf (stream , ""
"Usage: %s [options] low_pc high_pc command...\n"
"\n"
"Single-step profile COMMAND\n"
"\n"
" -c, --console-trace trace every EIP value to the console. *Lots* slower.\n"
@ -798,7 +800,7 @@ usage (FILE * stream)
"spent in each dll the program used. No sense optimizing a function in\n"
"your program if most of the time is spent in the DLL.\n"
"\n"
"I usually use the -v, -s, and -l options:\n"
"Typically use the -v, -s, and -l options:\n"
"\n"
" ssp -v -s -l -d 0x61001000 0x61080000 hello.exe\n"
"\n");
@ -810,24 +812,15 @@ usage (FILE * stream)
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\
Single-Step Profiler\n\
Copyright 2000, 2001, 2002 Red Hat, Inc.\n\
Compiled on %s\n\
", prog_name, len, v, __DATE__);
printf ("ssp (cygwin) %d.%d.%d\n"
"Single-Step Profiler\n"
"Copyright (C) 2000 - %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);
}
int
@ -839,13 +832,7 @@ main (int argc, char **argv)
setbuf (stdout, 0);
prog_name = strrchr (argv[0], '/');
if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
if (prog_name == NULL)
prog_name = argv[0];
else
prog_name++;
prog_name = program_invocation_short_name;
while ((c = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
switch (c)
@ -885,7 +872,8 @@ main (int argc, char **argv)
print_version ();
exit (0);
default:
usage (stderr);
fprintf (stderr, "Try `%s --help' for more information.\n", prog_name);
exit (1);
}
if ( (argc - optind) < 3 )

View File

@ -1,7 +1,7 @@
/* strace.cc
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009, 2010 Red Hat Inc.
2009, 2010, 2011 Red Hat Inc.
Written by Chris Faylor <cgf@redhat.com>
@ -24,6 +24,7 @@ details. */
#include <errno.h>
#include "cygwin/include/sys/strace.h"
#include "cygwin/include/sys/cygwin.h"
#include "cygwin/include/cygwin/version.h"
#include "path.h"
#undef cygwin_internal
#include "loadlib.h"
@ -32,9 +33,6 @@ details. */
/* we *know* we're being built with GCC */
#define alloca __builtin_alloca
// Version string.
static const char version[] = "$Revision$";
static const char *pgm;
static int forkdebug = 1;
static int numerror = 1;
@ -678,7 +676,8 @@ proc_child (unsigned mask, FILE *ofile, pid_t pid)
remove_child (ev.dwProcessId);
break;
case EXCEPTION_DEBUG_EVENT:
if (ev.u.Exception.ExceptionRecord.ExceptionCode != STATUS_BREAKPOINT)
if (ev.u.Exception.ExceptionRecord.ExceptionCode
!= (DWORD) STATUS_BREAKPOINT)
{
status = DBG_EXCEPTION_NOT_HANDLED;
if (ev.u.Exception.dwFirstChance)
@ -850,6 +849,7 @@ usage (FILE *where = stderr)
fprintf (where, "\
Usage: %s [OPTIONS] <command-line>\n\
Usage: %s [OPTIONS] -p <pid>\n\
\n\
Trace system calls and signals\n\
\n\
-b, --buffer-size=SIZE set size of output file buffer\n\
@ -868,7 +868,7 @@ Trace system calls and signals\n\
-T, --toggle toggle tracing in a process already being\n\
traced. Requires -p <pid>\n\
-u, --usecs toggle printing of microseconds timestamp\n\
-v, --version output version information and exit\n\
-V, --version output version information and exit\n\
-w, --new-window spawn program under test in a new window\n\
\n", pgm, pgm);
if ( where == stdout)
@ -903,7 +903,7 @@ Trace system calls and signals\n\
non-checked-in code\n\
");
if (where == stderr)
fprintf (stderr, "Try '%s --help' for more information.\n", pgm);
fprintf (stderr, "Try `%s --help' for more information.\n", pgm);
exit (where == stderr ? 1 : 0 );
}
@ -923,33 +923,24 @@ struct option longopts[] = {
{"trace-children", no_argument, NULL, 'f'},
{"translate-error-numbers", no_argument, NULL, 'n'},
{"usecs", no_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
static const char *const opts = "+b:dhHfm:no:p:qS:tTuvw";
static const char *const opts = "+b:dhHfm:no:p:qS:tTuVw";
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\
System Trace\n\
Copyright 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.\n\
Compiled on %s\n\
", pgm, len, v, __DATE__);
printf ("strace (cygwin) %d.%d.%d\n"
"System Trace\n"
"Copyright (C) 2000 - %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);
}
int
@ -1040,15 +1031,15 @@ character #%d.\n", optarg, (int) (endptr - optarg), endptr);
show_usecs ^= 1;
delta ^= 1;
break;
case 'v':
case 'V':
// Print version info and exit
print_version ();
return 0;
case 'w':
new_window ^= 1;
break;
case '?':
fprintf (stderr, "Try '%s --help' for more information.\n", pgm);
default:
fprintf (stderr, "Try `%s --help' for more information.\n", pgm);
exit (1);
}

View File

@ -1,6 +1,6 @@
/* umount.cc
Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2008 Red Hat, Inc.
Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2008, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -15,33 +15,34 @@ details. */
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <cygwin/version.h>
static void remove_all_user_mounts ();
static const char version[] = "$Revision$";
static const char *progname;
struct option longopts[] =
{
{"help", no_argument, NULL, 'h' },
{"remove-user-mounts", no_argument, NULL, 'U'},
{"version", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
char opts[] = "hUv";
char opts[] = "hUV";
static void
usage (FILE *where = stderr)
{
fprintf (where, "\
Usage: %s [OPTION] [<posixpath>]\n\
\n\
Unmount filesystems\n\
\n\
-h, --help output usage information and exit\n\
-U, --remove-user-mounts remove all user mounts\n\
-v, --version output version information and exit\n\
", progname);
-V, --version output version information and exit\n\
\n", progname);
exit (where == stderr ? 1 : 0);
}
@ -55,24 +56,15 @@ error (const char *path)
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\n\
", progname, len, v, __DATE__);
printf ("umount (cygwin) %d.%d.%d\n"
"Unmount filesystem utility\n"
"Copyright (C) 1996 - %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);
}
int
@ -87,13 +79,7 @@ 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++;
progname = program_invocation_short_name;
if (argc == 1)
usage ();
@ -108,11 +94,12 @@ main (int argc, char **argv)
usage ();
do_what = saw_remove_all_user_mounts;
break;
case 'v':
case 'V':
print_version ();
exit (0);
default:
usage ();
fprintf (stderr, "Try `%s --help' for more information.\n", progname);
exit (1);
}
switch (do_what)

View File

@ -25,6 +25,7 @@ Usage: cygcheck [-v] [-h] PROGRAM
cygcheck --disable-unique-object-names Cygwin-DLL
cygcheck --show-unique-object-names Cygwin-DLL
cygcheck -h
List system information, check installed packages, or query package database.
At least one command option or a PROGRAM is required, as shown above.
@ -270,16 +271,20 @@ Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME...
cygpath [-c HANDLE]
cygpath [-ADHOPSW]
cygpath [-F ID]
Convert Unix and Windows format paths, or output system path information
Output type options:
-d, --dos print DOS (short) form of NAMEs (C:\PROGRA~1\)
-m, --mixed like --windows, but with regular slashes (C:/WINNT)
-M, --mode report on mode of file (currently binmode or textmode)
-u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt)
-w, --windows print Windows form of NAMEs (C:\WINNT)
-t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows'
Path conversion options:
-a, --absolute output absolute path
-l, --long-name print Windows long form of NAMEs (with -w, -m only)
-p, --path NAME is a PATH list (i.e., '/bin:/usr/bin')
@ -289,7 +294,9 @@ Path conversion options:
or one of the reserved words ANSI, OEM, or UTF8.
If this option is missing, cygpath defaults to the
character set defined by the current locale.
System information:
-A, --allusers use `All Users' instead of current user for -D, -P
-D, --desktop output `Desktop' directory and exit
-H, --homeroot output `Profiles' directory (home root) and exit
@ -298,13 +305,15 @@ System information:
-S, --sysdir output system directory and exit
-W, --windir output `Windows' directory and exit
-F, --folder ID output special folder with numeric ID and exit
Other options:
-f, --file FILE read FILE for input; use - to read from STDIN
-o, --option read options from FILE as well (for use with --file)
-c, --close HANDLE close HANDLE (for use in captured process)
-i, --ignore ignore missing argument
-h, --help output usage information and exit
-v, --version output version information and exit
-V, --version output version information and exit
</screen>
<para>The <command>cygpath</command> program is a utility that
@ -410,12 +419,13 @@ other formats.</para>
<screen>
Usage: dumper [OPTION] FILENAME WIN32PID
Dump core from WIN32PID to FILENAME.core
-d, --verbose be verbose while dumping
-h, --help output help information and exit
-q, --quiet be quiet while dumping (default)
-v, --version output version information and exit
-V, --version output version information and exit
</screen>
<para>The <command>dumper</command> utility can be used to create a
@ -454,10 +464,43 @@ the same directories as on the machine where the core dump was created.
</sect2>
<sect2 id="getconf"><title>getconf</title>
<screen>
Usage: getconf [-v specification] variable_name [pathname]
getconf -a [pathname]
Get configuration values
-v specification Indicate specific version for which configuration
values shall be fetched.
-a, --all Print all known configuration values
Other options:
-h, --help This text
-V, --version Print program version and exit
</screen>
<para>The <command>getconf</command> utility prints the value of the
configuration variable specified by <literal>variable_name</literal>.
If <literal>pathname</literal> is given, <command>getconf</command> prints
the value of the configuration variable for the specified pathname.</para>
<para>If you specify the <literal>-v</literal> option, the parameter
denotes a specification for which the value of the configuration variable
should be printed.</para>
<para>Use the <literal>-a</literal> option to print a list of all available
configuration variables.</para>
</sect2>
<sect2 id="getfacl"><title>getfacl</title>
<screen>
Usage: getfacl [-adn] FILE [FILE2...]
Display file and directory access control lists (ACLs).
-a, --all display the filename, the owner, the group, and
@ -466,7 +509,7 @@ Display file and directory access control lists (ACLs).
the default ACL of the directory, if it exists
-h, --help output usage information and exit
-n, --noname display user and group IDs instead of names
-v, --version output version information and exit
-V, --version output version information and exit
When multiple files are specified on the command line, a blank
line separates the ACLs for each file.
@ -506,13 +549,14 @@ The format for ACL output is as follows:
<screen>
Usage: kill [-f] [-signal] [-s signal] pid1 [pid2 ...]
kill -l [signal]
Send signals to processes
-f, --force force, using win32 interface if necessary
-l, --list print a list of signal names
-s, --signal send signal (use kill --list for a list)
-h, --help output usage information and exit
-v, --version output version information and exit
-V, --version output version information and exit
</screen>
<para>The <command>kill</command> program allows you to send arbitrary
@ -603,12 +647,35 @@ SIGUSR2 31 user defined signal 2
</sect2>
<sect2 id="ldd"><title>ldd</title>
<screen>
Usage: ldd [OPTION]... FILE...
Print shared library dependencies
-h, --help print this help and exit
-V, --version print version information and exit
-r, --function-relocs process data and function relocations
(currently unimplemented)
-u, --unused print unused direct dependencies
(currently unimplemented)
-v, --verbose print all information
(currently unimplemented)
</screen>
<para><command>ldd</command> prints the shared libraries (DLLs) an executable
or DLL is linked against. No modifying option is implemented yet.</para>
</sect2>
<sect2 id="locale"><title>locale</title>
<screen>
Usage: locale [-amvhV]
or: locale [-ck] NAME
or: locale [-usfnU]
Get locale-specific information.
System information:
@ -754,9 +821,11 @@ bash$ locale noexpr
<screen>
Usage: mkgroup [OPTION]...
Print /etc/group file to stdout
Options:
-l,--local [machine[,offset]]
print local groups with gid offset offset
(from local machine if no machine specified)
@ -785,7 +854,7 @@ Options:
-s,--no-sids (ignored)
-u,--users (ignored)
-h,--help print this message
-v,--version print version information and exit
-V,--version print version information and exit
Default is to print local groups on stand-alone machines, plus domain
groups on domain controllers and domain member machines.
@ -849,9 +918,11 @@ up as a group in <command>ls -l</command> output.
<screen>
Usage: mkpasswd [OPTIONS]...
Print /etc/passwd file to stdout
Options:
-l,--local [machine[,offset]]
print local user accounts with uid offset offset
(from local machine if no machine specified)
@ -882,7 +953,7 @@ Options:
-s,--no-sids (ignored)
-g,--local-groups (ignored)
-h,--help displays this message
-v,--version version information and exit
-V,--version version information and exit
Default is to print local accounts on stand-alone machines, domain accounts
on domain controllers and domain member machines.
@ -958,6 +1029,7 @@ up as file owners in <command>ls -l</command> output.
Usage: mount [OPTION] [&lt;win32path&gt; &lt;posixpath&gt;]
mount -a
mount &lt;posixpath&gt;
Display information about mounted filesystems, or mount a filesystem
-a, --all mount all filesystems mentioned in fstab
@ -969,7 +1041,7 @@ Display information about mounted filesystems, or mount a filesystem
and cygdrive prefixes
-o, --options X[,X...] specify mount options
-p, --show-cygdrive-prefix show user and/or system cygdrive path prefix
-v, --version output version information and exit
-V, --version output version information and exit
</screen>
<para>The <command>mount</command> program is used to map your drives
@ -1166,9 +1238,10 @@ automounted filesystems default to this set of options. For instance
<sect3 id="utils-limitations"><title>Limitations</title>
<para>Limitations: there is a hard-coded limit of 30 mount
points. Also, although you can mount to pathnames that do not start
with "/", there is no way to make use of such mount points.</para>
<para>Limitations: there is a hard-coded limit of 64 mount points
(up to Cygwin 1.7.9: 30 mount points). Also, although you can mount
to pathnames that do not start with "/", there is no way to make use
of such mount points.</para>
<para>Normally the POSIX mount point in Cygwin is an existing empty
directory, as in standard UNIX. If this is the case, or if there is a
@ -1204,6 +1277,7 @@ find <filename>mtpt</filename>.
<screen>
Usage: passwd [OPTION] [USER]
Change USER's password or password attributes.
User operations:
@ -1235,7 +1309,7 @@ Other options:
-S, --status display password status for USER (locked, expired,
etc.) plus global system password settings.
-h, --help output usage information and exit.
-v, --version output version information and exit.
-V, --version output version information and exit.
If no option is given, change USER's password. If no user name is given,
operate on current user. System operations must not be mixed with user
@ -1352,6 +1426,7 @@ some systems.</para>
<screen>
Usage: ps [-aefls] [-u UID]
Report process status
-a, --all show processes of all users
@ -1362,7 +1437,7 @@ Report process status
-p, --process show information for specified PID
-s, --summary show process summary
-u, --user list processes owned by UID
-v, --version output version information and exit
-V, --version output version information and exit
-W, --windows show windows as well as cygwin processes
With no options, ps outputs the long format by default
</screen>
@ -1413,9 +1488,11 @@ option.
<screen>
Usage: regtool [OPTION] (add|check|get|list|remove|unset|load|unload|save) KEY
View or edit the Win32 registry
Actions:
add KEY\SUBKEY add new SUBKEY
check KEY exit 0 if KEY exists, 1 if not
get KEY\VALUE prints VALUE to stdout
@ -1428,16 +1505,19 @@ Actions:
save KEY\SUBKEY PATH save SUBKEY into new hive PATH
Options for 'list' Action:
-k, --keys print only KEYs
-l, --list print only VALUEs
-p, --postfix like ls -p, appends '\' postfix to KEY names
Options for 'get' Action:
-b, --binary print REG_BINARY data as hex bytes
-n, --none print data as stream of bytes as stored in registry
-x, --hex print numerical data as hex numbers
Options for 'set' Action:
-b, --binary set type to REG_BINARY (hex args or '-')
-D, --dword-be set type to REG_DWORD_BIG_ENDIAN
-e, --expand-string set type to REG_EXPAND_SZ
@ -1448,9 +1528,11 @@ Options for 'set' Action:
-s, --string set type to REG_SZ
Options for 'set' and 'unset' Actions:
-K&lt;c&gt;, --key-separator[=]&lt;c&gt; set key separator to &lt;c&gt; instead of '\'
Other Options:
-h, --help output usage information and exit
-q, --quiet no error output, just nonzero return if KEY/VALUE missing
-v, --verbose verbose output, including VALUE contents when applicable
@ -1579,6 +1661,7 @@ an alternate key/value separator character.
<screen>
Usage: setfacl [-r] (-f ACL_FILE | -s acl_entries) FILE...
setfacl [-r] ([-d acl_entries] [-m acl_entries]) FILE...
Modify file and directory access control lists (ACLs)
-d, --delete delete one or more specified ACL entries
@ -1590,7 +1673,7 @@ Modify file and directory access control lists (ACLs)
-s, --substitute substitute specified ACL entries for the
ACL of FILE
-h, --help output usage information and exit
-v, --version output version information and exit
-V, --version output version information and exit
At least one of (-d, -f, -m, -s) must be specified
</screen>
@ -1724,10 +1807,33 @@ account currently.
</sect2>
<sect2 id="setmetamode"><title>setmetamode</title>
<screen>
Usage: setmetamode [metabit|escprefix]
Get or set keyboard meta mode
Without argument, it shows the current meta key mode.
metabit|meta|bit The meta key sets the top bit of the character.
escprefix|esc|prefix The meta key sends an escape prefix.
Other options:
-h, --help This text
-V, --version Print program version and exit
</screen>
<para><command>setmetamode</command> can be used to determine and set the
key code sent by the meta (aka <literal>Alt</literal>) key.</para>
</sect2>
<sect2 id="ssp"><title>ssp</title>
<screen>
Usage: ssp [options] low_pc high_pc command...
Single-step profile COMMAND
-c, --console-trace trace every EIP value to the console. *Lots* slower.
@ -1925,6 +2031,7 @@ $ ssp <literal>-v</literal> <literal>-s</literal> <literal>-l</literal> <literal
<screen>
Usage: strace.exe [OPTIONS] &lt;command-line&gt;
Usage: strace.exe [OPTIONS] -p &lt;pid&gt;
Trace system calls and signals
-b, --buffer-size=SIZE set size of output file buffer
@ -1944,7 +2051,7 @@ Trace system calls and signals
-T, --toggle toggle tracing in a process already being
traced. Requires -p &lt;pid&gt;
-u, --usecs toggle printing of microseconds timestamp
-v, --version output version information and exit
-V, --version output version information and exit
-w, --new-window spawn program under test in a new window
MASK can be any combination of the following mnemonics and/or hex values
@ -2002,11 +2109,12 @@ This program is mainly useful for debugging the Cygwin DLL itself.</para>
<screen>
Usage: umount.exe [OPTION] [&lt;posixpath&gt;]
Unmount filesystems
-h, --help output usage information and exit
-U, --remove-user-mounts remove all user mounts
-v, --version output version information and exit
-V, --version output version information and exit
</screen>
<para>The <command>umount</command> program removes mounts from the