diff options
Diffstat (limited to 'sal/inc/osl')
-rw-r--r-- | sal/inc/osl/conditn.h | 127 | ||||
-rw-r--r-- | sal/inc/osl/conditn.hxx | 145 | ||||
-rw-r--r-- | sal/inc/osl/diagnose.h | 163 | ||||
-rw-r--r-- | sal/inc/osl/file.h | 1066 | ||||
-rw-r--r-- | sal/inc/osl/file.hxx | 1408 | ||||
-rw-r--r-- | sal/inc/osl/interlck.h | 93 | ||||
-rw-r--r-- | sal/inc/osl/module.h | 165 | ||||
-rw-r--r-- | sal/inc/osl/mutex.h | 145 | ||||
-rw-r--r-- | sal/inc/osl/mutex.hxx | 232 | ||||
-rw-r--r-- | sal/inc/osl/pipe.h | 148 | ||||
-rw-r--r-- | sal/inc/osl/process.h | 375 | ||||
-rw-r--r-- | sal/inc/osl/profile.h | 205 | ||||
-rw-r--r-- | sal/inc/osl/profile.hxx | 276 | ||||
-rw-r--r-- | sal/inc/osl/security.h | 263 | ||||
-rw-r--r-- | sal/inc/osl/semaphor.h | 146 | ||||
-rw-r--r-- | sal/inc/osl/semaphor.hxx | 152 | ||||
-rw-r--r-- | sal/inc/osl/signal.h | 182 | ||||
-rw-r--r-- | sal/inc/osl/socket.h | 1001 | ||||
-rw-r--r-- | sal/inc/osl/thread.h | 329 | ||||
-rw-r--r-- | sal/inc/osl/time.h | 212 | ||||
-rw-r--r-- | sal/inc/osl/util.h | 130 |
21 files changed, 6963 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 für 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 +* +*************************************************************************/ |