1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #if defined(_WIN32) // Windows
21 # define WIN32_LEAN_AND_MEAN
35 # include <crt_externs.h>
36 # define environ (*_NSGetEnviron())
38 extern char** environ
;
43 # define SLEEP(t) (Sleep((t)*1000))
45 # define SLEEP(t) (sleep((t)))
48 static void wait_for_seconds(char* time
)
55 static void w_to_a(LPCWSTR strW
, LPSTR strA
, DWORD size
)
57 WideCharToMultiByte(CP_ACP
, 0, strW
, -1, strA
, size
, nullptr, nullptr);
60 static void dump_env(char* file_path
)
62 LPWSTR env
= GetEnvironmentStringsW();
65 std::ofstream
file(file_path
);
68 while (size_t l
= wcslen(p
))
70 w_to_a(p
, buffer
, sizeof(buffer
));
71 file
<< buffer
<< '\0';
74 FreeEnvironmentStringsW(env
);
77 static void dump_env(char* file_path
)
79 std::ofstream
file(file_path
);
80 for (int i
= 0; environ
[i
] != nullptr; ++i
)
81 file
<< environ
[i
] << '\0';
85 int main(int argc
, char* argv
[])
89 if (strcmp("-join", argv
[1]) == 0)
91 // coverity[tainted_data] - this is a build-time only test tool
92 wait_for_seconds(argv
[2]);
94 else if (strcmp("-env", argv
[1]) == 0)
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */