summaryrefslogtreecommitdiff
path: root/sal/inc
diff options
context:
space:
mode:
Diffstat (limited to 'sal/inc')
-rw-r--r--sal/inc/internal/once.h79
-rw-r--r--sal/inc/makefile.mk47
-rw-r--r--sal/inc/osl/conditn.h92
-rw-r--r--sal/inc/osl/conditn.hxx128
-rw-r--r--sal/inc/osl/diagnose.h160
-rw-r--r--sal/inc/osl/diagnose.hxx205
-rw-r--r--sal/inc/osl/doublecheckedlocking.h81
-rw-r--r--sal/inc/osl/endian.h235
-rw-r--r--sal/inc/osl/file.h1593
-rw-r--r--sal/inc/osl/file.hxx1953
-rw-r--r--sal/inc/osl/getglobalmutex.hxx50
-rw-r--r--sal/inc/osl/interlck.h57
-rw-r--r--sal/inc/osl/module.h211
-rw-r--r--sal/inc/osl/module.hxx158
-rw-r--r--sal/inc/osl/mutex.h77
-rw-r--r--sal/inc/osl/mutex.hxx253
-rw-r--r--sal/inc/osl/nlsupport.h60
-rw-r--r--sal/inc/osl/pipe.h102
-rw-r--r--sal/inc/osl/pipe.hxx212
-rw-r--r--sal/inc/osl/pipe_decl.hxx235
-rw-r--r--sal/inc/osl/process.h428
-rw-r--r--sal/inc/osl/profile.h140
-rw-r--r--sal/inc/osl/profile.hxx204
-rw-r--r--sal/inc/osl/security.h158
-rw-r--r--sal/inc/osl/security.hxx110
-rw-r--r--sal/inc/osl/security_decl.hxx117
-rw-r--r--sal/inc/osl/semaphor.h95
-rw-r--r--sal/inc/osl/semaphor.hxx126
-rw-r--r--sal/inc/osl/signal.h114
-rw-r--r--sal/inc/osl/socket.h891
-rw-r--r--sal/inc/osl/socket.hxx565
-rw-r--r--sal/inc/osl/socket_decl.hxx722
-rw-r--r--sal/inc/osl/thread.h191
-rw-r--r--sal/inc/osl/thread.hxx233
-rw-r--r--sal/inc/osl/time.h160
-rw-r--r--sal/inc/osl/util.h53
-rw-r--r--sal/inc/pch/precompiled_sal.cxx29
-rw-r--r--sal/inc/pch/precompiled_sal.hxx32
-rw-r--r--sal/inc/rtl/alloc.h266
-rw-r--r--sal/inc/rtl/allocator.hxx192
-rw-r--r--sal/inc/rtl/bootstrap.h233
-rw-r--r--sal/inc/rtl/bootstrap.hxx234
-rw-r--r--sal/inc/rtl/byteseq.h322
-rw-r--r--sal/inc/rtl/byteseq.hxx143
-rw-r--r--sal/inc/rtl/cipher.h319
-rw-r--r--sal/inc/rtl/crc.h66
-rw-r--r--sal/inc/rtl/digest.h639
-rw-r--r--sal/inc/rtl/instance.hxx472
-rw-r--r--sal/inc/rtl/locale.h140
-rw-r--r--sal/inc/rtl/locale.hxx266
-rw-r--r--sal/inc/rtl/logfile.h134
-rw-r--r--sal/inc/rtl/logfile.hxx205
-rw-r--r--sal/inc/rtl/malformeduriexception.hxx74
-rw-r--r--sal/inc/rtl/math.h474
-rw-r--r--sal/inc/rtl/math.hxx432
-rw-r--r--sal/inc/rtl/memory.h51
-rw-r--r--sal/inc/rtl/process.h82
-rw-r--r--sal/inc/rtl/random.h114
-rw-r--r--sal/inc/rtl/ref.hxx242
-rw-r--r--sal/inc/rtl/strbuf.h119
-rw-r--r--sal/inc/rtl/strbuf.hxx665
-rw-r--r--sal/inc/rtl/string.h1193
-rw-r--r--sal/inc/rtl/string.hxx941
-rw-r--r--sal/inc/rtl/tencinfo.h276
-rw-r--r--sal/inc/rtl/textcvt.h180
-rw-r--r--sal/inc/rtl/textenc.h279
-rw-r--r--sal/inc/rtl/tres.h106
-rw-r--r--sal/inc/rtl/tres.hxx112
-rw-r--r--sal/inc/rtl/unload.h315
-rw-r--r--sal/inc/rtl/uri.h354
-rw-r--r--sal/inc/rtl/uri.hxx154
-rw-r--r--sal/inc/rtl/ustrbuf.h165
-rw-r--r--sal/inc/rtl/ustrbuf.hxx774
-rw-r--r--sal/inc/rtl/ustring.h1660
-rw-r--r--sal/inc/rtl/ustring.hxx1540
-rw-r--r--sal/inc/rtl/uuid.h209
-rw-r--r--sal/inc/sal/alloca.h66
-rw-r--r--sal/inc/sal/config.h152
-rw-r--r--sal/inc/sal/macros.h51
-rw-r--r--sal/inc/sal/main.h152
-rw-r--r--sal/inc/sal/mathconf.h147
-rw-r--r--sal/inc/sal/types.h435
-rw-r--r--sal/inc/systools/win32/AutoSystoolInit.hxx62
-rw-r--r--sal/inc/systools/win32/StrConvert.h132
-rw-r--r--sal/inc/systools/win32/SyncObjects.hxx110
-rw-r--r--sal/inc/systools/win32/advapi9x.h209
-rw-r--r--sal/inc/systools/win32/comdlg9x.h80
-rw-r--r--sal/inc/systools/win32/comptr.hxx233
-rw-r--r--sal/inc/systools/win32/comtools.hxx194
-rw-r--r--sal/inc/systools/win32/kernel9x.h383
-rw-r--r--sal/inc/systools/win32/mpr9x.h72
-rw-r--r--sal/inc/systools/win32/shell9x.h101
-rw-r--r--sal/inc/systools/win32/snprintf.h80
-rw-r--r--sal/inc/systools/win32/user9x.h192
-rw-r--r--sal/inc/systools/win32/uwinapi.h121
95 files changed, 27470 insertions, 0 deletions
diff --git a/sal/inc/internal/once.h b/sal/inc/internal/once.h
new file mode 100644
index 000000000000..4438f281215c
--- /dev/null
+++ b/sal/inc/internal/once.h
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SAL_INTERNAL_ONCE_H
+#define INCLUDED_SAL_INTERNAL_ONCE_H
+
+/** sal_once_type
+ * (platform dependent)
+ */
+
+#if defined(SAL_UNX) || defined(SAL_OS2)
+
+#include <pthread.h>
+
+typedef pthread_once_t sal_once_type;
+
+#define SAL_ONCE_INIT PTHREAD_ONCE_INIT
+#define SAL_ONCE(once, init) pthread_once((once), (init))
+
+#elif defined(SAL_W32)
+
+#define WIN32_LEAN_AND_MEAN
+#pragma warning(push,1) /* disable warnings within system headers */
+#include <windows.h>
+#pragma warning(pop)
+
+typedef struct sal_once_st sal_once_type;
+struct sal_once_st
+{
+ LONG volatile m_done;
+ LONG volatile m_lock;
+};
+
+#define SAL_ONCE_INIT { 0, 0 }
+#define SAL_ONCE(once, init) \
+{ \
+ sal_once_type * control = (once); \
+ if (!(control->m_done)) \
+ { \
+ while (InterlockedExchange(&(control->m_lock), 1) == 1) Sleep(0); \
+ if (!(control->m_done)) \
+ { \
+ void (*init_routine)(void) = (init); \
+ (*init_routine)(); \
+ control->m_done = 1; \
+ } \
+ InterlockedExchange(&(control->m_lock), 0); \
+ } \
+}
+
+#else
+#error Unknown platform
+#endif /* SAL_UNX | SAL_W32 */
+
+#endif /* INCLUDED_SAL_INTERNAL_ONCE_H */
diff --git a/sal/inc/makefile.mk b/sal/inc/makefile.mk
new file mode 100644
index 000000000000..19d6b36fe084
--- /dev/null
+++ b/sal/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=sal
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/sal/inc/osl/conditn.h b/sal/inc/osl/conditn.h
new file mode 100644
index 000000000000..debcdd882179
--- /dev/null
+++ b/sal/inc/osl/conditn.h
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _OSL_CONDITION_H_
+#define _OSL_CONDITION_H_
+
+#include <osl/time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* oslCondition;
+
+typedef enum {
+ osl_cond_result_ok, /* successful completion */
+ osl_cond_result_error, /* error occured, check osl_getLastSocketError() for details */
+ osl_cond_result_timeout, /* blocking operation timed out */
+ osl_cond_result_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslConditionResult;
+
+/** Creates a condition.
+ The condition is in the reset-state.
+ @returns 0 if condition could not be created.
+*/
+oslCondition SAL_CALL osl_createCondition(void);
+
+/** Free the memory used by the condition.
+ @param Condition the condition handle.
+*/
+void SAL_CALL osl_destroyCondition(oslCondition Condition);
+
+/** Sets condition to True => wait() will not block, check() returns True.
+ NOTE: ALL threads waiting on this condition are unblocked!
+ @param Condition handle to a created condition.
+ @return False if system-call failed.
+*/
+sal_Bool SAL_CALL osl_setCondition(oslCondition Condition);
+
+/** Sets condition to False => wait() will block, check() returns False
+ @param Condition handle to a created condition.
+ @return False if system-call failed.
+*/
+sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition);
+
+/** Blocks if condition is not set<BR>
+ If condition has been destroyed prematurely, wait() will
+ return with False.
+ @param Condition handle to a created condition.
+ @param pTimeout Tiemout value or NULL for infinite waiting
+ @return False if system-call failed.
+*/
+oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const TimeValue* pTimeout);
+
+/** Queries the state of the condition without blocking.
+ @param Condition handle to a created condition.
+ @return True: condition is set. <BR>
+ False: condition is not set. <BR>
+*/
+sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_CONDITION_H_ */
+
diff --git a/sal/inc/osl/conditn.hxx b/sal/inc/osl/conditn.hxx
new file mode 100644
index 000000000000..e0393ca98302
--- /dev/null
+++ b/sal/inc/osl/conditn.hxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_CONDITN_HXX_
+#define _OSL_CONDITN_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/time.h>
+
+#include <osl/conditn.h>
+
+
+namespace osl
+{
+
+ class Condition
+ {
+ public:
+
+ enum Result
+ {
+ result_ok = osl_cond_result_ok,
+ result_error = osl_cond_result_error,
+ result_timeout = osl_cond_result_timeout
+ };
+
+ /* Create a condition.
+ */
+ Condition()
+ {
+ condition = osl_createCondition();
+ }
+
+ /* Release the OS-structures and free condition data-structure.
+ */
+ ~Condition()
+ {
+ osl_destroyCondition(condition);
+ }
+
+ /* Release all waiting threads, check returns sal_True.
+ */
+ void set()
+ {
+ osl_setCondition(condition);
+ }
+
+ /* Reset condition to false: wait() will block, check() returns sal_False.
+ */
+ void reset() {
+ osl_resetCondition(condition);
+ }
+
+ /** Blocks the calling thread until condition is set.
+ */
+ Result wait(const TimeValue *pTimeout = 0)
+ {
+ return (Result) osl_waitCondition(condition, pTimeout);
+ }
+
+ /** Checks if the condition is set without blocking.
+ */
+ sal_Bool check()
+ {
+ return osl_checkCondition(condition);
+ }
+
+
+ private:
+ oslCondition condition;
+
+ /** The underlying oslCondition has no reference count.
+
+ Since the underlying oslCondition is not a reference counted object, copy
+ constructed Condition may work on an already destructed oslCondition object.
+
+ */
+ Condition(const Condition&);
+
+ /** The underlying oslCondition has no reference count.
+
+ When destructed, the Condition object destroys the undelying oslCondition,
+ which might cause severe problems in case it's a temporary object.
+
+ */
+ Condition(oslCondition condition);
+
+ /** This assignment operator is private for the same reason as
+ the copy constructor.
+ */
+ Condition& operator= (const Condition&);
+
+ /** This assignment operator is private for the same reason as
+ the constructor taking a oslCondition argument.
+ */
+ Condition& operator= (oslCondition);
+ };
+
+}
+
+#endif /* __cplusplus */
+#endif /* _OSL_CONDITN_HXX_ */
+
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
new file mode 100644
index 000000000000..055a7971e7b6
--- /dev/null
+++ b/sal/inc/osl/diagnose.h
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _OSL_DIAGNOSE_H_
+#define _OSL_DIAGNOSE_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* //////////////////////////////////////////////////////////////////////////
+ Diagnostic support
+*/
+
+void SAL_CALL osl_breakDebug(void);
+sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const sal_Char* pszMessage);
+void SAL_CALL osl_trace(const sal_Char* pszFormat, ...);
+sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszErrorMessage);
+
+/*
+ For message delivery
+*/
+
+/** a message delivery function which receives a pre-formatted message string
+*/
+typedef void (SAL_CALL *pfunc_osl_printDebugMessage)( const sal_Char * pszMessage );
+
+/** a message delivery function which receives detailed information about where the message was triggered
+*/
+typedef void (SAL_CALL *pfunc_osl_printDetailedDebugMessage)( const sal_Char * pszFileName, sal_Int32 nLine, const sal_Char* pszMessage );
+
+/** sets a message delivery function
+
+ The function set here is ignored if a function for detailed message information
+ (pfunc_osl_printDetailedDebugMessage) has been set.
+
+ The given message handler must be able to cope with a <NULL/> message.
+*/
+pfunc_osl_printDebugMessage SAL_CALL osl_setDebugMessageFunc( pfunc_osl_printDebugMessage pNewFunc );
+
+/** sets a delivery function for detailed message information.
+
+ The given message handler must be able to cope with a <NULL/> message.
+*/
+pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pfunc_osl_printDetailedDebugMessage pNewFunc );
+
+#ifdef __cplusplus
+}
+#endif
+
+#define OSL_THIS_FILE __FILE__
+
+/* the macro OSL_THIS_FUNC is intended to be an office internal macro for now */
+#ifdef __func__
+#define OSL_THIS_FUNC __func__
+#elifdef __PRETTY_FUNCTION__
+#define OSL_THIS_FUNC __PRETTY_FUNCTION__
+#elifdef __FUNCTION__
+#define OSL_THIS_FUNC __FUNCTION__
+#else
+#define OSL_THIS_FUNC " "
+#endif
+
+/* the macro OSL_TO_STRING is intended to be an office internal macro for now */
+#define OSL_TO_STRING( x ) #x
+
+/* the macro OSL_MACRO_VALUE_TO_STRING is intended to be an office internal macro for now */
+#define OSL_MACRO_VALUE_TO_STRING( x ) OSL_TO_STRING( x )
+
+/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now */
+#define OSL_LOG_PREFIX OSL_THIS_FILE ":" OSL_THIS_FUNC ":" OSL_MACRO_VALUE_TO_STRING( __LINE__ ) "; "
+
+#define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
+#define OSL_TRACE _OSL_TRACE
+#define OSL_ASSERT(c) _OSL_ASSERT(c, OSL_THIS_FILE, __LINE__)
+#define OSL_ENSURE(c, m) _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
+
+#define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
+#define OSL_PRECOND(c, m) OSL_ENSURE(c, m)
+#define OSL_POSTCOND(c, m) OSL_ENSURE(c, m)
+
+
+#ifdef __cplusplus
+#define _OSL_GLOBAL ::
+#else
+#define _OSL_GLOBAL
+#endif /* __cplusplus */
+
+#ifdef _WIN16
+#if OSL_DEBUG_LEVEL > 0
+#undef OSL_DEBUG_LEVEL
+#define OSL_DEBUG_LEVEL 0
+#endif
+#endif
+
+
+
+#if OSL_DEBUG_LEVEL > 0
+
+#define _OSL_DEBUG_ONLY(f) (f)
+#define _OSL_ASSERT(c, f, l) \
+ do \
+ { \
+ if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, 0)) \
+ _OSL_GLOBAL osl_breakDebug(); \
+ } while (0)
+
+#define _OSL_ENSURE(c, f, l, m) \
+ do \
+ { \
+ if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \
+ _OSL_GLOBAL osl_breakDebug(); \
+ } while (0)
+
+#else
+
+#define _OSL_DEBUG_ONLY(f) ((void)0)
+#define _OSL_ASSERT(c, f, l) ((void)0)
+#define _OSL_ENSURE(c, f, l, m) ((void)0)
+
+#endif /* OSL_DEBUG_LEVEL */
+
+#if OSL_DEBUG_LEVEL > 1
+
+#define _OSL_TRACE _OSL_GLOBAL osl_trace
+
+#else
+
+#define _OSL_TRACE 1 ? ((void)0) : _OSL_GLOBAL osl_trace
+
+#endif /* OSL_DEBUG_LEVEL */
+
+#endif /* _OSL_DIAGNOSE_H_ */
diff --git a/sal/inc/osl/diagnose.hxx b/sal/inc/osl/diagnose.hxx
new file mode 100644
index 000000000000..e7360e93349e
--- /dev/null
+++ b/sal/inc/osl/diagnose.hxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#if ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
+#define OSL_DIAGNOSE_HXX_INCLUDED
+
+#if ! defined(_OSL_DIAGNOSE_H_)
+#include "osl/diagnose.h"
+#endif
+#if ! defined(_OSL_INTERLOCK_H_)
+#include "osl/interlck.h"
+#endif
+#if ! defined(_OSL_MUTEX_HXX_)
+#include "osl/mutex.hxx"
+#endif
+#if ! defined(INCLUDED_RTL_ALLOCATOR_HXX)
+#include "rtl/allocator.hxx"
+#endif
+#if ! defined(_RTL_INSTANCE_HXX_)
+#include "rtl/instance.hxx"
+#endif
+#include <hash_set>
+#include <functional>
+#include <typeinfo>
+
+namespace osl {
+/// @internal
+namespace detail {
+
+struct ObjectRegistryData;
+
+} // namespace detail
+} // namespace osl
+
+extern "C" {
+
+/** @internal */
+bool SAL_CALL osl_detail_ObjectRegistry_storeAddresses( char const* pName )
+ SAL_THROW_EXTERN_C();
+
+/** @internal */
+bool SAL_CALL osl_detail_ObjectRegistry_checkObjectCount(
+ ::osl::detail::ObjectRegistryData const& rData, ::std::size_t nExpected )
+ SAL_THROW_EXTERN_C();
+
+/** @internal */
+void SAL_CALL osl_detail_ObjectRegistry_registerObject(
+ ::osl::detail::ObjectRegistryData & rData, void const* pObj )
+ SAL_THROW_EXTERN_C();
+
+/** @internal */
+void SAL_CALL osl_detail_ObjectRegistry_revokeObject(
+ ::osl::detail::ObjectRegistryData & rData, void const* pObj )
+ SAL_THROW_EXTERN_C();
+
+/** @internal */
+::osl::Mutex & SAL_CALL osl_detail_ObjectRegistry_getMutex()
+ SAL_THROW_EXTERN_C();
+
+} // extern "C"
+
+namespace osl {
+
+/// @internal
+namespace detail {
+
+struct VoidPtrHash : ::std::unary_function<void const*, ::std::size_t> {
+ ::std::size_t operator()( void const* p ) const {
+ ::std::size_t const d = static_cast< ::std::size_t >(
+ reinterpret_cast< ::std::ptrdiff_t >(p) );
+ return d + (d >> 3);
+ }
+};
+
+typedef ::std::hash_set<void const*, VoidPtrHash, ::std::equal_to<void const*>,
+ ::rtl::Allocator<void const*> > VoidPointerSet;
+
+struct ObjectRegistryData {
+ ObjectRegistryData( ::std::type_info const& rTypeInfo )
+ : m_pName(rTypeInfo.name()), m_nCount(0), m_addresses(),
+ m_bStoreAddresses(osl_detail_ObjectRegistry_storeAddresses(m_pName)){}
+
+ char const* const m_pName;
+ oslInterlockedCount m_nCount;
+ VoidPointerSet m_addresses;
+ bool const m_bStoreAddresses;
+};
+
+template <typename T>
+class ObjectRegistry
+{
+public:
+ ObjectRegistry() : m_data( typeid(T) ) {}
+ ~ObjectRegistry() { checkObjectCount(0); }
+
+ bool checkObjectCount( ::std::size_t nExpected ) const {
+ bool const bRet = osl_detail_ObjectRegistry_checkObjectCount(
+ m_data, nExpected );
+ if (!bRet && m_data.m_bStoreAddresses) {
+ MutexGuard const guard( osl_detail_ObjectRegistry_getMutex() );
+ // following loop is for debugging purposes, iterating over map:
+ VoidPointerSet::const_iterator iPos(m_data.m_addresses.begin());
+ VoidPointerSet::const_iterator const iEnd(m_data.m_addresses.end());
+ for ( ; iPos != iEnd; ++iPos ) {
+ OSL_ASSERT( *iPos != 0 );
+ }
+ }
+ return bRet;
+ }
+
+ void registerObject( void const* pObj ) {
+ osl_detail_ObjectRegistry_registerObject(m_data, pObj);
+ }
+
+ void revokeObject( void const* pObj ) {
+ osl_detail_ObjectRegistry_revokeObject(m_data, pObj);
+ }
+
+private:
+ // not impl:
+ ObjectRegistry( ObjectRegistry const& );
+ ObjectRegistry const& operator=( ObjectRegistry const& );
+
+ ObjectRegistryData m_data;
+};
+
+} // namespace detail
+
+/** Helper class which indicates leaking object(s) of a particular class in
+ non-pro builds; use e.g.
+
+ <pre>
+ class MyClass : private osl::DebugBase<MyClass> {...};
+ </pre>
+
+ Using the environment variable
+
+ OSL_DEBUGBASE_STORE_ADDRESSES=MyClass;YourClass;...
+
+ you can specify a ';'-separated list of strings matching to class names
+ (or "all" for all classes), for which DebugBase stores addresses to created
+ objects instead of just counting them. This enables you to iterate over
+ leaking objects in your debugger.
+
+ @tpl InheritingClassT binds the template instance to that class
+ @internal Use at own risk.
+ For now this is just public (yet unpublished) API and may change
+ in the future!
+*/
+template <typename InheritingClassT>
+class DebugBase
+{
+public:
+#if OSL_DEBUG_LEVEL <= 0
+ static bool checkObjectCount( ::std::size_t = 0 ) { return true; }
+#else // OSL_DEBUG_LEVEL > 0
+ /** @return whether the expected number of objects is alive,
+ else this function OSL_ASSERTs
+ */
+ static bool checkObjectCount( ::std::size_t nExpected = 0 ) {
+ return StaticObjectRegistry::get().checkObjectCount(nExpected);
+ }
+
+protected:
+ DebugBase() {
+ StaticObjectRegistry::get().registerObject( this );
+ }
+ ~DebugBase() {
+ StaticObjectRegistry::get().revokeObject( this );
+ }
+
+private:
+ struct StaticObjectRegistry
+ : ::rtl::Static<detail::ObjectRegistry<InheritingClassT>,
+ StaticObjectRegistry> {};
+#endif
+};
+
+} // namespace osl
+
+#endif // ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
+
diff --git a/sal/inc/osl/doublecheckedlocking.h b/sal/inc/osl/doublecheckedlocking.h
new file mode 100644
index 000000000000..1be9f2467c7a
--- /dev/null
+++ b/sal/inc/osl/doublecheckedlocking.h
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if !defined INCLUDED_OSL_DOUBLECHECKEDLOCKING_H
+#define INCLUDED_OSL_DOUBLECHECKEDLOCKING_H
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** A platform specific macro needed to make double-checked locking work.
+
+ See
+ <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>
+ for a description of double-checked locking, why it is broken, and how it
+ can be fixed. On platforms where it is necessary, this macro will expand
+ to some memory barrier instruction. On many platforms, double-checked
+ locking works as it is, though, so on those platforms this macro will be
+ empty. This is a macro instead of a (C++ inline) function to allow for
+ maximum performance in both C and C++.
+
+ If possible, use the rtl_Instance template instead of explicitly spelling
+ out the double-checked locking pattern. There are few cases where you
+ will have to spell it out explicitly (e.g., the logic of a certain
+ instance of the pattern is too complex to be mapped to the template, or
+ some compiler refuses to compile a template instantiation due to internal
+ compiler errors), though, and you should always call this macro at the
+ right places then:
+
+ static T * pInstance = 0;
+
+ T * p = pInstance;
+ if (!p)
+ {
+ Guard aGuard(aMutex);
+ p = pInstance;
+ if (!p)
+ {
+ p = ...;
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ pInstance = p;
+ }
+ }
+ else
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ return p;
+
+ One extra advantage of this macro is that it makes it easier to find all
+ places where double-checked locking is used.
+ */
+#define OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER() /* empty */
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_OSL_DOUBLECHECKEDLOCKING_H */
diff --git a/sal/inc/osl/endian.h b/sal/inc/osl/endian.h
new file mode 100644
index 000000000000..e8701bdc768a
--- /dev/null
+++ b/sal/inc/osl/endian.h
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_ENDIAN_H_
+#define _OSL_ENDIAN_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Determine the platform byte order as _BIG_ENDIAN, _LITTLE_ENDIAN, ...
+ */
+#ifdef _WIN32
+# if defined(_M_IX86)
+# define _LITTLE_ENDIAN
+# elif defined(_M_MRX000)
+# define _LITTLE_ENDIAN
+# elif defined(_M_ALPHA)
+# define _LITTLE_ENDIAN
+# elif defined(_M_PPC)
+# define _LITTLE_ENDIAN
+# endif
+#endif
+
+#ifdef LINUX
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# elif __BYTE_ORDER == __PDP_ENDIAN
+# define _PDP_ENDIAN
+# endif
+#endif
+
+#ifdef NETBSD
+# include <machine/endian.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# define _BIG_ENDIAN
+# elif BYTE_ORDER == PDP_ENDIAN
+# define _PDP_ENDIAN
+# endif
+#endif
+
+#ifdef FREEBSD
+# include <sys/param.h>
+# include <machine/endian.h>
+#if __FreeBSD_version < 500000
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# define _BIG_ENDIAN
+# elif BYTE_ORDER == PDP_ENDIAN
+# define _PDP_ENDIAN
+# endif
+#endif
+#endif
+
+#ifdef SCO
+# include <sys/types.h>
+# include <sys/byteorder.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# define _BIG_ENDIAN
+# elif BYTE_ORDER == PDP_ENDIAN
+# define _PDP_ENDIAN
+# endif
+#endif
+
+#ifdef AIX
+# include <sys/machine.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# define _BIG_ENDIAN
+# elif BYTE_ORDER == PDP_ENDIAN
+# define _PDP_ENDIAN
+# endif
+#endif
+
+#ifdef HPUX
+# include <machine/param.h>
+#endif
+
+#ifdef _WIN16
+# define _LITTLE_ENDIAN
+#endif
+
+#ifdef OS2
+# include <machine/endian.h>
+#endif
+
+#ifdef SOLARIS
+# include <sys/isa_defs.h>
+#endif
+
+#ifdef MACOSX
+# include <machine/endian.h>
+# if BYTE_ORDER == LITTLE_ENDIAN
+# ifndef _LITTLE_ENDIAN
+# define _LITTLE_ENDIAN
+# endif
+# elif BYTE_ORDER == BIG_ENDIAN
+# ifndef _BIG_ENDIAN
+# define _BIG_ENDIAN
+# endif
+# elif BYTE_ORDER == PDP_ENDIAN
+# ifndef _PDP_ENDIAN
+# define _PDP_ENDIAN
+# endif
+# endif
+#endif
+
+/** Check supported platform.
+ */
+#if !defined(_WIN32) && !defined(_WIN16) && !defined(OS2) && \
+ !defined(LINUX) && !defined(NETBSD) && !defined(SCO) && \
+ !defined(AIX) && !defined(HPUX) && \
+ !defined(SOLARIS) && !defined(MACOSX) && !defined(FREEBSD)
+# error "Target platform not specified !"
+#endif
+
+
+/** Define the determined byte order as OSL_BIGENDIAN or OSL_LITENDIAN.
+ */
+#if defined _LITTLE_ENDIAN
+# define OSL_LITENDIAN
+#elif defined _BIG_ENDIAN
+# define OSL_BIGENDIAN
+#else
+# error undetermined endianess
+#endif
+
+
+/** Define macros for byte order manipulation.
+ */
+#ifndef OSL_MAKEBYTE
+# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
+#endif
+#ifndef OSL_LONIBBLE
+# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
+#endif
+#ifndef OSL_HINIBBLE
+# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
+#endif
+
+#ifndef OSL_MAKEWORD
+# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8))
+#endif
+#ifndef OSL_LOBYTE
+# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
+#endif
+#ifndef OSL_HIBYTE
+# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
+#endif
+
+#ifndef OSL_MAKEDWORD
+# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
+#endif
+#ifndef OSL_LOWORD
+# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
+#endif
+#ifndef OSL_HIWORD
+# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
+#endif
+
+
+/** Define macros for swapping between host and network byte order.
+ */
+#ifdef OSL_BIGENDIAN
+#ifndef OSL_NETWORD
+# define OSL_NETWORD(w) (sal_uInt16)(w)
+#endif
+#ifndef OSL_NETDWORD
+# define OSL_NETDWORD(d) (sal_uInt32)(d)
+#endif
+#else /* OSL_LITENDIAN */
+#ifndef OSL_NETWORD
+# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
+#endif
+#ifndef OSL_NETDWORD
+# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
+#endif
+#endif /* OSL_BIGENDIAN */
+
+
+/** Define macros for swapping between byte orders.
+ */
+#ifndef OSL_SWAPWORD
+# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
+#endif
+#ifndef OSL_SWAPDWORD
+# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_OSL_ENDIAN_H_ */
+
diff --git a/sal/inc/osl/file.h b/sal/inc/osl/file.h
new file mode 100644
index 000000000000..29196469fa61
--- /dev/null
+++ b/sal/inc/osl/file.h
@@ -0,0 +1,1593 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/** @HTML */
+
+#ifndef _OSL_FILE_H_
+#define _OSL_FILE_H_
+
+#include <osl/time.h>
+# include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @file
+
+Main goals and usage hints
+
+The main intentention of this interface is to provide an universal portable and
+high performance access to file system issues on any operating system.<p>
+
+There are a few main goals:<p>
+
+1.The path specifications always has to be absolut. Any usage of relative path
+specifications is forbidden. Exceptions are <code>osl_getSystemPathFromFileURL</code>,
+<code>osl_getFileURLFromSystemPath</code> and <code>osl_getAbsoluteFileURL</code>. Most operating systems
+provide a "Current Directory" per process. This is the reason why relative path
+specifications can cause problems in multithreading environments.<p>
+
+2.Proprietary notations of file paths are not supported. Every path notation
+must the file URL specification. File URLs must be encoded in UTF8 and
+after that escaped. Although the URL parameter is a unicode string, the must
+contain only ASCII characters<p>
+
+3.The caller cannot get any information whether a file system is case sensitive,
+case preserving or not. The operating system implementation itself should
+determine if it can map case-insensitive paths. The case correct notation of
+a filename or file path is part of the "File Info". This case correct name
+can be used as a unique key if neccessary.<p>
+
+4. Obtaining information about files or volumes is controlled by a
+bitmask which specifies which fields are of interest. Due to performance
+issues it is not recommended to obtain information which is not needed.
+But if the operating system provides more information anyway the
+implementation can set more fields on output as were requested. It is in the
+responsibility of the caller to decide if he uses this additional information
+or not. But he should do so to prevent further unnecessary calls if the information
+is already there.<br>
+
+The input bitmask supports a flag <code>osl_FileStatus_Mask_Validate</code> which
+can be used to force retrieving uncached validated information. Setting this flag
+when calling <code>osl_getFileStatus</code> in combination with no other flag is
+a synonym for a "FileExists". This should only be done when processing a single file
+(f.e. before opening) and NEVER during enumeration of directory contents on any step
+of information processing. This would change the runtime behaviour from O(n) to
+O(n*n/2) on nearly every file system.<br>
+On Windows NT reading the contents of an directory with 7000 entries and
+getting full information about every file only takes 0.6 seconds. Specifying the
+flag <code>osl_FileStatus_Mask_Validate</code> for each entry will increase the
+time to 180 seconds (!!!).
+
+*/
+
+
+
+/* Error codes according to errno */
+
+typedef enum {
+ osl_File_E_None,
+ osl_File_E_PERM,
+ osl_File_E_NOENT,
+ osl_File_E_SRCH,
+ osl_File_E_INTR,
+ osl_File_E_IO,
+ osl_File_E_NXIO,
+ osl_File_E_2BIG,
+ osl_File_E_NOEXEC,
+ osl_File_E_BADF,
+ osl_File_E_CHILD,
+ osl_File_E_AGAIN,
+ osl_File_E_NOMEM,
+ osl_File_E_ACCES,
+ osl_File_E_FAULT,
+ osl_File_E_BUSY,
+ osl_File_E_EXIST,
+ osl_File_E_XDEV,
+ osl_File_E_NODEV,
+ osl_File_E_NOTDIR,
+ osl_File_E_ISDIR,
+ osl_File_E_INVAL,
+ osl_File_E_NFILE,
+ osl_File_E_MFILE,
+ osl_File_E_NOTTY,
+ osl_File_E_FBIG,
+ osl_File_E_NOSPC,
+ osl_File_E_SPIPE,
+ osl_File_E_ROFS,
+ osl_File_E_MLINK,
+ osl_File_E_PIPE,
+ osl_File_E_DOM,
+ osl_File_E_RANGE,
+ osl_File_E_DEADLK,
+ osl_File_E_NAMETOOLONG,
+ osl_File_E_NOLCK,
+ osl_File_E_NOSYS,
+ osl_File_E_NOTEMPTY,
+ osl_File_E_LOOP,
+ osl_File_E_ILSEQ,
+ osl_File_E_NOLINK,
+ osl_File_E_MULTIHOP,
+ osl_File_E_USERS,
+ osl_File_E_OVERFLOW,
+ osl_File_E_NOTREADY,
+ osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
+ osl_File_E_TIMEDOUT,
+ osl_File_E_NETWORK,
+ osl_File_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslFileError;
+
+typedef void *oslDirectory;
+typedef void *oslDirectoryItem;
+
+
+/** Open a directory for enumerating its contents.
+
+ @param pustrDirectoryURL [in]
+ The full qualified URL of the directory.
+
+ @param pDirectory [out]
+ On success it receives a handle used for subsequent calls by osl_getNextDirectoryItem().
+ The handle has to be released by a call to osl_closeDirectory().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOENT the specified path doesn't exist<br>
+ osl_File_E_NOTDIR the specified path is not an directory <br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_NAMETOOLONG File name too long<br>
+ osl_File_E_LOOP Too many symbolic links encountered<p>
+
+ @see osl_getNextDirectoryItem()
+ @see osl_closeDirectory()
+*/
+
+oslFileError SAL_CALL osl_openDirectory( rtl_uString *pustrDirectoryURL, oslDirectory *pDirectory);
+
+
+/** Retrieve the next item of a previously opened directory.
+
+ Retrieves the next item of a previously opened directory.
+ All handles have an initial refcount of 1.
+
+ @param Directory [in]
+ A directory handle received from a previous call to osl_openDirectory().
+
+ @param pItem [out]
+ On success it receives a handle that can be used for subsequent calls to osl_getFileStatus().
+ The handle has to be released by a call to osl_releaseDirectoryItem().
+
+ @param uHint [in]
+ With this parameter the caller can tell the implementation that (s)he
+ is going to call this function uHint times afterwards. This enables the implementation to
+ get the information for more than one file and cache it until the next calls.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_NOENT no more entries in this directory<br>
+ osl_File_E_BADF invalid oslDirectory parameter<br>
+ osl_File_E_OVERFLOW the value too large for defined data type
+
+ @see osl_releaseDirectoryItem()
+ @see osl_acquireDirectoryItem()
+ @see osl_getDirectoryItem()
+ @see osl_getFileStatus()
+*/
+
+oslFileError SAL_CALL osl_getNextDirectoryItem(
+ oslDirectory Directory,
+ oslDirectoryItem *pItem,
+ sal_uInt32 uHint
+ );
+
+
+/** Release a directory handle.
+
+ @param Directory [in]
+ A handle received by a call to osl_openDirectory().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures<br>
+ osl_File_E_BADF invalid oslDirectory parameter<br>
+ osl_File_E_INTR the function call was interrupted<p>
+
+ @see osl_openDirectory()
+*/
+
+oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory);
+
+
+/** Retrieve a single directory item.
+
+ Retrieves a single directory item. The returned handle has an initial refcount of 1.
+ Due to performance issues it is not recommended to use this function while
+ enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
+
+ @param pustrFileURL [in]
+ An absolute file URL.
+
+ @param pItem [out]
+ On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
+ The handle has to be released by a call to osl_releaseDirectoryItem().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_NAMETOOLONG the file name is too long<br>
+ osl_File_E_NOTDIR a component of the path prefix of path is not a directory<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_INTR the function call was interrupted<p>
+
+ @see osl_releaseDirectoryItem()
+ @see osl_acquireDirectoryItem()
+ @see osl_getFileStatus()
+ @see osl_getNextDirectoryItem()
+*/
+
+oslFileError SAL_CALL osl_getDirectoryItem(
+ rtl_uString *pustrFileURL,
+ oslDirectoryItem *pItem
+ );
+
+
+/** Increase the refcount of a directory item handle.
+
+ The caller responsible for releasing the directory item handle using osl_releaseDirectoryItem().
+
+ @param Item [in]
+ A handle received by a call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getDirectoryItem()
+ @see osl_getNextDirectoryItem()
+ @see osl_releaseDirectoryItem()
+*/
+
+oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item );
+
+
+/** Decrease the refcount of a directory item handle.
+
+ Decreases the refcount of a directory item handle.
+ If the refcount reaches 0 the data associated with
+ this directory item handle will be released.
+
+ @param Item [in]
+ A handle received by a call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getDirectoryItem()
+ @see osl_getNextDirectoryItem()
+ @see osl_acquireDirectoryItem()
+*/
+
+oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item );
+
+/* File types */
+
+typedef enum {
+ osl_File_Type_Directory,
+ osl_File_Type_Volume,
+ osl_File_Type_Regular,
+ osl_File_Type_Fifo,
+ osl_File_Type_Socket,
+ osl_File_Type_Link,
+ osl_File_Type_Special,
+ osl_File_Type_Unknown
+} oslFileType;
+
+/* File attributes */
+#define osl_File_Attribute_ReadOnly 0x00000001
+#define osl_File_Attribute_Hidden 0x00000002
+#define osl_File_Attribute_Executable 0x00000010
+#define osl_File_Attribute_GrpWrite 0x00000020
+#define osl_File_Attribute_GrpRead 0x00000040
+#define osl_File_Attribute_GrpExe 0x00000080
+#define osl_File_Attribute_OwnWrite 0x00000100
+#define osl_File_Attribute_OwnRead 0x00000200
+#define osl_File_Attribute_OwnExe 0x00000400
+#define osl_File_Attribute_OthWrite 0x00000800
+#define osl_File_Attribute_OthRead 0x00001000
+#define osl_File_Attribute_OthExe 0x00002000
+
+/* Flags specifying which fields to retreive by osl_getFileStatus */
+
+#define osl_FileStatus_Mask_Type 0x00000001
+#define osl_FileStatus_Mask_Attributes 0x00000002
+#define osl_FileStatus_Mask_CreationTime 0x00000010
+#define osl_FileStatus_Mask_AccessTime 0x00000020
+#define osl_FileStatus_Mask_ModifyTime 0x00000040
+#define osl_FileStatus_Mask_FileSize 0x00000080
+#define osl_FileStatus_Mask_FileName 0x00000100
+#define osl_FileStatus_Mask_FileURL 0x00000200
+#define osl_FileStatus_Mask_LinkTargetURL 0x00000400
+#define osl_FileStatus_Mask_All 0x7FFFFFFF
+#define osl_FileStatus_Mask_Validate 0x80000000
+
+
+typedef
+
+/** Structure containing information about files and directories
+
+ @see osl_getFileStatus()
+ @see oslFileType
+*/
+
+struct _oslFileStatus {
+/** Must be initialized with the size in bytes of the structure before passing it to any function */
+ sal_uInt32 uStructSize;
+/** Determines which members of the structure contain valid data */
+ sal_uInt32 uValidFields;
+/** The type of the file (file, directory, volume). */
+ oslFileType eType;
+/** File attributes */
+ sal_uInt64 uAttributes;
+/** First creation time in nanoseconds since 1/1/1970. Can be the last modify time depending on
+ platform or file system. */
+ TimeValue aCreationTime;
+/** Last access time in nanoseconds since 1/1/1970. Can be the last modify time depending on
+ platform or file system. */
+ TimeValue aAccessTime;
+/** Last modify time in nanoseconds since 1/1/1970. */
+ TimeValue aModifyTime;
+/** Size in bytes of the file. Zero for directories and volumes. */
+ sal_uInt64 uFileSize;
+/** Case correct name of the file. Should be set to zero before calling <code>osl_getFileStatus</code>
+ and released after usage. */
+ rtl_uString *ustrFileName;
+/** Full URL of the file. Should be set to zero before calling <code>osl_getFileStatus</code>
+ and released after usage. */
+ rtl_uString *ustrFileURL;
+/** Full URL of the target file if the file itself is a link.
+ Should be set to zero before calling <code>osl_getFileStatus</code>
+ and released after usage. */
+ rtl_uString *ustrLinkTargetURL;
+} oslFileStatus;
+
+
+/** Retrieve information about a single file or directory.
+
+ @param Item [in]
+ A handle received by a previous call to osl_getDirectoryItem() or osl_getNextDirectoryItem().
+
+ @param pStatus [in|out]
+ Points to a structure which receives the information of the file or directory
+ represented by the handle Item. The member uStructSize has to be initialized to
+ sizeof(oslFileStatus) before calling this function.
+
+ @param uFieldMask [in]
+ Specifies which fields of the structure pointed to by pStatus are of interest to the caller.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_BADF invalid oslDirectoryItem parameter<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_OVERFLOW value too large for defined data type<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_NXIO no such device or address<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_NOSYS function not implemented<p>
+
+ @see osl_getDirectoryItem()
+ @see osl_getNextDirectoryItem()
+ @see oslFileStatus
+*/
+
+oslFileError SAL_CALL osl_getFileStatus( oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask );
+
+
+typedef void *oslVolumeDeviceHandle;
+
+
+/** Unmount a volume device.
+
+ Unmount the volume specified by the given oslVolumeDeviceHandle.
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @return
+ osl_File_E_None on success<br>
+
+ @todo
+ specify all error codes that may be returned
+
+ @see osl_getVolumeInformation()
+*/
+
+oslFileError SAL_CALL osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle );
+
+
+/** Automount a volume device.
+
+ Automount the volume device specified by the given oslVolumeDeviceHandle.
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @return
+ osl_File_E_None on success<br>
+
+ @todo
+ specify all error codes that may be returned
+
+ @see osl_getVolumeInformation()
+*/
+
+oslFileError SAL_CALL osl_automountVolumeDevice( oslVolumeDeviceHandle Handle );
+
+
+/** Release a volume device handle.
+
+ Releases the given oslVolumeDeviceHandle which was acquired by a call to
+ osl_getVolumeInformation() or osl_acquireVolumeDeviceHandle().
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @return
+ osl_File_E_None on success<br>
+
+ @todo
+ specify all error codes that may be returned
+
+ @see osl_acquireVolumeDeviceHandle()
+ @see osl_getVolumeInformation()
+*/
+
+oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle );
+
+/** Acquire a volume device handle.
+
+ Acquires the given oslVolumeDeviceHandle which was acquired by a call to
+ osl_getVolumeInformation(). The caller is responsible for releasing the
+ acquired handle by calling osl_releaseVolumeDeviceHandle().
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @return
+ osl_File_E_None on success<br>
+
+ @todo
+ specify all error codes that may be returned
+
+ @see osl_getVolumeInformation()
+*/
+
+oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle );
+
+
+/** Get the full qualified URL where a device is mounted to.
+
+ @param Handle [in]
+ An oslVolumeDeviceHandle received by a call to osl_getVolumeInformation().
+
+ @param ppustrDirectoryURL [out]
+ Receives the full qualified URL where the device is mounted to.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NXIO no such device or address<br>
+ osl_File_E_NODEV no such device<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_FAULT bad address<br>
+ osl_FilE_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_EOVERFLOW value too large for defined data type<br>
+
+ @see osl_getVolumeInformation()
+ @see osl_automountVolumeDevice()
+ @see osl_unmountVolumeDevice()
+*/
+
+oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **ppustrDirectoryURL);
+
+/* Volume attributes */
+
+#define osl_Volume_Attribute_Removeable 0x00000001L
+#define osl_Volume_Attribute_Remote 0x00000002L
+#define osl_Volume_Attribute_CompactDisc 0x00000004L
+#define osl_Volume_Attribute_FixedDisk 0x00000008L
+#define osl_Volume_Attribute_RAMDisk 0x00000010L
+#define osl_Volume_Attribute_FloppyDisk 0x00000020L
+
+#define osl_Volume_Attribute_Case_Is_Preserved 0x00000040L
+#define osl_Volume_Attribute_Case_Sensitive 0x00000080L
+
+/* Flags specifying which fields to retreive by osl_getVolumeInfo */
+
+#define osl_VolumeInfo_Mask_Attributes 0x00000001L
+#define osl_VolumeInfo_Mask_TotalSpace 0x00000002L
+#define osl_VolumeInfo_Mask_UsedSpace 0x00000004L
+#define osl_VolumeInfo_Mask_FreeSpace 0x00000008L
+#define osl_VolumeInfo_Mask_MaxNameLength 0x00000010L
+#define osl_VolumeInfo_Mask_MaxPathLength 0x00000020L
+#define osl_VolumeInfo_Mask_FileSystemName 0x00000040L
+#define osl_VolumeInfo_Mask_DeviceHandle 0x00000080L
+#define osl_VolumeInfo_Mask_FileSystemCaseHandling 0x00000100L
+
+typedef
+
+/** Structure containing information about volumes
+
+ @see osl_getVolumeInformation()
+ @see oslFileType
+*/
+
+struct _oslVolumeInfo {
+/** Must be initialized with the size in bytes of the structure before passing it to any function */
+ sal_uInt32 uStructSize;
+/** Determines which members of the structure contain valid data */
+ sal_uInt32 uValidFields;
+/** Attributes of the volume (remote and/or removable) */
+ sal_uInt32 uAttributes;
+/** Total availiable space on the volume for the current process/user */
+ sal_uInt64 uTotalSpace;
+/** Used space on the volume for the current process/user */
+ sal_uInt64 uUsedSpace;
+/** Free space on the volume for the current process/user */
+ sal_uInt64 uFreeSpace;
+/** Maximum length of file name of a single item */
+ sal_uInt32 uMaxNameLength;
+/** Maximum length of a full quallified path in system notation */
+ sal_uInt32 uMaxPathLength;
+/** Points to a string that receives the name of the file system type. String should be set to zero before calling <code>osl_getVolumeInformation</code>
+ and released after usage. */
+ rtl_uString *ustrFileSystemName;
+/** Pointer to handle the receives underlying device. Handle should be set to zero before calling <code>osl_getVolumeInformation</code>*/
+ oslVolumeDeviceHandle *pDeviceHandle;
+} oslVolumeInfo;
+
+
+/** Retrieve information about a volume.
+
+ Retrieves information about a volume. A volume can either be a mount point, a network
+ resource or a drive depending on Operating System and File System. Before calling this
+ function osl_getFileStatus() should be called to determine if the type is
+ osl_file_Type_Volume.
+
+ @param pustrDirectoryURL [in]
+ Full qualified URL of the volume
+
+ @param pInfo [out]
+ On success it receives information about the volume.
+
+ @param uFieldMask [in]
+ Specifies which members of the structure should be filled
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ ols_File_E_FAULT Bad address<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_NOSYS function not implemented<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_INTR function call was interrupted<br>
+
+ @see osl_getFileStatus()
+ @see oslVolumeInfo
+*/
+
+oslFileError SAL_CALL osl_getVolumeInformation(
+ rtl_uString *pustrDirectoryURL,
+ oslVolumeInfo *pInfo,
+ sal_uInt32 uFieldMask );
+
+typedef void *oslFileHandle;
+
+/* Open flags */
+
+#define osl_File_OpenFlag_Read 0x00000001L
+#define osl_File_OpenFlag_Write 0x00000002L
+#define osl_File_OpenFlag_Create 0x00000004L
+#define osl_File_OpenFlag_NoLock 0x00000008L
+
+/** Open a regular file.
+
+ Open a file. Only regular files can be openend.
+
+ @param pustrFileURL [in]
+ The full qualified URL of the file to open.
+
+ @param pHandle [out]
+ On success it receives a handle to the open file.
+
+ @param uFlags [in]
+ Specifies the open mode.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NAMETOOLONG pathname was too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_AGAIN a write lock could not be established<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NXIO no such device or address<br>
+ osl_File_E_NODEV no such device<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_TXTBSY text file busy<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_MFILE too many open files used by the process<br>
+ osl_File_E_NFILE too many open files in the system<br>
+ osl_File_E_DQUOT quota exceeded<br>
+ osl_File_E_EXIST file exists<br>
+ osl_FilE_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_EOVERFLOW value too large for defined data type<br>
+
+ @see osl_closeFile()
+ @see osl_setFilePos()
+ @see osl_getFilePos()
+ @see osl_readFile()
+ @see osl_writeFile()
+ @see osl_setFileSize()
+ @see osl_getFileSize()
+*/
+
+oslFileError SAL_CALL osl_openFile( rtl_uString *pustrFileURL, oslFileHandle *pHandle, sal_uInt32 uFlags );
+
+#define osl_Pos_Absolut 1
+#define osl_Pos_Current 2
+#define osl_Pos_End 3
+
+/** Set the internal position pointer of an open file.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param uHow [in]
+ Distance to move the internal position pointer (from uPos).
+
+ @param uPos [in]
+ Absolute position from the beginning of the file.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_getFilePos()
+*/
+
+oslFileError SAL_CALL osl_setFilePos( oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos );
+
+
+/** Retrieve the current position of the internal pointer of an open file.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pPos [out]
+ On success receives the current position of the file pointer.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_setFilePos()
+ @see osl_readFile()
+ @see osl_writeFile()
+*/
+
+oslFileError SAL_CALL osl_getFilePos( oslFileHandle Handle, sal_uInt64 *pPos );
+
+
+/** Set the file size of an open file.
+
+ Sets the file size of an open file. The file can be truncated or enlarged by the function.
+ The position of the file pointer is not affeced by this function.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param uSize [in]
+ New size in bytes.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_setFilePos()
+ @see osl_getFileStatus()
+ @see osl_getFileSize()
+*/
+
+oslFileError SAL_CALL osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize );
+
+
+/** Get the file size of an open file.
+
+ Gets the file size of an open file.
+ The position of the file pointer is not affeced by this function.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pSize [out]
+ Current size in bytes.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files<br>
+
+ @see osl_openFile()
+ @see osl_setFilePos()
+ @see osl_getFileStatus()
+*/
+
+oslFileError SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64 *pSize );
+
+
+/** Map flags.
+
+ @since UDK 3.2.10
+ */
+#define osl_File_MapFlag_RandomAccess ((sal_uInt32)(0x1))
+
+/** Map flag denoting that the mapped address space will be accessed by the
+ process soon (and it is advantageous for the operating system to already
+ start paging in the data).
+
+ @since UDK 3.2.12
+ */
+#define osl_File_MapFlag_WillNeed ((sal_uInt32)(0x2))
+
+/** Map a shared file into memory.
+
+ @since UDK 3.2.10
+ */
+oslFileError
+SAL_CALL osl_mapFile (
+ oslFileHandle Handle,
+ void** ppAddr,
+ sal_uInt64 uLength,
+ sal_uInt64 uOffset,
+ sal_uInt32 uFlags
+);
+
+
+/** Unmap a shared file from memory.
+
+ @since UDK 3.2.10
+ */
+oslFileError
+SAL_CALL osl_unmapFile (
+ void* pAddr,
+ sal_uInt64 uLength
+);
+
+
+/** Read a number of bytes from a file.
+
+ Reads a number of bytes from a file. The internal file pointer is
+ increased by the number of bytes read.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pBuffer [out]
+ Points to a buffer which receives data. The buffer must be large enough
+ to hold uBytesRequested bytes.
+
+ @param uBytesRequested [in]
+ Number of bytes which should be retrieved.
+
+ @param pBytesRead [out]
+ On success the number of bytes which have actually been retrieved.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_openFile()
+ @see osl_writeFile()
+ @see osl_readLine()
+ @see osl_setFilePos()
+*/
+
+oslFileError SAL_CALL osl_readFile( oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead );
+
+
+/** Test if the end of a file is reached.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pIsEOF [out]
+ Points to a variable that receives the end-of-file status.
+
+ @return
+ osl_File_E_None on success <br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_NOLINK link has been severed<p>
+
+ @see osl_openFile()
+ @see osl_readFile()
+ @see osl_readLine()
+ @see osl_setFilePos()
+*/
+
+oslFileError SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF );
+
+
+/** Write a number of bytes to a file.
+
+ Writes a number of bytes to a file.
+ The internal file pointer is increased by the number of bytes read.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param pBuffer [in]
+ Points to a buffer which contains the data.
+
+ @param uBytesToWrite [in]
+ Number of bytes which should be written.
+
+ @param pBytesWritten [out]
+ On success the number of bytes which have actually been written.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_FBIG file too large<br>
+ osl_File_E_DQUOT quota exceeded<p>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errosr<br>
+ osl_File_E_NOLCK no record locks available<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_NXIO no such device or address<br>
+
+ @see osl_openFile()
+ @see osl_readFile()
+ @see osl_setFilePos()
+*/
+
+oslFileError SAL_CALL osl_writeFile( oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten );
+
+/** Read a number of bytes from a specified offset in a file.
+
+ The current position of the internal file pointer may or may not be changed.
+
+ @since UDK 3.2.10
+ */
+oslFileError SAL_CALL osl_readFileAt(
+ oslFileHandle Handle,
+ sal_uInt64 uOffset,
+ void* pBuffer,
+ sal_uInt64 uBytesRequested,
+ sal_uInt64* pBytesRead
+);
+
+
+/** Write a number of bytes to a specified offset in a file.
+
+ The current position of the internal file pointer may or may not be changed.
+
+ @since UDK 3.2.10
+ */
+oslFileError SAL_CALL osl_writeFileAt(
+ oslFileHandle Handle,
+ sal_uInt64 uOffset,
+ const void* pBuffer,
+ sal_uInt64 uBytesToWrite,
+ sal_uInt64* pBytesWritten
+);
+
+
+/** Read a line from a file.
+
+ Reads a line from a file. The new line delimiter is NOT returned!
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @param ppSequence [in/out]
+ A pointer pointer to a sal_Sequence that will hold the line read on success.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_BADF bad file<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_AGAIN operation would block<br>
+ osl_File_E_NOLINK link has been severed<p>
+
+ @see osl_openFile()
+ @see osl_readFile()
+ @see osl_writeFile()
+ @see osl_setFilePos()
+*/
+
+oslFileError SAL_CALL osl_readLine( oslFileHandle Handle, sal_Sequence** ppSequence );
+
+/** Synchronize the memory representation of a file with that on the physical medium.
+
+ The function ensures that all modified data and attributes of the file associated with
+ the given file handle have been written to the physical medium.
+ In case the hard disk has a write cache enabled, the data may not really be on
+ permanent storage when osl_syncFile returns.
+
+ @param Handle
+ [in] Handle to a file received by a previous call to osl_openFile().
+
+ @return
+ <dl>
+ <dt>osl_File_E_None</dt>
+ <dd>On success</dd>
+ <dt>osl_File_E_INVAL</dt>
+ <dd>The value of the input parameter is invalid</dd>
+ </dl>
+ <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
+ <dl>
+ <dt>osl_File_E_BADF</dt>
+ <dd>The file associated with the given file handle is not open for writing</dd>
+ <dt>osl_File_E_IO</dt>
+ <dd>An I/O error occurred</dd>
+ <dt>osl_File_E_NOSPC</dt>
+ <dd>There is no enough space on the target device</dd>
+ <dt>osl_File_E_ROFS</dt>
+ <dd>The file associated with the given file handle is located on a read only file system</dd>
+ <dt>osl_File_E_TIMEDOUT</dt>
+ <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
+ </dl>
+
+ @see osl_openFile()
+ @see osl_writeFile()
+*/
+oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle);
+
+/** Close an open file.
+
+ @param Handle [in]
+ Handle to a file received by a previous call to osl_openFile().
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_BADF Bad file<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_IO on I/O errors<br>
+
+ @see osl_openFile()
+*/
+
+oslFileError SAL_CALL osl_closeFile( oslFileHandle Handle );
+
+
+/** Create a directory.
+
+ @param pustrDirectoryURL [in]
+ Full qualified URL of the directory to create.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_EXIST file exists<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_NOSPC no space left on device<br>
+ osl_File_E_DQUOT quota exceeded<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_FAULT bad address<br>
+ osl_FileE_IO on I/O errors<br>
+ osl_File_E_MLINK too many links<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_removeDirectory()
+*/
+
+oslFileError SAL_CALL osl_createDirectory( rtl_uString* pustrDirectoryURL );
+
+
+/** Remove an empty directory.
+
+ @param pustrDirectoryURL [in]
+ Full qualified URL of the directory.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NOTEMPTY directory not empty<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_BUSY device or resource busy<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_BUSY device or resource busy<br>
+ osl_File_E_EXIST file exists<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_createDirectory()
+*/
+
+oslFileError SAL_CALL osl_removeDirectory( rtl_uString* pustrDirectoryURL );
+
+/** Function pointer representing a function that will be called by osl_createDirectoryPath
+ if a directory has been created.
+
+ To avoid unpredictable results the callee must not access the directory whose
+ creation is just notified.
+
+ @param pData
+ [in] User specified data given in osl_createDirectoryPath.
+
+ @param aDirectoryUrl
+ [in] The absolute file URL of the directory that was just created by
+ osl_createDirectoryPath.
+
+ @see osl_createDirectoryPath
+*/
+typedef void (SAL_CALL *oslDirectoryCreationCallbackFunc)(void* pData, rtl_uString* aDirectoryUrl);
+
+/** Create a directory path.
+
+ The osl_createDirectoryPath function creates a specified directory path.
+ All nonexisting sub directories will be created.
+ <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
+ osl_File_E_EXIST for existing directories. Programming against this error
+ code is in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
+
+ @param aDirectoryUrl
+ [in] The absolute file URL of the directory path to create.
+ A relative file URL will not be accepted.
+
+ @param aDirectoryCreationFunc
+ [in] Pointer to a function that will be called synchronously
+ for each sub directory that was created. The value of this
+ parameter may be NULL, in this case notifications will not be
+ sent.
+
+ @param pData
+ [in] User specified data to be passed to the directory creation
+ callback function. The value of this parameter may be arbitrary
+ and will not be interpreted by osl_createDirectoryPath.
+
+ @return
+ <dl>
+ <dt>osl_File_E_None</dt>
+ <dd>On success</dd>
+ <dt>osl_File_E_INVAL</dt>
+ <dd>The format of the parameters was not valid</dd>
+ <dt>osl_File_E_ACCES</dt>
+ <dd>Permission denied</dd>
+ <dt>osl_File_E_EXIST</dt>
+ <dd>The final node of the specified directory path already exist</dd>
+ <dt>osl_File_E_NAMETOOLONG</dt>
+ <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
+ <dt>osl_File_E_NOTDIR</dt>
+ <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
+ <dt>osl_File_E_ROFS</dt>
+ <dd>Read-only file system</dd>
+ <dt>osl_File_E_NOSPC</dt>
+ <dd>No space left on device</dd>
+ <dt>osl_File_E_DQUOT</dt>
+ <dd>Quota exceeded</dd>
+ <dt>osl_File_E_FAULT</dt>
+ <dd>Bad address</dd>
+ <dt>osl_File_E_IO</dt>
+ <dd>I/O error</dd>
+ <dt>osl_File_E_LOOP</dt>
+ <dd>Too many symbolic links encountered</dd>
+ <dt>osl_File_E_NOLINK</dt>
+ <dd>Link has been severed</dd>
+ <dt>osl_File_E_invalidError</dt>
+ <dd>An unknown error occurred</dd>
+ </dl>
+
+ @see oslDirectoryCreationFunc
+ @see oslFileError
+ @see osl_createDirectory
+*/
+oslFileError SAL_CALL osl_createDirectoryPath(
+ rtl_uString* aDirectoryUrl,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData);
+
+/** Remove a regular file.
+
+ @param pustrFileURL [in]
+ Full qualified URL of the file to remove.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_ROFS read-only file system<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_IO on I/O errors<br>
+ osl_File_E_BUSY device or resource busy<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+ osl_File_E_TXTBSY text file busy<br>
+
+ @see osl_openFile()
+*/
+
+oslFileError SAL_CALL osl_removeFile( rtl_uString* pustrFileURL );
+
+
+/** Copy a file to a new destination.
+
+ Copies a file to a new destination. Copies only files not directories.
+ No assumptions should be made about preserving attributes or file time.
+
+ @param pustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param pustrDestFileURL [in]
+ Full qualified URL of the destination file. A directory is NOT a valid destination file!
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ISDIR is a directory<br>
+ osl_File_E_ROFS read-only file system<p>
+
+ @see osl_moveFile()
+ @see osl_removeFile()
+*/
+
+oslFileError SAL_CALL osl_copyFile( rtl_uString* pustrSourceFileURL, rtl_uString *pustrDestFileURL );
+
+
+/** Move a file or directory to a new destination or renames it.
+
+ Moves a file or directory to a new destination or renames it.
+ File time and attributes are preserved.
+
+ @param pustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param pustrDestFileURL [in]
+ Full qualified URL of the destination file. An existing directory is NOT a valid destination !
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_PERM operation not permitted<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_ROFS read-only file system<br>
+
+ @see osl_copyFile()
+*/
+
+oslFileError SAL_CALL osl_moveFile( rtl_uString* pustrSourceFileURL, rtl_uString *pustrDestFileURL );
+
+
+/** Determine a valid unused canonical name for a requested name.
+
+ Determines a valid unused canonical name for a requested name.
+ Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
+ If a file or directory with the requested name already exists a new name is generated following
+ the common rules on the actual Operating System and File System.
+
+ @param pustrRequestedURL [in]
+ Requested name of a file or directory.
+
+ @param ppustrValidURL [out]
+ On success receives a name which is unused and valid on the actual Operating System and
+ File System.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getFileStatus()
+*/
+
+oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *pustrRequestedURL, rtl_uString **ppustrValidURL);
+
+
+/** Convert a path relative to a given directory into an full qualified file URL.
+
+ Convert a path relative to a given directory into an full qualified file URL.
+ The function resolves symbolic links if possible and path ellipses, so on success
+ the resulting absolute path is fully resolved.
+
+ @param pustrBaseDirectoryURL [in]
+ Base directory URL to which the relative path is related to.
+
+ @param pustrRelativeFileURL [in]
+ An URL of a file or directory relative to the directory path specified by pustrBaseDirectoryURL
+ or an absolute path.
+ If pustrRelativeFileURL denotes an absolute path pustrBaseDirectoryURL will be ignored.
+
+ @param ppustrAbsoluteFileURL [out]
+ On success it receives the full qualified absoulte file URL.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOMEM not enough memory for allocating structures <br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_ACCES permission denied<br>
+ osl_File_E_NOENT no such file or directory<br>
+ osl_File_E_NAMETOOLONG file name too long<br>
+ osl_File_E_OVERFLOW value too large for defined data type<br>
+ osl_File_E_FAULT bad address<br>
+ osl_File_E_INTR function call was interrupted<br>
+ osl_File_E_LOOP too many symbolic links encountered<br>
+ osl_File_E_MULTIHOP multihop attempted<br>
+ osl_File_E_NOLINK link has been severed<br>
+
+ @see osl_getFileStatus()
+*/
+
+oslFileError SAL_CALL osl_getAbsoluteFileURL(
+ rtl_uString* pustrBaseDirectoryURL,
+ rtl_uString *pustrRelativeFileURL,
+ rtl_uString **ppustrAbsoluteFileURL );
+
+
+/** Convert a system dependend path into a file URL.
+
+ @param pustrSystemPath [in]
+ A System dependent path of a file or directory.
+
+ @param ppustrFileURL [out]
+ On success it receives the file URL.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getSystemPathFromFileURL()
+*/
+
+oslFileError SAL_CALL osl_getFileURLFromSystemPath( rtl_uString *pustrSystemPath, rtl_uString **ppustrFileURL);
+
+
+/** Searche a full qualified system path or a file URL.
+
+ @param pustrFileName [in]
+ A system dependent path, a file URL, a file or relative directory.
+
+ @param pustrSearchPath [in]
+ A list of system paths, in which a given file has to be searched. The Notation of a path list is
+ system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
+ These paths are only for the search of a file or a relative path, otherwise it will be ignored.
+ If pustrSearchPath is NULL or while using the search path the search failed, the function searches for
+ a matching file in all system directories and in the directories listed in the PATH environment
+ variable.
+ The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
+ aware of the Operating System and so doesn't know which path list delimiter to use.
+
+ @param ppustrFileURL [out]
+ On success it receives the full qualified file URL.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOTDIR not a directory<br>
+ osl_File_E_NOENT no such file or directory not found<br>
+
+ @see osl_getFileURLFromSystemPath()
+ @see osl_getSystemPathFromFileURL()
+*/
+
+oslFileError SAL_CALL osl_searchFileURL( rtl_uString *pustrFileName, rtl_uString *pustrSearchPath, rtl_uString **ppustrFileURL );
+
+
+/** Convert a file URL into a system dependend path.
+
+ @param pustrFileURL [in]
+ A File URL.
+
+ @param ppustrSystemPath [out]
+ On success it receives the system path.
+
+ @return
+ osl_File_E_None on success
+ osl_File_E_INVAL the format of the parameters was not valid
+
+ @see osl_getFileURLFromSystemPath()
+*/
+
+oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *pustrFileURL, rtl_uString **ppustrSystemPath);
+
+
+/** Function pointer representing the function called back from osl_abbreviateSystemPath
+
+ @param ustrText [in]
+ Text to calculate the width for
+
+ @return
+ The width of the text specified by ustrText, e.g. it can return the width in pixel
+ or the width in character count.
+
+ @see osl_abbreviateSystemPath()
+*/
+
+typedef sal_uInt32 (SAL_CALL *oslCalcTextWidthFunc)( rtl_uString *ustrText );
+
+
+/** Abbreviate a system notation path.
+
+ @param ustrSystemPath [in]
+ The full system path to abbreviate
+
+ @param pustrCompacted [out]
+ Receives the compacted system path on output
+
+ @param pfnCalcWidth [in]
+ Function ptr that calculates the width of a string. Can be zero.
+
+ @param uMaxWidth [in]
+ Maximum width allowed that is retunrned from pfnCalcWidth.
+ If pfnCalcWidth is zero the character count is assumed as width.
+
+ @return
+ osl_File_E_None on success<br>
+
+ @see oslCalcTextWidthFunc
+*/
+
+oslFileError SAL_CALL osl_abbreviateSystemPath(
+ rtl_uString *ustrSystemPath,
+ rtl_uString **pustrCompacted,
+ sal_uInt32 uMaxWidth,
+ oslCalcTextWidthFunc pCalcWidth );
+
+
+/** Set file attributes.
+
+ @param pustrFileURL [in]
+ The full qualified file URL.
+
+ @param uAttributes [in]
+ Attributes of the file to be set.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+
+ @see osl_getFileStatus()
+*/
+
+oslFileError SAL_CALL osl_setFileAttributes( rtl_uString *pustrFileURL, sal_uInt64 uAttributes );
+
+
+/** Set the file time.
+
+ @param pustrFileURL [in]
+ The full qualified URL of the file.
+
+ @param aCreationTime [in]
+ Creation time of the given file.
+
+ @param aLastAccessTime [in]
+ Time of the last access of the given file.
+
+ @param aLastWriteTime [in]
+ Time of the last modifying of the given file.
+
+ @return
+ osl_File_E_None on success<br>
+ osl_File_E_INVAL the format of the parameters was not valid<br>
+ osl_File_E_NOENT no such file or directory not found<br>
+
+ @see osl_getFileStatus()
+*/
+
+oslFileError SAL_CALL osl_setFileTime(
+ rtl_uString *pustrFileURL,
+ const TimeValue *aCreationTime,
+ const TimeValue *aLastAccessTime,
+ const TimeValue *aLastWriteTime);
+
+
+/** Retrieves the file URL of the system's temporary directory path
+
+ @param pustrTempDirURL[out]
+ On success receives the URL of system's temporary directory path.
+
+ @return
+ osl_File_E_None on success
+ osl_File_E_NOENT no such file or directory not found
+*/
+
+oslFileError SAL_CALL osl_getTempDirURL( rtl_uString **pustrTempDirURL );
+
+
+/** Creates a temporary file in the directory provided by the caller or the
+ directory returned by osl_getTempDirURL.
+
+ Creates a temporary file in the directory provided by the caller or the
+ directory returned by osl_getTempDirURL.
+ Under UNIX Operating Systems the file will be created with read and write
+ access for the user exclusively.
+ If the caller requests only a handle to the open file but not the name of
+ it, the file will be automatically removed on close else the caller is
+ responsible for removing the file on success.
+
+ @param pustrDirectoryURL [in]
+ Specifies the full qualified URL where the temporary file should be created.
+ If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
+
+ @param pHandle [out]
+ On success receives a handle to the open file. If pHandle is 0 the file will
+ be closed on return, in this case ppustrTempFileURL must not be 0.
+
+ @param ppustrTempFileURL [out]
+ On success receives the full qualified URL of the temporary file.
+ If ppustrTempFileURL is 0 the file will be automatically removed on close,
+ in this case pHandle must not be 0.
+ If ppustrTempFileURL is not 0 the caller receives the name of the created
+ file and is responsible for removing the file, in this case
+ *ppustrTempFileURL must be 0 or must point to a valid rtl_uString.
+
+ @descr
+ Description of the different pHandle, ppustrTempFileURL parameter combinations.
+ pHandle is 0 and ppustrTempDirURL is 0 - this combination is invalid
+ pHandle is not 0 and ppustrTempDirURL is 0 - a handle to the open file
+ will be returned on success and the file will be automatically removed on close.
+ pHandle is 0 and ppustrTempDirURL is not 0 - the name of the file will be returned,
+ the caller is responsible for opening, closing and removing the file.
+ pHandle is not 0 and ppustrTempDirURL is not 0 - a handle to the open file as well as
+ the file name will be returned, the caller is responsible for closing and removing
+ the file.
+
+ @return
+ osl_File_E_None on success
+ osl_File_E_INVAL the format of the parameter is invalid
+ osl_File_E_NOMEM not enough memory for allocating structures
+ osl_File_E_ACCES Permission denied
+ osl_File_E_NOENT No such file or directory
+ osl_File_E_NOTDIR Not a directory
+ osl_File_E_ROFS Read-only file system
+ osl_File_E_NOSPC No space left on device
+ osl_File_E_DQUOT Quota exceeded
+
+ @see osl_getTempDirURL()
+*/
+
+oslFileError SAL_CALL osl_createTempFile(
+ rtl_uString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ rtl_uString** ppustrTempFileURL);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_FILE_H_ */
+
+
diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx
new file mode 100644
index 000000000000..02b134540d20
--- /dev/null
+++ b/sal/inc/osl/file.hxx
@@ -0,0 +1,1953 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/** @HTML */
+
+#ifndef _OSL_FILE_HXX_
+#define _OSL_FILE_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/time.h>
+# include <rtl/memory.h>
+# include <rtl/ustring.hxx>
+
+#include <osl/file.h>
+# include <rtl/byteseq.hxx>
+
+#include <stdio.h>
+
+namespace osl
+{
+
+
+// -----------------------------------------------------------------------------
+/** Base class for all File System specific objects.
+
+ @see Directory
+ @see DirectoryItem
+ @see File
+ */
+
+class FileBase
+{
+public:
+
+ enum RC {
+ E_None = osl_File_E_None,
+ E_PERM = osl_File_E_PERM,
+ E_NOENT = osl_File_E_NOENT,
+ E_SRCH = osl_File_E_SRCH,
+ E_INTR = osl_File_E_INTR,
+ E_IO = osl_File_E_IO,
+ E_NXIO = osl_File_E_NXIO,
+ E_2BIG = osl_File_E_2BIG,
+ E_NOEXEC = osl_File_E_NOEXEC,
+ E_BADF = osl_File_E_BADF,
+ E_CHILD = osl_File_E_CHILD,
+ E_AGAIN = osl_File_E_AGAIN,
+ E_NOMEM = osl_File_E_NOMEM,
+ E_ACCES = osl_File_E_ACCES,
+ E_FAULT = osl_File_E_FAULT,
+ E_BUSY = osl_File_E_BUSY,
+ E_EXIST = osl_File_E_EXIST,
+ E_XDEV = osl_File_E_XDEV,
+ E_NODEV = osl_File_E_NODEV,
+ E_NOTDIR = osl_File_E_NOTDIR,
+ E_ISDIR = osl_File_E_ISDIR,
+ E_INVAL = osl_File_E_INVAL,
+ E_NFILE = osl_File_E_NFILE,
+ E_MFILE = osl_File_E_MFILE,
+ E_NOTTY = osl_File_E_NOTTY,
+ E_FBIG = osl_File_E_FBIG,
+ E_NOSPC = osl_File_E_NOSPC,
+ E_SPIPE = osl_File_E_SPIPE,
+ E_ROFS = osl_File_E_ROFS,
+ E_MLINK = osl_File_E_MLINK,
+ E_PIPE = osl_File_E_PIPE,
+ E_DOM = osl_File_E_DOM,
+ E_RANGE = osl_File_E_RANGE,
+ E_DEADLK = osl_File_E_DEADLK,
+ E_NAMETOOLONG = osl_File_E_NAMETOOLONG,
+ E_NOLCK = osl_File_E_NOLCK,
+ E_NOSYS = osl_File_E_NOSYS,
+ E_NOTEMPTY = osl_File_E_NOTEMPTY,
+ E_LOOP = osl_File_E_LOOP,
+ E_ILSEQ = osl_File_E_ILSEQ,
+ E_NOLINK = osl_File_E_NOLINK,
+ E_MULTIHOP = osl_File_E_MULTIHOP,
+ E_USERS = osl_File_E_USERS,
+ E_OVERFLOW = osl_File_E_OVERFLOW,
+ E_NOTREADY = osl_File_E_NOTREADY,
+ E_invalidError = osl_File_E_invalidError, /* unmapped error: always last entry in enum! */
+ E_TIMEDOUT = osl_File_E_TIMEDOUT,
+ E_NETWORK = osl_File_E_NETWORK
+ };
+
+
+public:
+
+ /** Determine a valid unused canonical name for a requested name.
+
+ Determines a valid unused canonical name for a requested name.
+ Depending on the Operating System and the File System the illegal characters are replaced by valid ones.
+ If a file or directory with the requested name already exists a new name is generated following
+ the common rules on the actual Operating System and File System.
+
+ @param ustrRequestedURL [in]
+ Requested name of a file or directory.
+
+ @param pustrValidURL [out]
+ On success receives a name which is unused and valid on the actual Operating System and
+ File System.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see DirectoryItem::getFileStatus()
+ */
+
+ static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL )
+ {
+ return (RC) osl_getCanonicalName( ustrRequestedURL.pData, &ustrValidURL.pData );
+ }
+
+ /** Convert a path relative to a given directory into an full qualified file URL.
+
+ Convert a path relative to a given directory into an full qualified file URL.
+ The function resolves symbolic links if possible and path ellipses, so on success
+ the resulting absolute path is fully resolved.
+
+ @param ustrBaseDirectoryURL [in]
+ Base directory URL to which the relative path is related to.
+
+ @param ustrRelativeFileURL [in]
+ An URL of a file or directory relative to the directory path specified by ustrBaseDirectoryURL
+ or an absolute path.
+ If ustrRelativeFileURL denotes an absolute path ustrBaseDirectoryURL will be ignored.
+
+ @param ustrAbsoluteFileURL [out]
+ On success it receives the full qualified absoulte file URL.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_NOTDIR not a directory
+ E_ACCES permission denied
+ E_NOENT no such file or directory
+ E_NAMETOOLONG file name too long
+ E_OVERFLOW value too large for defined data type
+ E_FAULT bad address
+ E_INTR function call was interrupted
+ E_LOOP too many symbolic links encountered
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+
+ @see DirectoryItem::getFileStatus()
+ */
+
+ static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, const ::rtl::OUString& ustrRelativeFileURL, ::rtl::OUString& ustrAbsoluteFileURL )
+ {
+ return (RC) osl_getAbsoluteFileURL( ustrBaseDirectoryURL.pData, ustrRelativeFileURL.pData, &ustrAbsoluteFileURL.pData );
+ }
+
+ /** Convert a file URL into a system dependend path.
+
+ @param ustrFileURL [in]
+ A File URL.
+
+ @param ustrSystemPath [out]
+ On success it receives the system path.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see getFileURLFromSystemPath()
+ */
+
+ static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL, ::rtl::OUString& ustrSystemPath )
+ {
+ return (RC) osl_getSystemPathFromFileURL( ustrFileURL.pData, &ustrSystemPath.pData );
+ }
+
+ /** Convert a system dependend path into a file URL.
+
+ @param ustrSystemPath [in]
+ A System dependent path of a file or directory.
+
+ @param ustrFileURL [out]
+ On success it receives the file URL.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see getSystemPathFromFileURL()
+ */
+
+ static inline RC getFileURLFromSystemPath( const ::rtl::OUString& ustrSystemPath, ::rtl::OUString& ustrFileURL )
+ {
+ return (RC) osl_getFileURLFromSystemPath( ustrSystemPath.pData, &ustrFileURL.pData );
+ }
+
+ /** Searche a full qualified system path or a file URL.
+
+ @param ustrFileName [in]
+ A system dependent path, a file URL, a file or relative directory
+
+ @param ustrSearchPath [in]
+ A list of system paths, in which a given file has to be searched. The Notation of a path list is
+ system dependend, e.g. on UNIX system "/usr/bin:/bin" and on Windows "C:\BIN;C:\BATCH".
+ These paths are only for the search of a file or a relative path, otherwise it will be ignored.
+ If ustrSearchPath is NULL or while using the search path the search failed, the function searches for
+ a matching file in all system directories and in the directories listed in the PATH environment
+ variable.
+ The value of an environment variable should be used (e.g. LD_LIBRARY_PATH) if the caller is not
+ aware of the Operating System and so doesn't know which path list delimiter to use.
+
+ @param ustrFileURL [out]
+ On success it receives the full qualified file URL.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOTDIR not a directory
+ E_NOENT no such file or directory not found
+
+ @see getFileURLFromSystemPath()
+ @see getSystemPathFromFileURL()
+ */
+
+ static inline RC searchFileURL( const ::rtl::OUString& ustrFileName, const ::rtl::OUString& ustrSearchPath, ::rtl::OUString& ustrFileURL )
+ {
+ return (RC) osl_searchFileURL( ustrFileName.pData, ustrSearchPath.pData, &ustrFileURL.pData );
+ }
+
+ /** Retrieves the file URL of the system's temporary directory path.
+
+ @param ustrTempDirURL[out]
+ On success receives the URL of system's temporary directory path.
+
+ @return
+ E_None on success
+ E_NOENT no such file or directory not found
+ */
+
+ static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
+ {
+ return (RC) osl_getTempDirURL( &ustrTempDirURL.pData );
+ }
+
+ /** Creates a temporary file in the directory provided by the caller or the
+ directory returned by getTempDirURL.
+ Under UNIX Operating Systems the file will be created with read and write
+ access for the user exclusively.
+ If the caller requests only a handle to the open file but not the name of
+ it, the file will be automatically removed on close else the caller is
+ responsible for removing the file on success.<br><br>
+
+ @param pustrDirectoryURL [in]
+ Specifies the full qualified URL where the temporary file should be created.
+ If pustrDirectoryURL is 0 the path returned by osl_getTempDirURL will be used.
+
+ @param pHandle [out]
+ On success receives a handle to the open file.
+ If pHandle is 0 the file will be closed on return, in this case
+ pustrTempFileURL must not be 0.
+
+ @param pustrTempFileURL [out]
+ On success receives the full qualified URL of the temporary file.
+ If pustrTempFileURL is 0 the file will be automatically removed
+ on close, in this case pHandle must not be 0.
+ If pustrTempFileURL is not 0 the caller receives the name of the
+ created file and is responsible for removing the file.
+
+ @descr
+ Description of the different pHandle, ppustrTempFileURL parameter combinations.
+ pHandle is 0 and pustrTempDirURL is 0 - this combination is invalid<br>
+ pHandle is not 0 and pustrTempDirURL is 0 - a handle to the open file
+ will be returned on success and the file will be automatically removed on close<br>
+ pHandle is 0 and pustrTempDirURL is not 0 - the name of the file will be
+ returned, the caller is responsible for opening, closing and removing the file.<br>
+ pHandle is not 0 and pustrTempDirURL is not 0 - a handle to the open file as well as
+ the file name will be returned, the caller is responsible for closing and removing
+ the file.<br>
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameter is invalid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES Permission denied
+ E_NOENT No such file or directory
+ E_NOTDIR Not a directory
+ E_ROFS Read-only file system
+ E_NOSPC No space left on device
+ E_DQUOT Quota exceeded
+
+ @see getTempDirURL()
+ */
+
+ static inline RC createTempFile(
+ ::rtl::OUString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ ::rtl::OUString* pustrTempFileURL)
+ {
+ rtl_uString* pustr_dir_url = pustrDirectoryURL ? pustrDirectoryURL->pData : 0;
+ rtl_uString** ppustr_tmp_file_url = pustrTempFileURL ? &pustrTempFileURL->pData : 0;
+
+ return (RC) osl_createTempFile(pustr_dir_url, pHandle, ppustr_tmp_file_url);
+ }
+};
+
+
+// -----------------------------------------------------------------------------
+/** The VolumeDevice class.
+
+ @see VolumeInfo
+*/
+#ifdef OS2
+class VolumeInfo;
+#endif
+
+class VolumeDevice : public FileBase
+{
+#ifdef OS2
+public:
+#endif
+ oslVolumeDeviceHandle _aHandle;
+
+public:
+
+ /** Constructor.
+ */
+
+ VolumeDevice() : _aHandle( NULL )
+ {
+ }
+
+ /** Copy constructor.
+
+ @param rDevice
+ The other volume device.
+ */
+
+ VolumeDevice( const VolumeDevice & rDevice )
+ {
+ _aHandle = rDevice._aHandle;
+ if ( _aHandle )
+ osl_acquireVolumeDeviceHandle( _aHandle );
+ }
+
+ /** Destructor.
+ */
+
+ ~VolumeDevice()
+ {
+ if ( _aHandle )
+ osl_releaseVolumeDeviceHandle( _aHandle );
+ }
+
+ /** Assignment operator.
+
+ @param rDevice
+ The other volume device.
+ */
+
+ inline VolumeDevice & operator =( const VolumeDevice & rDevice )
+ {
+ oslVolumeDeviceHandle newHandle = rDevice._aHandle;
+
+ if ( newHandle )
+ osl_acquireVolumeDeviceHandle( newHandle );
+
+ if ( _aHandle )
+ osl_releaseVolumeDeviceHandle( _aHandle );
+
+ _aHandle = newHandle;
+
+ return *this;
+ }
+
+ /** Automount a volume device.
+
+ @return
+ E_None on success
+
+ @todo
+ specify all error codes that may be returned
+ */
+
+ inline RC automount()
+ {
+ return (RC)osl_automountVolumeDevice( _aHandle );
+ }
+
+ /** Unmount a volume device.
+
+ @return
+ E_None on success
+
+ @todo
+ specify all error codes that may be returned
+ */
+
+ inline RC unmount()
+ {
+ return (RC)osl_unmountVolumeDevice( _aHandle );
+ }
+
+ /** Get the full qualified URL where a device is mounted to.
+
+ @return
+ The full qualified URL where the device is mounted to.
+ */
+ inline rtl::OUString getMountPath()
+ {
+ rtl::OUString aPath;
+ osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData );
+ return aPath;
+ }
+
+ friend class VolumeInfo;
+};
+
+// -----------------------------------------------------------------------------
+
+#define VolumeInfoMask_Attributes osl_VolumeInfo_Mask_Attributes
+#define VolumeInfoMask_TotalSpace osl_VolumeInfo_Mask_TotalSpace
+#define VolumeInfoMask_UsedSpace osl_VolumeInfo_Mask_UsedSpace
+#define VolumeInfoMask_FreeSpace osl_VolumeInfo_Mask_FreeSpace
+#define VolumeInfoMask_MaxNameLength osl_VolumeInfo_Mask_MaxNameLength
+#define VolumeInfoMask_MaxPathLength osl_VolumeInfo_Mask_MaxPathLength
+#define VolumeInfoMask_FileSystemName osl_VolumeInfo_Mask_FileSystemName
+#define VolumeInfoMask_FileSystemCaseHandling osl_VolumeInfo_Mask_FileSystemCaseHandling
+
+class Directory;
+
+/** The VolumeInfo class.
+
+ Neither copy nor assignment is allowed for this class.
+
+ @see Directory::getVolumeInfo
+*/
+
+
+class VolumeInfo
+{
+ oslVolumeInfo _aInfo;
+ sal_uInt32 _nMask;
+ VolumeDevice _aDevice;
+
+ /** Copy constructor.
+ */
+
+ VolumeInfo( VolumeInfo& );
+
+ /** Assginment operator.
+ */
+
+ VolumeInfo& operator = ( VolumeInfo& );
+
+public:
+
+ /** Constructor.
+
+ @param nMask
+ Set of flaggs decribing the demanded information.
+ */
+
+ VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
+ {
+ _aInfo.uStructSize = sizeof( oslVolumeInfo );
+ rtl_fillMemory( &_aInfo.uValidFields, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ), 0 );
+ _aInfo.pDeviceHandle = &_aDevice._aHandle;
+ }
+
+ /** Destructor.
+ */
+
+ ~VolumeInfo()
+ {
+ if( _aInfo.ustrFileSystemName )
+ rtl_uString_release( _aInfo.ustrFileSystemName );
+ }
+
+ /** Check if specified fields are valid.
+
+ @param nMask
+ Set of flags for the fields to check.
+
+ @return sal_True if all fields are valid else sal_False.
+ */
+
+ inline sal_Bool isValid( sal_uInt32 nMask ) const
+ {
+ return ( nMask & _aInfo.uValidFields ) == nMask;
+ }
+
+ /** Check the remote flag.
+
+ @return
+ sal_True if Attributes are valid and the volume is remote else sal_False.
+ */
+
+ inline sal_Bool getRemoteFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Remote);
+ }
+
+ /** Check the removeable flag.
+
+ @return
+ sal_True if attributes are valid and the volume is removable else sal_False.
+ */
+
+ inline sal_Bool getRemoveableFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_Removeable);
+ }
+
+ /** Check the compact disc flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a CDROM else sal_False.
+ */
+
+ inline sal_Bool getCompactDiscFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_CompactDisc);
+ }
+
+ /** Check the floppy disc flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a floppy disk else sal_False.
+ */
+
+ inline sal_Bool getFloppyDiskFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FloppyDisk);
+ }
+
+ /** Check the fixed disk flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a fixed disk else sal_False.
+ */
+
+ inline sal_Bool getFixedDiskFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_FixedDisk);
+ }
+
+ /** Check the RAM disk flag.
+
+ @return
+ sal_True if attributes are valid and the volume is a RAM disk else sal_False.
+ */
+
+ inline sal_Bool getRAMDiskFlag() const
+ {
+ return 0 != (_aInfo.uAttributes & osl_Volume_Attribute_RAMDisk);
+ }
+
+ /** Determine the total space of a volume device.
+
+ @return
+ The total diskspace of this volume if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt64 getTotalSpace() const
+ {
+ return _aInfo.uTotalSpace;
+ }
+
+ /** Determine the free space of a volume device.
+
+ @return
+ The free diskspace of this volume if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt64 getFreeSpace() const
+ {
+ return _aInfo.uFreeSpace;
+ }
+
+ /** Determine the used space of a volume device.
+
+ @return
+ The used diskspace of this volume if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt64 getUsedSpace() const
+ {
+ return _aInfo.uUsedSpace;
+ }
+
+ /** Determine the maximal length of a file name.
+
+ @return
+ The maximal length of a file name if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt32 getMaxNameLength() const
+ {
+ return _aInfo.uMaxNameLength;
+ }
+
+ /** Determine the maximal length of a path name.
+
+ @return
+ The maximal length of a path if this information is valid,
+ 0 otherwise.
+ */
+
+ inline sal_uInt32 getMaxPathLength() const
+ {
+ return _aInfo.uMaxPathLength;
+ }
+
+ /** Determine the name of the volume device's File System.
+
+ @return
+ The name of the volume's fielsystem if this information is valid,
+ otherwise an empty string.
+ */
+
+ inline ::rtl::OUString getFileSystemName() const
+ {
+ return _aInfo.ustrFileSystemName ? ::rtl::OUString( _aInfo.ustrFileSystemName ) : ::rtl::OUString();
+ }
+
+
+ /** Get the volume device handle.
+
+ @return
+ The device handle of the volume if this information is valid,
+ otherwise returns NULL;
+ */
+
+ inline VolumeDevice getDeviceHandle() const
+ {
+ return _aDevice;
+ }
+
+ /** Return whether the file system is case sensitive or
+ case insensitive
+
+ @return
+ true if the file system is case sensitive false otherwise
+ */
+ bool isCaseSensitiveFileSystem() const
+ {
+ return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Sensitive);
+ }
+
+ /** Return whether the file system preserves the case of
+ file and directory names or not
+
+ @return
+ true if the file system preserves the case of file and
+ directory names false otherwise
+ */
+ bool isCasePreservingFileSystem() const
+ {
+ return (_aInfo.uAttributes & osl_Volume_Attribute_Case_Is_Preserved);
+ }
+
+ friend class Directory;
+};
+
+// -----------------------------------------------------------------------------
+
+#define FileStatusMask_Type osl_FileStatus_Mask_Type
+#define FileStatusMask_Attributes osl_FileStatus_Mask_Attributes
+#define FileStatusMask_CreationTime osl_FileStatus_Mask_CreationTime
+#define FileStatusMask_AccessTime osl_FileStatus_Mask_AccessTime
+#define FileStatusMask_ModifyTime osl_FileStatus_Mask_ModifyTime
+#define FileStatusMask_FileSize osl_FileStatus_Mask_FileSize
+#define FileStatusMask_FileName osl_FileStatus_Mask_FileName
+#define FileStatusMask_FileURL osl_FileStatus_Mask_FileURL
+#define FileStatusMask_LinkTargetURL osl_FileStatus_Mask_LinkTargetURL
+#define FileStatusMask_All osl_FileStatus_Mask_All
+#define FileStatusMask_Validate osl_FileStatus_Mask_Validate
+
+#define Attribute_ReadOnly osl_File_Attribute_ReadOnly
+#define Attribute_Hidden osl_File_Attribute_Hidden
+#define Attribute_Executable osl_File_Attribute_Executable
+#define Attribute_GrpWrite osl_File_Attribute_GrpWrite
+#define Attribute_GrpRead osl_File_Attribute_GrpRead
+#define Attribute_GrpExe osl_File_Attribute_GrpExe
+#define Attribute_OwnWrite osl_File_Attribute_OwnWrite
+#define Attribute_OwnRead osl_File_Attribute_OwnRead
+#define Attribute_OwnExe osl_File_Attribute_OwnExe
+#define Attribute_OthWrite osl_File_Attribute_OthWrite
+#define Attribute_OthRead osl_File_Attribute_OthRead
+#define Attribute_OthExe osl_File_Attribute_OthExe
+
+class DirectoryItem;
+
+/** The FileStatus class.
+
+ @see DirectoryItem::getFileStatus
+*/
+
+class FileStatus
+{
+ oslFileStatus _aStatus;
+ sal_uInt32 _nMask;
+
+ /** Copy constructor.
+ */
+
+ FileStatus( FileStatus& );
+
+ /** Assignment operator.
+ */
+
+ FileStatus& operator = ( FileStatus& );
+
+public:
+
+ enum Type {
+ Directory = osl_File_Type_Directory,
+ Volume = osl_File_Type_Volume,
+ Regular = osl_File_Type_Regular,
+ Fifo = osl_File_Type_Fifo,
+ Socket = osl_File_Type_Socket,
+ Link = osl_File_Type_Link,
+ Special = osl_File_Type_Special,
+ Unknown = osl_File_Type_Unknown
+ };
+
+ /** Constructor.
+
+ @param nMask
+ Set of flaggs decribing the demanded information.
+ */
+
+ FileStatus( sal_uInt32 nMask ): _nMask( nMask )
+ {
+ _aStatus.uStructSize = sizeof( oslFileStatus );
+ rtl_fillMemory( &_aStatus.uValidFields, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ), 0 );
+ }
+
+ /** Destructor.
+ */
+
+ ~FileStatus()
+ {
+ if ( _aStatus.ustrFileURL )
+ rtl_uString_release( _aStatus.ustrFileURL );
+ if ( _aStatus.ustrLinkTargetURL )
+ rtl_uString_release( _aStatus.ustrLinkTargetURL );
+ if ( _aStatus.ustrFileName )
+ rtl_uString_release( _aStatus.ustrFileName );
+ }
+
+ /** Check if specified fields are valid.
+
+ @param nMask
+ Set of flags for the fields to check.
+
+ @return
+ sal_True if all fields are valid else sal_False.
+ */
+
+ inline sal_Bool isValid( sal_uInt32 nMask ) const
+ {
+ return ( nMask & _aStatus.uValidFields ) == nMask;
+ }
+
+ /** Get the file type.
+
+ @return
+ The file type if this information is valid, Unknown otherwise.
+ */
+ inline Type getFileType() const
+ {
+ return (_aStatus.uValidFields & FileStatusMask_Type) ? (Type) _aStatus.eType : Unknown;
+ }
+
+ /** Get the file attributes.
+
+ @return
+ The set of attribute flags of this file.
+ */
+
+ inline sal_uInt64 getAttributes() const
+ {
+ return _aStatus.uAttributes;
+ }
+
+ /** Get the creation time of this file.
+
+ @return
+ The creation time if this information is valid,
+ an uninitialized TimeValue otherwise.
+ */
+
+ inline TimeValue getCreationTime() const
+ {
+ return _aStatus.aCreationTime;
+ }
+
+ /** Get the file access time.
+
+ @return
+ The last access time if this information is valid,
+ an uninitialized TimeValue otherwise.
+ */
+
+ inline TimeValue getAccessTime() const
+ {
+ return _aStatus.aAccessTime;
+ }
+
+ /** Get the file modification time.
+
+ @return
+ The last modified time if this information is valid,
+ an uninitialized TimeValue otherwise.
+ */
+
+ inline TimeValue getModifyTime() const
+ {
+ return _aStatus.aModifyTime;
+ }
+
+ /** Get the size of the file.
+
+ @return
+ The actual file size if this information is valid, 0 otherwise.
+ */
+
+ inline sal_uInt64 getFileSize() const
+ {
+ return _aStatus.uFileSize;
+ }
+
+ /** Get the file name.
+
+ @return
+ The file name if this information is valid, an empty string otherwise.
+ */
+
+ inline ::rtl::OUString getFileName() const
+ {
+ return _aStatus.ustrFileName ? ::rtl::OUString(_aStatus.ustrFileName) : ::rtl::OUString();
+ }
+
+
+ /** Get the URL of the file.
+
+ @return
+ The full qualified URL of the file if this information is valid, an empty string otherwise.
+ */
+
+ inline ::rtl::OUString getFileURL() const
+ {
+ return _aStatus.ustrFileURL ? ::rtl::OUString(_aStatus.ustrFileURL) : ::rtl::OUString();
+ }
+
+ /** Get the link target URL.
+
+ @return
+ The link target URL if this information is valid, an empty string otherwise.
+ */
+
+ inline ::rtl::OUString getLinkTargetURL() const
+ {
+ return _aStatus.ustrLinkTargetURL ? ::rtl::OUString(_aStatus.ustrLinkTargetURL) : ::rtl::OUString();
+ }
+
+ friend class DirectoryItem;
+};
+
+
+// -----------------------------------------------------------------------------
+/** The file class object provides access to file contents and attributes.
+
+ @see Directory
+ @see DirectoryItem
+ */
+
+class File: public FileBase
+{
+ oslFileHandle _pData;
+ ::rtl::OUString _aPath;
+
+ /** Copy constructor.
+ */
+
+ File( File& );
+
+ /** Assginment operator.
+ */
+
+ File& operator = ( File& );
+
+public:
+
+ /** Constructor.
+
+ @param ustrFileURL [in]
+ The full qualified URL of the file. Relative paths are not allowed.
+ */
+
+ File( const ::rtl::OUString& ustrFileURL ): _pData( 0 ), _aPath( ustrFileURL ) {}
+
+ /** Destructor
+ */
+
+ inline ~File()
+ {
+ close();
+ }
+
+ #define OpenFlag_Read osl_File_OpenFlag_Read
+ #define OpenFlag_Write osl_File_OpenFlag_Write
+ #define OpenFlag_Create osl_File_OpenFlag_Create
+ #define OpenFlag_NoLock osl_File_OpenFlag_NoLock
+
+ /** Open a regular file.
+
+ Open a file. Only regular files can be openend.
+
+ @param uFlags [in]
+ Specifies the open mode.
+
+ @return
+ E_None on success
+ E_NOMEM not enough memory for allocating structures
+ E_INVAL the format of the parameters was not valid
+ E_NAMETOOLONG pathname was too long
+ E_NOENT no such file or directory
+ E_ACCES permission denied
+ E_AGAIN a write lock could not be established
+ E_NOTDIR not a directory
+ E_NXIO no such device or address
+ E_NODEV no such device
+ E_ROFS read-only file system
+ E_TXTBSY text file busy
+ E_FAULT bad address
+ E_LOOP too many symbolic links encountered
+ E_NOSPC no space left on device
+ E_ISDIR is a directory
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_DQUOT quota exceeded
+ E_EXIST file exists
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_EOVERFLOW value too large for defined data type
+
+ @see close()
+ @see setPos()
+ @see getPos()
+ @see read()
+ @see write()
+ @see getSize()
+ @see setSize()
+ */
+
+ inline RC open( sal_uInt32 uFlags )
+ {
+ return (RC) osl_openFile( _aPath.pData, &_pData, uFlags );
+ }
+
+ /** Close an open file.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_BADF Bad file
+ E_INTR function call was interrupted
+ E_NOLINK link has been severed
+ E_NOSPC no space left on device
+ E_IO on I/O errors
+
+ @see open()
+ */
+
+ inline RC close()
+ {
+ oslFileError Error = osl_File_E_BADF;
+
+ if( _pData )
+ {
+ Error=osl_closeFile( _pData );
+ _pData = NULL;
+ }
+
+ return (RC) Error;
+ }
+
+
+ #define Pos_Absolut osl_Pos_Absolut
+ #define Pos_Current osl_Pos_Current
+ #define Pos_End osl_Pos_End
+
+ /** Set the internal position pointer of an open file.
+
+ @param uHow [in]
+ Distance to move the internal position pointer (from uPos).
+
+ @param uPos [in]
+ Absolute position from the beginning of the file.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see getPos()
+ */
+
+ inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
+ {
+ return (RC) osl_setFilePos( _pData, uHow, uPos );
+ }
+
+ /** Retrieve the current position of the internal pointer of an open file.
+
+ @param uPos [out]
+ On success receives the current position of the file pointer.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see setPos()
+ @see read()
+ @see write()
+ */
+
+ inline RC getPos( sal_uInt64& uPos )
+ {
+ return (RC) osl_getFilePos( _pData, &uPos );
+ }
+
+ /** Test if the end of a file is reached.
+
+ @param pIsEOF [out]
+ Points to a variable that receives the end-of-file status.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_ISDIR is a directory
+ E_BADF bad file
+ E_FAULT bad address
+ E_AGAIN operation would block
+ E_NOLINK link has been severed
+
+ @see open()
+ @see read()
+ @see readLine()
+ @see setPos()
+ */
+
+ inline RC isEndOfFile( sal_Bool *pIsEOF )
+ {
+ return (RC) osl_isEndOfFile( _pData, pIsEOF );
+ }
+
+ /** Set the file size of an open file.
+
+ Sets the file size of an open file. The file can be truncated or enlarged by the function.
+ The position of the file pointer is not affeced by this function.
+
+ @param uSize [in]
+ New size in bytes.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see setPos()
+ @see getStatus()
+ */
+
+ inline RC setSize( sal_uInt64 uSize )
+ {
+ return (RC) osl_setFileSize( _pData, uSize );
+ }
+
+ /** Get the file size of an open file.
+
+ Gets the file size of an open file.
+ The position of the file pointer is not affeced by this function.
+
+ @param rSize [out]
+ Current size in bytes.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_OVERFLOW the resulting file offset would be a value which cannot be represented correctly for regular files
+
+ @see open()
+ @see setPos()
+ @see getSize()
+ @see setSize()
+ @see getStatus()
+ */
+
+ inline RC getSize( sal_uInt64 &rSize )
+ {
+ return (RC) osl_getFileSize( _pData, &rSize );
+ }
+
+ /** Read a number of bytes from a file.
+
+ Reads a number of bytes from a file. The internal file pointer is
+ increased by the number of bytes read.
+
+ @param pBuffer [out]
+ Points to a buffer which receives data. The buffer must be large enough
+ to hold uBytesRequested bytes.
+
+ @param uBytesRequested [in]
+ Number of bytes which should be retrieved.
+
+ @param rBytesRead [out]
+ On success the number of bytes which have actually been retrieved.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_ISDIR is a directory
+ E_BADF bad file
+ E_FAULT bad address
+ E_AGAIN operation would block
+ E_NOLINK link has been severed
+
+ @see open()
+ @see write()
+ @see readLine()
+ @see setPos()
+ */
+
+ inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
+ {
+ return (RC) osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead );
+ }
+
+ /** Write a number of bytes to a file.
+
+ Writes a number of bytes to a file.
+ The internal file pointer is increased by the number of bytes read.
+
+ @param pBuffer [in]
+ Points to a buffer which contains the data.
+
+ @param uBytesToWrite [in]
+ Number of bytes which should be written.
+
+ @param rBytesWritten [out]
+ On success the number of bytes which have actually been written.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_FBIG file too large
+ E_DQUOT quota exceeded
+ E_AGAIN operation would block
+ E_BADF bad file
+ E_FAULT bad address
+ E_INTR function call was interrupted
+ E_IO on I/O errosr
+ E_NOLCK no record locks available
+ E_NOLINK link has been severed
+ E_NOSPC no space left on device
+ E_NXIO no such device or address
+
+ @see open()
+ @see read()
+ @see setPos()
+ */
+
+ inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
+ {
+ return (RC) osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten );
+ }
+
+
+ /** Read a line from a file.
+
+ Reads a line from a file. The new line delimiter is NOT returned!
+
+ @param aSeq [in/out]
+ A reference to a ::rtl::ByteSequence that will hold the line read on success.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_INTR function call was interrupted
+ E_IO on I/O errors
+ E_ISDIR is a directory
+ E_BADF bad file
+ E_FAULT bad address
+ E_AGAIN operation would block
+ E_NOLINK link has been severed
+
+ @see open()
+ @see read()
+ @see write()
+ @see setPos()
+ */
+
+ inline RC readLine( ::rtl::ByteSequence& aSeq )
+ {
+ return (RC) osl_readLine( _pData, reinterpret_cast<sal_Sequence**>(&aSeq) );
+ }
+
+ /** Synchronize the memory representation of a file with that on the physical medium.
+
+ The function ensures that all modified data and attributes of the file associated with
+ the given file handle have been written to the physical medium.
+ In case the hard disk has a write cache enabled, the data may not really be on
+ permanent storage when osl_syncFile returns.
+
+ @return
+ <dl>
+ <dt>E_None</dt>
+ <dd>On success</dd>
+ <dt>E_INVAL</dt>
+ <dd>The value of the input parameter is invalid</dd>
+ </dl>
+ <br><p><strong>In addition to these error codes others may occur as well, for instance:</strong></p><br>
+ <dt>E_BADF</dt>
+ <dd>The file is not open for writing</dd>
+ <dt>E_IO</dt>
+ <dd>An I/O error occurred</dd>
+ <dt>E_NOSPC</dt>
+ <dd>There is no enough space on the target device</dd>
+ <dt>E_ROFS</dt>
+ <dd>The file is located on a read only file system</dd>
+ <dt>E_TIMEDOUT</dt>
+ <dd>A remote connection timed out. This may happen when a file is on a remote location</dd>
+ </dl>
+
+ @see osl_syncFile()
+ @see open()
+ @see write()
+ */
+ inline RC sync() const
+ {
+ OSL_PRECOND(_pData, "File::sync(): File not open");
+ return (RC)osl_syncFile(_pData);
+ }
+
+ /** Copy a file to a new destination.
+
+ Copies a file to a new destination. Copies only files not directories.
+ No assumptions should be made about preserving attributes or file time.
+
+ @param ustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param ustrDestFileURL [in]
+ Full qualified URL of the destination file. A directory is NOT a valid destination file!
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_PERM operation not permitted
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ISDIR is a directory
+ E_ROFS read-only file system
+
+ @see move()
+ @see remove()
+ */
+
+ inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
+ {
+ return (RC) osl_copyFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
+ }
+
+ /** Move a file or directory to a new destination or renames it.
+
+ Moves a file or directory to a new destination or renames it.
+ File time and attributes are preserved.
+
+ @param ustrSourceFileURL [in]
+ Full qualified URL of the source file.
+
+ @param ustrDestFileURL [in]
+ Full qualified URL of the destination file. An existing directory is NOT a valid destination !
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_PERM operation not permitted
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ROFS read-only file system
+
+ @see copy()
+ */
+
+ inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
+ {
+ return (RC) osl_moveFile( ustrSourceFileURL.pData, ustrDestFileURL.pData );
+ }
+
+ /** Remove a regular file.
+
+ @param ustrFileURL [in]
+ Full qualified URL of the file to remove.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_PERM operation not permitted
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ISDIR is a directory
+ E_ROFS read-only file system
+ E_FAULT bad address
+ E_LOOP too many symbolic links encountered
+ E_IO on I/O errors
+ E_BUSY device or resource busy
+ E_INTR function call was interrupted
+ E_LOOP too many symbolic links encountered
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_TXTBSY text file busy
+
+ @see open()
+ */
+
+ inline static RC remove( const ::rtl::OUString& ustrFileURL )
+ {
+ return (RC) osl_removeFile( ustrFileURL.pData );
+ }
+
+ /** Set file attributes.
+
+ @param ustrFileURL [in]
+ The full qualified file URL.
+
+ @param uAttributes [in]
+ Attributes of the file to be set.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+
+ @see FileStatus
+ */
+
+ inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
+ {
+ return (RC) osl_setFileAttributes( ustrFileURL.pData, uAttributes );
+ }
+
+ /** Set the file time.
+
+ @param ustrFileURL [in]
+ The full qualified URL of the file.
+
+ @param rCreationTime [in]
+ Creation time of the given file.
+
+ @param rLastAccessTime [in]
+ Time of the last access of the given file.
+
+ @param rLastWriteTime [in]
+ Time of the last modifying of the given file.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOENT no such file or directory not found
+
+ @see FileStatus
+ */
+
+ inline static RC setTime(
+ const ::rtl::OUString& ustrFileURL,
+ const TimeValue& rCreationTime,
+ const TimeValue& rLastAccessTime,
+ const TimeValue& rLastWriteTime )
+ {
+ return (RC) osl_setFileTime(
+ ustrFileURL.pData,
+ &rCreationTime,
+ &rLastAccessTime,
+ &rLastWriteTime );
+ }
+
+ friend class DirectoryItem;
+};
+
+// -----------------------------------------------------------------------------
+/** The directory item class object provides access to file status information.
+
+ @see FileStatus
+ */
+
+class DirectoryItem: public FileBase
+{
+ oslDirectoryItem _pData;
+
+public:
+
+ /** Constructor.
+ */
+
+ DirectoryItem(): _pData( NULL )
+ {
+ }
+
+ /** Copy constructor.
+ */
+
+ DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
+ {
+ if( _pData )
+ osl_acquireDirectoryItem( _pData );
+ }
+
+ /** Destructor.
+ */
+
+ ~DirectoryItem()
+ {
+ if( _pData )
+ osl_releaseDirectoryItem( _pData );
+ }
+
+ /** Assignment operator.
+ */
+
+ DirectoryItem& operator=(const DirectoryItem& rItem )
+ {
+ if (&rItem != this)
+ {
+ if( _pData )
+ osl_releaseDirectoryItem( _pData );
+
+ _pData = rItem._pData;
+
+ if( _pData )
+ osl_acquireDirectoryItem( _pData );
+ }
+ return *this;
+ }
+
+ /** Check for validity of this instance.
+
+ @return
+ sal_True if object is valid directory item else sal_False.
+ */
+
+ inline sal_Bool is()
+ {
+ return _pData != NULL;
+ }
+
+ /** Retrieve a single directory item.
+
+ Retrieves a single directory item. The returned handle has an initial refcount of 1.
+ Due to performance issues it is not recommended to use this function while
+ enumerating the contents of a directory. In this case use osl_getNextDirectoryItem() instead.
+
+ @param ustrFileURL [in]
+ An absolute file URL.
+
+ @param rItem [out]
+ On success it receives a handle which can be used for subsequent calls to osl_getFileStatus().
+ The handle has to be released by a call to osl_releaseDirectoryItem().
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NOENT no such file or directory
+ E_LOOP too many symbolic links encountered
+ E_NAMETOOLONG the file name is too long
+ E_NOTDIR a component of the path prefix of path is not a directory
+ E_IO on I/O errors
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_FAULT bad address
+ E_INTR the function call was interrupted
+
+ @see FileStatus
+ @see Directory::getNextItem()
+ */
+
+ static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
+ {
+ if( rItem._pData)
+ {
+ osl_releaseDirectoryItem( rItem._pData );
+ rItem._pData = NULL;
+ }
+
+ return (RC) osl_getDirectoryItem( ustrFileURL.pData, &rItem._pData );
+ }
+
+ /** Retrieve information about a single file or directory.
+
+ @param rStatus [in|out]
+ Reference to a class which receives the information of the file or directory
+ represented by this directory item.
+
+ @return
+ E_None on success
+ E_NOMEM not enough memory for allocating structures
+ E_INVAL the format of the parameters was not valid
+ E_LOOP too many symbolic links encountered
+ E_ACCES permission denied
+ E_NOENT no such file or directory
+ E_NAMETOOLONG file name too long
+ E_BADF invalid oslDirectoryItem parameter
+ E_FAULT bad address
+ E_OVERFLOW value too large for defined data type
+ E_INTR function call was interrupted
+ E_NOLINK link has been severed
+ E_MULTIHOP components of path require hopping to multiple remote machines and the file system does not allow it
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NOSPC no space left on device
+ E_NXIO no such device or address
+ E_IO on I/O errors
+ E_NOSYS function not implemented
+
+ @see get()
+ @see Directory::getNextItem()
+ @see FileStatus
+ */
+
+ inline RC getFileStatus( FileStatus& rStatus )
+ {
+ return (RC) osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask );
+ }
+
+ friend class Directory;
+};
+
+//###########################################
+
+/** Base class for observers of directory creation notifications.
+
+ Clients which uses the method createDirectoryPath of the class
+ Directory may want to be informed about the directories that
+ have been created. This may be accomplished by deriving from
+ this base class and overwriting the virtual function
+ DirectoryCreated.
+
+ @see Directory::createPath
+*/
+class DirectoryCreationObserver
+{
+public:
+ virtual ~DirectoryCreationObserver() {};
+
+ /** This method will be called when a new directory has been
+ created and needs to be overwritten by derived classes.
+ You must not delete the directory that was just created
+ otherwise you will run into an endless loop.
+
+ @param aDirectoryUrl
+ [in]The absolute file URL of the directory that was just created by
+ ::osl::Directory::createPath.
+ */
+ virtual void DirectoryCreated(const rtl::OUString& aDirectoryUrl) = 0;
+};
+
+//###########################################
+// This just an internal helper function for
+// private use.
+extern "C" inline void SAL_CALL onDirectoryCreated(void* pData, rtl_uString* aDirectoryUrl)
+{
+ (static_cast<DirectoryCreationObserver*>(pData))->DirectoryCreated(aDirectoryUrl);
+}
+
+/** The directory class object provides a enumeration of DirectoryItems.
+
+ @see DirectoryItem
+ @see File
+ */
+
+class Directory: public FileBase
+{
+ oslDirectory _pData;
+ ::rtl::OUString _aPath;
+
+ /** Copy constructor.
+ */
+
+ Directory( Directory& );
+
+ /** Assignment operator.
+ */
+
+ Directory& operator = ( Directory& );
+
+public:
+
+ /** Constructor.
+
+ @param strPath [in]
+ The full qualified URL of the directory.
+ Relative URLs are not allowed.
+ */
+
+ Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
+ {
+ }
+
+ /** Destructor.
+ */
+
+ ~Directory()
+ {
+ close();
+ }
+
+ /** Open a directory for enumerating its contents.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOENT the specified path doesn't exist
+ E_NOTDIR the specified path is not an directory
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NAMETOOLONG File name too long
+ E_LOOP Too many symbolic links encountered
+
+ @see getNextItem()
+ @see close()
+ */
+
+ inline RC open()
+ {
+ return (RC) osl_openDirectory( _aPath.pData, &_pData );
+ }
+
+ /** Query if directory is open.
+
+ Query if directory is open and so item enumeration is valid.
+
+ @return
+ sal_True if the directory is open else sal_False.
+
+ @see open()
+ @see close()
+ */
+
+ inline sal_Bool isOpen() { return _pData != NULL; };
+
+ /** Close a directory.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_BADF invalid oslDirectory parameter
+ E_INTR the function call was interrupted
+
+ @see open()
+ */
+
+ inline RC close()
+ {
+ oslFileError Error = osl_File_E_BADF;
+
+ if( _pData )
+ {
+ Error=osl_closeDirectory( _pData );
+ _pData = NULL;
+ }
+
+ return (RC) Error;
+ }
+
+
+ /** Resets the directory item enumeration to the beginning.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOENT the specified path doesn't exist
+ E_NOTDIR the specified path is not an directory
+ E_NOMEM not enough memory for allocating structures
+ E_ACCES permission denied
+ E_MFILE too many open files used by the process
+ E_NFILE too many open files in the system
+ E_NAMETOOLONG File name too long
+ E_LOOP Too many symbolic links encountered
+
+ @see open()
+ */
+
+ inline RC reset()
+ {
+ close();
+ return open();
+ }
+
+ /** Retrieve the next item of a previously opened directory.
+
+ Retrieves the next item of a previously opened directory.
+
+ @param rItem [out]
+ On success a valid DirectoryItem.
+
+ @param nHint [in]
+ With this parameter the caller can tell the implementation that (s)he
+ is going to call this function uHint times afterwards. This enables the implementation to
+ get the information for more than one file and cache it until the next calls.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_NOENT no more entries in this directory
+ E_BADF invalid oslDirectory parameter
+ E_OVERFLOW the value too large for defined data type
+
+ @see DirectoryItem
+ */
+
+ inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
+ {
+ if( rItem._pData )
+ {
+ osl_releaseDirectoryItem( rItem._pData );
+ rItem._pData = 0;
+ }
+ return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint );
+ }
+
+
+ /** Retrieve information about a volume.
+
+ Retrieves information about a volume. A volume can either be a mount point, a network
+ resource or a drive depending on Operating System and File System.
+
+ @param ustrDirectoryURL [in]
+ Full qualified URL of the volume
+
+ @param rInfo [out]
+ On success it receives information about the volume.
+
+ @return
+ E_None on success
+ E_NOMEM not enough memory for allocating structures
+ E_INVAL the format of the parameters was not valid
+ E_NOTDIR not a directory
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_ACCES permission denied
+ E_LOOP too many symbolic links encountered
+ E_FAULT Bad address
+ E_IO on I/O errors
+ E_NOSYS function not implemented
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+ E_INTR function call was interrupted
+
+ @see FileStatus
+ @see VolumeInfo
+ */
+
+ inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
+ {
+ return (RC) osl_getVolumeInformation( ustrDirectoryURL.pData, &rInfo._aInfo, rInfo._nMask );
+ }
+
+ /** Create a directory.
+
+ @param ustrDirectoryURL [in]
+ Full qualified URL of the directory to create.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_EXIST file exists
+ E_ACCES permission denied
+ E_NAMETOOLONG file name too long
+ E_NOENT no such file or directory
+ E_NOTDIR not a directory
+ E_ROFS read-only file system
+ E_NOSPC no space left on device
+ E_DQUOT quota exceeded
+ E_LOOP too many symbolic links encountered
+ E_FAULT bad address
+ E_IO on I/O errors
+ E_MLINK too many links
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+
+ @see remove()
+ */
+
+ inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
+ {
+ return (RC) osl_createDirectory( ustrDirectoryURL.pData );
+ }
+
+ /** Remove an empty directory.
+
+ @param ustrDirectoryURL [in]
+ Full qualified URL of the directory.
+
+ @return
+ E_None on success
+ E_INVAL the format of the parameters was not valid
+ E_NOMEM not enough memory for allocating structures
+ E_PERM operation not permitted
+ E_ACCES permission denied
+ E_NOENT no such file or directory
+ E_NOTDIR not a directory
+ E_NOTEMPTY directory not empty
+ E_FAULT bad address
+ E_NAMETOOLONG file name too long
+ E_BUSY device or resource busy
+ E_ROFS read-only file system
+ E_LOOP too many symbolic links encountered
+ E_BUSY device or resource busy
+ E_EXIST file exists
+ E_IO on I/O errors
+ E_MULTIHOP multihop attempted
+ E_NOLINK link has been severed
+
+ @see create()
+ */
+
+ inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
+ {
+ return (RC) osl_removeDirectory( ustrDirectoryURL.pData );
+ }
+
+ /** Create a directory path.
+
+ The osl_createDirectoryPath function creates a specified directory path.
+ All nonexisting sub directories will be created.
+ <p><strong>PLEASE NOTE:</strong> You cannot rely on getting the error code
+ E_EXIST for existing directories. Programming against this error code is
+ in general a strong indication of a wrong usage of osl_createDirectoryPath.</p>
+
+ @param aDirectoryUrl
+ [in] The absolute file URL of the directory path to create.
+ A relative file URL will not be accepted.
+
+ @param aDirectoryCreationObserver
+ [in] Pointer to an instance of type DirectoryCreationObserver that will
+ be informed about the creation of a directory. The value of this
+ parameter may be NULL, in this case notifications will not be sent.
+
+ @return
+ <dl>
+ <dt>E_None</dt>
+ <dd>On success</dd>
+ <dt>E_INVAL</dt>
+ <dd>The format of the parameters was not valid</dd>
+ <dt>E_ACCES</dt>
+ <dd>Permission denied</dd>
+ <dt>E_EXIST</dt>
+ <dd>The final node of the specified directory path already exist</dd>
+ <dt>E_NAMETOOLONG</dt>
+ <dd>The name of the specified directory path exceeds the maximum allowed length</dd>
+ <dt>E_NOTDIR</dt>
+ <dd>A component of the specified directory path already exist as file in any part of the directory path</dd>
+ <dt>E_ROFS</dt>
+ <dd>Read-only file system</dd>
+ <dt>E_NOSPC</dt>
+ <dd>No space left on device</dd>
+ <dt>E_DQUOT</dt>
+ <dd>Quota exceeded</dd>
+ <dt>E_FAULT</dt>
+ <dd>Bad address</dd>
+ <dt>E_IO</dt>
+ <dd>I/O error</dd>
+ <dt>E_LOOP</dt>
+ <dd>Too many symbolic links encountered</dd>
+ <dt>E_NOLINK</dt>
+ <dd>Link has been severed</dd>
+ <dt>E_invalidError</dt>
+ <dd>An unknown error occurred</dd>
+ </dl>
+
+ @see DirectoryCreationObserver
+ @see create
+ */
+ static RC createPath(
+ const ::rtl::OUString& aDirectoryUrl,
+ DirectoryCreationObserver* aDirectoryCreationObserver = NULL)
+ {
+ return (RC)osl_createDirectoryPath(
+ aDirectoryUrl.pData,
+ (aDirectoryCreationObserver) ? onDirectoryCreated : NULL,
+ aDirectoryCreationObserver);
+ }
+};
+
+} /* namespace osl */
+
+#endif /* __cplusplus */
+#endif /* _OSL_FILE_HXX_ */
+
diff --git a/sal/inc/osl/getglobalmutex.hxx b/sal/inc/osl/getglobalmutex.hxx
new file mode 100644
index 000000000000..43d463c2d1cd
--- /dev/null
+++ b/sal/inc/osl/getglobalmutex.hxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if !defined INCLUDED_OSL_GETGLOBALMUTEX_HXX
+#define INCLUDED_OSL_GETGLOBALMUTEX_HXX
+
+#include "osl/mutex.hxx"
+
+namespace osl {
+
+/** A helper functor for the rtl_Instance template.
+
+ See the rtl_Instance template for examples of how this class is used.
+ */
+class GetGlobalMutex
+{
+public:
+ ::osl::Mutex * operator()()
+ {
+ return ::osl::Mutex::getGlobalMutex();
+ }
+};
+
+}
+
+#endif // INCLUDED_OSL_GETGLOBALMUTEX_HXX
diff --git a/sal/inc/osl/interlck.h b/sal/inc/osl/interlck.h
new file mode 100644
index 000000000000..0785ef350965
--- /dev/null
+++ b/sal/inc/osl/interlck.h
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_INTERLOCK_H_
+#define _OSL_INTERLOCK_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef sal_Int32 oslInterlockedCount;
+
+/** Increments the count variable addressed by pCount.
+ @param Address of counter variable
+ @return The result of the operation is zero, the value of the count variable.
+*/
+oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount);
+
+/** Decrement the count variable addressed by pCount.
+ @param Address of counter variable
+ @return The result of the operation is the new value is of the count variable.
+*/
+oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_INTERLOCK_H_ */
+
+
diff --git a/sal/inc/osl/module.h b/sal/inc/osl/module.h
new file mode 100644
index 000000000000..78558fed4105
--- /dev/null
+++ b/sal/inc/osl/module.h
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/** @HTML */
+
+#ifndef _OSL_MODULE_H_
+#define _OSL_MODULE_H_
+
+# include <rtl/ustring.h>
+# include <rtl/tencinfo.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef SAL_DLLPREFIX
+#define SAL_MODULENAME(name) SAL_DLLPREFIX name SAL_DLLEXTENSION
+#else
+#define SAL_MODULENAME(name) name SAL_DLLEXTENSION
+#endif
+
+#if defined(SAL_W32) || defined(SAL_OS2)
+#define SAL_MODULENAME_WITH_VERSION(name, version) name version SAL_DLLEXTENSION
+
+#elif defined(SAL_UNX)
+#if defined(MACOSX)
+#define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name ".dylib." version
+#else
+#define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name SAL_DLLEXTENSION "." version
+#endif
+
+#endif
+
+#define SAL_LOADMODULE_DEFAULT 0x00000
+#define SAL_LOADMODULE_LAZY 0x00001
+#define SAL_LOADMODULE_NOW 0x00002
+#define SAL_LOADMODULE_GLOBAL 0x00100
+
+typedef void* oslModule;
+
+/** Generic Function pointer type that will be used as symbol address.
+ @see osl_getFunctionSymbol.
+ @see osl_getModuleURLFromFunctionAddress.
+*/
+typedef void ( SAL_CALL *oslGenericFunction )( void );
+
+/** Load a shared library or module.
+ @param strModuleName denotes the name of the module to be loaded.
+ @return NULL if the module could not be loaded, otherwise a handle to the module.
+*/
+oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode);
+
+/** Load a module located relative to some other module.
+
+ @param baseModule
+ must point to a function that is part of the code of some loaded module;
+ must not be NULL.
+
+ @param relativePath
+ a relative URL; must not be NULL.
+
+ @param mode
+ the SAL_LOADMODULE_xxx flags.
+
+ @return
+ a non-NULL handle to the loaded module, or NULL if an error occurred.
+
+ @since UDK 3.2.8
+*/
+oslModule SAL_CALL osl_loadModuleRelative(
+ oslGenericFunction baseModule, rtl_uString * relativePath, sal_Int32 mode);
+
+/** Retrieve the handle of an already loaded module.
+
+ This function can be used to search for a function symbol in the process address space.
+ Do not use the returned handle as an argument to osl_unloadModule. On Unix platforms,
+ pModuleName gets ignored and the special handle RTLD_DEFAULT is returned.
+
+ @param pModuleName
+ [in] denotes the name of the module to search for. Ignored on Unix
+
+ @param pResult
+ [out] a pointer to a oslModule that is updated with the requested module handle
+ on success.
+
+ @return
+ sal_True if the module handle could be retrieved and has been copied to *pResult.
+ sal_False if the module has not been loaded yet.
+
+ @see osl_getFunctionSymbol
+ @see osl_getAsciiFunctionSymbol
+*/
+sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult);
+
+/** Release the module
+*/
+void SAL_CALL osl_unloadModule(oslModule Module);
+
+/** lookup the specified symbol name.
+ @return address of the symbol or NULL if lookup failed.
+*/
+void* SAL_CALL osl_getSymbol( oslModule Module, rtl_uString *strSymbolName);
+
+/** Lookup the specified function symbol name.
+
+ osl_getFunctionSymbol is an alternative function for osl_getSymbol.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param Module
+ [in] the handle of the Module.
+
+ @param ustrFunctionSymbolName
+ [in] Name of the function that will be looked up.
+
+ @return
+ <dl>
+ <dt>Function address.</dt>
+ <dd>on success</dd>
+ <dt>NULL</dt>
+ <dd>lookup failed or the parameter are invalid.</dd>
+ </dl>
+
+ @see osl_getSymbol
+ @see osl_getAsciiFunctionSymbol
+*/
+oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *ustrFunctionSymbolName );
+
+/** Lookup the specified function symbol name.
+
+ osl_getAsciiFunctionSymbol is an alternative function for osl_getFunctionSymbol.
+ It expects the C-style function name string to contain ascii characters only.
+
+ @param Module
+ [in] a module handle as returned by osl_loadModule or osl_getModuleHandle
+
+ @param pFunctionSymbolName
+ [in] Name of the function that will be looked up.
+
+ @return
+ <dl>
+ <dt>Function address.</dt>
+ <dd>on success</dd>
+ <dt>NULL</dt>
+ <dd>lookup failed or the parameter are invalid.</dd>
+ </dl>
+
+ @see osl_getModuleHandle
+ @see osl_getFunctionSymbol
+*/
+oslGenericFunction SAL_CALL osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol);
+
+
+/** Lookup URL of module which is mapped at the specified address.
+ @param pv specifies an address in the process memory space.
+ @param pustrURL receives the URL of the module that is mapped at pv.
+ @return sal_True on success, sal_False if no module can be found at the specified address.
+*/
+sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL );
+
+/** Lookup URL of module which is mapped at the specified function address.
+
+ osl_getModuleURLFromFunctionAddress is an alternative function for osl_getModuleURLFromAddress.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param pf
+ [in] function address in oslGenericFunction format.
+
+ @param pustrFunctionURL
+ [out] receives the URL of the module that is mapped at pf.
+
+ @return
+ <dl>
+ <dt>sal_True</dt>
+ <dd>on success</dd>
+ <dt>sal_False</dt>
+ <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd>
+ </dl>
+
+ @see osl_getModuleURLFromAddress
+*/
+sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction pf, rtl_uString **pustrFunctionURL );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_MODULE_H_ */
diff --git a/sal/inc/osl/module.hxx b/sal/inc/osl/module.hxx
new file mode 100644
index 000000000000..fd787569b454
--- /dev/null
+++ b/sal/inc/osl/module.hxx
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/** @HTML */
+
+#ifndef _OSL_MODULE_HXX_
+#define _OSL_MODULE_HXX_
+
+#include <rtl/ustring.hxx>
+#include <osl/module.h>
+
+namespace osl
+{
+
+class Module
+{
+ Module( const Module&);
+ Module& operator = ( const Module&);
+
+public:
+ static sal_Bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) {
+ return osl_getModuleURLFromAddress(addr, &libraryUrl.pData);
+ }
+
+ /** Get module URL from the specified function address in the module.
+
+ Similar to getUrlFromAddress, but use a function address to get URL of the Module.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param addr
+ [in] function address in oslGenericFunction format.
+
+ @param libraryUrl
+ [in|out] receives the URL of the module.
+
+ @return
+ <dl>
+ <dt>sal_True</dt>
+ <dd>on success</dd>
+ <dt>sal_False</dt>
+ <dd>can not get the URL from the specified function address or the parameter is invalid.</dd>
+ </dl>
+
+ @see getUrlFromAddress
+ */
+ static sal_Bool getUrlFromAddress( oslGenericFunction addr, ::rtl::OUString & libraryUrl){
+ return osl_getModuleURLFromFunctionAddress( addr, &libraryUrl.pData );
+ }
+
+ Module(): m_Module(0){}
+
+ Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(0)
+ {
+ load( strModuleName, nRtldMode);
+ }
+
+ ~Module()
+ {
+ osl_unloadModule(m_Module);
+ }
+
+ sal_Bool SAL_CALL load( const ::rtl::OUString& strModuleName,
+ sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
+ {
+ unload();
+ m_Module= osl_loadModule( strModuleName.pData, nRtldMode );
+ return is();
+ }
+
+ /// @since UDK 3.2.8
+ sal_Bool SAL_CALL loadRelative(
+ ::oslGenericFunction baseModule, ::rtl::OUString const & relativePath,
+ ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT)
+ {
+ unload();
+ m_Module = osl_loadModuleRelative(baseModule, relativePath.pData, mode);
+ return is();
+ }
+
+ void SAL_CALL unload()
+ {
+ if (m_Module)
+ {
+ osl_unloadModule(m_Module);
+ m_Module = 0;
+ }
+ }
+
+ sal_Bool SAL_CALL is() const
+ {
+ return m_Module != NULL;
+ }
+
+ void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
+ {
+ return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
+ }
+
+ /** Get function address by the function name in the module.
+
+ getFunctionSymbol is an alternative function for getSymbol.
+ Use Function pointer as symbol address to conceal type conversion.
+
+ @param ustrFunctionSymbolName
+ [in] Function name to be looked up.
+
+ @return
+ <dl>
+ <dt>oslGenericFunction format function address</dt>
+ <dd>on success</dd>
+ <dt>NULL</dt>
+ <dd>lookup failed or parameter is somewhat invalid</dd>
+ </dl>
+
+ @see getSymbol
+ */
+ oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName )
+ {
+ return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
+ }
+
+ operator oslModule() const
+ {
+ return m_Module;
+ }
+
+private:
+ oslModule m_Module;
+
+};
+
+}
+
+#endif
diff --git a/sal/inc/osl/mutex.h b/sal/inc/osl/mutex.h
new file mode 100644
index 000000000000..2c779aadf566
--- /dev/null
+++ b/sal/inc/osl/mutex.h
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_MUTEX_H_
+#define _OSL_MUTEX_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _oslMutexImpl;
+typedef struct _oslMutexImpl * oslMutex;
+
+/** Create a thread-local mutex.
+ @return 0 if the mutex could not be created, otherwise a handle to the mutex.
+*/
+oslMutex SAL_CALL osl_createMutex(void);
+
+/** Release the OS-structures and free mutex data-structure.
+ @param Mutex the mutex-handle
+*/
+void SAL_CALL osl_destroyMutex(oslMutex Mutex);
+
+/** Acquire the mutex, block if already acquired by another thread.
+ @param Mutex handle to a created mutex.
+ @return False if system-call fails.
+*/
+sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex);
+
+/** Try to acquire the mutex without blocking.
+ @param Mutex handle to a created mutex.
+ @return False if it could not be acquired.
+*/
+sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex);
+
+/** Release the mutex.
+ @param Mutex handle to a created mutex.
+ @return False if system-call fails.
+*/
+sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex);
+
+/** Returns a unique and global mutex.
+ @return the global mutex.
+*/
+oslMutex * SAL_CALL osl_getGlobalMutex(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_MUTEX_H_ */
diff --git a/sal/inc/osl/mutex.hxx b/sal/inc/osl/mutex.hxx
new file mode 100644
index 000000000000..0fe0bd1b653e
--- /dev/null
+++ b/sal/inc/osl/mutex.hxx
@@ -0,0 +1,253 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_MUTEX_HXX_
+#define _OSL_MUTEX_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/mutex.h>
+
+
+namespace osl
+{
+ /** A mutual exclusion synchronization object
+ */
+ class Mutex {
+
+ public:
+ /** Create a thread-local mutex.
+ @return 0 if the mutex could not be created, otherwise a handle to the mutex.
+ @seealso ::osl_createMutex()
+ */
+ Mutex()
+ {
+ mutex = osl_createMutex();
+ }
+
+ /** Release the OS-structures and free mutex data-structure.
+ @seealso ::osl_destroyMutex()
+ */
+ ~Mutex()
+ {
+ osl_destroyMutex(mutex);
+ }
+
+ /** Acquire the mutex, block if already acquired by another thread.
+ @return sal_False if system-call fails.
+ @seealso ::osl_acquireMutex()
+ */
+ sal_Bool acquire()
+ {
+ return osl_acquireMutex(mutex);
+ }
+
+ /** Try to acquire the mutex without blocking.
+ @return sal_False if it could not be acquired.
+ @seealso ::osl_tryToAcquireMutex()
+ */
+ sal_Bool tryToAcquire()
+ {
+ return osl_tryToAcquireMutex(mutex);
+ }
+
+ /** Release the mutex.
+ @return sal_False if system-call fails.
+ @seealso ::osl_releaseMutex()
+ */
+ sal_Bool release()
+ {
+ return osl_releaseMutex(mutex);
+ }
+
+ /** Returns a global static mutex object.
+ The global and static mutex object can be used to initialize other
+ static objects in a thread safe manner.
+ @return the global mutex object
+ @seealso ::osl_getGlobalMutex()
+ */
+ static Mutex * getGlobalMutex()
+ {
+ return (Mutex *)osl_getGlobalMutex();
+ }
+
+ private:
+ oslMutex mutex;
+
+ /** The underlying oslMutex has no reference count.
+
+ Since the underlying oslMutex is not a reference counted object, copy
+ constructed Mutex may work on an already destructed oslMutex object.
+
+ */
+ Mutex(const Mutex&);
+
+ /** The underlying oslMutex has no reference count.
+
+ When destructed, the Mutex object destroys the undelying oslMutex,
+ which might cause severe problems in case it's a temporary object.
+
+ */
+ Mutex(oslMutex Mutex);
+
+ /** This assignment operator is private for the same reason as
+ the copy constructor.
+ */
+ Mutex& operator= (const Mutex&);
+
+ /** This assignment operator is private for the same reason as
+ the constructor taking a oslMutex argument.
+ */
+ Mutex& operator= (oslMutex);
+ };
+
+ /** A helper class for mutex objects and interfaces.
+ */
+ template<class T>
+ class Guard
+ {
+ private:
+ Guard( const Guard& );
+ const Guard& operator = ( const Guard& );
+
+ protected:
+ T * pT;
+ public:
+
+ /** Acquires the object specified as parameter.
+ */
+ Guard(T * pT_) : pT(pT_)
+ {
+ pT->acquire();
+ }
+
+ /** Acquires the object specified as parameter.
+ */
+ Guard(T & t) : pT(&t)
+ {
+ pT->acquire();
+ }
+
+ /** Releases the mutex or interface. */
+ ~Guard()
+ {
+ pT->release();
+ }
+ };
+
+ /** A helper class for mutex objects and interfaces.
+ */
+ template<class T>
+ class ClearableGuard
+ {
+ private:
+ ClearableGuard( const ClearableGuard& );
+ const ClearableGuard& operator = ( const ClearableGuard& );
+ protected:
+ T * pT;
+ public:
+
+ /** Acquires the object specified as parameter.
+ */
+ ClearableGuard(T * pT_) : pT(pT_)
+ {
+ pT->acquire();
+ }
+
+ /** Acquires the object specified as parameter.
+ */
+ ClearableGuard(T & t) : pT(&t)
+ {
+ pT->acquire();
+ }
+
+ /** Releases the mutex or interface if not already released by clear().
+ */
+ ~ClearableGuard()
+ {
+ if (pT)
+ pT->release();
+ }
+
+ /** Releases the mutex or interface.
+ */
+ void clear()
+ {
+ if(pT)
+ {
+ pT->release();
+ pT = NULL;
+ }
+ }
+ };
+
+ /** A helper class for mutex objects and interfaces.
+ */
+ template< class T >
+ class ResettableGuard : public ClearableGuard< T >
+ {
+ private:
+ ResettableGuard(ResettableGuard &); // not defined
+ void operator =(ResettableGuard &); // not defined
+
+ protected:
+ T* pResetT;
+ public:
+ /** Acquires the object specified as parameter.
+ */
+ ResettableGuard( T* pT_ ) :
+ ClearableGuard<T>( pT_ ),
+ pResetT( pT_ )
+ {}
+
+ /** Acquires the object specified as parameter.
+ */
+ ResettableGuard( T& rT ) :
+ ClearableGuard<T>( rT ),
+ pResetT( &rT )
+ {}
+
+ /** Re-aquires the mutex or interface.
+ */
+ void reset()
+ {
+ if( pResetT )
+ {
+ this->pT = pResetT;
+ this->pT->acquire();
+ }
+ }
+ };
+
+ typedef Guard<Mutex> MutexGuard;
+ typedef ClearableGuard<Mutex> ClearableMutexGuard;
+ typedef ResettableGuard< Mutex > ResettableMutexGuard;
+}
+
+#endif /* __cplusplus */
+#endif /* _OSL_MUTEX_HXX_ */
+
diff --git a/sal/inc/osl/nlsupport.h b/sal/inc/osl/nlsupport.h
new file mode 100644
index 000000000000..7ded09293442
--- /dev/null
+++ b/sal/inc/osl/nlsupport.h
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _OSL_NLSUPPORT_H_
+#define _OSL_NLSUPPORT_H_
+
+# include <rtl/locale.h>
+# include <rtl/textenc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ Determines the text encoding used by the underlying platform for the
+ specified locale.
+
+ @param pLocale
+ the locale to return the text encoding for. If this parameter is NULL,
+ the default locale of the current process is used.
+
+ @returns the rtl_TextEncoding that matches the platform specific encoding
+ description or RTL_TEXTENCODING_DONTKNOW if no mapping is available.
+*/
+
+rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_NLSUPPORT_H_ */
+
+
diff --git a/sal/inc/osl/pipe.h b/sal/inc/osl/pipe.h
new file mode 100644
index 000000000000..aec479777cdb
--- /dev/null
+++ b/sal/inc/osl/pipe.h
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _OSL_PIPE_H_
+#define _OSL_PIPE_H_
+
+# include <rtl/ustring.h>
+
+
+# include <osl/security.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ osl_Pipe_E_None, /* no error */
+ osl_Pipe_E_NotFound, /* Pipe could not be found */
+ osl_Pipe_E_AlreadyExists, /* Pipe already exists */
+ osl_Pipe_E_NoProtocol, /* Protocol not available */
+ osl_Pipe_E_NetworkReset, /* Network dropped connection because of reset */
+ osl_Pipe_E_ConnectionAbort, /* Software caused connection abort */
+ osl_Pipe_E_ConnectionReset, /* Connection reset by peer */
+ osl_Pipe_E_NoBufferSpace, /* No buffer space available */
+ osl_Pipe_E_TimedOut, /* Connection timed out */
+ osl_Pipe_E_ConnectionRefused, /* Connection refused */
+ osl_Pipe_E_invalidError, /* unmapped error: always last entry in enum! */
+ osl_Pipe_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslPipeError;
+
+typedef sal_uInt32 oslPipeOptions;
+#define osl_Pipe_OPEN 0x0000 /* open existing pipe */
+#define osl_Pipe_CREATE 0x0001 /* create pipe and open it, fails if already existst */
+
+typedef struct oslPipeImpl * oslPipe;
+
+/**
+ */
+oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security);
+
+/** decreases the refcount of the pipe.
+ If the refcount drops to zero, the handle is destroyed.
+ */
+void SAL_CALL osl_releasePipe( oslPipe );
+
+/** increases the refcount of the pipe.
+ */
+void SAL_CALL osl_acquirePipe( oslPipe Pipe );
+
+/** closes the pipe, any read,write or accept actions stop immeadiatly.
+ */
+void SAL_CALL osl_closePipe( oslPipe );
+
+
+oslPipe SAL_CALL osl_acceptPipe(oslPipe Pipe);
+
+sal_Int32 SAL_CALL osl_sendPipe(oslPipe Pipe, const void* pBuffer, sal_Int32 BufferSize);
+sal_Int32 SAL_CALL osl_receivePipe(oslPipe Pipe, void* pBuffer, sal_Int32 BufferSize);
+
+/** Reads blocking from the pipe.
+ @return Number of read bytes. If less than BufferSize, the pipe was closed.
+ */
+sal_Int32 SAL_CALL osl_readPipe( oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize );
+
+/** Writes blocking onto the pipe.
+ @return Number of written bytes. If less than BufferSize, the pipe was closed.
+ */
+sal_Int32 SAL_CALL osl_writePipe( oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize );
+
+oslPipeError SAL_CALL osl_getLastPipeError(oslPipe Pipe);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_PIPE_H_ */
+
diff --git a/sal/inc/osl/pipe.hxx b/sal/inc/osl/pipe.hxx
new file mode 100644
index 000000000000..7ad85d86bcfc
--- /dev/null
+++ b/sal/inc/osl/pipe.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _OSL_PIPE_HXX_
+#define _OSL_PIPE_HXX_
+
+#include <osl/pipe_decl.hxx>
+
+namespace osl
+{
+ //______________________________________________________________________________
+ inline Pipe::Pipe()
+ : m_handle( 0 )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
+ : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
+ : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(const Pipe& pipe )
+ : m_handle( pipe.m_handle )
+ {
+ if( m_handle )
+ osl_acquirePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
+ : m_handle ( pipe )
+ {}
+
+ //______________________________________________________________________________
+ inline Pipe::Pipe(oslPipe pipe)
+ : m_handle( pipe )
+ {
+ if( m_handle )
+ osl_acquirePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Pipe::~Pipe()
+ {
+ if( m_handle )
+ osl_releasePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
+ oslPipeOptions Options, const Security &rSec )
+ {
+ *this = Pipe( strName, Options, rSec );
+ return is();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
+ {
+ *this = Pipe( strName, Options );
+ return is();
+ }
+ //______________________________________________________________________________
+ inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
+ {
+ *this = pipe.getHandle();
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
+ {
+ if( pipe )
+ osl_acquirePipe( pipe );
+ if( m_handle )
+ osl_releasePipe( m_handle );
+ m_handle = pipe;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL Pipe::is() const
+ {
+ return m_handle != 0;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
+ {
+ return m_handle == rPipe.m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline void SAL_CALL Pipe::close()
+ {
+ osl_closePipe( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline void SAL_CALL Pipe::clear()
+ {
+ if( m_handle )
+ {
+ osl_releasePipe( m_handle );
+ m_handle = 0;
+ }
+ }
+
+ //______________________________________________________________________________
+ inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
+ {
+ Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE);
+ if( Connection.is() )
+ return osl_Pipe_E_None;
+ else
+ return getError();
+ }
+
+ //______________________________________________________________________________
+ inline oslPipeError SAL_CALL Pipe::getError() const
+ {
+ return osl_getLastPipeError( 0 );
+ }
+
+ //______________________________________________________________________________
+ inline oslPipe SAL_CALL Pipe::getHandle() const
+ {
+ return m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(){}
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(oslPipe hPipe)
+ : Pipe( hPipe )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
+ : Pipe( strName, Options , rSec )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
+ : Pipe( strName, Options )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
+ : Pipe( aPipe )
+ {}
+ //______________________________________________________________________________
+ inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire )
+ : Pipe( pipe , noacquire )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
+ {
+ return osl_readPipe( m_handle, pBuffer, n );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
+ {
+ return osl_writePipe( m_handle, pBuffer , n );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
+ {
+ return osl_receivePipe( m_handle, pBuffer , BytesToRead );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
+ {
+ return osl_sendPipe( m_handle, pBuffer , BytesToSend );
+ }
+
+}
+#endif
diff --git a/sal/inc/osl/pipe_decl.hxx b/sal/inc/osl/pipe_decl.hxx
new file mode 100644
index 000000000000..65756ddd2f6b
--- /dev/null
+++ b/sal/inc/osl/pipe_decl.hxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _OSL_PIPE_DECL_HXX_
+#define _OSL_PIPE_DECL_HXX_
+
+#include <osl/pipe.h>
+# include <osl/security.hxx>
+#include <rtl/ustring.hxx>
+
+namespace osl {
+
+class StreamPipe;
+
+/** Represents a pipe.
+*/
+class Pipe
+{
+protected:
+ oslPipe m_handle;
+
+public:
+
+ /** Does not create a pipe. Use assignment operator to
+ make this a useable pipe.
+ */
+ inline Pipe();
+
+ /** Creates an insecure pipe that is accessible for all users.
+ @param strName
+ @param Options
+ */
+ inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options);
+
+ /** Creates a secure pipe that access depends on the umask settings.
+ @param strName
+ @param Options
+ @param Security
+ */
+ inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity);
+
+ /** Copy constructor.
+ */
+ inline Pipe(const Pipe& pipe);
+
+ /** Constructs a Pipe reference without acquiring the handle
+ */
+ inline Pipe( oslPipe pipe, __sal_NoAcquire noacquire );
+
+ /** Creates pipe as wrapper around the underlying oslPipe.
+ @param Pipe
+ */
+ inline Pipe(oslPipe Pipe);
+
+ /** Destructor. Destroys the underlying oslPipe.
+ */
+ inline ~Pipe();
+
+ inline sal_Bool SAL_CALL is() const;
+
+ /** Creates an insecure pipe that is accessible for all users
+ with the given attributes.
+ If the pipe was already created, the old one will be discarded.
+ @param strName
+ @param Options
+ @param Security
+ @return True if socket was successfully created.
+ */
+ inline sal_Bool create( const ::rtl::OUString & strName,
+ oslPipeOptions Options, const Security &rSec );
+
+ /** Creates a secure that access rights depend on the umask settings
+ with the given attributes.
+
+ If socket was already created, the old one will be discarded.
+ @param strName
+ @param Options
+ @return True if socket was successfully created.
+ */
+ inline sal_Bool create( const ::rtl::OUString & strName, oslPipeOptions Options = osl_Pipe_OPEN );
+
+ /** releases the underlying handle
+ */
+ inline void SAL_CALL clear();
+
+ /** Assignment operator. If pipe was already created, the old one will
+ be discarded.
+ */
+ inline Pipe& SAL_CALL operator= (const Pipe& pipe);
+
+ /** Assignment operator. If pipe was already created, the old one will
+ be discarded.
+ */
+ inline Pipe& SAL_CALL operator= (const oslPipe pipe );
+
+ /** Checks if the pipe is valid.
+ @return True if the object represents a valid pipe.
+ */
+ inline sal_Bool SAL_CALL isValid() const;
+
+ inline sal_Bool SAL_CALL operator==( const Pipe& rPipe ) const;
+
+ /** Closes the pipe.
+ */
+ inline void SAL_CALL close();
+
+ /** Accept connection on an existing pipe
+ */
+ inline oslPipeError SAL_CALL accept(StreamPipe& Connection);
+
+
+ /** Delivers a constant decribing the last error for the pipe system.
+ @return ENONE if no error occured, invalid_PipeError if
+ an unknown (unmapped) error occured, otherwise an enum describing the
+ error.
+ */
+ inline oslPipeError SAL_CALL getError() const;
+
+ inline oslPipe SAL_CALL getHandle() const;
+};
+
+/** A pipe to send or receive a stream of data.
+*/
+class StreamPipe : public Pipe
+{
+public:
+
+ /** Creates an unattached pipe. You must attach the pipe to an oslPipe
+ e.g. by using the operator=(oslPipe), before you can use the stream-
+ functionality of the object.
+ */
+ inline StreamPipe();
+
+ /** Creates pipe as wrapper around the underlying oslPipe.
+ @param Pipe
+ */
+ inline StreamPipe(oslPipe Pipe);
+
+ /** Copy constructor.
+ @param Pipe
+ */
+ inline StreamPipe(const StreamPipe& Pipe);
+
+ /** Creates a pipe.
+ @param strName
+ @param Options
+ */
+ inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options = osl_Pipe_OPEN);
+
+ /** Creates a pipe.
+ @param strName
+ @param Options
+ @param rSec
+ */
+ inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec );
+
+ /** Constructs a Pipe reference without acquiring the handle
+ */
+ inline StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire );
+
+ /** Attaches the oslPipe to this object. If the object
+ already was attached to an oslPipe, the old one will
+ be closed and destroyed.
+ @param Pipe.
+ */
+ inline StreamPipe & SAL_CALL operator=(oslPipe Pipe);
+
+ /** Assignment operator
+ */
+ inline StreamPipe& SAL_CALL operator=(const Pipe& pipe);
+
+ /** Tries to receives BytesToRead data from the connected pipe,
+
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ data.
+ @param BytesToRead [in] The number of bytes to read. pBuffer must have at least
+ this size.
+ @return the number of received bytes.
+ */
+ inline sal_Int32 SAL_CALL recv(void* pBuffer, sal_Int32 BytesToRead) const;
+
+ /** Tries to sends BytesToSend data from the connected pipe.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @return the number of transfered bytes.
+ */
+ inline sal_Int32 SAL_CALL send(const void* pBuffer, sal_Int32 BytesToSend) const;
+
+ /** Retrieves n bytes from the stream and copies them into pBuffer.
+ The method avoids incomplete reads due to packet boundaries.
+ @param pBuffer receives the read data.
+ @param n the number of bytes to read. pBuffer must be large enough
+ to hold the n bytes!
+ @return the number of read bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ inline sal_Int32 SAL_CALL read(void* pBuffer, sal_Int32 n) const;
+
+ /** Writes n bytes from pBuffer to the stream. The method avoids
+ incomplete writes due to packet boundaries.
+ @param pBuffer contains the data to be written.
+ @param n the number of bytes to write.
+ @return the number of written bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ sal_Int32 SAL_CALL write(const void* pBuffer, sal_Int32 n) const;
+};
+
+}
+#endif
diff --git a/sal/inc/osl/process.h b/sal/inc/osl/process.h
new file mode 100644
index 000000000000..73892bccebe0
--- /dev/null
+++ b/sal/inc/osl/process.h
@@ -0,0 +1,428 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _OSL_PROCESS_H_
+#define _OSL_PROCESS_H_
+
+#include <rtl/ustring.h>
+#include <rtl/textenc.h>
+#include <rtl/locale.h>
+
+#include <osl/time.h>
+#include <osl/file.h>
+#include <osl/pipe.h>
+#include <osl/socket.h>
+#include <osl/security.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef sal_Int32 oslProcessOption;
+#define osl_Process_WAIT 0x0001 /* wait for completion */
+#define osl_Process_SEARCHPATH 0x0002 /* search path for executable */
+#define osl_Process_DETACHED 0x0004 /* run detached */
+#define osl_Process_NORMAL 0x0000 /* run in normal window */
+#define osl_Process_HIDDEN 0x0010 /* run hidden */
+#define osl_Process_MINIMIZED 0x0020 /* run in minimized window */
+#define osl_Process_MAXIMIZED 0x0040 /* run in maximized window */
+#define osl_Process_FULLSCREEN 0x0080 /* run in fullscreen window */
+
+typedef sal_Int32 oslProcessData;
+
+/* defines for osl_getProcessInfo , can be OR'ed */
+#define osl_Process_IDENTIFIER 0x0001 /* retrieves the process identifier */
+#define osl_Process_EXITCODE 0x0002 /* retrieves exit code of the process */
+#define osl_Process_CPUTIMES 0x0004 /* retrieves used cpu time */
+#define osl_Process_HEAPUSAGE 0x0008 /* retrieves the used size of heap */
+
+typedef sal_uInt32 oslProcessIdentifier;
+typedef sal_uInt32 oslProcessExitCode;
+
+typedef enum {
+ osl_Process_E_None, /* no error */
+ osl_Process_E_NotFound, /* image not found */
+ osl_Process_E_TimedOut, /* timout occured */
+ osl_Process_E_NoPermission, /* permission denied */
+ osl_Process_E_Unknown, /* unknown error */
+ osl_Process_E_InvalidError, /* unmapped error */
+ osl_Process_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslProcessError;
+
+typedef enum {
+ osl_Process_TypeNone, /* no descriptor */
+ osl_Process_TypeSocket, /* socket */
+ osl_Process_TypeFile, /* file */
+ osl_Process_TypePipe, /* pipe */
+ osl_Process_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslDescriptorType;
+
+typedef sal_Int32 oslDescriptorFlag;
+#define osl_Process_DFNONE 0x0000
+#define osl_Process_DFWAIT 0x0001
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(push, 4)
+#endif
+
+typedef struct {
+ sal_uInt32 Size;
+ oslProcessData Fields;
+ oslProcessIdentifier Ident;
+ oslProcessExitCode Code;
+ TimeValue UserTime;
+ TimeValue SystemTime;
+ sal_uInt32 HeapUsage;
+} oslProcessInfo;
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+# pragma pack(pop)
+#endif
+
+/** Process handle
+
+ @see osl_executeProcess
+ @see osl_terminateProcess
+ @see osl_freeProcessHandle
+ @see osl_getProcessInfo
+ @see osl_joinProcess
+*/
+typedef void* oslProcess;
+
+/** Execute a process.
+
+ Executes the program image provided in strImageName in a new process.
+
+ @param ustrImageName
+ [in] The file URL of the executable to be started.
+ Can be NULL in this case the file URL of the executable must be the first element
+ in ustrArguments.
+
+ @param ustrArguments
+ [in] An array of argument strings. Can be NULL if strImageName is not NULL.
+ If strImageName is NULL it is expected that the first element contains
+ the file URL of the executable to start.
+
+ @param nArguments
+ [in] The number of arguments provided. If this number is 0 strArguments will be ignored.
+
+ @param Options
+ [in] A combination of int-constants to describe the mode of execution.
+
+ @param Security
+ [in] The user and his rights for which the process is started. May be NULL in which case
+ the process will be started in the context of the current user.
+
+ @param ustrDirectory
+ [in] The file URL of the working directory of the new proces. If the specified directory
+ does not exist or is inaccessible the working directory of the newly created process
+ is undefined. If this parameter is NULL or the caller provides an empty string the
+ new process will have the same current working directory as the calling process.
+
+ @param ustrEnviroments
+ [in] An array of strings describing environment variables that should be merged into the
+ environment of the new process. Each string has to be in the form "variable=value".
+ This parameter can be NULL in which case the new process gets the same environment
+ as the parent process.
+
+ @param nEnvironmentVars
+ [in] The number of environment variables to set.
+
+ @param pProcess
+ [out] Pointer to a oslProcess variable, wich receives the handle of the newly created process.
+ This parameter must not be NULL.
+
+ @return
+ <dl>
+ <dt>osl_Process_E_None</dt>
+ <dd>on success</dd>
+ <dt>osl_Process_E_NotFound</dt>
+ <dd>if the specified executable could not be found</dd>
+ <dt>osl_Process_E_InvalidError</dt>
+ <dd>if invalid parameters will be detected</dd>
+ <dt>osl_Process_E_Unknown</dt>
+ <dd>if arbitrary other errors occur</dd>
+ </dl>
+
+ @see oslProcessOption
+ @see osl_executeProcess_WithRedirectedIO
+ @see osl_freeProcessHandle
+ @see osl_loginUser
+*/
+oslProcessError SAL_CALL osl_executeProcess(
+ rtl_uString* ustrImageName,
+ rtl_uString* ustrArguments[],
+ sal_uInt32 nArguments,
+ oslProcessOption Options,
+ oslSecurity Security,
+ rtl_uString* ustrDirectory,
+ rtl_uString* ustrEnvironments[],
+ sal_uInt32 nEnvironmentVars,
+ oslProcess* pProcess);
+
+
+/** Execute a process and redirect child process standard IO.
+
+ @param ustrImageName
+ [in] The file URL of the executable to be started.
+ Can be NULL in this case the file URL of the executable must be the first element
+ in ustrArguments.
+
+ @param ustrArguments
+ [in] An array of argument strings. Can be NULL if strImageName is not NULL.
+ If strImageName is NULL it is expected that the first element contains
+ the file URL of the executable to start.
+
+ @param nArguments
+ [in] The number of arguments provided. If this number is 0 strArguments will be ignored.
+
+ @param Options
+ [in] A combination of int-constants to describe the mode of execution.
+
+ @param Security
+ [in] The user and his rights for which the process is started. May be NULL in which case
+ the process will be started in the context of the current user.
+
+ @param ustrDirectory
+ [in] The file URL of the working directory of the new proces. If the specified directory
+ does not exist or is inaccessible the working directory of the newly created process
+ is undefined. If this parameter is NULL or the caller provides an empty string the
+ new process will have the same current working directory as the calling process.
+
+ @param ustrEnviroments
+ [in] An array of strings describing environment variables that should be merged into the
+ environment of the new process. Each string has to be in the form "variable=value".
+ This parameter can be NULL in which case the new process gets the same environment
+ as the parent process.
+
+ @param nEnvironmentVars
+ [in] The number of environment variables to set.
+
+ @param pProcess
+ [out] Pointer to a oslProcess variable, wich receives the handle of the newly created process.
+ This parameter must not be NULL.
+
+ @param pChildInputWrite
+ [in] Pointer to a oslFileHandle variable that receives the handle which can be used to write
+ to the child process standard input device. The returned handle is not random accessible.
+ The handle has to be closed with osl_closeFile if no longer used. This parameter can be NULL.
+
+ @param pChildOutputRead
+ [in] Pointer to a oslFileHandle variable that receives the handle which can be used to read from
+ the child process standard output device. The returned handle is not random accessible.
+ The Handle has to be closed with osl_closeFile if no longer used. This parameter can be NULL.
+
+ @param pChildErrorRead
+ [in] Pointer to a oslFileHandle variable that receives the handle which can be used to read from
+ the child process standard error device. The returned handle is not random accessible.
+ The Handle has to be closed with osl_closeFile if no longer used. This parameter can be NULL.
+
+ @return
+ <dl>
+ <dt>osl_Process_E_None</dt>
+ <dd>on success</dd>
+ <dt>osl_Process_E_NotFound</dt>
+ <dd>if the specified executable could not be found</dd>
+ <dt>osl_Process_E_InvalidError</dt>
+ <dd>if invalid parameters will be detected</dd>
+ <dt>osl_Process_E_Unknown</dt>
+ <dd>if arbitrary other errors occur</dd>
+ </dl>
+
+ @see oslProcessOption
+ @see osl_executeProcess
+ @see osl_freeProcessHandle
+ @see osl_loginUser
+ @see osl_closeFile
+*/
+oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
+ rtl_uString* strImageName,
+ rtl_uString* ustrArguments[],
+ sal_uInt32 nArguments,
+ oslProcessOption Options,
+ oslSecurity Security,
+ rtl_uString* ustrDirectory,
+ rtl_uString* ustrEnvironments[],
+ sal_uInt32 nEnvironmentVars,
+ oslProcess* pProcess,
+ oslFileHandle* pChildInputWrite,
+ oslFileHandle* pChildOutputRead,
+ oslFileHandle* pChildErrorRead);
+
+/** Terminate a process
+ @param Process [in] the handle of the process to be terminated
+
+ @see osl_executeProcess
+ @see osl_getProcess
+ @see osl_joinProcess
+ */
+oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process);
+
+
+/** @deprecated
+ Retrieve the process handle of a process identifier
+ @param Ident [in] a process identifier
+
+ @return the process handle on success, NULL in all other cases
+ */
+oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident);
+
+
+/** Free the specified proces-handle.
+ @param Process [in]
+*/
+void SAL_CALL osl_freeProcessHandle(oslProcess Process);
+
+
+/** Wait for completation of the specified childprocess.
+ @param Process [in]
+ @return ols_Process_E_None
+ @see osl_executeProcess
+*/
+oslProcessError SAL_CALL osl_joinProcess(oslProcess Process);
+
+/** Wait with a timeout for the completion of the specified child
+ process.
+
+ @param Process [in]
+ A process identifier.
+
+ @param pTimeout [in]
+ A timeout value or NULL for infinite waiting.
+ The unit of resolution is second.
+
+ @return
+ osl_Process_E_None on success
+ osl_Process_E_TimedOut waiting for the child process timed out
+ osl_Process_E_Unknown an error occured or the parameter are invalid
+
+ @see osl_executeProcess
+*/
+oslProcessError SAL_CALL osl_joinProcessWithTimeout(oslProcess Process, const TimeValue* pTimeout);
+
+/** Retrieves information about a Process
+ @param Process [in] the process handle of the process
+ @param Field [in] the information which is to be retrieved
+ this can be one or more of
+ osl_Process_IDENTIFIER
+ osl_Process_EXITCODE
+ osl_Process_CPUTIMES
+ osl_Process_HEAPUSAGE
+ @param pInfo [out] a pointer to a vaid oslProcessInfo structure.
+ the Size field has to be initialized with the size
+ of the oslProcessInfo structure.
+ on success the the Field member holds the (or'ed)
+ retrieved valid information fields.
+ @return osl_Process_E_None on success, osl_Process_E_Unknown on failure.
+ */
+oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData Fields,
+ oslProcessInfo* pInfo);
+
+/** Get the filename of the executable.
+ @param strFile [out] the string that receives the executable file path.
+ @return osl_Process_E_None or does not return.
+ @see osl_executeProcess
+*/
+oslProcessError SAL_CALL osl_getExecutableFile(rtl_uString **strFile);
+
+/** @return the number of commandline arguments passed to the main-function of
+ this process
+ @see osl_getCommandArg
+*/
+sal_uInt32 SAL_CALL osl_getCommandArgCount(void);
+
+/** Get the nArg-th command-line argument passed to the main-function of this process.
+ @param nArg [in] The number of the argument to return.
+ @param strCommandArg [out] The string receives the nArg-th command-line argument.
+ @return osl_Process_E_None or does not return.
+ @see osl_executeProcess
+*/
+oslProcessError SAL_CALL osl_getCommandArg(sal_uInt32 nArg, rtl_uString **strCommandArg);
+
+/** Set the command-line arguments as passed to the main-function of this process.
+
+ Depricated: This function is only for internal use. Passing the args from main will
+ only work for Unix, on Windows there's no effect, the full command line will automtically
+ be taken. This is due to Windows 9x/ME limitation that don't allow UTF-16 wmain to provide
+ a osl_setCommandArgsU( int argc, sal_Unicode **argv );
+
+ @param argc [in] The number of elements in the argv array.
+ @param argv [in] The array of command-line arguments.
+ @see osl_getExecutableFile
+ @see osl_getCommandArgCount
+ @see osl_getCommandArg
+*/
+void SAL_CALL osl_setCommandArgs (int argc, char **argv);
+
+/** Get the value of one enviroment variable.
+ @param strVar [in] denotes the name of the variable to get.
+ @param strValue [out] string that receives the value of environment variable.
+*/
+oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *strVar, rtl_uString **strValue);
+
+/** Get the working directory of the current process as a file URL.
+
+ The file URL is encoded as common for the OSL file API.
+ @param pustrWorkingDir [out] string that receives the working directory file URL.
+*/
+
+oslProcessError SAL_CALL osl_getProcessWorkingDir( rtl_uString **pustrWorkingDir );
+
+/** Get the locale the process is currently running in.
+
+ The unix implementation caches the value it returns, so if you have to change the locale
+ your are running in, you will have to use osl_setProcessLocale therefor.
+
+ @param ppLocale [out] a pointer that receives the currently selected locale structure
+ @see osl_setProcessLocale
+*/
+
+oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale );
+
+/** Change the locale of the process.
+
+ @param pLocale [in] a pointer to the locale to be set
+ @see osl_getProcessLocale
+*/
+
+oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * pLocale );
+
+
+sal_Bool SAL_CALL osl_sendResourcePipe(oslPipe Pipe, oslSocket Socket);
+
+oslSocket SAL_CALL osl_receiveResourcePipe(oslPipe Pipe);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_PROCESS_H_ */
+
diff --git a/sal/inc/osl/profile.h b/sal/inc/osl/profile.h
new file mode 100644
index 000000000000..d4d7299aebff
--- /dev/null
+++ b/sal/inc/osl/profile.h
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_PROFILE_H_
+#define _OSL_PROFILE_H_
+
+#include <sal/types.h>
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef sal_uInt32 oslProfileOption;
+
+#define osl_Profile_DEFAULT 0x0000
+#define osl_Profile_SYSTEM 0x0001 /* use system depended functinality */
+#define osl_Profile_READLOCK 0x0002 /* lock file for reading */
+#define osl_Profile_WRITELOCK 0x0004 /* lock file for writing */
+#define osl_Profile_FLUSHWRITE 0x0010 /* writing only with flush */
+
+
+typedef void* oslProfile;
+
+/** Deprecated API.
+ Open or create a configuration profile.
+ @return 0 if the profile could not be created, otherwise a handle to the profile.
+ @deprecated
+*/
+oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, oslProfileOption Options);
+
+/** Deprecated API.
+ Close the opened profile an flush all data to the disk.
+ @param Profile handle to a opened profile.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile);
+
+
+/** Deprecated API.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile);
+/** Deprecated API.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_Char* pszString, sal_uInt32 MaxLen,
+ const sal_Char* pszDefault);
+/** Deprecated API.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_readProfileBool(oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_Bool Default);
+/** Deprecated API.
+ @deprecated
+*/
+sal_uInt32 SAL_CALL osl_readProfileIdent(oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_uInt32 FirstId, const sal_Char* Strings[],
+ sal_uInt32 Default);
+
+/** Deprecated API.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ const sal_Char* pszString);
+/** Deprecated API.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_writeProfileBool(oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_Bool Value);
+/** Deprecated API.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_writeProfileIdent(oslProfile Profile,
+ const sal_Char* pszSection, const sal_Char* pszEntry,
+ sal_uInt32 FirstId, const sal_Char* Strings[],
+ sal_uInt32 Value);
+
+/** Deprecated API.
+ Acquire the mutex, block if already acquired by another thread.
+ @param Profile handle to a opened profile.
+ @return False if section or entry could not be found.
+ @deprecated
+*/
+sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
+ const sal_Char *pszSection, const sal_Char *pszEntry);
+
+/** Deprecated API.
+ Get all entries belonging to the specified section.
+ @param Profile handle to a opened profile.
+ @return Pointer to a array of pointers.
+ @deprecated
+*/
+sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_Char *pszSection,
+ sal_Char* pszBuffer, sal_uInt32 MaxLen);
+
+/** Deprecated API.
+ Get all section entries
+ @param Profile handle to a opened profile.
+ @return Pointer to a array of pointers.
+ @deprecated
+*/
+sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuffer, sal_uInt32 MaxLen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_PROFILE_H_ */
+
diff --git a/sal/inc/osl/profile.hxx b/sal/inc/osl/profile.hxx
new file mode 100644
index 000000000000..a1fc0499172d
--- /dev/null
+++ b/sal/inc/osl/profile.hxx
@@ -0,0 +1,204 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_PROFILE_HXX_
+#define _OSL_PROFILE_HXX_
+
+#include "profile.h"
+#include <rtl/ustring.hxx>
+#include <string.h>
+#include <list>
+
+namespace osl {
+
+ typedef oslProfileOption ProfileOption;
+
+ const int Profile_DEFAULT = osl_Profile_DEFAULT;
+ const int Profile_SYSTEM = osl_Profile_SYSTEM; /* use system depended functinality */
+ const int Profile_READLOCK = osl_Profile_READLOCK; /* lock file for reading */
+ const int Profile_WRITELOCK = osl_Profile_WRITELOCK; /* lock file for writing */
+
+ /** Deprecated API.
+ @deprecated
+ */
+ class Profile {
+ oslProfile profile;
+
+ public:
+ /** Open or create a configuration profile.
+ @return 0 if the profile could not be created, otherwise a handle to the profile.
+ */
+ Profile(const rtl::OUString strProfileName, oslProfileOption Options = Profile_DEFAULT )
+ {
+ profile = osl_openProfile(strProfileName.pData, Options);
+ if( ! profile )
+ throw std::exception();
+ }
+
+
+ /** Close the opened profile an flush all data to the disk.
+ @param Profile handle to a opened profile.
+ */
+ ~Profile()
+ {
+ osl_closeProfile(profile);
+ }
+
+
+ sal_Bool flush()
+ {
+ return osl_flushProfile(profile);
+ }
+
+ rtl::OString readString( const rtl::OString& rSection, const rtl::OString& rEntry,
+ const rtl::OString& rDefault)
+ {
+ sal_Char aBuf[1024];
+ return osl_readProfileString( profile,
+ rSection,
+ rEntry,
+ aBuf,
+ sizeof( aBuf ),
+ rDefault ) ? rtl::OString( aBuf ) : rtl::OString();
+
+ }
+
+ sal_Bool readBool( const rtl::OString& rSection, const rtl::OString& rEntry, sal_Bool bDefault )
+ {
+ return osl_readProfileBool( profile, rSection, rEntry, bDefault );
+ }
+
+ sal_uInt32 readIdent(const rtl::OString& rSection, const rtl::OString& rEntry,
+ sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings,
+ sal_uInt32 nDefault)
+ {
+ int nItems = rStrings.size();
+ const sal_Char** pStrings = new const sal_Char*[ nItems+1 ];
+ std::list< rtl::OString >::const_iterator it = rStrings.begin();
+ nItems = 0;
+ while( it != rStrings.end() )
+ {
+ pStrings[ nItems++ ] = *it;
+ ++it;
+ }
+ pStrings[ nItems ] = NULL;
+ sal_uInt32 nRet = osl_readProfileIdent(profile, rSection, rEntry, nFirstId, pStrings, nDefault);
+ delete pStrings;
+ return nRet;
+ }
+
+ sal_Bool writeString(const rtl::OString& rSection, const rtl::OString& rEntry,
+ const rtl::OString& rString)
+ {
+ return osl_writeProfileString(profile, rSection, rEntry, rString);
+ }
+
+ sal_Bool writeBool(const rtl::OString& rSection, const rtl::OString& rEntry, sal_Bool Value)
+ {
+ return osl_writeProfileBool(profile, rSection, rEntry, Value);
+ }
+
+ sal_Bool writeIdent(const rtl::OString& rSection, const rtl::OString& rEntry,
+ sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings,
+ sal_uInt32 nValue)
+ {
+ int nItems = rStrings.size();
+ const sal_Char** pStrings = new const sal_Char*[ nItems+1 ];
+ std::list< rtl::OString >::const_iterator it = rStrings.begin();
+ nItems = 0;
+ while( it != rStrings.end() )
+ {
+ pStrings[ nItems++ ] = *it;
+ ++it;
+ }
+ pStrings[ nItems ] = NULL;
+ sal_Bool bRet =
+ osl_writeProfileIdent(profile, rSection, rEntry, nFirstId, pStrings, nValue );
+ delete pStrings;
+ return bRet;
+ }
+
+ /** Acquire the mutex, block if already acquired by another thread.
+ @param Profile handle to a opened profile.
+ @return False if section or entry could not be found.
+ */
+ sal_Bool removeEntry(const rtl::OString& rSection, const rtl::OString& rEntry)
+ {
+ return osl_removeProfileEntry(profile, rSection, rEntry);
+ }
+
+ /** Get all entries belonging to the specified section.
+ @param Profile handle to a opened profile.
+ @return Pointer to a array of pointers.
+ */
+ std::list< rtl::OString > getSectionEntries(const rtl::OString& rSection )
+ {
+ std::list< rtl::OString > aEntries;
+
+ // count buffer size necessary
+ int n = osl_getProfileSectionEntries( profile, rSection, NULL, 0 );
+ if( n > 1 )
+ {
+ sal_Char* pBuf = new sal_Char[ n+1 ];
+ osl_getProfileSectionEntries( profile, rSection, pBuf, n+1 );
+ int nLen;
+ for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 )
+ aEntries.push_back( rtl::OString( pBuf+n ) );
+ delete pBuf;
+ }
+
+ return aEntries;
+ }
+
+ /** Get all section entries
+ @param Profile handle to a opened profile.
+ @return Pointer to a array of pointers.
+ */
+ std::list< rtl::OString > getSections()
+ {
+ std::list< rtl::OString > aSections;
+
+ // count buffer size necessary
+ int n = osl_getProfileSections( profile, NULL, 0 );
+ if( n > 1 )
+ {
+ sal_Char* pBuf = new sal_Char[ n+1 ];
+ osl_getProfileSections( profile, pBuf, n+1 );
+ int nLen;
+ for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 )
+ aSections.push_back( rtl::OString( pBuf+n ) );
+ delete pBuf;
+ }
+
+ return aSections;
+ }
+ };
+}
+
+#endif /* _OSL_PROFILE_HXX_ */
+
+
diff --git a/sal/inc/osl/security.h b/sal/inc/osl/security.h
new file mode 100644
index 000000000000..9a6233a61702
--- /dev/null
+++ b/sal/inc/osl/security.h
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SECURITY_H_
+#define _OSL_SECURITY_H_
+
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ osl_Security_E_None,
+ osl_Security_E_UserUnknown,
+ osl_Security_E_WrongPassword,
+ osl_Security_E_Unknown,
+ osl_Security_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSecurityError;
+
+/** Process handle
+ @see osl_loginUser
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+*/
+typedef void* oslSecurity;
+
+/** Create a security handle for the current user.
+ @return a security handle or NULL on failure.
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+ @see osl_executeApplication
+*/
+oslSecurity SAL_CALL osl_getCurrentSecurity(void);
+
+/** Create a security handle for the denoted user.
+ Try to log in the user on the local system.
+ @param strzUserName [in] denotes the name of the user to logg in.
+ @param strPasswd [in] the password for this user.
+ @param pSecurity [out] returns the security handle if user could be logged in.
+ @return osl_Security_E_None if user could be logged in, otherwise an error-code.
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+ @see osl_executeApplication
+*/
+oslSecurityError SAL_CALL osl_loginUser(
+ rtl_uString *strUserName,
+ rtl_uString *strPasswd,
+ oslSecurity *pSecurity
+ );
+
+/** Create a security handle for the denoted user.
+ Try to log in the user on the denoted file server. On success the homedir will be
+ the maped drive on this server.
+ @param strUserName [in] denotes the name of the user to logg in.
+ @param strPasswd [in] the password for this user.
+ @param strFileServer [in] denotes the file server on wich the user is logged in.
+ @param pSecurity [out] returns the security handle if user could be logged in.
+ @return osl_Security_E_None if user could be logged in, otherwise an error-code.
+ @see osl_freeSecurityHandle
+ @see osl_executeProcess
+ @see osl_executeApplication
+*/
+oslSecurityError SAL_CALL osl_loginUserOnFileServer(
+ rtl_uString *strUserName,
+ rtl_uString *strPasswd,
+ rtl_uString *strFileServer,
+ oslSecurity *pSecurity
+ );
+
+/** Query if the user who is denotes by this security has administrator rigths.
+ @param Security [in] the security handle for th user.
+ @return True, if the user has adminsitrator rights, otherwise false.
+*/
+sal_Bool SAL_CALL osl_isAdministrator(oslSecurity Security);
+
+/** Free the security handle, created by osl_loginUser or osl_getCurrentSecurity.
+ @param Security [in] the security handle.
+ @see osl_loginUser
+*/
+void SAL_CALL osl_freeSecurityHandle(oslSecurity Security);
+
+/** Get the login ident for the user of this security handle.
+ @param Security [in] the security handle.
+ @param strIdent [out] the string that receives the ident on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent);
+
+/** Get the login name for the user of this security handle.
+ @param Security [in] the security handle.
+ @param pszName [out] the string that receives the user name on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+sal_Bool SAL_CALL osl_getUserName(oslSecurity Security, rtl_uString **strName);
+
+/** Get the home directory of the user of this security handle.
+ @param Security [in] the security handle.
+ @param strDirectory [out] the string that receives the directory path on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **strDirectory);
+
+/** Get the directory for configuration data of the user of this security handle.
+ @param Security [in] the security handle.
+ @param strDirectory [out] the string that receives the directory path on success.
+ @return True, if the security handle is valid, otherwise False.
+*/
+sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **strDirectory);
+
+
+/** Load Profile of the User
+ Implemented just for Windows
+ @param oslSecurity Security [in] previously fetch Security of the User
+ @return True if the Profile could successfully loaded, False otherwise.
+*/
+
+sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security);
+
+
+/** Unload a User Profile
+ Implemented just for Windows
+ @param oslSecurity Security [in] previously fetch Security of the User
+ @return nothing is returned!
+*/
+
+void SAL_CALL osl_unloadUserProfile(oslSecurity Security);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SECURITY_H_ */
+
diff --git a/sal/inc/osl/security.hxx b/sal/inc/osl/security.hxx
new file mode 100644
index 000000000000..966e3279837d
--- /dev/null
+++ b/sal/inc/osl/security.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SECURITY_HXX_
+#define _OSL_SECURITY_HXX_
+
+#include <rtl/ustring.hxx>
+
+#ifndef _OSL_SECURITY_DECL_HXX
+# include <osl/security_decl.hxx>
+#endif
+
+namespace osl
+{
+
+inline Security::Security()
+{
+ m_handle = osl_getCurrentSecurity();
+}
+
+inline Security::~Security()
+{
+ osl_freeSecurityHandle(m_handle);
+}
+
+inline sal_Bool Security::logonUser(const rtl::OUString& strName,
+ const rtl::OUString& strPasswd)
+{
+ osl_freeSecurityHandle(m_handle);
+
+ m_handle = 0;
+
+ return (osl_loginUser( strName.pData, strPasswd.pData, &m_handle)
+ == osl_Security_E_None);
+}
+
+inline sal_Bool Security::logonUser( const rtl::OUString& strName,
+ const rtl::OUString& strPasswd,
+ const rtl::OUString& strFileServer )
+{
+ osl_freeSecurityHandle(m_handle);
+
+ m_handle = NULL;
+
+ return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_handle)
+ == osl_Security_E_None);
+}
+
+inline sal_Bool Security::getUserIdent( rtl::OUString& strIdent) const
+{
+ return osl_getUserIdent( m_handle, &strIdent.pData );
+}
+
+
+inline sal_Bool Security::getUserName( rtl::OUString& strName ) const
+{
+ return osl_getUserName( m_handle, &strName.pData );
+}
+
+
+inline sal_Bool Security::getHomeDir( rtl::OUString& strDirectory) const
+{
+ return osl_getHomeDir(m_handle, &strDirectory.pData );
+}
+
+
+inline sal_Bool Security::getConfigDir( rtl::OUString& strDirectory ) const
+{
+ return osl_getConfigDir( m_handle, &strDirectory.pData );
+}
+
+inline sal_Bool Security::isAdministrator() const
+{
+ return osl_isAdministrator(m_handle);
+}
+
+inline oslSecurity Security::getHandle() const
+{
+ return m_handle;
+}
+
+
+}
+
+#endif // _OSL_SECURITY_HXX_
+
diff --git a/sal/inc/osl/security_decl.hxx b/sal/inc/osl/security_decl.hxx
new file mode 100644
index 000000000000..753469dff026
--- /dev/null
+++ b/sal/inc/osl/security_decl.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SECURITY_DECL_HXX_
+#define _OSL_SECURITY_DECL_HXX_
+
+#include <rtl/ustring.hxx>
+# include <osl/security.h>
+
+namespace osl
+{
+
+/** capsulate security informations for one user.
+ A object of this class is used to execute a process with the rights an
+ security options of a scecified user.
+ @see Process::executeProcess
+*/
+class Security
+{
+protected:
+ oslSecurity m_handle;
+
+public:
+ /// constructor
+ inline Security();
+ /// destructor
+ inline ~Security();
+ /** get the security information for one user.
+ The underlying operating system is asked for this information.
+ @param strName [in] denotes the name of the user
+ @param strPasswd [in] denotes the password of this user
+ @return True, if the specified user is known by the underlying operating system,
+ otherwise False
+ */
+ inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
+ const ::rtl::OUString& strPasswd);
+ /** get the security information for one user.
+ This method will try to login the user at the denoted file server.
+ If a network resource named \\server\username exists and this resource
+ could be connected by this user, the methos will return true and getHomeDir
+ will return \\server\username.
+ @param strName [in] denotes the name of the user
+ @param strPasswd [in] denotes the password of this user
+ @return True, if the specified user is known by file server and the
+ could be connected, otherwise False
+ */
+ inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString & strName,
+ const ::rtl::OUString & strPasswd,
+ const ::rtl::OUString & strFileServer);
+
+ /** get the ident of the logged in user.
+ @param strName [out] is the buffer which returns the name
+ @param max [in] is the size of this buffer
+ @return True, if any user is successfuly logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getUserIdent( ::rtl::OUString& strIdent) const;
+
+ /** get the name of the logged in user.
+ @param strName [out] is the buffer which returns the name
+ @param max [in] is the size of this buffer
+ @return True, if any user is successfuly logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getUserName( ::rtl::OUString& strName) const;
+
+ /** get the home directory of the logged in user.
+ @param strDirectory [out] is the buffer which returns the directory name
+ @param max [in] is the size of this buffer
+ @return True, if any user is successfuly logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString& strDirectory) const;
+
+ /** get the directory for configuration data of the logged in user.
+ @param strDirectory [out] is the buffer which returns the directory name
+ @param max [in] is the size of this buffer
+ @return True, if any user is successfuly logged in, otherwise False
+ */
+ inline sal_Bool SAL_CALL getConfigDir( ::rtl::OUString & strDirectory) const;
+
+ /** Query if the user who is logged inhas administrator rigths.
+ @return True, if the user has administrator rights, otherwise false.
+ */
+ inline sal_Bool SAL_CALL isAdministrator() const;
+
+ /** Returns the underlying oslSecurity handle
+ */
+ inline oslSecurity getHandle() const;
+
+};
+
+}
+
+#endif // _OSL_SECURITY_HXX_
+
diff --git a/sal/inc/osl/semaphor.h b/sal/inc/osl/semaphor.h
new file mode 100644
index 000000000000..c0c74515404a
--- /dev/null
+++ b/sal/inc/osl/semaphor.h
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SEMAPHORE_H_
+#define _OSL_SEMAPHORE_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* oslSemaphore;
+
+/** Creates a semaphore.<BR>
+
+ @deprecated
+ Must not be used, as unnamed semaphores are not supported on Mac OS X.
+
+ @param InitialCount denotes the starting value the semaphore. If you set it to
+ zero, the first acquire() blocks. Otherwise InitialCount acquire()s are
+ immedeatly successfull.
+ @return 0 if the semaphore could not be created, otherwise a handle to the sem.
+*/
+oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount);
+
+/** Release the OS-structures and free semaphore data-structure
+
+ @deprecated
+ Must not be used, as unnamed semaphores are not supported on Mac OS X.
+
+ @return fbbb
+*/
+void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore);
+
+/** acquire() decreases the count. It will block if it tries to
+ decrease below zero.
+
+ @deprecated
+ Must not be used, as unnamed semaphores are not supported on Mac OS X.
+
+ @return False if the system-call failed.
+*/
+sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore);
+
+/** tryToAcquire() tries to decreases the count. It will
+ return with False if it would decrease the count below zero.
+ (When acquire() would block.) If it could successfully
+ decrease the count, it will return True.
+
+ @deprecated
+ Must not be used, as unnamed semaphores are not supported on Mac OS X.
+*/
+sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore);
+
+/** release() increases the count.
+
+ @deprecated
+ Must not be used, as unnamed semaphores are not supported on Mac OS X.
+
+ @return False if the system-call failed.
+*/
+sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SEMAPHORE_H_ */
+
+
diff --git a/sal/inc/osl/semaphor.hxx b/sal/inc/osl/semaphor.hxx
new file mode 100644
index 000000000000..a45737d27524
--- /dev/null
+++ b/sal/inc/osl/semaphor.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SEMAPHORE_HXX_
+#define _OSL_SEMAPHORE_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/semaphor.h>
+
+
+namespace osl
+{
+ /** C++ wrapper class around C semaphore functions.
+
+ @deprecated
+ Must not be used, as unnamed semaphores are not supported on Mac OS X.
+ */
+ class Semaphore {
+
+ public:
+
+ /** Creates a semaphore.<BR>
+ @param InitialCount denotes the starting value the semaphore. If you set it to
+ zero, the first acquire() blocks. Otherwise InitialCount acquire()s are
+ immedeatly successfull.
+ @return 0 if the semaphore could not be created, otherwise a handle to the sem.
+ */
+
+ Semaphore(sal_uInt32 initialCount)
+ {
+ semaphore = osl_createSemaphore(initialCount);
+ }
+
+ /** Release the OS-structures and free semaphore data-structure
+ @return fbbb
+ */
+ ~Semaphore()
+ {
+ osl_destroySemaphore(semaphore);
+ }
+
+ /** acquire() decreases the count. It will block if it tries to
+ decrease below zero.
+ @return False if the system-call failed.
+ */
+ sal_Bool acquire()
+ {
+ return osl_acquireSemaphore(semaphore);
+ }
+
+ /** tryToAcquire() tries to decreases the count. It will
+ return with False if it would decrease the count below zero.
+ (When acquire() would block.) If it could successfully
+ decrease the count, it will return True.
+ */
+ sal_Bool tryToAcquire()
+ {
+ return osl_tryToAcquireSemaphore(semaphore);
+ }
+
+ /** release() increases the count.
+ @return False if the system-call failed.
+ */
+ sal_Bool release()
+ {
+ return osl_releaseSemaphore(semaphore);
+ }
+
+ private:
+ oslSemaphore semaphore;
+
+ /** The underlying oslSemaphore has no reference count.
+
+ Since the underlying oslSemaphore is not a reference counted object, copy
+ constructed Semaphore may work on an already destructed oslSemaphore object.
+
+ */
+ Semaphore(const Semaphore&);
+
+ /** The underlying oslSemaphore has no reference count.
+
+ When destructed, the Semaphore object destroys the undelying oslSemaphore,
+ which might cause severe problems in case it's a temporary object.
+
+ */
+ Semaphore(oslSemaphore Semaphore);
+
+ /** This assignment operator is private for the same reason as
+ the copy constructor.
+ */
+ Semaphore& operator= (const Semaphore&);
+
+ /** This assignment operator is private for the same reason as
+ the constructor taking a oslSemaphore argument.
+ */
+ Semaphore& operator= (oslSemaphore);
+ };
+}
+
+#endif /* __cplusplus */
+#endif /* _OSL_SEMAPHORE_HXX_ */
diff --git a/sal/inc/osl/signal.h b/sal/inc/osl/signal.h
new file mode 100644
index 000000000000..b9e8520a9194
--- /dev/null
+++ b/sal/inc/osl/signal.h
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SIGNAL_H_
+#define _OSL_SIGNAL_H_
+
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OSL_SIGNAL_USER_RESERVED 0
+
+#define OSL_SIGNAL_USER_RESOURCEFAILURE (OSL_SIGNAL_USER_RESERVED - 1)
+#define OSL_SIGNAL_USER_X11SUBSYSTEMERROR (OSL_SIGNAL_USER_RESERVED - 2)
+#define OSL_SIGNAL_USER_RVPCONNECTIONERROR (OSL_SIGNAL_USER_RESERVED - 3)
+
+typedef void* oslSignalHandler;
+
+typedef enum
+{
+ osl_Signal_System,
+ osl_Signal_Terminate,
+ osl_Signal_AccessViolation,
+ osl_Signal_IntegerDivideByZero,
+ osl_Signal_FloatDivideByZero,
+ osl_Signal_DebugBreak,
+ osl_Signal_User,
+ osl_Signal_Alarm,
+ osl_Signal_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSignal;
+
+typedef enum
+{
+ osl_Signal_ActCallNextHdl,
+ osl_Signal_ActIgnore,
+ osl_Signal_ActAbortApp,
+ osl_Signal_ActKillApp,
+ osl_Signal_Act_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSignalAction;
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(push, 4)
+#endif
+
+typedef struct
+{
+ oslSignal Signal;
+ sal_Int32 UserSignal;
+ void* UserData;
+} oslSignalInfo;
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+# pragma pack(pop)
+#endif
+
+/** the function-ptr. representing the signal handler-function.
+*/
+typedef oslSignalAction (SAL_CALL *oslSignalHandlerFunction)(void* pData, oslSignalInfo* pInfo);
+
+oslSignalHandler SAL_CALL osl_addSignalHandler(oslSignalHandlerFunction Handler, void* pData);
+
+sal_Bool SAL_CALL osl_removeSignalHandler(oslSignalHandler hHandler);
+
+oslSignalAction SAL_CALL osl_raiseSignal(sal_Int32 UserSignal, void* UserData);
+
+/** Enables or disables error reporting
+
+ On default error reporting is enabled after process startup.
+
+ @param bEnable [in]
+ Enables or disables error reporting.
+
+ @return
+ sal_True if previous state of error reporting was enabled<br>
+ sal_False if previous state of error reporting was disbaled<br>
+*/
+
+sal_Bool SAL_CALL osl_setErrorReporting( sal_Bool bEnable );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SIGNAL_H_ */
+
+
diff --git a/sal/inc/osl/socket.h b/sal/inc/osl/socket.h
new file mode 100644
index 000000000000..d1cf998c94e3
--- /dev/null
+++ b/sal/inc/osl/socket.h
@@ -0,0 +1,891 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SOCKET_H_
+#define _OSL_SOCKET_H_
+
+#include <rtl/ustring.h>
+#include <rtl/byteseq.h>
+
+#include <osl/time.h>
+#include <rtl/tencinfo.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* error returns */
+#define OSL_INADDR_NONE 0xffffffff
+#define OSL_INVALID_PORT (-1)
+#define OSL_INVALID_IPX_SOCKET_NO 0xffffffff
+
+/**@HTML
+
+*/
+
+/**
+ Opaque datatype SocketAddr.
+*/
+typedef struct oslSocketAddrImpl * oslSocketAddr;
+
+
+/**
+ Represents the address-family of a socket
+*/
+typedef enum {
+ osl_Socket_FamilyInet, /* IP */
+ osl_Socket_FamilyIpx, /* Novell IPX/SPX */
+ osl_Socket_FamilyInvalid, /* always last entry in enum! */
+ osl_Socket_Family_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslAddrFamily;
+
+/**
+ represent a specific protocol within a address-family
+*/
+typedef enum {
+ osl_Socket_ProtocolIp, /* for all af_inet */
+ osl_Socket_ProtocolIpx, /* af_ipx datagram sockets (IPX) */
+ osl_Socket_ProtocolSpx, /* af_ipx seqpacket or stream for SPX */
+ osl_Socket_ProtocolSpxII, /* af_ipx seqpacket or stream for SPX II */
+ osl_Socket_ProtocolInvalid,
+ osl_Socket_Protocol_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslProtocol;
+
+
+/**
+ Represents the type of a socket
+*/
+typedef enum {
+ osl_Socket_TypeStream,
+ osl_Socket_TypeDgram,
+ osl_Socket_TypeRaw,
+ osl_Socket_TypeRdm,
+ osl_Socket_TypeSeqPacket,
+ osl_Socket_TypeInvalid, /* always last entry in enum! */
+ osl_Socket_Type_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketType;
+
+
+/**
+ Represents socket-options
+*/
+typedef enum {
+ osl_Socket_OptionDebug,
+ osl_Socket_OptionAcceptConn,
+ osl_Socket_OptionReuseAddr,
+ osl_Socket_OptionKeepAlive,
+ osl_Socket_OptionDontRoute,
+ osl_Socket_OptionBroadcast,
+ osl_Socket_OptionUseLoopback,
+ osl_Socket_OptionLinger,
+ osl_Socket_OptionOOBinLine,
+ osl_Socket_OptionSndBuf,
+ osl_Socket_OptionRcvBuf,
+ osl_Socket_OptionSndLowat,
+ osl_Socket_OptionRcvLowat,
+ osl_Socket_OptionSndTimeo,
+ osl_Socket_OptionRcvTimeo,
+ osl_Socket_OptionError,
+ osl_Socket_OptionType,
+ osl_Socket_OptionTcpNoDelay,
+ osl_Socket_OptionInvalid, /* always last entry in enum! */
+ osl_Socket_Option_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketOption;
+
+/**
+ Represents the different socket-option levels
+*/
+typedef enum {
+ osl_Socket_LevelSocket,
+ osl_Socket_LevelTcp,
+ osl_Socket_LevelInvalid, /* always last entry in enum! */
+ osl_Socket_Level_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketOptionLevel;
+
+
+/**
+ Represents flags to be used with send/recv-calls.
+*/
+typedef enum {
+ osl_Socket_MsgNormal,
+ osl_Socket_MsgOOB,
+ osl_Socket_MsgPeek,
+ osl_Socket_MsgDontRoute,
+ osl_Socket_MsgMaxIOVLen,
+ osl_Socket_MsgInvalid, /* always last entry in enum! */
+ osl_Socket_Msg_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketMsgFlag;
+
+/**
+ Used by shutdown to denote which end of the socket to "close".
+*/
+typedef enum {
+ osl_Socket_DirRead,
+ osl_Socket_DirWrite,
+ osl_Socket_DirReadWrite,
+ osl_Socket_DirInvalid, /* always last entry in enum! */
+ osl_Socket_Dir_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketDirection;
+
+/** Describes the various error socket error conditions, which may
+ occur */
+typedef enum {
+ osl_Socket_E_None, /* no error */
+ osl_Socket_E_NotSocket, /* Socket operation on non-socket */
+ osl_Socket_E_DestAddrReq, /* Destination address required */
+ osl_Socket_E_MsgSize, /* Message too long */
+ osl_Socket_E_Prototype, /* Protocol wrong type for socket */
+ osl_Socket_E_NoProtocol, /* Protocol not available */
+ osl_Socket_E_ProtocolNoSupport, /* Protocol not supported */
+ osl_Socket_E_TypeNoSupport, /* Socket type not supported */
+ osl_Socket_E_OpNotSupport, /* Operation not supported on socket */
+ osl_Socket_E_PfNoSupport, /* Protocol family not supported */
+ osl_Socket_E_AfNoSupport, /* Address family not supported by */
+ /* protocol family */
+ osl_Socket_E_AddrInUse, /* Address already in use */
+ osl_Socket_E_AddrNotAvail, /* Can't assign requested address */
+ osl_Socket_E_NetDown, /* Network is down */
+ osl_Socket_E_NetUnreachable, /* Network is unreachable */
+ osl_Socket_E_NetReset, /* Network dropped connection because */
+ /* of reset */
+ osl_Socket_E_ConnAborted, /* Software caused connection abort */
+ osl_Socket_E_ConnReset, /* Connection reset by peer */
+ osl_Socket_E_NoBufferSpace, /* No buffer space available */
+ osl_Socket_E_IsConnected, /* Socket is already connected */
+ osl_Socket_E_NotConnected, /* Socket is not connected */
+ osl_Socket_E_Shutdown, /* Can't send after socket shutdown */
+ osl_Socket_E_TooManyRefs, /* Too many references: can't splice */
+ osl_Socket_E_TimedOut, /* Connection timed out */
+ osl_Socket_E_ConnRefused, /* Connection refused */
+ osl_Socket_E_HostDown, /* Host is down */
+ osl_Socket_E_HostUnreachable, /* No route to host */
+ osl_Socket_E_WouldBlock, /* call would block on non-blocking socket */
+ osl_Socket_E_Already, /* operation already in progress */
+ osl_Socket_E_InProgress, /* operation now in progress */
+ osl_Socket_E_InvalidError, /* unmapped error: always last entry in enum! */
+ osl_Socket_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketError;
+
+/** Common return codes of socket related functions.
+ */
+typedef enum {
+ osl_Socket_Ok, /* successful completion */
+ osl_Socket_Error, /* error occured, check osl_getLastSocketError() for details */
+ osl_Socket_TimedOut, /* blocking operation timed out */
+ osl_Socket_Interrupted, /* blocking operation was interrupted */
+ osl_Socket_InProgress, /* nonblocking operation is in progress */
+ osl_Socket_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslSocketResult;
+
+typedef sal_uInt8 oslSocketIpxNetNumber[4];
+typedef sal_uInt8 oslSocketIpxNodeNumber[6];
+
+/**@} end section types
+*/
+
+/**@{ begin section oslSocketAddr
+*/
+
+/** Creates a socket-address for the given family.
+ @param family If family == osl_Socket_FamilyInet the address is
+ set to INADDR_ANY port 0.
+ @return 0 if address could not be created.
+*/
+oslSocketAddr SAL_CALL osl_createEmptySocketAddr(oslAddrFamily Family);
+
+
+/** Creates a new SocketAddress and fills it from Addr.
+*/
+oslSocketAddr SAL_CALL osl_copySocketAddr(oslSocketAddr Addr);
+
+/** Compares the values of two SocketAddresses.
+ @return <code>sal_True</code> if both addresses denote the same socket address,
+ <code>sal_False</code> otherwise.
+*/
+sal_Bool SAL_CALL osl_isEqualSocketAddr(
+ oslSocketAddr Addr1, oslSocketAddr Addr2);
+
+/** Uses the systems name-service interface to find an address for strHostname.
+ @param strHostname [in] The name for which you search for an address.
+ @return The desired address if one could be found, otherwise 0.
+ Don't forget to destroy the address if you don't need it any longer.
+*/
+oslSocketAddr SAL_CALL osl_resolveHostname(rtl_uString *strHostname);
+
+/** Create an internet address usable for sending broadcast datagrams.
+ To limit the broadcast to your subnet, pass your hosts IP address
+ in dotted decimal notation as first argument.
+ @see osl_sendToSocket()
+ @see oslSocketAddr
+ @param strDottedAddr [in] dotted decimal internet address, may be 0.
+ @param Port [in] port number in host byte order.
+ @return 0 if address could not be created.
+*/
+oslSocketAddr SAL_CALL osl_createInetBroadcastAddr (
+ rtl_uString *strDottedAddr, sal_Int32 Port);
+
+
+/** Create an internet-address, consisting of hostaddress and port.
+ We interpret strDottedAddr as a dotted-decimal inet-addr
+ (e.g. "141.99.128.50").
+ @param strDottedAddr [in] String with dotted address.
+ @param Port [in] portnumber in host byte order.
+ @return 0 if address could not be created.
+*/
+oslSocketAddr SAL_CALL osl_createInetSocketAddr (
+ rtl_uString *strDottedAddr, sal_Int32 Port);
+
+
+/** Frees all resources allocated by Addr. The handle Addr must not
+ be used after the call anymore.
+*/
+void SAL_CALL osl_destroySocketAddr(oslSocketAddr Addr);
+
+/** Looks up the port-number designated to the specified service/protocol-pair.
+ (e.g. "ftp" "tcp").
+ @return OSL_INVALID_PORT if no appropriate entry was found, otherwise the port-number.
+*/
+sal_Int32 SAL_CALL osl_getServicePort(rtl_uString *strServicename, rtl_uString *strProtocol);
+
+
+
+/** Retrieves the address-family from the Addr.
+ @return the family of the socket-address.
+ In case of an unknown family you get <code>osl_Socket_FamilyInvalid</code>.
+*/
+oslAddrFamily SAL_CALL osl_getFamilyOfSocketAddr(oslSocketAddr Addr);
+
+
+/** Retrieves the internet port-number of Addr.
+ @return the port-number of the address in host-byte order. If Addr
+ is not an address of type <code>osl_Socket_FamilyInet</code>, it returns <code>OSL_INVALID_PORT</code>
+*/
+sal_Int32 SAL_CALL osl_getInetPortOfSocketAddr(oslSocketAddr Addr);
+
+
+/** Sets the Port of Addr.
+ @param Port [in] is expected in host byte-order.
+ @return <code>sal_False</code> if Addr is not an inet-addr.
+*/
+sal_Bool SAL_CALL osl_setInetPortOfSocketAddr(oslSocketAddr Addr, sal_Int32 Port);
+
+
+/** Returns the hostname represented by Addr.
+ @param strHostname out-parameter. The hostname represented by the address. If
+ there is no hostname to be found, it returns 0.
+*/
+oslSocketResult SAL_CALL osl_getHostnameOfSocketAddr(oslSocketAddr Addr, rtl_uString **strHostname);
+
+
+/** Gets the address in dotted decimal format.
+ @param strDottedInetAddr out-parameter. Contains the dotted decimal address
+ (e.g. 141.99.20.34) represented by the address.
+ If the address is invalid or not of type <code>osl_Socket_FamilyInet</code>,
+ it returns 0.
+ @return <code>osl_Socket_Ok</code> or <code>osl_Socket_Error</code>
+*/
+oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr(oslSocketAddr Addr, rtl_uString **strDottedInetAddr);
+
+/** Sets the addr field in the struct sockaddr with pByteSeq. pByteSeq must be in network byte order.
+ */
+oslSocketResult SAL_CALL osl_setAddrOfSocketAddr( oslSocketAddr Addr, sal_Sequence *pByteSeq );
+
+/** Returns the addr field in the struct sockaddr.
+ @param ppByteSeq out parameter. After the call, *ppByteSeq contains the ipadrress
+ in network byteorder. *ppByteSeq may be 0 in case of an invalid socket handle.
+ @return <code>osl_Socket_Ok</code> or <code>osl_Socket_Error</code>
+ */
+oslSocketResult SAL_CALL osl_getAddrOfSocketAddr( oslSocketAddr Addr, sal_Sequence **ppByteSeq );
+
+/*
+ Opaque datatype HostAddr.
+*/
+typedef struct oslHostAddrImpl * oslHostAddr;
+
+
+/** Create an oslHostAddr from given hostname and socket address.
+ @param strHostname [in] The hostname to be stored.
+ @param Addr [in] The socket address to be stored.
+ @return The created address or 0 upon failure.
+*/
+oslHostAddr SAL_CALL osl_createHostAddr(rtl_uString *strHostname, const oslSocketAddr Addr);
+
+
+/** Create an oslHostAddr by resolving the given strHostname.
+ Successful name resolution should result in the fully qualified
+ domain name (FQDN) and it's address as hostname and socket address
+ members of the resulting oslHostAddr.
+ @param strHostname [in] The hostname to be resolved.
+ @return The resulting address or 0 upon failure.
+*/
+oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname);
+
+
+/** Create an oslHostAddr by reverse resolution of the given Addr.
+ Successful name resolution should result in the fully qualified
+ domain name (FQDN) and it's address as hostname and socket address
+ members of the resulting oslHostAddr.
+ @param Addr [in] The socket address to be reverse resolved.
+ @return The resulting address or 0 upon failure.
+*/
+oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr Addr);
+
+
+/** Create a copy of the given Addr.
+ @return The copied address or 0 upon failure.
+*/
+oslHostAddr SAL_CALL osl_copyHostAddr(const oslHostAddr Addr);
+
+
+/** Frees all resources allocated by Addr. The handle Addr must not
+ be used after the call anymore.
+*/
+void SAL_CALL osl_destroyHostAddr(oslHostAddr Addr);
+
+
+/** Get the hostname member of Addr.
+ @return The hostname or 0 upon failure.
+*/
+void SAL_CALL osl_getHostnameOfHostAddr(const oslHostAddr Addr, rtl_uString **strHostname);
+
+
+/** Get the socket address member of Addr.
+ @return The socket address or 0 upon failure.
+*/
+oslSocketAddr SAL_CALL osl_getSocketAddrOfHostAddr(const oslHostAddr Addr);
+
+/** Retrieve this machines hostname.
+ May not always be a fully qualified domain name (FQDN).
+ @param strLocalHostname out-parameter. The string that receives the local host name.
+ @return <code>sal_True</code> upon success, <code>sal_False</code> otherwise.
+*/
+oslSocketResult SAL_CALL osl_getLocalHostname(rtl_uString **strLocalHostname);
+
+
+/**@} end section oslHostAddr
+*/
+
+/**@{ begin section oslSocket
+*/
+
+
+/*-***************************************************************************/
+/* oslSocket */
+/*-***************************************************************************/
+
+typedef struct oslSocketImpl * oslSocket;
+
+/** increases the refcount of the socket handle by one
+ */
+void SAL_CALL osl_acquireSocket( oslSocket Socket );
+
+/** decreases the refcount of the socket handle by one.
+
+ If the refcount drops to zero, the underlying socket handle
+ is destroyed and becomes invalid.
+ */
+void SAL_CALL osl_releaseSocket( oslSocket Socket );
+
+/** Create a socket of the specified Family and Type. The semantic of
+ the Protocol parameter depends on the given family and type.
+ @return 0 if socket could not be created, otherwise you get a handle
+ to the allocated socket-datastructure.
+*/
+oslSocket SAL_CALL osl_createSocket(oslAddrFamily Family,
+ oslSocketType Type,
+ oslProtocol Protocol);
+
+/** Retrieves the Address of the local end of the socket.
+ Note that a socket must be bound or connected before
+ a vaild address can be returned.
+ @return 0 if socket-address could not be created, otherwise you get
+ the created Socket-Address.
+*/
+oslSocketAddr SAL_CALL osl_getLocalAddrOfSocket(oslSocket Socket);
+
+/** Retrieves the Address of the remote end of the socket.
+ Note that a socket must be connected before
+ a vaild address can be returned.
+ @return 0 if socket-address could not be created, otherwise you get
+ the created Socket-Address.
+*/
+oslSocketAddr SAL_CALL osl_getPeerAddrOfSocket(oslSocket Socket);
+
+/** Binds the given address to the socket.
+ @param Socket [in]
+ @param Address [in]
+ @return <code>sal_False</code> if the bind failed, <code> sal_True</code> if successful.
+ @see osl_getLastSocketError()
+*/
+sal_Bool SAL_CALL osl_bindAddrToSocket(oslSocket Socket,
+ oslSocketAddr Addr);
+
+/** Connects the socket to the given address.
+
+ @param Socket [in] a bound socket.
+ @param Addr [in] the peer address.
+ @param pTimeout Timeout value or NULL for blocking.
+
+ @return <code>osl_Socket_Ok</code> on successful connection,
+ <code>osl_Socket_TimedOut</code> if operation timed out,
+ <code>osl_Socket_Interrupted</code> if operation was interrupted
+ <code>osl_Socket_Error</code> if the connection failed.
+*/
+oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket Socket,
+ oslSocketAddr Addr,
+ const TimeValue* pTimeout);
+
+
+/** Prepares the socket to act as an acceptor of incoming connections.
+ You should call "listen" before you use "accept".
+ @param MaxPendingConnections [in] denotes the length of the queue of
+ pending connections for this socket. If MaxPendingConnections is
+ -1, the systems default value will be used (Usually 5).
+ @return <code>sal_False</code> if the listen failed.
+*/
+sal_Bool SAL_CALL osl_listenOnSocket(oslSocket Socket,
+ sal_Int32 MaxPendingConnections);
+
+
+/** Waits for an ingoing connection on the socket.
+ This call blocks if there is no incoming connection present.
+ @param pAddr [in] if pAddr is != 0, the peers address is returned.
+ @return 0 if the accept-call failed, otherwise you get a socket
+ representing the new connection.
+*/
+oslSocket SAL_CALL osl_acceptConnectionOnSocket(oslSocket Socket,
+ oslSocketAddr* pAddr);
+
+/** Tries to receive BytesToRead data from the connected socket,
+ if no error occurs. Note that incomplete recvs due to
+ packet boundaries may occur.
+
+ @param Socket [in] A connected socket to be used to listen on.
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ data.
+ @param BytesToRead [in] The number of bytes to read. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of received bytes.
+*/
+sal_Int32 SAL_CALL osl_receiveSocket(oslSocket Socket,
+ void* pBuffer,
+ sal_uInt32 BytesToRead,
+ oslSocketMsgFlag Flag);
+
+/** Tries to receives BufferSize data from the (usually unconnected)
+ (datagram-)socket, if no error occurs.
+
+ @param Socket [in] A bound socket to be used to listen for a datagram.
+ @param pSenderAddr [out] An pointer to a created oslSocketAddr handle
+ or to a null handle. After the call, it will contain the constructed
+ oslSocketAddr of the datagrams sender. If pSenderAddr itself is 0,
+ it is ignored.
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ datagram.
+ @param BufferSize [in] The size of pBuffer.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of received bytes.
+*/
+sal_Int32 SAL_CALL osl_receiveFromSocket(oslSocket Socket,
+ oslSocketAddr SenderAddr,
+ void* pBuffer,
+ sal_uInt32 BufferSize,
+ oslSocketMsgFlag Flag);
+
+/** Tries to send BytesToSend data from the connected socket,
+ if no error occurs.
+
+ @param Socket [in] A connected socket.
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes.
+*/
+sal_Int32 SAL_CALL osl_sendSocket(oslSocket Socket,
+ const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag Flag);
+
+/** Tries to send one datagram with BytesToSend data to the given ReceiverAddr
+ via the (implicitly unconnected) datagram-socket.
+ Since there is only sent one packet, the function sends the data always complete
+ even with incomplete packet boundaries.
+
+ @param Socket [in] A bound or unbound socket. Socket will be bound
+ after a successful call.
+
+ @param ReceiverAddr [in] An initialized oslSocketAddress that contains
+ the destination address for this send.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes.
+*/
+sal_Int32 SAL_CALL osl_sendToSocket(oslSocket Socket,
+ oslSocketAddr ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag Flag);
+
+/** Checks if read operations will block.
+
+ You can specify a timeout-value in seconds/microseconds that denotes
+ how long the operation will block if the Socket is not ready.
+
+ @return <code>sal_True</code> if read operations (recv, recvFrom, accept) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occured.
+
+ @param Socket the Socket to perfom the operation on.
+ @param pTimeout if NULL, the operation will block without a timeout.
+*/
+sal_Bool SAL_CALL osl_isReceiveReady(oslSocket Socket, const TimeValue* pTimeout);
+
+/** Checks if send operations will block.
+ You can specify a timeout-value in seconds/microseconds that denotes
+ how long the operation will block if the Socket is not ready.
+ @return <code>sal_True</code> if send operations (send, sendTo) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occured.
+
+ @param Socket the Socket to perfom the operation on.
+ @param pTimeout if NULL, the operation will block without a timeout. Otherwise
+ the time define by timeout value.
+*/
+sal_Bool SAL_CALL osl_isSendReady(oslSocket Socket, const TimeValue* pTimeout);
+
+/** Checks if a request for out-of-band data will block.
+ You can specify a timeout-value in seconds/microseconds that denotes
+ how long the operation will block if the Socket has no pending OOB data.
+ @return <code>sal_True</code> if OOB-request operations (recv with appropriate flags)
+ on the Socket will NOT block; <code>sal_False</code> if it would block or if an error occured.
+
+ @param Socket the Socket to perfom the operation on.
+ @param pTimeout if NULL, the operation will block without a timeout.
+*/
+sal_Bool SAL_CALL osl_isExceptionPending(oslSocket Socket, const TimeValue* pTimeout);
+
+/** Shuts down communication on a connected socket.
+ @param Direction denotes which end of the socket
+ should be closed:
+ <ul>
+ <li> <code>osl_Socket_DirRead</code> closes read operations.
+ <li> <code>osl_Socket_DirReadWrite</code> closes write operations.
+ <li> <code>osl_Socket_DirWrite</code> closes read and write operations.
+ </ul>
+ @return <code>sal_True</code> if the socket could be closed down.
+*/
+sal_Bool SAL_CALL osl_shutdownSocket(oslSocket Socket,
+ oslSocketDirection Direction);
+
+/** Retrieves attributes associated with the socket.
+ @param Socket is the socket to query.
+
+ @param Level selects the level for which an option should be queried.
+ Valid values are:
+ <ul>
+ <li> osl_sol_socket: Socket Level
+ <li> osl_sol_tcp: Level of Transmission Control Protocol
+ </ul>
+
+ @param Option denotes the option to query.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> <code>osl_Socket_Option_Debug</code><br>
+ (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.
+
+ <li> <code>osl_Socket_OptionAcceptConn</code><br>
+ <li> <code>osl_Socket_OptionReuseAddr</code><br>
+ (sal_Bool) Allows the socket to be bound to an address that is
+ already in use.
+ 1 = multiple bound allowed, 0 = no multiple bounds allowed
+
+ <li><code>osl_Socket_OptionKeepAlive</code><br>
+ (sal_Bool) Keepalive packets are sent by the underlying socket.
+ 1 = enabled, 0 = disabled
+
+ <li><code>osl_Socket_OptionDontRoute</code><br>
+ (sal_Bool) Do not route: send directly to interface.
+ 1 = do not route , 0 = routing possible
+
+ <li><code>osl_Socket_OptionBroadcast</code><br>
+ (sal_Bool) Transmission of broadcast messages are allowed on the socket.
+ 1 = transmission allowed, 0 = transmission disallowed
+
+ <li><code>osl_Socket_OptionUseLoopback</code><br>
+
+ <li><code>osl_Socket_OptionLinger</code><br>
+ (sal_Int32) Linger on close if unsent data is present.
+ 0 = linger is off, > 0 = timeout in seconds.
+
+ <li><code>osl_Socket_OptionOOBinLine</code><br>
+
+
+ <li><code>osl_Socket_OptionSndBuf</code><br>
+ (sal_Int32) Size of the send buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket.
+
+ <li><code>osl_Socket_OptionRcvBuf</code><br>
+ (sal_Int32) Size of the receive buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket and larger packet sizes.
+
+ <li><code>osl_Socket_OptionSndLowat</code><br>
+
+ <li><code>osl_Socket_OptionRcvLowat</code><br>
+
+ <li><code>osl_Socket_OptionSndTimeo</code><br>
+ (sal_Int32) Data is sent after this timeout. This allows gathering
+ of data to send larger packages but increases latency times.
+
+ <li><code>osl_Socket_OptionRcvTimeo</code><br>
+
+ <li><code>osl_Socket_OptionError</code><br>
+ <li><code>osl_Socket_OptionType</code><br>
+
+ <li><code>osl_Socket_OptionTcpNoDelay</code><br>
+ Disables the Nagle algorithm for send coalescing. (Do not
+ collect data until a packet is full, instead send immediatly.
+ This increases network traffic but might improve latency-times.)
+ 1 = disables the algorithm, 0 = keeps it enabled.
+ </ul>
+ If not above mentioned otherwise, the options are only valid for
+ level <code>osl_Socket_LevelSocket</code>.
+
+ @param pBuffer Pointer to a buffer large enough to take the desired
+ attribute-value.
+
+ @param BufferSize contains the length of the Buffer.
+
+ @return -1 if an error occured or else the size of the data copied into
+ pBuffer.
+ @see osl_setSocketOption()
+*/
+sal_Int32 SAL_CALL osl_getSocketOption(oslSocket Socket,
+ oslSocketOptionLevel Level,
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen);
+
+/** Sets the sockets attributes.
+
+ @param Socket is the socket to modify.
+
+ @param Level selects the level for which an option should be changed.
+ Valid values are:
+ <ul>
+ <li> osl_sol_socket: Socket Level
+ <li> osl_sol_tcp: Level of Transmission Control Protocol
+ </ul>
+
+ @param Option denotes the option to modify. See osl_setSocketOption() for more
+ details.
+
+ @param pBuffer Pointer to a Buffer which contains the attribute-value.
+
+ @param BufferSize contains the length of the Buffer.
+
+ @return True if the option could be changed.
+*/
+sal_Bool SAL_CALL osl_setSocketOption(oslSocket Socket,
+ oslSocketOptionLevel Level,
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen);
+
+/** Enables/disables non-blocking-mode of the socket.
+ @param Socket Change mode for this socket.
+ @param On <code>sal_True</code> enables non-blocking mode,
+ <code>sal_False</code> disables non-blocking mode.
+ @return <code>sal_True</code> if mode could be changed.
+*/
+sal_Bool SAL_CALL osl_enableNonBlockingMode(oslSocket Socket,
+ sal_Bool On);
+
+
+/** Query state of non-blocking-mode of the socket.
+ @param Socket Query mode for this socket.
+ @return True if non-blocking-mode is enabled.
+*/
+sal_Bool SAL_CALL osl_isNonBlockingMode(oslSocket Socket);
+
+
+/** Queries the socket for its type.
+ @return one of:
+ <ul>
+ <li> osl_Socket_TypeStream
+ <li> osl_Socket_TypeDgram
+ <li> osl_Socket_TypeRaw
+ <li> osl_Socket_TypeRdm
+ <li> osl_Socket_TypeSeqPacket
+ <li> osl_invalid_SocketType, if an error occured
+ </ul>
+
+*/
+oslSocketType SAL_CALL osl_getSocketType(oslSocket Socket);
+
+/** returns a string which describes the last socket error.
+ @param strError out-parameter. The string that receives the error message.
+*/
+void SAL_CALL osl_getLastSocketErrorDescription(oslSocket Socket, rtl_uString **strError);
+
+/** returns a constant decribing the last error for the socket system.
+ @return <code>osl_Socket_E_NONE</code> if no error occured,
+ <code>osl_invalid_SocketError</code> if an unknown (unmapped)
+ error occured, otherwise an enum describing the error.
+*/
+oslSocketError SAL_CALL osl_getLastSocketError(oslSocket Socket);
+
+/** Type for the representation of socket sets.
+*/
+typedef struct oslSocketSetImpl * oslSocketSet;
+
+/** Creates a set of sockets to be used with osl_demultiplexSocketEvents().
+ @return A oslSocketSet or 0 if creation failed.
+*/
+oslSocketSet SAL_CALL osl_createSocketSet(void);
+
+/** Destroys a oslSocketSet.
+*/
+void SAL_CALL osl_destroySocketSet(oslSocketSet Set);
+
+/** Clears the set from all previously added sockets.
+ @param Set the set to be cleared.
+*/
+void SAL_CALL osl_clearSocketSet(oslSocketSet Set);
+
+
+/** Adds a socket to the set.
+ @param Set the set were the socket is added.
+ @param Socket the socket to be added.
+*/
+void SAL_CALL osl_addToSocketSet(oslSocketSet Set, oslSocket Socket);
+
+/** Removes a socket from the set.
+ @param Set the set were the socket is removed from.
+ @param Socket the socket to be removed.
+*/
+void SAL_CALL osl_removeFromSocketSet(oslSocketSet Set, oslSocket Socket);
+
+/** Checks if socket is in the set.
+ @param Set the set to be checked.
+ @param Socket check if this socket is in the set.
+ @return <code>sal_True</code> if socket is in the set.
+*/
+sal_Bool SAL_CALL osl_isInSocketSet(oslSocketSet Set, oslSocket Socket);
+
+/** Checks multiple sockets for events.
+ @param IncomingSet Checks the sockets in this set
+ for incoming events (read, accept). If the set is 0,
+ it is just skipped.
+ @param OutgoingSet Checks the sockets in this set
+ for outgoing events (write, connect). If the set is 0,
+ it is just skipped.
+ @param OutOfBandSet Checks the sockets in this set
+ for out-of-band events. If the set is 0, it is just skipped.
+ @param msTimeout Number of milliseconds to wait for events. If
+ msTimeout is -1, the call will block until an event or an error
+ occurs.
+ @return -1 on errors, otherwise the number of sockets with
+ pending events. In case of timeout, the number might be 0.
+*/
+sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet,
+ oslSocketSet OutgoingSet,
+ oslSocketSet OutOfBandSet,
+ const TimeValue* pTimeout);
+
+/** Closes the socket terminating any ongoing dataflow.
+ */
+void SAL_CALL osl_closeSocket(oslSocket Socket);
+
+
+/** Retrieves n bytes from the stream and copies them into pBuffer.
+ The function avoids incomplete reads due to packet boundaries.
+ @param pBuffer receives the read data.
+ @param n the number of bytes to read. pBuffer must be large enough
+ to hold the n bytes!
+ @return the number of read bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+*/
+sal_Int32 SAL_CALL osl_readSocket( oslSocket Socket, void *pBuffer, sal_Int32 nSize );
+
+
+/** Writes n bytes from pBuffer to the stream. The method avoids
+ incomplete writes due to packet boundaries.
+ @param pBuffer contains the data to be written.
+ @param n the number of bytes to write.
+ @return the number of written bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+*/
+sal_Int32 SAL_CALL osl_writeSocket( oslSocket Socket, const void *pBuffer, sal_Int32 nSize );
+
+/**@} end section oslSocket
+*/
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_SOCKET_H_ */
+
diff --git a/sal/inc/osl/socket.hxx b/sal/inc/osl/socket.hxx
new file mode 100644
index 000000000000..db05fe242982
--- /dev/null
+++ b/sal/inc/osl/socket.hxx
@@ -0,0 +1,565 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _OSL_SOCKET_HXX_
+#define _OSL_SOCKET_HXX_
+
+#include <osl/socket_decl.hxx>
+
+namespace osl
+{
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr()
+ : m_handle( osl_createEmptySocketAddr( osl_Socket_FamilyInet ) )
+ {}
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr(const SocketAddr& Addr)
+ : m_handle( osl_copySocketAddr( Addr.m_handle ) )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr(oslSocketAddr Addr)
+ : m_handle( osl_copySocketAddr( Addr ) )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr(oslSocketAddr Addr, __osl_socket_NoCopy )
+ : m_handle( Addr )
+ {
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort)
+ : m_handle( osl_createInetSocketAddr( strAddrOrHostName.pData, nPort ) )
+ {
+ if(! m_handle )
+ {
+ m_handle = osl_resolveHostname(strAddrOrHostName.pData);
+
+ // host found?
+ if(m_handle)
+ {
+ osl_setInetPortOfSocketAddr(m_handle, nPort);
+ }
+ else
+ {
+ osl_destroySocketAddr( m_handle );
+ m_handle = 0;
+ }
+ }
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr::~SocketAddr()
+ {
+ if( m_handle )
+ osl_destroySocketAddr( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString SocketAddr::getHostname( oslSocketResult *pResult ) const
+ {
+ ::rtl::OUString hostname;
+ oslSocketResult result = osl_getHostnameOfSocketAddr( m_handle, &(hostname.pData) );
+ if( pResult )
+ *pResult = result;
+ return hostname;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 SAL_CALL SocketAddr::getPort() const
+ {
+ return osl_getInetPortOfSocketAddr(m_handle);
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL SocketAddr::setPort( sal_Int32 nPort )
+ {
+ return osl_setInetPortOfSocketAddr(m_handle, nPort );
+ }
+
+ inline sal_Bool SAL_CALL SocketAddr::setHostname( const ::rtl::OUString &sDottedIpOrHostname )
+ {
+ *this = SocketAddr( sDottedIpOrHostname , getPort() );
+ return is();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL SocketAddr::setAddr( const ::rtl::ByteSequence & address )
+ {
+ return osl_setAddrOfSocketAddr( m_handle, address.getHandle() )
+ == osl_Socket_Ok;
+ }
+
+ inline ::rtl::ByteSequence SAL_CALL SocketAddr::getAddr( oslSocketResult *pResult ) const
+ {
+ ::rtl::ByteSequence sequence;
+ oslSocketResult result = osl_getAddrOfSocketAddr( m_handle,(sal_Sequence **) &sequence );
+ if( pResult )
+ *pResult = result;
+ return sequence;
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr & SAL_CALL SocketAddr::operator= (oslSocketAddr Addr)
+ {
+ oslSocketAddr pNewAddr = osl_copySocketAddr( Addr );
+ if( m_handle )
+ osl_destroySocketAddr( m_handle );
+ m_handle = pNewAddr;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline SocketAddr & SAL_CALL SocketAddr::operator= (const SocketAddr& Addr)
+ {
+ *this = (Addr.getHandle());
+ return *this;
+ }
+
+ inline SocketAddr & SAL_CALL SocketAddr::assign( oslSocketAddr Addr, __osl_socket_NoCopy )
+ {
+ if( m_handle )
+ osl_destroySocketAddr( m_handle );
+ m_handle = Addr;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SAL_CALL SocketAddr::operator== (oslSocketAddr Addr) const
+ {
+ return osl_isEqualSocketAddr( m_handle, Addr );
+ }
+
+ inline oslSocketAddr SocketAddr::getHandle() const
+ {
+ return m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool SocketAddr::is() const
+ {
+ return m_handle != 0;
+ }
+
+ // (static method)______________________________________________________________
+ inline ::rtl::OUString SAL_CALL SocketAddr::getLocalHostname( oslSocketResult *pResult )
+ {
+ ::rtl::OUString hostname;
+ oslSocketResult result = osl_getLocalHostname( &(hostname.pData) );
+ if(pResult )
+ *pResult = result;
+ return hostname;
+ }
+
+ // (static method)______________________________________________________________
+ inline void SAL_CALL SocketAddr::resolveHostname(
+ const ::rtl::OUString & strHostName, SocketAddr &Addr)
+ {
+ Addr = SocketAddr( osl_resolveHostname( strHostName.pData ) , SAL_NO_COPY );
+ }
+
+ // (static method)______________________________________________________________
+ inline sal_Int32 SAL_CALL SocketAddr::getServicePort(
+ const ::rtl::OUString& strServiceName,
+ const ::rtl::OUString & strProtocolName )
+ {
+ return osl_getServicePort( strServiceName.pData, strProtocolName.pData );
+ }
+
+ //______________________________________________________________________________
+ inline Socket::Socket(oslSocketType Type,
+ oslAddrFamily Family,
+ oslProtocol Protocol)
+ : m_handle( osl_createSocket(Family, Type, Protocol) )
+ {}
+
+ //______________________________________________________________________________
+ inline Socket::Socket( oslSocket socketHandle, __sal_NoAcquire )
+ : m_handle( socketHandle )
+ {}
+
+ //______________________________________________________________________________
+ inline Socket::Socket( oslSocket socketHandle )
+ : m_handle( socketHandle )
+ {
+ osl_acquireSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Socket::Socket( const Socket & socket )
+ : m_handle( socket.getHandle() )
+ {
+ osl_acquireSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Socket::~Socket()
+ {
+ osl_releaseSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline Socket& Socket::operator= ( oslSocket socketHandle)
+ {
+ osl_acquireSocket( socketHandle );
+ osl_releaseSocket( m_handle );
+ m_handle = socketHandle;
+ return *this;
+ }
+
+ //______________________________________________________________________________
+ inline Socket& Socket::operator= (const Socket& sock)
+ {
+ return (*this) = sock.getHandle();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::operator==( const Socket& rSocket ) const
+ {
+ return m_handle == rSocket.getHandle();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::operator==( const oslSocket socketHandle ) const
+ {
+ return m_handle == socketHandle;
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::shutdown( oslSocketDirection Direction )
+ {
+ osl_shutdownSocket( m_handle , Direction );
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::close()
+ {
+ osl_closeSocket( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::getLocalAddr( SocketAddr & addr) const
+ {
+ addr.assign( osl_getLocalAddrOfSocket( m_handle ) , SAL_NO_COPY );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getLocalPort() const
+ {
+ SocketAddr addr( 0 );
+ getLocalAddr( addr );
+ return addr.getPort();
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString Socket::getLocalHost() const
+ {
+ SocketAddr addr( 0 );
+ getLocalAddr( addr );
+ return addr.getHostname();
+ }
+
+ //______________________________________________________________________________
+ inline void Socket::getPeerAddr( SocketAddr &addr ) const
+ {
+ addr.assign( osl_getPeerAddrOfSocket( m_handle ), SAL_NO_COPY );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getPeerPort() const
+ {
+ SocketAddr addr( 0 );
+ getPeerAddr( addr );
+ return addr.getPort();
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString Socket::getPeerHost() const
+ {
+ SocketAddr addr( 0 );
+ getPeerAddr( addr );
+ return addr.getHostname();
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::bind(const SocketAddr& LocalInterface)
+ {
+ return osl_bindAddrToSocket( m_handle , LocalInterface.getHandle() );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isRecvReady(const TimeValue *pTimeout ) const
+ {
+ return osl_isReceiveReady( m_handle , pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isSendReady(const TimeValue *pTimeout ) const
+ {
+ return osl_isSendReady( m_handle, pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isExceptionPending(const TimeValue *pTimeout ) const
+ {
+ return osl_isExceptionPending( m_handle, pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketType Socket::getType() const
+ {
+ return osl_getSocketType( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getOption(
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level) const
+ {
+ return osl_getSocketOption( m_handle, Level, Option, pBuffer , BufferLen );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::setOption( oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level ) const
+ {
+ return osl_setSocketOption( m_handle, Level, Option , pBuffer, BufferLen );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::setOption( oslSocketOption option, sal_Int32 nValue )
+ {
+ return setOption( option, &nValue, sizeof( nValue ) );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 Socket::getOption( oslSocketOption option ) const
+ {
+ sal_Int32 n;
+ getOption( option, &n, sizeof( n ) );
+ return n;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::enableNonBlockingMode( sal_Bool bNonBlockingMode)
+ {
+ return osl_enableNonBlockingMode( m_handle , bNonBlockingMode );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Bool Socket::isNonBlockingMode() const
+ {
+ return osl_isNonBlockingMode( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline void SAL_CALL Socket::clearError() const
+ {
+ sal_Int32 err = 0;
+ getOption(osl_Socket_OptionError, &err, sizeof(err));
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketError Socket::getError() const
+ {
+ return osl_getLastSocketError( m_handle );
+ }
+
+ //______________________________________________________________________________
+ inline ::rtl::OUString Socket::getErrorAsString( ) const
+ {
+ ::rtl::OUString error;
+ osl_getLastSocketErrorDescription( m_handle, &(error.pData) );
+ return error;
+ }
+
+ //______________________________________________________________________________
+ inline oslSocket Socket::getHandle() const
+ {
+ return m_handle;
+ }
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket(oslAddrFamily Family,
+ oslProtocol Protocol,
+ oslSocketType Type )
+ : Socket( Type, Family, Protocol )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket( oslSocket socketHandle, __sal_NoAcquire noacquire )
+ : Socket( socketHandle, noacquire )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket( oslSocket socketHandle )
+ : Socket( socketHandle )
+ {}
+
+ //______________________________________________________________________________
+ inline StreamSocket::StreamSocket( const StreamSocket & socket )
+ : Socket( socket )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::read(void* pBuffer, sal_uInt32 n)
+ {
+ return osl_readSocket( m_handle, pBuffer, n );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::write(const void* pBuffer, sal_uInt32 n)
+ {
+ return osl_writeSocket( m_handle, pBuffer, n );
+ }
+
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::recv(void* pBuffer,
+ sal_uInt32 BytesToRead,
+ oslSocketMsgFlag Flag)
+ {
+ return osl_receiveSocket( m_handle, pBuffer,BytesToRead, Flag );
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 StreamSocket::send(const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag Flag)
+ {
+ return osl_sendSocket( m_handle, pBuffer, BytesToSend, Flag );
+ }
+
+ //______________________________________________________________________________
+ inline ConnectorSocket::ConnectorSocket(oslAddrFamily Family,
+ oslProtocol Protocol,
+ oslSocketType Type)
+ : StreamSocket( Family, Protocol ,Type )
+ {}
+
+ //______________________________________________________________________________
+ inline oslSocketResult ConnectorSocket::connect( const SocketAddr& TargetHost,
+ const TimeValue* pTimeout )
+ {
+ return osl_connectSocketTo( m_handle , TargetHost.getHandle(), pTimeout );
+ }
+
+ //______________________________________________________________________________
+ inline AcceptorSocket::AcceptorSocket(oslAddrFamily Family ,
+ oslProtocol Protocol ,
+ oslSocketType Type )
+ : Socket( Type, Family, Protocol )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Bool AcceptorSocket::listen(sal_Int32 MaxPendingConnections)
+ {
+ return osl_listenOnSocket( m_handle, MaxPendingConnections );
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketResult AcceptorSocket::acceptConnection( StreamSocket& Connection)
+ {
+ oslSocket o = osl_acceptConnectionOnSocket( m_handle, 0 );
+ oslSocketResult status = osl_Socket_Ok;
+ if( o )
+ {
+ Connection = StreamSocket( o , SAL_NO_ACQUIRE );
+ }
+ else
+ {
+ Connection = StreamSocket();
+ status = osl_Socket_Error;
+ }
+ return status;
+ }
+
+ //______________________________________________________________________________
+ inline oslSocketResult AcceptorSocket::acceptConnection(
+ StreamSocket& Connection, SocketAddr & PeerAddr)
+ {
+ // TODO change in/OUT parameter
+ oslSocket o = osl_acceptConnectionOnSocket( m_handle, (oslSocketAddr *)&PeerAddr );
+ oslSocketResult status = osl_Socket_Ok;
+ if( o )
+ {
+ Connection = StreamSocket( o , SAL_NO_ACQUIRE );
+ }
+ else
+ {
+ Connection = StreamSocket();
+ status = osl_Socket_Error;
+ }
+ return status;
+ }
+
+ //______________________________________________________________________________
+ inline DatagramSocket::DatagramSocket(oslAddrFamily Family,
+ oslProtocol Protocol,
+ oslSocketType Type)
+ : Socket( Type, Family, Protocol )
+ {}
+
+ //______________________________________________________________________________
+ inline sal_Int32 DatagramSocket::recvFrom(void* pBuffer,
+ sal_uInt32 BufferSize,
+ SocketAddr* pSenderAddr,
+ oslSocketMsgFlag Flag )
+ {
+ sal_Int32 nByteRead;
+ if( pSenderAddr )
+ {
+ // TODO : correct the out-parameter pSenderAddr outparameter
+ nByteRead = osl_receiveFromSocket( m_handle, pSenderAddr->getHandle() , pBuffer,
+ BufferSize, Flag);
+// nByteRead = osl_receiveFromSocket( m_handle, *(oslSocketAddr**) &pSenderAddr , pBuffer,
+// BufferSize, Flag);
+ }
+ else
+ {
+ nByteRead = osl_receiveFromSocket( m_handle, 0 , pBuffer , BufferSize , Flag );
+ }
+ return nByteRead;
+ }
+
+ //______________________________________________________________________________
+ inline sal_Int32 DatagramSocket::sendTo( const SocketAddr& ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BufferSize,
+ oslSocketMsgFlag Flag )
+ {
+ return osl_sendToSocket( m_handle, ReceiverAddr.getHandle(), pBuffer, BufferSize, Flag );
+ }
+}
+#endif
diff --git a/sal/inc/osl/socket_decl.hxx b/sal/inc/osl/socket_decl.hxx
new file mode 100644
index 000000000000..138c110c0719
--- /dev/null
+++ b/sal/inc/osl/socket_decl.hxx
@@ -0,0 +1,722 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_SOCKET_DECL_HXX_
+#define _OSL_SOCKET_DECL_HXX_
+
+#include <osl/socket.h>
+#include <rtl/ustring.hxx>
+#include <rtl/byteseq.hxx>
+
+/** @HTML
+ */
+namespace osl
+{
+ enum __osl_socket_NoCopy { SAL_NO_COPY };
+
+ /** The class should be understood as a reference to a socket address handle ( struct sockaddr ).
+
+ The handle is mutable.
+ */
+ class SocketAddr
+ {
+ protected:
+ oslSocketAddr m_handle;
+ public:
+
+ /** Creates socket address of unknown type.
+ */
+ inline SocketAddr();
+
+ /** Copy constructor.
+ */
+ inline SocketAddr(const SocketAddr& Addr);
+
+ /** The SocketAddr takes over the responsibility of the handle ( which means,
+ that the handle gets destructed by the destructor of this reference)
+
+ @param nocopy use SAL_NO_COPY
+ */
+ inline SocketAddr(const oslSocketAddr , __osl_socket_NoCopy nocopy );
+
+ /** Copyconstructs the oslSocketAddr handle.
+ */
+ inline SocketAddr(oslSocketAddr Addr);
+
+ /** tcpip-specif constructor.
+ @param strAddrOrHostName strAddrOrHostName hostname or dotted ip-number of the network
+ interface, the socket shall be created on.
+ @param nPort tcp-ip port number
+ */
+ inline SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort );
+
+ /** destroys underlying oslSocketAddress
+ */
+ inline ~SocketAddr();
+
+ /** checks, if the SocketAddr was created successful.
+ @return <code>sal_True</code> if there is a valid underlying handle,
+ otherwise sal_False.
+ */
+ inline sal_Bool is() const;
+
+ /** Converts the address to a (human readable) domain-name.
+
+ @param pResult 0, if you are not interested in errors,
+ otherwise *pResult contains an error code on failure
+ or osl_Socket_Ok on success
+ @return the hostname of this SocketAddr or an empty string on failure.
+ @see osl_getHostnameOfSocketAddr()
+ */
+ inline ::rtl::OUString SAL_CALL getHostname( oslSocketResult *pResult = 0 ) const;
+
+ /** Sets the ipaddress or hostname of the SocketAddress
+ */
+ inline sal_Bool SAL_CALL setHostname( const ::rtl::OUString &sDottedIpOrHostname );
+
+ /** Returns the port number of the address.
+ @return the port in host-byte order or or OSL_INVALID_PORT on errors.
+ */
+ inline sal_Int32 SAL_CALL getPort() const;
+
+ /** Sets the port number of the address.
+ @return true if successfule.
+ */
+ inline sal_Bool SAL_CALL setPort( sal_Int32 nPort );
+
+ /** Sets the address of the underlying socket address struct in network byte order.
+ @return true on success, false signales falure.
+ */
+ inline sal_Bool SAL_CALL setAddr( const ::rtl::ByteSequence & address );
+
+ /** Returns the address of the underlying socket in network byte order
+ */
+ inline ::rtl::ByteSequence SAL_CALL getAddr( oslSocketResult *pResult = 0 ) const;
+
+ /** assign the handle to this reference. The previous handle is released.
+ */
+ inline SocketAddr & SAL_CALL operator= (oslSocketAddr Addr);
+
+ /**
+ */
+ inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr);
+
+ /** Assigns the socket addr without copyconstructing it.
+ @param nocopy use SAL_NO_COPY
+ */
+ inline SocketAddr & SAL_CALL assign( oslSocketAddr Addr, __osl_socket_NoCopy nocopy );
+
+ /** Returns true if the underlying handle is identical to the Addr handle.
+ */
+ inline sal_Bool SAL_CALL operator== (oslSocketAddr Addr) const;
+
+ /** Returns true if the underlying handle is identical to the Addr handle.
+ */
+ inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const;
+
+ /** Returns the underlying SocketAddr handle without copyconstructing it.
+ */
+ inline oslSocketAddr SAL_CALL getHandle() const;
+
+ /** Get the hostname for the local interface.
+ @param after the call *pResult contains osl_Socket_Ok on success or
+ an error on failure.
+ @return the hostname
+ */
+ static inline ::rtl::OUString SAL_CALL getLocalHostname( oslSocketResult *pResult = 0);
+
+ /** Tries to find an address for a host.
+ @see osl_resolveHostname()
+ @return A new created socket-address or 0 if the name could not be found.
+ */
+ static inline void SAL_CALL resolveHostname(
+ const ::rtl::OUString & strHostName , SocketAddr & Addr );
+
+ /**
+ Tries to find the port associated with the given service/protocol-
+ pair (e.g. "ftp"/"tcp").
+ @return the port number in host-byte order or <code>OSL_INVALID_PORT</code>
+ if no service/protocol pair could be found.
+ */
+ static inline sal_Int32 SAL_CALL getServicePort(
+ const ::rtl::OUString& strServiceName,
+ const ::rtl::OUString & strProtocolName= ::rtl::OUString::createFromAscii( "tcp" ) );
+ };
+
+
+ class Socket
+ {
+ protected:
+ oslSocket m_handle;
+ protected:
+ /** Creates a socket. Note it's protected.
+ @param Type
+ @param Family
+ @param Protocol
+ */
+ inline Socket(oslSocketType Type,
+ oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp);
+ public:
+ inline Socket( );
+
+ inline Socket( const Socket & socket );
+
+ inline Socket( oslSocket socketHandle );
+
+ /** The instance takes over the handle's ownership without acquiring the
+ handle, but releases it within the dtor.
+ @param noacquire use SAL_NO_ACQUIRE
+ */
+ inline Socket( oslSocket socketHandle, __sal_NoAcquire noacquire );
+
+ /** Destructor. Releases the underlying handle
+ */
+ inline ~Socket();
+
+ /** Assignment operator. If socket was already created, the old one will
+ be discarded.
+ */
+ inline Socket& SAL_CALL operator= ( oslSocket socketHandle);
+
+ /** Assignment operator. If socket was already created, the old one will
+ be discarded.
+ */
+ inline Socket& SAL_CALL operator= (const Socket& sock);
+
+ /**
+ @return <code>sal_True</code>, when the underlying handle of both
+ Socket instances are identical, <code>sal_False</code> otherwise.
+ */
+ inline sal_Bool SAL_CALL operator==( const Socket& rSocket ) const ;
+
+ /**
+ @return <code>sal_True</code>, when the underlying handle of both
+ Socket instances are identical, <code>sal_False</code> otherwise.
+ */
+ inline sal_Bool SAL_CALL operator==( const oslSocket socketHandle ) const;
+
+ /** Closes a definite or both directions of the bidirectional stream.
+
+ @param Direction
+ @see osl_shutdownSocket()
+ */
+ inline void SAL_CALL shutdown( oslSocketDirection Direction = osl_Socket_DirReadWrite );
+
+ /** Closes a socket.
+ Note that closing a socket is identical to shutdown( osl_Socket_DirReadWrite ),
+ as the operating system distinguish both cases, both functions or offered in this API.
+ @see osl_closeSocket()
+ */
+ inline void SAL_CALL close();
+
+ /** Retrieves the address of the local interface of this socket.
+ @param Addr [out] receives the address.
+ @see osl_getLocalAddrOfSocket()
+ */
+ inline void SAL_CALL getLocalAddr( SocketAddr &Addr ) const;
+
+ /** Get the local port of the socket. Usually used after bind().
+ @return the port number or OSL_INVALID_PORT on errors.
+ */
+ inline sal_Int32 SAL_CALL getLocalPort() const;
+
+ /** Get the hostname for the local interface.
+ @return the hostname or an empty string ("").
+ */
+ inline ::rtl::OUString SAL_CALL getLocalHost() const;
+
+ /** Retrieves the address of the remote host of this socket.
+ @param Addr [out] receives the address.
+ */
+ inline void SAL_CALL getPeerAddr( SocketAddr & Addr) const;
+
+ /** Get the remote port of the socket.
+ @return the port number or OSL_INVALID_PORT on errors.
+ */
+ inline sal_Int32 SAL_CALL getPeerPort() const;
+
+ /** Get the hostname for the remote interface.
+ @return the hostname or an empty string ("").
+ */
+ inline ::rtl::OUString SAL_CALL getPeerHost() const;
+
+ /** Binds the socket to the specified (local) interface.
+ @param LocalInterface Address of the Interface
+ @return True if bind was successful.
+ */
+ inline sal_Bool SAL_CALL bind(const SocketAddr& LocalInterface);
+
+ /** Checks if read operations will block.
+
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how the operation will block if the Socket is not ready.
+ @return <code>sal_True</code> if read operations (recv, recvFrom, accept) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occured.
+
+ @param pTimeout if 0, the operation will block without a timeout. Otherwise
+ the specified amout of time.
+ */
+ inline sal_Bool SAL_CALL isRecvReady(const TimeValue *pTimeout = 0) const;
+
+ /** Checks if send operations will block.
+
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how the operation will block if the Socket is not ready.
+ @return <code>sal_True</code> if send operations (send, sendTo) on the Socket
+ will NOT block; <code>sal_False</code> if it would block or if an error occured.
+
+ @param pTimeout if 0, the operation will block without a timeout. Otherwise
+ the specified amout of time.
+ */
+ inline sal_Bool SAL_CALL isSendReady(const TimeValue *pTimeout = 0) const;
+
+
+ /** Checks if a request for out-of-band data will block.
+
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how the operation will block if the Socket has no pending OOB data.
+
+ @return <code>sal_True</code> if OOB-request operations (recv with appropriate flags)
+ on the Socket will NOT block; <code>sal_False</code> if it would block or if
+ an error occured.
+
+ @param pTimeout if 0, the operation will block without a timeout. Otherwise
+ the specified amout of time.
+ */
+ inline sal_Bool SAL_CALL isExceptionPending(const TimeValue *pTimeout = 0) const;
+
+
+ /** Queries the socket for its type.
+ @return one of:
+ <ul>
+ <li> <code>osl_Socket_TypeStream</code>
+ <li> <code>osl_Socket_TypeDgram</code>
+ <li> <code>osl_Socket_TypeRaw</code>
+ <li> <code>osl_Socket_TypeRdm</code>
+ <li> <code>osl_Socket_TypeSeqPacket</code>
+ <li> <code>osl_invalid_SocketType</code>, if an error occured
+ </ul>
+ */
+ inline oslSocketType SAL_CALL getType() const;
+
+ /** Retrieves option-attributes associated with the socket.
+ @param Option The attribute to query.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> <code>osl_Socket_Option_Debug</code><br>
+ (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.
+
+ <li> <code>osl_Socket_OptionAcceptConn</code><br>
+ <li> <code>osl_Socket_OptionReuseAddr</code><br>
+ (sal_Bool) Allows the socket to be bound to an address that is
+ already in use.
+ 1 = multiple bound allowed, 0 = no multiple bounds allowed
+
+ <li><code>osl_Socket_OptionKeepAlive</code><br>
+ (sal_Bool) Keepalive packets are sent by the underlying socket.
+ 1 = enabled, 0 = disabled
+
+ <li><code>osl_Socket_OptionDontRoute</code><br>
+ (sal_Bool) Do not route: send directly to interface.
+ 1 = do not route , 0 = routing possible
+
+ <li><code>osl_Socket_OptionBroadcast</code><br>
+ (sal_Bool) Transmission of broadcast messages are allowed on the socket.
+ 1 = transmission allowed, 0 = transmission disallowed
+
+ <li><code>osl_Socket_OptionUseLoopback</code><br>
+
+ <li><code>osl_Socket_OptionLinger</code><br>
+ (linger) Linger on close if unsent data is present.
+ linger has two members: l_onoff, l_linger
+ l_onoff = 0 is off, l_onoff > 0 and l_linger= timeout in seconds.
+
+ <li><code>osl_Socket_OptionOOBinLine</code><br>
+
+
+ <li><code>osl_Socket_OptionSndBuf</code><br>
+ (sal_Int32) Size of the send buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket.
+
+ <li><code>osl_Socket_OptionRcvBuf</code><br>
+ (sal_Int32) Size of the receive buffer in bytes. Data is sent after
+ SndTimeo or when the buffer is full. This allows faster writing
+ to the socket and larger packet sizes.
+
+ <li><code>osl_Socket_OptionSndLowat</code><br>
+
+ <li><code>osl_Socket_OptionRcvLowat</code><br>
+
+ <li><code>osl_Socket_OptionSndTimeo</code><br>
+ (sal_Int32) Data is sent after this timeout. This allows gathering
+ of data to send larger packages but increases latency times.
+
+ <li><code>osl_Socket_OptionRcvTimeo</code><br>
+
+ <li><code>osl_Socket_OptionError</code><br>
+ <li><code>osl_Socket_OptionType</code><br>
+
+ <li><code>osl_Socket_OptionTcpNoDelay</code><br>
+ Disables the Nagle algorithm for send coalescing. (Do not
+ collect data until a packet is full, instead send immediatly.
+ This increases network traffic but might improve latency-times.)
+ 1 = disables the algorithm, 0 = keeps it enabled.
+ </ul>
+
+ If not above mentioned otherwise, the options are only valid for
+ level <code>osl_Socket_LevelSocket</code>.
+ @param pBuffer The Buffer will be filled with the attribute.
+
+ @param BufferSize The size of pBuffer.
+
+ @param Level The option level.
+
+ Valid values are:
+ <ul>
+ <li><code>osl_Socket_LevelSocket</code> : Socket Level
+ <li><code>osl_Socket_LevelTcp</code> : Level of Transmission Control Protocol
+ </ul>
+ @return The size of the attribute copied into pBuffer or -1 if an error
+ occured.
+ */
+ inline sal_Int32 SAL_CALL getOption(
+ oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level= osl_Socket_LevelSocket) const;
+
+ /** Sets the sockets attributes.
+
+ @param Option denotes the option to modify.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> osl_Socket_Option_Debug
+ <li> osl_Socket_OptionAcceptConn
+ <li> osl_Socket_OptionReuseAddr
+ <li> osl_Socket_OptionKeepAlive
+ <li> osl_Socket_OptionDontRoute
+ <li> osl_Socket_OptionBroadcast
+ <li> osl_Socket_OptionUseLoopback
+ <li> osl_Socket_OptionLinger
+ <li> osl_Socket_OptionOOBinLine
+ <li> osl_Socket_OptionSndBuf
+ <li> osl_Socket_OptionRcvBuf
+ <li> osl_Socket_OptionSndLowat
+ <li> osl_Socket_OptionRcvLowat
+ <li> osl_Socket_OptionSndTimeo
+ <li> osl_Socket_OptionRcvTimeo
+ <li> osl_Socket_OptionError
+ <li> osl_Socket_OptionType
+ <li> osl_Socket_OptionTcpNoDelay
+ </ul>
+
+ If not above mentioned otherwise, the options are only valid for
+ level osl_Socket_LevelSocket.
+
+ @param pBuffer Pointer to a Buffer which contains the attribute-value.
+
+ @param BufferSize contains the length of the Buffer.
+
+ @param Level selects the level for which an option should be changed.
+ Valid values are:
+ <ul>
+ <li> osl_Socket_evel_Socket : Socket Level
+ <li> osl_Socket_Level_Tcp : Level of Transmission Control Protocol
+ </ul>
+
+ @return True if the option could be changed.
+ */
+ inline sal_Bool SAL_CALL setOption( oslSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ oslSocketOptionLevel Level= osl_Socket_LevelSocket ) const;
+
+ /** Convenience function for setting sal_Bool and sal_Int32 option values.
+ @see setOption()
+ */
+ inline sal_Bool setOption( oslSocketOption option, sal_Int32 nValue );
+
+ /** Convenience function for retrieving sal_Bool and sal_Int32 option values.
+ @see setOption()
+ */
+ inline sal_Int32 getOption( oslSocketOption option ) const;
+
+ /** Enables/disables non-blocking mode of the socket.
+ @param bNonBlockingMode If <code>sal_True</code>, blocking mode will be switched off
+ If <code>sal_False</code>, the socket will become a blocking
+ socket (which is the default behaviour of a socket).
+ @return <code>sal_True</code> if mode could be set.
+ */
+ inline sal_Bool SAL_CALL enableNonBlockingMode( sal_Bool bNonBlockingMode);
+
+ /** Query blocking mode of the socket.
+ @return <code>sal_True</code> if non-blocking mode is set.
+ */
+ inline sal_Bool SAL_CALL isNonBlockingMode() const;
+
+
+ /** clears the error status
+ */
+ inline void SAL_CALL clearError() const;
+
+ /** returns a constant decribing the last error for the socket system.
+
+ @return osl_Socket_E_NONE if no error occured, invalid_SocketError if
+ an unknown (unmapped) error occured, otherwise an enum describing the
+ error.
+ @see osl_getLastSocketError()
+ */
+ inline oslSocketError getError() const;
+
+ /** Builds a string with the last error-message for the socket.
+ */
+ inline ::rtl::OUString getErrorAsString( ) const;
+
+ /** Returns the underlying handle unacquired (The caller must acquire it to keep it).
+ */
+ inline oslSocket getHandle() const;
+ };
+
+
+ class StreamSocket : public Socket
+ {
+ public:
+ /** Creates a socket.
+ @param Type For some protocols it might be desirable to
+ use a different type than <code>osl_Socket_TypeStream</code>
+ (like <code>osl_Socket_TypeSeqPacket</code>).
+ Therefore this parameter is not hidden.
+ */
+ inline StreamSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp,
+ oslSocketType Type = osl_Socket_TypeStream);
+
+ inline StreamSocket( const StreamSocket & );
+
+ inline StreamSocket( oslSocket Socket , __sal_NoAcquire noacquire );
+
+ inline StreamSocket( oslSocket Socket );
+
+ /** Retrieves n bytes from the stream and copies them into pBuffer.
+ The method avoids incomplete reads due to packet boundaries and is thus
+ blocking.
+ @param pBuffer receives the read data. pBuffer must be large enough
+ to hold n bytes.
+ @param n the number of bytes to read.
+ @return the number of read bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ inline sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 n);
+
+ /** Writes n bytes from pBuffer to the stream. The method avoids
+ incomplete writes due to packet boundaries and is thus blocking.
+ @param pBuffer contains the data to be written.
+ @param n the number of bytes to write.
+ @return the number of written bytes. The number will only be smaller than
+ n if an exceptional condition (e.g. connection closed) occurs.
+ */
+ inline sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
+
+
+ /** Tries to receive BytesToRead data from the connected socket,
+
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ data. pBuffer must have at least have a size of BytesToRead.
+ @param BytesToRead [in] The number of bytes to read.
+ @param Flag [in] Modifier for the call. Valid values are:
+
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+ @return the number of received bytes, which may be less than BytesToRead.
+ */
+ inline sal_Int32 SAL_CALL recv(void* pBuffer,
+ sal_uInt32 BytesToRead,
+ oslSocketMsgFlag flags= osl_Socket_MsgNormal);
+
+ /** Tries to send BytesToSend data to the connected socket.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes. It may be less than BytesToSend.
+ */
+ sal_Int32 SAL_CALL send(const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ oslSocketMsgFlag= osl_Socket_MsgNormal);
+ };
+
+ class ConnectorSocket : public StreamSocket
+ {
+ public:
+ /** Creates a socket that can connect to a (remote) host.
+ @param Type For some protocols it might be desirable to
+ use a different type than sock_stream <code>osl_Socket_TypeSeqPacket</code>
+ (like <code>osl_Socket_TypeSeqPacket</code>).
+ Therefore we do not hide this parameter here.
+ */
+ ConnectorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp,
+ oslSocketType Type = osl_Socket_TypeStream);
+
+
+ /** Connects the socket to a (remote) host.
+ @param TargetHost The address of the target.
+ @param pTimeOut The timeout for blocking. If 0, a default system dependent timeout
+ us used.
+ @return <code> osl_Socket_Ok</code> if connected successfully,
+ <code>osl_Socket_TimedOut</code> on timeout,
+ <code>osl_Socket_Interrupted</code> if unblocked forcefully (by osl::Socket::close()),
+ <code>osl_Socket_Error</code> if connect failed.
+ */
+ oslSocketResult SAL_CALL connect(const SocketAddr& TargetHost, const TimeValue* pTimeout = 0);
+ };
+
+ /** Allows to accept socket connections.
+ */
+ class AcceptorSocket : public Socket
+ {
+ public:
+ inline AcceptorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
+ oslProtocol Protocol = osl_Socket_ProtocolIp,
+ oslSocketType Type = osl_Socket_TypeStream);
+
+ /** Prepare a socket for the accept-call. The socket must have been
+ bound before to the local address.
+ @param MaxPendingConnections The maximum number of pending
+ connections (waiting to be accepted) on this socket. If you use
+ -1, a system default value is used.
+ @return <code>sal_True</code> if call was successful.
+ */
+ inline sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
+
+ /** Accepts incoming connections on the socket. You must
+ precede this call with osl::Socket::bind() and listen().
+ @param Connection receives the incoming connection.
+ @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
+ <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
+ <code>osl_Socket_Error</code> on errors.
+ */
+ inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection);
+
+ /** Accepts incoming connections on the socket. You must
+ precede this call with osl::Socket::bind() and listen().
+ @param PeerAddr receives the address of the connecting entity
+ (your communication partner).
+ @param Connection receives the incoming connection.
+ @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
+ <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
+ <code>osl_Socket_Error</code> on errors.
+ */
+ inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection, SocketAddr & PeerAddr);
+ };
+
+
+
+ /** A connectionless socket to send and receive datagrams.
+ */
+ class DatagramSocket : public Socket
+ {
+ public:
+
+ /** Creates a datagram socket.
+ @param Type is sock_dgram by default.
+ */
+ inline DatagramSocket(oslAddrFamily Family= osl_Socket_FamilyInet,
+ oslProtocol Protocol= osl_Socket_ProtocolIp,
+ oslSocketType Type= osl_Socket_TypeDgram);
+
+ /** Tries to receives BufferSize data from the socket, if no error occurs.
+
+ @param pSenderAddr [out] You must provide pointer to a SocketAddr.
+ It will be filled with the address of the datagrams sender.
+ If pSenderAddr is 0, it is ignored.
+ @param pBuffer [out] Points to a buffer that will be filled with the received
+ datagram.
+ @param BufferSize [in] The size of pBuffer.
+ @param Flag [in] Modifier for the call. Valid values are:
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of received bytes.
+ */
+ inline sal_Int32 SAL_CALL recvFrom(void* pBuffer,
+ sal_uInt32 BufferSize,
+ SocketAddr* pSenderAddr= 0,
+ oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
+
+ /** Tries to send one datagram with BytesToSend size to the given ReceiverAddr.
+ Since there is only send one packet, the function doesn't care about
+ packet boundaries.
+
+ @param ReceiverAddr [in] A SocketAddr that contains
+ the destination address for this send.
+
+ @param pBuffer [in] Points to a buffer that contains the send-data.
+ @param BufferSize [in] The number of bytes to send. pBuffer must have at least
+ this size.
+ @param Flag [in] Modifier for the call. Valid values are:
+
+ <ul>
+ <li><code>osl_Socket_MsgNormal</code>
+ <li><code>osl_Socket_MsgOOB</code>
+ <li><code>osl_Socket_MsgPeek</code>
+ <li><code>osl_Socket_MsgDontRoute</code>
+ <li><code>osl_Socket_MsgMaxIOVLen</code>
+ </ul>
+
+ @return the number of transfered bytes.
+ */
+ inline sal_Int32 SAL_CALL sendTo( const SocketAddr& ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BufferSize,
+ oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
+ };
+
+}
+
+#endif
diff --git a/sal/inc/osl/thread.h b/sal/inc/osl/thread.h
new file mode 100644
index 000000000000..16860644d7a0
--- /dev/null
+++ b/sal/inc/osl/thread.h
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_THREAD_H_
+#define _OSL_THREAD_H_
+
+#include <osl/time.h>
+
+#ifndef _RTL_TEXTENC_H_
+# include <rtl/textenc.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ Opaque data type for threads. As with all other osl-handles
+ you can initialize and/or test it to/for 0.
+*/
+typedef void* oslThread;
+
+/** the function-ptr. representing the threads worker-function.
+*/
+typedef void (SAL_CALL *oslWorkerFunction)(void*);
+
+/** levels of thread-priority
+ Note that oslThreadPriorityUnknown might be returned
+ by getPriorityOfThread() (e.g. when it is terminated),
+ but mustn't be used with setPriority()!
+*/
+typedef enum
+{
+ osl_Thread_PriorityHighest,
+ osl_Thread_PriorityAboveNormal,
+ osl_Thread_PriorityNormal,
+ osl_Thread_PriorityBelowNormal,
+ osl_Thread_PriorityLowest,
+ osl_Thread_PriorityUnknown, /* don't use to set */
+ osl_Thread_Priority_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+} oslThreadPriority;
+
+
+typedef sal_uInt32 oslThreadIdentifier;
+
+typedef sal_uInt32 oslThreadKey;
+
+/** Create the thread, using the function-ptr pWorker as
+ its main (worker) function. This functions receives in
+ its void* parameter the value supplied by pThreadData.
+ Once the OS-structures are initialized,the thread starts
+ running.
+ @return 0 if creation failed, otherwise a handle to the thread
+*/
+oslThread SAL_CALL osl_createThread(oslWorkerFunction pWorker, void* pThreadData);
+
+/** Create the thread, using the function-ptr pWorker as
+ its main (worker) function. This functions receives in
+ its void* parameter the value supplied by pThreadData.
+ The thread will be created, but it won't start running.
+ To wake-up the thread, use resume().
+ @return 0 if creation failed, otherwise a handle to the thread
+*/
+oslThread SAL_CALL osl_createSuspendedThread(oslWorkerFunction pWorker, void* pThreadData);
+
+/** Get the identifier for the specified thread or if parameter
+ Thread is NULL of the current active thread.
+ @return identifier of the thread
+*/
+oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread);
+
+/** Release the thread handle.
+ If Thread is NULL, the function won't do anything.
+ Note that we do not interfere with the actual running of
+ the thread, we just free up the memory needed by the handle.
+*/
+void SAL_CALL osl_destroyThread(oslThread Thread);
+
+/** Wake-up a thread that was suspended with suspend() or
+ createSuspended(). The oslThread must be valid!
+*/
+void SAL_CALL osl_resumeThread(oslThread Thread);
+
+/** Suspend the execution of the thread. If you want the thread
+ to continue, call resume(). The oslThread must be valid!
+*/
+void SAL_CALL osl_suspendThread(oslThread Thread);
+
+/** Changes the threads priority.
+ The oslThread must be valid!
+*/
+void SAL_CALL osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority);
+
+/** Retrieves the threads priority.
+ Returns oslThreadPriorityUnknown for invalid Thread-argument or
+ terminated thread. (I.e.: The oslThread might be invalid.)
+*/
+oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread);
+
+/** Returns True if the thread was created and has not terminated yet.
+ Note that according to this definition a "running" thread might be
+ suspended! Also returns False is Thread is NULL.
+*/
+sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread);
+
+/** Blocks the calling thread until Thread has terminated.
+ Returns immediately if Thread is NULL.
+*/
+void SAL_CALL osl_joinWithThread(oslThread Thread);
+
+/** Blocks the calling thread at least for the given number
+ of time.
+*/
+void SAL_CALL osl_waitThread(const TimeValue* pDelay);
+
+/** The requested thread will get terminate the next time
+ scheduleThread() is called.
+*/
+void SAL_CALL osl_terminateThread(oslThread Thread);
+
+/** Offers the rest of the threads time-slice to the OS.
+ scheduleThread() should be called in the working loop
+ of the thread, so any other thread could also get the
+ processor. Returns False if the thread should terminate, so
+ the thread could free any allocated resources.
+*/
+sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread);
+
+/** Offers the rest of the threads time-slice to the OS.
+ Under POSIX you _need_ to yield(), otherwise, since the
+ threads are not preempted during execution, NO other thread
+ (even with higher priority) gets the processor. Control is
+ only given to another thread if the current thread blocks
+ or uses yield().
+*/
+void SAL_CALL osl_yieldThread(void);
+
+/* Callback when data stored in a thread key is no longer needed */
+
+typedef void (SAL_CALL *oslThreadKeyCallbackFunction)(void *);
+
+/** Create a key to an associated thread local storage pointer. */
+oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback);
+
+/** Destroy a key to an associated thread local storage pointer. */
+void SAL_CALL osl_destroyThreadKey(oslThreadKey Key);
+
+/** Get to key associated thread specific data. */
+void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key);
+
+/** Set to key associated thread specific data. */
+sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData);
+
+/** Get the current thread local text encoding. */
+rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void);
+
+/** Set the thread local text encoding.
+ @return the old text encoding.
+*/
+rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding(rtl_TextEncoding Encoding);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_THREAD_H_ */
+
diff --git a/sal/inc/osl/thread.hxx b/sal/inc/osl/thread.hxx
new file mode 100644
index 000000000000..51fe059d2210
--- /dev/null
+++ b/sal/inc/osl/thread.hxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _THREAD_HXX_
+#define _THREAD_HXX_
+
+#ifdef __cplusplus
+
+#include <osl/time.h>
+
+
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <rtl/alloc.h>
+
+namespace osl
+{
+/** threadFunc is the function which is executed by the threads
+ created by the osl::Thread class. The function's signature
+ matches the one of oslWorkerFunction which is declared in
+ osl/thread.h .
+*/
+extern "C" inline void SAL_CALL threadFunc( void* param);
+
+class Thread
+{
+ Thread( const Thread& );
+ Thread& operator= ( const Thread& );
+public:
+ // these are here to force memory de/allocation to sal lib.
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW (())
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW (())
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW (())
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW (())
+ {}
+
+ Thread(): m_hThread(0){}
+
+ virtual ~Thread()
+ {
+ osl_destroyThread( m_hThread);
+ }
+
+ sal_Bool SAL_CALL create()
+ {
+ OSL_ASSERT(m_hThread == 0); // only one running thread per instance
+ if (m_hThread)
+ return sal_False;
+
+ m_hThread = osl_createSuspendedThread( threadFunc, (void*)this);
+ if ( m_hThread )
+ osl_resumeThread(m_hThread);
+
+ return m_hThread != 0;
+ }
+
+ sal_Bool SAL_CALL createSuspended()
+ {
+ OSL_ASSERT(m_hThread == 0); // only one running thread per instance
+ if( m_hThread)
+ return sal_False;
+ m_hThread= osl_createSuspendedThread( threadFunc,
+ (void*)this);
+ return m_hThread != 0;
+ }
+
+ virtual void SAL_CALL suspend()
+ {
+ if( m_hThread )
+ osl_suspendThread(m_hThread);
+ }
+
+ virtual void SAL_CALL resume()
+ {
+ if( m_hThread )
+ osl_resumeThread(m_hThread);
+ }
+
+ virtual void SAL_CALL terminate()
+ {
+ if( m_hThread )
+ osl_terminateThread(m_hThread);
+ }
+
+ virtual void SAL_CALL join()
+ {
+ osl_joinWithThread(m_hThread);
+ }
+
+ sal_Bool SAL_CALL isRunning() const
+ {
+ return osl_isThreadRunning(m_hThread);
+ }
+
+ void SAL_CALL setPriority( oslThreadPriority Priority)
+ {
+ if( m_hThread )
+ osl_setThreadPriority(m_hThread, Priority);
+ }
+
+ oslThreadPriority SAL_CALL getPriority() const
+ {
+ return m_hThread ? osl_getThreadPriority(m_hThread) : osl_Thread_PriorityUnknown;
+ }
+
+ oslThreadIdentifier SAL_CALL getIdentifier() const
+ {
+ return osl_getThreadIdentifier(m_hThread);
+ }
+
+ static oslThreadIdentifier SAL_CALL getCurrentIdentifier()
+ {
+ return osl_getThreadIdentifier(0);
+ }
+
+ static void SAL_CALL wait(const TimeValue& Delay)
+ {
+ osl_waitThread(&Delay);
+ }
+
+ static void SAL_CALL yield()
+ {
+ osl_yieldThread();
+ }
+
+
+ virtual sal_Bool SAL_CALL schedule()
+ {
+ return m_hThread ? osl_scheduleThread(m_hThread) : sal_False;
+ }
+
+ SAL_CALL operator oslThread() const
+ {
+ return m_hThread;
+ }
+
+protected:
+
+ /** The thread functions calls the protected functions
+ run and onTerminated.
+ */
+ friend void SAL_CALL threadFunc( void* param);
+
+ virtual void SAL_CALL run() = 0;
+
+ virtual void SAL_CALL onTerminated()
+ {
+ }
+
+private:
+ oslThread m_hThread;
+};
+
+extern "C" inline void SAL_CALL threadFunc( void* param)
+{
+ Thread* pObj= (Thread*)param;
+ pObj->run();
+ pObj->onTerminated();
+}
+
+class ThreadData
+{
+ ThreadData( const ThreadData& );
+ ThreadData& operator= (const ThreadData& );
+public:
+ /// Create a thread specific local data key
+ ThreadData( oslThreadKeyCallbackFunction pCallback= 0 )
+ {
+ m_hKey = osl_createThreadKey( pCallback );
+ }
+
+ /// Destroy a thread specific local data key
+ ~ThreadData()
+ {
+ osl_destroyThreadKey(m_hKey);
+ }
+
+ /** Set the data associated with the data key.
+ @returns True if operation was successfull
+ */
+ sal_Bool SAL_CALL setData(void *pData)
+ {
+ return (osl_setThreadKeyData(m_hKey, pData));
+ }
+
+ /** Get the data associated with the data key.
+ @returns The data asscoitaed with the data key or
+ NULL if no data was set
+ */
+ void* SAL_CALL getData()
+ {
+ return osl_getThreadKeyData(m_hKey);
+ }
+
+ operator oslThreadKey() const
+ {
+ return m_hKey;
+ }
+
+private:
+ oslThreadKey m_hKey;
+};
+
+} // end namespace osl
+#endif
+#endif
diff --git a/sal/inc/osl/time.h b/sal/inc/osl/time.h
new file mode 100644
index 000000000000..95bac4c89ec2
--- /dev/null
+++ b/sal/inc/osl/time.h
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OSL_TIME_H_
+#define _OSL_TIME_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****************************************************************************/
+/* TimeValue */
+/****************************************************************************/
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(push, 4)
+#endif
+
+/* Time since Jan-01-1970 */
+
+typedef struct {
+ sal_uInt32 Seconds;
+ sal_uInt32 Nanosec;
+} TimeValue;
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+# pragma pack(pop)
+#endif
+
+
+/****************************************************************************/
+/* oslDateTime */
+/****************************************************************************/
+
+typedef struct _oslDateTime
+{
+ /*----------------------------------------------------------------------*/
+ /** contains the nanoseconds .
+ */
+ sal_uInt32 NanoSeconds;
+
+ /** contains the seconds (0-59).
+ */
+ sal_uInt16 Seconds;
+
+ /*----------------------------------------------------------------------*/
+ /** contains the minutes (0-59).
+ */
+ sal_uInt16 Minutes;
+
+ /*----------------------------------------------------------------------*/
+ /** contains the hour (0-23).
+ */
+ sal_uInt16 Hours;
+
+ /*----------------------------------------------------------------------*/
+ /** is the day of month (1-31).
+ */
+ sal_uInt16 Day;
+
+ /*----------------------------------------------------------------------*/
+ /** is the day of week (0-6 , 0 : Sunday).
+ */
+ sal_uInt16 DayOfWeek;
+
+ /*----------------------------------------------------------------------*/
+ /** is the month of year (1-12).
+ */
+ sal_uInt16 Month;
+
+ /*----------------------------------------------------------------------*/
+ /** is the year.
+ */
+ sal_uInt16 Year;
+
+} oslDateTime;
+
+
+/** Get the current system time as TimeValue.
+ @return false if any error occurs.
+*/
+sal_Bool SAL_CALL osl_getSystemTime( TimeValue* pTimeVal );
+
+
+/** Get the GMT from a TimeValue and fill a struct oslDateTime
+ @param pTimeVal[in] TimeValue
+ @param pDateTime[out] On success it receives a struct oslDateTime
+
+ @return sal_False if any error occurs else sal_True.
+*/
+sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime* pDateTime );
+
+
+/** Get the GMT from a oslDateTime and fill a TimeValue
+ @param pDateTime[in] oslDateTime
+ @param pTimeVal[out] On success it receives a TimeValue
+
+ @return sal_False if any error occurs else sal_True.
+*/
+sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValue* pTimeVal );
+
+
+/** Convert GMT to local time
+ @param pSystemTimeVal[in] system time to convert
+ @param pLocalTimeVal[out] On success it receives the local time
+
+ @return sal_False if any error occurs else sal_True.
+*/
+sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
+
+
+/** Convert local time to GMT
+ @param pLocalTimeVal[in] local time to convert
+ @param pSystemTimeVal[out] On success it receives the system time
+
+ @return sal_False if any error occurs else sal_True.
+*/
+sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
+
+
+/** Get the value of the global timer
+ @return current timer value in milli seconds
+ */
+
+sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OSL_TIME_H_ */
+
diff --git a/sal/inc/osl/util.h b/sal/inc/osl/util.h
new file mode 100644
index 000000000000..aa988afbbff3
--- /dev/null
+++ b/sal/inc/osl/util.h
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _OSL_UTIL_H_
+#define _OSL_UTIL_H_
+
+#include "sal/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @param pEthernetAddr 6 bytes of memory
+
+ @return sal_True if the ethernetaddress could be retrieved. <br>
+ sal_False if no address could be found. This may be either because
+ there is no ethernet card or there is no appropriate algorithm
+ implemented on the platform. In this case, pEthernetAddr is
+ unchanged.
+*/
+sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 *pEthernetAddr );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sal/inc/pch/precompiled_sal.cxx b/sal/inc/pch/precompiled_sal.cxx
new file mode 100644
index 000000000000..79ca1ead5bab
--- /dev/null
+++ b/sal/inc/pch/precompiled_sal.cxx
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_sal.hxx"
+
diff --git a/sal/inc/pch/precompiled_sal.hxx b/sal/inc/pch/precompiled_sal.hxx
new file mode 100644
index 000000000000..cd20926ac377
--- /dev/null
+++ b/sal/inc/pch/precompiled_sal.hxx
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:56.045599
+
+#ifdef PRECOMPILED_HEADERS
+#endif
+
diff --git a/sal/inc/rtl/alloc.h b/sal/inc/rtl/alloc.h
new file mode 100644
index 000000000000..7b3967de716b
--- /dev/null
+++ b/sal/inc/rtl/alloc.h
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_ALLOC_H_
+#define _RTL_ALLOC_H_
+
+# include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** Allocate memory.
+ @descr A call to this function will return NULL upon the requested
+ memory size being either zero or larger than currently allocatable.
+
+ @param Bytes [in] memory size.
+ @return pointer to allocated memory.
+ */
+void * SAL_CALL rtl_allocateMemory (
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Reallocate memory.
+ @descr A call to this function with parameter 'Ptr' being NULL
+ is equivalent to a rtl_allocateMemory() call.
+
+ A call to this function with parameter 'Bytes' being 0
+ is equivalent to a rtl_freeMemory() call.
+
+ @see rtl_allocateMemory()
+ @see rtl_freeMemory()
+
+ @param Ptr [in] pointer to previously allocated memory.
+ @param Bytes [in] new memory size.
+ @return pointer to reallocated memory. May differ from Ptr.
+ */
+void * SAL_CALL rtl_reallocateMemory (
+ void * Ptr,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Free memory.
+ @param Ptr [in] pointer to previously allocated memory.
+ @return none. Memory is released. Ptr is invalid.
+ */
+void SAL_CALL rtl_freeMemory (
+ void * Ptr
+) SAL_THROW_EXTERN_C();
+
+
+/** Allocate and zero memory.
+ @descr A call to this function will return NULL upon the requested
+ memory size being either zero or larger than currently allocatable.
+
+ @param Bytes [in] memory size.
+ @return pointer to allocated and zero'ed memory.
+ */
+void * SAL_CALL rtl_allocateZeroMemory (
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Zero and free memory.
+ @param Ptr [in] pointer to previously allocated memory.
+ @param Bytes [in] memory size.
+ @return none. Memory is zero'ed and released. Ptr is invalid.
+ */
+void SAL_CALL rtl_freeZeroMemory (
+ void * Ptr,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Opaque rtl_arena_type.
+ */
+typedef struct rtl_arena_st rtl_arena_type;
+
+#define RTL_ARENA_NAME_LENGTH 31
+
+
+/** rtl_arena_create()
+ *
+ * @param pName [in] descriptive name; for debugging purposes.
+ * @param quantum [in] resource allocation unit / granularity; rounded up to next power of 2.
+ * @param quantum_cache_max [in] max resources to cache; rounded up to next multiple of quantum; usually 0.
+ * @param source_arena [in] passed as argument to source_alloc, source_free; usually NULL.
+ * @param source_alloc [in] function to allocate resources; usually rtl_arena_alloc.
+ * @param source_free [in] function to free resources; usually rtl_arena_free.
+ * @param nFlags [in] flags; usually 0.
+ *
+ * @return pointer to rtl_arena_type, or NULL upon failure.
+ *
+ * @see rtl_arena_destroy()
+ */
+rtl_arena_type *
+SAL_CALL rtl_arena_create (
+ const char * pName,
+ sal_Size quantum,
+ sal_Size quantum_cache_max,
+ rtl_arena_type * source_arena,
+ void * (SAL_CALL * source_alloc)(rtl_arena_type *, sal_Size *),
+ void (SAL_CALL * source_free) (rtl_arena_type *, void *, sal_Size),
+ int nFlags
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_arena_destroy()
+ *
+ * @param pArena [in] the arena to destroy.
+ * @return None
+ *
+ * @see rtl_arena_create()
+ */
+void
+SAL_CALL rtl_arena_destroy (
+ rtl_arena_type * pArena
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_arena_alloc()
+ *
+ * @param pArena [in] arena from which resource is allocated.
+ * @param pBytes [inout] size of resource to allocate.
+ *
+ * @return allocated resource, or NULL upon failure.
+ *
+ * @see rtl_arena_free()
+ */
+void *
+SAL_CALL rtl_arena_alloc (
+ rtl_arena_type * pArena,
+ sal_Size * pBytes
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_arena_free()
+ *
+ * @param pArena [in] arena from which resource was allocated.
+ * @param pAddr [in] resource to free.
+ * @param nBytes [in] size of resource.
+ *
+ * @return None.
+ *
+ * @see rtl_arena_alloc()
+ */
+void
+SAL_CALL rtl_arena_free (
+ rtl_arena_type * pArena,
+ void * pAddr,
+ sal_Size nBytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Opaque rtl_cache_type.
+ */
+typedef struct rtl_cache_st rtl_cache_type;
+
+#define RTL_CACHE_NAME_LENGTH 31
+
+#define RTL_CACHE_FLAG_BULKDESTROY 1
+
+/** rtl_cache_create()
+ *
+ * @param pName [in] descriptive name; for debugging purposes.
+ * @param nObjSize [in] object size.
+ * @param nObjAlign [in] object alignment; usually 0 for suitable default.
+ * @param constructor [in] object constructor callback function; returning 1 for success or 0 for failure.
+ * @param destructor [in] object destructor callback function.
+ * @param reclaim [in] reclaim callback function.
+ * @param pUserArg [in] opaque argument passed to callback functions.
+ * @param nFlags [in] flags.
+ *
+ * @return pointer to rtl_cache_type, or NULL upon failure.
+ *
+ * @see rtl_cache_destroy()
+ */
+rtl_cache_type *
+SAL_CALL rtl_cache_create (
+ const char * pName,
+ sal_Size nObjSize,
+ sal_Size nObjAlign,
+ int (SAL_CALL * constructor)(void * pObj, void * pUserArg),
+ void (SAL_CALL * destructor) (void * pObj, void * pUserArg),
+ void (SAL_CALL * reclaim) (void * pUserArg),
+ void * pUserArg,
+ rtl_arena_type * pSource,
+ int nFlags
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_cache_destroy()
+ *
+ * @param pCache [in] the cache to destroy.
+ *
+ * @return None.
+ *
+ * @see rtl_cache_create()
+ */
+void
+SAL_CALL rtl_cache_destroy (
+ rtl_cache_type * pCache
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_cache_alloc()
+ *
+ * @param pCache [in] cache from which object is allocated.
+ *
+ * @return pointer to allocated object, or NULL upon failure.
+ */
+void *
+SAL_CALL rtl_cache_alloc (
+ rtl_cache_type * pCache
+) SAL_THROW_EXTERN_C();
+
+
+/** rtl_cache_free()
+ *
+ * @param pCache [in] cache from which object was allocated.
+ * @param pObj [in] object to free.
+ *
+ * @return None.
+ *
+ * @see rtl_cache_alloc()
+ */
+void
+SAL_CALL rtl_cache_free (
+ rtl_cache_type * pCache,
+ void * pObj
+) SAL_THROW_EXTERN_C();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_RTL_ALLOC_H_ */
+
diff --git a/sal/inc/rtl/allocator.hxx b/sal/inc/rtl/allocator.hxx
new file mode 100644
index 000000000000..c753a98189a3
--- /dev/null
+++ b/sal/inc/rtl/allocator.hxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#if !defined INCLUDED_RTL_ALLOCATOR_HXX
+#define INCLUDED_RTL_ALLOCATOR_HXX
+
+#if ! defined(_SAL_TYPES_H_)
+#include "sal/types.h"
+#endif
+#if ! defined(_RTL_ALLOC_H_)
+#include "rtl/alloc.h"
+#endif
+
+#include <cstddef>
+
+//######################################################
+// This is no general purpose STL allocator but one
+// necessary to use STL for some implementation but
+// avoid linking sal against the STLPort library!!!
+// For more information on when and how to define a
+// custom stl allocator have a look at Scott Meyers:
+// "Effective STL", Nicolai M. Josuttis:
+// "The C++ Standard Library - A Tutorial and Reference"
+// and at http://www.josuttis.com/cppcode/allocator.html
+
+namespace rtl {
+
+/** @internal */
+template<class T>
+class Allocator
+{
+public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef ::std::size_t size_type;
+ typedef ::std::ptrdiff_t difference_type;
+
+ //-----------------------------------------
+ template<class U>
+ struct rebind
+ {
+ typedef Allocator<U> other;
+ };
+
+ //-----------------------------------------
+ pointer address (reference value) const
+ {
+ return &value;
+ }
+
+ //-----------------------------------------
+ const_pointer address (const_reference value) const
+ {
+ return &value;
+ }
+
+ //-----------------------------------------
+ Allocator() SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ template<class U>
+ Allocator (const Allocator<U>&) SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ Allocator(const Allocator&) SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ ~Allocator() SAL_THROW(())
+ {}
+
+ //-----------------------------------------
+ size_type max_size() const SAL_THROW(())
+ {
+ return size_type(-1)/sizeof(T);
+ }
+
+ //-----------------------------------------
+ /* Normally the code for allocate should
+ throw a std::bad_alloc exception if the
+ requested memory could not be allocated:
+ (C++ standard 20.4.1.1):
+
+ pointer allocate (size_type n, const void* hint = 0)
+ {
+ pointer p = reinterpret_cast<pointer>(
+ rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
+
+ if (NULL == p)
+ throw ::std::bad_alloc();
+
+ return p;
+ }
+
+ but some compilers do not compile it if exceptions
+ are not enabled, e.g. GCC under Linux and it is
+ in general not desired to compile sal with exceptions
+ enabled. */
+ pointer allocate (size_type n, const void* hint = 0)
+ {
+ hint = hint; /* avoid warnings */
+ return reinterpret_cast<pointer>(
+ rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
+ }
+
+ //-----------------------------------------
+ void deallocate (pointer p, size_type /* n */)
+ {
+ rtl_freeMemory(p);
+ }
+
+ //-----------------------------------------
+ void construct (pointer p, const T& value)
+ {
+ new ((void*)p)T(value);
+ }
+
+ //-----------------------------------------
+ void destroy (pointer p)
+ {
+ p->~T();
+ }
+};
+
+//######################################################
+// Custom STL allocators must be stateless (see
+// references above) that's why the operators below
+// return always true or false
+
+/** @internal */
+template<class T, class U>
+inline bool operator== (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
+{
+ return true;
+}
+
+/** @internal */
+template<class T, class U>
+inline bool operator!= (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
+{
+ return false;
+}
+
+} /* namespace rtl */
+
+//######################################################
+/** REQUIRED BY STLPort (see stlport '_alloc.h'):
+ Hack for compilers that do not support member
+ template classes (e.g. MSVC 6)
+
+ @internal
+*/
+namespace _STL
+{
+ /** @internal */
+ template<class T, class U>
+ inline ::rtl::Allocator<U> & __stl_alloc_rebind (::rtl::Allocator<T> & a, U const *)
+ {
+ return (::rtl::Allocator<U>&)(a);
+ }
+}
+
+#endif /* INCLUDED_RTL_ALLOCATOR_HXX */
+
diff --git a/sal/inc/rtl/bootstrap.h b/sal/inc/rtl/bootstrap.h
new file mode 100644
index 000000000000..1c33c45b1fa1
--- /dev/null
+++ b/sal/inc/rtl/bootstrap.h
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_BOOTSTRAP_H_
+#define _RTL_BOOTSTRAP_H_
+
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ @HTML
+ @file
+
+ The described concept provides a platform independent way to access
+ minimum bootstrap settings for every application by excplitly or
+ implicitly passing the values to the application.<p>
+
+ MULTI-LEVEL STRATEGY FOR RETRIEVAL OF BOOTSTRAP VALUES :<p>
+
+ The 1st level is tried first. On failure,
+ the next level is tried. Every query starts at the first level again, so
+ that one setting may be taken from the 3rd and one from the 1st level.<p>
+
+ 1st level: explicitly set variables via rtl_bootstrap_set()
+
+ 2nd level: command line arguments. A "-env:SETTINGNAME=value" is given on
+ command line. This allows to give an application a certain setting, even
+ if an ini-file exists (espicially useful for e.g. daemons that want to
+ start an executable with dynamical changing settings).<p>
+
+ 3rd level: environment variables. The application tries to get the
+ setting from the environment.<p>
+
+ 4th level: executable ini-file. Every application looks for an ini-file.
+ The filename defaults to /absoulte/path/to/executable[rc|.ini]
+ (without .bin or .exe suffix). The ini-filename can be
+ set by the special command line parameter
+ '-env:INIFILENAME=/absolute/path/to/inifile' at runtime or it may
+ be set at compiletime by an API-call.<p>
+
+ 5th level: URE_BOOTSTRAP ini-file. If the bootstrap variable URE_BOOTSTRAP
+ expands to the URL of an ini-file, that ini-file is searched.<p>
+
+ 6th level: default. An application can have some default settings decided
+ at compile time, which allow the application to run even with no
+ deployment settings. <p>
+
+ If neither of the above levels leads to an successful retrieval of the value
+ (no default possible), the application may fail to start.<p>
+
+ NAMING CONVENTIONS <p>
+
+ Naming conventions for names of bootstrap values :
+ Names may only include characters, that are allowed charcters for
+ environment variables. This excludes '.', ' ', ';', ':' and any non-ascii
+ character. Names are case insensitive.<p>
+
+ An ini-file is only allowed to have one section, which must be named '[Bootstrap]'.
+ The section may be omitted.
+ The section name does not appear in the name of the corresponding
+ environment variable or commandline arg.
+ Values maybe arbitrary unicode strings, they must be encoded in UTF8.<p>
+
+ Example:<p>
+
+ in an ini-file:
+ <code>
+ [Sectionname]
+ Name=value
+ </code><p>
+
+ as commandline arg:
+ <code>-env:Name=value</code><p>
+
+ as environment
+ <code>
+ setenv Name value
+ set Name=value
+ </code><p>
+
+ SPECIAL VARIABLES:
+
+ <ul>
+ <li> INIFILENAME<br>
+ This variable allows to set the inifilename. This makes only sense, if the filename
+ is different than the executable file name. It must be given on command line. If it is
+ given the executable ini-file is ignored.
+ </li>
+*/
+
+/** may be called by an application to set an ini-filename.
+
+ <p>
+ Must be called before rtl_bootstrap_get(). May not be called twice.
+ If it is never called, a the filename executable.ini (win)
+ or execuablerc (unx) is assumed.
+
+ @param pName Name of the inifile with path but WITHOUT
+ suffix (.ini or rc)
+*/
+void SAL_CALL rtl_bootstrap_setIniFileName( rtl_uString *pName )
+ SAL_THROW_EXTERN_C();
+
+/**
+ @param ppValue
+ out parameter. Contains always a valid rtl_uString pointer.
+ @param pName
+ The name of the bootstrap setting to be retrieved.
+ @param pDefault
+ maybe NULL. If once the default is
+ returned, successive calls always return this
+ default value, even when called with different
+ defaults.
+
+ @return <code>sal_True</code>, when a value could be retrieved successfully,
+ <code>sal_False</code>, when none of the 4 methods gave a value. ppValue
+ then contains ane empty string.
+ When a pDefault value is given, the function returns always
+ <code>sal_True</code>.
+*/
+sal_Bool SAL_CALL rtl_bootstrap_get( rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault )
+ SAL_THROW_EXTERN_C();
+
+/** Sets a bootstrap parameter.
+
+ @param pName
+ name of bootstrap parameter
+ @param pValue
+ value of bootstrap parameter
+*/
+void SAL_CALL rtl_bootstrap_set( rtl_uString * pName, rtl_uString * pValue )
+ SAL_THROW_EXTERN_C();
+
+
+typedef void * rtlBootstrapHandle;
+
+/**
+ Opens a bootstrap argument container.
+ @param pIniName [in] The name of the ini-file to use, if <code>NULL</code> defaults
+ to the excutables name
+ @return Handle for a boostrap argument container
+*/
+rtlBootstrapHandle SAL_CALL rtl_bootstrap_args_open(rtl_uString * pIniName)
+ SAL_THROW_EXTERN_C();
+
+/**
+ Closes a boostrap agument container.
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+*/
+void SAL_CALL rtl_bootstrap_args_close(rtlBootstrapHandle handle)
+ SAL_THROW_EXTERN_C();
+
+/**
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+ @param pName [in] The name of the variable to be retrieved
+ @param ppValue [out] The result of the retrieval. *ppValue may be null in case of failure.
+ @param pDefault [in] The default value for the retrieval, may be <code>NULL</code>
+
+ @return The status of the retrieval, <code>sal_True</code> on success.
+*/
+sal_Bool SAL_CALL rtl_bootstrap_get_from_handle(rtlBootstrapHandle handle, rtl_uString *pName, rtl_uString **ppValue, rtl_uString *pDefault)
+ SAL_THROW_EXTERN_C();
+
+
+/** Returns the name of the inifile associated with this handle.
+
+ @param ppIniName contains after the call the name of the ini-filename.
+*/
+void SAL_CALL rtl_bootstrap_get_iniName_from_handle(rtlBootstrapHandle handle, rtl_uString ** ppIniName)
+ SAL_THROW_EXTERN_C();
+
+/** Expands a macro using bootstrap variables.
+
+ @param handle [in] The handle got by <code>rtl_bootstrap_args_open()</code>
+ @param macro [inout] The macro to be expanded
+*/
+void SAL_CALL rtl_bootstrap_expandMacros_from_handle(
+ rtlBootstrapHandle handle, rtl_uString ** macro )
+ SAL_THROW_EXTERN_C();
+/** Expands a macro using default bootstrap variables.
+
+ @param macro [inout] The macro to be expanded
+*/
+void SAL_CALL rtl_bootstrap_expandMacros(
+ rtl_uString ** macro )
+ SAL_THROW_EXTERN_C();
+
+/** Escapes special characters ("$" and "\").
+
+ @param value
+ an arbitrary, non-NULL value
+
+ @param encoded
+ non-NULL out parameter, receiving the given value with all occurences of
+ special characters ("$" and "\") escaped
+
+ @since UDK 3.2.9
+*/
+void SAL_CALL rtl_bootstrap_encode(
+ rtl_uString const * value, rtl_uString ** encoded )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sal/inc/rtl/bootstrap.hxx b/sal/inc/rtl/bootstrap.hxx
new file mode 100644
index 000000000000..f8f1f7a95f48
--- /dev/null
+++ b/sal/inc/rtl/bootstrap.hxx
@@ -0,0 +1,234 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_BOOTSTRAP_HXX_
+#define _RTL_BOOTSTRAP_HXX_
+#include <rtl/ustring.hxx>
+#include <rtl/bootstrap.h>
+
+namespace rtl
+{
+ class Bootstrap
+ {
+ void * _handle;
+
+ /** @internal */
+ inline Bootstrap( Bootstrap const & ); // not impl
+ /** @internal */
+ inline Bootstrap & operator = ( Bootstrap const & ); // not impl
+
+ public:
+ /**
+ @see rtl_bootstrap_setIniFileName()
+ */
+ static inline void SAL_CALL setIniFilename( const ::rtl::OUString &sFile );
+
+ /** Retrieves a bootstrap parameter
+ @param sName name of the bootstrap value. case insensitive.
+ @param outValue (out parameter). On success contains the value, otherwise
+ an empty string.
+ @return sal_False, if no value could be retrieved, otherwise sal_True
+ @see rtl_bootstrap_get()
+ */
+ static inline sal_Bool get(
+ const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue );
+
+ /** Retrieves a bootstrap parameter
+
+ @param sName name of the bootstrap value. case insensitive.
+ @param outValue (out parameter). Contains the value associated with sName.
+ @param aDefault if none of the other methods retrieved a value, outValue
+ is assigned to a Default.
+
+ @see rtl_bootstrap_get()
+ */
+ static inline void get(
+ const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue,
+ const ::rtl::OUString &aDefault );
+
+ /** Sets a bootstrap parameter.
+
+ @param pName
+ name of bootstrap parameter
+ @param pValue
+ value of bootstrap parameter
+
+ @see rtl_bootstrap_set()
+ */
+ static inline void set( ::rtl::OUString const & name, ::rtl::OUString const & value )
+ SAL_THROW( () );
+
+ /** default ctor.
+ */
+ inline Bootstrap();
+
+ /** Opens a bootstrap argment container
+ @see rtl_bootstrap_args_open()
+ */
+ inline Bootstrap(const OUString & iniName);
+
+ /** Closes a bootstrap argument container
+ @see rtl_bootstrap_args_close()
+ */
+ inline ~Bootstrap();
+
+ /** Retrieves a bootstrap argument.
+
+ It is first tried to retrieve the value via the global function
+ and second via the special bootstrap container.
+ @see rtl_bootstrap_get_from_handle()
+ */
+
+ inline sal_Bool getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue) const;
+
+ /** Retrieves a bootstrap argument.
+
+ It is first tried to retrieve the value via the global function
+ and second via the special bootstrap container.
+ @see rtl_bootstrap_get_from_handle()
+ */
+ inline void getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue,
+ const ::rtl::OUString &aDefault) const;
+
+ /** Retrieves the name of the underlying ini-file.
+ @see rtl_bootstrap_get_iniName_from_handle()
+ */
+ inline void getIniName(::rtl::OUString & iniName) const;
+
+ /** Expands a macro using bootstrap variables.
+
+ @param macro [inout] The macro to be expanded
+ */
+ inline void expandMacrosFrom( ::rtl::OUString & macro ) const SAL_THROW( () )
+ { rtl_bootstrap_expandMacros_from_handle( _handle, &macro.pData ); }
+
+ /** Expands a macro using default bootstrap variables.
+
+ @param macro [inout] The macro to be expanded
+ */
+ static inline void expandMacros( ::rtl::OUString & macro ) SAL_THROW( () )
+ { rtl_bootstrap_expandMacros( &macro.pData ); }
+
+ /** Provides the bootstrap internal handle.
+
+ @return bootstrap handle
+ */
+ inline rtlBootstrapHandle getHandle() const SAL_THROW( () )
+ { return _handle; }
+
+ /** Escapes special characters ("$" and "\").
+
+ @param value
+ an arbitrary value
+
+ @return
+ the given value, with all occurences of special characters ("$" and
+ "\") escaped
+
+ @since UDK 3.2.9
+ */
+ static inline ::rtl::OUString encode( ::rtl::OUString const & value )
+ SAL_THROW( () );
+ };
+
+ //----------------------------------------------------------------------------
+ // IMPLEMENTATION
+ //----------------------------------------------------------------------------
+ inline void Bootstrap::setIniFilename( const ::rtl::OUString &sFile )
+ {
+ rtl_bootstrap_setIniFileName( sFile.pData );
+ }
+
+ inline sal_Bool Bootstrap::get( const ::rtl::OUString &sName,
+ ::rtl::OUString & outValue )
+ {
+ return rtl_bootstrap_get( sName.pData , &(outValue.pData) , 0 );
+ }
+
+ inline void Bootstrap::get( const ::rtl::OUString &sName,
+ ::rtl::OUString & outValue,
+ const ::rtl::OUString & sDefault )
+ {
+ rtl_bootstrap_get( sName.pData , &(outValue.pData) , sDefault.pData );
+ }
+
+ inline void Bootstrap::set( ::rtl::OUString const & name, ::rtl::OUString const & value )
+ SAL_THROW( () )
+ {
+ rtl_bootstrap_set( name.pData, value.pData );
+ }
+
+ inline Bootstrap::Bootstrap()
+ {
+ _handle = 0;
+ }
+
+ inline Bootstrap::Bootstrap(const OUString & iniName)
+ {
+ if(iniName.getLength())
+ _handle = rtl_bootstrap_args_open(iniName.pData);
+
+ else
+ _handle = 0;
+ }
+
+ inline Bootstrap::~Bootstrap()
+ {
+ rtl_bootstrap_args_close(_handle);
+ }
+
+
+ inline sal_Bool Bootstrap::getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue) const
+ {
+ return rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, 0);
+ }
+
+ inline void Bootstrap::getFrom(const ::rtl::OUString &sName,
+ ::rtl::OUString &outValue,
+ const ::rtl::OUString &aDefault) const
+ {
+ rtl_bootstrap_get_from_handle(_handle, sName.pData, &outValue.pData, aDefault.pData);
+ }
+
+ inline void Bootstrap::getIniName(::rtl::OUString & iniName) const
+ {
+ rtl_bootstrap_get_iniName_from_handle(_handle, &iniName.pData);
+ }
+
+ inline ::rtl::OUString Bootstrap::encode( ::rtl::OUString const & value )
+ SAL_THROW( () )
+ {
+ ::rtl::OUString encoded;
+ rtl_bootstrap_encode(value.pData, &encoded.pData);
+ return encoded;
+ }
+}
+#endif
diff --git a/sal/inc/rtl/byteseq.h b/sal/inc/rtl/byteseq.h
new file mode 100644
index 000000000000..3c0b6862b70b
--- /dev/null
+++ b/sal/inc/rtl/byteseq.h
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_BYTESEQ_H_
+#define _RTL_BYTESEQ_H_
+
+#include <sal/types.h>
+#include <rtl/alloc.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** Assures that the reference count of the given byte sequence is one. Otherwise a new copy
+ of the sequence is created with a reference count of one.
+
+ @param ppSequence sequence
+*/
+void SAL_CALL rtl_byte_sequence_reference2One(
+ sal_Sequence ** ppSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Reallocates length of byte sequence.
+
+ @param ppSequence sequence
+ @param nSize new size of sequence
+*/
+void SAL_CALL rtl_byte_sequence_realloc(
+ sal_Sequence ** ppSequence, sal_Int32 nSize )
+ SAL_THROW_EXTERN_C();
+
+/** Acquires the byte sequence
+
+ @param pSequence sequence, that is to be acquired
+*/
+void SAL_CALL rtl_byte_sequence_acquire(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Releases the byte sequence. If the refcount drops to zero, the sequence is freed.
+
+ @param pSequence sequence, that is to be released; invalid after call
+*/
+void SAL_CALL rtl_byte_sequence_release(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a bytes sequence with length nLength. All bytes are set to zero.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence contains the newly constructed sequence
+ @param nLength length of new sequence
+*/
+void SAL_CALL rtl_byte_sequence_construct(
+ sal_Sequence **ppSequence , sal_Int32 nLength )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a bytes sequence with length nLength. The data is not initialized.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence contains the newly constructed sequence
+ @param nLength length of new sequence
+*/
+void SAL_CALL rtl_byte_sequence_constructNoDefault(
+ sal_Sequence **ppSequence , sal_Int32 nLength )
+ SAL_THROW_EXTERN_C();
+
+/** Constructs a byte sequence with length nLength and copies nLength bytes from pData.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence contains the newly constructed sequence
+ @param pData initial data
+ @param nLength length of new sequence
+*/
+void SAL_CALL rtl_byte_sequence_constructFromArray(
+ sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength )
+ SAL_THROW_EXTERN_C();
+
+/** Assigns the byte sequence pSequence to *ppSequence.
+
+ @param ppSequence inout sequence; on entry *ppSequence may be null, otherwise it is released;
+ after the call, *ppSequence references pSequence
+ @param pSequence the source sequence
+*/
+void SAL_CALL rtl_byte_sequence_assign(
+ sal_Sequence **ppSequence , sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Compares two byte sequences.
+
+ @return true, if the data within the sequences are identical; false otherwise
+*/
+sal_Bool SAL_CALL rtl_byte_sequence_equals(
+ sal_Sequence *pSequence1 , sal_Sequence *pSequence2 )
+ SAL_THROW_EXTERN_C();
+
+/** Returns the data array pointer of the sequence.
+
+ @return read-pointer to the data array of the sequence. If rtl_byte_sequence_reference2One()
+ has been called before, the pointer may be casted to a non const pointer and
+ the sequence may be modified
+*/
+const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+/** Returns the length of the sequence
+
+ @param pSequence sequence handle
+ @return length of the sequence
+*/
+sal_Int32 SAL_CALL rtl_byte_sequence_getLength(
+ sal_Sequence *pSequence )
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+namespace rtl
+{
+
+enum __ByteSequence_NoDefault
+{
+ /** This enum value can be used to create a bytesequence with uninitalized data
+ */
+ BYTESEQ_NODEFAULT = 0xcafe
+};
+
+enum __ByteSequence_NoAcquire
+{
+ /** This enum value can be used to create a bytesequence from a C-Handle without
+ acquiring the handle.
+ */
+ BYTESEQ_NOACQUIRE = 0xcafebabe
+};
+
+/** C++ class representing a SAL byte sequence.
+ C++ Sequences are reference counted and shared, so the sequence keeps a handle to its data.
+ To keep value semantics, copies are only generated if the sequence is to be modified
+ (new handle).
+*/
+class ByteSequence
+{
+ /** sequence handle
+ @internal
+ */
+ sal_Sequence * _pSequence;
+
+public:
+ // these are here to force memory de/allocation to sal lib.
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ /** @internal */
+ inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ /** @internal */
+ inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW( () )
+ {}
+
+ /** Default constructor: Creates an empty sequence.
+ */
+ inline ByteSequence() SAL_THROW( () );
+ /** Copy constructor: Creates a copy of given sequence.
+
+ @param rSeq another byte sequence
+ */
+ inline ByteSequence( const ByteSequence & rSeq ) SAL_THROW( () );
+ /** Copy constructor Creates a copy from the C-Handle.
+
+ @param pSequence another byte sequence handle
+ */
+ inline ByteSequence( sal_Sequence *pSequence ) SAL_THROW( () );
+ /** Constructor: Creates a copy of given data bytes.
+
+ @param pElements an array of bytes
+ @param len number of bytes
+ */
+ inline ByteSequence( const sal_Int8 * pElements, sal_Int32 len );
+ /** Constructor: Creates sequence of given length and initializes all bytes to 0.
+
+ @param len initial sequence length
+ */
+ inline ByteSequence( sal_Int32 len );
+ /** Constructor: Creates sequence of given length and does NOT initialize data.
+ Use this ctor for performance optimization only.
+
+ @param len initial sequence length
+ @param nodefault dummy parameter forcing explicit BYTESEQ_NODEFAULT
+ */
+ inline ByteSequence( sal_Int32 len , enum __ByteSequence_NoDefault nodefault );
+ /** Constructor:
+ Creates a sequence from a C-Handle without acquiring the handle, thus taking
+ over owenership. Eitherway the handle is release by the destructor.
+ This ctor is useful, when working with a c-interface (it safes a pair of
+ acquire and release call and is thus a performance optimization only).
+
+ @param pSequence sequence handle to be taken over
+ @param noacquire dummy parameter forcing explicit BYTESEQ_NOACQUIRE
+ */
+ inline ByteSequence( sal_Sequence *pSequence , enum __ByteSequence_NoAcquire noacquire ) SAL_THROW( () );
+ /** Destructor: Releases sequence handle. Last handle will free memory.
+ */
+ inline ~ByteSequence() SAL_THROW( () );
+
+ /** Assignment operator: Acquires given sequence handle and releases a previously set handle.
+
+ @param rSeq another byte sequence
+ @return this sequence
+ */
+ inline ByteSequence & SAL_CALL operator = ( const ByteSequence & rSeq ) SAL_THROW( () );
+
+ /** Gets the length of sequence.
+
+ @return length of sequence
+ */
+ inline sal_Int32 SAL_CALL getLength() const SAL_THROW( () )
+ { return _pSequence->nElements; }
+
+ /** Gets a pointer to byte array for READING. If the sequence has a length of 0, then the
+ returned pointer is undefined.
+
+ @return pointer to byte array
+ */
+ inline const sal_Int8 * SAL_CALL getConstArray() const SAL_THROW( () )
+ { return (const sal_Int8 *)_pSequence->elements; }
+ /** Gets a pointer to elements array for READING AND WRITING. In general if the sequence
+ has a handle acquired by other sequences (reference count > 1), then a new sequence is
+ created copying all bytes to keep value semantics!
+ If the sequence has a length of 0, then the returned pointer is undefined.
+
+ @return pointer to elements array
+ */
+ inline sal_Int8 * SAL_CALL getArray();
+
+ /** Non-const index operator:
+ Obtains a reference to byte indexed at given position.
+ In general if the sequence has a handle acquired by other
+ sequences (reference count > 1), then a new sequence is created
+ copying all bytes to keep value semantics!
+
+ @attention
+ The implementation does NOT check for array bounds!
+
+ @param nIndex index
+ @return non-const C++ reference to element at index nIndex
+ */
+ inline sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex );
+
+ /** Const index operator: Obtains a reference to byte indexed at given position.
+ The implementation does NOT check for array bounds!
+
+ @param nIndex index
+ @return const C++ reference to byte at element of indenx nIndex
+ */
+ inline const sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex ) const SAL_THROW( () )
+ { return getConstArray()[ nIndex ]; }
+
+ /** Equality operator: Compares two sequences.
+
+ @param rSeq another byte sequence (right side)
+ @return true if both sequences are equal, false otherwise
+ */
+ inline sal_Bool SAL_CALL operator == ( const ByteSequence & rSeq ) const SAL_THROW( () );
+ /** Unequality operator: Compares two sequences.
+
+ @param rSeq another byte sequence (right side)
+ @return false if both sequences are equal, true otherwise
+ */
+ inline sal_Bool SAL_CALL operator != ( const ByteSequence & rSeq ) const SAL_THROW( () );
+
+ /** Reallocates sequence to new length. If the sequence has a handle acquired by other sequences
+ (reference count > 1), then the remaining elements are copied to a new sequence handle to
+ keep value semantics!
+
+ @param nSize new size of sequence
+ */
+ inline void SAL_CALL realloc( sal_Int32 nSize );
+
+ /** Returns the UNnacquired C handle of the sequence
+
+ @return UNacquired handle of the sequence
+ */
+ inline sal_Sequence * SAL_CALL getHandle() const SAL_THROW( () )
+ { return _pSequence; }
+ /** Returns the UNnacquired C handle of the sequence (for compatibility reasons)
+
+ @return UNacquired handle of the sequence
+ */
+ inline sal_Sequence * SAL_CALL get() const SAL_THROW( () )
+ { return _pSequence; }
+};
+
+}
+#endif
+#endif
diff --git a/sal/inc/rtl/byteseq.hxx b/sal/inc/rtl/byteseq.hxx
new file mode 100644
index 000000000000..698e4f01df05
--- /dev/null
+++ b/sal/inc/rtl/byteseq.hxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_BYTESEQ_HXX_
+#define _RTL_BYTESEQ_HXX_
+
+#include <osl/interlck.h>
+#include <rtl/byteseq.h>
+#include <rtl/alloc.h>
+#include <rtl/memory.h>
+
+#if ! defined EXCEPTIONS_OFF
+#include <new>
+#endif
+
+
+namespace rtl
+{
+
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence() SAL_THROW( () )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_construct( &_pSequence, 0 );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW( () )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW( () )
+ : _pSequence( pSequence )
+{
+ ::rtl_byte_sequence_acquire( pSequence );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW( () )
+ : _pSequence( pSequence )
+{
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::ByteSequence( sal_Int32 len )
+ : _pSequence( 0 )
+{
+ ::rtl_byte_sequence_construct( &_pSequence, len );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline ByteSequence::~ByteSequence() SAL_THROW( () )
+{
+ ::rtl_byte_sequence_release( _pSequence );
+}
+//__________________________________________________________________________________________________
+inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW( () )
+{
+ ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
+ return *this;
+}
+//__________________________________________________________________________________________________
+inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW( () )
+{
+ return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
+}
+//__________________________________________________________________________________________________
+inline sal_Int8 * ByteSequence::getArray()
+{
+ ::rtl_byte_sequence_reference2One( &_pSequence );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+ return (sal_Int8 *)_pSequence->elements;
+}
+//__________________________________________________________________________________________________
+inline void ByteSequence::realloc( sal_Int32 nSize )
+{
+ ::rtl_byte_sequence_realloc( &_pSequence, nSize );
+#if ! defined EXCEPTIONS_OFF
+ if (_pSequence == 0)
+ throw ::std::bad_alloc();
+#endif
+}
+//__________________________________________________________________________________________________
+inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
+{
+ return getArray()[ nIndex ];
+}
+//__________________________________________________________________________________________________
+inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW( () )
+{
+ return (! operator == ( rSeq ));
+}
+
+}
+#endif
diff --git a/sal/inc/rtl/cipher.h b/sal/inc/rtl/cipher.h
new file mode 100644
index 000000000000..8cb2a2f2256b
--- /dev/null
+++ b/sal/inc/rtl/cipher.h
@@ -0,0 +1,319 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_CIPHER_H_
+#define _RTL_CIPHER_H_ "$Revision: 1.7 $"
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtlCipher interface.
+ *
+ *======================================================================*/
+/** Cipher Handle opaque type.
+ */
+typedef void* rtlCipher;
+
+
+/** Cipher Algorithm enumeration.
+ @see rtl_cipher_create()
+ */
+enum __rtl_CipherAlgorithm
+{
+ rtl_Cipher_AlgorithmBF,
+ rtl_Cipher_AlgorithmARCFOUR,
+ rtl_Cipher_AlgorithmInvalid,
+ rtl_Cipher_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Cipher Algorithm type.
+ */
+typedef enum __rtl_CipherAlgorithm rtlCipherAlgorithm;
+
+
+/** Cipher Mode enumeration.
+ @see rtl_cipher_create()
+ */
+enum __rtl_CipherMode
+{
+ rtl_Cipher_ModeECB,
+ rtl_Cipher_ModeCBC,
+ rtl_Cipher_ModeStream,
+ rtl_Cipher_ModeInvalid,
+ rtl_Cipher_Mode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Cipher Mode type.
+ */
+typedef enum __rtl_CipherMode rtlCipherMode;
+
+
+/** Cipher Direction enumeration.
+ @see rtl_cipher_init()
+ */
+enum __rtl_CipherDirection
+{
+ rtl_Cipher_DirectionBoth,
+ rtl_Cipher_DirectionDecode,
+ rtl_Cipher_DirectionEncode,
+ rtl_Cipher_DirectionInvalid,
+ rtl_Cipher_Direction_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Cipher Direction type.
+ */
+typedef enum __rtl_CipherDirection rtlCipherDirection;
+
+
+/** Error Code enumeration.
+ */
+enum __rtl_CipherError
+{
+ rtl_Cipher_E_None,
+ rtl_Cipher_E_Argument,
+ rtl_Cipher_E_Algorithm,
+ rtl_Cipher_E_Direction,
+ rtl_Cipher_E_Mode,
+ rtl_Cipher_E_BufferSize,
+ rtl_Cipher_E_Memory,
+ rtl_Cipher_E_Unknown,
+ rtl_Cipher_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Error Code type.
+ */
+typedef enum __rtl_CipherError rtlCipherError;
+
+
+/** Create a cipher handle for the given algorithm and mode.
+ @see rtlCipherAlgorithm
+ @see rtlCipherMode
+
+ @param Algorithm [in] cipher algorithm.
+ @param Mode [in] cipher mode.
+ @return Cipher handle, or 0 upon failure.
+ */
+rtlCipher SAL_CALL rtl_cipher_create (
+ rtlCipherAlgorithm Algorithm,
+ rtlCipherMode Mode
+) SAL_THROW_EXTERN_C();
+
+
+/** Inititialize a cipher for the given direction.
+ @see rtlCipherDirection
+
+ @param Cipher [in] cipher handle.
+ @param Direction [in] cipher direction.
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length in bytes.
+ @param pArgData [in] initialization vector buffer.
+ @param nArgLen [in] initialization vector length in bytes.
+ @return rtl_Cipher_E_None upon success.
+ */
+rtlCipherError SAL_CALL rtl_cipher_init (
+ rtlCipher Cipher,
+ rtlCipherDirection Direction,
+ const sal_uInt8 *pKeyData, sal_Size nKeyLen,
+ const sal_uInt8 *pArgData, sal_Size nArgLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Encode a buffer under a given cipher algorithm.
+ @precond Initialized for a compatible cipher direction.
+ @see rtl_cipher_init()
+
+ @param Cipher [in] cipher handle.
+ @param pData [in] plaintext buffer.
+ @param nDatLen [in] plaintext length in bytes.
+ @param pBuffer [out] ciphertext buffer.
+ @param nBufLen [in] ciphertext length in bytes.
+ @return rtl_Cipher_E_None upon success.
+ */
+rtlCipherError SAL_CALL rtl_cipher_encode (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Decode a buffer under a given cipher algorithm.
+ @precond Initialized for a compatible cipher direction.
+ @see rtl_cipher_init()
+
+ @param Cipher [in] cipher handle.
+ @param pData [in] ciphertext buffer.
+ @param nDatLen [in] ciphertext length in bytes.
+ @param pBuffer [out] plaintext buffer.
+ @param nBufLen [in] plaintext length in bytes.
+ @return rtl_Cipher_E_None upon success.
+ */
+rtlCipherError SAL_CALL rtl_cipher_decode (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a cipher handle.
+ @param Cipher [in] cipher handle to be destroyed.
+ @return None. Cipher handle destroyed and invalid.
+ */
+void SAL_CALL rtl_cipher_destroy (
+ rtlCipher Cipher
+) SAL_THROW_EXTERN_C();
+
+
+/*========================================================================
+ *
+ * rtl_cipherBF (Blowfish) interface.
+ *
+ *======================================================================*/
+/** Create a Blowfish cipher handle for the given mode.
+ @descr The Blowfish block cipher algorithm is specified in
+ Bruce Schneier: Applied Cryptography, 2nd edition, ch. 14.3
+
+ @see rtl_cipher_create()
+ */
+rtlCipher SAL_CALL rtl_cipher_createBF (
+ rtlCipherMode Mode
+) SAL_THROW_EXTERN_C();
+
+
+/** Inititialize a Blowfish cipher for the given direction.
+ @see rtl_cipher_init()
+ */
+rtlCipherError SAL_CALL rtl_cipher_initBF (
+ rtlCipher Cipher,
+ rtlCipherDirection Direction,
+ const sal_uInt8 *pKeyData, sal_Size nKeyLen,
+ const sal_uInt8 *pArgData, sal_Size nArgLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Encode a buffer under the Blowfish cipher algorithm.
+ @see rtl_cipher_encode()
+ */
+rtlCipherError SAL_CALL rtl_cipher_encodeBF (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Decode a buffer under the Blowfish cipher algorithm.
+ @see rtl_cipher_decode()
+ */
+rtlCipherError SAL_CALL rtl_cipher_decodeBF (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a Blowfish cipher handle.
+ @see rtl_cipher_destroy()
+ */
+void SAL_CALL rtl_cipher_destroyBF (
+ rtlCipher Cipher
+) SAL_THROW_EXTERN_C();
+
+
+/*========================================================================
+ *
+ * rtl_cipherARCFOUR (RC4) interface.
+ *
+ *======================================================================*/
+/** Create a RC4 cipher handle for the given mode.
+ @descr The RC4 symmetric stream cipher algorithm is specified in
+ Bruce Schneier: Applied Cryptography, 2nd edition, ch. 17.1
+
+ @see rtl_cipher_create()
+
+ @param Mode [in] cipher mode. Must be rtl_Cipher_ModeStream.
+ @return Cipher handle, or 0 upon failure.
+ */
+rtlCipher SAL_CALL rtl_cipher_createARCFOUR (
+ rtlCipherMode Mode
+) SAL_THROW_EXTERN_C();
+
+
+/** Inititialize a RC4 cipher for the given direction.
+ @see rtl_cipher_init()
+ */
+rtlCipherError SAL_CALL rtl_cipher_initARCFOUR (
+ rtlCipher Cipher,
+ rtlCipherDirection Direction,
+ const sal_uInt8 *pKeyData, sal_Size nKeyLen,
+ const sal_uInt8 *pArgData, sal_Size nArgLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Encode a buffer under the RC4 cipher algorithm.
+ @see rtl_cipher_encode()
+ */
+rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Decode a buffer under the RC4 cipher algorithm.
+ @see rtl_cipher_decode()
+ */
+rtlCipherError SAL_CALL rtl_cipher_decodeARCFOUR (
+ rtlCipher Cipher,
+ const void *pData, sal_Size nDatLen,
+ sal_uInt8 *pBuffer, sal_Size nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a RC4 cipher handle.
+ @see rtl_cipher_destroy()
+ */
+void SAL_CALL rtl_cipher_destroyARCFOUR (
+ rtlCipher Cipher
+) SAL_THROW_EXTERN_C();
+
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_RTL_CIPHER_H_ */
+
diff --git a/sal/inc/rtl/crc.h b/sal/inc/rtl/crc.h
new file mode 100644
index 000000000000..f30a873c67f2
--- /dev/null
+++ b/sal/inc/rtl/crc.h
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_CRC_H_
+#define _RTL_CRC_H_ "$Revision: 1.4 $"
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtl_crc32 interface.
+ *
+ *======================================================================*/
+/** Evaluate CRC32 over given data.
+ @descr This function evaluates the CRC polynomial 0xEDB88320.
+
+ @param Crc [in] CRC32 over previous data or zero.
+ @param Data [in] data buffer.
+ @param DatLen [in] data buffer length.
+ @return new CRC32 value.
+ */
+sal_uInt32 SAL_CALL rtl_crc32 (
+ sal_uInt32 Crc,
+ const void *Data, sal_uInt32 DatLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_CRC_H_ */
+
diff --git a/sal/inc/rtl/digest.h b/sal/inc/rtl/digest.h
new file mode 100644
index 000000000000..c0e3a346b90b
--- /dev/null
+++ b/sal/inc/rtl/digest.h
@@ -0,0 +1,639 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_DIGEST_H_
+#define _RTL_DIGEST_H_ "$Revision: 1.8 $"
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtlDigest.
+ *
+ *======================================================================*/
+/** Digest Handle opaque type.
+ */
+typedef void* rtlDigest;
+
+
+/** Digest Algorithm enumeration.
+ @see rtl_digest_create()
+ */
+enum __rtl_DigestAlgorithm
+{
+ rtl_Digest_AlgorithmMD2,
+ rtl_Digest_AlgorithmMD5,
+ rtl_Digest_AlgorithmSHA,
+ rtl_Digest_AlgorithmSHA1,
+
+ rtl_Digest_AlgorithmHMAC_MD5,
+ rtl_Digest_AlgorithmHMAC_SHA1,
+
+ rtl_Digest_AlgorithmInvalid,
+ rtl_Digest_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Digest Algorithm type.
+ */
+typedef enum __rtl_DigestAlgorithm rtlDigestAlgorithm;
+
+
+/** Error Code enumeration.
+ */
+enum __rtl_DigestError
+{
+ rtl_Digest_E_None,
+ rtl_Digest_E_Argument,
+ rtl_Digest_E_Algorithm,
+ rtl_Digest_E_BufferSize,
+ rtl_Digest_E_Memory,
+ rtl_Digest_E_Unknown,
+ rtl_Digest_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Error Code type.
+ */
+typedef enum __rtl_DigestError rtlDigestError;
+
+
+/** Create a digest handle for the given algorithm.
+ @see rtlDigestAlgorithm
+
+ @param Algorithm [in] digest algorithm.
+ @return Digest handle, or 0 upon failure.
+ */
+rtlDigest SAL_CALL rtl_digest_create (
+ rtlDigestAlgorithm Algorithm
+) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a digest handle.
+ @postcond Digest handle destroyed and invalid.
+ @param Digest [in] digest handle to be destroyed.
+ @return None.
+ */
+void SAL_CALL rtl_digest_destroy (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Query the algorithm of a given digest.
+ @param Digest [in] digest handle.
+ @return digest algorithm, or rtl_Digest_AlgorithmInvalid upon failure.
+ */
+rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Query the length of a given digest.
+ @param Digest [in] digest handle.
+ @return digest length, or 0 upon failure.
+ */
+sal_uInt32 SAL_CALL rtl_digest_queryLength (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Initialize a digest with given data.
+ @param Digest [in] digest handle.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_init (
+ rtlDigest Digest,
+ const sal_uInt8 *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a digest with given data.
+ @param Digest [in] digest handle.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_update (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a digest and retrieve the digest value.
+ @precond Digest value length must not be less than digest length.
+ @postcond Digest initialized to accept another update sequence.
+ @see rtl_digest_queryLength()
+ @see rtl_digest_update()
+
+ @param Digest [in] digest handle.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_get (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_MD2 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_MD2 16
+
+/** Create a MD2 digest handle.
+ @descr The MD2 digest algorithm is specified in
+
+ RFC 1319 (Informational)
+ The MD2 Message-Digest Algorithm
+
+ @see rtl_digest_create()
+ */
+rtlDigest SAL_CALL rtl_digest_createMD2 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a MD2 digest handle.
+ @see rtl_digest_destroy()
+ */
+void SAL_CALL rtl_digest_destroyMD2 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a MD2 digest with given data.
+ @see rtl_digest_update()
+ */
+rtlDigestError SAL_CALL rtl_digest_updateMD2 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a MD2 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_getMD2 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a MD2 digest value from given data.
+ @descr This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateMD2()
+ @see rtl_digest_getMD2()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_MD2 (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_MD5 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_MD5 16
+
+/** Create a MD5 digest handle.
+ @descr The MD5 digest algorithm is specified in
+
+ RFC 1321 (Informational)
+ The MD5 Message-Digest Algorithm
+
+ @see rtl_digest_create()
+ */
+rtlDigest SAL_CALL rtl_digest_createMD5 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a MD5 digest handle.
+ @see rtl_digest_destroy()
+ */
+void SAL_CALL rtl_digest_destroyMD5 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a MD5 digest with given data.
+ @see rtl_digest_update()
+ */
+rtlDigestError SAL_CALL rtl_digest_updateMD5 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a MD5 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_getMD5 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Retrieve the raw (not finalized) MD5 digest value.
+ @descr This function is a non-standard replacement for
+ rtl_digest_getMD5() and must be used with caution.
+
+ @postcond Digest initialized to accept another update sequence.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_rawMD5 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a MD5 digest value from given data.
+ @descr This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateMD5()
+ @see rtl_digest_getMD5()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_MD5 (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_SHA interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_SHA 20
+
+/** Create a SHA digest handle.
+ @descr The SHA digest algorithm is specified in
+
+ FIPS PUB 180 (Superseded by FIPS PUB 180-1)
+ Secure Hash Standard
+
+ @see rtl_digest_create()
+ */
+rtlDigest SAL_CALL rtl_digest_createSHA (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a SHA digest handle.
+ @see rtl_digest_destroy()
+ */
+void SAL_CALL rtl_digest_destroySHA (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a SHA digest with given data.
+ @see rtl_digest_update()
+ */
+rtlDigestError SAL_CALL rtl_digest_updateSHA (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a SHA digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_getSHA (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a SHA digest value from given data.
+ @descr This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateSHA()
+ @see rtl_digest_getSHA()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_SHA (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_SHA1 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_SHA1 20
+
+/** Create a SHA1 digest handle.
+ @descr The SHA1 digest algorithm is specified in
+
+ FIPS PUB 180-1 (Supersedes FIPS PUB 180)
+ Secure Hash Standard
+
+ @see rtl_digest_create()
+ */
+rtlDigest SAL_CALL rtl_digest_createSHA1 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a SHA1 digest handle.
+ @see rtl_digest_destroy()
+ */
+void SAL_CALL rtl_digest_destroySHA1 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a SHA1 digest with given data.
+ @see rtl_digest_update()
+ */
+rtlDigestError SAL_CALL rtl_digest_updateSHA1 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a SHA1 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_getSHA1 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a SHA1 digest value from given data.
+ @descr This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_updateSHA1()
+ @see rtl_digest_getSHA1()
+
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_SHA1 (
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_HMAC_MD5 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_HMAC_MD5 RTL_DIGEST_LENGTH_MD5
+
+/** Create a HMAC_MD5 digest handle.
+ @descr The HMAC_MD5 digest algorithm is specified in
+
+ RFC 2104 (Informational)
+ HMAC: Keyed-Hashing for Message Authentication
+
+ @see rtl_digest_create()
+ */
+rtlDigest SAL_CALL rtl_digest_createHMAC_MD5 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a HMAC_MD5 digest handle.
+ @see rtl_digest_destroy()
+ */
+void SAL_CALL rtl_digest_destroyHMAC_MD5 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Initialize a HMAC_MD5 digest.
+ @see rtl_digest_init()
+
+ @param Digest [in] digest handle.
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_initHMAC_MD5 (
+ rtlDigest Digest,
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a HMAC_MD5 digest with given data.
+ @see rtl_digest_update()
+ */
+rtlDigestError SAL_CALL rtl_digest_updateHMAC_MD5 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a HMAC_MD5 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_getHMAC_MD5 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a HMAC_MD5 digest value from given data.
+ @descr This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_initHMAC_MD5()
+ @see rtl_digest_updateHMAC_MD5()
+ @see rtl_digest_getHMAC_MD5()
+
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_HMAC_MD5 (
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_HMAC_SHA1 interface.
+ *
+ *======================================================================*/
+#define RTL_DIGEST_LENGTH_HMAC_SHA1 RTL_DIGEST_LENGTH_SHA1
+
+/** Create a HMAC_SHA1 digest handle.
+ @descr The HMAC_SHA1 digest algorithm is specified in
+
+ RFC 2104 (Informational)
+ HMAC: Keyed-Hashing for Message Authentication
+ RFC 2898 (Informational)
+ PKCS #5: Password-Based Cryptography Specification Version 2.0
+
+ @see rtl_digest_create()
+ */
+rtlDigest SAL_CALL rtl_digest_createHMAC_SHA1 (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a HMAC_SHA1 digest handle.
+ @see rtl_digest_destroy()
+ */
+void SAL_CALL rtl_digest_destroyHMAC_SHA1 (
+ rtlDigest Digest
+) SAL_THROW_EXTERN_C();
+
+
+/** Initialize a HMAC_SHA1 digest.
+ @see rtl_digest_init()
+
+ @param Digest [in] digest handle.
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_initHMAC_SHA1 (
+ rtlDigest Digest,
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Update a HMAC_SHA1 digest with given data.
+ @see rtl_digest_update()
+ */
+rtlDigestError SAL_CALL rtl_digest_updateHMAC_SHA1 (
+ rtlDigest Digest,
+ const void *pData, sal_uInt32 nDatLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Finalize a HMAC_SHA1 digest and retrieve the digest value.
+ @see rtl_digest_get()
+ */
+rtlDigestError SAL_CALL rtl_digest_getHMAC_SHA1 (
+ rtlDigest Digest,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+
+/** Evaluate a HMAC_SHA1 digest value from given data.
+ @descr This function performs an optimized call sequence on a
+ single data buffer, avoiding digest creation and destruction.
+
+ @see rtl_digest_initHMAC_SHA1()
+ @see rtl_digest_updateHMAC_SHA1()
+ @see rtl_digest_getHMAC_SHA1()
+
+ @param pKeyData [in] key material buffer.
+ @param nKeyLen [in] key material length.
+ @param pData [in] data buffer.
+ @param nDatLen [in] data length.
+ @param pBuffer [in] digest value buffer.
+ @param nBufLen [in] digest value length.
+
+ @return rtl_Digest_E_None upon success.
+ */
+rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1 (
+ const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen,
+ const void *pData, sal_uInt32 nDatLen,
+ sal_uInt8 *pBuffer, sal_uInt32 nBufLen
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * rtl_digest_PBKDF2 interface.
+ *
+ *======================================================================*/
+/** Password-Based Key Derivation Function.
+ @descr The PBKDF2 key derivation function is specified in
+
+ RFC 2898 (Informational)
+ PKCS #5: Password-Based Cryptography Specification Version 2.0
+
+ @param pKeyData [out] derived key
+ @param nKeyLen [in] derived key length
+ @param pPassData [in] password
+ @param nPassLen [in] password length
+ @param pSaltData [in] salt
+ @param nSaltLen [in] salt length
+ @param nCount [in] iteration count
+
+ @return rtl_Digest_E_None upon success.
+*/
+rtlDigestError SAL_CALL rtl_digest_PBKDF2 (
+ sal_uInt8 *pKeyData , sal_uInt32 nKeyLen,
+ const sal_uInt8 *pPassData, sal_uInt32 nPassLen,
+ const sal_uInt8 *pSaltData, sal_uInt32 nSaltLen,
+ sal_uInt32 nCount
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_DIGEST_H_ */
+
diff --git a/sal/inc/rtl/instance.hxx b/sal/inc/rtl/instance.hxx
new file mode 100644
index 000000000000..0bf4806bafd4
--- /dev/null
+++ b/sal/inc/rtl/instance.hxx
@@ -0,0 +1,472 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if !defined INCLUDED_RTL_INSTANCE_HXX
+#define INCLUDED_RTL_INSTANCE_HXX
+
+#include "osl/doublecheckedlocking.h"
+#include "osl/getglobalmutex.hxx"
+
+namespace {
+
+/** A non-broken version of the double-checked locking pattern.
+
+ See
+ <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>
+ for a description of double-checked locking, why it is broken, and how it
+ can be fixed. Always use this template instead of spelling out the
+ double-checked locking pattern explicitly, and only in those rare cases
+ where that is not possible and you have to spell it out explicitly, at
+ least call OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER() at the right
+ places. That way, all platform-dependent code to make double-checked
+ locking work can be kept in one place.
+
+ Usage scenarios:
+
+ 1 Static instance (most common case)
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if (!pInstance)
+ {
+ static T aInstance;
+ pInstance = &aInstance;
+ }
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+ #include "osl/getglobalmutex.hxx"
+
+ namespace {
+ struct Init
+ {
+ T * operator()()
+ {
+ static T aInstance;
+ return &aInstance;
+ }
+ };
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, Init, ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(
+ Init(), ::osl::GetGlobalMutex());
+ }
+
+ 2 Dynamic instance
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if (!pInstance)
+ pInstance = new T;
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+ #include "osl/getglobalmutex.hxx"
+
+ namespace {
+ struct Init
+ {
+ T * operator()()
+ {
+ return new T;
+ }
+ };
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, Init, ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(
+ Init(), ::osl::GetGlobalMutex());
+ }
+
+ 3 Other guard/mutex
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ SomeGuard aGuard(pSomeMutex);
+ if (!pInstance)
+ {
+ static T aInstance;
+ pInstance = &aInstance;
+ }
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+
+ namespace {
+ struct InitInstance
+ {
+ T * operator()()
+ {
+ static T aInstance;
+ return &aInstance;
+ }
+ };
+
+ struct InitGuard
+ {
+ SomeMutex * operator()()
+ {
+ return pSomeMutex;
+ }
+ };
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, InitInstance,
+ SomeGuard, InitGuard >::create(
+ InitInstance(), InitMutex());
+ }
+
+ 4 Calculate extra data
+
+ Pattern:
+
+ T * getInstance()
+ {
+ static T * pInstance = 0;
+ if (!pInstance)
+ {
+ Data aData(...);
+ ::osl::MutexGuard aGuard(::osl::Mutex::getGlobalMutex());
+ if (!pInstance)
+ {
+ static T aInstance(aData);
+ pInstance = &aInstance;
+ }
+ }
+ return pInstance;
+ }
+
+ Code:
+
+ #include "rtl/instance.hxx"
+ #include "osl/getglobalmutex.hxx"
+
+ namespace {
+ struct InitInstance
+ {
+ T * operator()()
+ {
+ static T aInstance;
+ return &aInstance;
+ }
+ }
+
+ struct InitData
+ {
+ Data const & operator()()
+ {
+ return ...;
+ }
+ }
+ }
+
+ T * getInstance()
+ {
+ return rtl_Instance< T, InitInstance,
+ ::osl::Mutex, ::osl::GetGlobalMutex,
+ Data, InitData >::create(
+ InitInstance(), ::osl::GetGlobalMutex(), InitData());
+ }
+
+ Some comments:
+
+ For any instantiation of rtl_Instance, at most one call to a create method
+ may occur in the program code: Each occurance of a create method within
+ the program code is supposed to return a fresh object instance on the
+ first call, and that same object instance on subsequent calls; but
+ independent occurances of create methods are supposed to return
+ independent object instances. Since there is a one-to-one correspondence
+ between object instances and instantiations of rtl_Instance, the
+ requirement should be clear. One measure to enforce the requirement is
+ that rtl_Instance lives in an unnamed namespace, so that instantiations of
+ rtl_Instance in different translation units will definitely be different
+ instantiations. A drawback of that measure is that the name of the class
+ needs a funny "hand coded" prefix "rtl_" instead of a proper namespace
+ prefix like "::rtl::".
+
+ A known problem with this template is when two occurences of calls to
+ create methods with identical template arguments appear in one translation
+ unit. Those two places will share a single object instance. This can be
+ avoided by using different Init structs (see the above code samples) in
+ the two places.
+
+ There is no need to make m_pInstance volatile, in order to avoid usage of
+ stale copies of m_pInstance: At the first check, a thread will see that
+ m_pInstance contains either 0 or a valid pointer. If it contains a valid
+ pointer, it cannot be stale, and that pointer is used. If it contains 0,
+ acquiring the mutex will ensure that the second check sees a non-stale
+ value in all cases.
+
+ On some compilers, the create methods would not be inlined if they
+ contained any static variables, so m_pInstance is made a class member
+ instead (and the create methods are inlined). But on MSC, the definition
+ of the class member m_pInstance would cause compilation to fail with an
+ internal compiler error. Since MSC is able to inline methods containing
+ static variables, m_pInstance is moved into the methods there. Note that
+ this only works well because for any instantiation of rtl_Instance at most
+ one call to a create method should be present, anyway.
+ */
+template< typename Inst, typename InstCtor,
+ typename Guard, typename GuardCtor,
+ typename Data = int, typename DataCtor = int >
+class rtl_Instance
+{
+public:
+ static inline Inst * create(InstCtor aInstCtor, GuardCtor aGuardCtor)
+ {
+#if defined _MSC_VER
+ static Inst * m_pInstance = 0;
+#endif // _MSC_VER
+ Inst * p = m_pInstance;
+ if (!p)
+ {
+ Guard aGuard(aGuardCtor());
+ p = m_pInstance;
+ if (!p)
+ {
+ p = aInstCtor();
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ m_pInstance = p;
+ }
+ }
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+ return p;
+ }
+
+ static inline Inst * create(InstCtor aInstCtor, GuardCtor aGuardCtor,
+ DataCtor aDataCtor)
+ {
+#if defined _MSC_VER
+ static Inst * m_pInstance = 0;
+#endif // _MSC_VER
+ Inst * p = m_pInstance;
+ if (!p)
+ {
+ Data aData(aDataCtor());
+ Guard aGuard(aGuardCtor());
+ p = m_pInstance;
+ if (!p)
+ {
+ p = aInstCtor(aData);
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ m_pInstance = p;
+ }
+ }
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+ return p;
+ }
+
+private:
+#if !defined _MSC_VER
+ static Inst * m_pInstance;
+#endif // _MSC_VER
+};
+
+#if !defined _MSC_VER
+template< typename Inst, typename InstCtor,
+ typename Guard, typename GuardCtor,
+ typename Data, typename DataCtor >
+Inst *
+rtl_Instance< Inst, InstCtor, Guard, GuardCtor, Data, DataCtor >::m_pInstance
+= 0;
+#endif // _MSC_VER
+
+}
+
+namespace rtl {
+
+/** Helper base class for a late-initialized (default-constructed)
+ static variable, implementing the double-checked locking pattern correctly.
+
+ @derive
+ Derive from this class (common practice), e.g.
+ <pre>
+ struct MyStatic : public rtl::Static<MyType, MyStatic> {};
+ ...
+ MyType & rStatic = MyStatic::get();
+ ...
+ </pre>
+
+ @tplparam T
+ variable's type
+ @tplparam Unique
+ Implementation trick to make the inner static holder unique,
+ using the outer class
+ (the one that derives from this base class)
+*/
+template<typename T, typename Unique>
+class Static {
+public:
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get() {
+ return *rtl_Instance<
+ T, StaticInstance,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex >::create(
+ StaticInstance(), ::osl::GetGlobalMutex() );
+ }
+private:
+ struct StaticInstance {
+ T * operator () () {
+ static T instance;
+ return &instance;
+ }
+ };
+};
+
+/** Helper class for a late-initialized static aggregate, e.g. an array,
+ implementing the double-checked locking pattern correctly.
+
+ @tplparam T
+ aggregate's element type
+ @tplparam InitAggregate
+ initializer functor class
+*/
+template<typename T, typename InitAggregate>
+class StaticAggregate {
+public:
+ /** Gets the static aggregate, late-initializing.
+ Mutual exclusion is performed using the osl global mutex.
+
+ @return
+ aggregate
+ */
+ static T * get() {
+ return rtl_Instance<
+ T, InitAggregate,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex >::create(
+ InitAggregate(), ::osl::GetGlobalMutex() );
+ }
+};
+
+/** Helper base class for a late-initialized static variable,
+ implementing the double-checked locking pattern correctly.
+
+ @derive
+ Derive from this class (common practice),
+ providing an initializer functor class, e.g.
+ <pre>
+ struct MyStatic : public rtl::StaticWithInit<MyType, MyStatic> {
+ MyType operator () () {
+ ...
+ return MyType( ... );
+ }
+ };
+ ...
+ MyType & rStatic = MyStatic::get();
+ ...
+ </pre>
+
+ @tplparam T
+ variable's type
+ @tplparam InitData
+ initializer functor class
+ @tplparam Unique
+ Implementation trick to make the inner static holder unique,
+ using the outer class
+ (the one that derives from this base class).
+ Default is InitData (common practice).
+ @tplparam Data
+ Initializer functor's return type.
+ Default is T (common practice).
+*/
+template<typename T, typename InitData,
+ typename Unique = InitData, typename Data = T>
+class StaticWithInit {
+public:
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get() {
+ return *rtl_Instance<
+ T, StaticInstanceWithInit,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex,
+ Data, InitData >::create( StaticInstanceWithInit(),
+ ::osl::GetGlobalMutex(),
+ InitData() );
+ }
+private:
+ struct StaticInstanceWithInit {
+ T * operator () ( Data d ) {
+ static T instance(d);
+ return &instance;
+ }
+ };
+};
+
+} // namespace rtl
+
+#endif // INCLUDED_RTL_INSTANCE_HXX
diff --git a/sal/inc/rtl/locale.h b/sal/inc/rtl/locale.h
new file mode 100644
index 000000000000..f2b0016942a3
--- /dev/null
+++ b/sal/inc/rtl/locale.h
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_LOCALE_H_
+#define _RTL_LOCALE_H_
+
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(push, 4)
+#endif
+
+/**
+ The implementation structur of a locale. Do not create this structure
+ direct. Only use the functions rtl_locale_register and
+ rtl_locale_setDefault. The strings Language, Country and Variant
+ are constants, so it is not necessary to acquire and release them.
+ */
+typedef struct _rtl_Locale
+{
+ /**
+ Lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ */
+ rtl_uString * Language;
+ /**
+ uppercase two-letter ISO-3166 code.
+ */
+ rtl_uString * Country;
+ /**
+ Lowercase vendor and browser specific code.
+ */
+ rtl_uString * Variant;
+ /**
+ The merged hash value of the Language, Country and Variant strings.
+ */
+ sal_Int32 HashCode;
+} rtl_Locale;
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+#pragma pack(pop)
+#endif
+
+/**
+ Register a locale from language, country and variant.
+ @param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ @param country uppercase two-letter ISO-3166 code. May be null.
+ @param variant vendor and browser specific code. May be null.
+ */
+rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
+
+/**
+ Common method of getting the current default Locale.
+ Used for the presentation: menus, dialogs, etc.
+ Generally set once when your applet or application is initialized,
+ then never reset. (If you do reset the default locale, you
+ probably want to reload your GUI, so that the change is reflected
+ in your interface.)
+ <p>More advanced programs will allow users to use different locales
+ for different fields, e.g. in a spreadsheet.
+ <BR>Note that the initial setting will match the host system.
+ */
+rtl_Locale * SAL_CALL rtl_locale_getDefault();
+
+/**
+ Sets the default.
+ Normally set once at the beginning of applet or application,
+ then never reset. <code>setDefault</code> does not reset the host locale.
+ @param language lowercase two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ @param country uppercase two-letter ISO-3166 code.
+ @param variant vendor and browser specific code. See class description.
+ */
+void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant );
+
+/**
+ Getter for programmatic name of field,
+ a lowercased two-letter ISO 639-1 or three-letter ISO 639-3 code.
+ @see #getDisplayLanguage
+ */
+rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This );
+
+/**
+ Getter for programmatic name of field,
+ an uppercased two-letter ISO-3166 code.
+ @see #getDisplayCountry
+ */
+rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This );
+
+/**
+ Getter for programmatic name of field.
+ @see #getDisplayVariant
+ */
+rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This );
+
+/**
+ Returns the hash code of the locale This.
+ */
+sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This );
+
+/**
+ Returns true if the locals are equal, otherwis false.
+ */
+sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_LOCALE_H_ */
+
+
diff --git a/sal/inc/rtl/locale.hxx b/sal/inc/rtl/locale.hxx
new file mode 100644
index 000000000000..7e6526c0e9bc
--- /dev/null
+++ b/sal/inc/rtl/locale.hxx
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_LOCALE_HXX_
+#define _RTL_LOCALE_HXX_
+
+#include <rtl/locale.h>
+#include <rtl/ustring.hxx>
+
+#ifdef __cplusplus
+
+namespace rtl
+{
+
+/**
+ A <code>OLocale</code> object represents a specific geographical, political,
+ or cultural region. An operation that requires a <code>OLocale</code> to perform
+ its task is called <em>locale-sensitive</em> and uses the <code>OLocale</code>
+ to tailor information for the user. For example, displaying a number
+ is a locale-sensitive operation--the number should be formatted
+ according to the customs/conventions of the user's native country,
+ region, or culture.
+
+ <P>
+ You create a <code>OLocale</code> object using one of the two constructors in
+ this class:
+ <blockquote>
+ <pre>
+ OLocale(String language, String country)
+ OLocale(String language, String country, String variant)
+ </pre>
+ </blockquote>
+ The first argument to both constructors is a valid <STRONG>ISO
+ Language Code.</STRONG> These codes are the lower-case two-letter
+ codes as defined by ISO-639.
+ You can find a full list of these codes at a number of sites, such as:
+ <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
+ <code>http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</code></a>
+
+ <P>
+ The second argument to both constructors is a valid <STRONG>ISO Country
+ Code.</STRONG> These codes are the upper-case two-letter codes
+ as defined by ISO-3166.
+ You can find a full list of these codes at a number of sites, such as:
+ <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html">
+ <code>http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</code></a>
+
+ <P>
+ The second constructor requires a third argument--the <STRONG>Variant.</STRONG>
+ The Variant codes are vendor and browser-specific.
+ For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX.
+ Where there are two variants, separate them with an underscore, and
+ put the most important one first. For
+ example, a Traditional Spanish collation might be referenced, with
+ "ES", "ES", "Traditional_WIN".
+
+ <P>
+ Because a <code>OLocale</code> object is just an identifier for a region,
+ no validity check is performed when you construct a <code>OLocale</code>.
+ If you want to see whether particular resources are available for the
+ <code>OLocale</code> you construct, you must query those resources. For
+ example, ask the <code>NumberFormat</code> for the locales it supports
+ using its <code>getAvailableLocales</code> method.
+ <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular
+ locale, you get back the best available match, not necessarily
+ precisely what you asked for. For more information, look at
+ <a href="java.util.ResourceBundle.html"><code>ResourceBundle</code></a>.
+
+ <P>
+ The <code>OLocale</code> class provides a number of convenient constants
+ that you can use to create <code>OLocale</code> objects for commonly used
+ locales. For example, the following creates a <code>OLocale</code> object
+ for the United States:
+ <blockquote>
+ <pre>
+ OLocale.US
+ </pre>
+ </blockquote>
+
+ <P>
+ Once you've created a <code>OLocale</code> you can query it for information about
+ itself. Use <code>getCountry</code> to get the ISO Country Code and
+ <code>getLanguage</code> to get the ISO Language Code. You can
+ use <code>getDisplayCountry</code> to get the
+ name of the country suitable for displaying to the user. Similarly,
+ you can use <code>getDisplayLanguage</code> to get the name of
+ the language suitable for displaying to the user. Interestingly,
+ the <code>getDisplayXXX</code> methods are themselves locale-sensitive
+ and have two versions: one that uses the default locale and one
+ that uses the locale specified as an argument.
+
+ <P>
+ The JDK provides a number of classes that perform locale-sensitive
+ operations. For example, the <code>NumberFormat</code> class formats
+ numbers, currency, or percentages in a locale-sensitive manner. Classes
+ such as <code>NumberFormat</code> have a number of convenience methods
+ for creating a default object of that type. For example, the
+ <code>NumberFormat</code> class provides these three convenience methods
+ for creating a default <code>NumberFormat</code> object:
+ <blockquote>
+ <pre>
+ NumberFormat.getInstance()
+ NumberFormat.getCurrencyInstance()
+ NumberFormat.getPercentInstance()
+ </pre>
+ </blockquote>
+ These methods have two variants; one with an explicit locale
+ and one without; the latter using the default locale.
+ <blockquote>
+ <pre>
+ NumberFormat.getInstance(myLocale)
+ NumberFormat.getCurrencyInstance(myLocale)
+ NumberFormat.getPercentInstance(myLocale)
+ </pre>
+ </blockquote>
+ A <code>OLocale</code> is the mechanism for identifying the kind of object
+ (<code>NumberFormat</code>) that you would like to get. The locale is
+ <STRONG>just</STRONG> a mechanism for identifying objects,
+ <STRONG>not</STRONG> a container for the objects themselves.
+
+ <P>
+ Each class that performs locale-sensitive operations allows you
+ to get all the available objects of that type. You can sift
+ through these objects by language, country, or variant,
+ and use the display names to present a menu to the user.
+ For example, you can create a menu of all the collation objects
+ suitable for a given language. Such classes must implement these
+ three class methods:
+ <blockquote>
+ <pre>
+ public static OLocale[] getAvailableLocales()
+ public static String getDisplayName(OLocale objectLocale,
+ OLocale displayLocale)
+ public static final String getDisplayName(OLocale objectLocale)
+ // getDisplayName will throw MissingResourceException if the locale
+ // is not one of the available locales.
+ </pre>
+ </blockquote>
+ */
+class OLocale
+{
+public:
+ OLocale( rtl_Locale * locale )
+ : pData( locale ) {}
+
+ OLocale( const OLocale & obj)
+ : pData(obj.pData) {}
+
+ OLocale & operator = ( const OLocale & obj)
+ {
+ pData = obj.pData;
+ return *this;
+ }
+
+ /**
+ Construct a locale from language, country, variant.
+ @param language lowercase two-letter ISO-639 code.
+ @param country uppercase two-letter ISO-3166 code.
+ @param variant vendor and browser specific code. See class description.
+ */
+ static OLocale registerLocale( const OUString & language, const OUString & country,
+ const OUString & variant )
+ {
+ return rtl_locale_register( language, country, variant );
+ }
+
+ /**
+ Construct a locale from language, country.
+ @param language lowercase two-letter ISO-639 code.
+ @param country uppercase two-letter ISO-3166 code.
+ */
+ static OLocale registerLocale( const OUString & language, const OUString & country )
+ {
+ return rtl_locale_register( language, country, NULL );
+ }
+
+ /** @deprecated
+ */
+ static OLocale getDefault() { return rtl_locale_getDefault(); }
+
+ /** @deprecated
+ */
+ static void setDefault( const OUString & language, const OUString & country,
+ const OUString & variant )
+ { rtl_locale_setDefault(language, country, variant); }
+
+ /**
+ Getter for programmatic name of field,
+ an lowercased two-letter ISO-639 code.
+ */
+ OUString getLanguage() const { return pData->Language; }
+
+ /**
+ Getter for programmatic name of field,
+ an uppercased two-letter ISO-3166 code.
+ */
+ OUString getCountry() const { return pData->Country; }
+
+ /**
+ Getter for programmatic name of field.
+ */
+ OUString getVariant() const { return pData->Variant; }
+
+
+ /**
+ Returns the hash code of the locale This.
+ */
+ sal_Int32 hashCode() const { return pData->HashCode; }
+
+ sal_Bool operator == (const OLocale & obj ) const
+ {
+ return pData == obj.pData;
+ }
+
+ rtl_Locale * getData() const { return pData; }
+
+private:
+ /**
+ Must be the first member in this class. OUString access this member with
+ *(rtl_Locale **)&locale.
+ */
+ rtl_Locale * pData;
+
+ OLocale()
+ : pData(rtl_locale_getDefault()) {}
+/*
+ OLocale( const OLocale & obj)
+ : pData(obj.pData) {}
+
+ OLocale & operator = ( const OLocale & obj)
+ { pData = obj.pData;
+ return *this;
+ }
+*/
+};
+
+}
+
+#endif /* __cplusplus */
+#endif /* _RTL_LOCALE_HXX_ */
+
+
diff --git a/sal/inc/rtl/logfile.h b/sal/inc/rtl/logfile.h
new file mode 100644
index 000000000000..dbb9e9c258cf
--- /dev/null
+++ b/sal/inc/rtl/logfile.h
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_LOGFILE_H_
+#define _RTL_LOGFILE_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** This function allows to log arbitrary messages even in a product-environment.
+
+ The logfile is created on first access and closed, when the sal-library gets unloaded.
+ The file is line buffered. A log file is not created if no log messages are
+ written.
+
+ The first time, rtl_logfile_trace is called, it checks for the bootstrap variable
+ RTL_LOGFILE. If the variable is not empty, it creates a file with the name
+ $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
+
+ @param pszformat A format string with fprintf-syntax
+ @param ... An arbitrary number of arguments for fprintf, matching the
+ format string.
+*/
+void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... );
+
+/** Like rtl_logfile_trace, but prefixing every log entry with the current time
+ and thread ID.
+
+ @param format
+ a format string with fprintf-like syntax
+
+ @param ...
+ an arbitrary number of arguments for fprintf, matching the given format
+ string
+
+ @since UDK 3.2.0
+*/
+void SAL_CALL rtl_logfile_longTrace(char const * format, ...);
+
+/** Return if a log file is written.
+
+ @return true if a log file is written
+
+ @since UDK 3.2.11
+*/
+sal_Bool SAL_CALL rtl_logfile_hasLogFile( void );
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef TIMELOG
+#define RTL_LOGFILE_TRACE( string ) \
+ rtl_logfile_longTrace( "| : %s\n", string )
+#define RTL_LOGFILE_TRACE1( frmt, arg1 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+
+#define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
+ rtl_logfile_trace( "\n" )
+
+// Now the macros with project and author arguments. The strings
+// are formatted in a way, so that the log file can be parsed by
+// post processing scripts.
+#define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) \
+ rtl_logfile_longTrace( "| %s (%s) : %s\n", \
+ project,\
+ author,\
+ string )
+#define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
+ rtl_logfile_longTrace( "| %s (%s) : ", \
+ project,\
+ author );\
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+
+#define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \
+ rtl_logfile_longTrace( "| %s (%s) : ", \
+ project,\
+ author ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \
+ rtl_logfile_longTrace( "| %s (%s) : ", \
+ project,\
+ author ); \
+ rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
+ rtl_logfile_trace( "\n" )
+#else
+#define RTL_LOGFILE_TRACE( string ) ((void)0)
+#define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0)
+#define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0)
+#define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0)
+
+#define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) ((void)0)
+#define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0)
+#define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0)
+#define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0)
+#endif // TIMELOG
+#endif
diff --git a/sal/inc/rtl/logfile.hxx b/sal/inc/rtl/logfile.hxx
new file mode 100644
index 000000000000..685637d504b0
--- /dev/null
+++ b/sal/inc/rtl/logfile.hxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_LOGFILE_HXX_
+#define _RTL_LOGFILE_HXX_
+
+#include <rtl/logfile.h>
+#include <rtl/string.hxx>
+
+namespace rtl
+{
+/**
+@descr The intended use for class Logfile is to write time stamp information
+ for profiling purposes.
+
+ Profiling output should only be generated for a special product version of OpenOffice
+ which is compiled with a defined preprocessor symbol 'TIMELOG'.
+ Therefore we have provided a set of macros that uses the class Logfile only if
+ this symbol is defined. If the macros are not sufficient, i.e. you need more
+ then three arguments for a printf style message, then you have to insert an
+ #ifdef TIMELOG/#endif brace yourself.
+
+ Additionally the environment variable RTL_LOGFILE has to be defined in order to generate
+ logging information. If the variable is not empty, it creates a file with the name
+ $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
+ It can be used as a run time switch for enabling or disabling the logging.
+ Note that this variable is evaluated only once at the first attempt to write a message.
+
+ The class LogFile collects runtime data within its constructor and destructor. It can be
+ used for timing whole functions.
+ If you want to write timing data without context you can use the RTL_LOGFILE_TRACE-macros
+ which are defined inside <rtl/logfile.h>.
+
+ The class LogFile should not be used directly, instead use the RTL_LOGFILE_CONTEXT/
+ RTL_LOGFILE_TRACE-macros.
+
+ Macro usage:
+ ------------
+ RTL_LOGFILE_CONTEXT( instance, name );
+ This macro creates an instance of class LogFile with the name "instance" and writes the current time,
+ thread id and "name" to the log file.
+
+ Example: RTL_LOGFILE_CONTEXT( aLog, "Timing for foo-method" );
+
+ RTL_LOGFILE_CONTEXT_TRACE( instance, mesage );
+ RTL_LOGFILE_CONTEXT_TRACEn( instance, frmt, arg1, .., arg3 );
+ These macros can be used to log information in a "instance" context. The "instance" object
+ is used to log message informations. All macros with "frmt" uses printf notation to log timing infos.
+
+ Example: RTL_LOGFILE_CONTEXT_TRACE( aLog, "Now we call an expensive function" );
+ RTL_LOGFIlE_CONTEXT_TRACE1( aLog, "Config entries read: %u", (unsigned short)i );
+
+ RTL_LOGFILE_TRACE( string );
+ RTL_LOGFILE_TRACEn( frmt, arg1, .., arg3 );
+ These macros can be used to log information outside a context. The macro directly calls
+ rtl_logfile_trace to write the info to the log file. All macros with "frmt" uses printf
+ notation to log timing infos.
+
+ Example: RTL_LOGFILE_TRACE( "Timing for loading a file" );
+ RTL_LOGFILE_TRACE1( aLog, "Timing for loading file: %s", aFileName );
+
+ The lines written to the log file consist of the following space separated elements:
+ 1. The time relative to the start of the global timer in milliseconds. The times is
+ started typically for the first logged line.
+ 2. Thread id. It's absolut value is probably of less interest than providing a way to
+ distinguish different threads.
+ 3. a. An opening or closing curly brace indicating the start or end of a scope.
+ 4a. Function name or general scope identifier.
+ b. A vertical line indicating an arbitrary message.
+ 4b optional function name or general scope identifier.
+ 5b A colon followed by a space and a free form message terminated by a newline.
+
+ There is a second version of creating a context. RTL_LOGFILE_CONTEXT_AUTHOR takes
+ two more arguments, the name of the project and the author's sign who is responsible
+ for the code in which the macro is used.
+*/
+ class Logfile
+ {
+ public:
+ inline Logfile( const sal_Char *name );
+ /** @descr Create a log file context where the message field consists of a project
+ name, the author's shortcut, and the actual message. These three strings
+ are written in a format that is understood by script that later parses the
+ log file and that so can extract the three strings.
+ @param project Short name of the project, like sw for writer or sc for calc.
+ @param author The sign of the person responsible for the code.
+ @param name The actual message, typically a method name.
+ */
+ inline Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name );
+ inline ~Logfile();
+ inline const sal_Char *getName();
+ private:
+ ::rtl::OString m_sName;
+ };
+
+ inline Logfile::Logfile( const sal_Char *name )
+ : m_sName( name )
+ {
+ rtl_logfile_longTrace( "{ %s\n", name );
+ }
+
+ inline Logfile::Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name )
+ : m_sName( project)
+ {
+ m_sName += " (";
+ m_sName += author;
+ m_sName += ") ";
+ m_sName += name;
+ rtl_logfile_longTrace( "{ %s\n", m_sName.pData->buffer );
+ }
+
+ inline Logfile::~Logfile()
+ {
+ rtl_logfile_longTrace( "} %s\n", m_sName.pData->buffer );
+ }
+
+ inline const sal_Char * Logfile::getName()
+ {
+ return m_sName.getStr();
+ }
+}
+
+#ifdef TIMELOG
+#define RTL_LOGFILE_CONTEXT( instance, name ) ::rtl::Logfile instance( name )
+#define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ::rtl::Logfile instance(project, author, name )
+#define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) \
+ rtl_logfile_longTrace( "| %s : %s\n", \
+ instance.getName(), \
+ message )
+#define RTL_LOGFILE_CONTEXT_TRACE1( instance , frmt, arg1 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt , arg1 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_CONTEXT_TRACE2( instance , frmt, arg1 , arg2 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt , arg1 , arg2 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_CONTEXT_TRACE3( instance , frmt, arg1 , arg2 , arg3 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt , arg1 , arg2 , arg3 ); \
+ rtl_logfile_trace( "\n" )
+
+#else
+#define RTL_LOGFILE_CONTEXT( instance, name ) ((void)0)
+#define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ((void)0)
+#define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) ((void)0)
+#define RTL_LOGFILE_CONTEXT_TRACE1( instance, frmt, arg1 ) ((void)0)
+#define RTL_LOGFILE_CONTEXT_TRACE2( instance, frmt, arg1, arg2 ) ((void)0)
+#define RTL_LOGFILE_CONTEXT_TRACE3( instance, frmt, arg1, arg2 , arg3 ) ((void)0)
+#endif
+
+// Normal RTL_LOGFILE_* entries will not make it into release versions,
+// TIMELOG is disabled a few versions prior relase build.
+//
+// We need some logs also in these builds, eg. for making performance regression tests.
+//
+// POLICY: Don't use RTL_LOGFILE_PRODUCT_* for your personal logging information.
+// Be aware that these logs make it into the product shipped to customers.
+// If you have good reasons for doing this, please contact product management.
+
+#define RTL_LOGFILE_PRODUCT_TRACE( string ) \
+ rtl_logfile_longTrace( "| : %s\n", string )
+#define RTL_LOGFILE_PRODUCT_TRACE1( frmt, arg1 ) \
+ rtl_logfile_longTrace( "| : " ); \
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \
+ ::rtl::Logfile instance( name )
+#define RTL_LOGFILE_PRODUCT_CONTEXT_TRACE1( instance, frmt, arg1 ) \
+ rtl_logfile_longTrace( "| %s : ", \
+ instance.getName() ); \
+ rtl_logfile_trace( frmt, arg1 ); \
+ rtl_logfile_trace( "\n" )
+#define RTL_LOGFILE_HASLOGFILE() \
+ rtl_logfile_hasLogFile()
+
+
+#endif
+
diff --git a/sal/inc/rtl/malformeduriexception.hxx b/sal/inc/rtl/malformeduriexception.hxx
new file mode 100644
index 000000000000..f196b4f00d60
--- /dev/null
+++ b/sal/inc/rtl/malformeduriexception.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_RTL_MALFORMEDURIEXCEPTION_HXX
+#define INCLUDED_RTL_MALFORMEDURIEXCEPTION_HXX
+
+#include "rtl/ustring.hxx"
+
+namespace rtl {
+
+/** An exception indicating a malformed URI.
+
+ <P>Used when parsing (part of) a URI fails for syntactical reasons.</P>
+ */
+class SAL_EXCEPTION_DLLPUBLIC_EXPORT MalformedUriException
+{
+public:
+ /** Create a MalformedUriException.
+
+ @param rMessage
+ A message containing any details about the exception.
+ */
+ inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException(
+ rtl::OUString const & rMessage): m_aMessage(rMessage) {}
+
+ inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException(
+ MalformedUriException const & other): m_aMessage(other.m_aMessage) {}
+
+ inline SAL_EXCEPTION_DLLPRIVATE ~MalformedUriException() {}
+
+ inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException operator =(
+ MalformedUriException const & other)
+ { m_aMessage = other.m_aMessage; return *this; }
+
+ /** Get the message.
+
+ @return
+ A reference to the message. The reference is valid for the lifetime of
+ this MalformedUriException.
+ */
+ inline SAL_EXCEPTION_DLLPRIVATE rtl::OUString const & getMessage() const
+ { return m_aMessage; }
+
+private:
+ rtl::OUString m_aMessage;
+};
+
+}
+
+#endif // INCLUDED_RTL_MALFORMEDURIEXCEPTION_HXX
diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h
new file mode 100644
index 000000000000..985ce700b049
--- /dev/null
+++ b/sal/inc/rtl/math.h
@@ -0,0 +1,474 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if !defined INCLUDED_RTL_MATH_H
+#define INCLUDED_RTL_MATH_H
+
+#include "rtl/ustring.h"
+#include "sal/types.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** Formatting modes for rtl_math_doubleToString and rtl_math_doubleToUString
+ and rtl_math_doubleToUStringBuffer.
+ */
+enum rtl_math_StringFormat
+{
+ /** Like sprintf() %E.
+ */
+ rtl_math_StringFormat_E,
+
+ /** Like sprintf() %f.
+ */
+ rtl_math_StringFormat_F,
+
+ /** Like sprintf() %G, 'F' or 'E' format is used depending on which one is
+ more compact.
+ */
+ rtl_math_StringFormat_G,
+
+ /** Automatic, 'F' or 'E' format is used depending on the numeric value to
+ be formatted.
+ */
+ rtl_math_StringFormat_Automatic,
+
+ /** @internal
+ */
+ rtl_math_StringFormat_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Status for rtl_math_stringToDouble and rtl_math_uStringToDouble.
+ */
+enum rtl_math_ConversionStatus
+{
+ /** Conversion was successful.
+ */
+ rtl_math_ConversionStatus_Ok,
+
+ /** Conversion caused overflow or underflow.
+ */
+ rtl_math_ConversionStatus_OutOfRange,
+
+ /** @internal
+ */
+ rtl_math_ConversionStatus_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Rounding modes for rtl_math_round.
+ */
+enum rtl_math_RoundingMode
+{
+ /** Like HalfUp, but corrects roundoff errors, preferred.
+ */
+ rtl_math_RoundingMode_Corrected,
+
+ /** Floor of absolute value, signed return (commercial).
+ */
+ rtl_math_RoundingMode_Down,
+
+ /** Ceil of absolute value, signed return (commercial).
+ */
+ rtl_math_RoundingMode_Up,
+
+ /** Floor of signed value.
+ */
+ rtl_math_RoundingMode_Floor,
+
+ /** Ceil of signed value.
+ */
+ rtl_math_RoundingMode_Ceiling,
+
+ /** Frac <= 0.5 ? floor of abs : ceil of abs, signed return.
+ */
+ rtl_math_RoundingMode_HalfDown,
+
+ /** Frac < 0.5 ? floor of abs : ceil of abs, signed return (mathematical).
+ */
+ rtl_math_RoundingMode_HalfUp,
+
+ /** IEEE rounding mode (statistical).
+ */
+ rtl_math_RoundingMode_HalfEven,
+
+ /** @internal
+ */
+ rtl_math_RoundingMode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Special decimal places constants for rtl_math_doubleToString and
+ rtl_math_doubleToUString and rtl_math_doubleToUStringBuffer.
+ */
+enum rtl_math_DecimalPlaces
+{
+ /** Value to be used with rtl_math_StringFormat_Automatic.
+ */
+ rtl_math_DecimalPlaces_Max = 0x7ffffff,
+
+ /** Value to be used with rtl_math_StringFormat_G.
+ In fact the same value as rtl_math_DecimalPlaces_Max, just an alias for
+ better understanding.
+ */
+ rtl_math_DecimalPlaces_DefaultSignificance = 0x7ffffff
+};
+
+
+/** Conversions analogous to sprintf() using internal rounding.
+
+ +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are
+ converted to "NaN".
+
+ @param pResult
+ Returns the resulting byte string. Must itself not be null, and must point
+ to either null or a valid string.
+
+ @param pResultCapacity
+ If null, pResult is considered to point to immutable strings, and a new
+ string will be allocated in pResult.
+ If non-null, it points to the current capacity of pResult, which is
+ considered to point to a string buffer (pResult must not itself be null in
+ this case, and must point to a string that has room for the given capacity).
+ The string representation of the given double value is inserted into pResult
+ at position nResultOffset. If pResult's current capacity is too small, a
+ new string buffer will be allocated in pResult as necessary, and
+ pResultCapacity will contain the new capacity on return.
+
+ @param nResultOffset
+ If pResult is used as a string buffer (i.e., pResultCapacity is non-null),
+ nResultOffset specifies the insertion offset within the buffer. Ignored
+ otherwise.
+
+ @param fValue
+ The value to convert.
+
+ @param eFormat
+ The format to use, one of rtl_math_StringFormat.
+
+ @param nDecPlaces
+ The number of decimals to be generated. Effectively fValue is rounded at
+ this position, specifying nDecPlaces <= 0 accordingly rounds the value
+ before the decimal point and fills with zeros.
+ If eFormat == rtl_math_StringFormat_Automatic and nDecPlaces ==
+ rtl_math_DecimalPlaces_Max, the highest number of significant decimals
+ possible is generated.
+ If eFormat == rtl_math_StringFormat_G, nDecPlaces specifies the number of
+ significant digits instead. If nDecPlaces ==
+ rtl_math_DecimalPlaces_DefaultSignificance, the default number (currently 6
+ as implemented by most libraries) of significant digits is generated.
+ According to the ANSI C90 standard the E style will be used only if the
+ exponent resulting from the conversion is less than -4 or greater than or
+ equal to the precision. However, as opposed to the ANSI standard, trailing
+ zeros are not necessarily removed from the fractional portion of the result
+ unless bEraseTrailingDecZeros == true was specified.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param pGroups
+ Either null (no grouping is used), or a null-terminated list of group
+ lengths. Each group length must be strictly positive. If the number of
+ digits in a conversion exceeds the specified range, the last (highest) group
+ length is repeated as needed. Values are applied from right to left, for a
+ grouping of 1,00,00,000 you'd have to specify pGroups={3,2,0}.
+
+ @param cGroupSeparator
+ The group separator. Ignored if pGroups is null.
+
+ @param bEraseTrailingDecZeros
+ Trailing zeros in decimal places are erased.
+ */
+void SAL_CALL rtl_math_doubleToString(rtl_String ** pResult,
+ sal_Int32 * pResultCapacity,
+ sal_Int32 nResultOffset, double fValue,
+ enum rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Char cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Char cGroupSeparator,
+ sal_Bool bEraseTrailingDecZeros)
+ SAL_THROW_EXTERN_C();
+
+/** Conversions analogous to sprintf() using internal rounding.
+
+ +/-HUGE_VAL are converted to "INF" and "-INF", NAN values are
+ converted to "NaN".
+
+ @param pResult
+ Returns the resulting Unicode string. Must itself not be null, and must
+ point to either null or a valid string.
+
+ @param pResultCapacity
+ If null, pResult is considered to point to immutable strings, and a new
+ string will be allocated in pResult.
+ If non-null, it points to the current capacity of pResult, which is
+ considered to point to a string buffer (pResult must not itself be null in
+ this case, and must point to a string that has room for the given capacity).
+ The string representation of the given double value is inserted into pResult
+ at position nResultOffset. If pResult's current capacity is too small, a
+ new string buffer will be allocated in pResult as necessary, and
+ pResultCapacity will contain the new capacity on return.
+
+ @param nResultOffset
+ If pResult is used as a string buffer (i.e., pResultCapacity is non-null),
+ nResultOffset specifies the insertion offset within the buffer. Ignored
+ otherwise.
+
+ @param fValue
+ The value to convert.
+
+ @param eFormat
+ The format to use, one of rtl_math_StringFormat.
+
+ @param nDecPlaces
+ The number of decimals to be generated. Effectively fValue is rounded at
+ this position, specifying nDecPlaces <= 0 accordingly rounds the value
+ before the decimal point and fills with zeros.
+ If eFormat == rtl_math_StringFormat_Automatic and nDecPlaces ==
+ rtl_math_DecimalPlaces_Max, the highest number of significant decimals
+ possible is generated.
+ If eFormat == rtl_math_StringFormat_G, nDecPlaces specifies the number of
+ significant digits instead. If nDecPlaces ==
+ rtl_math_DecimalPlaces_DefaultSignificance, the default number (currently 6
+ as implemented by most libraries) of significant digits is generated.
+ According to the ANSI C90 standard the E style will be used only if the
+ exponent resulting from the conversion is less than -4 or greater than or
+ equal to the precision. However, as opposed to the ANSI standard, trailing
+ zeros are not necessarily removed from the fractional portion of the result
+ unless bEraseTrailingDecZeros == true was specified.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param pGroups
+ Either null (no grouping is used), or a null-terminated list of group
+ lengths. Each group length must be strictly positive. If the number of
+ digits in a conversion exceeds the specified range, the last (highest) group
+ length is repeated as needed. Values are applied from right to left, for a
+ grouping of 1,00,00,000 you'd have to specify pGroups={3,2,0}.
+
+ @param cGroupSeparator
+ The group separator. Ignored if pGroups is null.
+
+ @param bEraseTrailingDecZeros
+ Trailing zeros in decimal places are erased.
+ */
+void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult,
+ sal_Int32 * pResultCapacity,
+ sal_Int32 nResultOffset, double fValue,
+ enum rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Unicode cGroupSeparator,
+ sal_Bool bEraseTrailingDecZeros)
+ SAL_THROW_EXTERN_C();
+
+/** Conversion analogous to strtod(), convert a string representing a
+ decimal number into a double value.
+
+ Leading tabs (0x09) and spaces (0x20) are eaten. Overflow returns
+ +/-HUGE_VAL, underflow 0. In both cases pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange, otherwise to
+ rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are
+ recognized as +/-HUGE_VAL, pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are
+ recognized and the value is set to +/-NAN, pStatus is set to
+ rtl_math_ConversionStatus_Ok.
+
+ @param pBegin
+ Points to the start of the byte string to convert. Must not be null.
+
+ @param pEnd
+ Points one past the end of the byte string to convert. The condition
+ pEnd >= pBegin must hold.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param cGroupSeparator
+ The group (aka thousands) separator.
+
+ @param pStatus
+ If non-null, returns the status of the conversion.
+
+ @param pParsedEnd
+ If non-null, returns one past the position of the last character parsed
+ away. Thus if [pBegin..pEnd) only contains the numerical string to be
+ parsed, *pParsedEnd == pEnd on return.
+ */
+double SAL_CALL rtl_math_stringToDouble(
+ sal_Char const * pBegin, sal_Char const * pEnd, sal_Char cDecSeparator,
+ sal_Char cGroupSeparator, enum rtl_math_ConversionStatus * pStatus,
+ sal_Char const ** pParsedEnd) SAL_THROW_EXTERN_C();
+
+/** Conversion analogous to strtod(), convert a string representing a
+ decimal number into a double value.
+
+ Leading tabs (U+0009) and spaces (U+0020) are eaten. Overflow returns
+ +/-HUGE_VAL, underflow 0. In both cases pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange, otherwise to
+ rtl_math_ConversionStatus_Ok. "INF", "-INF" and "+/-1.#INF" are
+ recognized as +/-HUGE_VAL, pStatus is set to
+ rtl_math_ConversionStatus_OutOfRange. "NaN" and "+/-1.#NAN" are
+ recognized and the value is set to +/-NAN, pStatus is set to
+ rtl_math_ConversionStatus_Ok.
+
+ @param pBegin
+ Points to the start of the Unicode string to convert. Must not be null.
+
+ @param pEnd
+ Points one past the end of the Unicode string to convert. The condition
+ pEnd >= pBegin must hold.
+
+ @param cDecSeparator
+ The decimal separator.
+
+ @param cGroupSeparator
+ The group (aka thousands) separator.
+
+ @param pStatus
+ If non-null, returns the status of the conversion.
+
+ @param pParsedEnd
+ If non-null, returns one past the position of the last character parsed
+ away. Thus if [pBegin..pEnd) only contains the numerical string to be
+ parsed, *pParsedEnd == pEnd on return.
+ */
+double SAL_CALL rtl_math_uStringToDouble(
+ sal_Unicode const * pBegin, sal_Unicode const * pEnd,
+ sal_Unicode cDecSeparator, sal_Unicode cGroupSeparator,
+ enum rtl_math_ConversionStatus * pStatus, sal_Unicode const ** pParsedEnd)
+ SAL_THROW_EXTERN_C();
+
+/** Rounds a double value.
+
+ @param fValue
+ Specifies the value to be rounded.
+
+ @param nDecPlaces
+ Specifies the decimal place where rounding occurs. Must be in the range
+ -20 to +20, inclusive. Negative if rounding occurs before the decimal
+ point.
+
+ @param eMode
+ Specifies the rounding mode.
+ */
+double SAL_CALL rtl_math_round(double fValue, int nDecPlaces,
+ enum rtl_math_RoundingMode eMode)
+ SAL_THROW_EXTERN_C();
+
+/** Scales fVal to a power of 10 without calling pow() or div() for nExp values
+ between -16 and +16, providing a faster method.
+
+ @param fValue
+ The value to be raised.
+
+ @param nExp
+ The exponent.
+
+ @return
+ fVal * pow(10.0, nExp)
+ */
+double SAL_CALL rtl_math_pow10Exp(double fValue, int nExp) SAL_THROW_EXTERN_C();
+
+/** Rounds value to 15 significant decimal digits.
+
+ @param fValue
+ The value to be rounded.
+ */
+double SAL_CALL rtl_math_approxValue(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns more accurate e^x-1 for x near 0 than calculating directly.
+
+ expm1 is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term e^x-1.
+ */
+double SAL_CALL rtl_math_expm1(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns more accurate log(1+x) for x near 0 than calculating directly.
+
+ log1p is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term log(1+x).
+ */
+double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns more accurate atanh(x) for x near 0 than calculating
+ 0.5*log((1+x)/(1-x)).
+
+ atanh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term atanh(x).
+ */
+double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the Errorfunction erf.
+
+ erf is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term erf(x).
+ */
+double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the complement Errorfunction erfc.
+
+ erfc is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term erfc(x).
+ */
+double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the inverse hyperbolic sine.
+
+ asinh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term asinh(x).
+ */
+double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the inverse hyperbolic cosine.
+
+ acosh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term acosh(x).
+ */
+double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C();
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_RTL_MATH_H */
diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx
new file mode 100644
index 000000000000..31308b561185
--- /dev/null
+++ b/sal/inc/rtl/math.hxx
@@ -0,0 +1,432 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if !defined INCLUDED_RTL_MATH_HXX
+#define INCLUDED_RTL_MATH_HXX
+
+#include "rtl/math.h"
+#include "rtl/string.hxx"
+#include "rtl/ustring.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "sal/mathconf.h"
+#include "sal/types.h"
+
+#include <math.h>
+
+namespace rtl {
+
+namespace math {
+
+/** A wrapper around rtl_math_doubleToString.
+ */
+inline rtl::OString doubleToString(double fValue, rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Char cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Char cGroupSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OString aResult;
+ rtl_math_doubleToString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, pGroups, cGroupSeparator,
+ bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToString, with no grouping.
+ */
+inline rtl::OString doubleToString(double fValue, rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Char cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OString aResult;
+ rtl_math_doubleToString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, 0, 0, bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToUString.
+ */
+inline rtl::OUString doubleToUString(double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Unicode cGroupSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OUString aResult;
+ rtl_math_doubleToUString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, pGroups, cGroupSeparator,
+ bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToUString, with no grouping.
+ */
+inline rtl::OUString doubleToUString(double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl::OUString aResult;
+ rtl_math_doubleToUString(&aResult.pData, 0, 0, fValue, eFormat, nDecPlaces,
+ cDecSeparator, 0, 0, bEraseTrailingDecZeros);
+ return aResult;
+}
+
+/** A wrapper around rtl_math_doubleToUString that appends to an
+ rtl::OUStringBuffer.
+ */
+inline void doubleToUStringBuffer( rtl::OUStringBuffer& rBuffer, double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ sal_Int32 const * pGroups,
+ sal_Unicode cGroupSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl_uString ** pData;
+ sal_Int32 * pCapacity;
+ rBuffer.accessInternals( &pData, &pCapacity );
+ rtl_math_doubleToUString( pData, pCapacity, rBuffer.getLength(), fValue,
+ eFormat, nDecPlaces, cDecSeparator, pGroups,
+ cGroupSeparator, bEraseTrailingDecZeros);
+}
+
+/** A wrapper around rtl_math_doubleToUString that appends to an
+ rtl::OUStringBuffer, with no grouping.
+ */
+inline void doubleToUStringBuffer( rtl::OUStringBuffer& rBuffer, double fValue,
+ rtl_math_StringFormat eFormat,
+ sal_Int32 nDecPlaces,
+ sal_Unicode cDecSeparator,
+ bool bEraseTrailingDecZeros = false)
+{
+ rtl_uString ** pData;
+ sal_Int32 * pCapacity;
+ rBuffer.accessInternals( &pData, &pCapacity );
+ rtl_math_doubleToUString( pData, pCapacity, rBuffer.getLength(), fValue,
+ eFormat, nDecPlaces, cDecSeparator, 0, 0,
+ bEraseTrailingDecZeros);
+}
+
+/** A wrapper around rtl_math_stringToDouble.
+ */
+inline double stringToDouble(rtl::OString const & rString,
+ sal_Char cDecSeparator, sal_Char cGroupSeparator,
+ rtl_math_ConversionStatus * pStatus,
+ sal_Int32 * pParsedEnd)
+{
+ sal_Char const * pBegin = rString.getStr();
+ sal_Char const * pEnd;
+ double fResult = rtl_math_stringToDouble(pBegin,
+ pBegin + rString.getLength(),
+ cDecSeparator, cGroupSeparator,
+ pStatus, &pEnd);
+ if (pParsedEnd != 0)
+ *pParsedEnd = (sal_Int32)(pEnd - pBegin);
+ return fResult;
+}
+
+/** A wrapper around rtl_math_uStringToDouble.
+ */
+inline double stringToDouble(rtl::OUString const & rString,
+ sal_Unicode cDecSeparator,
+ sal_Unicode cGroupSeparator,
+ rtl_math_ConversionStatus * pStatus,
+ sal_Int32 * pParsedEnd)
+{
+ sal_Unicode const * pBegin = rString.getStr();
+ sal_Unicode const * pEnd;
+ double fResult = rtl_math_uStringToDouble(pBegin,
+ pBegin + rString.getLength(),
+ cDecSeparator, cGroupSeparator,
+ pStatus, &pEnd);
+ if (pParsedEnd != 0)
+ *pParsedEnd = (sal_Int32)(pEnd - pBegin);
+ return fResult;
+}
+
+/** A wrapper around rtl_math_round.
+ */
+inline double round(
+ double fValue, int nDecPlaces = 0,
+ rtl_math_RoundingMode eMode = rtl_math_RoundingMode_Corrected)
+{
+ return rtl_math_round(fValue, nDecPlaces, eMode);
+}
+
+/** A wrapper around rtl_math_pow10Exp.
+ */
+inline double pow10Exp(double fValue, int nExp)
+{
+ return rtl_math_pow10Exp(fValue, nExp);
+}
+
+/** A wrapper around rtl_math_approxValue.
+ */
+inline double approxValue(double fValue)
+{
+ return rtl_math_approxValue(fValue);
+}
+
+/** A wrapper around rtl_math_expm1.
+ */
+inline double expm1(double fValue)
+{
+ return rtl_math_expm1(fValue);
+}
+
+/** A wrapper around rtl_math_log1p.
+ */
+inline double log1p(double fValue)
+{
+ return rtl_math_log1p(fValue);
+}
+
+/** A wrapper around rtl_math_atanh.
+ */
+inline double atanh(double fValue)
+{
+ return rtl_math_atanh(fValue);
+}
+
+/** A wrapper around rtl_math_erf.
+ */
+inline double erf(double fValue)
+{
+ return rtl_math_erf(fValue);
+}
+
+/** A wrapper around rtl_math_erfc.
+ */
+inline double erfc(double fValue)
+{
+ return rtl_math_erfc(fValue);
+}
+
+/** A wrapper around rtl_math_asinh.
+ */
+inline double asinh(double fValue)
+{
+ return rtl_math_asinh(fValue);
+}
+
+/** A wrapper around rtl_math_acosh.
+ */
+inline double acosh(double fValue)
+{
+ return rtl_math_acosh(fValue);
+}
+
+
+/** Test equality of two values with an accuracy of the magnitude of the
+ given values scaled by 2^-48 (4 bits roundoff stripped).
+
+ @ATTENTION
+ approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+ */
+inline bool approxEqual(double a, double b)
+{
+ if ( a == b )
+ return true;
+ double x = a - b;
+ return (x < 0.0 ? -x : x)
+ < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
+}
+
+/** Add two values.
+
+ If signs differ and the absolute values are equal according to approxEqual()
+ the method returns 0.0 instead of calculating the sum.
+
+ If you wanted to sum up multiple values it would be convenient not to call
+ approxAdd() for each value but instead remember the first value not equal to
+ 0.0, add all other values using normal + operator, and with the result and
+ the remembered value call approxAdd().
+ */
+inline double approxAdd(double a, double b)
+{
+ if ( ((a < 0.0 && b > 0.0) || (b < 0.0 && a > 0.0))
+ && approxEqual( a, -b ) )
+ return 0.0;
+ return a + b;
+}
+
+/** Substract two values (a-b).
+
+ If signs are identical and the values are equal according to approxEqual()
+ the method returns 0.0 instead of calculating the substraction.
+ */
+inline double approxSub(double a, double b)
+{
+ if ( ((a < 0.0 && b < 0.0) || (a > 0.0 && b > 0.0)) && approxEqual( a, b ) )
+ return 0.0;
+ return a - b;
+}
+
+/** floor() method taking approxValue() into account.
+
+ Use for expected integer values being calculated by double functions.
+ */
+inline double approxFloor(double a)
+{
+ return floor( approxValue( a ));
+}
+
+/** ceil() method taking approxValue() into account.
+
+ Use for expected integer values being calculated by double functions.
+ */
+inline double approxCeil(double a)
+{
+ return ceil( approxValue( a ));
+}
+
+/** Tests whether a value is neither INF nor NAN.
+ */
+inline bool isFinite(double d)
+{
+ return SAL_MATH_FINITE(d) != 0;
+}
+
+/** If a value represents +INF or -INF.
+
+ The sign bit may be queried with isSignBitSet().
+
+ If isFinite(d)==false and isInf(d)==false then NAN.
+ */
+inline bool isInf(double d)
+{
+ // exponent==0x7ff fraction==0
+ return (SAL_MATH_FINITE(d) == 0) &&
+ (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_hi == 0)
+ && (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_lo
+ == 0);
+}
+
+/** Test on any QNAN or SNAN.
+ */
+inline bool isNan(double d)
+{
+ // exponent==0x7ff fraction!=0
+ return (SAL_MATH_FINITE(d) == 0) && (
+ (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_hi != 0)
+ || (reinterpret_cast< sal_math_Double * >(&d)->inf_parts.fraction_lo
+ != 0) );
+}
+
+/** If the sign bit is set.
+ */
+inline bool isSignBitSet(double d)
+{
+ return reinterpret_cast< sal_math_Double * >(&d)->inf_parts.sign != 0;
+}
+
+/** Set to +INF if bNegative==false or -INF if bNegative==true.
+ */
+inline void setInf(double * pd, bool bNegative)
+{
+ union
+ {
+ double sd;
+ sal_math_Double md;
+ };
+ md.w32_parts.msw = bNegative ? 0xFFF00000 : 0x7FF00000;
+ md.w32_parts.lsw = 0;
+ *pd = sd;
+}
+
+/** Set a QNAN.
+ */
+inline void setNan(double * pd)
+{
+ union
+ {
+ double sd;
+ sal_math_Double md;
+ };
+ md.w32_parts.msw = 0x7FFFFFFF;
+ md.w32_parts.lsw = 0xFFFFFFFF;
+ *pd = sd;
+}
+
+/** If a value is a valid argument for sin(), cos(), tan().
+
+ IEEE 754 specifies that absolute values up to 2^64 (=1.844e19) for the
+ radian must be supported by trigonometric functions. Unfortunately, at
+ least on x86 architectures, the FPU doesn't generate an error pattern for
+ values >2^64 but produces erroneous results instead and sets only the
+ "invalid operation" (IM) flag in the status word :-( Thus the application
+ has to handle it itself.
+ */
+inline bool isValidArcArg(double d)
+{
+ return fabs(d)
+ <= (static_cast< double >(static_cast< unsigned long >(0x80000000))
+ * static_cast< double >(static_cast< unsigned long >(0x80000000))
+ * 2);
+}
+
+/** Safe sin(), returns NAN if not valid.
+ */
+inline double sin(double d)
+{
+ if ( isValidArcArg( d ) )
+ return ::sin( d );
+ setNan( &d );
+ return d;
+}
+
+/** Safe cos(), returns NAN if not valid.
+ */
+inline double cos(double d)
+{
+ if ( isValidArcArg( d ) )
+ return ::cos( d );
+ setNan( &d );
+ return d;
+}
+
+/** Safe tan(), returns NAN if not valid.
+ */
+inline double tan(double d)
+{
+ if ( isValidArcArg( d ) )
+ return ::tan( d );
+ setNan( &d );
+ return d;
+}
+
+}
+
+}
+
+#endif // INCLUDED_RTL_MATH_HXX
diff --git a/sal/inc/rtl/memory.h b/sal/inc/rtl/memory.h
new file mode 100644
index 000000000000..11e50e9dc963
--- /dev/null
+++ b/sal/inc/rtl/memory.h
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _RTL_MEMORY_H_
+#define _RTL_MEMORY_H_
+
+# include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void SAL_CALL rtl_zeroMemory(void *Ptr, sal_Size Bytes);
+void SAL_CALL rtl_fillMemory(void *Ptr, sal_Size Bytes, sal_uInt8 Fill);
+void SAL_CALL rtl_copyMemory(void *Dst, const void *Src, sal_Size Bytes);
+void SAL_CALL rtl_moveMemory(void *Dst, const void *Src, sal_Size Bytes);
+sal_Int32 SAL_CALL rtl_compareMemory(const void *MemA, const void *MemB, sal_Size Bytes);
+void* SAL_CALL rtl_findInMemory(const void *MemA, sal_uInt8 ch, sal_Size Bytes);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /*_RTL_MEMORY_H_ */
+
diff --git a/sal/inc/rtl/process.h b/sal/inc/rtl/process.h
new file mode 100644
index 000000000000..b2e471f2def6
--- /dev/null
+++ b/sal/inc/rtl/process.h
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_PROCESS_H_
+#define _RTL_PROCESS_H_
+
+#include <sal/types.h>
+#include <osl/process.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ gets a 16-byte fixed size identifier which is guaranteed not to change
+ during the current process.
+
+ The current implementation creates a 16-byte uuid without using
+ the ethernet address of system. Thus the
+ identifier is different from identifiers created
+ in other processes with a very probability.
+
+ @param pTargetUUID 16 byte of memory
+ @see rtl_createUiid()
+ */
+void SAL_CALL rtl_getGlobalProcessId( sal_uInt8 *pTargetUUID );
+
+/** Get the nArg-th command-line argument passed to the main-function of this process.
+
+ This functions differs from osl_getCommandArg() in filtering any bootstrap values
+ given by command args, that means that all arguments starting with "-env:" will be
+ ignored by this function.
+
+ @param nArg [in] The number of the argument to return.
+ @param strCommandArg [out] The string receives the nArg-th command-line argument.
+ @return osl_Process_E_None or does not return.
+ @see osl_getCommandArg()
+ @see rtl_getCommandArgCount()
+*/
+oslProcessError SAL_CALL rtl_getAppCommandArg(sal_uInt32 nArg, rtl_uString **strCommandArg);
+
+/** Returns the number of command line arguments at process start.
+
+ This functions differs from osl_getCommandArg() in filtering any bootstrap values
+ given by command args, that means that all arguments starting with "-env:" will be
+ ignored by this function.
+
+ @return the number of commandline arguments passed to the main-function of this process.
+ @see osl_getCommandArgCount()
+ @see rtl_getCommandArg()
+*/
+sal_uInt32 SAL_CALL rtl_getAppCommandArgCount();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sal/inc/rtl/random.h b/sal/inc/rtl/random.h
new file mode 100644
index 000000000000..52e2d56968b9
--- /dev/null
+++ b/sal/inc/rtl/random.h
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_RANDOM_H_
+#define _RTL_RANDOM_H_ "$Revision: 1.7 $"
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ *
+ * rtlRandom interface.
+ *
+ *======================================================================*/
+/** Random Pool opaque type.
+ */
+typedef void* rtlRandomPool;
+
+
+/** Error Code enumeration.
+ */
+enum __rtl_RandomError
+{
+ rtl_Random_E_None,
+ rtl_Random_E_Argument,
+ rtl_Random_E_Memory,
+ rtl_Random_E_Unknown,
+ rtl_Random_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
+
+/** Error Code type.
+ */
+typedef enum __rtl_RandomError rtlRandomError;
+
+
+/** Create a Random Pool.
+ @return initialized Random Pool, or NULL upon failure.
+ */
+rtlRandomPool SAL_CALL rtl_random_createPool (void) SAL_THROW_EXTERN_C();
+
+
+/** Destroy a Random Pool.
+ @param Pool [in] a Random Pool.
+ @return none. Pool is invalid.
+ */
+void SAL_CALL rtl_random_destroyPool (
+ rtlRandomPool Pool
+) SAL_THROW_EXTERN_C();
+
+
+/** Add bytes to a Random Pool.
+ @param Pool [in] a Random Pool.
+ @param pBuffer [in] a buffer containing the bytes to add.
+ @param nBufLen [in] the number of bytes to read from the buffer.
+ @return rtl_Random_E_None upon success.
+ */
+rtlRandomError SAL_CALL rtl_random_addBytes (
+ rtlRandomPool Pool,
+ const void *Buffer,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+
+/** Retrieve bytes from a Random Pool.
+ @param Pool [in] a Random Pool.
+ @param pBuffer [inout] a buffer to receive the random bytes.
+ @param nBufLen [in] the number of bytes to write to the buffer.
+ @return rtl_Random_E_None upon success.
+ */
+rtlRandomError SAL_CALL rtl_random_getBytes (
+ rtlRandomPool Pool,
+ void *Buffer,
+ sal_Size Bytes
+) SAL_THROW_EXTERN_C();
+
+/*========================================================================
+ *
+ * The End.
+ *
+ *======================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_RANDOM_H_ */
+
diff --git a/sal/inc/rtl/ref.hxx b/sal/inc/rtl/ref.hxx
new file mode 100644
index 000000000000..66e621cc29a5
--- /dev/null
+++ b/sal/inc/rtl/ref.hxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_REF_HXX_
+#define _RTL_REF_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+namespace rtl
+{
+
+/** Interface for a reference type.
+*/
+class IReference
+{
+public:
+ /** @see osl_incrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL acquire() = 0;
+
+ /** @see osl_decrementInterlockedCount.
+ */
+ virtual oslInterlockedCount SAL_CALL release() = 0;
+};
+
+
+/** Template reference class for reference type derived from IReference.
+*/
+template <class reference_type>
+class Reference
+{
+ /** The <b>reference_type</b> body pointer.
+ */
+ reference_type * m_pBody;
+
+
+public:
+ /** Constructor...
+ */
+ inline Reference()
+ : m_pBody (0)
+ {}
+
+
+ /** Constructor...
+ */
+ inline Reference (reference_type * pBody)
+ : m_pBody (pBody)
+ {
+ if (m_pBody)
+ m_pBody->acquire();
+ }
+
+
+ /** Copy constructor...
+ */
+ inline Reference (const Reference<reference_type> & handle)
+ : m_pBody (handle.m_pBody)
+ {
+ if (m_pBody)
+ m_pBody->acquire();
+ }
+
+
+ /** Destructor...
+ */
+ inline ~Reference()
+ {
+ if (m_pBody)
+ m_pBody->release();
+ }
+
+ /** Set...
+ Similar to assignment.
+ */
+ inline Reference<reference_type> &
+ SAL_CALL set (reference_type * pBody)
+ {
+ if (pBody)
+ pBody->acquire();
+ reference_type * const pOld = m_pBody;
+ m_pBody = pBody;
+ if (pOld)
+ pOld->release();
+ return *this;
+ }
+
+ /** Assignment.
+ Unbinds this instance from its body (if bound) and
+ bind it to the body represented by the handle.
+ */
+ inline Reference<reference_type> &
+ SAL_CALL operator= (const Reference<reference_type> & handle)
+ {
+ return set( handle.m_pBody );
+ }
+
+ /** Assignment...
+ */
+ inline Reference<reference_type> &
+ SAL_CALL operator= (reference_type * pBody)
+ {
+ return set( pBody );
+ }
+
+ /** Unbind the body from this handle.
+ Note that for a handle representing a large body,
+ "handle.clear().set(new body());" _might_
+ perform a little bit better than "handle.set(new body());",
+ since in the second case two large objects exist in memory
+ (the old body and the new body).
+ */
+ inline Reference<reference_type> & SAL_CALL clear()
+ {
+ if (m_pBody)
+ {
+ reference_type * const pOld = m_pBody;
+ m_pBody = 0;
+ pOld->release();
+ }
+ return *this;
+ }
+
+
+ /** Get the body. Can be used instead of operator->().
+ I.e. handle->someBodyOp() and handle.get()->someBodyOp()
+ are the same.
+ */
+ inline reference_type * SAL_CALL get() const
+ {
+ return m_pBody;
+ }
+
+
+ /** Probably most common used: handle->someBodyOp().
+ */
+ inline reference_type * SAL_CALL operator->() const
+ {
+ OSL_PRECOND(m_pBody, "Reference::operator->() : null body");
+ return m_pBody;
+ }
+
+
+ /** Allows (*handle).someBodyOp().
+ */
+ inline reference_type & SAL_CALL operator*() const
+ {
+ OSL_PRECOND(m_pBody, "Reference::operator*() : null body");
+ return *m_pBody;
+ }
+
+
+ /** Returns True if the handle does point to a valid body.
+ */
+ inline sal_Bool SAL_CALL is() const
+ {
+ return (m_pBody != 0);
+ }
+
+
+ /** Returns True if this points to pBody.
+ */
+ inline sal_Bool SAL_CALL operator== (const reference_type * pBody) const
+ {
+ return (m_pBody == pBody);
+ }
+
+
+ /** Returns True if handle points to the same body.
+ */
+ inline sal_Bool
+ SAL_CALL operator== (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody == handle.m_pBody);
+ }
+
+
+ /** Needed to place References into STL collection.
+ */
+ inline sal_Bool
+ SAL_CALL operator!= (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody != handle.m_pBody);
+ }
+
+
+ /** Needed to place References into STL collection.
+ */
+ inline sal_Bool
+ SAL_CALL operator< (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody < handle.m_pBody);
+ }
+
+
+ /** Needed to place References into STL collection.
+ */
+ inline sal_Bool
+ SAL_CALL operator> (const Reference<reference_type> & handle) const
+ {
+ return (m_pBody > handle.m_pBody);
+ }
+};
+
+/** @internal
+ Enables boost::mem_fn and boost::bind to recognize Reference.
+*/
+template <typename T>
+inline T * get_pointer( Reference<T> const& r )
+{
+ return r.get();
+}
+
+} // namespace rtl
+
+#endif /* !_RTL_REF_HXX_ */
diff --git a/sal/inc/rtl/strbuf.h b/sal/inc/rtl/strbuf.h
new file mode 100644
index 000000000000..b471cf8f5f83
--- /dev/null
+++ b/sal/inc/rtl/strbuf.h
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRBUF_H_
+#define _RTL_STRBUF_H_
+
+#include <rtl/string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @HTML
+ Allocates a new <code>String</code> that contains characters from
+ the character array argument.
+
+ The <code>count</code> argument specifies
+ the length of the array. The initial capacity of the string buffer is
+ <code>16</code> plus the length of the string argument.
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param value the initial value of the string.
+ @param count the length of value.
+ */
+void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr,
+ const sal_Char * value,
+ sal_Int32 count);
+
+/**
+ Allocates a new <code>String</code> that contains the same sequence of
+ characters as the string argument.
+
+ The initial capacity is the larger of:
+ <ul>
+ <li> The <code>bufferLen</code> argument.
+ <li> The <code>length</code> of the string argument.
+ </ul>
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param capacity the initial len of the string buffer.
+ @param oldStr the initial value of the string.
+ @return the new capacity of the string buffer
+ */
+sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr,
+ sal_Int32 capacity,
+ rtl_String * olsStr );
+
+/**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ If the current capacity of this string buffer is less than the
+ argument, then a new internal buffer is allocated with greater
+ capacity. The new capacity is the larger of:
+ <ul>
+ <li>The <code>minimumCapacity</code> argument.
+ <li>Twice the old capacity, plus <code>2</code>.
+ </ul>
+ If the <code>minimumCapacity</code> argument is nonpositive, this
+ method takes no action and simply returns.
+
+ @param capacity in: old capicity, out: new capacity.
+ @param minimumCapacity the minimum desired capacity.
+ */
+void SAL_CALL rtl_stringbuffer_ensureCapacity( /*inout*/rtl_String ** This,
+ /*inout*/sal_Int32* capacity,
+ sal_Int32 minimumCapacity);
+
+
+/**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+
+ @param capacity the capacity of the string buffer
+ @param offset the offset.
+ @param ch a character array.
+ @param len the number of characters to append.
+ @return this string buffer.
+ */
+void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This,
+ /*inout*/sal_Int32 * capacity,
+ sal_Int32 offset,
+ const sal_Char * str,
+ sal_Int32 len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_STRBUF_H_ */
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
new file mode 100644
index 000000000000..b6920049f2fb
--- /dev/null
+++ b/sal/inc/rtl/strbuf.hxx
@@ -0,0 +1,665 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRBUF_HXX_
+#define _RTL_STRBUF_HXX_
+
+#include "osl/diagnose.h"
+#include <rtl/strbuf.h>
+#include <rtl/string.hxx>
+
+#ifdef __cplusplus
+
+namespace rtl
+{
+
+/** @HTML
+
+ A string buffer implements a mutable sequence of characters.
+ <p>
+ String buffers are safe for use by multiple threads. The methods
+ are synchronized where necessary so that all the operations on any
+ particular instance behave as if they occur in some serial order.
+ <p>
+ String buffers are used by the compiler to implement the binary
+ string concatenation operator <code>+</code>. For example, the code:
+ <p><blockquote><pre>
+ x = "a" + 4 + "c"
+ </pre></blockquote><p>
+ is compiled to the equivalent of:
+ <p><blockquote><pre>
+ x = new OStringBuffer().append("a").append(4).append("c")
+ .toString()
+ </pre></blockquote><p>
+ The principal operations on a <code>OStringBuffer</code> are the
+ <code>append</code> and <code>insert</code> methods, which are
+ overloaded so as to accept data of any type. Each effectively
+ converts a given datum to a string and then appends or inserts the
+ characters of that string to the string buffer. The
+ <code>append</code> method always adds these characters at the end
+ of the buffer; the <code>insert</code> method adds the characters at
+ a specified point.
+ <p>
+ For example, if <code>z</code> refers to a string buffer object
+ whose current contents are "<code>start</code>", then
+ the method call <code>z.append("le")</code> would cause the string
+ buffer to contain "<code>startle</code>", whereas
+ <code>z.insert(4, "le")</code> would alter the string buffer to
+ contain "<code>starlet</code>".
+ <p>
+ Every string buffer has a capacity. As long as the length of the
+ character sequence contained in the string buffer does not exceed
+ the capacity, it is not necessary to allocate a new internal
+ buffer array. If the internal buffer overflows, it is
+ automatically made larger.
+ */
+class OStringBuffer
+{
+public:
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity of 16 characters.
+ */
+ OStringBuffer()
+ : pData(NULL)
+ , nCapacity( 16 )
+ {
+ rtl_string_new_WithLength( &pData, nCapacity );
+ }
+
+ /**
+ Allocates a new string buffer that contains the same sequence of
+ characters as the string buffer argument.
+
+ @param value a <code>OStringBuffer</code>.
+ */
+ OStringBuffer( const OStringBuffer & value )
+ : pData(NULL)
+ , nCapacity( value.nCapacity )
+ {
+ rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
+ }
+
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity specified by the <code>length</code> argument.
+
+ @param length the initial capacity.
+ */
+ OStringBuffer(sal_Int32 length)
+ : pData(NULL)
+ , nCapacity( length )
+ {
+ rtl_string_new_WithLength( &pData, length );
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string argument.
+
+ The initial
+ capacity of the string buffer is <code>16</code> plus the length
+ of the string argument.
+
+ @param value the initial string value.
+ */
+ OStringBuffer(OString value)
+ : pData(NULL)
+ , nCapacity( value.getLength() + 16 )
+ {
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
+ }
+
+ /** Assign to this a copy of value.
+ */
+ OStringBuffer& operator = ( const OStringBuffer& value )
+ {
+ if (this != &value)
+ {
+ rtl_stringbuffer_newFromStringBuffer(&pData,
+ value.nCapacity,
+ value.pData);
+ nCapacity = value.nCapacity;
+ }
+ return *this;
+ }
+
+ /**
+ Release the string data.
+ */
+ ~OStringBuffer()
+ {
+ rtl_string_release( pData );
+ }
+
+ /**
+ Fill the string data in the new string and clear the buffer.
+
+ This method is more efficient than the contructor of the string. It does
+ not copy the buffer.
+
+ @return the string previously contained in the buffer.
+ */
+ OString makeStringAndClear()
+ {
+ OString aRet( pData );
+ rtl_string_new(&pData);
+ nCapacity = 0;
+ return aRet;
+ }
+
+ /**
+ Returns the length (character count) of this string buffer.
+
+ @return the number of characters in this string buffer.
+ */
+ sal_Int32 getLength() const
+ {
+ return pData->length;
+ }
+
+ /**
+ Returns the current capacity of the String buffer.
+
+ The capacity
+ is the amount of storage available for newly inserted
+ characters. The real buffer size is 2 bytes longer, because
+ all strings are 0 terminated.
+
+ @return the current capacity of this string buffer.
+ */
+ sal_Int32 getCapacity() const
+ {
+ return nCapacity;
+ }
+
+ /**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ The new capacity will be at least as large as the maximum of the current
+ length (so that no contents of the buffer is destroyed) and the given
+ minimumCapacity. If the given minimumCapacity is negative, nothing is
+ changed.
+
+ @param minimumCapacity the minimum desired capacity.
+ */
+ void ensureCapacity(sal_Int32 minimumCapacity)
+ {
+ rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
+ }
+
+ /**
+ Sets the length of this String buffer.
+
+ If the <code>newLength</code> argument is less than the current
+ length of the string buffer, the string buffer is truncated to
+ contain exactly the number of characters given by the
+ <code>newLength</code> argument.
+ <p>
+ If the <code>newLength</code> argument is greater than or equal
+ to the current length, sufficient null characters
+ (<code>'&#92;u0000'</code>) are appended to the string buffer so that
+ length becomes the <code>newLength</code> argument.
+ <p>
+ The <code>newLength</code> argument must be greater than or equal
+ to <code>0</code>.
+
+ @param newLength the new length of the buffer.
+ */
+ void setLength(sal_Int32 newLength)
+ {
+ OSL_ASSERT(newLength >= 0);
+ // Avoid modifications if pData points to const empty string:
+ if( newLength != pData->length )
+ {
+ if( newLength > nCapacity )
+ rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
+ else
+ pData->buffer[newLength] = '\0';
+ pData->length = newLength;
+ }
+ }
+
+ /**
+ Returns the character at a specific index in this string buffer.
+
+ The first character of a string buffer is at index
+ <code>0</code>, the next at index <code>1</code>, and so on, for
+ array indexing.
+ <p>
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the desired character.
+ @return the character at the specified index of this string buffer.
+ */
+ sal_Char charAt( sal_Int32 index )
+ {
+ OSL_ASSERT(index >= 0 && index < pData->length);
+ return pData->buffer[ index ];
+ }
+
+ /**
+ Return a null terminated character array.
+ */
+ operator const sal_Char *() const { return pData->buffer; }
+
+ /**
+ Return a null terminated character array.
+ */
+ const sal_Char* getStr() const { return pData->buffer; }
+
+
+ /**
+ The character at the specified index of this string buffer is set
+ to <code>ch</code>.
+
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the character to modify.
+ @param ch the new character.
+ */
+ OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch)
+ {
+ OSL_ASSERT(index >= 0 && index < pData->length);
+ pData->buffer[ index ] = ch;
+ return *this;
+ }
+
+ /**
+ Appends the string to this string buffer.
+
+ The characters of the <code>String</code> argument are appended, in
+ order, to the contents of this string buffer, increasing the
+ length of this string buffer by the length of the argument.
+
+ @param str a string.
+ @return this string buffer.
+ */
+ OStringBuffer & append(const OString &str)
+ {
+ return append( str.getStr(), str.getLength() );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ The characters of the array argument are appended, in order, to
+ the contents of this string buffer. The length of this string
+ buffer increases by the length of the argument.
+
+ @param str the characters to be appended.
+ @return this string buffer.
+ */
+ OStringBuffer & append( const sal_Char * str )
+ {
+ return append( str, rtl_str_getLength( str ) );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ Characters of the character array <code>str</code> are appended,
+ in order, to the contents of this string buffer. The length of this
+ string buffer increases by the value of <code>len</code>.
+
+ @param str the characters to be appended; must be non-null, and must
+ point to at least len characters
+ @param len the number of characters to append; must be non-negative
+ @return this string buffer.
+ */
+ OStringBuffer & append( const sal_Char * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
+ return *this;
+ }
+
+ /**
+ Appends the string representation of the <code>sal_Bool</code>
+ argument to the string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Bool b)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
+ return append( sz, rtl_str_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code>
+ argument to this string buffer.
+
+ The argument is appended to the contents of this string buffer.
+ The length of this string buffer increases by <code>1</code>.
+
+ @param ch a <code>char</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Char c)
+ {
+ return append( &c, 1 );
+ }
+
+ /**
+ Appends the string representation of the <code>sal_Int32</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param i an <code>sal_Int32</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
+ return append( sz, rtl_str_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>long</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param l a <code>long</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
+ return append( sz, rtl_str_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>float</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param f a <code>float</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(float f)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
+ return append( sz, rtl_str_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Appends the string representation of the <code>double</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param d a <code>double</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(double d)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
+ return append( sz, rtl_str_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Inserts the string into this string buffer.
+
+ The characters of the <code>String</code> argument are inserted, in
+ order, into this string buffer at the indicated offset. The length
+ of this string buffer is increased by the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a string.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, const OString & str)
+ {
+ return insert( offset, str.getStr(), str.getLength() );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param ch a character array.
+ @return this string buffer.
+ */
+ OStringBuffer & insert( sal_Int32 offset, const sal_Char * str )
+ {
+ return insert( offset, str, rtl_str_getLength( str ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param ch a character array.
+ @param len the number of characters to append.
+ @return this string buffer.
+ */
+ OStringBuffer & insert( sal_Int32 offset, const sal_Char * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len );
+ return *this;
+ }
+
+ /**
+ Inserts the string representation of the <code>sal_Bool</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Bool b)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
+ return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code>
+ argument into this string buffer.
+
+ The second argument is inserted into the contents of this string
+ buffer at the position indicated by <code>offset</code>. The length
+ of this string buffer increases by one.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param ch a <code>char</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Char c)
+ {
+ return insert( offset, &c, 1 );
+ }
+
+ /**
+ Inserts the string representation of the second <code>sal_Int32</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b an <code>sal_Int32</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT32];
+ return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>long</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>long</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFINT64];
+ return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>float</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>float</code>.
+ @return this string buffer.
+ */
+ OStringBuffer insert(sal_Int32 offset, float f)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT];
+ return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>double</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>double</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & insert(sal_Int32 offset, double d)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE];
+ return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) );
+ }
+private:
+ /**
+ A pointer to the data structur which contains the data.
+ */
+ rtl_String * pData;
+
+ /**
+ The len of the pData->buffer.
+ */
+ sal_Int32 nCapacity;
+};
+
+}
+
+#endif /* __cplusplus */
+#endif /* _RTL_STRBUF_HXX_ */
+
+
diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h
new file mode 100644
index 000000000000..fe8548078227
--- /dev/null
+++ b/sal/inc/rtl/string.h
@@ -0,0 +1,1193 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRING_H_
+#define _RTL_STRING_H_
+
+#include <sal/types.h>
+#include <osl/interlck.h>
+#include <rtl/textcvt.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ======================================================================= */
+
+/** Return the length of a string.
+
+ The length is equal to the number of 8-bit characters in the string,
+ without the terminating NUL character.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the length of the sequence of characters represented by this string,
+ excluding the terminating NUL character.
+ */
+sal_Int32 SAL_CALL rtl_str_getLength( const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting. Both strings must be
+ null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_str_compare( const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_str_compare_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_str_shortenedCompare_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string
+ compares less than the second string, and a value greater than 0 if the
+ first string compares greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_str_reverseCompare_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting. Both strings must be null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase( const sal_Char * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_str_compareIgnoreAsciiCase_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters, ignoring the case
+ of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes. The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ a hash code for the given string.
+ */
+sal_Int32 SAL_CALL rtl_str_hashCode( const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @return
+ a hash code for the given string.
+ */
+sal_Int32 SAL_CALL rtl_str_hashCode_WithLength( const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+sal_Int32 SAL_CALL rtl_str_indexOfChar( const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+sal_Int32 SAL_CALL rtl_str_indexOfChar_WithLength( const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+sal_Int32 SAL_CALL rtl_str_lastIndexOfChar( const sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+sal_Int32 SAL_CALL rtl_str_lastIndexOfChar_WithLength( const sal_Char * str, sal_Int32 len, sal_Char ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_str_indexOfStr( const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_str_indexOfStr_WithLength( const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_str_lastIndexOfStr( const sal_Char * str, const sal_Char * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_str_lastIndexOfStr_WithLength( const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+void SAL_CALL rtl_str_replaceChar( sal_Char * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+void SAL_CALL rtl_str_replaceChar_WithLength( sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+void SAL_CALL rtl_str_toAsciiLowerCase( sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+void SAL_CALL rtl_str_toAsciiLowerCase_WithLength( sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+void SAL_CALL rtl_str_toAsciiUpperCase( sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+void SAL_CALL rtl_str_toAsciiUpperCase_WithLength( sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of a string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the new length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_trim( sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of the string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the original length of the string.
+
+ @return
+ the new length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_trim_WithLength( sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Create the string representation of a boolean.
+
+ If b is true, the buffer is filled with the string "true" and 5 is
+ returned. If b is false, the buffer is filled with the string "false" and
+ 6 is returned. This function cannot be used for language-specific
+ operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFBOOLEAN define to create
+ a buffer that is big enough.
+
+ @param b
+ a boolean value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_valueOfBoolean( sal_Char * str, sal_Bool b ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFBOOLEAN 6
+
+/** Create the string representation of a character.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFCHAR define to create a
+ buffer that is big enough.
+
+ @param ch
+ a character value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_valueOfChar( sal_Char * str, sal_Char ch ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFCHAR 2
+
+/** Create the string representation of an integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFINT32 define to create a
+ buffer that is big enough.
+
+ @param i
+ an integer value.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_valueOfInt32( sal_Char * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MIN_RADIX 2
+#define RTL_STR_MAX_RADIX 36
+#define RTL_STR_MAX_VALUEOFINT32 33
+
+/** Create the string representation of a long integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFINT64 define to create a
+ buffer that is big enough.
+
+ @param l
+ a long integer value.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_valueOfInt64( sal_Char * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFINT64 65
+
+/** Create the string representation of a float.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFFLOAT define to create a
+ buffer that is big enough.
+
+ @param f
+ a float value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_valueOfFloat( sal_Char * str, float f ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFFLOAT 15
+
+/** Create the string representation of a double.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_STR_MAX_VALUEOFDOUBLE define to create
+ a buffer that is big enough.
+
+ @param d
+ a double value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_str_valueOfDouble( sal_Char * str, double d ) SAL_THROW_EXTERN_C();
+#define RTL_STR_MAX_VALUEOFDOUBLE 25
+
+/** Interpret a string as a boolean.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ true if the string is "1" or "true" in any ASCII case, false otherwise.
+ */
+sal_Bool SAL_CALL rtl_str_toBoolean( const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as an integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the integer value represented by the string, or 0 if the string does not
+ represent an integer.
+ */
+sal_Int32 SAL_CALL rtl_str_toInt32( const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a long integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_STR_MIN_RADIX (2) and RTL_STR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the long integer value represented by the string, or 0 if the string does
+ not represent a long integer.
+ */
+sal_Int64 SAL_CALL rtl_str_toInt64( const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a float.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a float.
+ */
+float SAL_CALL rtl_str_toFloat( const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a double.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a double.
+ */
+double SAL_CALL rtl_str_toDouble( const sal_Char * str ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(push, 4)
+#endif
+
+/** The implementation of a byte string.
+
+ @internal
+ */
+typedef struct _rtl_String
+{
+ oslInterlockedCount refCount; /* opaque */
+ sal_Int32 length;
+ sal_Char buffer[1];
+} rtl_String;
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+#pragma pack(pop)
+#endif
+
+/* ----------------------------------------------------------------------- */
+
+/** Increment the reference count of a string.
+
+ @param str
+ a string.
+ */
+void SAL_CALL rtl_string_acquire( rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Decrement the reference count of a string.
+
+ If the count goes to zero than the string data is deleted.
+
+ @param str
+ a string.
+ */
+void SAL_CALL rtl_string_release( rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing no characters.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+ */
+void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
+ If len is greater than zero, the reference count of the new string will be
+ 1. The values of all characters are set to 0 and the length of the string
+ is 0. This function does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param len
+ the number of characters.
+ */
+void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of another string.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a valid string.
+ */
+void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, const rtl_String * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a null-terminated character array.
+ */
+void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a character array. Need not be null-terminated, but must be at least as
+ long as the specified len.
+
+ @param len
+ the length of the character array.
+ */
+void SAL_CALL rtl_string_newFromStr_WithLength( rtl_String ** newStr, const sal_Char * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Assign a new value to a string.
+
+ First releases any value str might currently hold, then acquires
+ rightValue.
+
+ @param str
+ pointer to the string. The pointed-to data must be null or a valid
+ string.
+
+ @param rightValue
+ a valid string.
+ */
+void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ) SAL_THROW_EXTERN_C();
+
+/** Return the length of a string.
+
+ The length is equal to the number of characters in the string.
+
+ @param str
+ a valid string.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_string_getLength( const rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Return a pointer to the underlying character array of a string.
+
+ @param str
+ a valid string.
+
+ @return
+ a pointer to the null-terminated character array.
+ */
+sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string that is the concatenation of two other strings.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where one of the two other strings is empty), so it must not be modified
+ without checking the reference count. This function does not handle
+ out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param left
+ a valid string.
+
+ @param right
+ a valid string.
+ */
+void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing a substring of another string.
+
+ The new string results from replacing a number of characters (count),
+ starting at the specified position (index) in the original string (str),
+ with some new substring (subStr). If subStr is null, than only a number
+ of characters is deleted.
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param index
+ the index into str at which to start replacement. Must be between 0 and
+ the length of str, inclusive.
+
+ @param count
+ the number of charcters to remove. Must not be negative, and the sum of
+ index and count must not exceed the length of str.
+
+ @param subStr
+ either null or a valid string to be inserted.
+ */
+void SAL_CALL rtl_string_newReplaceStrAt( rtl_String ** newStr, rtl_String * str, sal_Int32 idx, sal_Int32 count, rtl_String * subStr ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a single character
+ within another string.
+
+ The new string results from replacing all occurrences of oldChar in str
+ with newChar.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where oldChar does not occur in str), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+void SAL_CALL rtl_string_newReplace( rtl_String ** newStr, rtl_String * str, sal_Char oldChar, sal_Char newChar ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII uppercase letters to lowercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+void SAL_CALL rtl_string_newToAsciiLowerCase( rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII lowercase letters to uppercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+void SAL_CALL rtl_string_newToAsciiUpperCase( rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by removing white space from both ends of another
+ string.
+
+ The new string results from removing all characters with values less than
+ or equal to 32 (the space character) form both ends of str.
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be removed), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+void SAL_CALL rtl_string_newTrim( rtl_String ** newStr, rtl_String * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by extracting a single token from another string.
+
+ Starting at index, the token's next token is searched for. If there is no
+ such token, the result is an empty string. Otherwise, all characters from
+ the start of that token and up to, but not including the next occurrence
+ of cTok make up the resulting token. The return value is the position of
+ the next token, or -1 if no more tokens follow.
+
+ Example code could look like
+ rtl_String * pToken = NULL;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ nIndex = rtl_string_getToken(&pToken, pStr, 0, ';', nIndex);
+ ...
+ }
+ while (nIndex >= 0);
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string. If either token or index is negative, an empty token is stored in
+ newStr (and -1 is returned).
+
+ @param str
+ a valid string.
+
+ @param token
+ the number of the token to return, starting at index.
+
+ @param cTok
+ the character that seperates the tokens.
+
+ @param index
+ the position at which searching for the token starts. Must not be greater
+ than the length of str.
+
+ @return
+ the index of the next token, or -1 if no more tokens follow.
+ */
+sal_Int32 SAL_CALL rtl_string_getToken( rtl_String ** newStr , rtl_String * str, sal_Int32 token, sal_Char cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+/** Supply an ASCII string literal together with its length.
+
+ This macro can be used to compute (some of) the arguments in function calls
+ like rtl::OString(RTL_CONSTASCII_STRINGPARAM("foo")) or
+ rtl::OUString::equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("foo")).
+
+ @param constAsciiStr
+ must be an expression of type "(possibly cv-qualified reference to) array of
+ (possibly cv-qualified) char." Each element of the referenced array must
+ represent an ASCII value in the range 0x00--0x7F. The last element of the
+ referenced array is not considered part of the represented ASCII string, and
+ its value should be 0x00. Depending on where this macro is used, the nature
+ of the supplied expression might be further restricted.
+*/
+#define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, ((sal_Int32)sizeof(constAsciiStr)-1)
+
+/** Supply the length of an ASCII string literal.
+
+ This macro can be used to compute arguments in function calls like
+ rtl::OUString::match(other, RTL_CONSTASCII_LENGTH("prefix")).
+
+ @param constAsciiStr
+ must be an expression of type "(possibly cv-qualified reference to) array of
+ (possibly cv-qualified) char." Each element of the referenced array must
+ represent an ASCII value in the range 0x00--0x7F. The last element of the
+ referenced array is not considered part of the represented ASCII string, and
+ its value should be 0x00. Depending on where this macro is used, the nature
+ of the supplied expression might be further restricted.
+*/
+#define RTL_CONSTASCII_LENGTH( constAsciiStr ) ((sal_Int32)(sizeof(constAsciiStr)-1))
+
+/* ======================================================================= */
+
+/* predefined constants for String-Conversion */
+#define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\
+ RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\
+ RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\
+ RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE)
+
+/* ----------------------------------------------------------------------- */
+
+/** Create a new byte string by converting a Unicode string, using a specific
+ text encoding.
+
+ The lengths of the byte string and the Unicode string may differ (e.g.,
+ for double-byte encodings, UTF-7, UTF-8).
+
+ If the length of the Unicode string is greater than zero, the reference
+ count of the new string will be 1.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a Unicode character array. Need not be null-terminated, but must be at
+ least as long as the specified len.
+
+ @param len
+ the length of the Unicode character array.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OUSTRING_TO_OSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+void SAL_CALL rtl_uString2String( rtl_String ** newStr, const sal_Unicode * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
+
+/**
+ Converts a Unicode string to a byte string, signalling failure.
+
+ @param pTarget
+ An out parameter receiving the converted string. Must not be null itself, and
+ must contain either null or a pointer to a valid rtl_String; the contents are
+ not modified if conversion fails (rtl_convertUStringToString returns false).
+
+ @param pSource
+ The Unicode string. May only be null if nLength is zero.
+
+ @param nLength
+ The length of the Unicode string. Must be non-negative.
+
+ @param nEncoding
+ The text encoding to convert into. Must be an octet encoding (i.e.,
+ rtl_isOctetTextEncoding(nEncoding) must return true).
+
+ @param nFlags
+ A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the conversion
+ (see rtl_convertUnicodeToText). RTL_UNICODETOTEXT_FLAGS_FLUSH need not be
+ included, it is implicitly assumed. Typical uses are either
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot be
+ converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS (make a
+ best efforts conversion).
+
+ @return
+ True if the conversion succeeded, false otherwise.
+ */
+sal_Bool SAL_CALL rtl_convertUStringToString(rtl_String ** pTarget,
+ sal_Unicode const * pSource,
+ sal_Int32 nLength,
+ rtl_TextEncoding nEncoding,
+ sal_uInt32 nFlags)
+ SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_STRING_H_ */
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
new file mode 100644
index 000000000000..c85da92c177b
--- /dev/null
+++ b/sal/inc/rtl/string.hxx
@@ -0,0 +1,941 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_STRING_HXX_
+#define _RTL_STRING_HXX_
+
+#ifdef __cplusplus
+
+#ifndef _RTL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#include <rtl/memory.h>
+#include <rtl/textenc.h>
+#include <rtl/string.h>
+
+#if !defined EXCEPTIONS_OFF
+#include <new>
+#endif
+
+namespace rtl
+{
+
+/* ======================================================================= */
+
+/**
+ This String class provide base functionality for C++ like 8-Bit
+ character array handling. The advantage of this class is, that it
+ handle all the memory managament for you - and it do it
+ more efficient. If you assign a string to another string, the
+ data of both strings are shared (without any copy operation or
+ memory allocation) as long as you do not change the string. This class
+ stores also the length of the string, so that many operations are
+ faster as the C-str-functions.
+
+ This class provide only readonly string handling. So you could create
+ a string and you could only query the content from this string.
+ It provide also functionality to change the string, but this results
+ in every case in a new string instance (in the most cases with an
+ memory allocation). You don't have functionality to change the
+ content of the string. If you want change the string content, than
+ you should us the OStringBuffer class, which provide these
+ functionality and avoid to much memory allocation.
+
+ The design of this class is similar to the string classes in Java
+ and so more people should have fewer understanding problems when they
+ use this class.
+*/
+
+class OString
+{
+public:
+ /** @internal */
+ rtl_String * pData;
+
+private:
+ /** @internal */
+ class DO_NOT_ACQUIRE;
+
+ /** @internal */
+ OString( rtl_String * value, DO_NOT_ACQUIRE * )
+ {
+ pData = value;
+ }
+
+public:
+ /**
+ New string containing no characters.
+ */
+ OString() SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_new( &pData );
+ }
+
+ /**
+ New string from OString.
+
+ @param str a OString.
+ */
+ OString( const OString & str ) SAL_THROW(())
+ {
+ pData = str.pData;
+ rtl_string_acquire( pData );
+ }
+
+ /**
+ New string from OString data.
+
+ @param str a OString data.
+ */
+ OString( rtl_String * str ) SAL_THROW(())
+ {
+ pData = str;
+ rtl_string_acquire( pData );
+ }
+
+ /**
+ New string from a single character.
+
+ @param value a character.
+ */
+ explicit OString( sal_Char value ) SAL_THROW(())
+ : pData (0)
+ {
+ rtl_string_newFromStr_WithLength( &pData, &value, 1 );
+ }
+
+ /**
+ New string from a character buffer array.
+
+ @param value a NULL-terminated character array.
+ */
+ OString( const sal_Char * value ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_newFromStr( &pData, value );
+ }
+
+ /**
+ New string from a character buffer array.
+
+ @param value a character array.
+ @param length the number of character which should be copied.
+ The character array length must be greater or
+ equal than this value.
+ */
+ OString( const sal_Char * value, sal_Int32 length ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_string_newFromStr_WithLength( &pData, value, length );
+ }
+
+ /**
+ New string from a Unicode character buffer array.
+
+ @param value a Unicode character array.
+ @param length the number of character which should be converted.
+ The Unicode character array length must be
+ greater or equal than this value.
+ @param encoding the text encoding in which the Unicode character
+ sequence should be converted.
+ @param convertFlags flags which controls the conversion.
+ see RTL_UNICODETOTEXT_FLAGS_...
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+ */
+ OString( const sal_Unicode * value, sal_Int32 length,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
+ {
+ pData = 0;
+ rtl_uString2String( &pData, value, length, encoding, convertFlags );
+#if defined EXCEPTIONS_OFF
+ OSL_ASSERT(pData != NULL);
+#else
+ if (pData == 0) {
+ throw std::bad_alloc();
+ }
+#endif
+ }
+
+ /**
+ Release the string data.
+ */
+ ~OString() SAL_THROW(())
+ {
+ rtl_string_release( pData );
+ }
+
+ /**
+ Assign a new string.
+
+ @param str a OString.
+ */
+ OString & operator=( const OString & str ) SAL_THROW(())
+ {
+ rtl_string_assign( &pData, str.pData );
+ return *this;
+ }
+
+ /**
+ Append a string to this string.
+
+ @param str a OString.
+ */
+ OString & operator+=( const OString & str ) SAL_THROW(())
+ {
+ rtl_string_newConcat( &pData, pData, str.pData );
+ return *this;
+ }
+
+ /**
+ Returns the length of this string.
+
+ The length is equal to the number of characters in this string.
+
+ @return the length of the sequence of characters represented by this
+ object.
+ */
+ sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
+
+ /**
+ Returns a pointer to the characters of this string.
+
+ <p>The returned pointer is not guaranteed to point to a null-terminated
+ byte string. Note that this string object may contain embedded null
+ characters, which will thus also be embedded in the returned byte
+ string.</p>
+
+ @return a pointer to a (not necessarily null-terminated) byte string
+ representing the characters of this string object.
+ */
+ operator const sal_Char *() const SAL_THROW(()) { return pData->buffer; }
+
+ /**
+ Returns a pointer to the characters of this string.
+
+ <p>The returned pointer is guaranteed to point to a null-terminated byte
+ string. But note that this string object may contain embedded null
+ characters, which will thus also be embedded in the returned
+ null-terminated byte string.</p>
+
+ @return a pointer to a null-terminated byte string representing the
+ characters of this string object.
+ */
+ const sal_Char * getStr() const SAL_THROW(()) { return pData->buffer; }
+
+ /**
+ Compares two strings.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OString & str ) const SAL_THROW(())
+ {
+ return rtl_str_compare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Compares two strings with an maximum count of characters.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @param maxLength the maximum count of characters to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OString & rObj, sal_Int32 maxLength ) const SAL_THROW(())
+ {
+ return rtl_str_shortenedCompare_WithLength( pData->buffer, pData->length,
+ rObj.pData->buffer, rObj.pData->length, maxLength );
+ }
+
+ /**
+ Compares two strings in reverse order.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 reverseCompareTo( const OString & str ) const SAL_THROW(())
+ {
+ return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equals( const OString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_str_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCase( const OString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_str_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool match( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_str_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length, str.pData->length ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string, ignoring the case of
+ ASCII letters.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchIgnoreAsciiCase( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length,
+ str.pData->length ) == 0;
+ }
+
+ friend sal_Bool operator == ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.getLength() == rStr2.getLength() && rStr1.compareTo( rStr2 ) == 0; }
+ friend sal_Bool operator == ( const OString& rStr1, const sal_Char * pStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( pStr2 ) == 0; }
+ friend sal_Bool operator == ( const sal_Char * pStr1, const OString& rStr2 ) SAL_THROW(())
+ { return OString( pStr1 ).compareTo( rStr2 ) == 0; }
+
+ friend sal_Bool operator != ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, rStr2 )); }
+ friend sal_Bool operator != ( const OString& rStr1, const sal_Char * pStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, pStr2 )); }
+ friend sal_Bool operator != ( const sal_Char * pStr1, const OString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( pStr1, rStr2 )); }
+
+ friend sal_Bool operator < ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) < 0; }
+ friend sal_Bool operator > ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) > 0; }
+ friend sal_Bool operator <= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) <= 0; }
+ friend sal_Bool operator >= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) >= 0; }
+
+ /**
+ Returns a hashcode for this string.
+
+ @return a hash code value for this object.
+
+ @see rtl::OStringHash for convenient use of STLPort's hash_map
+ */
+ sal_Int32 hashCode() const SAL_THROW(())
+ {
+ return rtl_str_hashCode_WithLength( pData->buffer, pData->length );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified character, starting the search at the specified index.
+
+ @param ch character to be located.
+ @param fromIndex the index to start the search from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return the index of the first occurrence of the character in the
+ character sequence represented by this string that is
+ greater than or equal to fromIndex, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting at the end.
+
+ @param ch character to be located.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 lastIndexOf( sal_Char ch ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting before the specified
+ index.
+
+ @param ch character to be located.
+ @param fromIndex the index before which to start the search.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string that
+ is less than fromIndex, or -1
+ if the character does not occur before that point.
+ */
+ sal_Int32 lastIndexOf( sal_Char ch, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified substring, starting at the specified index.
+
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index to start the search from.
+ @return If the string argument occurs one or more times as a substring
+ within this string at the starting index, then the index
+ of the first character of the first such substring is
+ returned. If it does not occur as a substring starting
+ at fromIndex or beyond, -1 is returned.
+ */
+ sal_Int32 indexOf( const OString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting at the end.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @return If the string argument occurs one or more times as a substring
+ within this string, then the index of the first character of
+ the last such substring is returned. If it does not occur as
+ a substring, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OString & str ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting before the specified
+ index.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index before which to start the search.
+ @return If the string argument occurs one or more times as a substring
+ within this string before the starting index, then the index
+ of the first character of the last such substring is
+ returned. Otherwise, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OString & str, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex. It is an error for
+ beginIndex to be negative or to be greater than the length of this string.
+
+ @param beginIndex the beginning index, inclusive.
+ @return the specified substring.
+ */
+ OString copy( sal_Int32 beginIndex ) const SAL_THROW(())
+ {
+ OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
+ if ( beginIndex == 0 )
+ return *this;
+ else
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newFromStr_WithLength( &pNew, pData->buffer+beginIndex, getLength()-beginIndex );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. It is an error for either beginIndex or count to be negative,
+ or for beginIndex + count to be greater than the length of this string.
+
+ @param beginIndex the beginning index, inclusive.
+ @param count the number of characters.
+ @return the specified substring.
+ */
+ OString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
+ {
+ OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength()
+ && count >= 0 && count <= getLength() - beginIndex);
+ if ( (beginIndex == 0) && (count == getLength()) )
+ return *this;
+ else
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newFromStr_WithLength( &pNew, pData->buffer+beginIndex, count );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+ }
+
+ /**
+ Concatenates the specified string to the end of this string.
+
+ @param str the string that is concatenated to the end
+ of this string.
+ @return a string that represents the concatenation of this string
+ followed by the string argument.
+ */
+ OString concat( const OString & str ) const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newConcat( &pNew, pData, str.pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ friend OString operator+( const OString & str1, const OString & str2 ) SAL_THROW(())
+ {
+ return str1.concat( str2 );
+ }
+
+ /**
+ Returns a new string resulting from replacing n = count characters
+ from position index in this string with newStr.
+
+ @param index the replacing index in str.
+ The index must be greater or equal as 0 and
+ less or equal as the length of the string.
+ @param count the count of charcters that will replaced
+ The count must be greater or equal as 0 and
+ less or equal as the length of the string minus index.
+ @param newStr the new substring.
+ @return the new string.
+ */
+ OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of
+ oldChar in this string with newChar.
+
+ If the character oldChar does not occur in the character sequence
+ represented by this object, then the string is assigned with
+ str.
+
+ @param oldChar the old character.
+ @param newChar the new character.
+ @return a string derived from this string by replacing every
+ occurrence of oldChar with newChar.
+ */
+ OString replace( sal_Char oldChar, sal_Char newChar ) const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newReplace( &pNew, pData, oldChar, newChar );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Converts from this string all ASCII uppercase characters (65-90)
+ to ASCII lowercase characters (97-122).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII lowercase.
+ */
+ OString toAsciiLowerCase() const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newToAsciiLowerCase( &pNew, pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Converts from this string all ASCII lowercase characters (97-122)
+ to ASCII uppercase characters (65-90).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII uppercase.
+ */
+ OString toAsciiUpperCase() const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newToAsciiUpperCase( &pNew, pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from removing white space from both ends
+ of the string.
+
+ All characters that have codes less than or equal to
+ 32 (the space character) are considered to be white space.
+ If the string doesn't contain white spaces at both ends,
+ then the new string is assigned with str.
+
+ @return the string, with white space removed from the front and end.
+ */
+ OString trim() const SAL_THROW(())
+ {
+ rtl_String* pNew = 0;
+ rtl_string_newTrim( &pNew, pData );
+ return OString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a token in the string.
+
+ Example:
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ OString aToken = aStr.getToken( 0, ';', nIndex );
+ ...
+ }
+ while ( nIndex >= 0 );
+
+ @param token the number of the token to return.
+ @param cTok the character which seperate the tokens.
+ @param index the position at which the token is searched in the
+ string.
+ The index must not be greater thanthe length of the
+ string.
+ This param is set to the position of the
+ next token or to -1, if it is the last token.
+ @return the token; if either token or index is negative, an empty token
+ is returned (and index is set to -1)
+ */
+ OString getToken( sal_Int32 token, sal_Char cTok, sal_Int32& index ) const SAL_THROW(())
+ {
+ rtl_String * pNew = 0;
+ index = rtl_string_getToken( &pNew, pData, token, cTok, index );
+ return OString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Returns the Boolean value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return sal_True, if the string is 1 or "True" in any ASCII case.
+ sal_False in any other case.
+ */
+ sal_Bool toBoolean() const SAL_THROW(())
+ {
+ return rtl_str_toBoolean( pData->buffer );
+ }
+
+ /**
+ Returns the first character from this string.
+
+ @return the first character from this string or 0, if this string
+ is emptry.
+ */
+ sal_Char toChar() const SAL_THROW(())
+ {
+ return pData->buffer[0];
+ }
+
+ /**
+ Returns the int32 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int32 represented from this string.
+ 0 if this string represents no number.
+ */
+ sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_str_toInt32( pData->buffer, radix );
+ }
+
+ /**
+ Returns the int64 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int64 represented from this string.
+ 0 if this string represents no number.
+ */
+ sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_str_toInt64( pData->buffer, radix );
+ }
+
+ /**
+ Returns the float value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the float represented from this string.
+ 0.0 if this string represents no number.
+ */
+ float toFloat() const SAL_THROW(())
+ {
+ return rtl_str_toFloat( pData->buffer );
+ }
+
+ /**
+ Returns the double value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the double represented from this string.
+ 0.0 if this string represents no number.
+ */
+ double toDouble() const SAL_THROW(())
+ {
+ return rtl_str_toDouble( pData->buffer );
+ }
+
+ /**
+ Returns the string representation of the sal_Bool argument.
+
+ If the sal_Bool is true, the string "true" is returned.
+ If the sal_Bool is false, the string "false" is returned.
+ This function can't be used for language specific conversion.
+
+ @param b a sal_Bool.
+ @return a string with the string representation of the argument.
+ */
+ static OString valueOf( sal_Bool b ) SAL_THROW(())
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the char argument.
+
+ @param c a character.
+ @return a string with the string representation of the argument.
+ */
+ static OString valueOf( sal_Char c ) SAL_THROW(())
+ {
+ return OString( &c, 1 );
+ }
+
+ /**
+ Returns the string representation of the int argument.
+
+ This function can't be used for language specific conversion.
+
+ @param i a int32.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ */
+ static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFINT32];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt32( aBuf, i, radix ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the long argument.
+
+ This function can't be used for language specific conversion.
+
+ @param ll a int64.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ */
+ static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the float argument.
+
+ This function can't be used for language specific conversion.
+
+ @param f a float.
+ @return a string with the string representation of the argument.
+ */
+ static OString valueOf( float f ) SAL_THROW(())
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFFLOAT];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfFloat( aBuf, f ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the double argument.
+
+ This function can't be used for language specific conversion.
+
+ @param d a double.
+ @return a string with the string representation of the argument.
+ */
+ static OString valueOf( double d ) SAL_THROW(())
+ {
+ sal_Char aBuf[RTL_STR_MAX_VALUEOFDOUBLE];
+ rtl_String* pNewData = 0;
+ rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfDouble( aBuf, d ) );
+ return OString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+};
+
+/* ======================================================================= */
+
+/** A helper to use OStrings with hash maps.
+
+ Instances of this class are unary function objects that can be used as
+ hash function arguments to STLPort's hash_map and similar constructs.
+ */
+struct OStringHash
+{
+ /** Compute a hash code for a string.
+
+ @param rString
+ a string.
+
+ @return
+ a hash code for the string. This hash code should not be stored
+ persistently, as its computation may change in later revisions.
+ */
+ size_t operator()( const rtl::OString& rString ) const
+ { return (size_t)rString.hashCode(); }
+};
+
+/* ======================================================================= */
+
+} /* Namespace */
+
+#endif /* __cplusplus */
+
+#endif /* _RTL_STRING_HXX_ */
diff --git a/sal/inc/rtl/tencinfo.h b/sal/inc/rtl/tencinfo.h
new file mode 100644
index 000000000000..49c010ebd374
--- /dev/null
+++ b/sal/inc/rtl/tencinfo.h
@@ -0,0 +1,276 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_TENCINFO_H
+#define _RTL_TENCINFO_H
+
+#ifndef _SAL_TYPES_H
+#include <sal/types.h>
+#endif
+#include <rtl/textenc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// See rtl_TextEncodingInfo.Flags below for documentation on these values:
+#define RTL_TEXTENCODING_INFO_CONTEXT ((sal_uInt32)0x00000001)
+#define RTL_TEXTENCODING_INFO_ASCII ((sal_uInt32)0x00000002)
+#define RTL_TEXTENCODING_INFO_UNICODE ((sal_uInt32)0x00000004)
+#define RTL_TEXTENCODING_INFO_MULTIBYTE ((sal_uInt32)0x00000008)
+#define RTL_TEXTENCODING_INFO_R2L ((sal_uInt32)0x00000010)
+#define RTL_TEXTENCODING_INFO_7BIT ((sal_uInt32)0x00000020)
+#define RTL_TEXTENCODING_INFO_SYMBOL ((sal_uInt32)0x00000040)
+#define RTL_TEXTENCODING_INFO_MIME ((sal_uInt32)0x00000080)
+
+/** Information about a text encoding.
+ */
+typedef struct _rtl_TextEncodingInfo
+{
+ /** The size (in bytes) of this structure. Should be 12.
+ */
+ sal_uInt32 StructSize;
+
+ /** The minimum number of bytes needed to encode any character in the
+ given encoding.
+
+ Can be rather meaningless for encodings that encode global state along
+ with the characters (e.g., ISO-2022 encodings).
+ */
+ sal_uInt8 MinimumCharSize;
+
+ /** The maximum number of bytes needed to encode any character in the
+ given encoding.
+
+ Can be rather meaningless for encodings that encode global state along
+ with the characters (e.g., ISO-2022 encodings).
+ */
+ sal_uInt8 MaximumCharSize;
+
+ /** The average number of bytes needed to encode a character in the given
+ encoding.
+ */
+ sal_uInt8 AverageCharSize;
+
+ /** An unused byte, for padding.
+ */
+ sal_uInt8 Reserved;
+
+ /** Any combination of the RTL_TEXTENCODING_INFO flags.
+
+ RTL_TEXTENCODING_INFO_CONTEXT: The encoding uses some mechanism (like
+ state-changing byte sequences) to switch between different modes (e.g.,
+ to encode multiple character repertoires within the same byte ranges).
+
+ Even if an encoding does not have the CONTEXT property, interpretation
+ of certain byte values within that encoding can depend on context (e.g.,
+ a certain byte value could be either a single-byte character or a
+ subsequent byte of a multi-byte character). Likewise, the single shift
+ characters (SS2 and SS3) used by some of the EUC encodings (to denote
+ that the following bytes constitute a character from another character
+ repertoire) do not imply that encodings making use of these characters
+ have the CONTEXT property. Examples of encodings that do have the
+ CONTEXT property are the ISO-2022 encodings and UTF-7.
+
+ RTL_TEXTENCODING_INFO_ASCII: The encoding is a superset of ASCII. More
+ specifically, any appearance of a byte in the range 0x20--7F denotes the
+ corresponding ASCII character (from SPACE to DELETE); in particular,
+ such a byte cannot be part of a multi-byte character. Note that the
+ ASCII control codes 0x00--1F are not included here, as they are used for
+ special purposes in some encodings.
+
+ If an encoding has this property, it is easy to search for occurences of
+ ASCII characters within strings of this encoding---you do not need to
+ keep track whether a byte in the range 0x20--7F really represents an
+ ASCII character or rather is part of some multi-byte character.
+
+ The guarantees when mapping between Unicode and a given encoding with
+ the ASCII property are as follows: When mapping from Unicode to the
+ given encoding, U+0020--007F map to 0x20--7F (but there can also be
+ other Unicode characters mapping into the range 0x20--7F), and when
+ mapping from the given encoding to Unicode, 0x20--7F map to U+0020--007F
+ (again, there can also be other characters mapping into the range
+ U+0020--007F). In particular, this ensures round-trip conversion for
+ the ASCII range.
+
+ In principle, the ASCII property is orthogonal to the CONTEXT property.
+ In practice, however, an encoding that has the ASCII property will most
+ likely not also have the CONTEXT property.
+
+ RTL_TEXTENCODING_INFO_UNICODE: The encoding is based on the Unicode
+ character repertoire.
+
+ RTL_TEXTENCODING_INFO_MULTIBYTE: A multi-byte encoding.
+
+ RTL_TEXTENCODING_INFO_R2L: An encoding used mainly or exclusively for
+ languages written from right to left.
+
+ RTL_TEXTENCODING_INFO_7BIT: A 7-bit instead of an 8-bit encoding.
+
+ RTL_TEXTENCODING_INFO_SYMBOL: A (generic) encoding for symbol character
+ sets.
+
+ RTL_TEXTENCODING_INFO_MIME: The encoding is registered as a MIME
+ charset.
+ */
+ sal_uInt32 Flags;
+} rtl_TextEncodingInfo;
+
+/** Determine whether a text encoding uses single octets as basic units of
+ information (and can thus be used with the conversion routines in
+ rtl/textcvt.h).
+
+ @param nEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ True if the given encoding uses single octets as basic units of
+ information, false otherwise.
+ */
+sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding);
+
+/** Return information about a text encoding.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @param pEncInfo
+ Returns information about the given encoding. Must not be null, and the
+ StructSize member must be set correctly.
+
+ @return
+ True if information about the given encoding is available, false
+ otherwise.
+ */
+sal_Bool SAL_CALL rtl_getTextEncodingInfo( rtl_TextEncoding eTextEncoding, rtl_TextEncodingInfo* pEncInfo );
+
+/** Map from a numeric Windows charset to a text encoding.
+
+ @param nWinCharset
+ Any numeric Windows charset.
+
+ @return
+ The corresponding rtl_TextEncoding value, or RTL_TEXTENCODING_DONTKNOW if
+ no mapping is applicable.
+ */
+rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromWindowsCharset( sal_uInt8 nWinCharset );
+
+/** Map from a MIME charset to a text encoding.
+
+ @param pMimeCharset
+ Any MIME charset string. Must not be null.
+
+ @return
+ The corresponding rtl_TextEncoding value, or RTL_TEXTENCODING_DONTKNOW if
+ no mapping is applicable.
+ */
+rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pMimeCharset );
+
+/** Map from a Unix charset to a text encoding.
+
+ @param pMimeCharset
+ Any Unix charset string. Must not be null.
+
+ @return
+ The corresponding rtl_TextEncoding value, or RTL_TEXTENCODING_DONTKNOW if
+ no mapping is applicable.
+ */
+rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pUnixCharset );
+
+/** Map from a text encoding to the best matching numeric Windows charset.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The best matching numeric Windows charset, or 1 if none matches.
+ */
+sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding );
+
+/** Map from a text encoding to a corresponding MIME charset name, if
+ available (see <http://www.iana.org/assignments/character-sets>).
+
+ @param nEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The (preferred) MIME charset name corresponding to the given encoding, or
+ NULL if none is available.
+ */
+char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(rtl_TextEncoding
+ nEncoding);
+
+/** Map from a text encoding to the best matching MIME charset.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The best matching MIME charset string, or null if none matches.
+ */
+const sal_Char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding );
+
+/** Map from a text encoding to the best matching Unix charset.
+
+ @param eTextEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The best matching Unix charset string, or null if none matches.
+ */
+const sal_Char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding );
+
+/** Map from a Windows code page to a text encoding.
+
+ @param nCodePage
+ Any Windows code page number.
+
+ @return
+ The corresponding rtl_TextEncoding value (which will be an octet text
+ encoding, see rtl_isOctetTextEncoding), or RTL_TEXTENCODING_DONTKNOW if no
+ mapping is applicable.
+ */
+rtl_TextEncoding SAL_CALL
+rtl_getTextEncodingFromWindowsCodePage(sal_uInt32 nCodePage);
+
+/** Map from a text encoding to a Windows code page.
+
+ @param nEncoding
+ Any rtl_TextEncoding value.
+
+ @return
+ The corresponding Windows code page number, or 0 if no mapping is
+ applicable.
+ */
+sal_uInt32 SAL_CALL
+rtl_getWindowsCodePageFromTextEncoding(rtl_TextEncoding nEncoding);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_TENCINFO_H */
diff --git a/sal/inc/rtl/textcvt.h b/sal/inc/rtl/textcvt.h
new file mode 100644
index 000000000000..b22813daf754
--- /dev/null
+++ b/sal/inc/rtl/textcvt.h
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_TEXTCVT_H
+#define _RTL_TEXTCVT_H
+
+#ifndef _SAL_TYPES_H
+#include <sal/types.h>
+#endif
+#include <rtl/textenc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Documentation about this file can be found at
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html>. */
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_TextToUnicodeConverter;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_TextToUnicodeContext;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+rtl_TextToUnicodeConverter SAL_CALL rtl_createTextToUnicodeConverter( rtl_TextEncoding eTextEncoding );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+void SAL_CALL rtl_destroyTextToUnicodeConverter( rtl_TextToUnicodeConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+rtl_TextToUnicodeContext SAL_CALL rtl_createTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+void SAL_CALL rtl_destroyTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+void SAL_CALL rtl_resetTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext );
+
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR ((sal_uInt32)0x0001)
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE ((sal_uInt32)0x0002)
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE ((sal_uInt32)0x0003)
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT ((sal_uInt32)0x0004)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR ((sal_uInt32)0x0010)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE ((sal_uInt32)0x0020)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT ((sal_uInt32)0x0030)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR ((sal_uInt32)0x0100)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE ((sal_uInt32)0x0200)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT ((sal_uInt32)0x0300)
+#define RTL_TEXTTOUNICODE_FLAGS_FLUSH ((sal_uInt32)0x8000)
+#define RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE 0x10000
+ /* Accept any global document signatures (for example, in UTF-8, a leading
+ EF BB BF encoding the Byte Order Mark U+FEFF) */
+
+#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK ((sal_uInt32)0x000F)
+#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK ((sal_uInt32)0x00F0)
+#define RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK ((sal_uInt32)0x0F00)
+
+#define RTL_TEXTTOUNICODE_INFO_ERROR ((sal_uInt32)0x0001)
+#define RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL ((sal_uInt32)0x0002)
+#define RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL ((sal_uInt32)0x0004)
+#define RTL_TEXTTOUNICODE_INFO_UNDEFINED ((sal_uInt32)0x0008)
+#define RTL_TEXTTOUNICODE_INFO_MBUNDEFINED ((sal_uInt32)0x0010)
+#define RTL_TEXTTOUNICODE_INFO_INVALID ((sal_uInt32)0x0020)
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+sal_Size SAL_CALL rtl_convertTextToUnicode( rtl_TextToUnicodeConverter hConverter,
+ rtl_TextToUnicodeContext hContext,
+ const sal_Char* pSrcBuf, sal_Size nSrcBytes,
+ sal_Unicode* pDestBuf, sal_Size nDestChars,
+ sal_uInt32 nFlags, sal_uInt32* pInfo,
+ sal_Size* pSrcCvtBytes );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_UnicodeToTextConverter;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+typedef void* rtl_UnicodeToTextContext;
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+rtl_UnicodeToTextConverter SAL_CALL rtl_createUnicodeToTextConverter( rtl_TextEncoding eTextEncoding );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+void SAL_CALL rtl_destroyUnicodeToTextConverter( rtl_UnicodeToTextConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+rtl_UnicodeToTextContext SAL_CALL rtl_createUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+void SAL_CALL rtl_destroyUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext );
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+void SAL_CALL rtl_resetUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext );
+
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR ((sal_uInt32)0x0001)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE ((sal_uInt32)0x0002)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0 ((sal_uInt32)0x0003)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK ((sal_uInt32)0x0004)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE ((sal_uInt32)0x0005)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT ((sal_uInt32)0x0006)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR ((sal_uInt32)0x0010)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE ((sal_uInt32)0x0020)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_0 ((sal_uInt32)0x0030)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_QUESTIONMARK ((sal_uInt32)0x0040)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE ((sal_uInt32)0x0050)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT ((sal_uInt32)0x0060)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE ((sal_uInt32)0x0100)
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR ((sal_uInt32)0x0200)
+#define RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ((sal_uInt32)0x0400)
+#define RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE ((sal_uInt32)0x0800)
+#define RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE ((sal_uInt32)0x1000)
+#define RTL_UNICODETOTEXT_FLAGS_PRIVATE_IGNORE ((sal_uInt32)0x2000)
+#define RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE ((sal_uInt32)0x4000)
+#define RTL_UNICODETOTEXT_FLAGS_FLUSH ((sal_uInt32)0x8000)
+#define RTL_UNICODETOTEXT_FLAGS_GLOBAL_SIGNATURE 0x10000
+ /* Write any global document signatures (for example, in UTF-8, a leading
+ EF BB BF encoding the Byte Order Mark U+FEFF) */
+
+#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK ((sal_uInt32)0x000F)
+#define RTL_UNICODETOTEXT_FLAGS_INVALID_MASK ((sal_uInt32)0x00F0)
+
+#define RTL_UNICODETOTEXT_INFO_ERROR ((sal_uInt32)0x0001)
+#define RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL ((sal_uInt32)0x0002)
+#define RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL ((sal_uInt32)0x0004)
+#define RTL_UNICODETOTEXT_INFO_UNDEFINED ((sal_uInt32)0x0008)
+#define RTL_UNICODETOTEXT_INFO_INVALID ((sal_uInt32)0x0010)
+
+/** see http://udk.openoffice.org/cpp/man/spec/textconversion.html
+ */
+sal_Size SAL_CALL rtl_convertUnicodeToText( rtl_UnicodeToTextConverter hConverter,
+ rtl_UnicodeToTextContext hContext,
+ const sal_Unicode* pSrcBuf, sal_Size nSrcChars,
+ sal_Char* pDestBuf, sal_Size nDestBytes,
+ sal_uInt32 nFlags, sal_uInt32* pInfo,
+ sal_Size* pSrcCvtChars );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_TEXTCVT_H */
diff --git a/sal/inc/rtl/textenc.h b/sal/inc/rtl/textenc.h
new file mode 100644
index 000000000000..6b0b67e3c8ab
--- /dev/null
+++ b/sal/inc/rtl/textenc.h
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_TEXTENC_H
+#define _RTL_TEXTENC_H
+
+#ifdef _SOLAR_RSC_INVOKED
+/* Enable resources to use these values, rsc can't handle casts */
+#define RTL_TEXTENC_CAST( val ) (val)
+
+#else /* !_SOLAR_RSC_INVOKED */
+
+#ifndef _SAL_TYPES_H
+#include <sal/types.h>
+#endif
+
+/** The various supported text encodings.
+
+ Possible values include a wide range of single- and multi-byte encodings
+ (ranging from RTL_TEXTENCODING_MS_1252 to RTL_TEXTENCODING_GB_18030),
+ the ISO 10646 (Unicode) specific encodings RTL_TEXTENCODING_UCS4 and
+ RTL_TEXTENCODING_UCS2 (aka RTL_TEXTENCODING_UNICODE), and
+ RTL_TEXTENCODING_DONTKNOW to indicate an unknown or missing encoding.
+ */
+typedef sal_uInt16 rtl_TextEncoding;
+
+#define RTL_TEXTENC_CAST( val ) ((rtl_TextEncoding) val)
+
+#endif /* _SOLAR_RSC_INVOKED */
+
+#define RTL_TEXTENCODING_DONTKNOW (RTL_TEXTENC_CAST( 0 ))
+#define RTL_TEXTENCODING_MS_1252 (RTL_TEXTENC_CAST( 1 ))
+#define RTL_TEXTENCODING_APPLE_ROMAN (RTL_TEXTENC_CAST( 2 ))
+#define RTL_TEXTENCODING_IBM_437 (RTL_TEXTENC_CAST( 3 ))
+#define RTL_TEXTENCODING_IBM_850 (RTL_TEXTENC_CAST( 4 ))
+#define RTL_TEXTENCODING_IBM_860 (RTL_TEXTENC_CAST( 5 ))
+#define RTL_TEXTENCODING_IBM_861 (RTL_TEXTENC_CAST( 6 ))
+#define RTL_TEXTENCODING_IBM_863 (RTL_TEXTENC_CAST( 7 ))
+#define RTL_TEXTENCODING_IBM_865 (RTL_TEXTENC_CAST( 8 ))
+/* Reserved: RTL_TEXTENCODING_SYSTEM (RTL_TEXTENC_CAST( 9 )) */
+#define RTL_TEXTENCODING_SYMBOL (RTL_TEXTENC_CAST( 10 ))
+#define RTL_TEXTENCODING_ASCII_US (RTL_TEXTENC_CAST( 11 ))
+#define RTL_TEXTENCODING_ISO_8859_1 (RTL_TEXTENC_CAST( 12 ))
+#define RTL_TEXTENCODING_ISO_8859_2 (RTL_TEXTENC_CAST( 13 ))
+#define RTL_TEXTENCODING_ISO_8859_3 (RTL_TEXTENC_CAST( 14 ))
+#define RTL_TEXTENCODING_ISO_8859_4 (RTL_TEXTENC_CAST( 15 ))
+#define RTL_TEXTENCODING_ISO_8859_5 (RTL_TEXTENC_CAST( 16 ))
+#define RTL_TEXTENCODING_ISO_8859_6 (RTL_TEXTENC_CAST( 17 ))
+#define RTL_TEXTENCODING_ISO_8859_7 (RTL_TEXTENC_CAST( 18 ))
+#define RTL_TEXTENCODING_ISO_8859_8 (RTL_TEXTENC_CAST( 19 ))
+#define RTL_TEXTENCODING_ISO_8859_9 (RTL_TEXTENC_CAST( 20 ))
+#define RTL_TEXTENCODING_ISO_8859_14 (RTL_TEXTENC_CAST( 21 ))
+#define RTL_TEXTENCODING_ISO_8859_15 (RTL_TEXTENC_CAST( 22 ))
+#define RTL_TEXTENCODING_IBM_737 (RTL_TEXTENC_CAST( 23 ))
+#define RTL_TEXTENCODING_IBM_775 (RTL_TEXTENC_CAST( 24 ))
+#define RTL_TEXTENCODING_IBM_852 (RTL_TEXTENC_CAST( 25 ))
+#define RTL_TEXTENCODING_IBM_855 (RTL_TEXTENC_CAST( 26 ))
+#define RTL_TEXTENCODING_IBM_857 (RTL_TEXTENC_CAST( 27 ))
+#define RTL_TEXTENCODING_IBM_862 (RTL_TEXTENC_CAST( 28 ))
+#define RTL_TEXTENCODING_IBM_864 (RTL_TEXTENC_CAST( 29 ))
+#define RTL_TEXTENCODING_IBM_866 (RTL_TEXTENC_CAST( 30 ))
+#define RTL_TEXTENCODING_IBM_869 (RTL_TEXTENC_CAST( 31 ))
+#define RTL_TEXTENCODING_MS_874 (RTL_TEXTENC_CAST( 32 ))
+#define RTL_TEXTENCODING_MS_1250 (RTL_TEXTENC_CAST( 33 ))
+#define RTL_TEXTENCODING_MS_1251 (RTL_TEXTENC_CAST( 34 ))
+#define RTL_TEXTENCODING_MS_1253 (RTL_TEXTENC_CAST( 35 ))
+#define RTL_TEXTENCODING_MS_1254 (RTL_TEXTENC_CAST( 36 ))
+#define RTL_TEXTENCODING_MS_1255 (RTL_TEXTENC_CAST( 37 ))
+#define RTL_TEXTENCODING_MS_1256 (RTL_TEXTENC_CAST( 38 ))
+#define RTL_TEXTENCODING_MS_1257 (RTL_TEXTENC_CAST( 39 ))
+#define RTL_TEXTENCODING_MS_1258 (RTL_TEXTENC_CAST( 40 ))
+#define RTL_TEXTENCODING_APPLE_ARABIC (RTL_TEXTENC_CAST( 41 ))
+#define RTL_TEXTENCODING_APPLE_CENTEURO (RTL_TEXTENC_CAST( 42 ))
+#define RTL_TEXTENCODING_APPLE_CROATIAN (RTL_TEXTENC_CAST( 43 ))
+#define RTL_TEXTENCODING_APPLE_CYRILLIC (RTL_TEXTENC_CAST( 44 ))
+#define RTL_TEXTENCODING_APPLE_DEVANAGARI (RTL_TEXTENC_CAST( 45 ))
+#define RTL_TEXTENCODING_APPLE_FARSI (RTL_TEXTENC_CAST( 46 ))
+#define RTL_TEXTENCODING_APPLE_GREEK (RTL_TEXTENC_CAST( 47 ))
+#define RTL_TEXTENCODING_APPLE_GUJARATI (RTL_TEXTENC_CAST( 48 ))
+#define RTL_TEXTENCODING_APPLE_GURMUKHI (RTL_TEXTENC_CAST( 49 ))
+#define RTL_TEXTENCODING_APPLE_HEBREW (RTL_TEXTENC_CAST( 50 ))
+#define RTL_TEXTENCODING_APPLE_ICELAND (RTL_TEXTENC_CAST( 51 ))
+#define RTL_TEXTENCODING_APPLE_ROMANIAN (RTL_TEXTENC_CAST( 52 ))
+#define RTL_TEXTENCODING_APPLE_THAI (RTL_TEXTENC_CAST( 53 ))
+#define RTL_TEXTENCODING_APPLE_TURKISH (RTL_TEXTENC_CAST( 54 ))
+#define RTL_TEXTENCODING_APPLE_UKRAINIAN (RTL_TEXTENC_CAST( 55 ))
+#define RTL_TEXTENCODING_APPLE_CHINSIMP (RTL_TEXTENC_CAST( 56 ))
+#define RTL_TEXTENCODING_APPLE_CHINTRAD (RTL_TEXTENC_CAST( 57 ))
+#define RTL_TEXTENCODING_APPLE_JAPANESE (RTL_TEXTENC_CAST( 58 ))
+#define RTL_TEXTENCODING_APPLE_KOREAN (RTL_TEXTENC_CAST( 59 ))
+#define RTL_TEXTENCODING_MS_932 (RTL_TEXTENC_CAST( 60 ))
+#define RTL_TEXTENCODING_MS_936 (RTL_TEXTENC_CAST( 61 ))
+#define RTL_TEXTENCODING_MS_949 (RTL_TEXTENC_CAST( 62 ))
+#define RTL_TEXTENCODING_MS_950 (RTL_TEXTENC_CAST( 63 ))
+#define RTL_TEXTENCODING_SHIFT_JIS (RTL_TEXTENC_CAST( 64 ))
+#define RTL_TEXTENCODING_GB_2312 (RTL_TEXTENC_CAST( 65 ))
+#define RTL_TEXTENCODING_GBT_12345 (RTL_TEXTENC_CAST( 66 ))
+#define RTL_TEXTENCODING_GBK (RTL_TEXTENC_CAST( 67 ))
+#define RTL_TEXTENCODING_BIG5 (RTL_TEXTENC_CAST( 68 ))
+#define RTL_TEXTENCODING_EUC_JP (RTL_TEXTENC_CAST( 69 ))
+#define RTL_TEXTENCODING_EUC_CN (RTL_TEXTENC_CAST( 70 ))
+#define RTL_TEXTENCODING_EUC_TW (RTL_TEXTENC_CAST( 71 ))
+#define RTL_TEXTENCODING_ISO_2022_JP (RTL_TEXTENC_CAST( 72 ))
+#define RTL_TEXTENCODING_ISO_2022_CN (RTL_TEXTENC_CAST( 73 ))
+#define RTL_TEXTENCODING_KOI8_R (RTL_TEXTENC_CAST( 74 ))
+#define RTL_TEXTENCODING_UTF7 (RTL_TEXTENC_CAST( 75 ))
+#define RTL_TEXTENCODING_UTF8 (RTL_TEXTENC_CAST( 76 ))
+#define RTL_TEXTENCODING_ISO_8859_10 (RTL_TEXTENC_CAST( 77 ))
+#define RTL_TEXTENCODING_ISO_8859_13 (RTL_TEXTENC_CAST( 78 ))
+#define RTL_TEXTENCODING_EUC_KR (RTL_TEXTENC_CAST( 79 ))
+#define RTL_TEXTENCODING_ISO_2022_KR (RTL_TEXTENC_CAST( 80 ))
+#define RTL_TEXTENCODING_JIS_X_0201 (RTL_TEXTENC_CAST( 81 ))
+#define RTL_TEXTENCODING_JIS_X_0208 (RTL_TEXTENC_CAST( 82 ))
+#define RTL_TEXTENCODING_JIS_X_0212 (RTL_TEXTENC_CAST( 83 ))
+#define RTL_TEXTENCODING_MS_1361 (RTL_TEXTENC_CAST( 84 ))
+#define RTL_TEXTENCODING_GB_18030 (RTL_TEXTENC_CAST( 85 ))
+#define RTL_TEXTENCODING_BIG5_HKSCS (RTL_TEXTENC_CAST( 86 ))
+#define RTL_TEXTENCODING_TIS_620 (RTL_TEXTENC_CAST( 87 ))
+#define RTL_TEXTENCODING_KOI8_U (RTL_TEXTENC_CAST( 88 ))
+#define RTL_TEXTENCODING_ISCII_DEVANAGARI (RTL_TEXTENC_CAST( 89 ))
+#define RTL_TEXTENCODING_JAVA_UTF8 (RTL_TEXTENC_CAST( 90 ))
+#define RTL_TEXTENCODING_ADOBE_STANDARD (RTL_TEXTENC_CAST( 91 ))
+#define RTL_TEXTENCODING_ADOBE_SYMBOL (RTL_TEXTENC_CAST( 92 ))
+#define RTL_TEXTENCODING_PT154 (RTL_TEXTENC_CAST( 93 ))
+#define RTL_TEXTENCODING_ADOBE_DINGBATS (RTL_TEXTENC_CAST( 94 ))
+/* ATTENTION! Whenever some encoding is added here, make sure to update
+ * rtl_isOctetTextEncoding in tencinfo.c.
+ */
+
+#define RTL_TEXTENCODING_USER_START (RTL_TEXTENC_CAST( 0x8000 ))
+#define RTL_TEXTENCODING_USER_END (RTL_TEXTENC_CAST( 0xEFFF ))
+
+#define RTL_TEXTENCODING_UCS4 (RTL_TEXTENC_CAST( 0xFFFE ))
+#define RTL_TEXTENCODING_UCS2 (RTL_TEXTENC_CAST( 0xFFFF ))
+#define RTL_TEXTENCODING_UNICODE RTL_TEXTENCODING_UCS2
+
+/****** Overview over the TextEncodings *****
+# Arabic (Apple Macintosh) RTL_TEXTENCODING_APPLE_ARABIC
+Arabic (DOS/OS2-864) RTL_TEXTENCODING_IBM_864
+Arabic (ISO-8859-6) RTL_TEXTENCODING_ISO_8859_6
+Arabic (Windows-1256) RTL_TEXTENCODING_MS_1256
+
+Baltic (DOS/OS2-775) RTL_TEXTENCODING_IBM_775
+Baltic (ISO-8859-4) RTL_TEXTENCODING_ISO_8859_4
+Baltic (Windows-1257) RTL_TEXTENCODING_MS_1257
+
+Central European (Apple Macintosh) RTL_TEXTENCODING_APPLE_CENTEURO
+Central European (Apple Macintosh/Croatian) RTL_TEXTENCODING_APPLE_CROATIAN
+Central European (Apple Macintosh/Romanian) RTL_TEXTENCODING_APPLE_ROMANIAN
+Central European (DOS/OS2-852) RTL_TEXTENCODING_IBM_852
+Central European (ISO-8859-2) RTL_TEXTENCODING_ISO_8859_2
+Central European (ISO-8859-10) RTL_TEXTENCODING_ISO_8859_10
+Central European (ISO-8859-13) RTL_TEXTENCODING_ISO_8859_13
+Central European (Windows-1250/WinLatin 2) RTL_TEXTENCODING_MS_1250
+
+Chinese Simplified (Apple Macintosh) RTL_TEXTENCODING_APPLE_CHINSIMP
+Chinese Simplified (EUC-CN) RTL_TEXTENCODING_EUC_CN
+Chinese Simplified (GB-2312) RTL_TEXTENCODING_GB_2312
+Chinese Simplified (GBK/GB-2312-80) RTL_TEXTENCODING_GBK
+# Chinese Simplified (ISO-2022-CN) RTL_TEXTENCODING_ISO_2022_CN
+Chinese Simplified (Windows-936) RTL_TEXTENCODING_MS_936
+# Chinese Simplified (GB-18030) RTL_TEXTENCODING_GB_18030
+
+Chinese Traditional (Apple Macintosh) RTL_TEXTENCODING_APPLE_CHINTRAD
+Chinese Traditional (BIG5) RTL_TEXTENCODING_BIG5
+# Chinese Traditional (EUC-TW) RTL_TEXTENCODING_EUC_TW
+Chinese Traditional (GBT-12345) RTL_TEXTENCODING_GBT_12345
+Chinese Traditional (Windows-950) RTL_TEXTENCODING_MS_950
+Chinese Traditional (BIG5-HKSCS) RTL_TEXTENCODING_BIG5_HKSCS
+
+Cyrillic (Apple Macintosh) RTL_TEXTENCODING_APPLE_CYRILLIC
+Cyrillic (Apple Macintosh/Ukrainian) RTL_TEXTENCODING_APPLE_UKRAINIAN
+Cyrillic (DOS/OS2-855) RTL_TEXTENCODING_IBM_855
+Cyrillic (DOS/OS2-866/Russian) RTL_TEXTENCODING_IBM_866
+Cyrillic (ISO-8859-5) RTL_TEXTENCODING_ISO_8859_5
+Cyrillic (KOI8-R) RTL_TEXTENCODING_KOI8_R
+Cyrillic (KOI8-U) RTL_TEXTENCODING_KOI8_U
+Cyrillic (Windows-1251) RTL_TEXTENCODING_MS_1251
+
+Greek (Apple Macintosh) RTL_TEXTENCODING_APPLE_GREEK
+Greek (DOS/OS2-737) RTL_TEXTENCODING_IBM_737
+Greek (DOS/OS2-869/Modern) RTL_TEXTENCODING_IBM_869
+Greek (ISO-8859-7) RTL_TEXTENCODING_ISO_8859_7
+Greek (Windows-1253) RTL_TEXTENCODING_MS_1253
+
+# Hebrew (Apple Macintosh) RTL_TEXTENCODING_APPLE_HEBREW
+Hebrew (DOS/OS2-862) RTL_TEXTENCODING_IBM_862
+Hebrew (ISO-8859-8) RTL_TEXTENCODING_ISO_8859_8
+Hebrew (Windows-1255) RTL_TEXTENCODING_MS_1255
+
+Korean (Apple Macintosh) RTL_TEXTENCODING_APPLE_KOREAN
+Korean (EUC-KR) RTL_TEXTENCODING_EUC_KR
+# Korean (ISO-2022-KR) RTL_TEXTENCODING_ISO_2022_KR
+Korean (Windows-Wansung-949) RTL_TEXTENCODING_MS_949
+Korean (Windows-Johab-1361) RTL_TEXTENCODING_MS_1361
+
+Latin 3 (ISO-8859-3) RTL_TEXTENCODING_ISO_8859_3
+
+Indian (ISCII Devanagari) RTL_TEXTENCODING_ISCII_DEVANAGARI
+
+Japanese (Apple Macintosh) RTL_TEXTENCODING_APPLE_JAPANESE
+Japanese (EUC-JP) RTL_TEXTENCODING_EUC_JP
+# Japanese (ISO-2022-JP) RTL_TEXTENCODING_ISO_2022_JP
+Japanese (Shift-JIS) RTL_TEXTENCODING_SHIFT_JIS
+Japanese (Windows-932) RTL_TEXTENCODING_MS_932
+
+Symbol RTL_TEXTENCODING_SYMBOL
+
+# Thai (Apple Macintosh) RTL_TEXTENCODING_APPLE_THAI
+Thai (Dos/Windows-874) RTL_TEXTENCODING_MS_874
+Thai (TIS 620) RTL_TEXTENCODING_TIS_620
+
+Turkish (Apple Macintosh) RTL_TEXTENCODING_APPLE_TURKISH
+Turkish (DOS/OS2-857) RTL_TEXTENCODING_IBM_857
+Turkish (ISO-8859-9) RTL_TEXTENCODING_ISO_8859_9
+Turkish (Windows-1254) RTL_TEXTENCODING_MS_1254
+
+Unicode (UTF-7) RTL_TEXTENCODING_UTF7
+Unicode (UTF-8) RTL_TEXTENCODING_UTF8
+Unicode (Java's modified UTF-8) RTL_TEXTENCODING_JAVA_UTF8
+
+Vietnamese (Windows-1258) RTL_TEXTENCODING_MS_1258
+
+Western (Apple Macintosh) RTL_TEXTENCODING_APPLE_ROMAN
+Western (Apple Macintosh/Icelandic) RTL_TEXTENCODING_APPLE_ICELAND
+Western (ASCII/US) RTL_TEXTENCODING_ASCII_US
+Western (DOS/OS2-437/US) RTL_TEXTENCODING_IBM_437
+Western (DOS/OS2-850/International) RTL_TEXTENCODING_IBM_850
+Western (DOS/OS2-860/Portugese) RTL_TEXTENCODING_IBM_860
+Western (DOS/OS2-861/Icelandic) RTL_TEXTENCODING_IBM_861
+Western (DOS/OS2-863/Canadian-French) RTL_TEXTENCODING_IBM_863
+Western (DOS/OS2-865/Nordic) RTL_TEXTENCODING_IBM_865
+Western (ISO-8859-1) RTL_TEXTENCODING_ISO_8859_1
+Western (ISO-8859-14) RTL_TEXTENCODING_ISO_8859_14
+Western (ISO-8859-15/EURO) RTL_TEXTENCODING_ISO_8859_15
+Western (Window-1252/WinLatin 1) RTL_TEXTENCODING_MS_1252
+
+Not known and currently not supported
+# RTL_TEXTENCODING_APPLE_DEVANAGARI
+# RTL_TEXTENCODING_APPLE_FARSI
+# RTL_TEXTENCODING_APPLE_GUJARATI
+# RTL_TEXTENCODING_APPLE_GURMUKHI
+
+Only for internal implementations and not useful for user interface.
+These encodings are not used for text encodings, only used for
+font-/textoutput encodings.
+Japanese (JIS 0201) RTL_TEXTENCODING_JISX_0201
+Japanese (JIS 0208) RTL_TEXTENCODING_JISX_0208
+Japanese (JIS 0212) RTL_TEXTENCODING_JISX_0212
+
+# Currently not implemented
+*/
+
+#endif /* _RTL_TEXTENC_H */
+
diff --git a/sal/inc/rtl/tres.h b/sal/inc/rtl/tres.h
new file mode 100644
index 000000000000..9535d0b2adc2
--- /dev/null
+++ b/sal/inc/rtl/tres.h
@@ -0,0 +1,106 @@
+#ifndef _RTL_TRES_H_
+#define _RTL_TRES_H_
+
+#include <osl/diagnose.h>
+#include <rtl/string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* comandline flags */
+#define rtl_tres_Flag_BOOM 0x00000001
+#define rtl_tres_Flag_VERBOSE 0x00000002
+#define rtl_tres_Flag_SKIP 0x00000004
+#define rtl_tres_Flag_LOG 0x00000010
+#define rtl_tres_Flag_HIS 0x00000100
+#define rtl_tres_Flag_TIME 0x00000200
+#define rtl_tres_Flag_MSG 0x00000400
+#define rtl_tres_Flag_QUIET 0x00000800
+
+ /* state flags */
+#define rtl_tres_Flag_SUB 0x01000000
+#define rtl_tres_Flag_PASSED 0x10000000
+#define rtl_tres_Flag_OK 0x20000000
+
+
+
+ /* forward declaration and type definition */
+struct _rtl_TestResult;
+typedef struct _rtl_TestResult rtl_TestResult;
+
+
+typedef void* rtl_funcstate;
+typedef void* rtl_cmpstate;
+
+ /* type definitions of function pointers wich can be overloaded */
+typedef sal_Bool (SAL_CALL *rtl_tres_state_ptr)(
+ rtl_TestResult*,
+ sal_Bool,
+ const sal_Char*,
+ const sal_Char*,
+ sal_Bool
+ );
+
+typedef void (SAL_CALL *rtl_tres_end_ptr)( rtl_TestResult*, const sal_Char* );
+typedef sal_Bool (SAL_CALL *rtl_tres_ispassed_ptr)( rtl_TestResult* );
+typedef sal_Bool (SAL_CALL *rtl_tres_isok_ptr)( rtl_TestResult* );
+typedef rtl_funcstate (SAL_CALL *rtl_tres_funcstate_ptr)( rtl_TestResult* );
+typedef sal_Bool (SAL_CALL *rtl_tres_isbit_ptr)( rtl_TestResult*,
+ sal_uInt32 );
+
+typedef rtl_funcstate (SAL_CALL *rtl_tres_getnextfuncstate_ptr)
+ ( rtl_funcstate );
+typedef rtl_funcstate (SAL_CALL *rtl_tres_getprevfuncstate_ptr)
+ ( rtl_funcstate );
+typedef sal_uInt32 (SAL_CALL *rtl_tres_getflags_ptr)( rtl_funcstate );
+typedef rtl_String* (SAL_CALL *rtl_tres_getname_ptr)( rtl_funcstate );
+typedef sal_uInt32 (SAL_CALL *rtl_tres_getstart_ptr)( rtl_funcstate );
+typedef sal_uInt32 (SAL_CALL *rtl_tres_getstop_ptr)( rtl_funcstate );
+typedef rtl_cmpstate (SAL_CALL *rtl_tres_getcmpstate_ptr)( rtl_funcstate );
+
+typedef sal_Bool (SAL_CALL *rtl_tres_getstat_ptr)( rtl_cmpstate );
+typedef rtl_String* (SAL_CALL *rtl_tres_getmsg_ptr)( rtl_cmpstate );
+typedef rtl_cmpstate (SAL_CALL *rtl_tres_getnextcmpstate_ptr)( rtl_cmpstate );
+
+ /* type definition of vtable structure for testresult */
+typedef struct _rtl_TestResult_vtable
+{
+ sal_uInt32 vtablesize;
+ rtl_tres_state_ptr state_;
+ rtl_tres_end_ptr end_;
+ rtl_tres_ispassed_ptr ispassed;
+ rtl_tres_isok_ptr isok;
+ rtl_tres_funcstate_ptr funcstate;
+ rtl_tres_isbit_ptr isbit;
+ rtl_tres_getnextfuncstate_ptr nextfuncstate;
+ rtl_tres_getprevfuncstate_ptr prevfuncstate;
+ rtl_tres_getflags_ptr flags;
+ rtl_tres_getname_ptr name;
+ rtl_tres_getstart_ptr start;
+ rtl_tres_getstop_ptr stop;
+ rtl_tres_getcmpstate_ptr cmpstate;
+ rtl_tres_getstat_ptr stat;
+ rtl_tres_getmsg_ptr msg;
+ rtl_tres_getnextcmpstate_ptr nextcmpstate;
+
+} rtl_TestResult_vtable;
+
+ /* type definition of testresult structure */
+struct _rtl_TestResult
+{
+ rtl_TestResult_vtable * pFuncs;
+ void * pExternalData;
+
+};
+
+
+ /* exports */
+rtl_TestResult* SAL_CALL rtl_tres_create( const sal_Char* meth, sal_uInt32 flags );
+void SAL_CALL rtl_tres_destroy( rtl_TestResult* res );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_TRES_H_ */
diff --git a/sal/inc/rtl/tres.hxx b/sal/inc/rtl/tres.hxx
new file mode 100644
index 000000000000..6fcd5b7c61e7
--- /dev/null
+++ b/sal/inc/rtl/tres.hxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_TRES_HXX_
+#define _RTL_TRES_HXX_
+
+
+#include <rtl/tres.h>
+
+//#include <stdarg.h>
+
+// <namespace_rtl>
+namespace rtl
+{
+/*==========================================================================*/
+
+// <class_TestResult>
+class TestResult
+{
+ // pointer to testresult structure
+ rtl_TestResult* pData;
+
+ // <private_ctors>
+ TestResult();
+ TestResult( const TestResult& oRes );
+ // </private_ctors>
+
+public:
+
+
+ // <public_ctors>
+ TestResult( const sal_Char* meth, sal_uInt32 flags = 0 )
+ {
+ pData = rtl_tres_create( meth, flags );
+ } // </public_ctors>
+
+ // <dtor>
+ ~TestResult()
+ {
+ rtl_tres_destroy( pData );
+ }
+ // </dtor>
+
+ // <public_methods>
+ rtl_TestResult* getData()
+ {
+ return pData;
+ }
+ // <method_state>
+ sal_Bool state(
+ sal_Bool tst_state,
+ const sal_Char* msg = 0,
+ const sal_Char* sub = 0,
+ sal_Bool verbose = sal_False
+ )
+ {
+ return pData->pFuncs->state_( pData, tst_state, msg, sub, verbose );
+ } // </method_state>
+
+ void end( sal_Char* msg = 0 )
+ {
+ pData->pFuncs->end_( pData, msg );
+ } // </method_state>
+}; // </class_TestResult>
+
+} // </namespace_rtl>
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sal/inc/rtl/unload.h b/sal/inc/rtl/unload.h
new file mode 100644
index 000000000000..30a8ddbe4a8f
--- /dev/null
+++ b/sal/inc/rtl/unload.h
@@ -0,0 +1,315 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_UNLOAD_H_
+#define _RTL_UNLOAD_H_
+
+#include <sal/types.h>
+#include <osl/time.h>
+#include <osl/interlck.h>
+#include <osl/module.h>
+
+///@HTML
+/** @file
+The API enables an effective way of unloading libraries in a centralized way.
+The mechanism ensures that used libraries are not unloaded. This prevents
+crashes if library code is being used after unloading the library.
+The unloading mechanism currently only works with libraries which contain
+UNO services. A library cannot be unloaded if one of the following conditions
+apply
+
+<ul>
+<li>An instance is still referenced </li>
+<li>A module has been loaded without registering it </li>
+<li>The service manager has created a one instance service </li>
+<li>A service instance has been added to an UNO context </li>
+</ul>
+
+<b>Notification Mechanism</b>
+The API provides a notification mechanism. Clients can use it to do clean up,
+such as releasing cached references, in order to allow modules to be unloaded.
+As long as someone holds a reference to an object whose housing module
+supports unloading the module cannot be unloaded.<p>
+
+Because of the inherent danger of crashing the application by using this API
+all instances which control threads should be registered listeners. On
+notification they have to ensure that their threads assume a safe state, that
+is, they run outside of modules which could be unloaded and do not jump
+back into module code as a result of a finished function call. In other words,
+there must not be an address of the module on the thread's stack.
+<p>
+Since current operating systems lack APIs in respect to controlling the
+position of threads within libraries, it would be a major effort to comply with
+that recommendation. The best and most efficient way of handling the unloading
+scenario is to let all threads, except for the main thread, die in case of a
+notification.
+<p>
+Use this API with great care because it might crash the application. See the
+respective documentation (Library Unloading) on the udk.openoffice.org web site.
+*/
+
+
+/**
+A library which supports unloading has to implement and export a function
+called <code>component_canUnload</code>. <p>
+If the function returns <code>sal_True</code> then the module can be safely unloaded.
+That is the case when there are no external references to code within the
+library. In case a module houses UNO components then the function must return
+<code>sal_False</code> after the first factory has been handed out. The function then
+continues to return <code>sal_False</code> as long as there is at least one object (factory
+or service instance) which originated from the module.<p>
+
+Libraries which not only contain UNO components (or none at all) have to
+provide a means to control whether they can be unloaded or not, e.g. However,
+there is no concept yet. <p>
+
+The argument <code>pTime</code> is an optional out-parameter. If the return value is
+<code>sal_True</code> then <code>pTime</code> reflects a point in time since
+when the module could have
+been unloaded. Since that time the function would have continually returned
+<code>sal_True</code> up to the present. The value of <code>pTime</code> is
+important for the decision
+as to a module will be unloaded. When someone initiates the unloading of
+modules by calling <code>rtl_unloadUnusedModules</code> then the caller can specify a time
+span with the effect that only those modules are unloaded which are unused at
+least for that amount of time. If <code>component_canUnload</code> does not
+fill in <code>pTime</code>
+then the module is unloaded immediately.<p>
+
+<code>component_canUnload</code> is implicitly called by <code>rtl_unloadUnusedModules
+</code>. There is no need to call the function directly.
+*/
+#define COMPONENT_CANUNLOAD "component_canUnload"
+typedef sal_Bool (SAL_CALL * component_canUnloadFunc)( TimeValue* pTime);
+
+
+/** C-interface for a module reference counting
+ */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+By registering a module, one declares that a module supports the
+unloading mechanism. One registers a module by calling this function.<p>
+
+A module can only be unloaded from memory when it has been registered
+as many times as it has been loaded. The reason is that a library can
+be &quot;loaded&quot; several times by <code>osl_loadModule</code>
+within the same process. The
+function will then return the same module handle because the library will
+effectively only be loaded once. To remove the library from memory it is
+necessary to call <code>osl_unloadModule</code> as often as <code>
+osl_loadModule</code> was called. The
+function <code>rtl_unloadUnusedModules</code> calls <code>osl_unloadModule</code>
+for a module as many
+times as it was registered. If, for example, a module has been registered one
+time less then <code>osl_loadModule</code> has been called and the module can be unloaded
+then it needs a call to <code>rtl_unloadUnusedModules</code> and an explicit call to
+<code>osl_unloadModule</code> to remove the module from memory. <p>
+
+A module must be registered every time it has been loaded otherwise the
+unloading mechanism is not effective.<p>
+
+Before a module is registered, one has to make sure that the module is in a
+state that prevents it from being unloaded. In other words,
+<code>component_canUnload</code> must return <code>sal_False</code>. Assuming that
+<code>component_canUnload</code>
+returns <code>sal_True</code> and it is registered regardless, then a call to
+<code>rtl_unloadUnusedModules</code> causes the module to be unloaded. This unloading can
+be set off by a different thread and the thread which registered the module is
+&quot;unaware&quot; of this. Then when the first thread tries to obtain a factory or
+calls another function in the module, the application will crash, because the
+module has been unloaded before. Therefore one has to ensure that the module
+cannot be unloaded before it is registered. This is simply done by obtaining a
+factory from the module. As long as a factory or some other object, which has
+been created by the factory, is alive, the <code>component_canUnload</code> function will
+return <code>sal_False</code>.<p>
+Loading and registering have to be in this order:<br>
+<ul>
+<li>load a library (<code>osl_loadModule</code>)</li>
+<li>get the <code>component_getFactory</code> function and get a factory</li>
+<li>register the module (rtl_registerModuleForUnloading</li>
+</ul>
+Usually the service manager is used to obtain an instance of a service.
+The service manager registers all modules which support the unloading mechanism.
+When the service manager is used to get service instances than one does not
+have to bother about registering.
+
+@param module a module handle as is obtained by osl_loadModule
+@return sal_True - the module could be registered for unloading, sal_False otherwise
+*/
+sal_Bool SAL_CALL rtl_registerModuleForUnloading( oslModule module);
+
+/**
+The function revokes the registration of a module. By calling the function for
+a previously registered module one prevents the module from being unloaded by
+this unloading mechanism. However, in order to completely unregister the module
+it is necessary to call the function as often as the module has been registered.
+<p>
+<code>rtl_unloadUnusedModules</code> unregisters the modules which it unloads. Therefore
+there is no need to call this function unless one means to prevent the unloading of a module.
+
+@param module a module handle as is obtained by osl_loadModule
+*/
+void SAL_CALL rtl_unregisterModuleForUnloading( oslModule module);
+/**
+This function sets off the unloading mechanism. At first it notifies the
+unloading listeners in order to give them a chance to do cleanup and get
+their threads in a safe state. Then all registered modules are asked if they
+can be unloaded. That is, the function calls component_canUnload on every
+registered module. If <code>sal_True</code> is returned then <code>osl_unloadModule</code>
+is called for the belonging module as often as it is registered.
+<p>
+A call to <code>osl_unloadModule</code> does not guarantee that the module is unloaded even
+if its <code>component_canUnload</code> function returns <code>sal_True</code>.
+<p>
+The optional in-parameter <code>libUnused</code> specifies a period of time which a library
+must be unused in order to qualify for being unloaded. By using this argument
+one can counter the multithreading problem as described further above. It is in
+the responsibility of the user of this function to provide a timespan big enough
+to ensure that all threads are out of modules (see <code>component_canUnload</code>).
+<p>
+The service managers which have been created by functions such as
+<code>createRegistryServiceFactory</code> (declared in cppuhelper/servicefactory.hxx) are
+registered listeners and release the references to factories on notification.
+
+
+@param libUnused span of time that a module must be unused to be unloaded. the
+argument is optional.
+*/
+void SAL_CALL rtl_unloadUnusedModules( TimeValue* libUnused);
+
+/**
+rtl_addUnloadingListener takes an argument of this type.
+
+@param id - The value that has been passed as second argument to rtl_addUnloadingListener
+*/
+typedef void (SAL_CALL *rtl_unloadingListenerFunc)(void* id);
+/**
+The function registered an unloading listener. The callback argument is a
+function which is called when the unloading procedure has been initiated by a call to
+<code>rtl_unloadUnusedLibraries</code>. The second argument is used to distinguish between different
+listener instances and may be <code>NULL</code>. It will be passed as argument when the callback
+function is being called. The return value identifies the registered listener and will
+be used for removing the listener later on. If the same listener is added more then
+once then every registration is treated as if made for a different listener. That is,
+a different cookie is returned and the callback function will be called as many times
+as it has been registered.
+@param callback - a function that is called to notify listeners.
+@param this - a value to distinguish different listener instances
+@return identifier which is used in rtl_removeUnloadingListener
+*/
+sal_Int32 SAL_CALL rtl_addUnloadingListener( rtl_unloadingListenerFunc callback, void* _this);
+
+/**
+Listeners (the callback functions) must be unregistered before the listener code
+becomes invalid. That is, if a module contains listener code, namely callback
+functions of type <code>rtl_unloadingListenerFunc</code>, then those functions must not be
+registered when <code>component_canUnload</code> returns <code>sal_True</code>.
+
+@param cookie is an identifier as returned by <code>rtl_addUnloadingListener</code> function.
+*/
+void SAL_CALL rtl_removeUnloadingListener( sal_Int32 cookie );
+
+
+/**
+Pointers to <code>rtl_ModuleCount</code> are passed as arguments to the default factory creator
+functions: <code>createSingleComponentFactory</code>, <code>createSingleFactory</code>,
+<code>createOneInstanceFactory</code>.
+The factory implementation is calling <code>rtl_ModuleCount.acquire</code> when it is being
+constructed and it is calling <code>rtl_ModuleCount.release</code>. The implementations of
+<code>acquire</code>
+and <code>release</code> should influence the return value of <code>component_canUnload</code>
+in a way that it
+returns <code>sal_False</code> after <code>acquire</code> has been called. That is the module will not be unloaded
+once a default factory has been created. A call to <code>release</code> may cause
+<code>component_canUnload</code> to return <code>sal_False</code>, but only if there are
+no object alive which
+originated from the module. These objects are factory instances and the service instances
+which have been created by these factories.
+<p>
+It is not necessary to synchronize <code>acquire</code> and <code>release</code> as a whole.
+Simply sychronize the
+access to a counter variable, e.g. the <code>rtl_moduleCount_release</code> implementation:
+<pre>
+extern "C" void rtl_moduleCount_acquire(rtl_ModuleCount * that )
+{
+ rtl_StandardModuleCount* pMod= (rtl_StandardModuleCount*)that;
+ osl_incrementInterlockedCount( &pMod->counter);
+}
+</pre>
+The SAL library offers functions that can be used for <code>acquire</code> and <code>release</code>. See struct
+<code>_rtl_StandardModuleCount</code>.
+*/
+typedef struct _rtl_ModuleCount
+{
+ void ( SAL_CALL * acquire ) ( struct _rtl_ModuleCount * that );
+ void ( SAL_CALL * release ) ( struct _rtl_ModuleCount * that );
+}rtl_ModuleCount;
+
+
+#define MODULE_COUNT_INIT \
+{ {rtl_moduleCount_acquire,rtl_moduleCount_release}, rtl_moduleCount_canUnload, 0, {0, 0}}
+
+/**
+This struct can be used to implement the unloading mechanism. To make a UNO library
+unloadable create one global instance of this struct in the module. To initialize it one
+uses the MODULE_COUNT_INIT macro.
+
+<pre>rtl_StandardModuleCount globalModuleCount= MODULE_COUNT_INIT</pre>;
+*/
+typedef struct _rtl_StandardModuleCount
+{
+ rtl_ModuleCount modCnt;
+ sal_Bool ( *canUnload ) ( struct _rtl_StandardModuleCount* a, TimeValue* libUnused);
+ oslInterlockedCount counter;
+ TimeValue unusedSince;
+} rtl_StandardModuleCount;
+
+/** Default implementation for <code>rtl_ModuleCount.acquire</code>. Use this function along with
+<code>rtl_StandardModuleCount</code>.
+*/
+void rtl_moduleCount_acquire(rtl_ModuleCount * that );
+/** Default implementation for <code>rtl_ModuleCount.release</code>.
+Use this function along with
+<code>rtl_StandardModuleCount</code>.
+*/
+void rtl_moduleCount_release( rtl_ModuleCount * that );
+
+/** Default implementation for <code>component_canUnload</code>. Use this function along with
+<code>rtl_StandardModuleCount</code>.
+*/
+sal_Bool rtl_moduleCount_canUnload( rtl_StandardModuleCount * that, TimeValue* libUnused);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/sal/inc/rtl/uri.h b/sal/inc/rtl/uri.h
new file mode 100644
index 000000000000..aace6e934d27
--- /dev/null
+++ b/sal/inc/rtl/uri.h
@@ -0,0 +1,354 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_URI_H_
+#define _RTL_URI_H_
+
+#include "rtl/textenc.h"
+#include "rtl/ustring.h"
+#include "sal/types.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** Various predefined URI 'char classes.'
+
+ @descr
+ A 'char class' defines which (ASCII) characters can be written 'as they
+ are' in a part of a Uri, and which characters have to be written using
+ escape sequences ('%' followed by two hex digits). Characters outside
+ the ASCII range are always written using escape sequences.
+
+ @descr
+ If there are other frequently used char classes, they can be added to
+ this enumeration; the function rtl_getUriCharClass() has to be adapted
+ then, too.
+ */
+typedef enum
+{
+ /** The empty char class.
+
+ @descr
+ All characters are written using escape sequences.
+ */
+ rtl_UriCharClassNone,
+
+ /** The RFC 2732 <uric> char class.
+
+ @descr
+ The 'valid' characters are !$&'()*+,-./:;=?@[]_~ plus digits and
+ letters.
+ */
+ rtl_UriCharClassUric,
+
+ /** The RFC 2396 <uric_no_slash> char class.
+
+ @descr
+ The 'valid' characters are !$&'()*+,-.:;=?@_~ plus digits and letters.
+ */
+ rtl_UriCharClassUricNoSlash,
+
+ /** The RFC 2396 <rel_segment> char class.
+
+ @descr
+ The 'valid' characters are !$&'()*+,-.;=@_~ plus digits and letters.
+ */
+ rtl_UriCharClassRelSegment,
+
+ /** The RFC 2396 <reg_name> char class.
+
+ @descr
+ The 'valid' characters are !$&'()*+,-.:;=@_~ plus digits and letters.
+ */
+ rtl_UriCharClassRegName,
+
+ /** The RFC 2396 <userinfo> char class.
+
+ @descr
+ The 'valid' characters are !$&'()*+,-.:;=_~ plus digits and letters.
+ */
+ rtl_UriCharClassUserinfo,
+
+ /** The RFC 2396 <pchar> char class.
+
+ @descr
+ The 'valid' characters are !$&'()*+,-.:=@_~ plus digits and letters.
+ */
+ rtl_UriCharClassPchar,
+
+ /** The char class for the values of uno URL parameters.
+
+ @descr
+ The 'valid' characters are !$&'()*+-./:?@_~ plus digits and letters.
+ */
+ rtl_UriCharClassUnoParamValue,
+
+ rtl_UriCharClass_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+}
+rtl_UriCharClass;
+
+/** The mechanism describing how escape sequences in the input of
+ rtl_uriEncode() are handled.
+ */
+typedef enum
+{
+ /** The special meaning of '%' is ignored (i.e., there are by definition
+ no escape sequences in the input).
+
+ @descr
+ This mechanism is useful to encode user input as part of a URI (e.g.,
+ the user-supplied password in an ftp URL---'%20abcde' is a valid
+ password, so do not assume that the '%20' is an escaped space).
+ */
+ rtl_UriEncodeIgnoreEscapes,
+
+ /** All escape sequences ('%' followed by two hex digits) are kept intact,
+ even if they represent characters that need not be escaped or if they
+ do not even map to characters in the given charset.
+
+ @descr
+ This mechanism is useful when passing on complete URIs more or less
+ unmodified (e.g., within an HTTP proxy): missing escape sequences are
+ added, but existing escape sequences are not touched (except that any
+ lower case hex digits are replaced by upper case hex digits).
+ */
+ rtl_UriEncodeKeepEscapes,
+
+ /** All escape sequences ('%' followed by two hex digits) are resolved in
+ a first step; only those that represent characters that need to be
+ escaped are kept intact.
+
+ @descr
+ This mechanism is useful to properly encode complete URIs entered by
+ the user: the URI is brought into a 'canonic form,' but care is taken
+ not to damage (valid) escape sequences the (careful) user already
+ entered as such.
+ */
+ rtl_UriEncodeCheckEscapes,
+
+ /** Like rtl_UriEncodeIgnoreEscapes, but indicating failure when converting
+ unmappable characters.
+
+ @since UDK 3.2.0
+ */
+ rtl_UriEncodeStrict,
+
+ /** Like rtl_UriEncodeKeepEscapes, but indicating failure when converting
+ unmappable characters.
+
+ @since UDK 3.2.7
+ */
+ rtl_UriEncodeStrictKeepEscapes,
+
+ rtl_UriEncode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+}
+rtl_UriEncodeMechanism;
+
+/** The mechanism describing how rtl_uriDecode() translates (part of) a URI
+ into a Unicode string.
+ */
+typedef enum
+{
+ /** The text is returned completely unmodified.
+ */
+ rtl_UriDecodeNone,
+
+ /** The text is returned in the form of an IURI (cf.
+ draft-masinter-url-i18n-05.txt).
+
+ @descr
+ All escape sequences representing ASCII characters (%00--%7F) are
+ kept, all other escape sequences are interpreted as UTF-8 characters
+ and translated to Unicode, if possible.
+ */
+ rtl_UriDecodeToIuri,
+
+ /** The text is decoded.
+
+ @descr
+ All escape sequences representing characters from the given charset
+ are decoded and translated to Unicode, if possible.
+ */
+ rtl_UriDecodeWithCharset,
+
+ /** Like rtl_UriDecodeWithCharset, but indicating failure when converting
+ unmappable characters.
+
+ @since UDK 3.2.0
+ */
+ rtl_UriDecodeStrict,
+
+ rtl_UriDecode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+}
+rtl_UriDecodeMechanism;
+
+/** Map a predefined rtl_UriCharClass to a form usable by rtl_uriEncode().
+
+ @descr
+ The function rtl_uriEncode() expects an array of 128 booleans, and this
+ function maps rtl_UriCharClass enumeration members to such arrays.
+
+ @param eCharClass
+ Any valid member of rtl_UriCharClass.
+
+ @return
+ An array of 128 booleans, to be used in calls to rtl_uriEncode().
+ */
+sal_Bool const * SAL_CALL rtl_getUriCharClass(rtl_UriCharClass eCharClass)
+ SAL_THROW_EXTERN_C();
+
+/** Encode a text as (part of) a URI.
+
+ @param pText
+ Any Unicode string. Must not be null.
+
+ @param pCharClass
+ A char class, represented as an array of 128 booleans (true means keep the
+ corresponding ASCII character unencoded, false means encode it). Must not
+ be null, and the boolean corresponding to the percent sign (0x25) must be
+ false. (See rtl_getUriCharClass() for a function mapping from
+ rtl_UriCharClass to such arrays.)
+
+ @param eMechanism
+ The mechanism describing how escape sequences in the input text are
+ handled.
+
+ @param eCharset
+ When Unicode characters from the input text have to be written using
+ escape sequences (because they are either outside the ASCII range or do
+ not belong to the given char class), they are first translated into this
+ charset before being encoded using escape sequences.
+
+ Also, if the encode mechanism is rtl_UriEncodeCheckEscapes, all escape
+ sequences already present in the input text are interpreted as characters
+ from this charset.
+
+ @param pResult
+ Returns an encoded representation of the input text. Must itself not be
+ null, and must point to either null or a valid string.
+
+ If the encode mechanism is rtl_UriEncodeStrict, and pText cannot be
+ converted to eCharset because it contains unmappable characters (which
+ implies that pText is not empty), then an empty string is returned.
+ */
+void SAL_CALL rtl_uriEncode(rtl_uString * pText,
+ sal_Bool const * pCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset,
+ rtl_uString ** pResult)
+ SAL_THROW_EXTERN_C();
+
+/** Decode (a part of) a URI.
+
+ @param pText
+ Any Unicode string. Must not be null. (If the input is indeed part of a
+ valid URI, this string will only contain a subset of the ASCII characters,
+ but this function also handles other Unicode characters properly.)
+
+ @param eMechanism
+ The mechanism describing how the input text is translated into a Unicode
+ string.
+
+ @param eCharset
+ When the decode mechanism is rtl_UriDecodeWithCharset, all escape
+ sequences in the input text are interpreted as characters from this
+ charset. Those characters are translated to Unicode characters in the
+ resulting output, if possible.
+
+ When the decode mechanism is rtl_UriDecodeNone or rtl_UriDecodeToIuri,
+ this parameter is ignored (and is best specified as
+ RTL_TEXTENCODING_UTF8).
+
+ @param pResult
+ Returns a decoded representation of the input text. Must itself not be
+ null, and must point to either null or a valid string.
+
+ If the decode mechanism is rtl_UriDecodeStrict, and pText cannot be
+ converted to eCharset because it contains (encodings of) unmappable
+ characters (which implies that pText is not empty), then an empty string is
+ returned.
+ */
+void SAL_CALL rtl_uriDecode(rtl_uString * pText,
+ rtl_UriDecodeMechanism eMechanism,
+ rtl_TextEncoding eCharset,
+ rtl_uString ** pResult)
+ SAL_THROW_EXTERN_C();
+
+/** Convert a relative URI reference into an absolute one.
+
+ A URI reference is a URI plus an optional <"#" fragment> part.
+
+ This function uses the algorithm described in RFC 2396, section 5.2, with
+ the following clarifications: (1) Backwards-compatible relative URIs
+ starting with a scheme component (see RFC 2396, section 5.2, step 3) are not
+ supported. (2) Segments "." and ".." within the path of the base URI are
+ not considered special, RFC 2396 seems a bit unlcear about that point.
+ (3) Erroneous excess segments ".." within the path of the relative URI (if
+ it is indeed relative) are left intact, as the examples in RFC 2396,
+ section C.2, suggest. (4) If the relative URI is a reference to the
+ "current document," the "current document" is taken to be the base URI.
+
+ This function signals exceptions by returning false and letting pException
+ point to a message explaining the exception.
+
+ @param pBaseUriRef
+ An absolute, hierarchical URI reference that serves as the base URI. If it
+ has to be inspected (i.e., pRelUriRef is not an absolute URI already), and
+ if it either is not an absolute URI (i.e., does not begin with a
+ <scheme ":"> part) or has a path that is non-empty but does not start
+ with "/", an exception will be signaled.
+
+ @param pRelUriRef
+ An URI reference that may be either absolute or relative. If it is
+ absolute, it will be returned unmodified (and it need not be hierarchical
+ then).
+
+ @param pResult
+ Returns an absolute URI reference. Must itself not be null, and must point
+ to either null or a valid string. If an exception is signalled, it is left
+ unchanged.
+
+ @param pException
+ Returns an explanatory message in case an exception is signalled. Must
+ itself not be null, and must point to either null or a valid string. If no
+ exception is signalled, it is left unchanged.
+
+ @return
+ True if no exception is signalled, otherwise false.
+ */
+sal_Bool SAL_CALL rtl_uriConvertRelToAbs(rtl_uString * pBaseUriRef,
+ rtl_uString * pRelUriRef,
+ rtl_uString ** pResult,
+ rtl_uString ** pException)
+ SAL_THROW_EXTERN_C();
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTL_URI_H_ */
diff --git a/sal/inc/rtl/uri.hxx b/sal/inc/rtl/uri.hxx
new file mode 100644
index 000000000000..9dfe1d5ec80e
--- /dev/null
+++ b/sal/inc/rtl/uri.hxx
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_URI_HXX_
+#define _RTL_URI_HXX_
+
+#include "rtl/malformeduriexception.hxx"
+#include "rtl/uri.h"
+#include "rtl/textenc.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+namespace rtl {
+
+/** A wrapper around the C functions from <rtl/uri.h>.
+ */
+class Uri
+{
+public:
+ /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
+ an array of 128 booleans as char class.
+ */
+ static inline rtl::OUString encode(rtl::OUString const & rText,
+ sal_Bool const * pCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(());
+
+ /** A wrapper around rtl_uriEncode() from <rtl/uri.h> (see there), using
+ a predefined rtl_UriCharClass enumeration member.
+ */
+ static inline rtl::OUString encode(rtl::OUString const & rText,
+ rtl_UriCharClass eCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(());
+
+ /** A wrapper around rtl_uriDecode() from <rtl/uri.h> (see there).
+ */
+ static inline rtl::OUString decode(rtl::OUString const & rText,
+ rtl_UriDecodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(());
+
+ /** A wrapper around rtl_uriConvertRelToAbs() from <rtl/uri.h> (see there).
+
+ @exception MalformedUriException
+ Thrown in case rtl_uriConvertRelToAbs() signals an exception due to a
+ malformed base URI.
+ */
+ static inline rtl::OUString convertRelToAbs(
+ rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
+
+private:
+ /** not implemented
+ @internal */
+ Uri();
+
+ /** not implemented
+ @internal */
+ Uri(Uri &);
+
+ /** not implemented
+ @internal */
+ ~Uri();
+
+ /** not implemented
+ @internal */
+ void operator =(Uri);
+};
+
+inline rtl::OUString Uri::encode(rtl::OUString const & rText,
+ sal_Bool const * pCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(())
+{
+ rtl::OUString aResult;
+ rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
+ pCharClass,
+ eMechanism,
+ eCharset,
+ &aResult.pData);
+ return aResult;
+}
+
+inline rtl::OUString Uri::encode(rtl::OUString const & rText,
+ rtl_UriCharClass eCharClass,
+ rtl_UriEncodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(())
+{
+ rtl::OUString aResult;
+ rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
+ rtl_getUriCharClass(eCharClass),
+ eMechanism,
+ eCharset,
+ &aResult.pData);
+ return aResult;
+}
+
+inline rtl::OUString Uri::decode(rtl::OUString const & rText,
+ rtl_UriDecodeMechanism eMechanism,
+ rtl_TextEncoding eCharset)
+ SAL_THROW(())
+{
+ rtl::OUString aResult;
+ rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
+ eMechanism,
+ eCharset,
+ &aResult.pData);
+ return aResult;
+}
+
+inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
+ rtl::OUString const & rRelUriRef)
+{
+ rtl::OUString aResult;
+ rtl::OUString aException;
+ if (!rtl_uriConvertRelToAbs(
+ const_cast< rtl::OUString & >(rBaseUriRef).pData,
+ const_cast< rtl::OUString & >(rRelUriRef).pData, &aResult.pData,
+ &aException.pData))
+ throw MalformedUriException(aException);
+ return aResult;
+}
+
+}
+
+#endif // _RTL_URI_HXX_
diff --git a/sal/inc/rtl/ustrbuf.h b/sal/inc/rtl/ustrbuf.h
new file mode 100644
index 000000000000..632040818f21
--- /dev/null
+++ b/sal/inc/rtl/ustrbuf.h
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_USTRBUF_H_
+#define _RTL_USTRBUF_H_
+
+#include <rtl/ustring.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @HTML
+ Allocates a new <code>String</code> that contains characters from
+ the character array argument.
+
+ The <code>count</code> argument specifies
+ the length of the array. The initial capacity of the string buffer is
+ <code>16</code> plus the length of the string argument.
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param value the initial value of the string.
+ @param count the length of value.
+ */
+void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr,
+ const sal_Unicode * value,
+ sal_Int32 count );
+
+/**
+ Allocates a new <code>String</code> that contains the same sequence of
+ characters as the string argument.
+
+ The initial capacity is the larger of:
+ <ul>
+ <li> The <code>bufferLen</code> argument.
+ <li> The <code>length</code> of the string argument.
+ </ul>
+
+ @param newStr out parameter, contains the new string. The reference count is 1.
+ @param capacity the initial len of the string buffer.
+ @param oldStr the initial value of the string.
+ @return the new capacity of the string buffer
+ */
+sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr,
+ sal_Int32 capacity,
+ rtl_uString * olsStr );
+
+/**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ If the current capacity of this string buffer is less than the
+ argument, then a new internal buffer is allocated with greater
+ capacity. The new capacity is the larger of:
+ <ul>
+ <li>The <code>minimumCapacity</code> argument.
+ <li>Twice the old capacity, plus <code>2</code>.
+ </ul>
+ If the <code>minimumCapacity</code> argument is nonpositive, this
+ method takes no action and simply returns.
+
+ @param capacity in: old capicity, out: new capacity.
+ @param minimumCapacity the minimum desired capacity.
+ */
+void SAL_CALL rtl_uStringbuffer_ensureCapacity( /*inout*/rtl_uString ** This,
+ /*inout*/sal_Int32* capacity,
+ sal_Int32 minimumCapacity);
+
+/**
+ Inserts the string representation of the <code>str</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+
+ @param This The string, on that the operation should take place
+ @param capacity the capacity of the string buffer
+ @param offset the offset.
+ @param str a character array.
+ @param len the number of characters to append.
+ */
+void SAL_CALL rtl_uStringbuffer_insert( /*inout*/rtl_uString ** This,
+ /*inout*/sal_Int32 * capacity,
+ sal_Int32 offset,
+ const sal_Unicode * str,
+ sal_Int32 len);
+
+/**
+ Inserts a single UTF-32 character into this string buffer.
+
+ <p>The single UTF-32 character will be represented within the string buffer
+ as either one or two UTF-16 code units.</p>
+
+ @param pThis the string buffer on which the operation is performed
+
+ @param capacity the capacity of the string buffer
+
+ @param offset the offset into this string buffer (from zero to the length
+ of this string buffer, inclusive)
+
+ @param c a well-formed UTF-32 code unit (that is, a value in the range
+ <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
+ <code>0xD800</code>&ndash;<code>0xDFFF</code>)
+ */
+void SAL_CALL rtl_uStringbuffer_insertUtf32(
+ rtl_uString ** pThis, sal_Int32 * capacity, sal_Int32 offset, sal_uInt32 c)
+ SAL_THROW_EXTERN_C();
+
+/**
+ Inserts the 8-Bit ASCII string representation of the <code>str</code>
+ array argument into this string buffer.
+
+ Since this function is optimized
+ for performance, the ASCII character values are not converted in any way.
+ The caller has to make sure that all ASCII characters are in the allowed
+ range between 0 and 127.
+ <p>
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+
+ @param This The string, on that the operation should take place
+ @param capacity the capacity of the string buffer
+ @param offset the offset.
+ @param str a character array.
+ @param len the number of characters to append.
+ */
+void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This,
+ /*inout*/sal_Int32 * capacity,
+ sal_Int32 offset,
+ const sal_Char * str,
+ sal_Int32 len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_USTRBUF_H_ */
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
new file mode 100644
index 000000000000..3f8421b1f3c7
--- /dev/null
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -0,0 +1,774 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_USTRBUF_HXX_
+#define _RTL_USTRBUF_HXX_
+
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.h>
+#ifndef _RTL_USTRING_HXX
+#include <rtl/ustring.hxx>
+#endif
+
+#ifdef __cplusplus
+
+namespace rtl
+{
+
+/** @HTML
+ A string buffer implements a mutable sequence of characters.
+ <p>
+ String buffers are safe for use by multiple threads. The methods
+ are synchronized where necessary so that all the operations on any
+ particular instance behave as if they occur in some serial order.
+ <p>
+ String buffers are used by the compiler to implement the binary
+ string concatenation operator <code>+</code>. For example, the code:
+ <p><blockquote><pre>
+ x = "a" + 4 + "c"
+ </pre></blockquote><p>
+ is compiled to the equivalent of:
+ <p><blockquote><pre>
+ x = new OUStringBuffer().append("a").append(4).append("c")
+ .toString()
+ </pre></blockquote><p>
+ The principal operations on a <code>OUStringBuffer</code> are the
+ <code>append</code> and <code>insert</code> methods, which are
+ overloaded so as to accept data of any type. Each effectively
+ converts a given datum to a string and then appends or inserts the
+ characters of that string to the string buffer. The
+ <code>append</code> method always adds these characters at the end
+ of the buffer; the <code>insert</code> method adds the characters at
+ a specified point.
+ <p>
+ For example, if <code>z</code> refers to a string buffer object
+ whose current contents are "<code>start</code>", then
+ the method call <code>z.append("le")</code> would cause the string
+ buffer to contain "<code>startle</code>", whereas
+ <code>z.insert(4, "le")</code> would alter the string buffer to
+ contain "<code>starlet</code>".
+ <p>
+ Every string buffer has a capacity. As long as the length of the
+ character sequence contained in the string buffer does not exceed
+ the capacity, it is not necessary to allocate a new internal
+ buffer array. If the internal buffer overflows, it is
+ automatically made larger.
+ */
+class OUStringBuffer
+{
+public:
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity of 16 characters.
+ */
+ OUStringBuffer()
+ : pData(NULL)
+ , nCapacity( 16 )
+ {
+ rtl_uString_new_WithLength( &pData, nCapacity );
+ }
+
+ /**
+ Allocates a new string buffer that contains the same sequence of
+ characters as the string buffer argument.
+
+ @param value a <code>OStringBuffer</code>.
+ */
+ OUStringBuffer( const OUStringBuffer & value )
+ : pData(NULL)
+ , nCapacity( value.nCapacity )
+ {
+ rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData );
+ }
+
+ /**
+ Constructs a string buffer with no characters in it and an
+ initial capacity specified by the <code>length</code> argument.
+
+ @param length the initial capacity.
+ */
+ OUStringBuffer(sal_Int32 length)
+ : pData(NULL)
+ , nCapacity( length )
+ {
+ rtl_uString_new_WithLength( &pData, length );
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string argument.
+
+ The initial
+ capacity of the string buffer is <code>16</code> plus the length
+ of the string argument.
+
+ @param str the initial contents of the buffer.
+ */
+ OUStringBuffer(OUString value)
+ : pData(NULL)
+ , nCapacity( value.getLength() + 16 )
+ {
+ rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() );
+ }
+
+ /** Assign to this a copy of value.
+ */
+ OUStringBuffer& operator = ( const OUStringBuffer& value )
+ {
+ if (this != &value)
+ {
+ rtl_uStringbuffer_newFromStringBuffer(&pData,
+ value.nCapacity,
+ value.pData);
+ nCapacity = value.nCapacity;
+ }
+ return *this;
+ }
+
+ /**
+ Release the string data.
+ */
+ ~OUStringBuffer()
+ {
+ rtl_uString_release( pData );
+ }
+
+ /**
+ Fill the string data in the new string and clear the buffer.
+
+ This method is more efficient than the contructor of the string. It does
+ not copy the buffer.
+
+ @return the string previously contained in the buffer.
+ */
+ OUString makeStringAndClear()
+ {
+ OUString aRet( pData );
+ rtl_uString_new(&pData);
+ nCapacity = 0;
+ return aRet;
+ }
+
+ /**
+ Returns the length (character count) of this string buffer.
+
+ @return the number of characters in this string buffer.
+ */
+ sal_Int32 getLength() const
+ {
+ return pData->length;
+ }
+
+ /**
+ Returns the current capacity of the String buffer.
+
+ The capacity
+ is the amount of storage available for newly inserted
+ characters. The real buffer size is 2 bytes longer, because
+ all strings are 0 terminated.
+
+ @return the current capacity of this string buffer.
+ */
+ sal_Int32 getCapacity() const
+ {
+ return nCapacity;
+ }
+
+ /**
+ Ensures that the capacity of the buffer is at least equal to the
+ specified minimum.
+
+ The new capacity will be at least as large as the maximum of the current
+ length (so that no contents of the buffer is destroyed) and the given
+ minimumCapacity. If the given minimumCapacity is negative, nothing is
+ changed.
+
+ @param minimumCapacity the minimum desired capacity.
+ */
+ void ensureCapacity(sal_Int32 minimumCapacity)
+ {
+ rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity );
+ }
+
+ /**
+ Sets the length of this String buffer.
+
+ If the <code>newLength</code> argument is less than the current
+ length of the string buffer, the string buffer is truncated to
+ contain exactly the number of characters given by the
+ <code>newLength</code> argument.
+ <p>
+ If the <code>newLength</code> argument is greater than or equal
+ to the current length, sufficient null characters
+ (<code>'&#92;u0000'</code>) are appended to the string buffer so that
+ length becomes the <code>newLength</code> argument.
+ <p>
+ The <code>newLength</code> argument must be greater than or equal
+ to <code>0</code>.
+
+ @param newLength the new length of the buffer.
+ */
+ void setLength(sal_Int32 newLength)
+ {
+ OSL_ASSERT(newLength >= 0);
+ // Avoid modifications if pData points to const empty string:
+ if( newLength != pData->length )
+ {
+ if( newLength > nCapacity )
+ rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength);
+ else
+ pData->buffer[newLength] = 0;
+ pData->length = newLength;
+ }
+ }
+
+ /**
+ Returns the character at a specific index in this string buffer.
+
+ The first character of a string buffer is at index
+ <code>0</code>, the next at index <code>1</code>, and so on, for
+ array indexing.
+ <p>
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the desired character.
+ @return the character at the specified index of this string buffer.
+ */
+ sal_Unicode charAt( sal_Int32 index ) const
+ {
+ OSL_ASSERT(index >= 0 && index < pData->length);
+ return pData->buffer[ index ];
+ }
+
+ /**
+ Return a null terminated unicode character array.
+ */
+ operator const sal_Unicode *() const { return pData->buffer; }
+
+ /**
+ Return a null terminated unicode character array.
+ */
+ const sal_Unicode* getStr() const { return pData->buffer; }
+
+
+ /**
+ The character at the specified index of this string buffer is set
+ to <code>ch</code>.
+
+ The index argument must be greater than or equal to
+ <code>0</code>, and less than the length of this string buffer.
+
+ @param index the index of the character to modify.
+ @param ch the new character.
+ */
+ OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
+ {
+ OSL_ASSERT(index >= 0 && index < pData->length);
+ pData->buffer[ index ] = ch;
+ return *this;
+ }
+
+ /**
+ Appends the string to this string buffer.
+
+ The characters of the <code>String</code> argument are appended, in
+ order, to the contents of this string buffer, increasing the
+ length of this string buffer by the length of the argument.
+
+ @param str a string.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(const OUString &str)
+ {
+ return append( str.getStr(), str.getLength() );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ The characters of the array argument are appended, in order, to
+ the contents of this string buffer. The length of this string
+ buffer increases by the length of the argument.
+
+ @param str the characters to be appended.
+ @return this string buffer.
+ */
+ OUStringBuffer & append( const sal_Unicode * str )
+ {
+ return append( str, rtl_ustr_getLength( str ) );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code> array
+ argument to this string buffer.
+
+ Characters of the character array <code>str</code> are appended,
+ in order, to the contents of this string buffer. The length of this
+ string buffer increases by the value of <code>len</code>.
+
+ @param str the characters to be appended; must be non-null, and must
+ point to at least len characters
+ @param len the number of characters to append; must be non-negative
+ @return this string buffer.
+ */
+ OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len );
+ return *this;
+ }
+
+ /**
+ Appends a 8-Bit ASCII character string to this string buffer.
+
+ Since this method is optimized for performance. the ASCII
+ character values are not converted in any way. The caller
+ has to make sure that all ASCII characters are in the
+ allowed range between 0 and 127. The ASCII string must be
+ NULL-terminated.
+ <p>
+ The characters of the array argument are appended, in order, to
+ the contents of this string buffer. The length of this string
+ buffer increases by the length of the argument.
+
+ @param str the 8-Bit ASCII characters to be appended.
+ @return this string buffer.
+ */
+ OUStringBuffer & appendAscii( const sal_Char * str )
+ {
+ return appendAscii( str, rtl_str_getLength( str ) );
+ }
+
+ /**
+ Appends a 8-Bit ASCII character string to this string buffer.
+
+ Since this method is optimized for performance. the ASCII
+ character values are not converted in any way. The caller
+ has to make sure that all ASCII characters are in the
+ allowed range between 0 and 127. The ASCII string must be
+ NULL-terminated.
+ <p>
+ Characters of the character array <code>str</code> are appended,
+ in order, to the contents of this string buffer. The length of this
+ string buffer increases by the value of <code>len</code>.
+
+ @param str the 8-Bit ASCII characters to be appended; must be non-null,
+ and must point to at least len characters
+ @param len the number of characters to append; must be non-negative
+ @return this string buffer.
+ */
+ OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len)
+ {
+ rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len );
+ return *this;
+ }
+
+
+ /**
+ Appends the string representation of the <code>sal_Bool</code>
+ argument to the string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Bool b)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ return append( sz, rtl_ustr_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Appends the string representation of the <code>char</code>
+ argument to this string buffer.
+
+ The argument is appended to the contents of this string buffer.
+ The length of this string buffer increases by <code>1</code>.
+
+ @param ch a <code>char</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Unicode c)
+ {
+ return append( &c, 1 );
+ }
+
+ /**
+ Appends the string representation of the <code>sal_Int32</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param i an <code>sal_Int32</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
+ return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>long</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param l a <code>long</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
+ return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Appends the string representation of the <code>float</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param f a <code>float</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(float f)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
+ return append( sz, rtl_ustr_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Appends the string representation of the <code>double</code>
+ argument to this string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param d a <code>double</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & append(double d)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
+ return append( sz, rtl_ustr_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Appends a single UTF-32 character to this string buffer.
+
+ <p>The single UTF-32 character will be represented within the string
+ buffer as either one or two UTF-16 code units.</p>
+
+ @param c a well-formed UTF-32 code unit (that is, a value in the range
+ <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
+ <code>0xD800</code>&ndash;<code>0xDFFF</code>)
+
+ @return
+ this string buffer
+ */
+ OUStringBuffer & appendUtf32(sal_uInt32 c) {
+ return insertUtf32(getLength(), c);
+ }
+
+ /**
+ Inserts the string into this string buffer.
+
+ The characters of the <code>String</code> argument are inserted, in
+ order, into this string buffer at the indicated offset. The length
+ of this string buffer is increased by the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param str a string.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
+ {
+ return insert( offset, str.getStr(), str.getLength() );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param ch a character array.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str )
+ {
+ return insert( offset, str, rtl_ustr_getLength( str ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code> array
+ argument into this string buffer.
+
+ The characters of the array argument are inserted into the
+ contents of this string buffer at the position indicated by
+ <code>offset</code>. The length of this string buffer increases by
+ the length of the argument.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param ch a character array.
+ @param len the number of characters to append.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len)
+ {
+ // insert behind the last character
+ rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len );
+ return *this;
+ }
+
+ /**
+ Inserts the string representation of the <code>sal_Bool</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>sal_Bool</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Bool b)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>char</code>
+ argument into this string buffer.
+
+ The second argument is inserted into the contents of this string
+ buffer at the position indicated by <code>offset</code>. The length
+ of this string buffer increases by one.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param ch a <code>char</code>.
+ @return this string buffer.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c)
+ {
+ return insert( offset, &c, 1 );
+ }
+
+ /**
+ Inserts the string representation of the second <code>sal_Int32</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b an <code>sal_Int32</code>.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32];
+ return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>long</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>long</code>.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 )
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64];
+ return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>float</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>float</code>.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer insert(sal_Int32 offset, float f)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT];
+ return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) );
+ }
+
+ /**
+ Inserts the string representation of the <code>double</code>
+ argument into this string buffer.
+
+ The second argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then inserted into this string buffer at the indicated
+ offset.
+ <p>
+ The offset argument must be greater than or equal to
+ <code>0</code>, and less than or equal to the length of this
+ string buffer.
+
+ @param offset the offset.
+ @param b a <code>double</code>.
+ @return this string buffer.
+ @exception StringIndexOutOfBoundsException if the offset is invalid.
+ */
+ OUStringBuffer & insert(sal_Int32 offset, double d)
+ {
+ sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE];
+ return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) );
+ }
+
+ /**
+ Inserts a single UTF-32 character into this string buffer.
+
+ <p>The single UTF-32 character will be represented within the string
+ buffer as either one or two UTF-16 code units.</p>
+
+ @param offset the offset into this string buffer (from zero to the length
+ of this string buffer, inclusive)
+
+ @param c a well-formed UTF-32 code unit (that is, a value in the range
+ <code>0</code>&ndash;<code>0x10FFFF</code>, but excluding
+ <code>0xD800</code>&ndash;<code>0xDFFF</code>)
+
+ @return this string buffer
+ */
+ OUStringBuffer & insertUtf32(sal_Int32 offset, sal_uInt32 c) {
+ rtl_uStringbuffer_insertUtf32(&pData, &nCapacity, offset, c);
+ return *this;
+ }
+
+ /** Allows access to the internal data of this OUStringBuffer, for effective
+ manipulation.
+
+ This method should be used with care. After you have called this
+ method, you may use the returned pInternalData or pInternalCapacity only
+ as long as you make no other method call on this OUStringBuffer.
+
+ @param pInternalData
+ This output parameter receives a pointer to the internal data
+ (rtl_uString pointer). pInternalData itself must not be null.
+
+ @param pInternalCapacity
+ This output parameter receives a pointer to the internal capacity.
+ pInternalCapacity itself must not be null.
+ */
+ inline void accessInternals(rtl_uString *** pInternalData,
+ sal_Int32 ** pInternalCapacity)
+ {
+ *pInternalData = &pData;
+ *pInternalCapacity = &nCapacity;
+ }
+
+private:
+ /**
+ A pointer to the data structur which contains the data.
+ */
+ rtl_uString * pData;
+
+ /**
+ The len of the pData->buffer.
+ */
+ sal_Int32 nCapacity;
+};
+
+}
+
+#endif /* __cplusplus */
+#endif /* _RTL_USTRBUF_HXX_ */
diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h
new file mode 100644
index 000000000000..22e697e370e8
--- /dev/null
+++ b/sal/inc/rtl/ustring.h
@@ -0,0 +1,1660 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_USTRING_H_
+#define _RTL_USTRING_H_
+
+#include <sal/types.h>
+#include <osl/interlck.h>
+#include <rtl/string.h>
+#include <rtl/textenc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ======================================================================= */
+
+/** Return the length of a string.
+
+ The length is equal to the number of 16-bit Unicode characters in the
+ string, without the terminating NUL character.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the length of the sequence of characters represented by this string,
+ excluding the terminating NUL character.
+ */
+sal_Int32 SAL_CALL rtl_ustr_getLength( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting. Both strings must be
+ null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_compare( const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_compare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string
+ compares less than the second string, and a value greater than 0 if the
+ first string compares greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_reverseCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front for equality.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns 'true' if, ans only if, both strings are equal.
+ This function cannot be used for language-specific sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified len.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified len.
+
+ @param len
+ the length of both strings.
+
+ @return
+ true if both strings are equal, false if they are not equal.
+ */
+
+sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength( const sal_Unicode * first, const sal_Char * second, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting. Both strings must be null-terminated.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated string which is compared with the first one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase( const sal_Unicode * first, const sal_Unicode * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_compareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters, ignoring the case
+ of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting. Both strings must be
+ null-terminated.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings from back to front.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. This function
+ cannot be used for language-specific sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second ASCII string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string
+ compares less than the second string, and a value greater than 0 if the
+ first string compares greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting. Both strings must be null-terminated.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first null-terminated string to be compared.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase( const sal_Unicode * first, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second ) SAL_THROW_EXTERN_C();
+
+/** Compare two strings, ignoring the case of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second string which is compared with the first one. Need not be
+ null-terminated, but must be at least as long as the specified secondLen.
+
+ @param secondLen
+ the length of the second string.
+
+ @return
+ 0 if both strings are equal, a value less than 0 if the first string is
+ less than the second string, and a value greater than 0 if the first
+ string is greater than the second string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ sal_Unicode const * first, sal_Int32 firstLen,
+ char const * second, sal_Int32 secondLen) SAL_THROW_EXTERN_C();
+
+/** Compare two strings with a maximum count of characters, ignoring the case
+ of ASCII characters.
+
+ The comparison is based on the numeric value of each character in the
+ strings and returns a value indicating their relationship. Character
+ values between 65 and 90 (ASCII A--Z) are interpreted as values between 97
+ and 122 (ASCII a--z). This function cannot be used for language-specific
+ sorting.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param first
+ the first string to be compared. Need not be null-terminated, but must be
+ at least as long as the specified firstLen.
+
+ @param firstLen
+ the length of the first string.
+
+ @param second
+ the second null-terminated ASCII string which is compared with the first
+ one.
+
+ @param shortenedLen
+ the maximum number of characters to compare. This length can be greater
+ or smaller than the lengths of the two strings.
+
+ @return
+ 0 if both substrings are equal, a value less than 0 if the first substring
+ is less than the second substring, and a value greater than 0 if the first
+ substring is greater than the second substring.
+ */
+sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 shortenedLen ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes. The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ a hash code for the given string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_hashCode( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Return a hash code for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @return
+ a hash code for the given string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength( const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+sal_Int32 SAL_CALL rtl_ustr_indexOfChar( const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the first occurrence of the character in the
+ string, or -1 if the character does not occur.
+ */
+sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength( const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar( const sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a character within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param ch
+ the character to be searched for.
+
+ @return
+ the index (starting at 0) of the last occurrence of the character in the
+ string, or -1 if the character does not occur. The returned value is
+ always smaller than the string length.
+ */
+sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength( const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_ustr_indexOfStr( const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength( const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Search for the first occurrence of an ASCII substring within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string; must be non-negative.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param subLen
+ the length of the substring; must be non-negative.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ If subLen is zero, -1 is returned.
+
+ @since UDK 3.2.7
+*/
+sal_Int32 SAL_CALL rtl_ustr_indexOfAscii_WithLength(
+ sal_Unicode const * str, sal_Int32 len,
+ char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+ Both strings must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param subStr
+ the null-terminated substring to be searched for.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr( const sal_Unicode * str, const sal_Unicode * subStr ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of a substring within a string.
+
+ If subStr is empty, or both str and subStr are empty, -1 is returned.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen.
+
+ @param subLen
+ the length of the substring.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ */
+sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength( const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ) SAL_THROW_EXTERN_C();
+
+/** Search for the last occurrence of an ASCII substring within a string.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string; must be non-negative.
+
+ @param subStr
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified subLen. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param subLen
+ the length of the substring; must be non-negative.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within the string, or -1 if the substring does not occur.
+ If subLen is zero, -1 is returned.
+
+ @since UDK 3.2.7
+*/
+sal_Int32 SAL_CALL rtl_ustr_lastIndexOfAscii_WithLength(
+ sal_Unicode const * str, sal_Int32 len,
+ char const * subStr, sal_Int32 subLen) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+ The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+void SAL_CALL rtl_ustr_replaceChar( sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
+
+/** Replace all occurrences of a single character within a string.
+
+ If oldChar does not occur within str, then the string is not modified.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+void SAL_CALL rtl_ustr_replaceChar_WithLength( sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+void SAL_CALL rtl_ustr_toAsciiLowerCase( sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII uppercase letters to lowercase within a string.
+
+ The characters with values between 65 and 90 (ASCII A--Z) are replaced
+ with values between 97 and 122 (ASCII a--z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength( sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z). The string must be
+ null-terminated.
+
+ @param str
+ a null-terminated string.
+ */
+void SAL_CALL rtl_ustr_toAsciiUpperCase( sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Convert all ASCII lowercase letters to uppercase within a string.
+
+ The characters with values between 97 and 122 (ASCII a--z) are replaced
+ with values between 65 and 90 (ASCII A--Z).
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+ */
+void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength( sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of a string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the new length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_trim( sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Remove white space from both ends of the string.
+
+ All characters with values less than or equal to 32 (the space character)
+ are considered to be white space. This function cannot be used for
+ language-specific operations. The string must be null-terminated.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the original length of the string.
+
+ @return
+ the new length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_trim_WithLength( sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Create the string representation of a boolean.
+
+ If b is true, the buffer is filled with the string "true" and 5 is
+ returned. If b is false, the buffer is filled with the string "false" and
+ 6 is returned. This function cannot be used for language-specific
+ operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFBOOLEAN define to
+ create a buffer that is big enough.
+
+ @param b
+ a boolean value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean( sal_Unicode * str, sal_Bool b ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFBOOLEAN RTL_STR_MAX_VALUEOFBOOLEAN
+
+/** Create the string representation of a character.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFCHAR define to create a
+ buffer that is big enough.
+
+ @param ch
+ a character value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_valueOfChar( sal_Unicode * str, sal_Unicode ch ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFCHAR RTL_STR_MAX_VALUEOFCHAR
+
+/** Create the string representation of an integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFINT32 define to create
+ a buffer that is big enough.
+
+ @param i
+ an integer value.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_valueOfInt32( sal_Unicode * str, sal_Int32 i, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MIN_RADIX RTL_STR_MIN_RADIX
+#define RTL_USTR_MAX_RADIX RTL_STR_MAX_RADIX
+#define RTL_USTR_MAX_VALUEOFINT32 RTL_STR_MAX_VALUEOFINT32
+
+/** Create the string representation of a long integer.
+
+ This function cannot be used for language-specific operations.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFINT64 define to create
+ a buffer that is big enough.
+
+ @param l
+ a long integer value.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_valueOfInt64( sal_Unicode * str, sal_Int64 l, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFINT64 RTL_STR_MAX_VALUEOFINT64
+
+/** Create the string representation of a float.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFFLOAT define to create
+ a buffer that is big enough.
+
+ @param f
+ a float value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_valueOfFloat( sal_Unicode * str, float f ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFFLOAT RTL_STR_MAX_VALUEOFFLOAT
+
+/** Create the string representation of a double.
+
+ This function cannot be used for language-specific conversion.
+
+ @param str
+ a buffer that is big enough to hold the result and the terminating NUL
+ character. You should use the RTL_USTR_MAX_VALUEOFDOUBLE define to create
+ a buffer that is big enough.
+
+ @param d
+ a double value.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_ustr_valueOfDouble( sal_Unicode * str, double d ) SAL_THROW_EXTERN_C();
+#define RTL_USTR_MAX_VALUEOFDOUBLE RTL_STR_MAX_VALUEOFDOUBLE
+
+/** Interpret a string as a boolean.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ true if the string is "1" or "true" in any ASCII case, false otherwise.
+ */
+sal_Bool SAL_CALL rtl_ustr_toBoolean( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as an integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the integer value represented by the string, or 0 if the string does not
+ represent an integer.
+ */
+sal_Int32 SAL_CALL rtl_ustr_toInt32( const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a long integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the long integer value represented by the string, or 0 if the string does
+ not represent a long integer.
+ */
+sal_Int64 SAL_CALL rtl_ustr_toInt64( const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a float.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a float.
+ */
+float SAL_CALL rtl_ustr_toFloat( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/** Interpret a string as a double.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @return
+ the float value represented by the string, or 0.0 if the string does not
+ represent a double.
+ */
+double SAL_CALL rtl_ustr_toDouble( const sal_Unicode * str ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+#pragma pack(push, 4)
+#endif
+
+/** The implementation of a Unicode string.
+
+ @internal
+*/
+typedef struct _rtl_uString
+{
+ oslInterlockedCount refCount; /* opaque */
+ sal_Int32 length;
+ sal_Unicode buffer[1];
+} rtl_uString;
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+#pragma pack(pop)
+#endif
+
+/* ----------------------------------------------------------------------- */
+
+/** Increment the reference count of a string.
+
+ @param str
+ a string.
+ */
+void SAL_CALL rtl_uString_acquire( rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Decrement the reference count of a string.
+
+ If the count goes to zero than the string data is deleted.
+
+ @param str
+ a string.
+ */
+void SAL_CALL rtl_uString_release( rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing no characters.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+ */
+void SAL_CALL rtl_uString_new( rtl_uString ** newStr ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
+ If len is greater than zero, the reference count of the new string will be
+ 1. The values of all characters are set to 0 and the length of the string
+ is 0. This function does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param len
+ the number of characters.
+ */
+void SAL_CALL rtl_uString_new_WithLength( rtl_uString ** newStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of another string.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a valid string.
+ */
+void SAL_CALL rtl_uString_newFromString( rtl_uString ** newStr, const rtl_uString * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a null-terminated character array.
+ */
+void SAL_CALL rtl_uString_newFromStr( rtl_uString ** newStr, const sal_Unicode * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a character array. Need not be null-terminated, but must be at least as
+ long as the specified len.
+
+ @param len
+ the length of the character array.
+ */
+void SAL_CALL rtl_uString_newFromStr_WithLength( rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string that contains a copy of a character array.
+
+ If the length of value is greater than zero, the reference count of the
+ new string will be 1. This function does not handle out-of-memory
+ conditions.
+
+ Since this function is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range of 0 and 127, inclusive.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param value
+ a null-terminated ASCII character array.
+ */
+void SAL_CALL rtl_uString_newFromAscii( rtl_uString ** newStr, const sal_Char * value ) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string from an array of Unicode code points.
+
+ @param newString
+ a non-null pointer to a (possibly null) rtl_uString pointer, which (if
+ non-null) will have been passed to rtl_uString_release before the function
+ returns. Upon return, points to the newly allocated string or to null if
+ there was either an out-of-memory condition or the resulting number of
+ UTF-16 code units would have been larger than SAL_MAX_INT32. The newly
+ allocated string (if any) must ultimately be passed to rtl_uString_release.
+
+ @param codePoints
+ an array of at least codePointCount code points, which each must be in the
+ range from 0 to 0x10FFFF, inclusive. May be null if codePointCount is zero.
+
+ @param codePointCount
+ the non-negative number of code points.
+
+ @since UDK 3.2.7
+*/
+void SAL_CALL rtl_uString_newFromCodePoints(
+ rtl_uString ** newString, sal_uInt32 const * codePoints,
+ sal_Int32 codePointCount) SAL_THROW_EXTERN_C();
+
+/** Assign a new value to a string.
+
+ First releases any value str might currently hold, then acquires
+ rightValue.
+
+ @param str
+ pointer to the string. The pointed-to data must be null or a valid
+ string.
+
+ @param rightValue
+ a valid string.
+ */
+void SAL_CALL rtl_uString_assign( rtl_uString ** str, rtl_uString * rightValue ) SAL_THROW_EXTERN_C();
+
+/** Return the length of a string.
+
+ The length is equal to the number of characters in the string.
+
+ @param str
+ a valid string.
+
+ @return
+ the length of the string.
+ */
+sal_Int32 SAL_CALL rtl_uString_getLength( const rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Return a pointer to the underlying character array of a string.
+
+ @param str
+ a valid string.
+
+ @return
+ a pointer to the null-terminated character array.
+ */
+sal_Unicode * SAL_CALL rtl_uString_getStr( rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string that is the concatenation of two other strings.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where one of the two other strings is empty), so it must not be modified
+ without checking the reference count. This function does not handle
+ out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param left
+ a valid string.
+
+ @param right
+ a valid string.
+ */
+void SAL_CALL rtl_uString_newConcat( rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing a substring of another string.
+
+ The new string results from replacing a number of characters (count),
+ starting at the specified position (index) in the original string (str),
+ with some new substring (subStr). If subStr is null, than only a number
+ of characters is deleted.
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param index
+ the index into str at which to start replacement. Must be between 0 and
+ the length of str, inclusive.
+
+ @param count
+ the number of charcters to remove. Must not be negative, and the sum of
+ index and count must not exceed the length of str.
+
+ @param subStr
+ either null or a valid string to be inserted.
+ */
+void SAL_CALL rtl_uString_newReplaceStrAt( rtl_uString ** newStr, rtl_uString * str, sal_Int32 idx, sal_Int32 count, rtl_uString * subStr ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by replacing all occurrences of a single character
+ within another string.
+
+ The new string results from replacing all occurrences of oldChar in str
+ with newChar.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where oldChar does not occur in str), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+
+ @param oldChar
+ the old character.
+
+ @param newChar
+ the new character.
+ */
+void SAL_CALL rtl_uString_newReplace( rtl_uString ** newStr, rtl_uString * str, sal_Unicode oldChar, sal_Unicode newChar ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII uppercase letters to lowercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 65 and 90 (ASCII A--Z) by values between 97 and 122 (ASCII a--z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+void SAL_CALL rtl_uString_newToAsciiLowerCase( rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by converting all ASCII lowercase letters to uppercase
+ within another string.
+
+ The new string results from replacing all characters with values between
+ 97 and 122 (ASCII a--z) by values between 65 and 90 (ASCII A--Z).
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be converted), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+void SAL_CALL rtl_uString_newToAsciiUpperCase( rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by removing white space from both ends of another
+ string.
+
+ The new string results from removing all characters with values less than
+ or equal to 32 (the space character) form both ends of str.
+
+ This function cannot be used for language-specific conversion. The new
+ string does not necessarily have a reference count of 1 (in cases where
+ no characters need to be removed), so it must not be modified without
+ checking the reference count. This function does not handle out-of-memory
+ conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a valid string.
+ */
+void SAL_CALL rtl_uString_newTrim( rtl_uString ** newStr, rtl_uString * str ) SAL_THROW_EXTERN_C();
+
+/** Create a new string by extracting a single token from another string.
+
+ Starting at index, the token's next token is searched for. If there is no
+ such token, the result is an empty string. Otherwise, all characters from
+ the start of that token and up to, but not including the next occurrence
+ of cTok make up the resulting token. The return value is the position of
+ the next token, or -1 if no more tokens follow.
+
+ Example code could look like
+ rtl_uString * pToken = NULL;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
+ ...
+ }
+ while (nIndex >= 0);
+
+ The new string does not necessarily have a reference count of 1, so it
+ must not be modified without checking the reference count. This function
+ does not handle out-of-memory conditions.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string. If either token or index is negative, an empty token is stored in
+ newStr (and -1 is returned).
+
+ @param str
+ a valid string.
+
+ @param token
+ the number of the token to return, starting at index.
+
+ @param cTok
+ the character that seperates the tokens.
+
+ @param index
+ the position at which searching for the token starts. Must not be greater
+ than the length of str.
+
+ @return
+ the index of the next token, or -1 if no more tokens follow.
+ */
+sal_Int32 SAL_CALL rtl_uString_getToken( rtl_uString ** newStr , rtl_uString * str, sal_Int32 token, sal_Unicode cTok, sal_Int32 idx ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+
+/** Supply an ASCII string literal together with its length and text encoding.
+
+ This macro can be used to compute (some of) the arguments in function calls
+ like rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).
+
+ @param constAsciiStr
+ must be an expression of type "(possibly cv-qualified reference to) array of
+ (possibly cv-qualified) char." Each element of the referenced array must
+ represent an ASCII value in the range 0x00--0x7F. The last element of the
+ referenced array is not considered part of the represented ASCII string, and
+ its value should be 0x00. Depending on where this macro is used, the nature
+ of the supplied expression might be further restricted.
+*/
+#define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) constAsciiStr, ((sal_Int32)(sizeof(constAsciiStr)-1)), RTL_TEXTENCODING_ASCII_US
+
+/* ======================================================================= */
+
+/* predefined constants for String-Conversion */
+#define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
+
+/* ----------------------------------------------------------------------- */
+
+/** Create a new Unicode string by converting a byte string, using a specific
+ text encoding.
+
+ The lengths of the byte string and the Unicode string may differ (e.g.,
+ for double-byte encodings, UTF-7, UTF-8).
+
+ If the length of the byte string is greater than zero, the reference count
+ of the new string will be 1.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param str
+ a byte character array. Need not be null-terminated, but must be at
+ least as long as the specified len.
+
+ @param len
+ the length of the byte character array.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OSTRING_TO_OUSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+void SAL_CALL rtl_string2UString( rtl_uString ** newStr, const sal_Char * str, sal_Int32 len, rtl_TextEncoding encoding, sal_uInt32 convertFlags ) SAL_THROW_EXTERN_C();
+
+/* ======================================================================= */
+/* Interning methods */
+
+/** Return a canonical representation for a string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param str
+ pointer to the string to be interned.
+
+ @since UDK 3.2.7
+ */
+void SAL_CALL rtl_uString_intern( rtl_uString ** newStr,
+ rtl_uString * str) SAL_THROW_EXTERN_C();
+
+/** Return a canonical representation for a string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @param newStr
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ If an out-of-memory condition occurs, newStr will point to a null pointer
+ upon return.
+
+ @param str
+ a byte character array. Need not be null-terminated, but must be at
+ least as long as the specified len.
+
+ @param len
+ the length of the byte character array.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OSTRING_TO_OUSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+
+ @param pInfo
+ pointer to return conversion status in, or NULL.
+
+ @since UDK 3.2.7
+ */
+void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr,
+ const sal_Char * str,
+ sal_Int32 len,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags,
+ sal_uInt32 *pInfo) SAL_THROW_EXTERN_C();
+
+/** Iterate through a string based on code points instead of UTF-16 code units.
+
+ See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
+ definitions of the various terms used in this description.
+
+ The given string is interpreted as a sequence of zero or more UTF-16 code
+ units. For each index into this sequence (from zero to one less than the
+ length of the sequence, inclusive), a code point represented starting at the
+ given index is computed as follows:
+
+ - If the UTF-16 code unit addressed by the index constitutes a well-formed
+ UTF-16 code unit sequence, the computed code point is the scalar value
+ encoded by that UTF-16 code unit sequence.
+
+ - Otherwise, if the index is at least two UTF-16 code units away from the
+ end of the sequence, and the sequence of two UTF-16 code units addressed by
+ the index constitutes a well-formed UTF-16 code unit sequence, the computed
+ code point is the scalar value encoded by that UTF-16 code unit sequence.
+
+ - Otherwise, the computed code point is the UTF-16 code unit addressed by
+ the index. (This last case catches unmatched surrogates as well as indices
+ pointing into the middle of surrogate pairs.)
+
+ @param string
+ pointer to a valid string; must not be null.
+
+ @param indexUtf16
+ pointer to a UTF-16 based index into the given string; must not be null. On
+ entry, the index must be in the range from zero to the length of the string
+ (in UTF-16 code units), inclusive. Upon successful return, the index will
+ be updated to address the UTF-16 code unit that is the given
+ incrementCodePoints away from the initial index.
+
+ @param incrementCodePoints
+ the number of code points to move the given *indexUtf16. If non-negative,
+ moving is done after determining the code point at the index. If negative,
+ moving is done before determining the code point at the (then updated)
+ index. The value must be such that the resulting UTF-16 based index is in
+ the range from zero to the length of the string (in UTF-16 code units),
+ inclusive.
+
+ @return
+ the code point (an integer in the range from 0 to 0x10FFFF, inclusive) that
+ is represented within the string starting at the index computed as follows:
+ If incrementCodePoints is non-negative, the index is the initial value of
+ *indexUtf16; if incrementCodePoints is negative, the index is the updated
+ value of *indexUtf16. In either case, the computed index must be in the
+ range from zero to one less than the length of the string (in UTF-16 code
+ units), inclusive.
+
+ @since UDK 3.2.7
+*/
+sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
+ rtl_uString const * string, sal_Int32 * indexUtf16,
+ sal_Int32 incrementCodePoints);
+
+/** Converts a byte string to a Unicode string, signalling failure.
+
+ @param target
+ An out parameter receiving the converted string. Must not be null itself,
+ and must contain either null or a pointer to a valid rtl_uString; the
+ contents are unspecified if conversion fails (rtl_convertStringToUString
+ returns false).
+
+ @param source
+ The byte string. May only be null if length is zero.
+
+ @param length
+ The length of the byte string. Must be non-negative.
+
+ @param encoding
+ The text encoding to convert from. Must be an octet encoding (i.e.,
+ rtl_isOctetTextEncoding(encoding) must return true).
+
+ @param flags
+ A combination of RTL_TEXTTOUNICODE_FLAGS that detail how to do the
+ conversion (see rtl_convertTextToUnicode). RTL_TEXTTOUNICODE_FLAGS_FLUSH
+ need not be included, it is implicitly assumed. Typical uses are either
+ RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR (fail if a byte or multi-byte sequence
+ cannot be converted from the source encoding) or
+ OSTRING_TO_OUSTRING_CVTFLAGS (make a best efforts conversion).
+
+ @return
+ True if the conversion succeeded, false otherwise.
+
+ @since UDK 3.2.9
+*/
+sal_Bool SAL_CALL rtl_convertStringToUString(
+ rtl_uString ** target, char const * source, sal_Int32 length,
+ rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTL_USTRING_H_ */
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
new file mode 100644
index 000000000000..9a2ef8b9edc9
--- /dev/null
+++ b/sal/inc/rtl/ustring.hxx
@@ -0,0 +1,1540 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RTL_USTRING_HXX_
+#define _RTL_USTRING_HXX_
+
+#ifdef __cplusplus
+
+#ifndef _RTL_DIAGNOSE_H_
+#include "osl/diagnose.h"
+#endif
+#include <rtl/ustring.h>
+#include <rtl/string.hxx>
+#include <rtl/memory.h>
+
+#if defined EXCEPTIONS_OFF
+#include <stdlib.h>
+#else
+#include <new>
+#endif
+
+namespace rtl
+{
+/* ======================================================================= */
+
+/**
+ This String class provide base functionality for C++ like Unicode
+ character array handling. The advantage of this class is, that it
+ handle all the memory managament for you - and it do it
+ more efficient. If you assign a string to another string, the
+ data of both strings are shared (without any copy operation or
+ memory allocation) as long as you do not change the string. This class
+ stores also the length of the string, so that many operations are
+ faster as the C-str-functions.
+
+ This class provide only readonly string handling. So you could create
+ a string and you could only query the content from this string.
+ It provide also functionality to change the string, but this results
+ in every case in a new string instance (in the most cases with an
+ memory allocation). You don't have functionality to change the
+ content of the string. If you want change the string content, than
+ you should us the OStringBuffer class, which provide these
+ functionality and avoid to much memory allocation.
+
+ The design of this class is similar to the string classes in Java
+ and so more people should have fewer understanding problems when they
+ use this class.
+*/
+
+class OUString
+{
+public:
+ /** @internal */
+ rtl_uString * pData;
+
+private:
+ /** @internal */
+ class DO_NOT_ACQUIRE{};
+
+ /** @internal */
+ OUString( rtl_uString * value, DO_NOT_ACQUIRE * )
+ {
+ pData = value;
+ }
+
+public:
+ /**
+ New string containing no characters.
+ */
+ OUString() SAL_THROW(())
+ {
+ pData = 0;
+ rtl_uString_new( &pData );
+ }
+
+ /**
+ New string from OUString.
+
+ @param str a OUString.
+ */
+ OUString( const OUString & str ) SAL_THROW(())
+ {
+ pData = str.pData;
+ rtl_uString_acquire( pData );
+ }
+
+ /**
+ New string from OUString data.
+
+ @param str a OUString data.
+ */
+ OUString( rtl_uString * str ) SAL_THROW(())
+ {
+ pData = str;
+ rtl_uString_acquire( pData );
+ }
+ /** New OUString from OUString data without acquiring it. Takeover of ownership.
+
+ @param str
+ OUString data
+ @param dummy
+ SAL_NO_ACQUIRE to distinguish from other ctors
+ */
+ inline OUString( rtl_uString * str, __sal_NoAcquire ) SAL_THROW( () )
+ { pData = str; }
+
+
+ /**
+ New string from a single Unicode character.
+
+ @param value a Unicode character.
+ */
+ explicit OUString( sal_Unicode value ) SAL_THROW(())
+ : pData (0)
+ {
+ rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
+ }
+
+ /**
+ New string from a Unicode character buffer array.
+
+ @param value a NULL-terminated Unicode character array.
+ */
+ OUString( const sal_Unicode * value ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_uString_newFromStr( &pData, value );
+ }
+
+ /**
+ New string from a Uniocde character buffer array.
+
+ @param value a Unicode character array.
+ @param length the number of character which should be copied.
+ The character array length must be greater or
+ equal than this value.
+ */
+ OUString( const sal_Unicode * value, sal_Int32 length ) SAL_THROW(())
+ {
+ pData = 0;
+ rtl_uString_newFromStr_WithLength( &pData, value, length );
+ }
+
+ /**
+ New string from a 8-Bit character buffer array.
+
+ @param value a 8-Bit character array.
+ @param length the number of character which should be converted.
+ The 8-Bit character array length must be
+ greater or equal than this value.
+ @param encoding the text encoding from which the 8-Bit character
+ sequence should be converted.
+ @param convertFlags flags which controls the conversion.
+ see RTL_TEXTTOUNICODE_FLAGS_...
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+ */
+ OUString( const sal_Char * value, sal_Int32 length,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
+ {
+ pData = 0;
+ rtl_string2UString( &pData, value, length, encoding, convertFlags );
+#if defined EXCEPTIONS_OFF
+ OSL_ASSERT(pData != NULL);
+#else
+ if (pData == 0) {
+ throw std::bad_alloc();
+ }
+#endif
+ }
+
+ /** Create a new string from an array of Unicode code points.
+
+ @param codePoints
+ an array of at least codePointCount code points, which each must be in
+ the range from 0 to 0x10FFFF, inclusive. May be null if codePointCount
+ is zero.
+
+ @param codePointCount
+ the non-negative number of code points.
+
+ @exception std::bad_alloc
+ is thrown if either an out-of-memory condition occurs or the resulting
+ number of UTF-16 code units would have been larger than SAL_MAX_INT32.
+
+ @since UDK 3.2.7
+ */
+ inline explicit OUString(
+ sal_uInt32 const * codePoints, sal_Int32 codePointCount):
+ pData(NULL)
+ {
+ rtl_uString_newFromCodePoints(&pData, codePoints, codePointCount);
+ if (pData == NULL) {
+#if defined EXCEPTIONS_OFF
+ abort();
+#else
+ throw std::bad_alloc();
+#endif
+ }
+ }
+
+ /**
+ Release the string data.
+ */
+ ~OUString() SAL_THROW(())
+ {
+ rtl_uString_release( pData );
+ }
+
+ /** Provides an OUString const & passing a storage pointer of an
+ rtl_uString * handle.
+ It is more convenient to use C++ OUString member functions when dealing
+ with rtl_uString * handles. Using this function avoids unnecessary
+ acquire()/release() calls for a temporary OUString object.
+
+ @param ppHandle
+ pointer to storage
+ @return
+ OUString const & based on given storage
+ */
+ static inline OUString const & unacquired( rtl_uString * const * ppHandle )
+ { return * reinterpret_cast< OUString const * >( ppHandle ); }
+
+ /**
+ Assign a new string.
+
+ @param str a OUString.
+ */
+ OUString & operator=( const OUString & str ) SAL_THROW(())
+ {
+ rtl_uString_assign( &pData, str.pData );
+ return *this;
+ }
+
+ /**
+ Append a string to this string.
+
+ @param str a OUString.
+ */
+ OUString & operator+=( const OUString & str ) SAL_THROW(())
+ {
+ rtl_uString_newConcat( &pData, pData, str.pData );
+ return *this;
+ }
+
+ /**
+ Returns the length of this string.
+
+ The length is equal to the number of Unicode characters in this string.
+
+ @return the length of the sequence of characters represented by this
+ object.
+ */
+ sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
+
+ /**
+ Returns a pointer to the Unicode character buffer from this string.
+
+ It isn't necessarily NULL terminated.
+
+ @return a pointer to the Unicode characters buffer from this object.
+ */
+ operator const sal_Unicode *() const SAL_THROW(()) { return pData->buffer; }
+
+ /**
+ Returns a pointer to the Unicode character buffer from this string.
+
+ It isn't necessarily NULL terminated.
+
+ @return a pointer to the Unicode characters buffer from this object.
+ */
+ const sal_Unicode * getStr() const SAL_THROW(()) { return pData->buffer; }
+
+ /**
+ Compares two strings.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_compare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Compares two strings with an maximum count of characters.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @param maxLength the maximum count of characters to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareTo( const OUString & str, sal_Int32 maxLength ) const SAL_THROW(())
+ {
+ return rtl_ustr_shortenedCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length, maxLength );
+ }
+
+ /**
+ Compares two strings in reverse order.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ This function can't be used for language specific sorting.
+
+ @param str the object to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 reverseCompareTo( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equals( const OUString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_ustr_reverseCompare_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+ {
+ if ( pData->length != str.pData->length )
+ return sal_False;
+ if ( pData == str.pData )
+ return sal_True;
+ return rtl_ustr_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool match( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length, str.pData->length ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string, ignoring the case of
+ ASCII letters.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchIgnoreAsciiCase( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length,
+ str.pData->length ) == 0;
+ }
+
+ /**
+ Compares two strings.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific sorting.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareToAscii( const sal_Char* asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length, asciiStr );
+ }
+
+ /**
+ Compares two strings with an maximum count of characters.
+
+ The comparison is based on the numeric value of each character in
+ the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific sorting.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param maxLength the maximum count of characters to be compared.
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32 maxLength ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer, pData->length,
+ asciiStr, maxLength );
+ }
+
+ /**
+ Compares two strings in reverse order.
+
+ This could be useful, if normally both strings start with the same
+ content. The comparison is based on the numeric value of each character
+ in the strings and return a value indicating their relationship.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater or
+ equal as asciiStrLength.
+ This function can't be used for language specific sorting.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return 0 - if both strings are equal
+ < 0 - if this string is less than the string argument
+ > 0 - if this string is greater than the string argument
+ */
+ sal_Int32 reverseCompareToAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length,
+ asciiStr, asciiStrLength );
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsAscii( const sal_Char* asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compare_WithLength( pData->buffer, pData->length,
+ asciiStr ) == 0;
+ }
+
+ /**
+ Perform a comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater or
+ equal as asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ if ( pData->length != asciiStrLength )
+ return sal_False;
+
+ return rtl_ustr_asciil_reverseEquals_WithLength(
+ pData->buffer, asciiStr, asciiStrLength );
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
+ }
+
+ /**
+ Perform a ASCII lowercase comparison of two strings.
+
+ The result is true if and only if second string
+ represents the same sequence of characters as the first string,
+ ignoring the case.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater or
+ equal as asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @return sal_True if the strings are equal;
+ sal_False, otherwise.
+ */
+ sal_Bool equalsIgnoreAsciiCaseAsciiL( const sal_Char * asciiStr, sal_Int32 asciiStrLength ) const SAL_THROW(())
+ {
+ if ( pData->length != asciiStrLength )
+ return sal_False;
+
+ return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, asciiStr ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater or
+ equal as asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param str the object (substring) to be compared.
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_shortenedCompare_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ asciiStr, asciiStrLength ) == 0;
+ }
+
+ /**
+ Match against a substring appearing in this string, ignoring the case of
+ ASCII letters.
+
+ The result is true if and only if the second string appears as a substring
+ of this string, at the given position.
+ Character values between 65 and 90 (ASCII A-Z) are interpreted as
+ values between 97 and 122 (ASCII a-z).
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated and must be greater or
+ equal as asciiStrLength.
+ This function can't be used for language specific comparison.
+
+ @param asciiStr the 8-Bit ASCII character string to be compared.
+ @param asciiStrLength the length of the ascii string
+ @param fromIndex the index to start the comparion from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return sal_True if str match with the characters in the string
+ at the given position;
+ sal_False, otherwise.
+ */
+ sal_Bool matchIgnoreAsciiCaseAsciiL( const sal_Char* asciiStr, sal_Int32 asciiStrLength, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ asciiStr, asciiStrLength ) == 0;
+ }
+
+ /**
+ Check whether this string ends with a given ASCII string.
+
+ @param asciiStr a sequence of at least asciiStrLength ASCII characters
+ (bytes in the range 0x00--0x7F)
+ @param asciiStrLen the length of asciiStr; must be non-negative
+ @return true if this string ends with asciiStr; otherwise, false is
+ returned
+
+ @since UDK 3.2.7
+ */
+ inline bool endsWithAsciiL(char const * asciiStr, sal_Int32 asciiStrLength)
+ const
+ {
+ return asciiStrLength <= pData->length
+ && rtl_ustr_asciil_reverseEquals_WithLength(
+ pData->buffer + pData->length - asciiStrLength, asciiStr,
+ asciiStrLength);
+ }
+
+ /**
+ Check whether this string ends with a given ASCII string, ignoring the
+ case of ASCII letters.
+
+ @param asciiStr a sequence of at least asciiStrLength ASCII characters
+ (bytes in the range 0x00--0x7F)
+ @param asciiStrLen the length of asciiStr; must be non-negative
+ @return true if this string ends with asciiStr, ignoring the case of ASCII
+ letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
+ */
+ inline bool endsWithIgnoreAsciiCaseAsciiL(
+ char const * asciiStr, sal_Int32 asciiStrLength) const
+ {
+ return asciiStrLength <= pData->length
+ && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ pData->buffer + pData->length - asciiStrLength,
+ asciiStrLength, asciiStr, asciiStrLength)
+ == 0);
+ }
+
+ friend sal_Bool operator == ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.getLength() == rStr2.getLength() && rStr1.compareTo( rStr2 ) == 0; }
+ friend sal_Bool operator == ( const OUString& rStr1, const sal_Unicode * pStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( pStr2 ) == 0; }
+ friend sal_Bool operator == ( const sal_Unicode * pStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
+
+ friend sal_Bool operator != ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, rStr2 )); }
+ friend sal_Bool operator != ( const OUString& rStr1, const sal_Unicode * pStr2 ) SAL_THROW(())
+ { return !(operator == ( rStr1, pStr2 )); }
+ friend sal_Bool operator != ( const sal_Unicode * pStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return !(operator == ( pStr1, rStr2 )); }
+
+ friend sal_Bool operator < ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) < 0; }
+ friend sal_Bool operator > ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) > 0; }
+ friend sal_Bool operator <= ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) <= 0; }
+ friend sal_Bool operator >= ( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ { return rStr1.compareTo( rStr2 ) >= 0; }
+
+ /**
+ Returns a hashcode for this string.
+
+ @return a hash code value for this object.
+
+ @see rtl::OUStringHash for convenient use of STLPort's hash_map
+ */
+ sal_Int32 hashCode() const SAL_THROW(())
+ {
+ return rtl_ustr_hashCode_WithLength( pData->buffer, pData->length );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified character, starting the search at the specified index.
+
+ @param ch character to be located.
+ @param fromIndex the index to start the search from.
+ The index must be greater or equal than 0
+ and less or equal as the string length.
+ @return the index of the first occurrence of the character in the
+ character sequence represented by this string that is
+ greater than or equal to fromIndex, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 indexOf( sal_Unicode ch, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfChar_WithLength( pData->buffer+fromIndex, pData->length-fromIndex, ch );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting at the end.
+
+ @param ch character to be located.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string, or
+ -1 if the character does not occur.
+ */
+ sal_Int32 lastIndexOf( sal_Unicode ch ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified character, searching backward starting before the specified
+ index.
+
+ @param ch character to be located.
+ @param fromIndex the index before which to start the search.
+ @return the index of the last occurrence of the character in the
+ character sequence represented by this string that
+ is less than fromIndex, or -1
+ if the character does not occur before that point.
+ */
+ sal_Int32 lastIndexOf( sal_Unicode ch, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch );
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified substring, starting at the specified index.
+
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index to start the search from.
+ @return If the string argument occurs one or more times as a substring
+ within this string at the starting index, then the index
+ of the first character of the first such substring is
+ returned. If it does not occur as a substring starting
+ at fromIndex or beyond, -1 is returned.
+ */
+ sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.pData->buffer, str.pData->length );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+
+ /**
+ Returns the index within this string of the first occurrence of the
+ specified ASCII substring, starting at the specified index.
+
+ @param str
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified len. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param len
+ the length of the substring; must be non-negative.
+
+ @param fromIndex
+ the index to start the search from. Must be in the range from zero to
+ the length of this string, inclusive.
+
+ @return
+ the index (starting at 0) of the first character of the first occurrence
+ of the substring within this string starting at the given fromIndex, or
+ -1 if the substring does not occur. If len is zero, -1 is returned.
+
+ @since UDK 3.2.7
+ */
+ sal_Int32 indexOfAsciiL(
+ char const * str, sal_Int32 len, sal_Int32 fromIndex = 0) const
+ SAL_THROW(())
+ {
+ sal_Int32 ret = rtl_ustr_indexOfAscii_WithLength(
+ pData->buffer + fromIndex, pData->length - fromIndex, str, len);
+ return ret < 0 ? ret : ret + fromIndex;
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting at the end.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @return If the string argument occurs one or more times as a substring
+ within this string, then the index of the first character of
+ the last such substring is returned. If it does not occur as
+ a substring, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OUString & str ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of
+ the specified substring, searching backward starting before the specified
+ index.
+
+ The returned index indicates the starting index of the substring
+ in this string.
+ If str doesn't include any character, always -1 is
+ returned. This is also the case, if both strings are empty.
+
+ @param str the substring to search for.
+ @param fromIndex the index before which to start the search.
+ @return If the string argument occurs one or more times as a substring
+ within this string before the starting index, then the index
+ of the first character of the last such substring is
+ returned. Otherwise, -1 is returned.
+ */
+ sal_Int32 lastIndexOf( const OUString & str, sal_Int32 fromIndex ) const SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, fromIndex,
+ str.pData->buffer, str.pData->length );
+ }
+
+ /**
+ Returns the index within this string of the last occurrence of the
+ specified ASCII substring.
+
+ @param str
+ the substring to be searched for. Need not be null-terminated, but must
+ be at least as long as the specified len. Must only contain characters
+ in the ASCII range 0x00--7F.
+
+ @param len
+ the length of the substring; must be non-negative.
+
+ @return
+ the index (starting at 0) of the first character of the last occurrence
+ of the substring within this string, or -1 if the substring does not
+ occur. If len is zero, -1 is returned.
+
+ @since UDK 3.2.7
+ */
+ sal_Int32 lastIndexOfAsciiL(char const * str, sal_Int32 len) const
+ SAL_THROW(())
+ {
+ return rtl_ustr_lastIndexOfAscii_WithLength(
+ pData->buffer, pData->length, str, len);
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex. It is an error for
+ beginIndex to be negative or to be greater than the length of this string.
+
+ @param beginIndex the beginning index, inclusive.
+ @return the specified substring.
+ */
+ OUString copy( sal_Int32 beginIndex ) const SAL_THROW(())
+ {
+ OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
+ if ( beginIndex == 0 )
+ return *this;
+ else
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newFromStr_WithLength( &pNew, pData->buffer+beginIndex, getLength()-beginIndex );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+ }
+
+ /**
+ Returns a new string that is a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. It is an error for either beginIndex or count to be negative,
+ or for beginIndex + count to be greater than the length of this string.
+
+ @param beginIndex the beginning index, inclusive.
+ @param count the number of characters.
+ @return the specified substring.
+ */
+ OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
+ {
+ OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength()
+ && count >= 0 && count <= getLength() - beginIndex);
+ if ( (beginIndex == 0) && (count == getLength()) )
+ return *this;
+ else
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newFromStr_WithLength( &pNew, pData->buffer+beginIndex, count );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+ }
+
+ /**
+ Concatenates the specified string to the end of this string.
+
+ @param str the string that is concatenated to the end
+ of this string.
+ @return a string that represents the concatenation of this string
+ followed by the string argument.
+ */
+ OUString concat( const OUString & str ) const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newConcat( &pNew, pData, str.pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ friend OUString operator+( const OUString& rStr1, const OUString& rStr2 ) SAL_THROW(())
+ {
+ return rStr1.concat( rStr2 );
+ }
+
+ /**
+ Returns a new string resulting from replacing n = count characters
+ from position index in this string with newStr.
+
+ @param index the replacing index in str.
+ The index must be greater or equal as 0 and
+ less or equal as the length of the string.
+ @param count the count of charcters that will replaced
+ The count must be greater or equal as 0 and
+ less or equal as the length of the string minus index.
+ @param newStr the new substring.
+ @return the new string.
+ */
+ OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from replacing all occurrences of
+ oldChar in this string with newChar.
+
+ If the character oldChar does not occur in the character sequence
+ represented by this object, then the string is assigned with
+ str.
+
+ @param oldChar the old character.
+ @param newChar the new character.
+ @return a string derived from this string by replacing every
+ occurrence of oldChar with newChar.
+ */
+ OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Converts from this string all ASCII uppercase characters (65-90)
+ to ASCII lowercase characters (97-122).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII lowercase.
+ */
+ OUString toAsciiLowerCase() const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newToAsciiLowerCase( &pNew, pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Converts from this string all ASCII lowercase characters (97-122)
+ to ASCII uppercase characters (65-90).
+
+ This function can't be used for language specific conversion.
+ If the string doesn't contain characters which must be converted,
+ then the new string is assigned with str.
+
+ @return the string, converted to ASCII uppercase.
+ */
+ OUString toAsciiUpperCase() const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newToAsciiUpperCase( &pNew, pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a new string resulting from removing white space from both ends
+ of the string.
+
+ All characters that have codes less than or equal to
+ 32 (the space character) are considered to be white space.
+ If the string doesn't contain white spaces at both ends,
+ then the new string is assigned with str.
+
+ @return the string, with white space removed from the front and end.
+ */
+ OUString trim() const SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newTrim( &pNew, pData );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a token in the string.
+
+ Example:
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ...
+ OUString aToken = aStr.getToken( 0, ';', nIndex );
+ ...
+ }
+ while ( nIndex >= 0 );
+
+ @param token the number of the token to return
+ @param cTok the character which seperate the tokens.
+ @param index the position at which the token is searched in the
+ string.
+ The index must not be greater than the length of the
+ string.
+ This param is set to the position of the
+ next token or to -1, if it is the last token.
+ @return the token; if either token or index is negative, an empty token
+ is returned (and index is set to -1)
+ */
+ OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(())
+ {
+ rtl_uString * pNew = 0;
+ index = rtl_uString_getToken( &pNew, pData, token, cTok, index );
+ return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Returns the Boolean value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return sal_True, if the string is 1 or "True" in any ASCII case.
+ sal_False in any other case.
+ */
+ sal_Bool toBoolean() const SAL_THROW(())
+ {
+ return rtl_ustr_toBoolean( pData->buffer );
+ }
+
+ /**
+ Returns the first character from this string.
+
+ @return the first character from this string or 0, if this string
+ is emptry.
+ */
+ sal_Unicode toChar() const SAL_THROW(())
+ {
+ return pData->buffer[0];
+ }
+
+ /**
+ Returns the int32 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int32 represented from this string.
+ 0 if this string represents no number.
+ */
+ sal_Int32 toInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_ustr_toInt32( pData->buffer, radix );
+ }
+
+ /**
+ Returns the int64 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the int64 represented from this string.
+ 0 if this string represents no number.
+ */
+ sal_Int64 toInt64( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_ustr_toInt64( pData->buffer, radix );
+ }
+
+ /**
+ Returns the float value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the float represented from this string.
+ 0.0 if this string represents no number.
+ */
+ float toFloat() const SAL_THROW(())
+ {
+ return rtl_ustr_toFloat( pData->buffer );
+ }
+
+ /**
+ Returns the double value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @return the double represented from this string.
+ 0.0 if this string represents no number.
+ */
+ double toDouble() const SAL_THROW(())
+ {
+ return rtl_ustr_toDouble( pData->buffer );
+ }
+
+
+ /**
+ Return a canonical representation for a string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @return
+ a version of the string from the pool.
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+
+ @since UDK 3.2.7
+ */
+ OUString intern() const
+ {
+ rtl_uString * pNew = 0;
+ rtl_uString_intern( &pNew, pData );
+#if defined EXCEPTIONS_OFF
+ OSL_ASSERT(pNew != NULL);
+#else
+ if (pNew == 0) {
+ throw std::bad_alloc();
+ }
+#endif
+ return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Return a canonical representation for a converted string.
+
+ A pool of strings, initially empty is maintained privately
+ by the string class. On invocation, if present in the pool
+ the original string will be returned. Otherwise this string,
+ or a copy thereof will be added to the pool and returned.
+
+ @param value a 8-Bit character array.
+ @param length the number of character which should be converted.
+ The 8-Bit character array length must be
+ greater or equal than this value.
+ @param encoding the text encoding from which the 8-Bit character
+ sequence should be converted.
+ @param convertFlags flags which controls the conversion.
+ see RTL_TEXTTOUNICODE_FLAGS_...
+ @param pInfo pointer to return conversion status or NULL.
+
+ @return
+ a version of the converted string from the pool.
+
+ @exception std::bad_alloc is thrown if an out-of-memory condition occurs
+
+ @since UDK 3.2.7
+ */
+ static OUString intern( const sal_Char * value, sal_Int32 length,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS,
+ sal_uInt32 *pInfo = NULL )
+ {
+ rtl_uString * pNew = 0;
+ rtl_uString_internConvert( &pNew, value, length, encoding,
+ convertFlags, pInfo );
+#if defined EXCEPTIONS_OFF
+ OSL_ASSERT(pNew != NULL);
+#else
+ if (pNew == 0) {
+ throw std::bad_alloc();
+ }
+#endif
+ return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
+ }
+
+ /**
+ Converts to an OString, signalling failure.
+
+ @param pTarget
+ An out parameter receiving the converted OString. Must not be null; the
+ contents are not modified if conversion fails (convertToOString returns
+ false).
+
+ @param nEncoding
+ The text encoding to convert into. Must be an octet encoding (i.e.,
+ rtl_isOctetTextEncoding(nEncoding) must return true).
+
+ @param nFlags
+ A combination of RTL_UNICODETOTEXT_FLAGS that detail how to do the
+ conversion (see rtl_convertUnicodeToText). RTL_UNICODETOTEXT_FLAGS_FLUSH
+ need not be included, it is implicitly assumed. Typical uses are either
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR (fail if a Unicode character cannot
+ be converted to the target nEncoding) or OUSTRING_TO_OSTRING_CVTFLAGS
+ (make a best efforts conversion).
+
+ @return
+ True if the conversion succeeded, false otherwise.
+ */
+ inline bool convertToString(OString * pTarget, rtl_TextEncoding nEncoding,
+ sal_uInt32 nFlags) const
+ {
+ return rtl_convertUStringToString(&pTarget->pData, pData->buffer,
+ pData->length, nEncoding, nFlags);
+ }
+
+ /** Iterate through this string based on code points instead of UTF-16 code
+ units.
+
+ See Chapter 3 of The Unicode Standard 5.0 (Addison--Wesley, 2006) for
+ definitions of the various terms used in this description.
+
+ This string is interpreted as a sequence of zero or more UTF-16 code
+ units. For each index into this sequence (from zero to one less than
+ the length of the sequence, inclusive), a code point represented
+ starting at the given index is computed as follows:
+
+ - If the UTF-16 code unit addressed by the index constitutes a
+ well-formed UTF-16 code unit sequence, the computed code point is the
+ scalar value encoded by that UTF-16 code unit sequence.
+
+ - Otherwise, if the index is at least two UTF-16 code units away from
+ the end of the sequence, and the sequence of two UTF-16 code units
+ addressed by the index constitutes a well-formed UTF-16 code unit
+ sequence, the computed code point is the scalar value encoded by that
+ UTF-16 code unit sequence.
+
+ - Otherwise, the computed code point is the UTF-16 code unit addressed
+ by the index. (This last case catches unmatched surrogates as well as
+ indices pointing into the middle of surrogate pairs.)
+
+ @param indexUtf16
+ pointer to a UTF-16 based index into this string; must not be null. On
+ entry, the index must be in the range from zero to the length of this
+ string (in UTF-16 code units), inclusive. Upon successful return, the
+ index will be updated to address the UTF-16 code unit that is the given
+ incrementCodePoints away from the initial index.
+
+ @param incrementCodePoints
+ the number of code points to move the given *indexUtf16. If
+ non-negative, moving is done after determining the code point at the
+ index. If negative, moving is done before determining the code point
+ at the (then updated) index. The value must be such that the resulting
+ UTF-16 based index is in the range from zero to the length of this
+ string (in UTF-16 code units), inclusive.
+
+ @return
+ the code point (an integer in the range from 0 to 0x10FFFF, inclusive)
+ that is represented within this string starting at the index computed as
+ follows: If incrementCodePoints is non-negative, the index is the
+ initial value of *indexUtf16; if incrementCodePoints is negative, the
+ index is the updated value of *indexUtf16. In either case, the computed
+ index must be in the range from zero to one less than the length of this
+ string (in UTF-16 code units), inclusive.
+
+ @since UDK 3.2.7
+ */
+ inline sal_uInt32 iterateCodePoints(
+ sal_Int32 * indexUtf16, sal_Int32 incrementCodePoints = 1) const
+ {
+ return rtl_uString_iterateCodePoints(
+ pData, indexUtf16, incrementCodePoints);
+ }
+
+ /**
+ Returns the string representation of the sal_Bool argument.
+
+ If the sal_Bool is true, the string "true" is returned.
+ If the sal_Bool is false, the string "false" is returned.
+ This function can't be used for language specific conversion.
+
+ @param b a sal_Bool.
+ @return a string with the string representation of the argument.
+ */
+ static OUString valueOf( sal_Bool b ) SAL_THROW(())
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the char argument.
+
+ @param c a character.
+ @return a string with the string representation of the argument.
+ */
+ static OUString valueOf( sal_Unicode c ) SAL_THROW(())
+ {
+ return OUString( &c, 1 );
+ }
+
+ /**
+ Returns the string representation of the int argument.
+
+ This function can't be used for language specific conversion.
+
+ @param i a int32.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ */
+ static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the long argument.
+
+ This function can't be used for language specific conversion.
+
+ @param ll a int64.
+ @param radix the radix (between 2 and 36)
+ @return a string with the string representation of the argument.
+ */
+ static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(())
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT64];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the float argument.
+
+ This function can't be used for language specific conversion.
+
+ @param f a float.
+ @return a string with the string representation of the argument.
+ */
+ static OUString valueOf( float f ) SAL_THROW(())
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfFloat( aBuf, f ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns the string representation of the double argument.
+
+ This function can't be used for language specific conversion.
+
+ @param d a double.
+ @return a string with the string representation of the argument.
+ */
+ static OUString valueOf( double d ) SAL_THROW(())
+ {
+ sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE];
+ rtl_uString* pNewData = 0;
+ rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfDouble( aBuf, d ) );
+ return OUString( pNewData, (DO_NOT_ACQUIRE*)0 );
+ }
+
+ /**
+ Returns a OUString copied without conversion from an ASCII
+ character string.
+
+ Since this method is optimized for performance, the ASCII character
+ values are not converted in any way. The caller has to make sure that
+ all ASCII characters are in the allowed range between 0 and
+ 127. The ASCII string must be NULL-terminated.
+
+ @param value the 8-Bit ASCII character string
+ @return a string with the string representation of the argument.
+ */
+ static OUString createFromAscii( const sal_Char * value ) SAL_THROW(())
+ {
+ rtl_uString* pNew = 0;
+ rtl_uString_newFromAscii( &pNew, value );
+ return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
+ }
+};
+
+/* ======================================================================= */
+
+/** A helper to use OUStrings with hash maps.
+
+ Instances of this class are unary function objects that can be used as
+ hash function arguments to STLPort's hash_map and similar constructs.
+ */
+struct OUStringHash
+{
+ /** Compute a hash code for a string.
+
+ @param rString
+ a string.
+
+ @return
+ a hash code for the string. This hash code should not be stored
+ persistently, as its computation may change in later revisions.
+ */
+ size_t operator()(const rtl::OUString& rString) const
+ { return (size_t)rString.hashCode(); }
+};
+
+/* ======================================================================= */
+
+/** Convert an OString to an OUString, using a specific text encoding.
+
+ The lengths of the two strings may differ (e.g., for double-byte
+ encodings, UTF-7, UTF-8).
+
+ @param rStr
+ an OString to convert.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OSTRING_TO_OUSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+inline OUString OStringToOUString( const OString & rStr,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS )
+{
+ return OUString( rStr.getStr(), rStr.getLength(), encoding, convertFlags );
+}
+
+/** Convert an OUString to an OString, using a specific text encoding.
+
+ The lengths of the two strings may differ (e.g., for double-byte
+ encodings, UTF-7, UTF-8).
+
+ @param rStr
+ an OUString to convert.
+
+ @param encoding
+ the text encoding to use for conversion.
+
+ @param convertFlags
+ flags which control the conversion. Either use
+ OUSTRING_TO_OSTRING_CVTFLAGS, or see
+ <http://udk.openoffice.org/cpp/man/spec/textconversion.html> for more
+ details.
+ */
+inline OString OUStringToOString( const OUString & rUnicode,
+ rtl_TextEncoding encoding,
+ sal_uInt32 convertFlags = OUSTRING_TO_OSTRING_CVTFLAGS )
+{
+ return OString( rUnicode.getStr(), rUnicode.getLength(), encoding, convertFlags );
+}
+
+/* ======================================================================= */
+
+} /* Namespace */
+
+#endif /* __cplusplus */
+
+#endif /* _RTL_USTRING_HXX */
diff --git a/sal/inc/rtl/uuid.h b/sal/inc/rtl/uuid.h
new file mode 100644
index 000000000000..3ff5bb2c1232
--- /dev/null
+++ b/sal/inc/rtl/uuid.h
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _RTL_UUID_H_
+#define _RTL_UUID_H_
+
+
+#include <sal/types.h>
+#include <rtl/string.h>
+
+/**
+ @HTML
+ @file
+ Specification (from draft-leach-uuids-guids-01.txt )
+
+ <p>
+ A UUID is an identifier that is unique across both space and time,
+ with respect to the space of all UUIDs. To be precise, the UUID
+ consists of a finite bit space. Thus, collision cannot be avoided in
+ principle. A UUID can be used for multiple purposes, from tagging objects
+ with an extremely short lifetime, to reliably identifying very persistent
+ objects across a network.
+
+ <p>
+ The generation of UUIDs does not require that a registration
+ authority be contacted for each identifier. Instead, Version 4 UUIDs are
+ generated from (pseudo unique) sequences of (pseudo) random bits.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Generates a new Version 4 (random number based) UUID (Universally Unique
+ IDentifier).
+
+ @param pTargetUUID pointer to at least 16 bytes of memory. After the call it contains
+ the newly generated uuid in network byte order.
+ @param pPredecessorUUID ignored (was used when this function returned
+ Version 1 instead of Version 4 UUIDs).
+ @param bUseEthernetAddress ignored (was used when this function returned
+ Version 1 instead of Version 4 UUIDs).
+ */
+void SAL_CALL rtl_createUuid( sal_uInt8 *pTargetUUID ,
+ const sal_uInt8 *pPredecessorUUID,
+ sal_Bool bUseEthernetAddress );
+
+/** Compare two UUID's lexically
+
+ <p>
+ Note: lexical ordering is not temporal ordering!
+ <p>
+ Note: For equalnesschecking, a memcmp(pUUID1,pUUID2,16) is more efficient
+
+ @return
+ <ul>
+ <li>-1 u1 is lexically before u2
+ <li>0 u1 is equal to u2
+ <li>1 u1 is lexically after u2
+ </ul>
+
+ */
+sal_Int32 SAL_CALL rtl_compareUuid( const sal_uInt8 *pUUID1 , const sal_uInt8 *pUUID2 );
+
+/** Creates named UUIDs.
+
+ <p>
+ The version 3 UUID is meant for generating UUIDs from <em>names</em> that
+ are drawn from, and unique within, some <em>name space</em>. Some examples
+ of names (and, implicitly, name spaces) might be DNS names, URLs, ISO
+ Object IDs (OIDs), reserved words in a programming language, or X.500
+ Distinguished Names (DNs); thus, the concept of name and name space
+ should be broadly construed, and not limited to textual names.
+
+ <p>
+ The requirements for such UUIDs are as follows:
+
+ <ul>
+ <li> The UUIDs generated at different times from the same name in the
+ same namespace MUST be equal
+
+ <li> The UUIDs generated from two different names in the same namespace
+ should be different (with very high probability)
+
+ <li> The UUIDs generated from the same name in two different namespaces
+ should be different with (very high probability)
+
+ <li> If two UUIDs that were generated from names are equal, then they
+ were generated from the same name in the same namespace (with very
+ high probability).
+ </ul>
+
+ @param pTargetUUID pointer to at least 16 bytes of memory. After the call
+ it contains the newly generated uuid in network byte order.
+ @param pNameSpaceUUID The namespace uuid. Below are some predefined ones,
+ but any arbitray uuid can be used as namespace.
+
+ @param pName the name
+ */
+void SAL_CALL rtl_createNamedUuid(
+ sal_uInt8 *pTargetUUID,
+ const sal_uInt8 *pNameSpaceUUID,
+ const rtl_String *pName
+ );
+
+
+
+/*
+ Predefined Namespaces
+ (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
+ */
+/** namesapce DNS
+
+ <p>
+ (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
+ <p>
+ 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_DNS {\
+ 0x6b,0xa7,0xb8,0x10,\
+ 0x9d,0xad,\
+ 0x11,0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+/** namespace URL
+
+ <p>
+ 6ba7b811-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_URL { \
+ 0x6b, 0xa7, 0xb8, 0x11,\
+ 0x9d, 0xad,\
+ 0x11, 0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+/** namespace oid
+
+ <p>
+ 6ba7b812-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_OID {\
+ 0x6b, 0xa7, 0xb8, 0x12,\
+ 0x9d, 0xad,\
+ 0x11, 0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+/** namespace X500
+
+ <p>
+ 6ba7b814-9dad-11d1-80b4-00c04fd430c8 */
+#define RTL_UUID_NAMESPACE_X500 {\
+ 0x6b, 0xa7, 0xb8, 0x14,\
+ 0x9d, 0xad,\
+ 0x11, 0xd1,\
+ 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
+ }
+
+
+/*
+ This macro must have a value below the system time resolution of the
+ system. The uuid routines use this value as an upper limit for adding ticks to the
+ the predecessor time value if system times are equal.
+ */
+#ifdef SAL_W32
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 1000
+#elif defined SAL_OS2 // YD we use posix functions for time
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10
+#elif LINUX
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10
+#elif NETBSD
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10
+#elif FREEBSD
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10
+#elif SOLARIS
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10
+#elif MACOSX
+#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 100000
+#else
+#error "System time resolution must be calculated!"
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sal/inc/sal/alloca.h b/sal/inc/sal/alloca.h
new file mode 100644
index 000000000000..17c242c4d1e2
--- /dev/null
+++ b/sal/inc/sal/alloca.h
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_SAL_ALLOCA_H
+#define INCLUDED_SAL_ALLOCA_H
+
+#if defined (SOLARIS) || defined (LINUX) || defined(__EMX__)
+
+#ifndef INCLUDED_ALLOCA_H
+#include <alloca.h>
+#define INCLUDED_ALLOCA_H
+#endif
+
+#elif defined (FREEBSD) || defined(NETBSD)
+
+#ifndef INCLUDED_STDLIB_H
+#include <stdlib.h>
+#define INCLUDED_STDLIB_H
+#endif
+
+#elif defined (MACOSX)
+
+#ifndef INCLUDED_SYS_TYPES_H
+#include <sys/types.h>
+#define INCLUDED_SYS_TYPES_H
+#endif
+
+#elif defined (WNT)
+
+#ifndef INCLUDED_MALLOC_H
+#include <malloc.h>
+#define INCLUDED_MALLOC_H
+#endif
+
+#else
+
+#error "unknown platform: please check for alloca"
+
+#endif
+
+#endif /* INCLUDED_SAL_ALLOCA_H */
+
diff --git a/sal/inc/sal/config.h b/sal/inc/sal/config.h
new file mode 100644
index 000000000000..7b2bd5154bc8
--- /dev/null
+++ b/sal/inc/sal/config.h
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SAL_CONFIG_H_
+#define _SAL_CONFIG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef INCLUDED_STDLIB_H
+#include <stdlib.h>
+#define INCLUDED_STDLIB_H
+#endif
+
+#ifdef WIN32
+#define SAL_W32
+#define SAL_DLLEXTENSION ".dll"
+#define SAL_PRGEXTENSION ".exe"
+#define SAL_PATHSEPARATOR ';'
+#define SAL_PATHDELIMITER '\\'
+#define SAL_CONFIGFILE( name ) name ".ini"
+#define SAL_SYSCONFIGFILE( name ) name ".ini"
+
+#ifdef _MSC_VER
+
+#ifndef _USE_MATH_DEFINES
+#define _USE_MATH_DEFINES // needed by Visual C++ for math constants
+#endif
+
+/* warnings ought to be disabled using /wd:n option of msvc.net compiler */
+#if _MSC_VER < 1300
+/* no performance warning: int to bool */
+#pragma warning( disable : 4800 )
+
+/* No warning for: C++ Exception Specification ignored */
+#pragma warning( disable : 4290 )
+
+#if OSL_DEBUG_LEVEL > 0
+/* No warning for: identifier was truncated to '255' characters in the browser information */
+#pragma warning( disable : 4786 )
+#endif
+#endif /* defined _MSC_VER < 1300 */
+
+#endif /* defined _MSC_VER */
+
+/* Provide ISO C99 compatible versions of snprint and vsnprintf */
+#ifdef __MINGW32__
+#define _SNPRINTF_DLLIMPORT
+#endif
+#ifndef _SNPRINTF_H
+#include <systools/win32/snprintf.h>
+#endif
+
+#endif /* defined WIN32 */
+
+/* BR: 16bit fuer Borland-Compiler */
+#ifdef __BORLANDC__
+#define SAL_W16
+#define SAL_DLLEXTENSION ".dll"
+#endif
+/* BR: 16bit fuer Borland-Compiler */
+
+#ifdef OS2
+#define SAL_OS2
+#define SAL_DLLEXTENSION ".dll"
+#define SAL_PRGEXTENSION ".exe"
+#define SAL_PATHSEPARATOR ';'
+#define SAL_PATHDELIMITER '\\'
+#define SAL_CONFIGFILE( name ) name ".ini"
+#define SAL_SYSCONFIGFILE( name ) name ".ini"
+#endif
+
+#if defined(SOLARIS) || defined(LINUX) || defined(NETBSD) || defined(FREEBSD) || defined(SCO)
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".so"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#define SAL_SYSCONFIGFILE( name ) "." name "rc"
+#endif
+
+#ifdef MACOSX
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".dylib"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#define SAL_SYSCONFIGFILE( name ) "." name "rc"
+#endif
+
+#ifdef HPUX
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".sl"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_CONFIGFILE( name ) name "rc"
+#define SAL_SYSCONFIGFILE( name ) "." name "rc"
+#endif
+
+#ifdef sun
+#undef sun
+#define sun sun
+#endif
+
+/* This is to work around a gcc 3.3 error that fixing actually breaks other
+ * compilers. This will create a dummy variable specifically for gcc 3.3 that
+ * allows it to compile and not break the others. Other compilers may follow
+ * with this eror later. */
+#if defined __GNUC__
+#if ((__GNUC__ == 3) && (__GNUC_MINOR__ > 2))
+# define SAL_ISO_CONST const
+#else
+# define SAL_ISO_CONST
+#endif
+#endif
+
+#endif /*_SAL_CONFIG_H_ */
+
+
diff --git a/sal/inc/sal/macros.h b/sal/inc/sal/macros.h
new file mode 100644
index 000000000000..800629ab095d
--- /dev/null
+++ b/sal/inc/sal/macros.h
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SAL_MACROS_H_
+#define _SAL_MACROS_H_
+
+#ifndef SAL_MAX
+# define SAL_MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef SAL_MIN
+# define SAL_MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef SAL_FIELDOFFSET
+# define SAL_FIELDOFFSET(type, field) ((sal_Int32)(&((type *)16)->field) - 16)
+#endif
+
+#ifndef SAL_BOUND
+# define SAL_BOUND(x,l,h) ((x) <= (l) ? (l) : ((x) >= (h) ? (h) : (x)))
+#endif
+
+#ifndef SAL_SWAP
+# define SAL_SWAP(a,b) ((a) ^= (b) ^= (a) ^= (b))
+#endif
+
+
+#endif
diff --git a/sal/inc/sal/main.h b/sal/inc/sal/main.h
new file mode 100644
index 000000000000..f360e4c95f19
--- /dev/null
+++ b/sal/inc/sal/main.h
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SAL_MAIN_H_
+#define _SAL_MAIN_H_
+
+#include <sal/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void SAL_CALL sal_detail_initialize(int argc, char ** argv);
+void SAL_CALL sal_detail_deinitialize();
+
+#define SAL_MAIN_WITH_ARGS_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ int ret; \
+ sal_detail_initialize(argc, argv); \
+ ret = sal_main_with_args(argc, argv); \
+ sal_detail_deinitialize(); \
+ return ret; \
+}
+
+#define SAL_MAIN_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ int ret; \
+ sal_detail_initialize(argc, argv); \
+ ret = sal_main(); \
+ sal_detail_deinitialize(); \
+ return ret; \
+}
+
+
+/* Definition macros for CRT entries */
+
+#ifdef SAL_W32
+
+#ifndef INCLUDED_STDLIB_H
+#include <stdlib.h>
+#define INCLUDED_STDLIB_H
+#endif
+
+/* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
+
+#if 0
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#else /* Simulated what windows.h does */
+
+#ifndef WINAPI
+# define WINAPI __stdcall
+#endif
+
+#if !defined(DECLARE_HANDLE)
+# ifdef STRICT
+ typedef void *HANDLE;
+# define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
+# else
+ typedef void *PVOID;
+ typedef PVOID HANDLE;
+# define DECLARE_HANDLE(name) typedef HANDLE name
+# endif
+DECLARE_HANDLE(HINSTANCE);
+#endif
+
+#endif
+
+#define SAL_WIN_WinMain \
+int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
+{ \
+ int argc = __argc; char ** argv = __argv; \
+ (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
+ return main(argc, argv); \
+}
+
+#else /* ! SAL_W32 */
+
+# define SAL_WIN_WinMain
+
+#endif /* ! SAL_W32 */
+
+/* Implementation macro */
+
+#define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
+ static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
+ SAL_MAIN_WITH_ARGS_IMPL \
+ SAL_WIN_WinMain \
+ static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
+
+#define SAL_IMPLEMENT_MAIN() \
+ static int SAL_CALL sal_main(void); \
+ SAL_MAIN_IMPL \
+ SAL_WIN_WinMain \
+ static int SAL_CALL sal_main(void)
+
+/*
+ "How to use" Examples:
+
+ #include <sal/main.h>
+
+ SAL_IMPLEMENT_MAIN()
+ {
+ DoSomething();
+
+ return 0;
+ }
+
+ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+ {
+ DoSomethingWithArgs(argc, argv);
+
+ return 0;
+ }
+
+*/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _SAL_MAIN_H_ */
+
diff --git a/sal/inc/sal/mathconf.h b/sal/inc/sal/mathconf.h
new file mode 100644
index 000000000000..bb623e2f2812
--- /dev/null
+++ b/sal/inc/sal/mathconf.h
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if !defined INCLUDED_SAL_MATHCONF_H
+#define INCLUDED_SAL_MATHCONF_H
+
+#include "osl/endian.h"
+
+#include <float.h>
+
+#if defined SOLARIS
+#include <ieeefp.h>
+#endif /* SOLARIS */
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Generally, the C standard guarantees that at program startup, "trapping or
+ stopping (if supported) is disabled on all [floating-point] exceptions"
+ (F.7.3/1 of the August 3, 1998 draft of C99), and that during program
+ execution, "a programmer can safely assume default modes (or be unaware of
+ them)" (7.6/2, footnote 161 of the August 3, 1998 draft of C99). Reportedly,
+ on Windows there are printer drivers that switch on exceptions. To avoid
+ problems, the SAL_MATH_FPEXCEPTIONS_OFF macro can be used to explicitly
+ switch off exceptions (on Windows).
+ */
+#if defined WNT
+#define SAL_MATH_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
+#else /* WNT */
+#define SAL_MATH_FPEXCEPTIONS_OFF()
+#endif /* WNT */
+
+
+/* SAL_MATH_FINITE(d): test double d on INFINITY, NaN et al. */
+#if defined( WNT)
+#define SAL_MATH_FINITE(d) _finite(d)
+#elif defined OS2
+#define SAL_MATH_FINITE(x) \
+ ((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
+ : (sizeof (x) == sizeof (double)) ? __isfinite(x) \
+ : __isfinitel(x))
+#elif defined LINUX || defined UNX
+#define SAL_MATH_FINITE(d) finite(d)
+#else /* WNT, LINUX, UNX */
+#error "SAL_MATH_FINITE not defined"
+#endif /* WNT, LINUX, UNX */
+
+
+/* This needs to be fixed for non--IEEE-754 platforms: */
+#if 1 /* IEEE 754 supported */
+#if defined OSL_BIGENDIAN
+
+/* IEEE 754 double structures for BigEndian */
+union sal_math_Double
+{
+ struct
+ {
+ unsigned sign : 1;
+ unsigned exponent :11;
+ unsigned fraction_hi :20;
+ unsigned fraction_lo :32;
+ } inf_parts;
+ struct
+ {
+ unsigned sign : 1;
+ unsigned exponent :11;
+ unsigned qnan_bit : 1;
+ unsigned bits :19;
+ unsigned fraction_lo :32;
+ } nan_parts;
+ struct
+ {
+ unsigned msw :32;
+ unsigned lsw :32;
+ } w32_parts;
+ double value;
+};
+
+#elif defined OSL_LITENDIAN
+
+/* IEEE 754 double structures for LittleEndian */
+union sal_math_Double
+{
+ struct {
+ unsigned fraction_lo :32;
+ unsigned fraction_hi :20;
+ unsigned exponent :11;
+ unsigned sign : 1;
+ } inf_parts;
+ struct {
+ unsigned fraction_lo :32;
+ unsigned bits :19;
+ unsigned qnan_bit : 1;
+ unsigned exponent :11;
+ unsigned sign : 1;
+ } nan_parts;
+ struct
+ {
+ unsigned lsw :32;
+ unsigned msw :32;
+ } w32_parts;
+ double value;
+};
+
+#else /* OSL_BIGENDIAN, OSL_LITENDIAN */
+
+#error "neither OSL_BIGENDIAN nor OSL_LITENDIAN"
+
+#endif /* OSL_BIGENDIAN, OSL_LITENDIAN */
+#else /* IEEE 754 supported */
+
+#error "don't know how to handle IEEE 754"
+
+#endif /* IEEE 754 supported */
+
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_SAL_MATHCONF_H */
diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h
new file mode 100644
index 000000000000..14c24480d98b
--- /dev/null
+++ b/sal/inc/sal/types.h
@@ -0,0 +1,435 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SAL_TYPES_H_
+#define _SAL_TYPES_H_
+
+#include <sal/config.h>
+
+/* Grab __SIZEOFxxx constants from typesconfig tool on Unix */
+#if defined UNX
+ #include <sal/typesizes.h>
+#elif defined(WNT) || defined(OS2)
+ /* FIXME: autogeneration of type sizes on Win32/Win64? */
+ #define SAL_TYPES_ALIGNMENT2 1
+ #define SAL_TYPES_ALIGNMENT4 1
+ #define SAL_TYPES_ALIGNMENT8 1
+ #define SAL_TYPES_SIZEOFSHORT 2
+ #define SAL_TYPES_SIZEOFINT 4
+ #define SAL_TYPES_SIZEOFLONG 4
+ #define SAL_TYPES_SIZEOFLONGLONG 8
+ #define SAL_TYPES_SIZEOFPOINTER 4
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************************************************************************/
+/* Data types
+*/
+
+/* Boolean */
+typedef unsigned char sal_Bool;
+# define sal_False ((sal_Bool)0)
+# define sal_True ((sal_Bool)1)
+
+/* char is assumed to always be 1 byte long */
+typedef signed char sal_Int8;
+typedef unsigned char sal_uInt8;
+
+#if SAL_TYPES_SIZEOFSHORT == 2
+ typedef signed short sal_Int16;
+ typedef unsigned short sal_uInt16;
+#else
+ #error "Could not find 16-bit type, add support for your architecture"
+#endif
+
+#if SAL_TYPES_SIZEOFLONG == 4
+ typedef signed long sal_Int32;
+ typedef unsigned long sal_uInt32;
+ #define SAL_PRIdINT32 "ld"
+ #define SAL_PRIuUINT32 "lu"
+ #define SAL_PRIxUINT32 "lx"
+ #define SAL_PRIXUINT32 "lX"
+#elif SAL_TYPES_SIZEOFINT == 4
+ typedef signed int sal_Int32;
+ typedef unsigned int sal_uInt32;
+ #define SAL_PRIdINT32 "d"
+ #define SAL_PRIuUINT32 "u"
+ #define SAL_PRIxUINT32 "x"
+ #define SAL_PRIXUINT32 "X"
+#else
+ #error "Could not find 32-bit type, add support for your architecture"
+#endif
+
+#if (_MSC_VER >= 1000)
+ typedef __int64 sal_Int64;
+ typedef unsigned __int64 sal_uInt64;
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##i64
+ #define SAL_CONST_UINT64(x) x##ui64
+
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined(__hpux) || defined (sgi)
+ #if SAL_TYPES_SIZEOFLONG == 8
+ typedef signed long int sal_Int64;
+ typedef unsigned long int sal_uInt64;
+
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##l
+ #define SAL_CONST_UINT64(x) x##ul
+
+ #define SAL_PRIdINT64 "ld"
+ #define SAL_PRIuUINT64 "lu"
+ #define SAL_PRIxUINT64 "lx"
+ #define SAL_PRIXUINT64 "lX"
+ #elif SAL_TYPES_SIZEOFLONGLONG == 8
+ typedef signed long long sal_Int64;
+ typedef unsigned long long sal_uInt64;
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##ll
+ #define SAL_CONST_UINT64(x) x##ull
+
+ #ifdef __MINGW32__
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+ #else
+ #define SAL_PRIdINT64 "lld"
+ #define SAL_PRIuUINT64 "llu"
+ #define SAL_PRIxUINT64 "llx"
+ #define SAL_PRIXUINT64 "llX"
+ #endif
+ #else
+ #error "Could not find 64-bit type, add support for your architecture"
+ #endif
+#else
+ #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
+#endif
+
+typedef char sal_Char;
+typedef signed char sal_sChar;
+typedef unsigned char sal_uChar;
+
+#if ( defined(SAL_W32) && !defined(__MINGW32__) )
+ typedef wchar_t sal_Unicode;
+#else
+ #define SAL_UNICODE_NOTEQUAL_WCHAR_T
+ typedef sal_uInt16 sal_Unicode;
+#endif
+
+typedef void * sal_Handle;
+
+/* sal_Size should currently be the native width of the platform */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_uInt32 sal_Size;
+ typedef sal_Int32 sal_sSize;
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_uInt64 sal_Size;
+ typedef sal_Int64 sal_sSize;
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/* sal_PtrDiff holds the result of a pointer subtraction */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_Int32 sal_PtrDiff;
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_Int64 sal_PtrDiff;
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/* printf-style conversion specification length modifiers for size_t and
+ ptrdiff_t (most platforms support C99, MSC has its own extension) */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ #define SAL_PRI_SIZET "I"
+ #define SAL_PRI_PTRDIFFT "I"
+#else
+ #define SAL_PRI_SIZET "z"
+ #define SAL_PRI_PTRDIFFT "t"
+#endif
+
+/* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
+ * pointer to void can be converted to this type and back to a pointer to void and the
+ * result will compare to the original pointer */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_Int32 sal_IntPtr;
+ typedef sal_uInt32 sal_uIntPtr;
+ #define SAL_PRIdINTPTR SAL_PRIdINT32
+ #define SAL_PRIuUINTPTR SAL_PRIuUINT32
+ #define SAL_PRIxUINTPTR SAL_PRIxUINT32
+ #define SAL_PRIXUINTPTR SAL_PRIXUINT32
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_Int64 sal_IntPtr;
+ typedef sal_uInt64 sal_uIntPtr;
+ #define SAL_PRIdINTPTR SAL_PRIdINT64
+ #define SAL_PRIuUINTPTR SAL_PRIuUINT64
+ #define SAL_PRIxUINTPTR SAL_PRIxUINT64
+ #define SAL_PRIXUINTPTR SAL_PRIXUINT64
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/********************************************************************************/
+/* Useful defines
+ */
+
+/* The following SAL_MIN_INTn defines codify the assumption that the signed
+ * sal_Int types use two's complement representation. Defining them as
+ * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
+ * unary minus operator to unsigned quantities.
+ */
+#define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
+#define SAL_MAX_INT8 ((sal_Int8) 0x7F)
+#define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
+#define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
+#define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
+#define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
+#define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
+#define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
+#define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
+#define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
+#define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
+#define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
+
+#if SAL_TYPES_SIZEOFLONG == 4
+#define SAL_MAX_SSIZE SAL_MAX_INT32
+#define SAL_MAX_SIZE SAL_MAX_UINT32
+#elif SAL_TYPES_SIZEOFLONG == 8
+#define SAL_MAX_SSIZE SAL_MAX_INT64
+#define SAL_MAX_SIZE SAL_MAX_UINT64
+#endif
+
+#if defined(SAL_W32) || defined(SAL_OS2) || defined(SAL_UNX)
+# define SAL_MAX_ENUM 0x7fffffff
+#elif defined(SAL_W16)
+# define SAL_MAX_ENUM 0x7fff
+#endif
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+# define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
+#if defined(_MSC_VER)
+# define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
+#else
+# define SAL_DLLPUBLIC_IMPORT
+#endif // defined(_MSC_VER)
+# define SAL_DLLPRIVATE
+#if defined(_MSC_VER)
+# define SAL_CALL __cdecl
+# define SAL_CALL_ELLIPSE __cdecl
+#else
+# define SAL_CALL
+# define SAL_CALL_ELLIPSE
+#endif
+#elif defined SAL_OS2 // YD
+/* YD 25/09/2007 gcc doesn't like imports inside class members */
+# define SAL_DLLPUBLIC_EXPORT
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE
+# define SAL_CALL
+# define SAL_CALL_ELLIPSE
+#elif defined SAL_UNX
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
+# define SAL_DLLPUBLIC_EXPORT __global
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __hidden
+# elif defined(__SUNPRO_C ) && (__SUNPRO_C >= 0x550)
+# define SAL_DLLPUBLIC_EXPORT __global
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __hidden
+# elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
+# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
+# else
+# define SAL_DLLPUBLIC_EXPORT
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE
+# endif
+# define SAL_CALL
+# define SAL_CALL_ELLIPSE
+#else
+# error("unknown platform")
+#endif
+
+/**
+ Exporting the symbols necessary for exception handling on GCC.
+
+ These macros are used for inline declarations of exception classes, as in
+ rtl/malformeduriexception.hxx.
+*/
+#if defined __GNUC__
+#define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
+#define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
+#else
+#define SAL_EXCEPTION_DLLPUBLIC_EXPORT
+#define SAL_EXCEPTION_DLLPRIVATE
+#endif
+
+/** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
+ This hinders the compiler from setting a generic vtable stating that
+ a pure virtual function was called and thus slightly reduces code size.
+*/
+#ifdef _MSC_VER
+# define SAL_NO_VTABLE __declspec(novtable)
+#else
+# define SAL_NO_VTABLE
+#endif
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#elif defined(SAL_OS2)
+# pragma pack(push, 4)
+#endif
+
+/** This is the binary specification of a SAL sequence.
+ <br>
+*/
+typedef struct _sal_Sequence
+{
+ /** reference count of sequence<br>
+ */
+ sal_Int32 nRefCount;
+ /** element count<br>
+ */
+ sal_Int32 nElements;
+ /** elements array<br>
+ */
+ char elements[1];
+} sal_Sequence;
+
+#define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
+
+#if defined( SAL_W32) || defined(SAL_OS2)
+#pragma pack(pop)
+#endif
+
+
+/** Wrap C++ const_cast, reinterpret_cast and static_cast expressions in
+ macros to keep code portable to old compilers (since most compilers still
+ lack RTTI support, dynamic_cast is not included here).
+ */
+#ifdef __cplusplus
+#if defined SAL_W32 || defined SOLARIS || defined LINUX || defined MACOSX || defined FREEBSD || defined NETBSD || defined AIX || defined OS2
+#define SAL_CONST_CAST(type, expr) (const_cast< type >(expr))
+#define SAL_REINTERPRET_CAST(type, expr) (reinterpret_cast< type >(expr))
+#define SAL_STATIC_CAST(type, expr) (static_cast< type >(expr))
+#else /* SAL_W32, SOLARIS, LINUX */
+#define SAL_CONST_CAST(type, expr) ((type) (expr))
+#define SAL_REINTERPRET_CAST(type, expr) ((type) (expr))
+#define SAL_STATIC_CAST(type, expr) ((type) (expr))
+#endif /* SAL_W32, SOLARIS, LINUX */
+#endif /* __cplusplus */
+
+/** Definition of function throw clause macros. These have been introduced
+ to reduce code size by balancing out compiler bugs.
+
+ These macros are ONLY for function declarations,
+ use common C++ throw statement for throwing exceptions, e.g.
+ throw RuntimeException();
+
+ SAL_THROW() should be used for all C++ functions, e.g. SAL_THROW( () )
+ SAL_THROW_EXTERN_C() should be used for all C functions
+*/
+#ifdef __cplusplus
+#if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi)
+#define SAL_THROW( exc )
+#else /* MSVC, all other */
+#define SAL_THROW( exc ) throw exc
+#endif /* __GNUC__, __SUNPRO_CC */
+#define SAL_THROW_EXTERN_C() throw ()
+#else /* ! __cplusplus */
+/* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */
+#define SAL_THROW_EXTERN_C()
+#endif
+
+
+
+#ifdef __cplusplus
+enum __sal_NoAcquire
+{
+ /** definition of a no acquire enum for ctors
+ */
+ SAL_NO_ACQUIRE
+};
+#endif /* __cplusplus */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+
+namespace sal {
+
+/**
+ A static_cast between integral types, to avoid C++ compiler warnings.
+
+ In C++ source code, use sal::static_int_cast<T>(n) instead of
+ static_cast<T>(n) whenever a compiler warning about integral type problems
+ shall be silenced. That way, source code that needs to be modified when the
+ type of any of the expressions involved in the compiler warning is changed
+ can be found more easily.
+
+ Both template arguments T1 and T2 must be integral types.
+*/
+template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
+ return static_cast< T1 >(n);
+}
+
+}
+
+#else /* __cplusplus */
+
+/**
+ A cast between integer types, to avoid C compiler warnings.
+
+ In C source code, use SAL_INT_CAST(type, expr) instead of ((type) (expr))
+ whenever a compiler warning about integer type problems shall be silenced.
+ That way, source code that needs to be modified when the type of any of the
+ expressions involved in the compiler warning is changed can be found more
+ easily.
+
+ The argument 'type' must be an integer type and the argument 'expr' must be
+ an integer expression. Both arguments are evaluated exactly once.
+*/
+#define SAL_INT_CAST(type, expr) ((type) (expr))
+
+#endif /* __cplusplus */
+
+#endif /*_SAL_TYPES_H_ */
+
diff --git a/sal/inc/systools/win32/AutoSystoolInit.hxx b/sal/inc/systools/win32/AutoSystoolInit.hxx
new file mode 100644
index 000000000000..d212ff83c334
--- /dev/null
+++ b/sal/inc/systools/win32/AutoSystoolInit.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _AUTOSYSTOOLINIT_HXX_
+#define _AUTOSYSTOOLINIT_HXX_
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+//------------------------------------------------------------------------
+// class used to automatically initialize/deinitialize the systools
+//------------------------------------------------------------------------
+
+class OAutoSystoolInit
+{
+ typedef void ( WINAPI *LPFNINIT_T )( );
+ typedef void ( WINAPI *LPFNDEINIT_T )( );
+
+public:
+ OAutoSystoolInit( LPFNINIT_T lpfnInit, LPFNDEINIT_T lpfnDeInit ) :
+ m_lpfnDeInit( lpfnDeInit )
+ {
+ if ( NULL != lpfnInit )
+ lpfnInit( );
+ }
+
+ ~OAutoSystoolInit( )
+ {
+ if ( NULL != m_lpfnDeInit )
+ m_lpfnDeInit( );
+ }
+
+private:
+ LPFNDEINIT_T m_lpfnDeInit; // address of the deinit function
+};
+
+#endif
diff --git a/sal/inc/systools/win32/StrConvert.h b/sal/inc/systools/win32/StrConvert.h
new file mode 100644
index 000000000000..f22f68cda46a
--- /dev/null
+++ b/sal/inc/systools/win32/StrConvert.h
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _STRCONVERT_H_
+#define _STRCONVERT_H_
+
+#include <windows.h>
+
+#ifdef NDEBUG
+#define STRCONVERT_H_HAD_NDEBUG
+#undef NDEBUG
+#endif
+#if OSL_DEBUG_LEVEL == 0
+#define NDEBUG
+#endif
+#include <assert.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+int AllocNecessarySpaceAndCopyWStr2Str( LPCWSTR lpcwstrString, LPSTR* lppStr );
+int AllocSpaceAndCopyWStr2Str( LPCWSTR lpcwstrString, DWORD nWCharsToCopy, LPSTR* lppStr );
+int CalcLenDblNullTerminatedWStr( LPCWSTR lpcwstrString );
+int CalcLenDblNullTerminatedStr( LPCSTR lpcstrString );
+void FreeSpaceStr( LPSTR lpszString );
+
+/* WC2MB allocates a sufficient amount of memory on stack and converts
+ the wide char parameter to multi byte string using the actual code
+ page.
+
+ @Param: wcStr - a wide char string
+ mbStr - the corresponding multi byte string
+
+ NOTE: due to the use of _alloca, this must be a macro and no function
+*/
+
+#define WC2MB( wcStr, mbStr ) \
+if( wcStr ) \
+{ \
+ int needed = WideCharToMultiByte( CP_ACP, 0, wcStr, -1, NULL, 0, NULL, NULL ); \
+ if( needed > 0 ) \
+ { \
+ int copied; \
+ mbStr = _alloca( needed * sizeof( CHAR ) ); \
+ copied = WideCharToMultiByte( CP_ACP, 0, wcStr, -1, mbStr, needed, NULL, NULL ); \
+ assert( copied == needed ); \
+ } \
+}
+
+
+/* WideCharListGetMultiByteLength
+ calculates the needed length of a corresponding the multi byte string
+ list for a wide char string list.
+
+ @Param: cp - the code page to use for convertion.
+ wcList - a double '\0' terminated wide char string list.
+*/
+
+int WideCharListGetMultiByteLength( UINT codepage, LPCWSTR wcList );
+
+/* WideCharListToMultiByteList
+ converts a double '\0' terminated list of wide char strings to a
+ multi byte string list.
+
+ @Param: cp - the code page to use for convertion.
+ wcList - a double '\0' terminated wide char string list.
+ mbList - a double '\0' terminated multi byte string list.
+ dwSize - size of buffer for multi byte string list.
+*/
+
+int WideCharListToMultiByteList( UINT codepage, LPCWSTR wcList, LPSTR mbList, DWORD dwSize );
+
+
+/* WCL2MBL allocates a sufficient amount of memory on stack and converts
+ the wide char list parameter to multi byte string list using the actual
+ code page.
+
+ @Param: wcList - a wide char string list
+ mbList - the corresponding multi byte string list
+
+ NOTE: due to the use of _alloca, this must be a macro and no function
+*/
+
+#define WCL2MBL( wcList, mbList ) \
+if( wcList ) \
+{ \
+ int needed = WideCharListGetMultiByteLength( CP_ACP, wcList ); \
+ if( needed > 0 ) \
+ { \
+ int copied; \
+ mbList = _alloca( needed * sizeof( CHAR ) ); \
+ copied = WideCharListToMultiByteList( CP_ACP, wcList, mbList, needed ); \
+ assert( copied == needed ); \
+ } \
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+// Restore NDEBUG state
+#ifdef STRCONVERT_H_HAD_NDEBUG
+#define NDEBUG
+#else
+#undef NDEBUG
+#endif
+
+#endif
diff --git a/sal/inc/systools/win32/SyncObjects.hxx b/sal/inc/systools/win32/SyncObjects.hxx
new file mode 100644
index 000000000000..87057bab6296
--- /dev/null
+++ b/sal/inc/systools/win32/SyncObjects.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SYNCOBJECTS_HXX_
+#define _SYNCOBJECTS_HXX_
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+#include <windows.h>
+
+//------------------------------------------------------------------------
+// a simple helper template for automatic locking/unlocking
+//------------------------------------------------------------------------
+
+template< class LOCK >
+class CLockGuard
+{
+public:
+ CLockGuard( LOCK* aLock ) :
+ m_pLock( aLock )
+ {
+ m_pLock->Lock( );
+ }
+
+ ~CLockGuard( )
+ {
+ m_pLock->Unlock( );
+ }
+
+private:
+ LOCK* m_pLock;
+};
+
+//------------------------------------------------------------------------
+// a interface base class for different locking sub classes
+//------------------------------------------------------------------------
+
+class CSyncObject
+{
+public:
+ virtual ~CSyncObject( ) = 0;
+
+ virtual int Lock( ) = 0;
+ virtual int Unlock( ) = 0;
+};
+
+//------------------------------------------------------------------------
+// if no synchronization is necessary this class will be used
+// declaring the functions as inline safes runtime overhead
+//------------------------------------------------------------------------
+
+class CNullLock
+{
+public:
+ inline virtual ~CNullLock ( ) {};
+ inline virtual int Lock( ) {};
+ inline virtual int Unlock() {};
+};
+
+//------------------------------------------------------------------------
+// a minimal wrapper for a win32 critical section
+//------------------------------------------------------------------------
+
+class CCriticalSection : public CSyncObject
+{
+public:
+ CCriticalSection( );
+ virtual ~CCriticalSection( );
+
+ // both functions return always 0
+ // because the win32 critsec functions
+ // don't return any return code
+ virtual int Lock( );
+ virtual int Unlock( );
+
+private:
+ CRITICAL_SECTION m_critSec;
+};
+
+
+typedef CLockGuard< CSyncObject > SyncObjLockGuard_t;
+
+#endif
diff --git a/sal/inc/systools/win32/advapi9x.h b/sal/inc/systools/win32/advapi9x.h
new file mode 100644
index 000000000000..302df89c50c3
--- /dev/null
+++ b/sal/inc/systools/win32/advapi9x.h
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the shlobj.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+// begin obsolete Win32 API functions -->
+#ifdef RegOpenKey
+#undef RegOpenKey
+#endif
+#ifdef RegEnumKey
+#undef RegEnumKey
+#endif
+#ifdef RegCreateKey
+#undef RegCreateKey
+#endif
+#ifdef RegQueryValue
+#undef RegQueryValue
+#endif
+#ifdef RegSetValue
+#undef RegSetValue
+#endif
+// <-- end obsolete Win32 functions
+
+#ifdef RegOpenKeyExW
+#undef RegOpenKeyExW
+#endif
+#ifdef RegEnumKeyExW
+#undef RegEnumKeyExW
+#endif
+#ifdef RegCreateKeyExW
+#undef RegCreateKeyExW
+#endif
+#ifdef RegDeleteKeyW
+#undef RegDeleteKeyW
+#endif
+#ifdef RegEnumValueW
+#undef RegEnumValueW
+#endif
+#ifdef RegQueryValueExW
+#undef RegQueryValueExW
+#endif
+#ifdef RegSetValueExW
+#undef RegSetValueExW
+#endif
+#ifdef RegDeleteValueW
+#undef RegDeleteValueW
+#endif
+#ifdef RegQueryInfoKeyW
+#undef RegQueryInfoKeyW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define ADVAPI9X_API extern
+
+ //------------------------------------------------------------------------
+// declare function pointers to the appropriate shell functions
+//------------------------------------------------------------------------
+
+ADVAPI9X_API LONG (WINAPI * lpfnRegOpenKeyExW) (
+ HKEY hKey, // handle to open key
+ LPCWSTR lpSubKey, // subkey name
+ DWORD ulOptions, // reserved
+ REGSAM samDesired, // security access mask
+ PHKEY phkResult // handle to open key
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegEnumKeyExW) (
+ HKEY hKey, // handle to key to enumerate
+ DWORD dwIndex, // subkey index
+ LPWSTR lpName, // subkey name
+ LPDWORD lpcName, // size of subkey buffer
+ LPDWORD lpReserved, // reserved
+ LPWSTR lpClass, // class string buffer
+ LPDWORD lpcClass, // size of class string buffer
+ PFILETIME lpftLastWriteTime // last write time
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegCreateKeyExW)(
+ HKEY hKey, // handle to open key
+ LPCWSTR lpSubKey, // subkey name
+ DWORD Reserved, // reserved
+ LPWSTR lpClass, // class string
+ DWORD dwOptions, // special options
+ REGSAM samDesired, // desired security access
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes, // inheritance
+ PHKEY phkResult, // key handle
+ LPDWORD lpdwDisposition // disposition value buffer
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegDeleteKeyW) (
+ HKEY hKey, // handle to open key
+ LPCWSTR lpSubKey // subkey name
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegEnumValueW) (
+ HKEY hKey, // handle to key to query
+ DWORD dwIndex, // index of value to query
+ LPWSTR lpValueName, // value buffer
+ LPDWORD lpcValueName, // size of value buffer
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpType, // type buffer
+ LPBYTE lpData, // data buffer
+ LPDWORD lpcbData // size of data buffer
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegQueryValueExW) (
+ HKEY hKey, // handle to key
+ LPCWSTR lpValueName, // value name
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpType, // type buffer
+ LPBYTE lpData, // data buffer
+ LPDWORD lpcbData // size of data buffer
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegSetValueExW)(
+ HKEY hKey, // handle to key
+ LPCWSTR lpValueName, // value name
+ DWORD Reserved, // reserved
+ DWORD dwType, // value type
+ CONST BYTE *lpData, // value data
+ DWORD cbData // size of value data
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegDeleteValueW) (
+ HKEY hKey, // handle to key
+ LPCWSTR lpValueName // value name
+);
+
+ADVAPI9X_API LONG (WINAPI *lpfnRegQueryInfoKeyW) (
+ HKEY hKey, // handle to key to query
+ LPWSTR lpClassW, // address of buffer for class string
+ LPDWORD lpcbClass, // address of size of class string buffer
+ LPDWORD lpReserved, // reserved
+ LPDWORD lpcSubKeys, // address of buffer for number of
+ // subkeys
+ LPDWORD lpcbMaxSubKeyLen, // address of buffer for longest subkey
+ // name length
+ LPDWORD lpcbMaxClassLen, // address of buffer for longest class
+ // string length
+ LPDWORD lpcValues, // address of buffer for number of value
+ // entries
+ LPDWORD lpcbMaxValueNameLen, // address of buffer for longest
+ // value name length
+ LPDWORD lpcbMaxValueLen, // address of buffer for longest value
+ // data length
+ LPDWORD lpcbSecurityDescriptor, // address of buffer for security
+ // descriptor length
+ PFILETIME lpftLastWriteTime // address of buffer for last write time
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define RegOpenKeyExW lpfnRegOpenKeyExW
+#define RegEnumKeyExW lpfnRegEnumKeyExW
+#define RegCreateKeyExW lpfnRegCreateKeyExW
+#define RegDeleteKeyW lpfnRegDeleteKeyW
+#define RegEnumValueW lpfnRegEnumValueW
+#define RegQueryValueExW lpfnRegQueryValueExW
+#define RegSetValueExW lpfnRegSetValueExW
+#define RegDeleteValueW lpfnRegDeleteValueW
+#define RegQueryInfoKeyW lpfnRegQueryInfoKeyW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/comdlg9x.h b/sal/inc/systools/win32/comdlg9x.h
new file mode 100644
index 000000000000..ce51bbe61ced
--- /dev/null
+++ b/sal/inc/systools/win32/comdlg9x.h
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifndef _COMMDLG_H_
+#include <commdlg.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the shlobj.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef GetOpenFileNameW
+#undef GetOpenFileNameW
+#endif
+
+#ifdef GetSaveFileNameW
+#undef GetSaveFileNameW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define COMDLG9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate comdlg functions
+//------------------------------------------------------------------------
+
+COMDLG9X_API BOOL ( WINAPI * lpfnGetOpenFileNameW ) ( LPOPENFILENAMEW lpofn );
+COMDLG9X_API BOOL ( WINAPI * lpfnGetSaveFileNameW ) ( LPOPENFILENAMEW lpofn );
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define GetOpenFileNameW lpfnGetOpenFileNameW
+#define GetSaveFileNameW lpfnGetSaveFileNameW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/comptr.hxx b/sal/inc/systools/win32/comptr.hxx
new file mode 100644
index 000000000000..1e880494b0ea
--- /dev/null
+++ b/sal/inc/systools/win32/comptr.hxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef COMPTR_HXX
+#define COMPTR_HXX
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <shobjidl.h>
+
+template< class T_INTERFACE ,
+ REFIID P_IID = IID_NULL ,
+ REFCLSID P_CLSID = CLSID_NULL >
+class ComPtr
+{
+ public:
+
+ //---------------------------------------------------------------------
+ /** initialize com ptr with null.
+ */
+ ComPtr()
+ {
+ m_pInterface = NULL;
+ }
+
+ //---------------------------------------------------------------------
+ /** initialize com ptr with given interface.
+ */
+ ComPtr(T_INTERFACE* pInterface)
+ {
+ m_pInterface = pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+ }
+
+ //---------------------------------------------------------------------
+ /** copy ctor.
+ */
+ ComPtr(const ComPtr< T_INTERFACE, P_IID, P_CLSID >& aCopy)
+ {
+ m_pInterface = aCopy.m_pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+ }
+
+ //---------------------------------------------------------------------
+ /** initialize object by quering external object for the right interface.
+ */
+ ComPtr(IUnknown* pIUnknown)
+ {
+ if (pIUnknown)
+ pIUnknown->QueryInterface(P_IID, (void**)&m_pInterface);
+ }
+
+ //---------------------------------------------------------------------
+ /** deinitialize com object right.
+ */
+ ~ComPtr()
+ {
+ release();
+ }
+
+ public:
+
+ //---------------------------------------------------------------------
+ HRESULT create()
+ {
+ return CoCreateInstance(P_CLSID, NULL, CLSCTX_ALL, P_IID, (void**)&m_pInterface);
+ }
+
+ //---------------------------------------------------------------------
+ operator T_INTERFACE*() const
+ {
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE& operator*() const
+ {
+ return *m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE** operator&()
+ {
+ return &m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator->() const
+ {
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator=(T_INTERFACE* pInterface)
+ {
+ if ( equals(pInterface) )
+ return m_pInterface;
+
+ m_pInterface->Release();
+ m_pInterface = pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator=(IUnknown* pIUnknown)
+ {
+ if (pIUnknown)
+ pIUnknown->QueryInterface(P_IID, (void**)&m_pInterface);
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* operator=(const ComPtr< T_INTERFACE, P_IID, P_CLSID >& aCopy)
+ {
+ m_pInterface = aCopy.m_pInterface;
+ if (m_pInterface)
+ m_pInterface->AddRef();
+
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* get() const
+ {
+ return m_pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ void attach(T_INTERFACE* pInterface)
+ {
+ if (pInterface)
+ {
+ m_pInterface->Release();
+ m_pInterface = pInterface;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ T_INTERFACE* detach()
+ {
+ T_INTERFACE* pInterface = m_pInterface;
+ m_pInterface = NULL;
+ return pInterface;
+ }
+
+ //---------------------------------------------------------------------
+ void release()
+ {
+ if (m_pInterface)
+ {
+ m_pInterface->Release();
+ m_pInterface = NULL;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ template< class T_QUERYINTERFACE >
+ HRESULT query(T_QUERYINTERFACE** pQuery)
+ {
+ return m_pInterface->QueryInterface(__uuidof(T_QUERYINTERFACE), (void**)pQuery);
+ }
+
+ //---------------------------------------------------------------------
+ HRESULT query(REFIID rIID ,
+ void** pQuery)
+ {
+ return m_pInterface->QueryInterface(rIID, pQuery);
+ }
+
+ //---------------------------------------------------------------------
+ HRESULT unknown(IUnknown** pQuery)
+ {
+ return m_pInterface->QueryInterface(IID_IUnknown, (void**)pQuery);
+ }
+
+ //---------------------------------------------------------------------
+ ::sal_Bool equals(IUnknown* pCheck)
+ {
+ if (
+ ( ! m_pInterface ) &&
+ ( ! pCheck )
+ )
+ return sal_True;
+
+ IUnknown* pCurrent = NULL;
+ m_pInterface->QueryInterface(IID_IUnknown, (void**)&pCurrent);
+
+ ::sal_Bool bEquals = (pCheck == pCurrent);
+ pCurrent->Release();
+
+ return bEquals;
+ }
+
+ //---------------------------------------------------------------------
+ ::sal_Bool is()
+ {
+ return (m_pInterface != 0);
+ }
+
+ private:
+ T_INTERFACE* m_pInterface;
+};
+
+#endif
diff --git a/sal/inc/systools/win32/comtools.hxx b/sal/inc/systools/win32/comtools.hxx
new file mode 100644
index 000000000000..096015517a35
--- /dev/null
+++ b/sal/inc/systools/win32/comtools.hxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#include <string>
+#include <stdexcept>
+#if defined _MSC_VER
+#pragma warning(push,1)
+#endif
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+namespace sal
+{
+namespace systools
+{
+ typedef int HRESULT;
+
+ /* Simple exception class for propagating COM errors */
+ class ComError : public std::runtime_error
+ {
+ public:
+ ComError(const std::string& message, HRESULT hr) :
+ std::runtime_error(message),
+ hr_(hr)
+ {}
+
+ HRESULT GetHresult() const
+ {
+ return hr_;
+ }
+
+ private:
+ HRESULT hr_;
+ };
+
+ /* A simple COM smart pointer template */
+ template <typename T>
+ class COMReference
+ {
+ public:
+ COMReference() :
+ com_ptr_(NULL)
+ {
+ }
+
+ explicit COMReference(T* comptr) :
+ com_ptr_(comptr)
+ {
+ addRef();
+ }
+
+ /* Explicitly controllable whether AddRef will be called or not */
+ COMReference(T* comptr, bool bAddRef) :
+ com_ptr_(comptr)
+ {
+ if (bAddRef)
+ addRef();
+ }
+
+ COMReference(const COMReference<T>& other) :
+ com_ptr_(other.com_ptr_)
+ {
+ addRef();
+ }
+
+ COMReference<T>& operator=(const COMReference<T>& other)
+ {
+ if (other.com_ptr_)
+ other.com_ptr_->AddRef();
+ release();
+ com_ptr_ = other.com_ptr_;
+ return *this;
+ }
+
+ COMReference<T>& operator=(T* comptr)
+ {
+ release();
+ com_ptr_ = comptr;
+ addRef();
+ return *this;
+ }
+
+ ~COMReference()
+ {
+ release();
+ }
+
+ template<typename InterfaceType>
+ COMReference<InterfaceType> QueryInterface(REFIID iid)
+ {
+ COMReference<InterfaceType> ip;
+ HRESULT hr = E_FAIL;
+ if (com_ptr_)
+ hr = com_ptr_->QueryInterface(iid, reinterpret_cast<LPVOID*>(&ip));
+
+ if (FAILED(hr))
+ throw ComError("QueryInterface failed: Interface not supported!", hr);
+
+ return ip;
+ }
+
+ T* operator->() const
+ {
+ return com_ptr_;
+ }
+
+ T& operator*() const
+ {
+ return *com_ptr_;
+ }
+
+ /* Necessary for assigning com_ptr_ from functions like
+ CoCreateInstance which require a 'void**' */
+ T** operator&()
+ {
+ release();
+ com_ptr_ = NULL;
+ return &com_ptr_;
+ }
+
+ T* get() const
+ {
+ return com_ptr_;
+ }
+
+ COMReference<T>& clear()
+ {
+ release();
+ com_ptr_ = NULL;
+ return *this;
+ }
+
+ bool is() const
+ {
+ return (com_ptr_ != NULL);
+ }
+
+ private:
+ ULONG addRef()
+ {
+ ULONG cnt = 0;
+ if (com_ptr_)
+ cnt = com_ptr_->AddRef();
+ return cnt;
+ }
+
+ ULONG release()
+ {
+ ULONG cnt = 0;
+ if (com_ptr_)
+ cnt = com_ptr_->Release();
+ return cnt;
+ }
+
+ private:
+ T* com_ptr_;
+ };
+
+} // systools
+} // sal
+
+/* Typedefs for some popular COM interfaces */
+typedef sal::systools::COMReference<IDataObject> IDataObjectPtr;
+typedef sal::systools::COMReference<IStream> IStreamPtr;
+typedef sal::systools::COMReference<IEnumFORMATETC> IEnumFORMATETCPtr;
+
diff --git a/sal/inc/systools/win32/kernel9x.h b/sal/inc/systools/win32/kernel9x.h
new file mode 100644
index 000000000000..647e7d58542d
--- /dev/null
+++ b/sal/inc/systools/win32/kernel9x.h
@@ -0,0 +1,383 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the winbase.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef LoadLibraryW
+#undef LoadLibraryW
+#endif
+
+#ifdef LoadLibraryExW
+#undef LoadLibraryExW
+#endif
+
+#ifdef GetModuleFileNameW
+#undef GetModuleFileNameW
+#endif
+
+#ifdef GetLogicalDriveStringsW
+#undef GetLogicalDriveStringsW
+#endif
+
+#ifdef DeleteFileW
+#undef DeleteFileW
+#endif
+
+#ifdef CopyFileW
+#undef CopyFileW
+#endif
+
+#ifdef MoveFileW
+#undef MoveFileW
+#endif
+
+#ifdef MoveFileExW
+#undef MoveFileExW
+#endif
+
+#ifdef CreateFileW
+#undef CreateFileW
+#endif
+
+#ifdef RemoveDirectoryW
+#undef RemoveDirectoryW
+#endif
+
+#ifdef CreateDirectoryW
+#undef CreateDirectoryW
+#endif
+
+#ifdef CreateDirectoryExW
+#undef CreateDirectoryExW
+#endif
+
+#ifdef CreateFileW
+#undef CreateFileW
+#endif
+
+#ifdef GetLongPathNameW
+#undef GetLongPathNameW
+#endif
+
+#ifdef GetLocaleInfoW
+#undef GetLocaleInfoW
+#endif
+
+#ifdef GetFullPathNameW
+#undef GetFullPathNameW
+#endif
+
+#ifdef CreateProcessW
+#undef CreateProcessW
+#endif
+
+#ifdef CreateProcessAsUserW
+#undef CreateProcessAsUserW
+#endif
+
+#ifdef GetEnvironmentVariableW
+#undef GetEnvironmentVariableW
+#endif
+
+#ifdef GetDriveTypeW
+#undef GetDriveTypeW
+#endif
+
+#ifdef GetCurrentDirectoryW
+#undef GetCurrentDirectoryW
+#endif
+
+#ifdef SetCurrentDirectoryW
+#undef SetCurrentDirectoryW
+#endif
+
+#ifdef GetVolumeInformationW
+#undef GetVolumeInformationW
+#endif
+
+
+#ifdef GetDiskFreeSpaceExA
+#undef GetDiskFreeSpaceExA
+#endif
+
+#ifdef GetDiskFreeSpaceExW
+#undef GetDiskFreeSpaceExW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define KERNEL9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate kernel functions
+//------------------------------------------------------------------------
+
+//BOOL WINAPI RegisterServiceProcess( DWORD dwProcessID, BOOL fRegister );
+
+KERNEL9X_API HMODULE (WINAPI *lpfnLoadLibraryExW ) (
+ LPCWSTR lpLibFileName, // file name of module
+ HANDLE hFile, // reserved, must be NULL
+ DWORD dwFlags // entry-point execution option
+);
+
+KERNEL9X_API DWORD (WINAPI *lpfnGetModuleFileNameW ) (
+ HMODULE hModule, // handle to module
+ LPWSTR lpFilename, // file name of module
+ DWORD nSize // size of buffer
+);
+
+KERNEL9X_API DWORD (WINAPI *lpfnGetLogicalDriveStringsW ) (
+ DWORD nBufferLength, // size of buffer
+ LPWSTR lpBuffer // drive strings buffer
+);
+
+KERNEL9X_API HANDLE ( WINAPI *lpfnCreateFileW )(
+ LPCWSTR lpFileName,
+ DWORD dwDesiredAccess,
+ DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition,
+ DWORD dwFlagsAndAttributes,
+ HANDLE hTemplateFile
+);
+
+KERNEL9X_API DWORD WINAPI GetCanonicalPathNameA(
+ LPCSTR lpszPath, // file name
+ LPSTR lpszCanonicalPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+KERNEL9X_API DWORD WINAPI GetCanonicalPathNameW(
+ LPCWSTR lpszPath, // file name
+ LPWSTR lpszCanonicalPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+KERNEL9X_API HANDLE ( WINAPI * lpfnCreateFileW ) (
+ LPCWSTR lpFileName,
+ DWORD dwDesiredAccess,
+ DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition,
+ DWORD dwFlagsAndAttributes,
+ HANDLE hTemplateFile );
+
+KERNEL9X_API BOOL (WINAPI *lpfnDeleteFileW ) (
+ LPCWSTR lpFileName // file name
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnCopyFileW ) (
+ LPCWSTR lpExistingFileName, // file name
+ LPCWSTR lpNewFileName, // new file name
+ BOOL bFailIfExist // operation if file exists
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnMoveFileW ) (
+ LPCWSTR lpExistingFileName, // file name
+ LPCWSTR lpNewFileName // new file name
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnMoveFileExW ) (
+ LPCWSTR lpExistingFileName, // file name
+ LPCWSTR lpNewFileName, // new file name
+ DWORD dwFlags // move options
+);
+
+KERNEL9X_API BOOL (WINAPI *lpfnRemoveDirectoryW ) (
+ LPCWSTR lpPathName // directory name
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateDirectoryW ) (
+ LPCWSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes );
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateDirectoryExW ) (
+ LPCWSTR lpTemplateDirectory,
+ LPCWSTR lpNewDirectory,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes );
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetLongPathNameW ) (
+ LPCWSTR lpszShortPath, // file name
+ LPWSTR lpszLongPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+// GetCanonicalPath is a tool function with no exact counterpart
+// in the win32 api; we use nevertheless a function pointer
+// because every variable etc. must root in the Kernel9x.lib else
+// we loose our AutoSystoolInit object during linking
+KERNEL9X_API DWORD ( WINAPI * lpfnGetCanonicalPathW ) (
+ LPCWSTR lpszPath, // file name
+ LPWSTR lpszCanonicalPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+KERNEL9X_API int ( WINAPI* lpfnGetLocaleInfoW ) (
+ LCID Locale, // locale identifier
+ LCTYPE LCType, // information type
+ LPWSTR lpLCData, // information buffer
+ int cchData // size of buffer
+);
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetFullPathNameW )(
+ LPCWSTR lpFileName, // file name
+ DWORD nBufferLength, // size of path buffer
+ LPWSTR lpBuffer, // path buffer
+ LPWSTR *lpFilePart // address of file name in path
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateProcessW )(
+ LPCWSTR lpApplicationName, // name of executable module
+ LPWSTR lpCommandLine, // command line string
+ LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
+ LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
+ BOOL bInheritHandles, // handle inheritance option
+ DWORD dwCreationFlags, // creation flags
+ LPVOID lpEnvironment, // new environment block
+ LPCWSTR lpCurrentDirectory, // current directory name
+ LPSTARTUPINFOW lpStartupInfo, // startup information
+ LPPROCESS_INFORMATION lpProcessInformation // process information
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnCreateProcessAsUserW )(
+ HANDLE hToken, // handle to user token
+ LPCWSTR lpApplicationName, // name of executable module
+ LPWSTR lpCommandLine, // command-line string
+ LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
+ LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
+ BOOL bInheritHandles, // inheritance option
+ DWORD dwCreationFlags, // creation flags
+ LPVOID lpEnvironment, // new environment block
+ LPCWSTR lpCurrentDirectory, // current directory name
+ LPSTARTUPINFOW lpStartupInfo, // startup information
+ LPPROCESS_INFORMATION lpProcessInformation // process information
+);
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetEnvironmentVariableW )(
+ LPCWSTR lpName, // environment variable name
+ LPWSTR lpBuffer, // buffer for variable value
+ DWORD nSize // size of buffer
+);
+
+
+KERNEL9X_API UINT ( WINAPI * lpfnGetDriveTypeW )(
+ LPCWSTR lpRootPathName // root directory
+);
+
+KERNEL9X_API DWORD ( WINAPI * lpfnGetCurrentDirectoryW )(
+ DWORD nBufferLength, // size of directory buffer
+ LPWSTR lpBuffer // directory buffer
+);
+
+KERNEL9X_API BOOL ( WINAPI * lpfnSetCurrentDirectoryW )(
+ LPCWSTR lpPathName // new directory name
+);
+
+// GetVolumeInformation
+KERNEL9X_API BOOL ( WINAPI* lpfnGetVolumeInformationW )(
+ LPCWSTR lpRootPathName, // root directory
+ LPWSTR lpVolumeNameBuffer, // volume name buffer
+ DWORD nVolumeNameSize, // length of name buffer
+ LPDWORD lpVolumeSerialNumber, // volume serial number
+ LPDWORD lpMaximumComponentLength, // maximum file name length
+ LPDWORD lpFileSystemFlags, // file system options
+ LPWSTR lpFileSystemName, // file system name buffer
+ DWORD nFileSystemNameSize // length of file system name buffer
+);
+
+// GetDiskFreeSpaceExA
+KERNEL9X_API BOOL (WINAPI *lpfnGetDiskFreeSpaceExA)(
+ LPCSTR lpDirectoryName, // directory name
+ PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
+ PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
+ PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
+);
+
+// GetDiskFreeSpaceExW
+KERNEL9X_API BOOL (WINAPI *lpfnGetDiskFreeSpaceExW)(
+ LPCWSTR lpDirectoryName, // directory name
+ PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
+ PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
+ PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define LoadLibraryExW lpfnLoadLibraryExW
+#define LoadLibraryW(c) LoadLibraryExW(c, NULL, 0)
+#define GetModuleFileNameW lpfnGetModuleFileNameW
+#define GetLogicalDriveStringsW lpfnGetLogicalDriveStringsW
+#define CreateFileW lpfnCreateFileW
+#define DeleteFileW lpfnDeleteFileW
+#define CopyFileW lpfnCopyFileW
+#define MoveFileW lpfnMoveFileW
+#define MoveFileExW lpfnMoveFileExW
+#define RemoveDirectoryW lpfnRemoveDirectoryW
+#define CreateDirectoryW lpfnCreateDirectoryW
+#define CreateDirectoryExW lpfnCreateDirectoryExW
+#define GetLongPathNameW lpfnGetLongPathNameW
+#define GetFullPathNameW lpfnGetFullPathNameW
+
+#define GetCanonicalPath lpfnGetCanonicalPathW
+#define GetLocaleInfoW lpfnGetLocaleInfoW
+
+#define CreateProcessW lpfnCreateProcessW
+#define CreateProcessAsUserW lpfnCreateProcessAsUserW
+#define GetEnvironmentVariableW lpfnGetEnvironmentVariableW
+#define GetDriveTypeW lpfnGetDriveTypeW
+
+#define GetCurrentDirectoryW lpfnGetCurrentDirectoryW
+#define SetCurrentDirectoryW lpfnSetCurrentDirectoryW
+
+#define GetVolumeInformationW lpfnGetVolumeInformationW
+#define GetDiskFreeSpaceExA lpfnGetDiskFreeSpaceExA
+#define GetDiskFreeSpaceExW lpfnGetDiskFreeSpaceExW
+
+#ifdef __cplusplus
+}
+#endif
+
+
diff --git a/sal/inc/systools/win32/mpr9x.h b/sal/inc/systools/win32/mpr9x.h
new file mode 100644
index 000000000000..15b122025381
--- /dev/null
+++ b/sal/inc/systools/win32/mpr9x.h
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the winuser.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef WNetGetConnectionW
+#undef WNetGetConnectionW
+#endif
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define MPR9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate user32 functions
+//------------------------------------------------------------------------
+
+MPR9X_API DWORD (WINAPI *lpfnWNetGetConnectionW)(
+ LPCWSTR lpLocalName, // pointer to local name
+ LPWSTR lpRemoteName, // pointer to buffer for remote name
+ LPDWORD lpnLength // pointer to buffer size, in characters
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define WNetGetConnectionW lpfnWNetGetConnectionW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/shell9x.h b/sal/inc/systools/win32/shell9x.h
new file mode 100644
index 000000000000..30716314830d
--- /dev/null
+++ b/sal/inc/systools/win32/shell9x.h
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _SHELL9X_H_
+#define _SHELL9X_H_
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifndef _SHLOBJ_H_
+#include <shlobj.h>
+#endif
+
+#include <shellapi.h>
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the shlobj.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef CommandLineToArgvW
+#undef CommandLineToArgvW
+#endif
+
+#ifdef SHBrowseForFolderW
+#undef SHBrowseForFolderW
+#endif
+
+#ifdef SHGetPathFromIDListW
+#undef SHGetPathFromIDListW
+#endif
+
+#ifdef ShellExecuteExW
+#undef ShellExecuteExW
+#endif
+
+//------------------------------------------------------------------------
+// set the compiler directives for the function pointer we declare below
+// if we build sal or sal will be used as static library we define extern
+// else sal exports the function pointers from a dll and we use __declspec
+//------------------------------------------------------------------------
+
+#define SHELL9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate shell functions
+//------------------------------------------------------------------------
+
+SHELL9X_API LPWSTR * ( WINAPI * lpfnCommandLineToArgvW ) ( LPCWSTR lpCmdLine, int *pNumArgs );
+SHELL9X_API LPITEMIDLIST ( WINAPI * lpfnSHBrowseForFolderW ) ( LPBROWSEINFOW lpbi );
+SHELL9X_API BOOL ( WINAPI * lpfnSHGetPathFromIDListW ) ( LPCITEMIDLIST pidl, LPWSTR pszPath );
+
+SHELL9X_API BOOL ( WINAPI * lpfnShellExecuteExW ) ( LPSHELLEXECUTEINFOW lpExecInfo );
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define CommandLineToArgvW lpfnCommandLineToArgvW
+#define SHBrowseForFolderW lpfnSHBrowseForFolderW
+#define SHGetPathFromIDListW lpfnSHGetPathFromIDListW
+
+#define ShellExecuteExW lpfnShellExecuteExW
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sal/inc/systools/win32/snprintf.h b/sal/inc/systools/win32/snprintf.h
new file mode 100644
index 000000000000..79441f032fee
--- /dev/null
+++ b/sal/inc/systools/win32/snprintf.h
@@ -0,0 +1,80 @@
+#ifndef _SNPRINTF_H
+#define _SNPRINTF_H
+
+#if !defined(_WIN32)
+#error ERROR: Only Win32 target supported!
+#endif
+
+/* Macros for Unicode/ANSI support like in TCHAR.H */
+
+#ifdef _UNICODE
+#define sntprintf snwprintf
+#define vsntprintf vsnwprintf
+#else
+#define sntprintf snprintf
+#define vsntprintf vsnprintf
+#endif
+
+/* Define needed types if they are not yet defined */
+
+#if 0
+# ifndef _INC_STDARG
+# include <stdarg.h>
+# endif
+#else
+# ifndef _VA_LIST_DEFINED
+ typedef char * va_list;
+# define _VA_LIST_DEFINED
+# endif
+#endif
+
+#if 0
+# ifndef _INC_WCHAR
+# include <wchar.h>
+# endif
+#else
+# ifndef _WCHAR_T_DEFINED
+ typedef unsigned short wchar_t;
+# define _WCHAR_T_DEFINED
+# endif
+#endif
+
+#ifndef _SNPRINTF_DLLIMPORT
+#define _SNPRINTF_DLLIMPORT __declspec( dllimport )
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Implementations of snprintf following the ISO/IEC 9899:1999 (ISO C99)
+ standard.
+ The difference compared to _snprintf is that the buffer always is zero
+ terminated (unless count is zero) and the return value is the number of
+ characters (not including terminating zero) that would have been written
+ even if the buffer wasn't large
+ enough to hold the string. */
+
+
+
+/* UNICODE version */
+_SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
+
+/* SBCS and MBCS version */
+_SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
+
+/* Conflict with STL_port inline implementation */
+#if 0
+/* UNICODE version */
+_SNPRINTF_DLLIMPORT int __cdecl vsnwprintf( wchar_t *buffer, size_t count, const wchar_t *format, va_list ap );
+
+/* SBCS and MBCS version */
+_SNPRINTF_DLLIMPORT int __cdecl vsnprintf( char *buffer, size_t count, const char *format, va_list ap );
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNPRINTF_H */
diff --git a/sal/inc/systools/win32/user9x.h b/sal/inc/systools/win32/user9x.h
new file mode 100644
index 000000000000..da30bf222836
--- /dev/null
+++ b/sal/inc/systools/win32/user9x.h
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifndef _WINDOWS_
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+//------------------------------------------------------------------------
+// undefine the macros defined in the winuser.h file in order to avoid
+// warnings because of multiple defines
+//------------------------------------------------------------------------
+
+#ifdef SendMessageW
+#undef SendMessageW
+#endif
+
+#ifdef CreateWindowExW
+#undef CreateWindowExW
+#endif
+
+#ifdef RegisterClassExW
+#undef RegisterClassExW
+#endif
+
+#ifdef UnregisterClassW
+#undef UnregisterClassW
+#endif
+
+#ifdef RegisterClipboardFormatW
+#undef RegisterClipboardFormatW
+#endif
+
+#ifdef GetClipboardFormatNameW
+#undef GetClipboardFormatNameW
+#endif
+
+#ifdef SetWindowTextW
+#undef SetWindowTextW
+#endif
+
+#ifdef GetWindowTextW
+#undef GetWindowTextW
+#endif
+
+#ifdef InsertMenuItemW
+#undef InsertMenuItemW
+#endif
+
+#ifndef DrawTextW
+#undef DrawTextW
+#endif
+
+//------------------------------------------------------------------------
+// defines
+//------------------------------------------------------------------------
+
+#define USER9X_API extern
+
+//------------------------------------------------------------------------
+// declare function pointers to the appropriate user32 functions
+//------------------------------------------------------------------------
+
+USER9X_API LRESULT ( WINAPI * lpfnSendMessageW) (
+ HWND hWnd, // handle to the destination window
+ UINT Msg, // message
+ WPARAM wParam, // first message parameter
+ LPARAM lParam // second message parameter
+);
+
+USER9X_API HWND ( WINAPI * lpfnCreateWindowExW ) (
+ DWORD dwExStyle, // extended window style
+ LPCWSTR lpClassName, // registered class name
+ LPCWSTR lpWindowName, // window name
+ DWORD dwStyle, // window style
+ int x, // horizontal position of window
+ int y, // vertical position of window
+ int nWidth, // window width
+ int nHeight, // window height
+ HWND hWndParent, // handle to parent or owner window
+ HMENU hMenu, // menu handle or child identifier
+ HINSTANCE hInstance, // handle to application instance
+ LPVOID lpParam // window-creation data
+);
+
+USER9X_API ATOM ( WINAPI * lpfnRegisterClassExW ) (
+ CONST WNDCLASSEXW* lpwcx // class data
+);
+
+USER9X_API BOOL ( WINAPI * lpfnUnregisterClassW ) (
+ LPCWSTR lpClassName, // class name
+ HINSTANCE hInstance // handle to application instance
+);
+
+USER9X_API UINT (WINAPI * lpfnRegisterClipboardFormatW) (
+ LPCWSTR lpszFormat // name of new format
+);
+
+USER9X_API int ( WINAPI * lpfnGetClipboardFormatNameW ) (
+ UINT format, // clipboard format to retrieve
+ LPWSTR lpszFormatName, // format name
+ int cchMaxCount // length of format name buffer
+);
+
+USER9X_API BOOL ( WINAPI * lpfnSetWindowTextW ) (
+ HWND hWnd,
+ LPCWSTR lpString
+);
+
+USER9X_API int ( WINAPI * lpfnGetWindowTextW ) (
+ HWND hWnd, // handle to the window or control
+ LPWSTR lpString, // text buffer
+ int nMaxCount // length of text buffer
+);
+
+USER9X_API BOOL ( WINAPI * lpfnInsertMenuItemW ) (
+ HMENU hMenu, // handle to menu
+ UINT uItem, // identifier or position
+ BOOL fByPosition, // meaning of uItem
+ LPCMENUITEMINFOW lpmii // menu item information
+);
+
+USER9X_API int ( WINAPI * lpfnDrawTextW ) (
+ HDC hDC, // handle to DC
+ LPCWSTR lpString, // text to draw
+ int nCount, // text length
+ LPRECT lpRect, // formatting dimensions
+ UINT uFormat // text-drawing options
+);
+
+USER9X_API BOOL ( WINAPI * lpfnDrawStateW ) (
+ HDC hdc, // handle to device context
+ HBRUSH hbr, // handle to brush
+ DRAWSTATEPROC lpOutputFunc, // callback function
+ LPARAM lData, // image information
+ WPARAM wData, // more image information
+ int x, // horizontal location
+ int y, // vertical location
+ int cx, // image width
+ int cy, // image height
+ UINT fuFlags // image type and state
+);
+
+//------------------------------------------------------------------------
+// redefine the above undefined macros so that the preprocessor replaces
+// all occurrences of this macros with our function pointer
+//------------------------------------------------------------------------
+
+#define SendMessageW lpfnSendMessageW
+#define CreateWindowExW lpfnCreateWindowExW
+#define RegisterClassExW lpfnRegisterClassExW
+#define UnregisterClassW lpfnUnregisterClassW
+#define RegisterClipboardFormatW lpfnRegisterClipboardFormatW
+#define GetClipboardFormatNameW lpfnGetClipboardFormatNameW
+#define SetWindowTextW lpfnSetWindowTextW
+#define GetWindowTextW lpfnGetWindowTextW
+#define InsertMenuItemW lpfnInsertMenuItemW
+#define DrawTextW lpfnDrawTextW
+#define DrawStateW lpfnDrawStateW
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/sal/inc/systools/win32/uwinapi.h b/sal/inc/systools/win32/uwinapi.h
new file mode 100644
index 000000000000..8c55ae6cf275
--- /dev/null
+++ b/sal/inc/systools/win32/uwinapi.h
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#pragma once
+
+#ifdef _UWINAPI_
+# define _KERNEL32_
+# define _USER32_
+# define _SHELL32_
+#endif
+
+#ifndef _WINDOWS_
+#ifdef _MSC_VER
+# pragma warning(push,1) /* disable warnings within system headers */
+#endif
+# include <windows.h>
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+#endif
+
+#ifdef __MINGW32__
+#include <basetyps.h>
+#ifdef _UWINAPI_
+#define WINBASEAPI
+#endif
+#endif
+
+/** GetUserDomain
+
+The GetUserDomain function retrieves the name of the NT domain the user is
+logged in.
+
+Parameters
+ @param lpBuffer
+ [out] Pointer to a buffer that receives a null-terminated string
+ containing the domain name.
+ @param nBufferSize
+ [in] Specifies the size, in TCHARs, of the buffer pointed to
+ by the lpBuffer parameter.
+
+
+Return Values
+ @return
+ If the function succeeds, the return value is the number of TCHARs stored
+ into the buffer pointed to by lpBuffer, not including the terminating
+ null character.
+
+ If the domain name can't be retrieved, the return value is zero.
+
+ If the buffer pointed to by lpBuffer is not large enough, the return value
+ is the buffer size, in TCHARs, required to hold the value string and its
+ terminating null character.
+
+Remarks
+ Windows 95/98/Me: If the user is not logged in onto a NT domain server
+ the name of the workgroup is returned.
+
+Requirements
+ Windows NT/2000/XP: Included in Windows NT 4 and later.
+ Windows 95/98/Me: Included in Windows 95 and later.
+ Header: Declared in Uwinapi.h; include Uwinapi.h.
+ Library: Use Uwinapi.lib.
+ Unicode: Implemented as Unicode and ANSI versions on Windows 95/98/Me/NT/2000/XP.
+
+See Also
+@see
+*/
+
+EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainA( LPSTR lpBuffer, DWORD nBuffserSize );
+EXTERN_C WINBASEAPI DWORD WINAPI GetUserDomainW( LPWSTR lpBuffer, DWORD nBuffserSize );
+
+#ifdef UNICODE
+#define GetUserDomain GetUserDomainW
+#else
+#define GetUserDomain GetUserDomainA
+#endif
+
+EXTERN_C WINBASEAPI DWORD WINAPI GetProcessId( HANDLE hProcess );
+
+/* macro that calculates the count of elements of a static array */
+
+#define elementsof(buf) (sizeof(buf) / sizeof((buf)[0]))
+
+#ifdef __cplusplus
+
+inline bool IsValidHandle(HANDLE handle)
+{
+ return handle != INVALID_HANDLE_VALUE && handle != NULL;
+}
+
+#else /* __cplusplus */
+
+#define IsValidHandle(Handle) ((DWORD)(Handle) + 1 > 1)
+
+#endif /* __cplusplus */
+