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 .
25 #define WIN32_LEAN_AND_MEAN
27 #pragma warning(push, 1)
34 #include <tools/pathutils.hxx>
36 #define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
37 #define MY_STRING(s) (s), MY_LENGTH(s)
41 wchar_t * getBrandPath(wchar_t * path
) {
42 DWORD n
= GetModuleFileNameW(NULL
, path
, MAX_PATH
);
43 if (n
== 0 || n
>= MAX_PATH
) {
46 return tools::filename(path
);
50 if (fwrite("\0\0", 1, 2, stdout
) != 2) {
56 wchar_t const * frontBegin
, wchar_t const * frontEnd
,
57 wchar_t const * backBegin
, std::size_t backLength
)
59 wchar_t path
[MAX_PATH
];
60 wchar_t * end
= tools::buildPath(
61 path
, frontBegin
, frontEnd
, backBegin
, backLength
);
65 std::size_t n
= (end
- path
) * sizeof (wchar_t);
66 if (fwrite(path
, 1, n
, stdout
) != n
) {
74 int main(int argc
, char ** argv
, char **) {
75 if (argc
== 2 && strcmp(argv
[1], "c++") == 0) {
77 int wmain(int argc
, wchar_t ** argv
, wchar_t **) {
78 if (argc
== 2 && wcscmp(argv
[1], L
"c++") == 0) {
80 wchar_t path
[MAX_PATH
];
81 wchar_t * pathEnd
= getBrandPath(path
);
82 writePath(path
, pathEnd
, MY_STRING(L
""));
84 } else if (argc
== 2 && strcmp(argv
[1], "java") == 0) {
86 } else if (argc
== 2 && wcscmp(argv
[1], L
"java") == 0) {
88 if (fwrite("1", 1, 1, stdout
) != 1) {
91 wchar_t path
[MAX_PATH
];
92 wchar_t * pathEnd
= getBrandPath(path
);
93 writePath(path
, pathEnd
, MY_STRING(L
"classes\\ridl.jar"));
95 writePath(path
, pathEnd
, MY_STRING(L
"classes\\jurt.jar"));
97 writePath(path
, pathEnd
, MY_STRING(L
"classes\\juh.jar"));
99 writePath(path
, pathEnd
, MY_STRING(L
"classes\\unoil.jar"));
101 writePath(path
, pathEnd
, MY_STRING(L
""));
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */