summaryrefslogtreecommitdiff
path: root/sal/workben
diff options
context:
space:
mode:
Diffstat (limited to 'sal/workben')
-rw-r--r--sal/workben/clipboardwben/testcopy/StdAfx.cpp8
-rw-r--r--sal/workben/clipboardwben/testcopy/StdAfx.h32
-rw-r--r--sal/workben/clipboardwben/testcopy/TestWin32.icobin0 -> 1590 bytes
-rw-r--r--sal/workben/clipboardwben/testcopy/XTDataObject.cxx470
-rw-r--r--sal/workben/clipboardwben/testcopy/XTDataObject.hxx132
-rw-r--r--sal/workben/clipboardwben/testcopy/cbcpytest.cxx402
-rw-r--r--sal/workben/clipboardwben/testcopy/cbcpytest.rc122
-rw-r--r--sal/workben/clipboardwben/testcopy/makefile.mk67
-rw-r--r--sal/workben/clipboardwben/testcopy/resource.h31
-rw-r--r--sal/workben/clipboardwben/testcopy/small.icobin0 -> 318 bytes
-rw-r--r--sal/workben/clipboardwben/testpaste/StdAfx.cpp8
-rw-r--r--sal/workben/clipboardwben/testpaste/StdAfx.h32
-rw-r--r--sal/workben/clipboardwben/testpaste/TestWin32.icobin0 -> 1590 bytes
-rw-r--r--sal/workben/clipboardwben/testpaste/cbptest.cxx428
-rw-r--r--sal/workben/clipboardwben/testpaste/cbptest.rc120
-rw-r--r--sal/workben/clipboardwben/testpaste/makefile.mk67
-rw-r--r--sal/workben/clipboardwben/testpaste/resource.h28
-rw-r--r--sal/workben/clipboardwben/testpaste/small.icobin0 -> 318 bytes
-rw-r--r--sal/workben/clipboardwben/testviewer/StdAfx.cpp8
-rw-r--r--sal/workben/clipboardwben/testviewer/StdAfx.h32
-rw-r--r--sal/workben/clipboardwben/testviewer/TestWin32.icobin0 -> 1590 bytes
-rw-r--r--sal/workben/clipboardwben/testviewer/cbvtest.cxx351
-rw-r--r--sal/workben/clipboardwben/testviewer/cbvtest.rc127
-rw-r--r--sal/workben/clipboardwben/testviewer/makefile.mk67
-rw-r--r--sal/workben/clipboardwben/testviewer/resource.h32
-rw-r--r--sal/workben/clipboardwben/testviewer/small.icobin0 -> 318 bytes
-rw-r--r--sal/workben/export.exp1
-rw-r--r--sal/workben/getlocaleinfotest.cxx50
-rw-r--r--sal/workben/makefile.mk386
-rw-r--r--sal/workben/saldyntest.c52
-rw-r--r--sal/workben/salstattest.c56
-rw-r--r--sal/workben/t_cipher.c396
-rw-r--r--sal/workben/t_digest.c378
-rw-r--r--sal/workben/t_ojp_exe.cxx55
-rw-r--r--sal/workben/t_osl_getVolInfo.cxx132
-rw-r--r--sal/workben/t_osl_joinProcess.cxx228
-rw-r--r--sal/workben/t_random.c65
-rw-r--r--sal/workben/t_readline.c58
-rw-r--r--sal/workben/test.cxx66
-rw-r--r--sal/workben/testfile.cxx2786
-rw-r--r--sal/workben/testpip2.cxx97
-rw-r--r--sal/workben/testpipe.cxx168
-rw-r--r--sal/workben/testproc.cxx77
-rw-r--r--sal/workben/tgetpwnam.cxx248
44 files changed, 7863 insertions, 0 deletions
diff --git a/sal/workben/clipboardwben/testcopy/StdAfx.cpp b/sal/workben/clipboardwben/testcopy/StdAfx.cpp
new file mode 100644
index 000000000000..cb07d603f28f
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet
+// TestWin32.pch ist die vorkompilierte Header-Datei
+// stdafx.obj enthält die vorkompilierte Typinformation
+
+#include "stdafx.h"
+
+// ZU ERLEDIGEN: Verweis auf alle zusätzlichen Header-Dateien, die Sie in STDAFX.H
+// und nicht in dieser Datei benötigen
diff --git a/sal/workben/clipboardwben/testcopy/StdAfx.h b/sal/workben/clipboardwben/testcopy/StdAfx.h
new file mode 100644
index 000000000000..bb762adbdc36
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/StdAfx.h
@@ -0,0 +1,32 @@
+// stdafx.h : Include-Datei für Standard-System-Include-Dateien,
+// oder projektspezifische Include-Dateien, die häufig benutzt, aber
+// in unregelmäßigen Abständen geändert werden.
+//
+
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden
+
+
+// Windows-Header-Dateien:
+#include <windows.h>
+
+// Header-Dateien der C-Laufzeit
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+// Lokale Header-Dateien
+
+// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
diff --git a/sal/workben/clipboardwben/testcopy/TestWin32.ico b/sal/workben/clipboardwben/testcopy/TestWin32.ico
new file mode 100644
index 000000000000..255ff3be4fba
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/TestWin32.ico
Binary files differ
diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
new file mode 100644
index 000000000000..14887dd9021c
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
@@ -0,0 +1,470 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+#include <osl/diagnose.h>
+
+#ifndef _TWRAPPERDATAOBJECT_HXX_
+#include "XTDataObject.hxx"
+#endif
+
+#include <windows.h>
+#include <ole2.h>
+#include <memory>
+
+//------------------------------------------------------------------------
+// namespace directives
+//------------------------------------------------------------------------
+
+
+//============================================================================
+// OTWrapperDataObject
+//============================================================================
+
+//------------------------------------------------------------------------
+// ctor
+//------------------------------------------------------------------------
+
+CXTDataObject::CXTDataObject( LONG nRefCntInitVal ) :
+ m_nRefCnt( nRefCntInitVal )
+{
+}
+
+//------------------------------------------------------------------------
+// dtor
+//------------------------------------------------------------------------
+
+CXTDataObject::~CXTDataObject( )
+{
+}
+
+//------------------------------------------------------------------------
+// IUnknown->QueryInterface
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ OSL_ASSERT( NULL != ppvObject );
+
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IDataObject ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ ( (LPUNKNOWN)*ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IUnknown->AddRef
+//------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CXTDataObject::AddRef( )
+{
+ return static_cast< ULONG >( InterlockedIncrement( &m_nRefCnt ) );
+}
+
+//------------------------------------------------------------------------
+// IUnknown->Release
+//------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CXTDataObject::Release( )
+{
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = static_cast< ULONG >( InterlockedDecrement( &m_nRefCnt ) );
+
+ if ( 0 == nRefCnt )
+ {
+ delete this;
+ }
+
+ return nRefCnt;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetData
+// warning: 'goto' ahead (to easy error handling without using exceptions)
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium )
+{
+ OSL_ASSERT( ( NULL != pFormatetc ) &&
+ ( !IsBadReadPtr( (LPVOID)pFormatetc, sizeof( FORMATETC ) ) ) );
+ OSL_ASSERT( ( NULL != pmedium ) &&
+ ( !IsBadWritePtr( (LPVOID)pmedium, sizeof( STGMEDIUM ) ) ) );
+
+ if ( ( NULL == pFormatetc ) || ( NULL == pmedium ) )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ if ( CF_TEXT == pFormatetc->cfFormat )
+ {
+ char buff[] = "Hello World, How are you!";
+ LPSTREAM lpStream;
+
+ hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = lpStream->Write( buff, sizeof( buff ) * sizeof( char ), NULL );
+ if ( SUCCEEDED( hr ) )
+ {
+ HGLOBAL hGlob;
+
+ GetHGlobalFromStream( lpStream, &hGlob );
+
+ pmedium->tymed = TYMED_HGLOBAL;
+ pmedium->hGlobal = hGlob;
+ pmedium->pUnkForRelease = NULL;
+ }
+ lpStream->Release( );
+ hr = S_OK;
+ }
+ else
+ {
+ pmedium->tymed = TYMED_NULL;
+ }
+ }
+ else if ( CF_UNICODETEXT == pFormatetc->cfFormat )
+ {
+ WCHAR buff[] = L"Hello World, How are you!";
+ LPSTREAM lpStream;
+
+ hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream );
+ if ( SUCCEEDED( hr ) )
+ {
+ hr = lpStream->Write( buff, sizeof( buff ) * sizeof( WCHAR ), NULL );
+ if ( SUCCEEDED( hr ) )
+ {
+ HGLOBAL hGlob;
+
+ GetHGlobalFromStream( lpStream, &hGlob );
+
+ pmedium->tymed = TYMED_HGLOBAL;
+ pmedium->hGlobal = hGlob;
+ pmedium->pUnkForRelease = NULL;
+ }
+ lpStream->Release( );
+ hr = S_OK;
+ }
+ else
+ {
+ pmedium->tymed = TYMED_NULL;
+ }
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->EnumFormatEtc
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc )
+{
+ if ( ( NULL == ppenumFormatetc ) || ( DATADIR_SET == dwDirection ) )
+ return E_INVALIDARG;
+
+ *ppenumFormatetc = NULL;
+
+ HRESULT hr = E_FAIL;
+
+ if ( DATADIR_GET == dwDirection )
+ {
+ *ppenumFormatetc = new CEnumFormatEtc( this );
+ static_cast< LPUNKNOWN >( *ppenumFormatetc )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->QueryGetData
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::QueryGetData( LPFORMATETC pFormatetc )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetDataHere
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetDataHere( LPFORMATETC, LPSTGMEDIUM )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->GetCanonicalFormatEtc
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::GetCanonicalFormatEtc( LPFORMATETC, LPFORMATETC )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->SetData
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::SetData( LPFORMATETC, LPSTGMEDIUM, BOOL )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->DAdvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::DAdvise( LPFORMATETC, DWORD, LPADVISESINK, DWORD * )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->DUnadvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::DUnadvise( DWORD )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// IDataObject->EnumDAdvise
+//------------------------------------------------------------------------
+
+STDMETHODIMP CXTDataObject::EnumDAdvise( LPENUMSTATDATA * )
+{
+ return E_NOTIMPL;
+}
+
+//------------------------------------------------------------------------
+// for our convenience
+//------------------------------------------------------------------------
+
+CXTDataObject::operator IDataObject*( )
+{
+ return static_cast< IDataObject* >( this );
+}
+
+
+//============================================================================
+// CEnumFormatEtc
+//============================================================================
+
+
+//----------------------------------------------------------------------------
+// ctor
+//----------------------------------------------------------------------------
+
+CEnumFormatEtc::CEnumFormatEtc( LPUNKNOWN pUnkDataObj ) :
+ m_nRefCnt( 0 ),
+ m_pUnkDataObj( pUnkDataObj ),
+ m_nCurrentPos( 0 )
+{
+ m_cfFormats[0] = CF_UNICODETEXT;
+ m_cfFormats[1] = CF_TEXT;
+}
+
+//----------------------------------------------------------------------------
+// dtor
+//----------------------------------------------------------------------------
+
+CEnumFormatEtc::~CEnumFormatEtc( )
+{
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->QueryInterface
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::QueryInterface( REFIID iid, LPVOID* ppvObject )
+{
+ if ( NULL == ppvObject )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_NOINTERFACE;
+
+ *ppvObject = NULL;
+
+ if ( ( __uuidof( IUnknown ) == iid ) || ( __uuidof( IEnumFORMATETC ) == iid ) )
+ {
+ *ppvObject = static_cast< IUnknown* >( this );
+ static_cast< LPUNKNOWN >( *ppvObject )->AddRef( );
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->AddRef
+//----------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::AddRef( )
+{
+ // keep the dataobject alive
+ m_pUnkDataObj->AddRef( );
+ return InterlockedIncrement( &m_nRefCnt );
+}
+
+//----------------------------------------------------------------------------
+// IUnknown->Release
+//----------------------------------------------------------------------------
+
+STDMETHODIMP_(ULONG) CEnumFormatEtc::Release( )
+{
+ // release the outer dataobject
+ m_pUnkDataObj->Release( );
+
+ // we need a helper variable because it's
+ // not allowed to access a member variable
+ // after an object is destroyed
+ ULONG nRefCnt = InterlockedDecrement( &m_nRefCnt );
+ if ( 0 == nRefCnt )
+ delete this;
+
+ return nRefCnt;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Next
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched )
+{
+ OSL_ASSERT( ( ( celt > 0 ) && ( NULL != rgelt ) ) ||
+ ( ( 0 == celt ) && ( NULL == rgelt ) ) );
+
+ if ( ( 0 != celt ) && ( NULL == rgelt ) )
+ return E_INVALIDARG;
+
+ ULONG ulFetched = 0;
+ ULONG ulToFetch = celt;
+ HRESULT hr = S_FALSE;
+
+ while( ( m_nCurrentPos < sizeof( m_cfFormats ) ) && ( ulToFetch > 0 ) )
+ {
+ OSL_ASSERT( !IsBadWritePtr( (LPVOID)rgelt, sizeof( FORMATETC ) ) );
+
+ rgelt->cfFormat = m_cfFormats[m_nCurrentPos];
+ rgelt->ptd = NULL;
+ rgelt->dwAspect = DVASPECT_CONTENT;
+ rgelt->lindex = -1;
+ rgelt->tymed = TYMED_HGLOBAL;
+
+ ++m_nCurrentPos;
+ ++rgelt;
+ --ulToFetch;
+ ++ulFetched;
+ }
+
+ if ( ulFetched == celt )
+ hr = S_OK;
+
+ if ( NULL != pceltFetched )
+ {
+ OSL_ASSERT( !IsBadWritePtr( (LPVOID)pceltFetched, sizeof( ULONG ) ) );
+ *pceltFetched = ulFetched;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Skip
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Skip( ULONG celt )
+{
+ HRESULT hr = S_FALSE;
+
+ if ( ( m_nCurrentPos + celt ) < sizeof( m_cfFormats ) )
+ {
+ m_nCurrentPos += celt;
+ hr = S_OK;
+ }
+
+ return hr;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Reset
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Reset( )
+{
+ m_nCurrentPos = 0;
+ return S_OK;
+}
+
+//----------------------------------------------------------------------------
+// IEnumFORMATETC->Clone
+//----------------------------------------------------------------------------
+
+STDMETHODIMP CEnumFormatEtc::Clone( IEnumFORMATETC** ppenum )
+{
+ OSL_ASSERT( NULL != ppenum );
+
+ if ( NULL == ppenum )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_FAIL;
+
+ *ppenum = NULL;
+
+ CEnumFormatEtc* pCEnumFEtc = new CEnumFormatEtc( m_pUnkDataObj );
+ if ( NULL != pCEnumFEtc )
+ {
+ pCEnumFEtc->m_nCurrentPos = m_nCurrentPos;
+ *ppenum = static_cast< IEnumFORMATETC* >( pCEnumFEtc );
+ static_cast< LPUNKNOWN >( *ppenum )->AddRef( );
+ hr = NOERROR;
+ }
+
+ return hr;
+}
+
diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.hxx b/sal/workben/clipboardwben/testcopy/XTDataObject.hxx
new file mode 100644
index 000000000000..d2639b591590
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/XTDataObject.hxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _XTDATAOBJECT_HXX_
+#define _XTDATAOBJECT_HXX_
+
+
+//------------------------------------------------------------------------
+// includes
+//------------------------------------------------------------------------
+
+/*
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp>
+#include "WinClipboard.hxx"
+*/
+
+#include <windows.h>
+#include <ole2.h>
+#include <objidl.h>
+
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+class EnumFormatEtc;
+
+class CXTDataObject : public IDataObject
+{
+public:
+ CXTDataObject( LONG nRefCntInitVal = 0);
+ ~CXTDataObject( );
+
+ //-----------------------------------------------------------------
+ // ole interface implementation
+ //-----------------------------------------------------------------
+
+ //IUnknown
+ STDMETHODIMP QueryInterface(REFIID iid, LPVOID* ppvObject);
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ //IDataObject
+ STDMETHODIMP GetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
+ STDMETHODIMP GetDataHere( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium );
+ STDMETHODIMP QueryGetData( LPFORMATETC pFormatetc );
+ STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pFormatectIn, LPFORMATETC pFormatetcOut );
+ STDMETHODIMP SetData( LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease );
+ STDMETHODIMP EnumFormatEtc( DWORD dwDirection, IEnumFORMATETC** ppenumFormatetc );
+ STDMETHODIMP DAdvise( LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD* pdwConnection );
+ STDMETHODIMP DUnadvise( DWORD dwConnection );
+ STDMETHODIMP EnumDAdvise( LPENUMSTATDATA* ppenumAdvise );
+
+ operator IDataObject*( );
+
+ // notification handler
+ //void SAL_CALL LostOwnership( );
+
+ //sal_Int64 SAL_CALL QueryDataSize( );
+
+ // retrieve the data from the source
+ // necessary so that
+ //void SAL_CALL GetAllDataFromSource( );
+
+private:
+ LONG m_nRefCnt;
+ //CWinClipboard& m_rCWinClipboard;
+ //const const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& m_rXClipboardOwner;
+ //const const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& m_rXTDataSource;
+
+ //friend class CWinClipboard;
+ friend class CEnumFormatEtc;
+};
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+class CEnumFormatEtc : public IEnumFORMATETC
+{
+public:
+ CEnumFormatEtc( LPUNKNOWN pUnkDataObj );
+ ~CEnumFormatEtc( );
+
+ // IUnknown
+ STDMETHODIMP QueryInterface( REFIID iid, LPVOID* ppvObject );
+ STDMETHODIMP_( ULONG ) AddRef( );
+ STDMETHODIMP_( ULONG ) Release( );
+
+ //IEnumFORMATETC
+ STDMETHODIMP Next( ULONG celt, LPFORMATETC rgelt, ULONG* pceltFetched );
+ STDMETHODIMP Skip( ULONG celt );
+ STDMETHODIMP Reset( );
+ STDMETHODIMP Clone( IEnumFORMATETC** ppenum );
+
+private:
+ LONG m_nRefCnt;
+ LPUNKNOWN m_pUnkDataObj;
+ ULONG m_nCurrentPos;
+ CLIPFORMAT m_cfFormats[2];
+};
+
+
+typedef CEnumFormatEtc *PCEnumFormatEtc;
+
+#endif
diff --git a/sal/workben/clipboardwben/testcopy/cbcpytest.cxx b/sal/workben/clipboardwben/testcopy/cbcpytest.cxx
new file mode 100644
index 000000000000..1ce6c8cd2d76
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/cbcpytest.cxx
@@ -0,0 +1,402 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+// TestWin32.cpp : Definiert den Einsprungpunkt für die Anwendung.
+//
+
+#define _WIN32_DCOM
+#undef _UNICODE
+
+#include "stdafx.h"
+
+#include <windows.h>
+
+#include <ole2.h>
+#include <objidl.h>
+#include <objbase.h>
+#include <process.h>
+#include <olectl.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <..\..\inc\systools\win32\MtaOleClipb.h>
+#include "XTDataObject.hxx"
+
+#include "resource.h"
+
+#define MAX_LOADSTRING 100
+#undef USE_MTACB
+
+#define MSG_FLUSHCLIPBOARD WM_USER + 1
+
+// Globale Variablen:
+HINSTANCE hInst; // aktuelle Instanz
+TCHAR szTitle[MAX_LOADSTRING]; // Text der Titelzeile
+TCHAR szWindowClass[MAX_LOADSTRING]; // Text der Titelzeile
+ATOM MyRegisterClass( HINSTANCE hInstance );
+BOOL InitInstance( HINSTANCE, int );
+LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
+LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM );
+void CopyClipboardData(HWND hwndParent);
+void FlushClipboard( );
+void PasteData( HWND hWnd );
+void SetLocale();
+
+
+LPSTREAM g_pStm = NULL;
+char* pTextBuff = NULL;
+DWORD lData = 0;
+CXTDataObject* g_xtDo = NULL;
+HWND g_hWnd;
+HANDLE g_hEvent;
+BOOL g_bEnd;
+
+//----------------------------------------------------
+// a thread function
+//----------------------------------------------------
+
+unsigned int _stdcall ThreadProc(LPVOID pParam)
+{
+ while( !g_bEnd )
+ {
+ WaitForSingleObject( g_hEvent, INFINITE );
+ SendMessage( g_hWnd, MSG_FLUSHCLIPBOARD, WPARAM(0), LPARAM(0) );
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------
+// WinMain
+//----------------------------------------------------
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow )
+{
+ // ZU ERLEDIGEN: Fügen Sie hier den Code ein.
+ MSG msg;
+ HACCEL hAccelTable;
+ HRESULT hr = E_FAIL;
+
+ /*
+ g_hEvent = CreateEvent( 0,
+ FALSE,
+ FALSE,
+ NULL
+ );
+
+ g_bEnd = FALSE;
+
+ _beginthreadex( ThreadProc,
+ 0,
+ NULL,
+ 0,
+ 0,
+ NULL );
+ */
+
+ // it's important to initialize ole
+ // in order to use the clipboard
+#ifdef USE_MTACB
+ hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+#else
+ hr = OleInitialize( NULL );
+#endif
+
+
+ // Globale Zeichenfolgen initialisieren
+ LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+ LoadString(hInstance, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING);
+ MyRegisterClass(hInstance);
+
+ // Initialisierung der Anwendung durchführen:
+ if( !InitInstance( hInstance, nCmdShow ) )
+ {
+ return FALSE;
+ }
+
+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32);
+
+ // Hauptnachrichtenschleife:
+ while( GetMessage(&msg, NULL, 0, 0) )
+ {
+ if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) )
+ {
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+ }
+
+ // uninitializing the ole libraries
+#ifdef USE_MTACB
+ CoUninitialize( );
+#else
+ OleUninitialize( );
+#endif
+
+ CloseHandle( g_hEvent );
+
+ return msg.wParam;
+}
+
+
+
+//----------------------------------------------------------------
+// FUNKTION: MyRegisterClass()
+//
+// AUFGABE: Registriert die Fensterklasse.
+//
+// KOMMENTARE:
+//
+// Diese Funktion und ihre Verwendung sind nur notwendig, wenn dieser Code
+// mit Win32-Systemen vor der 'RegisterClassEx'-Funktion kompatibel sein soll,
+// die zu Windows 95 hinzugefügt wurde. Es ist wichtig diese Funktion aufzurufen,
+// damit der Anwendung kleine Symbole mit den richtigen Proportionen zugewiesen
+// werden.
+//----------------------------------------------------------------
+
+ATOM MyRegisterClass( HINSTANCE hInstance )
+{
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32);
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wcex.lpszMenuName = (LPCTSTR)IDC_TESTWIN32;
+ wcex.lpszClassName = _T(szWindowClass);
+ wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+
+ return RegisterClassEx(&wcex);
+}
+
+//----------------------------------------------------------------
+// FUNKTION: InitInstance(HANDLE, int)
+//
+// AUFGABE: Speichert die Instanzzugriffsnummer und erstellt das Hauptfenster
+//
+// KOMMENTARE:
+//
+// In dieser Funktion wird die Instanzzugriffsnummer in einer globalen Variable
+// gespeichert und das Hauptprogrammfenster erstellt und angezeigt.
+//----------------------------------------------------------------
+
+BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
+{
+ hInst = hInstance; // Instanzzugriffsnummer in unserer globalen Variable speichern
+
+ g_hWnd = CreateWindowEx(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+ if( !g_hWnd )
+ {
+ return FALSE;
+ }
+
+ ShowWindow( g_hWnd, nCmdShow );
+ UpdateWindow( g_hWnd );
+
+ return TRUE;
+}
+
+//----------------------------------------------------------------
+// FUNKTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// AUFGABE: Verarbeitet Nachrichten für das Hauptfenster.
+//
+// WM_COMMAND - Anwendungsmenü verarbeiten
+// WM_PAINT - Hauptfenster darstellen
+// WM_DESTROY - Beendigungsnachricht ausgeben und zurückkehren
+//----------------------------------------------------------------
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId;
+ int wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ TCHAR szHello[MAX_LOADSTRING];
+
+
+ LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
+
+ switch( message )
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ // Menüauswahlen analysieren:
+ switch( wmId )
+ {
+ case IDD_COPY:
+ CopyClipboardData(hWnd);
+ break;
+ case IDD_PASTE2:
+ PasteData(hWnd);
+ break;
+ case IDD_LOCALE:
+ SetLocale();
+ break;
+ case IDM_EXIT:
+ DestroyWindow( hWnd );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ break;
+
+ case WM_PAINT:
+ hdc = BeginPaint (hWnd, &ps);
+ // ZU ERLEDIGEN: Hier beliebigen Code zum Zeichnen hinzufügen...
+ RECT rt;
+ GetClientRect( hWnd, &rt );
+
+ if ( NULL != pTextBuff )
+ {
+ DrawText( hdc, pTextBuff, lData, &rt, DT_CENTER );
+ }
+ else
+ {
+ DrawText( hdc, szHello, strlen(szHello), &rt, DT_CENTER );
+ }
+
+ EndPaint( hWnd, &ps );
+ break;
+
+ case WM_DESTROY:
+ g_bEnd = TRUE;
+ SetEvent( g_hEvent );
+ FlushClipboard( );
+ PostQuitMessage( 0 );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ return 0;
+}
+
+//----------------------------------------------
+// copy data into the clipboard
+//----------------------------------------------
+
+void CopyClipboardData( HWND hWnd )
+{
+ g_xtDo = new CXTDataObject( 1 );
+#ifdef USE_MTACB
+ MTASetClipboard( static_cast< IDataObject* >( g_xtDo ) );
+#else
+ OleSetClipboard( static_cast< IDataObject* >( g_xtDo ) );
+#endif
+}
+
+//----------------------------------------------
+// flush the content into the clipboard
+//----------------------------------------------
+
+void FlushClipboard( )
+{
+ if ( NULL != g_xtDo )
+ {
+#ifdef USE_MTACB
+ HRESULT hr = MTAIsCurrentClipboard( static_cast< IDataObject* >( g_xtDo ) );
+ if ( S_OK == hr )
+ MTAFlushClipboard( );
+#else
+ HRESULT hr = OleIsCurrentClipboard( static_cast< IDataObject* >( g_xtDo ) );
+ if ( S_OK == hr )
+ OleFlushClipboard( );
+#endif
+
+ static_cast< IDataObject* >( g_xtDo )->Release( );
+ }
+}
+
+
+void PasteData(HWND hWnd)
+{
+ IDataObject* pDataObj;
+
+ //FlushClipboard( );
+
+ HRESULT hr = OleGetClipboard( &pDataObj );
+ if ( SUCCEEDED( hr ) )
+ {
+ FORMATETC fetc;
+ STGMEDIUM stgmedium;
+
+ fetc.cfFormat = CF_LOCALE;
+ fetc.ptd = NULL;
+ fetc.dwAspect = DVASPECT_CONTENT;
+ fetc.lindex = -1;
+ fetc.tymed = TYMED_HGLOBAL;
+
+ hr = pDataObj->GetData( &fetc, &stgmedium );
+ if ( SUCCEEDED( hr ) )
+ {
+ LPVOID lpData = GlobalLock( stgmedium.hGlobal );
+
+ if ( NULL != lpData )
+ {
+ LCID lcid = *( (WORD*)lpData );
+
+ WORD langID = LANGIDFROMLCID( lcid );
+ WORD sublangID = SUBLANGID( langID );
+
+ TCHAR buff[6];
+ int cbWritten = GetLocaleInfo( lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof( buff ) );
+ cbWritten = GetLocaleInfo( lcid, LOCALE_IDEFAULTCODEPAGE, buff, sizeof( buff ) );
+
+ GlobalUnlock( stgmedium.hGlobal );
+ }
+ else
+ {
+ DWORD dwLastError = GetLastError( );
+ }
+
+ ReleaseStgMedium( &stgmedium );
+ }
+ }
+}
+
+
+void SetLocale()
+{
+ LCID threadLcid = GetThreadLocale();
+}
+
diff --git a/sal/workben/clipboardwben/testcopy/cbcpytest.rc b/sal/workben/clipboardwben/testcopy/cbcpytest.rc
new file mode 100644
index 000000000000..a9db008536ac
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/cbcpytest.rc
@@ -0,0 +1,122 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO"
+IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_TESTWIN32 MENU DISCARDABLE
+BEGIN
+ POPUP "&Datei"
+ BEGIN
+ MENUITEM "&Copy", IDD_COPY
+ MENUITEM "Paste", IDD_PASTE2
+ MENUITEM "Set Locale", IDD_LOCALE
+ MENUITEM SEPARATOR
+ MENUITEM "&Beenden", IDM_EXIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE
+BEGIN
+ "?", IDM_ABOUT, ASCII, ALT
+ "/", IDM_ABOUT, ASCII, ALT
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_APP_TITLE "TestWin32"
+ IDS_HELLO "Hallo Welt!"
+ IDC_TESTWIN32 "TESTWIN32"
+END
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/sal/workben/clipboardwben/testcopy/makefile.mk b/sal/workben/clipboardwben/testcopy/makefile.mk
new file mode 100644
index 000000000000..7c1454f05db8
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sal
+TARGET=cbcpytest
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+= $(LFS_CFLAGS)
+CXXFLAGS+= $(LFS_CFLAGS)
+
+# --- Files --------------------------------------------------------
+
+#
+# test clipboard paste
+#
+ # --- Resources ----------------------------------------------------
+ RCFILES= cbcpytest.rc
+
+ OBJFILES= $(OBJ)$/cbcpytest.obj $(OBJ)$/XTDataObject.obj
+
+ APP1TARGET= $(TARGET)
+ APP1OBJS= $(OBJFILES)
+ APP1NOSAL= TRUE
+ APP1NOSVRES= $(RES)$/$(TARGET).res
+
+ APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB) $(SALLIB)
+
+ APP1LIBS=$(LB)$/iole9x.lib \
+ $(LB)$/tools32.lib
+
+ APP1DEPN= makefile.mk $(APP1NOSVRES)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sal/workben/clipboardwben/testcopy/resource.h b/sal/workben/clipboardwben/testcopy/resource.h
new file mode 100644
index 000000000000..5f70db1bb13f
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/resource.h
@@ -0,0 +1,31 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by cbcpytest.rc
+//
+#define IDC_MYICON 2
+#define IDD_TESTWIN32_DIALOG 102
+#define IDD_ABOUTBOX 103
+#define IDS_APP_TITLE 103
+#define IDM_ABOUT 104
+#define IDM_EXIT 105
+#define IDS_HELLO 106
+#define IDI_TESTWIN32 107
+#define IDI_SMALL 108
+#define IDC_TESTWIN32 109
+#define IDR_MAINFRAME 128
+#define IDD_PASTE 32771
+#define IDD_COPY 32771
+#define IDD_PASTE2 32772
+#define IDD_LOCALE 32773
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32774
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
diff --git a/sal/workben/clipboardwben/testcopy/small.ico b/sal/workben/clipboardwben/testcopy/small.ico
new file mode 100644
index 000000000000..8f94d9aa8285
--- /dev/null
+++ b/sal/workben/clipboardwben/testcopy/small.ico
Binary files differ
diff --git a/sal/workben/clipboardwben/testpaste/StdAfx.cpp b/sal/workben/clipboardwben/testpaste/StdAfx.cpp
new file mode 100644
index 000000000000..cb07d603f28f
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet
+// TestWin32.pch ist die vorkompilierte Header-Datei
+// stdafx.obj enthält die vorkompilierte Typinformation
+
+#include "stdafx.h"
+
+// ZU ERLEDIGEN: Verweis auf alle zusätzlichen Header-Dateien, die Sie in STDAFX.H
+// und nicht in dieser Datei benötigen
diff --git a/sal/workben/clipboardwben/testpaste/StdAfx.h b/sal/workben/clipboardwben/testpaste/StdAfx.h
new file mode 100644
index 000000000000..bb762adbdc36
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/StdAfx.h
@@ -0,0 +1,32 @@
+// stdafx.h : Include-Datei für Standard-System-Include-Dateien,
+// oder projektspezifische Include-Dateien, die häufig benutzt, aber
+// in unregelmäßigen Abständen geändert werden.
+//
+
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden
+
+
+// Windows-Header-Dateien:
+#include <windows.h>
+
+// Header-Dateien der C-Laufzeit
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+// Lokale Header-Dateien
+
+// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
diff --git a/sal/workben/clipboardwben/testpaste/TestWin32.ico b/sal/workben/clipboardwben/testpaste/TestWin32.ico
new file mode 100644
index 000000000000..255ff3be4fba
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/TestWin32.ico
Binary files differ
diff --git a/sal/workben/clipboardwben/testpaste/cbptest.cxx b/sal/workben/clipboardwben/testpaste/cbptest.cxx
new file mode 100644
index 000000000000..f26d51ec6d72
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/cbptest.cxx
@@ -0,0 +1,428 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+// TestWin32.cpp : Definiert den Einsprungpunkt für die Anwendung.
+//
+
+#define _WIN32_DCOM
+
+#include "stdafx.h"
+
+#include <windows.h>
+
+#include <ole2.h>
+#include <objidl.h>
+#include <objbase.h>
+#include <process.h>
+#include <olectl.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <..\..\inc\systools\win32\MtaOleClipb.h>
+
+#include "resource.h"
+
+#define MAX_LOADSTRING 100
+
+// Globale Variablen:
+HINSTANCE hInst; // aktuelle Instanz
+WCHAR szTitle[MAX_LOADSTRING]; // Text der Titelzeile
+WCHAR szWindowClass[MAX_LOADSTRING]; // Text der Titelzeile
+ATOM MyRegisterClass( HINSTANCE hInstance );
+BOOL InitInstance( HINSTANCE, int );
+LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
+LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM );
+void PasteClipboardData(HWND hwndParent);
+void PasteClipboardData2(HWND hwndParent);
+
+LPSTREAM g_pStm = NULL;
+char* pTextBuff = NULL;
+DWORD lData = 0;
+
+//----------------------------------------------------
+// a thread function
+//----------------------------------------------------
+
+unsigned int _stdcall ThreadProc(LPVOID pParam)
+{
+ IDataObject* pIDataObj = NULL;
+ FORMATETC formatETC;
+ STGMEDIUM stgMedium;
+ LPVOID pGlobMem;
+ HWND hwnd;
+ DWORD sizeGlobBuff;
+ HRESULT hr;
+
+ hwnd = (HWND)pParam;
+
+ OleInitialize( NULL );
+
+ hr = OleGetClipboard( &pIDataObj );
+
+ hr = CoGetInterfaceAndReleaseStream(
+ g_pStm,
+ __uuidof(IDataObject),
+ reinterpret_cast<LPVOID*>(&pIDataObj));
+
+ formatETC.cfFormat = CF_TEXT;
+ formatETC.ptd = NULL;
+ formatETC.dwAspect = DVASPECT_CONTENT;
+ formatETC.lindex = -1;
+ formatETC.tymed = TYMED_HGLOBAL;
+
+ hr = pIDataObj->GetData( &formatETC, &stgMedium );
+ pGlobMem = GlobalLock( stgMedium.hGlobal );
+ if ( NULL != pGlobMem )
+ {
+ if ( NULL != pTextBuff )
+ {
+ free( pTextBuff );
+ }
+
+ sizeGlobBuff = GlobalSize( stgMedium.hGlobal );
+ pTextBuff = (char*)malloc( sizeGlobBuff + 1 );
+ ZeroMemory( pTextBuff, sizeGlobBuff + 1 );
+
+ memcpy( pTextBuff, pGlobMem, sizeGlobBuff );
+ lData = sizeGlobBuff;
+
+ InvalidateRect( hwnd, NULL, TRUE );
+ UpdateWindow( hwnd );
+ }
+
+ GlobalUnlock( stgMedium.hGlobal );
+
+ ReleaseStgMedium( &stgMedium );
+
+ pIDataObj->Release();
+
+ //CoUninitialize( );
+
+ OleUninitialize( );
+
+ return 0;
+}
+
+//----------------------------------------------------
+// WinMain
+//----------------------------------------------------
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow )
+{
+ // ZU ERLEDIGEN: Fügen Sie hier den Code ein.
+ MSG msg;
+ HACCEL hAccelTable;
+ HRESULT hr = E_FAIL;
+
+ // it's important to initialize ole
+ // in order to use the clipboard
+ //hr = OleInitialize( NULL );
+ hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+ //hr = CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+
+ // Globale Zeichenfolgen initialisieren
+ LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+ LoadStringW(hInstance, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING);
+ MyRegisterClass(hInstance);
+
+ // Initialisierung der Anwendung durchführen:
+ if( !InitInstance( hInstance, nCmdShow ) )
+ {
+ return FALSE;
+ }
+
+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32);
+
+ // Hauptnachrichtenschleife:
+ while( GetMessage(&msg, NULL, 0, 0) )
+ {
+ if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) )
+ {
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+ }
+
+ // uninitializing the ole libraries
+ //OleUninitialize( );
+ CoUninitialize( );
+
+ return msg.wParam;
+}
+
+
+
+//
+// FUNKTION: MyRegisterClass()
+//
+// AUFGABE: Registriert die Fensterklasse.
+//
+// KOMMENTARE:
+//
+// Diese Funktion und ihre Verwendung sind nur notwendig, wenn dieser Code
+// mit Win32-Systemen vor der 'RegisterClassEx'-Funktion kompatibel sein soll,
+// die zu Windows 95 hinzugefügt wurde. Es ist wichtig diese Funktion aufzurufen,
+// damit der Anwendung kleine Symbole mit den richtigen Proportionen zugewiesen
+// werden.
+//
+ATOM MyRegisterClass( HINSTANCE hInstance )
+{
+ WNDCLASSEXW wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32);
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wcex.lpszMenuName = (LPCWSTR)IDC_TESTWIN32;
+ wcex.lpszClassName = szWindowClass;
+ wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+
+ return RegisterClassExW(&wcex);
+}
+
+//
+// FUNKTION: InitInstance(HANDLE, int)
+//
+// AUFGABE: Speichert die Instanzzugriffsnummer und erstellt das Hauptfenster
+//
+// KOMMENTARE:
+//
+// In dieser Funktion wird die Instanzzugriffsnummer in einer globalen Variable
+// gespeichert und das Hauptprogrammfenster erstellt und angezeigt.
+//
+BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
+{
+ HWND hWnd;
+
+ hInst = hInstance; // Instanzzugriffsnummer in unserer globalen Variable speichern
+
+ hWnd = CreateWindowExW(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+ if( !hWnd )
+ {
+ return FALSE;
+ }
+
+ ShowWindow( hWnd, nCmdShow );
+ UpdateWindow( hWnd );
+
+ return TRUE;
+}
+
+//
+// FUNKTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// AUFGABE: Verarbeitet Nachrichten für das Hauptfenster.
+//
+// WM_COMMAND - Anwendungsmenü verarbeiten
+// WM_PAINT - Hauptfenster darstellen
+// WM_DESTROY - Beendigungsnachricht ausgeben und zurückkehren
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId;
+ int wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ TCHAR szHello[MAX_LOADSTRING];
+
+
+ LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
+
+ switch( message )
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ // Menüauswahlen analysieren:
+ switch( wmId )
+ {
+ case IDD_PASTE:
+ //PasteClipboardData(hWnd);
+ PasteClipboardData2(hWnd);
+ break;
+
+ case IDM_EXIT:
+ DestroyWindow( hWnd );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ break;
+
+ case WM_PAINT:
+ hdc = BeginPaint (hWnd, &ps);
+ // ZU ERLEDIGEN: Hier beliebigen Code zum Zeichnen hinzufügen...
+ RECT rt;
+ GetClientRect( hWnd, &rt );
+
+ if ( NULL != pTextBuff )
+ {
+ DrawText( hdc, pTextBuff, lData, &rt, DT_CENTER );
+ }
+ else
+ {
+ DrawText( hdc, szHello, strlen(szHello), &rt, DT_CENTER );
+ }
+
+ EndPaint( hWnd, &ps );
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage( 0 );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ return 0;
+}
+
+void PasteClipboardData2(HWND hwndParent)
+{
+ IDataObject* pIDataObject;
+ HRESULT hr;
+ FORMATETC formatETC;
+ STGMEDIUM stgMedium;
+ LPVOID pGlobMem;
+ HWND hwnd;
+ DWORD sizeGlobBuff;
+
+ hr = MTAGetClipboard( &pIDataObject );
+ if ( SUCCEEDED( hr ) )
+ {
+ formatETC.cfFormat = CF_TEXT;
+ formatETC.ptd = NULL;
+ formatETC.dwAspect = DVASPECT_CONTENT;
+ formatETC.lindex = -1;
+ formatETC.tymed = TYMED_HGLOBAL;
+
+ hr = pIDataObject->GetData( &formatETC, &stgMedium );
+ pGlobMem = GlobalLock( stgMedium.hGlobal );
+ if ( NULL != pGlobMem )
+ {
+ if ( NULL != pTextBuff )
+ {
+ free( pTextBuff );
+ }
+
+ sizeGlobBuff = GlobalSize( stgMedium.hGlobal );
+ pTextBuff = (char*)malloc( sizeGlobBuff + 1 );
+ ZeroMemory( pTextBuff, sizeGlobBuff + 1 );
+
+ memcpy( pTextBuff, pGlobMem, sizeGlobBuff );
+ lData = sizeGlobBuff;
+
+ InvalidateRect( hwndParent, NULL, TRUE );
+ UpdateWindow( hwndParent );
+ }
+
+ GlobalUnlock( stgMedium.hGlobal );
+
+ ReleaseStgMedium( &stgMedium );
+
+ pIDataObject->Release();
+ }
+}
+
+//----------------------------------------------------
+// clipboard handling
+//----------------------------------------------------
+
+/*
+void PasteClipboardData(HWND hwndParent)
+{
+ IDataObject* pIDataObj = NULL;
+ HRESULT hr = E_FAIL;
+ unsigned int dwId;
+
+ hr = OleGetClipboard( &pIDataObj );
+ if ( SUCCEEDED( hr ) )
+ {
+ HRESULT hr = CoMarshalInterThreadInterfaceInStream(
+ __uuidof(IDataObject), //The IID of inteface to be marshaled
+ pIDataObj, //The interface pointer
+ &g_pStm //IStream pointer
+ );
+
+ HANDLE hThread = (HANDLE)_beginthreadex(
+ NULL, //Security
+ 0, //Stack Size
+ ThreadProc, //Start Address
+ NULL, //Parmeter
+ (unsigned int)hwndParent, //Creation Flag
+ &dwId //Thread Id
+ );
+
+ //Wait for the thread to finish execution
+ //A thread handle is signaled is thread execution
+ //is complete
+ for(;;)
+ {
+ DWORD dwRet = ::MsgWaitForMultipleObjects(
+ 1, //Count of objects
+ &hThread, //pointer to the array of objects
+ FALSE, //Wait for all objects?
+ INFINITE, //Wait How Long?
+ QS_ALLINPUT //Wait for all messges
+ );
+
+ //This means that the object is signaled
+ if ( dwRet != WAIT_OBJECT_0 + 1 )
+ break;
+
+ //Remove the messages from the queue
+ MSG msg;
+
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0)
+ {
+ //Not essential
+ TranslateMessage(&msg);
+ //Let the windowproc handle the message
+ DispatchMessage(&msg);
+ }
+ }
+
+ CloseHandle( hThread );
+ pIDataObj->Release();
+ }
+}
+*/
diff --git a/sal/workben/clipboardwben/testpaste/cbptest.rc b/sal/workben/clipboardwben/testpaste/cbptest.rc
new file mode 100644
index 000000000000..2deeb86a93a2
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/cbptest.rc
@@ -0,0 +1,120 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO"
+IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_TESTWIN32 MENU DISCARDABLE
+BEGIN
+ POPUP "&Datei"
+ BEGIN
+ MENUITEM "&Paste", IDD_PASTE
+ MENUITEM SEPARATOR
+ MENUITEM "&Beenden", IDM_EXIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE
+BEGIN
+ "?", IDM_ABOUT, ASCII, ALT
+ "/", IDM_ABOUT, ASCII, ALT
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_APP_TITLE "TestWin32"
+ IDS_HELLO "Hallo Welt!"
+ IDC_TESTWIN32 "TESTWIN32"
+END
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/sal/workben/clipboardwben/testpaste/makefile.mk b/sal/workben/clipboardwben/testpaste/makefile.mk
new file mode 100644
index 000000000000..5514d7c569b0
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sal
+TARGET=cbptest
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+= $(LFS_CFLAGS)
+CXXFLAGS+= $(LFS_CFLAGS)
+
+# --- Files --------------------------------------------------------
+
+#
+# test clipboard paste
+#
+ # --- Resources ----------------------------------------------------
+ RCFILES= cbptest.rc
+
+ OBJFILES= $(OBJ)$/cbptest.obj
+
+ APP1TARGET= $(TARGET)
+ APP1OBJS= $(OBJFILES)
+ APP1NOSAL= TRUE
+ APP1NOSVRES= $(RES)$/$(TARGET).res
+
+ APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB)
+
+ APP1LIBS=$(LB)$/ole9x.lib \
+ $(LB)$/tools32.lib
+
+ APP1DEPN= makefile.mk $(APP1NOSVRES)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sal/workben/clipboardwben/testpaste/resource.h b/sal/workben/clipboardwben/testpaste/resource.h
new file mode 100644
index 000000000000..5206e911eabf
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/resource.h
@@ -0,0 +1,28 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by mtacb.rc
+//
+#define IDC_MYICON 2
+#define IDD_TESTWIN32_DIALOG 102
+#define IDD_ABOUTBOX 103
+#define IDS_APP_TITLE 103
+#define IDM_ABOUT 104
+#define IDM_EXIT 105
+#define IDS_HELLO 106
+#define IDI_TESTWIN32 107
+#define IDI_SMALL 108
+#define IDC_TESTWIN32 109
+#define IDR_MAINFRAME 128
+#define IDD_PASTE 32771
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32772
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
diff --git a/sal/workben/clipboardwben/testpaste/small.ico b/sal/workben/clipboardwben/testpaste/small.ico
new file mode 100644
index 000000000000..8f94d9aa8285
--- /dev/null
+++ b/sal/workben/clipboardwben/testpaste/small.ico
Binary files differ
diff --git a/sal/workben/clipboardwben/testviewer/StdAfx.cpp b/sal/workben/clipboardwben/testviewer/StdAfx.cpp
new file mode 100644
index 000000000000..cb07d603f28f
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet
+// TestWin32.pch ist die vorkompilierte Header-Datei
+// stdafx.obj enthält die vorkompilierte Typinformation
+
+#include "stdafx.h"
+
+// ZU ERLEDIGEN: Verweis auf alle zusätzlichen Header-Dateien, die Sie in STDAFX.H
+// und nicht in dieser Datei benötigen
diff --git a/sal/workben/clipboardwben/testviewer/StdAfx.h b/sal/workben/clipboardwben/testviewer/StdAfx.h
new file mode 100644
index 000000000000..bb762adbdc36
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/StdAfx.h
@@ -0,0 +1,32 @@
+// stdafx.h : Include-Datei für Standard-System-Include-Dateien,
+// oder projektspezifische Include-Dateien, die häufig benutzt, aber
+// in unregelmäßigen Abständen geändert werden.
+//
+
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden
+
+
+// Windows-Header-Dateien:
+#include <windows.h>
+
+// Header-Dateien der C-Laufzeit
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+// Lokale Header-Dateien
+
+// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
diff --git a/sal/workben/clipboardwben/testviewer/TestWin32.ico b/sal/workben/clipboardwben/testviewer/TestWin32.ico
new file mode 100644
index 000000000000..255ff3be4fba
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/TestWin32.ico
Binary files differ
diff --git a/sal/workben/clipboardwben/testviewer/cbvtest.cxx b/sal/workben/clipboardwben/testviewer/cbvtest.cxx
new file mode 100644
index 000000000000..d79758971728
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/cbvtest.cxx
@@ -0,0 +1,351 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+// TestWin32.cpp : Definiert den Einsprungpunkt für die Anwendung.
+//
+
+#define _WIN32_DCOM
+
+#include "stdafx.h"
+
+#include <windows.h>
+
+#include <ole2.h>
+#include <objidl.h>
+#include <objbase.h>
+#include <process.h>
+#include <olectl.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <crtdbg.h>
+#include <..\..\inc\systools\win32\MtaOleClipb.h>
+
+#include "resource.h"
+
+#define MAX_LOADSTRING 100
+
+// Globale Variablen:
+HINSTANCE g_hInst; // aktuelle Instanz
+HWND g_hwndMain;
+WCHAR szTitle[MAX_LOADSTRING]; // Text der Titelzeile
+WCHAR szWindowClass[MAX_LOADSTRING]; // Text der Titelzeile
+LPSTREAM g_pStm = NULL;
+char* pTextBuff = NULL;
+DWORD lData = 0;
+UINT g_nCBChanges = 0;
+
+// forward declaration
+ATOM MyRegisterClass( HINSTANCE hInstance );
+BOOL InitInstance( HINSTANCE, int );
+HMENU GetSubMenuHandle( HWND hwndParent, UINT uiTopLevelIndex );
+BOOL IsClipboardViewer( HWND hwndParent );
+void SwitchMenuState( HWND hwndParent );
+void RegisterClipboardViewer( BOOL bRegister );
+void ShowAvailableClipboardFormats( HWND hWnd, HDC hdc, PAINTSTRUCT ps, RECT rcWnd );
+void ClearClipboardContent( HWND hWnd );
+
+void CALLBACK OnClipboardContentChange( void );
+LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
+LRESULT CALLBACK About( HWND, UINT, WPARAM, LPARAM );
+
+//----------------------------------------------------
+// WinMain
+//----------------------------------------------------
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow )
+{
+ // ZU ERLEDIGEN: Fügen Sie hier den Code ein.
+ MSG msg;
+ HACCEL hAccelTable;
+ HRESULT hr = E_FAIL;
+
+ // it's important to initialize ole
+ // in order to use the clipboard
+ //hr = OleInitialize( NULL );
+ hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
+
+ g_hInst = hInstance;
+
+ // Globale Zeichenfolgen initialisieren
+ LoadStringW(g_hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+ LoadStringW(g_hInst, IDC_TESTWIN32, szWindowClass, MAX_LOADSTRING);
+ MyRegisterClass(g_hInst);
+
+ // Initialisierung der Anwendung durchführen:
+ if( !InitInstance( g_hInst, nCmdShow ) )
+ {
+ return FALSE;
+ }
+
+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTWIN32);
+
+ // Hauptnachrichtenschleife:
+ while( GetMessage(&msg, NULL, 0, 0) )
+ {
+ if( !TranslateAccelerator (msg.hwnd, hAccelTable, &msg) )
+ {
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+ }
+
+ // uninitializing the ole libraries
+ //OleUninitialize( );
+ CoUninitialize( );
+
+ return msg.wParam;
+}
+
+
+
+//
+// FUNKTION: MyRegisterClass()
+//
+// AUFGABE: Registriert die Fensterklasse.
+//
+// KOMMENTARE:
+//
+// Diese Funktion und ihre Verwendung sind nur notwendig, wenn dieser Code
+// mit Win32-Systemen vor der 'RegisterClassEx'-Funktion kompatibel sein soll,
+// die zu Windows 95 hinzugefügt wurde. Es ist wichtig diese Funktion aufzurufen,
+// damit der Anwendung kleine Symbole mit den richtigen Proportionen zugewiesen
+// werden.
+//
+ATOM MyRegisterClass( HINSTANCE hInstance )
+{
+ WNDCLASSEXW wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTWIN32);
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wcex.lpszMenuName = (LPCWSTR)IDC_TESTWIN32;
+ wcex.lpszClassName = szWindowClass;
+ wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+
+ return RegisterClassExW(&wcex);
+}
+
+//
+// FUNKTION: InitInstance(HANDLE, int)
+//
+// AUFGABE: Speichert die Instanzzugriffsnummer und erstellt das Hauptfenster
+//
+// KOMMENTARE:
+//
+// In dieser Funktion wird die Instanzzugriffsnummer in einer globalen Variable
+// gespeichert und das Hauptprogrammfenster erstellt und angezeigt.
+//
+BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
+{
+ g_hwndMain = CreateWindowExW(0, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+ if( !IsWindow( g_hwndMain ) )
+ {
+ return FALSE;
+ }
+
+ ShowWindow( g_hwndMain, nCmdShow );
+ UpdateWindow( g_hwndMain );
+
+ return TRUE;
+}
+
+//
+// FUNKTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// AUFGABE: Verarbeitet Nachrichten für das Hauptfenster.
+//
+// WM_COMMAND - Anwendungsmenü verarbeiten
+// WM_PAINT - Hauptfenster darstellen
+// WM_DESTROY - Beendigungsnachricht ausgeben und zurückkehren
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId;
+ int wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ WCHAR szHello[MAX_LOADSTRING];
+
+
+ LoadStringW(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
+
+ switch( message )
+ {
+ case WM_CREATE:
+ ClearClipboardContent( hWnd );
+ break;
+
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ // Menüauswahlen analysieren:
+ switch( wmId )
+ {
+ case IDD_CBVIEWER:
+ SwitchMenuState( hWnd );
+ RegisterClipboardViewer( IsClipboardViewer( hWnd ) );
+ break;
+
+ case IDM_EXIT:
+ DestroyWindow( hWnd );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ break;
+
+ case WM_PAINT:
+ hdc = BeginPaint (hWnd, &ps);
+ // ZU ERLEDIGEN: Hier beliebigen Code zum Zeichnen hinzufügen...
+ RECT rt;
+ GetClientRect( hWnd, &rt );
+
+ if ( IsClipboardViewer( g_hwndMain ) )
+ {
+ ShowAvailableClipboardFormats( hWnd, hdc, ps, rt );
+ }
+ else
+ {
+ WCHAR wcString[MAX_LOADSTRING];
+ LoadStringW(g_hInst, IDS_MSG_CBVIEWER_IS_OFF, wcString, MAX_LOADSTRING);
+ DrawTextW( hdc, wcString, wcslen( wcString ), &rt, DT_CENTER );
+ }
+
+ EndPaint( hWnd, &ps );
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage( 0 );
+ break;
+
+ default:
+ return DefWindowProc( hWnd, message, wParam, lParam );
+ }
+ return 0;
+}
+
+HMENU GetSubMenuHandle( HWND hwndParent, UINT uiTopLevelIndex )
+{
+ HMENU hMenuMain = GetMenu( hwndParent );
+ _ASSERT( IsMenu( hMenu ) );
+
+ HMENU hSubMenu = GetSubMenu( hMenuMain, uiTopLevelIndex );
+ _ASSERT( IsMenu( hSubMenu ) );
+
+ return hSubMenu;
+}
+
+BOOL IsClipboardViewer( HWND hwndParent )
+{
+ HMENU hSubMenu = GetSubMenuHandle( hwndParent, 0 );
+ UINT uiMState = GetMenuState( hSubMenu, 0, MF_BYPOSITION );
+ return ( MF_CHECKED == uiMState );
+}
+
+void SwitchMenuState( HWND hwndParent )
+{
+ HMENU hSubMenu = GetSubMenuHandle( hwndParent, 0 );
+ WCHAR wcMenuString[MAX_LOADSTRING];
+
+ if ( IsClipboardViewer( hwndParent ) )
+ {
+ LoadStringW(g_hInst, IDS_CBVIEWER_OFF, wcMenuString, MAX_LOADSTRING);
+ ModifyMenuW( hSubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_CBVIEWER, wcMenuString );
+ CheckMenuItem( hSubMenu, 0, MF_BYPOSITION | MF_UNCHECKED );
+ }
+ else
+ {
+ LoadStringW(g_hInst, IDS_CBVIEWER_ON, wcMenuString, MAX_LOADSTRING);
+ ModifyMenuW( hSubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_CBVIEWER, wcMenuString );
+ CheckMenuItem( hSubMenu, 0, MF_BYPOSITION | MF_CHECKED );
+ }
+}
+
+void RegisterClipboardViewer( BOOL bRegister )
+{
+ if ( bRegister )
+ MTARegisterClipboardViewer( OnClipboardContentChange );
+ else // unregister
+ MTARegisterClipboardViewer( NULL );
+
+ InvalidateRect( g_hwndMain, NULL, TRUE );
+ UpdateWindow( g_hwndMain );
+}
+
+void ShowAvailableClipboardFormats( HWND hWnd, HDC hdc, PAINTSTRUCT ps, RECT rcWnd )
+{
+ if ( !OpenClipboard( hWnd ) )
+ {
+ WCHAR szErrMsg[] = { L"Couldn't open the clipboard" };
+ DrawTextW( hdc, szErrMsg, wcslen( szErrMsg ), &rcWnd, DT_CENTER );
+ return;
+ }
+ else
+ {
+ WCHAR szCBChangedMsg[100];
+
+ wsprintfW( szCBChangedMsg, L"Clipboard content changed %d", g_nCBChanges );
+ DrawTextW( hdc, szCBChangedMsg, wcslen( szCBChangedMsg ), &rcWnd, DT_CENTER );
+
+ CloseClipboard( );
+ }
+}
+
+void ClearClipboardContent( HWND hWnd )
+{
+ if ( OpenClipboard( hWnd ) )
+ {
+ EmptyClipboard( );
+ CloseClipboard( );
+ }
+}
+
+// clipboard viewer callback function
+void CALLBACK OnClipboardContentChange( void )
+{
+ ++g_nCBChanges;
+ InvalidateRect( g_hwndMain, NULL, TRUE );
+ UpdateWindow( g_hwndMain );
+}
+
diff --git a/sal/workben/clipboardwben/testviewer/cbvtest.rc b/sal/workben/clipboardwben/testviewer/cbvtest.rc
new file mode 100644
index 000000000000..b6c5163f7261
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/cbvtest.rc
@@ -0,0 +1,127 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_TESTWIN32 ICON DISCARDABLE "TestWin32.ICO"
+IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_TESTWIN32 MENU DISCARDABLE
+BEGIN
+ POPUP "&Datei"
+ BEGIN
+ MENUITEM "&CB Viewer off", IDD_CBVIEWER
+ MENUITEM SEPARATOR
+ MENUITEM "&Beenden", IDM_EXIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_TESTWIN32 ACCELERATORS MOVEABLE PURE
+BEGIN
+ "?", IDM_ABOUT, ASCII, ALT
+ "/", IDM_ABOUT, ASCII, ALT
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_APP_TITLE "TestWin32"
+ IDS_HELLO "Hallo Welt!"
+ IDC_TESTWIN32 "TESTWIN32"
+ IDS_CBVIEWER_ON "CB Viewer on"
+ IDS_CBVIEWER_OFF "CB Viewer off"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_MSG_CBVIEWER_IS_OFF "Clipboard Viewer inactive!"
+END
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/sal/workben/clipboardwben/testviewer/makefile.mk b/sal/workben/clipboardwben/testviewer/makefile.mk
new file mode 100644
index 000000000000..fa3e47cb48b2
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sal
+TARGET=cbvtest
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+= $(LFS_CFLAGS)
+CXXFLAGS+= $(LFS_CFLAGS)
+
+# --- Files --------------------------------------------------------
+
+#
+# test clipboard paste
+#
+ # --- Resources ----------------------------------------------------
+ RCFILES= cbvtest.rc
+
+ OBJFILES= $(OBJ)$/cbvtest.obj
+
+ APP1TARGET= $(TARGET)
+ APP1OBJS= $(OBJFILES)
+ APP1NOSAL= TRUE
+ APP1NOSVRES= $(RES)$/$(TARGET).res
+
+ APP1STDLIBS+=$(OLE32LIB) $(USER32LIB) $(KERNEL32LIB)
+
+ APP1LIBS=$(LB)$/iole9x.lib \
+ $(LB)$/tools32.lib
+
+ APP1DEPN= makefile.mk $(APP1NOSVRES)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sal/workben/clipboardwben/testviewer/resource.h b/sal/workben/clipboardwben/testviewer/resource.h
new file mode 100644
index 000000000000..fa4a79779aa9
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/resource.h
@@ -0,0 +1,32 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by cbvtest.rc
+//
+#define IDC_MYICON 2
+#define IDD_TESTWIN32_DIALOG 102
+#define IDD_ABOUTBOX 103
+#define IDS_APP_TITLE 103
+#define IDM_ABOUT 104
+#define IDM_EXIT 105
+#define IDS_HELLO 106
+#define IDI_TESTWIN32 107
+#define IDI_SMALL 108
+#define IDC_TESTWIN32 109
+#define IDS_CBVIEWER_ON 110
+#define IDS_CBVIEWER_OFF 111
+#define IDS_MSG_CBVIEWER_IS_OFF 112
+#define IDR_MAINFRAME 128
+#define IDD_PASTE 32771
+#define IDD_CBVIEWER 32771
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32772
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
diff --git a/sal/workben/clipboardwben/testviewer/small.ico b/sal/workben/clipboardwben/testviewer/small.ico
new file mode 100644
index 000000000000..8f94d9aa8285
--- /dev/null
+++ b/sal/workben/clipboardwben/testviewer/small.ico
Binary files differ
diff --git a/sal/workben/export.exp b/sal/workben/export.exp
new file mode 100644
index 000000000000..8a37bf2291a8
--- /dev/null
+++ b/sal/workben/export.exp
@@ -0,0 +1 @@
+registerAllTestFunction \ No newline at end of file
diff --git a/sal/workben/getlocaleinfotest.cxx b/sal/workben/getlocaleinfotest.cxx
new file mode 100644
index 000000000000..a0c3134c5fa4
--- /dev/null
+++ b/sal/workben/getlocaleinfotest.cxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <rtl/locale.h>
+#include <osl/nlsupport.h>
+#include <rtl/ustring.hxx>
+
+int _cdecl main( int argc, char * argv[] )
+{
+ rtl::OUString lang = rtl::OUString::createFromAscii( "de" );
+ rtl::OUString country = rtl::OUString::createFromAscii( "DE" );
+ rtl_TextEncoding rtlTextEnc;
+
+ rtl_Locale* rtlLocale =
+ rtl_locale_register( lang.getStr( ), country.getStr( ), NULL );
+
+ if ( rtlLocale )
+ rtlTextEnc = osl_getTextEncodingFromLocale( rtlLocale );
+
+ return(0);
+}
+
+
diff --git a/sal/workben/makefile.mk b/sal/workben/makefile.mk
new file mode 100644
index 000000000000..c93d756ba132
--- /dev/null
+++ b/sal/workben/makefile.mk
@@ -0,0 +1,386 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=sal
+TARGET=workben
+LIBTARGET=NO
+TARGETTYPE=CUI
+#ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=YES
+
+#TESTAPP=test_osl_getVolInfo
+#TESTAPP=test_osl_joinProcess
+#TESTAPP=getlocaleinfotest
+#TESTAPP=test_osl_joinProcess
+#TESTAPP=getlocaleinfotest
+#TESTAPP=salstattest
+#TESTAPP=saldyntest
+
+TESTAPP=t_readline
+#TESTAPP=t_cipher
+#TESTAPP=t_digest
+#TESTAPP=t_random
+#TESTAPP=t_layer
+#TESTAPP=t_tls
+#TESTAPP=t_zip
+
+#TESTAPP=testfile
+#TESTAPP=testpipe
+#TESTAPP=testpip2
+#TESTAPP=testproc
+#TESTAPP=tgetpwnam
+#TESTAPP=salstattest
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+= $(LFS_CFLAGS)
+CXXFLAGS+= $(LFS_CFLAGS)
+
+# --- Files --------------------------------------------------------
+
+.IF "$(TESTAPP)" == "test_osl_getVolInfo"
+
+SHL1OBJS=$(SLO)$/t_osl_getVolInfo.obj
+SHL1TARGET=togvi
+
+.IF "$(GUI)" == "WNT"
+APP1STDLIBS=$(KERNEL32LIB)
+SHL1STDLIBS=$(LB)$/isal.lib
+SHL1STDLIBS+=$(SOLARLIBDIR)$/cppunit.lib
+.ENDIF
+
+.IF "$(GUI)" == "UNX"
+SHL1STDLIBS=$(LB)$/libsal.so
+SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a
+.ENDIF
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=export.exp
+.ENDIF
+
+.IF "$(TESTAPP)" == "test_osl_joinProcess"
+OBJFILES=$(OBJ)$/t_ojp_exe.obj
+APP1TARGET=ojpx
+APP1OBJS=$(OBJFILES)
+
+.IF "$(GUI)" == "UNX"
+APP1STDLIBS=$(LB)$/libsal.so
+.ENDIF
+
+SHL1OBJS=$(SLO)$/t_osl_joinProcess.obj
+SHL1TARGET=tojp
+
+.IF "$(GUI)" == "WNT"
+APP1STDLIBS=$(KERNEL32LIB)
+SHL1STDLIBS=$(LB)$/isal.lib
+SHL1STDLIBS+=$(SOLARLIBDIR)$/cppunit.lib
+.ENDIF
+
+.IF "$(GUI)" == "UNX"
+SHL1STDLIBS=$(LB)$/libsal.so
+SHL1STDLIBS+=$(SOLARLIBDIR)$/libcppunit$(DLLPOSTFIX).a
+.ENDIF
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=export.exp
+.ENDIF
+
+.IF "$(TESTAPP)" == "getlocaleinfotest"
+
+ OBJFILES=$(OBJ)$/getlocaleinfotest.obj
+
+ APP1TARGET= getlitest
+ APP1OBJS=$(OBJFILES)
+
+ APP1STDLIBS=\
+ $(KERNEL32LIB)
+
+ APP1LIBS=\
+ $(LB)$/kernel9x.lib\
+ $(LB)$/isal.lib
+
+ APP1DEPN=$(LB)$/isal.lib
+
+.ENDIF
+
+.IF "$(TESTAPP)" == "salstattest"
+
+ CFLAGS+= -DUSE_SAL_STATIC
+
+ OBJFILES= $(OBJ)$/salstattest.obj
+
+ APP1TARGET= salstattest
+ APP1OBJS= $(OBJFILES)
+ APP1STDLIBS=\
+ $(LB)$/asal.lib\
+ $(SHELL32LIB)\
+ $(USER32LIB)\
+ $(COMDLG32LIB)\
+ $(ADVAPI32LIB)
+
+ APP1DEPN= $(LB)$/asal.lib
+
+.ENDIF # salstattest
+
+.IF "$(TESTAPP)" == "saldyntest"
+
+ OBJFILES= $(OBJ)$/saldyntest.obj
+
+ APP1TARGET= saldyntest
+ APP1OBJS= $(OBJFILES)
+ APP1STDLIBS=\
+ $(LB)$/isal.lib\
+ $(SHELL32LIB)\
+ $(USER32LIB)\
+ $(COMDLG32LIB)\
+ $(ADVAPI32LIB)
+
+ APP1DEPN= $(LB)$/isal.lib
+
+.ENDIF # salstattest
+
+#
+# t_readline
+#
+.IF "$(TESTAPP)" == "t_readline"
+
+CFILES= t_readline.c
+OBJFILES= $(OBJ)$/t_readline.obj
+
+APP1TARGET= t_readline
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS=$(SALLIB)
+APP1DEPN= $(SLB)$/sal.lib
+
+APP1RPATH=UREBIN
+
+.ENDIF # t_readline
+
+#
+# t_cipher
+#
+.IF "$(TESTAPP)" == "t_cipher"
+
+CFILES= t_cipher.c
+OBJFILES= $(OBJ)$/t_cipher.obj
+
+APP1TARGET= t_cipher
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS=$(SALLIB)
+APP1DEPN= $(SLB)$/sal.lib
+
+.ENDIF # t_cipher
+
+#
+# t_digest.
+#
+.IF "$(TESTAPP)" == "t_digest"
+
+CFILES= t_digest.c
+OBJFILES= $(OBJ)$/t_digest.obj
+
+APP2TARGET= t_digest
+APP2OBJS= $(OBJFILES)
+APP2STDLIBS=$(SALLIB)
+APP2DEPN= $(SLB)$/sal.lib
+
+.ENDIF # t_digest
+
+#
+# t_random.
+#
+.IF "$(TESTAPP)" == "t_random"
+
+CFILES= t_random.c
+OBJFILES= $(OBJ)$/t_random.obj
+
+APP3TARGET= t_random
+APP3OBJS= $(OBJFILES)
+APP3STDLIBS=$(SALLIB)
+APP3DEPN= $(SLB)$/sal.lib
+
+.ENDIF # t_random
+
+#
+# t_layer.
+#
+.IF "$(TESTAPP)" == "t_layer"
+
+CFILES= t_layer.c
+OBJFILES= $(OBJ)$/t_layer.obj
+
+APP4TARGET= t_layer
+APP4OBJS= $(OBJFILES)
+APP4STDLIBS=$(SALLIB)
+APP4DEPN= $(SLB)$/sal.lib
+
+.ENDIF # t_layer
+
+#
+# t_tls.
+#
+.IF "$(TESTAPP)" == "t_tls"
+
+CFILES= t_tls.c
+OBJFILES= $(OBJ)$/t_tls.obj
+
+.IF "$(SALTLSLIB)" == ""
+
+.IF "$(GUI)" == "UNX"
+SALTLSLIB= -lsaltls2
+.ENDIF # unx
+
+.IF "$(GUI)" == "WNT"
+SALTLSLIB= $(SALTLSLIB)
+.ENDIF # wnt
+
+.ENDIF # saltlslib
+
+APP5TARGET= t_tls
+APP5OBJS= $(OBJFILES)
+APP5STDLIBS=$(SALTLSLIB) $(SALLIB)
+APP5DEPN= $(SLB)$/sal.lib
+
+.ENDIF # t_tls
+
+#
+# t_zip.
+#
+.IF "$(TESTAPP)" == "t_zip"
+
+CFILES= t_zip.c
+OBJFILES= $(OBJ)$/t_zip.obj
+
+.IF "$(SALZIPLIB)" == ""
+
+.IF "$(GUI)" == "UNX"
+SALZIPLIB= -lsalzip2
+.ENDIF # unx
+
+.IF "$(GUI)" == "WNT"
+SALZIPLIB= $(SALZIPLIB)
+.ENDIF # wnt
+
+.ENDIF # salziplib
+
+APP6TARGET= t_zip
+APP6OBJS= $(OBJFILES)
+APP6STDLIBS=$(SALZIPLIB) $(SALLIB)
+APP6DEPN= $(SLB)$/sal.lib
+
+.ENDIF # t_zip
+
+#
+# testfile
+#
+.IF "$(TESTAPP)" == "testfile"
+
+CXXFILES= testfile.cxx
+OBJFILES= $(OBJ)$/testfile.obj
+
+APP1TARGET= testfile
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS=$(SALLIB)
+APP1DEPN= $(SLB)$/sal.lib
+
+.ENDIF # testfile
+
+#
+# testpipe
+#
+.IF "$(TESTAPP)" == "testpipe"
+
+CXXFILES= testpipe.cxx
+OBJFILES= $(OBJ)$/testpipe.obj
+
+APP2TARGET= testpipe
+APP2OBJS= $(OBJFILES)
+APP2STDLIBS=$(SALLIB)
+APP2DEPN= $(SLB)$/sal.lib
+
+.ENDIF # testpipe
+
+#
+# testpip2
+#
+.IF "$(TESTAPP)" == "testpip2"
+
+CXXFILES= testpip2.cxx
+OBJFILES= $(OBJ)$/testpip2.obj
+
+APP3TARGET= testpip2
+APP3OBJS= $(OBJFILES)
+APP3STDLIBS=$(SALLIB)
+APP3DEPN= $(SLB)$/sal.lib
+
+.ENDIF # testpip2
+
+#
+# testproc
+#
+.IF "$(TESTAPP)" == "testproc"
+
+CXXFILES= testproc.cxx
+OBJFILES= $(OBJ)$/testproc.obj
+
+APP4TARGET= testproc
+APP4OBJS= $(OBJFILES)
+APP4STDLIBS=$(SALLIB)
+APP4DEPN= $(SLB)$/sal.lib
+
+.ENDIF # testproc
+
+#
+# tgetpwnam
+#
+.IF "$(TESTAPP)" == "tgetpwnam"
+.IF "$(OS)"=="SCO" || "$(OS)"=="NETBSD" || "$(OS)"=="FREEBSD"
+
+CXXFILES= tgetpwnam.cxx
+OBJFILES= $(OBJ)$/tgetpwnam.obj
+
+APP5TARGET= tgetpwnam
+APP5OBJS= $(OBJFILES)
+APP5STDLIBS=$(SALLIB)
+APP5DEPN= $(SLB)$/sal.lib
+
+.ENDIF # (sco | netbsd | freebsd)
+.ENDIF # tgetpwname
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sal/workben/saldyntest.c b/sal/workben/saldyntest.c
new file mode 100644
index 000000000000..c8cc6c430d26
--- /dev/null
+++ b/sal/workben/saldyntest.c
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * 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 <systools/win32/shell9x.h>
+#include <systools/win32/kernel9x.h>
+
+int _cdecl main( int argc, char * argv[] )
+{
+ BROWSEINFOW bi;
+ wchar_t buff[260];
+ DWORD dwRet;
+
+ bi.hwndOwner = NULL;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = buff;
+ bi.lpszTitle = L"Test";
+ bi.ulFlags = 0;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+
+ SHBrowseForFolderW( &bi );
+
+ dwRet = GetCanonicalPathW( L"c:\\", buff, 260 );
+
+ return(0);
+}
+
+
diff --git a/sal/workben/salstattest.c b/sal/workben/salstattest.c
new file mode 100644
index 000000000000..e19e07ad8260
--- /dev/null
+++ b/sal/workben/salstattest.c
@@ -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.
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <systools/win32/shell9x.h>
+#include <systools/win32/kernel9x.h>
+
+//#include <windows.h>
+//#include <shlobj.h>
+
+int _cdecl main( int argc, char * argv[] )
+{
+ BROWSEINFOW bi;
+ wchar_t buff[260];
+ DWORD dwRet;
+
+ bi.hwndOwner = NULL;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = buff;
+ bi.lpszTitle = L"Test";
+ bi.ulFlags = 0;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+
+ SHBrowseForFolderW( &bi );
+
+ dwRet = GetLongPathNameW( L"c:\\", buff, 260 );
+
+ return(0);
+}
+
+
diff --git a/sal/workben/t_cipher.c b/sal/workben/t_cipher.c
new file mode 100644
index 000000000000..b7126bd46de1
--- /dev/null
+++ b/sal/workben/t_cipher.c
@@ -0,0 +1,396 @@
+/*************************************************************************
+ *
+ * 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 <sal/types.h>
+#include <osl/diagnose.h>
+#include <rtl/cipher.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#define NUM_VARIABLE_KEY_TESTS 34
+#define NUM_SET_KEY_TESTS 24
+
+/* plaintext bytes -- left halves */
+unsigned long plaintext_l[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = {
+ 0x00000000l, 0xFFFFFFFFl, 0x10000000l, 0x11111111l, 0x11111111l,
+ 0x01234567l, 0x00000000l, 0x01234567l, 0x01A1D6D0l, 0x5CD54CA8l,
+ 0x0248D438l, 0x51454B58l, 0x42FD4430l, 0x059B5E08l, 0x0756D8E0l,
+ 0x762514B8l, 0x3BDD1190l, 0x26955F68l, 0x164D5E40l, 0x6B056E18l,
+ 0x004BD6EFl, 0x480D3900l, 0x437540C8l, 0x072D43A0l, 0x02FE5577l,
+ 0x1D9D5C50l, 0x30553228l, 0x01234567l, 0x01234567l, 0x01234567l,
+ 0xFFFFFFFFl, 0x00000000l, 0x00000000l, 0xFFFFFFFFl, 0xFEDCBA98l,
+ 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l,
+ 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l,
+ 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l,
+ 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l,
+ 0xFEDCBA98l, 0xFEDCBA98l, 0xFEDCBA98l };
+
+/* plaintext bytes -- right halves */
+unsigned long plaintext_r[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = {
+ 0x00000000l, 0xFFFFFFFFl, 0x00000001l, 0x11111111l, 0x11111111l,
+ 0x89ABCDEFl, 0x00000000l, 0x89ABCDEFl, 0x39776742l, 0x3DEF57DAl,
+ 0x06F67172l, 0x2DDF440Al, 0x59577FA2l, 0x51CF143Al, 0x774761D2l,
+ 0x29BF486Al, 0x49372802l, 0x35AF609Al, 0x4F275232l, 0x759F5CCAl,
+ 0x09176062l, 0x6EE762F2l, 0x698F3CFAl, 0x77075292l, 0x8117F12Al,
+ 0x18F728C2l, 0x6D6F295Al, 0x89ABCDEFl, 0x89ABCDEFl, 0x89ABCDEFl,
+ 0xFFFFFFFFl, 0x00000000l, 0x00000000l, 0xFFFFFFFFl, 0x76543210l,
+ 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l,
+ 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l,
+ 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l,
+ 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l, 0x76543210l,
+ 0x76543210l, 0x76543210l, 0x76543210l };
+
+/* key bytes for variable key tests */
+unsigned char variable_key[NUM_VARIABLE_KEY_TESTS][8] = {
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
+ { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 },
+ { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
+ { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 },
+ { 0x7C, 0xA1, 0x10, 0x45, 0x4A, 0x1A, 0x6E, 0x57 },
+ { 0x01, 0x31, 0xD9, 0x61, 0x9D, 0xC1, 0x37, 0x6E },
+ { 0x07, 0xA1, 0x13, 0x3E, 0x4A, 0x0B, 0x26, 0x86 },
+ { 0x38, 0x49, 0x67, 0x4C, 0x26, 0x02, 0x31, 0x9E },
+ { 0x04, 0xB9, 0x15, 0xBA, 0x43, 0xFE, 0xB5, 0xB6 },
+ { 0x01, 0x13, 0xB9, 0x70, 0xFD, 0x34, 0xF2, 0xCE },
+ { 0x01, 0x70, 0xF1, 0x75, 0x46, 0x8F, 0xB5, 0xE6 },
+ { 0x43, 0x29, 0x7F, 0xAD, 0x38, 0xE3, 0x73, 0xFE },
+ { 0x07, 0xA7, 0x13, 0x70, 0x45, 0xDA, 0x2A, 0x16 },
+ { 0x04, 0x68, 0x91, 0x04, 0xC2, 0xFD, 0x3B, 0x2F },
+ { 0x37, 0xD0, 0x6B, 0xB5, 0x16, 0xCB, 0x75, 0x46 },
+ { 0x1F, 0x08, 0x26, 0x0D, 0x1A, 0xC2, 0x46, 0x5E },
+ { 0x58, 0x40, 0x23, 0x64, 0x1A, 0xBA, 0x61, 0x76 },
+ { 0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xB0, 0x07 },
+ { 0x49, 0x79, 0x3E, 0xBC, 0x79, 0xB3, 0x25, 0x8F },
+ { 0x4F, 0xB0, 0x5E, 0x15, 0x15, 0xAB, 0x73, 0xA7 },
+ { 0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF },
+ { 0x01, 0x83, 0x10, 0xDC, 0x40, 0x9B, 0x26, 0xD6 },
+ { 0x1C, 0x58, 0x7F, 0x1C, 0x13, 0x92, 0x4F, 0xEF },
+ { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
+ { 0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E },
+ { 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
+ { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF },
+ { 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 }};
+
+/* key bytes for set key tests */
+unsigned char set_key[24] = {
+ 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87,
+ 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F,
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
+
+/* ciphertext bytes -- left halves */
+unsigned long ciphertext_l[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = {
+ 0x4EF99745l, 0x51866FD5l, 0x7D856F9Al, 0x2466DD87l, 0x61F9C380l,
+ 0x7D0CC630l, 0x4EF99745l, 0x0ACEAB0Fl, 0x59C68245l, 0xB1B8CC0Bl,
+ 0x1730E577l, 0xA25E7856l, 0x353882B1l, 0x48F4D088l, 0x432193B7l,
+ 0x13F04154l, 0x2EEDDA93l, 0xD887E039l, 0x5F99D04Fl, 0x4A057A3Bl,
+ 0x452031C1l, 0x7555AE39l, 0x53C55F9Cl, 0x7A8E7BFAl, 0xCF9C5D7Al,
+ 0xD1ABB290l, 0x55CB3774l, 0xFA34EC48l, 0xA7907951l, 0xC39E072Dl,
+ 0x014933E0l, 0xF21E9A77l, 0x24594688l, 0x6B5C5A9Cl, 0xF9AD597Cl,
+ 0xE91D21C1l, 0xE9C2B70Al, 0xBE1E6394l, 0xB39E4448l, 0x9457AA83l,
+ 0x8BB77032l, 0xE87A244El, 0x15750E7Al, 0x122BA70Bl, 0x3A833C9Al,
+ 0x9409DA87l, 0x884F8062l, 0x1F85031Cl, 0x79D9373Al, 0x93142887l,
+ 0x03429E83l, 0xA4299E27l, 0xAFD5AED1l, 0x10851C0El, 0xE6F51ED7l,
+ 0x64A6E14Al, 0x80C7D7D4l, 0x05044B62l };
+
+/* ciphertext bytes -- right halves */
+unsigned long ciphertext_r[NUM_VARIABLE_KEY_TESTS + NUM_SET_KEY_TESTS] = {
+ 0x6198DD78l, 0xB85ECB8Al, 0x613063F2l, 0x8B963C9Dl, 0x2281B096l,
+ 0xAFDA1EC7l, 0x6198DD78l, 0xC6A0A28Dl, 0xEB05282Bl, 0x250F09A0l,
+ 0x8BEA1DA4l, 0xCF2651EBl, 0x09CE8F1Al, 0x4C379918l, 0x8951FC98l,
+ 0xD69D1AE5l, 0xFFD39C79l, 0x3C2DA6E3l, 0x5B163969l, 0x24D3977Bl,
+ 0xE4FADA8El, 0xF59B87BDl, 0xB49FC019l, 0x937E89A3l, 0x4986ADB5l,
+ 0x658BC778l, 0xD13EF201l, 0x47B268B2l, 0x08EA3CAEl, 0x9FAC631Dl,
+ 0xCDAFF6E4l, 0xB71C49BCl, 0x5754369Al, 0x5D9E0A5Al, 0x49DB005El,
+ 0xD961A6D6l, 0x1BC65CF3l, 0x08640F05l, 0x1BDB1E6El, 0xB1928C0Dl,
+ 0xF960629Dl, 0x2CC85E82l, 0x4F4EC577l, 0x3AB64AE0l, 0xFFC537F6l,
+ 0xA90F6BF2l, 0x5060B8B4l, 0x19E11968l, 0x714CA34Fl, 0xEE3BE15Cl,
+ 0x8CE2D14Bl, 0x469FF67Bl, 0xC1BC96A8l, 0x3858DA9Fl, 0x9B9DB21Fl,
+ 0xFD36B46Fl, 0x5A5479ADl, 0xFA52D080l };
+
+
+static sal_uInt8 cbc_key[16] =
+{
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+ 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87
+};
+static sal_uInt8 cbc_iv[8] =
+{
+ 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
+};
+
+static sal_Char cbc_data[40] = "7654321 Now is the time for ";
+
+static sal_uInt8 ecb_ok[32] =
+{
+ 0x2A, 0xFD, 0x7D, 0xAA, 0x60, 0x62, 0x6B, 0xA3,
+ 0x86, 0x16, 0x46, 0x8C, 0xC2, 0x9C, 0xF6, 0xE1,
+ 0x29, 0x1E, 0x81, 0x7C, 0xC7, 0x40, 0x98, 0x2D,
+ 0x6F, 0x87, 0xAC, 0x5F, 0x17, 0x1A, 0xAB, 0xEA
+};
+static sal_uInt8 cbc_ok[32] =
+{
+ 0x6B, 0x77, 0xB4, 0xD6, 0x30, 0x06, 0xDE, 0xE6,
+ 0x05, 0xB1, 0x56, 0xE2, 0x74, 0x03, 0x97, 0x93,
+ 0x58, 0xDE, 0xB9, 0xE7, 0x15, 0x46, 0x16, 0xD9,
+ 0x59, 0xF1, 0x65, 0x2B, 0xD5, 0xFF, 0x92, 0xCC
+};
+static sal_uInt8 cfb_ok[] =
+{
+ 0xE7, 0x32, 0x14, 0xA2, 0x82, 0x21, 0x39, 0xCA,
+ 0xF2, 0x6E, 0xCF, 0x6D, 0x2E, 0xB9, 0xE7, 0x6E,
+ 0x3D, 0xA3, 0xDE, 0x04, 0xD1, 0x51, 0x72, 0x00,
+ 0x51, 0x9D, 0x57, 0xA6, 0xC3
+};
+
+static sal_uInt8 arcfour_key[6][30] =
+{
+ { 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
+ { 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
+ { 8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ { 4, 0xef, 0x01, 0x23, 0x45 },
+ { 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
+ { 4, 0xef, 0x01, 0x23, 0x45 }
+};
+static sal_uInt8 arcfour_data_len[6] =
+{
+ 8, 8, 8, 20, 28, 10
+};
+static sal_uInt8 arcfour_data[6][30] =
+{
+ { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff },
+ { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
+ 0x12, 0x34, 0x56, 0x78, 0xff },
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff }
+};
+static sal_uInt8 arcfour_ok[6][30] =
+{
+ { 0x75, 0xb7, 0x87, 0x80, 0x99, 0xe0, 0xc5, 0x96, 0x00},
+ { 0x74, 0x94, 0xc2, 0xe7, 0x10, 0x4b, 0x08, 0x79, 0x00},
+ { 0xde, 0x18, 0x89, 0x41, 0xa3, 0x37, 0x5d, 0x3a, 0x00},
+ { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
+ 0xbd, 0x61, 0x5a, 0x11, 0x62, 0xe1, 0xc7, 0xba,
+ 0x36, 0xb6, 0x78, 0x58, 0x00 },
+ { 0x66, 0xa0, 0x94, 0x9f, 0x8a, 0xf7, 0xd6, 0x89,
+ 0x1f, 0x7f, 0x83, 0x2b, 0xa8, 0x33, 0xc0, 0x0c,
+ 0x89, 0x2e, 0xbe, 0x30, 0x14, 0x3c, 0xe2, 0x87,
+ 0x40, 0x01, 0x1e, 0xcf, 0x00 },
+ { 0xd6, 0xa1, 0x41, 0xa7, 0xec, 0x3c, 0x38, 0xdf,
+ 0xbd, 0x61, 0x00}
+};
+
+int SAL_CALL main (int argc, char *argv)
+{
+ rtlCipher cipher;
+
+ /* ECB */
+ cipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeECB);
+ OSL_ASSERT(cipher != 0);
+ if (cipher != 0)
+ {
+ rtlCipherError result;
+ sal_uInt8 ecb_in[40], ecb_out[40];
+ sal_uInt32 length = strlen(cbc_data) + 1;
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionBoth,
+ cbc_key, sizeof(cbc_key), NULL, 0);
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (ecb_out, 0, sizeof(ecb_out));
+ result = rtl_cipher_encode (
+ cipher, cbc_data, length, ecb_out, sizeof(ecb_out));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (ecb_out, ecb_ok, sizeof(ecb_ok)) == 0);
+
+ memset (ecb_in, 0, sizeof(ecb_in));
+ result = rtl_cipher_decode (
+ cipher, ecb_out, length, ecb_in, sizeof(ecb_in));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (ecb_in, cbc_data, length) == 0);
+
+ rtl_cipher_destroy (cipher);
+ }
+
+ /* CBC */
+ cipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeCBC);
+ OSL_ASSERT(cipher != 0);
+ if (cipher != 0)
+ {
+ rtlCipherError result;
+ sal_uInt8 cbc_in[40], cbc_out[40];
+ sal_uInt32 length = strlen(cbc_data) + 1;
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionEncode,
+ cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (cbc_out, 0, sizeof(cbc_out));
+ result = rtl_cipher_encode (
+ cipher, cbc_data, length, cbc_out, sizeof(cbc_out));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (cbc_out, cbc_ok, sizeof(cbc_ok)) == 0);
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionDecode,
+ cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (cbc_in, 0, sizeof(cbc_in));
+ result = rtl_cipher_decode (
+ cipher, cbc_out, length, cbc_in, sizeof(cbc_in));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (cbc_in, cbc_data, length) == 0);
+
+ rtl_cipher_destroy (cipher);
+ }
+
+ /* CFB */
+ cipher = rtl_cipher_create (rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream);
+ OSL_ASSERT(cipher != 0);
+ if (cipher != 0)
+ {
+ rtlCipherError result;
+ sal_uInt8 cfb_in[40], cfb_out[40];
+ sal_uInt32 length = strlen(cbc_data) + 1;
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionEncode,
+ cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (cfb_out, 0, sizeof(cfb_out));
+ result = rtl_cipher_encode (
+ cipher, cbc_data, length, cfb_out, sizeof(cfb_out));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (cfb_out, cfb_ok, sizeof(cfb_ok)) == 0);
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionDecode,
+ cbc_key, sizeof(cbc_key), cbc_iv, sizeof(cbc_iv));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (cfb_in, 0, sizeof(cfb_in));
+ result = rtl_cipher_decode (
+ cipher, cfb_out, length, cfb_in, sizeof(cfb_in));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (cfb_in, cbc_data, length) == 0);
+
+ rtl_cipher_destroy (cipher);
+ }
+
+ /* ARCFOUR */
+ cipher = rtl_cipher_create (rtl_Cipher_AlgorithmARCFOUR, rtl_Cipher_ModeStream);
+ OSL_ASSERT(cipher != 0);
+ if (cipher != 0)
+ {
+ rtlCipherError result;
+ sal_uInt8 arcfour_out[40];
+ sal_Size length;
+ int i, n;
+
+ n = sizeof(arcfour_data_len) / sizeof(arcfour_data_len[0]);
+ for (i = 0; i < n; i++)
+ {
+ length = arcfour_data_len[i];
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionBoth,
+ &(arcfour_key[i][1]), arcfour_key[i][0], 0, 0);
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (arcfour_out, 0, sizeof(arcfour_out));
+ result = rtl_cipher_encode (
+ cipher, &(arcfour_data[i][0]), length,
+ arcfour_out, sizeof(arcfour_out));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (arcfour_out, arcfour_ok[i], length) == 0);
+ }
+
+ n = arcfour_data_len[3];
+ for (i = 1; i < n; i++)
+ {
+ length = i;
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionBoth,
+ &(arcfour_key[3][1]), arcfour_key[3][0], 0, 0);
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (arcfour_out, 0, sizeof(arcfour_out));
+ result = rtl_cipher_encode (
+ cipher, &(arcfour_data[3][0]), length,
+ arcfour_out, sizeof(arcfour_out));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+ OSL_ASSERT(memcmp (arcfour_out, arcfour_ok[3], length) == 0);
+ OSL_ASSERT(arcfour_out[length] == 0);
+ }
+
+ n = arcfour_data_len[3];
+ for (i = 1; i < n; i++)
+ {
+ length = i;
+
+ result = rtl_cipher_init (
+ cipher, rtl_Cipher_DirectionBoth,
+ &(arcfour_key[3][1]), arcfour_key[3][0], 0, 0);
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ memset (arcfour_out, 0, sizeof(arcfour_out));
+ result = rtl_cipher_encode (
+ cipher, &(arcfour_data[3][0]), length,
+ &(arcfour_out[0]), sizeof(arcfour_out));
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ result = rtl_cipher_encode (
+ cipher, &(arcfour_data[3][length]), n - length,
+ &(arcfour_out[length]), sizeof(arcfour_out) - length);
+ OSL_ASSERT(result == rtl_Cipher_E_None);
+
+ OSL_ASSERT(memcmp (arcfour_out, arcfour_ok[3], length) == 0);
+ }
+
+ rtl_cipher_destroy (cipher);
+ }
+
+ /* Done */
+ return 0;
+}
diff --git a/sal/workben/t_digest.c b/sal/workben/t_digest.c
new file mode 100644
index 000000000000..ab6acf11572b
--- /dev/null
+++ b/sal/workben/t_digest.c
@@ -0,0 +1,378 @@
+/*************************************************************************
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+
+#include <rtl/digest.h>
+
+static const char *digest_in_MD[] =
+{
+ "",
+ "a",
+ "abc",
+ "message digest",
+ "abcdefghijklmnopqrstuvwxyz",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ NULL,
+};
+
+static const char *digest_out_MD2[]=
+{
+ "8350e5a3e24c153df2275c9f80692773",
+ "32ec01ec4a6dac72c0ab96fb34c0b5d1",
+ "da853b0d3f88d99b30283a69e6ded6bb",
+ "ab4f496bfb2a530b219ff33031fe06b0",
+ "4e8ddff3650292ab5a4108c3aa47940b",
+ "da33def2a42df13975352846c30338cd",
+ "d5976f79d83d3a0dc9806c3c66f3efd8",
+};
+
+static const char *digest_out_MD5[]=
+{
+ "d41d8cd98f00b204e9800998ecf8427e",
+ "0cc175b9c0f1b6a831c399e269772661",
+ "900150983cd24fb0d6963f7d28e17f72",
+ "f96b697d7cb7938d525a2f31aaf161d0",
+ "c3fcd3d76192e4007dfb496cca67e13b",
+ "d174ab98d277d9f5a5611c2c9f419d9f",
+ "57edf4a22be3c955ac49da2e2107b67a",
+};
+
+static const char *digest_in_SHA[]=
+{
+ "abc",
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ NULL,
+};
+
+static const char *digest_out_SHA_0[]=
+{
+ "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880",
+ "d2516ee1acfa5baf33dfc1c471e438449ef134c8",
+};
+
+static const char *digest_out_SHA_1[]=
+{
+ "a9993e364706816aba3e25717850c26c9cd0d89d",
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
+};
+
+static const char *digest_bigout_SHA_0=
+ "3232affa48628a26653b5aaa44541fd90d690603";
+
+static const char *digest_bigout_SHA_1=
+ "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
+
+
+static const char digest_key_HMAC_MD5_1[] =
+{
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x00
+};
+static const char digest_key_HMAC_MD5_2[] =
+{
+ /* "Jefe" */
+ 'J', 'e', 'f', 'e',
+ 0x00
+};
+static const unsigned char digest_key_HMAC_MD5_3[] =
+{
+ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
+ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
+ 0x00
+};
+static const char *digest_key_HMAC_MD5[] =
+{
+ (const char*)&digest_key_HMAC_MD5_1,
+ (const char*)&digest_key_HMAC_MD5_2, /* "Jefe", */
+ (const char*)&digest_key_HMAC_MD5_3,
+ NULL
+};
+
+static const unsigned char digest_in_HMAC_MD5_3[] =
+{
+ 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
+ 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
+ 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
+ 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
+ 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
+ 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD,
+ 0xDD, 0xDD,
+ 0x00
+};
+static const char *digest_in_HMAC_MD5[] =
+{
+ "Hi There",
+ "what do ya want for nothing?",
+ (const char*)&digest_in_HMAC_MD5_3,
+ NULL
+};
+
+static const char *digest_out_HMAC_MD5[] =
+{
+ "9294727a3638bb1c13f48ef8158bfc9d",
+ "750c783e6ab0b503eaa86e310a5db738",
+ "56be34521d144c88dbb8c733f0e8b3f6",
+ NULL
+};
+static const char *digest_out_HMAC_SHA1[] =
+{
+ /* unofficial, i.e. not verified */
+ "675b0b3a1b4ddf4e124872da6c2f632bfed957e9",
+ "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79",
+ "d730594d167e35d5956fd8003d0db3d3f46dc7bb",
+ NULL
+};
+
+
+static char *pt (unsigned char *md, int length)
+{
+ int i;
+ static char buf[80];
+
+ for (i=0; i<length; i++)
+ sprintf(&(buf[i*2]),"%02x",md[i]);
+
+ return(buf);
+}
+
+int SAL_CALL main (int argc, char **argv)
+{
+ const char **P,**R, **Q;
+ char *p;
+ int i=1, err=0;
+
+ unsigned char md[80];
+ unsigned char buffer[1000];
+
+ rtlDigest Digest;
+
+ P=digest_in_MD;
+ R=digest_out_MD2;
+ i = 1;
+ while (*P)
+ {
+ rtl_digest_MD2 (*P, strlen(*P), md, sizeof(md));
+
+ p=pt (md, RTL_DIGEST_LENGTH_MD2);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating MD2 on '%s'\n",*P);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (MD2) %d ok\n",i);
+ i++;
+ R++;
+ P++;
+ }
+
+ P=digest_in_MD;
+ R=digest_out_MD5;
+ i=1;
+ while (*P)
+ {
+ rtl_digest_MD5 (*P, strlen(*P), md, sizeof(md));
+
+ p=pt (md, RTL_DIGEST_LENGTH_MD5);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating MD5 on '%s'\n",*P);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (MD5) %d ok\n",i);
+ i++;
+ R++;
+ P++;
+ }
+
+ P=digest_in_SHA;
+ R=digest_out_SHA_0;
+ i=1;
+ while (*P)
+ {
+ rtl_digest_SHA (*P, strlen(*P), md, sizeof(md));
+
+ p=pt (md, RTL_DIGEST_LENGTH_SHA);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating SHA-0 on '%s'\n",*P);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (SHA-0) %d ok\n",i);
+ i++;
+ R++;
+ P++;
+ }
+
+ memset (buffer, 'a', sizeof(buffer));
+ R = &digest_bigout_SHA_0;
+
+ Digest = rtl_digest_createSHA();
+ for (i=0; i<1000; i++)
+ rtl_digest_updateSHA (Digest, buffer, sizeof(buffer));
+
+ rtl_digest_getSHA (Digest, md, sizeof(md));
+ rtl_digest_destroySHA (Digest);
+
+ p=pt (md, RTL_DIGEST_LENGTH_SHA);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating SHA-0 on '%s'\n",p);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (SHA-0) n ok\n");
+
+ P=digest_in_SHA;
+ R=digest_out_SHA_1;
+ i=1;
+ while (*P)
+ {
+ rtl_digest_SHA1 (*P, strlen(*P), md, sizeof(md));
+
+ p=pt (md, RTL_DIGEST_LENGTH_SHA1);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating SHA-1 on '%s'\n",*P);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (SHA-1) %d ok\n",i);
+ i++;
+ R++;
+ P++;
+ }
+
+ memset (buffer, 'a', sizeof(buffer));
+ R = &digest_bigout_SHA_1;
+
+ Digest = rtl_digest_createSHA1();
+ for (i=0; i<1000; i++)
+ rtl_digest_updateSHA1 (Digest, buffer, sizeof(buffer));
+
+ rtl_digest_getSHA1 (Digest, md, sizeof(md));
+ rtl_digest_destroySHA1 (Digest);
+
+ p=pt (md, RTL_DIGEST_LENGTH_SHA1);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating SHA-1 on '%s'\n",p);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (SHA-1) n ok\n");
+
+
+ P=digest_in_HMAC_MD5;
+ Q=digest_key_HMAC_MD5;
+ R=digest_out_HMAC_MD5;
+ Digest = rtl_digest_createHMAC_MD5();
+ i = 1;
+ while (*P)
+ {
+ rtl_digest_initHMAC_MD5 (Digest, *Q, strlen(*Q));
+ rtl_digest_updateHMAC_MD5 (Digest, *P, strlen(*P));
+ rtl_digest_getHMAC_MD5 (Digest, md, sizeof(md));
+
+ p=pt (md, RTL_DIGEST_LENGTH_HMAC_MD5);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating HMAC-MD5 on '%s'\n",*P);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (HMAC-MD5) %d ok\n",i);
+ i++;
+ R++;
+ P++;
+ Q++;
+ }
+ rtl_digest_destroyHMAC_MD5 (Digest);
+
+
+ P=digest_in_HMAC_MD5;
+ Q=digest_key_HMAC_MD5;
+ R=digest_out_HMAC_SHA1;
+ Digest = rtl_digest_createHMAC_SHA1();
+ i = 1;
+ while (*P)
+ {
+ rtl_digest_initHMAC_SHA1 (Digest, *Q, strlen(*Q));
+ rtl_digest_updateHMAC_SHA1 (Digest, *P, strlen(*P));
+ rtl_digest_getHMAC_SHA1 (Digest, md, sizeof(md));
+
+ p=pt (md, RTL_DIGEST_LENGTH_HMAC_SHA1);
+ if (strcmp (p, *R))
+ {
+ printf("error calculating HMAC-SHA-1 on '%s'\n",*P);
+ printf("got %s instead of %s\n",p,*R);
+ err++;
+ }
+ else
+ printf("test (HMAC-SHA-1) %d ok\n",i);
+ i++;
+ P++;
+ Q++;
+ R++;
+ }
+ rtl_digest_destroyHMAC_SHA1 (Digest);
+
+
+ P=digest_in_HMAC_MD5;
+ Q=digest_key_HMAC_MD5;
+ rtl_digest_PBKDF2 (
+ md, RTL_DIGEST_LENGTH_MD5, /* [out] derived key */
+ Q[1], strlen(Q[1]), /* [in] password */
+ P[1], strlen(P[1]), /* [in] salt */
+ 1000); /* [in] iteration count */
+
+ p=pt (md, RTL_DIGEST_LENGTH_MD5);
+ if (strcmp (p, "6349e09cb6b8c1485cfa9780ee3264df"))
+ {
+ printf("error calculating PBKDF2 on '%s'\n", P[1]);
+ err++;
+ }
+ else
+ printf("test (PBKDF2) %d ok\n", 1);
+
+ return (err);
+}
+
diff --git a/sal/workben/t_ojp_exe.cxx b/sal/workben/t_ojp_exe.cxx
new file mode 100644
index 000000000000..4e8cdcd5962a
--- /dev/null
+++ b/sal/workben/t_ojp_exe.cxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+
+#ifdef WNT
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#else
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+int main(int argc, char* argv[])
+{
+ printf("osl process test executable started:\n");
+
+#ifdef WNT
+ Sleep(5000);
+#else
+ sleep(5);
+#endif
+
+ printf("osl process test executable ended:\n");
+
+ return (0);
+}
+
diff --git a/sal/workben/t_osl_getVolInfo.cxx b/sal/workben/t_osl_getVolInfo.cxx
new file mode 100644
index 000000000000..74e7a310f9ae
--- /dev/null
+++ b/sal/workben/t_osl_getVolInfo.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <cppunit/simpleheader.hxx>
+#include <osl/file.h>
+#include <rtl/ustring.hxx>
+
+#ifdef WNT
+# define TEST_PATH_1 "c:\\"
+# define TEST_PATH_2 "c:\\mnt\\MSDN"
+# define TEST_PATH_3 "c:\\Program Files"
+# define TEST_PATH_4 "\\\\Tra-1\\mnt\\c"
+# define TEST_PATH_5 "\\\\Tra-1\\mnt"
+# define TEST_PATH_6 "\\\\Tra-1\\mnt\\c\\"
+#else // UNX
+# define TEST_PATH_1 "/net/athene/export/home/tra"
+# define TEST_PATH_2 "/net/athene/export/home/tra/"
+# define TEST_PATH_3 "/"
+# define TEST_PATH_4 "."
+# define TEST_PATH_5 "/net/athene/export/home/tra/projects"
+# define TEST_PATH_6 "/blah"
+#endif
+
+//------------------------------
+//
+//------------------------------
+
+void test_getVolumeInformation(const rtl::OUString& path_url)
+ {
+ oslVolumeInfo vi;
+ memset((void*)&vi, 0, sizeof(vi));
+ vi.uStructSize = sizeof(vi);
+ vi.pDeviceHandle = NULL;
+
+ oslFileError err = osl_getVolumeInformation(
+ path_url.pData,
+ &vi,
+ osl_VolumeInfo_Mask_Attributes |
+ osl_VolumeInfo_Mask_TotalSpace |
+ osl_VolumeInfo_Mask_UsedSpace |
+ osl_VolumeInfo_Mask_FreeSpace |
+ osl_VolumeInfo_Mask_MaxNameLength |
+ osl_VolumeInfo_Mask_MaxPathLength |
+ osl_VolumeInfo_Mask_FileSystemName |
+ osl_VolumeInfo_Mask_DeviceHandle);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_getVolumeInformation failed",
+ err == osl_File_E_None
+ );
+ }
+
+//------------------------------
+//
+//------------------------------
+
+class TestClass_osl_getVolumeInformation : public CppUnit::TestFixture
+{
+public:
+
+ /*-------------------------------------
+ Start a process and join with this
+ process specify a timeout so that
+ osl_joinProcessWithTimeout returns
+ osl_Process_E_TimedOut
+ -------------------------------------*/
+
+ void test_osl_getVolumeInformation()
+ {
+ rtl::OUString path = rtl::OUString::createFromAscii(TEST_PATH_1);
+ rtl::OUString path_url;
+ osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
+ test_getVolumeInformation(path_url);
+
+ path = rtl::OUString::createFromAscii(TEST_PATH_2);
+ osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
+ test_getVolumeInformation(path_url);
+
+ path = rtl::OUString::createFromAscii(TEST_PATH_3);
+ osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
+ test_getVolumeInformation(path_url);
+
+ path = rtl::OUString::createFromAscii(TEST_PATH_4);
+ osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
+ test_getVolumeInformation(path_url);
+
+ path = rtl::OUString::createFromAscii(TEST_PATH_5);
+ osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
+ test_getVolumeInformation(path_url);
+
+ path = rtl::OUString::createFromAscii(TEST_PATH_6);
+ osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
+ test_getVolumeInformation(path_url);
+ }
+
+ CPPUNIT_TEST_SUITE( TestClass_osl_getVolumeInformation );
+ CPPUNIT_TEST( test_osl_getVolumeInformation );
+ CPPUNIT_TEST_SUITE_END( );
+};
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestClass_osl_getVolumeInformation, "Test osl_getVolumeInformation");
+
+NOADDITIONAL;
+
diff --git a/sal/workben/t_osl_joinProcess.cxx b/sal/workben/t_osl_joinProcess.cxx
new file mode 100644
index 000000000000..1c6f366505f8
--- /dev/null
+++ b/sal/workben/t_osl_joinProcess.cxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <cppunit/simpleheader.hxx>
+#include <osl/process.h>
+#include <rtl/ustring.hxx>
+#include <unistd.h>
+#include <signal.h>
+
+#ifdef WNT
+ const rtl::OUString IMAGE_NAME = rtl::OUString::createFromAscii("ojpx.exe");
+#else
+ const rtl::OUString IMAGE_NAME = rtl::OUString::createFromAscii("ojpx");
+#endif
+
+const rtl::OUString CWD = rtl::OUString::createFromAscii(".");
+
+//------------------------------
+//
+//------------------------------
+
+class Test_osl_Process : public CppUnit::TestFixture
+{
+public:
+
+ /*-------------------------------------
+ Start a process and join with this
+ process specify a timeout so that
+ osl_joinProcessWithTimeout returns
+ osl_Process_E_TimedOut
+ -------------------------------------*/
+
+ void test_osl_joinProcessWithTimeout_timeout_failure()
+ {
+ oslProcess process;
+ oslProcessError osl_error = osl_executeProcess(
+ IMAGE_NAME.pData,
+ NULL,
+ 0,
+ osl_Process_NORMAL,
+ osl_getCurrentSecurity(),
+ CWD.pData,
+ NULL,
+ 0,
+ &process);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_createProcess failed",
+ osl_error == osl_Process_E_None
+ );
+
+ TimeValue timeout;
+ timeout.Seconds = 1;
+ timeout.Nanosec = 0;
+
+ osl_error = osl_joinProcessWithTimeout(process, &timeout);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_joinProcessWithTimeout returned without timeout failure",
+ osl_Process_E_TimedOut == osl_error
+ );
+
+ osl_error = osl_terminateProcess(process);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_terminateProcess failed",
+ osl_error == osl_Process_E_None
+ );
+
+ osl_freeProcessHandle(process);
+ }
+
+ /*-------------------------------------
+ Start a process and join with this
+ process specify a timeout so that
+ osl_joinProcessWithTimeout returns
+ osl_Process_E_None
+ -------------------------------------*/
+
+ void test_osl_joinProcessWithTimeout_without_timeout_failure()
+ {
+ oslProcess process;
+ oslProcessError osl_error = osl_executeProcess(
+ IMAGE_NAME.pData,
+ NULL,
+ 0,
+ osl_Process_NORMAL,
+ osl_getCurrentSecurity(),
+ CWD.pData,
+ NULL,
+ 0,
+ &process);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_createProcess failed",
+ osl_error == osl_Process_E_None
+ );
+
+ TimeValue timeout;
+ timeout.Seconds = 10;
+ timeout.Nanosec = 0;
+
+ osl_error = osl_joinProcessWithTimeout(process, &timeout);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_joinProcessWithTimeout returned with failure",
+ osl_Process_E_None == osl_error
+ );
+
+ osl_freeProcessHandle(process);
+ }
+
+ /*-------------------------------------
+ Start a process and join with this
+ process specify an infinite timeout
+ -------------------------------------*/
+
+ void test_osl_joinProcessWithTimeout_infinite()
+ {
+ oslProcess process;
+ oslProcessError osl_error = osl_executeProcess(
+ IMAGE_NAME.pData,
+ NULL,
+ 0,
+ osl_Process_NORMAL,
+ osl_getCurrentSecurity(),
+ CWD.pData,
+ NULL,
+ 0,
+ &process);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_createProcess failed",
+ osl_error == osl_Process_E_None
+ );
+
+ osl_error = osl_joinProcessWithTimeout(process, NULL);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_joinProcessWithTimeout returned with failure",
+ osl_Process_E_None == osl_error
+ );
+
+ osl_freeProcessHandle(process);
+ }
+
+ /*-------------------------------------
+ Start a process and join with this
+ process using osl_joinProcess
+ -------------------------------------*/
+
+ void test_osl_joinProcess()
+ {
+ oslProcess process;
+ oslProcessError osl_error = osl_executeProcess(
+ IMAGE_NAME.pData,
+ NULL,
+ 0,
+ osl_Process_NORMAL,
+ osl_getCurrentSecurity(),
+ CWD.pData,
+ NULL,
+ 0,
+ &process);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_createProcess failed",
+ osl_error == osl_Process_E_None
+ );
+
+ osl_error = osl_joinProcess(process);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "osl_joinProcess returned with failure",
+ osl_Process_E_None == osl_error
+ );
+
+ osl_freeProcessHandle(process);
+ }
+
+ CPPUNIT_TEST_SUITE(Test_osl_Process);
+ CPPUNIT_TEST(test_osl_joinProcessWithTimeout_timeout_failure);
+ CPPUNIT_TEST(test_osl_joinProcessWithTimeout_without_timeout_failure);
+ CPPUNIT_TEST(test_osl_joinProcessWithTimeout_infinite);
+ CPPUNIT_TEST(test_osl_joinProcess);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_osl_Process, "Test_osl_Process");
+
+NOADDITIONAL;
+
diff --git a/sal/workben/t_random.c b/sal/workben/t_random.c
new file mode 100644
index 000000000000..dfd303a1c5da
--- /dev/null
+++ b/sal/workben/t_random.c
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+
+#include <rtl/random.h>
+
+static char *pt (unsigned char *md, int length)
+{
+ int i;
+ static char buf[80];
+
+ for (i=0; i<length; i++)
+ sprintf(&(buf[i*2]),"%02x",md[i]);
+
+ return(buf);
+}
+
+/*
+ * main.
+ */
+#ifdef WIN32
+int __cdecl main (int argc, char **argv)
+#else
+int main (int argc, char **argv)
+#endif
+{
+ rtlRandomPool pool;
+ pool = rtl_random_createPool();
+ if (pool)
+ {
+ unsigned char buffer[1000];
+
+ rtl_random_getBytes (pool, buffer, 8);
+ printf ("random: %s\n", pt (buffer, 8));
+ }
+ rtl_random_destroyPool (pool);
+ return(0);
+}
+
diff --git a/sal/workben/t_readline.c b/sal/workben/t_readline.c
new file mode 100644
index 000000000000..9cbc7d39cf20
--- /dev/null
+++ b/sal/workben/t_readline.c
@@ -0,0 +1,58 @@
+/*
+ * t_readline.c
+ */
+
+#include "osl/file.h"
+
+#include "osl/diagnose.h"
+#include "rtl/ustring.h"
+#include "rtl/byteseq.h"
+
+#include <stdio.h>
+
+/* main */
+int main (int argc, char ** argv)
+{
+ if (argc > 1)
+ {
+ oslFileError result;
+ oslFileHandle hFile = 0;
+
+ rtl_uString * pSystemPath = 0;
+ rtl_uString * pFileUrl = 0;
+
+ rtl_uString_newFromAscii (&pSystemPath, argv[1]);
+
+ result = osl_getFileURLFromSystemPath (pSystemPath, &pFileUrl);
+ rtl_uString_release (pSystemPath), pSystemPath = 0;
+ if (result != osl_File_E_None)
+ return (result);
+
+ result = osl_openFile (pFileUrl, &hFile, osl_File_OpenFlag_Read);
+ rtl_uString_release (pFileUrl), pFileUrl = 0;
+ if (result == osl_File_E_None)
+ {
+ sal_Sequence * pBuffer = 0;
+ for ( ;; )
+ {
+ sal_Int32 i, n;
+
+ result = osl_readLine (hFile, &pBuffer);
+ if (result != osl_File_E_None)
+ break;
+#if 0
+ if (pBuffer->elements[0] == 0)
+ /* @@@ cannot distinguish empty line from EOF @@@ */
+ break;
+#endif
+ for (i = 0, n = pBuffer->nElements; i < n; i++)
+ printf ("%c", (char)(pBuffer->elements[i]));
+ printf("\n");
+ }
+
+ rtl_byte_sequence_release (pBuffer), pBuffer = 0;
+ (void) osl_closeFile (hFile);
+ }
+ }
+ return 0;
+}
diff --git a/sal/workben/test.cxx b/sal/workben/test.cxx
new file mode 100644
index 000000000000..27469b4df02b
--- /dev/null
+++ b/sal/workben/test.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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <stdio.h>
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ void test_int64();
+ test_int64();
+
+ void test_profile(void);
+ test_profile();
+
+ void test_OString();
+ test_OString();
+
+/* void test_OWString(); */
+/* test_OWString(); */
+
+/* void test_OStringBuffer(); */
+/* test_OStringBuffer(); */
+
+/* void test_OWStringBuffer(); */
+/* test_OWStringBuffer(); */
+
+/* void test_OString2OWStringAndViceVersa(); */
+/* test_OString2OWStringAndViceVersa(); */
+
+ void test_uuid();
+ test_uuid();
+
+ return(0);
+}
+
+
diff --git a/sal/workben/testfile.cxx b/sal/workben/testfile.cxx
new file mode 100644
index 000000000000..8e3296a5aab5
--- /dev/null
+++ b/sal/workben/testfile.cxx
@@ -0,0 +1,2786 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#define UNICODE
+
+
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <osl/time.h>
+#include <rtl/alloc.h>
+#include <rtl/ustring.hxx>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+
+#ifdef UNX
+#include <wchar.h>
+#endif
+
+#ifdef WNT
+#include <windows.h>
+#endif
+
+using namespace osl;
+using namespace rtl;
+
+#define MAXIMPATH 256
+
+rtl::OUString root;
+
+rtl::OUString dir1;
+rtl::OUString dir2;
+rtl::OUString dir_on_server;
+rtl::OUString dir_not_exist;
+rtl::OUString dir_not_exist_on_server;
+rtl::OUString dir_wrong_semantic;
+
+rtl::OUString file1;
+rtl::OUString file2;
+rtl::OUString file3;
+rtl::OUString file_on_server;
+rtl::OUString file_not_exist;
+
+
+
+void print_error(::rtl::OString& str, FileBase::RC rc);
+
+void PressKey()
+{
+ printf("\nPress Return !\n");
+ int i=getchar();
+}
+
+void printFileName(::rtl::OUString& str)
+{
+ rtl::OString aString;
+
+ aString = rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
+
+ printf( "%s", aString.getStr() );
+
+ return;
+}
+
+//--------------------------------------------------
+// Initialization
+//--------------------------------------------------
+
+sal_Bool testLineBreak( sal_Char *pCount , sal_uInt64 nLen , sal_uInt32 *cLineBreak )
+{
+ sal_Bool fSuccess=sal_False;
+ *cLineBreak=0;
+
+ if (nLen==0)
+ return fSuccess;
+
+ if ( *pCount==13 )
+ {
+ if (nLen>=1 && *(pCount+1)==10)
+ *cLineBreak=2;
+ else
+ *cLineBreak=1;
+
+ if (nLen>=2 && *(pCount+2)==10)
+ (*cLineBreak)++;
+
+ fSuccess=sal_True;
+ }
+ else if ( *pCount==10 )
+ {
+ *cLineBreak=1;
+ fSuccess=sal_True;
+ }
+
+ return fSuccess;
+}
+
+// Initialization
+
+sal_Bool Initialize( void )
+{
+ DirectoryItem aItem;
+ FileStatus aStatus( FileStatusMask_All );
+ rtl_uString *strExeFileURL=NULL;
+ oslProcessError ProcessError;
+
+ rtl::OUString iniFileURL;
+ File *pFile;
+ sal_Unicode *pExeFileCount;
+
+ FileBase::RC rc;
+
+ sal_uInt64 uBytesRequested;
+ sal_uInt64 uBytesRead;
+ sal_Char *pBuffer;
+ sal_Char *pBegin;
+ sal_Char *pCount;
+
+ rtl::OUString dir[12];
+
+ // Open to the ini-file
+
+ ProcessError=osl_getExecutableFile(&strExeFileURL);
+
+ if ( ProcessError == osl_Process_E_None)
+ {
+ pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL);
+
+ // Search for the last slash in the Path
+ while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL))
+ pExeFileCount--;
+
+ // iniFileURL = strExeFileURL without the filename of the exe-File
+ iniFileURL=rtl::OUString( rtl_uString_getStr(strExeFileURL) ,(int) (pExeFileCount-rtl_uString_getStr(strExeFileURL)) );
+
+ // add "/testfile.ini" to iniFileURL
+ iniFileURL+=rtl::OUString::createFromAscii("/testfile.ini");
+
+ // Open the ini-File
+ pFile=new File( iniFileURL );
+ rc=pFile->open( OpenFlag_Read | OpenFlag_Write );
+ if ( rc!=FileBase::E_None )
+ {
+ rtl_uString_release(strExeFileURL);
+ return sal_False;
+ }
+ }
+ else
+ {
+ rtl_uString_release(strExeFileURL);
+ return sal_False;
+ }
+
+ // Get filesize of the ini-File
+
+ rc=DirectoryItem::get( iniFileURL, aItem );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+
+ rc=aItem.getFileStatus( aStatus );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+
+ uBytesRequested=aStatus.getFileSize();
+
+ // read ini-File
+ rc=pFile->setPos( Pos_Absolut, 0 );
+ pBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32) (uBytesRequested+1)*sizeof(sal_Char) );
+ rtl_zeroMemory( pBuffer, (sal_uInt32)(uBytesRequested+1)*sizeof(sal_Char) );
+
+ rc=pFile->read( pBuffer , uBytesRequested , uBytesRead );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+
+
+ pBegin=pBuffer;
+ pCount=pBegin;
+
+ for ( int i=0 ; i<12 ; i++ )
+ {
+ sal_uInt32 cLineBrake=0;
+ while ( (pCount-pBuffer < uBytesRead) && *pCount!='=')
+ pCount++;
+
+ pCount++;
+ pBegin=pCount;
+
+ while ( (pCount-pBuffer < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake))
+ pCount++;
+
+ dir[i]=rtl::OUString(pBegin, pCount-pBegin, RTL_TEXTENCODING_ASCII_US);
+
+ pCount+=cLineBrake;
+ pBegin=pCount;
+ }
+
+ root=rtl::OUString(dir[0]);
+ dir1=rtl::OUString(dir[1]);
+ dir2=rtl::OUString(dir[2]);
+ dir_on_server=rtl::OUString(dir[3]);
+ dir_not_exist=rtl::OUString(dir[4]);
+ dir_not_exist_on_server=rtl::OUString(dir[5]);
+ dir_wrong_semantic=rtl::OUString(dir[6]);
+
+ file1=rtl::OUString(dir[7]);
+ file2=rtl::OUString(dir[8]);
+ file3=rtl::OUString(dir[9]);
+ file_on_server=rtl::OUString(dir[10]);
+ file_not_exist=rtl::OUString(dir[11]);
+
+ // close the ini-file
+ rc=pFile->close();
+
+ rtl_freeMemory( pBuffer );
+
+
+ // Create directories
+ rc=Directory::create( dir1 );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+
+ rc=Directory::create( dir2 );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+
+ rc=Directory::create( dir_on_server );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+
+ pFile=new File( file1 );
+ rc=pFile->open( OpenFlag_Write | OpenFlag_Create );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+ rc=pFile->close();
+ delete pFile;
+
+ pFile=new File( file2 );
+ rc=pFile->open( OpenFlag_Write | OpenFlag_Create );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+ rc=pFile->close();
+ delete pFile;
+
+ pFile=new File( file_on_server );
+ rc=pFile->open( OpenFlag_Write | OpenFlag_Create );
+ if ( rc!=FileBase::E_None )
+ return sal_False;
+ rc=pFile->close();
+ delete pFile;
+
+ return sal_True;
+}
+
+//--------------------------------------------------
+// Shutdown
+//--------------------------------------------------
+
+sal_Bool Shutdown( void )
+{
+ sal_Bool fSuccess=sal_True;
+ FileBase::RC rc;
+ File *pFile;
+
+ // remove created files
+
+ pFile=new File( file1 );
+ rc=pFile->remove( file1 );
+ if ( rc!=FileBase::E_None )
+ fSuccess=sal_False;
+ delete pFile;
+
+ pFile=new File( file2 );
+ rc=pFile->remove( file2 );
+ if ( rc!=FileBase::E_None )
+ fSuccess=sal_False;
+ delete pFile;
+
+ // remove created directories
+
+ rc=Directory::remove( dir1 );
+ if ( rc!=FileBase::E_None )
+ fSuccess=sal_False;
+
+ rc=Directory::remove( dir2 );
+ if ( rc!=FileBase::E_None )
+ fSuccess=sal_False;
+
+ // remove created file on the server
+
+ pFile=new File( file_on_server );
+ rc=pFile->remove( file_on_server );
+ if ( rc!=FileBase::E_None )
+ fSuccess=sal_False;
+ delete pFile;
+
+ // remove created directory on the server
+
+ rc=Directory::remove( dir_on_server );
+ if ( rc!=FileBase::E_None )
+ fSuccess=sal_False;
+
+ return fSuccess;
+}
+
+//--------------------------------------------------
+// helper functions
+//--------------------------------------------------
+
+// Show FileType
+void showFileType( FileStatus::Type aType )
+{
+ if ( aType==FileStatus::Directory )
+ printf( "FileType: Directory \n" );
+ else if ( aType==FileStatus::Volume )
+ printf( "FileType: Volume \n" );
+ else if ( aType==FileStatus::Regular )
+ printf( "FileType: Regular \n" );
+ else if ( aType==FileStatus::Unknown )
+ printf( "FileType: Unknown \n" );
+
+}
+
+// Show Attributes
+void showAttributes( sal_uInt64 uAttributes )
+{
+ if ( uAttributes==0 )
+ printf( "No Attributes \n" );
+ if ( uAttributes & Attribute_ReadOnly )
+ printf( "Attribute: ReadOnly \n" );
+ if ( uAttributes & Attribute_Hidden )
+ printf( "Attribute: Hidden \n" );
+ if ( uAttributes & Attribute_Executable )
+ printf( "Attribute: Executable \n");
+ if ( uAttributes & Attribute_GrpWrite )
+ printf( "Attribute: GrpWrite \n");
+ if ( uAttributes & Attribute_GrpRead )
+ printf( "Attribute: GrpRead \n" );
+ if ( uAttributes & Attribute_GrpExe )
+ printf( "Attribute: GrpExe \n" );
+ if ( uAttributes & Attribute_OwnWrite )
+ printf( "Attribute: OwnWrite \n");
+ if ( uAttributes & Attribute_OwnRead )
+ printf( "Attribute: OwnRead \n" );
+ if ( uAttributes & Attribute_OwnExe )
+ printf( "Attribute: OwnExe \n" );
+ if ( uAttributes & Attribute_OthWrite )
+ printf( "Attribute: OthWrite \n" );
+ if ( uAttributes & Attribute_OthRead )
+ printf( "Attribute: OthRead \n");
+ if ( uAttributes & Attribute_OthExe )
+ printf( "Attribute: OthExe \n" );
+
+ return;
+}
+
+// Show Time
+void showTime( TimeValue aTime )
+{
+ TimeValue aLocalTimeVal, aSystemTimeVal , aSysTimeVal;
+ oslDateTime aDateTime, aSystemTime;
+
+ if ( osl_getLocalTimeFromSystemTime( &aTime, &aLocalTimeVal ) )
+ {
+ if ( osl_getDateTimeFromTimeValue( &aLocalTimeVal, &aDateTime ) )
+ {
+ printf("\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds);
+ }
+ else
+ printf("Error !\n");
+ }
+
+ if ( osl_getDateTimeFromTimeValue( &aTime, &aSystemTime ) )
+ {
+ printf("SystemTime: \t\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aSystemTime.Day, aSystemTime.Month, aSystemTime.Year, aSystemTime.Hours, aSystemTime.Minutes, aSystemTime.Seconds);
+ }
+ else
+ printf("Error !\n");
+
+ //Verify
+
+ if ( osl_getTimeValueFromDateTime( &aSystemTime, &aSystemTimeVal ) )
+ {
+ if ( ( aSystemTimeVal.Seconds == aTime.Seconds ) && ( aSystemTimeVal.Nanosec == aTime.Nanosec ))
+ printf ("Verify : TimeValue : ok! \n");
+ else
+ {
+ printf ("Verify : TimeValue : Error! \n");
+ printf ("aTime : %u \n", aTime.Seconds);
+ printf ("aSystemTimeVal : %u \n", aSystemTimeVal.Seconds);
+ }
+ }
+ else
+ printf ("Verify : TimeValue : Error! \n");
+
+
+ if ( osl_getSystemTimeFromLocalTime( &aLocalTimeVal , &aSysTimeVal ) )
+ {
+ if ( ( aSysTimeVal.Seconds == aTime.Seconds ) && ( aSysTimeVal.Nanosec == aTime.Nanosec ))
+ printf ("Verify : SystemTime : ok! \n");
+ else
+ {
+ printf ("Verify : SystemTime : Error! \n");
+ printf ("aTime : %u\n", aTime.Seconds);
+ printf ("aSystemTimeVal : %u\n", aSysTimeVal.Seconds);
+ }
+ }
+ else
+ printf ("Verify : SystemTime : Error! \n");
+
+ return;
+}
+
+TimeValue getSystemTime()
+{
+ TimeValue aTime;
+ time_t ltime;
+
+ time( &ltime );
+
+ aTime.Seconds = ltime;
+ aTime.Nanosec = 0;
+
+ return aTime;
+}
+
+
+//--------------------------------------------------
+// DirectoryOpenAndCloseTest
+//--------------------------------------------------
+
+void DirectoryOpenAndCloseTest( void )
+{
+ FileBase::RC rc;
+ int i=0;
+ Directory *pDir;
+
+ printf( "--------------------------------------------\n");
+ printf( "Directory-Open-And-Close-Test\n");
+ printf( "--------------------------------------------\n\n");
+
+ //--------------------------------------------------
+ // open an existing directory
+ //--------------------------------------------------
+
+ pDir=new Directory( dir1 );
+ printf( "Open an existing directory: ");
+ printFileName( dir1 );
+ printf( "\n" );
+
+ rc= pDir->open();
+ print_error( rtl::OString( "Open Directory" ), rc );
+
+ if ( pDir->isOpen() )
+ {
+ print_error( rtl::OString( "Directory is Open" ), rc );
+ }
+
+ // Close Directory
+ rc=pDir->close();
+ print_error( rtl::OString( "Close Directory" ), rc );
+
+ delete pDir;
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // open a not existing directory
+ //--------------------------------------------------
+
+ pDir=new Directory( dir_not_exist );
+
+ printf( "Open a not existing directory: ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+ rc= pDir->open();
+
+ print_error( rtl::OString( "Open Directory" ), rc );
+
+ delete pDir;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // open a directory with a wrong semantic
+ //--------------------------------------------------
+ pDir=new Directory( dir_wrong_semantic );
+
+ printf( "Open a directory with a wrong semantic: ");
+ printFileName( dir_wrong_semantic );
+ printf( "\n" );
+
+ rc= pDir->open();
+ print_error( rtl::OString( "Open Directory" ), rc );
+
+ delete pDir;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // open an existing directory on a server
+ //--------------------------------------------------
+
+ pDir=new Directory( dir_on_server );
+
+ printf( "Open an existing directory on a server: ");
+ printFileName( dir_on_server );
+ printf( "\n" );
+
+ rc= pDir->open();
+ print_error( rtl::OString( "Open Directory" ), rc );
+
+ // Close Directory
+ rc=pDir->close();
+ print_error( rtl::OString( "Close Directory" ), rc );
+
+ delete pDir;
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // open a not existing directory on a server
+ //--------------------------------------------------
+
+ pDir=new Directory( dir_not_exist_on_server );
+
+ printf( "Open a not existing directory on a server: ");
+ printFileName( dir_not_exist_on_server );
+ printf( "\n" );
+
+ rc= pDir->open();
+ print_error( rtl::OString( "Open Directory" ), rc );
+
+ delete pDir;
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Close a not existing directory
+ //--------------------------------------------------
+
+ pDir=new Directory( dir_not_exist );
+ printf( "Close a not existing directory: ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+ rc=pDir->close();
+ print_error( rtl::OString( "Close Directory" ), rc );
+
+ PressKey();
+ return;
+
+}
+
+//--------------------------------------------------
+// DirectoryCreateAndRemoveTest
+//--------------------------------------------------
+
+void DirectoryCreateAndRemoveTest( void )
+{
+ FileBase::RC rc,rc1;
+ int i=0;
+ Directory *pDir;
+
+ printf( "--------------------------------------------\n" );
+ printf( "Directory-Create-And-Remove-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ //--------------------------------------------------
+ // Create directory
+ //--------------------------------------------------
+ printf( "Create a not existing directory: ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+ rc=Directory::create( dir_not_exist) ;
+ print_error( rtl::OString( "Create Directory" ), rc );
+
+ // Verify
+ pDir=new Directory( dir_not_exist );
+
+ rc= pDir->open();
+ print_error( rtl::OString( "Verify" ), rc );
+ pDir->close();
+ delete pDir;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Create a directory on a server
+ //--------------------------------------------------
+
+ printf( "Create a not existing directory on a server: ");
+ printFileName( dir_not_exist_on_server );
+ printf( "\n" );
+
+ rc=Directory::create( dir_not_exist_on_server );
+ print_error( rtl::OString( "Create Directory" ), rc );
+
+ // Verify
+ pDir=new Directory( dir_not_exist_on_server );
+ rc= pDir->open();
+ print_error( rtl::OString( "Verify" ), rc );
+ pDir->close();
+ delete pDir;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Remove Directories
+ //--------------------------------------------------
+
+ printf( "Remove the created directories: \n" );
+
+ rc=Directory::remove( dir_not_exist );
+
+ rc1=Directory::remove( dir_not_exist_on_server );
+
+ if ( rc==FileBase::E_None && rc1==FileBase::E_None )
+ print_error( rtl::OString( "Remove Directories" ), FileBase::E_None );
+ else if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Remove local Directory" ),rc );
+ else
+ print_error( rtl::OString( "Remove Directory on a server" ),rc1 );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Remove a not existing directory
+ //--------------------------------------------------
+
+ printf( "Remove a not existing directory: ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+ rc=Directory::remove( dir_not_exist );
+ print_error( rtl::OString( "Remove" ),rc );
+
+ PressKey();
+ return;
+}
+
+//--------------------------------------------------
+// FileOpenAndCloseTest
+//--------------------------------------------------
+
+static void FileOpenAndCloseTest( void )
+{
+ FileBase::RC rc;
+ int i=0;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Open-And-Close-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ File *pFile;
+
+ pFile=new File( file1 );
+
+ printf( "Open an existing file: ");
+ printFileName( file1 );
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // open an existing file (Read)
+ //--------------------------------------------------
+
+ rc=pFile->open( OpenFlag_Read );
+ print_error( rtl::OString( "Open File (Read)" ), rc );
+
+ //--------------------------------------------------
+ // close the file
+ //--------------------------------------------------
+
+ rc=pFile->close();
+ print_error( rtl::OString( "Close File" ), rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // open an existing file (Write)
+ //--------------------------------------------------
+
+ rc=pFile->open( OpenFlag_Write );
+ print_error( rtl::OString( "Open File (Write)" ), rc );
+
+ //--------------------------------------------------
+ // close the file
+ //--------------------------------------------------
+
+ rc=pFile->close();
+ print_error( rtl::OString( "Close File" ), rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // close the file a second time
+ //--------------------------------------------------
+
+ rc=pFile->close();
+ print_error( rtl::OString( "Close the file a second time" ), rc );
+
+ delete pFile;
+ PressKey();
+}
+
+//--------------------------------------------------
+// FileCreateAndRemoveTest
+//--------------------------------------------------
+
+void FileCreateAndRemoveTest()
+{
+ FileBase::RC rc;
+ File *pFile;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Create-And-Remove-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ pFile=new File( file_not_exist );
+
+ printf( "Create File: ");
+ printFileName( file_not_exist );
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // open (create) a not existing file (Read and write)
+ //----------------------------------------------------
+
+ rc = pFile->open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
+
+ print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
+
+ //----------------------------------------------------
+ // close the file
+ //----------------------------------------------------
+
+ rc=pFile->close();
+ print_error( rtl::OString( "Close File" ), rc );
+
+ //----------------------------------------------------
+ // remove the file
+ //----------------------------------------------------
+
+ rc=pFile->remove( file_not_exist );
+ print_error( rtl::OString(" Remove File" ), rc );
+
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // remove the same file a second time
+ //----------------------------------------------------
+ rc=pFile->remove( file_not_exist );
+ print_error( rtl::OString( "Remove a not existing File" ), rc );
+
+ //----------------------------------------------------
+ // remove an open file
+ //----------------------------------------------------
+
+ pFile->open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
+
+ rc=pFile->remove( file_not_exist );
+ print_error( rtl::OString( "Remove an open File" ), rc );
+
+ pFile->close();
+ pFile->remove( file_not_exist );
+
+ PressKey();
+
+ return;
+}
+
+//--------------------------------------------------
+// FileWriteAndReadTest
+//--------------------------------------------------
+
+void FileWriteAndReadTest( void )
+{
+ FileBase::RC rc;
+
+ sal_uInt64 uWritten;
+ sal_uInt64 uRead;
+ sal_Char *pWriteBuffer="Hier kommt der Osterhase !";
+ sal_uInt64 nLen=strlen( pWriteBuffer );
+ sal_Char *pReadBuffer;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Write-And-Read-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ File *pFile;
+
+ pFile=new File( file_not_exist );
+
+ printf( "Create File: ");
+ printFileName( file_not_exist );
+ printf("\n");
+
+ //----------------------------------------------------
+ // open (create) a not existing file (Read and write)
+ //----------------------------------------------------
+
+ rc = pFile->open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
+
+ print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
+
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // write a string to the file
+ //----------------------------------------------------
+ rc=pFile->write( pWriteBuffer , nLen , uWritten );
+ print_error( rtl::OString( "Write File" ), rc );
+
+ if(uWritten==nLen)
+ printf( "Verify: OK! \n" );
+ else
+ printf( "Verify: Error\n" );
+
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // move the filepointer to the beginning
+ //----------------------------------------------------
+
+ rc=pFile->setPos( Pos_Absolut , 0 );
+ print_error( rtl::OString( "Set FilePointer to the beginning of the file" ), rc );
+
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // read the string
+ //----------------------------------------------------
+
+ pReadBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
+ rtl_zeroMemory( pReadBuffer, (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
+ rc=pFile->read( pReadBuffer , nLen,uRead );
+ print_error( rtl::OString( "Read File" ), rc );
+
+ if (strcmp(pWriteBuffer, pReadBuffer)==0)
+ {
+ printf( "Verify: OK !\n" );
+ printf( "Text: %s\n",pReadBuffer );
+ }
+ else
+ printf( "Verify: Error\n" );
+
+ rtl_freeMemory( pReadBuffer );
+
+ printf( "\n" );
+
+ // close the file
+ rc=pFile->close();
+ print_error( rtl::OString( "Close File" ), rc );
+
+ // remove the file
+ rc=pFile->remove( file_not_exist );
+ print_error( rtl::OString( "Remove File" ), rc );
+
+ PressKey();
+
+ return;
+
+}
+
+//--------------------------------------------------
+// FileCopyMoveTest
+//--------------------------------------------------
+
+void FileCopyAndMoveTest( void )
+{
+ FileBase::RC rc;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Copy-Move-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+
+ File *pFile;
+ rtl::OUString destPath(dir2);
+
+ //--------------------------------------------------
+ // FileCopyTest
+ //--------------------------------------------------
+
+ destPath+=rtl::OUString::createFromAscii("/");
+ destPath+=file3;
+
+ printf( "Copy the file ");
+ printFileName( file1 );
+ printf( " to ");
+ printFileName( destPath );
+ printf( "\n" );
+
+
+ rc=File::copy( file1 , destPath );
+ print_error( rtl::OString( "FileCopy" ), rc );
+
+ pFile=new File( destPath );
+
+ rc=pFile->open( OpenFlag_Read );
+ if ( rc == FileBase::E_None)
+ {
+ printf( "Verify: OK!\n" );
+ pFile->close();
+ File::remove( destPath );
+ }
+ else
+ printf( "Verify: Error!\n" );
+
+ delete pFile;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Copy a file to a not existing directory
+ //--------------------------------------------------
+
+ destPath=rtl::OUString( dir_not_exist );
+ destPath+=rtl::OUString::createFromAscii("/");
+ destPath+=file3;
+
+ printf( "Copy a file to a not existing directory \n");
+ printf( "Copy the file %s to %s\n", file1.getStr(), destPath.getStr() );
+
+ rc=File::copy( file1, destPath );
+ print_error( rtl::OString( "FileCopy" ), rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Copy a directory
+ //--------------------------------------------------
+
+ printf( "Copy the directory: ");
+ printFileName( dir1 );
+ printf( " to ");
+ printFileName( dir2 );
+ printf( "\n" );
+
+ rc=File::copy( dir1 , dir2 );
+ print_error( rtl::OString( "FileCopy" ), rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // FileMoveTest
+ //--------------------------------------------------
+
+ destPath=rtl::OUString( dir2 );
+ destPath+=rtl::OUString::createFromAscii("/");
+ destPath+=file3;
+
+ printf( "Move the file ");
+ printFileName( file1 );
+ printf( " to ");
+ printFileName( destPath );
+ printf( "\n" );
+
+ rc=File::move( file1, destPath );
+ print_error( rtl::OString( "FileMove" ), rc );
+
+ pFile=new File( destPath );
+
+ rc=pFile->open( OpenFlag_Read );
+ if ( rc==FileBase::E_None )
+ {
+ pFile->close();
+
+ delete pFile;
+ pFile=new File( file1 );
+
+ rc=pFile->open( OpenFlag_Read );
+
+ if ( rc!=FileBase::E_None )
+ {
+ printf( "Verify: OK!\n" );
+ File::move( destPath, file1 );
+ }
+ else
+ {
+ printf( "Verify: Error!\n" );
+ pFile->close();
+ File::remove( destPath );
+ }
+ }
+ else
+ printf( "Verify: Error!\n" );
+
+ delete pFile;
+
+ printf( "\n" );
+
+
+ //--------------------------------------------------
+ // Move a file to a not existing directory
+ //--------------------------------------------------
+
+ destPath=rtl::OUString( dir_not_exist );
+ destPath+=rtl::OUString::createFromAscii("/");
+ destPath+=file3;
+
+ printf( "Move a file to a not existing directory: \n");
+ printf( "Move the file ");
+ printFileName( file1 );
+ printf( " to ");
+ printFileName( destPath );
+ printf( "\n" );
+
+ rc=File::move( file1 , destPath );
+ print_error( rtl::OString( "FileMove" ), rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Move a directory
+ //--------------------------------------------------
+
+ printf( "Move a directory: \n");
+
+ printf( "Move the directory ");
+ printFileName( dir1 );
+ printf( " to ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+
+ rc=File::move( dir1 , dir_not_exist);
+ print_error( rtl::OString( "FileMove" ), rc );
+
+ if ( rc == FileBase::E_None )
+ File::move( dir_not_exist , dir1);
+
+ printf( "\n" );
+
+
+ PressKey();
+ return;
+}
+
+//----------------------------------------------------
+// FileSizeTest
+//----------------------------------------------------
+
+void FileSizeTest( void )
+{
+ FileBase::RC rc;
+ sal_uInt64 filesize;
+ DirectoryItem aItem;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Size-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+
+ File aFile( file_not_exist );
+
+ printf( "Create File: ");
+ printFileName( file_not_exist );
+ printf( "\n\n");
+
+ rc = aFile.open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
+ print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
+ printf( "\n" );
+
+ if ( rc == FileBase::E_None )
+ {
+ //----------------------------------------------------
+ // Set Filesize to 5000
+ //----------------------------------------------------
+
+ printf( "Set FileSize to 5000\n" );
+ rc=aFile.setSize( 5000 );
+ print_error( rtl::OString( "Set FileSize" ), rc );
+
+ printf( "\n" );
+ printf( "Verify:\n" );
+
+ //----------------------------------------------------
+ // Check whether Filesize is set to 5000
+ //----------------------------------------------------
+
+ rc=DirectoryItem::get( file_not_exist, aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ if ( rc == FileBase::E_None )
+ {
+ FileStatus rStatus( FileStatusMask_FileSize );
+ rc=aItem.getFileStatus( rStatus );
+ print_error( rtl::OString( "Get FileStatus" ), rc );
+
+ if ( rc == FileBase::E_None )
+ {
+ filesize=rStatus.getFileSize();
+
+ if ( filesize == 5000 )
+ printf( "\nOK : FileSize: %i\n", filesize );
+ else
+ printf( "\nError : FileSize: %i\n", filesize );
+ }
+ }
+
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // Set Filesize to -1
+ //----------------------------------------------------
+
+ printf( "Set FileSize to -1\n" );
+ rc=aFile.setSize( -1 );
+ print_error( rtl::OString( "Set FileSize" ), rc );
+
+ printf( "\n" );
+
+ // close the file
+ rc=aFile.close();
+ print_error( rtl::OString( "Close File" ), rc );
+
+ // remove the file
+ rc=File::remove( file_not_exist );
+ print_error( rtl::OString( "Remove File" ), rc );
+ }
+
+ PressKey();
+
+ return;
+}
+
+
+//----------------------------------------------------
+// FilePointerTest
+//----------------------------------------------------
+
+void FilePointerTest( void )
+{
+ FileBase::RC rc;
+ sal_uInt64 filepointer;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Pointer-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+
+ File rFile( file_not_exist );
+
+ printf( "Create File: ");
+ printFileName( file_not_exist );
+ printf( "\n\n");
+
+ rc = rFile.open( OpenFlag_Read | OpenFlag_Write | osl_File_OpenFlag_Create );
+ print_error( rtl::OString( "Create and Open File (Read & Write) "), rc );
+ printf( "\n" );
+
+ if ( rc==FileBase::E_None )
+ {
+
+ //----------------------------------------------------
+ // get the position of the filepointer
+ //----------------------------------------------------
+
+ rc =rFile.getPos( filepointer );
+ print_error( rtl::OString( "GetPos" ), rc );
+ printf( "Position of the FilePointer: %i\n", filepointer );
+
+ printf( "\n" );
+
+ //----------------------------------------------------
+ // set the filepointer at the end of a file
+ //----------------------------------------------------
+
+ printf( "Set FileSize to 5000\n" );
+ rFile.setSize( 5000 );
+
+ printf( "Set the FilePointer at the end of the file (5000)\n" );
+ rc=rFile.setPos( Pos_End,0 );
+ print_error( rtl::OString( "SetPos" ), rc );
+
+ rc=rFile.getPos( filepointer );
+
+ if ( filepointer==5000 )
+ {
+ print_error( rtl::OString( "GetPos" ), rc );
+ printf( "\nVerify: OK !\n" );
+ printf( "Filepointer-Position: %llu\n",filepointer );
+ }
+ else
+ {
+ print_error( rtl::OString( "GetPos" ), rc );
+ printf( "\nFilePointer-Test: Error\n" );
+ printf( "Filepointer-Position: %i != 5000 \n",filepointer );
+ }
+
+ printf( "\n" );
+
+ // close the file
+ rc=rFile.close();
+ print_error( rtl::OString( "Close File" ), rc );
+
+ // remove the file
+ rc=File::remove( file_not_exist );
+ print_error( rtl::OString( "Remove File" ), rc );
+ }
+
+ PressKey();
+
+ return;
+}
+
+//--------------------------------------------------
+// FileAttributesTest
+//--------------------------------------------------
+
+void verifyFileAttributes( void )
+{
+ FileBase::RC rc;
+ DirectoryItem aItem;
+ FileStatus rStatus( FileStatusMask_Attributes );
+
+ printf( "\nVerify:\n" );
+
+ rc=DirectoryItem::get( file1, aItem );
+
+ if ( rc==FileBase::E_None )
+ {
+ rc=aItem.getFileStatus( rStatus );
+
+ if ( rc==FileBase::E_None )
+ {
+ sal_uInt64 uAttributes=rStatus.getAttributes();
+ showAttributes(uAttributes);
+ printf( "\n" );
+ }
+ else
+ print_error( rtl::OString( "Get FileStatus" ), rc );
+ }
+ else
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ return;
+}
+
+#ifdef UNX
+void FileAttributesTest( void )
+{
+ FileBase::RC rc;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Attributes-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "File: ");
+ printFileName( file1 );
+ printf( "\n\n" );
+
+
+ rc=File::setAttributes( file1, Attribute_GrpWrite );
+ print_error( rtl::OString( "Set Attribute: GrpWrite" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_GrpRead );
+ print_error( rtl::OString( "Set Attribute: GrpRead" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_GrpExe );
+ print_error( rtl::OString( "Set Attribute: GrpExe" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_OwnWrite );
+ print_error( rtl::OString( "Set Attribute: OwnWrite" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_OwnRead );
+ print_error( rtl::OString( "Set Attribute: OwnRead" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_OwnExe );
+ print_error( rtl::OString( "Set Attribute: OwnExe" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_OthWrite );
+ print_error( rtl::OString( "Set Attribute: OthWrite" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_OthRead );
+ print_error( rtl::OString( "Set Attribute: OthRead" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ rc=File::setAttributes( file1, Attribute_OthExe );
+ print_error( rtl::OString( "Set Attribute: OthExe" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ if ( rc!=FileBase::E_None )
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+
+ rc=File::setAttributes( file1, Attribute_GrpWrite | Attribute_GrpRead | Attribute_GrpExe | Attribute_OwnWrite | Attribute_OwnRead | Attribute_OwnExe | Attribute_OthWrite | Attribute_OthRead | Attribute_OthExe );
+ print_error( rtl::OString( "Set all Attributes" ), rc );
+
+ verifyFileAttributes();
+
+ PressKey();
+
+ return;
+}
+#endif
+
+#ifdef WNT
+void FileAttributesTest( void )
+{
+ FileBase::RC rc;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Attributes-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "File: ");
+ printFileName( file1 );
+ printf( "\n\n" );
+
+
+ rc=File::setAttributes( file1, Attribute_ReadOnly );
+ print_error( rtl::OString( "Set Attribute: ReadOnly" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, Attribute_Hidden );
+ print_error( rtl::OString( "Set Attribute: Hidden" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ print_error( rtl::OString( "Reset Attributes" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, Attribute_Hidden | Attribute_ReadOnly );
+ print_error( rtl::OString( "Set Attribute: Hidden & ReadOnly" ), rc );
+
+ verifyFileAttributes();
+
+ rc=File::setAttributes( file1, 0 );
+ print_error( rtl::OString( "Reset Attributes") , rc );
+
+ verifyFileAttributes();
+
+ PressKey();
+
+ return;
+}
+#endif
+
+//--------------------------------------------------
+// FileTimeTest
+//--------------------------------------------------
+
+void FileTimeTest( void )
+{
+ FileBase::RC rc;
+
+ DirectoryItem aItem;
+
+ struct tm sSysCreationTime = { 0, 20, 12, 4, 9, 100 };
+ struct tm sSysAccessTime = { 0, 40, 1, 6, 5, 98 };
+ struct tm sSysModifyTime = { 0, 1, 24, 13, 11, 95 };
+
+ time_t aSysCreationTime = mktime( &sSysCreationTime );
+ time_t aSysAccessTime = mktime( &sSysAccessTime );
+ time_t aSysModifyTime = mktime( &sSysModifyTime );
+
+ TimeValue aCreationTime = { aSysCreationTime, 0};
+ TimeValue aAccessTime = { aSysAccessTime, 0};
+ TimeValue aModifyTime = { aSysModifyTime, 0};
+
+ TimeValue aCreationTimeRead;
+ TimeValue aAccessTimeRead;
+ TimeValue aModifyTimeRead;
+
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-Time-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "File: ");
+ printFileName( file1 );
+ printf( "\n\n" );
+
+ printf( "CreationTime \t : ");
+ showTime( aCreationTime );
+
+ printf( "\nAccessTime \t : ");
+ showTime( aAccessTime );
+
+ printf( "\nModifyTime \t : ");
+ showTime( aModifyTime );
+
+ //--------------------------------------------------
+ // setTime
+ //--------------------------------------------------
+
+ printf( "\n" );
+ rc=File::setTime( file1 , aCreationTime , aAccessTime , aModifyTime );
+ print_error( rtl::OString( "SetTime" ), rc );
+
+ //--------------------------------------------------
+ // Verify
+ //--------------------------------------------------
+
+ FileStatus rStatus( FileStatusMask_CreationTime | FileStatusMask_AccessTime | FileStatusMask_ModifyTime);
+
+ printf( "\nVerify:\n" );
+
+ rc=DirectoryItem::get( file1, aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ if ( rc==FileBase::E_None )
+ {
+ rc=aItem.getFileStatus( rStatus );
+ print_error( rtl::OString( "Get FileStatus" ), rc );
+ printf( "\n" );
+
+ if ( rc==FileBase::E_None )
+ {
+ //--------------------------------------------------
+ // GetCreationTime
+ //--------------------------------------------------
+
+ aCreationTimeRead=rStatus.getCreationTime();
+#ifdef WNT
+ if ( aCreationTime.Seconds == aCreationTimeRead.Seconds && aCreationTime.Nanosec == aCreationTimeRead.Nanosec )
+ printf( "GetCreationTime: ok : " );
+ else
+ printf( "GetCreationTime: Error : " );
+
+ showTime( aCreationTimeRead );
+ printf( "\n" );
+#endif
+ //--------------------------------------------------
+ // GetAccessTime
+ //--------------------------------------------------
+
+ aAccessTimeRead=rStatus.getAccessTime();
+
+ if ( aAccessTime.Seconds == aAccessTimeRead.Seconds && aAccessTime.Nanosec == aAccessTimeRead.Nanosec )
+ printf( "GetAccessTime: ok : " );
+ else
+ printf( "GetAccessTime: Error : " );
+
+ showTime( aAccessTimeRead );
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // GetModifyTime
+ //--------------------------------------------------
+
+ aModifyTimeRead=rStatus.getModifyTime();
+
+ if ( aModifyTime.Seconds == aModifyTimeRead.Seconds && aModifyTime.Nanosec == aModifyTimeRead.Nanosec )
+ printf( "GetModifyTime: ok : " );
+ else
+ printf( "GetModifyTime: Error : " );
+
+ showTime( aModifyTimeRead );
+ printf( "\n" );
+ }
+ }
+
+ PressKey();
+ return;
+}
+
+
+//--------------------------------------------------
+// DirectoryItemTest
+//--------------------------------------------------
+
+void DirectoryItemTest( void )
+{
+ FileBase::RC rc;
+ Directory *pDir;
+ DirectoryItem aItem;
+ FileStatus *pStatus;
+ File *pFile;
+
+ printf( "--------------------------------------------\n" );
+ printf( "Directory-Item-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ //--------------------------------------------------
+ // get DirectoryItem from an existing directory
+ //--------------------------------------------------
+
+ printf( "Get DirectoryItem from an existing Directory: ");
+ printFileName( dir1 );
+ printf( "\n");
+
+ rc=DirectoryItem::get( dir1 , aItem );
+ print_error( rtl::OString( "GetDirectoryItem" ), rc );
+
+ pStatus=new FileStatus( FileStatusMask_All );
+ rc=aItem.getFileStatus( *pStatus );
+
+ if ( rc==FileBase::E_None )
+ {
+ printf( "GetFileStatus: FileURL: ");
+ printFileName(pStatus->getFileURL() );
+ printf( "\n" );
+ }
+
+ delete pStatus;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // get DirectoryItem from a not existing directory
+ //--------------------------------------------------
+
+ printf( "Get DirectoryItem from a not existing Directory: ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+ rc=DirectoryItem::get( dir_not_exist , aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // get DirectoryItem from an existing file
+ //--------------------------------------------------
+
+ printf( "Get DirectoryItem from an existing File: ");
+ printFileName( file1 );
+ printf( "\n" );
+
+ rc=DirectoryItem::get( file1 , aItem );
+ print_error( rtl::OString( "GetDirectoryItem" ), rc );
+
+ pStatus=new FileStatus( FileStatusMask_All );
+ rc=aItem.getFileStatus( *pStatus );
+
+ if ( rc==FileBase::E_None )
+ {
+ printf( "GetFileStatus: FileURL: ");
+ printFileName( pStatus->getFileURL() );
+ printf( "\n" );
+ }
+
+ delete pStatus;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // get DirectoryItem from a not existing file
+ //--------------------------------------------------
+
+ printf( "Get DirectoryItem from a not existing File: ");
+ printFileName( file_not_exist );
+ printf( "\n" );
+
+ rc=DirectoryItem::get( file_not_exist , aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ printf( "\n" );
+
+ //----------------------------------------------------------
+ // get DirectoryItem from a directory with a wrong semantic
+ //----------------------------------------------------------
+
+ printf( "Get DirectoryItem from a Directory with a wrong semantic: ");
+ printFileName( dir_not_exist );
+ printf( "\n" );
+
+ rc=DirectoryItem::get( dir_wrong_semantic, aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ),rc );
+
+ printf( "\n" );
+
+ //---------------------------------------------------
+ // get DirectoryItem from a file-handle
+ //--------------------------------------------------
+
+ pFile=new File( file1 );
+
+ rc=pFile->open( OpenFlag_Read );
+ if ( rc==FileBase::E_None )
+ {
+ printf( "Get DirectoryItem from a File-Handle: ");
+ printFileName( file1 );
+ printf( "\n" );
+
+ rc=DirectoryItem::get( *pFile , aItem );
+ print_error( rtl::OString( "GetDirectoryItem" ), rc );
+
+ pStatus=new FileStatus( FileStatusMask_All );
+ rc=aItem.getFileStatus( *pStatus );
+
+ if ( rc==FileBase::E_None )
+ {
+ printf( "GetFileStatus: FileURL: ");
+ printFileName( pStatus->getFileURL() );
+ printf( "\n");
+ }
+
+ delete pStatus;
+
+ pFile->close();
+ }
+
+ delete pFile;
+
+ printf( "\n" );
+
+ //---------------------------------------------------
+ // get DirectoryItem from an empty file-handle
+ //--------------------------------------------------
+
+ pFile=new File( file1 );
+
+ printf( "Get DirectoryItem from an empty File-Handle\n" );
+ rc=DirectoryItem::get( *pFile , aItem );
+ print_error( rtl::OString( "GetDirectoryItem" ), rc );
+
+ delete pFile;
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // GetNextItem from a directory
+ //--------------------------------------------------
+
+ pDir=new Directory( dir1 );
+ printf( "Get next DirectoryItem from a directory: ");
+ printFileName( dir1);
+ printf( "\n" );
+
+ rc= pDir->open();
+ print_error( rtl::OString( "Open Directory" ), rc );
+
+ printf( "\n" );
+
+ if ( pDir->isOpen() )
+ {
+ //--------------------------------------------------
+ // get all files from the directory
+ //--------------------------------------------------
+
+ rtl::OUString str;
+ rtl::OUString str1[2];
+
+ aItem=DirectoryItem();
+ rc=pDir->getNextItem( aItem );
+ print_error( rtl::OString( "GetNextItem" ),rc );
+
+ while( rc==FileBase::E_None )
+ {
+
+ FileStatus rStatus( FileStatusMask_All );
+ aItem.getFileStatus( rStatus );
+
+ str=rStatus.getFileName();
+ printf( "Filename: ");
+ printFileName( str );
+ printf( "\n");
+
+ aItem=DirectoryItem();
+ rc=pDir->getNextItem( aItem );
+ print_error( rtl::OString( "GetNextItem" ),rc );
+ }
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // Reset-Test
+ //--------------------------------------------------
+
+ for (int i=0; i<2; i++)
+ {
+ aItem=DirectoryItem();
+ rc=pDir->reset();
+ rc=pDir->getNextItem( aItem );
+
+ FileStatus rStatus( FileStatusMask_All );
+ aItem.getFileStatus( rStatus );
+
+ str1[i]=rStatus.getFileName();
+ }
+
+
+ if ( str1[0].compareTo(str1[1]) == 0 )
+ print_error( rtl::OString( "Reset" ),FileBase::E_None );
+ else
+ print_error( rtl::OString( "Reset" ),FileBase::E_invalidError );
+
+ printf( "\n" );
+
+ // Close Directory
+ rc=pDir->close();
+ print_error( rtl::OString( "Close Directory" ), rc );
+ }
+
+ printf( "\n");
+
+ //--------------------------------------------------
+ // GetNextItem from a closed directory
+ //--------------------------------------------------
+
+ printf( "Get next DirectoryItem from a closed directory: ");
+ printFileName( dir1 );
+ printf( "\n" );
+
+ aItem=DirectoryItem();
+ rc=pDir->getNextItem( aItem );
+ print_error( rtl::OString( "GetNextItem" ),rc );
+
+ delete pDir;
+
+ PressKey();
+ return;
+}
+
+//--------------------------------------------------
+// FileStatusTest (for different types)
+//--------------------------------------------------
+
+void FileStatusTest( FileStatus *pStatus )
+{
+ //--------------------------------------------------
+ // GetFileType of the directory
+ //--------------------------------------------------
+
+ FileStatus::Type aType;
+
+ printf( "\ngetFileType:\n" );
+ aType=pStatus->getFileType();
+ showFileType( aType );
+
+ //--------------------------------------------------
+ // GetAttributes
+ //--------------------------------------------------
+
+ sal_uInt64 uAttributes;
+
+ printf( "\ngetAttributes:\n" );
+ uAttributes=pStatus->getAttributes();
+ showAttributes( uAttributes );
+
+ //--------------------------------------------------
+ // GetCreationTime
+ //--------------------------------------------------
+
+ TimeValue aCreationTime;
+
+ printf( "\ngetCreationTime:\n" );
+ aCreationTime=pStatus->getCreationTime();
+
+ printf( "CreationTime: " );
+ showTime( aCreationTime );
+
+ //--------------------------------------------------
+ // GetAccessTime
+ //--------------------------------------------------
+
+ TimeValue aAccessTime;
+
+ printf( "\ngetAccessTime:\n" );
+ aAccessTime=pStatus->getAccessTime();
+
+ printf( "AccessTime: " );
+ showTime( aAccessTime );
+
+ //--------------------------------------------------
+ // GetModifyTime
+ //--------------------------------------------------
+
+ TimeValue aModifyTime;
+
+ printf( "\ngetModifyTime:\n" );
+ aModifyTime=pStatus->getModifyTime();
+
+ printf( "ModifyTime: " );
+ showTime( aModifyTime );
+
+ //--------------------------------------------------
+ // GetFileSize
+ //--------------------------------------------------
+
+ sal_uInt64 FileSize;
+
+ printf( "\ngetFileSize:\n" );
+
+ FileSize=pStatus->getFileSize();
+ printf( "FileSize: %i\n", FileSize);
+
+ //--------------------------------------------------
+ // GetFileName
+ //--------------------------------------------------
+
+ rtl::OUString FileName;
+
+ printf( "\ngetFileName:\n" );
+
+ FileName=pStatus->getFileName();
+ printf( "FileName: ");
+ printFileName( FileName );
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // GetFileURL
+ //--------------------------------------------------
+
+ rtl::OUString FileURL;
+
+ printf( "\ngetFileURL:\n" );
+
+ FileURL=pStatus->getFileURL();
+ printf( "FileURL: ");
+ printFileName( FileURL );
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // GetLinkTargetURL
+ //--------------------------------------------------
+
+ rtl::OUString LinkTargetURL;
+
+ printf( "\ngetLinkTargetURL:\n");
+
+ LinkTargetURL=pStatus->getLinkTargetURL();
+ printf( "LinkTargetURL: ");
+ printFileName( LinkTargetURL );
+ printf( "\n" );
+
+ return;
+}
+
+//--------------------------------------------------
+// DirectoryFileStatusTest
+//--------------------------------------------------
+
+void DirectoryFileStatusTest( void )
+{
+ FileBase::RC rc;
+ DirectoryItem aItem;
+ FileStatus *pStatus;
+
+ printf( "--------------------------------------------\n" );
+ printf( "Directory-FileStatus-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "FileStatus of the directory: ");
+ printFileName( dir1 );
+ printf( "\n" );
+
+ aItem=DirectoryItem();
+
+ rc=DirectoryItem::get( dir1, aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ if ( rc==FileBase::E_None )
+ {
+ pStatus=new FileStatus( FileStatusMask_All );
+ rc=aItem.getFileStatus( *pStatus );
+
+ FileStatusTest( pStatus );
+
+ delete pStatus;
+ }
+
+ printf( "\n" );
+
+ PressKey();
+ return;
+}
+
+//--------------------------------------------------
+// FileFileStatusTest
+//--------------------------------------------------
+
+void FileFileStatusTest( void )
+{
+ FileBase::RC rc;
+ DirectoryItem aItem;
+ FileStatus *pStatus;
+
+ printf( "--------------------------------------------\n" );
+ printf( "File-FileStatus-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "FileStatus of the file: ");
+ printFileName( file1 );
+ printf( "\n" );
+
+ aItem=DirectoryItem();
+
+ rc=DirectoryItem::get( file1 , aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ if ( rc==FileBase::E_None )
+ {
+ pStatus=new FileStatus( FileStatusMask_All );
+ rc=aItem.getFileStatus( *pStatus );
+
+ FileStatusTest( pStatus );
+
+ delete pStatus;
+ }
+
+ printf( "\n" );
+
+ PressKey();
+ return;
+}
+
+//--------------------------------------------------
+// VolumeFileStatusTest
+//--------------------------------------------------
+
+void VolumeFileStatusTest( void )
+{
+ FileBase::RC rc;
+ DirectoryItem aItem;
+ FileStatus *pStatus;
+
+ printf( "--------------------------------------------\n" );
+ printf( "Volume-FileStatus-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "FileStatus of the Volume: ");
+ printFileName( root );
+ printf( "\n" );
+
+ aItem=DirectoryItem();
+
+ rc=DirectoryItem::get( root , aItem );
+ print_error( rtl::OString( "Get DirectoryItem" ), rc );
+
+ if ( rc==FileBase::E_None )
+ {
+ pStatus=new FileStatus( FileStatusMask_All) ;
+ rc=aItem.getFileStatus( *pStatus );
+
+ FileStatusTest( pStatus );
+
+ delete pStatus;
+ }
+
+ printf( "\n" );
+
+ PressKey();
+ return;
+}
+
+
+//--------------------------------------------------
+// VolumeInfoTest
+//--------------------------------------------------
+
+void VolumeInfoTest( void )
+{
+ FileBase::RC rc;
+
+ printf( "--------------------------------------------\n" );
+ printf( "Volume-Info-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ printf( "VolumeInfo of the volume ");
+ printFileName( root );
+
+ printf( "\n" );
+
+ VolumeInfo rInfo( VolumeInfoMask_FreeSpace );
+ rc=Directory::getVolumeInfo( root , rInfo );
+ print_error( rtl::OString( "GetVolumeInfo" ),rc );
+
+ printf( "\n" );
+
+ //--------------------------------------------------
+ // getRemoteFlag
+ //--------------------------------------------------
+
+ if ( rInfo.getRemoteFlag() )
+ printf( "RemoteFlag: Yes\n" );
+ else
+ printf( "RemoteFlag: No\n" );
+
+ //--------------------------------------------------
+ // getRemoveableFlag
+ //--------------------------------------------------
+
+ if ( rInfo.getRemoveableFlag() )
+ printf( "RemoveableFlag: Yes\n" );
+ else
+ printf( "RemoveableFlag: No\n" );
+
+ //--------------------------------------------------
+ // getTotalSpace
+ //--------------------------------------------------
+
+ sal_uInt64 TotalSpace;
+ TotalSpace=rInfo.getTotalSpace();
+ printf( "Total Space: %i\n",TotalSpace );
+
+ //--------------------------------------------------
+ // getFreeSpace
+ //--------------------------------------------------
+
+ sal_uInt64 FreeSpace;
+ FreeSpace=rInfo.getFreeSpace();
+ printf( "Free Space: %i\n",FreeSpace );
+
+ //--------------------------------------------------
+ // getUsedSpace
+ //--------------------------------------------------
+
+ sal_uInt64 UsedSpace;
+ UsedSpace=rInfo.getUsedSpace();
+ printf( "Used Space: %i\n",UsedSpace );
+
+ //--------------------------------------------------
+ // getMaxNameLength
+ //--------------------------------------------------
+
+ sal_uInt32 MaxNameLength;
+ MaxNameLength=rInfo.getMaxNameLength();
+ printf( "MaxNameLength: %i\n",MaxNameLength );
+
+ //--------------------------------------------------
+ // getMaxPathLength
+ //--------------------------------------------------
+
+ sal_uInt32 MaxPathLength;
+ MaxPathLength=rInfo.getMaxPathLength();
+ printf( "MaxPathLength: %i\n",MaxPathLength );
+
+ //--------------------------------------------------
+ // getFileSystemName
+ //--------------------------------------------------
+
+ rtl::OUString FileSystemName;
+ FileSystemName=rInfo.getFileSystemName();
+ printf( "File-System-Name: ");
+ printFileName( FileSystemName );
+ printf( "\n" );
+
+ PressKey();
+ return;
+}
+
+//--------------------------------------------------
+// FileBaseTest
+//--------------------------------------------------
+
+void ConvertPathTest(rtl::OUString& strPath)
+{
+ FileBase::RC rc;
+
+ rtl::OUString strNormPath;
+ rtl::OUString strFileURL;
+ rtl::OUString strNormPathFromFileURL;
+ rtl::OUString strSystemPath;
+
+ //--------------------------------------------------
+ // normalizePath
+ //--------------------------------------------------
+
+ rc=FileBase::getFileURLFromSystemPath( strPath, strNormPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Normalized Path: \t\t");
+ printFileName( strNormPath );
+ printf( "\n" );
+ }
+ else
+ printf( "normalizePath: Error \n" );
+
+ //--------------------------------------------------
+ // getFileURLFromSystemPath
+ //--------------------------------------------------
+
+ if ( strNormPath.getLength() != 0 )
+ {
+ rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "File-URL: \t\t\t");
+ printFileName( strFileURL );
+ printf( "\n" );
+ }
+ else
+ printf( "getFileURLFromSystemPath: Error \n" );
+ }
+ else
+ printf( "getFileURLFromSystemPath: not tested \n" );
+
+ //--------------------------------------------------
+ // getNormalizedPathFromFileURL
+ //--------------------------------------------------
+
+ if ( strFileURL.getLength() != 0 )
+ {
+ rc=FileBase::getSystemPathFromFileURL( strFileURL, strNormPathFromFileURL );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Normalized Path from File-URL: \t");
+ printFileName( strNormPathFromFileURL );
+ printf( "\n" );
+ }
+ else
+ printf( "getNormalizedPathFromFileURL: Error \n" );
+ }
+ else
+ printf( "getNormalizedPathFromFileURL: not tested \n" );
+
+
+ //--------------------------------------------------
+ // getSystemPathFromFileURL
+ //--------------------------------------------------
+
+ if ( strNormPath.getLength() != 0 )
+ {
+ rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "System-Path: \t\t\t");
+ printFileName( strSystemPath );
+ printf( "\n");
+ }
+ else
+ printf( "getSystemPathFromFileURL: Error \n" );
+ }
+ else
+ printf( "getSystemPathFromFileURL: not tested \n" );
+
+ //--------------------------------------------------
+ // Verify
+ //--------------------------------------------------
+
+ if ( strNormPathFromFileURL == strNormPath )
+ printf( "\nVerify: OK ! ( Normalized-Path == Normalized-Path-From-File-URL )\n" );
+ else
+ printf( "\nVerify: Error ! ( Normalized-Path != Normalized-Path-From-File-URL )\n" );
+
+ return;
+}
+
+void FileBaseTest()
+{
+ printf( "--------------------------------------------\n" );
+ printf( "FileBase-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ //--------------------------------------------------
+ // ConvertPath-Test (Local File)
+ //--------------------------------------------------
+
+ printf( "- Local File: ");
+ printFileName( file1 );
+ printf( "\n\n" );
+
+ ConvertPathTest(file1);
+
+ //--------------------------------------------------
+ // ConvertPath-Test (File on a server)
+ //--------------------------------------------------
+
+ printf( "\n- File on server: ");
+ printFileName( file_on_server );
+ printf( "\n\n" );
+ ConvertPathTest(file_on_server);
+
+ PressKey();
+
+ return;
+}
+
+
+//--------------------------------------------------
+// AbsolutePathTest
+//--------------------------------------------------
+void DoAbsolutePathTest(rtl::OUString strDirBase, rtl::OUString strRelative)
+{
+ FileBase::RC rc;
+
+ rtl::OUString strAbsolute;
+
+ printf( "Base-Directory: \t");
+ printFileName( strDirBase );
+ printf( "\n" );
+ printf( "Relative-Path: \t\t");
+ printFileName ( strRelative );
+ printf( "\n" );
+
+ rc=FileBase::getAbsoluteFileURL( strDirBase, strRelative, strAbsolute );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Absolute-Path: \t\t");
+ printFileName ( strAbsolute );
+ printf( "\n" );
+ }
+ else
+ printf( "Absolute-Path: Error \n" );
+
+ printf( "\n" );
+ return;
+}
+
+void AbsolutePathTest(void)
+{
+ printf( "--------------------------------------------\n" );
+ printf( "AbsolutePath-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii("."));
+ DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii(".."));
+ DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii("../.."));
+ DoAbsolutePathTest(dir1, rtl::OUString::createFromAscii("../HUHU"));
+
+ DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii("."));
+ DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii(".."));
+ DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii("../.."));
+ DoAbsolutePathTest(dir_on_server, rtl::OUString::createFromAscii("../HUHU"));
+
+ PressKey();
+ return;
+}
+
+
+//--------------------------------------------------
+// searchPathTest
+//--------------------------------------------------
+
+void SearchPathTest(void)
+{
+ FileBase::RC rc;
+
+ rtl::OUString strNormPath(file1);
+ rtl::OUString strFileURL;
+ rtl::OUString strSystemPath;
+ rtl::OUString strResultPath;
+
+ printf( "--------------------------------------------\n" );
+ printf( "SearchPath-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+
+ rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
+ print_error( rtl::OString( "getFileURLFromSystemPath" ), rc );
+ rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
+ print_error( rtl::OString( "getSystemPathFromFileURL" ), rc );
+
+ //--------------------------------------------------
+ // searchFileURL (with a normalized path)
+ //--------------------------------------------------
+
+ if ( strNormPath.getLength() != 0 )
+ {
+ printf( "\nSearch-Normalized-Path (with a normalized path) : ");
+ printFileName ( strNormPath );
+ printf( "\n" );
+
+ rc=FileBase::searchFileURL( strNormPath , rtl::OUString() , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Result: \t\t\t");
+ printFileName ( strResultPath );
+ printf( "\n" );
+ }
+ else
+ printf( "searchFileURL (with a normalized path): Error\n" );
+ }
+ else
+ printf( "searchFileURL (with a normalized path): not tested\n" );
+
+ //--------------------------------------------------
+ // searchFileURL (with a File-URL)
+ //--------------------------------------------------
+
+ if ( strFileURL.getLength() != 0 )
+ {
+ printf( "\nSearch-Normalized-Path (with a FileURL) : ");
+ printFileName( strFileURL );
+ printf( "\n" );
+
+ rc=FileBase::searchFileURL( strFileURL , rtl::OUString() , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Result: \t\t\t");
+ printFileName ( strResultPath );
+ printf( "\n" );
+ }
+ else
+ printf( "searchFileURL (with a FileURL path): Error\n" );
+ }
+ else
+ printf( "searchFileURL (with a FileURL path): not tested\n" );
+
+ //--------------------------------------------------
+ // searchFileURL (with a systempath)
+ //--------------------------------------------------
+
+ if ( strSystemPath.getLength() != 0 )
+ {
+ printf( "\nSearch-Normalized-Path (with a SystemPath) : ");
+ printFileName( strSystemPath );
+ printf( "\n" );
+
+ rc=FileBase::searchFileURL( strSystemPath , rtl::OUString() , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Result: \t\t\t");
+ printFileName( strResultPath );
+ printf( "\n" );
+ }
+ else
+ printf( "searchFileURL (with a systempath): Error\n" );
+ }
+ else
+ printf( "searchFileURL (with a systempath): not tested\n" );
+
+ //--------------------------------------------------
+ // searchFileURL (File and no searchpath)
+ //--------------------------------------------------
+
+ printf( "\nsearchFileURL: File (no searchpath) : ");
+ printFileName( file3 );
+ printf( "\n" );
+
+ rc=FileBase::searchFileURL( file3 , rtl::OUString::createFromAscii("") , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Result: \t\t\t");
+ printFileName( strResultPath );
+ printf( "\n" );
+ }
+ else
+ printf( "searchFileURL: File not found: OK ! \n" );
+
+ //--------------------------------------------------
+ // searchFileURL (File and Path)
+ //--------------------------------------------------
+
+ printf( "\nsearchFileURL: File : ");
+ printFileName( file3 );
+ printf( "\tSearchPath ");
+ printFileName( dir1 );
+ printf( "\n");
+
+ rc=FileBase::searchFileURL( file3 , dir1 , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Result: \t\t\t");
+ printFileName( strResultPath );
+ printf( "\n");
+ }
+ else
+ printf( "searchFileURL: File not found: Error\n" );
+
+ //------------------------------------------------------------
+ // searchFileURL (File and searchpath with two entries)
+ //------------------------------------------------------------
+
+ rtl::OUString strSearchPath( dir_not_exist );
+ strSearchPath+=rtl::OUString::createFromAscii(";");
+ strSearchPath+=dir_on_server;
+
+ printf( "\nsearchFileURL: File : ");
+ printFileName( file3 );
+ printf( "SearchPath ");
+ printFileName( strSearchPath );
+ printf( "\n");
+
+ rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ {
+ printf( "Result: \t\t\t");
+ printFileName( strResultPath );
+ printf( "\n" );
+ }
+ else
+ printf( "searchFileURL: File not found: Error\n" );
+
+ //-------------------------------------------------------------------
+ // searchFileURL (File and searchpath (with a wrong semantic))
+ //-------------------------------------------------------------------
+
+ strSearchPath=rtl::OUString( dir_wrong_semantic );
+
+ printf( "\nsearchFileURL: File : ");
+ printFileName( file3 );
+ printf( "SearchPath ");
+ printFileName( strSearchPath );
+ printf( "\n");
+
+ rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );
+
+ if ( rc == FileBase::E_None )
+ printf( "Error: Wrong Semantich but no error occurs !\n" );
+ else
+ printf( "searchFileURL: File not found: OK !\n" );
+
+ return;
+}
+
+//--------------------------------------------------
+// CanonicalNameTest
+//--------------------------------------------------
+
+void getCanonicalNameTest(rtl::OUString strPath)
+{
+ FileBase::RC rc;
+
+ rtl::OUString strValid;
+
+ printf( "Original-Name: \t\t");
+ printFileName( strPath );
+ printf( "\n" );
+
+ rc=FileBase::getCanonicalName( strPath, strValid );
+
+ if ( rc == FileBase::E_None)
+ {
+ printf( "Canonical-Name: \t");
+ printFileName( strValid );
+ printf( "\n");
+
+ }
+ else
+ printf( "Canonical-Name: Error \n" );
+
+ printf( "\n" );
+ return;
+}
+
+void CanonicalNameTest(void)
+{
+ printf( "--------------------------------------------\n" );
+ printf( "CanonicalName-Test\n" );
+ printf( "--------------------------------------------\n\n" );
+
+ getCanonicalNameTest( dir1 );
+ getCanonicalNameTest( dir_on_server );
+ getCanonicalNameTest( file1 );
+ getCanonicalNameTest( file_on_server );
+
+ PressKey();
+ return;
+}
+
+//--------------------------------------------------
+// print_error
+//--------------------------------------------------
+
+void print_error( ::rtl::OString& str, FileBase::RC rc )
+{
+
+ printf( "%s : ",str.getStr() );
+ switch(rc)
+ {
+ case FileBase::E_None:
+ printf("OK !\n");
+ break;
+ case FileBase::E_PERM:
+ printf("E_PERM\n");
+ break;
+ case FileBase::E_NOENT:
+ printf("E_NOENT\n");
+ break;
+ case FileBase::E_SRCH:
+ printf("E_SRCH\n");
+ break;
+ case FileBase::E_INTR:
+ printf("E_INTR\n");
+ break;
+ case FileBase::E_IO:
+ printf("E_IO\n");
+ break;
+ case FileBase::E_NXIO:
+ printf("E_NXIO\n");
+ break;
+ case FileBase::E_2BIG:
+ printf("E_2BIG\n");
+ break;
+ case FileBase::E_NOEXEC:
+ printf("E_NOEXEC\n");
+ break;
+ case FileBase::E_BADF:
+ printf("E_BADF\n");
+ break;
+ case FileBase::E_CHILD:
+ printf("E_CHILD\n");
+ break;
+ case FileBase::E_AGAIN:
+ printf("E_AGAIN\n");
+ break;
+ case FileBase::E_NOMEM:
+ printf("E_NOMEM\n");
+ break;
+ case FileBase::E_ACCES:
+ printf("E_ACCES\n");
+ break;
+ case FileBase::E_FAULT:
+ printf("E_FAULT\n");
+ break;
+ case FileBase::E_BUSY:
+ printf("E_BUSY\n");
+ break;
+ case FileBase::E_EXIST:
+ printf("E_EXIST\n");
+ break;
+ case FileBase::E_XDEV:
+ printf("E_XDEV\n");
+ break;
+ case FileBase::E_NODEV:
+ printf("E_NODEV\n");
+ break;
+ case FileBase::E_NOTDIR:
+ printf("E_NOTDIR\n");
+ break;
+ case FileBase::E_ISDIR:
+ printf("E_ISDIR\n");
+ break;
+ case FileBase::E_INVAL:
+ printf("E_INVAL\n");
+ break;
+ case FileBase::E_NFILE:
+ printf("E_NFILE\n");
+ break;
+ case FileBase::E_MFILE:
+ printf("E_MFILE\n");
+ break;
+ case FileBase::E_NOTTY:
+ printf("E_NOTTY\n");
+ break;
+ case FileBase::E_FBIG:
+ printf("E_FBIG\n");
+ break;
+ case FileBase::E_NOSPC:
+ printf("E_NOSPC\n");
+ break;
+ case FileBase::E_SPIPE:
+ printf("E_SPIPE\n");
+ break;
+ case FileBase::E_ROFS:
+ printf("E_ROFS\n");
+ break;
+ case FileBase::E_MLINK:
+ printf("E_MLINK\n");
+ break;
+ case FileBase::E_PIPE:
+ printf("E_PIPE\n");
+ break;
+ case FileBase::E_DOM:
+ printf("E_DOM\n");
+ break;
+ case FileBase::E_RANGE:
+ printf("E_RANGE\n");
+ break;
+ case FileBase::E_DEADLK:
+ printf("E_DEADLK\n");
+ break;
+ case FileBase::E_NAMETOOLONG:
+ printf("E_NAMETOOLONG\n");
+ break;
+ case FileBase::E_NOLCK:
+ printf("E_NOLCK\n");
+ break;
+ case FileBase::E_NOSYS:
+ printf("E_NOSYS\n");
+ break;
+ case FileBase::E_NOTEMPTY:
+ printf("E_NOTEMPTY\n");
+ break;
+ case FileBase::E_LOOP:
+ printf("E_LOOP\n");
+ break;
+ case FileBase::E_ILSEQ:
+ printf("E_ILSEQ\n");
+ break;
+ case FileBase::E_NOLINK:
+ printf("E_NOLINK\n");
+ break;
+ case FileBase::E_MULTIHOP:
+ printf("E_MULTIHOP\n");
+ break;
+ case FileBase::E_USERS:
+ printf("E_USERS\n");
+ break;
+ case FileBase::E_OVERFLOW:
+ printf("E_OVERFLOW\n");
+ break;
+ default:
+ printf("E_Unknown\n");
+ break;
+ }
+ return;
+}
+
+//--------------------------------------------------
+// main
+//--------------------------------------------------
+#if defined WNT
+ #define MAIN _cdecl main
+#else
+ #define MAIN main
+#endif
+
+int MAIN( int argc, char* argv[] )
+{
+ sal_Bool fSuccess=sal_False;
+
+ //Initialization
+ fSuccess=Initialize();
+ if ( !fSuccess )
+ {
+ printf("Error during Initialization");
+ return -1;
+ }
+
+
+ if (argc==1)
+ {
+ DirectoryOpenAndCloseTest();
+ DirectoryCreateAndRemoveTest();
+
+ FileOpenAndCloseTest();
+ FileCreateAndRemoveTest();
+ FileWriteAndReadTest();
+ FileCopyAndMoveTest();
+ FileSizeTest();
+ FilePointerTest();
+ FileAttributesTest();
+ FileTimeTest();
+ DirectoryItemTest();
+ DirectoryFileStatusTest();
+ VolumeFileStatusTest();
+ FileFileStatusTest();
+ VolumeInfoTest();
+ FileBaseTest();
+ SearchPathTest();
+ AbsolutePathTest();
+ CanonicalNameTest();
+ }
+ // command line arguments ?
+ else
+ {
+ int i=1;
+
+ while (i<argc)
+ {
+ if (strcmp(argv[i], "doc")==0)
+ DirectoryOpenAndCloseTest();
+ else if (strcmp(argv[i], "dcr")==0)
+ DirectoryCreateAndRemoveTest();
+ else if (strcmp(argv[i], "foc")==0)
+ FileOpenAndCloseTest();
+ else if (strcmp(argv[i], "fcr")==0)
+ FileCreateAndRemoveTest();
+ else if (strcmp(argv[i], "fwr")==0)
+ FileWriteAndReadTest();
+ else if (strcmp(argv[i], "fcm")==0)
+ FileCopyAndMoveTest();
+ else if (strcmp(argv[i], "fs")==0)
+ FileSizeTest();
+ else if (strcmp(argv[i], "fp")==0)
+ FilePointerTest();
+ else if (strcmp(argv[i], "fa")==0)
+ FileAttributesTest();
+ else if (strcmp(argv[i], "ft")==0)
+ FileTimeTest();
+ else if (strcmp(argv[i], "di")==0)
+ DirectoryItemTest();
+ else if (strcmp(argv[i], "dfs")==0)
+ DirectoryFileStatusTest();
+ else if (strcmp(argv[i], "vfs")==0)
+ VolumeFileStatusTest();
+ else if (strcmp(argv[i], "ffs")==0)
+ FileFileStatusTest();
+ else if (strcmp(argv[i], "vi")==0)
+ VolumeInfoTest();
+ else if (strcmp(argv[i], "fb")==0)
+ FileBaseTest();
+ else if (strcmp(argv[i], "sp")==0)
+ SearchPathTest();
+ else if (strcmp(argv[i], "ap")==0)
+ AbsolutePathTest();
+ else if (strcmp(argv[i], "cn")==0)
+ CanonicalNameTest();
+
+ i++;
+ }
+ }
+
+ // Shutdown
+ fSuccess=Shutdown();
+ if ( !fSuccess )
+ {
+ printf("Error during Shutdown");
+ return -1;
+ }
+
+ return 0;
+}
+
+
diff --git a/sal/workben/testpip2.cxx b/sal/workben/testpip2.cxx
new file mode 100644
index 000000000000..0fd57b083a15
--- /dev/null
+++ b/sal/workben/testpip2.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define INCL_DOSPROCESS
+#include <osl/pipe.h>
+#include <os2.h>
+
+// eindeutiger Name fr die Pipe
+const char pszPipeName[] = "TestPipe";
+
+oslPipe Pipe;
+
+
+void fail( const char * pszText, int retval )
+{
+ fprintf( stderr, "TestPipe Client: %s", pszText );
+ fprintf( stderr, "TestPipe Client: test failed, ErrNo: %d.\n", retval );
+ exit( retval );
+}
+
+
+
+/*
+ * Teste die Pipe-Implementation in osl
+ */
+
+int main (void)
+{
+ char szBuffer[ 256 ];
+ sSize_t nChars;
+
+ // gib dem Server die Chance, die Pipe zu ”ffnen
+ DosSleep( 1000 );
+
+ // erzeuge die Pipe
+ Pipe = osl_createPipe( pszPipeName, osl_Pipe_OPEN, 0 );
+
+ if( !Pipe )
+ fail( "unable to open pipe.\n",
+ osl_getLastPipeError(NULL));
+
+
+ // empfange Daten vom Server
+ nChars = osl_receivePipe( Pipe, szBuffer, 256 );
+
+ if( nChars < 0 )
+ fail( "unable to read from pipe.\n",
+ osl_getLastPipeError( Pipe ) );
+
+ printf( "TestPipe Client: data received: %s.\n", szBuffer );
+
+ // Sende die Daten wieder zurck.
+ nChars = osl_sendPipe( Pipe, szBuffer, nChars );
+
+ if( nChars < 0 )
+ fail( "unable to write on pipe.\n",
+ osl_getLastPipeError( Pipe ) );
+
+ // schliesse die Pipe
+ osl_destroyPipe( Pipe );
+
+ printf( "TestPipe Client: test passed.\n" );
+ return 0;
+}
+
+
+
diff --git a/sal/workben/testpipe.cxx b/sal/workben/testpipe.cxx
new file mode 100644
index 000000000000..6b860351d6b4
--- /dev/null
+++ b/sal/workben/testpipe.cxx
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <osl/pipe.h>
+#include <osl/process.h>
+#include <rtl/ustring.h>
+
+// eindeutiger Name fr die Pipe
+const char pszPipeName[] = "TestPipe";
+const char szTestString[] = "This is a test";
+char szBuffer[256];
+
+const char * cp;
+Size_t n;
+sSize_t nChars;
+
+// osl specific variables
+oslPipe Pipe;
+oslPipe C1Pipe;
+oslProcess Process = NULL;
+oslProcessError ProcessError;
+oslProcessInfo ProcessInfo;
+
+void fail( const char * pszText, int retval )
+{
+ fprintf( stderr, "TestPipe Server: %s", pszText );
+ fprintf( stderr, "TestPipe Server: test failed, ErrNo: %d.\n", retval );
+
+ if( Process ) osl_freeProcessHandle( Process );
+ exit( retval );
+}
+
+
+
+/*
+ * Teste die Pipe-Implementation in osl
+ */
+
+int main (int argc, const char *argv[])
+{
+ // erzeuge die Pipe
+ rtl_uString* ustrPipeName=0;
+ rtl_uString* ustrExeName=0;
+
+
+ rtl_uString_newFromAscii(&ustrPipeName,pszPipeName);
+ rtl_uString_newFromAscii(&ustrExeName, "//./tmp/testpip2.exe");
+
+ Pipe = osl_createPipe( ustrPipeName, osl_Pipe_CREATE, 0 );
+
+ if( !Pipe )
+ fail( "unable to create Pipe.\n",
+ osl_getLastPipeError(NULL));
+
+ // starte client process
+ ProcessError = osl_executeProcess( ustrExeName,
+ NULL,
+ 0,
+ osl_Process_NORMAL,
+ 0,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ &Process );
+
+ if( ProcessError != osl_Process_E_None )
+ fail( "unable to start client.\n", ProcessError );
+
+ // wait for connection
+ C1Pipe = osl_acceptPipe( Pipe );
+
+ if( !C1Pipe )
+ fail( "unable to connect to client.\n",
+ osl_getLastPipeError( Pipe ));
+
+
+ if( argc > 1 )
+ {
+ cp = argv[1];
+ n = strlen( cp ) + 1;
+ }
+ else
+ {
+ cp = szTestString;
+ n = sizeof(szTestString);
+ }
+
+ // sende TestString zum Client
+ nChars = osl_sendPipe( C1Pipe, cp, n );
+
+ if( nChars < 0 )
+ fail( "unable to write on pipe.\n",
+ osl_getLastPipeError( Pipe ) );
+
+ // empfange Daten vom Server
+ nChars = osl_receivePipe( C1Pipe, szBuffer, 256 );
+
+ if( nChars < 0 )
+ fail( "unable to read from pipe.\n",
+ osl_getLastPipeError( C1Pipe ) );
+
+ printf( "TestPipe Server: received data: %s.\n", szBuffer );
+
+ // warte bis das Client-Programm sich beendet
+ ProcessError = osl_joinProcess( Process );
+
+ if( ProcessError != osl_Process_E_None )
+ fail( "unable to wait for client.\n",
+ ProcessError );
+
+ // ermittle den Rckgabewert des Client-Programms
+ ProcessInfo.Size = sizeof( ProcessInfo );
+
+ ProcessError = osl_getProcessInfo( Process, osl_Process_EXITCODE, &ProcessInfo );
+
+ if( ProcessError != osl_Process_E_None )
+ fail( "unable to receive return value of client process.\n",
+ ProcessError );
+
+ if( ProcessInfo.Code != 0 )
+ fail( "client aborted.\n", ProcessInfo.Code );
+
+ // gib das Handle fuer den Client-Prozess frei
+ osl_freeProcessHandle( Process );
+
+ // schliesse die Pipes
+ osl_destroyPipe( C1Pipe );
+ osl_destroyPipe( Pipe );
+
+ printf( "TestPipe Server: test passed.\n" );
+ return 0;
+}
+
+
+
diff --git a/sal/workben/testproc.cxx b/sal/workben/testproc.cxx
new file mode 100644
index 000000000000..4fdb2ee9cac6
--- /dev/null
+++ b/sal/workben/testproc.cxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+
+#include <osl/process.h>
+#include <stdio.h>
+
+
+#if defined WNT
+ #define MAIN _cdecl main
+#else
+ #define MAIN main
+#endif
+
+void MAIN (void)
+{
+ oslProcess Process;
+ oslProcessError ProcessError;
+ sal_uInt32 nArgCount;
+ sal_uInt32 index;
+ rtl_uString* ustrExeFile=0;
+ rtl_uString* ustrArg=0;
+
+ nArgCount=osl_getCommandArgCount();
+
+ fprintf(stderr,"Arg Count == %i\n\n",nArgCount);
+
+ for ( index = 0 ; index <= nArgCount+1 ; index++ )
+ {
+ fprintf(stderr,"Getting Arg No . %i\n",index);
+
+ osl_getCommandArg(index,&ustrArg);
+
+ fprintf(stderr,"done ...\n\n",index);
+ }
+
+ ProcessError = osl_getExecutableFile(&ustrExeFile);
+
+/*
+ osl_executeProcess( "e:\\test\\os2de202.exe",
+ NULL,
+ osl_Process_NORMAL,
+ 0L,
+ NULL,
+ NULL,
+ NULL,
+ &Process );*/
+}
+
+
diff --git a/sal/workben/tgetpwnam.cxx b/sal/workben/tgetpwnam.cxx
new file mode 100644
index 000000000000..912c6b951532
--- /dev/null
+++ b/sal/workben/tgetpwnam.cxx
@@ -0,0 +1,248 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sal.hxx"
+
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <pthread.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#ifndef NETBSD
+#include <shadow.h>
+#endif
+
+/* exercises some reentrant libc-fucntions */
+
+extern "C"
+{
+ struct tm *localtime_r(const time_t *timep, struct tm *buffer);
+ struct passwd* getpwnam_r(char*, struct passwd*, char *, int);
+ struct spwd* getspnam_r(char*, struct spwd*, char *, int);
+ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
+ char *buffer, int buflen, int *h_errnop);
+}
+
+static int go;
+
+
+
+extern "C" void *workfunc1(void*)
+{
+ char buffer[256];
+ struct tm sttm;
+ time_t nepoch;
+ struct passwd stpwd;
+ struct hostent sthostent;
+ int nerr;
+
+ printf("starting thread 1 ...\n");
+ while (go) {
+ getpwnam_r("hr", &stpwd, buffer, sizeof(buffer));
+ gethostbyname_r("blauwal", &sthostent, buffer, sizeof(buffer), &nerr);
+ time(&nepoch);
+ localtime_r(&nepoch, &sttm);
+ }
+ return 0;
+}
+
+extern "C" void *workfunc2(void*)
+{
+ char buffer[256];
+ struct tm sttm;
+ time_t nepoch;
+ struct passwd stpwd;
+ struct hostent sthostent;
+ int nerr;
+
+ printf("starting thread 2 ...\n");
+ while(go) {
+ getpwnam_r("mh", &stpwd, buffer, sizeof(buffer));
+ gethostbyname_r("hr-1242", &sthostent, buffer, sizeof(buffer), &nerr);
+ time(&nepoch);
+ localtime_r(&nepoch, &sttm);
+ }
+ return 0;
+}
+
+
+extern int h_errno;
+
+int main(int argc, char *argv[])
+{
+ char buffer[256];
+ struct tm *ptm;
+ time_t nepoch;
+ struct passwd *pwd, *pres1;
+#ifndef NETBSD
+ struct spwd *spwd, *pres2;
+#endif
+ struct hostent *phostent, *pres3;
+ char **p;
+
+ pthread_t tid1,tid2;
+ int res1,res2;
+
+ go = 1;
+
+ pthread_create(&tid1, NULL, workfunc1, &res1);
+ pthread_create(&tid2, NULL, workfunc2, &res2);
+
+ pwd = (struct passwd*)malloc(sizeof(struct passwd));
+
+ pres1 = getpwnam_r("hr", pwd, buffer, sizeof(buffer));
+
+ sleep(3);
+
+ if (pres1) {
+ printf("Name: %s\n", pwd->pw_name);
+ printf("Passwd: %s\n", pwd->pw_passwd);
+ printf("Uid: %d\n", pwd->pw_uid);
+ printf("Gid: %d\n", pwd->pw_gid);
+#ifdef NETBSD
+ printf("Change: %s", ctime(&pwd->pw_change));
+ printf("Class: %s\n", pwd->pw_class);
+#else
+ printf("Age: %s\n", pwd->pw_age);
+ printf("Comment: %s\n", pwd->pw_comment);
+#endif
+ printf("Gecos: %s\n", pwd->pw_gecos);
+ printf("Dir: %s\n", pwd->pw_dir);
+ printf("Shell: %s\n", pwd->pw_shell);
+ }
+ else
+ printf("getpwnam_r() failed!\n");
+
+ free(pwd);
+
+#ifndef NETBSD
+ spwd = (struct spwd*)malloc(sizeof(struct spwd));
+
+ pres2 = getspnam_r("hr", spwd, buffer, sizeof(buffer));
+
+ if (pres2) {
+ printf("Name: %s\n", spwd->sp_namp);
+ printf("Passwd: %s\n", spwd->sp_pwdp);
+ printf("Last Change: %ld\n", spwd->sp_lstchg);
+ printf("Min: %ld\n", spwd->sp_min);
+ printf("Max: %ld\n", spwd->sp_max);
+ }
+ else
+ printf("getspnam_r() failed!\n");
+
+ free(spwd);
+#endif
+
+ ptm = (struct tm*)malloc(sizeof(struct tm));
+
+ time(&nepoch);
+ localtime_r(&nepoch, ptm);
+
+ printf("Seconds: %d\n", ptm->tm_sec);
+ printf("Minutes: %d\n", ptm->tm_min);
+ printf("Hour: %d\n", ptm->tm_hour);
+ printf("Day of Month: %d\n", ptm->tm_mday);
+ printf("Month: %d\n", ptm->tm_mon);
+ printf("Year: %d\n", ptm->tm_year);
+ printf("Day of week: %d\n", ptm->tm_wday);
+ printf("Day in the year: %d\n", ptm->tm_yday);
+ printf("Daylight saving time: %d\n", ptm->tm_isdst);
+#ifdef NETBSD
+ printf("Timezone: %s\n", ptm->tm_zone);
+#else
+ printf("Timezone: %s\n", ptm->tm_name);
+#endif
+
+ free(ptm);
+
+ phostent = (struct hostent*)malloc(sizeof(struct hostent));
+
+ pres3 = gethostbyname_r("blauwal", phostent, buffer, sizeof(buffer), h_errno);
+
+ if (pres3) {
+ printf("Official Hostname: %s\n", phostent->h_name);
+ for ( p = phostent->h_aliases; *p != NULL; p++ )
+ printf("Alias: %s\n", *p);
+ printf("Addresstype: %d\n", phostent->h_addrtype);
+ printf("Address length: %d\n", phostent->h_length);
+ if ( phostent->h_addrtype == AF_INET ) {
+ for ( p = phostent->h_addr_list; *p != NULL; *p++ )
+ printf("Address: %s\n", inet_ntoa(**((in_addr**)p)));
+ }
+ }
+
+
+ /* test boundary conditions */
+ char smallbuf[23]; /* buffer to small */
+ pres3 = gethostbyname_r("blauwal", phostent, smallbuf, sizeof(smallbuf), h_errno);
+ if (!pres3) {
+ perror("Expect ERANGE");
+ }
+ else
+ {
+ printf("ERROR: Check for buffersize went wrong\n");
+ }
+
+#ifdef NETBSD
+ char exactbuf[35];
+#else
+ char exactbuf[24]; /* should be exact the necessary size */
+#endif
+ pres3 = gethostbyname_r("blauwal", phostent, exactbuf, sizeof(exactbuf), &h_errno);
+ if (!pres3) {
+ perror("Check with exact buffersize");
+ }
+ else
+ {
+ printf("Boundary check ok\n");
+ }
+
+ /* test error conditions */
+ pres3 = gethostbyname_r("nohost", phostent, buffer, sizeof(buffer), &h_errno);
+ if (!pres3) {
+ herror("Expect HOST_NOT_FOUND");
+ }
+ else
+ {
+ printf("failed to detect non existant host\n");
+ }
+
+ free(phostent);
+ go = 0; /* atomic enough for our purposes */
+
+ pthread_join(tid1, NULL);
+ pthread_join(tid2, NULL);
+
+ exit(0);
+}
+
+