1 /* $MirOS: contrib/code/jupp/win32.c,v 1.3 2017/01/11 21:48:58 tg Exp $ */
4 * Copyright (c) 2016, 2017
5 * mirabilos <m@mirbsd.org>
7 * Provided that these terms and disclaimer and all copyright notices
8 * are retained or reproduced in an accompanying document, permission
9 * is granted to deal in this work without restriction, including un-
10 * limited rights to use, publicly perform, distribute, sell, modify,
11 * merge, give away, or sublicence.
13 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
14 * the utmost extent permitted by applicable law, neither express nor
15 * implied; without malicious intent or gross negligence. In no event
16 * may a licensor, author or contributor be held liable for indirect,
17 * direct, other damage, loss, or other issues arising in any way out
18 * of dealing in the work, even if advised of the possibility of such
19 * damage or existence of a defect, except proven that it results out
20 * of said person's immediate fault when using the work as intended.
25 #include <cygwin/version.h>
30 * Retrieve the realpath of the program (what could be argv[0] if the
31 * Unix designers had wanted it).
37 /* plus one to detect truncation */
38 char buf[MAX_PATH + 1];
40 if (!(res = GetModuleFileName(NULL, buf, sizeof(buf))) ||
41 ((size_t)res > (size_t)(MAX_PATH)))
48 /* return command line as passed to the .EXE (just like cygwin32’s dcrt0.cc) */
50 cygwin32_cmdline(void)
54 cp = strdup(GetCommandLineA());
55 if (!AreFileApisANSI())
57 return ((unsigned char *)cp);
60 /* Cygwin before 1.7.2 did not have locale support */
61 #if defined(CYGWIN_VERSION_API_MAJOR) && (CYGWIN_VERSION_API_MAJOR < 1) && \
62 defined(CYGWIN_VERSION_API_MINOR) && (CYGWIN_VERSION_API_MINOR < 222)
64 * Mirror get_cp() in winsup/cygwin/miscfuncs.cc as used by
65 * dev_console::str_to_con() in winsup/cygwin/fhandler_console.cc
70 return (AreFileApisANSI() ? GetACP() : GetOEMCP());
74 #endif /* __CYGWIN__ */