Cleanup formatting on some files. Remove excessive whitespace.

This commit is contained in:
Christopher Faylor 2000-10-28 05:00:00 +00:00
parent 3c952fed3f
commit eedc36cb12
15 changed files with 753 additions and 675 deletions

View File

@ -65,7 +65,7 @@ MINGW_DEP_LDLIBS:=${ALL_DEP_LDLIBS} ${MINGW_LIB}
ALL_LDFLAGS:=-B$(newlib_build)/libc/ -B$(newlib_build)/libm/ -B$(w32api_lib)/ \
$(LDFLAGS) $(ALL_LDLIBS)
MINGW_LDFLAGS:=$(ALL_LDFLAGS) $(MINGW_LIB)
DUMPER_LDFLAGS:=$(ALL_LDFLAGS) $(DUMPER_LIB)
DUMPER_LDFLAGS:=$(ALL_LDFLAGS) $(DUMPER_LIB)
PROGS:=mount$(EXEEXT) umount$(EXEEXT) ps$(EXEEXT) kill$(EXEEXT) \
mkpasswd$(EXEEXT) mkgroup$(EXEEXT) cygpath$(EXEEXT) cygcheck$(EXEEXT) \

View File

@ -1,8 +1,8 @@
dnl Autoconf configure script for Cygwin utilities.
dnl Copyright 1996, 1997 Cygnus Solutions.
dnl Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
dnl
dnl This file is part of Cygwin.
dnl
dnl
dnl This software is a copyrighted work licensed under the terms of the
dnl Cygwin license. Please consult the file "CYGWIN_LICENSE" for
dnl details.

View File

@ -29,8 +29,7 @@ typedef long long longlong;
typedef __int64 longlong;
#endif
const char *known_env_vars[] =
{
const char *known_env_vars[] = {
"c_include_path",
"compiler_path",
"cxx_include_path",
@ -55,21 +54,45 @@ const char *known_env_vars[] =
0
};
struct {
struct
{
const char *name;
int missing_is_good;
} common_apps[] = {
{ "bash", 0 },
{ "cat", 0 },
{ "cpp", 1 },
{ "find", 0 },
{ "gcc", 0 },
{ "gdb", 0 },
{ "ld", 0 },
{ "ls", 0 },
{ "make", 0 },
{ "sh", 0 },
{ 0, 0 }
}
common_apps[] =
{
{
"bash", 0}
,
{
"cat", 0}
,
{
"cpp", 1}
,
{
"find", 0}
,
{
"gcc", 0}
,
{
"gdb", 0}
,
{
"ld", 0}
,
{
"ls", 0}
,
{
"make", 0}
,
{
"sh", 0}
,
{
0, 0}
};
int num_paths = 0, max_paths = 0;
@ -102,8 +125,8 @@ void
init_paths ()
{
char tmp[4000], *sl;
add_path ((char *) ".", 1); /* to be replaced later */
add_path ((char *) ".", 1); /* the current directory */
add_path ((char *) ".", 1); /* to be replaced later */
add_path ((char *) ".", 1); /* the current directory */
GetSystemDirectory (tmp, 4000);
add_path (tmp, strlen (tmp));
sl = strrchr (tmp, '\\');
@ -148,7 +171,7 @@ find_on_path (char *file, char *default_extension,
return file;
if (strchr (file, '.'))
default_extension = (char *)"";
default_extension = (char *) "";
for (int i = 0; i < num_paths; i++)
{
@ -263,13 +286,13 @@ struct ExpDirectory
};
struct ImpDirectory
{
unsigned characteristics;
unsigned timestamp;
unsigned forwarder_chain;
unsigned name_rva;
unsigned iat_rva;
};
{
unsigned characteristics;
unsigned timestamp;
unsigned forwarder_chain;
unsigned name_rva;
unsigned iat_rva;
};
void track_down (char *file, char *suffix, int lvl);
@ -299,9 +322,9 @@ cygwin_info (HANDLE h)
major = minor = NULL;
while (buf < bufend)
if ((buf = (char *) memchr (buf, '%', bufend - buf)) == NULL)
break;
break;
else if (strncmp ("%%% Cygwin ", buf, CYGPREFIX) != 0)
buf++;
buf++;
else
{
char *p = strchr (buf += CYGPREFIX, '\n');
@ -339,8 +362,10 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse)
int nsections = get_word (fh, pe_header_offset + 4 + 2);
char *sections = (char *) malloc (nsections * 40);
SetFilePointer (fh, pe_header_offset + 4 + 20 + get_word (fh, pe_header_offset + 4 + 16),
0, FILE_BEGIN);
SetFilePointer (fh,
pe_header_offset + 4 + 20 + get_word (fh,
pe_header_offset + 4 +
16), 0, FILE_BEGIN);
ReadFile (fh, sections, nsections * 40, &junk, 0);
if (verbose && num_entries >= 1 && export_size > 0)
@ -436,8 +461,9 @@ track_down (char *file, char *suffix, int lvl)
printf ("%s", path);
HANDLE fh = CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE fh =
CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (fh == INVALID_HANDLE_VALUE)
{
printf (" - Cannot open\n");
@ -462,8 +488,7 @@ ls (char *f)
FileTimeToSystemTime (&info.ftLastWriteTime, &systime);
printf ("%5dk %04d/%02d/%02d %s",
(((int) info.nFileSizeLow) + 512) / 1024,
systime.wYear, systime.wMonth, systime.wDay,
f);
systime.wYear, systime.wMonth, systime.wDay, f);
dll_info (f, h, 16, 0);
CloseHandle (h);
@ -498,11 +523,11 @@ cygcheck (char *app)
extern char **environ;
struct RegInfo
{
RegInfo *prev;
char *name;
HKEY key;
};
{
RegInfo *prev;
char *name;
HKEY key;
};
void
show_reg (RegInfo * ri, int nest)
@ -538,8 +563,7 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
#if 0
char tmp[400];
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), tmp,
400, 0);
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), tmp, 400, 0);
printf ("RegQueryInfoKey: %s\n", tmp);
#endif
return;
@ -574,16 +598,6 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
break;
}
}
#if 0
else
{
char tmp[400];
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), tmp,
400, 0);
printf ("RegEnumValue: %s\n", tmp);
}
#endif
}
free (value_name);
free (value_data);
@ -592,7 +606,8 @@ scan_registry (RegInfo * prev, HKEY hKey, char *name, int cygnus)
char *subkey_name = (char *) malloc (max_subkey_len + 1);
for (i = 0; i < num_subkeys; i++)
{
if (RegEnumKey (hKey, i, subkey_name, max_subkey_len + 1) == ERROR_SUCCESS)
if (RegEnumKey (hKey, i, subkey_name, max_subkey_len + 1) ==
ERROR_SUCCESS)
{
HKEY sKey;
if (RegOpenKeyEx (hKey, subkey_name, 0, KEY_ALL_ACCESS, &sKey)
@ -746,13 +761,14 @@ dump_sysinfo ()
printf ("Listing available drives...\n");
printf ("Drv Type Size Free Flags Name\n");
}
int prev_mode = SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
int prev_mode =
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
int drivemask = GetLogicalDrives ();
HINSTANCE k32 = LoadLibrary ("kernel32.dll");
BOOL (WINAPI *gdfse) (LPCSTR, long long *, long long *, long long *) =
BOOL (WINAPI * gdfse) (LPCSTR, long long *, long long *, long long *) =
(BOOL (WINAPI *) (LPCSTR, long long *, long long *, long long *))
GetProcAddress (k32, "GetDiskFreeSpaceExA");
GetProcAddress (k32, "GetDiskFreeSpaceExA");
for (i = 0; i < 26; i++)
{
@ -790,8 +806,7 @@ dump_sysinfo ()
int percent_full = -1;
long long free_me = 0ULL, free_bytes = 0ULL, total_bytes = 1ULL;
if (gdfse != NULL
&& gdfse (drive, & free_me, & total_bytes, & free_bytes))
if (gdfse != NULL && gdfse (drive, &free_me, &total_bytes, &free_bytes))
{
capacity_mb = total_bytes / (1024L * 1024L);
percent_full = 100 - (int) ((100.0 * free_me) / total_bytes);
@ -834,7 +849,8 @@ dump_sysinfo ()
{
printf ("fd=floppy, hd=hard drive, cd=CD-ROM, net=Network Share\n");
printf ("CP=Case Preserving, CS=Case Sensitive, UN=Unicode\n");
printf ("PA=Persistent ACLS, FC=File Compression, VC=Volume Compression\n");
printf
("PA=Persistent ACLS, FC=File Compression, VC=Volume Compression\n");
}
printf ("\n");
@ -842,10 +858,9 @@ dump_sysinfo ()
if (givehelp)
{
printf ("Mount entries: these map POSIX directories to your NT drives.\n");
printf ("%-*s %-*s %-*s %s\n",
ml_fsname, "-NT-",
ml_dir, "-POSIX-",
printf
("Mount entries: these map POSIX directories to your NT drives.\n");
printf ("%-*s %-*s %-*s %s\n", ml_fsname, "-NT-", ml_dir, "-POSIX-",
ml_type, "-Type-", "-Flags-");
}
@ -856,24 +871,23 @@ dump_sysinfo ()
{
printf ("%-*s %-*s %-*s %s\n",
ml_fsname, mnt->mnt_fsname,
ml_dir, mnt->mnt_dir,
ml_type, mnt->mnt_type,
mnt->mnt_opts);
ml_dir, mnt->mnt_dir, ml_type, mnt->mnt_type, mnt->mnt_opts);
}
printf ("\n");
add_path ((char *) "\\bin", 4); /* just in case */
if (givehelp)
printf ("Looking to see where common programs can be found, if at all...\n");
printf
("Looking to see where common programs can be found, if at all...\n");
for (i = 0; common_apps[i].name; i++)
if (!find_on_path ((char *) common_apps[i].name, (char *) ".exe", 1, 0))
{
if (common_apps[i].missing_is_good)
printf ("Not Found: %s (good!)\n", common_apps[i].name);
else
printf ("Not Found: %s\n", common_apps[i].name);
}
{
if (common_apps[i].missing_is_good)
printf ("Not Found: %s (good!)\n", common_apps[i].name);
else
printf ("Not Found: %s\n", common_apps[i].name);
}
printf ("\n");
if (givehelp)
@ -922,8 +936,8 @@ int
check_keys ()
{
HANDLE h = CreateFileA ("CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE || h == NULL)
return keyeprint ("Opening CONIN$");
@ -936,7 +950,7 @@ check_keys ()
{
mode &= ~ENABLE_PROCESSED_INPUT;
if (!SetConsoleMode (h, mode))
keyeprint ("GetConsoleMode");
keyeprint ("GetConsoleMode");
}
fputs ("\nThis key check works only in a console window,", stderr);
@ -955,70 +969,74 @@ check_keys ()
{
prev_in = in;
if (!ReadConsoleInput (h, &in, 1, &mode))
keyeprint ("ReadConsoleInput");
keyeprint ("ReadConsoleInput");
if (!memcmp (&in, &prev_in, sizeof in))
continue;
continue;
switch (in.EventType)
{
case KEY_EVENT:
printf ("%s %ux VK: 0x%02x VS: 0x%02x A: 0x%02x CTRL: ",
in.Event.KeyEvent.bKeyDown ? "Pressed " : "Released",
in.Event.KeyEvent.wRepeatCount,
in.Event.KeyEvent.wVirtualKeyCode,
in.Event.KeyEvent.wVirtualScanCode,
(unsigned char) in.Event.KeyEvent.uChar.AsciiChar);
fputs (in.Event.KeyEvent.dwControlKeyState & CAPSLOCK_ON ?
"CL " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY ?
"EK " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED ?
"LA " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & LEFT_CTRL_PRESSED ?
"LC " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & NUMLOCK_ON ?
"NL " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & RIGHT_ALT_PRESSED ?
"RA " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & RIGHT_CTRL_PRESSED ?
"RC " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & SCROLLLOCK_ON ?
"SL " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED ?
"SH " : "-- ", stdout);
fputc ('\n', stdout);
break;
{
case KEY_EVENT:
printf ("%s %ux VK: 0x%02x VS: 0x%02x A: 0x%02x CTRL: ",
in.Event.KeyEvent.bKeyDown ? "Pressed " : "Released",
in.Event.KeyEvent.wRepeatCount,
in.Event.KeyEvent.wVirtualKeyCode,
in.Event.KeyEvent.wVirtualScanCode,
(unsigned char) in.Event.KeyEvent.uChar.AsciiChar);
fputs (in.Event.KeyEvent.dwControlKeyState & CAPSLOCK_ON ?
"CL " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY ?
"EK " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED ?
"LA " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & LEFT_CTRL_PRESSED ?
"LC " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & NUMLOCK_ON ?
"NL " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & RIGHT_ALT_PRESSED ?
"RA " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & RIGHT_CTRL_PRESSED ?
"RC " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & SCROLLLOCK_ON ?
"SL " : "-- ", stdout);
fputs (in.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED ?
"SH " : "-- ", stdout);
fputc ('\n', stdout);
break;
}
}
}
while (in.EventType != KEY_EVENT ||
in.Event.KeyEvent.bKeyDown != FALSE ||
in.Event.KeyEvent.uChar.AsciiChar != 'q');
in.Event.KeyEvent.bKeyDown != FALSE ||
in.Event.KeyEvent.uChar.AsciiChar != 'q');
CloseHandle (h);
return 0;
}
void
usage ()
{
fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
fprintf (stderr, " -s, --sysinfo = system information (not with -k)\n");
fprintf (stderr, " -v, --verbose = verbose output (indented) (for -s or programs)\n");
fprintf (stderr,
" -v, --verbose = verbose output (indented) (for -s or programs)\n");
fprintf (stderr, " -r, --registry = registry search (requires -s)\n");
fprintf (stderr, " -k, --keycheck = perform a keyboard check session (not with -s)\n");
fprintf (stderr,
" -k, --keycheck = perform a keyboard check session (not with -s)\n");
fprintf (stderr, " -h, --help = give help about the info\n");
fprintf (stderr, "You must at least give either -s or -k or a program name\n");
fprintf (stderr,
"You must at least give either -s or -k or a program name\n");
exit (1);
}
struct option longopts[] = {
{ "sysinfo", no_argument, NULL, 's' },
{ "registry", no_argument, NULL, 'r' },
{ "verbose", no_argument, NULL, 'v' },
{ "keycheck", no_argument, NULL, 'k' },
{ "help", no_argument, NULL, 'h' },
{ 0, no_argument, NULL, 0 }
{"sysinfo", no_argument, NULL, 's'},
{"registry", no_argument, NULL, 'r'},
{"verbose", no_argument, NULL, 'v'},
{"keycheck", no_argument, NULL, 'k'},
{"help", no_argument, NULL, 'h'},
{0, no_argument, NULL, 0}
};
char *opts = "srvkh";
@ -1031,24 +1049,23 @@ main (int argc, char **argv)
switch (i)
{
case 's':
sysinfo = 1;
break;
sysinfo = 1;
break;
case 'r':
registry = 1;
break;
registry = 1;
break;
case 'v':
verbose = 1;
break;
verbose = 1;
break;
case 'k':
keycheck = 1;
break;
keycheck = 1;
break;
case 'h':
givehelp = 1;
break;
givehelp = 1;
break;
default:
usage ();
/*NOTREACHED*/
}
usage ();
/*NOTREACHED*/}
argc -= optind;
argv += optind;
@ -1059,7 +1076,7 @@ main (int argc, char **argv)
usage ();
if (keycheck)
return check_keys();
return check_keys ();
init_paths ();
@ -1067,12 +1084,14 @@ main (int argc, char **argv)
{
if (argc == 1)
{
printf ("Here is where the OS will find your program, and which dlls\n");
printf
("Here is where the OS will find your program, and which dlls\n");
printf ("will be used for it. Use -v to see DLL version info\n");
}
else
{
printf ("Here is where the OS will find your programs, and which dlls\n");
printf
("Here is where the OS will find your programs, and which dlls\n");
printf ("will be used for them. Use -v to see DLL version info\n");
}

View File

@ -52,13 +52,13 @@ Usage: %s [-p|--path] (-u|--unix)|(-w|--windows [-s|--short-name]) filename\n\
-a|--absolute output absolute path\n\
-c|--close handle close handle (for use in captured process)\n\
-f|--file file read file for path information\n\
-u|--unix print Unix form of filename\n\
-w|--windows print Windows form of filename\n\
-u|--unix print Unix form of filename\n\
-w|--windows print Windows form of filename\n\
-s|--short-name print Windows short form of filename\n\
-W|--windir print `Windows' directory\n\
-S|--sysdir print `system' directory\n\
-p|--path filename argument is a path\n\
-i|--ignore ignore missing argument\n",
-W|--windir print `Windows' directory\n\
-S|--sysdir print `system' directory\n\
-p|--path filename argument is a path\n\
-i|--ignore ignore missing argument\n",
prog_name);
exit (ignore_flag ? 0 : status);
}

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@
#include <sys/acl.h>
#include <sys/stat.h>
char *permstr (mode_t perm)
char *
permstr (mode_t perm)
{
static char pbuf[4];
@ -20,7 +21,8 @@ char *permstr (mode_t perm)
}
#if 0
char *username (uid_t uid)
char *
username (uid_t uid)
{
static char ubuf[256];
struct passwd *pw;
@ -31,7 +33,8 @@ char *username (uid_t uid)
strcpy (ubuf, "<unknown>");
}
char *groupname (gid_t gid)
char *
groupname (gid_t gid)
{
static char gbuf[256];
struct group *gr;
@ -58,67 +61,66 @@ main (int argc, char **argv)
switch (c)
{
case 'a':
aopt = 1;
break;
aopt = 1;
break;
case 'd':
dopt = 1;
break;
dopt = 1;
break;
default:
fprintf (stderr, "usage: %s [-ad] file...\n", argv[0]);
return 1;
fprintf (stderr, "usage: %s [-ad] file...\n", argv[0]);
return 1;
}
while ((c = optind++) < argc)
{
if (stat (argv[c], &st))
{
perror (argv[0]);
continue;
}
if (! first)
putchar ('\n');
{
perror (argv[0]);
continue;
}
if (!first)
putchar ('\n');
first = 0;
printf ("# file: %s\n", argv[c]);
printf ("# owner: %d\n", st.st_uid);
printf ("# group: %d\n", st.st_gid);
if ((c = acl (argv[c], GETACL, MAX_ACL_ENTRIES, acls)) < 0)
{
perror (argv[0]);
continue;
}
{
perror (argv[0]);
continue;
}
for (i = 0; i < c; ++i)
{
if (acls[i].a_type & ACL_DEFAULT)
{
if (aopt)
continue;
printf ("default:");
}
else if (dopt)
continue;
switch (acls[i].a_type & ~ACL_DEFAULT)
{
case USER_OBJ:
printf ("user::");
break;
case USER:
printf ("user:%d:", acls[i].a_id);
break;
case GROUP_OBJ:
printf ("group::");
break;
case GROUP:
printf ("group:%d:", acls[i].a_id);
break;
case CLASS_OBJ:
printf ("mask::");
break;
case OTHER_OBJ:
printf ("other::");
break;
}
printf ("%s\n", permstr (acls[i].a_perm));
}
{
if (acls[i].a_type & ACL_DEFAULT)
{
if (aopt)
continue;
printf ("default:");
}
else if (dopt)
continue;
switch (acls[i].a_type & ~ACL_DEFAULT)
{
case USER_OBJ:
printf ("user::");
break;
case USER:
printf ("user:%d:", acls[i].a_id);
break;
case GROUP_OBJ:
printf ("group::");
break;
case GROUP:
printf ("group:%d:", acls[i].a_id);
break;
case CLASS_OBJ:
printf ("mask::");
break;
case OTHER_OBJ:
printf ("other::");
break;
}
printf ("%s\n", permstr (acls[i].a_perm));
}
}
return 0;
}

View File

@ -42,7 +42,7 @@ put_sid (PSID sid)
return s;
}
void
void
psx_dir (char *in, char *out)
{
if (isalpha (in[0]) && in[1] == ':')
@ -65,7 +65,7 @@ psx_dir (char *in, char *out)
*out = '\0';
}
void
void
uni2ansi (LPWSTR wcs, char *mbs)
{
if (wcs)
@ -75,7 +75,7 @@ uni2ansi (LPWSTR wcs, char *mbs)
*mbs = '\0';
}
int
int
enum_users (LPWSTR servername, int print_sids, int print_cygpath)
{
USER_INFO_3 *buffer;
@ -191,7 +191,7 @@ enum_users (LPWSTR servername, int print_sids, int print_cygpath)
return 0;
}
int
int
enum_local_groups (int print_sids)
{
LOCALGROUP_INFO_0 *buffer;
@ -277,7 +277,7 @@ enum_local_groups (int print_sids)
return 0;
}
void
void
usage ()
{
fprintf (stderr, "\n");
@ -296,7 +296,7 @@ usage ()
exit (1);
}
int
int
main (int argc, char **argv)
{
LPWSTR servername = NULL;

View File

@ -17,94 +17,96 @@ details. */
static int psapi_loaded = 0;
static HMODULE psapi_module_handle = NULL;
typedef BOOL WINAPI (tf_EnumProcessModules ) ( HANDLE, HMODULE*, DWORD, LPDWORD );
typedef BOOL WINAPI (tf_GetModuleInformation) ( HANDLE, HMODULE, LPMODULEINFO, DWORD );
typedef DWORD WINAPI (tf_GetModuleFileNameExA) ( HANDLE, HMODULE, LPSTR, DWORD );
typedef BOOL WINAPI (tf_EnumProcessModules) (HANDLE, HMODULE *, DWORD,
LPDWORD);
typedef BOOL WINAPI (tf_GetModuleInformation) (HANDLE, HMODULE, LPMODULEINFO,
DWORD);
typedef DWORD WINAPI (tf_GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR,
DWORD);
static tf_EnumProcessModules *psapi_EnumProcessModules = NULL;
static tf_GetModuleInformation *psapi_GetModuleInformation = NULL;
static tf_GetModuleFileNameExA *psapi_GetModuleFileNameExA = NULL;
/*
* Returns full name of Dll, which is loaded by hProcess at BaseAddress
* Uses psapi.dll
*/
/* Returns full name of Dll, which is loaded by hProcess at BaseAddress.
Uses psapi.dll. */
char*
psapi_get_module_name ( HANDLE hProcess, DWORD BaseAddress )
char *
psapi_get_module_name (HANDLE hProcess, DWORD BaseAddress)
{
DWORD len;
MODULEINFO mi;
unsigned int i;
HMODULE dh_buf [ 1 ];
HMODULE* DllHandle = dh_buf;
HMODULE dh_buf[1];
HMODULE *DllHandle = dh_buf;
DWORD cbNeeded;
BOOL ok;
char name_buf [ MAX_PATH + 1 ];
char name_buf[MAX_PATH + 1];
if ( !psapi_loaded ||
psapi_EnumProcessModules == NULL ||
psapi_GetModuleInformation == NULL ||
psapi_GetModuleFileNameExA == NULL )
if (!psapi_loaded ||
psapi_EnumProcessModules == NULL ||
psapi_GetModuleInformation == NULL ||
psapi_GetModuleFileNameExA == NULL)
{
if ( psapi_loaded ) goto failed;
if (psapi_loaded)
goto failed;
psapi_loaded = 1;
psapi_module_handle = LoadLibrary ( "psapi.dll" );
if ( ! psapi_module_handle )
goto failed;
psapi_EnumProcessModules = (tf_EnumProcessModules *) GetProcAddress ( psapi_module_handle, "EnumProcessModules" );
psapi_GetModuleInformation = (tf_GetModuleInformation *) GetProcAddress ( psapi_module_handle, "GetModuleInformation" );
psapi_GetModuleFileNameExA = (tf_GetModuleFileNameExA*) GetProcAddress ( psapi_module_handle, "GetModuleFileNameExA" );
if ( psapi_EnumProcessModules == NULL ||
psapi_GetModuleInformation == NULL ||
psapi_GetModuleFileNameExA == NULL ) goto failed;
psapi_module_handle = LoadLibrary ("psapi.dll");
if (!psapi_module_handle)
goto failed;
psapi_EnumProcessModules =
(tf_EnumProcessModules *) GetProcAddress (psapi_module_handle,
"EnumProcessModules");
psapi_GetModuleInformation =
(tf_GetModuleInformation *) GetProcAddress (psapi_module_handle,
"GetModuleInformation");
psapi_GetModuleFileNameExA =
(tf_GetModuleFileNameExA *) GetProcAddress (psapi_module_handle,
"GetModuleFileNameExA");
if (psapi_EnumProcessModules == NULL
|| psapi_GetModuleInformation == NULL
|| psapi_GetModuleFileNameExA == NULL)
goto failed;
}
ok = (*psapi_EnumProcessModules) ( hProcess,
DllHandle,
sizeof ( HMODULE ),
&cbNeeded );
ok = (*psapi_EnumProcessModules) (hProcess,
DllHandle, sizeof (HMODULE), &cbNeeded);
if ( !ok || !cbNeeded ) goto failed;
DllHandle = (HMODULE*) malloc ( cbNeeded );
if ( ! DllHandle ) goto failed;
ok = (*psapi_EnumProcessModules) ( hProcess,
DllHandle,
cbNeeded,
&cbNeeded );
if ( ! ok )
if (!ok || !cbNeeded)
goto failed;
DllHandle = (HMODULE *) malloc (cbNeeded);
if (!DllHandle)
goto failed;
ok = (*psapi_EnumProcessModules) (hProcess, DllHandle, cbNeeded, &cbNeeded);
if (!ok)
{
free ( DllHandle );
free (DllHandle);
goto failed;
}
for ( i = 0; i < cbNeeded / sizeof ( HMODULE ); i++ )
for (i = 0; i < cbNeeded / sizeof (HMODULE); i++)
{
if ( ! (*psapi_GetModuleInformation) ( hProcess,
DllHandle [ i ],
&mi,
sizeof ( mi ) ) )
{
free ( DllHandle );
goto failed;
}
if (!(*psapi_GetModuleInformation) (hProcess,
DllHandle[i], &mi, sizeof (mi)))
{
free (DllHandle);
goto failed;
}
len = (*psapi_GetModuleFileNameExA) ( hProcess,
DllHandle [ i ],
name_buf,
MAX_PATH );
if ( len == 0 )
{
free ( DllHandle );
goto failed;
}
len = (*psapi_GetModuleFileNameExA) (hProcess,
DllHandle[i], name_buf, MAX_PATH);
if (len == 0)
{
free (DllHandle);
goto failed;
}
if ( (DWORD) (mi.lpBaseOfDll) == BaseAddress )
{
free ( DllHandle );
return strdup ( name_buf );
}
if ((DWORD) (mi.lpBaseOfDll) == BaseAddress)
{
free (DllHandle);
return strdup (name_buf);
}
}
failed:

View File

@ -79,7 +79,7 @@ do_mount (const char *dev, const char *where, int flags)
{
if (force == FALSE)
fprintf (stderr, "%s: warning: %s is not a directory.\n", progname, where);
}
}
exit (0);
}
@ -167,7 +167,7 @@ main (int argc, const char **argv)
else
usage ();
}
if ((i + 2) != argc)
usage ();
@ -259,7 +259,7 @@ change_cygdrive_prefix (const char *new_prefix, int flags)
if (mount (NULL, new_prefix, flags))
error (new_prefix);
exit (0);
}

View File

@ -4,11 +4,11 @@
Written by Egor Duda <deo@logos-m.ru>
This file is part of Cygwin.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include <bfd.h>
#include <stdio.h>
@ -17,22 +17,25 @@ details. */
#include "dumper.h"
int
exclusion::add ( LPBYTE mem_base, DWORD mem_size )
exclusion::add (LPBYTE mem_base, DWORD mem_size)
{
while ( last >= size ) size += step;
region = (process_mem_region*) realloc ( region, size * sizeof ( process_mem_region ) );
if ( region == NULL ) return 0;
region [ last ].base = mem_base;
region [ last ].size = mem_size;
while (last >= size)
size += step;
region = (process_mem_region *) realloc (region, size * sizeof (process_mem_region));
if (region == NULL)
return 0;
region[last].base = mem_base;
region[last].size = mem_size;
last++;
return 1;
};
int cmp_regions ( const void* r1, const void* r2 )
int
cmp_regions (const void *r1, const void *r2)
{
if ( ((process_mem_region*) r1)->base < ((process_mem_region*) r2)->base )
if (((process_mem_region *) r1)->base < ((process_mem_region *) r2)->base)
return -1;
if ( ((process_mem_region*) r1)->base > ((process_mem_region*) r2)->base )
if (((process_mem_region *) r1)->base > ((process_mem_region *) r2)->base)
return 1;
return 0;
}
@ -40,49 +43,49 @@ int cmp_regions ( const void* r1, const void* r2 )
int
exclusion::sort_and_check ()
{
qsort ( region, last, sizeof ( process_mem_region ), &cmp_regions );
for ( process_mem_region* p = region; p < region + last - 1; p++ )
qsort (region, last, sizeof (process_mem_region), &cmp_regions);
for (process_mem_region * p = region; p < region + last - 1; p++)
{
process_mem_region* q = p + 1;
if ( p->base + size > q->base )
{
fprintf ( stderr, "region error @ %08x", p->base );
return 0;
}
process_mem_region *q = p + 1;
if (p->base + size > q->base)
{
fprintf (stderr, "region error @ %08x", p->base);
return 0;
}
}
return 1;
}
static void
select_data_section ( bfd *abfd, asection *sect, PTR obj )
select_data_section (bfd * abfd, asection * sect, PTR obj)
{
exclusion* excl_list = (exclusion*) obj;
exclusion *excl_list = (exclusion *) obj;
if ( ( sect->flags & ( SEC_CODE | SEC_DEBUGGING ) ) &&
sect->vma && sect->_raw_size )
if ((sect->flags & (SEC_CODE | SEC_DEBUGGING)) &&
sect->vma && sect->_raw_size)
{
excl_list->add ( (LPBYTE)sect->vma, (DWORD)sect->_raw_size );
deb_printf ( "excluding section: %20s %08lx\n", sect->name, sect->_raw_size);
excl_list->add ((LPBYTE) sect->vma, (DWORD) sect->_raw_size);
deb_printf ("excluding section: %20s %08lx\n", sect->name, sect->_raw_size);
}
}
int
parse_pe ( const char* file_name, exclusion* excl_list )
parse_pe (const char *file_name, exclusion * excl_list)
{
if ( file_name == NULL || excl_list == NULL ) return 0;
if (file_name == NULL || excl_list == NULL)
return 0;
bfd* abfd = bfd_openr ( file_name, "pei-i386" );
if ( abfd == NULL )
bfd *abfd = bfd_openr (file_name, "pei-i386");
if (abfd == NULL)
{
bfd_perror ( "failed to open file" );
bfd_perror ("failed to open file");
return 0;
}
bfd_check_format ( abfd, bfd_object );
bfd_map_over_sections ( abfd, &select_data_section, (PTR)excl_list );
bfd_check_format (abfd, bfd_object);
bfd_map_over_sections (abfd, &select_data_section, (PTR) excl_list);
excl_list->sort_and_check ();
bfd_close ( abfd );
bfd_close (abfd);
return 1;
}

View File

@ -498,7 +498,7 @@ run_program (char *cmdline)
if (++qq % 100 == 0)
fprintf (stderr, " %08x %d %d \r",
pc, ncalls, opcode_count);
if (sp == last_sp-4)
{
ncalls++;
@ -598,7 +598,7 @@ run_program (char *cmdline)
if (verbose)
printf ("load dll %08x:",
(int)event.u.LoadDll.lpBaseOfDll);
dll_ptr = (char *)"( u n k n o w n ) \0\0";
if (event.u.LoadDll.lpImageName)
{

View File

@ -19,7 +19,7 @@ section. Let's say we're profiling cygwin1.dll. Make sure you've
built it with debug symbols (else gprof won't run) and run objdump
like this:
objdump -h cygwin1.dll
objdump -h cygwin1.dll
It will print a report like this:
@ -63,8 +63,8 @@ the first part of the report reports the amount of time spent in each
function, like this:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
% cumulative self self total
time seconds seconds calls ms/call ms/call name
10.02 231.22 72.43 46 1574.57 1574.57 strcspn
7.95 288.70 57.48 130 442.15 442.15 strncasematch

View File

@ -30,17 +30,19 @@ static BOOL close_handle (HANDLE h, DWORD ok);
#define CloseHandle(h) close_handle(h, 0)
struct child_list
{
DWORD id;
HANDLE hproc;
int saw_stars;
char nfields;
long long start_time;
DWORD last_usecs;
struct child_list *next;
child_list ():id (0), hproc (NULL), saw_stars (0), nfields (0),
start_time (0), last_usecs (0), next (NULL)
{
DWORD id;
HANDLE hproc;
int saw_stars;
char nfields;
long long start_time;
DWORD last_usecs;
struct child_list *next;
child_list () : id (0), hproc (NULL), saw_stars (0), nfields (0),
start_time (0), last_usecs (0), next (NULL) {}
};
}
};
child_list children;
@ -85,7 +87,7 @@ DWORD lastid = 0;
HANDLE lasth;
#define PROCFLAGS \
PROCESS_ALL_ACCESS /*(PROCESS_DUP_HANDLE | PROCESS_TERMINATE | PROCESS_VM_READ | PROCESS_VM_WRITE)*/
PROCESS_ALL_ACCESS /*(PROCESS_DUP_HANDLE | PROCESS_TERMINATE | PROCESS_VM_READ | PROCESS_VM_WRITE) */
static void
add_child (DWORD id, HANDLE hproc)
{
@ -101,7 +103,7 @@ static child_list *
get_child (DWORD id)
{
child_list *c;
for (c = &children; (c = c->next) != NULL; )
for (c = &children; (c = c->next) != NULL;)
if (c->id == id)
return c;
@ -132,7 +134,7 @@ class linebuf
{
size_t alloc;
public:
size_t ix;
size_t ix;
char *buf;
linebuf ()
{
@ -140,9 +142,16 @@ public:
alloc = 0;
buf = NULL;
}
~linebuf () {if (buf) free (buf);}
~linebuf ()
{
if (buf)
free (buf);
}
void add (const char *what, int len);
void add (const char *what) {add (what, strlen (what));}
void add (const char *what)
{
add (what, strlen (what));
}
void prepend (const char *what, int len);
};
@ -172,15 +181,15 @@ linebuf::prepend (const char *what, int len)
buf[ix] = '\0';
}
if ((buflen = strlen (buf)))
memmove (buf + len, buf, buflen + 1);
memmove (buf + len, buf, buflen + 1);
else
buf[newix] = '\0';
buf[newix] = '\0';
memcpy (buf, what, len);
ix = newix;
}
static void
make_command_line (linebuf& one_line, char **argv)
make_command_line (linebuf & one_line, char **argv)
{
for (; *argv; argv++)
{
@ -240,26 +249,25 @@ create_child (char **argv)
memset (&si, 0, sizeof (si));
si.cb = sizeof (si);
/* cygwin32_conv_to_win32_path (exec_file, real_path);*/
/* cygwin32_conv_to_win32_path (exec_file, real_path); */
flags = forkdebug ? 0 : DEBUG_ONLY_THIS_PROCESS;
flags |= /*CREATE_NEW_PROCESS_GROUP | */CREATE_DEFAULT_ERROR_MODE | DEBUG_PROCESS;
flags |=
/*CREATE_NEW_PROCESS_GROUP | */ CREATE_DEFAULT_ERROR_MODE | DEBUG_PROCESS;
make_command_line (one_line, argv);
SetConsoleCtrlHandler (NULL, 0);
ret = CreateProcess (0,
one_line.buf,/* command line */
ret = CreateProcess (0, one_line.buf, /* command line */
NULL, /* Security */
NULL, /* thread */
TRUE, /* inherit handles */
flags, /* start flags */
NULL,
NULL, /* current directory */
&si,
&pi);
NULL, NULL, /* current directory */
&si, &pi);
if (!ret)
error (0, "error creating process %s, (error %d)", *argv, GetLastError());
error (0, "error creating process %s, (error %d)", *argv,
GetLastError ());
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
@ -294,9 +302,7 @@ output_winerror (FILE *ofile, char *s)
NULL,
errnum,
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) buf,
sizeof (buf),
NULL))
(LPTSTR) buf, sizeof (buf), NULL))
return 0;
/* Get rid the trailing CR/NL pair. */
@ -331,7 +337,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
DWORD nbytes;
child_list *child = get_child (id);
HANDLE hchild = child->hproc;
#define INTROLEN (sizeof (alen) - 1)
#define INTROLEN (sizeof (alen) - 1)
if (id == lastid && hchild != lasth)
warn (0, "%p != %p", hchild, lasth);
@ -341,7 +347,8 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
#ifndef DEBUGGING
return;
#else
error (0, "couldn't get message length from subprocess %d<%p>, windows error %d",
error (0,
"couldn't get message length from subprocess %d<%p>, windows error %d",
id, hchild, GetLastError ());
#endif
@ -378,8 +385,9 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
{
DWORD new_flag = 1;
if (!WriteProcessMemory (hchild, (LPVOID) n, &new_flag,
sizeof (new_flag), &nbytes))
error (0, "couldn't write strace flag to subprocess, windows error %d",
sizeof (new_flag), &nbytes))
error (0,
"couldn't write strace flag to subprocess, windows error %d",
GetLastError ());
return;
}
@ -387,9 +395,9 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
char *origs = s;
if (mask & n)
/* got it */;
/* got it */ ;
else if (!(mask & _STRACE_ALL) || (n & _STRACE_NOTALL))
return; /* This should not be included in "all" output */
return; /* This should not be included in "all" output */
DWORD dusecs, usecs;
char *ptusec, *ptrest;
@ -447,7 +455,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
{
for (i = 0; i < child->nfields; i++)
if ((news = strchr (news, ' ')) == NULL)
break; // Should never happen
break; // Should never happen
else
news++;
@ -459,8 +467,10 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
if (*s == '*')
{
SYSTEMTIME *st = syst (child->start_time);
fprintf (ofile, "Date/Time: %d-%02d-%02d %02d:%02d:%02d\n",
st->wYear, st->wMonth, st->wDay, st->wHour, st->wMinute, st->wSecond);
fprintf (ofile,
"Date/Time: %d-%02d-%02d %02d:%02d:%02d\n",
st->wYear, st->wMonth, st->wDay, st->wHour,
st->wMinute, st->wSecond);
child->saw_stars++;
}
}
@ -471,7 +481,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
char intbuf[40];
if (child->saw_stars < 2 || s != origs)
/* Nothing */;
/* Nothing */ ;
else if (hhmmss)
{
s = ptrest - 9;
@ -537,7 +547,8 @@ proc_child (unsigned mask, FILE *ofile)
remove_child (ev.dwProcessId);
break;
case EXCEPTION_DEBUG_EVENT:
if (ev.u.Exception.ExceptionRecord.ExceptionCode != STATUS_BREAKPOINT)
if (ev.u.Exception.ExceptionRecord.ExceptionCode !=
STATUS_BREAKPOINT)
{
status = DBG_EXCEPTION_NOT_HANDLED;
#if 0
@ -566,7 +577,7 @@ dostrace (unsigned mask, FILE *ofile, char **argv)
}
int
main(int argc, char **argv)
main (int argc, char **argv)
{
unsigned mask = 0;
FILE *ofile = NULL;
@ -627,7 +638,7 @@ static BOOL
close_handle (HANDLE h, DWORD ok)
{
child_list *c;
for (c = &children; (c = c->next) != NULL; )
for (c = &children; (c = c->next) != NULL;)
if (c->hproc == h && c->id != ok)
error (0, "Closing child handle %p", h);
return CloseHandle (h);

View File

@ -27,13 +27,18 @@ static void
usage (void)
{
fprintf (stderr, "Usage %s [-s] <posixpath>\n", progname);
fprintf (stderr, "-s = remove mount point from system-wide registry location\n");
fprintf (stderr,
"-s = remove mount point from system-wide registry location\n");
fprintf (stderr, "\n");
fprintf (stderr, "--remove-all-mounts = remove all mounts\n");
fprintf (stderr, "--remove-auto-mounts = remove all automatically mounted mounts\n");
fprintf (stderr, "--remove-user-mounts = remove all mounts in the current user mount registry area, including auto mounts\n");
fprintf (stderr, "--remove-system-mounts = remove all mounts in the system-wide mount registry area\n");
fprintf (stderr, "[-s] --remove-cygdrive-prefix = remove cygdrive path prefix\n");
fprintf (stderr,
"--remove-auto-mounts = remove all automatically mounted mounts\n");
fprintf (stderr,
"--remove-user-mounts = remove all mounts in the current user mount registry area, including auto mounts\n");
fprintf (stderr,
"--remove-system-mounts = remove all mounts in the system-wide mount registry area\n");
fprintf (stderr,
"[-s] --remove-cygdrive-prefix = remove cygdrive path prefix\n");
exit (1);
}
@ -57,7 +62,7 @@ main (int argc, char **argv)
for (i = 1; i < argc; ++i)
{
if (argv[i][0] != '-')
break;
break;
if (strcmp (argv[i], "-s") == 0)
{
@ -194,7 +199,7 @@ remove_all_system_mounts ()
static void
remove_cygdrive_prefix (int flags)
{
int res = cygwin_umount(NULL, flags | MOUNT_AUTO);
int res = cygwin_umount (NULL, flags | MOUNT_AUTO);
if (res)
error ("remove_cygdrive_prefix");
}

View File

@ -269,7 +269,7 @@ local machine or the default (or given) domain.</para>
<screen>
Usage passwd [name]
passwd [-x max] [-n min] [-i inact] [-L len]
passwd [-x max] [-n min] [-i inact] [-L len]
passwd {-l|-u|-S} name
-x max set max age of passwords
-n min set min age of passwords
@ -303,12 +303,12 @@ at this time. If not, <command>passwd</command> refuses to change the
password and exits.</para>
<para>Password expiry and length: The password aging information may be
changed by the administrators with the <literal>-x</literal>,
<literal>-n</literal> and <literal>-i</literal> options. The
changed by the administrators with the <literal>-x</literal>,
<literal>-n</literal> and <literal>-i</literal> options. The
<literal>-x</literal> option is used to set the maximum number of days
a password remains valid. After <emphasis>max</emphasis> days, the
password is required to be changed. The <literal>-n</literal> option is
used to set the minimum number of days before a password may be changed.
used to set the minimum number of days before a password may be changed.
The user will not be permitted to change the password until
<emphasis>min</emphasis> days have elapsed. The <literal>-i</literal>
option is used to disable an account after the password has been expired
@ -321,8 +321,8 @@ for users, which doesn't belong to the administrators group, to
password length are 0 to 14. In any of the above cases, a value of 0
means `no restrictions'.</para>
<para>Account maintenance: User accounts may be locked and unlocked with the
<literal>-l</literal> and <literal>-u</literal> flags. The
<para>Account maintenance: User accounts may be locked and unlocked with the
<literal>-l</literal> and <literal>-u</literal> flags. The
<literal>-l</literal> option disables an account. The <literal>-u</literal>
option re-enables an account.</para>
@ -383,9 +383,9 @@ to the current user.</para>
<para>The <command>mount</command> utility is also the mechanism for
adding new mounts to the mount table. The following example
demonstrates how to mount the directory
demonstrates how to mount the directory
<filename>C:\cygnus\cygwin-b20\H-i586-cygwin32\bin</filename>
to <filename>/bin</filename> and the network directory
to <filename>/bin</filename> and the network directory
<filename>\\pollux\home\joe\data</filename> to <filename>/data</filename>.
<filename>/bin</filename> is assumed to already exist.</para>
@ -423,7 +423,7 @@ instead of the user-specific one. System-wide mounts are displayed
by <command>mount</command> as being of the "system" type, as is the
case for the <filename>/</filename> partition in the last example.
Under Windows NT, only those users with Administrator priviledges are
permitted to modify the system-wide mount table.</para>
permitted to modify the system-wide mount table.</para>
<para>Note that a given POSIX path may only exist once in the user
table and once in the global, system-wide table. Attempts to replace