summaryrefslogtreecommitdiff
path: root/vos
diff options
context:
space:
mode:
Diffstat (limited to 'vos')
-rw-r--r--vos/docu/.html138
-rw-r--r--vos/inc/vos/conditn.hxx138
-rw-r--r--vos/inc/vos/connectn.hxx116
-rw-r--r--vos/inc/vos/diagnose.hxx56
-rw-r--r--vos/inc/vos/execabl.hxx152
-rw-r--r--vos/inc/vos/istream.hxx73
-rw-r--r--vos/inc/vos/macros.hxx159
-rw-r--r--vos/inc/vos/module.hxx79
-rw-r--r--vos/inc/vos/mutex.hxx183
-rw-r--r--vos/inc/vos/object.hxx193
-rw-r--r--vos/inc/vos/pipe.hxx259
-rw-r--r--vos/inc/vos/process.hxx319
-rw-r--r--vos/inc/vos/ref.hxx183
-rw-r--r--vos/inc/vos/ref.inl192
-rw-r--r--vos/inc/vos/refernce.hxx109
-rw-r--r--vos/inc/vos/refobj.hxx89
-rw-r--r--vos/inc/vos/refobj.inl86
-rw-r--r--vos/inc/vos/runnable.hxx67
-rw-r--r--vos/inc/vos/security.hxx121
-rw-r--r--vos/inc/vos/signal.hxx98
-rw-r--r--vos/inc/vos/socket.hxx1130
-rw-r--r--vos/inc/vos/stream.hxx285
-rw-r--r--vos/inc/vos/thread.hxx235
-rw-r--r--vos/inc/vos/timer.hxx200
-rw-r--r--vos/inc/vos/types.hxx40
-rw-r--r--vos/inc/vos/xception.hxx79
-rw-r--r--vos/prj/build.lst6
-rw-r--r--vos/prj/d.lst15
-rw-r--r--vos/source/conditn.cxx76
-rw-r--r--vos/source/dllentry.cxx62
-rw-r--r--vos/source/makefile.mk79
-rw-r--r--vos/source/module.cxx87
-rw-r--r--vos/source/mutex.cxx72
-rw-r--r--vos/source/object.cxx165
-rw-r--r--vos/source/pipe.cxx416
-rw-r--r--vos/source/process.cxx525
-rw-r--r--vos/source/refernce.cxx66
-rw-r--r--vos/source/security.cxx116
-rw-r--r--vos/source/signal.cxx64
-rw-r--r--vos/source/socket.cxx1723
-rw-r--r--vos/source/stream.cxx115
-rw-r--r--vos/source/thread.cxx240
-rw-r--r--vos/source/timer.cxx501
-rw-r--r--vos/source/xception.cxx43
-rw-r--r--vos/util/libvos1C50.so.mapfile274
-rw-r--r--vos/util/makefile.mk85
-rw-r--r--vos/version.mk40
47 files changed, 9549 insertions, 0 deletions
diff --git a/vos/docu/.html b/vos/docu/.html
new file mode 100644
index 000000000000..bce575d49d92
--- /dev/null
+++ b/vos/docu/.html
@@ -0,0 +1,138 @@
+<html><head><TITLE></TITLE></head>
+<body>
+<H2><A HREF ="#DOC.DOCU" > <IMG BORDER=0 SRC=down.gif></A> </H2>
+<TABLE>
+<TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IAcceptHandler.html><B>IAcceptHandler</B></A> <br>
+<I>Interface IAcceptHandler
+Overload onConnection() to handle a connected socket</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IAcceptHandlerFactory.html><B>IAcceptHandlerFactory</B></A> <br>
+<I>Interface IAcceptHandlerFactory
+Creates objects with IAcceptHandler interface</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OAcceptor.html><B>OAcceptor</B></A> <br>
+<I>Starts a thread where incoming connections are accepted</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OByteArray.html><B>OByteArray</B></A> <br>
+<I>Array of bytes</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OByteStream.html><B>OByteStream</B></A> <br>
+<I>Wraps a byte-stream around a byte array</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=ICondition.html><B>ICondition</B></A> <br>
+<I>ICondition
+
+Interface for a thread-spanning condition</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OCondition.html><B>OCondition</B></A> <br>
+<I>OCondition
+
+Implements the ICondition interface</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IConnectHandler.html><B>IConnectHandler</B></A> <br>
+<I>Interface IConnectHandler</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OConnector.html><B>OConnector</B></A> <br>
+<I>Delegates a connected socket to an IConnectHandler object</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OException.html><B>OException</B></A> <br>
+<I>Base class for exceptions</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OSimpleException.html><B>OSimpleException</B></A> <br>
+<I></I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IExecutable.html><B>IExecutable</B></A> <br>
+<I>IExecutable
+
+The IExecutable-interface is to be understood as wrapper around
+your application-code, which allows it to be executed asynchronously</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OExecutable.html><B>OExecutable</B></A> <br>
+<I>OExecutable
+added default impl</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OFiberingServer.html><B>OFiberingServer</B></A> <br>
+<I>OFiberingServer
+
+Depends on cooperative executing IExecutable-Objects</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OFuture.html><B>OFuture</B></A> <br>
+<I>OFuture, OFutureRef
+
+A future represents the result of an asynchronous operation</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OFutureRef.html><B>OFutureRef</B></A> <br>
+<I>OFutureRef
+
+</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IStream.html><B>IStream</B></A> <br>
+<I>Interface for a stream of data, on that you can read and write blocks of bytes</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IMutex.html><B>IMutex</B></A> <br>
+<I>IMutex interface
+
+</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OThreadMutex.html><B>OThreadMutex</B></A> <br>
+<I>OThreadMutex
+
+</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OGuard.html><B>OGuard</B></A> <br>
+<I>OGuard
+
+</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OObject.html><B>OObject</B></A> <br>
+<I>OObject
+common base class for all framework classes</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OCreateParam.html><B>OCreateParam</B></A> <br>
+<I>
+Basic class information</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OClassInfo.html><B>OClassInfo</B></A> <br>
+<I></I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IObserver.html><B>IObserver</B></A> <br>
+<I>IObserver
+
+</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IObserved.html><B>IObserved</B></A> <br>
+<I>IObserved
+
+Just an idea</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OObserver.html><B>OObserver</B></A> <br>
+<I>OObserver
+
+add default-implementation of refence-counting behaviour to IObserver-Interface
+
+</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=ORef.html><B>ORef</B></A> <br>
+<I>
+ORef<T>
+
+template type to implement handle/body behaviour
+with reference-counting</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IReferenceCounter.html><B>IReferenceCounter</B></A> <br>
+<I>Interface for refernce-counting</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IRunnable.html><B>IRunnable</B></A> <br>
+<I>IRunnable
+
+The IRunnable-interface is to be understood as wrapper around
+your application-code, which allows it to be executed asynchronously</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OExecutableThread.html><B>OExecutableThread</B></A> <br>
+<I>OExecutableThread
+
+A thread used to execute an IExecutable-Object</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OSemaphore.html><B>OSemaphore</B></A> <br>
+<I>Counting semaphore (unnamed, because thread-local)</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=ISocketTypes.html><B>ISocketTypes</B></A> <br>
+<I>Base data types</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=ISocketAddr.html><B>ISocketAddr</B></A> <br>
+<I>Base class for socket addresses</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OInetSocketAddr.html><B>OInetSocketAddr</B></A> <br>
+<I>Represents an internet-address</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OIpxSocketAddr.html><B>OIpxSocketAddr</B></A> <br>
+<I>Represents an IPX/SPX address</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OSocket.html><B>OSocket</B></A> <br>
+<I>Represents a socket</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OStreamSocket.html><B>OStreamSocket</B></A> <br>
+<I>A socket to send or receive a stream of data</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OAcceptorSocket.html><B>OAcceptorSocket</B></A> <br>
+<I>A socket to accept incoming connections</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OConnectorSocket.html><B>OConnectorSocket</B></A> <br>
+<I>A socket to initiate a conenction</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=ODatagramSocket.html><B>ODatagramSocket</B></A> <br>
+<I>A connectionless socket to send and receive datagrams</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=IPositionableStream.html><B>IPositionableStream</B></A> <br>
+<I>Adds seeking capabilities to IStream</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OStream.html><B>OStream</B></A> <br>
+<I>Implements IPositionableStream</I>
+</TD></TR><TR><TD VALIGN=top><IMG BORDER=0 SRC=icon1.gif> </TD><TD><A HREF=OString.html><B>OString</B></A> <br>
+<I>A string class</I>
+</TD></TR>
+</TABLE>
+<A NAME="DOC.DOCU">
+<DL></DL><P><I><A HREF="aindex.html"> alphabetic index</A></I> <I><A HREF="HIER.html"> hierarchy of classes</A></I><P></BODY><hr>
+<A HREF="http://www.zib.de/Visual/software/doc++/index.html"><IMG BORDER=0 ALIGN=RIGHT SRC=logo.gif></A>
+<P Align=Center><I>this page has been generated automatically by doc++
+<P Align=Center>(c)opyright by <A HREF="http://www.zib.de/zoeckler/"> Malte Z&oumlckler</A>, <A HREF="mailto:wunderling@zib.de"> Roland Wunderling </A><br>contact: <A HREF="mailto:doc++@zib.de"> doc++@zib.de </a> \ No newline at end of file
diff --git a/vos/inc/vos/conditn.hxx b/vos/inc/vos/conditn.hxx
new file mode 100644
index 000000000000..884ef85c91d6
--- /dev/null
+++ b/vos/inc/vos/conditn.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * 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 _VOS_CONDITN_HXX_
+#define _VOS_CONDITN_HXX_
+
+#ifndef _OSL_CONDITN_H_
+# include <osl/conditn.h>
+#endif
+#include <osl/time.h>
+# include <vos/object.hxx>
+
+namespace vos
+{
+
+/** ICondition
+
+ Interface for a thread-spanning condition. If a condition-object
+ is created, its initial condition is False. You can check the
+ condition nonblocking with "check()" or wait for it to become set
+ with "wait()". The methods "set()" and "reset()" are used to change
+ the conditions state.
+
+ @author Bernd Hofner
+ @version 1.0
+*/
+class ICondition
+{
+public:
+
+ ICondition() { }
+ virtual ~ICondition() { }
+
+
+
+ enum TResult
+ {
+ result_ok = osl_cond_result_ok,
+ result_error = osl_cond_result_error,
+ result_timeout = osl_cond_result_timeout
+ };
+
+ /** set condition to True =>
+ wait() will not block, check() returns True
+ */
+ virtual void SAL_CALL set()= 0;
+
+ /** set condition to False =>
+ wait() will block, check() returns False
+ */
+ virtual void SAL_CALL reset()= 0;
+
+ /** Blocks if condition is not set<BR>
+ If condition has been destroyed prematurely, wait() will
+ return with False.
+ */
+ virtual TResult SAL_CALL wait(const TimeValue* pTimeout = 0)= 0;
+
+ /** True: condition is set <BR>
+ False: condition is not set <BR>
+ does not block
+ */
+ virtual sal_Bool SAL_CALL check()= 0;
+};
+
+
+/** OCondition
+
+ Implements the ICondition interface.
+
+ @author Bernd Hofner
+ @version 1.0
+
+*/
+class OCondition : public OObject, public ICondition
+{
+
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OCondition, vos));
+
+public:
+
+ /// initial state of condition is not set
+ OCondition();
+ virtual ~OCondition();
+
+ /// set condition to True => wait() will not block, check() returns True
+ virtual void SAL_CALL set();
+
+ /// set condition to False => wait() will block, check() returns False
+ virtual void SAL_CALL reset();
+
+ /** Blocks if condition is not set<BR>
+ If condition has been destroyed prematurely, wait() will
+ return with False.
+ */
+ TResult SAL_CALL wait(const TimeValue* pTimeout = 0);
+
+ /** True: condition is set <BR>
+ False: condition is not set <BR>
+ does not block
+ */
+ virtual sal_Bool SAL_CALL check();
+
+protected:
+
+ oslCondition m_Condition;
+
+};
+
+}
+
+#endif // _VOS_CONDITN_HXX_
+
diff --git a/vos/inc/vos/connectn.hxx b/vos/inc/vos/connectn.hxx
new file mode 100644
index 000000000000..803ab56b92f0
--- /dev/null
+++ b/vos/inc/vos/connectn.hxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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 _VOS_CONNECTN_HXX_
+#define _VOS_CONNECTN_HXX_
+
+# include <vos/ref.hxx>
+# include <rtl/ustring.hxx>
+
+namespace vos
+{
+//---------------------------------------------------------------------------
+/** abstract connection class
+ */
+
+class IConnection: public ::vos::IReference
+{
+public:
+
+ //---------------------------------------------------------------------------
+ /** reads the specified amount of bytes from the stream. The call will block
+ until nBytesToRead bytes are available.
+
+ @param pData
+ pointer to the buffer to fill.
+
+ @param nBytesToRead
+ the number of bytes to read.
+
+ @returns
+ the number of bytes read;
+ */
+
+ virtual sal_Int32 SAL_CALL read( sal_Int8* pData, sal_Int32 nBytesToRead ) = 0;
+
+ //---------------------------------------------------------------------------
+ /** tries to read the specified amount of bytes from the stream.
+
+ @param pData
+ pointer to the buffer to fill.
+
+ @param nBytesToRead
+ the maximum number of bytes to read.
+
+ @returns
+ the number of bytes read;
+ */
+
+ virtual sal_Int32 SAL_CALL readSomeBytes( sal_Int8* pData, sal_Int32 nBytesToRead ) = 0;
+
+ //---------------------------------------------------------------------------
+ /** writes the specified number of bytes to the stream.
+
+ @param pData
+ pointer to the buffer to read from.
+
+ @param nBytesToWrite
+ the number of bytes to write.
+ */
+
+ virtual sal_Int32 SAL_CALL write( const sal_Int8* pData , sal_Int32 nBytesToWrite ) = 0;
+
+ //---------------------------------------------------------------------------
+ /** flushes all output data to the stream.
+ */
+
+ virtual sal_Int32 SAL_CALL flush() = 0;
+
+ //---------------------------------------------------------------------------
+ /** closes the stream of the connection.
+
+ NOTE: implementation must be able to handle more than one close calls.
+ */
+
+ virtual sal_Int32 SAL_CALL close() = 0;
+
+ //---------------------------------------------------------------------------
+ /** gets the source address
+ */
+ virtual ::rtl::OUString SAL_CALL getSource() = 0;
+
+ //---------------------------------------------------------------------------
+ /** gets the destination address
+ */
+ virtual ::rtl::OUString SAL_CALL getDestination() = 0;
+};
+
+}
+
+#endif // _VOS_CONNECTN_HXX_
+
diff --git a/vos/inc/vos/diagnose.hxx b/vos/inc/vos/diagnose.hxx
new file mode 100644
index 000000000000..a037c9517ec4
--- /dev/null
+++ b/vos/inc/vos/diagnose.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * 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 _VOS_DIAGNOSE_H_
+#define _VOS_DIAGNOSE_H_
+
+
+#ifndef _OSL_DIAGNOSE_H_
+ #include <osl/diagnose.h>
+#endif
+
+
+/*
+ Diagnostic support
+*/
+
+#define VOS_THIS_FILE __FILE__
+
+#define VOS_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s)
+#define VOS_TRACE _OSL_TRACE
+#define VOS_ASSERT(c) _OSL_ASSERT(c, VOS_THIS_FILE, __LINE__)
+#define VOS_VERIFY(c) OSL_VERIFY(c)
+#define VOS_ENSHURE(c, m) _OSL_ENSURE(c, VOS_THIS_FILE, __LINE__, m)
+#define VOS_ENSURE(c, m) _OSL_ENSURE(c, VOS_THIS_FILE, __LINE__, m)
+
+#define VOS_PRECOND(c, m) VOS_ENSHURE(c, m)
+#define VOS_POSTCOND(c, m) VOS_ENSHURE(c, m)
+
+#endif /* _VOS_DIAGNOSE_H_ */
+
+
diff --git a/vos/inc/vos/execabl.hxx b/vos/inc/vos/execabl.hxx
new file mode 100644
index 000000000000..04e0ef837b02
--- /dev/null
+++ b/vos/inc/vos/execabl.hxx
@@ -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 _VOS_EXECABL_HXX_
+#define _VOS_EXECABL_HXX_
+
+# include <vos/types.hxx>
+# include <vos/refernce.hxx>
+
+namespace vos
+{
+
+
+/** IExecutable
+
+ The IExecutable-interface is to be understood as wrapper around
+ your application-code, which allows it to be executed asynchronously.
+
+ Wether you want real asynchronous behaviour or just pseudo-multitasking
+ depends on which kind of execution-service you use to execute your executable.
+
+ (E.g. Threadpool/Fiberpool)
+
+ @author Bernd Hofner
+ @version 0.1
+*/
+
+class IExecutable : public NAMESPACE_VOS(IReference)
+{
+public:
+
+ /** Overload to implement your functionality.
+ Return True, if you want "execute()" to be called again.
+ */
+ virtual sal_Bool SAL_CALL execute()= 0;
+
+
+ /** If you use blocking calls within your execute-function,
+ you should provide here a means to unblock cleanly.
+ @Return False if you are not able to unblock the
+ thread.
+
+ */
+ virtual sal_Bool SAL_CALL unblock()= 0;
+
+ /**
+ STL demands this operators if you want to place
+ IExecutables per value in collections.
+ */
+ virtual sal_Bool SAL_CALL operator<(const IExecutable&) const= 0;
+ virtual sal_Bool SAL_CALL operator>(const IExecutable&) const= 0;
+ virtual sal_Bool SAL_CALL operator==(const IExecutable&) const= 0;
+ virtual sal_Bool SAL_CALL operator!=(const IExecutable&) const= 0;
+};
+
+
+/** OExecutable
+ added default impl. of IReferenceCounter
+*/
+class OExecutable : public NAMESPACE_VOS(IExecutable),
+ public NAMESPACE_VOS(OReference)
+
+{
+public:
+
+ virtual ~OExecutable()
+ {
+ }
+
+ /*
+ Since the dominance of the OReferenceCounter impl.
+ of the IReferenceCounter is not granted, delegate
+ the methods to this branch of the diamond-shaped
+ inheritance tree.
+ */
+
+ virtual RefCount SAL_CALL acquire()
+ {
+ return OReference::acquire();
+ }
+ virtual RefCount SAL_CALL release()
+ {
+ return OReference::release();
+ }
+ virtual RefCount SAL_CALL referenced() const
+ {
+ return OReference::referenced();
+ }
+
+
+ /** Default implementation of unblock does nothing.
+ */
+ virtual sal_Bool SAL_CALL unblock() { return sal_True; }
+
+
+ /**
+ STL demands this operators if you want to place
+ IExecutables per value in collections.
+ Use a default implementation of the comparison-operators
+ here without a correct semantic.
+ */
+ virtual sal_Bool SAL_CALL operator<(const IExecutable&) const
+ {
+ return sal_False;
+ }
+
+ virtual sal_Bool SAL_CALL operator>(const IExecutable&) const
+ {
+ return sal_False;
+ }
+
+ virtual sal_Bool SAL_CALL operator==(const IExecutable&) const
+ {
+ return sal_True;
+ }
+
+ virtual sal_Bool SAL_CALL operator!=(const IExecutable&) const
+ {
+ return sal_False;
+ }
+};
+
+}
+
+
+#endif // _VOS_EXECABL_HXX_
+
diff --git a/vos/inc/vos/istream.hxx b/vos/inc/vos/istream.hxx
new file mode 100644
index 000000000000..9aacf2829226
--- /dev/null
+++ b/vos/inc/vos/istream.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * 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 _VOS_ISTREAM_HXX_
+#define _VOS_ISTREAM_HXX_
+
+#include "sal/types.h"
+# include <vos/types.hxx>
+
+namespace vos
+{
+
+/** Interface for a stream of data, on that you can read and write blocks of bytes.
+*/
+class IStream
+{
+public:
+
+ IStream() { }
+ virtual ~IStream() { }
+
+
+ /** Retrieve n bytes from the stream and copy them into pBuffer.
+ @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
+ */
+ virtual sal_Int32 SAL_CALL read(void* pBuffer,
+ sal_uInt32 n) const= 0;
+
+ /** Write n bytes from pBuffer to the stream.
+ @param pBuffer contains the data to be written.
+ @param n the number of bytes to write.
+ @return the number of written bytes
+ */
+ virtual sal_Int32 SAL_CALL write(const void* pBuffer,
+ sal_uInt32 n)= 0;
+
+ /** Checks if stream is closed for further reading.
+ @return True is stream has ended (e.g. was closed).
+ */
+ virtual sal_Bool SAL_CALL isEof() const = 0;
+};
+
+}
+
+#endif // _VOS_ISTREAM_HXX_
+
diff --git a/vos/inc/vos/macros.hxx b/vos/inc/vos/macros.hxx
new file mode 100644
index 000000000000..ca1b750d67f4
--- /dev/null
+++ b/vos/inc/vos/macros.hxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * 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 _VOS_MACROS_HXX_
+#define _VOS_MACROS_HXX_
+
+
+#include <osl/endian.h>
+
+// *********************************************************************
+// Macro definitions
+
+#ifndef VOS_CAST
+# define VOS_CAST(type,value) (*((type*)&(value)))
+#endif
+
+#ifndef VOS_UNUSED
+# define VOS_UNUSED(x) (x=x)
+#endif
+
+#ifndef VOS_FOREVER
+# define VOS_FOREVER for(;;)
+#endif
+
+#ifndef VOS_MAX
+# define VOS_MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef VOS_MIN
+# define VOS_MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef VOS_ABS
+# define VOS_ABS(a) (((a) < 0) ? (-(a)) : (a))
+#endif
+#ifndef VOS_SIGN
+# define VOS_SIGN(a) ( ((a) < 0) ? (-1) : (((a) > 0) ? (1) : (0)) )
+#endif
+
+#ifndef VOS_BOUND
+# define VOS_BOUND(x,l,h) ((x) <= (l) ? (l) : ((x) >= (h) ? (h) : (x)))
+#endif
+
+#ifndef VOS_SWAP
+# define VOS_SWAP(a,b) ((a) ^= (b) ^= (a) ^= (b))
+#endif
+
+#ifndef VOS_BYTEBOUND
+# define VOS_BYTEBOUND(a) (((a) + 7) / 8)
+#endif
+
+#ifndef VOS_WORDBOUND
+# define VOS_WORDBOUND(a) ((((a) + 15) / 16) * 2)
+#endif
+
+#ifndef VOS_DWORDBOUND
+# define VOS_DWORDBOUND(a) ((((a) + 31) / 32) * 4)
+#endif
+
+#ifndef VOS_MAKEDWORD
+# define VOS_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
+#endif
+#ifndef VOS_LOWORD
+# define VOS_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
+#endif
+#ifndef VOS_HIWORD
+# define VOS_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
+#endif
+#ifndef VOS_MAKEWORD
+# define VOS_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8))
+#endif
+#ifndef VOS_LOBYTE
+# define VOS_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
+#endif
+#ifndef VOS_HIBYTE
+# define VOS_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
+#endif
+#ifndef VOS_MAKEBYTE
+# define VOS_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
+#endif
+#ifndef VOS_LONIBBLE
+# define VOS_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
+#endif
+#ifndef VOS_HINIBBLE
+# define VOS_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
+#endif
+
+#ifndef VOS_SWAPWORD
+# define VOS_SWAPWORD(w) VOS_MAKEWORD(VOS_HIBYTE(w),VOS_LOBYTE(w))
+#endif
+#ifndef VOS_SWAPDWORD
+# define VOS_SWAPDWORD(d) VOS_MAKEDWORD(VOS_SWAPWORD(VOS_HIWORD(d)),VOS_SWAPWORD(VOS_LOWORD(d)))
+#endif
+
+#ifdef OSL_BIGENDIAN
+#ifndef VOS_NETWORD
+# define VOS_NETWORD(w) (sal_uInt16)(w)
+#endif
+#ifndef VOS_NETDWORD
+# define VOS_NETDWORD(d) (sal_uInt32)(d)
+#endif
+#else // OSL_LITENDIAN
+#ifndef VOS_NETWORD
+# define VOS_NETWORD(w) VOS_MAKEWORD(VOS_HIBYTE(w),VOS_LOBYTE(w))
+#endif
+#ifndef VOS_NETDWORD
+# define VOS_NETDWORD(d) VOS_MAKEDWORD(VOS_NETWORD(VOS_HIWORD(d)),VOS_NETWORD(VOS_LOWORD(d)))
+#endif
+#endif // OSL_BIGENDIAN
+
+#ifdef _OSL_MEMSEG
+# define VOS_MAKEPTR(base, off) ((void _far *)VOS_MAKEDWORD((off), (base)))
+# define VOS_BASEOF(ptr) VOS_HIWORD(ptr)
+# define VOS_OFSTOF(ptr) VOS_LOWORD(ptr)
+#else
+# define VOS_MAKEPTR(base, off) ((void *)((base) + (off)))
+# define VOS_BASEOF(ptr) (ptr)
+# define VOS_OFSTOF(ptr) 0
+#endif
+
+#ifndef VOS_FIELDOFFSET
+# define VOS_FIELDOFFSET(type, field) ((sal_Int32)(&((type *)1)->field) - 1)
+#endif
+
+// def. for arbitrary namespace
+#define VOS_NAMESPACE(class_name, name_space) name_space::class_name
+
+// sal_Int16 def. for namespace vos
+#define NAMESPACE_VOS(class_name) vos::class_name
+
+// sal_Int16 def. for namespace std
+#define NAMESPACE_STD(class_name) std::class_name
+
+#endif //_VOS_MACROS_HXX_
+
diff --git a/vos/inc/vos/module.hxx b/vos/inc/vos/module.hxx
new file mode 100644
index 000000000000..d70cc101e4fc
--- /dev/null
+++ b/vos/inc/vos/module.hxx
@@ -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 _VOS_MODULE_HXX_
+#define _VOS_MODULE_HXX_
+
+# include <vos/object.hxx>
+# include <rtl/ustring.hxx>
+# include <osl/module.h>
+
+namespace vos
+{
+
+class OModule : public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OModule, vos));
+
+public:
+
+ /// default c'tor
+ OModule();
+
+ /// this c'tor is a combination of the default c'tor and load()
+ OModule(const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT);
+ virtual ~OModule();
+
+ /// loads the specified module
+ sal_Bool SAL_CALL load(const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT);
+
+ /// unloads the currently loaded module
+ void SAL_CALL unload();
+
+ /// returns sal_True, if a module is loaded, sal_False otherwise
+ sal_Bool SAL_CALL isLoaded();
+
+#if 0
+ // not implemented yet
+ // returns the name of the currently loaded module or an empty string if none.
+ ::rtl::OUString SAL_CALL getModuleName();
+#endif
+
+ /// returns a pointer to the specified Symbol if found, NULL otherwise
+ void* SAL_CALL getSymbol(const ::rtl::OUString& strSymbolName);
+
+protected:
+
+ oslModule m_Module;
+};
+
+}
+
+#endif
+
+
diff --git a/vos/inc/vos/mutex.hxx b/vos/inc/vos/mutex.hxx
new file mode 100644
index 000000000000..6336e23bd0f7
--- /dev/null
+++ b/vos/inc/vos/mutex.hxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * 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 _VOS_MUTEX_HXX_
+#define _VOS_MUTEX_HXX_
+
+# include <vos/types.hxx>
+# include <vos/object.hxx>
+# include <osl/mutex.h>
+
+namespace vos
+{
+
+
+/** IMutex interface
+
+ @author Bernd Hofner
+ @version 1.0
+*/
+
+class IMutex
+{
+public:
+
+ /// Blocks if Mutex is already in use
+ virtual void SAL_CALL acquire()= 0;
+
+ // Tries to get the mutex without blocking.
+ virtual sal_Bool SAL_CALL tryToAcquire()= 0;
+
+ /// releases the mutex.
+ virtual void SAL_CALL release()= 0;
+
+protected:
+ IMutex() { }
+ virtual ~IMutex() { }
+
+};
+
+// ----------------------------------------------------------
+
+/** OMutex
+
+ @author Bernd Hofner
+ @version 1.0
+*/
+
+class OMutex : public OObject, public IMutex
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OMutex, vos));
+
+public:
+ static IMutex& SAL_CALL getGlobalMutex();
+
+ /// Creates mutex
+ OMutex();
+ /// Implicitly destroys mutex
+ virtual ~OMutex();
+
+ /// Blocks if Mutex is already in use
+ virtual void SAL_CALL acquire();
+
+ /** Tries to get the mutex without blocking.
+ @return True if mutex could be obtained, otherwise False
+ */
+ virtual sal_Bool SAL_CALL tryToAcquire();
+
+ /// releases the mutex.
+ virtual void SAL_CALL release();
+
+protected:
+ oslMutex m_Impl;
+
+private:
+ // disable copy/assignment
+ OMutex(const OMutex&);
+ OMutex& SAL_CALL operator= (const OMutex&);
+};
+
+// *********************************************************************************
+
+/** OGuard
+
+ @author Bernd Hofner
+ @version 1.0
+*/
+
+class OGuard
+{
+ OGuard( const OGuard& );
+ const OGuard& operator = ( const OGuard& );
+public:
+ /** Acquires mutex
+ @param pMutex pointer to mutex which is to be acquired */
+ OGuard(IMutex* pMutex)
+ : m_rMutex( *pMutex )
+ { // only for compatible reasons
+ m_rMutex.acquire();
+ }
+ OGuard(IMutex & rMutex)
+ : m_rMutex( rMutex )
+ {
+ m_rMutex.acquire();
+ }
+
+ /** Releases mutex. */
+ virtual ~OGuard()
+ {
+ m_rMutex.release();
+ }
+
+protected:
+ IMutex& m_rMutex;
+};
+
+/** A guard that can release the mutex with the clear method.
+
+ @author Bernd Hofner
+ @version 1.0
+*/
+class OClearableGuard
+{
+ OClearableGuard( const OClearableGuard& );
+ const OClearableGuard& operator = ( const OClearableGuard& );
+public:
+ /** Acquires mutex
+ @param pMutex pointer to mutex which is to be acquired */
+ OClearableGuard(IMutex & rMutex)
+ : m_pMutex( &rMutex )
+ {
+ m_pMutex->acquire();
+ }
+
+ /** Releases mutex. */
+ virtual ~OClearableGuard()
+ {
+ if( m_pMutex )
+ m_pMutex->release();
+ }
+
+ /** Releases mutex. */
+ void SAL_CALL clear()
+ {
+ if( m_pMutex )
+ {
+ m_pMutex->release();
+ m_pMutex = NULL;
+ }
+ }
+protected:
+ IMutex* m_pMutex;
+};
+
+}
+
+
+#endif //_VOS_MUTEX_HXX_
+
+
diff --git a/vos/inc/vos/object.hxx b/vos/inc/vos/object.hxx
new file mode 100644
index 000000000000..6108280cf382
--- /dev/null
+++ b/vos/inc/vos/object.hxx
@@ -0,0 +1,193 @@
+/*************************************************************************
+ *
+ * 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 _VOS_OBJECT_HXX_
+#define _VOS_OBJECT_HXX_
+
+# include <vos/types.hxx>
+# include <vos/macros.hxx>
+
+namespace vos
+{
+
+// ***************************************
+// Object super class
+
+struct OClassInfo;
+struct OCreateParam;
+
+/** OObject
+ common base class for all framework classes. Used for memory-management
+ and runtime type-info.
+*/
+class OObject
+{
+public:
+
+ ///
+ OObject();
+
+ ///
+ OObject(const OCreateParam& rParam);
+
+ // Disable the copy constructor and assignment by default so you will get
+ // compiler errors instead of unexpected behaviour if you pass objects
+ // by value or assign objects.
+private:
+ OObject(const OObject& objectSrc); // no implementation
+ void SAL_CALL operator=(const OObject& objectSrc); // no implementation
+
+public:
+ virtual ~OObject();
+
+public:
+
+ /** Define private new and delete operator because of compiler bug,
+ when allocating and deleteing a exported class
+ */
+ void* SAL_CALL operator new(size_t size);
+ void* SAL_CALL operator new(size_t size, void* p);
+
+ void SAL_CALL operator delete(void* p);
+
+// Attributes
+public:
+
+ ///
+ virtual const OClassInfo& SAL_CALL getClassInfo() const;
+
+ ///
+ sal_Bool SAL_CALL isKindOf(const OClassInfo& rClass) const;
+
+// Implementation
+public:
+ static const OClassInfo& SAL_CALL classInfo();
+
+public:
+ static OClassInfo __ClassInfo__;
+};
+
+
+/**
+ Basic class information
+*/
+struct OCreateParam
+{
+ sal_uInt32 m_Size;
+ void* m_pParam;
+
+ ///
+ OCreateParam(void *pParam)
+ {
+ m_Size = sizeof(OCreateParam);
+ m_pParam = pParam;
+ }
+};
+
+/**
+*/
+struct OClassInfo
+{
+ ///
+ const sal_Char *m_pClassName;
+ ///
+ sal_Int32 m_nObjectSize;
+ /// schema number of the loaded class
+ sal_uInt32 m_wSchema;
+
+ ///
+ OObject* (SAL_CALL * m_pfnCreateObject)(const OCreateParam&); // NULL => abstract class
+
+ /// linked list of registered classes
+ const OClassInfo* m_pBaseClass;
+ /// linked list of registered classes
+ const OClassInfo* m_pNextClass;
+
+ ///
+ OObject* SAL_CALL createObject(const OCreateParam& rParam) const;
+
+ ///
+ sal_Bool SAL_CALL isDerivedFrom(const OClassInfo& rBaseClass) const;
+
+ ///
+ static const OClassInfo* SAL_CALL getClassInfo(const sal_Char* pClassName);
+
+ ///
+ OClassInfo(const sal_Char *pClassName, sal_Int32 ObjectSize,
+ const OClassInfo* pBaseClass = NULL, sal_uInt32 Schema = (sal_uInt32)-1,
+ OObject* (SAL_CALL * fnCreateObject)(const OCreateParam&) = NULL);
+};
+
+// *****************************************************************
+// Helper macros for declaring OClassInfo data
+
+
+#define VOS_STRINGIZE(name) #name
+
+#define VOS_CLASSNAME(class_name, domain_name) VOS_STRINGIZE(domain_name.class_name)
+
+#define VOS_CLASSINFO(class_name) (class_name::classInfo())
+
+// generate static object constructor for class registration
+struct VOS_CLASSINIT
+{ VOS_CLASSINIT(VOS_NAMESPACE(OClassInfo, vos)* pNewClass); };
+
+#define VOS_CLASSDATA(class_spec, class_name, base_class_name, wSchema, constructor) \
+ VOS_NAMESPACE(OClassInfo, vos) class_name::__ClassInfo__(class_spec, \
+ sizeof(class_name), &VOS_CLASSINFO(base_class_name), wSchema, constructor); \
+ const VOS_NAMESPACE(VOS_CLASSINIT, vos) class_name::__ClassInit__(&class_name::__ClassInfo__); \
+ const VOS_NAMESPACE(OClassInfo, vos)& SAL_CALL class_name::getClassInfo() const \
+ { return (VOS_CLASSINFO(class_name)); } \
+ const VOS_NAMESPACE(OClassInfo, vos)& SAL_CALL class_name::classInfo() \
+ { return (__ClassInfo__); }
+
+#define VOS_DECLARE_CLASSINFO(class_name) \
+public: \
+ static const VOS_NAMESPACE(VOS_CLASSINIT, vos) __ClassInit__; \
+ static VOS_NAMESPACE(OClassInfo, vos) __ClassInfo__; \
+public: \
+ virtual const VOS_NAMESPACE(OClassInfo, vos)& SAL_CALL getClassInfo() const; \
+ static const VOS_NAMESPACE(OClassInfo, vos)& SAL_CALL classInfo()
+
+#define VOS_IMPLEMENT_CLASSINFO(class_spec, class_name, base_class_name, wSchema) \
+ VOS_CLASSDATA(class_spec, class_name, base_class_name, wSchema, NULL)
+
+#define VOS_DECLARE_CLASSTYPE(class_name) \
+ VOS_DECLARE_CLASSINFO(class_name); \
+public: \
+ static VOS_NAMESPACE(OObject, vos)* SAL_CALL createObject(const VOS_NAMESPACE(OCreateParam, vos)& rParam);
+
+#define VOS_IMPLEMENT_CLASSTYPE(class_spec, class_name, base_class_name, wSchema) \
+ VOS_CLASSDATA(class_spec, class_name, base_class_name, wSchema, class_name::createObject) \
+ VOS_NAMESPACE(OObject, vos)* class_name::createObject(const VOS_NAMESPACE(OCreateParam, vos)& rParam) \
+ { return new class_name(rParam); }
+
+}
+
+#endif // _VOS_OBJECT_HXX_
+
diff --git a/vos/inc/vos/pipe.hxx b/vos/inc/vos/pipe.hxx
new file mode 100644
index 000000000000..e9b1145a36ee
--- /dev/null
+++ b/vos/inc/vos/pipe.hxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * 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 _VOS_PIPE_HXX_
+#define _VOS_PIPE_HXX_
+
+# include <osl/pipe.h>
+# include <vos/types.hxx>
+# include <vos/object.hxx>
+# include <vos/istream.hxx>
+#ifndef _VOS_REFERMCE_HXX_
+# include <vos/refernce.hxx>
+#endif
+# include <vos/refobj.hxx>
+# include <vos/security.hxx>
+# include <rtl/ustring.hxx>
+
+
+namespace vos
+{
+
+class OStreamPipe;
+
+/** Represents a pipe.
+*/
+class OPipe : public NAMESPACE_VOS(OReference),
+ public NAMESPACE_VOS(OObject)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OPipe));
+
+public:
+ /*
+ Represents pipe-options
+ */
+ enum TPipeOption {
+ TOption_Open = osl_Pipe_OPEN, /* open existing pipe */
+ TOption_Create = osl_Pipe_CREATE /* create pipe and open it, */
+ /* fails if already existst */
+ };
+
+ enum TPipeError {
+ E_None = osl_Pipe_E_None, /* no error */
+ E_NotFound = osl_Pipe_E_NotFound, /* Pipe could not be found */
+ E_AlreadyExists = osl_Pipe_E_AlreadyExists, /* Pipe already exists */
+ E_NoProtocol = osl_Pipe_E_NoProtocol, /* Protocol not available */
+ E_NetworkReset = osl_Pipe_E_NetworkReset, /* Network dropped connection because of reset */
+ E_ConnectionAbort = osl_Pipe_E_ConnectionAbort, /* Software caused connection abort */
+ E_ConnectionReset = osl_Pipe_E_ConnectionReset, /* Connection reset by peer */
+ E_NoBufferSpace = osl_Pipe_E_NoBufferSpace, /* No buffer space available */
+ E_TimedOut = osl_Pipe_E_TimedOut, /* Connection timed out */
+ E_ConnectionRefused = osl_Pipe_E_ConnectionRefused, /* Connection refused */
+ E_invalidError = osl_Pipe_E_invalidError /* unmapped error */
+ };
+
+protected:
+ typedef ORefObj<oslPipe> PipeRef;
+
+ PipeRef* m_pPipeRef;
+
+public:
+
+ /** Does not create a pipe. Use assignment operator to
+ make this a useable pipe.
+ */
+ OPipe();
+
+ /** Creates a pipe.
+ @param strName
+ @param Options
+ */
+ OPipe(const ::rtl::OUString& strName, TPipeOption Options = TOption_Open);
+
+ /** Creates a pipe.
+ @param strName
+ @param Options
+ @param Security
+ */
+ OPipe(const ::rtl::OUString& strName, TPipeOption Options,
+ const NAMESPACE_VOS(OSecurity)& rSecurity);
+
+ /** Copy constructor.
+ */
+ OPipe(const OPipe& pipe);
+
+ /** Creates pipe as wrapper around the underlying oslPipe.
+ @param Pipe
+ */
+ OPipe(oslPipe Pipe);
+
+ /** Destructor. Destroys the underlying oslPipe.
+ */
+ virtual ~OPipe();
+
+ /** Create a pipe 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.
+ */
+ sal_Bool SAL_CALL create(const ::rtl::OUString& strName, TPipeOption Options = TOption_Open);
+
+ /** Create a pipe with the given attributes.
+ If socket was already created, the old one will be discarded.
+ @param strName
+ @param Options
+ @param Security
+ @return True if socket was successfully created.
+ */
+ sal_Bool SAL_CALL create(const ::rtl::OUString& strName, TPipeOption Options,
+ const NAMESPACE_VOS(OSecurity)& rSecurity);
+
+ /** Assignment operator. If pipe was already created, the old one will
+ be discarded.
+ */
+ OPipe& SAL_CALL operator= (const OPipe& pipe);
+
+ /** Allow cast to underlying oslPipe.
+ */
+ SAL_CALL operator oslPipe() const;
+
+ /** Checks if the pipe is valid.
+ @return True if the object represents a valid pipe.
+ */
+ sal_Bool SAL_CALL isValid() const;
+
+ sal_Bool SAL_CALL operator==( const OPipe& rPipe )
+ {
+ return m_pPipeRef == rPipe.m_pPipeRef;
+ }
+
+ /** Closes the pipe.
+ */
+ virtual void SAL_CALL close();
+
+ /** Accept connection on an existing pipe
+ */
+ TPipeError SAL_CALL accept(OStreamPipe& Connection);
+
+ /** 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.
+ */
+ sal_Int32 SAL_CALL recv(void* pBuffer, sal_uInt32 BytesToRead);
+
+ /** 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.
+ */
+ sal_Int32 SAL_CALL send(const void* pBuffer, sal_uInt32 BytesToSend);
+
+ /** 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.
+ */
+ TPipeError SAL_CALL getError() const;
+
+};
+
+/** A pipe to send or receive a stream of data.
+*/
+class OStreamPipe : public NAMESPACE_VOS(OPipe),
+ public NAMESPACE_VOS(IStream)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OStreamPipe));
+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.
+ */
+ OStreamPipe();
+
+ /** Creates pipe as wrapper around the underlying oslPipe.
+ @param Pipe
+ */
+ OStreamPipe(oslPipe Pipe);
+
+ /** Copy constructor.
+ @param Pipe
+ */
+ OStreamPipe(const OStreamPipe& Pipe);
+
+ /** Destructor. Calls shutdown(readwrite) and close().
+ */
+ virtual ~OStreamPipe();
+
+ /** 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.
+ */
+ OStreamPipe& SAL_CALL operator=(oslPipe Pipe);
+
+ /** Assignment operator
+ */
+ OStreamPipe& SAL_CALL operator=(const OPipe& pipe);
+
+ /** 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.
+ */
+ virtual sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 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.
+ */
+ virtual sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
+
+ /** Checks if pipe is closed.
+ @return True if pipe is closed.
+ */
+ virtual sal_Bool SAL_CALL isEof() const;
+};
+
+}
+
+#endif // _VOS_PIPE_HXX_
+
diff --git a/vos/inc/vos/process.hxx b/vos/inc/vos/process.hxx
new file mode 100644
index 000000000000..e41a050acaa0
--- /dev/null
+++ b/vos/inc/vos/process.hxx
@@ -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 _VOS_PROCESS_HXX_
+#define _VOS_PROCESS_HXX_
+
+# include <rtl/ustring.hxx>
+# include <vos/mutex.hxx>
+# include <vos/security.hxx>
+# include <vos/object.hxx>
+# include <vos/socket.hxx>
+# include <osl/process.h>
+
+namespace vos
+{
+
+class OProcess;
+
+/** helper class to fill a vector of command line arguments
+ */
+class OArgumentList
+{
+ sal_uInt32 n_Args;
+ rtl_uString** m_aVec;
+
+public:
+
+ OArgumentList();
+ OArgumentList( sal_uInt32 nArgs, const ::rtl::OUString* aArgument1, ... );
+ // switched argument list to avoid ambiguity with previous constructor.
+ OArgumentList( const ::rtl::OUString aArgumentList[], sal_uInt32 nArgs );
+
+ OArgumentList( const OArgumentList& rOther);
+
+ OArgumentList& operator=( const OArgumentList& rOther);
+
+ virtual ~OArgumentList();
+
+ friend class OProcess;
+};
+
+/** helper class to fill a vector of environment settings
+ */
+class OEnvironment
+{
+ sal_Int32 n_Vars;
+ rtl_uString** m_aVec;
+
+public:
+
+ OEnvironment();
+ OEnvironment( sal_Int32 nVars, const ::rtl::OUString* aVariable1, ... );
+ // switched argument list to avoid ambiguity with previous constructor.
+ OEnvironment( const ::rtl::OUString aVariableList[], sal_Int32 nVars );
+
+ OEnvironment( const OEnvironment& rOther );
+
+ OEnvironment& operator=( const OEnvironment& rOther );
+
+ virtual ~OEnvironment();
+
+ friend class OProcess;
+};
+
+
+/** startup child processes.
+ @see OStartupInfo
+ Used for starting an monitoring child processes with special features:
+ <ul><li>setting enviroments,
+ <li>setting working directories,
+ <li>setting user rights and security,
+ <li>providing ioresources like file descriptors and sockets.</ul>
+*/
+class OProcess : public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OProcess, vos));
+
+public:
+
+ /** Options for execution mode:
+ */
+ enum TProcessOption
+ {
+ TOption_Wait = osl_Process_WAIT, // wait for completion
+ TOption_SearchPath = osl_Process_SEARCHPATH, // search path for executable
+ TOption_Detached = osl_Process_DETACHED, // run detached
+ TOption_Normal = osl_Process_NORMAL, // run in normal window
+ TOption_Hidden = osl_Process_HIDDEN, // run hidden
+ TOption_Minimized = osl_Process_MINIMIZED, // run in minimized window
+ TOption_Maximized = osl_Process_MAXIMIZED, // run in maximized window
+ TOption_FullScreen = osl_Process_FULLSCREEN // run in fullscreen window
+ };
+
+ /** Errorcodes:
+ */
+ enum TProcessError {
+ E_None = osl_Process_E_None, /* no error */
+ E_NotFound = osl_Process_E_NotFound, /* image not found */
+ E_TimedOut = osl_Process_E_TimedOut, /* timout occured */
+ E_NoPermission = osl_Process_E_NoPermission, /* permission denied */
+ E_Unknown = osl_Process_E_Unknown, /* unknown error */
+ E_InvalidError = osl_Process_E_InvalidError /* unmapped error */
+ };
+
+ enum TDescriptorFlags
+ {
+ TFlags_None = osl_Process_DFNONE,
+ TFlags_Wait = osl_Process_DFWAIT
+ };
+
+ enum TProcessData
+ {
+ TData_Identifier = osl_Process_IDENTIFIER,
+ TData_ExitCode = osl_Process_EXITCODE,
+ TData_CpuTimes = osl_Process_CPUTIMES,
+ TData_HeapUsage = osl_Process_HEAPUSAGE
+ };
+
+ struct TProcessInfo : public oslProcessInfo
+ {
+ TProcessInfo() { Size = sizeof(*this); }
+ };
+
+ typedef oslProcessIdentifier TProcessIdentifier;
+
+ /** Creating a process object by naming the executable.
+ Does not yet start the process.
+ @see execute
+ */
+
+ OProcess( );
+
+ OProcess(const ::rtl::OUString& strImageName);
+
+ OProcess(const ::rtl::OUString& strImageName,
+ const ::rtl::OUString& strWorkingDirectory);
+
+ /// destroying a process object
+ virtual ~OProcess();
+
+ SAL_CALL operator oslProcess()
+ { return m_Process; }
+
+ SAL_CALL operator oslProcess() const
+ { return m_Process; }
+
+ static OProcess* SAL_CALL getProcess(TProcessIdentifier Identifier);
+
+ /** execute the given process.
+ This process becomes a child of the caller.
+ If there are any ioresources provided from the calling process, this
+ function returns only, if the child process calls OStartupInfo::acceptIOResource().
+ @param Options [in] describes the execution mode.
+ @return only not eNONE, if too much enviroments are added.
+ @see OStartupInfo::acceptIOResource
+ */
+ TProcessError SAL_CALL execute(TProcessOption Options,
+ const OArgumentList& aArgumentList = OArgumentList(),
+ const OEnvironment& aEnvironment = OEnvironment()
+ );
+
+ /** execute the given process with the specified security.
+ This process becomes a child of the caller.
+ The process is executed with the rights of the user, for whom the security object is created.
+ If there are any ioresources provided from the calling process, this
+ function returns only, if the child process calls OStartupInfo::acceptIOResource().
+ @param Options [in] describes the execution mode.
+ @param Security [in] is a given security object for one logged in user.
+ @return eNONE, if the proccess could be executed, otherwise an errorcode.
+ @see OStartupInfo::acceptIOResource
+ */
+ TProcessError SAL_CALL execute(TProcessOption Options,
+ const OSecurity &Security,
+ const OArgumentList& aArgumentList = OArgumentList(),
+ const OEnvironment& aEnvironment = OEnvironment()
+ );
+
+ TProcessError SAL_CALL terminate();
+
+ TProcessError SAL_CALL getInfo(TProcessData Data, TProcessInfo* pInfo) const;
+
+ static TProcessError SAL_CALL getCurrentInfo(TProcessData Data, TProcessInfo* pInfo);
+
+ /** wait for the completation of this child process
+ @return eNONE if child process exits, otherwise nothing.
+ */
+ TProcessError SAL_CALL join();
+
+protected:
+ const ::rtl::OUString m_strImageName;
+ const ::rtl::OUString m_strDirectory;
+
+ oslProcess m_Process;
+};
+
+/** informations for client processes provided by the parent.
+ @see OProcess
+*/
+
+
+class OStartupInfo : public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OStartupInfo, vos));
+
+public:
+ /** Errorcodes:
+ */
+ enum TStartupError {
+ E_None = osl_Process_E_None, /* no error */
+ E_NotFound = osl_Process_E_NotFound, /* image not found */
+ E_TimedOut = osl_Process_E_TimedOut, /* timout occured */
+ E_NoPermission = osl_Process_E_NoPermission, /* permission denied */
+ E_Unknown = osl_Process_E_Unknown, /* unknown error */
+ E_InvalidError = osl_Process_E_InvalidError /* unmapped error */
+ };
+
+ /** Constructor.
+ */
+ OStartupInfo();
+
+ /** Destructor
+ */
+ ~OStartupInfo();
+
+ /** @return the number of command line arguments.
+ */
+ sal_uInt32 SAL_CALL getCommandArgCount();
+
+ /** get the nArg-th command argument passed to the main-function of this process.
+ @param nArg [in] the number of arguments to return.
+ @param strCommandArg [out] the string that receives the argument.
+ @return eNONE
+ */
+ TStartupError SAL_CALL getCommandArg(sal_uInt32 nArg, ::rtl::OUString& strCommandArg);
+
+ TStartupError SAL_CALL getExecutableFile(::rtl::OUString& strImageName)
+ const;
+
+ /** Get the value of one enviroment variable.
+ @param Name [in] denotes the name of the variable to get.
+ @param Buffer [out] is the buffer where the value of this variable is returned.
+ @param Max [in] is the size of this buffer.
+ @return eNONE, if the variable exist in the enviroment, otherwise False.
+ */
+ TStartupError SAL_CALL getEnvironment(const ::rtl::OUString& strVar, ::rtl::OUString& strValue);
+};
+
+
+
+/** get extended arguments from command line and an argument file
+ the file name is given on the command line as "@filename"
+ (filename must be in our UNC notation!)
+ enumeration starts with 0 (i.e. argv[1])
+ each line in the file will be treated as one argument
+ @see also OProcess and OStartupInfo
+*/
+
+class OExtCommandLineImpl;
+
+class OExtCommandLine : public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OExtCommandLine, vos));
+ static NAMESPACE_VOS(OExtCommandLineImpl)* pExtImpl;
+
+public:
+
+ /** Constructor.
+ */
+ OExtCommandLine();
+
+ /** Destructor
+ */
+ virtual ~OExtCommandLine();
+
+ /** @return the number of extended command line arguments.
+ */
+ sal_uInt32 SAL_CALL getCommandArgCount();
+
+
+ /** get the nArg-th extended command argument
+ @param nArg [in] the number of extended argument to return.
+ @param strCommandArg [out] the string that receives the argument.
+ @return sal_True if the nArg-th argument has been retriveded successfully
+ @return sal_False on all other cases
+ */
+ sal_Bool SAL_CALL getCommandArg(sal_uInt32 nArg, ::rtl::OUString& strCommandArg);
+
+
+};
+
+}
+
+#endif // _VOS_PROCESS_HXX_
+
+
diff --git a/vos/inc/vos/ref.hxx b/vos/inc/vos/ref.hxx
new file mode 100644
index 000000000000..7b68bc43f09f
--- /dev/null
+++ b/vos/inc/vos/ref.hxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * 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 _VOS_REF_HXX_
+#define _VOS_REF_HXX_
+
+/**
+ ORef<T>
+
+ template type to implement handle/body behaviour
+ with reference-counting.
+
+ Note that the template-type T MUST implement IReferenceCounter.
+
+*/
+
+# include <vos/refernce.hxx>
+#ifndef _VOS_DIAGNOSE_HXX_
+# include <vos/diagnose.hxx>
+#endif
+
+namespace vos
+{
+
+
+template <class T>
+class ORef
+{
+public:
+
+ /** Creates an "empty" reference, use "create()" or
+ assignment/copy-operator to make it a valid reference.
+ */
+ ORef();
+
+ /** Creates a reference which points to pBody.
+ pBodys reference is not changed!. (like create(...)).
+ */
+ ORef(T* pBody);
+
+ /** Overload copy-constr. to implement ref-counting.
+ As a result of the following code:
+
+ ORef<x> h1, h2;
+
+ h1.create();
+ h2= h1;
+
+ h1 and h2 will represent the same body.
+
+ */
+ ORef(const ORef<T>& handle);
+
+ /** Decreases ref-count of underlying body.
+ */
+ inline ~ORef();
+
+ /** Overload assignment-operator to implement ref-counting.
+ Unbinds this instance from its body (if bound) and
+ bind it to the body represented by the handle.
+ */
+ ORef<T>& SAL_CALL operator= (const ORef<T>& handle);
+
+
+
+ /** Binds the body to this handle.
+ The "pBody"s reference-count is increased.
+
+ If you call bind() on an existing body,
+ the old body is unbound before the new one is
+ assigned.
+
+ */
+ void SAL_CALL bind(T* pBody);
+
+ /** Unbind the body from this handle.
+ Note that for a handle representing a large body,
+ "handle.unbind().bind(new body());" _might_
+ perform a little bit better than "handle.bind(new body());",
+ since in the second case two large objects exist in memory
+ (the old body and the new body).
+ */
+ ORef<T>& SAL_CALL unbind();
+
+ /** Same as bind().
+ */
+ void SAL_CALL operator= (T* pBody);
+
+ /** Just in case you want to call handle().someBodyOp()...
+ */
+ T& SAL_CALL operator() () const;
+
+ /** Allows (*handle).someBodyOp().
+ */
+ T& SAL_CALL operator* () const;
+
+ /** Probably most common used: handle->someBodyOp().
+ */
+ T* SAL_CALL operator->() const;
+
+ /** Gives access to the handles body.
+ */
+ T& SAL_CALL getBody() const;
+
+ /** Can be used instead of operator->.
+ I.e. handle->someBodyOp() and handle.getBodyPtr()->someBodyOp()
+ are the same.
+ */
+ T* SAL_CALL getBodyPtr() const;
+
+ /** Returns True is the body is empty (the handle
+ does not point to a valid body).
+ */
+ sal_Bool SAL_CALL isEmpty() const;
+
+ /** Returns True is the body is "full" (the handle
+ does point to a valid body).
+ */
+ sal_Bool SAL_CALL isValid() const;
+
+ /** Returns True is handle points to the same body.
+ */
+ sal_Bool SAL_CALL isEqualBody(const ORef<T>& handle) const;
+
+ /** Delegates comparison to the body.
+ */
+ sal_Bool SAL_CALL operator== (const ORef<T>& handle) const;
+
+ /** Delegates comparison to the body.
+ */
+ sal_Bool SAL_CALL operator!= (const ORef<T>& handle) const;
+
+ /** Returns True is "this" points to pBody.
+ */
+ sal_Bool SAL_CALL operator== (const T* pBody) const;
+
+ /** Needed to place ORefs into STL collection.
+ Delegates comparison to the body.
+ */
+ sal_Bool SAL_CALL operator< (const ORef<T>& handle) const;
+
+ /** Needed to place ORefs into STL collection.
+ Delegates comparison to the body.
+ */
+ sal_Bool SAL_CALL operator> (const ORef<T>& handle) const;
+
+protected:
+
+ T* m_refBody;
+};
+
+// include template implementation
+#include <vos/ref.inl>
+
+}
+
+
+#endif // _VOS_REF_HXX_
diff --git a/vos/inc/vos/ref.inl b/vos/inc/vos/ref.inl
new file mode 100644
index 000000000000..48ccf19ea80e
--- /dev/null
+++ b/vos/inc/vos/ref.inl
@@ -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(OS2) && defined(ICC))
+#define CAST_TO_IREFERENCE(p) ((IReference*)(p))
+#else
+#define CAST_TO_IREFERENCE(p) (p)
+#endif
+
+template <class T>
+inline ORef<T>::ORef()
+{
+ m_refBody= 0;
+}
+
+template <class T>
+inline ORef<T>::ORef(T* pBody)
+{
+ m_refBody= pBody;
+
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->acquire();
+}
+
+template <class T>
+inline ORef<T>::ORef(const ORef<T>& handle)
+{
+ m_refBody= handle.m_refBody;
+
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->acquire();
+}
+
+template <class T>
+inline ORef<T>::~ORef()
+{
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->release();
+}
+
+template <class T>
+inline ORef<T>& ORef<T>::operator= (const ORef<T>& handle)
+{
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->release();
+
+ m_refBody= handle.m_refBody;
+
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->acquire();
+
+ return *this;
+}
+
+template <class T>
+inline void ORef<T>::bind(T* pBody)
+{
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->release();
+
+ m_refBody= pBody;
+
+ if (m_refBody)
+ CAST_TO_IREFERENCE(m_refBody)->acquire();
+}
+
+template <class T>
+inline ORef<T>& ORef<T>::unbind()
+{
+ if (m_refBody)
+ {
+ CAST_TO_IREFERENCE(m_refBody)->release();
+ m_refBody = 0;
+ }
+ return *this;
+}
+
+template <class T>
+inline void ORef<T>::operator= (T* pBody)
+{
+ bind(pBody);
+}
+
+template <class T>
+inline T& ORef<T>::operator() () const
+{
+ VOS_PRECOND(m_refBody, "ORef::operator(): can't deref nil body!");
+ return *m_refBody;
+}
+
+template <class T>
+inline T& ORef<T>::operator* () const
+{
+ VOS_PRECOND(m_refBody, "ORef::operator*: can't deref nil body!");
+ return *m_refBody;
+}
+
+template <class T>
+inline T* ORef<T>::operator->() const
+{
+ VOS_PRECOND(m_refBody, "ORef::operator->: nil body!");
+ return m_refBody;
+}
+
+template <class T>
+inline T& ORef<T>::getBody() const
+{
+ VOS_PRECOND(m_refBody, "ORef::getBody(): can't deref nil body!");
+ return *m_refBody;
+}
+
+template <class T>
+inline T* ORef<T>::getBodyPtr() const
+{
+ // might be nil
+ return m_refBody;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::isEmpty() const
+{
+ return m_refBody == 0;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::isValid() const
+{
+ return m_refBody != 0;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::isEqualBody(const ORef<T>& handle) const
+{
+ return m_refBody == handle.m_refBody;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::operator== (const ORef<T>& handle) const
+{
+ return m_refBody == handle.m_refBody;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::operator!= (const ORef<T>& handle) const
+{
+ return m_refBody != handle.m_refBody;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::operator== (const T* pBody) const
+{
+ return m_refBody == pBody;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::operator< (const ORef<T>& handle) const
+{
+ return m_refBody < handle.m_refBody;
+}
+
+template <class T>
+inline sal_Bool ORef<T>::operator> (const ORef<T>& handle) const
+{
+ return m_refBody > handle.m_refBody;
+}
+
+
diff --git a/vos/inc/vos/refernce.hxx b/vos/inc/vos/refernce.hxx
new file mode 100644
index 000000000000..25f0f39eb0f3
--- /dev/null
+++ b/vos/inc/vos/refernce.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * 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 _VOS_REFERNCE_HXX_
+#define _VOS_REFERNCE_HXX_
+
+# include <vos/types.hxx>
+# include <osl/interlck.h>
+# include <vos/object.hxx>
+
+namespace vos
+{
+
+/** Interface for refernce-counting
+*/
+class IReference
+{
+public:
+
+ IReference() { }
+ virtual ~IReference() { }
+
+ typedef oslInterlockedCount RefCount;
+
+ virtual RefCount SAL_CALL acquire()=0;
+ virtual RefCount SAL_CALL release()=0;
+
+ virtual RefCount SAL_CALL referenced() const=0;
+};
+
+class ORefCount
+{
+public:
+ typedef IReference::RefCount RefCount;
+
+ ORefCount() { m_RefCount = 0; }
+ ORefCount(RefCount n) { m_RefCount = n; }
+ virtual ~ORefCount();
+
+ RefCount SAL_CALL acquire() { return (osl_incrementInterlockedCount(&m_RefCount)); };
+ RefCount SAL_CALL release() { return (osl_decrementInterlockedCount(&m_RefCount)); };
+
+ RefCount SAL_CALL operator++() { return acquire(); }
+ // don't implement the postfix operator, it won't function this way!
+
+ RefCount SAL_CALL operator--() { return release(); }
+ // don't implement the postfix operator, it won't function this way!
+
+ RefCount SAL_CALL referenced() const
+ { return (m_RefCount); }
+
+protected:
+ RefCount m_RefCount;
+
+private:
+ // disable copy/assignment
+ ORefCount(const ORefCount&);
+ ORefCount& SAL_CALL operator= (const ORefCount&);
+};
+
+class OReference : public NAMESPACE_VOS(IReference)
+{
+public:
+ OReference();
+ virtual ~OReference();
+
+ virtual RefCount SAL_CALL acquire();
+ virtual RefCount SAL_CALL release();
+
+ virtual RefCount SAL_CALL referenced() const
+ { return (m_RefCount.referenced()); }
+
+protected:
+ ORefCount m_RefCount;
+
+private:
+ // disable copy/assignment
+ OReference(const OReference&);
+ OReference& SAL_CALL operator= (const OReference&);
+};
+
+}
+
+#endif // _VOS_REFERNCE_HXX_
+
diff --git a/vos/inc/vos/refobj.hxx b/vos/inc/vos/refobj.hxx
new file mode 100644
index 000000000000..a79d45c9bd0c
--- /dev/null
+++ b/vos/inc/vos/refobj.hxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * 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 _VOS_REFOBJ_HXX_
+#define _VOS_REFOBJ_HXX_
+
+/**
+ ORefObj<T>
+
+ template type to implement handle/body behaviour
+ with reference-counting.
+*/
+
+# include <vos/refernce.hxx>
+#ifndef _VOS_DIAGNOSE_HXX_
+# include <vos/diagnose.hxx>
+#endif
+
+namespace vos
+{
+
+template <class T>
+class ORefObj : public IReference
+{
+public:
+ ORefObj(const T& Obj);
+
+ inline ~ORefObj();
+
+ virtual RefCount SAL_CALL acquire()
+ { return (m_RefCount.acquire()); }
+ virtual RefCount SAL_CALL release()
+ { return (m_RefCount.release()); }
+ virtual RefCount SAL_CALL referenced() const
+ { return (m_RefCount.referenced()); }
+
+ T& SAL_CALL operator=(const T& Obj);
+
+ SAL_CALL operator T&();
+ SAL_CALL operator const T&() const;
+
+ T& SAL_CALL operator() ();
+ const T& SAL_CALL operator() () const;
+
+ const T& SAL_CALL getObj() const;
+ T& SAL_CALL getObj();
+
+protected:
+ T m_Obj;
+ ORefCount m_RefCount;
+
+private:
+ ORefObj(const ORefObj<T>& handle);
+ ORefObj<T>& SAL_CALL operator= (const ORefObj<T>& handle);
+};
+
+// include template implementation
+#include <vos/refobj.inl>
+
+}
+
+
+#endif // _VOS_REF_HXX_
+
diff --git a/vos/inc/vos/refobj.inl b/vos/inc/vos/refobj.inl
new file mode 100644
index 000000000000..78b4e0f2808d
--- /dev/null
+++ b/vos/inc/vos/refobj.inl
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+template <class T>
+ORefObj<T>::ORefObj(const T& Obj)
+{
+ m_Obj = Obj;
+
+ m_RefCount.acquire();
+}
+
+template <class T>
+inline ORefObj<T>::~ORefObj()
+{
+ VOS_ASSERT(m_RefCount.referenced() == 0);
+}
+
+template <class T>
+inline T& ORefObj<T>::operator=(const T& Obj)
+{
+ m_Obj = Obj;
+
+ return m_Obj;
+}
+
+template <class T>
+inline ORefObj<T>::operator T&()
+{
+ return m_Obj;
+}
+
+template <class T>
+inline ORefObj<T>::operator const T&() const
+{
+ return m_Obj;
+}
+
+template <class T>
+inline T& ORefObj<T>::operator() ()
+{
+ return m_Obj;
+}
+
+template <class T>
+inline const T& ORefObj<T>::operator() () const
+{
+ return m_Obj;
+}
+
+template <class T>
+inline T& ORefObj<T>::getObj()
+{
+ return m_Obj;
+}
+
+template <class T>
+inline const T& ORefObj<T>::getObj() const
+{
+ return m_Obj;
+}
+
diff --git a/vos/inc/vos/runnable.hxx b/vos/inc/vos/runnable.hxx
new file mode 100644
index 000000000000..d577181b2398
--- /dev/null
+++ b/vos/inc/vos/runnable.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * 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 _VOS_RUNNABLE_HXX_
+#define _VOS_RUNNABLE_HXX_
+
+# include <vos/types.hxx>
+# include <vos/refernce.hxx>
+
+namespace vos
+{
+
+
+/** IRunnable
+
+ The IRunnable-interface is to be understood as wrapper around
+ your application-code, which allows it to be executed asynchronously.
+
+
+ @author Bernd Hofner
+ @version 0.1
+*/
+
+class IRunnable
+{
+public:
+
+ IRunnable() { }
+ virtual ~IRunnable() { }
+
+
+ /** overload to implement your functionality.
+ */
+ virtual void SAL_CALL run()= 0;
+
+};
+
+
+}
+
+
+#endif // _VOS_RUNNABLE_HXX_
+
diff --git a/vos/inc/vos/security.hxx b/vos/inc/vos/security.hxx
new file mode 100644
index 000000000000..6f0766bc4b24
--- /dev/null
+++ b/vos/inc/vos/security.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _VOS_SECURITY_HXX_
+#define _VOS_SECURITY_HXX_
+
+# include <vos/object.hxx>
+# include <rtl/ustring.hxx>
+# include <osl/security.h>
+
+namespace vos
+{
+
+/** 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 OProcess::executeProcess
+ @author Bernd Hofner
+ @version 1.0
+
+*/
+class OSecurity : public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSecurity, vos));
+
+public:
+ /// constructor
+ OSecurity();
+ /// destructor
+ virtual ~OSecurity();
+ /** 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
+ */
+ 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
+ */
+ 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
+ */
+ 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
+ */
+ 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
+ */
+ 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
+ */
+ 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.
+ */
+ sal_Bool SAL_CALL isAdministrator() const;
+
+ virtual SAL_CALL operator oslSecurity() const;
+
+protected:
+
+ oslSecurity m_oslSecurity;
+};
+
+}
+
+#endif // _VOS_SECURITY_HXX_
+
diff --git a/vos/inc/vos/signal.hxx b/vos/inc/vos/signal.hxx
new file mode 100644
index 000000000000..ea9db4850490
--- /dev/null
+++ b/vos/inc/vos/signal.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * 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 _VOS_SIGNAL_HXX_
+#define _VOS_SIGNAL_HXX_
+
+# include <vos/types.hxx>
+# include <vos/object.hxx>
+# include <osl/signal.h>
+
+namespace vos
+{
+
+extern "C"
+typedef oslSignalAction SignalHandlerFunction_impl(void *, oslSignalInfo *);
+SignalHandlerFunction_impl signalHandlerFunction_impl;
+
+/** OSignalHandler is an objectoriented interface for signal handlers.
+
+ @author Ralf Hofmann
+ @version 1.0
+*/
+
+class OSignalHandler : public NAMESPACE_VOS(OObject)
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OSignalHandler, vos));
+
+public:
+
+ enum TSignal
+ {
+ TSignal_System = osl_Signal_System,
+ TSignal_Terminate = osl_Signal_Terminate,
+ TSignal_AccessViolation = osl_Signal_AccessViolation,
+ TSignal_IntegerDivideByZero = osl_Signal_IntegerDivideByZero,
+ TSignal_FloatDivideByZero = osl_Signal_FloatDivideByZero,
+ TSignal_DebugBreak = osl_Signal_DebugBreak,
+ TSignal_SignalUser = osl_Signal_User
+ };
+
+ enum TSignalAction
+ {
+ TAction_CallNextHandler = osl_Signal_ActCallNextHdl,
+ TAction_Ignore = osl_Signal_ActIgnore,
+ TAction_AbortApplication = osl_Signal_ActAbortApp,
+ TAction_KillApplication = osl_Signal_ActKillApp
+ };
+
+ typedef oslSignalInfo TSignalInfo;
+
+ /// Constructor
+ OSignalHandler();
+
+ /// Destructor kills thread if neccessary
+ virtual ~OSignalHandler();
+
+ static TSignalAction SAL_CALL raise(sal_Int32 Signal, void *pData = 0);
+
+protected:
+
+ /// Working method which should be overridden.
+ virtual TSignalAction SAL_CALL signal(TSignalInfo *pInfo) = 0;
+
+protected:
+ oslSignalHandler m_hHandler;
+
+ friend oslSignalAction signalHandlerFunction_impl(void *, oslSignalInfo *);
+};
+
+}
+
+#endif // _VOS_SIGNAL_HXX_
+
diff --git a/vos/inc/vos/socket.hxx b/vos/inc/vos/socket.hxx
new file mode 100644
index 000000000000..cfd51fbb069b
--- /dev/null
+++ b/vos/inc/vos/socket.hxx
@@ -0,0 +1,1130 @@
+/*************************************************************************
+ *
+ * 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 _VOS_SOCKET_HXX_
+#define _VOS_SOCKET_HXX_
+
+# include <vos/types.hxx>
+# include <vos/object.hxx>
+# include <vos/istream.hxx>
+#ifndef _VOS_REFERMCE_HXX_
+# include <vos/refernce.hxx>
+#endif
+# include <vos/refobj.hxx>
+# include <rtl/ustring.hxx>
+# include <osl/socket.h>
+
+#include <osl/time.h>
+
+namespace vos
+{
+
+/** Base data types
+*/
+class ISocketTypes
+{
+public:
+
+ ISocketTypes() { }
+ virtual ~ISocketTypes() { }
+
+ /*
+ Represents the address-family of a socket
+ */
+ enum TAddrFamily {
+ TFamily_Inet = osl_Socket_FamilyInet, /* IP */
+ TFamily_Ipx = osl_Socket_FamilyIpx, /* Novell IPX/SPX */
+ TFamily_Invalid = osl_Socket_FamilyInvalid
+ };
+
+ /*
+ represent a specific protocol within a address-family
+ */
+ enum TProtocol {
+ TProtocol_Ip = osl_Socket_ProtocolIp, /* for all af_inet */
+ TProtocol_Ipx = osl_Socket_ProtocolIpx, /* af_ipx datagram sockets (IPX) */
+ TProtocol_Spx = osl_Socket_ProtocolSpx, /* af_ipx seqpacket or stream for SPX */
+ TProtocol_SpxII = osl_Socket_ProtocolSpxII, /* af_ipx seqpacket or stream for SPX II */
+ TProtocol_Invalid = osl_Socket_ProtocolInvalid
+ };
+
+ /*
+ Represents the type of a socket
+ */
+ enum TSocketType {
+ TType_Stream = osl_Socket_TypeStream,
+ TType_Dgram = osl_Socket_TypeDgram,
+ TType_Raw = osl_Socket_TypeRaw,
+ TType_Rdm = osl_Socket_TypeRdm,
+ TType_SeqPacket = osl_Socket_TypeSeqPacket,
+ TType_Invalid = osl_Socket_TypeInvalid
+ };
+
+ /*
+ Represents socket-options
+ */
+ enum TSocketOption {
+ TOption_Debug = osl_Socket_OptionDebug,
+ TOption_AcceptConn = osl_Socket_OptionAcceptConn,
+ TOption_ReuseAddr = osl_Socket_OptionReuseAddr,
+ TOption_KeepAlive = osl_Socket_OptionKeepAlive,
+ TOption_DontRoute = osl_Socket_OptionDontRoute,
+ TOption_Broadcast = osl_Socket_OptionBroadcast,
+ TOption_UseLoopback = osl_Socket_OptionUseLoopback,
+ TOption_Linger = osl_Socket_OptionLinger,
+ TOption_OOBinLine = osl_Socket_OptionOOBinLine,
+ TOption_SndBuf = osl_Socket_OptionSndBuf,
+ TOption_RcvBuf = osl_Socket_OptionRcvBuf,
+ TOption_SndLowat = osl_Socket_OptionSndLowat,
+ TOption_RcvLowat = osl_Socket_OptionRcvLowat,
+ TOption_SndTimeo = osl_Socket_OptionSndTimeo,
+ TOption_RcvTimeo = osl_Socket_OptionRcvTimeo,
+ TOption_Error = osl_Socket_OptionError,
+ TOption_Type = osl_Socket_OptionType,
+ TOption_TcpNoDelay = osl_Socket_OptionTcpNoDelay,
+ TOption_Invalid = osl_Socket_OptionInvalid
+ };
+
+ /*
+ Represents the different socket-option levels
+ */
+ enum TSocketOptionLevel {
+ TLevel_Socket = osl_Socket_LevelSocket,
+ TLevel_Tcp = osl_Socket_LevelTcp,
+ TLevel_Invalid = osl_Socket_LevelInvalid
+ };
+
+ /*
+ Represents flags to be used with send/recv-calls.
+ */
+ enum TSocketMsgFlag {
+ TMsg_Normal = osl_Socket_MsgNormal,
+ TMsg_OOB = osl_Socket_MsgOOB,
+ TMsg_Peek = osl_Socket_MsgPeek,
+ TMsg_DontRoute = osl_Socket_MsgDontRoute,
+ TMsg_MaxIOVLen = osl_Socket_MsgMaxIOVLen,
+ TMsg_Invalid = osl_Socket_MsgInvalid
+ };
+
+ /*
+ Used by shutdown to denote which end of the socket to "close".
+ */
+ enum TSocketDirection {
+ TDirection_Read = osl_Socket_DirRead,
+ TDirection_Write = osl_Socket_DirWrite,
+ TDirection_ReadWrite = osl_Socket_DirReadWrite,
+ TDirection_Invalid = osl_Socket_DirInvalid
+ };
+
+ enum TSocketError {
+ E_None = osl_Socket_E_None, /* no error */
+ E_NotSocket = osl_Socket_E_NotSocket, /* Socket operation on non-socket */
+ E_DestAddrReq = osl_Socket_E_DestAddrReq, /* Destination address required */
+ E_MsgSize = osl_Socket_E_MsgSize, /* Message too sal_Int32 */
+ E_Prototype = osl_Socket_E_Prototype, /* Protocol wrong type for socket */
+ E_NoProtocol = osl_Socket_E_NoProtocol, /* Protocol not available */
+ E_ProtocolNoSupport = osl_Socket_E_ProtocolNoSupport, /* Protocol not supported */
+ E_TypeNoSupport = osl_Socket_E_TypeNoSupport, /* Socket type not supported */
+ E_OpNotSupport = osl_Socket_E_OpNotSupport, /* Operation not supported on socket */
+ E_PfNoSupport = osl_Socket_E_PfNoSupport, /* Protocol family not supported */
+ E_AfNoSupport = osl_Socket_E_AfNoSupport, /* Address family not supported by */
+ /* protocol family */
+ E_AddrInUse = osl_Socket_E_AddrInUse, /* Address already in use */
+ E_AddrNotAvail = osl_Socket_E_AddrNotAvail, /* Can't assign requested address */
+ E_NetDown = osl_Socket_E_NetDown, /* Network is down */
+ E_NetUnreachable = osl_Socket_E_NetUnreachable, /* Network is unreachable */
+ E_NetReset = osl_Socket_E_NetReset, /* Network dropped connection because */
+ /* of reset */
+ E_ConnAborted = osl_Socket_E_ConnAborted, /* Software caused connection abort */
+ E_ConnReset = osl_Socket_E_ConnReset, /* Connection reset by peer */
+ E_NoBufferSpace = osl_Socket_E_NoBufferSpace, /* No buffer space available */
+ E_IsConnected = osl_Socket_E_IsConnected, /* Socket is already connected */
+ E_NotConnected = osl_Socket_E_NotConnected, /* Socket is not connected */
+ E_Shutdown = osl_Socket_E_Shutdown, /* Can't send after socket shutdown */
+ E_TooManyRefs = osl_Socket_E_TooManyRefs, /* Too many references: can't splice */
+ E_TimedOut = osl_Socket_E_TimedOut, /* Connection timed out */
+ E_ConnRefused = osl_Socket_E_ConnRefused, /* Connection refused */
+ E_HostDown = osl_Socket_E_HostDown, /* Host is down */
+ E_HostUnreachable = osl_Socket_E_HostUnreachable, /* No route to host */
+ E_WouldBlock = osl_Socket_E_WouldBlock, /* call would block on non-blocking socket */
+ E_Already = osl_Socket_E_Already, /* operation already in progress */
+ E_InProgress = osl_Socket_E_InProgress, /* operation now in progress */
+
+ E_Invalid = osl_Socket_E_InvalidError /* unmapped error */
+ };
+
+ enum TResult {
+ TResult_Ok = osl_Socket_Ok, /* successful completion */
+ TResult_Error = osl_Socket_Error, /* error occured, check osl_getLastSocketError() for details */
+ TResult_TimedOut = osl_Socket_TimedOut, /* blocking operation timed out */
+ TResult_Interrupted = osl_Socket_Interrupted, /* blocking operation was interrupted */
+ TResult_InProgress = osl_Socket_InProgress /* nonblocking operation is in progress */
+ };
+};
+
+
+/** Base class for socket addresses.
+*/
+class ISocketAddr : public NAMESPACE_VOS(ISocketTypes)
+{
+public:
+ virtual ~ISocketAddr() { }
+
+
+ virtual TAddrFamily SAL_CALL getFamily() const= 0;
+ virtual TResult SAL_CALL getHostname(::rtl::OUString& strHostName) const= 0;
+ virtual SAL_CALL operator oslSocketAddr() const= 0;
+ virtual void SAL_CALL operator= (oslSocketAddr Addr)= 0;
+ virtual sal_Bool SAL_CALL operator== (oslSocketAddr Addr)= 0;
+};
+
+class OSocketAddr : public NAMESPACE_VOS(ISocketAddr),
+ public NAMESPACE_VOS(OObject)
+
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OSocketAddr));
+public:
+
+ /** Creates socket address of unknown type.
+ */
+ OSocketAddr();
+
+ /** Copy constructor.
+ */
+ OSocketAddr(const OSocketAddr& Addr);
+
+ /**
+ */
+ OSocketAddr(oslSocketAddr Addr);
+
+ /** destroys underlying oslSocketAddress
+ */
+ virtual ~OSocketAddr();
+
+ /** Queries the socket for its address family.
+ @return the address family of the socket.
+ */
+ virtual TAddrFamily SAL_CALL getFamily() const;
+
+ /** Cast Object to the underlying oslSocketAddr.
+ */
+ virtual SAL_CALL operator oslSocketAddr() const;
+
+ /** Converts the address to a (human readable) domain-name.
+ @return the hostname represented by the address.
+ On failure returns the empty string.
+ */
+ virtual TResult SAL_CALL getHostname(::rtl::OUString& strHostName) const;
+
+ /** Get the hostname for the local interface.
+ @return the hostname or an error.
+ */
+ static TResult SAL_CALL getLocalHostname(::rtl::OUString& strLocalHostName);
+
+ /** Tries to find an address for a host.
+ @return A new created socket-address or 0 if the name could not be found.
+ */
+ static oslSocketAddr SAL_CALL resolveHostname(const ::rtl::OUString& strHostName);
+
+ /** Wraps itself around the osl Socket-Address.
+ The object assumes ownership of the Addr, it
+ will be destroyed by destructor(). If the socket is already attached to
+ an oslSocketAddr, the existing one will be destroyed.
+ */
+ virtual void SAL_CALL operator= (oslSocketAddr Addr);
+
+ /** Compares to Addr
+ */
+ virtual sal_Bool SAL_CALL operator== (oslSocketAddr Addr);
+
+ /** Makes a copy of Addr.
+ */
+ OSocketAddr& SAL_CALL operator= (const OSocketAddr& Addr);
+
+
+protected:
+
+ oslSocketAddr m_SockAddr;
+};
+
+
+/** Represents an internet-address.
+*/
+class OInetSocketAddr : public NAMESPACE_VOS(OSocketAddr)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OInetSocketAddr));
+public:
+
+ /** Creates an empty internet-address (INADDR_ANY).
+ */
+ OInetSocketAddr();
+
+ /** Wraps itself around the osl Socket-Address.
+ The object assumes ownership of the Addr, it
+ will be destroyed by ~OInetSocketAddr().
+ */
+ OInetSocketAddr(oslSocketAddr Addr);
+
+ /**
+ Create a socket address either from a dotted decimal address
+ (e.g. 141.99.128.50) or a hostname (e.g. www.stardiv.de).
+ */
+ OInetSocketAddr(const ::rtl::OUString& strAddrOrHostName, sal_Int32 Port);
+
+ /**
+ Copy constructor.
+ */
+ OInetSocketAddr(const OInetSocketAddr& Addr);
+
+ /**
+ */
+ OInetSocketAddr(const OSocketAddr& Addr);
+
+
+ virtual ~OInetSocketAddr();
+
+ /**
+ */
+ virtual void SAL_CALL operator= (oslSocketAddr Addr);
+
+ /**
+ */
+ virtual sal_Bool SAL_CALL operator== (oslSocketAddr Addr);
+
+ /**
+ */
+ OInetSocketAddr& SAL_CALL operator= (const OInetSocketAddr& Addr);
+
+ /**
+ */
+ OInetSocketAddr& SAL_CALL operator= (const OSocketAddr& 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 CVOS_PORT_NONE
+ if no service/protocol pair could be found.
+ */
+ static sal_Int32 SAL_CALL getServicePort(const ::rtl::OUString& strServiceName,
+ const ::rtl::OUString& strProtocolName= ::rtl::OUString::createFromAscii( "tcp" ) );
+
+
+ /** Delivers the port number of the address.
+ @return the port in host-byte order or or OSL_INVALID_PORT on errors.
+ */
+ sal_Int32 SAL_CALL getPort() const;
+
+ /** Sets the port number of the address.
+ @return False if the port couldn't be set
+ (e.g because the address is not of family TFamily_Inet).
+ */
+ sal_Bool SAL_CALL setPort(sal_Int32 Port);
+
+ /** @return the dotted-address-form (141.99.128.90) of this address.
+ On failure returns the empty string.
+ */
+ TResult SAL_CALL getDottedAddr(::rtl::OUString& strDottedAddr) const;
+
+ /** Sets the host-part of the address from the dotted-address-form (141.99.128.90)
+ or from a hostname.
+ @param strDottedAddrOrHostname the address in dotted form or a hostname.
+ */
+ sal_Bool SAL_CALL setAddr(const ::rtl::OUString& strDottedAddrOrHostname);
+
+};
+
+/** Represents an IPX/SPX address.
+*/
+class OIpxSocketAddr : public NAMESPACE_VOS(OSocketAddr)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OIpxSocketAddr));
+public:
+
+ typedef oslSocketIpxNetNumber TIpxNetNumber;
+ typedef oslSocketIpxNodeNumber TIpxNodeNumber;
+
+ /** Creates an empty ipx-address.
+ */
+ OIpxSocketAddr();
+
+ /** Wraps itself around the osl Socket-Address.
+ The object assumes ownership of the Addr, it
+ will be destroyed by the destructor.
+ */
+ OIpxSocketAddr(oslSocketAddr Addr);
+
+ /** Create an IPX/SPX socketaddress from native parameters.
+ */
+ OIpxSocketAddr(const ::rtl::OUString& strNetNumber,
+ const ::rtl::OUString& strNodeNumber,
+ sal_uInt32 SocketNumber);
+
+ /** Copy constructor.
+ */
+ OIpxSocketAddr(const OIpxSocketAddr& Addr);
+
+ /**
+ */
+ OIpxSocketAddr(const OSocketAddr& Addr);
+
+ virtual ~OIpxSocketAddr();
+
+ /**
+ */
+ virtual void SAL_CALL operator= (oslSocketAddr Addr);
+
+ /**
+ */
+ virtual sal_Bool SAL_CALL operator== (oslSocketAddr Addr);
+
+ /**
+ */
+ OIpxSocketAddr& SAL_CALL operator= (const OIpxSocketAddr& Addr);
+
+ /**
+ */
+ OIpxSocketAddr& SAL_CALL operator= (const OSocketAddr& Addr);
+
+ /**
+ */
+ TResult SAL_CALL getNetNumber(TIpxNetNumber& NetNumber) const;
+
+ /**
+ */
+ TResult SAL_CALL getNodeNumber(TIpxNodeNumber& NodeNumber) const;
+
+ /**
+ */
+ sal_uInt32 SAL_CALL getSocketNumber() const;
+
+ /** Builds a human readable string in the format network.node:socket.
+ The numbers are given in hexadecimal form.
+ */
+ void SAL_CALL getAddressString(::rtl::OUString& strAddressString) const;
+};
+
+
+/** Represents a socket.
+*/
+class OSocket : public NAMESPACE_VOS(ISocketTypes),
+ public NAMESPACE_VOS(OReference),
+ public NAMESPACE_VOS(OObject)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OSocket));
+
+protected:
+ typedef ORefObj<oslSocket> SockRef;
+
+ SockRef* m_pSockRef;
+
+ TimeValue* m_pSendTimeout;
+ TimeValue* m_pRecvTimeout;
+
+public:
+
+ /** Does not create a socket. Use assignment operator to
+ make this a useable socket.
+ */
+ OSocket();
+
+ /** Creates a socket.
+ @param Family
+ @param Type
+ @param Protocol
+ */
+ OSocket(TSocketType Type,
+ TAddrFamily Family = TFamily_Inet,
+ TProtocol Protocol = TProtocol_Ip);
+
+ /** Copy constructor.
+ */
+ OSocket(const OSocket& sock);
+
+ /** Creates socket as wrapper around the underlying oslSocket.
+ @param Socket
+ */
+ OSocket(oslSocket Socket);
+
+ /** Destructor. Destroys the underlying oslSocket.
+ */
+ virtual ~OSocket();
+
+ /** Create a socket with the given attributes.
+ If socket was already created, the old one will be discarded.
+ @param Type
+ @param Family
+ @param Protocol
+ @return True if socket was successfully created.
+ */
+ sal_Bool SAL_CALL create(TSocketType Type,
+ TAddrFamily Family = TFamily_Inet,
+ TProtocol Protocol = TProtocol_Ip);
+
+ /** Assignment operator. If socket was already created, the old one will
+ be discarded.
+ */
+ OSocket& SAL_CALL operator= (const OSocket& sock);
+
+ /** Allow cast to underlying oslSocket.
+ */
+ SAL_CALL operator oslSocket() const;
+
+ /** Checks if the socket is valid.
+ @return True if the object represents a valid socket.
+ */
+ sal_Bool SAL_CALL isValid() const;
+
+ sal_Bool SAL_CALL operator==( const OSocket& rSocket )
+ {
+ return m_pSockRef == rSocket.m_pSockRef;
+ }
+
+ /** Closes the socket.
+ */
+ virtual void SAL_CALL close();
+
+ /** Retrieves the address of the local interface of this socket.
+ @param Addr [out] receives the address.
+ */
+ void SAL_CALL getLocalAddr(OSocketAddr& Addr) const;
+
+ /** Get the local port of the socket.
+ @return the port number or OSL_INVALID_PORT on errors.
+ */
+ sal_Int32 SAL_CALL getLocalPort() const;
+
+ /** Get the hostname for the local interface.
+ @return the hostname or an empty string ("").
+ */
+ TResult SAL_CALL getLocalHost(::rtl::OUString& strLocalHost) const;
+
+ /** Retrieves the address of the remote host of this socket.
+ @param Addr [out] receives the address.
+ */
+ void SAL_CALL getPeerAddr(OSocketAddr& Addr) const;
+
+ /** Get the remote port of the socket.
+ @return the port number or OSL_INVALID_PORT on errors.
+ */
+ sal_Int32 SAL_CALL getPeerPort() const;
+
+ /** Get the hostname for the remote interface.
+ @return the hostname or an empty string ("").
+ */
+ TResult SAL_CALL getPeerHost(::rtl::OUString& strPeerHost) const;
+
+ /** Binds the socket to the specified (local) interface.
+ @param LocalInterface Address of the Interface
+ @return True if bind was successful.
+ */
+ sal_Bool SAL_CALL bind(const OSocketAddr& LocalInterface);
+
+
+ /** Blocking send operations will unblock after the send-timeout.
+ @return 0 for disables timeout else timeout value.
+ */
+ const TimeValue* SAL_CALL getSendTimeout() const
+ { return m_pSendTimeout; }
+
+ /** Blocking receive operations will unblock after the send-timeout.
+ @return 0 for disables timeout else timeout value.
+ */
+ const TimeValue* SAL_CALL getRecvTimeout() const
+ { return m_pRecvTimeout; }
+
+ /** Blocking send operations will unblock after the send-timeout.
+ @param time pTimeout == 0 disables timeout. pTimeout != 0 sets timeout value.
+ */
+ void SAL_CALL setSendTimeout(const TimeValue* pTimeout = 0);
+
+ /** Blocking receive operations will unblock after the send-timeout.
+ @param time pTimeout == 0 disables timeout. pTimeout != 0 sets timeout value.
+ */
+ void SAL_CALL setRecvTimeout(const TimeValue* pTimeout = 0);
+
+ /** Checks if read operations will block.
+ You can specify a timeout-value in seconds/nanoseconds that denotes
+ how sal_Int32 the operation will block if the Socket is not ready.
+ @return True if read operations (recv, recvFrom, accept) on the Socket
+ will NOT block; False 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.
+ */
+ 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 sal_Int32 the operation will block if the Socket is not ready.
+ @return True if send operations (send, sendTo) on the Socket
+ will NOT block; False 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.
+ */
+ 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 sal_Int32 the operation will block if the Socket has no pending OOB data.
+
+ @return True if OOB-request operations (recv with appropriate flags)
+ on the Socket will NOT block; False 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.
+ */
+ sal_Bool SAL_CALL isExceptionPending(const TimeValue* pTimeout = 0) const;
+
+ /** Retrieves option-attributes associated with the socket.
+ @param Option The attribute to query.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> TOption_Debug
+ <li> TOption_AcceptConn
+ <li> TOption_ReuseAddr
+ <li> TOption_KeepAlive
+ <li> TOption_DontRoute
+ <li> TOption_Broadcast
+ <li> TOption_UseLoopback
+ <li> TOption_Linger
+ <li> TOption_OOBinLine
+ <li> TOption_SndBuf
+ <li> TOption_RcvBuf
+ <li> TOption_SndLowat
+ <li> TOption_RcvLowat
+ <li> TOption_SndTimeo
+ <li> TOption_RcvTimeo
+ <li> TOption_Error
+ <li> TOption_Type
+ <li> TOption_TcpNoDelay
+ </ul>
+ If not above mentioned otherwise, the options are only valid for
+ level TLevel_Socket.
+
+ @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> TLevel_Socket : Socket Level
+ <li> TLevel_Tcp : Level of Transmission Control Protocol
+ </ul>
+
+ @return The size of the attribute copied into pBuffer ot -1 if an error
+ occured.
+ */
+ sal_Int32 SAL_CALL getOption(TSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ TSocketOptionLevel Level= TLevel_Socket) const;
+
+ /** Sets the sockets attributes.
+
+ @param Option denotes the option to modify.
+ Valid values (depending on the Level) are:
+ <ul>
+ <li> TOption_Debug
+ <li> TOption_AcceptConn
+ <li> TOption_ReuseAddr
+ <li> TOption_KeepAlive
+ <li> TOption_DontRoute
+ <li> TOption_Broadcast
+ <li> TOption_UseLoopback
+ <li> TOption_Linger
+ <li> TOption_OOBinLine
+ <li> TOption_SndBuf
+ <li> TOption_RcvBuf
+ <li> TOption_SndLowat
+ <li> TOption_RcvLowat
+ <li> TOption_SndTimeo
+ <li> TOption_RcvTimeo
+ <li> TOption_Error
+ <li> TOption_Type
+ <li> TOption_TcpNoDelay
+ </ul>
+ If not above mentioned otherwise, the options are only valid for
+ level TLevel_Socket.
+
+ @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> TLevel_Socket : Socket Level
+ <li> TLevel_Tcp : Level of Transmission Control Protocol
+ </ul>
+
+ @return True if the option could be changed.
+ */
+ sal_Bool SAL_CALL setOption(TSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ TSocketOptionLevel Level= TLevel_Socket) const;
+
+
+ /** Enables/disables non-blocking mode of the socket.
+ @param On If True, non-blocking mode will be switched on, if False
+ socket will become a blocking socket, which is the default behaviour of a
+ socket.
+ @return True if mode could be set.
+ */
+ sal_Bool SAL_CALL enableNonBlockingMode(sal_Bool On= sal_True);
+
+ /** Query non-blocking mode of the socket.
+ @return True if non-blocking mode is set.
+ */
+ sal_Bool SAL_CALL isNonBlockingMode() const;
+
+ /** Queries the socket for its type.
+ @return one of:
+ <ul>
+ <li> TType_Stream
+ <li> TType_Dgram
+ <li> TType_Raw
+ <li> TType_Rdm
+ <li> TType_SeqPacket
+ <li> TType_Invalid
+ </ul>
+ */
+ TSocketType SAL_CALL getType() const;
+
+
+ /** Gets and clears the error status of the socket.
+ @returns the current error state.
+ */
+ sal_Int32 SAL_CALL clearError() const;
+
+ /** Enables/Disables debugging.
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setDebug(sal_Int32 opt = -1) const;
+
+ /** Allow the socket to be bound to an address that is already in use.
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setReuseAddr(sal_Int32 opt = -1) const;
+
+ /** Send keepalive-packets.
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setKeepAlive(sal_Int32 opt = -1) const;
+
+ /** Do not route: send directly to interface.
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setDontRoute(sal_Int32 opt = -1) const;
+
+
+ /** Allow transmission of broadcast messages on the socket.
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setBroadcast(sal_Int32 opt = -1) const;
+
+ /** Receive out-of-band data in the normal data stream.
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setOobinline(sal_Int32 opt = -1) const;
+
+ /** Linger on close if unsent data is present.
+ @param time values > 0 enable lingering with a timeout of time in seconds.
+ If time is 0, lingering will be disabled. If time is -1 no changes will occur.
+ @return the previous setting (0 == off, > 0 timeout-value in seconds).
+ */
+ sal_Int32 SAL_CALL setLinger(sal_Int32 time = -1) const;
+
+ /** Specify buffer size for sends.
+ You might want to use getOption() to check if the size changes were
+ really successful.
+ @param size Size >= 0 sets the size, -1 won't change anything.
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setSendBufSize(sal_Int32 size =-1) const;
+
+ /** Specify buffer size for receives.
+ You might want to use getOption() to check if the size changes were
+ really successful.
+ @param size Size >= 0 sets the size, -1 won't change anything.
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setRecvBufSize(sal_Int32 size =-1) const;
+
+ /** 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 response-times.)
+ @param opt 1 sets, 0 resets, -1 won't change anything
+ @return the previous setting
+ */
+ sal_Int32 SAL_CALL setTcpNoDelay(sal_Int32 sz =-1) const;
+
+ /** Builds a string with the last error-message for the socket.
+ @param pBuffer is filled with the error message.
+ @param nSize the size of pBuffer. The message will be cut
+ sal_Int16 if the buffer isn't large enough, but still remains
+ a valid zero-terminated string.
+ */
+ void SAL_CALL getError(::rtl::OUString& strError) const;
+
+ /** Delivers a constant decribing the last error for the socket system.
+ @return ENONE if no error occured, invalid_SocketError if
+ an unknown (unmapped) error occured, otherwise an enum describing the
+ error.
+ */
+ TSocketError SAL_CALL getError() const;
+
+};
+
+/** A socket to send or receive a stream of data.
+*/
+class OStreamSocket : public NAMESPACE_VOS(OSocket),
+ public NAMESPACE_VOS(IStream)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OStreamSocket));
+public:
+
+ /** Creates an unattached socket. You must attach the socket to an oslSocket
+ e.g. by using the operator=(oslSocket), before you can use the stream-
+ functionality of the object.
+ */
+ OStreamSocket();
+
+
+
+ /** Creates socket as wrapper around the underlying oslSocket.
+ @param Socket
+ */
+ OStreamSocket(oslSocket Socket);
+
+
+ /** Copy constructor.
+ @param Socket
+ */
+ OStreamSocket(const OStreamSocket& Socket);
+
+
+ /**
+ */
+ OStreamSocket(const OSocket& Socket);
+
+ /** Destructor. Calls shutdown(readwrite) and close().
+ */
+ virtual ~OStreamSocket();
+
+ /** Closes the socket after calling shutdown.
+ */
+ virtual void SAL_CALL close();
+
+ /** Attaches the oslSocket to this object. If the object
+ already was attached to an oslSocket, the old one will
+ be closed and destroyed.
+ @param Socket.
+ */
+ OStreamSocket& SAL_CALL operator=(oslSocket Socket);
+
+ /**
+ */
+ OStreamSocket& SAL_CALL operator=(const OSocket& Socket);
+
+ /**
+ */
+ OStreamSocket& SAL_CALL operator=(const OStreamSocket& Socket);
+
+ /** 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.
+ */
+ virtual sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 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.
+ */
+ virtual sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
+
+ /** Checks if socket is closed.
+ @return True if socket is closed.
+ */
+ virtual sal_Bool SAL_CALL isEof() const;
+
+ /** Tries to receives BytesToRead data from the connected socket,
+
+ @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> TMsg_Normal
+ <li> TMsg_OOB
+ <li> TMsg_Peek
+ <li> TMsg_DontRoute
+ <li> TMsg_MaxIOVLen
+ </ul>
+
+ @return the number of received bytes.
+ */
+ sal_Int32 SAL_CALL recv(void* pBuffer,
+ sal_uInt32 BytesToRead,
+ TSocketMsgFlag Flag= TMsg_Normal);
+
+
+ /** Tries to sends BytesToSend data from 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> TMsg_Normal
+ <li> TMsg_OOB
+ <li> TMsg_Peek
+ <li> TMsg_DontRoute
+ <li> TMsg_MaxIOVLen
+ </ul>
+
+ @return the number of transfered bytes.
+ */
+ sal_Int32 SAL_CALL send(const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ TSocketMsgFlag Flag= TMsg_Normal);
+
+ /** Closes a connection in a controlled manner.
+ @param Direction Says which "end" of the socket is to be closed.
+ */
+ sal_Bool SAL_CALL shutdown(TSocketDirection Direction= TDirection_ReadWrite);
+protected:
+
+ /** Creates a socket. This constructor is used only by derived classes
+ (e.g. OConnectorSocket).
+ @param Family
+ @param Protocol
+ @param Type For some protocols it might be desirable to
+ use a different type than sock_stream (like sock_seqpacket).
+ Therefore we do not hide this parameter here.
+ */
+ OStreamSocket(TAddrFamily Family,
+ TProtocol Protocol,
+ TSocketType Type= TType_Stream);
+
+
+};
+
+
+/** A socket to accept incoming connections.
+*/
+class OAcceptorSocket : public NAMESPACE_VOS(OSocket)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OAcceptorSocket));
+public:
+
+ /** Creates a socket that can accept connections.
+ @param Type For some protocols it might be desirable to
+ use a different type than sock_stream (like sock_seqpacket).
+ Therefore we do not hide this parameter here.
+ */
+ OAcceptorSocket(TAddrFamily Family= TFamily_Inet,
+ TProtocol Protocol= TProtocol_Ip,
+ TSocketType Type= TType_Stream);
+
+ /** Copy constructor.
+ */
+ OAcceptorSocket(const OAcceptorSocket& Socket);
+
+ /** Destructor. Closes the socket and destroys the underlying oslSocket.
+ */
+ virtual ~OAcceptorSocket();
+
+ /** Closes the socket. Also calls shutdown, needed to unblock
+ accept on some systems.
+ */
+ virtual void SAL_CALL close();
+
+ /** Prepare a socket for the accept-call.
+ @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 True if call was successful.
+ */
+ sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
+
+ /** Accepts incoming connections on the socket. You must
+ precede this call with bind() and listen().
+ @param Connection receives the incoming connection.
+ @return result_ok: if a connection has been accepted,
+ result_timeout: if m_RecvTimeout milliseconds passed without connect,
+ result_error: on errors.
+ */
+ TResult SAL_CALL acceptConnection(OStreamSocket& Connection);
+
+ /** Accepts incoming connections on the socket. You must
+ precede this call with bind() and listen().
+ @param PeerAddr receives the address of the connecting entity
+ (your communication partner).
+ @param Connection receives the incoming connection.
+ @return True if a connection has been accepted, False on errors.
+ @return result_ok: if a connection has been accepted,
+ result_timeout: if m_RecvTimeout milliseconds passed without connect,
+ result_error: on errors.
+ */
+ TResult SAL_CALL acceptConnection(OStreamSocket& Connection,
+ OSocketAddr& PeerAddr);
+
+};
+
+
+/** A socket to initiate a conenction.
+*/
+class OConnectorSocket : public NAMESPACE_VOS(OStreamSocket)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(OConnectorSocket));
+public:
+
+ /** Creates a socket that can accept connections.
+ @param Type For some protocols it might be desirable to
+ use a different type than sock_stream (like sock_seqpacket).
+ Therefore we do not hide this parameter here.
+ */
+ OConnectorSocket(TAddrFamily Family= TFamily_Inet,
+ TProtocol Protocol= TProtocol_Ip,
+ TSocketType Type= TType_Stream);
+
+ /** Copy constructor. Doesn't duplicate oslSocket.
+ */
+ OConnectorSocket(const OConnectorSocket& Socket);
+
+ /** Destructor. Relies on ~OStreamSocket to close down connection gracefully.
+ */
+ virtual ~OConnectorSocket();
+
+ /** Connects the socket to a (remote) host.
+ @param TargetHost The address of the target.
+ @param msTimeout The timeout in milliseconds. Use -1 to block.
+ @return result_ok if connected successfully,
+ result_timeout on timeout,
+ result_interrupted if unblocked forcefully (by close()),
+ result_error if connect failed.
+ */
+ TResult SAL_CALL connect(const OSocketAddr& TargetHost, const TimeValue* pTimeout = 0);
+};
+
+
+/** A connectionless socket to send and receive datagrams.
+*/
+class ODatagramSocket : public NAMESPACE_VOS(OSocket)
+{
+ VOS_DECLARE_CLASSINFO(NAMESPACE_VOS(ODatagramSocket));
+public:
+
+ /** Creates a datagram socket.
+ @param Type is sock_dgram by default.
+ */
+ ODatagramSocket(TAddrFamily Family= TFamily_Inet,
+ TProtocol Protocol= TProtocol_Ip,
+ TSocketType Type= TType_Dgram);
+
+ /** Copy constructor.
+ */
+ ODatagramSocket(const ODatagramSocket& Socket);
+
+ /** Destructor. Closes the socket.
+ */
+ virtual ~ODatagramSocket();
+
+
+ /** 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> TMsg_Normal
+ <li> TMsg_OOB
+ <li> TMsg_Peek
+ <li> TMsg_DontRoute
+ <li> TMsg_MaxIOVLen
+ </ul>
+
+ @return the number of received bytes.
+ */
+ sal_Int32 SAL_CALL recvFrom(void* pBuffer,
+ sal_uInt32 BufferSize,
+ OSocketAddr* pSenderAddr= 0,
+ TSocketMsgFlag Flag= TMsg_Normal);
+
+ /** Tries to send one datagram with BytesToSend data to the given ReceiverAddr.
+ Since we only send one packet, we don't need to concern ourselfes here with
+ incomplete sends due to 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> TMsg_Normal
+ <li> TMsg_OOB
+ <li> TMsg_Peek
+ <li> TMsg_DontRoute
+ <li> TMsg_MaxIOVLen
+ </ul>
+
+ @return the number of transfered bytes.
+ */
+ sal_Int32 SAL_CALL sendTo(const OSocketAddr& ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BufferSize,
+ TSocketMsgFlag Flag= TMsg_Normal);
+};
+
+
+
+}
+
+#endif // _VOS_SOCKET_HXX_
+
diff --git a/vos/inc/vos/stream.hxx b/vos/inc/vos/stream.hxx
new file mode 100644
index 000000000000..5e25aa1d103a
--- /dev/null
+++ b/vos/inc/vos/stream.hxx
@@ -0,0 +1,285 @@
+/*************************************************************************
+ *
+ * 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 _VOS_STREAM_HXX_
+#define _VOS_STREAM_HXX_
+
+# include <vos/types.hxx>
+# include <vos/object.hxx>
+# include <vos/istream.hxx>
+
+namespace vos
+{
+
+/** Adds seeking capabilities to IStream
+*/
+class IPositionableStream : public NAMESPACE_VOS(IStream)
+{
+
+public:
+
+ typedef sal_Int32 Offset;
+
+public:
+
+ ///
+ virtual sal_Bool SAL_CALL seekTo(Offset position) const = 0;
+
+ ///
+ virtual sal_Bool SAL_CALL seekRelative(Offset change) const = 0;
+
+ ///
+ virtual sal_Bool SAL_CALL seekToEnd() const = 0;
+
+ ///
+ virtual sal_Bool SAL_CALL changeSize(sal_uInt32 new_size) = 0;
+
+ ///
+ virtual sal_uInt32 SAL_CALL getSize() const = 0;
+
+
+ ///
+ virtual Offset SAL_CALL getOffset() const = 0;
+
+
+protected:
+ IPositionableStream() { }
+ virtual ~IPositionableStream() { }
+
+};
+
+
+/** Implements IPositionableStream
+*/
+class OStream : public NAMESPACE_VOS(OObject),
+ public NAMESPACE_VOS(IPositionableStream)
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OStream, vos));
+
+public:
+
+ ///
+ OStream(IPositionableStream& rStream);
+
+ ///
+ virtual ~OStream ();
+
+ // ----------------- Read operations -------------------------
+
+ ///
+ virtual sal_Int32 SAL_CALL read(void* pbuffer, sal_uInt32 n) const;
+
+ ///
+ sal_Int32 SAL_CALL read(IPositionableStream::Offset offset,
+ void* pbuffer,
+ sal_uInt32 n) const;
+
+ ///
+ inline sal_Bool SAL_CALL read(sal_Int32& value) const;
+
+ ///
+ inline sal_Bool SAL_CALL read(sal_Int16& value) const;
+
+ ///
+ inline sal_Bool SAL_CALL read(sal_Char& value) const;
+
+ ///
+ inline sal_Bool SAL_CALL read(sal_uInt8& value) const;
+
+ // ----------------- Write operations ------------------------
+
+ ///
+ virtual sal_Int32 SAL_CALL write(const void* pbuffer, sal_uInt32 n);
+
+ ///
+ sal_Int32 SAL_CALL write(IPositionableStream::Offset offset,
+ const void* pbuffer,
+ sal_uInt32 n);
+ ///
+ inline sal_Bool SAL_CALL write(sal_Int32 value);
+
+ ///
+ inline sal_Bool SAL_CALL write(sal_Int16 value);
+
+ ///
+ inline sal_Bool SAL_CALL write(sal_Char value);
+
+ ///
+ inline sal_Bool SAL_CALL write(sal_uInt8 value);
+
+ ///
+ sal_Bool SAL_CALL append(void* pbuffer, sal_uInt32 n); // Write at the end of the Stream.
+
+ // ------------- Positioning and sizing operations ----------
+
+ ///
+ inline sal_Bool SAL_CALL seekToBegin() const;
+
+ // ----------------- Stream interface ------------------------
+
+ ///
+ virtual sal_Bool SAL_CALL seekTo(IPositionableStream::Offset pos) const;
+
+ ///
+ virtual sal_Bool SAL_CALL seekToEnd() const;
+
+ ///
+ virtual sal_Bool SAL_CALL seekRelative(IPositionableStream::Offset change) const;
+
+ ///
+ virtual sal_Bool SAL_CALL changeSize(sal_uInt32 new_size);
+
+ ///
+ virtual sal_uInt32 SAL_CALL getSize() const;
+
+ ///
+ virtual sal_Bool SAL_CALL isEof() const;
+
+ ///
+ virtual IPositionableStream::Offset SAL_CALL getOffset() const;
+
+protected:
+ IPositionableStream& m_rStream;
+
+ // ----------------- Stream operators ------------------------
+
+ friend const OStream& operator>> (OStream& rStream, sal_Int32& value);
+ friend const OStream& operator>> (OStream& rStream, sal_Int16& value);
+ friend const OStream& operator>> (OStream& rStream, sal_uInt8& value);
+ friend const OStream& operator>> (OStream& rStream, sal_Char& value);
+ friend OStream& operator<< (OStream& rStream, sal_Int32 value);
+ friend OStream& operator<< (OStream& rStream, sal_Int16 value);
+ friend OStream& operator<< (OStream& rStream, sal_uInt8 value);
+ friend OStream& operator<< (OStream& rStream, sal_Char value);
+};
+
+inline sal_Bool OStream::read(sal_Int32& value) const
+{
+ return (read(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::read(sal_Int16& value) const
+{
+ return (read(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::read(sal_Char& value) const
+{
+ return (read(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::read(sal_uInt8& value) const
+{
+ return (read(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::write(sal_Int32 value)
+{
+ return (write(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::write(sal_Int16 value)
+{
+ return (write(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::write(sal_Char value)
+{
+ return (write(&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::write(sal_uInt8 value)
+{
+ return (write((sal_uInt8*)&value, sizeof(value)) == sizeof(value));
+}
+
+inline sal_Bool OStream::seekToBegin() const
+{
+ return (seekTo(0L));
+}
+
+inline const OStream& operator>> (OStream& rStream, sal_Int32& value)
+{
+ rStream.read(value);
+
+ return (rStream);
+}
+
+inline const OStream& operator>> (OStream& rStream, sal_Int16& value)
+{
+ rStream.read(value);
+
+ return (rStream);
+}
+
+inline const OStream& operator>> (OStream& rStream, sal_uInt8& value)
+{
+ rStream.read(value);
+
+ return (rStream);
+}
+
+inline const OStream& operator>> (OStream& rStream, sal_Char& value)
+{
+ rStream.read(value);
+
+ return (rStream);
+}
+
+inline OStream& operator<< (OStream& rStream, sal_Int32 value)
+{
+ rStream.write(value);
+
+ return (rStream);
+}
+
+inline OStream& operator<< (OStream& rStream, sal_Int16 value)
+{
+ rStream.write(value);
+
+ return (rStream);
+}
+
+inline OStream& operator<< (OStream& rStream, sal_uInt8 value)
+{
+ rStream.write(value);
+
+ return (rStream);
+}
+
+inline OStream& operator<< (OStream& rStream, sal_Char value)
+{
+ rStream.write(value);
+
+ return (rStream);
+}
+
+}
+
+#endif // _VOS_STREAM_HXX_
+
+
diff --git a/vos/inc/vos/thread.hxx b/vos/inc/vos/thread.hxx
new file mode 100644
index 000000000000..16f64c0e0812
--- /dev/null
+++ b/vos/inc/vos/thread.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 _VOS_THREAD_HXX_
+#define _VOS_THREAD_HXX_
+
+# include <vos/types.hxx>
+# include <vos/object.hxx>
+# include <osl/thread.h>
+# include <osl/conditn.h>
+# include <vos/runnable.hxx>
+
+#include <osl/time.h>
+
+namespace vos
+{
+
+extern "C" typedef void ThreadWorkerFunction_impl(void *);
+ThreadWorkerFunction_impl threadWorkerFunction_impl;
+
+/** OThread is an objectoriented interface for threads.
+ This class should be the base class for all objects using threads. The
+ main working function is the run() method and should be overriden in the
+ derived class. To support soft termination of a thread, yield() should
+ be called in regular intervalls and the return value should be checked.
+ If yield returned False the run method should return.
+
+ @author Bernd Hofner
+ @version 1.0
+*/
+
+class OThread : public NAMESPACE_VOS(IRunnable),
+ public NAMESPACE_VOS(OObject)
+{
+
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OThread, vos));
+
+ oslCondition m_aCondition;
+
+public:
+ /** priority of thread.
+ */
+ enum TThreadPriority
+ {
+ TPriority_Highest = osl_Thread_PriorityHighest,
+ TPriority_AboveNormal = osl_Thread_PriorityAboveNormal,
+ TPriority_Normal = osl_Thread_PriorityNormal,
+ TPriority_BelowNormal = osl_Thread_PriorityBelowNormal,
+ TPriority_Lowest = osl_Thread_PriorityLowest,
+ TPriority_Unknown = osl_Thread_PriorityUnknown
+ };
+
+ /**
+ */
+ enum TThreadSleep
+ {
+ TSleep_Normal,
+ TSleep_Cancel,
+ TSleep_Pending,
+ TSleep_Active,
+ TSleep_Error,
+ TSleep_Unknown
+ };
+
+ typedef oslThreadIdentifier TThreadIdentifier;
+
+ /// Constructor
+ OThread();
+
+ /// Destructor kills thread if neccessary
+ virtual ~OThread();
+
+ /** Create running instance of a thread.
+ @returns True if thread could be created.
+ */
+ sal_Bool SAL_CALL create();
+
+ /** Create suspended instance of a thread.
+ @returns True if thread could be created.
+ */
+ sal_Bool SAL_CALL createSuspended();
+
+ /// Suspend a runnng thread
+ void SAL_CALL suspend();
+
+ /// Resume a suspended thread
+ void SAL_CALL resume();
+
+ /** Tries to kill the thread.
+ will not block and might not succeed when run() won't heed isTerminationRequested().
+ */
+ virtual void SAL_CALL terminate();
+
+ /// Kill thread hard and block until it is actually gone
+ virtual void SAL_CALL kill();
+
+ /// Block till thread is terminated
+ void SAL_CALL join();
+
+ /// Check if thread is running.
+ sal_Bool SAL_CALL isRunning();
+
+ /** Change thread priority.
+ The valid priority levels are:
+ <ul>
+ <li>ThreadPriorityHighest,
+ <li>ThreadPriorityAboveNormal,
+ <li>ThreadPriorityNormal,
+ <li>ThreadPriorityBelowNormal,
+ <li>ThreadPriorityLowest,
+ </ul>
+ */
+ void SAL_CALL setPriority(TThreadPriority Priority);
+
+ /** Query thread priority.
+ Valid return values are:
+ <ul>
+ <li>ThreadPriorityHighest,
+ <li>ThreadPriorityAboveNormal,
+ <li>ThreadPriorityNormal,
+ <li>ThreadPriorityBelowNormal,
+ <li>ThreadPriorityLowest,
+ <li>ThreadPriorityUnknown (returned if thread is killed)
+ </ul>
+ */
+ TThreadPriority SAL_CALL getPriority();
+
+ TThreadIdentifier SAL_CALL getIdentifier() const;
+
+ static TThreadIdentifier SAL_CALL getCurrentIdentifier();
+
+ /** Let thread sleep a specified amout of time.
+ @param Delay specifies the number of time to sleep.
+ */
+ TThreadSleep SAL_CALL sleep(const TimeValue& Delay);
+
+ /** Awake the sleeping thread.
+ @returns False if at least one of the handles is invalid
+ or the thread is not sleeping.
+ */
+ sal_Bool SAL_CALL awake();
+
+ /** Let current thread wait a specified amout of time.
+ @param Delay specifies the number of time
+ to wait. Note, if you need to interrupt the waiting operation
+ use sleep instead.
+ */
+ static void SAL_CALL wait(const TimeValue& Delay);
+
+ /** Reschedules threads.
+ Call within your loop if you
+ want other threads offer some processing time.
+ This method is static, so it might be used by the
+ main-thread.
+ */
+ static void SAL_CALL yield();
+
+protected:
+
+ /// Working method which should be overridden.
+ virtual void SAL_CALL run() = 0;
+
+ /** Checks if thread should terminate.
+ isTerminationRequested() will return True if someone called
+ terminate().
+ @return True if thread should terminate, False if he can continue.
+ */
+ virtual sal_Bool SAL_CALL schedule();
+
+ /** Called when run() is done.
+ You might want to override it to do some cleanup.
+ */
+ virtual void SAL_CALL onTerminated();
+
+protected:
+ oslThread m_hThread;
+ sal_Bool m_bTerminating;
+
+ friend void threadWorkerFunction_impl(void *);
+};
+
+class OThreadData : public NAMESPACE_VOS(OObject)
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OThreadData, vos));
+
+public:
+ /// Create a thread specific local data key
+ OThreadData( oslThreadKeyCallbackFunction = 0 );
+
+ /// Destroy a thread specific local data key
+ virtual ~OThreadData();
+
+ /** Set the data associated with the data key.
+ @returns True if operation was successfull
+ */
+ sal_Bool SAL_CALL setData(void *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();
+
+protected:
+ oslThreadKey m_hKey;
+};
+
+}
+
+#endif // _VOS_THREAD_HXX_
+
diff --git a/vos/inc/vos/timer.hxx b/vos/inc/vos/timer.hxx
new file mode 100644
index 000000000000..4605092ec2f0
--- /dev/null
+++ b/vos/inc/vos/timer.hxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * 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 _VOS_TIMER_HXX_
+#define _VOS_TIMER_HXX_
+
+# include <vos/refernce.hxx>
+# include <vos/mutex.hxx>
+# include <osl/time.h>
+
+
+namespace vos
+{
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// TTimeValue
+//
+
+/** <code> struct TTimeValue </code> : class for times. Times are seconds in UTC since 01.01.1970
+ */
+struct TTimeValue : public TimeValue
+{
+ TTimeValue()
+ { Seconds = 0; Nanosec = 0; }
+
+ TTimeValue(sal_uInt32 Seconds, sal_uInt32 Nano);
+
+ TTimeValue(sal_uInt32 MilliSecs)
+ { Seconds = MilliSecs / 1000L; Nanosec = (MilliSecs % 1000) * 1000000L; }
+
+ TTimeValue(const TTimeValue& rTimeValue)
+ { Seconds = rTimeValue.Seconds; Nanosec = rTimeValue.Nanosec; }
+
+ TTimeValue(const TimeValue& rTimeValue)
+ { Seconds = rTimeValue.Seconds; Nanosec = rTimeValue.Nanosec; }
+
+ void SAL_CALL normalize();
+
+ void SAL_CALL addTime(const TTimeValue& Delta);
+
+ sal_Bool SAL_CALL isEmpty() const;
+};
+
+inline void TTimeValue::normalize()
+{
+ if (Nanosec > 1000000000)
+ {
+ Seconds += Nanosec / 1000000000;
+ Nanosec %= 1000000000;
+ }
+}
+
+inline TTimeValue::TTimeValue(sal_uInt32 Secs, sal_uInt32 Nano)
+{
+ Seconds = Secs;
+ Nanosec = Nano;
+
+ normalize();
+}
+
+inline void TTimeValue::addTime(const TTimeValue& Time)
+{
+ Seconds += Time.Seconds;
+ Nanosec += Time.Nanosec;
+
+ normalize();
+}
+
+inline sal_Bool TTimeValue::isEmpty() const
+{
+ return ((Seconds == 0) && (Nanosec == 0));
+}
+
+inline sal_Bool operator<(const TTimeValue& rTimeA, const TTimeValue& rTimeB)
+{
+ if (rTimeA.Seconds < rTimeB.Seconds)
+ return sal_True;
+ else if (rTimeA.Seconds > rTimeB.Seconds)
+ return sal_False;
+ else
+ return (rTimeA.Nanosec < rTimeB.Nanosec);
+}
+
+inline sal_Bool operator>(const TTimeValue& rTimeA, const TTimeValue& rTimeB)
+{
+ if (rTimeA.Seconds > rTimeB.Seconds)
+ return sal_True;
+ else if (rTimeA.Seconds < rTimeB.Seconds)
+ return sal_False;
+ else
+ return (rTimeA.Nanosec > rTimeB.Nanosec);
+}
+
+inline sal_Bool operator==(const TTimeValue& rTimeA, const TTimeValue& rTimeB)
+{
+ return ((rTimeA.Seconds == rTimeB.Seconds) &&
+ (rTimeA.Nanosec == rTimeB.Nanosec));
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Timer class
+//
+
+class OTimerManager;
+
+/** <code> class OTimer </code> : Interface for the Timer and handling the event
+*/
+class OTimer : virtual public OReference , virtual public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OTimer, vos));
+
+public:
+
+ /// constructor
+ OTimer();
+ /// constructor
+ OTimer(const TTimeValue& Time);
+ /// constructor
+ OTimer(const TTimeValue& Time, const TTimeValue& RepeatTime);
+ /// start timer.
+ void SAL_CALL start();
+ /// abort timer prematurely.
+ void SAL_CALL stop();
+ /// returns <code> sal_True </code> if timer is running.
+ sal_Bool SAL_CALL isTicking() const;
+ /// is the timer expired?
+ sal_Bool SAL_CALL isExpired() const;
+ /// does <code> pTimer </code> expires before us?
+ sal_Bool SAL_CALL expiresBefore(const OTimer* pTimer) const;
+ /// set the absolute time when the timer should fire
+ void SAL_CALL setAbsoluteTime(const TTimeValue& Time);
+ /// set the time to fire to 'now' + <code> Remaining </code>
+ void SAL_CALL setRemainingTime(const TTimeValue& Remaining);
+ /// set the time to fire to 'now' + <code> Remaining </code> with repeat interveal <code> Repeat </code>
+ void SAL_CALL setRemainingTime(const TTimeValue& Remaining, const TTimeValue& Repeat);
+ /// adds <code> Time </code> to the 'fire time'
+ void SAL_CALL addTime(const TTimeValue& Time);
+ /// returns the remaining time before timer expiration relative to now
+ TTimeValue SAL_CALL getRemainingTime() const;
+
+protected:
+
+ /// destructor
+ virtual ~OTimer();
+ /// what should be done when the 'timer fires'
+ virtual void SAL_CALL onShot() = 0;
+
+ /// holds (initial) exparation time of this timer
+ TTimeValue m_TimeOut;
+ /// holds the time of exparation of this timer
+ TTimeValue m_Expired;
+ /// holds the time interveal of successive exparations
+ TTimeValue m_RepeatDelta;
+ /// Pointer to the next timer (to fire)
+ OTimer* m_pNext;
+
+private:
+
+ /// copy constructor disabled
+ OTimer(const OTimer& rTimer);
+ /// assignment operator disabled
+ void SAL_CALL operator=(const OTimer& rTimer);
+
+ friend class OTimerManager;
+};
+
+}
+
+
+#endif //_VOS_TIMER_HXX_
+
+
diff --git a/vos/inc/vos/types.hxx b/vos/inc/vos/types.hxx
new file mode 100644
index 000000000000..c68f04e44d96
--- /dev/null
+++ b/vos/inc/vos/types.hxx
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * 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 _VOS_TYPES_HXX_
+#define _VOS_TYPES_HXX_
+
+
+/* disable some warnings for MS-C */
+#ifdef _MSC_VER
+# pragma warning (disable : 4786) // 4786: truncated names (longer 255 chars)
+# pragma warning (disable : 4355) // 4355: this used in initializer-list
+#endif
+
+#endif //_VOS_TYPES_HXX_
+
diff --git a/vos/inc/vos/xception.hxx b/vos/inc/vos/xception.hxx
new file mode 100644
index 000000000000..fff67cf4a9c6
--- /dev/null
+++ b/vos/inc/vos/xception.hxx
@@ -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 _XCEPTION_HXX_
+#define _XCEPTION_HXX_
+
+#include <vos/object.hxx>
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4290 )
+#endif
+
+namespace vos
+{
+
+/* avoid clashes with <vos/exception.hxx> */
+#define OException OBaseException
+
+/*
+ * Macros for true try/catch based Exception Handling (public)
+ * based on true rtti type checking
+ */
+
+#define THROW_AGAIN throw;
+#define THROW( Constructor ) throw Constructor;
+
+/*
+ * declaration of the exceptions that may be thrown by a function
+ * (e.g.) void myfunction(sal_Int32 a) throw ( std::bad_alloc );
+ * is not fully supported by all compilers
+ */
+
+#define THROWS( ARG ) throw ARG
+
+/*
+ * just a base class for further exceptions
+ */
+
+class OException : public OObject
+{
+ VOS_DECLARE_CLASSINFO(VOS_NAMESPACE(OException, vos));
+
+public:
+ virtual ~OException();
+ OException() {}
+ OException( const OException & ) : OObject() {}
+
+ OException& SAL_CALL operator=(const OException&)
+ { return *this; }
+};
+
+}
+
+#endif /* _XCEPTION_HXX_ */
+
diff --git a/vos/prj/build.lst b/vos/prj/build.lst
new file mode 100644
index 000000000000..acc2d2f7b2a3
--- /dev/null
+++ b/vos/prj/build.lst
@@ -0,0 +1,6 @@
+vo vos : sal solenv NULL
+vo vos usr1 - all vo_mkout NULL
+vo vos\inc\vos get - all vo_inc NULL
+vo vos\prj get - all vo_prj NULL
+vo vos\source nmake - all vo_sou NULL
+vo vos\util nmake - all vo_util vo_sou NULL
diff --git a/vos/prj/d.lst b/vos/prj/d.lst
new file mode 100644
index 000000000000..94d46bd59a68
--- /dev/null
+++ b/vos/prj/d.lst
@@ -0,0 +1,15 @@
+mkdir: %_DEST%\inc%_EXT%\vos
+..\version.mk %_DEST%\inc%_EXT%\vos\version.mk
+..\inc\vos\*.h %_DEST%\inc%_EXT%\vos\*.h
+..\inc\vos\*.hxx %_DEST%\inc%_EXT%\vos\*.hxx
+..\inc\vos\*.inl %_DEST%\inc%_EXT%\vos\*.inl
+
+..\%__SRC%\lib\avos.lib %_DEST%\lib%_EXT%\avos.lib
+..\%__SRC%\lib\ivos.lib %_DEST%\lib%_EXT%\ivos.lib
+..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl
+..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%
+..\%__SRC%\lib\lib*.a %_DEST%\lib%_EXT%
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\slb\cppvos.lib %_DEST%\lib%_EXT%\xvos.lib
+
+..\%__SRC%\bin\vos*.dll %_DEST%\bin%_EXT%\vos*.dll
diff --git a/vos/source/conditn.cxx b/vos/source/conditn.cxx
new file mode 100644
index 000000000000..f6acc4bb7fab
--- /dev/null
+++ b/vos/source/conditn.cxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * 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 <osl/time.h>
+#include <vos/conditn.hxx>
+#include <vos/diagnose.hxx>
+
+using namespace vos;
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OCondition, vos), VOS_NAMESPACE(OCondition, vos), VOS_NAMESPACE(OObject, vos), 0);
+
+/// initial state of condition is not set
+OCondition::OCondition()
+{
+ m_Condition= osl_createCondition();
+}
+
+OCondition::~OCondition()
+{
+ osl_destroyCondition(m_Condition);
+}
+
+/// set condition to sal_True => wait() will not block, check() returns sal_True
+void OCondition::set()
+{
+ osl_setCondition(m_Condition);
+}
+
+/// set condition to sal_False => wait() will block, check() returns sal_False
+void OCondition::reset()
+{
+ osl_resetCondition(m_Condition);
+}
+
+/** Blocks if condition is not set<BR>
+ If condition has been destroyed prematurely, wait() will
+ return with sal_False.
+*/
+OCondition::TResult OCondition::wait(const TimeValue* pTimeout)
+{
+ return (TResult)osl_waitCondition(m_Condition, pTimeout);
+}
+
+/** sal_True: condition is set <BR>
+ sal_False: condition is not set <BR>
+ does not block
+*/
+sal_Bool OCondition::check()
+{
+ return osl_checkCondition(m_Condition);
+}
+
diff --git a/vos/source/dllentry.cxx b/vos/source/dllentry.cxx
new file mode 100644
index 000000000000..d25de20bfb9f
--- /dev/null
+++ b/vos/source/dllentry.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+
+#include <windows.h>
+#include <winsock.h>
+
+
+#ifdef SHARED
+
+sal_Int32 CALLBACK LibMain(HINSTANCE hinst, WORD wDataSeg, WORD cbHeap, LPSTR lpszCmdLine )
+{
+ HGLOBAL hgblClassStruct;
+ LPWNDCLASS lpClassStruct;
+ static HINSTANCE hinstLib = NULL;
+
+ /* Has the library been initialized yet? */
+ if (hinstLib == NULL)
+ {
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ sal_Int32 error;
+
+
+ wVersionRequested = 0x0101;
+ error = WSAStartup( wVersionRequested, &wsaData );
+ if (error)
+ {
+ }
+ else
+ hinstLib = hinst;
+ }
+
+ return (hinstLib ? TRUE : FALSE); /* return TRUE = success; FALSE = fail */
+}
+
+#endif
+
diff --git a/vos/source/makefile.mk b/vos/source/makefile.mk
new file mode 100644
index 000000000000..7a4e6061622d
--- /dev/null
+++ b/vos/source/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=vos
+TARGET=cppvos
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/conditn.obj \
+ $(SLO)$/mutex.obj \
+ $(SLO)$/object.obj \
+ $(SLO)$/refernce.obj \
+ $(SLO)$/socket.obj \
+ $(SLO)$/thread.obj \
+ $(SLO)$/stream.obj \
+ $(SLO)$/module.obj \
+ $(SLO)$/timer.obj \
+ $(SLO)$/process.obj \
+ $(SLO)$/security.obj \
+ $(SLO)$/signal.obj \
+ $(SLO)$/pipe.obj \
+ $(SLO)$/xception.obj
+
+
+.IF "$(UPDATER)"=="YES"
+OBJFILES= $(OBJ)$/conditn.obj \
+ $(OBJ)$/mutex.obj \
+ $(OBJ)$/object.obj \
+ $(OBJ)$/refernce.obj \
+ $(OBJ)$/socket.obj \
+ $(OBJ)$/thread.obj \
+ $(OBJ)$/stream.obj \
+ $(OBJ)$/module.obj \
+ $(OBJ)$/timer.obj \
+ $(OBJ)$/process.obj \
+ $(OBJ)$/security.obj \
+ $(OBJ)$/signal.obj \
+ $(OBJ)$/pipe.obj \
+ $(OBJ)$/xception.obj
+
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+
diff --git a/vos/source/module.cxx b/vos/source/module.cxx
new file mode 100644
index 000000000000..23b916d2b1f9
--- /dev/null
+++ b/vos/source/module.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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 <vos/module.hxx>
+#include <vos/diagnose.hxx>
+
+using namespace vos;
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OModule, vos),
+ VOS_NAMESPACE(OModule, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+
+OModule::OModule()
+ :m_Module(0)
+{
+}
+
+OModule::OModule(const rtl::OUString& ustrModuleName, sal_Int32 nRtldMode) : m_Module(0)
+{
+ if (ustrModuleName)
+ load(ustrModuleName, nRtldMode);
+}
+
+OModule::~OModule()
+{
+ if (m_Module)
+ osl_unloadModule(m_Module);
+}
+
+sal_Bool OModule::load(const rtl::OUString& ustrModuleName, sal_Int32 nRtldMode)
+{
+ VOS_ASSERT(ustrModuleName);
+
+ unload();
+
+ m_Module = osl_loadModule( ustrModuleName.pData, nRtldMode );
+
+ return (m_Module != 0);
+}
+
+void OModule::unload()
+{
+ if (m_Module)
+ {
+ osl_unloadModule(m_Module);
+ m_Module = 0;
+ }
+}
+
+sal_Bool OModule::isLoaded()
+{
+ return m_Module != NULL;
+}
+
+void *OModule::getSymbol(const rtl::OUString& strSymbolName)
+{
+ VOS_ASSERT(strSymbolName);
+ VOS_ASSERT(m_Module);
+ return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
+}
+
diff --git a/vos/source/mutex.cxx b/vos/source/mutex.cxx
new file mode 100644
index 000000000000..d8cefb92028f
--- /dev/null
+++ b/vos/source/mutex.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+#include <vos/diagnose.hxx>
+#include <vos/object.hxx>
+#include <vos/mutex.hxx>
+
+using namespace vos;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// class Mutex
+//
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OMutex, vos), VOS_NAMESPACE(OMutex, vos), VOS_NAMESPACE(OObject, vos), 0);
+
+IMutex& OMutex::getGlobalMutex()
+{
+ static OMutex theGlobalMutex;
+
+ return theGlobalMutex;
+}
+
+OMutex::OMutex()
+{
+ m_Impl= osl_createMutex();
+}
+
+OMutex::~OMutex()
+{
+ osl_destroyMutex(m_Impl);
+}
+
+void OMutex::acquire()
+{
+ osl_acquireMutex(m_Impl);
+}
+
+sal_Bool OMutex::tryToAcquire()
+{
+ return osl_tryToAcquireMutex(m_Impl);
+}
+
+void OMutex::release()
+{
+ osl_releaseMutex(m_Impl);
+}
+
diff --git a/vos/source/object.cxx b/vos/source/object.cxx
new file mode 100644
index 000000000000..8761c7e4daed
--- /dev/null
+++ b/vos/source/object.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+#include <string.h>
+
+#include <rtl/alloc.h>
+#include <rtl/memory.h>
+
+#include <vos/diagnose.hxx>
+
+#include <vos/object.hxx>
+
+using namespace vos;
+
+/////////////////////////////////////////////////////////////////////////////
+// Object super class
+
+VOS_NAMESPACE(OClassInfo, vos) VOS_NAMESPACE(OObject, vos)::__ClassInfo__(VOS_CLASSNAME(OObject, vos), sizeof(VOS_NAMESPACE(OObject, vos)));
+
+OObject::OObject()
+{
+}
+
+OObject::OObject(const OCreateParam&)
+{
+}
+
+OObject::~OObject()
+{
+}
+
+void* OObject::operator new(size_t size)
+{
+ void* p = rtl_allocateMemory(size);
+
+ VOS_ASSERT(p != NULL);
+
+ return (p);
+}
+
+void* OObject::operator new(size_t, void* p)
+{
+ return (p);
+}
+
+void OObject::operator delete(void* p)
+{
+ rtl_freeMemory(p);
+}
+
+const OClassInfo& OObject::classInfo()
+{
+ return (__ClassInfo__);
+}
+
+const OClassInfo& OObject::getClassInfo() const
+{
+ return (VOS_CLASSINFO(VOS_NAMESPACE(OObject, vos)));
+}
+
+sal_Bool OObject::isKindOf(const OClassInfo& rClass) const
+{
+ VOS_ASSERT(this != NULL);
+
+ const OClassInfo& rClassThis = getClassInfo();
+
+ return (rClassThis.isDerivedFrom(rClass));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Basic class information
+
+OClassInfo::OClassInfo(const sal_Char *pClassName, sal_Int32 ObjectSize,
+ const OClassInfo* pBaseClass, sal_uInt32 Schema,
+ OObject* (SAL_CALL * fnCreateObject)(const OCreateParam&))
+{
+ m_pClassName = pClassName;
+ m_nObjectSize = ObjectSize;
+ m_wSchema = Schema;
+
+ m_pfnCreateObject = fnCreateObject;
+
+ m_pBaseClass = pBaseClass;
+ m_pNextClass = NULL;
+}
+
+OObject* OClassInfo::createObject(const OCreateParam& rParam) const
+{
+ if (m_pfnCreateObject == NULL)
+ return NULL;
+
+ OObject* pObject = NULL;
+ pObject = (*m_pfnCreateObject)(rParam);
+
+ return (pObject);
+}
+
+sal_Bool OClassInfo::isDerivedFrom(const OClassInfo& rClass) const
+{
+ VOS_ASSERT(this != NULL);
+
+ const OClassInfo* pClassThis = this;
+
+ while (pClassThis != NULL)
+ {
+ if (pClassThis == &rClass)
+ return (sal_True);
+
+ pClassThis = pClassThis->m_pBaseClass;
+ }
+
+ return (sal_False); // walked to the top, no match
+}
+
+const OClassInfo* OClassInfo::getClassInfo(const sal_Char* pClassName)
+{
+ VOS_ASSERT(pClassName != NULL);
+
+ const OClassInfo* pClass = &VOS_CLASSINFO(VOS_NAMESPACE(OObject, vos));
+
+ while (pClass != NULL)
+ {
+ if (strcmp(pClassName, pClass->m_pClassName) == 0)
+ break;
+
+ pClass = pClass->m_pNextClass;
+ }
+
+ return (pClass);
+}
+
+VOS_CLASSINIT::VOS_CLASSINIT(register OClassInfo* pNewClass)
+{
+ VOS_ASSERT(pNewClass != NULL);
+
+ OClassInfo* pClassRoot = (OClassInfo*)&VOS_CLASSINFO(VOS_NAMESPACE(OObject, vos));
+
+ pNewClass->m_pNextClass = pClassRoot->m_pNextClass;
+
+ pClassRoot->m_pNextClass = pNewClass;
+}
diff --git a/vos/source/pipe.cxx b/vos/source/pipe.cxx
new file mode 100644
index 000000000000..a7d8e655414d
--- /dev/null
+++ b/vos/source/pipe.cxx
@@ -0,0 +1,416 @@
+/*************************************************************************
+ *
+ * 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 <vos/pipe.hxx>
+#include <vos/diagnose.hxx>
+
+using namespace vos;
+
+///////////////////////////////////////////////////////////////////////////////
+// Pipe
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OPipe, vos),
+ VOS_NAMESPACE(OPipe, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+/*****************************************************************************/
+// OPipe()
+/*****************************************************************************/
+OPipe::OPipe()
+{
+ m_pPipeRef= 0;
+}
+
+/*****************************************************************************/
+// OPipe()
+/*****************************************************************************/
+
+OPipe::OPipe( const rtl::OUString& strName, TPipeOption Options)
+{
+ m_pPipeRef =
+ new PipeRef( osl_createPipe(strName.pData,
+ (oslPipeOptions)Options,
+ NULL) );
+
+ VOS_POSTCOND(m_pPipeRef != 0, "OPipe(): new failed.\n");
+ VOS_POSTCOND((*m_pPipeRef)(), "OPipe(): creation of pipe failed!\n");
+}
+
+/*****************************************************************************/
+// OPipe()
+/*****************************************************************************/
+
+OPipe::OPipe( const rtl::OUString& strName,
+ TPipeOption Options,
+ const OSecurity& rSecurity)
+{
+ m_pPipeRef=
+ new PipeRef(osl_createPipe(strName.pData,
+ (oslPipeOptions)Options,
+ (oslSecurity)rSecurity));
+
+ VOS_POSTCOND(m_pPipeRef != 0, "OPipe(): new failed.\n");
+ VOS_POSTCOND((*m_pPipeRef)(), "OPipe(): creation of pipe failed!\n");
+}
+
+/*****************************************************************************/
+// OPipe()
+/*****************************************************************************/
+OPipe::OPipe(const OPipe& pipe) :
+OReference(), OObject()
+{
+
+ VOS_ASSERT(pipe.m_pPipeRef != 0);
+
+ m_pPipeRef= pipe.m_pPipeRef;
+
+ m_pPipeRef->acquire();
+}
+
+/*****************************************************************************/
+// OPipe()
+/*****************************************************************************/
+OPipe::OPipe(oslPipe Pipe)
+{
+ m_pPipeRef = new PipeRef(Pipe);
+}
+
+
+/*****************************************************************************/
+// ~OPipe()
+/*****************************************************************************/
+OPipe::~OPipe()
+{
+ close();
+}
+
+/*****************************************************************************/
+// create
+/*****************************************************************************/
+sal_Bool OPipe::create( const rtl::OUString& strName, TPipeOption Options )
+{
+ // if this was a valid pipe, decrease reference
+ if ((m_pPipeRef) && (m_pPipeRef->release() == 0))
+ {
+ osl_releasePipe((*m_pPipeRef)());
+ delete m_pPipeRef;
+ m_pPipeRef= 0;
+ }
+
+ m_pPipeRef=
+ new PipeRef(osl_createPipe(strName.pData,
+ (oslPipeOptions)Options,
+ NULL));
+
+ VOS_POSTCOND(m_pPipeRef != 0, "OPipe(): new failed.\n");
+
+ return (*m_pPipeRef)() != 0;
+}
+
+/*****************************************************************************/
+// create
+/*****************************************************************************/
+sal_Bool OPipe::create( const rtl::OUString& strName,
+ TPipeOption Options,
+ const NAMESPACE_VOS(OSecurity)& rSecurity )
+{
+ // if this was a valid pipe, decrease reference
+ if ((m_pPipeRef) && (m_pPipeRef->release() == 0))
+ {
+ osl_releasePipe((*m_pPipeRef)());
+ delete m_pPipeRef;
+ m_pPipeRef= 0;
+ }
+
+ m_pPipeRef=
+ new PipeRef(osl_createPipe(strName.pData,
+ (oslPipeOptions)Options,
+ (oslSecurity)rSecurity));
+
+ VOS_POSTCOND(m_pPipeRef != 0, "OPipe(): new failed.\n");
+
+ return (*m_pPipeRef)() != 0;
+}
+
+/*****************************************************************************/
+// operator=
+/*****************************************************************************/
+OPipe& OPipe::operator= (const OPipe& pipe)
+{
+ VOS_PRECOND(pipe.m_pPipeRef != 0, "OPipe::operator=: tried to assign an empty/invalid pipe\n");
+
+ if (m_pPipeRef == pipe.m_pPipeRef)
+ return *this;
+
+ // if this was a valid pipe, decrease reference
+ if ((m_pPipeRef) && (m_pPipeRef->release() == 0))
+ {
+ osl_releasePipe((*m_pPipeRef)());
+ delete m_pPipeRef;
+ m_pPipeRef= 0;
+ }
+
+ m_pPipeRef= pipe.m_pPipeRef;
+
+ m_pPipeRef->acquire();
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator oslPipe()
+/*****************************************************************************/
+OPipe::operator oslPipe() const
+{
+ VOS_ASSERT(m_pPipeRef);
+ return (*m_pPipeRef)();
+}
+
+/*****************************************************************************/
+// isValid()
+/*****************************************************************************/
+sal_Bool OPipe::isValid() const
+{
+ return m_pPipeRef != 0 && (*m_pPipeRef)() != 0;
+}
+
+
+/*****************************************************************************/
+// close
+/*****************************************************************************/
+void OPipe::close()
+{
+ if (m_pPipeRef && (m_pPipeRef->release() == 0))
+ {
+ osl_releasePipe((*m_pPipeRef)());
+ delete m_pPipeRef;
+ }
+ m_pPipeRef= 0;
+}
+
+/*****************************************************************************/
+// accept
+/*****************************************************************************/
+OPipe::TPipeError OPipe::accept(OStreamPipe& Connection)
+{
+ if ( isValid() )
+ {
+ Connection = osl_acceptPipe((*m_pPipeRef)());
+
+ if(Connection.isValid())
+ return E_None;
+ }
+
+ return getError();
+}
+
+/*****************************************************************************/
+// recv
+/*****************************************************************************/
+sal_Int32 OPipe::recv(void* pBuffer, sal_uInt32 BytesToRead)
+{
+ if ( isValid() )
+ return osl_receivePipe((*m_pPipeRef)(),
+ pBuffer,
+ BytesToRead);
+ else
+ return -1;
+
+}
+
+/*****************************************************************************/
+// send
+/*****************************************************************************/
+sal_Int32 OPipe::send(const void* pBuffer, sal_uInt32 BytesToSend)
+{
+ if ( isValid() )
+ return osl_sendPipe((*m_pPipeRef)(),
+ pBuffer,
+ BytesToSend);
+ else
+ return -1;
+}
+
+/*****************************************************************************/
+// getError
+/*****************************************************************************/
+OPipe::TPipeError OPipe::getError() const
+{
+ if (m_pPipeRef)
+ return (TPipeError)osl_getLastPipeError((*m_pPipeRef)());
+ else
+ return (TPipeError)osl_getLastPipeError(NULL);
+}
+
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OStreamPipe, vos),
+ VOS_NAMESPACE(OStreamPipe, vos),
+ VOS_NAMESPACE(OPipe, vos), 0);
+
+
+
+/*****************************************************************************/
+// OStreamPipe
+/*****************************************************************************/
+OStreamPipe::OStreamPipe()
+{
+}
+
+/*****************************************************************************/
+// OStreamPipe
+/*****************************************************************************/
+OStreamPipe::OStreamPipe(oslPipe Pipe) :
+ OPipe(Pipe)
+{
+}
+
+/*****************************************************************************/
+// OStreamPipe
+// copy constructor
+/*****************************************************************************/
+OStreamPipe::OStreamPipe(const OStreamPipe& pipe) :
+OPipe(), IStream()
+{
+ VOS_ASSERT(pipe.m_pPipeRef != 0);
+
+ m_pPipeRef= pipe.m_pPipeRef;
+
+ m_pPipeRef->acquire();
+}
+
+/*****************************************************************************/
+// ~OStreamPipe
+/*****************************************************************************/
+OStreamPipe::~OStreamPipe()
+{
+}
+
+/*****************************************************************************/
+// operator=(oslPipe)
+/*****************************************************************************/
+OStreamPipe& OStreamPipe::operator=(oslPipe Pipe)
+{
+
+ // if this was a valid pipe, decrease reference
+ if (m_pPipeRef && (m_pPipeRef->release() == 0))
+ {
+ osl_releasePipe((*m_pPipeRef)());
+ delete m_pPipeRef;
+ m_pPipeRef= 0;
+ }
+
+ m_pPipeRef= new PipeRef(Pipe);
+
+ VOS_POSTCOND(m_pPipeRef != 0, "OPipe(): new failed.\n");
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator=OPipe
+/*****************************************************************************/
+
+OStreamPipe& OStreamPipe::operator= (const OPipe& pipe)
+{
+ OPipe::operator= ( pipe );
+ return *this;
+}
+
+/*****************************************************************************/
+// read
+/*****************************************************************************/
+sal_Int32 OStreamPipe::read(void* pBuffer, sal_uInt32 n) const
+{
+ VOS_ASSERT(m_pPipeRef && (*m_pPipeRef)());
+
+ /* loop until all desired bytes were read or an error occured */
+ sal_Int32 BytesRead= 0;
+ sal_Int32 BytesToRead= n;
+ while (BytesToRead > 0)
+ {
+ sal_Int32 RetVal;
+ RetVal= osl_receivePipe((*m_pPipeRef)(),
+ pBuffer,
+ BytesToRead);
+
+ /* error occured? */
+ if(RetVal <= 0)
+ {
+ break;
+ }
+
+ BytesToRead -= RetVal;
+ BytesRead += RetVal;
+ pBuffer= (sal_Char*)pBuffer + RetVal;
+ }
+
+ return BytesRead;
+}
+
+/*****************************************************************************/
+// write
+/*****************************************************************************/
+sal_Int32 OStreamPipe::write(const void* pBuffer, sal_uInt32 n)
+{
+ VOS_ASSERT(m_pPipeRef && (*m_pPipeRef)());
+
+ /* loop until all desired bytes were send or an error occured */
+ sal_Int32 BytesSend= 0;
+ sal_Int32 BytesToSend= n;
+ while (BytesToSend > 0)
+ {
+ sal_Int32 RetVal;
+
+ RetVal= osl_sendPipe((*m_pPipeRef)(),
+ pBuffer,
+ BytesToSend);
+
+ /* error occured? */
+ if(RetVal <= 0)
+ {
+ break;
+ }
+
+ BytesToSend -= RetVal;
+ BytesSend += RetVal;
+ pBuffer= (sal_Char*)pBuffer + RetVal;
+ }
+
+ return BytesSend;
+}
+
+sal_Bool OStreamPipe::isEof() const
+{
+ return isValid();
+}
+
+
+
+
diff --git a/vos/source/process.cxx b/vos/source/process.cxx
new file mode 100644
index 000000000000..71c8729d9023
--- /dev/null
+++ b/vos/source/process.cxx
@@ -0,0 +1,525 @@
+/*************************************************************************
+ *
+ * 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 <cstdarg>
+#include <vector>
+#include <rtl/ustring.hxx>
+#include <rtl/instance.hxx>
+
+#include "vos/process.hxx"
+#include "vos/diagnose.hxx"
+#include <osl/file.hxx>
+
+#define MAX_RESOURCES 100
+#define MAX_ARGS 100
+#define MAX_ENVIROMENTS 100
+
+using namespace vos;
+
+/////////////////////////////////////////////////////////////////////////////
+/// Argument
+
+OArgumentList::OArgumentList() :
+ n_Args(0),
+ m_aVec(0)
+{
+ // empty
+}
+
+OArgumentList::OArgumentList( sal_uInt32 nArgs, const ::rtl::OUString* aArgument1, ... ) :
+ n_Args( nArgs )
+{
+ m_aVec = new rtl_uString* [nArgs];
+ std::va_list pArgs;
+ sal_uInt32 i = 0;
+ const rtl::OUString* aArgument;
+
+ va_start ( pArgs, aArgument1 );
+ aArgument = aArgument1;
+
+ while( true ) {
+ m_aVec[i] = aArgument->pData;
+ rtl_uString_acquire( m_aVec[i++] );
+ if( i < n_Args )
+ aArgument = va_arg( pArgs,rtl::OUString* );
+ else
+ break;
+ }
+ va_end( pArgs );
+}
+
+
+OArgumentList::OArgumentList( const rtl::OUString aArgumentList[], sal_uInt32 nArgs ) :
+ n_Args( nArgs )
+{
+ m_aVec = new rtl_uString* [n_Args];
+ for( sal_uInt32 i = 0; i < n_Args; ++ i ) {
+ m_aVec[i] = aArgumentList[i].pData;
+ rtl_uString_acquire( m_aVec[i] );
+ }
+}
+
+OArgumentList::OArgumentList( const OArgumentList& rOther ) : n_Args( rOther.n_Args )
+{
+ m_aVec = new rtl_uString* [n_Args];
+
+ sal_uInt32 i;
+ for ( i = 0; i < n_Args; ++i )
+ {
+ m_aVec[i] = rOther.m_aVec[i];
+ rtl_uString_acquire( m_aVec[i] );
+ }
+}
+
+OArgumentList& OArgumentList::operator=( const OArgumentList& rOther )
+{
+ if ( this != &rOther )
+ {
+
+ // delete the old one
+ sal_uInt32 i;
+ for ( i = 0; i < n_Args; ++i )
+ rtl_uString_release( m_aVec[i] );
+
+ delete [] m_aVec;
+
+
+ n_Args = rOther.n_Args;
+ m_aVec = new rtl_uString* [n_Args];
+ for( i = 0; i < n_Args; ++i )
+ {
+ m_aVec[i] = rOther.m_aVec[i];
+ rtl_uString_acquire( m_aVec[i] );
+ }
+ }
+
+ return *this;
+}
+
+OArgumentList::~OArgumentList( )
+{
+ for( sal_uInt32 i = 0; i < n_Args; ++i ) rtl_uString_release( m_aVec[i] );
+ delete[] m_aVec;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// Environment
+
+OEnvironment::OEnvironment() :
+ n_Vars( 0 ),
+ m_aVec( 0 )
+{
+}
+
+OEnvironment::OEnvironment( sal_Int32 nVars, const ::rtl::OUString* aArgument1, ... ) :
+ n_Vars( nVars )
+{
+ m_aVec = new rtl_uString* [nVars];
+ std::va_list pArgs;
+ sal_Int32 i = 0;
+ const rtl::OUString* aArgument;
+
+ va_start ( pArgs, aArgument1 );
+ aArgument = aArgument1;
+
+ while( true ) {
+ m_aVec[i] = aArgument->pData;
+ rtl_uString_acquire( m_aVec[i++] );
+ if( i < n_Vars )
+ aArgument = va_arg( pArgs,rtl::OUString* );
+ else
+ break;
+ }
+ va_end( pArgs );
+}
+
+
+OEnvironment::OEnvironment( const ::rtl::OUString aVariableList[], sal_Int32 nVars ) :
+ n_Vars( nVars )
+{
+ m_aVec = new rtl_uString* [n_Vars];
+ for( sal_Int32 i = 0; i < n_Vars; ++ i ) {
+ m_aVec[i] = aVariableList[i].pData;
+ rtl_uString_acquire( m_aVec[i] );
+ }
+}
+
+OEnvironment::OEnvironment( const OEnvironment& rOther ) : n_Vars( rOther.n_Vars )
+{
+ m_aVec = new rtl_uString* [n_Vars];
+
+ sal_Int32 i;
+ for ( i = 0; i < n_Vars; ++i )
+ {
+ m_aVec[i] = rOther.m_aVec[i];
+ rtl_uString_acquire( m_aVec[i] );
+ }
+}
+
+OEnvironment& OEnvironment::operator=( const OEnvironment& rOther )
+{
+ if ( this != &rOther )
+ {
+ sal_Int32 i;
+ for ( i = 0; i < n_Vars; ++i )
+ rtl_uString_release( m_aVec[i] );
+
+ delete [] m_aVec;
+
+ n_Vars = rOther.n_Vars;
+ m_aVec = new rtl_uString* [n_Vars];
+ for ( i = 0; i < n_Vars; ++i )
+ {
+ m_aVec[i] = rOther.m_aVec[i];
+ rtl_uString_acquire( m_aVec[i] );
+ }
+ }
+
+ return *this;
+}
+
+OEnvironment::~OEnvironment()
+{
+ for( sal_Int32 i = 0; i < n_Vars; ++i ) rtl_uString_release( m_aVec[i] );
+ delete[] m_aVec;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Process
+
+
+VOS_IMPLEMENT_CLASSINFO(
+ VOS_CLASSNAME(OProcess, vos),
+ VOS_NAMESPACE(OProcess, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+
+OProcess::OProcess( ) :
+ m_strImageName( ),
+ m_strDirectory(),
+ m_Process(0)
+{
+}
+
+
+OProcess::OProcess( const rtl::OUString& strImageName ) :
+ m_strImageName( strImageName ),
+ m_strDirectory(),
+ m_Process(0)
+{
+ // empty
+}
+
+
+OProcess::OProcess(const rtl::OUString& strImageName, const rtl::OUString& strWorkingDirectory) :
+ m_strImageName( strImageName ),
+ m_strDirectory( strWorkingDirectory ),
+ m_Process(0)
+{
+ // empty
+}
+
+
+OProcess::~OProcess()
+{
+ osl_freeProcessHandle(m_Process);
+}
+
+OProcess* OProcess::getProcess(TProcessIdentifier Identifier)
+{
+ oslProcess hProcess = osl_getProcess(Identifier);
+
+ if (hProcess)
+ {
+ OProcess* pProcess = new OProcess( );
+
+ pProcess->m_Process = hProcess;
+
+ return pProcess;
+ }
+
+ return 0;
+}
+
+
+OProcess::TProcessError OProcess::execute(TProcessOption Options,
+ const OArgumentList& aArgumentList,
+ const OEnvironment& aEnvironment )
+{
+ return ((TProcessError)osl_executeProcess(m_strImageName.pData,
+ aArgumentList.m_aVec,
+ aArgumentList.n_Args,
+ Options,
+ 0,
+ m_strDirectory.pData,
+ aEnvironment.m_aVec,
+ aEnvironment.n_Vars,
+ &m_Process));
+}
+
+
+OProcess::TProcessError OProcess::execute( TProcessOption Options,
+ const OSecurity &Security,
+ const OArgumentList& aArgumentList,
+ const OEnvironment& aEnvironment )
+{
+ return ((TProcessError)osl_executeProcess(m_strImageName.pData,
+ aArgumentList.m_aVec,
+ aArgumentList.n_Args,
+ Options,
+ Security,
+ m_strDirectory.pData,
+ aEnvironment.m_aVec,
+ aEnvironment.n_Vars,
+ &m_Process));
+}
+
+
+OProcess::TProcessError OProcess::terminate()
+{
+ return (TProcessError)osl_terminateProcess(m_Process);
+}
+
+OProcess::TProcessError OProcess::getInfo(TProcessData Data, TProcessInfo* pInfo) const
+{
+ return (TProcessError)osl_getProcessInfo(m_Process, Data, pInfo);
+}
+
+OProcess::TProcessError OProcess::getCurrentInfo(TProcessData Data, TProcessInfo* pInfo)
+{
+ return (TProcessError)osl_getProcessInfo(0, Data, pInfo);
+}
+
+OProcess::TProcessError OProcess::join()
+{
+ return (TProcessError)osl_joinProcess(m_Process);
+}
+
+
+/*
+OProcess::TProcessError OProcess::searchPath(const sal_Char* Name, sal_Char *Buffer, sal_uInt32 Max,
+ const sal_Char* Path, sal_Char Separator)
+{
+ return (TProcessError)osl_searchPath(Name, Path, Separator, Buffer, Max);
+}
+*/
+
+/////////////////////////////////////////////////////////////////////////////
+// StartupInfo
+
+VOS_IMPLEMENT_CLASSINFO(
+ VOS_CLASSNAME(OStartupInfo, vos),
+ VOS_NAMESPACE(OStartupInfo, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OStartupInfo::OStartupInfo()
+{
+}
+
+OStartupInfo::~OStartupInfo()
+{
+}
+
+OStartupInfo::TStartupError OStartupInfo::getExecutableFile(
+ rtl::OUString& strImageName ) const
+{
+ return (TStartupError) osl_getExecutableFile( &strImageName.pData );
+}
+
+
+OStartupInfo::TStartupError OStartupInfo::getCommandArg(sal_uInt32 nArg, rtl::OUString& strCommandArg)
+{
+ return ( TStartupError ) osl_getCommandArg( nArg,&strCommandArg.pData );
+}
+
+sal_uInt32 OStartupInfo::getCommandArgCount()
+{
+ return osl_getCommandArgCount();
+}
+
+OStartupInfo::TStartupError OStartupInfo::getEnvironment(const rtl::OUString& strVar,
+ rtl::OUString& strValue)
+{
+ return ( TStartupError ) osl_getEnvironment( strVar.pData, &strValue.pData );
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// OExtCommandLineImpl
+//
+
+namespace vos
+{
+
+class OExtCommandLineImpl
+{
+ void init();
+
+ ::std::vector< ::rtl::OUString > aExtArgVector;
+ sal_uInt32 m_nArgCount;
+
+public:
+
+ OExtCommandLineImpl();
+ ~OExtCommandLineImpl();
+
+ sal_uInt32 SAL_CALL getCommandArgCount();
+
+ sal_Bool SAL_CALL getCommandArg(sal_uInt32 nArg, ::rtl::OUString& strCommandArg);
+};
+
+}
+
+OExtCommandLineImpl::OExtCommandLineImpl()
+ : m_nArgCount(0)
+{
+ init();
+}
+
+OExtCommandLineImpl::~OExtCommandLineImpl()
+{
+
+}
+
+
+sal_uInt32 SAL_CALL OExtCommandLineImpl::getCommandArgCount()
+{
+ return m_nArgCount;
+}
+
+
+sal_Bool SAL_CALL OExtCommandLineImpl::getCommandArg(sal_uInt32 nArg, ::rtl::OUString& strCommandArg)
+{
+ if ( nArg >= m_nArgCount )
+ {
+ return sal_False;
+ }
+
+ strCommandArg = aExtArgVector[nArg];
+
+ return sal_True;
+}
+
+
+void OExtCommandLineImpl::init()
+{
+ OStartupInfo aStartInfo;
+ sal_uInt32 nIndex=0;
+ sal_uInt32 nArgs = aStartInfo.getCommandArgCount();
+
+ for ( nIndex = 0 ; nIndex < nArgs ; ++nIndex )
+ {
+ ::rtl::OUString aString;
+ aStartInfo.getCommandArg(nIndex,aString);
+
+ if ( aString[0] == (sal_Unicode) '@' )
+ {
+ ::rtl::OUString aFileName = aString.copy(1);
+ ::osl::File aFile(aFileName);
+ ::rtl::ByteSequence aSeq;
+
+ ::osl::FileBase::RC aErr = aFile.open(OpenFlag_Read);
+
+ if ( aErr != ::osl::FileBase::E_None )
+ {
+ break;
+ }
+
+ do
+ {
+ aErr = aFile.readLine(aSeq);
+ if ( aSeq.getLength() != 0 )
+ {
+ ::rtl::OUString newString((sal_Char*)aSeq.getArray(), aSeq.getLength(), RTL_TEXTENCODING_ASCII_US);
+ aExtArgVector.push_back( newString );
+ m_nArgCount++;
+ }
+ }
+ while ( aErr == ::osl::FileBase::E_None && aSeq.getLength() > 0 );
+
+ aFile.close();
+ aFile.remove(aFileName);
+ }
+ else
+ {
+ aExtArgVector.push_back( aString );
+ m_nArgCount++;
+ }
+ }
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// OExtCommandLine
+//
+
+namespace
+{
+ struct lclMutex : public rtl::Static< NAMESPACE_VOS(OMutex), lclMutex > {};
+}
+
+OExtCommandLineImpl* OExtCommandLine::pExtImpl=0;
+
+
+VOS_IMPLEMENT_CLASSINFO(
+ VOS_CLASSNAME(OExtCommandLine, vos),
+ VOS_NAMESPACE(OExtCommandLine, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OExtCommandLine::OExtCommandLine()
+{
+ OGuard Guard(lclMutex::get());
+
+ if ( pExtImpl == NULL )
+ {
+ pExtImpl = new OExtCommandLineImpl;
+ }
+}
+
+OExtCommandLine::~OExtCommandLine()
+{
+
+
+}
+
+sal_uInt32 SAL_CALL OExtCommandLine::getCommandArgCount()
+{
+ return pExtImpl->getCommandArgCount();
+}
+
+
+sal_Bool SAL_CALL OExtCommandLine::getCommandArg(sal_uInt32 nArg, ::rtl::OUString& strCommandArg)
+{
+ return pExtImpl->getCommandArg(nArg,strCommandArg);
+}
+
diff --git a/vos/source/refernce.cxx b/vos/source/refernce.cxx
new file mode 100644
index 000000000000..ff21c1acb13e
--- /dev/null
+++ b/vos/source/refernce.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+
+#include <limits.h>
+#include <vos/diagnose.hxx>
+
+#include <vos/refernce.hxx>
+
+using namespace vos;
+
+ORefCount::~ORefCount()
+{
+
+}
+
+
+OReference::OReference()
+{
+}
+
+OReference::~OReference()
+{
+ VOS_ASSERT(m_RefCount.referenced() == 0);
+}
+
+IReference::RefCount OReference::acquire()
+{
+ return (m_RefCount.acquire());
+}
+
+IReference::RefCount OReference::release()
+{
+ RefCount Count = m_RefCount.release();
+
+ if (Count == 0)
+ delete this;
+
+ return (Count);
+}
+
+
diff --git a/vos/source/security.cxx b/vos/source/security.cxx
new file mode 100644
index 000000000000..b4fdc8e8d6a3
--- /dev/null
+++ b/vos/source/security.cxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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 <vos/security.hxx>
+#include <vos/diagnose.hxx>
+
+using namespace vos;
+
+/////////////////////////////////////////////////////////////////////////////
+// Object super class
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OSecurity, vos), VOS_NAMESPACE(OSecurity, vos), VOS_NAMESPACE(OObject, vos), 0);
+
+OSecurity::OSecurity()
+{
+ m_oslSecurity = osl_getCurrentSecurity();
+}
+
+OSecurity::~OSecurity()
+{
+ osl_freeSecurityHandle(m_oslSecurity);
+}
+
+sal_Bool OSecurity::logonUser(const rtl::OUString& strName,
+ const rtl::OUString& strPasswd)
+{
+ osl_freeSecurityHandle(m_oslSecurity);
+
+ m_oslSecurity = NULL;
+
+ return (osl_loginUser( strName.pData, strPasswd.pData, &m_oslSecurity)
+ == osl_Security_E_None);
+}
+
+
+sal_Bool OSecurity::logonUser( const rtl::OUString& strName,
+ const rtl::OUString& strPasswd,
+ const rtl::OUString& strFileServer )
+{
+ osl_freeSecurityHandle(m_oslSecurity);
+
+ m_oslSecurity = NULL;
+
+ return (osl_loginUserOnFileServer(strName.pData, strPasswd.pData, strFileServer.pData, &m_oslSecurity)
+ == osl_Security_E_None);
+}
+
+
+sal_Bool OSecurity::getUserIdent( rtl::OUString& strIdent) const
+{
+ VOS_ASSERT(m_oslSecurity);
+
+ return osl_getUserIdent( m_oslSecurity, &strIdent.pData );
+}
+
+
+sal_Bool OSecurity::getUserName( rtl::OUString& strName ) const
+{
+ VOS_ASSERT(m_oslSecurity);
+
+ return osl_getUserName( m_oslSecurity, &strName.pData );
+}
+
+
+sal_Bool OSecurity::getHomeDir( rtl::OUString& strDirectory) const
+{
+ VOS_ASSERT(m_oslSecurity);
+
+ return osl_getHomeDir(m_oslSecurity, &strDirectory.pData );
+}
+
+
+sal_Bool OSecurity::getConfigDir( rtl::OUString& strDirectory ) const
+{
+ VOS_ASSERT(m_oslSecurity);
+
+ return osl_getConfigDir( m_oslSecurity, &strDirectory.pData );
+}
+
+sal_Bool OSecurity::isAdministrator() const
+{
+ VOS_ASSERT(m_oslSecurity);
+
+ return osl_isAdministrator(m_oslSecurity);
+}
+
+OSecurity::operator oslSecurity() const
+{
+ return m_oslSecurity;
+}
+
diff --git a/vos/source/signal.cxx b/vos/source/signal.cxx
new file mode 100644
index 000000000000..1f879f8b225c
--- /dev/null
+++ b/vos/source/signal.cxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * 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 <vos/diagnose.hxx>
+#include <vos/object.hxx>
+#include <vos/signal.hxx>
+
+using namespace vos;
+
+oslSignalAction vos::signalHandlerFunction_impl(
+ void * pthis, oslSignalInfo * pInfo)
+{
+ NAMESPACE_VOS(OSignalHandler)* pThis= (NAMESPACE_VOS(OSignalHandler)*)pthis;
+
+ return ((oslSignalAction)pThis->signal(pInfo));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Thread class
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OSignalHandler, vos),
+ VOS_NAMESPACE(OSignalHandler, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OSignalHandler::OSignalHandler()
+{
+ m_hHandler = osl_addSignalHandler(signalHandlerFunction_impl, this);
+}
+
+OSignalHandler::~OSignalHandler()
+{
+ osl_removeSignalHandler(m_hHandler);
+}
+
+OSignalHandler::TSignalAction OSignalHandler::raise(sal_Int32 Signal, void *pData)
+{
+ return (TSignalAction)osl_raiseSignal(Signal, pData);
+}
+
diff --git a/vos/source/socket.cxx b/vos/source/socket.cxx
new file mode 100644
index 000000000000..c32faf17a4a5
--- /dev/null
+++ b/vos/source/socket.cxx
@@ -0,0 +1,1723 @@
+/*************************************************************************
+ *
+ * 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 <stdio.h>
+
+#include <rtl/memory.h>
+#include <osl/time.h>
+#include <vos/socket.hxx>
+#include <vos/diagnose.hxx>
+//#include <osl/tools.h>
+
+using namespace vos;
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OSocketAddr, vos),
+ VOS_NAMESPACE(OSocketAddr, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+
+/*****************************************************************************/
+// OSocketAddr()
+/*****************************************************************************/
+OSocketAddr::OSocketAddr()
+{
+ m_SockAddr= 0;
+}
+
+/*****************************************************************************/
+// OSocketAddr()
+/*****************************************************************************/
+OSocketAddr::OSocketAddr(oslSocketAddr Addr)
+{
+ m_SockAddr= Addr;
+}
+
+/*****************************************************************************/
+// OSocketAddr()
+/*****************************************************************************/
+OSocketAddr::OSocketAddr(const OSocketAddr& Addr) :
+ISocketAddr(), OObject()
+{
+ m_SockAddr= osl_copySocketAddr((oslSocketAddr)Addr);
+}
+
+/*****************************************************************************/
+// ~OSocketAddr()
+/*****************************************************************************/
+OSocketAddr::~OSocketAddr()
+{
+ osl_destroySocketAddr(m_SockAddr);
+}
+
+
+/*****************************************************************************/
+// getFamily()
+/*****************************************************************************/
+OSocketAddr::TAddrFamily OSocketAddr::getFamily() const
+{
+ return (TAddrFamily)osl_getFamilyOfSocketAddr(m_SockAddr);
+}
+
+/*****************************************************************************/
+// operator oslSocketAddr ()
+/*****************************************************************************/
+OSocketAddr::operator oslSocketAddr() const
+{
+ return m_SockAddr;
+}
+
+/*****************************************************************************/
+// getHostname()
+/*****************************************************************************/
+OSocketAddr::TResult OSocketAddr::getHostname(rtl::OUString& rBuffer ) const
+{
+ return (TResult)osl_getHostnameOfSocketAddr(m_SockAddr, &rBuffer.pData );
+}
+
+/*****************************************************************************/
+// getLocalHostname()
+/*****************************************************************************/
+OSocketAddr::TResult OSocketAddr::getLocalHostname( rtl::OUString& pBuffer )
+{
+ return (TResult)osl_getLocalHostname( &pBuffer.pData );
+}
+
+/*****************************************************************************/
+// resolveHostname()
+/*****************************************************************************/
+oslSocketAddr OSocketAddr::resolveHostname(const rtl::OUString& ustrHostname)
+{
+ return osl_resolveHostname( ustrHostname.pData );
+}
+
+/*****************************************************************************/
+// operator= (oslSocketAddr Addr)
+/*****************************************************************************/
+void OSocketAddr::operator= (oslSocketAddr Addr)
+{
+ if(m_SockAddr) {
+ osl_destroySocketAddr(m_SockAddr);
+ }
+
+ m_SockAddr= Addr;
+}
+
+/*****************************************************************************/
+// operator== (oslSocketAddr Addr)
+/*****************************************************************************/
+sal_Bool OSocketAddr::operator== (oslSocketAddr Addr)
+{
+ return (osl_isEqualSocketAddr(m_SockAddr, Addr));
+}
+
+/*****************************************************************************/
+// operator=(const OSocketAddr& Addr)
+/*****************************************************************************/
+OSocketAddr& OSocketAddr::operator=(const OSocketAddr& Addr)
+{
+ if(m_SockAddr) {
+ osl_destroySocketAddr(m_SockAddr);
+ }
+
+ m_SockAddr= osl_copySocketAddr((oslSocketAddr)Addr);
+
+ return *this;
+}
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OInetSocketAddr, vos),
+ VOS_NAMESPACE(OInetSocketAddr, vos),
+ VOS_NAMESPACE(OSocketAddr, vos), 0);
+
+
+
+/*****************************************************************************/
+// OInetSocketAddr
+// creates arbitrary inet-address (INADDR_ANY)
+/*****************************************************************************/
+OInetSocketAddr::OInetSocketAddr()
+{
+ m_SockAddr= osl_createEmptySocketAddr(osl_Socket_FamilyInet);
+}
+
+/*****************************************************************************/
+// OInetSocketAddr
+// uses the given oslSocketAddr as its own
+/*****************************************************************************/
+OInetSocketAddr::OInetSocketAddr(oslSocketAddr Addr) :
+ OSocketAddr(Addr)
+{
+ VOS_ASSERT(osl_getFamilyOfSocketAddr(Addr) == osl_Socket_FamilyInet);
+}
+
+/*****************************************************************************/
+// OInetSocketAddr
+// Create a socket address either from a dotted decimal address
+//(e.g. 141.99.128.50) or a hostname (e.g. www.stardiv.de).
+/*****************************************************************************/
+OInetSocketAddr::OInetSocketAddr(const rtl::OUString& ustrAddrOrHostname, sal_Int32 Port)
+{
+ // first try as dotted address.
+ m_SockAddr= osl_createInetSocketAddr(ustrAddrOrHostname.pData, Port);
+
+ // create failed, maybe it's an hostname
+ if(m_SockAddr == 0)
+ {
+ m_SockAddr= osl_resolveHostname(ustrAddrOrHostname.pData);
+
+ // host found?
+ if(m_SockAddr)
+ {
+ // set port will fail if addrtype is not osl_Socket_FamilyInet
+ VOS_VERIFY(osl_setInetPortOfSocketAddr(m_SockAddr, Port));
+ }
+ }
+}
+
+/*****************************************************************************/
+// OInetSocketAddr(const OInetSocketAddr&)
+/*****************************************************************************/
+OInetSocketAddr::OInetSocketAddr(const OInetSocketAddr& sa) :
+ OSocketAddr(sa)
+{
+ VOS_ASSERT(getFamily() == TFamily_Inet);
+}
+
+/*****************************************************************************/
+// OInetSocketAddr(const OSocketAddr&)
+/*****************************************************************************/
+OInetSocketAddr::OInetSocketAddr(const OSocketAddr& sa) :
+ OSocketAddr(sa)
+{
+ VOS_ASSERT(sa.getFamily() == TFamily_Inet);
+}
+
+/*****************************************************************************/
+// ~OInetSocketAddr
+/*****************************************************************************/
+OInetSocketAddr::~OInetSocketAddr()
+{
+}
+
+/*****************************************************************************/
+// operator= (oslSocketAddr Addr)
+/*****************************************************************************/
+void OInetSocketAddr::operator= (oslSocketAddr Addr)
+{
+ VOS_PRECOND(osl_getFamilyOfSocketAddr(Addr) == osl_Socket_FamilyInet,
+ "oslSocketAddr not of type osl_Socket_FamilyInet!");
+
+ OSocketAddr::operator=(Addr);
+}
+
+/*****************************************************************************/
+// operator== (oslSocketAddr Addr)
+/*****************************************************************************/
+sal_Bool OInetSocketAddr::operator== (oslSocketAddr Addr)
+{
+ return (osl_isEqualSocketAddr(m_SockAddr, Addr));
+}
+
+/*****************************************************************************/
+// operator=(const OInetSocketAddr& Addr)
+/*****************************************************************************/
+OInetSocketAddr& OInetSocketAddr::operator=(const OInetSocketAddr& Addr)
+{
+ VOS_ASSERT(Addr.getFamily() == TFamily_Inet);
+
+ OSocketAddr::operator=(Addr);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator=(const OSocketAddr& Addr)
+/*****************************************************************************/
+OInetSocketAddr& OInetSocketAddr::operator=(const OSocketAddr& Addr)
+{
+ VOS_ASSERT(Addr.getFamily() == TFamily_Inet);
+
+ OSocketAddr::operator=(Addr);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// getServicePort()
+/*****************************************************************************/
+sal_Int32 OInetSocketAddr::getServicePort(const rtl::OUString& ustrServiceName,
+ const rtl::OUString& ustrProtocolName)
+{
+ return osl_getServicePort(ustrServiceName.pData, ustrProtocolName.pData);
+}
+
+
+/*****************************************************************************/
+// getPort()
+/*****************************************************************************/
+sal_Int32 OInetSocketAddr::getPort () const
+{
+ return osl_getInetPortOfSocketAddr(m_SockAddr);
+}
+
+
+/*****************************************************************************/
+// setPort()
+/*****************************************************************************/
+sal_Bool OInetSocketAddr::setPort (sal_Int32 Port)
+{
+ return osl_setInetPortOfSocketAddr(m_SockAddr, Port);
+}
+
+
+/*****************************************************************************/
+// getDottedAddr()
+/*****************************************************************************/
+OSocketAddr::TResult OInetSocketAddr::getDottedAddr( rtl::OUString& pBuffer ) const
+{
+ return (TResult)osl_getDottedInetAddrOfSocketAddr(m_SockAddr, &pBuffer.pData );
+}
+
+/*****************************************************************************/
+// setAddr()
+/*****************************************************************************/
+sal_Bool OInetSocketAddr::setAddr(const rtl::OUString& ustrAddrOrHostname)
+{
+ sal_Int32 Port = 0;
+
+ if(m_SockAddr) {
+
+ // retrieve old port
+ Port= getPort();
+
+ // free old address
+ osl_destroySocketAddr(m_SockAddr);
+ m_SockAddr= 0;
+ }
+
+ // first try as dotted address.
+ m_SockAddr= osl_createInetSocketAddr(ustrAddrOrHostname.pData, Port);
+
+ // create failed, maybe it's an hostname
+ if(m_SockAddr == 0)
+ {
+
+ m_SockAddr= osl_resolveHostname( ustrAddrOrHostname.pData );
+
+ // host found?
+ if(m_SockAddr==0)
+ {
+ return sal_False;
+ }
+
+ // set port will fail if addrtype is not osl_Socket_FamilyInet
+ VOS_VERIFY(osl_setInetPortOfSocketAddr(m_SockAddr, Port));
+
+ }
+
+ return sal_True;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// OIpxSocketAddr
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OIpxSocketAddr, vos),
+ VOS_NAMESPACE(OIpxSocketAddr, vos),
+ VOS_NAMESPACE(OSocketAddr, vos), 0);
+
+
+/*****************************************************************************/
+// OIpxSocketAddr()
+/*****************************************************************************/
+OIpxSocketAddr::OIpxSocketAddr()
+{
+ m_SockAddr= osl_createEmptySocketAddr(osl_Socket_FamilyIpx);
+}
+
+/*****************************************************************************/
+// OIpxSocketAddr(oslSocketAddr)
+/*****************************************************************************/
+OIpxSocketAddr::OIpxSocketAddr(oslSocketAddr Addr) :
+ OSocketAddr(Addr)
+{
+ VOS_ASSERT(osl_getFamilyOfSocketAddr(Addr) == osl_Socket_FamilyIpx);
+}
+
+/*****************************************************************************/
+// OIpxSocketAddr()
+/*****************************************************************************/
+OIpxSocketAddr::OIpxSocketAddr(const rtl::OUString&,
+ const rtl::OUString&,
+ sal_uInt32 )
+{
+ // jbu : functionality removed from vos
+}
+
+/*****************************************************************************/
+// OIpxSocketAddr(OIpxSocketAddr&)
+/*****************************************************************************/
+OIpxSocketAddr::OIpxSocketAddr(const OIpxSocketAddr& sa) :
+ OSocketAddr(sa)
+{
+ VOS_ASSERT(sa.getFamily() == TFamily_Ipx);
+}
+
+
+/*****************************************************************************/
+// OIpxSocketAddr(OSocketAddr&)
+/*****************************************************************************/
+OIpxSocketAddr::OIpxSocketAddr(const OSocketAddr& sa) :
+ OSocketAddr(sa)
+{
+ VOS_ASSERT(sa.getFamily() == TFamily_Ipx);
+}
+
+/*****************************************************************************/
+// ~OIpxSocketAddr()
+/*****************************************************************************/
+OIpxSocketAddr::~OIpxSocketAddr()
+{
+}
+
+
+/*****************************************************************************/
+// operator=()
+/*****************************************************************************/
+void OIpxSocketAddr::operator= (oslSocketAddr Addr)
+{
+ VOS_PRECOND(osl_getFamilyOfSocketAddr(Addr) == osl_Socket_FamilyIpx,
+ "oslSocketAddr not of type osl_Socket_FamilyIpx!");
+
+ OSocketAddr::operator=(Addr);
+}
+
+/*****************************************************************************/
+// operator== (oslSocketAddr Addr)
+/*****************************************************************************/
+sal_Bool OIpxSocketAddr::operator== (oslSocketAddr Addr)
+{
+ return (osl_isEqualSocketAddr(m_SockAddr, Addr));
+}
+
+/*****************************************************************************/
+// operator=(const OIpxSocketAddr& Addr)
+/*****************************************************************************/
+OIpxSocketAddr& OIpxSocketAddr::operator=(const OIpxSocketAddr& Addr)
+{
+ VOS_ASSERT(Addr.getFamily() == TFamily_Ipx);
+
+ OSocketAddr::operator=(Addr);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator=(const OSocketAddr& Addr)
+/*****************************************************************************/
+OIpxSocketAddr& OIpxSocketAddr::operator=(const OSocketAddr& Addr)
+{
+ VOS_ASSERT(Addr.getFamily() == TFamily_Ipx);
+
+ OSocketAddr::operator=(Addr);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// getNetNumber()
+/*****************************************************************************/
+OSocketAddr::TResult OIpxSocketAddr::getNetNumber(TIpxNetNumber&) const
+{
+ // jbu : functionality removed from vos
+ return (TResult)0;
+}
+
+/*****************************************************************************/
+// getNodeNumber()
+/*****************************************************************************/
+OSocketAddr::TResult OIpxSocketAddr::getNodeNumber(TIpxNodeNumber& ) const
+{
+ // jbu : functionality removed from vos
+ return (TResult)0;
+}
+
+/*****************************************************************************/
+// getSocketNumber()
+/*****************************************************************************/
+sal_uInt32 OIpxSocketAddr::getSocketNumber() const
+{
+// return osl_getIpxSocketNumber(m_SockAddr);
+ return (TResult)0;
+}
+
+
+/*****************************************************************************/
+// getAddressString()
+/*****************************************************************************/
+//void OIpxSocketAddr::getAddressString(sal_Char* Buffer, sal_uInt32 Len) const
+void OIpxSocketAddr::getAddressString( rtl::OUString& ) const
+{
+ // jbu : functionality removed from vos
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Socket
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OSocket, vos),
+ VOS_NAMESPACE(OSocket, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+/*****************************************************************************/
+// OSocket()
+/*****************************************************************************/
+OSocket::OSocket()
+{
+ m_pRecvTimeout = 0;
+ m_pSendTimeout = 0;
+
+ m_pSockRef= 0;
+}
+
+
+/*****************************************************************************/
+// OSocket()
+/*****************************************************************************/
+OSocket::OSocket(TSocketType Type,
+ TAddrFamily Family,
+ TProtocol Protocol)
+{
+ m_pRecvTimeout = 0;
+ m_pSendTimeout = 0;
+
+ m_pSockRef=
+ new SockRef(osl_createSocket((oslAddrFamily)Family,
+ (oslSocketType)Type,
+ (oslProtocol)Protocol));
+
+ VOS_POSTCOND(m_pSockRef != 0, "OSocket(): new failed.\n");
+ VOS_POSTCOND((*m_pSockRef)(), "OSocket(): creation of socket failed!\n");
+}
+
+/*****************************************************************************/
+// OSocket()
+/*****************************************************************************/
+OSocket::OSocket(const OSocket& sock) :
+ISocketTypes(), OReference(), OObject()
+{
+ m_pRecvTimeout = 0;
+ m_pSendTimeout = 0;
+ m_pSockRef=0;
+
+ VOS_ASSERT(sock.m_pSockRef != 0);
+
+ if ( sock.m_pSockRef !=0 )
+ {
+ m_pSockRef= sock.m_pSockRef;
+
+ setRecvTimeout(sock.m_pRecvTimeout);
+ setSendTimeout(sock.m_pSendTimeout);
+
+ m_pSockRef->acquire();
+ }
+}
+
+/*****************************************************************************/
+// OSocket()
+/*****************************************************************************/
+OSocket::OSocket(oslSocket Socket)
+{
+ m_pRecvTimeout = 0;
+ m_pSendTimeout = 0;
+
+ m_pSockRef = new SockRef(Socket);
+}
+
+
+/*****************************************************************************/
+// ~OSocket()
+/*****************************************************************************/
+OSocket::~OSocket()
+{
+ close();
+
+ delete m_pRecvTimeout;
+ delete m_pSendTimeout;
+}
+
+
+/*****************************************************************************/
+// create
+/*****************************************************************************/
+sal_Bool OSocket::create(TSocketType Type,
+ TAddrFamily Family,
+ TProtocol Protocol)
+{
+ // if this was a valid socket, decrease reference
+ if ((m_pSockRef) && (m_pSockRef->release() == 0))
+ {
+ osl_releaseSocket((*m_pSockRef)());
+ delete m_pSockRef;
+ m_pSockRef= 0;
+ }
+
+ m_pSockRef=
+ new SockRef(osl_createSocket((oslAddrFamily)Family,
+ (oslSocketType)Type,
+ (oslProtocol)Protocol));
+
+ VOS_POSTCOND(m_pSockRef != 0, "OSocket(): new failed.\n");
+
+ return (*m_pSockRef)() != 0;
+}
+
+/*****************************************************************************/
+// operator=
+/*****************************************************************************/
+OSocket& OSocket::operator= (const OSocket& sock)
+{
+ VOS_PRECOND(sock.m_pSockRef != 0, "OSocket::operator=: tried to assign an empty/invalid socket\n");
+
+ if (m_pSockRef == sock.m_pSockRef)
+ return *this;
+
+ // if this was a valid socket, decrease reference
+ if ((m_pSockRef) && (m_pSockRef->release() == 0))
+ {
+ osl_releaseSocket((*m_pSockRef)());
+ delete m_pSockRef;
+ m_pSockRef= 0;
+ }
+
+ m_pSockRef= sock.m_pSockRef;
+
+ setRecvTimeout(sock.m_pRecvTimeout);
+ setSendTimeout(sock.m_pSendTimeout);
+
+ m_pSockRef->acquire();
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator oslSocket()
+/*****************************************************************************/
+OSocket::operator oslSocket() const
+{
+ VOS_ASSERT(m_pSockRef);
+ return (*m_pSockRef)();
+}
+
+/*****************************************************************************/
+// isValid()
+/*****************************************************************************/
+sal_Bool OSocket::isValid() const
+{
+ return m_pSockRef != 0 && (*m_pSockRef)() != 0;
+}
+
+
+/*****************************************************************************/
+// close
+/*****************************************************************************/
+void OSocket::close()
+{
+ if (m_pSockRef && (*m_pSockRef)() && (m_pSockRef->release() == 0))
+ {
+ osl_releaseSocket((*m_pSockRef)());
+ delete m_pSockRef;
+ }
+
+ m_pSockRef= 0;
+}
+
+/*****************************************************************************/
+// getLocalAddr
+/*****************************************************************************/
+void OSocket::getLocalAddr(OSocketAddr& sa) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ sa= osl_getLocalAddrOfSocket((*m_pSockRef)());
+ }
+}
+
+/*****************************************************************************/
+// getLocalPort
+/*****************************************************************************/
+sal_Int32 OSocket::getLocalPort() const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ sal_Int32 Port= OSL_INVALID_PORT;
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ oslSocketAddr Addr= osl_getLocalAddrOfSocket((*m_pSockRef)());
+
+ if(Addr)
+ {
+ Port= osl_getInetPortOfSocketAddr(Addr);
+ osl_destroySocketAddr(Addr);
+ }
+ }
+
+ return Port;
+}
+
+/*****************************************************************************/
+// getLocalHost
+/*****************************************************************************/
+OSocket::TResult OSocket::getLocalHost( rtl::OUString& pBuffer) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ oslSocketAddr Addr= osl_getLocalAddrOfSocket((*m_pSockRef)());
+
+ if(Addr)
+ {
+// TResult Result= (TResult)osl_getHostnameOfSocketAddr(Addr,
+// pBuffer, BufferSize);
+ TResult Result= (TResult)osl_getHostnameOfSocketAddr(Addr,
+ &pBuffer.pData );
+
+ osl_destroySocketAddr(Addr);
+
+ return Result;
+ }
+ }
+
+ return TResult_Error;
+}
+
+/*****************************************************************************/
+// getPeerAddr
+/*****************************************************************************/
+void OSocket::getPeerAddr(OSocketAddr& sa) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ sa= osl_getPeerAddrOfSocket((*m_pSockRef)());
+ }
+}
+
+/*****************************************************************************/
+// getPeerPort
+/*****************************************************************************/
+sal_Int32 OSocket::getPeerPort() const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ sal_Int32 Port= OSL_INVALID_PORT;
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ oslSocketAddr Addr= osl_getPeerAddrOfSocket((*m_pSockRef)());
+
+ if(Addr)
+ {
+ Port= osl_getInetPortOfSocketAddr(Addr);
+ osl_destroySocketAddr(Addr);
+ }
+ }
+
+ return Port;
+}
+
+/*****************************************************************************/
+// getPeerHost
+/*****************************************************************************/
+OSocket::TResult OSocket::getPeerHost( rtl::OUString& pBuffer ) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ oslSocketAddr Addr= osl_getPeerAddrOfSocket((*m_pSockRef)());
+
+ if(Addr)
+ {
+// TResult Result= (TResult)osl_getHostnameOfSocketAddr(Addr,
+// pBuffer, BufferSize);
+ TResult Result= (TResult)osl_getHostnameOfSocketAddr(Addr,
+ &pBuffer.pData );
+
+ osl_destroySocketAddr(Addr);
+
+ return Result;
+ }
+ }
+
+ return TResult_Error;
+}
+
+/*****************************************************************************/
+// bind
+/*****************************************************************************/
+sal_Bool OSocket::bind(const OSocketAddr& Addr)
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_bindAddrToSocket((*m_pSockRef)(), (oslSocketAddr)Addr);
+ }
+
+ return sal_False;
+}
+
+
+/*****************************************************************************/
+// setSendTimeout
+/*****************************************************************************/
+void OSocket::setSendTimeout(const TimeValue* pTimeout)
+{
+ delete m_pSendTimeout;
+
+ if (pTimeout)
+ m_pSendTimeout = new TimeValue(*pTimeout);
+ else
+ m_pSendTimeout = 0;
+}
+
+/*****************************************************************************/
+// setRecvTimeout
+/*****************************************************************************/
+void OSocket::setRecvTimeout(const TimeValue* pTimeout)
+{
+ delete m_pRecvTimeout;
+
+ if (pTimeout)
+ m_pRecvTimeout = new TimeValue(*pTimeout);
+ else
+ m_pRecvTimeout = 0;
+}
+
+/*****************************************************************************/
+// isRecvReady
+/*****************************************************************************/
+sal_Bool OSocket::isRecvReady(const TimeValue* pTimeout) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_isReceiveReady((*m_pSockRef)(), pTimeout);
+ }
+
+ return sal_False;
+}
+
+/*****************************************************************************/
+// isSendReady
+/*****************************************************************************/
+sal_Bool OSocket::isSendReady(const TimeValue* pTimeout) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_isSendReady((*m_pSockRef)(), pTimeout);
+ }
+
+ return sal_False;
+}
+
+/*****************************************************************************/
+// isExceptionPending
+/*****************************************************************************/
+sal_Bool OSocket::isExceptionPending(const TimeValue* pTimeout) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_isExceptionPending((*m_pSockRef)(), pTimeout);
+ }
+
+ return sal_False;
+}
+
+
+/*****************************************************************************/
+// getOption
+/*****************************************************************************/
+sal_Int32 OSocket::getOption(TSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ TSocketOptionLevel Level) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_getSocketOption((*m_pSockRef)(),
+ (oslSocketOptionLevel)Level,
+ (oslSocketOption)Option,
+ pBuffer,
+ BufferLen);
+ }
+
+ return sal_False;
+}
+
+/*****************************************************************************/
+// setOption
+/*****************************************************************************/
+sal_Bool OSocket::setOption(TSocketOption Option,
+ void* pBuffer,
+ sal_uInt32 BufferLen,
+ TSocketOptionLevel Level) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_setSocketOption((*m_pSockRef)(),
+ (oslSocketOptionLevel)Level,
+ (oslSocketOption)Option,
+ pBuffer,
+ BufferLen);
+ }
+
+ return sal_False;
+}
+
+
+/*****************************************************************************/
+// enableNonBlockingMode
+/*****************************************************************************/
+sal_Bool OSocket::enableNonBlockingMode(sal_Bool On)
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_enableNonBlockingMode((*m_pSockRef)(), On);
+ }
+
+ return sal_False;
+}
+
+/*****************************************************************************/
+// isNonBlockingMode
+/*****************************************************************************/
+sal_Bool OSocket::isNonBlockingMode() const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_isNonBlockingMode((*m_pSockRef)());
+ }
+
+ return sal_False;
+}
+
+/*****************************************************************************/
+// getType
+/*****************************************************************************/
+OSocket::TSocketType OSocket::getType() const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return (TSocketType)osl_getSocketType((*m_pSockRef)());
+ }
+
+ return TType_Invalid;
+}
+
+/*****************************************************************************/
+// clearError
+/*****************************************************************************/
+sal_Int32 OSocket::clearError() const
+{
+ sal_Int32 err = 0;
+
+ getOption(TOption_Error, &err, sizeof(err));
+
+ return err;
+}
+
+/*****************************************************************************/
+// setDebug
+/*****************************************************************************/
+sal_Int32 OSocket::setDebug(sal_Int32 opt) const
+{
+ sal_Int32 old= 0;
+
+ getOption(TOption_Debug, &old, sizeof(old));
+
+ if (opt != -1)
+ setOption(TOption_Debug, &opt, sizeof(opt));
+
+ return old;
+}
+
+/*****************************************************************************/
+// setReuseAddr
+/*****************************************************************************/
+sal_Int32 OSocket::setReuseAddr(sal_Int32 opt) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_ReuseAddr, &old, sizeof(old));
+
+ if (opt != -1)
+ setOption(TOption_ReuseAddr, &opt, sizeof(opt));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setKeepAlive
+/*****************************************************************************/
+sal_Int32 OSocket::setKeepAlive(sal_Int32 opt) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_KeepAlive, &old, sizeof(old));
+
+ if (opt != -1)
+ setOption(TOption_KeepAlive, &opt, sizeof(opt));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setDontRoute
+/*****************************************************************************/
+sal_Int32 OSocket::setDontRoute(sal_Int32 opt) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_DontRoute, &old, sizeof(old));
+
+ if (opt != -1)
+ setOption(TOption_DontRoute, &opt, sizeof(opt));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setBroadcast
+/*****************************************************************************/
+sal_Int32 OSocket::setBroadcast(sal_Int32 opt) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_Broadcast, &old, sizeof(old));
+
+ if (opt != -1)
+ setOption(TOption_Broadcast, &opt, sizeof(opt));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setOobinline
+/*****************************************************************************/
+sal_Int32 OSocket::setOobinline(sal_Int32 opt) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_OOBinLine, &old, sizeof(old));
+
+ if (opt != -1)
+ setOption(TOption_OOBinLine, &opt, sizeof(opt));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setLinger
+/*****************************************************************************/
+sal_Int32 OSocket::setLinger(sal_Int32 time) const
+{
+ /* local decl. of linger-struct */
+ struct SockLinger
+ {
+ sal_Int32 m_onoff; // option on/off
+ sal_Int32 m_linger; // linger time
+ };
+
+
+ SockLinger old = { 0, 0 };
+
+ getOption(TOption_Linger, &old, sizeof(old));
+
+ if (time > 0) // enable linger with wait-times > 0
+ {
+ SockLinger nw = { 1, time };
+ setOption(TOption_Linger, &nw, sizeof(nw));
+ }
+ else if (time == 0) // disable linger with wait-time == 0
+ {
+ SockLinger nw = { 0, old.m_linger };
+ setOption(TOption_Linger, &nw, sizeof(nw));
+ }
+
+ // returns 0 if linger was off, else the linger-time
+ return (old.m_onoff ? old.m_linger : 0);
+}
+
+/*****************************************************************************/
+// setSendBufSize
+/*****************************************************************************/
+sal_Int32 OSocket::setSendBufSize(sal_Int32 sz) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_SndBuf, &old, sizeof(old));
+
+ if (sz >= 0)
+ setOption(TOption_SndBuf, &sz, sizeof(sz));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setRecvBufSize
+/*****************************************************************************/
+sal_Int32 OSocket::setRecvBufSize(sal_Int32 sz) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_RcvBuf, &old, sizeof(old));
+
+ if (sz >= 0)
+ setOption(TOption_RcvBuf, &sz, sizeof(sz));
+
+ return (old);
+}
+
+/*****************************************************************************/
+// setTcpNoDelay
+/*****************************************************************************/
+sal_Int32 OSocket::setTcpNoDelay(sal_Int32 sz) const
+{
+ sal_Int32 old = 0;
+
+ getOption(TOption_TcpNoDelay, &old, sizeof(old), TLevel_Tcp);
+
+ if (sz >= 0)
+ setOption(TOption_TcpNoDelay, &sz, sizeof(sz), TLevel_Tcp);
+
+ return (old);
+}
+
+/*****************************************************************************/
+// getError
+/*****************************************************************************/
+//void OSocket::getError(sal_Char* pBuffer, sal_uInt32 nSize) const
+void OSocket::getError( rtl::OUString& pBuffer ) const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if (m_pSockRef && (*m_pSockRef)())
+ osl_getLastSocketErrorDescription((*m_pSockRef)(), &pBuffer.pData );
+ else
+ osl_getLastSocketErrorDescription(NULL, &pBuffer.pData );
+}
+
+/*****************************************************************************/
+// getError
+/*****************************************************************************/
+OSocket::TSocketError OSocket::getError() const
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if (m_pSockRef && (*m_pSockRef)())
+ return (TSocketError)osl_getLastSocketError((*m_pSockRef)());
+ else
+ return (TSocketError)osl_getLastSocketError(NULL);
+}
+
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OAcceptorSocket, vos),
+ VOS_NAMESPACE(OAcceptorSocket, vos),
+ VOS_NAMESPACE(OSocket, vos), 0);
+
+
+/*****************************************************************************/
+// OAcceptorSocket
+/*****************************************************************************/
+OAcceptorSocket::OAcceptorSocket(TAddrFamily Family,
+ TProtocol Protocol,
+ TSocketType Type) :
+ OSocket(Type, Family, Protocol)
+{
+}
+
+/*****************************************************************************/
+// OAcceptorSocket
+/*****************************************************************************/
+OAcceptorSocket::OAcceptorSocket(const OAcceptorSocket& sock) :
+ OSocket(sock)
+{
+}
+
+/*****************************************************************************/
+// ~OAcceptorSocket
+/*****************************************************************************/
+OAcceptorSocket::~OAcceptorSocket()
+{
+ if (m_pSockRef && (*m_pSockRef)() && (m_pSockRef->release() == 0))
+ {
+ /* mfe: prepare for forthcoming api change */
+ osl_closeSocket((*m_pSockRef)());
+ osl_releaseSocket((*m_pSockRef)());
+ delete m_pSockRef;
+ m_pSockRef = 0;
+ }
+}
+
+/*****************************************************************************/
+// close
+/*****************************************************************************/
+void OAcceptorSocket::close()
+{
+ if (m_pSockRef && (*m_pSockRef)() && (m_pSockRef->release() == 0))
+ {
+ osl_closeSocket((*m_pSockRef)());
+ }
+
+ m_pSockRef= 0;
+}
+
+/*****************************************************************************/
+// listen
+/*****************************************************************************/
+sal_Bool OAcceptorSocket::listen(sal_Int32 MaxPendingConnections)
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_listenOnSocket((*m_pSockRef)(), MaxPendingConnections);
+ }
+
+ return sal_False;
+}
+
+
+/*****************************************************************************/
+// acceptConnection
+/*****************************************************************************/
+OSocket::TResult OAcceptorSocket::acceptConnection(OStreamSocket& connection)
+{
+ if (m_pRecvTimeout && ! isRecvReady(m_pRecvTimeout))
+ return TResult_TimedOut;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+ OStreamSocket aSocket;
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ aSocket = osl_acceptConnectionOnSocket((*m_pSockRef)(), 0);
+ }
+
+ if( aSocket.isValid() )
+ {
+ connection = aSocket;
+ return TResult_Ok;
+ }
+ else
+ {
+ return TResult_Error;
+ }
+
+}
+
+/*****************************************************************************/
+// acceptConnection
+/*****************************************************************************/
+OSocket::TResult OAcceptorSocket::acceptConnection(OStreamSocket& connection,
+ OSocketAddr& sa)
+{
+ oslSocketAddr PeerAddr = 0;
+ oslSocket Socket = 0;
+
+ if (m_pRecvTimeout && ! isRecvReady(m_pRecvTimeout))
+ return TResult_TimedOut;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ Socket= osl_acceptConnectionOnSocket((*m_pSockRef)(), &PeerAddr);
+ }
+
+ if (Socket)
+ {
+ sa= PeerAddr;
+ connection= Socket;
+ return TResult_Ok;
+ }
+ else
+ {
+ return TResult_Error;
+ }
+}
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OStreamSocket, vos),
+ VOS_NAMESPACE(OStreamSocket, vos),
+ VOS_NAMESPACE(OSocket, vos), 0);
+
+
+
+/*****************************************************************************/
+// OStreamSocket
+/*****************************************************************************/
+OStreamSocket::OStreamSocket()
+{
+}
+
+/*****************************************************************************/
+// OStreamSocket
+/*****************************************************************************/
+OStreamSocket::OStreamSocket(TAddrFamily Family,
+ TProtocol Protocol,
+ TSocketType Type) :
+ OSocket(Type, Family, Protocol)
+{
+}
+
+
+/*****************************************************************************/
+// OStreamSocket
+/*****************************************************************************/
+OStreamSocket::OStreamSocket(oslSocket Socket) :
+ OSocket(Socket)
+{
+}
+
+/*****************************************************************************/
+// OStreamSocket
+// copy constructor
+/*****************************************************************************/
+OStreamSocket::OStreamSocket(const OStreamSocket& sock) :
+ OSocket(sock), IStream()
+{
+}
+
+/*****************************************************************************/
+// OStreamSocket
+// copy constructor
+/*****************************************************************************/
+OStreamSocket::OStreamSocket(const OSocket& sock) :
+ OSocket(sock)
+{
+}
+
+/*****************************************************************************/
+// ~OStreamSocket
+/*****************************************************************************/
+OStreamSocket::~OStreamSocket()
+{
+}
+
+/*****************************************************************************/
+// close
+/*****************************************************************************/
+void OStreamSocket::close()
+{
+ if (m_pSockRef && (*m_pSockRef)() && (m_pSockRef->release() == 0))
+ {
+ shutdown();
+ osl_releaseSocket((*m_pSockRef)());
+ delete m_pSockRef;
+ }
+
+ m_pSockRef= 0;
+}
+
+
+/*****************************************************************************/
+// operator=(oslSocket)
+/*****************************************************************************/
+OStreamSocket& OStreamSocket::operator=(oslSocket Socket)
+{
+ OSocket::operator=(Socket);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator=
+/*****************************************************************************/
+OStreamSocket& OStreamSocket::operator= (const OSocket& sock)
+{
+ OSocket::operator=(sock);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// operator=
+/*****************************************************************************/
+OStreamSocket& OStreamSocket::operator= (const OStreamSocket& sock)
+{
+ OSocket::operator=(sock);
+
+ return *this;
+}
+
+/*****************************************************************************/
+// read
+/*****************************************************************************/
+sal_Int32 OStreamSocket::read(void* pBuffer, sal_uInt32 n) const
+{
+ sal_uInt8 *Ptr = (sal_uInt8 *)pBuffer;
+
+ if (m_pRecvTimeout && ! isRecvReady(m_pRecvTimeout))
+ return 0;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( ! ( m_pSockRef && (*m_pSockRef)() ) )
+ {
+ return -1;
+ }
+
+ /* loop until all desired bytes were read or an error occured */
+ sal_uInt32 BytesRead= 0;
+ sal_uInt32 BytesToRead= n;
+ while (BytesToRead > 0)
+ {
+ sal_Int32 RetVal;
+ RetVal= osl_receiveSocket((*m_pSockRef)(),
+ Ptr,
+ BytesToRead,
+ osl_Socket_MsgNormal);
+
+ /* error occured? */
+ if(RetVal <= 0)
+ {
+ break;
+ }
+
+ BytesToRead -= RetVal;
+ BytesRead += RetVal;
+ Ptr += RetVal;
+
+ /* wait for next available data or timeout */
+ if ( BytesToRead > 0 && m_pRecvTimeout && ! isRecvReady(m_pRecvTimeout))
+ break;
+
+ }
+
+ return BytesRead;
+}
+
+/*****************************************************************************/
+// write
+/*****************************************************************************/
+sal_Int32 OStreamSocket::write(const void* pBuffer, sal_uInt32 n)
+{
+ sal_uInt8 *Ptr = (sal_uInt8 *)pBuffer;
+
+ if (m_pSendTimeout && ! isSendReady(m_pSendTimeout))
+ return 0;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( ! ( m_pSockRef && (*m_pSockRef)() ) )
+ {
+ return -1;
+ }
+
+ /* loop until all desired bytes were send or an error occured */
+ sal_uInt32 BytesSend= 0;
+ sal_uInt32 BytesToSend= n;
+ while (BytesToSend > 0)
+ {
+ sal_Int32 RetVal;
+
+ RetVal= osl_sendSocket((*m_pSockRef)(),
+ Ptr,
+ BytesToSend,
+ osl_Socket_MsgNormal);
+
+ /* error occured? */
+ if(RetVal <= 0)
+ {
+ break;
+ }
+
+ BytesToSend -= RetVal;
+ BytesSend += RetVal;
+ Ptr += RetVal;
+
+ /* wait till new data is available or timeout occures */
+ if ( BytesToSend > 0 && m_pSendTimeout && ! isSendReady(m_pSendTimeout))
+ break;
+ }
+
+ return BytesSend;
+}
+
+sal_Bool OStreamSocket::isEof() const
+{
+ return isValid();
+ // BHO not enough
+}
+
+/*****************************************************************************/
+// recv
+/*****************************************************************************/
+sal_Int32 OStreamSocket::recv(void* pBuffer,
+ sal_uInt32 BytesToRead,
+ TSocketMsgFlag Flag)
+{
+ if (m_pRecvTimeout && ! isRecvReady(m_pRecvTimeout))
+ return 0;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( ! ( m_pSockRef && (*m_pSockRef)() ) )
+ {
+ return -1;
+ }
+
+ return osl_receiveSocket((*m_pSockRef)(),
+ pBuffer,
+ BytesToRead,
+ (oslSocketMsgFlag)Flag);
+}
+
+/*****************************************************************************/
+// send
+/*****************************************************************************/
+sal_Int32 OStreamSocket::send(const void* pBuffer,
+ sal_uInt32 BytesToSend,
+ TSocketMsgFlag Flag)
+{
+ if (m_pSendTimeout && ! isSendReady(m_pSendTimeout))
+ return 0;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( ! ( m_pSockRef && (*m_pSockRef)() ) )
+ {
+ return -1;
+ }
+
+ return osl_sendSocket((*m_pSockRef)(),
+ pBuffer,
+ BytesToSend,
+ (oslSocketMsgFlag)Flag);
+}
+
+/*****************************************************************************/
+// shutdown
+/*****************************************************************************/
+sal_Bool OStreamSocket::shutdown(TSocketDirection Direction)
+{
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return osl_shutdownSocket((*m_pSockRef)(), (oslSocketDirection)Direction);
+ }
+
+ return sal_False;
+}
+
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OConnectorSocket, vos),
+ VOS_NAMESPACE(OConnectorSocket, vos),
+ VOS_NAMESPACE(OStreamSocket, vos), 0);
+
+
+
+/*****************************************************************************/
+// OConnectorSocket
+/*****************************************************************************/
+OConnectorSocket::OConnectorSocket(TAddrFamily Family,
+ TProtocol Protocol,
+ TSocketType Type) :
+ OStreamSocket(Family, Protocol, Type)
+{
+}
+
+/*****************************************************************************/
+// OConnectorSocket
+/*****************************************************************************/
+OConnectorSocket::OConnectorSocket(const OConnectorSocket& sock) :
+ OStreamSocket(sock)
+{
+}
+
+/*****************************************************************************/
+// ~OConnectorSocket
+/*****************************************************************************/
+OConnectorSocket::~OConnectorSocket()
+{
+}
+
+/*****************************************************************************/
+// connect
+/*****************************************************************************/
+OSocket::TResult OConnectorSocket::connect(const OSocketAddr& Addr,
+ const TimeValue* pTimeout)
+{
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( m_pSockRef && (*m_pSockRef)() )
+ {
+ return (TResult)osl_connectSocketTo((*m_pSockRef)(),
+ (oslSocketAddr)Addr,
+ pTimeout);
+ }
+
+ return TResult_Error;
+}
+
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(ODatagramSocket, vos),
+ VOS_NAMESPACE(ODatagramSocket, vos),
+ VOS_NAMESPACE(OSocket, vos), 0);
+
+
+/*****************************************************************************/
+// ODatagramSocket
+/*****************************************************************************/
+ODatagramSocket::ODatagramSocket(TAddrFamily Family,
+ TProtocol Protocol,
+ TSocketType Type) :
+ OSocket(Type, Family, Protocol)
+{
+}
+
+/*****************************************************************************/
+// ODatagramSocket
+/*****************************************************************************/
+ODatagramSocket::ODatagramSocket(const ODatagramSocket& sock) :
+ OSocket(sock)
+{
+}
+
+/*****************************************************************************/
+// ~ODatagramSocket
+/*****************************************************************************/
+ODatagramSocket::~ODatagramSocket()
+{
+}
+
+
+/*****************************************************************************/
+// recvFrom
+/*****************************************************************************/
+sal_Int32 ODatagramSocket::recvFrom(void* pBuffer,
+ sal_uInt32 BufferSize,
+ OSocketAddr* pSenderAddr,
+ TSocketMsgFlag Flag)
+{
+
+ if (m_pRecvTimeout && ! isRecvReady(m_pRecvTimeout))
+ return 0;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( ! ( m_pSockRef && (*m_pSockRef)() ) )
+ {
+ return -1;
+ }
+
+ sal_Int32 BytesRead;
+
+ if(pSenderAddr)
+ {
+ // we are interested in the senders address
+ oslSocketAddr SenderAddr= osl_createEmptySocketAddr(osl_Socket_FamilyInet);
+
+ BytesRead=
+ osl_receiveFromSocket((*m_pSockRef)(),
+ SenderAddr,
+ pBuffer,
+ BufferSize,
+ (oslSocketMsgFlag)Flag);
+
+ *pSenderAddr= SenderAddr;
+ }
+ else
+ {
+ // we don't want to know the senders address
+
+ BytesRead=
+ osl_receiveFromSocket((*m_pSockRef)(),
+ 0,
+ pBuffer,
+ BufferSize,
+ (oslSocketMsgFlag)Flag);
+ }
+
+ return BytesRead;
+}
+
+
+/*****************************************************************************/
+// sendTo
+/*****************************************************************************/
+sal_Int32 ODatagramSocket::sendTo(const OSocketAddr& ReceiverAddr,
+ const void* pBuffer,
+ sal_uInt32 BufferSize,
+ TSocketMsgFlag Flag)
+{
+ if (m_pSendTimeout && ! isSendReady(m_pSendTimeout))
+ return 0;
+
+ VOS_ASSERT(m_pSockRef && (*m_pSockRef)());
+
+ if ( ( m_pSockRef && (*m_pSockRef)() ) )
+ {
+
+ return osl_sendToSocket((*m_pSockRef)(),
+ (oslSocketAddr)ReceiverAddr,
+ pBuffer,
+ BufferSize,
+ (oslSocketMsgFlag)Flag);
+ }
+
+ return -1;
+}
+
diff --git a/vos/source/stream.cxx b/vos/source/stream.cxx
new file mode 100644
index 000000000000..5f7b5b55304f
--- /dev/null
+++ b/vos/source/stream.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * 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 <limits>
+
+#include <osl/diagnose.h>
+#include <vos/object.hxx>
+#include <vos/stream.hxx>
+
+using namespace vos;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Stream class
+//
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OStream, vos), VOS_NAMESPACE(OStream, vos), VOS_NAMESPACE(OObject, vos), 0);
+
+OStream::OStream(IPositionableStream& rStream)
+ : m_rStream(rStream)
+{
+}
+
+OStream::~OStream()
+{
+}
+
+sal_Int32 OStream::read(void* pbuffer, sal_uInt32 n) const
+{
+ return (m_rStream.read(pbuffer, n));
+}
+
+sal_Int32 OStream::read(IPositionableStream::Offset offset,
+ void* pbuffer, sal_uInt32 n) const
+{
+ return (seekTo(offset) ? read(pbuffer, n) : -1);
+}
+
+sal_Int32 OStream::write(const void* pbuffer, sal_uInt32 n)
+{
+ return
+ n <= static_cast< sal_uInt32 >(std::numeric_limits< sal_Int32 >::max())
+ && (m_rStream.write(pbuffer, n) == static_cast< sal_Int32 >(n));
+}
+
+sal_Int32 OStream::write(IPositionableStream::Offset offset,
+ const void* pbuffer, sal_uInt32 n)
+{
+ return (seekTo(offset) && write(pbuffer, n));
+}
+
+sal_Bool OStream::append(void* pbuffer, sal_uInt32 n)
+{
+ return (seekToEnd() && write(pbuffer, n));
+}
+
+sal_Bool OStream::seekTo(IPositionableStream::Offset pos) const
+{
+ return (m_rStream.seekTo(pos));
+}
+
+sal_Bool OStream::seekToEnd() const
+{
+ return (m_rStream.seekToEnd());
+}
+
+sal_Bool OStream::seekRelative(sal_Int32 change) const
+{
+ return (m_rStream.seekRelative(change));
+}
+
+sal_Bool OStream::changeSize(sal_uInt32 new_size)
+{
+ return (m_rStream.changeSize(new_size));
+}
+
+sal_uInt32 OStream::getSize() const
+{
+ return (m_rStream.getSize());
+}
+
+sal_Bool OStream::isEof() const
+{
+ return (m_rStream.isEof());
+}
+
+IPositionableStream::Offset OStream::getOffset() const
+{
+ return (m_rStream.getOffset());
+}
+
diff --git a/vos/source/thread.cxx b/vos/source/thread.cxx
new file mode 100644
index 000000000000..8b2c8826b753
--- /dev/null
+++ b/vos/source/thread.cxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * 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 <osl/time.h>
+#include <vos/diagnose.hxx>
+#include <vos/object.hxx>
+#include <vos/thread.hxx>
+
+using namespace vos;
+
+void vos::threadWorkerFunction_impl(void * pthis)
+{
+ NAMESPACE_VOS(OThread)* pThis= (NAMESPACE_VOS(OThread)*)pthis;
+
+ // call Handler-Function of OThread-derived class
+ pThis->run();
+
+ // if not already terminating, by a kill do normal shutdown
+ if (! pThis->m_bTerminating)
+ {
+ pThis->m_bTerminating = sal_True;
+
+ pThis->onTerminated(); // could e.g. delete this
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Thread class
+//
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OThread, vos),
+ VOS_NAMESPACE(OThread, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OThread::OThread()
+{
+ m_hThread = 0;
+ m_bTerminating = sal_False;
+ m_aCondition = osl_createCondition();
+}
+
+OThread::~OThread()
+{
+ if (m_hThread != 0)
+ {
+ osl_destroyThread(m_hThread);
+ }
+
+ osl_destroyCondition( m_aCondition );
+}
+
+sal_Bool OThread::create()
+{
+ VOS_ASSERT(m_hThread == 0); // only one running thread per instance
+
+ m_hThread = osl_createSuspendedThread(
+ threadWorkerFunction_impl, (void*)this);
+ if (m_hThread)
+ osl_resumeThread(m_hThread);
+
+ return m_hThread != 0;
+}
+
+sal_Bool OThread::createSuspended()
+{
+ VOS_ASSERT(m_hThread == 0); // only one running thread per instance
+
+ m_hThread= osl_createSuspendedThread(threadWorkerFunction_impl, (void*)this);
+ return m_hThread != 0;
+}
+
+void OThread::suspend()
+{
+ VOS_ASSERT(m_hThread != 0); // use only on running thread
+
+ osl_suspendThread(m_hThread);
+}
+
+void OThread::resume()
+{
+ VOS_ASSERT(m_hThread != 0); // use only on running thread
+
+ osl_resumeThread(m_hThread);
+}
+
+sal_Bool OThread::isRunning()
+{
+ return m_hThread != 0 && osl_isThreadRunning(m_hThread);
+}
+
+OThread::TThreadIdentifier OThread::getIdentifier() const
+{
+ return (TThreadIdentifier)osl_getThreadIdentifier(m_hThread);
+}
+
+OThread::TThreadIdentifier OThread::getCurrentIdentifier()
+{
+ return (TThreadIdentifier)osl_getThreadIdentifier(0);
+}
+
+void OThread::join()
+{
+ if (m_hThread) {
+ VOS_ASSERT(getCurrentIdentifier() != getIdentifier());
+ osl_joinWithThread(m_hThread);
+ }
+}
+
+OThread::TThreadSleep OThread::sleep(const TimeValue& Delay)
+{
+ TThreadSleep eRet;
+
+ switch( osl_waitCondition( m_aCondition, &Delay ) )
+ {
+ case osl_cond_result_ok:
+ eRet = TSleep_Normal;
+ break;
+
+ case osl_cond_result_timeout:
+ eRet = TSleep_Cancel;
+ break;
+
+ default:
+ eRet = TSleep_Error;
+ break;
+ }
+
+ return eRet;
+}
+
+void OThread::wait(const TimeValue& Delay) {
+ osl_waitThread(&Delay);
+}
+
+sal_Bool OThread::awake()
+{
+ osl_setCondition( m_aCondition );
+ return osl_resetCondition( m_aCondition );
+}
+
+void OThread::terminate()
+{
+ osl_terminateThread(m_hThread);
+}
+
+sal_Bool OThread::schedule() {
+ return osl_scheduleThread(m_hThread);
+}
+
+void OThread::kill()
+{
+ if (osl_isThreadRunning(m_hThread))
+ {
+ // flag we are shutting down
+ m_bTerminating = sal_True;
+
+ terminate();
+ join();
+ }
+}
+
+void OThread::setPriority(OThread::TThreadPriority Priority)
+{
+ osl_setThreadPriority(m_hThread, (oslThreadPriority)Priority);
+}
+
+OThread::TThreadPriority OThread::getPriority()
+{
+ return (TThreadPriority)osl_getThreadPriority(m_hThread);
+}
+
+
+void OThread::yield()
+{
+ osl_yieldThread();
+}
+
+void OThread::onTerminated()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// ThreadData class
+//
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OThreadData, vos),
+ VOS_NAMESPACE(OThreadData, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OThreadData::OThreadData( oslThreadKeyCallbackFunction pCallback )
+{
+ m_hKey = osl_createThreadKey( pCallback );
+ VOS_VERIFY(m_hKey);
+}
+
+OThreadData::~OThreadData()
+{
+ osl_destroyThreadKey(m_hKey);
+}
+
+sal_Bool OThreadData::setData(void *pData)
+{
+ VOS_ASSERT(m_hKey != 0);
+
+ return (osl_setThreadKeyData(m_hKey, pData));
+}
+
+void *OThreadData::getData()
+{
+ VOS_ASSERT(m_hKey != 0);
+
+ return (osl_getThreadKeyData(m_hKey));
+}
+
diff --git a/vos/source/timer.cxx b/vos/source/timer.cxx
new file mode 100644
index 000000000000..1c1e2385b60c
--- /dev/null
+++ b/vos/source/timer.cxx
@@ -0,0 +1,501 @@
+/*************************************************************************
+ *
+ * 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 <osl/time.h>
+
+#include <vos/timer.hxx>
+#include <vos/diagnose.hxx>
+#include <vos/ref.hxx>
+#include <vos/thread.hxx>
+#include <vos/conditn.hxx>
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Timer manager
+//
+
+class OTimerManagerCleanup;
+
+class NAMESPACE_VOS(OTimerManager) : public NAMESPACE_VOS(OThread)
+{
+
+public:
+
+ ///
+ OTimerManager();
+
+ ///
+ ~OTimerManager();
+
+ /// register timer
+ sal_Bool SAL_CALL registerTimer(NAMESPACE_VOS(OTimer)* pTimer);
+
+ /// unregister timer
+ sal_Bool SAL_CALL unregisterTimer(NAMESPACE_VOS(OTimer)* pTimer);
+
+ /// lookup timer
+ sal_Bool SAL_CALL lookupTimer(const NAMESPACE_VOS(OTimer)* pTimer);
+
+ /// retrieves the "Singleton" TimerManager Instance
+ static OTimerManager* SAL_CALL getTimerManager();
+
+
+protected:
+
+ /// worker-function of thread
+ virtual void SAL_CALL run();
+
+ // Checking and triggering of a timer event
+ void SAL_CALL checkForTimeout();
+
+ // cleanup Method
+ virtual void SAL_CALL onTerminated();
+
+ // sorted-queue data
+ NAMESPACE_VOS(OTimer)* m_pHead;
+ // List Protection
+ NAMESPACE_VOS(OMutex) m_Lock;
+ // Signal the insertion of a timer
+ NAMESPACE_VOS(OCondition) m_notEmpty;
+
+ // Synchronize access to OTimerManager
+ static NAMESPACE_VOS(OMutex) m_Access;
+
+ // "Singleton Pattern"
+ static NAMESPACE_VOS(OTimerManager)* m_pManager;
+
+ friend class OTimerManagerCleanup;
+
+};
+
+using namespace vos;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Timer class
+//
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OTimer, vos),
+ VOS_NAMESPACE(OTimer, vos),
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OTimer::OTimer()
+{
+ m_TimeOut = 0;
+ m_Expired = 0;
+ m_RepeatDelta = 0;
+ m_pNext = 0;
+}
+
+OTimer::OTimer(const TTimeValue& Time)
+{
+ m_TimeOut = Time;
+ m_RepeatDelta = 0;
+ m_Expired = 0;
+ m_pNext = 0;
+
+ m_TimeOut.normalize();
+}
+
+OTimer::OTimer(const TTimeValue& Time, const TTimeValue& Repeat)
+{
+ m_TimeOut = Time;
+ m_RepeatDelta = Repeat;
+ m_Expired = 0;
+ m_pNext = 0;
+
+ m_TimeOut.normalize();
+ m_RepeatDelta.normalize();
+}
+
+OTimer::~OTimer()
+{
+ stop();
+}
+
+void OTimer::start()
+{
+ if (! isTicking())
+ {
+ if (! m_TimeOut.isEmpty())
+ setRemainingTime(m_TimeOut);
+
+ OTimerManager *pManager = OTimerManager::getTimerManager();
+
+ VOS_ASSERT(pManager);
+
+ if ( pManager != 0 )
+ {
+ pManager->registerTimer(this);
+ }
+ }
+}
+
+void OTimer::stop()
+{
+ OTimerManager *pManager = OTimerManager::getTimerManager();
+
+ VOS_ASSERT(pManager);
+
+ if ( pManager != 0 )
+ {
+ pManager->unregisterTimer(this);
+ }
+}
+
+sal_Bool OTimer::isTicking() const
+{
+ OTimerManager *pManager = OTimerManager::getTimerManager();
+
+ VOS_ASSERT(pManager);
+
+ if (pManager)
+ return pManager->lookupTimer(this);
+ else
+ return sal_False;
+
+}
+
+sal_Bool OTimer::isExpired() const
+{
+ TTimeValue Now;
+
+ osl_getSystemTime(&Now);
+
+ return !(Now < m_Expired);
+}
+
+sal_Bool OTimer::expiresBefore(const OTimer* pTimer) const
+{
+ VOS_ASSERT(pTimer);
+
+ if ( pTimer != 0 )
+ {
+ return m_Expired < pTimer->m_Expired;
+ }
+ else
+ {
+ return sal_False;
+ }
+}
+
+void OTimer::setAbsoluteTime(const TTimeValue& Time)
+{
+ m_TimeOut = 0;
+ m_Expired = Time;
+ m_RepeatDelta = 0;
+
+ m_Expired.normalize();
+}
+
+void OTimer::setRemainingTime(const TTimeValue& Remaining)
+{
+ osl_getSystemTime(&m_Expired);
+
+ m_Expired.addTime(Remaining);
+}
+
+void OTimer::setRemainingTime(const TTimeValue& Remaining, const TTimeValue& Repeat)
+{
+ osl_getSystemTime(&m_Expired);
+
+ m_Expired.addTime(Remaining);
+
+ m_RepeatDelta = Repeat;
+}
+
+void OTimer::addTime(const TTimeValue& Delta)
+{
+ m_Expired.addTime(Delta);
+}
+
+TTimeValue OTimer::getRemainingTime() const
+{
+ TTimeValue Now;
+
+ osl_getSystemTime(&Now);
+
+ sal_Int32 secs = m_Expired.Seconds - Now.Seconds;
+
+ if (secs < 0)
+ return TTimeValue(0, 0);
+
+ sal_Int32 nsecs = m_Expired.Nanosec - Now.Nanosec;
+
+ if (nsecs < 0)
+ {
+ if (secs > 0)
+ {
+ secs -= 1;
+ nsecs += 1000000000;
+ }
+ else
+ return TTimeValue(0, 0);
+ }
+
+ return TTimeValue(secs, nsecs);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Timer manager
+//
+
+OMutex NAMESPACE_VOS(OTimerManager)::m_Access;
+OTimerManager* NAMESPACE_VOS(OTimerManager)::m_pManager=0;
+
+OTimerManager::OTimerManager()
+{
+ OGuard Guard(&m_Access);
+
+ VOS_ASSERT(m_pManager == 0);
+
+ m_pManager = this;
+
+ m_pHead= 0;
+
+ m_notEmpty.reset();
+
+ // start thread
+ create();
+}
+
+OTimerManager::~OTimerManager()
+{
+ OGuard Guard(&m_Access);
+
+ if ( m_pManager == this )
+ m_pManager = 0;
+}
+
+void OTimerManager::onTerminated()
+{
+ delete this; // mfe: AAARRRGGGHHH!!!
+}
+
+OTimerManager* OTimerManager::getTimerManager()
+{
+ OGuard Guard(&m_Access);
+
+ if (! m_pManager)
+ new OTimerManager;
+
+ return (m_pManager);
+}
+
+sal_Bool OTimerManager::registerTimer(OTimer* pTimer)
+{
+ VOS_ASSERT(pTimer);
+
+ if ( pTimer == 0 )
+ {
+ return sal_False;
+ }
+
+ OGuard Guard(&m_Lock);
+
+ // try to find one with equal or lower remaining time.
+ OTimer** ppIter = &m_pHead;
+
+ while (*ppIter)
+ {
+ if (pTimer->expiresBefore(*ppIter))
+ {
+ // next element has higher remaining time,
+ // => insert new timer before
+ break;
+ }
+ ppIter= &((*ppIter)->m_pNext);
+ }
+
+ // next element has higher remaining time,
+ // => insert new timer before
+ pTimer->m_pNext= *ppIter;
+ *ppIter = pTimer;
+
+
+ if (pTimer == m_pHead)
+ {
+ // it was inserted as new head
+ // signal it to TimerManager Thread
+ m_notEmpty.set();
+ }
+
+ return sal_True;
+}
+
+sal_Bool OTimerManager::unregisterTimer(OTimer* pTimer)
+{
+ VOS_ASSERT(pTimer);
+
+ if ( pTimer == 0 )
+ {
+ return sal_False;
+ }
+
+ // lock access
+ OGuard Guard(&m_Lock);
+
+ OTimer** ppIter = &m_pHead;
+
+ while (*ppIter)
+ {
+ if (pTimer == (*ppIter))
+ {
+ // remove timer from list
+ *ppIter = (*ppIter)->m_pNext;
+ return sal_True;
+ }
+ ppIter= &((*ppIter)->m_pNext);
+ }
+
+ return sal_False;
+}
+
+sal_Bool OTimerManager::lookupTimer(const OTimer* pTimer)
+{
+ VOS_ASSERT(pTimer);
+
+ if ( pTimer == 0 )
+ {
+ return sal_False;
+ }
+
+ // lock access
+ OGuard Guard(&m_Lock);
+
+ // check the list
+ for (OTimer* pIter = m_pHead; pIter != 0; pIter= pIter->m_pNext)
+ {
+ if (pIter == pTimer)
+ {
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+void OTimerManager::checkForTimeout()
+{
+
+ m_Lock.acquire();
+
+ if ( m_pHead == 0 )
+ {
+ m_Lock.release();
+ return;
+ }
+
+ OTimer* pTimer = m_pHead;
+
+ if (pTimer->isExpired())
+ {
+ // remove expired timer
+ m_pHead = pTimer->m_pNext;
+
+ pTimer->acquire();
+
+ m_Lock.release();
+
+ pTimer->onShot();
+
+ // restart timer if specified
+ if ( ! pTimer->m_RepeatDelta.isEmpty() )
+ {
+ TTimeValue Now;
+
+ osl_getSystemTime(&Now);
+
+ Now.Seconds += pTimer->m_RepeatDelta.Seconds;
+ Now.Nanosec += pTimer->m_RepeatDelta.Nanosec;
+
+ pTimer->m_Expired = Now;
+
+ registerTimer(pTimer);
+ }
+ pTimer->release();
+ }
+ else
+ {
+ m_Lock.release();
+ }
+
+
+ return;
+}
+
+void OTimerManager::run()
+{
+ setPriority(TPriority_BelowNormal);
+
+ while (schedule())
+ {
+ TTimeValue delay;
+ TTimeValue* pDelay=0;
+
+
+ m_Lock.acquire();
+
+ if (m_pHead != 0)
+ {
+ delay = m_pHead->getRemainingTime();
+ pDelay=&delay;
+ }
+ else
+ {
+ pDelay=0;
+ }
+
+
+ m_notEmpty.reset();
+
+ m_Lock.release();
+
+
+ m_notEmpty.wait(pDelay);
+
+ checkForTimeout();
+ }
+
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Timer manager cleanup
+//
+
+// jbu:
+// The timer manager cleanup has been removed (no thread is killed anymore).
+// So the thread leaks.
+// This will result in a GPF in case the vos-library gets unloaded before
+// process termination.
+// -> TODO : rewrite this file, so that the timerManager thread gets destroyed,
+// when there are no timers anymore !
diff --git a/vos/source/xception.cxx b/vos/source/xception.cxx
new file mode 100644
index 000000000000..a454460be69b
--- /dev/null
+++ b/vos/source/xception.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * 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 <vos/xception.hxx>
+
+using namespace vos;
+
+/*
+ * OException, baseclass of all exceptions
+ */
+
+VOS_IMPLEMENT_CLASSINFO(VOS_CLASSNAME(OException, vos), \
+ VOS_NAMESPACE(OException, vos), \
+ VOS_NAMESPACE(OObject, vos), 0);
+
+OException::~OException()
+{
+}
+
diff --git a/vos/util/libvos1C50.so.mapfile b/vos/util/libvos1C50.so.mapfile
new file mode 100644
index 000000000000..9891ef97b2aa
--- /dev/null
+++ b/vos/util/libvos1C50.so.mapfile
@@ -0,0 +1,274 @@
+{
+ global:
+ __1cDvosFOPipe2G6Mrk1_r1_;
+ __1cDvosFOPipe2T6M_v_;
+ __1cDvosFOPipe2t6M_v_;
+ __1cDvosFOPipe2t6Mpkcn0BLTPipeOption__v_;
+ __1cDvosFOPipe2t6Mpkcn0BLTPipeOption_rkn0AJOSecurity__v_;
+ __1cDvosFOPipe2v6kM_pv_;
+ __1cDvosFOPipeEsend6MpkvL_l_;
+ __1cDvosFOPipeFclose6M_v_;
+ __1cDvosFOPipeGaccept6Mrn0ALOStreamPipe__n0BKTPipeError__;
+ __1cDvosFOPipeGcreate6Mpkcn0BLTPipeOption__C_;
+ __1cDvosFOPipeGcreate6Mpkcn0BLTPipeOption_rkn0AJOSecurity__C_;
+ __1cDvosFOPipeHisValid6kM_C_;
+ __1cDvosGIMutex2T5B6M_v_;
+ __1cDvosGIMutexG__vtbl_;
+ __1cDvosGOMutex2T5B6M_v_;
+ __1cDvosGOMutex2T6M_v_;
+ __1cDvosGOMutex2t5B6M_v_;
+ __1cDvosGOMutex2t6M_v_;
+ __1cDvosGOMutexHacquire6M_v_;
+ __1cDvosGOMutexHrelease6M_v_;
+ __1cDvosGOMutexJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosGOMutexMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosGOMutexMtryToAcquire6M_C_;
+ __1cDvosGOMutexOgetGlobalMutex6F_rn0AGIMutex__;
+ __1cDvosGOTimer2T5B6M_v_;
+ __1cDvosGOTimer2t5B6M_v_;
+ __1cDvosGOTimer2t5B6Mrkn0AKTTimeValue_4_v_;
+ __1cDvosGOTimer2t5B6Mrkn0AKTTimeValue__v_;
+ __1cDvosGOTimerEstop6M_v_;
+ __1cDvosGOTimerFstart6M_v_;
+ __1cDvosGOTimerJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosGOTimerJisTicking6kM_C_;
+ __1cDvosGOTimerMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosGOTimerQsetRemainingTime6Mrkn0AKTTimeValue__v_;
+ __1cDvosHIStream2T5B6M_v_;
+ __1cDvosHODaemon2T5B6M_v_;
+ __1cDvosHODaemon2t5B6Mpkcp24Ln0ANIDaemonAccessSTDaemonStartupMode_4_v_;
+ __1cDvosHODaemonHacquire6M_l_;
+ __1cDvosHODaemonHexecute6Mlppc_n0AOIDaemonManagerTTDaemonManagerError__;
+ __1cDvosHODaemonHgetMode6kM_n0ANIDaemonAccessSTDaemonStartupMode__;
+ __1cDvosHODaemonHrelease6M_l_;
+ __1cDvosHODaemonJgetStatus6kM_n0ANIDaemonAccessNTDaemonStatus__;
+ __1cDvosHODaemonJparseArgs6Flppc_n0BSTCommandLineOption__;
+ __1cDvosHODaemonJsetStatus6Mn0ANIDaemonAccessNTDaemonStatus__v_;
+ __1cDvosHODaemonKgetVersion6kM_L_;
+ __1cDvosHODaemonKreferenced6kM_l_;
+ __1cDvosHODaemonLsetListener6Mrkn0AEORef4n0APIDaemonListener____v_;
+ __1cDvosHODaemonMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosHODaemonNgetIdentifier6kM_pkc_;
+ __1cDvosHODaemonNgetManufactor6kM_pkc_;
+ __1cDvosHODaemonOgetDisplayName6kM_pkc_;
+ __1cDvosHODaemonPgetDependencies6kM_pkc_;
+ __1cDvosHODaemonQexecuteAsProcess6MC_n0AOIDaemonManagerTTDaemonManagerError__;
+ __1cDvosHOModule2T6M_v_;
+ __1cDvosHOModule2t6Mpkcl_v_;
+ __1cDvosHOModuleEload6Mpkcl_C_;
+ __1cDvosHOModuleGunload6M_v_;
+ __1cDvosHOModuleJgetSymbol6Mpkc_pv_;
+ __1cDvosHOObject2T5B6M_v_;
+ __1cDvosHOObject2k6Fpv_v_;
+ __1cDvosHOObject2n6FI_pv_;
+ __1cDvosHOObject2n6FIpv_2_;
+ __1cDvosHOObject2t5B6M_v_;
+ __1cDvosHOObjectIisKindOf6kMrkn0AKOClassInfo__C_;
+ __1cDvosHOObjectJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosHOObjectMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosHOSocket2T5B6M_v_;
+ __1cDvosHOSocket2t5B6Mn0AMISocketTypesLTSocketType_n0CLTAddrFamily_n0CJTProtocol__v_;
+ __1cDvosHOSocket2t5B6Mpv_v_;
+ __1cDvosHOSocket2v6kM_pv_;
+ __1cDvosHOSocketEbind6Mrkn0ALOSocketAddr__C_;
+ __1cDvosHOSocketFclose6M_v_;
+ __1cDvosHOSocketHisValid6kM_C_;
+ __1cDvosHOSocketJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosHOSocketLgetPeerAddr6kMrn0ALOSocketAddr__v_;
+ __1cDvosHOSocketLgetPeerHost6kMpcl_n0AMISocketTypesHTResult__;
+ __1cDvosHOSocketLgetPeerPort6kM_l_;
+ __1cDvosHOSocketMgetLocalAddr6kMrn0ALOSocketAddr__v_;
+ __1cDvosHOSocketMgetLocalHost6kMpcl_n0AMISocketTypesHTResult__;
+ __1cDvosHOSocketMgetLocalPort6kM_l_;
+ __1cDvosHOSocketMsetReuseAddr6kMl_l_;
+ __1cDvosHOSocketNsetTcpNoDelay6kMl_l_;
+ __1cDvosHOSocketOsetRecvBufSize6kMl_l_;
+ __1cDvosHOSocketOsetSendBufSize6kMl_l_;
+ __1cDvosHOSocketVenableNonBlockingMode6MC_C_;
+ __1cDvosHOThread2T5B6M_v_;
+ __1cDvosHOThread2t5B6M_v_;
+ __1cDvosHOThreadEjoin6M_v_;
+ __1cDvosHOThreadEkill6M_v_;
+ __1cDvosHOThreadEwait6FrknJTimeValue__v_;
+ __1cDvosHOThreadFsleep6MrknJTimeValue__n0BMTThreadSleep__;
+ __1cDvosHOThreadFyield6F_v_;
+ __1cDvosHOThreadGcreate6M_C_;
+ __1cDvosHOThreadGresume6M_v_;
+ __1cDvosHOThreadHsuspend6M_v_;
+ __1cDvosHOThreadIschedule6M_C_;
+ __1cDvosHOThreadJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosHOThreadJisRunning6M_C_;
+ __1cDvosHOThreadJterminate6M_v_;
+ __1cDvosHOThreadLsetPriority6Mn0BPTThreadPriority__v_;
+ __1cDvosHOThreadMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosHOThreadMonTerminated6M_v_;
+ __1cDvosHOThreadNgetIdentifier6kM_L_;
+ __1cDvosHOThreadPcreateSuspended6M_C_;
+ __1cDvosHOThreadUgetCurrentIdentifier6F_L_;
+ __1cDvosIOChannelNcreateChannel6Frn0AHOObject__n0AEORef4n0B____;
+ __1cDvosIOProcess2T6M_v_;
+ __1cDvosIOProcess2t6Mpkcp2E_v_;
+ __1cDvosIOProcess2t6Mpkcpp2L_v_;
+ __1cDvosIOProcessEjoin6M_n0BNTProcessError__;
+ __1cDvosIOProcessHexecute6Mn0BOTProcessOption__n0BNTProcessError__;
+ __1cDvosIOProcessHexecute6Mn0BOTProcessOption_rkn0AJOSecurity__n0BNTProcessError__;
+ __1cDvosIOProcessHgetInfo6kMn0BMTProcessData_pn0BMTProcessInfo__n0BNTProcessError__;
+ __1cDvosIOProcessJterminate6M_n0BNTProcessError__;
+ __1cDvosIOProcessKgetProcess6FL_p1_;
+ __1cDvosIOProcessMsetDirectory6Mpkc_v_;
+ __1cDvosIOProcessOaddEnvironment6Mpkcp2_v_;
+ __1cDvosIOProcessOgetCurrentInfo6Fn0BMTProcessData_pn0BMTProcessInfo__n0BNTProcessError__;
+ __1cDvosIOProcessRprovideIOResource6Mpvn0BQTDescriptorFlags__v_;
+ __1cDvosIOProfile2T5B6M_v_;
+ __1cDvosIOProfile2T6M_v_;
+ __1cDvosIOProfile2t5B6M_v_;
+ __1cDvosIOProfile2t5B6Mpkcn0BOTProfileOption__v_;
+ __1cDvosIOProfile2t6M_v_;
+ __1cDvosIOProfile2t6Mpkcn0BOTProfileOption__v_;
+ __1cDvosIOProfileEopen6Mpkcn0BOTProfileOption__C_;
+ __1cDvosIOProfileFclose6M_v_;
+ __1cDvosIOProfileIreadBool6Mpkcp2C_C_;
+ __1cDvosIOProfileJreadIdent6Mpkcp2Lp4L_L_;
+ __1cDvosIOProfileJwriteBool6Mpkcp2C_C_;
+ __1cDvosIOProfileKreadString6Mpkcp2pcL4_C_;
+ __1cDvosIOProfileKwriteIdent6Mpkcp2Lp4L_C_;
+ __1cDvosIOProfileLgetSections6MpkcpcL_L_;
+ __1cDvosIOProfileLremoveEntry6Mpkcp2_C_;
+ __1cDvosIOProfileLwriteString6Mpkcp24_C_;
+ __1cDvosIOProfileOgetProfileName6FpcLpkcp3_C_;
+ __1cDvosIOProfileRgetSectionEntries6MpkcpcL_L_;
+ __1cDvosJOAcceptor2T5B6M_v_;
+ __1cDvosJOAcceptor2t5B6Mrn0AVIAcceptHandlerFactory_rn0ALOSocketAddr_n0AMISocketTypesJTProtocol_n0ELTSocketType_C_v_;
+ __1cDvosJOAcceptor2t6Mrn0AVIAcceptHandlerFactory_rn0ALOSocketAddr_n0AMISocketTypesJTProtocol_n0ELTSocketType_C_v_;
+ __1cDvosJOAcceptorDrun6M_v_;
+ __1cDvosJOAcceptorJterminate6M_v_;
+ __1cDvosJOAcceptorRacceptConnections6Ml_C_;
+ __1cDvosJORefCount2T6M_v_;
+ __1cDvosJORefCountG__vtbl_;
+ __1cDvosJOSecurity2T6M_v_;
+ __1cDvosJOSecurity2t6M_v_;
+ __1cDvosJOSecurityJlogonUser6Mpkcp2_C_;
+ __1cDvosJOSecurityKgetHomeDir6kMpcL_C_;
+ __1cDvosJOSecurityLgetUserName6kMpcL_C_;
+ __1cDvosJOSecurityMgetConfigDir6kMpcL_C_;
+ __1cDvosJOSecurityMgetUserIdent6kMpcL_C_;
+ __1cDvosJOSecurityPisAdministrator6kM_C_;
+ __1cDvosKIReference2T5B6M_v_;
+ __1cDvosKIReferenceG__vtbl_;
+ __1cDvosKOClassInfo2t6Mpkclpk1LpFrkn0AMOCreateParam__pn0AHOObject__v_;
+ __1cDvosKOClassInfoNisDerivedFrom6kMrk1_C_;
+ __1cDvosKOCondition2T6M_v_;
+ __1cDvosKOCondition2t6M_v_;
+ __1cDvosKOConditionDset6M_v_;
+ __1cDvosKOConditionEwait6MpknJTimeValue__n0AKIConditionHTResult__;
+ __1cDvosKOConditionFcheck6M_C_;
+ __1cDvosKOConditionFreset6M_v_;
+ __1cDvosKOReference2T5B6M_v_;
+ __1cDvosKOReference2t5B6M_v_;
+ __1cDvosKOReferenceHacquire6M_l_;
+ __1cDvosKOReferenceHrelease6M_l_;
+ __1cDvosKOSemaphore2T6M_v_;
+ __1cDvosKOSemaphore2t6M_v_;
+ __1cDvosKOSemaphoreG__vtbl_;
+ __1cDvosKOSemaphoreGcreate6ML_v_;
+ __1cDvosKOSemaphoreHacquire6M_v_;
+ __1cDvosKOSemaphoreHrelease6M_v_;
+ __1cDvosKOSemaphoreMtryToAcquire6M_C_;
+ __1cDvosLOEventQdDueueNdispatchEvent6Ml_C_;
+ __1cDvosLOEventQdDueueQregisterListener6Mpn0ATIEventQdDueueListener__C_;
+ __1cDvosLOEventQdDueueSderegisterListener6Mpn0ATIEventQdDueueListener__C_;
+ __1cDvosLOSocketAddr2G6Mrk1_r1_;
+ __1cDvosLOSocketAddr2T6M_v_;
+ __1cDvosLOSocketAddr2t6M_v_;
+ __1cDvosLOSocketAddr2t6Mpv_v_;
+ __1cDvosLOSocketAddr2v6kM_pv_;
+ __1cDvosLOSocketAddrLgetHostname6kMpcl_n0AMISocketTypesHTResult__;
+ __1cDvosLOSocketAddrPresolveHostname6Fpkc_pv_;
+ __1cDvosLOSocketAddrQgetLocalHostname6Fpcl_n0AMISocketTypesHTResult__;
+ __1cDvosLOStreamPipe2G6Mpv_r1_;
+ __1cDvosLOStreamPipe2G6Mrkn0AFOPipe__r1_;
+ __1cDvosLOStreamPipe2T6M_v_;
+ __1cDvosLOStreamPipe2t6M_v_;
+ __1cDvosLOStreamPipe2t6Mrk1_v_;
+ __1cDvosLOStreamPipeEread6kMpvL_l_;
+ __1cDvosLOStreamPipeFisEof6kM_C_;
+ __1cDvosLOStreamPipeFwrite6MpkvL_l_;
+ __1cDvosLOThreadData2T6M_v_;
+ __1cDvosLOThreadData2t6M_v_;
+ __1cDvosLOThreadDataHgetData6M_pv_;
+ __1cDvosLOThreadDataHsetData6Mpv_C_;
+ __1cDvosMOStartupInfo2T6M_v_;
+ __1cDvosMOStartupInfo2t6M_v_;
+ __1cDvosMOStartupInfoOgetCommandArgs6MpcL_n0BNTStartupError__;
+ __1cDvosMOStartupInfoOgetEnvironment6MpkcpcL_n0BNTStartupError__;
+ __1cDvosMOStartupInfoQacceptIOResource6Mrn0AHOSocket__C_;
+ __1cDvosMOStartupInfoRgetExecutableFile6MpcL_n0BNTStartupError__;
+ __1cDvosNOStreamSocket2G6Mrk1_r1_;
+ __1cDvosNOStreamSocket2T6M_v_;
+ __1cDvosNOStreamSocket2t6M_v_;
+ __1cDvosNOStreamSocket2t6Mrk1_v_;
+ __1cDvosNOStreamSocketEread6kMpvL_l_;
+ __1cDvosNOStreamSocketErecv6MpvLn0AMISocketTypesOTSocketMsgFlag__l_;
+ __1cDvosNOStreamSocketFclose6M_v_;
+ __1cDvosNOStreamSocketFisEof6kM_C_;
+ __1cDvosNOStreamSocketFwrite6MpkvL_l_;
+ __1cDvosNOStreamSocketIshutdown6Mn0AMISocketTypesQTSocketDirection__C_;
+ __1cDvosNOStreamSocketJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosNVOS_CLASSINIT2t6Mpn0AKOClassInfo__v_;
+ __1cDvosOIAcceptHandler2T5B6M_v_;
+ __1cDvosOIDaemonManagerQgetGlobalManager6F_n0AEORef4n0B____;
+ __1cDvosOOBaseException2T5B6M_v_;
+ __1cDvosOOBaseExceptionG__vtbl_;
+ __1cDvosOOBaseExceptionJclassInfo6F_rkn0AKOClassInfo__;
+ __1cDvosOOBaseExceptionMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosOOChannelBrokerWgetGlobalChannelBroker6F_n0AEORef4n0B____;
+ __1cDvosOOSignalHandler2T5B6M_v_;
+ __1cDvosOOSignalHandler2t5B6M_v_;
+ __1cDvosOOSignalHandlerFraise6Flpv_n0BNTSignalAction__;
+ __1cDvosOOSignalHandlerMgetClassInfo6kM_rkn0AKOClassInfo__;
+ __1cDvosPOAcceptorSocket2T6M_v_;
+ __1cDvosPOAcceptorSocket2t6Mn0AMISocketTypesLTAddrFamily_n0CJTProtocol_n0CLTSocketType__v_;
+ __1cDvosPOAcceptorSocketFclose6M_v_;
+ __1cDvosPOAcceptorSocketGlisten6Ml_C_;
+ __1cDvosPOAcceptorSocketQacceptConnection6Mrn0ANOStreamSocket__n0AMISocketTypesHTResult__;
+ __1cDvosPODaemonProperty2G6Mrk1_r1_;
+ __1cDvosPODaemonProperty2T6M_v_;
+ __1cDvosPODaemonProperty2t6M_v_;
+ __1cDvosPODaemonProperty2t6MpkcC_v_;
+ __1cDvosPODaemonProperty2t6MpkcL_v_;
+ __1cDvosPODaemonProperty2t6MpkcrknDrtlHOString__v_;
+ __1cDvosPODaemonPropertyHgetName6kM_nDrtlHOString__;
+ __1cDvosPODaemonPropertyHgetType6kM_n0BTTDaemonPropertyType__;
+ __1cDvosPODaemonPropertyIgetULong6ML_L_;
+ __1cDvosPODaemonPropertyJgetString6ML_nDrtlHOString__;
+ __1cDvosPODaemonPropertyKgetBoolean6ML_C_;
+ __1cDvosPOInetSocketAddr2G6Mrk1_r1_;
+ __1cDvosPOInetSocketAddr2T6M_v_;
+ __1cDvosPOInetSocketAddr2t6M_v_;
+ __1cDvosPOInetSocketAddr2t6Mpkcl_v_;
+ __1cDvosPOInetSocketAddr2t6Mpv_v_;
+ __1cDvosPOInetSocketAddr2t6Mrkn0ALOSocketAddr__v_;
+ __1cDvosPOInetSocketAddrHgetPort6kM_l_;
+ __1cDvosPOInetSocketAddrHsetAddr6Mpkc_C_;
+ __1cDvosPOInetSocketAddrHsetPort6Ml_C_;
+ __1cDvosPOInetSocketAddrNgetDottedAddr6kMpcl_n0AMISocketTypesHTResult__;
+ __1cDvosQOConnectorSocket2T6M_v_;
+ __1cDvosQOConnectorSocket2t6Mn0AMISocketTypesLTAddrFamily_n0CJTProtocol_n0CLTSocketType__v_;
+ __1cDvosQOConnectorSocketHconnect6Mrkn0ALOSocketAddr_pknJTimeValue__n0AMISocketTypesHTResult__;
+ __1cDvosSORealDynamicLoaderGgetApi6kM_pv_;
+ __1cDvosSORealDynamicLoaderHacquire6M_L_;
+ __1cDvosSORealDynamicLoaderHrelease6M_L_;
+ __1cDvosSORealDynamicLoaderLnewInstance6Fpp1pkcp4C_2_;
+ __1cDvosSORealDynamicLoaderLnewInstance6Fpp1pkcp4ClC_2_;
+ __1cDvosSORealDynamicLoaderQcomputeSolarName6Fpkcpcl_l_;
+ __1cDvosSORealDynamicLoaderRcomputeModuleName6Fpkcpcl_l_;
+ __1cDvosSORealDynamicLoaderScomputeLibraryName6Fpkcpcl_l_;
+ __1cDvosTIEventQdDueueListener2T5B6M_v_;
+ __1cDvosVIAcceptHandlerFactory2T5B6M_v_;
+ __1cDvosW__RTTI__1nDvosGOTimer__;
+ vosEngulfException;
+ vosMatchException;
+ vosSalvageException;
+ local:
+ *;
+}; \ No newline at end of file
diff --git a/vos/util/makefile.mk b/vos/util/makefile.mk
new file mode 100644
index 000000000000..46c9af4c93db
--- /dev/null
+++ b/vos/util/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+RTLLIB=irtl.lib
+
+PRJ=..
+
+PRJNAME=vos
+TARGET=vos
+TARGETTYPE=CUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : ..$/version.mk
+
+# --- Files --------------------------------------------------------
+
+SHL1TARGET=$(VOS_TARGET)$(VOS_MAJOR)$(COMID)
+SHL1IMPLIB=i$(TARGET)
+
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS=$(WSOCK32LIB) $(SALLIB)
+.ELSE
+SHL1STDLIBS=$(SALLIB)
+.ENDIF
+
+SHL1LIBS= $(SLB)$/cpp$(TARGET).lib
+.IF "$(GUI)" != "UNX"
+.IF "$(COM)" != "GCC"
+SHL1OBJS= \
+ $(SLO)$/object.obj
+.ENDIF
+.ENDIF
+
+SHL1DEPN=
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME =$(SHL1TARGET)
+DEF1DEPN =$(MISC)$/$(SHL1TARGET).flt
+DEFLIB1NAME =cppvos
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/$(SHL1TARGET).flt:
+ @echo ------------------------------
+ @echo Making: $@
+ @echo WEP > $@
+ @echo LIBMAIN >> $@
+ @echo LibMain >> $@
+ @echo _alloc >> $@
+ @echo alloc >> $@
+ @echo _CT >> $@
+ @echo _TI2 >> $@
+ @echo _TI1 >> $@
+ @echo exception::exception >> $@
+ @echo @std@ >> $@
+ @echo __>>$@
+
diff --git a/vos/version.mk b/vos/version.mk
new file mode 100644
index 000000000000..f5447ebeedba
--- /dev/null
+++ b/vos/version.mk
@@ -0,0 +1,40 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+# target
+VOS_TARGET=vos
+
+# the major
+VOS_MAJOR=3
+# the minor
+VOS_MINOR=0
+# the micro
+VOS_MICRO=0
+
+# this is a c++ compatible library
+VOS_CPP=1
+