* 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.
This commit is contained in:
Christopher Faylor
2013-07-19 17:28:34 +00:00
parent 4b25516b5d
commit 521953a83a
7 changed files with 117 additions and 29 deletions

View File

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