FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/tools/executable_wrapper.h at patch-1 · computerscienceiscool/node · GitHub
computerscienceiscool
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
tools
/
executable_wrapper.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
55 lines (48 loc) · 1.48 KB
Breadcrumbs
node
/
tools
/
executable_wrapper.h
Copy path
File metadata and controls
executable file
·
55 lines (48 loc) · 1.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
ifndef
TOOLS_EXECUTABLE_WRAPPER_H_
#
define
TOOLS_EXECUTABLE_WRAPPER_H_
//
TODO(joyeecheung): reuse this in mksnapshot.
#
include
"
uv.h
"
#
ifdef
_WIN32
#
include
<
windows.h
>
#
endif
namespace
node
{
#
ifdef
_WIN32
using
argv_type =
wchar_t
*;
#
define
NODE_MAIN
int
wmain
void
FixupMain
(
int
argc, argv_type raw_argv[],
char
*** argv) {
//
Convert argv to UTF8.
*argv =
new
char
*[argc +
1
];
for
(
int
i =
0
; i < argc; i++) {
//
Compute the size of the required buffer
DWORD
size =
WideCharToMultiByte
(
CP_UTF8
,
0
, raw_argv[i], -
1
,
nullptr
,
0
,
nullptr
,
nullptr
);
if
(size ==
0
) {
//
This should never happen.
fprintf
(stderr,
"
Could not convert arguments to utf8.
"
);
exit
(
1
);
}
//
Do the actual conversion
(*argv)[i] =
new
char
[size];
DWORD
result =
WideCharToMultiByte
(
CP_UTF8
,
0
, raw_argv[i], -
1
, (*argv)[i], size,
nullptr
,
nullptr
);
if
(result ==
0
) {
//
This should never happen.
fprintf
(stderr,
"
Could not convert arguments to utf8.
"
);
exit
(
1
);
}
}
(*argv)[argc] =
nullptr
;
}
#
else
using
argv_type =
char
*;
#
define
NODE_MAIN
int
main
void
FixupMain
(
int
argc, argv_type raw_argv[],
char
*** argv) {
*argv =
uv_setup_args
(argc, raw_argv);
//
Disable stdio buffering, it interacts poorly with printf()
//
calls elsewhere in the program (e.g., any logging from V8.)
setvbuf
(stdout,
nullptr
, _IONBF,
0
);
setvbuf
(stderr,
nullptr
, _IONBF,
0
);
}
#
endif
}
//
namespace node
#
endif
//
TOOLS_EXECUTABLE_WRAPPER_H_
Back
|
FazBrowse Home
|
New Git URL