char array should be null terminated
[LibreOffice.git] / jvmfwk / source / fwkutil.hxx
blob9e241cf92efe9b698f431e22575f288e58edc598
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #if !defined INCLUDED_JVMFWK_FWKUTIL_HXX
29 #define INCLUDED_JVMFWK_FWKUTIL_HXX
31 #include "sal/config.h"
32 #include "osl/mutex.hxx"
33 #include "rtl/bootstrap.hxx"
34 #include "rtl/instance.hxx"
35 #include "rtl/ustrbuf.hxx"
36 #include "rtl/byteseq.hxx"
37 #include "osl/thread.hxx"
38 #if OSL_DEBUG_LEVEL >=2
39 #include <stdio.h>
40 #endif
43 namespace jfw
46 /** Returns the file URL of the directory where the framework library
47 (this library) resides.
49 rtl::OUString getLibraryLocation();
51 /** provides a bootstrap class which already knows the values from the
52 jvmfkwrc file.
54 struct Bootstrap :
55 public ::rtl::StaticWithInit< const rtl::Bootstrap *, Bootstrap > {
56 const rtl::Bootstrap * operator () () {
57 ::rtl::OUStringBuffer buf(256);
58 buf.append(getLibraryLocation());
59 buf.appendAscii(SAL_CONFIGFILE("/jvmfwk3"));
60 ::rtl::OUString sIni = buf.makeStringAndClear();
61 ::rtl::Bootstrap * bootstrap = new ::rtl::Bootstrap(sIni);
62 #if OSL_DEBUG_LEVEL >=2
63 rtl::OString o = rtl::OUStringToOString( sIni , osl_getThreadTextEncoding() );
64 fprintf(stderr, "[Java framework] Using configuration file %s\n" , o.getStr() );
65 #endif
66 return bootstrap;
70 struct FwkMutex: public ::rtl::Static<osl::Mutex, FwkMutex> {};
72 rtl::ByteSequence encodeBase16(const rtl::ByteSequence& rawData);
73 rtl::ByteSequence decodeBase16(const rtl::ByteSequence& data);
75 rtl::OUString getPlatform();
78 rtl::OUString getDirFromFile(const rtl::OUString& usFilePath);
80 /** Returns the file URL of the folder where the executable resides.
82 rtl::OUString getExecutableDirectory();
83 /** Locates the plugin library and returns the file URL.
85 First tries to locate plugin relative to baseUrl (if relative);
86 vnd.sun.star.expand URLs are supported. If that fails, tries to
87 locate plugin relative to the executable. If that fails, and plugin
88 contains no slashes, tries to locate plugin in a platform-specific way
89 (e.g., LD_LIBRARY_PATH).
91 @param baseUrl
92 The base file URL relative to which the plugin argument is interpreted.
94 @param plugin
95 The argument is an absolute or relative URL or just the name of the plugin.
97 rtl::OUString findPlugin(
98 const rtl::OUString & baseUrl, const rtl::OUString & plugin);
101 enum FileStatus
103 FILE_OK,
104 FILE_DOES_NOT_EXIST,
105 FILE_INVALID
108 /** checks if the URL is a file.
110 If it is a link to a file than
111 it is resolved. Assuming that the argument
112 represents a relative URL then FILE_INVALID
113 is returned.
116 @return
117 one of the values of FileStatus.
119 @exception
120 Errors occurred during determining if the file exists
122 FileStatus checkFileURL(const rtl::OUString & path);
125 struct PluginLibrary;
126 class VersionInfo;
127 class CJavaInfo;
129 bool isAccessibilitySupportDesired();
131 rtl::OUString buildClassPathFromDirectory(const rtl::OUString & relPath);
133 rtl::OUString retrieveClassPath( ::rtl::OUString const & macro );
135 #endif
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */