diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 14:18:43 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 14:18:43 +0000 |
commit | 9399c662f36c385b0c705eb34e636a9aec450282 (patch) | |
tree | f502e9d9258960ff214ab90e98e31d0075e60196 /sal/inc |
initial import
Diffstat (limited to 'sal/inc')
52 files changed, 15027 insertions, 0 deletions
diff --git a/sal/inc/osl/conditn.h b/sal/inc/osl/conditn.h new file mode 100644 index 000000000000..88fec4967bc7 --- /dev/null +++ b/sal/inc/osl/conditn.h @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $RCSfile: conditn.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_CONDITION_H_ +#define _OSL_CONDITION_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* oslCondition; + +typedef enum { + osl_cond_result_ok, /* successful completion */ + osl_cond_result_error, /* error occured, check osl_getLastSocketError() for details */ + osl_cond_result_timeout, /* blocking operation timed out */ + osl_cond_result_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslConditionResult; + +/** Creates a condition. + @returns 0 if condition could not be created. +*/ +oslCondition SAL_CALL osl_createCondition(void); + +/** Free the memory used by the condition. + @param Condition the condition handle. +*/ +void SAL_CALL osl_destroyCondition(oslCondition Condition); + +/** Sets condition to True => wait() will not block, check() returns True. + NOTE: ALL threads waiting on this condition are unblocked! + @param Condition handle to a created condition. + @return False if system-call failed. +*/ +sal_Bool SAL_CALL osl_setCondition(oslCondition Condition); + +/** Sets condition to False => wait() will block, check() returns False + @param Condition handle to a created condition. + @return False if system-call failed. +*/ +sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition); + +/** Blocks if condition is not set<BR> + If condition has been destroyed prematurely, wait() will + return with False. + @param Condition handle to a created condition. + @param pTimeout Tiemout value or NULL for infinite waiting + @return False if system-call failed. +*/ +oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const TimeValue* pTimeout); + +/** Queries the state of the condition without blocking. + @param Condition handle to a created condition. + @return True: condition is set. <BR> + False: condition is not set. <BR> +*/ +sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_CONDITION_H_ */ + diff --git a/sal/inc/osl/conditn.hxx b/sal/inc/osl/conditn.hxx new file mode 100644 index 000000000000..d736df281a6d --- /dev/null +++ b/sal/inc/osl/conditn.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * $RCSfile: conditn.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_CONDITN_HXX_ +#define _OSL_CONDITN_HXX_ + +#ifdef __cplusplus + +#include <osl/macros.hxx> + +#include <osl/conditn.h> + + +#ifdef _USE_NAMESPACE +namespace osl +{ +#endif + + class Condition + { + public: + + enum Result + { + result_ok = osl_cond_result_ok, + result_error = osl_cond_result_error, + result_timeout = osl_cond_result_timeout + }; + + /* Create a condition. + */ + Condition() + { + condition = osl_createCondition(); + } + + /* Release the OS-structures and free condition data-structure. + */ + ~Condition() + { + osl_destroyCondition(condition); + } + + /* Release all waiting threads, check returns sal_True. + */ + void set() + { + osl_setCondition(condition); + } + + /* Reset condition to false: wait() will block, check() returns sal_False. + */ + void reset() { + osl_resetCondition(condition); + } + + /** Blocks the calling thread until condition is set. + */ + Result wait(const TimeValue *pTimeout = 0) + { + return (Result) osl_waitCondition(condition, pTimeout); + } + + /** Checks if the condition is set without blocking. + */ + sal_Bool check() + { + return osl_checkCondition(condition); + } + + + private: + oslCondition condition; + + Condition(oslCondition condition) + { + this->condition = condition; + } + }; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _OSL_CONDITN_HXX_ */ + diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h new file mode 100644 index 000000000000..ca48805f90ba --- /dev/null +++ b/sal/inc/osl/diagnose.h @@ -0,0 +1,163 @@ +/************************************************************************* + * + * $RCSfile: diagnose.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_DIAGNOSE_H_ +#define _OSL_DIAGNOSE_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* ////////////////////////////////////////////////////////////////////////// + Diagnostic support +*/ + +void SAL_CALL osl_breakDebug(void); +sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const sal_Char* pszMessage); +void SAL_CALL osl_trace(const sal_Char* pszFormat, ...); +sal_Int32 SAL_CALL osl_reportError(sal_uInt32 nType, const sal_Char* pszErrorMessage); + +#ifdef __cplusplus +} +#endif + +#define OSL_THIS_FILE __FILE__ + +#define OSL_DEBUG_ONLY(s) _OSL_DEBUG_ONLY(s) +#define OSL_TRACE _OSL_TRACE +#define OSL_ASSERT(c) _OSL_ASSERT(c, OSL_THIS_FILE, __LINE__) +#define OSL_VERIFY(c) _OSL_VERIFY(c, OSL_THIS_FILE, __LINE__) +#define OSL_ENSHURE(c, m) _OSL_ENSHURE(c, OSL_THIS_FILE, __LINE__, m) +#define OSL_ENSURE(c, m) _OSL_ENSHURE(c, OSL_THIS_FILE, __LINE__, m) + +#define OSL_PRECOND(c, m) OSL_ENSHURE(c, m) +#define OSL_POSTCOND(c, m) OSL_ENSHURE(c, m) + + +#ifdef __cplusplus +#define _OSL_GLOBAL :: +#else +#define _OSL_GLOBAL +#endif /* __cplusplus */ + +#ifdef _WIN16 +#ifdef _DEBUG +#undef _DEBUG +#endif +#endif + + + +#ifdef _DEBUG + +#define _OSL_DEBUG_ONLY(f) (f) +#define _OSL_TRACE _OSL_GLOBAL osl_trace +#define _OSL_ASSERT(c, f, l) \ + do \ + { \ + if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, 0)) \ + _OSL_GLOBAL osl_breakDebug(); \ + } while (0) +#define _OSL_VERIFY(c, f, l) \ + do \ + { \ + if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, 0)) \ + _OSL_GLOBAL osl_breakDebug(); \ + } while (0) +#define _OSL_ENSHURE(c, f, l, m) \ + do \ + { \ + if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \ + _OSL_GLOBAL osl_breakDebug(); \ + } while (0) +#define _OSL_ENSHURE(c, f, l, m) \ + do \ + { \ + if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \ + _OSL_GLOBAL osl_breakDebug(); \ + } while (0) +#define _OSL_ENSURE(c, f, l, m) \ + do \ + { \ + if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \ + _OSL_GLOBAL osl_breakDebug(); \ + } while (0) + +#else + +#define _OSL_DEBUG_ONLY(f) ((void)0) +#define _OSL_TRACE 1 ? ((void)0) : _OSL_GLOBAL osl_trace +#define _OSL_ASSERT(c, f, l) ((void)0) +#define _OSL_VERIFY(c, f, l) ((void)(c)) +#define _OSL_ENSHURE(c, f, l, m) ((void)0) +#define _OSL_ENSURE(c, f, l, m) ((void)0) + +#endif /* !_DEBUG */ + +#endif /* _OSL_DIAGNOSE_H_ */ + + + diff --git a/sal/inc/osl/file.h b/sal/inc/osl/file.h new file mode 100644 index 000000000000..1151b7bd69d7 --- /dev/null +++ b/sal/inc/osl/file.h @@ -0,0 +1,1066 @@ +/************************************************************************* + * + * $RCSfile: file.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_FILE_H_ +#define _OSL_FILE_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifndef _RTL_USTRING_H +# include <rtl/ustring.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Main goals and usage hints + +The main intentention of this interface is to provide an universal portable and +high performance access to file system issues on any operating system.<p> + +There are a few main goals:<p> + +1.The path specifications always have to be absolut. Any usage of relative path +specifications is forbidden. Most operating systems provide a +"Current Directory" per process. This is the reason why relative path +specifications can cause problems in multithreading environments.<p> + +2.Proprietary notations of file paths are not supported. Every path notation +must follow the UNC notation. The directory divider is the slash character.<p> + +3.The caller cannot get any information whether a file system is case sensitive, +case preserving or not. The operating system implementation itself should +determine if it can map case-insensitive paths. The case correct notation of +a filename or file path is part of the "File Info". This case correct name +can be used as a unique key if neccessary.<p> + +4. Obtaining information about files or volumes is controlled by a +bitmask which specifies which fields are of interest. Due to performance +issues it is not recommended to obtain information which is not needed. +But if the operating system provides more information anyway the +implementation can set more fields on output as were requested. It is in the +responsibility of the caller to decide if he uses this additional information +or not. But he should do so to prevent further unnecessary calls if the information +is already there.<br> + +The input bitmask supports a flag <code>osl_FileStatus_Mask_Validate</code> which +can be used to force retrieving uncached validated information. Setting this flag +when calling <code>osl_getFileStatus</code> in combination with no other flag is +a synonym for a "FileExists". This should only be done when processing a single file +(f.e. before opening) and NEVER during enumeration of directory contents on any step +of information processing. This would change the runtime behaviour from O(n) to +O(n*n/2) on nearly every file system.<br> +On Windows NT reading the contents of an directory with 7000 entries and +getting full information about every file only takes 0.6 seconds. Specifying the +flag <code>osl_FileStatus_Mask_Validate</code> for each entry will increase the +time to 180 seconds (!!!). + +*/ + + + +/* Error codes according to errno */ + +typedef enum { + osl_File_E_None, + osl_File_E_PERM, + osl_File_E_NOENT, + osl_File_E_SRCH, + osl_File_E_INTR, + osl_File_E_IO, + osl_File_E_NXIO, + osl_File_E_2BIG, + osl_File_E_NOEXEC, + osl_File_E_BADF, + osl_File_E_CHILD, + osl_File_E_AGAIN, + osl_File_E_NOMEM, + osl_File_E_ACCES, + osl_File_E_FAULT, + osl_File_E_BUSY, + osl_File_E_EXIST, + osl_File_E_XDEV, + osl_File_E_NODEV, + osl_File_E_NOTDIR, + osl_File_E_ISDIR, + osl_File_E_INVAL, + osl_File_E_NFILE, + osl_File_E_MFILE, + osl_File_E_NOTTY, + osl_File_E_FBIG, + osl_File_E_NOSPC, + osl_File_E_SPIPE, + osl_File_E_ROFS, + osl_File_E_MLINK, + osl_File_E_PIPE, + osl_File_E_DOM, + osl_File_E_RANGE, + osl_File_E_DEADLK, + osl_File_E_NAMETOOLONG, + osl_File_E_NOLCK, + osl_File_E_NOSYS, + osl_File_E_NOTEMPTY, + osl_File_E_LOOP, + osl_File_E_ILSEQ, + osl_File_E_NOLINK, + osl_File_E_MULTIHOP, + osl_File_E_USERS, + osl_File_E_OVERFLOW, + osl_File_E_invalidError, /* unmapped error: always last entry in enum! */ + osl_File_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslFileError; + +typedef void *oslDirectory; +typedef void *oslDirectoryItem; + +/** Opens a directory for enumerating its contents. + + @param strDirenctoryPath [in] Denotes the full qualified path of the directory follwing the UNC + notation. The path devider is '/'. Relative path specifications are not allowed. + @param pDirectory [out] on success it receives a handle used for subsequent calls by <code>osl_getNextDirectoryItem</code> + on error it receives NULL. The handle has to be released by a call to <code>osl_closeDirectory</code>. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOENT the specified path doesn't exist<br> + osl_File_E_NOTDIR the specified path is not an directory <br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_ACCES permission denied<br> + osl_File_E_MFILE too many open files used by the process<br> + osl_File_E_NFILE too many open files in the system<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_LOOP Too many symbolic links encountered<p> + + @see osl_getNextDirectoryItem + @see osl_closeDirectory +*/ + +oslFileError SAL_CALL osl_openDirectory( rtl_uString *strDirectoryPath, oslDirectory *pDirectory); + +/** Retrieves the next item(s) of a previously openend directory. All handles have an initial + refcount of 1. + + @param Directory [in] is the directory handle received from a previous call to <code>osl_openDirectory</code>. + @param pItem [out] On success it receives a handle that can be used for subsequent calls to <code>osl_getFileStatus</code>. + The handle has to be released by a call to <code>osl_releaseDirectoryItem</code>. + @param uHint [in] With this parameter the caller can tell the implementation that (s)he + is going to call this function uHint times afterwards. This enables the implementation to + get the information for more than one file and cache it until the next calls. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_NOENT No more entries in this directory<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_BADF oslDirectory parameter is not valid<br> + osl_File_E_OVERFLOW Value too large for defined data type<p> + + @see osl_releaseDirectoryItem + @see osl_acquireDirectoryItem + @see osl_getDirectoryItem + @see osl_getFileStatus + @see osl_createDirectoryItemFromHandle +*/ + +oslFileError SAL_CALL osl_getNextDirectoryItem( + oslDirectory Directory, + oslDirectoryItem *pItem, + sal_uInt32 uHint + ); + + +/** Releases a directory handle + + @param Directory [in] a handle received by a call to <code>osl_openDirectory</code>. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_BADF Invalid oslDirectory parameter<br> + osl_File_E_INTR function call was interrupted<p> + + @see osl_openDirectory +*/ + +oslFileError SAL_CALL osl_closeDirectory( + oslDirectory Directory + ); + + +/** Retrieves a single directory item handle with an initial refcount of 1. + + @param strFilePath [in] absolute file path following the notation explained in the documentation for + <code>osl_openDirectory</code>. Due to performance issues it is not recommended to use this function + while enumerating the contents of a directory. In this case use <code>osl_getNextDirectoryItem</code> instead. + @param pItem [out] on success it receives a handle which can be used for subsequent calls to <code>osl_getFileStatus</code>. + The handle has to be released by a call to <code>osl_releaseDirectoryItem</code>. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_ACCES permission denied<br> + osl_File_E_MFILE too many open files used by the process<br> + osl_File_E_NFILE too many open files in the system<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_NOTDIR A component of the path prefix of path is not a directory<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_IO I/O error<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_FAULT Bad address<br> + osl_File_E_INTR function call was interrupted<p> + + + @see osl_releaseDirectoryItem + @see osl_acquireDirectoryItem + @see osl_getFileStatus + @see osl_getNextDirectoryItem + @see osl_createDirectoryItemFromHandle +*/ + +oslFileError SAL_CALL osl_getDirectoryItem( + rtl_uString *strFilePath, + oslDirectoryItem *pItem + ); + + +/** Increases the refcount of a directory item handle + + @param Item [in] a handle received by a call to <code>osl_getDirectoryItem</code>, <code>osl_getNextDirectoryItem</code> or + <code>osl_createDirectoryItemFromHandle</code>. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_INVAL the format of the parameters was not valid<p> + + @see osl_getDirectoryItem + @see osl_getNextDirectoryItem + @see osl_createDirectoryItemFromHandle + @see osl_releaseDirectoryItem +*/ + +oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item ); + +/** Decreases the refcount of a directory item handle and releases the data if the + refcount reaches 0. + + @param Item [in] a handle received by a call to <code>osl_getDirectoryItem</code>, <code>osl_getNextDirectoryItem</code> or + <code>osl_createDirectoryItemFromHandle</code>. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_INVAL the format of the parameters was not valid<p> + + @see osl_getDirectoryItem + @see osl_getNextDirectoryItem + @see osl_acquireDirectoryItemosl_createDirectoryItemFromHandle + @see osl_acquireDirectoryItem +*/ + +oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item ); + +/* File types */ + +typedef enum { + osl_File_Type_Directory, + osl_File_Type_Volume, + osl_File_Type_Regular, + osl_File_Type_Fifo, + osl_File_Type_Socket, + osl_File_Type_Link, + osl_File_Type_Special, + osl_File_Type_Unknown +} oslFileType; + +/* File attributes */ +#define osl_File_Attribute_ReadOnly 0x00000001 +#define osl_File_Attribute_Hidden 0x00000002 +#define osl_File_Attribute_Executable 0x00000010 +#define osl_File_Attribute_GrpWrite 0x00000020 +#define osl_File_Attribute_GrpRead 0x00000040 +#define osl_File_Attribute_GrpExe 0x00000080 +#define osl_File_Attribute_OwnWrite 0x00000100 +#define osl_File_Attribute_OwnRead 0x00000200 +#define osl_File_Attribute_OwnExe 0x00000400 +#define osl_File_Attribute_OthWrite 0x00000800 +#define osl_File_Attribute_OthRead 0x00001000 +#define osl_File_Attribute_OthExe 0x00002000 + +/* Flags specifying which fields to retreive by osl_getFileStatus */ + +#define osl_FileStatus_Mask_Type 0x00000001 +#define osl_FileStatus_Mask_Attributes 0x00000002 +#define osl_FileStatus_Mask_CreationTime 0x00000010 +#define osl_FileStatus_Mask_AccessTime 0x00000020 +#define osl_FileStatus_Mask_ModifyTime 0x00000040 +#define osl_FileStatus_Mask_FileSize 0x00000080 +#define osl_FileStatus_Mask_FileName 0x00000100 +#define osl_FileStatus_Mask_FilePath 0x00000200 +#define osl_FileStatus_Mask_NativePath 0x00000400 +#define osl_FileStatus_Mask_All 0x7FFFFFFF +#define osl_FileStatus_Mask_Validate 0x80000000 + + +typedef + +/** Structure containing information about files and directories + + @see osl_getFileStatus + @see oslFileType +*/ + +struct _oslFileStatus { +/** Must be initialized with the size in bytes of the structure before passing it to any function */ + sal_uInt32 uStructSize; +/** Determines which members of the structure contain valid data */ + sal_uInt32 uValidFields; +/** The type of the file (file, directory, volume). */ + oslFileType eType; +/** File attributes */ + sal_uInt64 uAttributes; +/** First creation time in nanoseconds since 1/1/1970. Can be the last modify time depending on + platform or file system. */ + TimeValue aCreationTime; +/** Last access time in nanoseconds since 1/1/1970. Can be the last modify time depending on + platform or file system. */ + TimeValue aAccessTime; +/** Last modify time in nanoseconds since 1/1/1970. */ + TimeValue aModifyTime; +/** Size in bytes of the file. Zero for directories and volumes. */ + sal_uInt64 uFileSize; +/** Case correct name of the file. Should be set to zero before calling <code>osl_getFileStatus</code> + and released after usage. */ + rtl_uString *strFileName; +/** Full path of the file in UNC notation. Should be set to zero before calling <code>osl_getFileStatus</code> + and released after usage. */ + rtl_uString **pstrFilePath; +/** Full path of the file in platform depending notation. This is for displaying the path in the UI. + Should be set to zero before calling <code>osl_getFileStatus</code> + and released after usage. */ + rtl_uString **pstrNativePath; +} oslFileStatus; + +/** Retrieves information about a single file or directory + + @param Item [in] a handle received by a previous call to <code>osl_getDirectoryItem</code>, + <code>osl_getNextDirectoryItem</code> or <code>osl_createDirectoryItemFromHandle</code>. + @param pStatus [in/out] points to a structure which receives the information of the file or directory + represented by the handle <code>Item</code>. The member <code>uStructSize</code> has to be initialized to + <code>sizeof(oslFileStatus)</code> before calling this function. + @param uFieldMask [in] specifies which fields of the structure pointed to by <code>pStatus</code> + are of interest to the caller. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_NAMETOOLONG file name too long<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_BADF Invalid oslDirectoryItem parameter<br> + osl_File_E_FAULT Bad address<br> + osl_File_E_OVERFLOW Value too large for defined data type<br> + osl_File_E_INTR function call was interrupted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_MULTIHOP Components of path require hopping to multiple remote machines and the file system does not allow it<br> + osl_File_E_MFILE too many open files used by the process<br> + osl_File_E_NFILE too many open files in the system<br> + osl_File_E_NOSPC No space left on device<br> + osl_File_E_NXIO No such device or address<br> + osl_File_E_IO I/O error<br> + osl_File_E_NOSYS Function not implemented<p> + + @see osl_getDirectoryItem + @see osl_getNextDirectoryItem + @see osl_createDirectoryItemFromHandle + @see oslFileStatus +*/ + +oslFileError SAL_CALL osl_getFileStatus( oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask ); + + +typedef void *oslVolumeDeviceHandle; + + +oslFileError SAL_CALL osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle ); + +oslFileError SAL_CALL osl_automountVolumeDevice( oslVolumeDeviceHandle Handle ); + +oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle ); + +oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle ); + +/** Gets the normalized absolute file system path where a device is mounted to. + + @param Handle [in] Device handle of the volume retrieved with <code>osl_getVolumeInformation</code>. + @param pstrPath [out] Receives the path where the device is mounted to. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_ACCES permission denied<br> + osl_File_E_NXIO No such device or address<br> + osl_File_E_NODEV No such device<br> + osl_File_E_NOENT No such file or directory<br> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_FAULT Bad address<br> + osl_FilE_E_INTR function call was interrupted<br> + osl_File_E_IO I/O error<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_EOVERFLOW Value too large for defined data type<p> + + @see osl_getVolumeInformation + @see osl_automountVolumeDevice + @see osl_unmountVolumeDevice +*/ + +oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath ); + +/* Volume attributes */ + +#define osl_Volume_Attribute_Removeable 0x00000001L +#define osl_Volume_Attribute_Remote 0x00000002L + +/* Flags specifying which fields to retreive by osl_getVolumeInfo */ + +#define osl_VolumeInfo_Mask_Attributes 0x00000001L +#define osl_VolumeInfo_Mask_TotalSpace 0x00000002L +#define osl_VolumeInfo_Mask_UsedSpace 0x00000004L +#define osl_VolumeInfo_Mask_FreeSpace 0x00000008L +#define osl_VolumeInfo_Mask_MaxNameLength 0x00000010L +#define osl_VolumeInfo_Mask_MaxPathLength 0x00000020L +#define osl_VolumeInfo_Mask_FileSystemName 0x00000040L +#define osl_VolumeInfo_Mask_DeviceHandle 0x00000080L + +typedef + +/** Structure containing information about volumes + + @see osl_getVolumeInformation + @see oslFileType +*/ + +struct _oslVolumeInfo { +/** Must be initialized with the size in bytes of the structure before passing it to any function */ + sal_uInt32 uStructSize; +/** Determines which members of the structure contain valid data */ + sal_uInt32 uValidFields; +/** Attributes of the volume (remote and/or removable) */ + sal_uInt32 uAttributes; +/** Total availiable space on the volume for the current process/user */ + sal_uInt64 uTotalSpace; +/** Used space on the volume for the current process/user */ + sal_uInt64 uUsedSpace; +/** Free space on the volume for the current process/user */ + sal_uInt64 uFreeSpace; +/** Maximum length of file name of a single item */ + sal_uInt32 uMaxNameLength; +/** Maximum length of a full quallified path in UNC notation */ + sal_uInt32 uMaxPathLength; +/** Name of the file system type. Should be set to zero before calling <code>osl_getVolumeInformation</code> + and released after usage. */ + rtl_uString **pstrFileSystemName; +/** Handle of underlying device */ + oslVolumeDeviceHandle *pDeviceHandle; +} oslVolumeInfo; + + +/** Retrieves information about a volume. A volume can either be a mount point, a network + resource or a drive depending on operating system and file system. Before calling this + function <code>osl_getFileStatus</code> should be called to determine if the type is + <code>osl_file_Type_Volume</code>. + + @param strDirectory [in] Full qualified UNC path to the volume + @param pInfo [out] On success it receives information about the volume. + @param uFieldMask [in] Specifies which members of the structure should be filled + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_INVAL the format of the parameters was not valid<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_NOTDIR Not a directory<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_ACCES permission denied<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + ols_File_E_FAULT Bad address<br> + osl_File_E_IO I/O error<br> + osl_File_E_NOSYS Function not implemented<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_INTR function call was interrupted<p> + + @see osl_getFileStatus + @see oslVolumeInfo +*/ + +oslFileError SAL_CALL osl_getVolumeInformation( rtl_uString *strDirectory, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask ); + +typedef void *oslFileHandle; + +/* Open flags */ + +#define osl_File_OpenFlag_Read 0x00000001L +#define osl_File_OpenFlag_Write 0x00000002L +#define osl_File_OpenFlag_Create 0x00000004L + +/** Opens a file. + + @param strPath [in] Full qualified path to the file to open. Only regular files + can be openend. + @param pHandle [out] On success it receives a handle to the open file. + @param uFlags [in] Specifies the open mode. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NAMETOOLONG pathname was too long<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_ACCES permission denied<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_NOTDIR Not a directory<br> + osl_File_E_NXIO No such device or address<br> + osl_File_E_NODEV No such device<br> + osl_File_E_ROFS Read-only file system<br> + osl_File_E_TXTBSY Text file busy<br> + osl_File_E_FAULT Bad address<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_NOSPC No space left on device<br> + osl_File_E_ISDIR Is a directory<br> + osl_File_E_MFILE too many open files used by the process<br> + osl_File_E_NFILE too many open files in the system<br> + osl_File_E_DQUOT Quota exceeded<br> + osl_File_E_EXIST File exists<br> + osl_FilE_E_INTR function call was interrupted<br> + osl_File_E_IO I/O error<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_EOVERFLOW Value too large for defined data type<p> + + @see osl_closeFile + @see osl_setFilePos + @see osl_getFilePos + @see osl_readFile + @see osl_writeFile + @see osl_setFileSize + @see osl_createDirectoryItemFromHandle +*/ + +oslFileError SAL_CALL osl_openFile( rtl_uString *strPath, oslFileHandle *pHandle, sal_uInt32 uFlags ); + +#define osl_Pos_Absolut 1 +#define osl_Pos_Current 2 +#define osl_Pos_End 3 + +/** Sets the internal position pointer of an open file. + @param Handle [in] Handle of an open file received by a previous call to <code>osl_openFile</code>. + @param uHow [in] Distance to move the internal position pointer (from uPos). + @param uPos [in] Absolute position from the beginning of the file. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_OVERFLOW The resulting file offset would be a value which cannot + be represented correctly for regular files<p> + + @see osl_openFile + @see osl_getFilePos +*/ + +oslFileError SAL_CALL osl_setFilePos( oslFileHandle Handle, sal_uInt32 uHow, sal_uInt64 uPos ); + + +/** Retrieves the current position of the internal pointer of an open file. + @param Handle [in] Handle to an open file. + @param pPos [out] On Success it receives the current position of the file pointer. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_OVERFLOW The resulting file offset would be a value which cannot + be represented correctly for regular files<p> + + @see osl_openFile + @see osl_setFilePos + @see osl_readFile + @see osl_writeFile +*/ + +oslFileError SAL_CALL osl_getFilePos( oslFileHandle Handle, sal_uInt64 *pPos ); + + +/** Sets the file size of an open file. The file can be truncated or enlarged by the function. + The position of the file pointer is not affeced by this function. + @param Handle [in] Handle to an open file. + @param uSize [int] New size in bytes. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_OVERFLOW The resulting file offset would be a value which cannot + be represented correctly for regular files<p> + + @see osl_openFile + @see osl_setFilePos + @see osl_getFileStatus +*/ + +oslFileError SAL_CALL osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize ); + + +/** Reads a number of bytes from a file. The internal file pointer is increased by the number of bytes + read. + @param Handle [in] Handle to an open file. + @param pBuffer [out] Points to a buffer which receives data. The buffer must be large enough + to hold <code>uBytesRequested</code> bytes. + @param uBytesRequested [in] Number of bytes which should be retrieved. + @param pBytesRead [out] On success the number of bytes which have actually been retrieved. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_INTR function call was interrupted<br> + osl_File_E_IO I/O error<br> + osl_File_E_ISDIR Is a directory<br> + osl_File_E_BADF Bad file<br> + osl_File_E_FAULT Bad address<br> + osl_File_E_AGAIN Operation would block<br> + osl_File_E_NOLINK Link has been severed<p> + + @see osl_openFile + @see osl_writeFile + @see osl_setFilePos +*/ + +oslFileError SAL_CALL osl_readFile( oslFileHandle Handle, void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64 *pBytesRead ); + + +/** Writes a number of bytes to a file. The internal file pointer is increased by the number of bytes + read. + @param Handle [in] Handle to an open file. + @param pBuffer [int] Points to a buffer which contains the data. + @param uBytesToWrite [in] Number of bytes which should be written. + @param pBytesWritten [out] On success the number of bytes which have actually been written. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_FBIG File too large<br> + osl_File_E_DQUOT Quota exceeded<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_AGAIN Operation would block<br> + osl_File_E_BADF Bad file<br> + osl_File_E_FAULT Bad address<br> + osl_File_E_INTR function call was interrupted<br> + osl_File_E_IO I/O error<br> + osl_File_E_NOLCK No record locks available<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_NOSPC No space left on device<br> + osl_File_E_NXIO No such device or address<p> + + @see osl_openFile + @see osl_readFile + @see osl_setFilePos +*/ + +oslFileError SAL_CALL osl_writeFile( oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten ); + + +/** Closes an open file. + @param Handle [in] Handle to a file previously open by a call to <code>osl_openFile</code>. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_BADF Bad file<br> + osl_File_E_INTR function call was interrupted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_NOSPC No space left on device<br> + osl_File_E_IO I/O error<p> +*/ + +oslFileError SAL_CALL osl_closeFile( oslFileHandle Handle ); + + +/** Get a directory item handle from an open file with an initial refcount of 1. + @param Handle [in] A Hdnale to an open file. + @param pItem [out] On success it receives a handle to a directory item which can be used + in subsequent calls to <code>osl_getFileStatus</code>. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<p> + + @see osl_openFile + @see osl_getFileStatus + @see osl_acquireDirectoryItem + @see osl_releaseDirectoryItem +*/ + +oslFileError SAL_CALL osl_createDirectoryItemFromHandle( oslFileHandle Handle, oslDirectoryItem *pItem ); + + +/** Creates a directory. + @param strPatg [in] Full qualified UNC path of the directory to create. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_EXIST File exists<br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_NOTDIR Not a directory<br> + osl_File_E_ROFS Read-only file system<br> + osl_File_E_NOSPC No space left on device<br> + osl_File_E_DQUOT Quota exceeded<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_FAULT Bad address<br> + osl_FileE_IO I/O error<br> + osl_File_E_MLINK Too many links<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<p> + + @see osl_removeDirectory +*/ + +oslFileError SAL_CALL osl_createDirectory( rtl_uString* strPath ); + +/** Removes an empty directory. + + @param strPath [in] Full qualified UNC path of the directory. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_PERM Operation not permitted<br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_NOTDIR Not a directory<br> + osl_File_E_NOTEMPTY Directory not empty<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_FAULT Bad address<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_BUSY Device or resource busy<br> + osl_File_E_ROFS Read-only file system<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_BUSY Device or resource busy<br> + osl_File_E_EXIST File exists<br> + osl_File_E_IO I/O error<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<p> + + @see osl_createDirectory +*/ + +oslFileError SAL_CALL osl_removeDirectory( rtl_uString* strPath ); + + +/** Removes (erases) a regular file. + + @param strPath [in] Full qualified UNC path of the directory. + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_PERM Operation not permitted<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_ISDIR Is a directory<br> + osl_File_E_ROFS Read-only file system<p> + + These errorcodes can (eventually) be returned:<p> + osl_File_E_FAULT Bad address<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_IO I/O error<br> + osl_File_E_BUSY Device or resource busy<br> + osl_File_E_INTR function call was interrupted<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<br> + osl_File_E_TXTBSY Text file busy<p> +*/ + +oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath ); + + +/** Copies a file to a new destination. Copies only files not directories. No assumptions should + be made about preserving attributes or file time. + @param strPath [in] Full qualified UNC path of the source file. + @param strDestPath [in] Full qualified UNC path of the destination file. A directory is + NOT a valid destination file ! + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_PERM Operation not permitted<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_ISDIR Is a directory<br> + osl_File_E_ROFS Read-only file system<p> + + @see osl_moveFile + @see osl_removeFile + @see osl_createDirectory +*/ + +oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath ); + + +/** Moves a file or directory to a new destination or renames it. File time and attributes + are preserved. + @param strPath [in] Full qualified UNC path of the source file. + @param strDestPath [in] Full qualified UNC path of the destination file. An existing directory + is NOT a valid destination ! + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_PERM Operation not permitted<br> + osl_File_E_NAMETOOLONG File name too long<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_ROFS Read-only file system<p> + + @see osl_copyFile +*/ + +oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath ); + + +/** Determines a valid unused canonical name for a requested name. Depending on file system and operation system + the illegal characters are replaced by valid ones. If a file or directory with the requested name + already exists a new name is generated following the common rules on the actual file system and + operating system. + + @param strRequested [in] Requested name of a file or directory. + @param strValid [out] On success receives a name which is unused and valid on the actual operating system and + file system. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_getFileStatus +*/ + +oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *strRequested, rtl_uString **strValid); + + +/** Converts a path relative to a given directory into an full qualified UNC path. + + @param strDirBase [in] Base directory to which the relative path is related to. + @param strRelative[in] Path of a file or directory relative to the directory path + specified by <code>strDirBase</code>. + @param strAbsolute [out] On success it receives the full qualified UNC path of the + requested relative path. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOMEM not enough memory for allocating structures <br> + osl_File_E_NOTDIR Not a directory<br> + osl_File_E_ACCES Permission denied<br> + osl_File_E_NOENT No such file or directory<br> + osl_File_E_NAMETOOLONG File name too long<p> + + + These errorcodes can (eventually) be returned:<p> + osl_File_E_OVERFLOW Value too large for defined data type<p> + osl_File_E_FAULT Bad address<br> + osl_File_E_INTR function call was interrupted<br> + osl_File_E_LOOP Too many symbolic links encountered<br> + osl_File_E_MULTIHOP Multihop attempted<br> + osl_File_E_NOLINK Link has been severed<p> + + @see osl_getFileStatus +*/ + + +oslFileError SAL_CALL osl_getAbsolutePath( rtl_uString* strDirBase, rtl_uString *strRelative, rtl_uString **strAbsolute ); + + +/** Converts a system dependent path into a full qualified UNC path + + @param strSysPath[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_getCanonicalName + +*/ + +oslFileError SAL_CALL osl_normalizePath( rtl_uString *strSysPath, rtl_uString **strPath ); + + +/** Converts a File URL into a full qualified UNC path + + @param urlPath[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_normalizePath + +*/ + +oslFileError SAL_CALL osl_getNormalizedPathFromFileURL( rtl_uString *urlPath, rtl_uString **strPath ); + + +/** Converts a full qualified UNC path into a FileURL + + @param dir[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_normalizePath + @see osl_getNormalizedPathFromFileURL + +*/ + +oslFileError SAL_CALL osl_getFileURLFromNormalizedPath( rtl_uString *normPath, rtl_uString **strPath); + + +/** Searches a full qualified UNC-Path/File + + @param filePath[in] System dependent path / Normalized Path / File-URL or file or relative directory + @param searchPath[in] Paths, in which a given file has to be searched. These paths are only for the search of a + file or a relative path, otherwise it will be ignored. If it is set to NULL or while using the + search path the search failed the function searches for a matching file in all system directories and in the directories + listed in the PATH environment variable + @param strPath[out] On success it receives the full qualified UNC path + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOTDIR Not a directory<br> + osl_File_E_NOENT No such file or directory not found<br> + @see osl_normalizePath + +*/ + +/** Converts a full qualified UNC path into a system dependend path + + @param dir[in] Full qualified UNC path + @param strPath[out] On success it receives the system dependent path of a file or a directory + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_normalizePath + @see osl_getNormalizedPathFromFileURL + +*/ + +oslFileError SAL_CALL osl_getSystemPathFromNormalizedPath( rtl_uString *normPath, rtl_uString **strPath); + +oslFileError SAL_CALL osl_searchNormalizedPath( rtl_uString *filePath, rtl_uString *searchPath, rtl_uString **strPath ); + + +/** Sets file-attributes + + @param filePath[in] Path of the file + @param uAttributes[in] Attributes of the file to be set + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + @see osl_getFileStatus + +*/ + +oslFileError SAL_CALL osl_setFileAttributes( rtl_uString *filePath, sal_uInt64 uAttributes ); + + +/** Sets file-Time + + @param filePath[in] Path of the file + @param aCreationTime[in] creation time of the given file + @param aLastAccessTime[in] time of the last access of the given file + @param aLastWriteTime[in] time of the last modifying of the given file + + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + osl_File_E_NOENT No such file or directory not found<br> + @see osl_getFileStatus + +*/ + +oslFileError SAL_CALL osl_setFileTime( rtl_uString *filePath, TimeValue *aCreationTime, + TimeValue *aLastAccessTime, + TimeValue *aLastWriteTime); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_FILE_H_ */ + + diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx new file mode 100644 index 000000000000..b852debb57e8 --- /dev/null +++ b/sal/inc/osl/file.hxx @@ -0,0 +1,1408 @@ +/************************************************************************* + * + * $RCSfile: file.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_FILE_HXX_ +#define _OSL_FILE_HXX_ + +#ifdef __cplusplus + +#ifndef _RTL_MEMORY_H_ +# include <rtl/memory.h> +#endif + +#ifndef _RTL_USTRING_ +# include <rtl/ustring> +#endif + +#include <osl/file.h> +#include <osl/macros.hxx> + + +#ifdef _USE_NAMESPACE +namespace osl +{ +#endif + + +/** The VolumeInfo class + + @see Directory::getVolumeInfo +*/ + +#define VolumeInfoMask_Attributes osl_VolumeInfo_Mask_Attributes +#define VolumeInfoMask_TotalSpace osl_VolumeInfo_Mask_TotalSpace +#define VolumeInfoMask_UsedSpace osl_VolumeInfo_Mask_UsedSpace +#define VolumeInfoMask_FreeSpace osl_VolumeInfo_Mask_FreeSpace +#define VolumeInfoMask_MaxNameLength osl_VolumeInfo_Mask_MaxNameLength +#define VolumeInfoMask_MaxPathLength osl_VolumeInfo_Mask_MaxPathLengt +#define VolumeInfoMask_FileSystemName osl_VolumeInfo_Mask_FileSystemName + +class Directory; + +class VolumeInfo +{ + oslVolumeInfo _aInfo; + sal_uInt32 _nMask; + rtl_uString *_strFileSystemName; + + /** define copy c'tor and assginment operator privat + */ + + VolumeInfo( VolumeInfo& ); + VolumeInfo& operator = ( VolumeInfo& ); + +public: + + /** C'tor + + @param nMask set of flaggs decribing the demanded information. + */ + + VolumeInfo( sal_uInt32 nMask ): _nMask( nMask ) + { + _aInfo.uStructSize = sizeof( oslVolumeInfo ); + rtl_fillMemory( &_aInfo.uValidFields, sizeof( oslVolumeInfo ) - sizeof( sal_uInt32 ), 0 ); + _strFileSystemName=NULL; + _aInfo.pstrFileSystemName = &_strFileSystemName; + } + + /** D'tor + */ + + ~VolumeInfo() + { + if (_strFileSystemName!=NULL) + rtl_uString_release(_strFileSystemName); + } + + /** check if specified fields are valid + + @param set of flags for the fields to check + @return sal_True if all fields are valid, sal_False otherwise. + */ + + inline sal_Bool isValid( sal_uInt32 nMask ) const + { + return ( nMask & _aInfo.uValidFields ) == nMask; + } + + /** @return sal_True if Attributes are valid and the volume is remote, + sal_False otherwise. + */ + + inline sal_Bool getRemoteFlag() const + { + return (sal_Bool) (_aInfo.uAttributes & osl_Volume_Attribute_Remote); + } + + /** @return sal_True if attributes are valid and the volume is removable, + sal_False otherwise. + */ + + inline sal_Bool getRemoveableFlag() const + { + return (sal_Bool) (_aInfo.uAttributes & osl_Volume_Attribute_Removeable); + } + + /** @return the total diskspace of this volume if this information is valid, + 0 otherwise. + */ + + inline sal_uInt64 getTotalSpace() const + { + return _aInfo.uTotalSpace; + } + + /** @return the free diskspace of this volume if this information is valid, + 0 otherwise. + */ + + inline sal_uInt64 getFreeSpace() const + { + return _aInfo.uFreeSpace; + } + + /** @return the used diskspace of this volume if this information is valid, + 0 otherwise. + */ + + inline sal_uInt64 getUsedSpace() const + { + return _aInfo.uUsedSpace; + } + + /** @return the maximal length of a file name if this information is valid, + 0 otherwise. + */ + + inline sal_uInt32 getMaxNameLength() const + { + return _aInfo.uMaxNameLength; + } + + /** @return the maximal length of a path if this information is valid, + 0 otherwise. + */ + + inline sal_uInt32 getMaxPathLength() const + { + return _aInfo.uMaxPathLength; + } + + /** @return the name of the volume's fielsystem if this information is valid, + otherwise an empty string. + */ + + inline ::rtl::OUString getFileSystemName() const + { + return _strFileSystemName; + } + + friend class Directory; +}; + +// ----------------------------------------------------------------------------- + +/** The FileStatus class + + @see DirectoryItem::getFileStatus +*/ + +#define FileStatusMask_Type osl_FileStatus_Mask_Type +#define FileStatusMask_Attributes osl_FileStatus_Mask_Attributes +#define FileStatusMask_CreationTime osl_FileStatus_Mask_CreationTime +#define FileStatusMask_AccessTime osl_FileStatus_Mask_AccessTime +#define FileStatusMask_ModifyTime osl_FileStatus_Mask_ModifyTime +#define FileStatusMask_FileSize osl_FileStatus_Mask_FileSize +#define FileStatusMask_FileName osl_FileStatus_Mask_FileName +#define FileStatusMask_FilePath osl_FileStatus_Mask_FilePath +#define FileStatusMask_NativePath osl_FileStatus_Mask_NativePath +#define FileStatusMask_All osl_FileStatus_Mask_All +#define FileStatusMask_Validate osl_FileStatus_Mask_Validate + +#define Attribute_ReadOnly osl_File_Attribute_ReadOnly +#define Attribute_Hidden osl_File_Attribute_Hidden +#define Attribute_Executable osl_File_Attribute_Executable +#define Attribute_GrpWrite osl_File_Attribute_GrpWrite +#define Attribute_GrpRead osl_File_Attribute_GrpRead +#define Attribute_GrpExe osl_File_Attribute_GrpExe +#define Attribute_OwnWrite osl_File_Attribute_OwnWrite +#define Attribute_OwnRead osl_File_Attribute_OwnRead +#define Attribute_OwnExe osl_File_Attribute_OwnExe +#define Attribute_OthWrite osl_File_Attribute_OthWrite +#define Attribute_OthRead osl_File_Attribute_OthRead +#define Attribute_OthExe osl_File_Attribute_OthExe + +class DirectoryItem; + +class FileStatus +{ + oslFileStatus _aStatus; + sal_uInt32 _nMask; + rtl_uString *_strNativePath; + rtl_uString *_strFilePath; + + /** define copy c'tor and assginment operator privat + */ + + FileStatus( FileStatus& ); + FileStatus& operator = ( FileStatus& ); + +public: + + enum Type { + Directory = osl_File_Type_Directory, + Volume = osl_File_Type_Volume, + Regular = osl_File_Type_Regular, + Fifo = osl_File_Type_Fifo, + Socket = osl_File_Type_Socket, + Link = osl_File_Type_Link, + Special = osl_File_Type_Special, + Unknown = osl_File_Type_Unknown + }; + + /** C'tor + + @param nMask set of flaggs decribing the demanded information. + */ + + FileStatus( sal_uInt32 nMask ): _nMask( nMask ), _strNativePath( NULL ), _strFilePath( NULL ) + { + _aStatus.uStructSize = sizeof( oslFileStatus ); + rtl_fillMemory( &_aStatus.uValidFields, sizeof( oslFileStatus ) - sizeof( sal_uInt32 ), 0 ); + _aStatus.pstrNativePath = &_strNativePath; + _aStatus.pstrFilePath = &_strFilePath; + } + + /** D'tor + */ + + ~FileStatus() + { + if ( _strFilePath ) + rtl_uString_release( _strFilePath ); + if ( _strNativePath ) + rtl_uString_release( _strNativePath ); + if ( _aStatus.strFileName ) + rtl_uString_release( _aStatus.strFileName ); + } + + /** check if specified fields are valid + + @param set of flags for the fields to check + @return sal_True if all fields are valid, sal_False otherwise. + */ + inline sal_Bool isValid( sal_uInt32 nMask ) const + { + return ( nMask & _aStatus.uValidFields ) == nMask; + } + + /** @return the file type if this information is valid, + Unknown otherwise. + */ + inline Type getFileType() const + { + return (_aStatus.uValidFields & FileStatusMask_Type) ? (Type) _aStatus.eType : Unknown; + } + + /** @return the set of attribute flags of this file + */ + + inline sal_uInt64 getAttributes() const + { + return _aStatus.uAttributes; + } + + /** @return the creation time if this information is valid, + an uninitialized TimeValue otherwise. + */ + + inline TimeValue getCreationTime() const + { + return _aStatus.aCreationTime; + } + + /** @return the last access time if this information is valid, + an uninitialized TimeValue otherwise. + */ + + inline TimeValue getAccessTime() const + { + return _aStatus.aAccessTime; + } + + /** @return the last modified time if this information is valid, + an uninitialized TimeValue otherwise. + */ + + inline TimeValue getModifyTime() const + { + return _aStatus.aModifyTime; + } + + /** @return the actual file size if this information is valid, + 0 otherwise. + */ + + inline sal_uInt64 getFileSize() const + { + return _aStatus.uFileSize; + } + + /** @return the file name if this information is valid, an empty + string otherwise. + */ + + inline ::rtl::OUString getFileName() const + { + return _aStatus.strFileName ? ::rtl::OUString(_aStatus.strFileName) : ::rtl::OUString(); + } + + /** @return the file path in UNC notation if this information is valid, + an empty string otherwise. + */ + + inline ::rtl::OUString getFilePath() const + { + return _strFilePath ? ::rtl::OUString(_strFilePath) : ::rtl::OUString(); + } + + /** @return the file path in host notation if this information is valid, + an empty string otherwise. + */ + + inline ::rtl::OUString getNativePath() const + { + return _strNativePath ? ::rtl::OUString(_strNativePath) : ::rtl::OUString(); + } + + friend class DirectoryItem; +}; + +// ----------------------------------------------------------------------------- + +/** Base class for all filesystem specific objects + + @see Directory + @see DirectoryItem + @see File + */ + +class FileBase +{ +public: + + enum RC { + E_None = osl_File_E_None, + E_PERM = osl_File_E_PERM, + E_NOENT = osl_File_E_NOENT, + E_SRCH = osl_File_E_SRCH, + E_INTR = osl_File_E_INTR, + E_IO = osl_File_E_IO, + E_NXIO = osl_File_E_NXIO, + E_2BIG = osl_File_E_2BIG, + E_NOEXEC = osl_File_E_NOEXEC, + E_BADF = osl_File_E_BADF, + E_CHILD = osl_File_E_CHILD, + E_AGAIN = osl_File_E_AGAIN, + E_NOMEM = osl_File_E_NOMEM, + E_ACCES = osl_File_E_ACCES, + E_FAULT = osl_File_E_FAULT, + E_BUSY = osl_File_E_BUSY, + E_EXIST = osl_File_E_EXIST, + E_XDEV = osl_File_E_XDEV, + E_NODEV = osl_File_E_NODEV, + E_NOTDIR = osl_File_E_NOTDIR, + E_ISDIR = osl_File_E_ISDIR, + E_INVAL = osl_File_E_INVAL, + E_NFILE = osl_File_E_NFILE, + E_MFILE = osl_File_E_MFILE, + E_NOTTY = osl_File_E_NOTTY, + E_FBIG = osl_File_E_FBIG, + E_NOSPC = osl_File_E_NOSPC, + E_SPIPE = osl_File_E_SPIPE, + E_ROFS = osl_File_E_ROFS, + E_MLINK = osl_File_E_MLINK, + E_PIPE = osl_File_E_PIPE, + E_DOM = osl_File_E_DOM, + E_RANGE = osl_File_E_RANGE, + E_DEADLK = osl_File_E_DEADLK, + E_NAMETOOLONG = osl_File_E_NAMETOOLONG, + E_NOLCK = osl_File_E_NOLCK, + E_NOSYS = osl_File_E_NOSYS, + E_NOTEMPTY = osl_File_E_NOTEMPTY, + E_LOOP = osl_File_E_LOOP, + E_ILSEQ = osl_File_E_ILSEQ, + E_NOLINK = osl_File_E_NOLINK, + E_MULTIHOP = osl_File_E_MULTIHOP, + E_USERS = osl_File_E_USERS, + E_OVERFLOW = osl_File_E_OVERFLOW, + E_invalidError = osl_File_E_invalidError /* unmapped error: always last entry in enum! */ + }; + + +public: + + /** Determines a valid unused canonical name for a requested name. Depending on file system and operation system + the illegal characters are replaced by valid ones. If a file or directory with the requested name + already exists a new name is generated following the common rules on the actual file system and + operating system. + + @param strRequested [in] Requested name of a file or directory. + @param strValid [out] On success receives a name which is unused and valid on the actual operating system and + file system. + + @return osl_File_E_None on success otherwise one of the following errorcodes:<p> + osl_File_E_INVAL the format of the parameters was not valid<br> + + @see osl_getFileStatus + */ + + static inline RC getCanonicalName( const ::rtl::OUString& strRequested, ::rtl::OUString& strValid ) + { + return (RC) osl_getCanonicalName( strRequested.pData, &strValid.pData ); + } + + /** Converts a path relative to a given directory into an full qualified UNC path. + + @param strDirBase [in] Base directory to which the relative path is related to. + @param strRelative[in] Path of a file or directory relative to the directory path + specified by <code>strDirBase</code>. + @param strAbsolute [out] On success it receives the full qualified UNC path of the + requested relative path. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_NOTDIR Not a directory<br> + E_ACCES Permission denied<br> + E_NOENT No such file or directory<br> + E_NAMETOOLONG File name too long<p> + + + These errorcodes can (eventually) be returned:<p> + E_OVERFLOW Value too large for defined data type<p> + E_FAULT Bad address<br> + E_INTR function call was interrupted<br> + E_LOOP Too many symbolic links encountered<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<p> + + @see getStatus + */ + + static inline RC getAbsolutePath( const ::rtl::OUString& strDirBase, const ::rtl::OUString& strRelative, ::rtl::OUString& strAbsolute ) + { + return (RC) osl_getAbsolutePath( strDirBase.pData, strRelative.pData, &strAbsolute.pData ); + } + + /** Converts a system dependent path into a full qualified UNC path + + @param strSysPath[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see getCanonicalName + */ + + static inline RC normalizePath( const ::rtl::OUString& strSysPath, ::rtl::OUString& strPath ) + { + return (RC) osl_normalizePath( strSysPath.pData, &strPath.pData ); + } + + /** Converts a File URL into a full qualified UNC path + + @param urlPath[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see normalizePath + */ + + static inline RC getNormalizedPathFromFileURL( const ::rtl::OUString& strPath, ::rtl::OUString& normPath ) + { + return (RC) osl_getNormalizedPathFromFileURL( strPath.pData, &normPath.pData ); + } + + /** Converts a full qualified UNC path into a FileURL + + @param dir[in] System dependent path of a file or a directory + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see normalizePath + @see getNormalizedPathFromFileURL + */ + + static inline RC getFileURLFromNormalizedPath( const ::rtl::OUString& normPath, ::rtl::OUString& strPath ) + { + return (RC) osl_getFileURLFromNormalizedPath( normPath.pData, &strPath.pData ); + } + + /** Converts a full qualified UNC path into a system depended path + + @param dir[in] Full qualified UNC path + @param strPath[out] On success it receives the System dependent path of a file or a directory + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + @see normalizePath + @see getNormalizedPathFromFileURL + */ + + static inline RC getSystemPathFromNormalizedPath( const ::rtl::OUString& normPath, ::rtl::OUString& strPath ) + { + return (RC)osl_getSystemPathFromNormalizedPath( normPath.pData, &strPath.pData ); + } + + /** Searches a full qualified UNC-Path/File + + @param filePath[in] System dependent path / Normalized Path / File-URL or file or relative directory + @param searchPath[in] Paths, in which a given file has to be searched. These paths are only for the search of a + file or a relative path, otherwise it will be ignored. If it is set to NULL or while using the + search path the search failed the function searches for a matching file in all system directories and in the directories + listed in the PATH environment variable + @param strPath[out] On success it receives the full qualified UNC path + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOTDIR Not a directory<br> + E_NOENT No such file or directory not found<br> + @see normalizePath + */ + + static inline RC searchNormalizedPath( const ::rtl::OUString& filePath, const ::rtl::OUString& searchPath, ::rtl::OUString& strPath ) + { + return (RC) osl_searchNormalizedPath( filePath.pData, searchPath.pData, &strPath.pData ); + } +}; + +// ----------------------------------------------------------------------------- + +/** The VolumeDevice class + + @see VolumeInfo +*/ + +class VolumeDevice : public FileBase +{ + oslVolumeDeviceHandle _aHandle; + +public: + VolumeDevice() : _aHandle( NULL ) + { + } + + VolumeDevice( const VolumeDevice & rDevice ) + { + _aHandle = rDevice._aHandle; + if ( _aHandle ) + osl_acquireVolumeDeviceHandle( _aHandle ); + } + + ~VolumeDevice() + { + if ( _aHandle ) + osl_releaseVolumeDeviceHandle( _aHandle ); + } + + + inline VolumeDevice & operator =( const VolumeDevice & rDevice ) + { + oslVolumeDeviceHandle newHandle = rDevice._aHandle; + + if ( newHandle ) + osl_acquireVolumeDeviceHandle( _aHandle ); + + if ( _aHandle ) + osl_releaseVolumeDeviceHandle( _aHandle ); + + _aHandle = newHandle; + + return *this; + } + + inline RC automount() + { + return (RC)osl_automountVolumeDevice( _aHandle ); + } + + inline RC unmount() + { + return (RC)osl_unmountVolumeDevice( _aHandle ); + } + + inline rtl::OUString getMountPath() + { + rtl::OUString aPath; + osl_getVolumeDeviceMountPath( _aHandle, &aPath.pData ); + return aPath; + } + + friend class VolumeInfo; +}; + +// ----------------------------------------------------------------------------- + +/** The file class object provides access to file contents and attributes + + @see Directory + @see DirectoryItem + */ + +class File: public FileBase +{ + oslFileHandle _pData; + ::rtl::OUString _aPath; + + /** define copy c'tor and assginment operator privat + */ + + File( File& ); + File& operator = ( File& ); + +public: + + /** C'tor + + @param strPath [in] The full qualified path of the file in UNC notation. + The path delimiter is '/'. Relative paths are not allowed. + */ + + File( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath ) {}; + + /** D'tor + */ + + inline ~File() + { + close(); + } + + /** Opens a file. + @param uFlags [in] Specifies the open mode. + @return E_None on success otherwise one of the following errorcodes:<p> + E_NOMEM not enough memory for allocating structures <br> + E_INVAL the format of the parameters was not valid<br> + E_NAMETOOLONG pathname was too long<br> + E_NOENT No such file or directory<br> + E_ACCES permission denied<P> + E_ISDIR Is a directory<p> + + These errorcodes can (eventually) be returned:<p> + E_NOTDIR Not a directory<br> + E_NXIO No such device or address<br> + E_NODEV No such device<br> + E_ROFS Read-only file system<br> + E_TXTBSY Text file busy<br> + E_ISDIR Is a directory<br> + E_FAULT Bad address<br> + E_LOOP Too many symbolic links encountered<br> + E_NOSPC No space left on device<br> + E_MFILE too many open files used by the process<br> + E_NFILE too many open files in the system<br> + E_DQUOT Quota exceeded<br> + E_EXIST File exists<br> + E_INTR function call was interrupted<br> + E_IO I/O error<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<br> + E_EOVERFLOW Value too large for defined data type<p> + + @see close + @see setPos + @see getPos + @see read + @see write + @see setSize + */ + + #define OpenFlag_Read osl_File_OpenFlag_Read + #define OpenFlag_Write osl_File_OpenFlag_Write + #define OpenFlag_Create osl_File_OpenFlag_Create + + inline RC open( sal_uInt32 uFlags ) + { + return (RC) osl_openFile( _aPath.pData, &_pData, uFlags ); + } + + /** Closes an open file. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<p> + + These errorcodes can (eventually) be returned:<p> + E_BADF Bad file<br> + E_INTR function call was interrupted<br> + E_NOLINK Link has been severed<br> + E_NOSPC No space left on device<br> + E_IO I/O error<p> + */ + + inline RC close() + { + oslFileError Error = osl_File_E_BADF; + + if( _pData ) + { + Error=osl_closeFile( _pData ); + _pData = NULL; + } + + return (RC) Error; + }; + + + /** Sets the internal position pointer of an open file. + @param uHow [in] Distance to move the internal position pointer (from uPos). + @param uPos [in] Absolute position from the beginning of the file. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_OVERFLOW The resulting file offset would be a value which cannot + be represented correctly for regular files<p> + + @see open + @see getPos + */ + + #define Pos_Absolut osl_Pos_Absolut + #define Pos_Current osl_Pos_Current + #define Pos_End osl_Pos_End + + inline RC setPos( sal_uInt32 uHow, sal_uInt64 uPos ) + { + return (RC) osl_setFilePos( _pData, uHow, uPos ); + } + + /** Retrieves the current position of the internal pointer of an open file. + @param pPos [out] On Success it receives the current position of the file pointer. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_OVERFLOW The resulting file offset would be a value which cannot + be represented correctly for regular files<p> + + @see open + @see setPos + @see read + @see write + */ + + inline RC getPos( sal_uInt64& uPos ) + { + return (RC) osl_getFilePos( _pData, &uPos ); + } + + + /** Sets the file size of an open file. The file can be truncated or enlarged by the function. + The position of the file pointer is not affeced by this function. + @param uSize [int] New size in bytes. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_OVERFLOW The resulting file offset would be a value which cannot + be represented correctly for regular files<p> + + @see open + @see setPos + @see getStatus + */ + + inline RC setSize( sal_uInt64 uSize ) + { + return (RC) osl_setFileSize( _pData, uSize ); + } + + /** Reads a number of bytes from a file. The internal file pointer is increased by the number of bytes + read. + @param pBuffer [out] Points to a buffer which receives data. The buffer must be large enough + to hold <code>uBytesRequested</code> bytes. + @param uBytesRequested [in] Number of bytes which should be retrieved. + @param rBytesRead [out] On success the number of bytes which have actually been retrieved. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + + These errorcodes can (eventually) be returned:<p> + E_INTR function call was interrupted<br> + E_IO I/O error<br> + E_ISDIR Is a directory<br> + E_BADF Bad file<br> + E_FAULT Bad address<br> + E_AGAIN Operation would block<br> + E_NOLINK Link has been severed<p> + + @see open + @see write + @see setPos + */ + + inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead ) + { + return (RC) osl_readFile( _pData, pBuffer, uBytesRequested, &rBytesRead ); + } + + /** Writes a number of bytes to a file. The internal file pointer is increased by the number of bytes + read. + @param pBuffer [in] Points to a buffer which contains the data. + @param uBytesToWrite [in] Number of bytes which should be written. + @param rBytesWritten [out] On success the number of bytes which have actually been written. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_FBIG File too large<br> + E_DQUOT Quota exceeded<p> + + These errorcodes can (eventually) be returned:<p> + E_AGAIN Operation would block<br> + E_BADF Bad file<br> + E_FAULT Bad address<br> + E_INTR function call was interrupted<br> + E_IO I/O error<br> + E_NOLCK No record locks available<br> + E_NOLINK Link has been severed<br> + E_NOSPC No space left on device<br> + E_NXIO No such device or address<p> + + @see openFile + @see readFile + @see setFilePos + */ + + inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten) + { + return (RC) osl_writeFile( _pData, pBuffer, uBytesToWrite, &rBytesWritten ); + } + + /** Copies a file to a new destination. Copies only files not directories. No assumptions should + be made about preserving attributes or file time. + @param strPath [in] Full qualified UNC path of the source file. + @param strDestPath [in] Full qualified UNC path of the destination file. A directory is + NOT a valid destination file ! + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_ACCES Permission denied<br> + E_PERM Operation not permitted<br> + E_NAMETOOLONG File name too long<br> + E_NOENT No such file or directory<br> + E_ISDIR Is a directory<br> + E_ROFS Read-only file system<p> + + @see move + @see remove + */ + inline static RC copy( const ::rtl::OUString& strPath, const ::rtl::OUString& strDestPath ) + { + return (RC) osl_copyFile( strPath.pData, strDestPath.pData ); + } + + /** Moves a file or directory to a new destination or renames it. File time and attributes + are preserved. + @param strPath [in] Full qualified UNC path of the source file. + @param strDestPath [in] Full qualified UNC path of the destination file. An existing directory + is NOT a valid destination ! + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_ACCES Permission denied<br> + E_PERM Operation not permitted<br> + E_NAMETOOLONG File name too long<br> + E_NOENT No such file or directory<br> + E_ROFS Read-only file system<p> + + @see copy + */ + + inline static RC move( const ::rtl::OUString& strPath, const ::rtl::OUString& strDestPath ) + { + return (RC) osl_moveFile( strPath.pData, strDestPath.pData ); + } + + /** Removes (erases) a regular file. + + @param strPath [in] Full qualified UNC path of the directory. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_ACCES Permission denied<br> + E_PERM Operation not permitted<br> + E_NAMETOOLONG File name too long<br> + E_NOENT No such file or directory<br> + E_ISDIR Is a directory<br> + E_ROFS Read-only file system<p> + + These errorcodes can (eventually) be returned:<p> + E_FAULT Bad address<br> + E_LOOP Too many symbolic links encountered<br> + E_IO I/O error<br> + E_BUSY Device or resource busy<br> + E_INTR function call was interrupted<br> + E_LOOP Too many symbolic links encountered<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<br> + E_TXTBSY Text file busy<p> + */ + + inline static RC remove( const ::rtl::OUString& strPath ) + { + return (RC) osl_removeFile( strPath.pData ); + } + + /** Sets file-attributes + + @param filePath[in] Path of the file + @param uAttributes[in] Attributes of the file to be set + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + @see getStatus + */ + + inline static RC setAttributes( const ::rtl::OUString& strPath, sal_uInt64 uAttributes ) + { + return (RC) osl_setFileAttributes( strPath.pData, uAttributes ); + } + + /** Sets file-Time + + @param filePath[in] Path of the file + @param aCreationTime[in] creation time of the given file + @param aLastAccessTime[in] time of the last access of the given file + @param aLastWriteTime[in] time of the last modifying of the given file + + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOENT No such file or directory not found<br> + @see getStatus + */ + + inline static RC setTime( const ::rtl::OUString& strPath, TimeValue& rCreationTime, + TimeValue& rLastAccessTime, + TimeValue& rLastWriteTime ) + { + return (RC) osl_setFileTime( strPath.pData, &rCreationTime, + &rLastAccessTime, + &rLastWriteTime ); + } + + friend class DirectoryItem; +}; + +// ----------------------------------------------------------------------------- + +/** The directory item class object provides access to file status information. + + @see FileStatus + */ + +class DirectoryItem: public FileBase +{ + oslDirectoryItem _pData; + + +public: + + /** default c'tor + */ + + DirectoryItem(): _pData( NULL ) + { + } + + /** Copy C'tor + */ + + DirectoryItem( DirectoryItem& rItem ): _pData( rItem._pData) + { + osl_acquireDirectoryItem( _pData ); + } + + + /** D'tor + */ + + ~DirectoryItem() + { + if( _pData ) + osl_releaseDirectoryItem( _pData ); + } + + /** assignment operator + */ + + DirectoryItem& operator = ( DirectoryItem& rItem ) + { + if( _pData ) + osl_releaseDirectoryItem( _pData ); + + _pData = rItem._pData; + osl_acquireDirectoryItem( _pData ); + return *this; + }; + + /** @return sal_True if object is valid directory item, + sal_False otherwise. + */ + + inline sal_Bool is() + { + return _pData != NULL; + } + + /** fills a single directory item object + + @param strFilePath [in] absolute file path following the notation explained in the documentation for + <code>osl_openDirectory</code>. Due to performance issues it is not recommended to use this function + while enumerating the contents of a directory. In this case use <code>osl_getNextDirectoryItem</code> instead. + @param rItem [out] on success it receives a valid directory item object. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_ACCES permission denied<br> + E_MFILE too many open files used by the process<br> + E_NFILE too many open files in the system<br> + E_NOENT No such file or directory<br> + E_LOOP Too many symbolic links encountered<br> + E_NAMETOOLONG File name too long<br> + E_NOTDIR A component of the path prefix of path is not a directory<p> + + These errorcodes can (eventually) be returned:<p> + E_IO I/O error<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<br> + E_FAULT Bad address<br> + E_INTR function call was interrupted<p> + + + @see getFileStatus + @see Directory::getNextItem + */ + + static inline RC get( const ::rtl::OUString& strPath, DirectoryItem& rItem ) + { + if( rItem._pData) + osl_releaseDirectoryItem( rItem._pData ); + + return (RC) osl_getDirectoryItem( strPath.pData, &rItem._pData ); + } + + /** Get a directory item handle from an open file. + @param rItem [out] On success it receives a handle to a directory item which can be used + in subsequent calls to <code>getStatus</code>. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<p> + + @see File + @see getStatus + */ + + static inline RC get( const File& rFile, DirectoryItem& rItem ) + { + if( rItem._pData) + osl_releaseDirectoryItem( rItem._pData ); + + return (RC) osl_createDirectoryItemFromHandle( rFile._pData, &rItem._pData ); + } + + + /** Retrieves information about a single file or directory + + @param rStatus [in/out] reference of FileStatus class object that should be filled. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_NOMEM not enough memory for allocating structures <br> + E_INVAL the format of the parameters was not valid<br> + E_LOOP Too many symbolic links encountered<br> + E_ACCES Permission denied<br> + E_NOENT No such file or directory<br> + E_NAMETOOLONG file name too long<p> + + These errorcodes can (eventually) be returned:<p> + E_BADF Invalid oslDirectoryItem parameter<br> + E_FAULT Bad address<br> + E_OVERFLOW Value too large for defined data type<br> + E_INTR function call was interrupted<br> + E_NOLINK Link has been severed<br> + E_MULTIHOP Components of path require hopping to multiple remote machines and the file system does not allow it<br> + E_MFILE too many open files used by the process<br> + E_NFILE too many open files in the system<br> + E_NOSPC No space left on device<br> + E_NXIO No such device or address<br> + E_IO I/O error<br> + E_NOSYS Function not implemented<p> + + @see DirectoryItem::get + @see Directory::getNextItem + */ + + inline RC getFileStatus( FileStatus& rStatus ) + { + return (RC) osl_getFileStatus( _pData, &rStatus._aStatus, rStatus._nMask ); + } + + friend class Directory; +}; + +// ----------------------------------------------------------------------------- + +/** The directory class object provides a enumeration of DirectoryItems. + + @see DirectoryItem + @see File + */ + +class Directory: public FileBase +{ + oslDirectory _pData; + ::rtl::OUString _aPath; + + /** define copy c'tor and assginment operator privat + */ + Directory( Directory& ); + Directory& operator = ( Directory& ); + + +public: + + /** C'tor + + @param strPath [in] The full qualified path of the directory in UNC notation. + The path delimiter is '/'. Relative paths are not allowed. + */ + + Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath ) + { + }; + + /** D'tor + */ + + ~Directory() + { + close(); + } + + /** Opens a directory for enumerating its contents. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOENT the specified path doesn't exist<br> + E_NOTDIR the specified path is not an directory <br> + E_NOMEM not enough memory for allocating structures <br> + E_ACCES permission denied<br> + E_MFILE too many open files used by the process<br> + E_NFILE too many open files in the system<br> + E_NAMETOOLONG File name too long<br> + E_LOOP Too many symbolic links encountered<p> + + @see getNextItem + @see close + */ + + inline RC open() + { + return (RC) osl_openDirectory( _aPath.pData, &_pData ); + } + + /** query if directory item enumeration is valid. + + @return sal_True if enumeration is valid (opened), sal_False otherwise + + @see open + @see close + */ + + inline sal_Bool isOpen() { return _pData != NULL; }; + + /** closes a directory item enumeration + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <p> + + These errorcodes can (eventually) be returned:<p> + E_BADF Invalid oslDirectory parameter<br> + E_INTR function call was interrupted<p> + + @see open + */ + + inline RC close() + { + oslFileError Error = osl_File_E_BADF; + + if( _pData ) + { + Error=osl_closeDirectory( _pData ); + _pData = NULL; + } + + return (RC) Error; + } + + + /** resets the directory item enumeration to the beginning. + + @return the same as open + @see open + */ + + inline RC reset() + { + close(); + return open(); + } + + /** Retrieves the next item of a previously openend directory + @param rItem [out] The class that receives the next item's data. + @param nHint [in] With this parameter the caller can tell the implementation that one + is going to call this function uHint times afterwards. This enables the implementation to + get the information for more than one file and cache it until the next calls. + + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_NOENT No more entries in this directory<p> + + These errorcodes can (eventually) be returned:<p> + E_BADF oslDirectory parameter is not valid<br> + E_OVERFLOW Value too large for defined data type<p> + + @see DirectoryItem::get + */ + + inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 ) + { + return ( RC) osl_getNextDirectoryItem( _pData, &rItem._pData, nHint ); + } + + /** Retrieves information about a volume. A volume can either be a mount point, a network + resource or a drive depending on operating system and file system. Before calling this + function <code>File::getStatus</code> should be called to determine if the type is + <code>Type_Volume</code>. + + @param strDirectory [in] Full qualified UNC path to the volume + @param rInfo [out] On success it receives information about the volume. + @return E_None on success otherwise one of the following errorcodes:<p> + E_NOMEM not enough memory for allocating structures <br> + E_INVAL the format of the parameters was not valid<p> + + These errorcodes can (eventually) be returned:<p> + E_NOTDIR Not a directory<br> + E_NAMETOOLONG File name too long<br> + E_NOENT No such file or directory<br> + E_ACCES permission denied<br> + E_LOOP Too many symbolic links encountered<br> + E_FAULT Bad address<br> + E_IO I/O error<br> + E_NOSYS Function not implemented<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<br> + E_INTR function call was interrupted<p> + + @see getFileStatus + @see VolumeInfo + */ + + inline static RC getVolumeInfo( const ::rtl::OUString& strPath, VolumeInfo& rInfo ) + { + return (RC) osl_getVolumeInformation( strPath.pData, &rInfo._aInfo, rInfo._nMask ); + } + + /** Creates a directory. + + @param strPath [in] Full qualified UNC path of the directory to create. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_EXIST File exists<br> + E_ACCES Permission denied<br> + E_NAMETOOLONG File name too long<br> + E_NOENT No such file or directory<br> + E_NOTDIR Not a directory<br> + E_ROFS Read-only file system<br> + E_NOSPC No space left on device<br> + E_DQUOT Quota exceeded<p> + + These errorcodes can (eventually) be returned:<p> + E_LOOP Too many symbolic links encountered<br> + E_FAULT Bad address<br> + E_IO I/O error<br> + E_MLINK Too many links<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<p> + + @see remove + */ + + inline static RC create( const ::rtl::OUString& strPath ) + { + return (RC) osl_createDirectory( strPath.pData ); + } + + /** Removes an empty directory. + + @param strPath [in] Full qualified UNC path of the empty directory to remove. + @return E_None on success otherwise one of the following errorcodes:<p> + E_INVAL the format of the parameters was not valid<br> + E_NOMEM not enough memory for allocating structures <br> + E_PERM Operation not permitted<br> + E_ACCES Permission denied<br> + E_NOENT No such file or directory<br> + E_NOTDIR Not a directory<br> + E_NOTEMPTY Directory not empty<p> + + These errorcodes can (eventually) be returned:<p> + E_FAULT Bad address<br> + E_NAMETOOLONG File name too long<br> + E_BUSY Device or resource busy<br> + E_ROFS Read-only file system<br> + E_LOOP Too many symbolic links encountered<br> + E_BUSY Device or resource busy<br> + E_EXIST File exists<br> + E_IO I/O error<br> + E_MULTIHOP Multihop attempted<br> + E_NOLINK Link has been severed<p> + + @see create + */ + + inline static RC remove( const ::rtl::OUString& strPath ) + { + return (RC) osl_removeDirectory( strPath.pData ); + } +}; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _OSL_FILE_HXX_ */ + diff --git a/sal/inc/osl/interlck.h b/sal/inc/osl/interlck.h new file mode 100644 index 000000000000..ca149802b026 --- /dev/null +++ b/sal/inc/osl/interlck.h @@ -0,0 +1,93 @@ +/************************************************************************* + * + * $RCSfile: interlck.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_INTERLOCK_H_ +#define _OSL_INTERLOCK_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef sal_Int32 oslInterlockedCount; + +/** Increments the count variable addressed by pCount. + @param Address of counter variable + @return The result of the operation is zero, the value of the count variable. +*/ +oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount); + +/** Decrement the count variable addressed by pCount. + @param Address of counter variable + @return The result of the operation is the new value is of the count variable. +*/ +oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_INTERLOCK_H_ */ + + diff --git a/sal/inc/osl/module.h b/sal/inc/osl/module.h new file mode 100644 index 000000000000..3d79af0d3742 --- /dev/null +++ b/sal/inc/osl/module.h @@ -0,0 +1,165 @@ +/************************************************************************* + * + * $RCSfile: module.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_MODULE_H_ +#define _OSL_MODULE_H_ + +#ifndef _RTL_USTRING_H +# include <rtl/ustring.h> +#endif + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifndef _RTL_TENCINFO_H +# include <rtl/tencinfo.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +#define SAL_LOADMODULE_DEFAULT 0x00000 +#define SAL_LOADMODULE_LAZY 0x00001 +#define SAL_LOADMODULE_NOW 0x00002 +#define SAL_LOADMODULE_GLOBAL 0x00100 + + +typedef void* oslModule; + + +/** Load a module.<BR> + @param strModuleName denotes the name of the module to be loaded. + @return 0 if the module could not be loaded, otherwise a handle to the module. +*/ +oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode); + +/** Release the Module +*/ +void SAL_CALL osl_unloadModule(oslModule Module); + +/** lookup the specified symbolname. + @returns address of the symbol or 0 if lookup failed, +*/ +void* SAL_CALL osl_getSymbol(oslModule Module, rtl_uString *strSymbolName); + +/** ascii interface for internal use. + @returns address of the symbol or 0 if lookup failed, +*/ +void* SAL_CALL osl_getSymbolA(oslModule Module, const char *pszSymbolName); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_MODULE_H_ */ + + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.8 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.7 2000/05/17 14:30:14 mfe +* comments upgraded +* +* Revision 1.6 2000/03/31 15:55:56 rs +* UNICODE-Changes +* +* Revision 1.5 2000/03/16 16:43:52 obr +* Unicode API changes +* +* Revision 1.4 2000/01/06 11:46:32 mfe +* #71540# : for incompatible z'en +* +* Revision 1.3 2000/01/04 14:07:19 mfe +* osl_loadModule takes 2nd parameter +* +* Revision 1.2 1999/10/27 15:02:07 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:19 jsc +* verschoben aus osl +* +* Revision 1.6 1999/08/05 11:14:35 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.5 1999/01/20 18:53:40 jsc +* #61011# Typumstellung +* +* Revision 1.4 1998/02/16 19:34:51 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.3 1997/07/31 15:28:38 ts +* *** empty log message *** +* +* Revision 1.2 1997/07/17 11:02:27 rh +* Header adapted and profile added +* +* Revision 1.1 1997/07/03 10:04:31 rh +* Module handling added +* +*************************************************************************/ + diff --git a/sal/inc/osl/mutex.h b/sal/inc/osl/mutex.h new file mode 100644 index 000000000000..4958a2f4b033 --- /dev/null +++ b/sal/inc/osl/mutex.h @@ -0,0 +1,145 @@ +/************************************************************************* + * + * $RCSfile: mutex.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_MUTEX_H_ +#define _OSL_MUTEX_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct _oslMutexImpl; +typedef struct _oslMutexImpl * oslMutex; + +/** Create a thread-local mutex. + @return 0 if the mutex could not be created, otherwise a handle to the mutex. +*/ +oslMutex SAL_CALL osl_createMutex(void); + +/** Release the OS-structures and free mutex data-structure. + @param Mutex the mutex-handle +*/ +void SAL_CALL osl_destroyMutex(oslMutex Mutex); + +/** Acquire the mutex, block if already acquired by another thread. + @param Mutex handle to a created mutex. + @return False if system-call fails. +*/ +sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex); + +/** Try to acquire the mutex without blocking. + @param Mutex handle to a created mutex. + @return False if it could not be acquired. +*/ +sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex); + +/** Release the mutex. + @param Mutex handle to a created mutex. + @return False if system-call fails. +*/ +sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex); + +oslMutex * SAL_CALL osl_getGlobalMutex(); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_MUTEX_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.6 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.5 2000/05/17 14:30:14 mfe +* comments upgraded +* +* Revision 1.4 1999/12/08 10:40:52 jbu +* #70413# changed oslMutex forward struct +* +* Revision 1.3 1999/10/27 15:02:07 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.2 1999/09/28 13:04:31 kr +* new: getGlobalMutex +* +* Revision 1.1 1999/08/05 10:18:19 jsc +* verschoben aus osl +* +* Revision 1.4 1999/08/05 11:14:36 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.3 1999/01/20 18:53:40 jsc +* #61011# Typumstellung +* +* Revision 1.2 1998/07/04 14:56:57 rh +* Prototype for OS/2 +* +* Revision 1.1 1998/02/16 19:34:51 rh +* Cleanup of ports, integration of Size_t, features for process +* +*************************************************************************/ diff --git a/sal/inc/osl/mutex.hxx b/sal/inc/osl/mutex.hxx new file mode 100644 index 000000000000..e428778fd113 --- /dev/null +++ b/sal/inc/osl/mutex.hxx @@ -0,0 +1,232 @@ +/************************************************************************* + * + * $RCSfile: mutex.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_MUTEX_HXX_ +#define _OSL_MUTEX_HXX_ + +#ifdef __cplusplus + +#include <osl/macros.hxx> + +#include <osl/mutex.h> + + +#ifdef _USE_NAMESPACE +namespace osl +{ +#endif + + class Mutex { + oslMutex mutex; + + // these make no sense + Mutex( oslMutex ) {} + Mutex( const Mutex & ) {} + + public: + /** Create a thread-local mutex. + @return 0 if the mutex could not be created, otherwise a handle to the mutex. + */ + Mutex() + { + mutex = osl_createMutex(); + } + + /** Release the OS-structures and free mutex data-structure. + */ + ~Mutex() + { + osl_destroyMutex(mutex); + } + + /** Acquire the mutex, block if already acquired by another thread. + @return False if system-call fails. + */ + sal_Bool acquire() + { + return osl_acquireMutex(mutex); + } + + /** Try to acquire the mutex without blocking. + @return False if it could not be acquired. + */ + sal_Bool tryToAcquire() + { + return osl_tryToAcquireMutex(mutex); + } + + /** Release the mutex. + @return False if system-call fails. + */ + sal_Bool release() + { + return osl_releaseMutex(mutex); + } + + static Mutex * getGlobalMutex() + { + return (Mutex *)osl_getGlobalMutex(); + } + }; + + template<class T> + class Guard + { + protected: + T * pT; + public: + + Guard(T * pT) : pT(pT) + { + pT->acquire(); + } + + Guard(T & t) : pT(&t) + { + pT->acquire(); + } + + /** Releases mutex. */ + ~Guard() + { + pT->release(); + } + }; + + template<class T> + class ClearableGuard + { + protected: + T * pT; + public: + + ClearableGuard(T * pT) : pT(pT) + { + pT->acquire(); + } + + ClearableGuard(T & t) : pT(&t) + { + pT->acquire(); + } + + /** Releases mutex. */ + ~ClearableGuard() + { + if (pT) + pT->release(); + } + + /** Releases mutex. */ + void clear() + { + if(pT) + { + pT->release(); + pT = NULL; + } + } + }; + + typedef Guard<Mutex> MutexGuard; + typedef ClearableGuard<Mutex> ClearableMutexGuard; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _OSL_MUTEX_HXX_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.10 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.9 2000/07/04 13:38:41 dbo +* mutex copy ctors make no sense +* +* Revision 1.8 2000/05/17 14:30:14 mfe +* comments upgraded +* +* Revision 1.7 2000/01/04 14:48:04 dbo +* #70396# corrected ClearableGuard +* +* Revision 1.6 1999/10/27 15:02:07 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.5 1999/10/18 09:08:41 rt +* syntax change in template for gcc for windows +* +* Revision 1.4 1999/10/05 10:23:31 obr +* changed OMutex to Mutex etc. +* +* Revision 1.3 1999/09/28 15:13:08 kr +* Protection +* +* Revision 1.2 1999/09/28 13:04:07 kr +* *** empty log message *** +* +* Revision 1.1 1999/09/23 12:09:22 kr +* inline header wrapper for mutex semaphore guard +* +*************************************************************************/ diff --git a/sal/inc/osl/pipe.h b/sal/inc/osl/pipe.h new file mode 100644 index 000000000000..83ffa0a3bf97 --- /dev/null +++ b/sal/inc/osl/pipe.h @@ -0,0 +1,148 @@ +/************************************************************************* + * + * $RCSfile: pipe.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_PIPE_H_ +#define _OSL_PIPE_H_ + +#ifndef _RTL_USTRING_H +# include <rtl/ustring.h> +#endif + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifndef _OSL_SECURITY_H_ +# include <osl/security.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + osl_Pipe_E_None, /* no error */ + osl_Pipe_E_NotFound, /* Pipe could not be found */ + osl_Pipe_E_AlreadyExists, /* Pipe already exists */ + osl_Pipe_E_NoProtocol, /* Protocol not available */ + osl_Pipe_E_NetworkReset, /* Network dropped connection because of reset */ + osl_Pipe_E_ConnectionAbort, /* Software caused connection abort */ + osl_Pipe_E_ConnectionReset, /* Connection reset by peer */ + osl_Pipe_E_NoBufferSpace, /* No buffer space available */ + osl_Pipe_E_TimedOut, /* Connection timed out */ + osl_Pipe_E_ConnectionRefused, /* Connection refused */ + osl_Pipe_E_invalidError, /* unmapped error: always last entry in enum! */ + osl_Pipe_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslPipeError; + +typedef sal_uInt32 oslPipeOptions; +#define osl_Pipe_OPEN 0x0000 /* open existing pipe */ +#define osl_Pipe_CREATE 0x0001 /* create pipe and open it, fails if already existst */ + +typedef void* oslPipe; + +oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security); +void SAL_CALL osl_destroyPipe(oslPipe Pipe); + +oslPipe SAL_CALL osl_copyPipe(oslPipe Pipe); + +oslPipe SAL_CALL osl_acceptPipe(oslPipe Pipe); + +sal_Int32 SAL_CALL osl_sendPipe(oslPipe Pipe, const void* pBuffer, sal_uInt32 BufferSize); +sal_Int32 SAL_CALL osl_receivePipe(oslPipe Pipe, void* pBuffer, sal_uInt32 BufferSize); + +oslPipeError SAL_CALL osl_getLastPipeError(oslPipe Pipe); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_PIPE_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.5 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.4 2000/05/17 14:30:14 mfe +* comments upgraded +* +* Revision 1.3 2000/03/16 16:43:52 obr +* Unicode API changes +* +* Revision 1.2 1999/10/27 15:02:07 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:19 jsc +* verschoben aus osl +* +* Revision 1.3 1999/08/05 11:14:37 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.2 1999/01/20 18:53:40 jsc +* #61011# Typumstellung +* +* Revision 1.1 1998/03/13 15:07:31 rh +* Cleanup of enum chaos and implemntation of pipes +* +*************************************************************************/ diff --git a/sal/inc/osl/process.h b/sal/inc/osl/process.h new file mode 100644 index 000000000000..e3cf3d77b5fc --- /dev/null +++ b/sal/inc/osl/process.h @@ -0,0 +1,375 @@ +/************************************************************************* + * + * $RCSfile: process.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_PROCESS_H_ +#define _OSL_PROCESS_H_ + +#ifndef _RTL_USTRING_H +# include <rtl/ustring.h> +#endif +#ifndef _RTL_TEXTENC_H +# include <rtl/textenc.h> +#endif + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifndef _OSL_FILE_H_ +# include <osl/file.h> +#endif + +#ifndef _OSL_PIPE_H_ +#include <osl/pipe.h> +#endif + +#ifndef _OSL_SOCKET_H_ +# include <osl/socket.h> +#endif +#ifndef _OSL_SECURITY_H_ +# include <osl/security.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef sal_Int32 oslProcessOption; +#define osl_Process_WAIT 0x0001 /* wait for completion */ +#define osl_Process_SEARCHPATH 0x0002 /* search path for executable */ +#define osl_Process_DETACHED 0x0004 /* run detached */ +#define osl_Process_NORMAL 0x0000 /* run in normal window */ +#define osl_Process_HIDDEN 0x0010 /* run hidden */ +#define osl_Process_MINIMIZED 0x0020 /* run in minimized window */ +#define osl_Process_MAXIMIZED 0x0040 /* run in maximized window */ +#define osl_Process_FULLSCREEN 0x0080 /* run in fullscreen window */ + +typedef sal_Int32 oslProcessData; +#define osl_Process_IDENTIFIER 0x0001 +#define osl_Process_EXITCODE 0x0002 +#define osl_Process_CPUTIMES 0x0004 +#define osl_Process_HEAPUSAGE 0x0008 + +typedef sal_uInt32 oslProcessIdentifier; +typedef sal_uInt32 oslProcessExitCode; + +typedef enum { + osl_Process_E_None, /* no error */ + osl_Process_E_NotFound, /* image not found */ + osl_Process_E_TimedOut, /* timout occured */ + osl_Process_E_NoPermission, /* permission denied */ + osl_Process_E_Unknown, /* unknown error */ + osl_Process_E_InvalidError, /* unmapped error */ + osl_Process_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslProcessError; + +typedef enum { + osl_Process_TypeNone, /* no descriptor */ + osl_Process_TypeSocket, /* socket */ + osl_Process_TypeFile, /* file */ + osl_Process_TypePipe, /* pipe */ + osl_Process_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslDescriptorType; + +typedef sal_Int32 oslDescriptorFlag; +#define osl_Process_DFNONE 0x0000 +#define osl_Process_DFWAIT 0x0001 + +#ifdef SAL_W32 +# pragma pack(push, 8) +#elif defined(SAL_OS2) +# pragma pack(1) +#endif + +typedef union { + oslSocket Socket; + oslFileHandle File; +} oslResourceDescriptor; + +/** */ +typedef struct { + oslDescriptorType Type; + oslDescriptorFlag Flags; + oslResourceDescriptor Descriptor; +} oslIOResource; + +typedef struct { + sal_uInt32 Size; + oslProcessData Fields; + oslProcessIdentifier Ident; + oslProcessExitCode Code; + TimeValue UserTime; + TimeValue SystemTime; + sal_uInt32 HeapUsage; +} oslProcessInfo; + +#ifdef SAL_W32 +# pragma pack(pop) +#elif defined(SAL_OS2) +# pragma pack() +#endif + +/** Process handle + @see osl_executeProcess + @see osl_freeProcessHandle + @see osl_joinProcess +*/ +typedef void* oslProcess; + +/** Execute a process. + @param strImageName [in] denotes the name of the executable to be started. + @param strArguments [in] is an array of argument strings. + @param nArgument [in] the number of arguments provided. + @param Options [in] is a combination of int-constants to describe the mode of execution. + @param Security [in] describes a the user and his rights for wich the process is started. + @param strDirectory [in] denotes the name of the startup directory. + @param strEnviroments [in] is an array of strings wich describes the enviroment to set. + Each string has the form "variable=value". + @param nEnvironmentVars [in] the number of environment vars to set. + @param pResource [in] is a NULL terminated array of resources to transmit to the client process. + @param pProcess [out] points to a oslProcess variable, in wich the processhandle is returned. + @return osl_Process_E_None if the executable could be started, otherwise an error-code. + @see osl_freeProcessHandle + @see osl_getIOResources + @see osl_loginUser +*/ +oslProcessError SAL_CALL osl_executeProcess(rtl_uString *strImageName, + rtl_uString *strArguments[], + sal_uInt32 nArguments, + oslProcessOption Options, + oslSecurity Security, + rtl_uString *strWorkDir, + rtl_uString *strEnvironment[], + sal_uInt32 nEnvironmentVars, + oslIOResource* pResources, + oslProcess *pProcess); + +oslProcessError SAL_CALL osl_terminateProcess(oslProcess Process); + +oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident); + +/** Free the specified proces-handle. + @param Process [in] +*/ +void SAL_CALL osl_freeProcessHandle(oslProcess Process); + +/** Wait for completation of the specified childprocess. + @param Process [in] + @return ols_Process_E_None + @see osl_executeProcess +*/ +oslProcessError SAL_CALL osl_joinProcess(oslProcess Process); + +oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData Fields, + oslProcessInfo* pInfo); + +/** Get the filename of the executable. + @param strFile [out] the string that receives the executable file path. + @return osl_Process_E_None or does not return. + @see osl_executeProcess +*/ +oslProcessError SAL_CALL osl_getExecutableFile(rtl_uString **strFile); + +/** @return the number of commandline arguments passed to the main-function of + this process + @see osl_getCommandArg +*/ +sal_uInt32 SAL_CALL osl_getCommandArgCount(); + +/** Get the nArg-th command-line argument passed to the main-function of this process. + @param nArg [in] The number of the argument to return. + @param strCommandArg [out] The string receives the nArg-th command-line argument. + @return osl_Process_E_None or does not return. + @see osl_executeProcess +*/ +oslProcessError SAL_CALL osl_getCommandArg(sal_uInt32 nArg, rtl_uString **strCommandArg); + +/** Get the value of one enviroment variable. + @param strVar [in] denotes the name of the variable to get. + @param strValue [out] string that receives the value of environment variable. +*/ +oslProcessError SAL_CALL osl_getEnvironment(rtl_uString *strVar, rtl_uString **strValue); + +/** Receive io-resources like file descriptors or sockets from the parent process. + @param Resources [out] is the buffer in wich the resources are returned. + @param Max [in] is the size of this buffer. + @return osl_Process_E_None if the variable exists, otherwise an errorcode. + @see osl_executeProcess (provide the ioresources) +*/ +oslProcessError SAL_CALL osl_getIOResources(oslIOResource Resources[], sal_uInt32 Max); + +/** Receive a single io-resource inherited by a parent process using the Netsape + portable runtime. + NOTE: Currently only pipes are supported. + @param pResource [out] the buffer to be filled. + @param name [in] the name identifying the requested handle. +*/ +oslProcessError SAL_CALL osl_getIOResource(oslIOResource *pResource, const char * name); + +sal_Bool SAL_CALL osl_sendResourcePipe(oslPipe Pipe, oslSocket Socket); + +oslSocket SAL_CALL osl_receiveResourcePipe(oslPipe Pipe); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_PROCESS_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.13 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.12 2000/07/31 17:41:51 mfe +* send and receive resource dummy implemented +* +* Revision 1.11 2000/07/21 16:15:41 mfe +* IO resource funcs added +* +* Revision 1.10 2000/06/18 12:18:57 obr +* enable inheritance of nspr file handles +* +* Revision 1.9 2000/05/17 14:30:14 mfe +* comments upgraded +* +* Revision 1.8 2000/03/31 17:02:04 rs +* UNICODE-Changes +* +* Revision 1.7 2000/03/27 09:17:50 hro +* UNICODE New osl_getThreadTextEncoding +* +* Revision 1.6 2000/03/20 15:23:15 obr +* Unicode API changes +* +* Revision 1.5 2000/03/17 13:41:25 obr +* Fixed parameter/docu +* +* Revision 1.4 2000/03/17 13:05:34 obr +* osl_getDefaulttextEncoding added. +* +* Revision 1.3 2000/03/17 12:03:56 obr +* Unicode API changes +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:19 jsc +* verschoben aus osl +* +* Revision 1.18 1999/08/05 11:14:38 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.17 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.16 1998/07/20 17:17:33 rh +* #53072, #53073 Bugfixes for 5.0 +* +* Revision 1.15 1998/03/13 15:07:31 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.14 1998/02/16 19:34:51 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.13 1997/11/28 08:55:50 fm +* osl_PTSOCKETSEMAPHORE added +* +* Revision 1.12 1997/09/22 16:36:15 rh +* terminate added +* +* Revision 1.11 1997/07/31 15:28:39 ts +* *** empty log message *** +* +* Revision 1.10 1997/07/25 10:01:07 fm +* *** empty log message *** +* +* Revision 1.9 1997/07/22 14:29:29 rh +* process added +* +* Revision 1.8 1997/07/18 08:45:13 ts +* *** empty log message *** +* +* Revision 1.7 1997/07/17 19:01:44 ts +* *** empty log message *** +* +* Revision 1.6 1997/07/17 11:20:54 ts +* *** empty log message *** +* +* Revision 1.5 1997/07/17 11:02:27 rh +* Header adapted and profile added +* +* Revision 1.4 1997/07/15 19:01:58 rh +* system.h inserted +* +* Revision 1.3 1997/07/14 09:09:11 rh +* Adaptions for killable sleeps +* +* Revision 1.2 1997/07/11 10:14:28 ts +* *** empty log message *** +* +* Revision 1.1 1997/07/11 07:33:02 rh +* added +* +*************************************************************************/ diff --git a/sal/inc/osl/profile.h b/sal/inc/osl/profile.h new file mode 100644 index 000000000000..360e36b70155 --- /dev/null +++ b/sal/inc/osl/profile.h @@ -0,0 +1,205 @@ +/************************************************************************* + * + * $RCSfile: profile.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_PROFILE_H_ +#define _OSL_PROFILE_H_ + +#ifndef _RTL_USTRING_H +# include <rtl/ustring.h> +#endif + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef sal_uInt32 oslProfileOption; + +#define osl_Profile_DEFAULT 0x0000 +#define osl_Profile_SYSTEM 0x0001 /* use system depended functinality */ +#define osl_Profile_READLOCK 0x0002 /* lock file for reading */ +#define osl_Profile_WRITELOCK 0x0004 /* lock file for writing */ +#define osl_Profile_FLUSHWRITE 0x0010 /* writing only with flush */ + + +typedef void* oslProfile; + +/** Open or create a configuration profile. + @return 0 if the profile could not be created, otherwise a handle to the profile. +*/ +oslProfile SAL_CALL osl_openProfile(rtl_uString *strProfileName, oslProfileOption Options); + +/** Close the opened profile an flush all data to the disk. + @param Profile handle to a opened profile. +*/ +sal_Bool SAL_CALL osl_closeProfile(oslProfile Profile); + + +sal_Bool SAL_CALL osl_flushProfile(oslProfile Profile); + + +sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile, + const sal_Char* pszSection, const sal_Char* pszEntry, + sal_Char* pszString, sal_uInt32 MaxLen, + const sal_Char* pszDefault); +sal_Bool SAL_CALL osl_readProfileBool(oslProfile Profile, + const sal_Char* pszSection, const sal_Char* pszEntry, + sal_Bool Default); +sal_uInt32 SAL_CALL osl_readProfileIdent(oslProfile Profile, + const sal_Char* pszSection, const sal_Char* pszEntry, + sal_uInt32 FirstId, const sal_Char* Strings[], + sal_uInt32 Default); + +sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile, + const sal_Char* pszSection, const sal_Char* pszEntry, + const sal_Char* pszString); +sal_Bool SAL_CALL osl_writeProfileBool(oslProfile Profile, + const sal_Char* pszSection, const sal_Char* pszEntry, + sal_Bool Value); +sal_Bool SAL_CALL osl_writeProfileIdent(oslProfile Profile, + const sal_Char* pszSection, const sal_Char* pszEntry, + sal_uInt32 FirstId, const sal_Char* Strings[], + sal_uInt32 Value); + +/** Acquire the mutex, block if already acquired by another thread. + @param Profile handle to a opened profile. + @return False if section or entry could not be found. +*/ +sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile, + const sal_Char *pszSection, const sal_Char *pszEntry); + +/** Get all entries belonging to the specified section. + @param Profile handle to a opened profile. + @return Pointer to a array of pointers. +*/ +sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_Char *pszSection, + sal_Char* pszBuffer, sal_uInt32 MaxLen); + +/** Get all section entries + @param Profile handle to a opened profile. + @return Pointer to a array of pointers. +*/ +sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuffer, sal_uInt32 MaxLen); + +sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName, rtl_uString** strProfileName); + + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_PROFILE_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.8 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.7 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.6 2000/03/22 17:06:42 mfe +* #73273# #72225# : now a UniCode Version +* +* Revision 1.5 2000/03/22 16:58:30 mfe +* #73273# #72225# : new Option for writing via flush without lock +* +* Revision 1.3 2000/03/06 14:14:46 mfe +* #73273# : added osl_flushProfile +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:19 jsc +* verschoben aus osl +* +* Revision 1.8 1999/08/05 11:14:39 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.7 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.6 1998/05/04 10:44:01 rh +* Added osl_getProfileSections, minor changes on Unix signals, +* starting every process under unix in a separate thread, +* fix unix thread problem, when freeing a handle of a running thread +* +* Revision 1.5 1998/03/13 15:07:32 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.4 1998/02/16 19:34:51 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.3 1997/12/12 14:15:21 rh +* Added CR/LF conversion, locking and system integration +* +* Revision 1.2 1997/09/18 10:57:28 rh +* getProfileName added +* +* Revision 1.1 1997/07/17 11:02:27 rh +* Header adapted and profile added +* +*************************************************************************/ + diff --git a/sal/inc/osl/profile.hxx b/sal/inc/osl/profile.hxx new file mode 100644 index 000000000000..6fd53441e269 --- /dev/null +++ b/sal/inc/osl/profile.hxx @@ -0,0 +1,276 @@ +/************************************************************************* + * + * $RCSfile: profile.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:12 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_PROFILE_HXX_ +#define _OSL_PROFILE_HXX_ + +#include "profile.h" + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif + +#include <list> + +namespace osl { + + typedef oslProfileOption ProfileOption; + + const int Profile_DEFAULT = osl_Profile_DEFAULT; + const int Profile_SYSTEM = osl_Profile_SYSTEM; /* use system depended functinality */ + const int Profile_READLOCK = osl_Profile_READLOCK; /* lock file for reading */ + const int Profile_WRITELOCK = osl_Profile_WRITELOCK; /* lock file for writing */ + + class Profile { + oslProfile profile; + + public: + /** Open or create a configuration profile. + @return 0 if the profile could not be created, otherwise a handle to the profile. + */ + Profile(const rtl::OUString strProfileName, oslProfileOption Options = Profile_DEFAULT ) + { + profile = osl_openProfile(strProfileName.pData, Options); + if( ! profile ) + throw std::exception(); + } + + + /** Close the opened profile an flush all data to the disk. + @param Profile handle to a opened profile. + */ + ~Profile() + { + sal_Bool err = osl_closeProfile(profile); + } + + + sal_Bool flush() + { + return osl_flushProfile(profile); + } + + rtl::OString readString( const rtl::OString& rSection, const rtl::OString& rEntry, + const rtl::OString& rDefault) + { + sal_Char aBuf[1024]; + return osl_readProfileString( profile, + rSection, + rEntry, + aBuf, + sizeof( aBuf ), + rDefault ) ? rtl::OString( aBuf ) : rtl::OString(); + + } + + sal_Bool readBool( const rtl::OString& rSection, const rtl::OString& rEntry, sal_Bool bDefault ) + { + return osl_readProfileBool( profile, rSection, rEntry, bDefault ); + } + + sal_uInt32 readIdent(const rtl::OString& rSection, const rtl::OString& rEntry, + sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings, + sal_uInt32 nDefault) + { + int nItems = rStrings.size(); + const sal_Char** pStrings = new const sal_Char*[ nItems+1 ]; + std::list< rtl::OString >::const_iterator it = rStrings.begin(); + nItems = 0; + while( it != rStrings.end() ) + { + pStrings[ nItems++ ] = *it; + ++it; + } + pStrings[ nItems ] = NULL; + sal_uInt32 nRet = osl_readProfileIdent(profile, rSection, rEntry, nFirstId, pStrings, nDefault); + delete pStrings; + return nRet; + } + + sal_Bool writeString(const rtl::OString& rSection, const rtl::OString& rEntry, + const rtl::OString& rString) + { + return osl_writeProfileString(profile, rSection, rEntry, rString); + } + + sal_Bool writeBool(const rtl::OString& rSection, const rtl::OString& rEntry, sal_Bool Value) + { + return osl_writeProfileBool(profile, rSection, rEntry, Value); + } + + sal_Bool writeIdent(const rtl::OString& rSection, const rtl::OString& rEntry, + sal_uInt32 nFirstId, const std::list< rtl::OString >& rStrings, + sal_uInt32 nValue) + { + int nItems = rStrings.size(); + const sal_Char** pStrings = new const sal_Char*[ nItems+1 ]; + std::list< rtl::OString >::const_iterator it = rStrings.begin(); + nItems = 0; + while( it != rStrings.end() ) + { + pStrings[ nItems++ ] = *it; + ++it; + } + pStrings[ nItems ] = NULL; + sal_Bool bRet = + osl_writeProfileIdent(profile, rSection, rEntry, nFirstId, pStrings, nValue ); + delete pStrings; + return bRet; + } + + /** Acquire the mutex, block if already acquired by another thread. + @param Profile handle to a opened profile. + @return False if section or entry could not be found. + */ + sal_Bool removeEntry(const rtl::OString& rSection, const rtl::OString& rEntry) + { + return osl_removeProfileEntry(profile, rSection, rEntry); + } + + /** Get all entries belonging to the specified section. + @param Profile handle to a opened profile. + @return Pointer to a array of pointers. + */ + std::list< rtl::OString > getSectionEntries(const rtl::OString& rSection ) + { + std::list< rtl::OString > aEntries; + + // count buffer size necessary + int n = osl_getProfileSectionEntries( profile, rSection, NULL, 0 ); + if( n > 1 ) + { + sal_Char* pBuf = new sal_Char[ n+1 ]; + osl_getProfileSectionEntries( profile, rSection, pBuf, n+1 ); + int nLen; + for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 ) + aEntries.push_back( rtl::OString( pBuf+n ) ); + delete pBuf; + } + + return aEntries; + } + + /** Get all section entries + @param Profile handle to a opened profile. + @return Pointer to a array of pointers. + */ + std::list< rtl::OString > getSections() + { + std::list< rtl::OString > aSections; + + // count buffer size necessary + int n = osl_getProfileSections( profile, NULL, 0 ); + if( n > 1 ) + { + sal_Char* pBuf = new sal_Char[ n+1 ]; + osl_getProfileSections( profile, pBuf, n+1 ); + int nLen; + for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 ) + aSections.push_back( rtl::OString( pBuf+n ) ); + delete pBuf; + } + + return aSections; + } + + static rtl::OUString getName(const rtl::OUString& rPath, const rtl::OUString& rName) + { + rtl::OUString aProfileName; + return osl_getProfileName( rPath.pData, rName.pData, &aProfileName.pData ) ? aProfileName : rtl::OUString(); + } + + }; +} + +#endif /* _OSL_PROFILE_HXX_ */ + + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.9 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.8 2000/05/31 08:52:40 obr +* inline statement fixed +* +* Revision 1.7 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.6 2000/03/16 16:43:53 obr +* Unicode API changes +* +* Revision 1.5 2000/03/06 14:15:08 mfe +* #73273# : added flush() method +* +* Revision 1.4 1999/11/09 16:15:25 pl +* add: correct namespace +* +* Revision 1.3 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.2 1999/09/30 11:45:58 pl +* use OStrings to get rid of buffers +* +* Revision 1.1 1999/09/30 08:26:57 kr +* profile header inline wrapper +* +*************************************************************************/ diff --git a/sal/inc/osl/security.h b/sal/inc/osl/security.h new file mode 100644 index 000000000000..d98683f39a58 --- /dev/null +++ b/sal/inc/osl/security.h @@ -0,0 +1,263 @@ +/************************************************************************* + * + * $RCSfile: security.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_SECURITY_H_ +#define _OSL_SECURITY_H_ + +#ifndef _RTL_USTRING_H_ +# include <rtl/ustring.h> +#endif + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + osl_Security_E_None, + osl_Security_E_UserUnknown, + osl_Security_E_WrongPassword, + osl_Security_E_Unknown, + osl_Security_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSecurityError; + +/** Process handle + @see osl_loginUser + @see osl_freeSecurityHandle + @see osl_executeProcess +*/ +typedef void* oslSecurity; + +/** Create a security handle for the current user. + @return a security handle or NULL on failure. + @see osl_freeSecurityHandle + @see osl_executeProcess + @see osl_executeApplication +*/ +oslSecurity SAL_CALL osl_getCurrentSecurity(void); + +/** Create a security handle for the denoted user. + Try to log in the user on the local system. + @param strzUserName [in] denotes the name of the user to logg in. + @param strPasswd [in] the password for this user. + @param pSecurity [out] returns the security handle if user could be logged in. + @return osl_Security_E_None if user could be logged in, otherwise an error-code. + @see osl_freeSecurityHandle + @see osl_executeProcess + @see osl_executeApplication +*/ +oslSecurityError SAL_CALL osl_loginUser( + rtl_uString *strUserName, + rtl_uString *strPasswd, + oslSecurity *pSecurity + ); + +/** Create a security handle for the denoted user. + Try to log in the user on the denoted file server. On success the homedir will be + the maped drive on this server. + @param strUserName [in] denotes the name of the user to logg in. + @param strPasswd [in] the password for this user. + @param strFileServer [in] denotes the file server on wich the user is logged in. + @param pSecurity [out] returns the security handle if user could be logged in. + @return osl_Security_E_None if user could be logged in, otherwise an error-code. + @see osl_freeSecurityHandle + @see osl_executeProcess + @see osl_executeApplication +*/ +oslSecurityError SAL_CALL osl_loginUserOnFileServer( + rtl_uString *strUserName, + rtl_uString *strPasswd, + rtl_uString *strFileServer, + oslSecurity *pSecurity + ); + +/** Query if the user who is denotes by this security has administrator rigths. + @param Security [in] the security handle for th user. + @return True, if the user has adminsitrator rights, otherwise false. +*/ +sal_Bool SAL_CALL osl_isAdministrator(oslSecurity Security); + +/** Free the security handle, created by osl_loginUser. + @param Security [in] the security handle. + @see osl_loginUser +*/ +void SAL_CALL osl_freeSecurityHandle(oslSecurity Security); + +/** Get the login ident for the user of this security handle. + @param Security [in] the security handle. + @param strIdent [out] the string that receives the ident on success. + @return True, if the security handle is valid, otherwise False. +*/ +sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent); + +/** Get the login name for the user of this security handle. + @param Security [in] the security handle. + @param pszName [out] the string that receives the user name on success. + @return True, if the security handle is valid, otherwise False. +*/ +sal_Bool SAL_CALL osl_getUserName(oslSecurity Security, rtl_uString **strName); + +/** Get the home directory of the user of this security handle. + @param Security [in] the security handle. + @param strDirectory [out] the string that receives the directory path on success. + @return True, if the security handle is valid, otherwise False. +*/ +sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **strDirectory); + +/** Get the directory for configuration data of the user of this security handle. + @param Security [in] the security handle. + @param strDirectory [out] the string that receives the directory path on success. + @return True, if the security handle is valid, otherwise False. +*/ +sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **strDirectory); + + +/** Load Profile of the User + Implemented just for Windows + @param oslSecurity Security [in] previously fetch Security of the User + @return True if the Profile could successfully loaded, False otherwise. +*/ + +sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security); + + +/** Unload a User Profile + Implemented just for Windows + @param oslSecurity Security [in] previously fetch Security of the User + @return nothing is returned! +*/ + +void SAL_CALL osl_unloadUserProfile(oslSecurity Security); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_SECURITY_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.7 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.6 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.5 2000/03/31 16:55:43 rs +* UNICODE-Changes +* +* Revision 1.4 2000/03/16 16:43:53 obr +* Unicode API changes +* +* Revision 1.3 1999/11/18 09:44:26 mfe +* loadUserprofile moved from process.c to security.c +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:20 jsc +* verschoben aus osl +* +* Revision 1.13 1999/08/05 11:14:41 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.12 1999/07/09 15:35:33 br +* BR: fuer win16 +* +* Revision 1.11 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.10 1998/09/18 15:33:41 rh +* #56761# neue locations fr cfg/ini files +* +* Revision 1.9 1998/03/13 15:07:32 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.8 1998/02/16 19:34:51 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.7 1997/10/21 14:22:21 ts +* Abfrage, ob ein Benutzer Adminstratorrechte hat eingebaut +* +* Revision 1.6 1997/10/17 16:00:44 ts +* osl_logonUserOnFileServer hinzugefuegt +* +* Revision 1.5 1997/10/14 07:52:51 fm +* *** empty log message *** +* +* Revision 1.4 1997/07/31 15:28:39 ts +* *** empty log message *** +* +* Revision 1.3 1997/07/22 14:29:30 rh +* process added +* +* Revision 1.2 1997/07/17 19:01:45 ts +* *** empty log message *** +* +* Revision 1.1 1997/07/17 11:22:18 ts +* *** empty log message *** +* +*************************************************************************/ + diff --git a/sal/inc/osl/semaphor.h b/sal/inc/osl/semaphor.h new file mode 100644 index 000000000000..911778cb0b82 --- /dev/null +++ b/sal/inc/osl/semaphor.h @@ -0,0 +1,146 @@ +/************************************************************************* + * + * $RCSfile: semaphor.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_SEMAPHORE_H_ +#define _OSL_SEMAPHORE_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* oslSemaphore; + +/** Creates a semaphore.<BR> + @param InitialCount denotes the starting value the semaphore. If you set it to + zero, the first acquire() blocks. Otherwise InitialCount acquire()s are + immedeatly successfull. + @return 0 if the semaphore could not be created, otherwise a handle to the sem. +*/ +oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount); + +/** Release the OS-structures and free semaphore data-structure + @return fbbb +*/ +void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore); + +/** acquire() decreases the count. It will block if it tries to + decrease below zero. + @return False if the system-call failed. +*/ +sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore); + +/** tryToAcquire() tries to decreases the count. It will + return with False if it would decrease the count below zero. + (When acquire() would block.) If it could successfully + decrease the count, it will return True. +*/ +sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore); + +/** release() increases the count. + @return False if the system-call failed. +*/ +sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_SEMAPHORE_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.4 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.3 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:20 jsc +* verschoben aus osl +* +* Revision 1.6 1999/08/05 11:14:41 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.5 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.4 1998/02/16 19:34:52 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.3 1997/07/31 15:28:40 ts +* *** empty log message *** +* +* Revision 1.2 1997/07/17 11:02:28 rh +* Header adapted and profile added +* +* Revision 1.1 1997/06/19 13:10:10 bho +* first version of OSL. +* +*************************************************************************/ + diff --git a/sal/inc/osl/semaphor.hxx b/sal/inc/osl/semaphor.hxx new file mode 100644 index 000000000000..097bc6a81dd9 --- /dev/null +++ b/sal/inc/osl/semaphor.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: semaphor.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_SEMAPHORE_HXX_ +#define _OSL_SEMAPHORE_HXX_ + +#ifdef __cplusplus + +#include <osl/macros.hxx> + +#include <osl/semaphore.h> + + +#ifdef _USE_NAMESPACE +namespace osl +{ +#endif + + class Semaphore { + oslSemaphore semaphore; + + public: + + /** Creates a semaphore.<BR> + @param InitialCount denotes the starting value the semaphore. If you set it to + zero, the first acquire() blocks. Otherwise InitialCount acquire()s are + immedeatly successfull. + @return 0 if the semaphore could not be created, otherwise a handle to the sem. + */ + + Semaphore(sal_uInt32 initialCount) + { + semaphore = osl_createSemaphore(initialCount); + } + + /** Release the OS-structures and free semaphore data-structure + @return fbbb + */ + ~Semaphore() + { + osl_destroySemaphore(semaphore); + } + + /** acquire() decreases the count. It will block if it tries to + decrease below zero. + @return False if the system-call failed. + */ + sal_Bool acquire() + { + return osl_acquireSemaphore(semaphore); + } + + /** tryToAcquire() tries to decreases the count. It will + return with False if it would decrease the count below zero. + (When acquire() would block.) If it could successfully + decrease the count, it will return True. + */ + sal_Bool tryToAcquire() + { + return osl_tryToAcquireSemaphore(semaphore); + } + + /** release() increases the count. + @return False if the system-call failed. + */ + sal_Bool release() + { + return osl_releaseSemaphore(semaphore); + } + }; +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _OSL_SEMAPHORE_HXX_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.4 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.3 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/09/23 12:09:17 kr +* inline header wrapper for mutex semaphore guard +* +*************************************************************************/ + diff --git a/sal/inc/osl/signal.h b/sal/inc/osl/signal.h new file mode 100644 index 000000000000..439dd2feb60a --- /dev/null +++ b/sal/inc/osl/signal.h @@ -0,0 +1,182 @@ +/************************************************************************* + * + * $RCSfile: signal.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_SIGNAL_H_ +#define _OSL_SIGNAL_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define OSL_SIGNAL_USER_RESERVED 0 + +#define OSL_SIGNAL_USER_RESOURCEFAILURE (OSL_SIGNAL_USER_RESERVED - 1) +#define OSL_SIGNAL_USER_X11SUBSYSTEMERROR (OSL_SIGNAL_USER_RESERVED - 2) +#define OSL_SIGNAL_USER_RVPCONNECTIONERROR (OSL_SIGNAL_USER_RESERVED - 3) + +typedef void* oslSignalHandler; + +typedef enum +{ + osl_Signal_System, + osl_Signal_Terminate, + osl_Signal_AccessViolation, + osl_Signal_IntegerDivideByZero, + osl_Signal_FloatDivideByZero, + osl_Signal_DebugBreak, + osl_Signal_User, + osl_Signal_Alarm, + osl_Signal_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSignal; + +typedef enum +{ + osl_Signal_ActCallNextHdl, + osl_Signal_ActIgnore, + osl_Signal_ActAbortApp, + osl_Signal_ActKillApp, + osl_Signal_Act_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSignalAction; + +#ifdef SAL_W32 +# pragma pack(push, 8) +#elif defined(SAL_OS2) +# pragma pack(1) +#endif + +typedef struct +{ + oslSignal Signal; + sal_Int32 UserSignal; + void* UserData; +} oslSignalInfo; + +#ifdef SAL_W32 +# pragma pack(pop) +#elif defined(SAL_OS2) +# pragma pack() +#endif + +/** the function-ptr. representing the signal handler-function. +*/ +typedef oslSignalAction (SAL_CALL *oslSignalHandlerFunction)(void* pData, oslSignalInfo* pInfo); + +oslSignalHandler SAL_CALL osl_addSignalHandler(oslSignalHandlerFunction Handler, void* pData); + +sal_Bool SAL_CALL osl_removeSignalHandler(oslSignalHandler hHandler); + +oslSignalAction SAL_CALL osl_raiseSignal(sal_Int32 UserSignal, void* UserData); + + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_SIGNAL_H_ */ + + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.8 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.7 2000/08/11 16:46:28 pl +* #77400# #76899# corrected define +* +* Revision 1.6 2000/08/11 16:31:40 pl +* #77400# add OSL_SIGNAL_USER_RVPCONNECTIONERROR +* +* Revision 1.5 2000/05/29 16:45:16 hro +* SRC591: Explicite SAL_CALL calling convention +* +* Revision 1.4 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.3 1999/12/22 13:37:55 mfe +* #71232# : added Alarm Signal Type +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:20 jsc +* verschoben aus osl +* +* Revision 1.5 1999/08/05 11:14:42 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.4 1999/04/22 07:54:04 rh +* #63033# Deliver breakpoints via signal TSignal_DebugBreak +* +* Revision 1.3 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.2 1998/03/13 15:07:32 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.1 1998/03/06 15:42:09 rh +* Added signal handling +* +*************************************************************************/ diff --git a/sal/inc/osl/socket.h b/sal/inc/osl/socket.h new file mode 100644 index 000000000000..d20ebb9ad422 --- /dev/null +++ b/sal/inc/osl/socket.h @@ -0,0 +1,1001 @@ +/************************************************************************* + * + * $RCSfile: socket.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_SOCKET_H_ +#define _OSL_SOCKET_H_ + +#ifndef _RTL_USTRING_H_ +# include <rtl/ustring.h> +#endif + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifndef _RTL_TENCINFO_H +# include <rtl/tencinfo.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* error returns */ +#define OSL_INADDR_NONE 0xffffffff +#define OSL_INVALID_PORT 0xffffffff +#define OSL_INVALID_IPX_SOCKET_NO 0xffffffff + +/**@{ begin section types +*/ + +/* + Opaque datatype SocketAddr. +*/ +typedef void* oslSocketAddr; + + +/* + Represents the address-family of a socket +*/ +typedef enum { + osl_Socket_FamilyInet, /* IP */ + osl_Socket_FamilyIpx, /* Novell IPX/SPX */ + osl_Socket_FamilyInvalid, /* always last entry in enum! */ + osl_Socket_Family_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslAddrFamily; + +/* + represent a specific protocol within a address-family +*/ +typedef enum { + osl_Socket_ProtocolIp, /* for all af_inet */ + osl_Socket_ProtocolIpx, /* af_ipx datagram sockets (IPX) */ + osl_Socket_ProtocolSpx, /* af_ipx seqpacket or stream for SPX */ + osl_Socket_ProtocolSpxII, /* af_ipx seqpacket or stream for SPX II */ + osl_Socket_ProtocolInvalid, + osl_Socket_Protocol_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslProtocol; + + +/* + Represents the type of a socket +*/ +typedef enum { + osl_Socket_TypeStream, + osl_Socket_TypeDgram, + osl_Socket_TypeRaw, + osl_Socket_TypeRdm, + osl_Socket_TypeSeqPacket, + osl_Socket_TypeInvalid, /* always last entry in enum! */ + osl_Socket_Type_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketType; + + +/* + Represents socket-options +*/ +typedef enum { + osl_Socket_OptionDebug, + osl_Socket_OptionAcceptConn, + osl_Socket_OptionReuseAddr, + osl_Socket_OptionKeepAlive, + osl_Socket_OptionDontRoute, + osl_Socket_OptionBroadcast, + osl_Socket_OptionUseLoopback, + osl_Socket_OptionLinger, + osl_Socket_OptionOOBinLine, + osl_Socket_OptionSndBuf, + osl_Socket_OptionRcvBuf, + osl_Socket_OptionSndLowat, + osl_Socket_OptionRcvLowat, + osl_Socket_OptionSndTimeo, + osl_Socket_OptionRcvTimeo, + osl_Socket_OptionError, + osl_Socket_OptionType, + osl_Socket_OptionTcpNoDelay, + osl_Socket_OptionInvalid, /* always last entry in enum! */ + osl_Socket_Option_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketOption; + +/* + Represents the different socket-option levels +*/ +typedef enum { + osl_Socket_LevelSocket, + osl_Socket_LevelTcp, + osl_Socket_LevelInvalid, /* always last entry in enum! */ + osl_Socket_Level_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketOptionLevel; + + +/* + Represents flags to be used with send/recv-calls. +*/ +typedef enum { + osl_Socket_MsgNormal, + osl_Socket_MsgOOB, + osl_Socket_MsgPeek, + osl_Socket_MsgDontRoute, + osl_Socket_MsgMaxIOVLen, + osl_Socket_MsgInvalid, /* always last entry in enum! */ + osl_Socket_Msg_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketMsgFlag; + +/* + Used by shutdown to denote which end of the socket to "close". +*/ +typedef enum { + osl_Socket_DirRead, + osl_Socket_DirWrite, + osl_Socket_DirReadWrite, + osl_Socket_DirInvalid, /* always last entry in enum! */ + osl_Socket_Dir_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketDirection; + + +typedef enum { + osl_Socket_E_None, /* no error */ + osl_Socket_E_NotSocket, /* Socket operation on non-socket */ + osl_Socket_E_DestAddrReq, /* Destination address required */ + osl_Socket_E_MsgSize, /* Message too long */ + osl_Socket_E_Prototype, /* Protocol wrong type for socket */ + osl_Socket_E_NoProtocol, /* Protocol not available */ + osl_Socket_E_ProtocolNoSupport, /* Protocol not supported */ + osl_Socket_E_TypeNoSupport, /* Socket type not supported */ + osl_Socket_E_OpNotSupport, /* Operation not supported on socket */ + osl_Socket_E_PfNoSupport, /* Protocol family not supported */ + osl_Socket_E_AfNoSupport, /* Address family not supported by */ + /* protocol family */ + osl_Socket_E_AddrInUse, /* Address already in use */ + osl_Socket_E_AddrNotAvail, /* Can't assign requested address */ + osl_Socket_E_NetDown, /* Network is down */ + osl_Socket_E_NetUnreachable, /* Network is unreachable */ + osl_Socket_E_NetReset, /* Network dropped connection because */ + /* of reset */ + osl_Socket_E_ConnAborted, /* Software caused connection abort */ + osl_Socket_E_ConnReset, /* Connection reset by peer */ + osl_Socket_E_NoBufferSpace, /* No buffer space available */ + osl_Socket_E_IsConnected, /* Socket is already connected */ + osl_Socket_E_NotConnected, /* Socket is not connected */ + osl_Socket_E_Shutdown, /* Can't send after socket shutdown */ + osl_Socket_E_TooManyRefs, /* Too many references: can't splice */ + osl_Socket_E_TimedOut, /* Connection timed out */ + osl_Socket_E_ConnRefused, /* Connection refused */ + osl_Socket_E_HostDown, /* Host is down */ + osl_Socket_E_HostUnreachable, /* No route to host */ + osl_Socket_E_WouldBlock, /* call would block on non-blocking socket */ + osl_Socket_E_Already, /* operation already in progress */ + osl_Socket_E_InProgress, /* operation now in progress */ + osl_Socket_E_InvalidError, /* unmapped error: always last entry in enum! */ + osl_Socket_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketError; + + +typedef enum { + osl_Socket_Ok, /* successful completion */ + osl_Socket_Error, /* error occured, check osl_getLastSocketError() for details */ + osl_Socket_TimedOut, /* blocking operation timed out */ + osl_Socket_Interrupted, /* blocking operation was interrupted */ + osl_Socket_InProgress, /* nonblocking operation is in progress */ + osl_Socket_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslSocketResult; + +typedef sal_uInt8 oslSocketIpxNetNumber[4]; +typedef sal_uInt8 oslSocketIpxNodeNumber[6]; + +/**@} end section types +*/ + +/**@{ begin section oslSocketAddr +*/ + + +/** Creates a socket-address for the given family. + If family == osl_af_inet the address is set to INADDR_ANY + port 0. + @return 0 if address could not be created. +*/ +oslSocketAddr SAL_CALL osl_createEmptySocketAddr(oslAddrFamily Family); + + +/** Create a new SocketAddress and fill it from Addr. +*/ +oslSocketAddr SAL_CALL osl_copySocketAddr(oslSocketAddr Addr); + +/** Compare to SocketAddress. +*/ +sal_Bool SAL_CALL osl_isEqualSocketAddr( + oslSocketAddr Addr1, oslSocketAddr Addr2); + + +/** Uses the systems name-service interface to find an address for strHostname. + @param strHostname [in] The name for which you search for an address. + @return The desired address if one could be found, otherwise 0. + Don't forget to destroy the address if you don't need it any longer. +*/ +oslSocketAddr SAL_CALL osl_resolveHostname(rtl_uString *strHostname); + + +/** Create an internet address usable for sending broadcast datagrams. + To limit the broadcast to your subnet, pass your hosts IP address + in dotted decimal notation as first argument. + @see osl_sendToSocket(..., oslSocketAddr ReceiverAddr, ...). + @param strDottedAddr [in] dotted decimal internet address, may be 0. + @param Port [in] port number in host byte order. + @return 0 if address could not be created. +*/ +oslSocketAddr SAL_CALL osl_createInetBroadcastAddr ( + rtl_uString *strDottedAddr, sal_Int32 Port); + + +/** Create an internet-address, consisting of hostaddress and port. + We interpret strDottedAddr as a dotted-decimal inet-addr + (e.g. "141.99.128.50"). + @param strDottedAddr [in] String with dotted address. + @param Port [in] portnumber in host byte order. + @return 0 if address could not be created. +*/ +oslSocketAddr SAL_CALL osl_createInetSocketAddr ( + rtl_uString *strDottedAddr, sal_Int32 Port); + + +/** Create an IPX address. +*/ +oslSocketAddr SAL_CALL osl_createIpxSocketAddr(rtl_uString * strNetNumber, + rtl_uString * strNodeNumber, + sal_uInt32 SocketNumber); + +/** Free all memory allocated by pAddress. +*/ +void SAL_CALL osl_destroySocketAddr(oslSocketAddr Addr); + + + +/** Looks up the port-number designated to the specified service/protocol-pair. + (e.g. "ftp" "tcp"). + @return OSL_INVALID_PORT if no appropriate entry was found, otherwise the port-number. +*/ +sal_Int32 SAL_CALL osl_getServicePort(rtl_uString *strServicename, rtl_uString *strProtocol); + + + +/** Retrieves the address-family from the Addr. + @return the family of the socket-address. + In case of an unknown family you get osl_invalid_AddrFamily. +*/ +oslAddrFamily SAL_CALL osl_getFamilyOfSocketAddr(oslSocketAddr Addr); + + +/** Retrieves the internet port-number of Addr. + @return the port-number of the address in host-byte order. If Addr + is not an address of type osl_af_inet, it returns OSL_INVALID_PORT +*/ +sal_Int32 SAL_CALL osl_getInetPortOfSocketAddr(oslSocketAddr Addr); + + +/** Sets the Port of Addr. + @param Port [in] is expected in host byte-order. + @return False if Addr is not an inet-addr. +*/ +sal_Bool SAL_CALL osl_setInetPortOfSocketAddr(oslSocketAddr Addr, sal_Int32 Port); + + +/** Gets the hostname represented by Addr. + @return the hostname represented by the address. If + there is no hostname to be found, it returns 0. +*/ +oslSocketResult SAL_CALL osl_getHostnameOfSocketAddr(oslSocketAddr Addr, rtl_uString **strHostname); + + +/** Gets the address in dotted decimal format. + @return the dotted decimal address (e.g. 141.99.20.34) represented + by the address. If the address is invalid or not of type osl_af_inet, + it returns 0. +*/ +oslSocketResult SAL_CALL osl_getDottedInetAddrOfSocketAddr(oslSocketAddr Addr, rtl_uString **strDottedInetAddr); + + +/** Gets the IPX Net-Number of the address. + @return the (4 bytes long) net-number or 0 if not an IPX address. +*/ +oslSocketResult SAL_CALL osl_getIpxNetNumber(oslSocketAddr Addr, oslSocketIpxNetNumber NetNumber); + + +/** Gets the IPX Node-Number of the address. + @return the (6 bytes long) net-number or 0 if not an IPX address. +*/ +oslSocketResult SAL_CALL osl_getIpxNodeNumber(oslSocketAddr Addr, oslSocketIpxNodeNumber NodeNumber); + +/** Gets the IPX Socket-Number of the address. + @return the IPX socket number or OSL_INVALID_IPX_SOCKET_NO if not an IPX address. +*/ +sal_Int32 SAL_CALL osl_getIpxSocketNumber(oslSocketAddr Addr); + +/**@} end section oslSocketAddr +*/ + +/**@{ begin section oslHostAddr +*/ + +/* + Opaque datatype HostAddr. +*/ +typedef void* oslHostAddr; + + +/** Create an oslHostAddr from given hostname and socket address. + @param strHostname [in] The hostname to be stored. + @param Addr [in] The socket address to be stored. + @return The created address or 0 upon failure. +*/ +oslHostAddr SAL_CALL osl_createHostAddr(rtl_uString *strHostname, const oslSocketAddr Addr); + + +/** Create an oslHostAddr by resolving the given strHostname. + Successful name resolution should result in the fully qualified + domain name (FQDN) and it's address as hostname and socket address + members of the resulting oslHostAddr. + @param strHostname [in] The hostname to be resolved. + @return The resulting address or 0 upon failure. +*/ +oslHostAddr SAL_CALL osl_createHostAddrByName(rtl_uString *strHostname); + + +/** Create an oslHostAddr by reverse resolution of the given Addr. + Successful name resolution should result in the fully qualified + domain name (FQDN) and it's address as hostname and socket address + members of the resulting oslHostAddr. + @param Addr [in] The socket address to be reverse resolved. + @return The resulting address or 0 upon failure. +*/ +oslHostAddr SAL_CALL osl_createHostAddrByAddr(const oslSocketAddr Addr); + + +/** Create a copy of the given Addr. + @return The copied address or 0 upon failure. +*/ +oslHostAddr SAL_CALL osl_copyHostAddr(const oslHostAddr Addr); + + +/** Free all memory allocated by Addr. +*/ +void SAL_CALL osl_destroyHostAddr(oslHostAddr Addr); + + +/** Get the hostname member of Addr. + @return The hostname or 0 upon failure. +*/ +void SAL_CALL osl_getHostnameOfHostAddr(const oslHostAddr Addr, rtl_uString **strHostname); + + +/** Get the socket address member of Addr. + @return The socket address or 0 upon failure. +*/ +oslSocketAddr SAL_CALL osl_getSocketAddrOfHostAddr(const oslHostAddr Addr); + +/** Retrieve this machines hostname. + May not always be a fully qualified domain name (FQDN). + @param strLocalHostname [out] The string that receives the local host name. + @return True upon success, False otherwise. +*/ +oslSocketResult SAL_CALL osl_getLocalHostname(rtl_uString **strLocalHostname); + + +/**@} end section oslHostAddr +*/ + +/**@{ begin section oslSocket +*/ + + +/*-***************************************************************************/ +/* oslSocket */ +/*-***************************************************************************/ + +typedef void* oslSocket; + +/** Create a socket of the specified Family and Type. The semantic of + the Protocol parameter depends on the given family and type. + @return 0 if socket could not be created, otherwise you get a handle + to the allocated socket-datastructure. +*/ +oslSocket SAL_CALL osl_createSocket(oslAddrFamily Family, + oslSocketType Type, + oslProtocol Protocol); + +/** Create a socket as a copy of another. + @return 0 if socket could not be created, otherwise you get a handle + to the allocated socket-datastructure. +*/ +oslSocket SAL_CALL osl_copySocket(oslSocket Socket); + +/** Closes the socket and frees the Socket data-structure. + For a graceful termination of a connection, you should call + osl_shutdownSocket() first. + @param Socket [in] The Socket to be closed and destroyed. +*/ +void SAL_CALL osl_destroySocket(oslSocket Socket); + + +/** Retrieves the Address of the local end of the socket. + Note that a socket must be bound or connected before + a vaild address can be returned. + @return 0 if socket-address could not be created, otherwise you get + the created Socket-Address. +*/ +oslSocketAddr SAL_CALL osl_getLocalAddrOfSocket(oslSocket Socket); + +/** Retrieves the Address of the remote end of the socket. + Note that a socket must be connected before + a vaild address can be returned. + @return 0 if socket-address could not be created, otherwise you get + the created Socket-Address. +*/ +oslSocketAddr SAL_CALL osl_getPeerAddrOfSocket(oslSocket Socket); + +/** Binds the given address to the socket. + @param Socket [in] + @param Address [in] + @return False if the bind failed. +*/ +sal_Bool SAL_CALL osl_bindAddrToSocket(oslSocket Socket, + oslSocketAddr Addr); + +/** Connects the socket to the given address. + + @param Socket [in] a bound socket. + @param Addr [in] the peer address. + @param pTimeout Timeout value or NULL for blocking. + + @return osl_sock_result_ok on successful connection, + osl_sock_result_timeout if operation timed out, + osl_sock_result_interrupted if operation was interrupted + osl_sock_result_error if the connection failed. +*/ +oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket Socket, + oslSocketAddr Addr, + const TimeValue* pTimeout); + + +/** Prepares the socket to act as an acceptor of incoming connections. + You should call "listen" before you use "accept". + @param MaxPendingConnections [in] denotes the length of the queue of + pending connections for this socket. If MaxPendingConnections is + -1, the systems default value will be used (Usually 5). + @return False if the listen failed. +*/ +sal_Bool SAL_CALL osl_listenOnSocket(oslSocket Socket, + sal_Int32 MaxPendingConnections); + + +/** Waits for an ingoing connection on the socket. + This call blocks if there is no incoming connection present. + @param pAddr [in] if pAddr is != 0, the peers address is returned. + @return 0 if the accept-call failed, otherwise you get a socket + representing the new connection. +*/ +oslSocket SAL_CALL osl_acceptConnectionOnSocket(oslSocket Socket, + oslSocketAddr* pAddr); + +/** Tries to receive BytesToRead data from the connected socket, + if no error occurs. Note that incomplete recvs due to + packet boundaries may occur. + + @param Socket [in] A connected socket to be used to listen on. + @param pBuffer [out] Points to a buffer that will be filled with the received + data. + @param BytesToRead [in] The number of bytes to read. pBuffer must have at least + this size. + @param Flag [in] Modifier for the call. Valid values are: + <ul> + <li> osl_msg_normal, + <li> osl_msg_oob, + <li> osl_msg_peek, + <li> osl_msg_dontroute, + <li> osl_msg_maxiovlen, + </ul> + + @return the number of received bytes. +*/ +sal_Int32 SAL_CALL osl_receiveSocket(oslSocket Socket, + void* pBuffer, + sal_uInt32 BytesToRead, + oslSocketMsgFlag Flag); + +/** Tries to receives BufferSize data from the (usually unconnected) + (datagram-)socket, if no error occurs. + + @param Socket [in] A bound socket to be used to listen for a datagram. + @param SenderAddr [out] An initialized oslSocketAddress. It will be + filled with the address of the datagrams sender. If SenderAddr is 0, + it is ignored. + @param pBuffer [out] Points to a buffer that will be filled with the received + datagram. + @param BufferSize [in] The size of pBuffer. + @param Flag [in] Modifier for the call. Valid values are: + <ul> + <li> osl_msg_normal, + <li> osl_msg_oob, + <li> osl_msg_peek, + <li> osl_msg_dontroute, + <li> osl_msg_maxiovlen, + </ul> + + @return the number of received bytes. +*/ +sal_Int32 SAL_CALL osl_receiveFromSocket(oslSocket Socket, + oslSocketAddr SenderAddr, + void* pBuffer, + sal_uInt32 BufferSize, + oslSocketMsgFlag Flag); + +/** Tries to send BytesToSend data from the connected socket, + if no error occurs. + + @param Socket [in] A connected socket. + @param pBuffer [in] Points to a buffer that contains the send-data. + @param BytesToSend [in] The number of bytes to send. pBuffer must have at least + this size. + @param Flag [in] Modifier for the call. Valid values are: + <ul> + <li> osl_msg_normal, + <li> osl_msg_oob, + <li> osl_msg_peek, + <li> osl_msg_dontroute, + <li> osl_msg_maxiovlen, + </ul> + + @return the number of transfered bytes. +*/ +sal_Int32 SAL_CALL osl_sendSocket(oslSocket Socket, + const void* pBuffer, + sal_uInt32 BytesToSend, + oslSocketMsgFlag Flag); + +/** Tries to send one datagram with BytesToSend data to the given ReceiverAddr + via the (implicitly unconnected) datagram-socket. + Since we only send one packet, we don't need to concern ourselfes here with + incomplete sends due to packet boundaries. + + @param Socket [in] A bound or unbound socket. Socket will be bound + after a successful call. + + @param ReceiverAddr [in] An initialized oslSocketAddress that contains + the destination address for this send. + + @param pBuffer [in] Points to a buffer that contains the send-data. + @param BytesToSend [in] The number of bytes to send. pBuffer must have at least + this size. + @param Flag [in] Modifier for the call. Valid values are: + <ul> + <li> osl_msg_normal, + <li> osl_msg_oob, + <li> osl_msg_peek, + <li> osl_msg_dontroute, + <li> osl_msg_maxiovlen, + </ul> + + @return the number of transfered bytes. +*/ +sal_Int32 SAL_CALL osl_sendToSocket(oslSocket Socket, + oslSocketAddr ReceiverAddr, + const void* pBuffer, + sal_uInt32 BytesToSend, + oslSocketMsgFlag Flag); + +/** Checks if read operations will block. + You can specify a timeout-value in seconds/microseconds that denotes + how long the operation will block if the Socket is not ready. + @return True if read operations (recv, recvFrom, accept) on the Socket + will NOT block; False if it would block or if an error occured. + + @param Socket the Socket to perfom the operation on. + @param pTimeout if NULL, the operation will block without a timeout. Otherwise + the time define by timeout value. +*/ +sal_Bool SAL_CALL osl_isReceiveReady(oslSocket Socket, const TimeValue* pTimeout); + +/** Checks if send operations will block. + You can specify a timeout-value in seconds/microseconds that denotes + how long the operation will block if the Socket is not ready. + @return True if send operations (send, sendTo) on the Socket + will NOT block; False if it would block or if an error occured. + + @param Socket the Socket to perfom the operation on. + @param pTimeout if NULL, the operation will block without a timeout. Otherwise + the time define by timeout value. +*/ +sal_Bool SAL_CALL osl_isSendReady(oslSocket Socket, const TimeValue* pTimeout); + +/** Checks if a request for out-of-band data will block. + You can specify a timeout-value in seconds/microseconds that denotes + how long the operation will block if the Socket has no pending OOB data. + @return True if OOB-request operations (recv with appropriate flags) + on the Socket will NOT block; False if it would block or if an error occured. + + @param Socket the Socket to perfom the operation on. + @param pTimeout if NULL, the operation will block without a timeout. Otherwise + the time define by timeout value. +*/ +sal_Bool SAL_CALL osl_isExceptionPending(oslSocket Socket, const TimeValue* pTimeout); + +/** Shuts down communication on a connected socket. + @param Direction denotes which end of the socket + should be closed: + <ul> + <li> osl_shut_read closes read operations. + <li> osl_shut_write closes write operations. + <li> osl_shut_readwrite closes read and write operations. + </ul> + @return True if the socket could be closed down. +*/ +sal_Bool SAL_CALL osl_shutdownSocket(oslSocket Socket, + oslSocketDirection Direction); + +/** Retrieves attributes associated with the socket. + @param Socket is the socket to query. + + @param Level selects the level for which an option should be queried. + Valid values are: + <ul> + <li> osl_sol_socket: Socket Level + <li> osl_sol_tcp: Level of Transmission Control Protocol + </ul> + + @param Option denotes the option to query. + Valid values (depending on the Level) are: + <ul> + <li> osl_so_debug, + <li> osl_so_acceptconn, + <li> osl_so_reuseaddr, + <li> osl_so_keepalive, + <li> osl_so_dontroute, + <li> osl_so_broadcast, + <li> osl_so_useloopback, + <li> osl_so_linger, + <li> osl_so_oobinline, + <li> osl_so_sndbuf, + <li> osl_so_rcvbuf, + <li> osl_so_sndlowat, + <li> osl_so_rcvlowat, + <li> osl_so_sndtimeo, + <li> osl_so_rcvtimeo, + <li> osl_so_error, + <li> osl_so_type, + <li> osl_so_tcp_nodelay, (sol_tcp) + </ul> + If not above mentioned otherwise, the options are only valid for + level sol_socket. + + @param pBuffer Pointer to a Buffer with enough room to take the desired + attribute-value. + + @param BufferSize contains the length of the Buffer. + + @return -1 if an error occured or else the size of the data copied into + pBuffer. +*/ +sal_Int32 SAL_CALL osl_getSocketOption(oslSocket Socket, + oslSocketOptionLevel Level, + oslSocketOption Option, + void* pBuffer, + sal_uInt32 BufferLen); + +/** Sets the sockets attributes. + + @param Socket is the socket to modify. + + @param Level selects the level for which an option should be changed. + Valid values are: + <ul> + <li> osl_sol_socket: Socket Level + <li> osl_sol_tcp: Level of Transmission Control Protocol + </ul> + + @param Option denotes the option to modify. + Valid values (depending on the Level) are: + <ul> + <li> osl_so_debug, + <li> osl_so_acceptconn, + <li> osl_so_reuseaddr, + <li> osl_so_keepalive, + <li> osl_so_dontroute, + <li> osl_so_broadcast, + <li> osl_so_useloopback, + <li> osl_so_linger, + <li> osl_so_oobinline, + <li> osl_so_sndbuf, + <li> osl_so_rcvbuf, + <li> osl_so_sndlowat, + <li> osl_so_rcvlowat, + <li> osl_so_sndtimeo, + <li> osl_so_rcvtimeo, + <li> osl_so_error, + <li> osl_so_type, + <li> osl_so_tcp_nodelay, (sol_tcp) + </ul> + If not above mentioned otherwise, the options are only valid for + level sol_socket. + + @param pBuffer Pointer to a Buffer which contains the attribute-value. + + @param BufferSize contains the length of the Buffer. + + @return True if the option could be changed. +*/ +sal_Bool SAL_CALL osl_setSocketOption(oslSocket Socket, + oslSocketOptionLevel Level, + oslSocketOption Option, + void* pBuffer, + sal_uInt32 BufferLen); + +/** Enables/disables non-blocking-mode of the socket. + @param Socket Change mode for this socket. + @param On True: enable non-blocking mode, False: disable non-blocking mode. + @return True if mode could be changed. +*/ +sal_Bool SAL_CALL osl_enableNonBlockingMode(oslSocket Socket, + sal_Bool On); + + +/** Query state of non-blocking-mode of the socket. + @param Socket Query mode for this socket. + @return True if non-blocking-mode is enabled. +*/ +sal_Bool SAL_CALL osl_isNonBlockingMode(oslSocket Socket); + + +/** Queries the socket for its type. + @return one of: + <ul> + <li> osl_sock_stream, + <li> osl_sock_dgram, + <li> osl_sock_raw, + <li> osl_sock_rdm, + <li> osl_sock_seqpacket, + <li> osl_invalid_SocketType, if an error occured + </ul> + +*/ +oslSocketType SAL_CALL osl_getSocketType(oslSocket Socket); + +/** Delivers a string which describes the last socket error. + @param strError The string that receives the error message. + than the provided buffer, it will be cut short. Buffer sizes about 128 chars + should be large enough. +*/ +void SAL_CALL osl_getLastSocketErrorDescription(oslSocket Socket, rtl_uString **strError); + +/** Delivers a constant decribing the last error for the socket system. + @return osl_Socket_E_NONE if no error occured, osl_invalid_SocketError if + an unknown (unmapped) error occured, otherwise an enum describing the + error. +*/ +oslSocketError SAL_CALL osl_getLastSocketError(oslSocket Socket); + +/** Type for the representation of socket sets. +*/ +typedef void* oslSocketSet; + +/** Creates a set of sockets to be used with osl_demultiplexSocketEvents(). + @return A oslSocketSet or 0 if creation failed. +*/ +oslSocketSet SAL_CALL osl_createSocketSet(); + +/** Destroys a oslSocketSet. +*/ +void SAL_CALL osl_destroySocketSet(oslSocketSet Set); + +/** Clears the set from all previously added sockets. + @param Set the set to be cleared. +*/ +void SAL_CALL osl_clearSocketSet(oslSocketSet Set); + + +/** Adds a socket to the set. + @param Set the set were the socket is added. + @param Socket the socket to be added. +*/ +void SAL_CALL osl_addToSocketSet(oslSocketSet Set, oslSocket Socket); + +/** Removes a socket from the set. + @param Set the set were the socket is removed from. + @param Socket the socket to be removed. +*/ +void SAL_CALL osl_removeFromSocketSet(oslSocketSet Set, oslSocket Socket); + +/** Checks if socket is in the set. + @param Set the set to be checked. + @param Socket check if this socket is in the set. + @return True if socket is in the set. +*/ +sal_Bool SAL_CALL osl_isInSocketSet(oslSocketSet Set, oslSocket Socket); + +/** Checks multiple sockets for events. + @param IncomingSet Checks the sockets in this set + for incoming events (read, accept). If the set is 0, + it is just skipped. + @param OutgoingSet Checks the sockets in this set + for outgoing events (write, connect). If the set is 0, + it is just skipped. + @param OutOfBandSet Checks the sockets in this set + for out-of-band events. If the set is 0, it is just skipped. + @param msTimeout Number of milliseconds to wait for events. If + msTimeout is -1, the call will block until an event or an error + occurs. + @return -1 on errors, otherwise the number of sockets with + pending events. In case of timeout, the number might be 0. +*/ +sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet, + oslSocketSet OutgoingSet, + oslSocketSet OutOfBandSet, + const TimeValue* pTimeout); + +void SAL_CALL osl_closeSocket(oslSocket Socket); + + +/**@} end section oslSocket +*/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_SOCKET_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.8 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.7 2000/06/27 15:45:29 mhu +* Added function osl_createInetBroadcastAddr(). +* +* Revision 1.6 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.5 2000/03/31 15:56:19 rs +* UNICODE-Changes +* +* Revision 1.4 2000/03/20 08:56:22 obr +* Unicode API changes +* +* Revision 1.3 2000/03/16 16:43:53 obr +* Unicode API changes +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:20 jsc +* verschoben aus osl +* +* Revision 1.22 1999/08/05 11:14:43 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.21 1999/07/21 16:13:06 ts +* #67730# changed channel maneger api +* +* Revision 1.20 1999/03/04 09:58:37 rh +* #62583 compare socketaddr +* +* Revision 1.19 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.18 1998/03/13 15:07:32 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.17 1998/02/16 19:34:52 rh +* Cleanup of ports, integration of sal_uInt32, features for process +* +* Revision 1.16 1997/12/09 10:55:40 mib +* AIX +* +* Revision 1.15 1997/11/25 10:14:40 fm +* initial release for S/390 +* +* Revision 1.14 1997/10/16 16:12:04 rh +* *** empty log message *** +* +* Revision 1.13 1997/10/15 10:26:02 mhu +* Added function: sal_Bool osl_getLocalHostname (sal_Char *pBuffer, int BufferSize) +* +* Revision 1.12 1997/09/15 10:53:54 mhu +* Added function osl_copyHostAddr(const oslHostAddr Addr). +* +* Revision 1.11 1997/09/09 12:03:29 fm +* *** empty log message *** +* +* Revision 1.10 1997/09/08 17:17:53 mhu +* Added support for domain name resolution (oslHostAddr). +* +* Revision 1.9 1997/09/04 09:51:44 rh +* Blockmode +* +* Revision 1.8 1997/08/23 20:36:40 rh +* return value for name resolving +* +* Revision 1.7 1997/08/22 14:47:36 rh +* TimeValue inserted +* +* Revision 1.6 1997/07/31 18:28:54 rh +* Standard types adapted +* +* Revision 1.5 1997/07/31 15:28:40 ts +* *** empty log message *** +* +* Revision 1.4 1997/07/17 11:02:28 rh +* Header adapted and profile added +* +* Revision 1.3 1997/06/25 13:16:31 rh +* Formatting +* +* Revision 1.2 1997/06/25 08:44:40 bho +* !changed implementation of sems to SYS V, because POSIX Sems are not +* supported yet by solaris. +* +* Revision 1.1 1997/06/19 13:10:11 bho +* first version of OSL. +* +*************************************************************************/ + diff --git a/sal/inc/osl/thread.h b/sal/inc/osl/thread.h new file mode 100644 index 000000000000..15fc7e8f4f9b --- /dev/null +++ b/sal/inc/osl/thread.h @@ -0,0 +1,329 @@ +/************************************************************************* + * + * $RCSfile: thread.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_THREAD_H_ +#define _OSL_THREAD_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifndef _RTL_TEXTENC_H_ +# include <rtl/textenc.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Opaque data type for threads. As with all other osl-handles + you can initialize and/or test it to/for 0. +*/ +typedef void* oslThread; + +/** the function-ptr. representing the threads worker-function. +*/ +typedef void (SAL_CALL *oslWorkerFunction)(void*); + +/** levels of thread-priority + Note that oslThreadPriorityUnknown might be returned + by getPriorityOfThread() (e.g. when it is terminated), + but mustn't be used with setPriority()! +*/ +typedef enum +{ + osl_Thread_PriorityHighest, + osl_Thread_PriorityAboveNormal, + osl_Thread_PriorityNormal, + osl_Thread_PriorityBelowNormal, + osl_Thread_PriorityLowest, + osl_Thread_PriorityUnknown, /* don't use to set */ + osl_Thread_Priority_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslThreadPriority; + + +typedef enum +{ + osl_Thread_SleepNormal, + osl_Thread_SleepCancel, + osl_Thread_SleepPending, + osl_Thread_SleepActive, + osl_Thread_SleepError, + osl_Thread_SleepUnknown, /* don't use to set */ + osl_Thread_Sleep_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} oslThreadSleep; + +typedef sal_uInt32 oslThreadIdentifier; + +typedef sal_uInt32 oslThreadKey; + +/** Create the thread, using the function-ptr pWorker as + its main (worker) function. This functions receives in + its void* parameter the value supplied by pThreadData. + Once the OS-structures are initialized,the thread starts + running. + @return 0 if creation failed, otherwise a handle to the thread +*/ +oslThread SAL_CALL osl_createThread(oslWorkerFunction pWorker, void* pThreadData); + +/** Create the thread, using the function-ptr pWorker as + its main (worker) function. This functions receives in + its void* parameter the value supplied by pThreadData. + The thread will be created, but it won't start running. + To wake-up the thread, use resume(). + @return 0 if creation failed, otherwise a handle to the thread +*/ +oslThread SAL_CALL osl_createSuspendedThread(oslWorkerFunction pWorker, void* pThreadData); + +/** Get the identifier for the specified thread or if parameter + Thread is NULL of the current active thread. + @return identifier of the thread +*/ +oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread); + +/** Forcefully abort the thread, if it is still running. + Then release the OS-structures and our thread data-structure. + If Thread is NULL, the function won't do anything. +*/ +void SAL_CALL osl_destroyThread(oslThread Thread); + +/** Release our thread data-structure. + If Thread is NULL, the function won't do anything. + Note that we do not interfere with the actual running of + the thread, we just free up the memory needed by the handle. +*/ +void SAL_CALL osl_freeThreadHandle(oslThread Thread); + +/** Wake-up a thread that was suspended with suspend() or + createSuspended(). The oslThread must be valid! +*/ +void SAL_CALL osl_resumeThread(oslThread Thread); + +/** Suspend the execution of the thread. If you want the thread + to continue, call resume(). The oslThread must be valid! +*/ +void SAL_CALL osl_suspendThread(oslThread Thread); + +/** Changes the threads priority. + The oslThread must be valid! +*/ +void SAL_CALL osl_setThreadPriority(oslThread Thread, oslThreadPriority Priority); + +/** Retrieves the threads priority. + Returns oslThreadPriorityUnknown for invalid Thread-argument or + terminated thread. (I.e.: The oslThread might be invalid.) +*/ +oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread); + +/** Returns True if the thread was created and has not terminated yet. + Note that according to this definition a "running" thread might be + suspended! Also returns False is Thread is NULL. +*/ +sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread); + +/** Blocks the calling thread until Thread has terminated. + Returns immediately if Thread is NULL. +*/ +void SAL_CALL osl_joinWithThread(oslThread Thread); + +/** Blocks the calling thread at least for the given number of + of time. Returns False if the sleep is aborted by a call + to awakeThread. +*/ +oslThreadSleep SAL_CALL osl_sleepThread(oslThread Thread, const TimeValue* pDelay); + +/** Awake a sleeping thread. Returns False if at least one of + the handles is invalid or the thread is not sleeping. +*/ +sal_Bool SAL_CALL osl_awakeThread(oslThread Thread); + +/** Blocks the calling thread at least for the given number + of time. +*/ +void SAL_CALL osl_waitThread(const TimeValue* pDelay); + +/** The requested thread will get terminate the next time + scheduleThread() is called. +*/ +void SAL_CALL osl_terminateThread(oslThread Thread); + +/** Offers the rest of the threads time-slice to the OS. + scheduleThread() should be called in the working loop + of the thread, so any other thread could also get the + processor. Returns False if the thread should terminate, so + the thread could free any allocated resources. +*/ +sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread); + +/** Offers the rest of the threads time-slice to the OS. + Under POSIX you _need_ to yield(), otherwise, since the + threads are not preempted during execution, NO other thread + (even with higher priority) gets the processor. Control is + only given to another thread if the current thread blocks + or uses yield(). +*/ +void SAL_CALL osl_yieldThread(void); + +/** Create a key to an associated thread local storage pointer. */ +oslThreadKey SAL_CALL osl_createThreadKey(void); + +/** Destroy a key to an associated thread local storage pointer. */ +void SAL_CALL osl_destroyThreadKey(oslThreadKey Key); + +/** Get to key associated thread specific data. */ +void* SAL_CALL osl_getThreadKeyData(oslThreadKey Key); + +/** Set to key associated thread specific data. */ +sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData); + +/** Get the current thread local text encoding. */ +rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(); + +/** Set the thread local text encoding. + @return the old text encoding. +*/ +rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding(rtl_TextEncoding Encoding); + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_THREAD_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.9 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.8 2000/07/31 09:34:24 mfe +* changed declaration of setthreadtextenconding +* +* Revision 1.7 2000/07/27 20:23:46 patrick.luby +* Set osl_setThreadTextEncoding prototype to match function definition in +* osl/unx/thread.c file. +* +* Revision 1.6 2000/05/29 16:45:16 hro +* SRC591: Explicite SAL_CALL calling convention +* +* Revision 1.5 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.4 2000/03/27 09:16:51 hro +* UNICODE New osl_getThreadTextEncoding +* +* Revision 1.3 1999/12/22 13:38:17 mfe +* some clean up +* +* Revision 1.2 1999/10/27 15:02:08 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:20 jsc +* verschoben aus osl +* +* Revision 1.15 1999/08/05 11:14:44 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.14 1999/03/19 09:05:58 jsc +* #60455# osl_isCurrentThresad entfernt +* +* Revision 1.13 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.12 1998/11/05 11:13:16 rh +* #59037# Thread local storage implementation +* +* Revision 1.11 1998/03/13 15:07:33 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.10 1998/02/26 18:35:27 rh +* Avoid unix zombies and rename oslThreadHandle to oslThread +* +* Revision 1.9 1998/02/16 19:34:52 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.8 1997/10/16 16:35:51 rh +* *** empty log message *** +* +* Revision 1.7 1997/10/16 16:26:08 rh +* *** empty log message *** +* +* Revision 1.6 1997/09/09 12:03:30 fm +* *** empty log message *** +* +* Revision 1.5 1997/08/22 14:47:38 rh +* TimeValue inserted +* +* Revision 1.4 1997/07/22 14:29:30 rh +* process added +* +* Revision 1.3 1997/07/17 11:02:29 rh +* Header adapted and profile added +* +* Revision 1.2 1997/07/14 09:09:12 rh +* Adaptions for killable sleeps +* +* Revision 1.1 1997/06/19 13:10:13 bho +* first version of OSL. +* +*************************************************************************/ + diff --git a/sal/inc/osl/time.h b/sal/inc/osl/time.h new file mode 100644 index 000000000000..660159935e9e --- /dev/null +++ b/sal/inc/osl/time.h @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: time.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_TIME_H_ +#define _OSL_TIME_H_ + +#ifndef _OSL_TYPES_H_ +# include <osl/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************/ +/* oslDateTime */ +/****************************************************************************/ + +typedef struct _oslDateTime +{ + //------------------------------------------------------------------------- + /** contains the nanoseconds . + */ + sal_uInt32 NanoSeconds; + + //------------------------------------------------------------------------- + /** contains the seconds (0-59). + */ + sal_uInt16 Seconds; + + //------------------------------------------------------------------------- + /** contains the minutes (0-59). + */ + sal_uInt16 Minutes; + + //------------------------------------------------------------------------- + /** contains the hour (0-23). + */ + sal_uInt16 Hours; + + //------------------------------------------------------------------------- + /** is the day of month (1-31). + */ + sal_uInt16 Day; + + //------------------------------------------------------------------------- + /** is the day of week (0-6 , 0 : Sunday). + */ + sal_uInt16 DayOfWeek; + + //------------------------------------------------------------------------- + /** is the month of year (1-12). + */ + sal_uInt16 Month; + + //------------------------------------------------------------------------- + /** is the year. + */ + sal_uInt16 Year; + +} oslDateTime; + + +/** Get the current system time as TimeValue. + @return false if any error occurs. +*/ +sal_Bool SAL_CALL osl_getSystemTime( TimeValue* pTimeVal ); + + +/** Get the GMT from a TimeValue and fill a struct oslDateTime + @param pTimeVal[in] TimeValue + @param pDateTime[out] On success it receives a struct oslDateTime + + @return sal_False if any error occurs else sal_True. +*/ +sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime* pDateTime ); + + +/** Get the GMT from a oslDateTime and fill a TimeValue + @param pDateTime[in] oslDateTime + @param pTimeVal[out] On success it receives a TimeValue + + @return sal_False if any error occurs else sal_True. +*/ +sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValue* pTimeVal ); + + +/** Convert GMT to local time + @param pSystemTimeVal[in] system time to convert + @param pLocalTimeVal[out] On success it receives the local time + + @return sal_False if any error occurs else sal_True. +*/ +sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal ); + + +/** Convert local time to GMT + @param pLocalTimeVal[in] local time to convert + @param pSystemTimeVal[out] On success it receives the system time + + @return sal_False if any error occurs else sal_True. +*/ +sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal ); + + +#ifdef __cplusplus +} +#endif + +#endif /* _OSL_TIME_H_ */ + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.6 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.5 2000/08/18 14:01:05 rs +* new time functions +* +* Revision 1.4 2000/07/26 15:12:52 rs +* DateTime functions +* +* Revision 1.3 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.2 1999/10/27 15:02:09 mfe +* Change of Copyright, removed compiler warnings, code clean up, ... +* +* Revision 1.1 1999/08/05 10:18:20 jsc +* verschoben aus osl +* +* Revision 1.7 1999/08/05 11:14:44 jsc +* verschoben in root inc-Verzeichnis +* +* Revision 1.6 1999/01/20 18:53:41 jsc +* #61011# Typumstellung +* +* Revision 1.5 1998/03/13 15:07:33 rh +* Cleanup of enum chaos and implemntation of pipes +* +* Revision 1.4 1998/02/16 19:34:52 rh +* Cleanup of ports, integration of Size_t, features for process +* +* Revision 1.3 1997/08/22 14:47:38 rh +* TimeValue inserted +* +* Revision 1.2 1997/07/23 07:07:02 rh +* Change Micor to Nano-seconds +* +* Revision 1.1 1997/07/21 19:13:13 rh +* getSystemTime added +* +*************************************************************************/ diff --git a/sal/inc/osl/util.h b/sal/inc/osl/util.h new file mode 100644 index 000000000000..d0e26c3fd6dd --- /dev/null +++ b/sal/inc/osl/util.h @@ -0,0 +1,130 @@ +/************************************************************************* + * + * $RCSfile: util.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _OSL_UTIL_H_ +#define _OSL_UTIL_H_ + +#include "sal/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*** + * + * @param pEthernetAddr 6 bytes of memory + * + * @return sal_True if the ethernetaddress could be retrieved. <br> + * sal_False if no address could be found. This may be either because + * there is no ethernet card or there is no appropriate algorithm + * implemented on the platform. In this case, pEthernetAddr is + * unchanged. + * + ***/ +sal_Bool SAL_CALL osl_getEthernetAddress( sal_uInt8 *pEthernetAddr ); + +/** + @deprecated + Set the solar build number. Affect the profile function from osl and + the ORealDynamicLoader class from vos. + Default is the SUPD from the build process if it was build with the + solar environment, otherwise 0. + */ +void SAL_CALL osl_setSUPD( sal_Int32 n ); + +/** + @deprecated + Return the solar build number + */ +sal_Int32 SAL_CALL osl_getSUPD(); + +#ifdef __cplusplus +} +#endif + +#endif + +/************************************************************************* +* +* $Log: not supported by cvs2svn $ +* Revision 1.7 2000/09/18 14:28:49 willem.vandorp +* OpenOffice header added. +* +* Revision 1.6 2000/05/26 10:12:13 hro +* SAL_CALL for osl_getSUPD, osl_getSUPD +* +* Revision 1.5 2000/05/17 14:50:15 mfe +* comments upgraded +* +* Revision 1.4 2000/03/16 16:43:53 obr +* Unicode API changes +* +* Revision 1.3 2000/03/16 14:16:34 mm +* #74230# setSUPD +* +* Revision 1.2 1999/12/06 14:59:18 jbu +* osl_getEthernetAddress added +* +* Revision 1.1 1999/10/25 09:48:05 mfe +* added getEtherAddr +* +*************************************************************************/ diff --git a/sal/inc/rtl/alloc.h b/sal/inc/rtl/alloc.h new file mode 100644 index 000000000000..67bbaa8706cd --- /dev/null +++ b/sal/inc/rtl/alloc.h @@ -0,0 +1,116 @@ +/************************************************************************* + * + * $RCSfile: alloc.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_ALLOC_H_ +#define _RTL_ALLOC_H_ + +#ifndef _SAL_TYPES_H_ +# include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/** Allocate memory. + * @param Bytes [in] memory size. + * @return pointer to allocated memory. + */ +void * SAL_CALL rtl_allocateMemory (sal_uInt32 Bytes); + + +/** Reallocate memory. + * @param Ptr [in] pointer to previously allocated memory. + * @param Bytes [in] new memory size. + * @return pointer to reallocated memory. May differ from Ptr. + */ +void * SAL_CALL rtl_reallocateMemory (void *Ptr, sal_uInt32 Bytes); + + +/** Free memory. + * @param Ptr [in] pointer to previously allocated memory. + * @return none. Memory is released. Ptr is invalid. + */ +void SAL_CALL rtl_freeMemory (void *Ptr); + + +/** Allocate and zero memory. + * @param Bytes [in] memory size. + * @return pointer to allocated and zero'ed memory. + */ +void * SAL_CALL rtl_allocateZeroMemory (sal_uInt32 Bytes); + + +/** Zero and free memory. + * @param Ptr [in] pointer to previously allocated memory. + * @param Bytes [in] memory size. + * @return none. Memory is zero'ed and released. Ptr is invalid. + */ +void SAL_CALL rtl_freeZeroMemory (void *Ptr, sal_uInt32 Bytes); + + +#ifdef __cplusplus +} +#endif + +#endif /*_RTL_ALLOC_H_ */ + diff --git a/sal/inc/rtl/byteseq.h b/sal/inc/rtl/byteseq.h new file mode 100644 index 000000000000..c4d5c5b1f694 --- /dev/null +++ b/sal/inc/rtl/byteseq.h @@ -0,0 +1,330 @@ +/************************************************************************* + * + * $RCSfile: byteseq.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _RTL_BYTESEQ_H_ +#define _RTL_BYTESEQ_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** Assures that the reference count of the given byte sequence is one. + Otherwise a new copy of the sequence is created with a reference count of one. + <br> + @param ppSequence sequence +*/ +void SAL_CALL rtl_byte_sequence_reference2One( + sal_Sequence ** ppSequence ); + +/** Reallocates length of byte sequence. + <br> + @param ppSequence sequence + @param nSize new size of sequence +*/ +void SAL_CALL rtl_byte_sequence_realloc( + sal_Sequence ** ppSequence, sal_Int32 nSize ); + +/** Acquires the byte sequence <br> + @param pSequence sequence, that shall be acquired. + */ +void SAL_CALL rtl_byte_sequence_acquire( sal_Sequence *pSequence ); + +/** Releases the byte sequence. If the refcount drops to zero, + * the sequence is freed.<br> + + @param pSequence sequence, that shall be released. Invalid after call. + */ +void SAL_CALL rtl_byte_sequence_release( sal_Sequence *pSequence ); + +/** Constructs a bytes sequence with length nLength. All bytes are set to zero. + * + * @param On entry *ppSequence may be null , otherwise it is released. + * After the call, ppSequence contains the newly constructed sequence. + * + * + **/ +void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32 nLength ); + +/** Constructs a bytes sequence with length nLength. The data is not initialized. + * + * @param ppSequence contains the newly constructed sequence. + * *ppSequence is released on entry if needed. + * + **/ +void SAL_CALL rtl_byte_sequence_constructNoDefault( + sal_Sequence **ppSequence , sal_Int32 nLength ); + +/** Constructs a byte sequence with length nLength and copies nLength bytes from pData. + * + * @param ppSequence contains the newly constructed sequence. + * *ppSequence is released on entry if needed. + **/ +void SAL_CALL rtl_byte_sequence_constructFromArray( + sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength ); + +/** Assigns the byte sequence pSequence to ppSequence. + * + * @param On entry *ppSequence may be null , otherwise it is released. + * ppSequence contains after the call a copy of pSequence. + * @param pSequence the source sequence + **/ +void SAL_CALL rtl_byte_sequence_assign( sal_Sequence **ppSequence , sal_Sequence *pSequence ); + +/** Compares two byte sequences. + * + * @return sal_False, if the data within the sequences are different. <br> + * sal_True, if the data within the sequences are identical <br> + **/ +sal_Bool SAL_CALL rtl_byte_sequence_equals( sal_Sequence *pSequence1 , sal_Sequence *pSequence2 ); + + +/** Returns the data pointer of the sequence. + * + * @return const pointer to the data of the sequence. If rtl_byte_sequence_reference2One + * has been called before, the pointer may be casted to a non const pointer and + * the sequence may be modified. + **/ +const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray( sal_Sequence *pSequence ); + +/** Returns the length of the sequence + * + * + **/ +sal_Int32 SAL_CALL rtl_byte_sequence_getLength( sal_Sequence *pSequence ); + +#ifdef __cplusplus +} +namespace rtl +{ + +enum __ByteSequence_NoDefault +{ + /** This enum value can be used to create a bytesequence with uninitalized data. + <br> + */ + BYTESEQ_NODEFAULT = 0xcafe +}; + +enum __ByteSequence_NoAcquire +{ + /** This enum value can be used to create a bytesequence from a C-Handle without + acquiring the handle. + <br> + */ + BYTESEQ_NOACQUIRE = 0xcafebabe +}; +/** C++ class representing a SAL byte sequence.<br> + C++ Sequences are reference counted and shared, so the sequence keeps a handle + to its data. + To keep value semantics, copies are only generated if the sequence is to be modified + (new handle). + <br> +*/ +class ByteSequence +{ + /** sequence handle<br> + */ + sal_Sequence * _pSequence; + +public: + /** Default constructor: + Creates an empty sequence. + <br> + */ + inline ByteSequence(); + /** Copy constructor: + Creates a copy of given sequence. + <br> + @param rSeq another byte sequence + */ + inline ByteSequence( const ByteSequence & rSeq ); + /** Copy constructor + Creates a copy from the C-Handle. + */ + inline ByteSequence( sal_Sequence *pSequence ); + /** Constructor: + Creates a copy of given bytes. + <br> + @param pElement an array of bytes + @param len number of bytes + */ + inline ByteSequence( const sal_Int8 * pElements, sal_Int32 len ); + /** Constructor: + Creates sequence of given length and initializes all bytes to 0. + <br> + @param len initial sequence length + */ + inline ByteSequence( sal_Int32 len ); + /** Constructor: + Creates sequence of given length and does NOT initialize data. Use + this ctor for performance optimization only. + <br> + @param len initial sequence length + @param dummy parameter + */ + inline ByteSequence( sal_Int32 len , enum __ByteSequence_NoDefault nodefault ); + /** Constructor: + Creates a sequence from a C-Handle without acquiring the handle. Eitherway + the handle is release by the destructor. This ctor is useful, when working + with a c-interface (it safes a pair of acquire and release call and is thus + a performance optimization only ). + <br> + */ + inline ByteSequence( sal_Sequence *pSequence , enum __ByteSequence_NoAcquire noacquire ); + /** Destructor: + Releases sequence handle. Last handle will free memory. + <br> + */ + inline ~ByteSequence(); + + /** Assignment operator: + Acquires given sequence handle and releases previously set handle. + <br> + @param rSeq another byte sequence + @return this sequence + */ + inline ByteSequence & SAL_CALL operator = ( const ByteSequence & rSeq ); + + /** Gets length of sequence. + <br> + @return length of sequence + */ + inline sal_Int32 SAL_CALL getLength() const + { return _pSequence->nElements; } + + /** Gets a pointer to byte array for <b>reading</b>. + If the sequence has a length of 0, then the returned pointer is undefined. + <br> + @return pointer to byte array + */ + inline const sal_Int8 * SAL_CALL getConstArray() const + { return (const sal_Int8 *)_pSequence->elements; } + /** Gets a pointer to elements array for <b>reading and writing</b>.<br> + In general if the sequence has a handle acquired by other sequences + (reference count > 1), then a new sequence is created copying + all bytes to keep value semantics!<br> + If the sequence has a length of 0, then the returned pointer is undefined. + <br> + @return pointer to elements array + */ + inline sal_Int8 * SAL_CALL getArray(); + + /** Non-const index operator: + Obtains a reference to byte indexed at given position.<br> + The implementation does <b>not</b> check for array bounds!<br> + In general if the sequence has a handle acquired by other sequences + (reference count > 1), then a new sequence is created copying + all bytes to keep value semantics! + <br> + @param nIndex index + @return non-const C++ reference to element + */ + inline sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex ) + { return getArray()[ nIndex ]; } + /** Const index operator: + Obtains a reference to byte indexed at given position.<br> + The implementation does <b>not</b> check for array bounds!<br> + <br> + @param nIndex index + @return const C++ reference to byte + */ + inline const sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex ) const + { return getConstArray()[ nIndex ]; } + + /** Equality operator: + Compares two sequences. + <br> + @param rSeq another byte sequence (right side) + @return true if both sequences are equal, false otherwise + */ + inline sal_Bool SAL_CALL operator == ( const ByteSequence & rSeq ) const; + /** Unequality operator: + Compares two sequences. + <br> + @param rSeq another byte sequence (right side) + @return false if both sequences are equal, true otherwise + */ + inline sal_Bool SAL_CALL operator != ( const ByteSequence & rSeq ) const + { return (! operator == ( rSeq )); } + + /** Reallocates sequence to new length. + If the sequence has a handle acquired by other sequences + (reference count > 1), then the remaining elements are copied + to a new sequence handle to keep value semantics! + <br> + @param nSize new size of sequence + */ + inline void SAL_CALL realloc( sal_Int32 nSize ); + + /** Returns the (unacquired) C-Handle of the sequence + * + **/ + inline sal_Sequence * SAL_CALL getHandle() + { return _pSequence; } +}; + +} +#endif +#endif diff --git a/sal/inc/rtl/byteseq.hxx b/sal/inc/rtl/byteseq.hxx new file mode 100644 index 000000000000..5fe4c0132ddd --- /dev/null +++ b/sal/inc/rtl/byteseq.hxx @@ -0,0 +1,155 @@ +/************************************************************************* + * + * $RCSfile: byteseq.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:13 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _RTL_BYTESEQ_HXX_ +#define _RTL_BYTESEQ_HXX_ + +#ifndef _OSL_INTERLOCK_H_ +#include <osl/interlck.h> +#endif +#ifndef _RTL_BYTESEQ_H_ +#include <rtl/byteseq.h> +#endif +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif +#ifndef _RTL_MEMORY_H_ +#include <rtl/memory.h> +#endif + + +namespace rtl +{ + +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence() + : _pSequence( 0 ) +{ + rtl_byte_sequence_construct( &_pSequence , 0 ); +} +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) : + _pSequence( 0 ) +{ + rtl_byte_sequence_assign( &_pSequence , rSeq._pSequence ); +} +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence( sal_Sequence *pSequence) : + _pSequence( pSequence ) +{ + rtl_byte_sequence_acquire( pSequence ); +} +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len ) + : _pSequence( 0 ) +{ + rtl_byte_sequence_constructFromArray( &_pSequence, pElements , len ); +} +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault value ) + : _pSequence( 0 ) +{ + rtl_byte_sequence_constructNoDefault( &_pSequence , len ); +} +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire value ) + : _pSequence( pSequence ) +{ +} +//__________________________________________________________________________________________________ +inline ByteSequence::ByteSequence( sal_Int32 len ) + : _pSequence( 0 ) +{ + rtl_byte_sequence_construct( &_pSequence , len ); +} +//__________________________________________________________________________________________________ +inline ByteSequence::~ByteSequence() +{ + rtl_byte_sequence_release( _pSequence ); +} +//__________________________________________________________________________________________________ +inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) +{ + rtl_byte_sequence_assign( &_pSequence , rSeq._pSequence ); + return *this; +} +//__________________________________________________________________________________________________ +inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const +{ + if (_pSequence == rSeq._pSequence) + return sal_True; + if (_pSequence->nElements != rSeq._pSequence->nElements) + return sal_False; + return (0 == ::rtl_compareMemory( _pSequence->elements, rSeq._pSequence->elements, _pSequence->nElements )); +} +//__________________________________________________________________________________________________ +inline sal_Int8 * ByteSequence::getArray() +{ + ::rtl_byte_sequence_reference2One( &_pSequence ); + return (sal_Int8 *)_pSequence->elements; +} +//__________________________________________________________________________________________________ +inline void ByteSequence::realloc( sal_Int32 nSize ) +{ + ::rtl_byte_sequence_realloc( &_pSequence, nSize ); +} + +} +#endif diff --git a/sal/inc/rtl/cipher.h b/sal/inc/rtl/cipher.h new file mode 100644 index 000000000000..f64685108773 --- /dev/null +++ b/sal/inc/rtl/cipher.h @@ -0,0 +1,275 @@ +/************************************************************************* + * + * $RCSfile: cipher.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_CIPHER_H_ +#define _RTL_CIPHER_H_ "$Revision: 1.1.1.1 $" + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*======================================================================== + * + * rtlCipher interface. + * + *======================================================================*/ +/** Opaque cipher handle. + */ +typedef void* rtlCipher; + + +/** rtlCipherAlgorithm. + * + * @see rtl_cipher_create. + */ +typedef enum +{ + rtl_Cipher_AlgorithmBF, + rtl_Cipher_AlgorithmInvalid, + rtl_Cipher_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlCipherAlgorithm; + + +/** rtlCipherMode. + * + * @see rtl_cipher_create. + */ +typedef enum +{ + rtl_Cipher_ModeECB, + rtl_Cipher_ModeCBC, + rtl_Cipher_ModeStream, + rtl_Cipher_ModeInvalid, + rtl_Cipher_Mode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlCipherMode; + + +/** rtlCipherDirection. + * + * @see rtl_cipher_init. + */ +typedef enum +{ + rtl_Cipher_DirectionBoth, + rtl_Cipher_DirectionDecode, + rtl_Cipher_DirectionEncode, + rtl_Cipher_DirectionInvalid, + rtl_Cipher_Direction_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlCipherDirection; + + +/** rtlCipherError. + */ +typedef enum +{ + rtl_Cipher_E_None, + rtl_Cipher_E_Argument, + rtl_Cipher_E_Algorithm, + rtl_Cipher_E_Direction, + rtl_Cipher_E_Mode, + rtl_Cipher_E_BufferSize, + rtl_Cipher_E_Memory, + rtl_Cipher_E_Unknown, + rtl_Cipher_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlCipherError; + + +/** rtl_cipher_create. + * Create a cipher handle for the given algorithm and mode. + * + * @param Algorithm [in] + * @param Mode [in] + * @return Cipher handle, or 0 upon failure. + */ +rtlCipher SAL_CALL rtl_cipher_create ( + rtlCipherAlgorithm Algorithm, + rtlCipherMode Mode); + + +/** rtl_cipher_init. + * + * @param Cipher [in] + * @param Direction [in] + * @param pKeyData [in] + * @param nKeyLen [in] + * @param pArgData [in] + * @param nArgLen [in] + * @return rtl_Cipher_E_None upon success. + */ +rtlCipherError SAL_CALL rtl_cipher_init ( + rtlCipher Cipher, + rtlCipherDirection Direction, + const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, + const sal_uInt8 *pArgData, sal_uInt32 nArgLen); + + +/** rtl_cipher_encode. + * + * @param Cipher [in] + * @param pData [in] + * @param nDatLen [in] + * @param pBuffer [out] + * @param nBufLen [in] + * @return rtl_Cipher_E_None upon success. + */ +rtlCipherError SAL_CALL rtl_cipher_encode ( + rtlCipher Cipher, + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + + +/** rtl_cipher_decode. + * + * @param Cipher [in] + * @param pData [in] + * @param nDatLen [in] + * @param pBuffer [out] + * @param nBufLen [in] + * @return rtl_Cipher_E_None upon success. + */ +rtlCipherError SAL_CALL rtl_cipher_decode ( + rtlCipher Cipher, + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + + +/** rtl_cipher_destroy. + * + * @param Cipher [in] handle to be destroyed. + * @return None. Cipher handle destroyed and invalid. + */ +void SAL_CALL rtl_cipher_destroy (rtlCipher Cipher); + + +/*======================================================================== + * + * rtl_cipherBF (Blowfish) interface. + * + * Reference: + * Bruce Schneier: Applied Cryptography, 2nd edition, ch. 14.3 + * + *======================================================================*/ +/** rtl_cipher_createBF. + * + * @return Cipher handle, or 0 upon failure. + * @see rtl_cipher_create. + */ +rtlCipher SAL_CALL rtl_cipher_createBF (rtlCipherMode Mode); + + +/** rtl_cipher_initBF. + * + * @return rtl_Cipher_E_None upon success. + * @see rtl_cipher_init. + */ +rtlCipherError SAL_CALL rtl_cipher_initBF ( + rtlCipher Cipher, + rtlCipherDirection Direction, + const sal_uInt8 *pKeyData, sal_uInt32 nKeyLen, + const sal_uInt8 *pArgData, sal_uInt32 nArgLen); + + +/** rtl_cipher_encodeBF. + * + * @return rtl_Cipher_E_None upon success. + * @see rtl_cipher_encode. + */ +rtlCipherError SAL_CALL rtl_cipher_encodeBF ( + rtlCipher Cipher, + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + + +/** rtl_cipher_decodeBF. + * + * @return rtl_Cipher_E_None upon success. + * @see rtl_cipher_decode. + */ +rtlCipherError SAL_CALL rtl_cipher_decodeBF ( + rtlCipher Cipher, + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + + +/** rtl_cipher_destroyBF. + * + * @param Cipher [in] handle to be destroyed. + * @return None. Cipher handle destroyed and invalid. + * @see rtl_cipher_destroy. + */ +void SAL_CALL rtl_cipher_destroyBF (rtlCipher Cipher); + +/*======================================================================== + * + * The End. + * + *======================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RTL_CIPHER_H_ */ + diff --git a/sal/inc/rtl/crc.h b/sal/inc/rtl/crc.h new file mode 100644 index 000000000000..fac1552b03af --- /dev/null +++ b/sal/inc/rtl/crc.h @@ -0,0 +1,100 @@ +/************************************************************************* + * + * $RCSfile: crc.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_CRC_H_ +#define _RTL_CRC_H_ "$Revision: 1.1.1.1 $" + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*======================================================================== + * + * rtl_crc32 interface. + * + *======================================================================*/ +/** Evaluate CRC32 over given data. + * + * @param Crc [in] CRC32 over previous data or zero. + * @param Data [in] data buffer. + * @param DatLen [in] data buffer length. + * @return new CRC32 value. + */ +sal_uInt32 SAL_CALL rtl_crc32 ( + sal_uInt32 Crc, + const void *Data, sal_uInt32 DatLen); + +/*======================================================================== + * + * The End. + * + *======================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_CRC_H_ */ + diff --git a/sal/inc/rtl/digest.h b/sal/inc/rtl/digest.h new file mode 100644 index 000000000000..a92f09ee5f68 --- /dev/null +++ b/sal/inc/rtl/digest.h @@ -0,0 +1,224 @@ +/************************************************************************* + * + * $RCSfile: digest.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_DIGEST_H_ +#define _RTL_DIGEST_H_ "$Revision: 1.1.1.1 $" + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*======================================================================== + * + * rtlDigest. + * + *======================================================================*/ +typedef void* rtlDigest; + +typedef enum { + rtl_Digest_AlgorithmMD2, + rtl_Digest_AlgorithmMD5, + rtl_Digest_AlgorithmSHA, + rtl_Digest_AlgorithmSHA1, + rtl_Digest_AlgorithmInvalid, + rtl_Digest_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlDigestAlgorithm; + +typedef enum { + rtl_Digest_E_None, + rtl_Digest_E_Argument, + rtl_Digest_E_Algorithm, + rtl_Digest_E_BufferSize, + rtl_Digest_E_Memory, + rtl_Digest_E_Unknown, + rtl_Digest_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlDigestError; + +rtlDigest SAL_CALL rtl_digest_create (rtlDigestAlgorithm Algorithm); +void SAL_CALL rtl_digest_destroy (rtlDigest Digest); + +rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (rtlDigest Digest); +sal_uInt32 SAL_CALL rtl_digest_queryLength (rtlDigest Digest); + +rtlDigestError SAL_CALL rtl_digest_update ( + rtlDigest Digest, + const void *pData, sal_uInt32 nDatLen); + +rtlDigestError SAL_CALL rtl_digest_get ( + rtlDigest Digest, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +/*======================================================================== + * + * rtl_digest_MD2 interface. + * + * Reference: + * RFC 1319 - The MD2 Message-Digest Algorithm (Informational) + * + *======================================================================*/ +#define RTL_DIGEST_LENGTH_MD2 16 + +rtlDigest SAL_CALL rtl_digest_createMD2 (void); +void SAL_CALL rtl_digest_destroyMD2 (rtlDigest Digest); + +rtlDigestError SAL_CALL rtl_digest_updateMD2 ( + rtlDigest Digest, + const void *pData, sal_uInt32 nDatLen); + +rtlDigestError SAL_CALL rtl_digest_getMD2 ( + rtlDigest Digest, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +rtlDigestError SAL_CALL rtl_digest_MD2 ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +/*======================================================================== + * + * rtl_digest_MD5 interface. + * + * Reference: + * RFC 1321 - The MD5 Message-Digest Algorithm (Informational) + * + *======================================================================*/ +#define RTL_DIGEST_LENGTH_MD5 16 + +rtlDigest SAL_CALL rtl_digest_createMD5 (void); +void SAL_CALL rtl_digest_destroyMD5 (rtlDigest Digest); + +rtlDigestError SAL_CALL rtl_digest_updateMD5 ( + rtlDigest Digest, + const void *pData, sal_uInt32 nDatLen); + +rtlDigestError SAL_CALL rtl_digest_getMD5 ( + rtlDigest Digest, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +rtlDigestError SAL_CALL rtl_digest_MD5 ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +/*======================================================================== + * + * rtl_digest_SHA interface. + * + * Reference: + * FIPS PUB 180 - Secure Hash Standard (Superseded by FIPS PUB 180-1) + * + *======================================================================*/ +#define RTL_DIGEST_LENGTH_SHA 20 + +rtlDigest SAL_CALL rtl_digest_createSHA (void); +void SAL_CALL rtl_digest_destroySHA (rtlDigest Digest); + +rtlDigestError SAL_CALL rtl_digest_updateSHA ( + rtlDigest Digest, + const void *pData, sal_uInt32 nDatLen); + +rtlDigestError SAL_CALL rtl_digest_getSHA ( + rtlDigest Digest, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +rtlDigestError SAL_CALL rtl_digest_SHA ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +/*======================================================================== + * + * rtl_digest_SHA1 interface. + * + * Reference: + * FIPS PUB 180-1 - Secure Hash Standard (Supersedes FIPS PUB 180) + * + *======================================================================*/ +#define RTL_DIGEST_LENGTH_SHA1 20 + +rtlDigest SAL_CALL rtl_digest_createSHA1 (void); +void SAL_CALL rtl_digest_destroySHA1 (rtlDigest Digest); + +rtlDigestError SAL_CALL rtl_digest_updateSHA1 ( + rtlDigest Digest, + const void *pData, sal_uInt32 nDatLen); + +rtlDigestError SAL_CALL rtl_digest_getSHA1 ( + rtlDigest Digest, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +rtlDigestError SAL_CALL rtl_digest_SHA1 ( + const void *pData, sal_uInt32 nDatLen, + sal_uInt8 *pBuffer, sal_uInt32 nBufLen); + +/*======================================================================== + * + * The End. + * + *======================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_DIGEST_H_ */ + diff --git a/sal/inc/rtl/locale.h b/sal/inc/rtl/locale.h new file mode 100644 index 000000000000..58a9174e34e5 --- /dev/null +++ b/sal/inc/rtl/locale.h @@ -0,0 +1,182 @@ +/************************************************************************* + * + * $RCSfile: locale.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_LOCALE_H_ +#define _RTL_LOCALE_H_ + +#ifndef _RTL_USTRING_ +#ifdef __BORLANDC__ +#include <rtl/wstring.> +#else +#include <rtl/ustring> +#endif /*__BORLANDC__*/ +#endif /*_RTL_USTRING_*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef SAL_W32 +# pragma pack(push, 8) +#elif defined(SAL_OS2) +# pragma pack(1) +#endif + +/** + * The implementation structur of a locale. Do not create this structure + * direct. Only use the functions rtl_locale_register and + * rtl_locale_setDefault. The strings Language, Country and Variant + * are constants, so it is not necessary to acquire and release them. + */ +typedef struct _rtl_Locale +{ + /** + * Lowercase two-letter ISO-639 code. + */ + rtl_uString * Language; + /** + * uppercase two-letter ISO-3166 code. + */ + rtl_uString * Country; + /** + * Lowercase vendor and browser specific code. + */ + rtl_uString * Variant; + /** + * The merged hash value of the Language, Country and Variant strings. + */ + sal_Int32 HashCode; +} rtl_Locale; + +#ifdef SAL_W32 +# pragma pack(pop) +#elif defined(SAL_OS2) +# pragma pack() +#endif + +/** + * Register a locale from language, country and variant. + * @param language lowercase two-letter ISO-639 code. + * @param country uppercase two-letter ISO-3166 code. May be null. + * @param variant vendor and browser specific code. May be null. + */ +rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ); + +/** + * Common method of getting the current default Locale. + * Used for the presentation: menus, dialogs, etc. + * Generally set once when your applet or application is initialized, + * then never reset. (If you do reset the default locale, you + * probably want to reload your GUI, so that the change is reflected + * in your interface.) + * <p>More advanced programs will allow users to use different locales + * for different fields, e.g. in a spreadsheet. + * <BR>Note that the initial setting will match the host system. + */ +rtl_Locale * SAL_CALL rtl_locale_getDefault(); + +/** + * Sets the default. + * Normally set once at the beginning of applet or application, + * then never reset. <code>setDefault</code> does not reset the host locale. + * @param language lowercase two-letter ISO-639 code. + * @param country uppercase two-letter ISO-3166 code. + * @param variant vendor and browser specific code. See class description. + */ +void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant ); + +/** + * Getter for programmatic name of field, + * an lowercased two-letter ISO-639 code. + * @see #getDisplayLanguage + */ +rtl_uString * SAL_CALL rtl_locale_getLanguage( rtl_Locale * This ); + +/** + * Getter for programmatic name of field, + * an uppercased two-letter ISO-3166 code. + * @see #getDisplayCountry + */ +rtl_uString * SAL_CALL rtl_locale_getCountry( rtl_Locale * This ); + +/** + * Getter for programmatic name of field. + * @see #getDisplayVariant + */ +rtl_uString * SAL_CALL rtl_locale_getVariant( rtl_Locale * This ); + +/** + * Returns the hash code of the locale This. + */ +sal_Int32 SAL_CALL rtl_locale_hashCode( rtl_Locale * This ); + +/** + * Returns true if the locals are equal, otherwis false. + */ +sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj ); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_LOCALE_H_ */ + + diff --git a/sal/inc/rtl/locale.hxx b/sal/inc/rtl/locale.hxx new file mode 100644 index 000000000000..4ee31db7e71c --- /dev/null +++ b/sal/inc/rtl/locale.hxx @@ -0,0 +1,316 @@ +/************************************************************************* + * + * $RCSfile: locale.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_LOCALE_HXX_ +#define _RTL_LOCALE_HXX_ + +#ifndef _RTL_LOCALE_H_ +#include <rtl/locale.h> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifdef __cplusplus + +#ifdef _USE_NAMESPACE +namespace rtl +{ +#endif + +/** + * + * A <code>OLocale</code> object represents a specific geographical, political, + * or cultural region. An operation that requires a <code>OLocale</code> to perform + * its task is called <em>locale-sensitive</em> and uses the <code>OLocale</code> + * to tailor information for the user. For example, displaying a number + * is a locale-sensitive operation--the number should be formatted + * according to the customs/conventions of the user's native country, + * region, or culture. + * + * <P> + * You create a <code>OLocale</code> object using one of the two constructors in + * this class: + * <blockquote> + * <pre> + * OLocale(String language, String country) + * OLocale(String language, String country, String variant) + * </pre> + * </blockquote> + * The first argument to both constructors is a valid <STRONG>ISO + * Language Code.</STRONG> These codes are the lower-case two-letter + * codes as defined by ISO-639. + * You can find a full list of these codes at a number of sites, such as: + * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt"> + * <code>http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</code></a> + * + * <P> + * The second argument to both constructors is a valid <STRONG>ISO Country + * Code.</STRONG> These codes are the upper-case two-letter codes + * as defined by ISO-3166. + * You can find a full list of these codes at a number of sites, such as: + * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html"> + * <code>http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</code></a> + * + * <P> + * The second constructor requires a third argument--the <STRONG>Variant.</STRONG> + * The Variant codes are vendor and browser-specific. + * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX. + * Where there are two variants, separate them with an underscore, and + * put the most important one first. For + * example, a Traditional Spanish collation might be referenced, with + * "ES", "ES", "Traditional_WIN". + * + * <P> + * Because a <code>OLocale</code> object is just an identifier for a region, + * no validity check is performed when you construct a <code>OLocale</code>. + * If you want to see whether particular resources are available for the + * <code>OLocale</code> you construct, you must query those resources. For + * example, ask the <code>NumberFormat</code> for the locales it supports + * using its <code>getAvailableLocales</code> method. + * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular + * locale, you get back the best available match, not necessarily + * precisely what you asked for. For more information, look at + * <a href="java.util.ResourceBundle.html"><code>ResourceBundle</code></a>. + * + * <P> + * The <code>OLocale</code> class provides a number of convenient constants + * that you can use to create <code>OLocale</code> objects for commonly used + * locales. For example, the following creates a <code>OLocale</code> object + * for the United States: + * <blockquote> + * <pre> + * OLocale.US + * </pre> + * </blockquote> + * + * <P> + * Once you've created a <code>OLocale</code> you can query it for information about + * itself. Use <code>getCountry</code> to get the ISO Country Code and + * <code>getLanguage</code> to get the ISO Language Code. You can + * use <code>getDisplayCountry</code> to get the + * name of the country suitable for displaying to the user. Similarly, + * you can use <code>getDisplayLanguage</code> to get the name of + * the language suitable for displaying to the user. Interestingly, + * the <code>getDisplayXXX</code> methods are themselves locale-sensitive + * and have two versions: one that uses the default locale and one + * that uses the locale specified as an argument. + * + * <P> + * The JDK provides a number of classes that perform locale-sensitive + * operations. For example, the <code>NumberFormat</code> class formats + * numbers, currency, or percentages in a locale-sensitive manner. Classes + * such as <code>NumberFormat</code> have a number of convenience methods + * for creating a default object of that type. For example, the + * <code>NumberFormat</code> class provides these three convenience methods + * for creating a default <code>NumberFormat</code> object: + * <blockquote> + * <pre> + * NumberFormat.getInstance() + * NumberFormat.getCurrencyInstance() + * NumberFormat.getPercentInstance() + * </pre> + * </blockquote> + * These methods have two variants; one with an explicit locale + * and one without; the latter using the default locale. + * <blockquote> + * <pre> + * NumberFormat.getInstance(myLocale) + * NumberFormat.getCurrencyInstance(myLocale) + * NumberFormat.getPercentInstance(myLocale) + * </pre> + * </blockquote> + * A <code>OLocale</code> is the mechanism for identifying the kind of object + * (<code>NumberFormat</code>) that you would like to get. The locale is + * <STRONG>just</STRONG> a mechanism for identifying objects, + * <STRONG>not</STRONG> a container for the objects themselves. + * + * <P> + * Each class that performs locale-sensitive operations allows you + * to get all the available objects of that type. You can sift + * through these objects by language, country, or variant, + * and use the display names to present a menu to the user. + * For example, you can create a menu of all the collation objects + * suitable for a given language. Such classes must implement these + * three class methods: + * <blockquote> + * <pre> + * public static OLocale[] getAvailableLocales() + * public static String getDisplayName(OLocale objectLocale, + * OLocale displayLocale) + * public static final String getDisplayName(OLocale objectLocale) + * // getDisplayName will throw MissingResourceException if the locale + * // is not one of the available locales. + * </pre> + * </blockquote> + * + * @see ResourceBundle + * @see java.text.Format + * @see java.text.NumberFormat + * @see java.text.Collation + * @version 1.21 29 Jan 1997 + * @author Mark Davis + */ +class OLocale +{ +public: + OLocale( rtl_Locale * locale ) + : pData( locale ) {} + + OLocale( const OLocale & obj) + : pData(obj.pData) {} + + OLocale & operator = ( const OLocale & obj) + { + pData = obj.pData; + return *this; + } + + /** + * Construct a locale from language, country, variant. + * @param language lowercase two-letter ISO-639 code. + * @param country uppercase two-letter ISO-3166 code. + * @param variant vendor and browser specific code. See class description. + */ + static OLocale registerLocale( const OUString & language, const OUString & country, + const OUString & variant ) + { + return rtl_locale_register( language, country, variant ); + } + + /** + * Construct a locale from language, country. + * @param language lowercase two-letter ISO-639 code. + * @param country uppercase two-letter ISO-3166 code. + */ + static OLocale registerLocale( const OUString & language, const OUString & country ) + { + return rtl_locale_register( language, country, NULL ); + } + + /** @deprecated + */ + static OLocale getDefault() { return rtl_locale_getDefault(); } + + /** @deprecated + */ + static void setDefault( const OUString & language, const OUString & country, + const OUString & variant ) + { rtl_locale_setDefault(language, country, variant); } + + /** + * Getter for programmatic name of field, + * an lowercased two-letter ISO-639 code. + */ + OUString getLanguage() const { return pData->Language; } + + /** + * Getter for programmatic name of field, + * an uppercased two-letter ISO-3166 code. + */ + OUString getCountry() const { return pData->Country; } + + /** + * Getter for programmatic name of field. + */ + OUString getVariant() const { return pData->Variant; } + + + /** + * Returns the hash code of the locale This. + */ + sal_Int32 hashCode() const { return pData->HashCode; } + + sal_Bool operator == (const OLocale & obj ) const + { + return pData == obj.pData; + } + + rtl_Locale * getData() const { return pData; } + +private: + /** + * Must be the first member in this class. OUString access this member with + * *(rtl_Locale **)&locale. + */ + rtl_Locale * pData; + + OLocale() + : pData(rtl_locale_getDefault()) {} +/* + OLocale( const OLocale & obj) + : pData(obj.pData) {} + + OLocale & operator = ( const OLocale & obj) + { pData = obj.pData; + return *this; + } +*/ +}; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _RTL_LOCALE_HXX_ */ + + diff --git a/sal/inc/rtl/memory.h b/sal/inc/rtl/memory.h new file mode 100644 index 000000000000..99f822ac754e --- /dev/null +++ b/sal/inc/rtl/memory.h @@ -0,0 +1,87 @@ +/************************************************************************* + * + * $RCSfile: memory.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _RTL_MEMORY_H_ +#define _RTL_MEMORY_H_ + +#ifndef _SAL_TYPES_H_ +# include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +void SAL_CALL rtl_zeroMemory(void *Ptr, sal_uInt32 Bytes); +void SAL_CALL rtl_fillMemory(void *Ptr, sal_uInt32 Bytes, sal_uInt8 Fill); +void SAL_CALL rtl_copyMemory(void *Dst, const void *Src, sal_uInt32 Bytes); +void SAL_CALL rtl_moveMemory(void *Dst, const void *Src, sal_uInt32 Bytes); +sal_Int32 SAL_CALL rtl_compareMemory(const void *MemA, const void *MemB, sal_uInt32 Bytes); +void* SAL_CALL rtl_findInMemory(const void *MemA, sal_uInt8 ch, sal_uInt32 Bytes); + +#ifdef __cplusplus +} +#endif + + +#endif /*_RTL_MEMORY_H_ */ + diff --git a/sal/inc/rtl/process.h b/sal/inc/rtl/process.h new file mode 100644 index 000000000000..a8672df810b7 --- /dev/null +++ b/sal/inc/rtl/process.h @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $RCSfile: process.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _RTL_PROCESS_H_ +#define _RTL_PROCESS_H_ + +#include <sal/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/******** + * gets a 16-byte fixed size identifier which is guaranteed not to change + * during the current process. + * + * The current implementation creates a 16-byte uuid without using + * the ethernet address of system ( @see rtl_createUiid ). Thus the + * identifier is very likely to be different from identifiers created + * in other processes. + * + * @param pTargetUUID 16 byte of memory + * + ******/ +void SAL_CALL rtl_getGlobalProcessId( sal_uInt8 *pTargetUUID ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sal/inc/rtl/random.h b/sal/inc/rtl/random.h new file mode 100644 index 000000000000..9d764b597af9 --- /dev/null +++ b/sal/inc/rtl/random.h @@ -0,0 +1,139 @@ +/************************************************************************* + * + * $RCSfile: random.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_RANDOM_H_ +#define _RTL_RANDOM_H_ "$Revision: 1.1.1.1 $" + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*======================================================================== + * + * rtlRandom interface. + * + *======================================================================*/ +/** rtlRandomPool. + */ +typedef void* rtlRandomPool; + +/** rtlRandomError. + */ +typedef enum +{ + rtl_Random_E_None, + rtl_Random_E_Argument, + rtl_Random_E_Memory, + rtl_Random_E_Unknown, + rtl_Random_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +} rtlRandomError; + +/** rtl_random_createPool. + * + * @return Pool + */ +rtlRandomPool SAL_CALL rtl_random_createPool (void); + +/** rtl_random_destroyPool. + * + * @param Pool [in] + */ +void SAL_CALL rtl_random_destroyPool ( + rtlRandomPool Pool); + +/** rtl_random_addBytes. + * + * @param Pool [in] + * @param pBuffer [in] + * @param nBufLen [in] + */ +rtlRandomError SAL_CALL rtl_random_addBytes ( + rtlRandomPool Pool, + const void *Buffer, + sal_uInt32 Bytes); + +/** rtl_random_getBytes. + * + * @param Pool [in] + * @param pBuffer [inout] + * @param nBufLen [in] + */ +rtlRandomError SAL_CALL rtl_random_getBytes ( + rtlRandomPool Pool, + void *Buffer, + sal_uInt32 Bytes); + +/*======================================================================== + * + * The End. + * + *======================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_RANDOM_H_ */ + diff --git a/sal/inc/rtl/strbuf.h b/sal/inc/rtl/strbuf.h new file mode 100644 index 000000000000..0c64f6794211 --- /dev/null +++ b/sal/inc/rtl/strbuf.h @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: strbuf.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_STRBUF_H_ +#define _RTL_STRBUF_H_ + +#ifndef _RTL_STRING_H_ +#include <rtl/string.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Allocates a new <code>String</code> that contains characters from + * the character array argument. The <code>count</code> argument specifies + * the length of the array. The initial capacity of the string buffer is + * <code>16</code> plus the length of the string argument. + * + * @param newStr out parameter, contains the new string. The reference count is 1. + * @param value the initial value of the string. + * @param count the length of value. + */ +void SAL_CALL rtl_stringbuffer_newFromStr_WithLength( rtl_String ** newStr, + const sal_Char * value, + sal_Int32 count); + +/** + * Allocates a new <code>String</code> that contains the same sequence of + * characters as the string argument. The initial capacity is the larger of: + * <ul> + * <li> The <code>bufferLen</code> argument. + * <li> The <code>length</code> of the string argument. + * </ul> + * + * @param newStr out parameter, contains the new string. The reference count is 1. + * @param capacity the initial len of the string buffer. + * @param oldStr the initial value of the string. + * @return the new capacity of the string buffer + */ +sal_Int32 SAL_CALL rtl_stringbuffer_newFromStringBuffer( rtl_String ** newStr, + sal_Int32 capacity, + rtl_String * olsStr ); + +/** + * Ensures that the capacity of the buffer is at least equal to the + * specified minimum. + * If the current capacity of this string buffer is less than the + * argument, then a new internal buffer is allocated with greater + * capacity. The new capacity is the larger of: + * <ul> + * <li>The <code>minimumCapacity</code> argument. + * <li>Twice the old capacity, plus <code>2</code>. + * </ul> + * If the <code>minimumCapacity</code> argument is nonpositive, this + * method takes no action and simply returns. + * + * @param capacity in: old capicity, out: new capacity. + * @param minimumCapacity the minimum desired capacity. + */ +void SAL_CALL rtl_stringbuffer_ensureCapacity( /*inout*/rtl_String ** This, + /*inout*/sal_Int32* capacity, + sal_Int32 minimumCapacity); + + +/** + * Inserts the string representation of the <code>char</code> array + * argument into this string buffer. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param capacity the capacity of the string buffer + * @param offset the offset. + * @param ch a character array. + * @param len the number of characters to append. + * @return this string buffer. + */ +void SAL_CALL rtl_stringbuffer_insert( /*inout*/rtl_String ** This, + /*inout*/sal_Int32 * capacity, + sal_Int32 offset, + const sal_Char * str, + sal_Int32 len); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_STRBUF_H_ */ + + diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx new file mode 100644 index 000000000000..42b0307e8f15 --- /dev/null +++ b/sal/inc/rtl/strbuf.hxx @@ -0,0 +1,682 @@ +/************************************************************************* + * + * $RCSfile: strbuf.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_STRBUF_HXX_ +#define _RTL_STRBUF_HXX_ + +#ifndef _RTL_STRBUF_H_ +#include <rtl/strbuf.h> +#endif +#ifndef _RTL_STRING_HXX_ +#include <rtl/string.hxx> +#endif + +#ifdef __cplusplus + +#ifdef _USE_NAMESPACE +namespace rtl +{ +#endif + +/** + * A string buffer implements a mutable sequence of characters. + * <p> + * String buffers are safe for use by multiple threads. The methods + * are synchronized where necessary so that all the operations on any + * particular instance behave as if they occur in some serial order. + * <p> + * String buffers are used by the compiler to implement the binary + * string concatenation operator <code>+</code>. For example, the code: + * <p><blockquote><pre> + * x = "a" + 4 + "c" + * </pre></blockquote><p> + * is compiled to the equivalent of: + * <p><blockquote><pre> + * x = new OStringBuffer().append("a").append(4).append("c") + * .toString() + * </pre></blockquote><p> + * The principal operations on a <code>OStringBuffer</code> are the + * <code>append</code> and <code>insert</code> methods, which are + * overloaded so as to accept data of any type. Each effectively + * converts a given datum to a string and then appends or inserts the + * characters of that string to the string buffer. The + * <code>append</code> method always adds these characters at the end + * of the buffer; the <code>insert</code> method adds the characters at + * a specified point. + * <p> + * For example, if <code>z</code> refers to a string buffer object + * whose current contents are "<code>start</code>", then + * the method call <code>z.append("le")</code> would cause the string + * buffer to contain "<code>startle</code>", whereas + * <code>z.insert(4, "le")</code> would alter the string buffer to + * contain "<code>starlet</code>". + * <p> + * Every string buffer has a capacity. As long as the length of the + * character sequence contained in the string buffer does not exceed + * the capacity, it is not necessary to allocate a new internal + * buffer array. If the internal buffer overflows, it is + * automatically made larger. + */ +class OStringBuffer +{ +public: + /** + * Constructs a string buffer with no characters in it and an + * initial capacity of 16 characters. + */ + OStringBuffer() + : pData(NULL) + , nCapacity( 16 ) + { + rtl_string_new_WithLength( &pData, nCapacity ); + } + + /** + * Allocates a new string buffer that contains the same sequence of + * characters as the string buffer argument. + * + * @param value a <code>OStringBuffer</code>. + */ + OStringBuffer( const OStringBuffer & value ) + : pData(NULL) + , nCapacity( value.nCapacity ) + { + rtl_stringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData ); + } + + /** + * Constructs a string buffer with no characters in it and an + * initial capacity specified by the <code>length</code> argument. + * + * @param length the initial capacity. + */ + OStringBuffer(sal_Int32 length) + : pData(NULL) + , nCapacity( length ) + { + rtl_string_new_WithLength( &pData, length ); + } + + /** + * Constructs a string buffer so that it represents the same + * sequence of characters as the string argument. The initial + * capacity of the string buffer is <code>16</code> plus the length + * of the string argument. + * + * @param value the initial string value. + */ + OStringBuffer(OString value) + : pData(NULL) + , nCapacity( value.getLength() + 16 ) + { + rtl_stringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() ); + } + + /** + * Release the string own string data and notice and acquire the string data of value. + */ + OStringBuffer& operator = ( const OStringBuffer& value ) + { + rtl_string_assign( &pData, value.pData ); + return *this; + } + + /** + * Release the string data. + */ + ~OStringBuffer() + { + rtl_string_release( pData ); + } + + /** + * Fill the string data in the new string and clear the buffer.<BR> + * This method is more efficient than the contructor of the string. It does + * not copy the buffer. + * + * @return the string previously contained in the buffer. + */ + OString makeStringAndClear() + { + OString aRet( pData ); + RTL_STRING_NEW(&pData); + nCapacity = 0; + return aRet; + } + + /** + * Returns the length (character count) of this string buffer. + * + * @return the number of characters in this string buffer. + */ + sal_Int32 getLength() + { + return pData->length; + } + + /** + * Returns the current capacity of the String buffer. The capacity + * is the amount of storage available for newly inserted + * characters. The real buffer size is 2 bytes longer, because + * all strings are 0 terminated. + * + * @return the current capacity of this string buffer. + */ + sal_Int32 getCapacity() + { + return nCapacity; + } + + /** + * Ensures that the capacity of the buffer is at least equal to the + * specified minimum. + * If the current capacity of this string buffer is less than the + * argument, then a new internal buffer is allocated with greater + * capacity. The new capacity is the larger of: + * <ul> + * <li>The <code>minimumCapacity</code> argument. + * <li>Twice the old capacity, plus <code>2</code>. + * </ul> + * If the <code>minimumCapacity</code> argument is nonpositive, this + * method takes no action and simply returns. + * + * @param minimumCapacity the minimum desired capacity. + */ + void ensureCapacity(sal_Int32 minimumCapacity) + { + rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity ); + } + + /** + * Sets the length of this String buffer. + * If the <code>newLength</code> argument is less than the current + * length of the string buffer, the string buffer is truncated to + * contain exactly the number of characters given by the + * <code>newLength</code> argument. + * <p> + * If the <code>newLength</code> argument is greater than or equal + * to the current length, sufficient null characters + * (<code>'\u0000'</code>) are appended to the string buffer so that + * length becomes the <code>newLength</code> argument. + * <p> + * The <code>newLength</code> argument must be greater than or equal + * to <code>0</code>. + * + * @param newLength the new length of the buffer. + */ + void setLength(sal_Int32 newLength) + { + if( newLength > nCapacity ) + rtl_stringbuffer_ensureCapacity(&pData, &nCapacity, newLength); + else + pData->buffer[newLength] = '\0'; + pData->length = newLength; + } + + /** + * Returns the character at a specific index in this string buffer. + * <p> + * The first character of a string buffer is at index + * <code>0</code>, the next at index <code>1</code>, and so on, for + * array indexing. + * <p> + * The index argument must be greater than or equal to + * <code>0</code>, and less than the length of this string buffer. + * + * @param index the index of the desired character. + * @return the character at the specified index of this string buffer. + */ + sal_Char charAt( sal_Int32 index ) + { + return pData->buffer[ index ]; + } + + /** + * Return a null terminated character array. + */ + operator const sal_Char *() const { return pData->buffer; } + + /** + * Return a null terminated character array. + */ + const sal_Char* getStr() const { return pData->buffer; } + + + /** + * The character at the specified index of this string buffer is set + * to <code>ch</code>. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than the length of this string buffer. + * + * @param index the index of the character to modify. + * @param ch the new character. + */ + OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch) + { + pData->buffer[ index ] = ch; + return *this; + } + + /** + * Appends the string to this string buffer. + * <p> + * The characters of the <code>String</code> argument are appended, in + * order, to the contents of this string buffer, increasing the + * length of this string buffer by the length of the argument. + * + * @param str a string. + * @return this string buffer. + */ + OStringBuffer & append(const OString &str) + { + return append( str.getStr(), str.getLength() ); + } + + /** + * Appends the string representation of the <code>char</code> array + * argument to this string buffer. + * <p> + * The characters of the array argument are appended, in order, to + * the contents of this string buffer. The length of this string + * buffer increases by the length of the argument. + * + * @param str the characters to be appended. + * @return this string buffer. + */ + OStringBuffer & append( const sal_Char * str ) + { + return append( str, rtl_str_getLength( str ) ); + } + + /** + * Appends the string representation of the <code>char</code> array + * argument to this string buffer. + * <p> + * Characters of the character array <code>str</code> are appended, + * in order, to the contents of this string buffer. The length of this + * string buffer increases by the value of <code>len</code>. + * + * @param str the characters to be appended. + * @param len the number of characters to append. + * @return this string buffer. + */ + OStringBuffer & append( const sal_Char * str, sal_Int32 len) + { + // insert behind the last character + rtl_stringbuffer_insert( &pData, &nCapacity, getLength(), str, len ); + return *this; + } + + /** + * Appends the string representation of the <code>sal_Bool</code> + * argument to the string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param b a <code>sal_Bool</code>. + * @return this string buffer. + */ + OStringBuffer & append(sal_Bool b) + { + sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN]; + return append( sz, rtl_str_valueOfBoolean( sz, b ) ); + } + + /** + * Appends the string representation of the <code>char</code> + * argument to this string buffer. + * <p> + * The argument is appended to the contents of this string buffer. + * The length of this string buffer increases by <code>1</code>. + * + * @param ch a <code>char</code>. + * @return this string buffer. + */ + OStringBuffer & append(sal_Char c) + { + return append( &c, 1 ); + } + + /** + * Appends the string representation of the <code>sal_Int32</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param i an <code>sal_Int32</code>. + * @return this string buffer. + */ + OStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 ) + { + sal_Char sz[RTL_STR_MAX_VALUEOFINT32]; + return append( sz, rtl_str_valueOfInt32( sz, i, radix ) ); + } + + /** + * Appends the string representation of the <code>long</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param l a <code>long</code>. + * @return this string buffer. + */ + OStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 ) + { + sal_Char sz[RTL_STR_MAX_VALUEOFINT64]; + return append( sz, rtl_str_valueOfInt64( sz, l, radix ) ); + } + + /** + * Appends the string representation of the <code>float</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param f a <code>float</code>. + * @return this string buffer. + */ + OStringBuffer & append(float f) + { + sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT]; + return append( sz, rtl_str_valueOfFloat( sz, f ) ); + } + + /** + * Appends the string representation of the <code>double</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param d a <code>double</code>. + * @return this string buffer. + */ + OStringBuffer & append(double d) + { + sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE]; + return append( sz, rtl_str_valueOfDouble( sz, d ) ); + } + + /** + * Inserts the string into this string buffer. + * <p> + * The characters of the <code>String</code> argument are inserted, in + * order, into this string buffer at the indicated offset. The length + * of this string buffer is increased by the length of the argument. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param str a string. + * @return this string buffer. + */ + OStringBuffer & insert(sal_Int32 offset, const OString & str) + { + return insert( offset, str.getStr(), str.getLength() ); + } + + /** + * Inserts the string representation of the <code>char</code> array + * argument into this string buffer. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param offset the offset. + * @param ch a character array. + * @return this string buffer. + */ + OStringBuffer & insert( sal_Int32 offset, const sal_Char * str ) + { + return insert( offset, str, rtl_str_getLength( str ) ); + } + + /** + * Inserts the string representation of the <code>char</code> array + * argument into this string buffer. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param offset the offset. + * @param ch a character array. + * @param len the number of characters to append. + * @return this string buffer. + */ + OStringBuffer & insert( sal_Int32 offset, const sal_Char * str, sal_Int32 len) + { + // insert behind the last character + rtl_stringbuffer_insert( &pData, &nCapacity, offset, str, len ); + return *this; + } + + /** + * Inserts the string representation of the <code>sal_Bool</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>sal_Bool</code>. + * @return this string buffer. + */ + OStringBuffer & insert(sal_Int32 offset, sal_Bool b) + { + sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN]; + return insert( offset, sz, rtl_str_valueOfBoolean( sz, b ) ); + } + + /** + * Inserts the string representation of the <code>char</code> + * argument into this string buffer. + * <p> + * The second argument is inserted into the contents of this string + * buffer at the position indicated by <code>offset</code>. The length + * of this string buffer increases by one. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param ch a <code>char</code>. + * @return this string buffer. + */ + OStringBuffer & insert(sal_Int32 offset, sal_Char c) + { + return insert( offset, &c, 1 ); + } + + /** + * Inserts the string representation of the second <code>sal_Int32</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b an <code>sal_Int32</code>. + * @return this string buffer. + */ + OStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 ) + { + sal_Char sz[RTL_STR_MAX_VALUEOFINT32]; + return insert( offset, sz, rtl_str_valueOfInt32( sz, i, radix ) ); + } + + /** + * Inserts the string representation of the <code>long</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>long</code>. + * @return this string buffer. + */ + OStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 ) + { + sal_Char sz[RTL_STR_MAX_VALUEOFINT64]; + return insert( offset, sz, rtl_str_valueOfInt64( sz, l, radix ) ); + } + + /** + * Inserts the string representation of the <code>float</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>float</code>. + * @return this string buffer. + */ + OStringBuffer insert(sal_Int32 offset, float f) + { + sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT]; + return insert( offset, sz, rtl_str_valueOfFloat( sz, f ) ); + } + + /** + * Inserts the string representation of the <code>double</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>double</code>. + * @return this string buffer. + */ + OStringBuffer & insert(sal_Int32 offset, double d) + { + sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE]; + return insert( offset, sz, rtl_str_valueOfDouble( sz, d ) ); + } +private: + /** + * A pointer to the data structur which contains the data. + */ + rtl_String * pData; + + /** + * The len of the pData->buffer. + */ + sal_Int32 nCapacity; +}; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _RTL_STRBUF_HXX_ */ + + diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h new file mode 100644 index 000000000000..24343c908165 --- /dev/null +++ b/sal/inc/rtl/string.h @@ -0,0 +1,588 @@ +/************************************************************************* + * + * $RCSfile: string.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_STRING_H_ +#define _RTL_STRING_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _RTL_TEXTCVT_H +#include <rtl/textcvt.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Returns the length of this string. + * The length is equal to the number of 8-bit + * characters in the string. + * + * @param str must be a NULL-terminated string. + * @return the length of the sequence of characters represented by this + * string. + */ +sal_Int32 SAL_CALL rtl_str_getLength( const sal_Char * str ); + +/** + * Compares first string to second string object. Both + * strings must be NULL-terminated. + * The result is <code>true</code> if and only if second string represents + * the same sequence of characters as the first string, where case is ignored. + * <p> + * Two characters are considered the same, ignoring case, if at + * least one of the following is true: + * <ul> + * <li>The two characters are the same (as compared by the <code>==</code> + * operator). + * <li>Applying the method <code>Character.toUppercase</code> to each + * character produces the same result. + * <li>Applying the method <code>Character.toLowercase</code> to each + * character produces the same result. + * </ul> + * <p> + * Two sequences of characters are the same, ignoring case, if the + * sequences have the same length and corresponding characters are + * the same, ignoring case. + * + * @param first the <code>string</code> to compared. + * @param second the <code>string</code> to compare first + * <code>String</code> against. + * @return <code>true</code> if the <code>String</code>s are equal, + * ignoring case; <code>false</code> otherwise. + */ +sal_Bool SAL_CALL rtl_str_equalsIgnoreCase_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * second, sal_Int32 secondLen ); +sal_Bool SAL_CALL rtl_str_equalsIgnoreCase( const sal_Char * first, const sal_Char * second ); + +/** + * Compares two strings lexicographically. Both + * strings must be NULL-terminated. + * The comparison is based on the ascii value of each character in + * the strings. + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if first string + * is lexicographically less than the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string. + */ +sal_Int32 SAL_CALL rtl_str_compare_WithLength( const sal_Char * first, sal_Int32 firstLen, const sal_Char * Second, sal_Int32 SecondLen ); +sal_Int32 SAL_CALL rtl_str_compare( const sal_Char * first, const sal_Char * Second ); + +/** + * rtl_str_compareIgnoreCase() and rtl_str_compareIgnoreCase_WithLength() + * functions are caseinsensitive versions of rtl_str_compare() and + * rtl_str_compare_WithLength() respectively, described above. They assume + * the ASCII characterset and ignore differences in case when comparing + * lower and upper case characters. rtl_str_compareIgnoreCase_WithLength() + * does not compare more than len characters. Both strings have to be NULL + * terminated + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if a all lowercase + * version of first string is lexicographically less than a all + * lowercase version of the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string, again both + * strings all lowercase. + */ +sal_Int32 SAL_CALL +rtl_str_compareIgnoreCase_WithLength( + const sal_Char *first, const sal_Char *second, sal_Int32 len ); +sal_Int32 SAL_CALL +rtl_str_compareIgnoreCase( const sal_Char *first, const sal_Char *second ); + +/** + * Returns a hashcode for the string. + * + * @param str a NULL-terminated string. + * @return a hash code value for str. + */ +sal_Int32 SAL_CALL rtl_str_hashCode_WithLength( const sal_Char * str, sal_Int32 len ); +sal_Int32 SAL_CALL rtl_str_hashCode( const sal_Char * str ); + +/** + * Returns the index within the string of the first occurrence of the + * specified character. + * + * @param str a NULL-terminated string. + * @param ch a character. + * @return the index of the first occurrence of the character in the + * character sequence represented by the string, or + * <code>-1</code> if the character does not occur. + */ +sal_Int32 SAL_CALL rtl_str_indexOfChar_WithLength( const sal_Char * str, sal_Int32 len, sal_Char ch ); +sal_Int32 SAL_CALL rtl_str_indexOfChar( const sal_Char * str, sal_Char ch ); + +/** + * Returns the index within the string of the last occurrence of the + * specified character, searching backward starting at the specified index. + * + * @param str a NULL-terminated string. + * @param ch a character. + * @return the index of the last occurrence of the character in the + * character sequence represented by the string, or + * <code>-1</code> if the character does not occur. + */ +sal_Int32 SAL_CALL rtl_str_lastIndexOfChar_WithLength( const sal_Char * str, sal_Int32 len, sal_Char ch ); +sal_Int32 SAL_CALL rtl_str_lastIndexOfChar( const sal_Char * str, sal_Char ch ); + +/** + * Returns the index within the string of the first occurrence of the + * specified substring. + * + * @param str a NULL-terminated string. + * @param subStr a NULL-terminated substring to be searched for. + * @return if the string argument occurs as a substring within the + * string, then the index of the first character of the first + * such substring is returned; if it does not occur as a + * substring, <code>-1</code> is returned. + */ +sal_Int32 SAL_CALL rtl_str_indexOfStr_WithLength( const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ); +sal_Int32 SAL_CALL rtl_str_indexOfStr( const sal_Char * str, const sal_Char * subStr ); + +/** + * Returns the index within this string of the last occurrence of + * the specified substring. + * The returned index indicates the start of the substring, and it + * must be equal to or less than <code>fromIndex</code>. + * + * @param str a NULL-terminated string. + * @param subStr a NULL-terminated substring to be searched for. + * @return If the string argument occurs one or more times as a substring + * within the string, then the index of the first character of + * the last such substring is returned. If it does not occur as a + * substring <code>-1</code> is returned. + */ +sal_Int32 SAL_CALL rtl_str_lastIndexOfStr_WithLength( const sal_Char * str, sal_Int32 len, const sal_Char * subStr, sal_Int32 subLen ); +sal_Int32 SAL_CALL rtl_str_lastIndexOfStr( const sal_Char * ggstr, const sal_Char * subStr ); + +/** + * Replaces all occurrences of <code>oldChar</code> in the string with + * <code>newChar</code>. + * <p> + * If the character <code>oldChar</code> does not occur in the + * character sequence represented by this object, then the string is + *not modified. + * + * @param str a NULL-terminated string. + * @param oldChar the old character. + * @param newChar the new character. + */ +void SAL_CALL rtl_str_replaceChar_WithLength( sal_Char * str, sal_Int32 len, sal_Char oldChar, sal_Char newChar); +void SAL_CALL rtl_str_replaceChar( sal_Char * str, sal_Char oldChar, sal_Char newChar); + +/** + * Converts all of the characters in the <code>string</code> to lower case. + * @param str a NULL-terminated string. + */ +void SAL_CALL rtl_str_toAsciiLowerCase_WithLength( sal_Char * str, sal_Int32 len ); +void SAL_CALL rtl_str_toAsciiLowerCase( sal_Char * str ); + +/** + * Converts all of the characters in the <code>string</code> to upper case. + * + * @param str a NULL-terminated string. + */ +void SAL_CALL rtl_str_toAsciiUpperCase_WithLength(sal_Char * str, sal_Int32 len); +void SAL_CALL rtl_str_toAsciiUpperCase(sal_Char * str); + +/** + * Removes white space from both ends of the string. + * <p> + * All characters that have codes less than or equal to + * <code>'\u0020'</code> (the space character) are considered to be + * white space. + * + * @param str a NULL-terminated string. + * @return new length of the string. + */ +sal_Int32 SAL_CALL rtl_str_trim_WithLength( sal_Char * str, sal_Int32 len ); +sal_Int32 SAL_CALL rtl_str_trim( sal_Char * str ); + +/** + * Returns the string representation of the <code>sal_Bool</code> argument. + * + * @param str a newly allocated string with the length <code>RTL_STR_MAX_VALUEOFBOOLEAN</code>. + * @param b a <code>sal_Bool</code>. + * @return if the argument is <code>true</code>, a string equal to + * <code>"true"</code> is returned; otherwise, a string equal to + * <code>"false"</code> is returned. + */ +#define RTL_STR_MAX_VALUEOFBOOLEAN 6 +sal_Int32 SAL_CALL rtl_str_valueOfBoolean( sal_Char * str, sal_Bool b ); + +/** + * Returns the string representation of the <code>char</code> argument. + * + * @param str a newly allocated string with the length <code>RTL_STR_MAX_VALUEOFCHAR</code>. + * @param ch a <code>char</code>. + * @return a newly allocated string of length <code>1</code> containing + * as its single character the argument <code>ch</code>. + */ +#define RTL_STR_MAX_VALUEOFCHAR 2 +sal_Int32 SAL_CALL rtl_str_valueOfChar( sal_Char * str, sal_Char ch ); + +/** + * Returns the string representation of the <code>int</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Integer.toString</code> method of one argument. + * + * @param str a newly allocated string with the length <code>RTL_STR_MAX_VALUEOFINT32</code>. + * @param i an <code>sal_Int32</code>. + * @return a newly allocated string containing a string representation of + * the <code>int</code> argument. + * @see java.lang.Integer#toString(int, int) + */ +#define RTL_STR_MIN_RADIX 2 +#define RTL_STR_MAX_RADIX 36 +#define RTL_STR_MAX_VALUEOFINT32 33 +sal_Int32 SAL_CALL rtl_str_valueOfInt32(sal_Char * str, sal_Int32 i, sal_Int16 radix ); + +/** + * Returns the string representation of the <code>long</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Long.toString</code> method of one argument. + * + * @param str a newly allocated string with the length <code>RTL_STR_MAX_VALUEOFINT64</code>. + * @param l a <code>sal_Int64</code>. + * @return a newly allocated string containing a string representation of + * the <code>long</code> argument. + * @see java.lang.Long#toString(long) + */ +#define RTL_STR_MAX_VALUEOFINT64 65 +sal_Int32 SAL_CALL rtl_str_valueOfInt64(sal_Char * str, sal_Int64 l, sal_Int16 radix ); + +/** + * Returns the string representation of the <code>float</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Float.toString</code> method of one argument. + * + * @param f a <code>float</code>. + * @return a newly allocated string containing a string representation of + * the <code>float</code> argument. + * @see java.lang.Float#toString(float) + */ +#define RTL_STR_MAX_VALUEOFFLOAT 1 /*???*/ +sal_Int32 SAL_CALL rtl_str_valueOfFloat(sal_Char * str, float f); + +/** + * Returns the string representation of the <code>double</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Double.toString</code> method of one argument. + * + * @param d a <code>double</code>. + * @return a newly allocated string containing a string representation of + * the <code>double</code> argument. + * @see java.lang.Double#toString(double) + */ +#define RTL_STR_MAX_VALUEOFDOUBLE 1/*???*/ +sal_Int32 SAL_CALL rtl_str_valueOfDouble(sal_Char * str, double d); + + +/*######################################################################*/ + + +/** + * A string with this reference count is static und must not deleted. + * It is also not allowed to modifiy the reference count. + */ +#define RTL_STATIC_ASCIISTRING_REF ((sal_Int32)0x80000000) + +#ifdef SAL_W32 +# pragma pack(push, 8) +#elif defined(SAL_OS2) +# pragma pack(1) +#endif + +/** + * The implementation structure of a ascii string. + */ +typedef struct _rtl_String +{ + sal_Int32 refCount; + sal_Int32 length; + sal_Char buffer[1]; +} rtl_String; + +#ifdef SAL_W32 +# pragma pack(pop) +#elif defined(SAL_OS2) +# pragma pack() +#endif + +/** + * Increment the reference count of the string. + */ +void SAL_CALL rtl_string_acquire( rtl_String * value ); + +/** + * Decrement the reference count of the string. If the count goes to zero than the string is + * deleted. + */ +void SAL_CALL rtl_string_release( rtl_String * value ); + +/** + * Allocates a new <code>string</code> containing no characters. + * Use the macro RTL_NEWDEFAULTSTRING() which optimize platform dependend + * the access to the default string. + */ +void SAL_CALL rtl_string_new( rtl_String ** newStr); +#define RTL_STRING_NEW(newStr) rtl_string_new(newStr) + +/** + * Allocates a new <code>string</code> containing nLen characters. + * The values of the characters are '\0' defined. + */ +void SAL_CALL rtl_string_new_WithLength( rtl_String ** newStr, sal_Int32 nLen ); + +/** + * Allocates a new string that contains the same sequence of + * characters as the string argument.<BR> + * + * @param value a <code>string</code>. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newFromString( rtl_String ** newStr, rtl_String * value); + +/** + * Allocates a new <code>string</code> so that it represents the + * sequence of characters currently contained in the character array + * argument. + * + * @param value the initial value of the string. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newFromStr( rtl_String ** newStr, const sal_Char * value ); + +/** + * Allocates a new <code>String</code> that contains characters from + * the character array argument. + * + * @param value array that is the source of characters. + * @param len the length of the array. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newFromStr_WithLength(rtl_String ** newStr, + const sal_Char * value, + sal_Int32 Len); + +/** + * Assign rightValue to *str. Release *str and aquire rightValue! + */ +void SAL_CALL rtl_string_assign( rtl_String ** str, rtl_String * rightValue ); + +/** + * Returns the length of this string. + * The length is equal to the number of 16-bit + * Unicode characters in the string. + * + * @return the length of the sequence of characters represented by the + * string. + */ +sal_Int32 SAL_CALL rtl_string_getLength( rtl_String * str ); + +/** + * Return the pointer to the sal_Char array of the <code>string</code>. + * + * @return a null terminated sal_Char *. + */ +sal_Char * SAL_CALL rtl_string_getStr( rtl_String * str ); + +/** + * Concatenates the right string to the end of the left string. Left and + * right must be NULL-terminated strings. + * <p> + * + * @return a string that represents the concatenation of the strings. + */ +void SAL_CALL rtl_string_newConcat( rtl_String ** newStr, rtl_String * left, rtl_String * right ); + +/** + * Returns a new string resulting from replacing all occurrences of + * <code>oldChar</code> in this string with <code>newChar</code>. + * <p> + * If the character <code>oldChar</code> does not occur in the + * character sequence represented by the string, then the string is + * returned. + * + * @param oldChar the old character. + * @param newChar the new character. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newReplace( rtl_String ** newStr, + rtl_String * str, + sal_Char oldChar, + sal_Char newChar); + +/** + * Returns a new string resulting from replacing n = count characters + * from position index in this string with <code>newStr</code>. + * <p> + * + * @param index the index for beginning. + * @param count the count of charcters that will replaced + * @param newStr the new substring. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newReplaceStrAt( rtl_String ** newStr, + rtl_String * str, + sal_Int32 index, + sal_Int32 count, + rtl_String * newSub); + +/** + * Converts all of the characters in this <code>String</code> to lower + * case using the rules of the given locale. + * @param locale use the case transformation rules for this locale + * @return the String, converted to lowercase. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newToLowerCase( rtl_String ** newStr, rtl_String * str); + +/** + * Converts all of the characters in this <code>String</code> to upper + * case using the rules of the given locale. + * @param locale use the case transformation rules for this locale + * @return the String, converted to uppercase. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newToUpperCase( rtl_String ** newStr, rtl_String * str); + +/** + * Removes white space from both ends of the string. + * <p> + * All characters that have codes less than or equal to + * <code>'\u0020'</code> (the space character) are considered to be + * white space. + * + * @return this string, with white space removed from the front and end. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_newTrim( rtl_String ** newStr, rtl_String * str ); + +/** + * Returns the number of tokens in this <code>String</code> seperated + * by <code>cTok</code>. + * + * @param cTok the character which seperate the tokens + * @return the number of tokens. + */ +sal_Int32 SAL_CALL rtl_string_getTokenCount( rtl_String * str , sal_Char cTok); + +/** + * Returns a new string for the token specified by nToken. If nToken < 0 or + * nToken > tokenCount then an empty string is returned. + * + * @param nToken the number of the token to return. + * @param cTok the character which seperate the tokens + * @param newStr the new string for the token + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_string_getToken( rtl_String ** newStr , rtl_String * str, sal_Int32 nToken, sal_Char cTok); + +/* predefined constants used in headers wstring, wstring.hxx, string.hxx */ +#define OSTRING_TO_OUSTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\ + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\ + RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT) +/* For SOffice 5.2, because we have problems, when the string get a diffrent length */ +#define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\ + RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\ + RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\ + RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\ + RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE) +/* For the future, when we use unicode +#define OUSTRING_TO_OSTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\ + RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\ + RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\ + RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR |\ + RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\ + RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE |\ + RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE) +*/ + +/* constAsciiStr must be a "..." or char const aFoo[] = "..." */ +#ifndef RTL_CONSTASCII_STRINGPARAM +#define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, sizeof( constAsciiStr )-1 +#endif +#ifndef RTL_CONSTASCII_LENGTH +#define RTL_CONSTASCII_LENGTH( constAsciiStr ) (sizeof( constAsciiStr )-1) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_STRING_H_ */ + + diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx new file mode 100644 index 000000000000..53586cc2f311 --- /dev/null +++ b/sal/inc/rtl/string.hxx @@ -0,0 +1,827 @@ +/************************************************************************* + * + * $RCSfile: string.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_STRING_HXX_ +#define _RTL_STRING_HXX_ + +#ifndef _RTL_STRING_H_ +#include <rtl/string.h> +#endif +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif +#ifndef _RTL_MEMORY_H_ +#include <rtl/memory.h> +#endif +#ifndef _RTL_TEXTENC_H +#include <rtl/textenc.h> +#endif +#ifndef _RTL_MACROS_HXX_ +#include <rtl/macros.hxx> +#endif + +#ifdef __cplusplus + +class ByteString; + +#ifdef _USE_NAMESPACE +namespace rtl +{ +#endif + +/** + * The <code>OAsciiString</code> class represents character strings. All + * string literals in Java programs, such as <code>"abc"</code>, are + * implemented as instances of this class. + * <p> + * Strings are constant; their values cannot be changed after they + * are created. OAsciiString buffers support mutable strings. + * Because OAsciiString objects are immutable they can be shared. For example: + * <p><blockquote><pre> + * OAsciiString str = "abc"; + * </pre></blockquote><p> + * is equivalent to: + * <p><blockquote><pre> + * char data[] = {'a', 'b', 'c'}; + * OAsciiString str = new OAsciiString(data); + * </pre></blockquote><p> + * Here are some more examples of how strings can be used: + * <p><blockquote><pre> + * System.out.println("abc"); + * OAsciiString cde = "cde"; + * System.out.println("abc" + cde); + * OAsciiString c = "abc".substring(2,3); + * OAsciiString d = cde.substring(1, 2); + * </pre></blockquote> + * <p> + * The class <code>OAsciiString</code> includes methods for examining + * individual characters of the sequence, for comparing strings, for + * searching strings, for extracting substrings, and for creating a + * copy of a string with all characters translated to uppercase or to + * lowercase. + */ +class OString +{ + class DO_NOT_ACQUIRE; + OString( rtl_String * value, DO_NOT_ACQUIRE * ) + : pData( value ) + { + } +public: + /** + * A pointer to the data structur which contains the data. + */ + rtl_String * pData; + + /** + * Allocates a new <code>OString</code> containing no characters. + */ + OString() + : pData(NULL) + { + RTL_STRING_NEW(&pData); + } + + /** + * Notice and acquire the string data of value. + * + * @param value a <code>OString</code>. + */ + OString( const OString & value ) + : pData( value.pData ) + { + rtl_string_acquire( pData ); + } + + /** + * Notice and acquire the string data of value. + * + * @param value a <code>rtl_String</code>. + */ + OString( rtl_String * value ) + : pData(value) + { + rtl_string_acquire( pData ); + } + + /** + * Allocates a new <code>OString</code> so that it represents the + * sequence of characters currently contained in the character array + * argument. + * + * @param value the initial value of the string. + */ + OString( const sal_Char * value) + : pData(NULL) + { + rtl_string_newFromStr( &pData, value ); + } + + /** + * Allocates a new <code>OString</code> that contains characters from + * a subarray of the character array argument. The <code>offset</code> + * argument is the index of the first character of the subarray and + * the <code>count</code> argument specifies the length of the + * subarray. + * + * @param value array that is the source of characters. + * @param offset the initial offset. + * @param count the length. + * @exception StringIndexOutOfBoundsException if the <code>offset</code> + * and <code>count</code> arguments index characters outside + * the bounds of the <code>value</code> array. + */ + OString( const sal_Char * value, sal_Int32 length ) + : pData(NULL) + { + rtl_string_newFromStr_WithLength( &pData, value, length ); + } + + /** + * Allocates a new <code>OString</code> that contains the first + * <code>count</code> characters of the Unicode character array argument. + * The Unicode string is converted to a 8 bit string using the + * <code>encoding</code> argument. + * + * @param value Unicode character array + * @param count the length. + * @param encoding TextEncoding used to convert the 8 bit string + * @exception StringIndexOutOfBoundsException <code>count</code> argument + * is bigger than the length of the 8 bit character string. + */ + OString( const sal_Unicode * value, sal_Int32 length, rtl_TextEncoding encoding ) + : pData(NULL) + { + RTL_STRING_NEW(&pData); + if( value ) + { + // for exception + //sal_Int32 len = rtl_ustr_getLength(value); + //if( len < length ) + // throw StringIndexOutOfBoundsException; + + if( length ) + rtl_uString2String( &pData, value, length, encoding, OUSTRING_TO_OSTRING_CVTFLAGS ); + } + } + + OString( const ByteString & value ); + + /** + * Release the string own string data and notice and acquire the string data of value. + */ + OString& operator = ( const OString& value ) + { + rtl_string_assign( &pData, value.pData ); + return *this; + } + + /** + * Release the string own string data and replace the string data with new string data + * containing the old string data concatenate with the sting data of value. + */ + OString operator+=( const OString& rStr ) + { + rtl_string_newConcat( &pData, pData, rStr.pData ); + return *this; + } + + /** + * Release the string data. + */ + ~OString() + { + rtl_string_release( pData ); + } + + /** + * Allocates a new string that contains the sequence of characters + * currently contained in the string buffer argument. + * + * @param buffer a <code>StringBuffer</code>. + */ + //public OString (StringBuffer buffer) { + + /** + * Returns the length of this string. + * The length is equal to the number of 16-bit + * Unicode characters in the string. + * + * @return the length of the sequence of characters represented by this + * object. + */ + sal_Int32 getLength() const { return pData->length; } + + /** + * Returns the character at the specified index. An index ranges + * from <code>0</code> to <code>length() - 1</code>. + * + * @param index the index of the character. + * @return the character at the specified index of this string. + * The first character is at index <code>0</code>. + * @exception StringIndexOutOfBoundsException if the index is out of + * range. + */ + //sal_Char operator [] ( sal_Int32 nIndex ) const + // { return pData->buffer[nIndex]; } + + /** + * Return a null terminated character array. + */ + operator const sal_Char *() const { return pData->buffer; } + + /** + * Return a null terminated unicode character array. + */ + const sal_Char* getStr() const { return pData->buffer; } + + /** + * Compares this string to the specified object. + * The result is <code>true</code> if and only if the argument is not + * <code>null</code> and is a <code>OString</code> object that represents + * the same sequence of characters as this object. + * + * @param anObject the object to compare this <code>OString</code> + * against. + * @return <code>true</code> if the <code>OString </code>are equal; + * <code>false</code> otherwise. + * @see java.lang.OString#compareTo(java.lang.OString) + * @see java.lang.OString#equalsIgnoreCase(java.lang.OString) + */ + sal_Bool equals( const OString & rObj ) const + { + return getLength() == rObj.getLength() && compareTo( rObj ) == 0; + } + + /** + * Compares this OString to another object. + * The result is <code>true</code> if and only if the argument is not + * <code>null</code> and is a <code>OString</code> object that represents + * the same sequence of characters as this object, where case is ignored. + * <p> + * Two characters are considered the same, ignoring case, if at + * least one of the following is true: + * <ul> + * <li>The two characters are the same (as compared by the <code>==</code> + * operator). + * <li>Applying the method <code>Character.toUppercase</code> to each + * character produces the same result. + * <li>Applying the method <code>Character.toLowercase</code> to each + * character produces the same result. + * </ul> + * <p> + * Two sequences of characters are the same, ignoring case, if the + * sequences have the same length and corresponding characters are + * the same, ignoring case. + * + * @param anotherString the <code>OString</code> to compare this + * <code>OString</code> against. + * @return <code>true</code> if the <code>OString</code>s are equal, + * ignoring case; <code>false</code> otherwise. + * @see java.lang.Character#toLowerCase(char) + * @see java.lang.Character#toUpperCase(char) + */ + sal_Bool equalsIgnoreCase( const OString & rObj ) const + { + return rtl_str_equalsIgnoreCase_WithLength( pData->buffer, pData->length, + rObj.pData->buffer, rObj.pData->length ); + } + + /** + * Compares two strings lexicographically. + * The comparison is based on the Unicode value of each character in + * the strings. + * + * @param anotherString the <code>OString</code> to be compared. + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if this string + * is lexicographically less than the string argument; and a + * value greater than <code>0</code> if this string is + * lexicographically greater than the string argument. + */ + sal_Int32 compareTo( const OString & rObj ) const + { + return rtl_str_compare_WithLength( pData->buffer, pData->length, + rObj.pData->buffer, rObj.pData->length ); + } + + /** + * Compares two strings lexicographically using only the number of + * characters given in the length parameter. + * The comparison is based on the Unicode value of each character in + * the strings. + * + * @param anotherString the <code>OString</code> to be compared. + * @param length the number of characters that are compared. + * @return 'This string' and 'argument string' here means the substring + * defined by the length parameter. + * the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if this string + * is lexicographically less than the string argument; and a + * value greater than <code>0</code> if this string is + * lexicographically greater than the string argument. + */ + sal_Int32 compareTo( const OString & rObj, sal_Int32 length ) const + { + return rtl_str_compare_WithLength( pData->buffer, length, + rObj.pData->buffer, rObj.pData->length ); + } + + friend sal_Bool operator == ( const OString& rStr1, const OString& rStr2 ) + { return rStr1.getLength() == rStr2.getLength() && rStr1.compareTo( rStr2 ) == 0; } + friend sal_Bool operator == ( const OString& rStr1, const sal_Char * pStr2 ) + { return rStr1.compareTo( pStr2 ) == 0; } + friend sal_Bool operator == ( const sal_Char * pStr1, const OString& rStr2 ) + { return OString( pStr1 ).compareTo( rStr2 ) == 0; } + + friend sal_Bool operator != ( const OString& rStr1, const OString& rStr2 ) + { return !(operator == ( rStr1, rStr2 )); } + friend sal_Bool operator != ( const OString& rStr1, const sal_Char * pStr2 ) + { return !(operator == ( rStr1, pStr2 )); } + friend sal_Bool operator != ( const sal_Char * pStr1, const OString& rStr2 ) + { return !(operator == ( pStr1, rStr2 )); } + + friend sal_Bool operator < ( const OString& rStr1, const OString& rStr2 ) + { return rStr1.compareTo( rStr2 ) < 0; } + friend sal_Bool operator > ( const OString& rStr1, const OString& rStr2 ) + { return rStr1.compareTo( rStr2 ) > 0; } + friend sal_Bool operator <= ( const OString& rStr1, const OString& rStr2 ) + { return rStr1.compareTo( rStr2 ) <= 0; } + friend sal_Bool operator >= ( const OString& rStr1, const OString& rStr2 ) + { return rStr1.compareTo( rStr2 ) >= 0; } + + /** + * Returns a hashcode for this string. + * + * @return a hash code value for this object. + */ + sal_Int32 hashCode() const + { + return rtl_str_hashCode_WithLength( pData->buffer, pData->length ); + } + + /** + * Returns the index within this string of the first occurrence of the + * specified character, starting the search at the specified index. + * + * @param ch a character. + * @param fromIndex the index to start the search from. + * @return the index of the first occurrence of the character in the + * character sequence represented by this object that is greater + * than or equal to <code>fromIndex</code>, or <code>-1</code> + * if the character does not occur. + */ + sal_Int32 indexOf( sal_Char ch, sal_Int32 fromIndex = 0 ) const + { + sal_Int32 ret = rtl_str_indexOfChar_WithLength( pData->buffer + fromIndex, pData->length - fromIndex, ch ); + return (ret < 0 ? ret : ret + fromIndex); + } + + /** + * Returns the index within this string of the first occurence of + * the specified substring. + * The returned index indicates the start of the substring, and it + * must be equal to or less than <code>fromIndex</code>. + * + * @param str the substring to search for. + * @param fromIndex the index to start the search from. + * @return If the string argument occurs one or more times as a substring + * within this object at a starting index no greater than + * <code>fromIndex</code>, then the index of the first character of + * the last such substring is returned. If it does not occur as a + * substring starting at <code>fromIndex</code> or earlier, + * <code>-1</code> is returned. + */ + sal_Int32 indexOf( const OString & str, int fromIndex = 0) const + { + sal_Int32 ret = rtl_str_indexOfStr_WithLength( pData->buffer + fromIndex, pData->length - fromIndex, + str.pData->buffer, str.pData->length ); + return (ret < 0 ? ret : ret + fromIndex); + } + + /** + * Returns the index within this string of the last occurrence of the + * specified character, searching backward starting at the end. + * + * @param ch a character. + * @param fromIndex the index to start the search from. + * @return the index of the last occurrence of the character in the + * character sequence represented by this object that is less + * than or equal to <code>length -1</code>, or <code>-1</code> + * if the character does not occur before that point. + */ + sal_Int32 lastIndexOf( sal_Char ch, int fromIndex ) const + { + return rtl_str_lastIndexOfChar_WithLength( pData->buffer, fromIndex, ch ); + } + + /** + * Returns the index within this string of the last occurrence of the + * specified character, searching backward starting at the end. + * + * @param ch a character. + * @param fromIndex the index to start the search from. + * @return the index of the last occurrence of the character in the + * character sequence represented by this object that is less + * than or equal to <code>length -1</code>, or <code>-1</code> + * if the character does not occur before that point. + */ + sal_Int32 lastIndexOf( sal_Char ch ) const + { + return rtl_str_lastIndexOfChar_WithLength( pData->buffer, pData->length, ch ); + } + + /** + * Returns the index within this string of the last occurrence of + * the specified substring. + * The returned index indicates the start of the substring, and it + * must be equal to or less than <code>fromIndex</code>. + * + * @param str the substring to search for. + * @param fromIndex the index to start the search from. + * @return If the string argument occurs one or more times as a substring + * within this object at a starting index no greater than + * <code>fromIndex</code>, then the index of the first character of + * the last such substring is returned. If it does not occur as a + * substring starting at <code>fromIndex</code> or earlier, + * <code>-1</code> is returned. + */ + sal_Int32 lastIndexOf( const OString & str, int fromIndex ) const + { + return rtl_str_lastIndexOfStr_WithLength( pData->buffer, fromIndex, + str.pData->buffer, str.pData->length ); + } + + /** + * Returns the index within this string of the last occurrence of + * the specified substring. + * The returned index indicates the start of the substring, and it + * must be equal to or less than <code>fromIndex</code>. + * + * @param str the substring to search for. + * @param fromIndex the index to start the search from. + * @return If the string argument occurs one or more times as a substring + * within this object at a starting index no greater than + * <code>fromIndex</code>, then the index of the first character of + * the last such substring is returned. If it does not occur as a + * substring starting at <code>fromIndex</code> or earlier, + * <code>-1</code> is returned. + */ + sal_Int32 lastIndexOf( const OString & str ) const + { + return rtl_str_lastIndexOfStr_WithLength( pData->buffer, pData->length, + str.pData->buffer, str.pData->length ); + } + + /** + * Returns a new string that is a substring of this string. The + * substring begins at the specified index and extends to the end of + * this string. + * + * @param beginIndex the beginning index, inclusive. + * @return the specified substring. + * @exception StringIndexOutOfBoundsException if the + * <code>beginIndex</code> is out of range. + */ + OString copy( sal_Int32 beginIndex) const + { + return copy( beginIndex, getLength() - beginIndex ); + } + + + /** + * Returns a new string that is a substring of this string. The + * substring begins at the specified <code>beginIndex</code> and + * extends to the character at index <code>endIndex - 1</code>. + * + * @param beginIndex the beginning index, inclusive. + * @param count the number of characters. + * @return the specified substring. + * @exception StringIndexOutOfBoundsException if the + * <code>beginIndex</code> or the <code>endIndex</code> is + * out of range. + */ + OString copy( sal_Int32 beginIndex, sal_Int32 count ) const + { + if( beginIndex == 0 && count == getLength() ) + return *this; + else + { + OString newStr; + rtl_string_newFromStr_WithLength( &newStr.pData, pData->buffer + beginIndex, count ); + return newStr; + } + } + + /** + * Concatenates the specified string to the end of this string. + * <p> + * If the length of the argument string is <code>0</code>, then this + * object is returned. + * + * @param str the <code>OString</code> that is concatenated to the end + * of this <code>OString</code>. + * @return a string that represents the concatenation of this object's + * characters followed by the string argument's characters. + */ + OString concat( const OString & str ) const + { + OString newStr; + rtl_string_newConcat( &newStr.pData, pData, str.pData ); + return newStr; + } + + friend OString operator+( const OString& rStr1, const OString& rStr2 ) + { + return rStr1.concat( rStr2 ); + } + + /** + * Returns a new string resulting from replacing all occurrences of + * <code>oldChar</code> in this string with <code>newChar</code>. + * <p> + * If the character <code>oldChar</code> does not occur in the + * character sequence represented by this object, then this string is + * returned. + * + * @param oldChar the old character. + * @param newChar the new character. + * @return a string derived from this string by replacing every + * occurrence of <code>oldChar</code> with <code>newChar</code>. + */ + OString replace( sal_Char oldChar, sal_Char newChar ) const + { + rtl_String * pNew = 0; + rtl_string_newReplace( &pNew, pData, oldChar, newChar ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Returns a new string resulting from replacing n = count characters + * from position index in this string with <code>newStr</code>. + * <p> + * + * @param index the index for beginning. + * @param count the count of charcters that will replaced + * @param newStr the new substring. + * @return the new string. The reference count is 1. + */ + OString replaceAt(sal_Int32 index, sal_Int32 count, const OString& newStr ) const + { + rtl_String * pNew = 0; + rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Converts this <code>OString</code> to lowercase. + * <p> + * If no character in the string has a different lowercase version, + * based on calling the <code>toLowerCase</code> method defined by + * <code>Character</code>, then the original string is returned. + * <p> + * Otherwise, a new string is allocated, whose length is identical + * to this string, and such that each character that has a different + * lowercase version is mapped to this lowercase equivalent. + * + * @return the string, converted to lowercase. + * @see java.lang.Character#toLowerCase(char) + * @see java.lang.OString#toUpperCase() + */ + OString toLowerCase() const + { + rtl_String * pNew = 0; + rtl_string_newToLowerCase( &pNew, pData ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Converts this string to uppercase. + * <p> + * If no character in this string has a different uppercase version, + * based on calling the <code>toUpperCase</code> method defined by + * <code>Character</code>, then the original string is returned. + * <p> + * Otherwise, a new string is allocated, whose length is identical + * to this string, and such that each character that has a different + * uppercase version is mapped to this uppercase equivalent. + * + * @return the string, converted to uppercase. + * @see java.lang.Character#toUpperCase(char) + * @see java.lang.OString#toLowerCase() + */ + OString toUpperCase() const + { + rtl_String * pNew = 0; + rtl_string_newToUpperCase( &pNew, pData ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Removes white space from both ends of this string. + * <p> + * All characters that have codes less than or equal to + * <code>'\u0020'</code> (the space character) are considered to be + * white space. + * + * @return this string, with white space removed from the front and end. + */ + OString trim() const + { + rtl_String * pNew = 0; + rtl_string_newTrim( &pNew, pData ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Returns the string representation of the <code>sal_Bool</code> argument. + * + * @param b a <code>sal_Bool</code>. + * @return if the argument is <code>true</code>, a string equal to + * <code>"true"</code> is returned; otherwise, a string equal to + * <code>"false"</code> is returned. + */ + static OString valueOf(sal_Bool b) + { + sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN]; + rtl_String * pNew = 0; + rtl_string_newFromStr_WithLength( &pNew, sz, rtl_str_valueOfBoolean( sz, b ) ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Returns the string representation of the <code>char</code> * argument. + * + * @param c a <code>char</code>. + * @return a newly allocated string of length <code>1</code> containing + * as its single character the argument <code>c</code>. + */ + static OString valueOf(sal_Char c) + { + return OString( &c, 1 ); + } + + /** + * Returns the string representation of the <code>int</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Integer.toString</code> method of one argument. + * + * @param i an <code>int</code>. + * @return a newly allocated string containing a string representation of + * the <code>int</code> argument. + * @see java.lang.Integer#toString(int, int) + */ + static OString valueOf(sal_Int32 i, sal_Int16 radix = 10 ) + { + sal_Char sz[RTL_STR_MAX_VALUEOFINT32]; + rtl_String * pNew = 0; + rtl_string_newFromStr_WithLength( &pNew, sz, rtl_str_valueOfInt32( sz, i, radix ) ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Returns the string representation of the <code>long</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Long.toString</code> method of one argument. + * + * @param l a <code>long</code>. + * @return a newly allocated string containing a string representation of + * the <code>long</code> argument. + * @see java.lang.Long#toString(long) + */ + static OString valueOf(sal_Int64 l, sal_Int16 radix = 10 ) + { + sal_Char sz[RTL_STR_MAX_VALUEOFINT64]; + rtl_String * pNew = 0; + rtl_string_newFromStr_WithLength( &pNew, sz, rtl_str_valueOfInt64( sz, l, radix ) ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Returns the string representation of the <code>float</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Float.toString</code> method of one argument. + * + * @param f a <code>float</code>. + * @return a newly allocated string containing a string representation of + * the <code>float</code> argument. + * @see java.lang.Float#toString(float) + */ + static OString valueOf(float f) + { + sal_Char sz[RTL_STR_MAX_VALUEOFFLOAT]; + rtl_String * pNew = 0; + rtl_string_newFromStr_WithLength( &pNew, sz, rtl_str_valueOfFloat( sz, f ) ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + /** + * Returns the string representation of the <code>double</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Double.toString</code> method of one argument. + * + * @param d a <code>double</code>. + * @return a newly allocated string containing a string representation of + * the <code>double</code> argument. + * @see java.lang.Double#toString(double) + */ + static OString valueOf(double d) + { + sal_Char sz[RTL_STR_MAX_VALUEOFDOUBLE]; + rtl_String * pNew = 0; + rtl_string_newFromStr_WithLength( &pNew, sz, rtl_str_valueOfDouble( sz, d ) ); + return OString( pNew, (DO_NOT_ACQUIRE *)0 ); + } + + // UString compatibility deprecated + sal_Int32 len() const { return getLength(); } + + sal_Int32 search( sal_Char ch ) const { return indexOf( ch ); } + + sal_Int32 getTokenCount( sal_Char cTok = ';' ) const + { + return rtl_string_getTokenCount(pData, cTok ); + } + + OString getToken( sal_Int32 nToken, sal_Char cTok = ';' ) const + { + OString newStr; + rtl_string_getToken( &newStr.pData, pData, nToken, cTok ); + return newStr; + } + + sal_Int32 search( const OString& rStr, sal_Int32 nIndex = 0) const { return indexOf( rStr, nIndex ); } + sal_Int32 search( const sal_Char* pchar, sal_Int32 nIndex = 0) const { return indexOf( pchar, nIndex ); } +}; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _RTL_STRING_HXX_ */ + + + diff --git a/sal/inc/rtl/tencinfo.h b/sal/inc/rtl/tencinfo.h new file mode 100644 index 000000000000..d2ebe8680cf8 --- /dev/null +++ b/sal/inc/rtl/tencinfo.h @@ -0,0 +1,166 @@ +/************************************************************************* + * + * $RCSfile: tencinfo.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _RTL_TENCINFO_H +#define _RTL_TENCINFO_H + +#ifndef _SAL_TYPES_H +#include <sal/types.h> +#endif +#ifndef _RTL_TEXTENC_H +#include <rtl/textenc.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------- */ +/* - Scripts - */ +/* ----------- */ + +typedef sal_uInt16 rtl_Script; +#define SCRIPT_DONTKNOW ((rtl_Script)0) +#define SCRIPT_UNICODE ((rtl_Script)1) +#define SCRIPT_SYMBOL ((rtl_Script)2) +#define SCRIPT_LATIN ((rtl_Script)3) +#define SCRIPT_EASTEUROPE ((rtl_Script)4) +#define SCRIPT_CYRILLIC ((rtl_Script)5) +#define SCRIPT_BALTIC ((rtl_Script)6) +#define SCRIPT_TURKISH ((rtl_Script)7) +#define SCRIPT_GREEK ((rtl_Script)8) +#define SCRIPT_JAPANESE ((rtl_Script)9) +#define SCRIPT_CHINESE_SIMPLIFIED ((rtl_Script)10) +#define SCRIPT_CHINESE_TRADITIONAL ((rtl_Script)11) +#define SCRIPT_KOREAN ((rtl_Script)12) +#define SCRIPT_ARABIC ((rtl_Script)13) +#define SCRIPT_HEBREW ((rtl_Script)14) +#define SCRIPT_ARMENIAN ((rtl_Script)15) +#define SCRIPT_DEVANAGARI ((rtl_Script)16) +#define SCRIPT_BENGALI ((rtl_Script)17) +#define SCRIPT_GURMUKHI ((rtl_Script)18) +#define SCRIPT_GUJARATI ((rtl_Script)19) +#define SCRIPT_ORIYA ((rtl_Script)20) +#define SCRIPT_TAMIL ((rtl_Script)21) +#define SCRIPT_TELUGU ((rtl_Script)22) +#define SCRIPT_KANNADA ((rtl_Script)23) +#define SCRIPT_MALAYALAM ((rtl_Script)24) +#define SCRIPT_THAI ((rtl_Script)25) +#define SCRIPT_VIETNAMESE ((rtl_Script)26) +#define SCRIPT_LAO ((rtl_Script)27) +#define SCRIPT_GEORGIEN ((rtl_Script)28) + +/* ---------------------------- */ +/* - TextEncoding - InfoFlags - */ +/* ---------------------------- */ + +#define RTL_TEXTENCODING_INFO_CONTEXT ((sal_uInt32)0x0001) +#define RTL_TEXTENCODING_INFO_ASCII ((sal_uInt32)0x0002) +#define RTL_TEXTENCODING_INFO_UNICODE ((sal_uInt32)0x0004) +#define RTL_TEXTENCODING_INFO_MULTIBYTE ((sal_uInt32)0x0008) +#define RTL_TEXTENCODING_INFO_R2L ((sal_uInt32)0x0010) +#define RTL_TEXTENCODING_INFO_7BIT ((sal_uInt32)0x0020) +#define RTL_TEXTENCODING_INFO_SYMBOL ((sal_uInt32)0x0040) +#define RTL_TEXTENCODING_INFO_MIME ((sal_uInt32)0x0080) + +/* ----------------------- */ +/* - TextEncoding - Info - */ +/* ----------------------- */ + +typedef struct _rtl_TextEncodingInfo +{ + sal_uInt32 StructSize; + sal_uInt8 MinimumCharSize; + sal_uInt8 MaximumCharSize; + sal_uInt8 AverageCharSize; + sal_uInt8 Reserved; + sal_uInt32 Flags; + rtl_Script Script; +} rtl_TextEncodingInfo; + +sal_Bool SAL_CALL rtl_getTextEncodingInfo( rtl_TextEncoding eTextEncoding, rtl_TextEncodingInfo* pEncInfo ); + +/* -------------------------------------- */ +/* - Charset and TextEncoding - Convert - */ +/* -------------------------------------- */ + +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromWindowsCharset( sal_uInt8 nWinCharset ); +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromPCCodePage( sal_uInt32 nCodePage ); +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMacTextEncoding( sal_uInt32 nMacTextEncoding ); +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pUnixCharset ); +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pMimeCharset ); + +/* Only for internal use. Because this functions are removed in future versions */ +sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ); +sal_uInt32 SAL_CALL rtl_getBestPCCodePageFromTextEncoding( rtl_TextEncoding eTextEncoding ); +sal_uInt32 SAL_CALL rtl_getBestMacTextEncodingFromTextEncoding( rtl_TextEncoding eTextEncoding ); +const sal_Char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ); +const sal_Char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_TENCINFO_H */ + + + diff --git a/sal/inc/rtl/textcvt.h b/sal/inc/rtl/textcvt.h new file mode 100644 index 000000000000..40e0ad79d18f --- /dev/null +++ b/sal/inc/rtl/textcvt.h @@ -0,0 +1,174 @@ +/************************************************************************* + * + * $RCSfile: textcvt.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_TEXTCVT_H +#define _RTL_TEXTCVT_H + +#ifndef _SAL_TYPES_H +#include <sal/types.h> +#endif +#ifndef _RTL_TEXTENC_H +#include <rtl/textenc.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------ */ +/* - convertTextToUnicode - */ +/* ------------------------ */ + +typedef void* rtl_TextToUnicodeConverter; +typedef void* rtl_TextToUnicodeContext; + +rtl_TextToUnicodeConverter SAL_CALL rtl_createTextToUnicodeConverter( rtl_TextEncoding eTextEncoding ); +void SAL_CALL rtl_destroyTextToUnicodeConverter( rtl_TextToUnicodeConverter hConverter ); +rtl_TextToUnicodeContext SAL_CALL rtl_createTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter ); +void SAL_CALL rtl_destroyTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext ); +void SAL_CALL rtl_resetTextToUnicodeContext( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext ); + +#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR ((sal_uInt32)0x0001) +#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE ((sal_uInt32)0x0002) +#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE ((sal_uInt32)0x0003) +#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT ((sal_uInt32)0x0004) +#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR ((sal_uInt32)0x0010) +#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE ((sal_uInt32)0x0020) +#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT ((sal_uInt32)0x0030) +#define RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR ((sal_uInt32)0x0100) +#define RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE ((sal_uInt32)0x0200) +#define RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT ((sal_uInt32)0x0300) +#define RTL_TEXTTOUNICODE_FLAGS_FLUSH ((sal_uInt32)0x8000) + +#define RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK ((sal_uInt32)0x000F) +#define RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK ((sal_uInt32)0x00F0) +#define RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK ((sal_uInt32)0x0F00) + +#define RTL_TEXTTOUNICODE_INFO_ERROR ((sal_uInt32)0x0001) +#define RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL ((sal_uInt32)0x0002) +#define RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL ((sal_uInt32)0x0004) +#define RTL_TEXTTOUNICODE_INFO_UNDEFINED ((sal_uInt32)0x0008) +#define RTL_TEXTTOUNICODE_INFO_MBUNDEFINED ((sal_uInt32)0x0010) +#define RTL_TEXTTOUNICODE_INFO_INVALID ((sal_uInt32)0x0020) + +sal_Size SAL_CALL rtl_convertTextToUnicode( rtl_TextToUnicodeConverter hConverter, + rtl_TextToUnicodeContext hContext, + const sal_Char* pSrcBuf, sal_Size nSrcBytes, + sal_Unicode* pDestBuf, sal_Size nDestChars, + sal_uInt32 nFlags, sal_uInt32* pInfo, + sal_Size* pSrcCvtBytes ); + +/* ------------------------ */ +/* - convertUnicodeToText - */ +/* ------------------------ */ + +typedef void* rtl_UnicodeToTextConverter; +typedef void* rtl_UnicodeToTextContext; + +rtl_UnicodeToTextConverter SAL_CALL rtl_createUnicodeToTextConverter( rtl_TextEncoding eTextEncoding ); +void SAL_CALL rtl_destroyUnicodeToTextConverter( rtl_UnicodeToTextConverter hConverter ); +rtl_UnicodeToTextContext SAL_CALL rtl_createUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter ); +void SAL_CALL rtl_destroyUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext ); +void SAL_CALL rtl_resetUnicodeToTextContext( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext ); + +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR ((sal_uInt32)0x0001) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE ((sal_uInt32)0x0002) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0 ((sal_uInt32)0x0003) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK ((sal_uInt32)0x0004) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_UNDERLINE ((sal_uInt32)0x0005) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT ((sal_uInt32)0x0006) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR ((sal_uInt32)0x0010) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE ((sal_uInt32)0x0020) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_0 ((sal_uInt32)0x0030) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_QUESTIONMARK ((sal_uInt32)0x0040) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_UNDERLINE ((sal_uInt32)0x0050) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT ((sal_uInt32)0x0060) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE ((sal_uInt32)0x0100) +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR ((sal_uInt32)0x0200) +#define RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ((sal_uInt32)0x0400) +#define RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE ((sal_uInt32)0x0800) +#define RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE ((sal_uInt32)0x1000) +#define RTL_UNICODETOTEXT_FLAGS_PRIVATE_IGNORE ((sal_uInt32)0x2000) +#define RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE ((sal_uInt32)0x4000) +#define RTL_UNICODETOTEXT_FLAGS_FLUSH ((sal_uInt32)0x8000) + +#define RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK ((sal_uInt32)0x000F) +#define RTL_UNICODETOTEXT_FLAGS_INVALID_MASK ((sal_uInt32)0x00F0) + +#define RTL_UNICODETOTEXT_INFO_ERROR ((sal_uInt32)0x0001) +#define RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL ((sal_uInt32)0x0002) +#define RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL ((sal_uInt32)0x0004) +#define RTL_UNICODETOTEXT_INFO_UNDEFINED ((sal_uInt32)0x0008) +#define RTL_UNICODETOTEXT_INFO_INVALID ((sal_uInt32)0x0010) + +sal_Size SAL_CALL rtl_convertUnicodeToText( rtl_UnicodeToTextConverter hConverter, + rtl_UnicodeToTextContext hContext, + const sal_Unicode* pSrcBuf, sal_Size nSrcChars, + sal_Char* pDestBuf, sal_Size nDestBytes, + sal_uInt32 nFlags, sal_uInt32* pInfo, + sal_Size* pSrcCvtChars ); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_TEXTCVT_H */ + diff --git a/sal/inc/rtl/textenc.h b/sal/inc/rtl/textenc.h new file mode 100644 index 000000000000..3475ca16fda0 --- /dev/null +++ b/sal/inc/rtl/textenc.h @@ -0,0 +1,274 @@ +/************************************************************************* + * + * $RCSfile: textenc.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_TEXTENC_H +#define _RTL_TEXTENC_H + +#ifndef _SAL_TYPES_H +#include <sal/types.h> +#endif + +typedef sal_uInt16 rtl_TextEncoding; +#define RTL_TEXTENCODING_DONTKNOW ((rtl_TextEncoding)0) +#define RTL_TEXTENCODING_MS_1252 ((rtl_TextEncoding)1) +#define RTL_TEXTENCODING_APPLE_ROMAN ((rtl_TextEncoding)2) +#define RTL_TEXTENCODING_IBM_437 ((rtl_TextEncoding)3) +#define RTL_TEXTENCODING_IBM_850 ((rtl_TextEncoding)4) +#define RTL_TEXTENCODING_IBM_860 ((rtl_TextEncoding)5) +#define RTL_TEXTENCODING_IBM_861 ((rtl_TextEncoding)6) +#define RTL_TEXTENCODING_IBM_863 ((rtl_TextEncoding)7) +#define RTL_TEXTENCODING_IBM_865 ((rtl_TextEncoding)8) +/* Reserved: RTL_TEXTENCODING_SYSTEM ((rtl_TextEncoding)9) */ +#define RTL_TEXTENCODING_SYMBOL ((rtl_TextEncoding)10) +#define RTL_TEXTENCODING_ASCII_US ((rtl_TextEncoding)11) +#define RTL_TEXTENCODING_ISO_8859_1 ((rtl_TextEncoding)12) +#define RTL_TEXTENCODING_ISO_8859_2 ((rtl_TextEncoding)13) +#define RTL_TEXTENCODING_ISO_8859_3 ((rtl_TextEncoding)14) +#define RTL_TEXTENCODING_ISO_8859_4 ((rtl_TextEncoding)15) +#define RTL_TEXTENCODING_ISO_8859_5 ((rtl_TextEncoding)16) +#define RTL_TEXTENCODING_ISO_8859_6 ((rtl_TextEncoding)17) +#define RTL_TEXTENCODING_ISO_8859_7 ((rtl_TextEncoding)18) +#define RTL_TEXTENCODING_ISO_8859_8 ((rtl_TextEncoding)19) +#define RTL_TEXTENCODING_ISO_8859_9 ((rtl_TextEncoding)20) +#define RTL_TEXTENCODING_ISO_8859_14 ((rtl_TextEncoding)21) +#define RTL_TEXTENCODING_ISO_8859_15 ((rtl_TextEncoding)22) +#define RTL_TEXTENCODING_IBM_737 ((rtl_TextEncoding)23) +#define RTL_TEXTENCODING_IBM_775 ((rtl_TextEncoding)24) +#define RTL_TEXTENCODING_IBM_852 ((rtl_TextEncoding)25) +#define RTL_TEXTENCODING_IBM_855 ((rtl_TextEncoding)26) +#define RTL_TEXTENCODING_IBM_857 ((rtl_TextEncoding)27) +#define RTL_TEXTENCODING_IBM_862 ((rtl_TextEncoding)28) +#define RTL_TEXTENCODING_IBM_864 ((rtl_TextEncoding)29) +#define RTL_TEXTENCODING_IBM_866 ((rtl_TextEncoding)30) +#define RTL_TEXTENCODING_IBM_869 ((rtl_TextEncoding)31) +#define RTL_TEXTENCODING_MS_874 ((rtl_TextEncoding)32) +#define RTL_TEXTENCODING_MS_1250 ((rtl_TextEncoding)33) +#define RTL_TEXTENCODING_MS_1251 ((rtl_TextEncoding)34) +#define RTL_TEXTENCODING_MS_1253 ((rtl_TextEncoding)35) +#define RTL_TEXTENCODING_MS_1254 ((rtl_TextEncoding)36) +#define RTL_TEXTENCODING_MS_1255 ((rtl_TextEncoding)37) +#define RTL_TEXTENCODING_MS_1256 ((rtl_TextEncoding)38) +#define RTL_TEXTENCODING_MS_1257 ((rtl_TextEncoding)39) +#define RTL_TEXTENCODING_MS_1258 ((rtl_TextEncoding)40) +#define RTL_TEXTENCODING_APPLE_ARABIC ((rtl_TextEncoding)41) +#define RTL_TEXTENCODING_APPLE_CENTEURO ((rtl_TextEncoding)42) +#define RTL_TEXTENCODING_APPLE_CROATIAN ((rtl_TextEncoding)43) +#define RTL_TEXTENCODING_APPLE_CYRILLIC ((rtl_TextEncoding)44) +#define RTL_TEXTENCODING_APPLE_DEVANAGARI ((rtl_TextEncoding)45) +#define RTL_TEXTENCODING_APPLE_FARSI ((rtl_TextEncoding)46) +#define RTL_TEXTENCODING_APPLE_GREEK ((rtl_TextEncoding)47) +#define RTL_TEXTENCODING_APPLE_GUJARATI ((rtl_TextEncoding)48) +#define RTL_TEXTENCODING_APPLE_GURMUKHI ((rtl_TextEncoding)49) +#define RTL_TEXTENCODING_APPLE_HEBREW ((rtl_TextEncoding)50) +#define RTL_TEXTENCODING_APPLE_ICELAND ((rtl_TextEncoding)51) +#define RTL_TEXTENCODING_APPLE_ROMANIAN ((rtl_TextEncoding)52) +#define RTL_TEXTENCODING_APPLE_THAI ((rtl_TextEncoding)53) +#define RTL_TEXTENCODING_APPLE_TURKISH ((rtl_TextEncoding)54) +#define RTL_TEXTENCODING_APPLE_UKRAINIAN ((rtl_TextEncoding)55) +#define RTL_TEXTENCODING_APPLE_CHINSIMP ((rtl_TextEncoding)56) +#define RTL_TEXTENCODING_APPLE_CHINTRAD ((rtl_TextEncoding)57) +#define RTL_TEXTENCODING_APPLE_JAPANESE ((rtl_TextEncoding)58) +#define RTL_TEXTENCODING_APPLE_KOREAN ((rtl_TextEncoding)59) +#define RTL_TEXTENCODING_MS_932 ((rtl_TextEncoding)60) +#define RTL_TEXTENCODING_MS_936 ((rtl_TextEncoding)61) +#define RTL_TEXTENCODING_MS_949 ((rtl_TextEncoding)62) +#define RTL_TEXTENCODING_MS_950 ((rtl_TextEncoding)63) +#define RTL_TEXTENCODING_SHIFT_JIS ((rtl_TextEncoding)64) +#define RTL_TEXTENCODING_GB_2312 ((rtl_TextEncoding)65) +#define RTL_TEXTENCODING_GBT_12345 ((rtl_TextEncoding)66) +#define RTL_TEXTENCODING_GBK ((rtl_TextEncoding)67) +#define RTL_TEXTENCODING_BIG5 ((rtl_TextEncoding)68) +#define RTL_TEXTENCODING_EUC_JP ((rtl_TextEncoding)69) +#define RTL_TEXTENCODING_EUC_CN ((rtl_TextEncoding)70) +#define RTL_TEXTENCODING_EUC_TW ((rtl_TextEncoding)71) +#define RTL_TEXTENCODING_ISO_2022_JP ((rtl_TextEncoding)72) +#define RTL_TEXTENCODING_ISO_2022_CN ((rtl_TextEncoding)73) +#define RTL_TEXTENCODING_KOI8_R ((rtl_TextEncoding)74) +#define RTL_TEXTENCODING_UTF7 ((rtl_TextEncoding)75) +#define RTL_TEXTENCODING_UTF8 ((rtl_TextEncoding)76) +#define RTL_TEXTENCODING_ISO_8859_10 ((rtl_TextEncoding)77) +#define RTL_TEXTENCODING_ISO_8859_13 ((rtl_TextEncoding)78) +#define RTL_TEXTENCODING_EUC_KR ((rtl_TextEncoding)79) +#define RTL_TEXTENCODING_ISO_2022_KR ((rtl_TextEncoding)80) +#define RTL_TEXTENCODING_JIS_X_0201 ((rtl_TextEncoding)81) +#define RTL_TEXTENCODING_JIS_X_0208 ((rtl_TextEncoding)82) +#define RTL_TEXTENCODING_JIS_X_0212 ((rtl_TextEncoding)83) + +#define RTL_TEXTENCODING_STD_COUNT ((rtl_TextEncoding)84) + +#define RTL_TEXTENCODING_USER_START ((rtl_TextEncoding)0x8000) +#define RTL_TEXTENCODING_USER_END ((rtl_TextEncoding)0xEFFF) + +#define RTL_TEXTENCODING_UCS4 ((rtl_TextEncoding)0xFFFE) +#define RTL_TEXTENCODING_UCS2 ((rtl_TextEncoding)0xFFFF) +#define RTL_TEXTENCODING_UNICODE RTL_TEXTENCODING_UCS2 + +/****** Overview over the TextEncodings ***** +# Arabic (Apple Macintosh) RTL_TEXTENCODING_APPLE_ARABIC +Arabic (DOS/OS2-864) RTL_TEXTENCODING_IBM_864 +Arabic (ISO-8859-6) RTL_TEXTENCODING_ISO_8859_6 +Arabic (Windows-1256) RTL_TEXTENCODING_MS_1256 + +Baltic (DOS/OS2-775) RTL_TEXTENCODING_IBM_775 +Baltic (ISO-8859-4) RTL_TEXTENCODING_ISO_8859_4 +Baltic (Windows-1257) RTL_TEXTENCODING_MS_1257 + +Central European (Apple Macintosh) RTL_TEXTENCODING_APPLE_CENTEURO +Central European (Apple Macintosh/Croatian) RTL_TEXTENCODING_APPLE_CROATIAN +Central European (Apple Macintosh/Romanian) RTL_TEXTENCODING_APPLE_ROMANIAN +Central European (DOS/OS2-852) RTL_TEXTENCODING_IBM_852 +Central European (ISO-8859-2) RTL_TEXTENCODING_ISO_8859_2 +Central European (ISO-8859-10) RTL_TEXTENCODING_ISO_8859_10 +Central European (ISO-8859-13) RTL_TEXTENCODING_ISO_8859_13 +Central European (Windows-1250/WinLatin 2) RTL_TEXTENCODING_MS_1250 + +Chinese Simplified (Apple Macintosh) RTL_TEXTENCODING_APPLE_CHINSIMP +Chinese Simplified (EUC-CN) RTL_TEXTENCODING_EUC_CN +Chinese Simplified (GB-2312) RTL_TEXTENCODING_GB_2312 +Chinese Simplified (GBK/GB-2312-80) RTL_TEXTENCODING_GBK +# Chinese Simplified (ISO-2022-CN) RTL_TEXTENCODING_ISO_2022_CN +Chinese Simplified (Windows-936) RTL_TEXTENCODING_MS_936 + +Chinese Traditional (Apple Macintosh) RTL_TEXTENCODING_APPLE_CHINTRAD +Chinese Traditional (BIG5) RTL_TEXTENCODING_BIG5 +# Chinese Traditional (EUC-TW) RTL_TEXTENCODING_EUC_TW +Chinese Traditional (GBT-12345) RTL_TEXTENCODING_GBT_12345 +Chinese Traditional (Windows-950) RTL_TEXTENCODING_MS_950 + +Cyrillic (Apple Macintosh) RTL_TEXTENCODING_APPLE_CYRILLIC +Cyrillic (Apple Macintosh/Ukrainian) RTL_TEXTENCODING_APPLE_UKRAINIAN +Cyrillic (DOS/OS2-855) RTL_TEXTENCODING_IBM_855 +Cyrillic (DOS/OS2-866/Russian) RTL_TEXTENCODING_IBM_866 +Cyrillic (ISO-8859-5) RTL_TEXTENCODING_ISO_8859_5 +Cyrillic (KOI8-R) RTL_TEXTENCODING_KOI8_R +Cyrillic (Windows-1251) RTL_TEXTENCODING_MS_1251 + +Greek (Apple Macintosh) RTL_TEXTENCODING_APPLE_GREEK +Greek (DOS/OS2-737) RTL_TEXTENCODING_IBM_737 +Greek (DOS/OS2-869/Modern) RTL_TEXTENCODING_IBM_869 +Greek (ISO-8859-7) RTL_TEXTENCODING_ISO_8859_7 +Greek (Windows-1253) RTL_TEXTENCODING_MS_1253 + +# Hebrew (Apple Macintosh) RTL_TEXTENCODING_APPLE_HEBREW +Hebrew (DOS/OS2-862) RTL_TEXTENCODING_IBM_862 +Hebrew (ISO-8859-8) RTL_TEXTENCODING_ISO_8859_8 +Hebrew (Windows-1255) RTL_TEXTENCODING_MS_1255 + +Korean (Apple Macintosh) RTL_TEXTENCODING_APPLE_KOREAN +Korean (EUC-KR) RTL_TEXTENCODING_EUC_KR +# Korean (ISO-2022-KR) RTL_TEXTENCODING_ISO_2022_KR +Korean (Windows-Wansung-949) RTL_TEXTENCODING_MS_949 + +Latin 3 (ISO-8859-3) RTL_TEXTENCODING_ISO_8859_3 + +Japanese (Apple Macintosh) RTL_TEXTENCODING_APPLE_JAPANESE +# Japanese (EUC-JP) RTL_TEXTENCODING_EUC_JP +# Japanese (ISO-2022-JP) RTL_TEXTENCODING_ISO_2022_JP +Japanese (Shift-JIS) RTL_TEXTENCODING_SHIFT_JIS +Japanese (Windows-932) RTL_TEXTENCODING_MS_932 + +Symbol RTL_TEXTENCODING_SYMBOL + +# Thai (Apple Macintosh) RTL_TEXTENCODING_APPLE_THAI +Thai (Dos/Windows-874) RTL_TEXTENCODING_MS_874 + +Turkish (Apple Macintosh) RTL_TEXTENCODING_APPLE_TURKISH +Turkish (DOS/OS2-857) RTL_TEXTENCODING_IBM_857 +Turkish (ISO-8859-9) RTL_TEXTENCODING_ISO_8859_9 +Turkish (Windows-1254) RTL_TEXTENCODING_MS_1254 + +Unicode (UTF-7) RTL_TEXTENCODING_UTF7 +Unicode (UTF-8) RTL_TEXTENCODING_UTF8 + +Vietnamese (Windows-1258) RTL_TEXTENCODING_MS_1258 + +Western (Apple Macintosh) RTL_TEXTENCODING_APPLE_ROMAN +Western (Apple Macintosh/Icelandic) RTL_TEXTENCODING_APPLE_ICELAND +Western (ASCII/US) RTL_TEXTENCODING_ASCII_US +Western (DOS/OS2-437/US) RTL_TEXTENCODING_IBM_437 +Western (DOS/OS2-850/International) RTL_TEXTENCODING_IBM_850 +Western (DOS/OS2-860/Portugese) RTL_TEXTENCODING_IBM_860 +Western (DOS/OS2-861/Icelandic) RTL_TEXTENCODING_IBM_861 +Western (DOS/OS2-863/Canadian-French) RTL_TEXTENCODING_IBM_863 +Western (DOS/OS2-865/Nordic) RTL_TEXTENCODING_IBM_865 +Western (ISO-8859-1) RTL_TEXTENCODING_ISO_8859_1 +Western (ISO-8859-14) RTL_TEXTENCODING_ISO_8859_14 +Western (ISO-8859-15/EURO) RTL_TEXTENCODING_ISO_8859_15 +Western (Window-1252/WinLatin 1) RTL_TEXTENCODING_MS_1252 + +Not known and currently not supported +# RTL_TEXTENCODING_APPLE_DEVANAGARI +# RTL_TEXTENCODING_APPLE_FARSI +# RTL_TEXTENCODING_APPLE_GUJARATI +# RTL_TEXTENCODING_APPLE_GURMUKHI + +Only for internal implementations and not useful for user interface. +These encodings are not used for text encodings, only used for +font-/textoutput encodings. +Japanese (JIS 0201) RTL_TEXTENCODING_JISX_0201 +Japanese (JIS 0208) RTL_TEXTENCODING_JISX_0208 +Japanese (JIS 0212) RTL_TEXTENCODING_JISX_0212 + +# Currently not implemented +*/ + +#endif /* _RTL_TEXTENC_H */ + diff --git a/sal/inc/rtl/ustrbuf.h b/sal/inc/rtl/ustrbuf.h new file mode 100644 index 000000000000..facc966410cc --- /dev/null +++ b/sal/inc/rtl/ustrbuf.h @@ -0,0 +1,176 @@ +/************************************************************************* + * + * $RCSfile: ustrbuf.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_USTRBUF_H_ +#define _RTL_USTRBUF_H_ + +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Allocates a new <code>String</code> that contains characters from + * the character array argument. The <code>count</code> argument specifies + * the length of the array. The initial capacity of the string buffer is + * <code>16</code> plus the length of the string argument. + * + * @param newStr out parameter, contains the new string. The reference count is 1. + * @param value the initial value of the string. + * @param count the length of value. + */ +void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr, + const sal_Unicode * value, + sal_Int32 count ); + +/** + * Allocates a new <code>String</code> that contains the same sequence of + * characters as the string argument. The initial capacity is the larger of: + * <ul> + * <li> The <code>bufferLen</code> argument. + * <li> The <code>length</code> of the string argument. + * </ul> + * + * @param newStr out parameter, contains the new string. The reference count is 1. + * @param capacity the initial len of the string buffer. + * @param oldStr the initial value of the string. + * @return the new capacity of the string buffer + */ +sal_Int32 SAL_CALL rtl_uStringbuffer_newFromStringBuffer( rtl_uString ** newStr, + sal_Int32 capacity, + rtl_uString * olsStr ); + +/** + * Ensures that the capacity of the buffer is at least equal to the + * specified minimum. + * If the current capacity of this string buffer is less than the + * argument, then a new internal buffer is allocated with greater + * capacity. The new capacity is the larger of: + * <ul> + * <li>The <code>minimumCapacity</code> argument. + * <li>Twice the old capacity, plus <code>2</code>. + * </ul> + * If the <code>minimumCapacity</code> argument is nonpositive, this + * method takes no action and simply returns. + * + * @param capacity in: old capicity, out: new capacity. + * @param minimumCapacity the minimum desired capacity. + */ +void SAL_CALL rtl_uStringbuffer_ensureCapacity( /*inout*/rtl_uString ** This, + /*inout*/sal_Int32* capacity, + sal_Int32 minimumCapacity); + +/** + * Inserts the string representation of the <code>str</code> array + * argument into this string buffer. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param This The string, on that the operation should take place + * @param capacity the capacity of the string buffer + * @param offset the offset. + * @param str a character array. + * @param len the number of characters to append. + */ +void SAL_CALL rtl_uStringbuffer_insert( /*inout*/rtl_uString ** This, + /*inout*/sal_Int32 * capacity, + sal_Int32 offset, + const sal_Unicode * str, + sal_Int32 len); + + +/** + * Inserts the 8-Bit ASCII string representation of the <code>str</code> + * array argument into this string buffer. Since this function is optimized + * for performance, the ASCII character values are not converted in any way. + * The caller has to make sure that all ASCII characters are in the allowed + * range between 0 and 127. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param This The string, on that the operation should take place + * @param capacity the capacity of the string buffer + * @param offset the offset. + * @param str a character array. + * @param len the number of characters to append. + */ +void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, + /*inout*/sal_Int32 * capacity, + sal_Int32 offset, + const sal_Char * str, + sal_Int32 len); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_USTRBUF_H_ */ + + diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx new file mode 100644 index 000000000000..6178ddf2e41d --- /dev/null +++ b/sal/inc/rtl/ustrbuf.hxx @@ -0,0 +1,736 @@ +/************************************************************************* + * + * $RCSfile: ustrbuf.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:14 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_USTRBUF_HXX_ +#define _RTL_USTRBUF_HXX_ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif +#ifndef _RTL_USTRBUF_H_ +#include <rtl/ustrbuf.h> +#endif +#ifndef _RTL_USTRING_ +#ifdef __BORLANDC__ +#include <rtl/wstring.> +#else +#include <rtl/ustring> +#endif /*__BORLANDC__*/ +#endif /*_RTL_USTRING_*/ + +#ifdef __cplusplus + +#ifdef _USE_NAMESPACE +namespace rtl +{ +#endif + +/** + * A string buffer implements a mutable sequence of characters. + * <p> + * String buffers are safe for use by multiple threads. The methods + * are synchronized where necessary so that all the operations on any + * particular instance behave as if they occur in some serial order. + * <p> + * String buffers are used by the compiler to implement the binary + * string concatenation operator <code>+</code>. For example, the code: + * <p><blockquote><pre> + * x = "a" + 4 + "c" + * </pre></blockquote><p> + * is compiled to the equivalent of: + * <p><blockquote><pre> + * x = new OUStringBuffer().append("a").append(4).append("c") + * .toString() + * </pre></blockquote><p> + * The principal operations on a <code>OUStringBuffer</code> are the + * <code>append</code> and <code>insert</code> methods, which are + * overloaded so as to accept data of any type. Each effectively + * converts a given datum to a string and then appends or inserts the + * characters of that string to the string buffer. The + * <code>append</code> method always adds these characters at the end + * of the buffer; the <code>insert</code> method adds the characters at + * a specified point. + * <p> + * For example, if <code>z</code> refers to a string buffer object + * whose current contents are "<code>start</code>", then + * the method call <code>z.append("le")</code> would cause the string + * buffer to contain "<code>startle</code>", whereas + * <code>z.insert(4, "le")</code> would alter the string buffer to + * contain "<code>starlet</code>". + * <p> + * Every string buffer has a capacity. As long as the length of the + * character sequence contained in the string buffer does not exceed + * the capacity, it is not necessary to allocate a new internal + * buffer array. If the internal buffer overflows, it is + * automatically made larger. + */ +class OUStringBuffer +{ +public: + /** + * Constructs a string buffer with no characters in it and an + * initial capacity of 16 characters. + */ + OUStringBuffer() + : pData(NULL) + , nCapacity( 16 ) + { + rtl_uString_new_WithLength( &pData, nCapacity ); + } + + /** + * Allocates a new string buffer that contains the same sequence of + * characters as the string buffer argument. + * + * @param value a <code>OStringBuffer</code>. + */ + OUStringBuffer( const OUStringBuffer & value ) + : pData(NULL) + , nCapacity( value.nCapacity ) + { + rtl_uStringbuffer_newFromStringBuffer( &pData, value.nCapacity, value.pData ); + } + + /** + * Constructs a string buffer with no characters in it and an + * initial capacity specified by the <code>length</code> argument. + * + * @param length the initial capacity. + */ + OUStringBuffer(sal_Int32 length) + : pData(NULL) + , nCapacity( length ) + { + rtl_uString_new_WithLength( &pData, length ); + } + + /** + * Constructs a string buffer so that it represents the same + * sequence of characters as the string argument. The initial + * capacity of the string buffer is <code>16</code> plus the length + * of the string argument. + * + * @param str the initial contents of the buffer. + */ + OUStringBuffer(OUString value) + : pData(NULL) + , nCapacity( value.getLength() + 16 ) + { + rtl_uStringbuffer_newFromStr_WithLength( &pData, value.getStr(), value.getLength() ); + } + + /** + * Release the string own string data and notice and acquire the string data of value. + */ + OUStringBuffer& operator = ( const OUStringBuffer& value ) + { + rtl_uString_assign( &pData, value.pData ); + return *this; + } + + /** + * Release the string data. + */ + ~OUStringBuffer() + { + rtl_uString_release( pData ); + } + + /** + * Fill the string data in the new string and clear the buffer.<BR> + * This method is more efficient than the contructor of the string. It does + * not copy the buffer. + * + * @return the string previously contained in the buffer. + */ + OUString makeStringAndClear() + { + OUString aRet( pData ); + RTL_USTRING_NEW(&pData); + nCapacity = 0; + return aRet; + } + + /** + * Returns the length (character count) of this string buffer. + * + * @return the number of characters in this string buffer. + */ + sal_Int32 getLength() + { + return pData->length; + } + + /** + * Returns the current capacity of the String buffer. The capacity + * is the amount of storage available for newly inserted + * characters. The real buffer size is 2 bytes longer, because + * all strings are 0 terminated. + * + * @return the current capacity of this string buffer. + */ + sal_Int32 getCapacity() + { + return nCapacity; + } + + /** + * Ensures that the capacity of the buffer is at least equal to the + * specified minimum. + * If the current capacity of this string buffer is less than the + * argument, then a new internal buffer is allocated with greater + * capacity. The new capacity is the larger of: + * <ul> + * <li>The <code>minimumCapacity</code> argument. + * <li>Twice the old capacity, plus <code>2</code>. + * </ul> + * If the <code>minimumCapacity</code> argument is nonpositive, this + * method takes no action and simply returns. + * + * @param minimumCapacity the minimum desired capacity. + */ + void ensureCapacity(sal_Int32 minimumCapacity) + { + rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, minimumCapacity ); + } + + /** + * Sets the length of this String buffer. + * If the <code>newLength</code> argument is less than the current + * length of the string buffer, the string buffer is truncated to + * contain exactly the number of characters given by the + * <code>newLength</code> argument. + * <p> + * If the <code>newLength</code> argument is greater than or equal + * to the current length, sufficient null characters + * (<code>'\u0000'</code>) are appended to the string buffer so that + * length becomes the <code>newLength</code> argument. + * <p> + * The <code>newLength</code> argument must be greater than or equal + * to <code>0</code>. + * + * @param newLength the new length of the buffer. + */ + void setLength(sal_Int32 newLength) + { + if( newLength > nCapacity ) + rtl_uStringbuffer_ensureCapacity(&pData, &nCapacity, newLength); + else + pData->buffer[newLength] = 0; + pData->length = newLength; + } + + /** + * Returns the character at a specific index in this string buffer. + * <p> + * The first character of a string buffer is at index + * <code>0</code>, the next at index <code>1</code>, and so on, for + * array indexing. + * <p> + * The index argument must be greater than or equal to + * <code>0</code>, and less than the length of this string buffer. + * + * @param index the index of the desired character. + * @return the character at the specified index of this string buffer. + */ + sal_Unicode charAt( sal_Int32 index ) + { + return pData->buffer[ index ]; + } + + /** + * Return a null terminated unicode character array. + */ + operator const sal_Unicode *() const { return pData->buffer; } + + /** + * Return a null terminated unicode character array. + */ + const sal_Unicode* getStr() const { return pData->buffer; } + + + /** + * The character at the specified index of this string buffer is set + * to <code>ch</code>. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than the length of this string buffer. + * + * @param index the index of the character to modify. + * @param ch the new character. + */ + OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch) + { + pData->buffer[ index ] = ch; + return *this; + } + + /** + * Appends the string to this string buffer. + * <p> + * The characters of the <code>String</code> argument are appended, in + * order, to the contents of this string buffer, increasing the + * length of this string buffer by the length of the argument. + * + * @param str a string. + * @return this string buffer. + */ + OUStringBuffer & append(const OUString &str) + { + return append( str.getStr(), str.getLength() ); + } + + /** + * Appends the string representation of the <code>char</code> array + * argument to this string buffer. + * <p> + * The characters of the array argument are appended, in order, to + * the contents of this string buffer. The length of this string + * buffer increases by the length of the argument. + * + * @param str the characters to be appended. + * @return this string buffer. + */ + OUStringBuffer & append( const sal_Unicode * str ) + { + return append( str, rtl_ustr_getLength( str ) ); + } + + /** + * Appends the string representation of the <code>char</code> array + * argument to this string buffer. + * <p> + * Characters of the character array <code>str</code> are appended, + * in order, to the contents of this string buffer. The length of this + * string buffer increases by the value of <code>len</code>. + * + * @param str the characters to be appended. + * @param len the number of characters to append. + * @return this string buffer. + */ + OUStringBuffer & append( const sal_Unicode * str, sal_Int32 len) + { + // insert behind the last character + rtl_uStringbuffer_insert( &pData, &nCapacity, getLength(), str, len ); + return *this; + } + + /** + * Appends a 8-Bit ASCII character string to this string buffer. + * Since this method is optimized for performance. the ASCII + * character values are not converted in any way. The caller + * has to make sure that all ASCII characters are in the + * allowed range between 0 and 127. The ASCII string must be + * NULL-terminated. + * <p> + * The characters of the array argument are appended, in order, to + * the contents of this string buffer. The length of this string + * buffer increases by the length of the argument. + * + * @param str the 8-Bit ASCII characters to be appended. + * @return this string buffer. + */ + OUStringBuffer & appendAscii( const sal_Char * str ) + { + return appendAscii( str, rtl_str_getLength( str ) ); + } + + /** + * Appends a 8-Bit ASCII character string to this string buffer. + * Since this method is optimized for performance. the ASCII + * character values are not converted in any way. The caller + * has to make sure that all ASCII characters are in the + * allowed range between 0 and 127. The ASCII string must be + * NULL-terminated. + * <p> + * Characters of the character array <code>str</code> are appended, + * in order, to the contents of this string buffer. The length of this + * string buffer increases by the value of <code>len</code>. + * + * @param str the 8-Bit ASCII characters to be appended. + * @param len the number of characters to append. + * @return this string buffer. + */ + OUStringBuffer & appendAscii( const sal_Char * str, sal_Int32 len) + { + rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, getLength(), str, len ); + return *this; + } + + + /** + * Appends the string representation of the <code>sal_Bool</code> + * argument to the string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param b a <code>sal_Bool</code>. + * @return this string buffer. + */ + OUStringBuffer & append(sal_Bool b) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN]; + return append( sz, rtl_ustr_valueOfBoolean( sz, b ) ); + } + + /** + * Appends the string representation of the <code>char</code> + * argument to this string buffer. + * <p> + * The argument is appended to the contents of this string buffer. + * The length of this string buffer increases by <code>1</code>. + * + * @param ch a <code>char</code>. + * @return this string buffer. + */ + OUStringBuffer & append(sal_Unicode c) + { + return append( &c, 1 ); + } + + /** + * Appends the string representation of the <code>sal_Int32</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param i an <code>sal_Int32</code>. + * @return this string buffer. + */ + OUStringBuffer & append(sal_Int32 i, sal_Int16 radix = 10 ) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32]; + return append( sz, rtl_ustr_valueOfInt32( sz, i, radix ) ); + } + + /** + * Appends the string representation of the <code>long</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param l a <code>long</code>. + * @return this string buffer. + */ + OUStringBuffer & append(sal_Int64 l, sal_Int16 radix = 10 ) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64]; + return append( sz, rtl_ustr_valueOfInt64( sz, l, radix ) ); + } + + /** + * Appends the string representation of the <code>float</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param f a <code>float</code>. + * @return this string buffer. + */ + OUStringBuffer & append(float f) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT]; + return append( sz, rtl_ustr_valueOfFloat( sz, f ) ); + } + + /** + * Appends the string representation of the <code>double</code> + * argument to this string buffer. + * <p> + * The argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then appended to this string buffer. + * + * @param d a <code>double</code>. + * @return this string buffer. + */ + OUStringBuffer & append(double d) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE]; + return append( sz, rtl_ustr_valueOfDouble( sz, d ) ); + } + + /** + * Inserts the string into this string buffer. + * <p> + * The characters of the <code>String</code> argument are inserted, in + * order, into this string buffer at the indicated offset. The length + * of this string buffer is increased by the length of the argument. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param str a string. + * @return this string buffer. + */ + OUStringBuffer & insert(sal_Int32 offset, const OUString & str) + { + return insert( offset, str.getStr(), str.getLength() ); + } + + /** + * Inserts the string representation of the <code>char</code> array + * argument into this string buffer. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param offset the offset. + * @param ch a character array. + * @return this string buffer. + */ + OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str ) + { + return insert( offset, str, rtl_ustr_getLength( str ) ); + } + + /** + * Inserts the string representation of the <code>char</code> array + * argument into this string buffer. + * <p> + * The characters of the array argument are inserted into the + * contents of this string buffer at the position indicated by + * <code>offset</code>. The length of this string buffer increases by + * the length of the argument. + * + * @param offset the offset. + * @param ch a character array. + * @param len the number of characters to append. + * @return this string buffer. + */ + OUStringBuffer & insert( sal_Int32 offset, const sal_Unicode * str, sal_Int32 len) + { + // insert behind the last character + rtl_uStringbuffer_insert( &pData, &nCapacity, offset, str, len ); + return *this; + } + + /** + * Inserts the string representation of the <code>sal_Bool</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>sal_Bool</code>. + * @return this string buffer. + */ + OUStringBuffer & insert(sal_Int32 offset, sal_Bool b) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFBOOLEAN]; + return insert( offset, sz, rtl_ustr_valueOfBoolean( sz, b ) ); + } + + /** + * Inserts the string representation of the <code>char</code> + * argument into this string buffer. + * <p> + * The second argument is inserted into the contents of this string + * buffer at the position indicated by <code>offset</code>. The length + * of this string buffer increases by one. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param ch a <code>char</code>. + * @return this string buffer. + */ + OUStringBuffer & insert(sal_Int32 offset, sal_Unicode c) + { + return insert( offset, &c, 1 ); + } + + /** + * Inserts the string representation of the second <code>sal_Int32</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b an <code>sal_Int32</code>. + * @return this string buffer. + * @exception StringIndexOutOfBoundsException if the offset is invalid. + */ + OUStringBuffer & insert(sal_Int32 offset, sal_Int32 i, sal_Int16 radix = 10 ) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT32]; + return insert( offset, sz, rtl_ustr_valueOfInt32( sz, i, radix ) ); + } + + /** + * Inserts the string representation of the <code>long</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>long</code>. + * @return this string buffer. + * @exception StringIndexOutOfBoundsException if the offset is invalid. + */ + OUStringBuffer & insert(sal_Int32 offset, sal_Int64 l, sal_Int16 radix = 10 ) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFINT64]; + return insert( offset, sz, rtl_ustr_valueOfInt64( sz, l, radix ) ); + } + + /** + * Inserts the string representation of the <code>float</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>float</code>. + * @return this string buffer. + * @exception StringIndexOutOfBoundsException if the offset is invalid. + */ + OUStringBuffer insert(sal_Int32 offset, float f) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFFLOAT]; + return insert( offset, sz, rtl_ustr_valueOfFloat( sz, f ) ); + } + + /** + * Inserts the string representation of the <code>double</code> + * argument into this string buffer. + * <p> + * The second argument is converted to a string as if by the method + * <code>String.valueOf</code>, and the characters of that + * string are then inserted into this string buffer at the indicated + * offset. + * <p> + * The offset argument must be greater than or equal to + * <code>0</code>, and less than or equal to the length of this + * string buffer. + * + * @param offset the offset. + * @param b a <code>double</code>. + * @return this string buffer. + * @exception StringIndexOutOfBoundsException if the offset is invalid. + */ + OUStringBuffer & insert(sal_Int32 offset, double d) + { + sal_Unicode sz[RTL_USTR_MAX_VALUEOFDOUBLE]; + return insert( offset, sz, rtl_ustr_valueOfDouble( sz, d ) ); + } +private: + /** + * A pointer to the data structur which contains the data. + */ + rtl_uString * pData; + + /** + * The len of the pData->buffer. + */ + sal_Int32 nCapacity; +}; + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* __cplusplus */ +#endif /* _RTL_USTRBUF_HXX_ */ + + diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h new file mode 100644 index 000000000000..952bb431a330 --- /dev/null +++ b/sal/inc/rtl/ustring.h @@ -0,0 +1,717 @@ +/************************************************************************* + * + * $RCSfile: ustring.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _RTL_USTRING_H_ +#define _RTL_USTRING_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_STRING_H_ +#include <rtl/string.h> +#endif +#ifndef _RTL_TEXTENC_H +#include <rtl/textenc.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Returns the length of this string. + * The length is equal to the number of 16-bit + * Unicode characters in the string. + * + * @param str must be a NULL-terminated string. + * @return the length of the sequence of characters represented by this + * string. + */ +sal_Int32 SAL_CALL rtl_ustr_getLength( const sal_Unicode * str ); + +/** + * Compares first string to second string object. Both + * strings must be NULL-terminated. + * The result is <code>true</code> if and only if second string represents + * the same sequence of characters as the first string, where case is ignored. + * <p> + * Two characters are considered the same, ignoring case, if at + * least one of the following is true: + * <ul> + * <li>The two characters are the same (as compared by the <code>==</code> + * operator). + * <li>Applying the method <code>Character.toUppercase</code> to each + * character produces the same result. + * <li>Applying the method <code>Character.toLowercase</code> to each + * character produces the same result. + * </ul> + * <p> + * Two sequences of characters are the same, ignoring case, if the + * sequences have the same length and corresponding characters are + * the same, ignoring case. + * + * @param first the <code>string</code> to compared. + * @param second the <code>string</code> to compare first + * <code>String</code> against. + * @return <code>true</code> if the <code>String</code>s are equal, + * ignoring case; <code>false</code> otherwise. + */ +sal_Bool SAL_CALL rtl_ustr_equalsIgnoreCase_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ); +sal_Bool SAL_CALL rtl_ustr_equalsIgnoreCase( const sal_Unicode * first, const sal_Unicode * second ); + +/** + * Compares two strings lexicographically. Both + * strings must be NULL-terminated. + * The comparison is based on the Unicode value of each character in + * the strings. + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if first string + * is lexicographically less than the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string. + */ +sal_Int32 SAL_CALL rtl_ustr_compare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, const sal_Unicode * second, sal_Int32 secondLen ); +sal_Int32 SAL_CALL rtl_ustr_compare( const sal_Unicode * first, const sal_Unicode * second ); + +/** + * Compares two strings lexicographically. Both + * strings must be NULL-terminated. + * The comparison is based on the Unicode value of each character in + * the strings. + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * @param shortenedLength the number of characters which should be compared. + * This length can be longer, shorter or equal than the both other strings. + * + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if first string + * is lexicographically less than the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string. + */ +sal_Int32 SAL_CALL rtl_ustr_shortenedCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, + const sal_Unicode * second, sal_Int32 secondLen, sal_Int32 shortenedLength ); + +/** + * Compares lexicographically a 16-Bit Unicode character string directly + * with a 8-Bit ASCII character string. Since this function is optimized + * for performance. the ASCII character values are not converted in any + * way. The caller has to make sure that all ASCII characters are in the + * allowed range between 0 and 127. strings must be NULL-terminated. + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if first string + * is lexicographically less than the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string. + */ +sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, + const sal_Char * second ); +sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode * first, const sal_Char * second ); + +/** + * Compares the string reverse lexicographically with a 8-Bit ASCII + * character string. <STRONG>The secondLength parameter is the length of + * the ASCII string and not the number of characters which should be + * compared.</STRONG> The reverse comparison is based on the + * numerical values of each Unicode/ASCII character in the + * strings with a 8-Bit ASCII character string. Since this + * method is optimized for performance. the ASCII character + * values are not converted in any way. The caller has to + * ensure that all ASCII characters are in the allowed + * range between 0 and 127. + * The ASCII string must be NULL-terminated. + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * @param secondLength the + * + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if first string + * is lexicographically less than the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string. + * <STRONG>The compare order is from the last character to the + * first one</STRONG>. + */ +sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, + const sal_Char * second, sal_Int32 secondLength ); + +/** + * Compares lexicographically a 16-Bit Unicode character string directly + * with a 8-Bit ASCII character string. Since this function is optimized + * for performance. the ASCII character values are not converted in any + * way. The caller has to make sure that all ASCII characters are in the + * allowed range between 0 and 127. strings must be NULL-terminated. + * + * @param first the <code>String</code> to be compared. + * @param second the <code>String</code> to compare first + * <code>String</code> against. + * @param shortenedLength the number of characters which should be compared. + * This length can be longer, shorter or equal than the both other strings. + * + * @return the value <code>0</code> if the argument string is equal to + * this string; a value less than <code>0</code> if first string + * is lexicographically less than the second string; and a + * value greater than <code>0</code> if first string is + * lexicographically greater than the second string. + */ +sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode * first, sal_Int32 firstLen, + const sal_Char * second, sal_Int32 shortenedLength ); + +/** + * Returns a hashcode for the string. + * + * @param str a NULL-terminated string. + * @return a hash code value for str. + */ +sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength( const sal_Unicode * str, sal_Int32 len ); +sal_Int32 SAL_CALL rtl_ustr_hashCode( const sal_Unicode * str ); + +/** + * Returns the index within the string of the first occurrence of the + * specified character. + * + * @param str a NULL-terminated string. + * @param ch a character. + * @return the index of the first occurrence of the character in the + * character sequence represented by the string, or + * <code>-1</code> if the character does not occur. + */ +sal_Int32 SAL_CALL rtl_ustr_indexOfChar_WithLength( const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ); +sal_Int32 SAL_CALL rtl_ustr_indexOfChar( const sal_Unicode * str, sal_Unicode ch ); + +/** + * Returns the index within the string of the last occurrence of the + * specified character, searching backward starting at the specified index. + * + * @param str a NULL-terminated string. + * @param ch a character. + * @return the index of the last occurrence of the character in the + * character sequence represented by the string, or + * <code>-1</code> if the character does not occur. + */ +sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar_WithLength( const sal_Unicode * str, sal_Int32 len, sal_Unicode ch ); +sal_Int32 SAL_CALL rtl_ustr_lastIndexOfChar( const sal_Unicode * str, sal_Unicode ch ); + +/** + * Returns the index within the string of the first occurrence of the + * specified substring. + * + * @param str a NULL-terminated string. + * @param subStr a NULL-terminated substring to be searched for. + * @return if the string argument occurs as a substring within the + * string, then the index of the first character of the first + * such substring is returned; if it does not occur as a + * substring, <code>-1</code> is returned. + */ +sal_Int32 SAL_CALL rtl_ustr_indexOfStr_WithLength( const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ); +sal_Int32 SAL_CALL rtl_ustr_indexOfStr( const sal_Unicode * str, const sal_Unicode * subStr ); + +/** + * Returns the index within this string of the last occurrence of + * the specified substring. + * The returned index indicates the start of the substring, and it + * must be equal to or less than <code>fromIndex</code>. + * + * @param str a NULL-terminated string. + * @param subStr a NULL-terminated substring to be searched for. + * @return If the string argument occurs one or more times as a substring + * within the string, then the index of the first character of + * the last such substring is returned. If it does not occur as a + * substring <code>-1</code> is returned. + */ +sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr_WithLength( const sal_Unicode * str, sal_Int32 len, const sal_Unicode * subStr, sal_Int32 subLen ); +sal_Int32 SAL_CALL rtl_ustr_lastIndexOfStr( const sal_Unicode * ggstr, const sal_Unicode * subStr ); + +/** + * Replaces all occurrences of <code>oldChar</code> in the string with + * <code>newChar</code>. + * <p> + * If the character <code>oldChar</code> does not occur in the + * character sequence represented by this object, then the string is + *not modified. + * + * @param str a NULL-terminated string. + * @param oldChar the old character. + * @param newChar the new character. + */ +void SAL_CALL rtl_ustr_replaceChar_WithLength( sal_Unicode * str, sal_Int32 len, sal_Unicode oldChar, sal_Unicode newChar); +void SAL_CALL rtl_ustr_replaceChar( sal_Unicode * str, sal_Unicode oldChar, sal_Unicode newChar); + +/** + * Converts all of the characters in the <code>string</code> to lower case. + * @param str a NULL-terminated string. + */ +void SAL_CALL rtl_ustr_toAsciiLowerCase_WithLength( sal_Unicode * str, sal_Int32 len ); +void SAL_CALL rtl_ustr_toAsciiLowerCase( sal_Unicode * str ); + +/** + * Converts all of the characters in the <code>string</code> to upper case. + * + * @param str a NULL-terminated string. + */ +void SAL_CALL rtl_ustr_toAsciiUpperCase_WithLength(sal_Unicode * str, sal_Int32 len); +void SAL_CALL rtl_ustr_toAsciiUpperCase(sal_Unicode * str); + +/** + * Removes white space from both ends of the string. + * <p> + * All characters that have codes less than or equal to + * <code>'\u0020'</code> (the space character) are considered to be + * white space. + * + * @param str a NULL-terminated string. + * @return new length of the string. + */ +sal_Int32 SAL_CALL rtl_ustr_trim_WithLength( sal_Unicode * str, sal_Int32 len ); +sal_Int32 SAL_CALL rtl_ustr_trim( sal_Unicode * str ); + +/** + * Returns the string representation of the <code>sal_Bool</code> argument. + * + * @param str a newly allocated string with the length <code>RTL_USTR_MAX_VALUEOFBOOLEAN</code>. + * @param b a <code>sal_Bool</code>. + * @return if the argument is <code>true</code>, a string equal to + * <code>"true"</code> is returned; otherwise, a string equal to + * <code>"false"</code> is returned. + */ +#define RTL_USTR_MAX_VALUEOFBOOLEAN 6 +sal_Int32 SAL_CALL rtl_ustr_valueOfBoolean( sal_Unicode * str, sal_Bool b ); + +/** + * Returns the string representation of the <code>char</code> argument. + * + * @param str a newly allocated string with the length <code>RTL_USTR_MAX_VALUEOFCHAR</code>. + * @param ch a <code>char</code>. + * @return a newly allocated string of length <code>1</code> containing + * as its single character the argument <code>ch</code>. + */ +#define RTL_USTR_MAX_VALUEOFCHAR 2 +sal_Int32 SAL_CALL rtl_ustr_valueOfChar( sal_Unicode * str, sal_Unicode ch ); + +/** + * Returns the string representation of the <code>int</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Integer.toString</code> method of one argument. + * + * @param str a newly allocated string with the length <code>RTL_USTR_MAX_VALUEOFINT32</code>. + * @param i an <code>sal_Int32</code>. + * @return a newly allocated string containing a string representation of + * the <code>int</code> argument. + * @see java.lang.Integer#toString(int, int) + */ +#define RTL_USTR_MIN_RADIX 2 +#define RTL_USTR_MAX_RADIX 36 +#define RTL_USTR_MAX_VALUEOFINT32 33 +sal_Int32 SAL_CALL rtl_ustr_valueOfInt32(sal_Unicode * str, sal_Int32 i, sal_Int16 radix ); + +/** + * Returns the string representation of the <code>long</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Long.toString</code> method of one argument. + * + * @param str a newly allocated string with the length <code>RTL_USTR_MAX_VALUEOFINT64</code>. + * @param l a <code>sal_Int64</code>. + * @return a newly allocated string containing a string representation of + * the <code>long</code> argument. + * @see java.lang.Long#toString(long) + */ +#define RTL_USTR_MAX_VALUEOFINT64 65 +sal_Int32 SAL_CALL rtl_ustr_valueOfInt64(sal_Unicode * str, sal_Int64 l, sal_Int16 radix ); + +/** + * Returns the string representation of the <code>float</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Float.toString</code> method of one argument. + * + * @param f a <code>float</code>. + * @return a newly allocated string containing a string representation of + * the <code>float</code> argument. + * @see java.lang.Float#toString(float) + */ +#define RTL_USTR_MAX_VALUEOFFLOAT 15 +sal_Int32 SAL_CALL rtl_ustr_valueOfFloat(sal_Unicode * str, float f); + +/** + * Returns the string representation of the <code>double</code> argument. + * <p> + * The representation is exactly the one returned by the + * <code>Double.toString</code> method of one argument. + * + * @param d a <code>double</code>. + * @return a newly allocated string containing a string representation of + * the <code>double</code> argument. + * @see java.lang.Double#toString(double) + */ +#define RTL_USTR_MAX_VALUEOFDOUBLE 25 +sal_Int32 SAL_CALL rtl_ustr_valueOfDouble(sal_Unicode * str, double d); + +/** + * Returns the int32 value represented <code>str</code> argument. + * <p> + * + * @param str a string representing a number + * @return the int32 represented by the string + * 0 if the string represents no number. + */ +sal_Int32 SAL_CALL rtl_ustr_toInt32( sal_Unicode * str, sal_Int16 radix ); + +/** + * Returns the int64 value represented <code>str</code> argument. + * <p> + * + * @param str a string representing a number + * @return the int64 represented by the string + * 0 if the string represents no number. + */ +sal_Int64 SAL_CALL rtl_ustr_toInt64( sal_Unicode * str, sal_Int16 radix ); + + /** + * Returns the float value represented <code>str</code> argument. + * <p> + * + * @param str a string representing a number + * @return the float represented by the string + * 0.0 if the string represents no number. + */ +float SAL_CALL rtl_ustr_toFloat( sal_Unicode * str ); + +/** + * Returns the double value represented <code>str</code> argument. + * <p> + * + * @param str a string representing a number + * @return the double represented by the string + * 0.0 if the string represents no number. + */ +double SAL_CALL rtl_ustr_toDouble( sal_Unicode * str ); + +/** + * A string with this reference count is static und must not deleted. + * It is also not allowed to modifiy the reference count. + */ +#define RTL_STATIC_STRING_REF ((sal_Int32)0x80000000) + +#ifdef SAL_W32 +# pragma pack(push, 4) +#elif defined(SAL_OS2) +# pragma pack(1) +#endif + +struct _rtl_Locale; + +/** + * The implementation structure of a string. + */ +typedef struct _rtl_uString +{ + sal_Int32 refCount; + sal_Int32 length; + sal_Unicode buffer[1]; +} rtl_uString; + +#ifdef SAL_W32 +# pragma pack(pop) +#elif defined(SAL_OS2) +# pragma pack() +#endif + +/** + * Increment the reference count of the string. + */ +void SAL_CALL rtl_uString_acquire( rtl_uString * value ); + +/** + * Decrement the reference count of the string. If the count goes to zero than the string is + * deleted. + */ +void SAL_CALL rtl_uString_release( rtl_uString * value ); + +/** + * Allocates a new <code>string</code> containing no characters. + * Use the macro RTL_NEWDEFAULTSTRING() which optimize platform dependend + * the access to the default string. + */ +void SAL_CALL rtl_uString_new( rtl_uString ** newStr); +#define RTL_USTRING_NEW(newStr) rtl_uString_new(newStr) + +/** + * Allocates a new <code>string</code> containing nLen characters. + * The values of the characters are '\u0000' defined. + */ +void SAL_CALL rtl_uString_new_WithLength( rtl_uString ** newStr, sal_Int32 nLen ); + +/** + * Allocates a new string that contains the same sequence of + * characters as the string argument.<BR> + * + * @param value a <code>string</code>. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newFromString( rtl_uString ** newStr, rtl_uString * value); + +/** + * Allocates a new <code>string</code> so that it represents the + * sequence of characters currently contained in the character array + * argument. + * + * @param value the initial value of the string. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newFromStr( rtl_uString ** newStr, const sal_Unicode * value ); + +/** + * Allocates a new <code>String</code> that contains characters from + * the character array argument. + * + * @param value array that is the source of characters. + * @param len the length of the array. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newFromStr_WithLength( rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 Len); + +/** + * Allocates a new <code>string</code> so that it represents the + * sequence of characters currently contained in the character array + * argument. + * + * @param value the initial value of the string. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newFromWStr( rtl_uString ** newStr, const wchar_t * value ); + +/** + * Allocates a new <code>String</code> that contains characters from + * the character array argument. + * + * @param value array that is the source of characters. + * @param len the length of the array. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newFromWStr_WithLength( rtl_uString ** newStr, const wchar_t * value, sal_Int32 Len); + +/** + * Allocates a new <code>string</code> so that it represents the + * sequence of ASCII characters currently contained in the sal_Char + * array argument. Since this function is optimized for performance. + * the ASCII character values are not converted in any way. The + * caller has to make sure that all ASCII characters are in the + * allowed range between 0 and 127. + * + * @param value the initial value of the string in ASCII characters. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newFromAscii( rtl_uString ** newStr, const sal_Char * value ); + +/** + * Assign rightValue to *str. Release *str and aquire rightValue! + */ +void SAL_CALL rtl_uString_assign( rtl_uString ** str, rtl_uString * rightValue ); + +/** + * Returns the length of this string. + * The length is equal to the number of 16-bit + * Unicode characters in the string. + * + * @return the length of the sequence of characters represented by the + * string. + */ +sal_Int32 SAL_CALL rtl_uString_getLength( rtl_uString * str ); + +/** + * Return the pointer to the sal_Unicode array of the <code>string</code>. + * + * @return a null terminated sal_Unicode *. + */ +sal_Unicode * SAL_CALL rtl_uString_getStr( rtl_uString * str ); + +/** + * Concatenates the right string to the end of the left string. Left and + * right must be NULL-terminated strings. + * <p> + * + * @return a string that represents the concatenation of the strings. + */ +void SAL_CALL rtl_uString_newConcat( rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ); + +/** + * Returns a new string resulting from replacing all occurrences of + * <code>oldChar</code> in this string with <code>newChar</code>. + * <p> + * If the character <code>oldChar</code> does not occur in the + * character sequence represented by the string, then the string is + * returned. + * + * @param oldChar the old character. + * @param newChar the new character. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newReplace( rtl_uString ** newStr, + rtl_uString * str, + sal_Unicode oldChar, + sal_Unicode newChar); + +/** + * Returns a new string resulting from replacing n = count characters + * from position index in this string with <code>newStr</code>. + * <p> + * + * @param index the index for beginning. + * @param count the count of charcters that will replaced + * @param newStr the new substring. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newReplaceStrAt( rtl_uString ** newStr, + rtl_uString * str, + sal_Int32 index, + sal_Int32 count, + rtl_uString * newSub); + +/** + * Converts all of the characters in this <code>String</code> to lower + * case using the rules of the given locale. + * @param locale use the case transformation rules for this locale + * @return the String, converted to lowercase. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newToLowerCase( rtl_uString ** newStr, rtl_uString * str, struct _rtl_Locale * locale ); + +/** + * Converts all of the characters in this <code>String</code> to upper + * case using the rules of the given locale. + * @param locale use the case transformation rules for this locale + * @return the String, converted to uppercase. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newToUpperCase( rtl_uString ** newStr, rtl_uString * str, struct _rtl_Locale * locale ); + +/** + * Removes white space from both ends of the string. + * <p> + * All characters that have codes less than or equal to + * <code>'\u0020'</code> (the space character) are considered to be + * white space. + * + * @return this string, with white space removed from the front and end. + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_newTrim( rtl_uString ** newStr, rtl_uString * str ); + +/** + * Returns the number of tokens in this <code>String</code> seperated + * by <code>cTok</code>. + * + * @param cTok the character which seperate the tokens + * @return the number of tokens. + */ +sal_Int32 SAL_CALL rtl_uString_getTokenCount( rtl_uString * str , sal_Unicode cTok); + +/** + * Returns a new string for the token specified by nToken. If nToken < 0 or + * nToken > tokenCount then an empty string is returned. + * + * @param nToken the number of the token to return. + * @param cTok the character which seperate the tokens + * @param newStr the new string for the token + * @return the new string. The reference count is 1. + */ +void SAL_CALL rtl_uString_getToken( rtl_uString ** newStr , rtl_uString * str, sal_Int32 nToken, sal_Unicode cTok); + + +void SAL_CALL rtl_string2UString( rtl_uString** newStr, const sal_Char* pStr, sal_Int32 nLen, + rtl_TextEncoding encoding, sal_uInt32 nCvtFlags ); + +void SAL_CALL rtl_uString2String( rtl_String** newStr, const sal_Unicode* pWStr, sal_Int32 nWLen, + rtl_TextEncoding encoding, sal_uInt32 nCvtFlags ); + +/* constAsciiStr must be a "..." or char const aFoo[] = "..." */ +#define RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) constAsciiStr, sizeof( constAsciiStr )-1, RTL_TEXTENCODING_ASCII_US +#ifndef RTL_CONSTASCII_STRINGPARAM +#define RTL_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, sizeof( constAsciiStr )-1 +#endif +#ifndef RTL_CONSTASCII_LENGTH +#define RTL_CONSTASCII_LENGTH( constAsciiStr ) (sizeof( constAsciiStr )-1) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RTL_USTRING_H_ */ + + diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx new file mode 100644 index 000000000000..2f11e3499aa8 --- /dev/null +++ b/sal/inc/rtl/ustring.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * $RCSfile: ustring.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _RTL_USTRING_HXX_ +#define _RTL_USTRING_HXX_ + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _RTL_STRING_HXX_ +#include <rtl/string.hxx> +#endif +#ifndef _RTL_LOCALE_HXX_ +#include <rtl/locale.hxx> +#endif + +#ifdef _USE_NAMESPACE +namespace rtl +{ +#endif + +/** + * Converts all of the characters in this <code>OUString</code> to lower + * case using the rules of the given locale. + * @param locale use the case transformation rules for this locale + * @return the OUString, converted to lowercase. + * @see java.lang.Character#toLowerCase(char) + * @see java.lang.OUString#toUpperCase() + * @since JDK1.1 + */ +inline OUString OUString::toLowerCase( const OLocale & locale ) const +{ + OUString newStr; + rtl_uString_newToLowerCase( &newStr.pData, pData, *(rtl_Locale **)&locale ); + return newStr; +} + + +/** + * Converts all of the characters in this <code>OUString</code> to upper + * case using the rules of the given locale. + * @param locale use the case transformation rules for this locale + * @return the OUString, converted to uppercase. + * @see java.lang.Character#toUpperCase(char) + * @see java.lang.OUString#toLowerCase(char) + * @since JDK1.1 + */ +inline OUString OUString::toUpperCase( const OLocale & locale) const +{ + OUString newStr; + rtl_uString_newToUpperCase( &newStr.pData, pData, *(rtl_Locale **)&locale ); + return newStr; +} + +// Helper functions +inline OUString OStringToOUString( const OString & rStr, + rtl_TextEncoding encoding, + sal_uInt32 nCvtFlags=OSTRING_TO_OUSTRING_CVTFLAGS ) +{ + OUString newStr; + if (rStr.getLength()) + rtl_string2UString( &newStr.pData, rStr.getStr(), rStr.getLength(), encoding, nCvtFlags ); + return newStr; +} + +inline OString OUStringToOString( const OUString & rUnicode, + rtl_TextEncoding encoding, + sal_uInt32 nCvtFlags=OUSTRING_TO_OSTRING_CVTFLAGS ) +{ + OString newStr; + if (rUnicode.getLength()) + rtl_uString2String( &newStr.pData, rUnicode.getStr(), rUnicode.getLength(), encoding, nCvtFlags ); + return newStr; +} + +#ifdef _USE_NAMESPACE +} +#endif + +#endif /* _RTL_USTRING_HXX_ */ + + diff --git a/sal/inc/rtl/uuid.h b/sal/inc/rtl/uuid.h new file mode 100644 index 000000000000..dfb9d3b70695 --- /dev/null +++ b/sal/inc/rtl/uuid.h @@ -0,0 +1,231 @@ +/************************************************************************* + * + * $RCSfile: uuid.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _RTL_UUID_H_ +#define _RTL_UUID_H_ + + +#include <sal/types.h> +#include <rtl/string.h> + +/*** + * (from <draft-leach-uuids-guids-01.txt> ) + * Specification + * + * A UUID is an identifier that is unique across both space and time, + * with respect to the space of all UUIDs. To be precise, the UUID + * consists of a finite bit space. Thus the time value used for + * constructing a UUID is limited and will roll over in the future + * (approximately at A.D. 3400, based on the specified algorithm). A + * UUID can be used for multiple purposes, from tagging objects with an + * extremely short lifetime, to reliably identifying very persistent + * objects across a network. + * + * The generation of UUIDs does not require that a registration + * authority be contacted for each identifier. Instead, it requires a + * unique value over space for each UUID generator. This spatially + * unique value is specified as an IEEE 802 address, which is usually + * already available to network-connected systems. This 48-bit address + * can be assigned based on an address block obtained through the IEEE + * registration authority. + * + *****/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Generates a new UUID (Universally Unique IDentifier). + * If available, the ethernetaddress of a networkcard is used, otherwise + * a 6 Byte random number is generated( for which rtlRandomPool is used ). + * + * + * @param pTargetUUID pointer to at least 16 bytes of memory. After the call it contains + * the newly generated uuid in network byte order. + * @param pPredecessorUUID pointer to the previously generated uuid in network byte + * order. The generator reuses the 6-Byte random value + * and the two byte context value and ensures, + * that pTargetUUID is generated with a later timestamp. + * Set pPredecessorUUID to 0 if no predecessor is available. + * The caller is responsible for making the value persistent + * (if desired). + * @param bUseEthernetAddress if sal_True, the generator uses the ethernet address of a + * network card (if available). <br> + * if sal_False, the generator generates a new 6-Byte random + * value each time it is called with pPredecessorUUID = 0. + * + **/ +void SAL_CALL rtl_createUuid( sal_uInt8 *pTargetUUID , + const sal_uInt8 *pPredecessorUUID, + sal_Bool bUseEthernetAddress ); + +/**** + * uuid_compare -- Compare two UUID's "lexically" and return + * -1 u1 is lexically before u2 + * 0 u1 is equal to u2 + * 1 u1 is lexically after u2 + * + * Note: lexical ordering is not temporal ordering! + * Note: For equalnesschecking, a memcmp(pUUID1,pUUID2,16) is more efficient + ****/ +sal_Int32 SAL_CALL rtl_compareUuid( const sal_uInt8 *pUUID1 , const sal_uInt8 *pUUID2 ); + +/**** + * The version 3 UUID is meant for generating UUIDs from "names" that + * are drawn from, and unique within, some "name space". Some examples + * of names (and, implicitly, name spaces) might be DNS names, URLs, ISO + * Object IDs (OIDs), reserved words in a programming language, or X.500 + * Distinguished Names (DNs); thus, the concept of name and name space + * should be broadly construed, and not limited to textual names. + * + * The requirements for such UUIDs are as follows: + * + * - The UUIDs generated at different times from the same name in the + * same namespace MUST be equal + * + * - The UUIDs generated from two different names in the same namespace + * should be different (with very high probability) + * + * - The UUIDs generated from the same name in two different namespaces + * should be different with (very high probability) + * + * - If two UUIDs that were generated from names are equal, then they + * were generated from the same name in the same namespace (with very + * high probability). + * + * @param pTargetUUID pointer to at least 16 bytes of memory. After the call + * it contains the newly generated uuid in network byte order. + * @param pNameSpaceUUID The namespace uuid. Below are some predefined ones, + * but any arbitray uuid can be used as namespace. + * + * @param pName the name + * + ****/ +void SAL_CALL rtl_createNamedUuid( + sal_uInt8 *pTargetUUID, + const sal_uInt8 *pNameSpaceUUID, + const rtl_String *pName + ); + + + +/**** + * Predefined Namespaces + * (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS; + * + ****/ +/* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */ +#define RTL_UUID_NAMESPACE_DNS {\ + 0x6b,0xa7,0xb8,0x10,\ + 0x9d,0xad,\ + 0x11,0xd1,\ + 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\ + } + +/* 6ba7b811-9dad-11d1-80b4-00c04fd430c8 */ +#define RTL_UUID_NAMESPACE_URL { \ + 0x6b, 0xa7, 0xb8, 0x11,\ + 0x9d, 0xad,\ + 0x11, 0xd1,\ + 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\ + } + +/* 6ba7b812-9dad-11d1-80b4-00c04fd430c8 */ +#define RTL_UUID_NAMESPACE_OID {\ + 0x6b, 0xa7, 0xb8, 0x12,\ + 0x9d, 0xad,\ + 0x11, 0xd1,\ + 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\ + } + +/* 6ba7b814-9dad-11d1-80b4-00c04fd430c8 */ +#define RTL_UUID_NAMESPACE_X500 {\ + 0x6b, 0xa7, 0xb8, 0x14,\ + 0x9d, 0xad,\ + 0x11, 0xd1,\ + 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\ + } + + +/** + * This macro must have a value below the system time resolution of the + * system. The uuid routines use this value as an upper limit for adding ticks to the + * the predecessor time value if system times are equal. + ***/ +#ifdef SAL_W32 +#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 1000 +#elif LINUX +#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10 +#elif SOLARIS +#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10 +#elif MACOSX +#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 100000 +#elif MACOS +#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 100000 +#else +#error "System time resolution must be calculated!" +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sal/inc/sal/config.h b/sal/inc/sal/config.h new file mode 100644 index 000000000000..77af6e31a0fc --- /dev/null +++ b/sal/inc/sal/config.h @@ -0,0 +1,124 @@ +/************************************************************************* + * + * $RCSfile: config.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_CONFIG_H_ +#define _SAL_CONFIG_H_ + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + + +/** The define _USE_NO_NAMEPSACE disable the use of namespaces. + default is that namespaces were used. +*/ +#ifndef _USE_NO_NAMESPACE +#if defined(USE_NAMESPACE) || !defined(_USE_NAMESPACE) +# define _USE_NAMESPACE +#endif +#endif + +#ifdef WIN32 +#define SAL_W32 + +/* No warning for: C++ Exception Specification ignored */ +#pragma warning( disable : 4290 ) + + #if defined(_DEBUG) + /* No warning for: identifier was truncated to '255' characters in the browser information */ + #pragma warning( disable : 4786 ) + #endif + +#endif + +/* BR: 16bit fuer Borland-Compiler */ +#ifdef __BORLANDC__ +#define SAL_W16 +#endif +/* BR: 16bit fuer Borland-Compiler */ + +#ifdef OS2 +#define SAL_OS2 +#endif + +#ifdef MAC +#define SAL_MAC +#endif + +#if defined(SOLARIS) || defined(LINUX) || defined(NETBSD) || \ + defined(SCO) || defined(MACOSX) +#define SAL_UNX +#endif + +#ifdef sun +#undef sun +#define sun sun +#endif + +#endif /*_SAL_CONFIG_H_ */ + + diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h new file mode 100644 index 000000000000..df0e61331907 --- /dev/null +++ b/sal/inc/sal/types.h @@ -0,0 +1,225 @@ +/************************************************************************* + * + * $RCSfile: types.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SAL_TYPES_H_ +#define _SAL_TYPES_H_ + +#include <sal/config.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/********************************************************************************/ +/* Data types +*/ + +/* Boolean */ + +typedef unsigned char sal_Bool; +# define sal_False ((unsigned char)0) +# define sal_True ((unsigned char)1) +/* +typedef int sal_Bool; +# define sal_False 0 +# define sal_True 1 +*/ +typedef signed char sal_Int8; +typedef unsigned char sal_uInt8; +typedef signed short sal_Int16; +typedef unsigned short sal_uInt16; +typedef signed long sal_Int32; +typedef unsigned long sal_uInt32; + +# if (_MSC_VER >= 1000) +typedef __int64 sal_Int64; +typedef unsigned __int64 sal_uInt64; +# elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (__MWERKS__) || defined(__hpux) +typedef long long sal_Int64; +typedef unsigned long long sal_uInt64; +# else +# define SAL_INT64_IS_STRUCT +typedef struct + { + sal_uInt32 Part1; + sal_uInt32 Part2; + } sal_Int64; + +typedef struct + { + sal_uInt32 Part1; + sal_uInt32 Part2; + } sal_uInt64; +#endif + +typedef char sal_Char; +typedef signed char sal_sChar; +typedef unsigned char sal_uChar; +#if defined(SAL_W32) +typedef wchar_t sal_Unicode; +#else +#define SAL_UNICODE_NOTEQUAL_WCHAR_T +typedef sal_uInt16 sal_Unicode; +#endif + +typedef void* sal_Handle; +typedef unsigned long sal_Size; + +#if defined(SAL_W32) || defined(SAL_OS2) || defined(SAL_UNX) || defined(SAL_MAC) +#define SAL_MAX_ENUM 0x7fffffff +#elif defined(SAL_W16) +#define SAL_MAX_ENUM 0x7fff +#endif + +#ifdef SAL_W32 +# define SAL_DLLEXPORT __declspec(dllexport) +# define SAL_CALL __cdecl +# define SAL_CALL_ELLIPSE __cdecl +#elif defined SAL_OS2 +# define SAL_DLLEXPORT +# define SAL_CALL +# define SAL_CALL_ELLIPSE +#elif defined SAL_UNX +# define SAL_DLLEXPORT +# define SAL_CALL +# define SAL_CALL_ELLIPSE +#elif defined SAL_MAC +# define SAL_DLLEXPORT +# define SAL_CALL +# define SAL_CALL_ELLIPSE +#elif defined SAL_W16 /* BR: kopiert von SAL_W32 */ +# define SAL_DLLEXPORT __declspec(dllexport) +# define SAL_CALL __cdecl +# define SAL_CALL_ELLIPSE __cdecl +#else +# error("unknown platform") +#endif + +void SAL_CALL sal_setInt64(sal_Int64* newInt, sal_uInt32 lowInt, sal_Int32 highInt); +void SAL_CALL sal_getInt64(sal_Int64 newInt, sal_uInt32* lowInt, sal_Int32* highInt); + +void SAL_CALL sal_setUInt64(sal_uInt64* newInt, sal_uInt32 lowInt, sal_uInt32 highInt); +void SAL_CALL sal_getUInt64(sal_uInt64 newInt, sal_uInt32* lowInt, sal_uInt32* highInt); + +#define SAL_PACK_PUSH +#define SAL_PACK_POP + +#ifdef SAL_W16 +#define SAL_HUGE +#else +#define SAL_HUGE +#endif + + +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(8) +#endif + +/** This is the binary specification of a SAL sequence. + <br> +*/ +typedef struct _sal_Sequence +{ + /** reference count of sequence<br> + */ + sal_Int32 nRefCount; + /** element count<br> + */ + sal_Int32 nElements; + /** elements array<br> + */ + char elements[1]; +} sal_Sequence; + +#define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements) + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + + +/** Wrap C++ const_cast, reinterpret_cast and static_cast expressions in + macros to keep code portable to old compilers (since most compilers still + lack RTTI support, dynamic_cast is not included here). + */ +#ifdef __cplusplus +#if defined SAL_W32 || defined SOLARIS || defined LINUX +#define SAL_CONST_CAST(type, expr) (const_cast< type >(expr)) +#define SAL_REINTERPRET_CAST(type, expr) (reinterpret_cast< type >(expr)) +#define SAL_STATIC_CAST(type, expr) (static_cast< type >(expr)) +#else /* SAL_W32, SOLARIS, LINUX */ +#define SAL_CONST_CAST(type, expr) ((type) (expr)) +#define SAL_REINTERPRET_CAST(type, expr) ((type) (expr)) +#define SAL_STATIC_CAST(type, expr) ((type) (expr)) +#endif /* SAL_W32, SOLARIS, LINUX */ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif + + +#endif /*_SAL_TYPES_H_ */ + diff --git a/sal/inc/systools/win32/StrConvert.h b/sal/inc/systools/win32/StrConvert.h new file mode 100644 index 000000000000..1922928433bb --- /dev/null +++ b/sal/inc/systools/win32/StrConvert.h @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: StrConvert.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _STRCONVERT_H_ +#define _STRCONVERT_H_ + +#include <windows.h> + +#ifdef __cplusplus +extern "C"{ +#endif + +int AllocNecessarySpaceAndCopyWStr2Str( LPCWSTR lpcwstrString, LPSTR* lppStr ); +int AllocSpaceAndCopyWStr2Str( LPCWSTR lpcwstrString, DWORD nWCharsToCopy, LPSTR* lppStr ); +int CalcLenDblNullTerminatedWStr( LPCWSTR lpcwstrString ); +int CalcLenDblNullTerminatedStr( LPCSTR lpcstrString ); +void FreeSpaceStr( LPSTR lpszString ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sal/inc/systools/win32/advapi9x.h b/sal/inc/systools/win32/advapi9x.h new file mode 100644 index 000000000000..427ff7136fa8 --- /dev/null +++ b/sal/inc/systools/win32/advapi9x.h @@ -0,0 +1,198 @@ +/************************************************************************* + * + * $RCSfile: advapi9x.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#pragma once + +#ifndef _WINDOWS_ +#include <windows.h> +#endif + +#ifdef __cplusplus +extern "C"{ +#endif + +/* obsolete Win32 API Functions */ +#ifdef RegOpenKey +#undef RegOpenKey +#endif +#ifdef RegEnumKey +#undef RegEnumKey +#endif +#ifdef RegCreateKey +#undef RegCreateKey +#endif +#ifdef RegQueryValue +#undef RegQueryValue +#endif +#ifdef RegSetValue +#undef RegSetValue +#endif + +/* undefine if already defined as macros */ +#ifdef RegOpenKeyExW +#undef RegOpenKeyExW +#endif +#ifdef RegEnumKeyExW +#undef RegEnumKeyExW +#endif +#ifdef RegCreateKeyExW +#undef RegCreateKeyExW +#endif +#ifdef RegDeleteKeyW +#undef RegDeleteKeyW +#endif +#ifdef RegEnumValueW +#undef RegEnumValueW +#endif +#ifdef RegQueryValueExW +#undef RegQueryValueExW +#endif +#ifdef RegSetValueExW +#undef RegSetValueExW +#endif +#ifdef RegDeleteValueW +#undef RegDeleteValueW +#endif + +extern LONG (WINAPI * lpfnRegOpenKeyExW) ( + HKEY hKey, // handle to open key + LPCWSTR lpSubKey, // subkey name + DWORD ulOptions, // reserved + REGSAM samDesired, // security access mask + PHKEY phkResult // handle to open key +); + +extern LONG (WINAPI *lpfnRegEnumKeyExW) ( + HKEY hKey, // handle to key to enumerate + DWORD dwIndex, // subkey index + LPWSTR lpName, // subkey name + LPDWORD lpcName, // size of subkey buffer + LPDWORD lpReserved, // reserved + LPWSTR lpClass, // class string buffer + LPDWORD lpcClass, // size of class string buffer + PFILETIME lpftLastWriteTime // last write time +); + +extern LONG (WINAPI *lpfnRegCreateKeyExW)( + HKEY hKey, // handle to open key + LPCWSTR lpSubKey, // subkey name + DWORD Reserved, // reserved + LPWSTR lpClass, // class string + DWORD dwOptions, // special options + REGSAM samDesired, // desired security access + LPSECURITY_ATTRIBUTES lpSecurityAttributes, // inheritance + PHKEY phkResult, // key handle + LPDWORD lpdwDisposition // disposition value buffer +); + +extern LONG (WINAPI *lpfnRegDeleteKeyW) ( + HKEY hKey, // handle to open key + LPCWSTR lpSubKey // subkey name +); + +extern LONG (WINAPI *lpfnRegEnumValueW) ( + HKEY hKey, // handle to key to query + DWORD dwIndex, // index of value to query + LPWSTR lpValueName, // value buffer + LPDWORD lpcValueName, // size of value buffer + LPDWORD lpReserved, // reserved + LPDWORD lpType, // type buffer + LPBYTE lpData, // data buffer + LPDWORD lpcbData // size of data buffer +); + +extern LONG (WINAPI *lpfnRegQueryValueExW) ( + HKEY hKey, // handle to key + LPCWSTR lpValueName, // value name + LPDWORD lpReserved, // reserved + LPDWORD lpType, // type buffer + LPBYTE lpData, // data buffer + LPDWORD lpcbData // size of data buffer +); + +extern LONG (WINAPI *lpfnRegSetValueExW)( + HKEY hKey, // handle to key + LPCWSTR lpValueName, // value name + DWORD Reserved, // reserved + DWORD dwType, // value type + CONST BYTE *lpData, // value data + DWORD cbData // size of value data +); + +extern LONG (WINAPI *lpfnRegDeleteValueW) ( + HKEY hKey, // handle to key + LPCWSTR lpValueName // value name +); + +#define RegOpenKeyExW lpfnRegOpenKeyExW +#define RegEnumKeyExW lpfnRegEnumKeyExW +#define RegCreateKeyExW lpfnRegCreateKeyExW +#define RegDeleteKeyW lpfnRegDeleteKeyW +#define RegEnumValueW lpfnRegEnumValueW +#define RegQueryValueExW lpfnRegQueryValueExW +#define RegSetValueExW lpfnRegSetValueExW +#define RegDeleteValueW lpfnRegDeleteValueW + +extern void Advapi9xInit(LPOSVERSIONINFO lpVersionInfo); +extern void Advapi9xDeInit(); + +#ifdef __cplusplus +} +#endif diff --git a/sal/inc/systools/win32/comdlg9x.h b/sal/inc/systools/win32/comdlg9x.h new file mode 100644 index 000000000000..2b96286de242 --- /dev/null +++ b/sal/inc/systools/win32/comdlg9x.h @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: comdlg9x.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#pragma once + +#ifndef _WINDOWS_ +#include <windows.h> +#endif + +#ifndef _COMMDLG_H_ +#include <commdlg.h> +#endif + +#ifdef __cplusplus +extern "C"{ +#endif + +/* undefine if already a macro */ + +#ifdef GetOpenFileNameW +#undef GetOpenFileNameW +#endif + +#ifdef GetSaveFileNameW +#undef GetSaveFileNameW +#endif + +extern BOOL ( WINAPI * lpfnGetOpenFileNameW) ( + LPOPENFILENAMEW lpofn +); + +extern BOOL ( WINAPI * lpfnGetSaveFileNameW) ( + LPOPENFILENAMEW lpofn +); + +/* define as macro */ +#define GetOpenFileNameW lpfnGetOpenFileNameW +#define GetSaveFileNameW lpfnGetSaveFileNameW + +void Comdlg9xInit(LPOSVERSIONINFO lpVersionInfo); +void Comdlg9xDeInit(); + +#ifdef __cplusplus +} +#endif diff --git a/sal/inc/systools/win32/kernel9x.h b/sal/inc/systools/win32/kernel9x.h new file mode 100644 index 000000000000..a2acefae7ebd --- /dev/null +++ b/sal/inc/systools/win32/kernel9x.h @@ -0,0 +1,205 @@ +/************************************************************************* + * + * $RCSfile: kernel9x.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#pragma once + +#ifndef _WINDOWS_ +#include <windows.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* undefine if already defined as macros */ +#ifdef LoadLibraryW +# undef LoadLibraryW +#endif + +#ifdef LoadLibraryExW +# undef LoadLibraryExW +#endif + +#ifdef GetModuleFileNameW +# undef GetModuleFileNameW +#endif + +#ifdef GetLogicalDriveStringsW +# undef GetLogicalDriveStringsW +#endif + +#ifdef DeleteFileW +# undef DeleteFileW +#endif + +#ifdef CopyFileW +# undef CopyFileW +#endif + +#ifdef MoveFileW +# undef MoveFileW +#endif + +#ifdef MoveFileExW +# undef MoveFileExW +#endif + +#ifdef CreateFileW +# undef CreateFileW +#endif + +//BOOL WINAPI RegisterServiceProcess( DWORD dwProcessID, BOOL fRegister ); + +extern HMODULE (WINAPI *lpfnLoadLibraryExW) ( + LPCWSTR lpLibFileName, // file name of module + HANDLE hFile, // reserved, must be NULL + DWORD dwFlags // entry-point execution option +); + +extern DWORD (WINAPI *lpfnGetModuleFileNameW) ( + HMODULE hModule, // handle to module + LPWSTR lpFilename, // file name of module + DWORD nSize // size of buffer +); + +extern DWORD (WINAPI *lpfnGetLogicalDriveStringsW) ( + DWORD nBufferLength, // size of buffer + LPWSTR lpBuffer // drive strings buffer +); + +extern HANDLE ( WINAPI *lpfnCreateFileW )( + LPCWSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile +); + +extern DWORD WINAPI GetCanonicalPathNameA( + LPCSTR lpszPath, // file name + LPSTR lpszCanonicalPath, // path buffer + DWORD cchBuffer // size of path buffer +); + +extern DWORD WINAPI GetCanonicalPathNameW( + LPCWSTR lpszPath, // file name + LPWSTR lpszCanonicalPath, // path buffer + DWORD cchBuffer // size of path buffer +); + + +extern BOOL (WINAPI *lpfnDeleteFileW) ( + LPCWSTR lpFileName // file name +); + +extern BOOL (WINAPI *lpfnCopyFileW) ( + LPCWSTR lpExistingFileName, // file name + LPCWSTR lpNewFileName, // new file name + BOOL bFailIfExist // operation if file exists +); + +extern BOOL (WINAPI *lpfnMoveFileW) ( + LPCWSTR lpExistingFileName, // file name + LPCWSTR lpNewFileName // new file name +); + +extern BOOL (WINAPI *lpfnMoveFileExW) ( + LPCWSTR lpExistingFileName, // file name + LPCWSTR lpNewFileName, // new file name + DWORD dwFlags // move options +); + +extern HANDLE (WINAPI *lpfnCreateFileW) ( + LPCWSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile +); + +#ifdef UNICODE +#define GetCanonicalPath GetCanonicalPathW +#else +#define GetCanonicalPath GetCanonicalPathA +#endif + +/* replace API calls */ +#define LoadLibraryExW lpfnLoadLibraryExW +#define LoadLibraryW(c) LoadLibraryExW(c, NULL, 0) +#define GetModuleFileNameW lpfnGetModuleFileNameW +#define GetLogicalDriveStringsW lpfnGetLogicalDriveStringsW +#define DeleteFileW lpfnDeleteFileW +#define CopyFileW lpfnCopyFileW +#define MoveFileW lpfnMoveFileW +#define MoveFileExW lpfnMoveFileExW +#define CreateFileW lpfnCreateFileW + +extern void Kernel9xInit(LPOSVERSIONINFO lpVersionInfo); +extern void Kernel9xDeInit(); + +#ifdef __cplusplus +} +#endif + + diff --git a/sal/inc/systools/win32/shell9x.h b/sal/inc/systools/win32/shell9x.h new file mode 100644 index 000000000000..0ef45873476f --- /dev/null +++ b/sal/inc/systools/win32/shell9x.h @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: shell9x.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#pragma once + +#ifndef _WINDOWS_ +#include <windows.h> +#endif + +#ifndef _SHLOBJ_H_ +#include <shlobj.h> +#endif + +#ifdef __cplusplus +extern "C"{ +#endif + +/* undefine if already a macro */ +#ifdef CommandLineToArgvW +#undef CommandLineToArgvW +#endif + +#ifdef SHBrowseForFolderW +#undef SHBrowseForFolderW +#endif + +#ifdef SHGetPathFromIDListW +#undef SHGetPathFromIDListW +#endif + +#ifdef SetWindowTextW +#undef SetWindowTextW +#endif + +extern LPWSTR * (WINAPI *lpfnCommandLineToArgvW) ( + LPCWSTR lpCmdLine, // pointer to a command-line string + int *pNumArgs // receives the argument count +); + +extern LPITEMIDLIST ( WINAPI * lpfnSHBrowseForFolderW) ( + LPBROWSEINFOW lpbi +); + +extern BOOL ( WINAPI * lpfnSHGetPathFromIDListW ) ( + LPCITEMIDLIST pidl, + LPWSTR pszPath +); + +extern BOOL ( WINAPI * lpfnSetWindowTextW ) ( + HWND hWnd, + LPCWSTR lpString +); + +/* define as macro */ +#define CommandLineToArgvW lpfnCommandLineToArgvW +#define SHBrowseForFolderW lpfnSHBrowseForFolderW +#define SHGetPathFromIDListW lpfnSHGetPathFromIDListW +#define SetWindowTextW lpfnSetWindowTextW + +void Shell9xInit(LPOSVERSIONINFO lpVersionInfo); +void Shell9xDeInit(); + +#ifdef __cplusplus +} +#endif diff --git a/sal/inc/systools/win32/user9x.h b/sal/inc/systools/win32/user9x.h new file mode 100644 index 000000000000..052b51401bcf --- /dev/null +++ b/sal/inc/systools/win32/user9x.h @@ -0,0 +1,132 @@ +/************************************************************************* + * + * $RCSfile: user9x.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:17:15 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#pragma once + +#ifndef _WINDOWS_ +#include <windows.h> +#endif + +#ifdef __cplusplus +extern "C"{ +#endif + +/* undefine if already a macro */ + +#ifdef SendMessageW +#undef SendMessageW +#endif + +#ifdef CreateWindowExW +#undef CreateWindowExW +#endif + +#ifdef RegisterClassExW +#undef RegisterClassExW +#endif + +#ifdef UnregisterClassW +#undef UnregisterClassW +#endif + +extern LRESULT ( WINAPI * lpfnSendMessageW) ( + HWND hWnd, // handle to the destination window + UINT Msg, // message + WPARAM wParam, // first message parameter + LPARAM lParam // second message parameter +); + +extern HWND ( WINAPI * lpfnCreateWindowExW ) ( + DWORD dwExStyle, // extended window style + LPCWSTR lpClassName, // registered class name + LPCWSTR lpWindowName, // window name + DWORD dwStyle, // window style + int x, // horizontal position of window + int y, // vertical position of window + int nWidth, // window width + int nHeight, // window height + HWND hWndParent, // handle to parent or owner window + HMENU hMenu, // menu handle or child identifier + HINSTANCE hInstance, // handle to application instance + LPVOID lpParam // window-creation data +); + +extern ATOM ( WINAPI * lpfnRegisterClassExW ) ( + CONST WNDCLASSEXW* lpwcx // class data +); + +extern BOOL ( WINAPI * lpfnUnregisterClassW ) ( + LPCWSTR lpClassName, // class name + HINSTANCE hInstance // handle to application instance +); + + +/* define as macro */ +#define SendMessageW lpfnSendMessageW +#define CreateWindowExW lpfnCreateWindowExW +#define RegisterClassExW lpfnRegisterClassExW +#define UnregisterClassW lpfnUnregisterClassExW + +void User9xInit(LPOSVERSIONINFO lpVersionInfo); +void User9xDeInit(); + +#ifdef __cplusplus +} +#endif |