2003-07-10 18:50:51 +00:00
|
|
|
/* $Id: cmdline.c,v 1.17 2003/07/10 18:50:51 chorns Exp $
|
1999-12-10 17:49:21 +00:00
|
|
|
*
|
1999-01-01 22:03:17 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/kernel32/proc/proc.c
|
|
|
|
* PURPOSE: Process functions
|
|
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ****************************************************************/
|
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <kernel32/kernel32.h>
|
1999-01-01 22:03:17 +00:00
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
static UNICODE_STRING CommandLineStringW;
|
|
|
|
static ANSI_STRING CommandLineStringA;
|
|
|
|
|
|
|
|
static WINBOOL bCommandLineInitialized = FALSE;
|
|
|
|
|
|
|
|
|
1999-01-01 22:03:17 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
1999-12-10 17:49:21 +00:00
|
|
|
static VOID
|
|
|
|
InitCommandLines (VOID)
|
|
|
|
{
|
2002-09-08 10:23:54 +00:00
|
|
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
// get command line
|
2000-01-11 17:32:13 +00:00
|
|
|
Params = NtCurrentPeb()->ProcessParameters;
|
2002-09-08 10:23:54 +00:00
|
|
|
RtlNormalizeProcessParams (Params);
|
1999-12-10 17:49:21 +00:00
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
// initialize command line buffers
|
|
|
|
CommandLineStringW.Length = Params->CommandLine.Length;
|
|
|
|
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
|
|
|
|
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
|
|
|
|
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
|
|
|
|
CommandLineStringW.MaximumLength);
|
|
|
|
|
|
|
|
RtlInitAnsiString(&CommandLineStringA, NULL);
|
|
|
|
|
|
|
|
// copy command line
|
1999-12-10 17:49:21 +00:00
|
|
|
RtlCopyUnicodeString (&CommandLineStringW,
|
2000-01-11 17:32:13 +00:00
|
|
|
&(Params->CommandLine));
|
2002-03-25 21:11:13 +00:00
|
|
|
CommandLineStringW.Buffer[CommandLineStringW.Length / sizeof(WCHAR)] = 0;
|
|
|
|
|
|
|
|
/* convert unicode string to ansi (or oem) */
|
|
|
|
if (bIsFileApiAnsi)
|
|
|
|
RtlUnicodeStringToAnsiString (&CommandLineStringA,
|
|
|
|
&CommandLineStringW,
|
|
|
|
TRUE);
|
|
|
|
else
|
|
|
|
RtlUnicodeStringToOemString (&CommandLineStringA,
|
|
|
|
&CommandLineStringW,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
CommandLineStringA.Buffer[CommandLineStringA.Length] = 0;
|
1999-12-10 17:49:21 +00:00
|
|
|
|
|
|
|
bCommandLineInitialized = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1999-01-01 22:03:17 +00:00
|
|
|
LPSTR STDCALL GetCommandLineA(VOID)
|
|
|
|
{
|
1999-12-10 17:49:21 +00:00
|
|
|
if (bCommandLineInitialized == FALSE)
|
|
|
|
{
|
|
|
|
InitCommandLines ();
|
|
|
|
}
|
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
DPRINT ("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
|
1999-12-10 17:49:21 +00:00
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
return(CommandLineStringA.Buffer);
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
1999-12-06 00:25:14 +00:00
|
|
|
LPWSTR STDCALL GetCommandLineW (VOID)
|
1999-01-01 22:03:17 +00:00
|
|
|
{
|
1999-12-10 17:49:21 +00:00
|
|
|
if (bCommandLineInitialized == FALSE)
|
|
|
|
{
|
|
|
|
InitCommandLines ();
|
|
|
|
}
|
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
DPRINT ("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
|
1999-12-10 17:49:21 +00:00
|
|
|
|
2002-03-25 21:11:13 +00:00
|
|
|
return(CommandLineStringW.Buffer);
|
1999-01-01 22:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
/* EOF */
|