1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoinfo.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
36 #define WIN32_LEAN_AND_MEAN
38 #pragma warning(push, 1)
45 #include "tools/pathutils.hxx"
47 #define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
48 #define MY_STRING(s) (s), MY_LENGTH(s)
52 wchar_t * getBrandPath(wchar_t * path
) {
53 DWORD n
= GetModuleFileNameW(NULL
, path
, MAX_PATH
);
54 if (n
== 0 || n
>= MAX_PATH
) {
57 return tools::filename(path
);
61 if (fwrite("\0\0", 1, 2, stdout
) != 2) {
67 wchar_t const * frontBegin
, wchar_t const * frontEnd
,
68 wchar_t const * backBegin
, std::size_t backLength
)
70 wchar_t path
[MAX_PATH
];
71 wchar_t * end
= tools::buildPath(
72 path
, frontBegin
, frontEnd
, backBegin
, backLength
);
76 std::size_t n
= (end
- path
) * sizeof (wchar_t);
77 if (fwrite(path
, 1, n
, stdout
) != n
) {
85 int main(int argc
, char ** argv
, char **) {
86 if (argc
== 2 && strcmp(argv
[1], "c++") == 0) {
88 int wmain(int argc
, wchar_t ** argv
, wchar_t **) {
89 if (argc
== 2 && wcscmp(argv
[1], L
"c++") == 0) {
91 wchar_t path
[MAX_PATH
];
92 wchar_t * pathEnd
= getBrandPath(path
);
93 if (tools::buildPath(path
, path
, pathEnd
, MY_STRING(L
"..\\basis-link"))
98 pathEnd
= tools::resolveLink(path
);
99 if (pathEnd
== NULL
||
100 (tools::buildPath(path
, path
, pathEnd
, MY_STRING(L
"\\ure-link")) ==
105 pathEnd
= tools::resolveLink(path
);
106 if (pathEnd
== NULL
) {
109 writePath(path
, pathEnd
, MY_STRING(L
"\\bin"));
111 } else if (argc
== 2 && strcmp(argv
[1], "java") == 0) {
113 } else if (argc
== 2 && wcscmp(argv
[1], L
"java") == 0) {
115 if (fwrite("1", 1, 1, stdout
) != 1) {
118 wchar_t path
[MAX_PATH
];
119 wchar_t * pathEnd
= getBrandPath(path
);
120 writePath(path
, pathEnd
, MY_STRING(L
""));
121 if (tools::buildPath(path
, path
, pathEnd
, MY_STRING(L
"..\\basis-link"))
126 pathEnd
= tools::resolveLink(path
);
127 if (pathEnd
== NULL
) {
131 writePath(path
, pathEnd
, MY_STRING(L
"\\program\\classes\\unoil.jar"));
132 if (tools::buildPath(path
, path
, pathEnd
, MY_STRING(L
"\\ure-link")) ==
137 pathEnd
= tools::resolveLink(path
);
138 if (pathEnd
== NULL
) {
142 writePath(path
, pathEnd
, MY_STRING(L
"\\java\\ridl.jar"));
144 writePath(path
, pathEnd
, MY_STRING(L
"\\java\\jurt.jar"));
146 writePath(path
, pathEnd
, MY_STRING(L
"\\java\\juh.jar"));