bump product version to 4.1.6.2
[LibreOffice.git] / desktop / win32 / source / unoinfo.cxx
blobbb02e89801128414e0e77d8773850915c4d801ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <cstddef>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <wchar.h>
25 #define WIN32_LEAN_AND_MEAN
26 #if defined _MSC_VER
27 #pragma warning(push, 1)
28 #endif
29 #include <windows.h>
30 #if defined _MSC_VER
31 #pragma warning(pop)
32 #endif
34 #include "tools/pathutils.hxx"
36 #define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
37 #define MY_STRING(s) (s), MY_LENGTH(s)
39 namespace {
41 wchar_t * getBrandPath(wchar_t * path) {
42 DWORD n = GetModuleFileNameW(NULL, path, MAX_PATH);
43 if (n == 0 || n >= MAX_PATH) {
44 exit(EXIT_FAILURE);
46 return tools::filename(path);
49 void writeNull() {
50 if (fwrite("\0\0", 1, 2, stdout) != 2) {
51 exit(EXIT_FAILURE);
55 void writePath(
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);
62 if (end == NULL) {
63 exit(EXIT_FAILURE);
65 std::size_t n = (end - path) * sizeof (wchar_t);
66 if (fwrite(path, 1, n, stdout) != n) {
67 exit(EXIT_FAILURE);
73 #ifdef __MINGW32__
74 int main(int argc, char ** argv, char **) {
75 if (argc == 2 && strcmp(argv[1], "c++") == 0) {
76 #else
77 int wmain(int argc, wchar_t ** argv, wchar_t **) {
78 if (argc == 2 && wcscmp(argv[1], L"c++") == 0) {
79 #endif
80 wchar_t path[MAX_PATH];
81 wchar_t * pathEnd = getBrandPath(path);
82 if (tools::buildPath(path, path, pathEnd, MY_STRING(L"..\\ure-link")) ==
83 NULL)
85 exit(EXIT_FAILURE);
87 pathEnd = tools::resolveLink(path);
88 if (pathEnd == NULL) {
89 exit(EXIT_FAILURE);
91 writePath(path, pathEnd, MY_STRING(L"\\bin"));
92 #ifdef __MINGW32__
93 } else if (argc == 2 && strcmp(argv[1], "java") == 0) {
94 #else
95 } else if (argc == 2 && wcscmp(argv[1], L"java") == 0) {
96 #endif
97 if (fwrite("1", 1, 1, stdout) != 1) {
98 exit(EXIT_FAILURE);
100 wchar_t path[MAX_PATH];
101 wchar_t * pathEnd = getBrandPath(path);
102 writePath(path, pathEnd, MY_STRING(L""));
103 writeNull();
104 writePath(path, pathEnd, MY_STRING(L"classes\\unoil.jar"));
105 if (tools::buildPath(path, path, pathEnd, MY_STRING(L"..\\ure-link")) ==
106 NULL)
108 exit(EXIT_FAILURE);
110 pathEnd = tools::resolveLink(path);
111 if (pathEnd == NULL) {
112 exit(EXIT_FAILURE);
114 writeNull();
115 writePath(path, pathEnd, MY_STRING(L"\\java\\ridl.jar"));
116 writeNull();
117 writePath(path, pathEnd, MY_STRING(L"\\java\\jurt.jar"));
118 writeNull();
119 writePath(path, pathEnd, MY_STRING(L"\\java\\juh.jar"));
120 } else {
121 exit(EXIT_FAILURE);
123 exit(EXIT_SUCCESS);
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */