diff options
Diffstat (limited to 'src/wix/wixnative/wixnative.cpp')
-rw-r--r-- | src/wix/wixnative/wixnative.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/wix/wixnative/wixnative.cpp b/src/wix/wixnative/wixnative.cpp index 7bd8dbca..d1236da1 100644 --- a/src/wix/wixnative/wixnative.cpp +++ b/src/wix/wixnative/wixnative.cpp | |||
@@ -36,3 +36,31 @@ int __cdecl wmain(int argc, LPWSTR argv[]) | |||
36 | ConsoleUninitialize(); | 36 | ConsoleUninitialize(); |
37 | return HRESULT_CODE(hr); | 37 | return HRESULT_CODE(hr); |
38 | } | 38 | } |
39 | |||
40 | HRESULT WixNativeReadStdinPreamble() | ||
41 | { | ||
42 | HRESULT hr = S_OK; | ||
43 | LPWSTR sczLine = NULL; | ||
44 | size_t cchPreamble = 0; | ||
45 | |||
46 | // Read the first line to determine if a byte-order-mark was prepended to stdin. | ||
47 | // A byte-order-mark is not normally expected but has been seen in some CI/CD systems. | ||
48 | // The preable is a single line with ":". | ||
49 | hr = ConsoleReadW(&sczLine); | ||
50 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "failed to read preamble from stdin"); | ||
51 | |||
52 | hr = ::StringCchLengthW(sczLine, STRSAFE_MAX_CCH, &cchPreamble); | ||
53 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "failed to get length of stdin preamble"); | ||
54 | |||
55 | // Ensure the preamble ends with ":" and ignore anything before that (since it may be a BOM). | ||
56 | if (!cchPreamble || sczLine[cchPreamble - 1] != L':') | ||
57 | { | ||
58 | hr = E_INVALIDDATA; | ||
59 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "expected ':' as preamble on first line of stdin"); | ||
60 | } | ||
61 | |||
62 | LExit: | ||
63 | ReleaseStr(sczLine); | ||
64 | |||
65 | return hr; | ||
66 | } | ||