Reactos
at listview 75 lines 2.3 kB view raw
1// 2// argv_data.cpp 3// 4// Copyright (c) Microsoft Corporation. All rights reserved. 5// 6// This file defines the global data that stores the command line with which the 7// program was executed, along with the parsed arguments (if the arguments were 8// parsed), and the accessors for the global data. 9// 10#include <corecrt_internal.h> 11 12 13 14extern "C" { 15 16 17// Note: In general, either the narrow or wide string variables will be set, 18// but not both. These get initialized by the CRT startup sequence before any 19// user code is executed. There are cases where any or all of the pointers may 20// be null during execution. Do not assume that they are non-null. 21 22int __argc = 0; // The number of arguments in __argv or __wargv 23char** __argv = nullptr; // The arguments as narrow strings 24wchar_t** __wargv = nullptr; // The arguments as wide strings 25char* _pgmptr = nullptr; // The name of the program as a narrow string 26wchar_t* _wpgmptr = nullptr; // The name of the program as a wide string 27char* _acmdln = nullptr; // The raw command line as a narrow string 28wchar_t* _wcmdln = nullptr; // The raw command line as a wide string 29 30_BEGIN_SECURE_CRT_DEPRECATION_DISABLE 31 32int* __cdecl __p___argc() { return &__argc; } 33char*** __cdecl __p___argv() { return &__argv; } 34wchar_t*** __cdecl __p___wargv() { return &__wargv; } 35char** __cdecl __p__pgmptr() { return &_pgmptr; } 36wchar_t** __cdecl __p__wpgmptr() { return &_wpgmptr; } 37char** __cdecl __p__acmdln() { return &_acmdln; } 38wchar_t** __cdecl __p__wcmdln() { return &_wcmdln; } 39 40errno_t __cdecl _get_wpgmptr(wchar_t** const result) 41{ 42 _VALIDATE_RETURN_ERRCODE(result != nullptr, EINVAL); 43 _VALIDATE_RETURN_ERRCODE(_wpgmptr != nullptr, EINVAL); 44 45 *result = _wpgmptr; 46 return 0; 47} 48 49errno_t __cdecl _get_pgmptr(char** const result) 50{ 51 _VALIDATE_RETURN_ERRCODE(result != nullptr, EINVAL); 52 _VALIDATE_RETURN_ERRCODE(_pgmptr != nullptr, EINVAL); 53 *result = _pgmptr; 54 return 0; 55} 56 57_END_SECURE_CRT_DEPRECATION_DISABLE 58 59 60 61bool __cdecl __acrt_initialize_command_line() 62{ 63 _acmdln = GetCommandLineA(); 64 _wcmdln = GetCommandLineW(); 65 return true; 66} 67 68bool __cdecl __acrt_uninitialize_command_line(bool const /* terminating */) 69{ 70 return true; 71} 72 73 74 75} // extern "C"