summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/kernel32.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-07-19 17:28:34 +0000
committerChristopher Faylor <me@cgf.cx>2013-07-19 17:28:34 +0000
commit521953a83a885011c9040b635a94db5eb6b8db56 (patch)
tree1aa05b8b65b691cb4c5dccab65c4864d5e95cb54 /winsup/cygwin/kernel32.cc
parent4b25516b5d410c38554c9595bcb674356ffee713 (diff)
downloadcygnal-521953a83a885011c9040b635a94db5eb6b8db56.tar.gz
cygnal-521953a83a885011c9040b635a94db5eb6b8db56.tar.bz2
cygnal-521953a83a885011c9040b635a94db5eb6b8db56.zip
* common.din: Export GetCommandLine{A,W}.
* kernel32.cc: Add includes needed for GetCommandLine functions. (ucmd): New function. (cygwin_GetCommandLineW): Ditto. (cygwin_GetCommandLineA): Ditto. * spawn.cc (child_info_spawn::worker): Rename one_line -> cmd. Use lb_wcs macro to generate a wide character version of the line buffer. Remove duplicate printing of command line. Don't access members of linebuf directly. * winf.h: Use pragma once. (linebuf): Make storage private. (linebuf::operator size_t): New operator. Return size of buf. (linebuf::operator wchar_t): New operator. (linebuf::wcs): New function. (lb_wcs): New macro. * include/cygwin/version.h: Bump API minor number to 268. * strfuncs.cc: Clarify descriptive file comment.
Diffstat (limited to 'winsup/cygwin/kernel32.cc')
-rw-r--r--winsup/cygwin/kernel32.cc51
1 files changed, 50 insertions, 1 deletions
diff --git a/winsup/cygwin/kernel32.cc b/winsup/cygwin/kernel32.cc
index 6eeb2dc43..9a5dc832e 100644
--- a/winsup/cygwin/kernel32.cc
+++ b/winsup/cygwin/kernel32.cc
@@ -1,6 +1,6 @@
/* kernel32.cc: Win32 replacement functions.
- Copyright 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+ Copyright 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
This file is part of Cygwin.
@@ -11,6 +11,15 @@ details. */
#include "winsup.h"
#include "shared_info.h"
#include "ntdll.h"
+#include "cygerrno.h"
+#include "security.h"
+#include "path.h"
+#include "fhandler.h"
+#include "dtable.h"
+#include "cygheap.h"
+#include "tls_pbuf.h"
+#include "winf.h"
+#include "sys/cygwin.h"
/* Implement CreateEvent/OpenEvent so that named objects are always created in
Cygwin shared object namespace. */
@@ -402,3 +411,43 @@ OpenFileMappingA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
}
return OpenFileMappingW (dwDesiredAccess, bInheritHandle, lpName ? name : NULL);
}
+
+/* The external functions below wrap Windows functions of the same name
+ and provide a Windows interface to Cygwin functionality. */
+
+/* Construct a unicode version of the Cygwin command line from __argv) */
+static UNICODE_STRING *
+ucmd ()
+{
+ static UNICODE_STRING wcmd;
+ if (!wcmd.Buffer)
+ {
+ linebuf cmd;
+ path_conv real_path (__argv[0]);
+ av newargv (__argc, __argv);
+ cmd.fromargv (newargv, real_path.get_win32 (), true);
+ RtlInitUnicodeString (&wcmd, cmd);
+ }
+ return &wcmd;
+}
+
+/* Cygwin replacement for GetCommandLineA. Returns a concatenated wide string
+ representing the argv list, constructed using roughly the same mechanism as
+ child_info_spawn::worker */
+extern "C" LPWSTR WINAPI
+cygwin_GetCommandLineW (void)
+{
+ return ucmd ()->Buffer;
+}
+
+/* Cygwin replacement for GetCommandLineA. Returns a concatenated string
+ representing the argv list, constructed using roughly the same mechanism
+ as child_info_spawn::worker */
+extern "C" LPSTR WINAPI
+cygwin_GetCommandLineA (void)
+{
+ static ANSI_STRING cmd;
+ if (!cmd.Buffer)
+ RtlUnicodeStringToAnsiString (&cmd, ucmd (), TRUE);
+ return cmd.Buffer;
+}