Commit Graph

68 Commits

Author SHA1 Message Date
Christopher Faylor 1b23b30b29 Clean up whitespace. 2011-12-17 23:39:47 +00:00
Corinna Vinschen 71148bfcd5 * Makefile.in (cygpath.exe): Add -luserenv to ALL_LDFLAGS.
* cygpath.cc: Throughout, use cygwin_conv_path WIN_W rather than WIN_A
	conversion.
	(get_long_path_name_w32impl): Remove.
	(get_long_name): Drop pre-Windows 2000 accommodations.  Just call
	GetLongPathNameW here directly.
	(get_special_folder): Convert first parameter to WCHAR buffer pointer.
	Drop conversion of result from WCHAR * to char *.
	(do_sysfolders): Accommodate change to get_special_folder and only
	convert result to char * last.  Drop pre-Windows 2000 accommodations
	and just call GetProfilesDirectoryW directly.  Replace call to
	GetWindowsDirectoryW with call to GetSystemWindowsDirectoryW.
	Just call GetShortPathNameW directly.
	(do_pathconv): Simplify buffer handling.
2011-12-02 16:15:26 +00:00
Corinna Vinschen 92b499acff * 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 14:57:48 +00:00
Corinna Vinschen ac5d7dcd18 * cygpath.cc (get_device_name): Fix path length test. 2010-12-06 13:40:24 +00:00
Corinna Vinschen d2cc418e6e * cygpath.cc (RtlEqualUnicodePathPrefix): New helper function.
(HARDDISK_PREFIX): Move.
	(GLOBALROOT_PREFIX): Define.
	(get_device_name): Take GLOBALROOT_PREFIX into account.
	Improve check for path to allow filesystem access via block devices.
	Potentially drop \\.\ prefix if resulting path is a valid DOS
	pathname.
	(do_pathconv): Make sure to drop \\?\ prefix only if path is
	actually a filesystem based path.
	(print_version): Fix copyright.
2010-09-06 09:48:55 +00:00
Corinna Vinschen 71d8f118da * loadlib.h: New header implementing safe LoadLibrary calls.
Include throughout files using LoadLibrary function.
	* cygcheck.cc (dump_sysinfo): Retrieve kernel32.dll handle via
	GetModuleHandle, rather than using LoadLibrary.
	* cygpath.cc (get_long_name): Ditto.
	(do_sysfolders): Append .dll suffix in LoadLibrary call.
	* ldh.cc (WinMain): Use LoadLibraryExW with DONT_RESOLVE_DLL_REFERENCES
	to avoid loading malicious library code.
	* locale.cc (print_locale_with_codeset): Change way to retrieve
	kernel32.dll path.
2010-08-28 11:22:37 +00:00
Corinna Vinschen 708bbfd08e * cygpath.cc (get_device_name): Prefer the \\.\X: DOS device for
harddisks, if available.
2010-08-26 12:06:27 +00:00
Corinna Vinschen 80206d7f71 * cygpath.cc (do_pathconv): Fix erroneously printing native NT path
prefix introduced by previous patch.
2010-02-22 17:40:46 +00:00
Corinna Vinschen 03ac74c168 * cygpath.cc (do_pathconv): Fix potential crash. 2010-02-13 11:41:53 +00:00
Corinna Vinschen 1b526b480b * cygpath.cc (get_mixed_name): Drop function. Replace with call to
convert_slashes throughout.
	(do_sysfolders): Free allocated buffer.
	(do_pathconv): Fix freeing last buffer.
2010-01-16 10:25:58 +00:00
Corinna Vinschen bf4b80201a * cygpath.cc: Throughout, free obsolete path buffers. 2010-01-07 17:19:12 +00:00
Corinna Vinschen 6004370ba1 * cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale.
Revert usage of argz functions when reading input from file and
	simplify option usage.  Allow only one option argument and use
	the rest as filename argument to allow spaces in filenames.  Restrict
	processing special folder type options to one line.
2010-01-07 12:08:11 +00:00
Corinna Vinschen 175e39bb7f * cygpath.cc (get_special_folder): Fetch path as WCHAR and convert
using my_wcstombs.
	(get_user_folder): Remove.
	(do_sysfolders): Use get_special_folder instead of get_user_folder.
	Fetch system paths as WCHAR and convert using my_wcstombs.
2009-10-15 11:40:02 +00:00
Corinna Vinschen 0a23799aee * cygpath.cc (codepage): New variable.
(long_options): Add --codepage option.
	(options): Add -C option.
	(usage): Add -C/--codepage description.
	(my_wcstombs): New function.  Use througout instead of wcstombs.
	(do_options): Handle -C/--codepage option.
	* utils.sgml (cygpath): Add description for new -C/--codepage option.
2009-05-17 11:16:12 +00:00
Corinna Vinschen 73535010d7 * cygpath.cc (main): Only setlocale for LC_CTYPE category. Fallback
to UTF-8 if locale is "C".
	* ldd.cc (main): Ditto.
	* mkgroup.c (main): Ditto.
	* mkpasswd.c (main): Ditto.
	* passwd.c (main): Ditto.
2009-05-15 11:30:18 +00:00
Corinna Vinschen 8c3a79bb97 * cygpath.cc (do_pathconv): Only skip \\?\ prefix if it's really
given.  Do backslash to slash conversion for mixed paths after
	handling \\?\ prefix.
2009-04-15 10:00:40 +00:00
Corinna Vinschen 26fb7ef5e4 * wide_path.h (class wide_path): New class to convert Windows path
to WCHAR win32 path, including long path conversion if necessary.
	* cygcheck.cc: Use class wide_path throughout to call Win32 functions
	taking potentially long filenames.
	(display_error): Use snprintf rather than sprintf.
	(display_error_fmt): Ditto.
	(dump_sysinfo): Use FindFirstFileW/FindNextFileW.
	* cygpath.cc: Use class wide_path throughout to call Win32 functions
	taking potentially long filenames.
	(get_device_name): Raise buffer size to take long pathnames.
	(get_short_paths): Convert to using GetShortPathNameW.
	(get_short_name): Ditto.
	(get_long_path_name_w32impl): Convert to equivalent of GetLongPathNameW.
	(get_long_name): Convert to using GetLongPathNameW.
	(do_sysfolders): Raise buffer size for POSIX pathname to PATH_MAX.
	(do_pathconv): In case of POSIX->Win32 conversion, convert to wchar_t
	Win32 path name and drop long pathname prefix if possible.
	(main): Call setlocale to accommodate wide char/multibyte conversions.
2009-03-14 14:56:20 +00:00
Corinna Vinschen a1e1990348 * Makefile.in (cygcheck.exe): Link against ntdll.
* bloda.cc: Use statically linked functions throughout.
	* cygpath.cc: Drop 9x considerations.
	* mkgroup.c: Revamp.  Redefine -l and -d options to take optional
	machine and domain parameters.  Redefine -c to work always, using
	token information.  Add -L, -D, -C to create unique groupnames in
	domain\group syntax.  Add -S option to define domain\group separator
	char.  Ignore -u and -s options.
	* mkpasswd.c: Revamp.  Redefine -l and -d options to take optional
	machine and domain parameters.  Redefine -c to work always, using
	token information.  Add -L, -D, -C to create unique usernames in
	domain\user syntax.  Add -S option to define domain\user separator
	char.  Ignore -g and -s options.  Prefer to take homedir from $HOME
	over $HOMEDRIVE/$HOMEPATH.
	* path.cc (oopts): Add "acl", "noacl", "posix=0" and "posix=1" options.
	(getmntent): Accomodate throughout.
	* ps.cc: Fix copyright dates.
	* utils.sgml: Fix text for mkgroup and mkpasswd.
2008-07-22 14:40:05 +00:00
Corinna Vinschen 2b2b42cf59 * cygpath.cc (do_sysfolders): Use cygwin_conv_path.
(do_pathconv): Use cygwin_conv_path and cygwin_conv_path_list.
	* dumper.cc (main): Use cygwin_conv_path.  Allocate target path
	dynamically.
	* mkpasswd.c (current_user): Use cygwin_conv_path.
	(enum_users): Ditto.
	* ps.cc (NT_MAX_PATH): Define.
	(main): Use cygwin_conv_path.
	* regtool.cc (find_key): Ditto. Allocate target path dynamically.
	(cmd_save): Ditto.
2008-03-12 12:47:09 +00:00
Corinna Vinschen df1841c310 * cygpath.cc (do_options): Allow outputflag combined with other
basic flags.  Only check options_from_file_flag if reading options
	from command line.
	(main): Check for NULL argz vector.  Don't free argz vector prematurely.
	Don't force flag combination in !options_from_file_flag case.
2007-05-29 07:54:45 +00:00
Corinna Vinschen fc2000254c * cygpath.cc: Include argz.h.
(options_from_file_flag): Move from main to global static variable.
	(mode_flag): Ditto.
	(do_sysfolders): Rename from dowin and accommodate throughout.
	Don't exit from here.
	(do_pathconv): Rename from doit and accommodate throughout.
	(print_version): Change copyright.
	(do_options): New function, centralizing option processing.
	Rework checking options for correctness.
	(action): New function, centralizing calling worker functions.
	(main): Simplify.  Move option processing to do_options.  Move calling
	worker functions to action.  Rework getting arguments from files.
2007-05-23 16:45:03 +00:00
Christopher Faylor c99e136f3d * utils/cygpath.cc (get_long_path_name_w32impl): Close handles returned by
FindFirstFile.
2007-03-31 00:03:25 +00:00
Corinna Vinschen ca9029913a * cygpath.cc (usage): Add -O and -F, remove tabs.
(get_special_folder): New function.
	(get_user_folder): New function.
	(dowin): Add -O and -F, better -D, -P error handling.
	(main): Add -O and -F.
	* utils.sgml (cygpath): Document -O and -F.
2007-01-09 12:17:05 +00:00
Corinna Vinschen 2dba45f4aa * Makefile.in (cygpath.exe): Add rule to link cygpath against ntdll.dll.
* cygpath.cc: Include DDK headers.
	(RtlAllocateUnicodeString): New static inline function.
	(get_device_name): New static function to evaluate DOS path from
	native NT path.
	(get_device_paths): New function to do the same for path lists.
	(doit): Call get_device_paths/get_device_name where appropriate.
2006-08-02 09:48:18 +00:00
Corinna Vinschen acc31d1a90 * cygpath.cc (get_long_name): Fallback to get_long_path_name_w32impl. 2006-07-31 07:31:56 +00:00
Corinna Vinschen bc31293a0d * cygpath.c (get_long_name): Cover the case that GetLongPathName
doesn't return valid information for non-existant files.  Just return
	incoming filename in that case.
2006-07-27 21:07:33 +00:00
Corinna Vinschen 4fc92aa730 * cygpath.cc (get_long_name): Load GetLongPathNameA instead of incorrect
GetLongPathName.
	(doit): Create mixed filename after converting to short or long pathname
	respectively.
2006-02-17 12:17:47 +00:00
Dave Korn 79f24ec37d * cygpath.cc (dowin): Remove stray debugging printf statement. 2006-01-18 12:34:59 +00:00
Christopher Faylor a39cfda7ba * Makefile.in: Link cygcheck with libwininet.a.
* cygcheck.cc: Add includes.
(grep_packages): New global variable.
(display_internet_error): New function.
(safe_chars): New global variable.
(base_url): Ditto.
(package_grep): New function.
(usage): Reword --help output for clarity.  Document new argument.
(longopts): Add 'package-query' option.
(opts): Add 'p' option, reorder to be consistent with 'longopts'.
(main): Accommodate new option.
* utils.sgml (cygcheck): Update --help output.  Document new -p option.
2005-11-22 17:19:17 +00:00
Christopher Faylor ac674bc896 * cygcheck.cc (cygwin_internal): Define as a "C" function.
* strace.cc (cygwin_internal): Ditto.
* cygpath.cc (print_version): Update copyright.
2005-05-17 01:26:16 +00:00
Christopher Faylor 5f8e4efa67 * cygpath.cc (usage): Pass in one more copy of program_name to printf to avoid
a SEGV.
2005-03-06 18:00:03 +00:00
Joshua Daniel Franklin 4c6344923e * cygpath.cc (usage): Clarify help output to indicate acceptance
of multiple file names as arguments.
2005-02-24 04:32:45 +00:00
Christopher Faylor befdf18b4d * cygpath.cc (usage): Don't issue helpful message if -i is used.
(from Igor Pechtchanski)
2004-03-15 21:34:12 +00:00
Christopher Faylor f135dd3ee7 * cygpath.cc (long_options): Add "mode" option.
(options): Ditto.
(usage): Report on new option.
(report_mode): New function.
(main): Implement -M option.
2004-02-25 01:23:20 +00:00
Christopher Faylor 7c03f79971 * Makefile.in (build_dumper): Detect missing iconv library.
* cygpath.cc (dowin): Report on filename conversion errors.
(doit): Ditto.
* strace.cc (main): Use symbolic constant for _STRACE_ALL when setting mask.
2004-02-21 04:51:15 +00:00
Corinna Vinschen 30352c261c * cygpath.cc (dowin): Revert accidental checkin from November. 2004-01-22 09:21:56 +00:00
Corinna Vinschen 0a5ea9471b * cygpath.cc (main): Allow multiple pathnames on command line. 2003-11-07 18:30:35 +00:00
Christopher Faylor ce17145aa8 revert accidental checkin 2003-10-17 17:20:06 +00:00
Christopher Faylor fa10472e4a * cygcheck.cc (pretty_id): Don't exec if `id' program is not found. 2003-10-17 17:19:31 +00:00
Christopher Faylor bd79b736d4 * Makefile.in (cygcheck.o): Use MINGW_CXX for compilation.
* cygcheck.cc: Just include <getopt.h> rather than cygwin version.
(pretty_id): Avoid compiler warnings.
* cygpath.cc (usage): Ditto.
2003-09-11 02:56:40 +00:00
Christopher Faylor cc3ce0bb5f Throughout, always return error when GetShortPathName returns 0. 2003-06-12 20:40:58 +00:00
Joshua Daniel Franklin aa275fe010 * cygcheck.cc (usage) Add description output. 2003-04-26 21:52:03 +00:00
Christopher Faylor 7ca68b7ec3 * cygpath.cc (doit): Allocate more space for non-path filename. 2003-02-12 22:48:13 +00:00
Christopher Faylor cf157504a8 * cygpath.cc (get_long_path_name_w32impl): Define similarly to GetLongPathName.
(get_long_name): Correctly prototype GetLongPathName.
(get_long_paths): Implement using get_long_name to cut down on code
duplication.
(doit): Do various things to make path output work predictably.
2002-10-31 02:40:26 +00:00
Christopher Faylor 0fa64fa3a7 * cygpath.cc (close_arg): Remove unused static.
* mkgroup.c (enum_local_users): Avoid compiler warning.
(enum_users): Ditto.
* mkpasswd.c: Ditto throughout.
* ssp.c: Ditto throughout.
2002-09-30 03:01:17 +00:00
Joshua Daniel Franklin 9b566b9695 2002-09-12 Igor Pechtchanski <pechtcha@cs.nyu.edu>
* cygpath.cc (options) New global variable.
	(main) Make short options global for easier change.
	(print_version) Add a missing newline.
2002-09-15 15:19:49 +00:00
Christopher Faylor 02eb4ad4d4 output some newlines. 2002-08-23 15:46:00 +00:00
Christopher Faylor 1050e57c9a * mount.cc (main): Ensure that mount_already_exists() also gets default flag
that is passed to do_mount.
* cygpath.cc (long_options): Add "dos" and "mixed", correct "close", "file" and
"type" to use NULL flag.
(usage): Clean up usage output (more), accomodate new options.
(main): Add --dos and --mixed options; accomodate all output forms in --type.
Make UNIXy output default.
2002-07-01 20:54:35 +00:00
Christopher Faylor 33bd2d1268 * cygpath.cc (usage): Clean up usage output.
(dowin): Correct output of -t mixed for -ADHPSW options.
2002-06-19 02:09:41 +00:00
Christopher Faylor 2bd6505b39 * cygpath.cc: Add option to output windows paths in different formats: "dos"
and "mixed".
(main): Process options.
(doit): Check new options flags.
2002-06-07 19:25:26 +00:00