* 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:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user