mfplat: Remove duplicated GUID entry from attribute tracing.
[wine/zf.git] / dlls / msvcrt / data.c
blob8b6c34abf5642a99336c79d4e947451a4d4313e5
1 /*
2 * msvcrt.dll dll data items
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <fcntl.h>
22 #include <math.h>
23 #include "msvcrt.h"
24 #include <winnls.h>
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
29 static WCHAR **initial_wargv;
30 static int initial_argc;
31 int MSVCRT___argc = 0;
32 static int wargc_expand;
33 unsigned int MSVCRT__commode = 0;
34 int MSVCRT__fmode = 0;
35 unsigned int MSVCRT__osver = 0;
36 unsigned int MSVCRT__osplatform = 0;
37 unsigned int MSVCRT__winmajor = 0;
38 unsigned int MSVCRT__winminor = 0;
39 unsigned int MSVCRT__winver = 0;
40 #ifdef _CRTDLL
41 unsigned int CRTDLL__basemajor_dll = 0;
42 unsigned int CRTDLL__baseminor_dll = 0;
43 unsigned int CRTDLL__baseversion_dll = 0;
44 unsigned int CRTDLL__cpumode_dll = 1;
45 unsigned int CRTDLL__osmode_dll = 1;
46 #endif
47 unsigned int MSVCRT___setlc_active = 0;
48 unsigned int MSVCRT___unguarded_readlc_active = 0;
49 double MSVCRT__HUGE = 0;
50 char **MSVCRT___argv = NULL;
51 wchar_t **MSVCRT___wargv = NULL;
52 static wchar_t **wargv_expand;
53 char *MSVCRT__acmdln = NULL;
54 wchar_t *MSVCRT__wcmdln = NULL;
55 char **MSVCRT__environ = NULL;
56 wchar_t **MSVCRT__wenviron = NULL;
57 char **MSVCRT___initenv = NULL;
58 wchar_t **MSVCRT___winitenv = NULL;
59 int MSVCRT_app_type = 0;
60 char* MSVCRT__pgmptr = NULL;
61 WCHAR* MSVCRT__wpgmptr = NULL;
63 /* Get a snapshot of the current environment
64 * and construct the __p__environ array
66 * The pointer returned from GetEnvironmentStrings may get invalid when
67 * some other module cause a reallocation of the env-variable block
69 * blk is an array of pointers to environment strings, ending with a NULL
70 * and after that the actual copy of the environment strings, ending in a \0
72 char ** msvcrt_SnapshotOfEnvironmentA(char **blk)
74 char* environ_strings = GetEnvironmentStringsA();
75 int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */
76 char *ptr;
78 for (ptr = environ_strings; *ptr; ptr += strlen(ptr) + 1)
80 /* Don't count environment variables starting with '=' which are command shell specific */
81 if (*ptr != '=') count++;
82 len += strlen(ptr) + 1;
84 if (blk)
85 blk = HeapReAlloc( GetProcessHeap(), 0, blk, count* sizeof(char*) + len );
86 else
87 blk = HeapAlloc(GetProcessHeap(), 0, count* sizeof(char*) + len );
89 if (blk)
91 if (count)
93 memcpy(&blk[count],environ_strings,len);
94 for (ptr = (char*) &blk[count]; *ptr; ptr += strlen(ptr) + 1)
96 /* Skip special environment strings set by the command shell */
97 if (*ptr != '=') blk[i++] = ptr;
100 blk[i] = NULL;
102 FreeEnvironmentStringsA(environ_strings);
103 return blk;
106 wchar_t ** msvcrt_SnapshotOfEnvironmentW(wchar_t **wblk)
108 wchar_t* wenviron_strings = GetEnvironmentStringsW();
109 int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */
110 wchar_t *wptr;
112 for (wptr = wenviron_strings; *wptr; wptr += wcslen(wptr) + 1)
114 /* Don't count environment variables starting with '=' which are command shell specific */
115 if (*wptr != '=') count++;
116 len += wcslen(wptr) + 1;
118 if (wblk)
119 wblk = HeapReAlloc( GetProcessHeap(), 0, wblk, count* sizeof(wchar_t*) + len * sizeof(wchar_t));
120 else
121 wblk = HeapAlloc(GetProcessHeap(), 0, count* sizeof(wchar_t*) + len * sizeof(wchar_t));
122 if (wblk)
124 if (count)
126 memcpy(&wblk[count],wenviron_strings,len * sizeof(wchar_t));
127 for (wptr = (wchar_t*)&wblk[count]; *wptr; wptr += wcslen(wptr) + 1)
129 /* Skip special environment strings set by the command shell */
130 if (*wptr != '=') wblk[i++] = wptr;
133 wblk[i] = NULL;
135 FreeEnvironmentStringsW(wenviron_strings);
136 return wblk;
139 static char **build_argv( WCHAR **wargv )
141 int argc;
142 char *p, **argv;
143 DWORD total = 0;
145 for (argc = 0; wargv[argc]; argc++)
146 total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL );
148 argv = HeapAlloc( GetProcessHeap(), 0, total + (argc + 1) * sizeof(*argv) );
149 p = (char *)(argv + argc + 1);
150 for (argc = 0; wargv[argc]; argc++)
152 DWORD reslen = WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, p, total, NULL, NULL );
153 argv[argc] = p;
154 p += reslen;
155 total -= reslen;
157 argv[argc] = NULL;
158 return argv;
161 static WCHAR **cmdline_to_argv( const WCHAR *src, int *ret_argc )
163 WCHAR **argv, *arg, *dst;
164 int argc, in_quotes = 0, bcount = 0, len = wcslen(src) + 1;
166 argc = 2 + len / 2;
167 argv = HeapAlloc( GetProcessHeap(), 0, argc * sizeof(*argv) + len * sizeof(WCHAR) );
168 arg = dst = (WCHAR *)(argv + argc);
169 argc = 0;
170 while (*src)
172 if ((*src == ' ' || *src == '\t') && !in_quotes)
174 /* skip the remaining spaces */
175 while (*src == ' ' || *src == '\t') src++;
176 if (!*src) break;
177 /* close the argument and copy it */
178 *dst++ = 0;
179 argv[argc++] = arg;
180 /* start with a new argument */
181 arg = dst;
182 bcount = 0;
184 else if (*src == '\\')
186 *dst++ = *src++;
187 bcount++;
189 else if (*src == '"')
191 if ((bcount & 1) == 0)
193 /* Preceded by an even number of '\', this is half that
194 * number of '\', plus a '"' which we discard.
196 dst -= bcount / 2;
197 src++;
198 if (in_quotes && *src == '"') *dst++ = *src++;
199 else in_quotes = !in_quotes;
201 else
203 /* Preceded by an odd number of '\', this is half that
204 * number of '\' followed by a '"'
206 dst -= bcount / 2 + 1;
207 *dst++ = *src++;
209 bcount = 0;
211 else /* a regular character */
213 *dst++ = *src++;
214 bcount = 0;
217 *dst = 0;
218 argv[argc++] = arg;
219 argv[argc] = NULL;
220 *ret_argc = argc;
221 return argv;
224 typedef void (CDECL *_INITTERMFUN)(void);
225 typedef int (CDECL *_INITTERM_E_FN)(void);
227 /***********************************************************************
228 * __p___argc (MSVCRT.@)
230 int* CDECL __p___argc(void) { return &MSVCRT___argc; }
232 /***********************************************************************
233 * __p__commode (MSVCRT.@)
235 unsigned int* CDECL __p__commode(void) { return &MSVCRT__commode; }
238 /***********************************************************************
239 * __p__pgmptr (MSVCRT.@)
241 char** CDECL __p__pgmptr(void) { return &MSVCRT__pgmptr; }
243 /***********************************************************************
244 * __p__wpgmptr (MSVCRT.@)
246 WCHAR** CDECL __p__wpgmptr(void) { return &MSVCRT__wpgmptr; }
248 /***********************************************************************
249 * _get_pgmptr (MSVCRT.@)
251 int CDECL _get_pgmptr(char** p)
253 if (!MSVCRT_CHECK_PMT(p)) return EINVAL;
255 *p = MSVCRT__pgmptr;
256 return 0;
259 /***********************************************************************
260 * _get_wpgmptr (MSVCRT.@)
262 int CDECL _get_wpgmptr(WCHAR** p)
264 if (!MSVCRT_CHECK_PMT(p)) return EINVAL;
265 *p = MSVCRT__wpgmptr;
266 return 0;
269 /***********************************************************************
270 * __p__fmode (MSVCRT.@)
272 int* CDECL __p__fmode(void) { return &MSVCRT__fmode; }
274 /***********************************************************************
275 * _set_fmode (MSVCRT.@)
277 int CDECL _set_fmode(int mode)
279 /* TODO: support _O_WTEXT */
280 if(!MSVCRT_CHECK_PMT(mode==_O_TEXT || mode==_O_BINARY))
281 return EINVAL;
283 MSVCRT__fmode = mode;
284 return 0;
287 /***********************************************************************
288 * _get_fmode (MSVCRT.@)
290 int CDECL _get_fmode(int *mode)
292 if(!MSVCRT_CHECK_PMT(mode))
293 return EINVAL;
295 *mode = MSVCRT__fmode;
296 return 0;
299 /***********************************************************************
300 * __p__osver (MSVCRT.@)
302 unsigned int* CDECL __p__osver(void) { return &MSVCRT__osver; }
304 /***********************************************************************
305 * __p__winmajor (MSVCRT.@)
307 unsigned int* CDECL __p__winmajor(void) { return &MSVCRT__winmajor; }
309 /***********************************************************************
310 * __p__winminor (MSVCRT.@)
312 unsigned int* CDECL __p__winminor(void) { return &MSVCRT__winminor; }
314 /***********************************************************************
315 * __p__winver (MSVCRT.@)
317 unsigned int* CDECL __p__winver(void) { return &MSVCRT__winver; }
319 /*********************************************************************
320 * __p__acmdln (MSVCRT.@)
322 char** CDECL __p__acmdln(void) { return &MSVCRT__acmdln; }
324 /*********************************************************************
325 * __p__wcmdln (MSVCRT.@)
327 wchar_t** CDECL __p__wcmdln(void) { return &MSVCRT__wcmdln; }
329 /*********************************************************************
330 * __p___argv (MSVCRT.@)
332 char*** CDECL __p___argv(void) { return &MSVCRT___argv; }
334 /*********************************************************************
335 * __p___wargv (MSVCRT.@)
337 wchar_t*** CDECL __p___wargv(void) { return &MSVCRT___wargv; }
339 /*********************************************************************
340 * __p__environ (MSVCRT.@)
342 char*** CDECL __p__environ(void)
344 return &MSVCRT__environ;
347 /*********************************************************************
348 * __p__wenviron (MSVCRT.@)
350 wchar_t*** CDECL __p__wenviron(void)
352 return &MSVCRT__wenviron;
355 /*********************************************************************
356 * __p___initenv (MSVCRT.@)
358 char*** CDECL __p___initenv(void) { return &MSVCRT___initenv; }
360 /*********************************************************************
361 * __p___winitenv (MSVCRT.@)
363 wchar_t*** CDECL __p___winitenv(void) { return &MSVCRT___winitenv; }
365 /*********************************************************************
366 * _get_osplatform (MSVCRT.@)
368 int CDECL _get_osplatform(int *pValue)
370 if (!MSVCRT_CHECK_PMT(pValue != NULL)) return EINVAL;
371 *pValue = MSVCRT__osplatform;
372 return 0;
375 /* INTERNAL: Create a wide string from an ascii string */
376 wchar_t *msvcrt_wstrdupa(const char *str)
378 const unsigned int len = strlen(str) + 1 ;
379 wchar_t *wstr = malloc(len* sizeof (wchar_t));
380 if (!wstr)
381 return NULL;
382 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,str,len,wstr,len);
383 return wstr;
386 /*********************************************************************
387 * ___unguarded_readlc_active_add_func (MSVCRT.@)
389 unsigned int * CDECL ___unguarded_readlc_active_add_func(void)
391 return &MSVCRT___unguarded_readlc_active;
394 /*********************************************************************
395 * ___setlc_active_func (MSVCRT.@)
397 unsigned int CDECL ___setlc_active_func(void)
399 return MSVCRT___setlc_active;
402 /* INTERNAL: Since we can't rely on Winelib startup code calling w/getmainargs,
403 * we initialise data values during DLL loading. When called by a native
404 * program we simply return the data we've already initialised. This also means
405 * you can call multiple times without leaking
407 void msvcrt_init_args(void)
409 OSVERSIONINFOW osvi;
411 MSVCRT__acmdln = _strdup( GetCommandLineA() );
412 MSVCRT__wcmdln = _wcsdup( GetCommandLineW() );
413 initial_wargv = cmdline_to_argv( GetCommandLineW(), &initial_argc );
414 MSVCRT___argc = initial_argc;
415 MSVCRT___wargv = initial_wargv;
416 MSVCRT___argv = build_argv( initial_wargv );
418 TRACE("got %s, wide = %s argc=%d\n", debugstr_a(MSVCRT__acmdln),
419 debugstr_w(MSVCRT__wcmdln),MSVCRT___argc);
421 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
422 GetVersionExW( &osvi );
423 MSVCRT__winver = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
424 MSVCRT__winmajor = osvi.dwMajorVersion;
425 MSVCRT__winminor = osvi.dwMinorVersion;
426 MSVCRT__osver = osvi.dwBuildNumber;
427 MSVCRT__osplatform = osvi.dwPlatformId;
428 TRACE( "winver %08x winmajor %08x winminor %08x osver %08x\n",
429 MSVCRT__winver, MSVCRT__winmajor, MSVCRT__winminor, MSVCRT__osver);
430 #ifdef _CRTDLL
431 CRTDLL__baseversion_dll = (GetVersion() >> 16);
432 CRTDLL__basemajor_dll = CRTDLL__baseversion_dll >> 8;
433 CRTDLL__baseminor_dll = CRTDLL__baseversion_dll & 0xff;
434 #endif
436 MSVCRT__HUGE = HUGE_VAL;
437 MSVCRT___setlc_active = 0;
438 MSVCRT___unguarded_readlc_active = 0;
439 MSVCRT__fmode = _O_TEXT;
441 MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(NULL);
442 MSVCRT___initenv = msvcrt_SnapshotOfEnvironmentA(NULL);
443 MSVCRT___winitenv = msvcrt_SnapshotOfEnvironmentW(NULL);
445 MSVCRT__pgmptr = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
446 if (MSVCRT__pgmptr)
448 if (!GetModuleFileNameA(0, MSVCRT__pgmptr, MAX_PATH))
449 MSVCRT__pgmptr[0] = '\0';
450 else
451 MSVCRT__pgmptr[MAX_PATH - 1] = '\0';
454 MSVCRT__wpgmptr = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
455 if (MSVCRT__wpgmptr)
457 if (!GetModuleFileNameW(0, MSVCRT__wpgmptr, MAX_PATH))
458 MSVCRT__wpgmptr[0] = '\0';
459 else
460 MSVCRT__wpgmptr[MAX_PATH - 1] = '\0';
464 /* INTERNAL: free memory used by args */
465 void msvcrt_free_args(void)
467 /* FIXME: more things to free */
468 HeapFree(GetProcessHeap(), 0, MSVCRT___argv);
469 HeapFree(GetProcessHeap(), 0, MSVCRT___initenv);
470 HeapFree(GetProcessHeap(), 0, MSVCRT___winitenv);
471 HeapFree(GetProcessHeap(), 0, MSVCRT__environ);
472 HeapFree(GetProcessHeap(), 0, MSVCRT__wenviron);
473 HeapFree(GetProcessHeap(), 0, MSVCRT__pgmptr);
474 HeapFree(GetProcessHeap(), 0, MSVCRT__wpgmptr);
475 HeapFree(GetProcessHeap(), 0, wargv_expand);
478 static int build_expanded_wargv(int *argc, wchar_t **argv)
480 int i, size=0, args_no=0, path_len;
481 BOOL is_expandable;
482 HANDLE h;
484 args_no = 0;
485 for(i=0; i < initial_argc; i++) {
486 WIN32_FIND_DATAW data;
487 int len = 0;
489 is_expandable = FALSE;
490 for(path_len = wcslen(initial_wargv[i])-1; path_len>=0; path_len--) {
491 if(initial_wargv[i][path_len]=='*' || initial_wargv[i][path_len]=='?')
492 is_expandable = TRUE;
493 else if(initial_wargv[i][path_len]=='\\' || initial_wargv[i][path_len]=='/')
494 break;
496 path_len++;
498 if(is_expandable)
499 h = FindFirstFileW(initial_wargv[i], &data);
500 else
501 h = INVALID_HANDLE_VALUE;
503 if(h != INVALID_HANDLE_VALUE) {
504 do {
505 if(data.cFileName[0]=='.' && (data.cFileName[1]=='\0' ||
506 (data.cFileName[1]=='.' && data.cFileName[2]=='\0')))
507 continue;
509 len = wcslen(data.cFileName)+1;
510 if(argv) {
511 argv[args_no] = (wchar_t*)(argv+*argc+1)+size;
512 memcpy(argv[args_no], initial_wargv[i], path_len*sizeof(wchar_t));
513 memcpy(argv[args_no]+path_len, data.cFileName, len*sizeof(wchar_t));
515 args_no++;
516 size += len+path_len;
517 }while(FindNextFileW(h, &data));
518 FindClose(h);
521 if(!len) {
522 len = wcslen(initial_wargv[i])+1;
523 if(argv) {
524 argv[args_no] = (wchar_t*)(argv+*argc+1)+size;
525 memcpy(argv[args_no], initial_wargv[i], len*sizeof(wchar_t));
527 args_no++;
528 size += len;
532 if(argv)
533 argv[args_no] = NULL;
534 size *= sizeof(wchar_t);
535 size += (args_no+1)*sizeof(wchar_t*);
536 *argc = args_no;
537 return size;
540 /*********************************************************************
541 * __wgetmainargs (MSVCRT.@)
543 int CDECL __wgetmainargs(int *argc, wchar_t** *wargv, wchar_t** *wenvp,
544 int expand_wildcards, int *new_mode)
546 TRACE("(%p,%p,%p,%d,%p).\n", argc, wargv, wenvp, expand_wildcards, new_mode);
548 if (expand_wildcards) {
549 HeapFree(GetProcessHeap(), 0, wargv_expand);
550 wargv_expand = HeapAlloc(GetProcessHeap(), 0,
551 build_expanded_wargv(&wargc_expand, NULL));
552 if (wargv_expand) {
553 build_expanded_wargv(&wargc_expand, wargv_expand);
555 MSVCRT___argc = wargc_expand;
556 MSVCRT___wargv = wargv_expand;
557 }else {
558 expand_wildcards = 0;
561 if (!expand_wildcards) {
562 MSVCRT___argc = initial_argc;
563 MSVCRT___wargv = initial_wargv;
566 /* Initialize the _wenviron array if it's not already created. */
567 if (!MSVCRT__wenviron)
568 MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(NULL);
569 *argc = MSVCRT___argc;
570 *wargv = MSVCRT___wargv;
571 *wenvp = MSVCRT___winitenv;
572 if (new_mode)
573 _set_new_mode( *new_mode );
574 return 0;
577 /*********************************************************************
578 * __getmainargs (MSVCRT.@)
580 int CDECL __getmainargs(int *argc, char** *argv, char** *envp,
581 int expand_wildcards, int *new_mode)
583 TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, envp, expand_wildcards, new_mode);
585 if (expand_wildcards) {
586 HeapFree(GetProcessHeap(), 0, wargv_expand);
587 wargv_expand = HeapAlloc(GetProcessHeap(), 0,
588 build_expanded_wargv(&wargc_expand, NULL));
589 if (wargv_expand) {
590 build_expanded_wargv(&wargc_expand, wargv_expand);
592 MSVCRT___argc = wargc_expand;
593 MSVCRT___argv = build_argv( wargv_expand );
594 }else {
595 expand_wildcards = 0;
598 if (!expand_wildcards) {
599 MSVCRT___argc = initial_argc;
600 MSVCRT___argv = build_argv( initial_wargv );
603 *argc = MSVCRT___argc;
604 *argv = MSVCRT___argv;
605 *envp = MSVCRT___initenv;
607 if (new_mode)
608 _set_new_mode( *new_mode );
609 return 0;
612 #ifdef _CRTDLL
613 /*********************************************************************
614 * __GetMainArgs (CRTDLL.@)
616 void CDECL __GetMainArgs( int *argc, char ***argv, char ***envp, int expand_wildcards )
618 int new_mode = 0;
619 __getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
621 #endif
623 /*********************************************************************
624 * _initterm (MSVCRT.@)
626 void CDECL _initterm(_INITTERMFUN *start,_INITTERMFUN *end)
628 _INITTERMFUN* current = start;
630 TRACE("(%p,%p)\n",start,end);
631 while (current<end)
633 if (*current)
635 TRACE("Call init function %p\n",*current);
636 (**current)();
637 TRACE("returned\n");
639 current++;
643 /*********************************************************************
644 * _initterm_e (MSVCRT.@)
646 * call an array of application initialization functions and report the return value
648 int CDECL _initterm_e(_INITTERM_E_FN *table, _INITTERM_E_FN *end)
650 int res = 0;
652 TRACE("(%p, %p)\n", table, end);
654 while (!res && table < end) {
655 if (*table) {
656 TRACE("calling %p\n", **table);
657 res = (**table)();
658 if (res)
659 TRACE("function %p failed: 0x%x\n", *table, res);
662 table++;
664 return res;
667 /*********************************************************************
668 * __set_app_type (MSVCRT.@)
670 void CDECL __set_app_type(int app_type)
672 TRACE("(%d) %s application\n", app_type, app_type == 2 ? "Gui" : "Console");
673 MSVCRT_app_type = app_type;
676 #if _MSVCR_VER>=140
678 /*********************************************************************
679 * _get_initial_narrow_environment (UCRTBASE.@)
681 char** CDECL _get_initial_narrow_environment(void)
683 return MSVCRT___initenv;
686 /*********************************************************************
687 * _configure_narrow_argv (UCRTBASE.@)
689 int CDECL _configure_narrow_argv(int mode)
691 TRACE("(%d)\n", mode);
692 return 0;
695 /*********************************************************************
696 * _initialize_narrow_environment (UCRTBASE.@)
698 int CDECL _initialize_narrow_environment(void)
700 TRACE("\n");
701 return 0;
704 /*********************************************************************
705 * _get_initial_wide_environment (UCRTBASE.@)
707 wchar_t** CDECL _get_initial_wide_environment(void)
709 return MSVCRT___winitenv;
712 /*********************************************************************
713 * _configure_wide_argv (UCRTBASE.@)
715 int CDECL _configure_wide_argv(int mode)
717 WARN("(%d) stub\n", mode);
718 return 0;
721 /*********************************************************************
722 * _initialize_wide_environment (UCRTBASE.@)
724 int CDECL _initialize_wide_environment(void)
726 WARN("stub\n");
727 return 0;
730 /*********************************************************************
731 * _get_narrow_winmain_command_line (UCRTBASE.@)
733 char* CDECL _get_narrow_winmain_command_line(void)
735 static char *narrow_command_line;
736 char *s;
738 if (narrow_command_line)
739 return narrow_command_line;
741 s = GetCommandLineA();
742 while (*s && *s != ' ' && *s != '\t')
744 if (*s++ == '"')
746 while (*s && *s++ != '"')
751 while (*s == ' ' || *s == '\t')
752 s++;
754 return narrow_command_line = s;
757 /*********************************************************************
758 * _get_wide_winmain_command_line (UCRTBASE.@)
760 wchar_t* CDECL _get_wide_winmain_command_line(void)
762 static wchar_t *wide_command_line;
763 wchar_t *s;
765 if (wide_command_line)
766 return wide_command_line;
768 s = GetCommandLineW();
769 while (*s && *s != ' ' && *s != '\t')
771 if (*s++ == '"')
773 while (*s && *s++ != '"')
778 while (*s == ' ' || *s == '\t')
779 s++;
781 return wide_command_line = s;
784 #endif /* _MSVCR_VER>=140 */
786 /*********************************************************************
787 * _get_winmajor (MSVCRT.@)
789 int CDECL _get_winmajor(int* value)
791 if (!MSVCRT_CHECK_PMT(value != NULL)) return EINVAL;
792 *value = MSVCRT__winmajor;
793 return 0;
796 /*********************************************************************
797 * _get_winminor (MSVCRT.@)
799 int CDECL _get_winminor(int* value)
801 if (!MSVCRT_CHECK_PMT(value != NULL)) return EINVAL;
802 *value = MSVCRT__winminor;
803 return 0;
806 /*********************************************************************
807 * _get_osver (MSVCRT.@)
809 int CDECL _get_osver(int* value)
811 if (!MSVCRT_CHECK_PMT(value != NULL)) return EINVAL;
812 *value = MSVCRT__osver;
813 return 0;