diff --git a/etc/c/recls/linux.mak b/etc/c/recls/linux.mak deleted file mode 100644 index e19ef09edbf..00000000000 --- a/etc/c/recls/linux.mak +++ /dev/null @@ -1,80 +0,0 @@ -# ############################################################################## -# File: makefile.unix -# -# Purpose: GCC 3.2+ makefile for the recls library (std.recls) -# -# Created: 24th November 2003 -# Updated: 24th November 2003 -# -# Copyright: Synesis Software Pty Ltd, (c) 2003. All rights reserved. -# -# Home: www.synesis.com.au/software -# -# ############################################################################## - -# ############################################################################## -# Macros - -CC = g++ -LD = g++ -AR = ar - -RECLS_INCLUDE = . -RECLS_LIBDIR = . -RECLS_SRCDIR = . - -STLSOFT_RECLS_PATCH_INCLUDE = #$(RECLS_INCLUDE) - -STLSOFT_INCLUDE = ../stlsoft - -F_WARN_ALL = -Wall -F_WARN_AS_ERR = # -F_OPT_SPEED = -O4 -F_TARG_PENTIUM = -mcpu=i686 -F_NOLOGO = - - -CCFLAGS = $(F_WARN_ALL) $(F_WARN_AS_ERR) $(F_OPT_SPEED) $(F_TARG_PENTIUM) $(F_NOLOGO) -CCDEFS = -DNDEBUG -DUNIX -D_M_IX86 - -CCARGS = $(CCFLAGS) $(CCDEFS) -c -I. -I$(STLSOFT_INCLUDE) - -################################################################################ -# Objects - -OBJS_C = \ - ./recls_api.o \ - ./recls_fileinfo.o \ - ./recls_internal.o \ - ./recls_util.o \ - ./recls_api_unix.o \ - ./recls_fileinfo_unix.o \ - ./recls_util_unix.o - - -################################################################################ -# Suffix rules - -.c.o: - $(CC) $(CCARGS) -o$@ $? - -.cpp.o: - $(CC) $(CCARGS) -o$@ $? - -################################################################################ -# Targets - -target: $(RECLS_LIBDIR)/librecls.a - -clean: - @echo Cleaning targets - @rm -f $(RECLS_LIBDIR)/librecls.a - @rm -f $(OBJS_C) - @rm -f *.map - -# executables - -$(RECLS_LIBDIR)/librecls.a: $(OBJS_C) - $(AR) -r $@ $(OBJS_C) - -################################################################################ diff --git a/etc/c/recls/recls.h b/etc/c/recls/recls.h deleted file mode 100644 index 95fae789d09..00000000000 --- a/etc/c/recls/recls.h +++ /dev/null @@ -1,655 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls.h - * - * Purpose: Main header file for the recls API. - * - * Created: 15th August 2003 - * Updated: 21st November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS -#define RECLS_INCL_H_RECLS - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_MAJOR 1 -# define RECLS_VER_H_RECLS_MINOR 5 -# define RECLS_VER_H_RECLS_REVISION 2 -# define RECLS_VER_H_RECLS_EDIT 24 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls.h The root header for the \ref group_recls API */ - -/** \name recls API Version - * - * \ingroup group_recls - */ -/** @{ */ -/** \def RECLS_VER_MAJOR The major version number of RECLS */ - -/** \def RECLS_VER_MINOR The minor version number of RECLS */ - -/** \def RECLS_VER_REVISION The revision version number of RECLS */ - -/** \def RECLS_VER The current composite version number of RECLS */ -/** @} */ - -/* recls version */ -#define RECLS_VER_MAJOR 1 -#define RECLS_VER_MINOR 2 -#define RECLS_VER_REVISION 1 -#define RECLS_VER_1_0_1 0x01000100 -#define RECLS_VER_1_1_1 0x01010100 -#define RECLS_VER_1_2_1 0x01020100 -#define RECLS_VER RECLS_VER_1_2_1 - -/* ///////////////////////////////////////////////////////////////////////////// - * Strictness - */ - -#ifndef RECLS_NO_STRICT -# define RECLS_STRICT -#endif /* !RECLS_NO_STRICT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -/* Detects C & C++ things, such as namespace support */ -#include "recls_language.h" -/* Includes platform-specific headers */ -#include "recls_platform.h" -/* Includes stddef.h / cstddef, and defines the recls types: recls_s/uint8/16/32/64_t */ -#include "recls_compiler.h" -/* Defines recls_filesize_t, recls_time_t */ -#include "recls_platform_types.h" - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -#if !defined(RECLS_NO_NAMESPACE) -# define RECLS_QUAL(x) ::recls::x -#else -# define RECLS_QUAL(x) x -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Pre-processor discrimination - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Function specifications - */ - -/*** Defines the recls linkage and calling convention */ -#define RECLS_FNDECL(rt) RECLS_LINKAGE_C rt RECLS_CALLCONV_DEFAULT - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/* recls_rc_t */ -#ifdef __cplusplus - -/** The type of return codes issued by the API functions */ -typedef recls_sint32_t recls_rc_t; - -/** General success code */ -const recls_rc_t RECLS_RC_OK(0); -/** General failure code */ -const recls_rc_t RECLS_RC_FAIL(-1); - -/** Returns non-zero if the given return code indicates failure */ -inline bool RECLS_FAILED(recls_rc_t const &rc) -{ - return rc < 0; -} - -/** Returns non-zero if the given return code indicates success */ -inline bool RECLS_SUCCEEDED(recls_rc_t const &rc) -{ - return !RECLS_FAILED(rc); -} - -#else /* ? __cplusplus */ - -/** The type of return codes issued by the API functions */ -typedef recls_sint32_t recls_rc_t; - -/** General success code */ -#define RECLS_RC_OK (0) -/** General failure code */ -#define RECLS_RC_FAIL (-1) - -/** Evaluates to non-zero if the given return code indicates failure */ -#define RECLS_FAILED(rc) ((rc) < 0) -/** Evaluates to non-zero if the given return code indicates success */ -#define RECLS_SUCCEEDED(rc) (!FAILED(rc)) - -#endif /* __cplusplus */ - - -/* hrecls_t */ -struct hrecls_t_; -/** The handle to a recursive search operation */ -typedef struct hrecls_t_ const * hrecls_t; - - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -/* Defines result codes */ -#include "recls_retcodes.h" - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Flags - */ - -/** \brief Search flags - * \ingroup group_recls - * - * These flags moderate the search behaviour of the - * \link recls::Recls_Search Recls_Search\endlink and - * \link recls::Recls_SearchProcess Recls_SearchProcess\endlink functions. - */ -enum RECLS_FLAG -{ - RECLS_F_FILES = 0x00000001 /*!< Include files in search. Included by default if none specified */ - , RECLS_F_DIRECTORIES = 0x00000002 /*!< Include directories in search. Not currently supported. */ - , RECLS_F_LINKS = 0x00000004 /*!< Include links in search. Ignored in Win32. */ - , RECLS_F_DEVICES = 0x00000008 /*!< Include devices in search. Not currently supported. */ - , RECLS_F_TYPEMASK = 0x00000FFF - , RECLS_F_RECURSIVE = 0x00010000 /*!< Searches given directory and all sub-directories */ - , RECLS_F_NO_FOLLOW_LINKS = 0x00020000 /*!< Does not expand links */ - , RECLS_F_DIRECTORY_PARTS = 0x00040000 /*!< Fills out the directory parts. Supported from version 1.1.1 onwards. */ - , RECLS_F_DETAILS_LATER = 0x00080000 /*!< Does not fill out anything other than the path. Not currently supported. */ -}; - -#if !defined(__cplusplus) && \ - !defined(RECLS_DOCUMENTATION_SKIP_SECTION) -typedef enum RECLS_FLAG RECLS_FLAG; -#endif /* !__cplusplus && !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -struct recls_fileinfo_t; - -/** Opaque type representing a file-system entry information */ -typedef struct recls_fileinfo_t const *recls_info_t; - -/** Opaque type representing a user-defined parameter to the process function */ -typedef void *recls_process_fn_param_t; - -/** User-supplied process function, used by Recls_SearchProcess() - * - * \param info entry info structure - * \param param the parameter passed to Recls_SearchProcess() - * \return A status to indicate whether to continue or cancel the processing - * \retval 0 cancel the processing - * \retval non-0 continue the processing - */ -typedef int (RECLS_CALLCONV_DEFAULT *hrecls_process_fn_t)(recls_info_t info, recls_process_fn_param_t param); - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace typedefs - */ - -#if !defined(RECLS_NO_NAMESPACE) -typedef recls_info_t info_t; -typedef recls_process_fn_param_t process_fn_param_t; -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Functions - */ - -/*************************************** - * Search control - */ - -/** \name Search control functions - * - * \ingroup group_recls - */ -/** @{ */ - -/** Searches a given directory for matching files of the given pattern - * - * - * \param searchRoot The directory representing the root of the search - * \param pattern The search pattern, e.g. "*.c" - * \param flags A combination of 0 or more RECLS_FLAG values - * \param phSrch Address of the search handle - * \return A status code indicating success/failure - * - */ -RECLS_FNDECL(recls_rc_t) Recls_Search( recls_char_t const *searchRoot - , recls_char_t const *pattern - , recls_uint32_t flags - , hrecls_t *phSrch); - -/** Searches a given directory for matching files of the given pattern, and processes them according to the given process function - * - * \param searchRoot The directory representing the root of the search - * \param pattern The search pattern, e.g. "*.c" - * \param flags A combination of 0 or more RECLS_FLAG values - * \param pfn The processing function - * \param param A caller-supplied parameter that is passed through to \c pfn on each invocation. The function can cancel the enumeration by returning 0 - * \return A status code indicating success/failure - * - * \note Available from version 1.1 of the recls API - */ -RECLS_FNDECL(recls_rc_t) Recls_SearchProcess( recls_char_t const *searchRoot - , recls_char_t const *pattern - , recls_uint32_t flags - , hrecls_process_fn_t pfn - , recls_process_fn_param_t param); - -/** Closes the given search - * - * \param hSrch Handle of the search to close. May not be NULL. - */ -RECLS_FNDECL(void) Recls_SearchClose( hrecls_t hSrch); - -/** @} */ - -/*************************************** - * Search enumeration - */ - -/** \name Search enumeration functions - * - * \ingroup group_recls - */ -/** @{ */ - -/** Advances the search one position - * - * \param hSrch Handle of the search to close. May not be NULL. - * \return Status code - * \retval RECLS_RC_OK Position was advanced; search handle can be queried for details - * \retval RECLS_RC_NO_MORE_DATA There are no more items in the search - * \retval Any other status code indicates an error - */ -RECLS_FNDECL(recls_rc_t) Recls_GetNext( hrecls_t hSrch); - -/** Advances the search one position, and retrieves the information for the new position - * - * \param hSrch Handle of the search to close. May not be NULL. - * \param phEntry Pointer to receive entry info structure. - * \return Status code - * \retval RECLS_RC_OK Position was advanced; search handle can be queried for details - * \retval RECLS_RC_NO_MORE_DATA There are no more items in the search - * \retval Any other status code indicates an error - */ -RECLS_FNDECL(recls_rc_t) Recls_GetDetails( hrecls_t hSrch - , recls_info_t *phEntry); - -/** Retrieves the information for the current search position - * - * \param hSrch Handle of the search to close. May not be NULL. - * \param phEntry Pointer to receive entry info structure. - * \return Status code - * \retval RECLS_RC_OK Position was advanced; search handle can be queried for details - * \retval Any other status code indicates an error - */ -RECLS_FNDECL(recls_rc_t) Recls_GetNextDetails( hrecls_t hSrch - , recls_info_t *phEntry); - -/** @} */ - -/*************************************** - * File entry info structure - */ - -/** \name File entry info structure functions - * - * \ingroup group_recls - */ -/** @{ */ - -/** Releases the resources associated with an entry info structure. - * - * \param hEntry The info entry structure. - */ -RECLS_FNDECL(void) Recls_CloseDetails( recls_info_t hEntry); - -/** Copies an entry info structure. - * - * \param hEntry The info entry structure. - * \param phEntry Address to receive a copy of the info entry structure. May not be NULL. - * \return Status code - * \retval RECLS_RC_OK Entry was generated. - * \retval Any other status code indicates an error - */ -RECLS_FNDECL(recls_rc_t) Recls_CopyDetails( recls_info_t hEntry - , recls_info_t *phEntry); - -/** Reports on the number of outstanding (i.e. in client code) file entry info structures - * - * \param hSrch Handle of the search to close. May not be NULL. - * \param count Pointer to an integer variable to receive the result. - * \return Status code - * \retval RECLS_RC_OK Information was retrieved. - * \retval Any other status code indicates an error - */ -RECLS_FNDECL(recls_rc_t) Recls_OutstandingDetails(hrecls_t hSrch - , recls_uint32_t *count); - -/** @} */ - -/*************************************** - * Error handling - */ - -/** \name Error handling functions - * - * \ingroup group_recls - */ -/** @{ */ - -/** Returns the last error code associated with the given search handle - * - * \param hSrch Handle of the search to close. May not be NULL. - * \return The last error code for the search handle - */ -RECLS_FNDECL(recls_rc_t) Recls_GetLastError( hrecls_t hSrch); - -/** Gets the error string representing the given error - * - * \param rc The error code - * \param buffer Pointer to character buffer in which to write the error. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the error. - */ -RECLS_FNDECL(size_t) Recls_GetErrorString( recls_rc_t rc - , recls_char_t *buffer - , size_t cchBuffer); - -/** Gets the error string representing the current error associated with the given search handle - * - * \param hSrch Handle of the search to close. May not be NULL. - * \param buffer Pointer to character buffer in which to write the error. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the error. - */ -RECLS_FNDECL(size_t) Recls_GetLastErrorString( hrecls_t hSrch - , recls_char_t *buffer - , size_t cchBuffer); - -/** @} */ - -/*************************************** - * Property elicitation - */ - -/** \name Property elicitation functions - * - * \ingroup group_recls - */ -/** @{ */ - -/** Retrieves the full path of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the path. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the path. - */ -RECLS_FNDECL(size_t) Recls_GetPathProperty( recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves the directory of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the directory. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the directory. - */ -RECLS_FNDECL(size_t) Recls_GetDirectoryProperty(recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves the directory and drive of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the directory. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the directory. - * \note On systems that do not have a drive, this function behaves identically to Recls_GetDirectoryProperty() - */ -RECLS_FNDECL(size_t) Recls_GetDirectoryPathProperty( recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves the file (filename + extension) of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the file. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the file. - */ -RECLS_FNDECL(size_t) Recls_GetFileProperty( recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves the short version of the file of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the file. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the file. - * - * \note On systems where there is no concept of a short name, this function behaves exactly as Recls_GetFileProperty() - */ -RECLS_FNDECL(size_t) Recls_GetShortFileProperty(recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves the filename (not including extension, if any) of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the filename. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the filename. - */ -RECLS_FNDECL(size_t) Recls_GetFileNameProperty( recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves the file extension of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param buffer Pointer to character buffer in which to write the extension. If NULL, the function returns the number of characters required. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL. - * \return The number of characters written to the buffer, or required for, the extension. - */ -RECLS_FNDECL(size_t) Recls_GetFileExtProperty( recls_info_t hEntry - , recls_char_t *buffer - , size_t cchBuffer); - -/** Retrieves a directory part of the given entry recls_fileinfo_t - * - * \param hEntry The entry recls_fileinfo_t. Cannot be NULL - * \param part The part requested. If -1, then the function returns the number of parts - * \param buffer Pointer to character buffer in which to write the extension. If NULL, the function returns the number of characters required. Ignored if part is -1. - * \param cchBuffer Number of character spaces in \c buffer. Ignored if \c buffer is NULL or part is -1. - * \return If \c part is -1, returns the number of parts. Otherwise, The number of characters written to the buffer, or required for, the extension. - * - * \note The behaviour is undefined if part is outside the range of parts. - */ -RECLS_FNDECL(size_t) Recls_GetDirectoryPartProperty(recls_info_t hEntry - , int part - , recls_char_t *buffer - , size_t cchBuffer); - - -/** Returns non-zero if the file entry is read-only. - * - * \param hEntry The file entry info structure to test. May not be NULL - * \retval true file entry is read-only - * \retval false file entry is not read-only - * - * \note There is no error return - */ -RECLS_FNDECL(recls_bool_t) Recls_IsFileReadOnly(recls_info_t hEntry); - -/** Returns non-zero if the file entry represents a directory. - * - * \param hEntry The file entry info structure to test. May not be NULL - * \retval true file entry is a directory - * \retval false file entry is not directory - * - * \note There is no error return - */ -RECLS_FNDECL(recls_bool_t) Recls_IsFileDirectory(recls_info_t hEntry); - -/** Returns non-zero if the file entry represents a link. - * - * \param hEntry The file entry info structure to test. May not be NULL - * \retval true file entry is a link - * \retval false file entry is not link - * - * \note There is no error return - */ -RECLS_FNDECL(recls_bool_t) Recls_IsFileLink( recls_info_t hEntry); - -/** Acquires the size of the file entry. - * - * \param hEntry The file entry info structure to test. May not be NULL - * \param size Pointer to the location in which to store the size - * - * \note There is no error return. File system entries that do not have a meaningful size will be given a notional size of 0. - */ -RECLS_FNDECL(void) Recls_GetSizeProperty( recls_info_t hEntry - , recls_filesize_t *size); - -/** Returns the time the file was created */ -RECLS_FNDECL(recls_time_t) Recls_GetCreationTime(recls_info_t hEntry); - -/** Returns the time the file was last modified */ -RECLS_FNDECL(recls_time_t) Recls_GetModificationTime(recls_info_t hEntry); - -/** Returns the time the file was last accessed */ -RECLS_FNDECL(recls_time_t) Recls_GetLastAccessTime(recls_info_t hEntry); - -/** Returns the time the file status was last changed */ -RECLS_FNDECL(recls_time_t) Recls_GetLastStatusChangeTime(recls_info_t hEntry); - -/** @} */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Platform-specific includes - */ - -/*** \def RECLS_PLATFORM_API_WIN32 Defined if Win32 platform-specific extensions are in use */ -/*** \def RECLS_PLATFORM_API_UNIX Defined if UNIX platform-specific extensions are in use */ - -#ifdef RECLS_PLATFORM_API_WIN32 -# undef RECLS_PLATFORM_API_WIN32 -#endif /* RECLS_PLATFORM_API_WIN32 */ - -#ifdef RECLS_PLATFORM_API_UNIX -# undef RECLS_PLATFORM_API_UNIX -#endif /* RECLS_PLATFORM_API_UNIX */ - -#if !defined(RECLS_PURE_API) -# if defined(RECLS_PLATFORM_IS_WIN32) -# include "recls_win32.h" -# define RECLS_PLATFORM_API_WIN32 -# elif defined(RECLS_PLATFORM_IS_UNIX) -# include "recls_unix.h" -# define RECLS_PLATFORM_API_UNIX -# else -# error Platform not recognised -# endif /* platform */ -#endif /* !RECLS_PURE_API */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_api.cpp b/etc/c/recls/recls_api.cpp deleted file mode 100644 index 184f0bc2a15..00000000000 --- a/etc/c/recls/recls_api.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_api.cpp - * - * Purpose: Main (platform-independent) implementation file for the recls API. - * - * Created: 16th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#define RECLS_PURE_API - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" - -#include - -#include "recls_debug.h" - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Search control - */ - -/** Closes the given search */ -RECLS_FNDECL(void) Recls_SearchClose(hrecls_t hSrch) -{ - function_scope_trace("Recls_SearchClose"); - - ReclsSearchInfo *si = ReclsSearchInfo::FromHandle(hSrch); - - recls_assert(NULL != si); - - delete si; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Search enumeration - */ - -RECLS_FNDECL(recls_rc_t) Recls_SearchProcess( recls_char_t const *searchRoot - , recls_char_t const *pattern - , recls_uint32_t flags - , hrecls_process_fn_t pfn - , recls_process_fn_param_t param) -{ - function_scope_trace("Recls_SearchProcess"); - - recls_assert(NULL != pfn); - - hrecls_t hSrch; - recls_rc_t rc = Recls_Search(searchRoot, pattern, flags, &hSrch); - - if(RECLS_SUCCEEDED(rc)) - { - recls_info_t info; - - do - { - rc = Recls_GetDetails(hSrch, &info); - - if(RECLS_FAILED(rc)) - { - break; - } - else - { - int res = (*pfn)(info, param); - - Recls_CloseDetails(info); - - if(0 == res) - { - break; - } - } - } - while(RECLS_SUCCEEDED(rc = Recls_GetNext(hSrch))); - - Recls_SearchClose(hSrch); - } - - if(RECLS_RC_NO_MORE_DATA == rc) - { - rc = RECLS_RC_OK; - } - - return rc; -} - -RECLS_FNDECL(recls_rc_t) Recls_GetNext(hrecls_t hSrch) -{ - function_scope_trace("Recls_GetNext"); - - ReclsSearchInfo *si = ReclsSearchInfo::FromHandle(hSrch); - - recls_assert(NULL != si); - - return si->GetNext(); -} - -RECLS_FNDECL(recls_rc_t) Recls_GetDetails( hrecls_t hSrch - , recls_info_t *pinfo) -{ - function_scope_trace("Recls_GetDetails"); - - ReclsSearchInfo *si = ReclsSearchInfo::FromHandle(hSrch); - - recls_assert(NULL != si); - recls_assert(NULL != pinfo); - - return si->GetDetails(pinfo); -} - -RECLS_FNDECL(recls_rc_t) Recls_GetNextDetails( hrecls_t hSrch - , recls_info_t *pinfo) -{ - function_scope_trace("Recls_GetNextDetails"); - - ReclsSearchInfo *si = ReclsSearchInfo::FromHandle(hSrch); - - recls_assert(NULL != si); - - return si->GetNextDetails(pinfo); -} - -/*************************************** - * File entry info structure - */ - -RECLS_FNDECL(void) Recls_CloseDetails(recls_info_t fileInfo) -{ - function_scope_trace("Recls_CloseDetails"); - - recls_assert(NULL != fileInfo); - - FileInfo_Release(fileInfo); -} - -RECLS_FNDECL(recls_rc_t) Recls_CopyDetails( recls_info_t fileInfo - , recls_info_t *pinfo) -{ - function_scope_trace("Recls_CopyDetails"); - - recls_assert(NULL != fileInfo); - - return FileInfo_Copy(fileInfo, pinfo); -} - -RECLS_FNDECL(recls_rc_t) Recls_OutstandingDetails( hrecls_t hSrch - , recls_uint32_t *count) -{ - function_scope_trace("Recls_OutstandingDetails"); - - ReclsSearchInfo *si = ReclsSearchInfo::FromHandle(hSrch); - - recls_assert(NULL != si); - recls_assert(NULL != count); - STLSOFT_SUPPRESS_UNUSED(si); - - recls_sint32_t cCreated; - recls_sint32_t cShared; - - FileInfo_BlockCount(&cCreated, &cShared); - - *count = cCreated; - - return RECLS_RC_OK; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Error handling - */ - -RECLS_FNDECL(recls_rc_t) Recls_GetLastError(hrecls_t hSrch) -{ - function_scope_trace("Recls_GetLastError"); - - ReclsSearchInfo *si = ReclsSearchInfo::FromHandle(hSrch); - - recls_assert(NULL != si); - - return si->GetLastError(); -} - -RECLS_FNDECL(size_t) Recls_GetLastErrorString( hrecls_t hSrch - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetLastErrorString"); - - return Recls_GetErrorString(Recls_GetLastError(hSrch), buffer, cchBuffer); -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Property elicitation - */ - -RECLS_FNDECL(size_t) Recls_GetPathProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetPathProperty"); - - recls_assert(NULL != fileInfo); - - return Recls_GetStringProperty_(&fileInfo->path, buffer, cchBuffer); -} - -RECLS_FNDECL(size_t) Recls_GetDirectoryProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetDirectoryProperty"); - - recls_assert(NULL != fileInfo); - - return Recls_GetStringProperty_(&fileInfo->directory, buffer, cchBuffer); -} - -RECLS_FNDECL(size_t) Recls_GetFileProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetFileProperty"); - - recls_assert(NULL != fileInfo); - - struct recls_strptrs_t file = - { - fileInfo->fileName.begin /* File is defined by start of fileName ... */ - , fileInfo->fileExt.end /* ... to end of fileExt. */ - }; - - return Recls_GetStringProperty_(&file, buffer, cchBuffer); -} - -RECLS_FNDECL(size_t) Recls_GetFileNameProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetFileNameProperty"); - - recls_assert(NULL != fileInfo); - - return Recls_GetStringProperty_(&fileInfo->fileName, buffer, cchBuffer); -} - -RECLS_FNDECL(size_t) Recls_GetFileExtProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetFileExtProperty"); - - recls_assert(NULL != fileInfo); - - return Recls_GetStringProperty_(&fileInfo->fileExt, buffer, cchBuffer); -} - -RECLS_FNDECL(size_t) Recls_GetDirectoryPartProperty( recls_info_t fileInfo - , int part - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetDirectoryPartProperty"); - - recls_assert(NULL != fileInfo); - - size_t cParts = fileInfo->directoryParts.end - fileInfo->directoryParts.begin; - -//debug_printf("%s: %u parts\n", fileInfo->path.begin, cParts); - - if(part < 0) - { - return cParts; - } - else - { - recls_assert(static_cast(part) < cParts); - - return Recls_GetStringProperty_(&fileInfo->directoryParts.begin[part], buffer, cchBuffer); - } -} - -RECLS_FNDECL(void) Recls_GetSizeProperty( recls_info_t fileInfo - , recls_filesize_t *size) -{ - function_scope_trace("Recls_GetSizeProperty"); - - recls_assert(NULL != fileInfo); - recls_assert(NULL != size); - - *size = fileInfo->size; -} - -RECLS_FNDECL(recls_time_t) Recls_GetModificationTime(recls_info_t fileInfo) -{ - function_scope_trace("Recls_GetModificationTime"); - - recls_assert(NULL != fileInfo); - - return fileInfo->modificationTime; -} - -RECLS_FNDECL(recls_time_t) Recls_GetLastAccessTime(recls_info_t fileInfo) -{ - function_scope_trace("Recls_GetLastAccessTime"); - - recls_assert(NULL != fileInfo); - - return fileInfo->lastAccessTime; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_api_unix.cpp b/etc/c/recls/recls_api_unix.cpp deleted file mode 100644 index 2dca7cc8d8f..00000000000 --- a/etc/c/recls/recls_api_unix.cpp +++ /dev/null @@ -1,1045 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_api_unix.cpp - * - * Purpose: Win32 implementation file for the recls API. - * - * Created: 16th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" -#include "recls_util.h" - -#include - -#include -#include - -# include -# include - -#include "recls_debug.h" - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -unixstl_ns_using(glob_sequence) - -typedef unixstl_ns_qual(filesystem_traits) traits_type; // We need to do this, because VC is a bit thick - -/* ///////////////////////////////////////////////////////////////////////////// - * Utility functions - */ - -#if defined(_DEBUG) && \ - defined(RECLS_PLATFORM_IS_WIN32) - -/* static */ tls_index function_scope::sm_index; - -#endif /* _DEBUG */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -static recls_info_t create_entryinfo_from_psrecord(recls_char_t const * /* rootDir */, recls_uint32_t flags, recls_char_t const *entry) -{ - typedef recls_char_t char_type; - - recls_char_t rootDir[PATH_MAX]; - recls_char_t entryName[PATH_MAX]; - recls_char_t *name_start; - - traits_type::str_copy(rootDir, entry); - name_start = strrchr(rootDir, '/'); - traits_type::str_copy(entryName, ++name_start); - *name_start = '\0'; - - function_scope_trace("create_entryinfo_from_psrecord"); - - // size of structure is: - // - // offsetof(struct recls_fileinfo_t, data) - // + directory parts - // + full path (+ null) - // + short name (+ null) - - size_t cchRootDir = traits_type::str_len(rootDir); - -// recls_assert(cchRootDir > 0); -// recls_assert(rootDir[cchRootDir - 1] == traits_type::path_name_separator()); - - size_t cchFileName = traits_type::str_len(entryName); - size_t cDirParts = ((flags & RECLS_F_DIRECTORY_PARTS) == RECLS_F_DIRECTORY_PARTS) ? count_dir_parts(rootDir, rootDir + cchRootDir) : 0; - size_t cbPath = align_up_size(sizeof(char_type) * (1 + cchRootDir + cchFileName)); - size_t cb = offsetof(struct recls_fileinfo_t, data) - + cDirParts * sizeof(recls_strptrs_t) - + cbPath; - - struct recls_fileinfo_t *info = const_cast(FileInfo_Allocate(cb)); - - if(NULL != info) - { - char_type *fullPath = (char_type*)&info->data[cDirParts * sizeof(recls_strptrs_t)]; -// char_type *altName = (char_type*)&info->data[cDirParts * sizeof(recls_strptrs_t) + cbPath]; - - // full path - traits_type::str_copy(fullPath, rootDir); - traits_type::str_cat(fullPath, entryName); - info->path.begin = fullPath; - info->path.end = fullPath + cchRootDir + cchFileName; - - // directory, file (name + ext) - info->directory.begin = fullPath; - info->directory.end = fullPath + cchRootDir; - info->fileName.begin = info->directory.end; - info->fileName.end = strrchr(info->directory.end, '.'); - if(NULL != info->fileName.end) - { - info->fileExt.begin = info->fileName.end + 1; - info->fileExt.end = info->directory.end + cchFileName; - } - else - { - info->fileName.end = info->directory.end + cchFileName; - info->fileExt.begin = info->directory.end + cchFileName; - info->fileExt.end = info->directory.end + cchFileName; - } - - // determine the directory parts - char_type const *p = info->directory.begin; - char_type const *l = info->directory.end; - struct recls_strptrs_t *begin = (struct recls_strptrs_t*)&info->data[0]; - - info->directoryParts.begin = begin; - info->directoryParts.end = begin + cDirParts; - - if(info->directoryParts.begin != info->directoryParts.end) - { - recls_assert((flags & RECLS_F_DIRECTORY_PARTS) == RECLS_F_DIRECTORY_PARTS); - - begin->begin = p; - - for(; p != l; ++p) - { - if(*p == traits_type::path_name_separator()) - { - begin->end = p + 1; - - if(++begin != info->directoryParts.end) - { - begin->begin = p + 1; - } - } - } - } - - struct stat st; - - stat(fullPath, &st); - - // attributes - info->attributes = st.st_mode; - - // time, size - info->lastStatusChangeTime = st.st_ctime; - info->modificationTime = st.st_mtime; - info->lastAccessTime = st.st_atime; - info->size = st.st_size; - - // Checks - recls_assert(info->path.begin < info->path.end); - - recls_assert(info->directory.begin < info->directory.end); - recls_assert(info->path.begin <= info->directory.begin); - recls_assert(info->directory.end <= info->path.end); - - recls_assert(info->fileName.begin <= info->fileName.end); - - recls_assert(info->fileExt.begin <= info->fileExt.end); - - recls_assert(info->fileName.begin < info->fileExt.end); - recls_assert(info->fileName.end <= info->fileExt.begin); - } - - return info; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * PlatformDirectoryNode - */ - -class PlatformDirectoryNode - : public ReclsDNode -{ -public: - typedef recls_char_t char_type; - typedef PlatformDirectoryNode class_type; -private: - typedef glob_sequence directory_sequence_t; - typedef glob_sequence entry_sequence_t; - -// Construction -private: - PlatformDirectoryNode(recls_uint32_t flags, char_type const *rootDir, char_type const *pattern); -public: - virtual ~PlatformDirectoryNode(); - - static PlatformDirectoryNode *FindAndCreate(recls_uint32_t flags, char_type const *rootDir, char_type const *pattern); - static PlatformDirectoryNode *FindAndCreate(recls_uint32_t flags, char_type const *rootDir, char_type const *subDir, char_type const *pattern); - -// ReclsDNode methods -private: - virtual recls_rc_t GetNext(); - virtual recls_rc_t GetDetails(recls_info_t *pinfo); - virtual recls_rc_t GetNextDetails(recls_info_t *pinfo); - -// Implementation -private: - recls_rc_t Initialise(); - - recls_bool_t _is_valid() const; - -#if defined(RECLS_COMPILER_IS_BORLAND) - static directory_sequence_t::const_iterator _select_iter(int b, directory_sequence_t::const_iterator trueVal, directory_sequence_t::const_iterator falseVal) - { - // I can't explain it, but Borland does not like the tertiary operator and the copy-ctors of the iterators - if(b) - { - return trueVal; - } - else - { - return falseVal; - } - } -#endif /* !RECLS_COMPILER_IS_BORLAND */ - static int _ssFlags_from_reclsFlags(recls_uint32_t flags) - { - recls_assert(0 == (flags & RECLS_F_LINKS)); // Doesn't work with links - recls_assert(0 == (flags & RECLS_F_DEVICES)); // Doesn't work with devices - - int ssFlags = 0; - - if(0 != (flags & RECLS_F_FILES)) - { - ssFlags |= entry_sequence_t::files; - } - if(0 != (flags & RECLS_F_DIRECTORIES)) - { - ssFlags |= entry_sequence_t::directories; - } - - return ssFlags; - } - -// Members -private: - recls_info_t m_current; - ReclsDNode *m_dnode; - recls_uint32_t const m_flags; - entry_sequence_t m_entries; - entry_sequence_t::const_iterator m_entriesBegin; - directory_sequence_t m_directories; - directory_sequence_t::const_iterator m_directoriesBegin; - char_type m_rootDir[RECLS_PATH_MAX]; - char_type m_pattern[RECLS_PATH_MAX]; -}; - -PlatformDirectoryNode::PlatformDirectoryNode(recls_uint32_t flags, PlatformDirectoryNode::char_type const *rootDir, PlatformDirectoryNode::char_type const *pattern) - : m_current(NULL) - , m_dnode(NULL) - , m_flags(flags) - , m_entries(rootDir, pattern, _ssFlags_from_reclsFlags(flags)) - , m_entriesBegin(m_entries.begin()) -#ifdef _MSC_VER // For testing - , m_directories(rootDir, "*.*", directory_sequence_t::directories) -#else /* ? _MSC_VER */ - , m_directories(rootDir, traits_type::pattern_all(), directory_sequence_t::directories) -#endif /* _MSC_VER */ -#if !defined(RECLS_COMPILER_IS_BORLAND) - , m_directoriesBegin((flags & RECLS_F_RECURSIVE) ? m_directories.begin() : m_directories.end()) -#else - , m_directoriesBegin(_select_iter((flags & RECLS_F_RECURSIVE), m_directories.begin(), m_directories.end())) -#endif /* !RECLS_COMPILER_IS_BORLAND */ -{ - function_scope_trace("PlatformDirectoryNode::PlatformDirectoryNode"); - -#if defined(RECLS_COMPILER_IS_BORLAND) -// m_directoriesBegin = ((flags & RECLS_F_RECURSIVE) ? m_directories.begin() : m_directories.end()); -#endif /* !RECLS_COMPILER_IS_BORLAND */ - - traits_type::str_copy(m_rootDir, rootDir); - traits_type::ensure_dir_end(m_rootDir); - traits_type::str_copy(m_pattern, pattern); - - recls_assert(stlsoft_raw_offsetof(PlatformDirectoryNode, m_entries) < stlsoft_raw_offsetof(PlatformDirectoryNode, m_entriesBegin)); - recls_assert(stlsoft_raw_offsetof(PlatformDirectoryNode, m_directories) < stlsoft_raw_offsetof(PlatformDirectoryNode, m_directoriesBegin)); -} - -inline /* static */ PlatformDirectoryNode *PlatformDirectoryNode::FindAndCreate(recls_uint32_t flags, PlatformDirectoryNode::char_type const *rootDir, PlatformDirectoryNode::char_type const *pattern) -{ - PlatformDirectoryNode *node; - - function_scope_trace("PlatformDirectoryNode::FindAndCreate"); - -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - try - { -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - node = new PlatformDirectoryNode(flags, rootDir, pattern); -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - } - catch(std::bad_alloc &) - { - node = NULL; - } -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - - if(NULL != node) - { - // Ensure that it, or one of its sub-nodes, has matching entries. - recls_rc_t rc = node->Initialise(); - - if(RECLS_FAILED(rc)) - { - delete node; - - node = NULL; - } - } - - recls_assert(NULL == node || node->_is_valid()); - - return node; -} - -inline /* static */ PlatformDirectoryNode *PlatformDirectoryNode::FindAndCreate(recls_uint32_t flags, PlatformDirectoryNode::char_type const *rootDir, PlatformDirectoryNode::char_type const *subDir, PlatformDirectoryNode::char_type const *pattern) -{ - char_type compositeDir[RECLS_PATH_MAX]; - - recls_assert(rootDir[traits_type::str_len(rootDir) - 1] == traits_type::path_name_separator()); - - // Only need subdir, since globbing provides partial path - traits_type::str_copy(compositeDir, subDir); - - return FindAndCreate(flags, compositeDir, pattern); -} - -PlatformDirectoryNode::~PlatformDirectoryNode() -{ - function_scope_trace("PlatformDirectoryNode::~PlatformDirectoryNode"); - - FileInfo_Release(m_current); - - delete m_dnode; -} - -recls_rc_t PlatformDirectoryNode::Initialise() -{ - function_scope_trace("PlatformDirectoryNode::Initialise"); - - recls_rc_t rc; - - recls_assert(NULL == m_current); - recls_assert(NULL == m_dnode); - - if(m_entriesBegin != m_entries.end()) - { - // (i) Try getting a file first, - m_current = create_entryinfo_from_psrecord(m_rootDir, m_flags, *m_entriesBegin); - - if(NULL == m_current) - { - rc = RECLS_RC_OUT_OF_MEMORY; - } - else - { - rc = RECLS_RC_OK; - } - } - else - { - if(m_directoriesBegin == m_directories.end()) - { - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - do - { -#if 1 - // The way glob_sequence works - m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, m_rootDir, *m_directoriesBegin, m_pattern); -#else /* ? 0 */ -// m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, (*m_directoriesBegin).get_path(), m_pattern); -#endif /* 0 */ - - } while(NULL == m_dnode && ++m_directoriesBegin != m_directories.end()); - - rc = (NULL == m_dnode) ? RECLS_RC_NO_MORE_DATA : RECLS_RC_OK; - } - } - - if(RECLS_SUCCEEDED(rc)) - { - recls_assert(_is_valid()); - } - - return rc; -} - -recls_bool_t PlatformDirectoryNode::_is_valid() const -{ - function_scope_trace("PlatformDirectoryNode::_is_valid"); - - recls_rc_t rc = RECLS_RC_OK; - -#ifdef STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT -# pragma message("Flesh these out") -#endif /* STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT */ - if(RECLS_SUCCEEDED(rc)) - { - - } - - if(RECLS_SUCCEEDED(rc)) - { - } - - if(RECLS_SUCCEEDED(rc)) - { - } - - if(RECLS_SUCCEEDED(rc)) - { - } - - // (i) Either we are enumerating files (m_current != NULL) or directories (m_dnode != NULL), but not both - recls_assert(NULL == m_current || NULL == m_dnode); - // (ii) Either we are enumerating files (m_current != NULL) or there are no more files to enumerate - recls_assert(NULL != m_current || m_entriesBegin == m_entries.end()); - - return RECLS_SUCCEEDED(rc); -} - - -recls_rc_t PlatformDirectoryNode::GetNext() -{ - function_scope_trace("PlatformDirectoryNode::GetNext"); - - recls_assert(_is_valid()); - - /* Searching operates as follows: - * - * 1. Return all the contents of the files - * 2. Return the contents of the directories. - * - * Hence, if m_dnode is non-NULL, we've already searched - */ - - /* States: - * - * - Iterating files: m_entriesBegin != m_entries.end(), m_dnode is NULL, m_directoriesBegin != m_directories.end() - * - Iterating directories: m_directoriesBegin != m_directories.end(), m_dnode is non-NULL, m_current is NULL - * - */ - - // Invariants - - // (i) Either we are enumerating files (m_current != NULL) or directories (m_dnode != NULL), but not both - recls_assert(NULL == m_current || NULL == m_dnode); - // (ii) Either we are enumerating files (m_current != NULL) or there are no more files to enumerate - recls_assert(NULL != m_current || m_entriesBegin == m_entries.end()); - - recls_rc_t rc = RECLS_RC_NO_MORE_DATA; - - if(NULL != m_current) - { - // Currently enumerating through the files - - recls_assert(m_entriesBegin != m_entries.end()); - recls_assert(NULL == m_dnode); - - // Advance, and check for end of sequence - ++m_entriesBegin; - - FileInfo_Release(m_current); - if(m_entriesBegin != m_entries.end()) - { - // Still enumerating, so just update m_current - m_current = create_entryinfo_from_psrecord(m_rootDir, m_flags, *m_entriesBegin); - - rc = RECLS_RC_OK; - } - else - { - // No more left in the files sequence, so delete m_current - m_current = NULL; - - rc = RECLS_RC_NO_MORE_DATA; - } - } - - if(NULL == m_current) - { - // Now we are either enumerating the directories, or we've already done so - - if(NULL != m_dnode) - { - // Currently enumerating the directories - rc = m_dnode->GetNext(); - - if(RECLS_RC_NO_MORE_DATA == rc) - { - ++m_directoriesBegin; - - delete m_dnode; - - m_dnode = NULL; - } - } - - if(m_directoriesBegin == m_directories.end()) - { - // Enumeration is complete. - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - if(NULL == m_dnode) - { - do - { - // Creation of the node will cause it to enter the first enumeration - // state. However, if there are no matching - - recls_assert(m_directoriesBegin != m_directories.end()); - -#if 1 - // The way glob_sequence works - m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, m_rootDir, *m_directoriesBegin, m_pattern); -#else /* ? 0 */ -// m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, (*m_directoriesBegin).get_path(), m_pattern); -#endif /* 0 */ - - if(NULL != m_dnode) - { - rc = RECLS_RC_OK; - } - else - { - ++m_directoriesBegin; - } - - } while(NULL == m_dnode && m_directoriesBegin != m_directories.end()); - } - } - } - - recls_assert(_is_valid()); - - return rc; -} - -recls_rc_t PlatformDirectoryNode::GetDetails(recls_info_t *pinfo) -{ - function_scope_trace("PlatformDirectoryNode::GetDetails"); - - recls_assert(_is_valid()); - - recls_rc_t rc; - - recls_assert(NULL != pinfo); - recls_assert(NULL == m_current || NULL == m_dnode); - - if(NULL != m_current) - { - // Currently searching for files from the current directory - - recls_assert(NULL == m_dnode); - - rc = FileInfo_Copy(m_current, pinfo); - -#if defined(_DEBUG) && \ - defined(RECLS_PLATFORM_IS_WIN32) - { - recls_char_t buffer[RECLS_PATH_MAX]; - - Recls_GetPathProperty(m_current, buffer, stlsoft_num_elements(buffer)); - - debug_printf(" [%s]\n", buffer); - } -#endif /* _DEBUG */ - } - else if(NULL != m_dnode) - { - recls_assert(NULL == m_current); - - // Sub-directory searching is active, so get from there. - - rc = m_dnode->GetDetails(pinfo); - } - else - { - // Enumeration has completed - rc = RECLS_RC_NO_MORE_DATA; - } - - recls_assert(_is_valid()); - - return rc; -} - -recls_rc_t PlatformDirectoryNode::GetNextDetails(recls_info_t *pinfo) -{ - function_scope_trace("PlatformDirectoryNode::GetNextDetails"); - - recls_assert(_is_valid()); - recls_assert(NULL != pinfo); - - recls_rc_t rc = GetNext(); - - if(RECLS_SUCCEEDED(rc)) - { - rc = GetDetails(pinfo); - } - - recls_assert(_is_valid()); - - return rc; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * ReclsSearchInfo - */ - -void *ReclsSearchInfo::operator new(size_t cb, int cDirParts, size_t cbRootDir) -{ - function_scope_trace("ReclsSearchInfo::operator new"); - - cbRootDir = align_up_size(cbRootDir); - - recls_assert(cb > stlsoft_raw_offsetof(ReclsSearchInfo, data)); - - cb = stlsoft_raw_offsetof(ReclsSearchInfo, data) - + (cDirParts) * sizeof(recls_strptrs_t) - + cbRootDir; - - return malloc(cb); -} - -#if !defined(RECLS_COMPILER_IS_BORLAND) && \ - !defined(RECLS_COMPILER_IS_DMC) -void ReclsSearchInfo::operator delete(void *pv, int /* cDirParts */, size_t /* cbRootDir */) -{ - function_scope_trace("ReclsSearchInfo::operator delete"); - - free(pv); -} -#endif /* !RECLS_COMPILER_IS_BORLAND && !RECLS_COMPILER_IS_DMC */ - -void ReclsSearchInfo::operator delete(void *pv) -{ - function_scope_trace("ReclsSearchInfo::operator delete"); - - free(pv); -} - -inline /* static */ recls_rc_t ReclsSearchInfo::FindAndCreate(ReclsSearchInfo::char_type const *rootDir, ReclsSearchInfo::char_type const *pattern, recls_uint32_t flags, ReclsSearchInfo **ppsi) -{ - function_scope_trace("ReclsSearchInfo::FindAndCreate"); - - recls_rc_t rc; - ReclsSearchInfo *si; - char_type fullPath[RECLS_PATH_MAX]; - size_t cchFullPath; - - *ppsi = NULL; - - cchFullPath = traits_type::get_full_path_name(rootDir, RECLS_NUM_ELEMENTS(fullPath), fullPath); - if( 0 == cchFullPath || - !file_exists(fullPath)) - { - rc = RECLS_RC_INVALID_DIRECTORY; - } - else - { -#if defined(EMULATE_UNIX_ON_WIN32) - recls_char_t *_fullPath = fullPath; - recls_char_t *fullPath = _fullPath + 2; - - std::replace(fullPath, fullPath + cchFullPath, '\\', traits_type::path_name_separator()); -#endif /* EMULATE_UNIX_ON_WIN32 */ - - traits_type::ensure_dir_end(fullPath); - - size_t lenSearchRoot = traits_type::str_len(fullPath); - - recls_assert(0 < lenSearchRoot); - - rootDir = fullPath; - - // Count the directory parts. This is always done for the ReclsSearchInfo class, since it - // uses them to recurse. - char_type const *begin = rootDir; - char_type const *const end = rootDir + lenSearchRoot; - int cDirParts = count_dir_parts(begin, end); - -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - try - { -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - si = new(cDirParts, sizeof(char_type) * (1 + lenSearchRoot)) ReclsSearchInfo(cDirParts, rootDir, pattern, flags); -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - } - catch(std::bad_alloc &) - { - si = NULL; - } -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - - if(NULL == si) - { - rc = RECLS_RC_FAIL; - } - else - { - // This is a nasty hack. It's tantamount to ctor & create function, so - // should be made more elegant soon. - if(NULL == si->m_dnode) - { - delete si; - - si = NULL; - - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - *ppsi = si; - - rc = RECLS_RC_OK; - } - } - } - - return rc; -} - -ReclsSearchInfo::char_type const *ReclsSearchInfo::_calc_rootDir(int cDirParts, ReclsSearchInfo::char_type const *rootDir) -{ - function_scope_trace("ReclsSearchInfo::_calc_rootDir"); - - // Root dir is located after file parts, and before pattern - return traits_type::str_copy((char_type*)&data[cDirParts * sizeof(recls_strptrs_t)], rootDir); -} - -ReclsSearchInfo::ReclsSearchInfo( int cDirParts - , ReclsSearchInfo::char_type const *rootDir - , ReclsSearchInfo::char_type const *pattern - , recls_uint32_t flags) - : m_flags(flags) - , m_lastError(RECLS_RC_OK) - , m_rootDir(_calc_rootDir(cDirParts, rootDir)) -{ - function_scope_trace("ReclsSearchInfo::ReclsSearchInfo"); - - recls_assert(NULL != rootDir); - recls_assert(NULL != pattern); - recls_assert(traits_type::str_len(rootDir) < RECLS_PATH_MAX); - recls_assert(traits_type::str_len(pattern) < RECLS_PATH_MAX); - - // Initialise the directory parts. - - recls_assert(rootDir[1] != ':'); - -// char_type const *p = rootDir; -// struct recls_strptrs_t *begin = (struct recls_strptrs_t*)&data[0]; - - // Now start the search - m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, rootDir, pattern); -} - -// Operations -recls_rc_t ReclsSearchInfo::GetNext() -{ - function_scope_trace("ReclsSearchInfo::GetNext"); - - recls_assert(NULL != m_dnode); - - m_lastError = m_dnode->GetNext(); - - if(RECLS_RC_NO_MORE_DATA == m_lastError) - { - delete m_dnode; - - m_dnode = NULL; - } - - return m_lastError; -} - -recls_rc_t ReclsSearchInfo::GetDetails(recls_info_t *pinfo) -{ - function_scope_trace("ReclsSearchInfo::GetDetails"); - - recls_assert(NULL != m_dnode); - - return (m_lastError = m_dnode->GetDetails(pinfo)); -} - -recls_rc_t ReclsSearchInfo::GetNextDetails(recls_info_t *pinfo) -{ - function_scope_trace("ReclsSearchInfo::GetNextDetails"); - - recls_assert(NULL != m_dnode); - - m_lastError = m_dnode->GetNextDetails(pinfo); - - if(RECLS_RC_NO_MORE_DATA == m_lastError) - { - delete m_dnode; - } - - return m_lastError; -} - -// Accessors - -recls_rc_t ReclsSearchInfo::GetLastError() const -{ - function_scope_trace("ReclsSearchInfo::GetLastError"); - - return m_lastError; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Search control - */ - -RECLS_FNDECL(recls_rc_t) Recls_Search( recls_char_t const *searchRoot - , recls_char_t const *pattern - , recls_uint32_t flags - , hrecls_t *phSrch) -{ - function_scope_trace("Recls_Search"); - - recls_assert(NULL != searchRoot); - recls_assert(NULL != pattern); - recls_assert(NULL != phSrch); - - *phSrch = ReclsSearchInfo::ToHandle(NULL); - - recls_rc_t rc; - - // Validate the search root - if( NULL == searchRoot || - 0 == *searchRoot) - { - searchRoot = "."; - } - - // Validate the flags - if(0 == (flags & RECLS_F_TYPEMASK)) - { - flags |= RECLS_F_FILES; - } - - // Since Win32 does not support all search types, we need to inform - // the caller if they ask to create a search that can never be - // satisfied. - if(0 == (flags & (RECLS_F_FILES | RECLS_F_DIRECTORIES))) - { - rc = RECLS_RC_INVALID_SEARCH_TYPE; - } - // Validate the pattern. - else if('\0' == *pattern) - { - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - ReclsSearchInfo *si; - - rc = ReclsSearchInfo::FindAndCreate(searchRoot, pattern, flags, &si); - - if(RECLS_SUCCEEDED(rc)) - { - *phSrch = ReclsSearchInfo::ToHandle(si); - - rc = RECLS_RC_OK; - } - } - - return rc; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Error handling - */ - -RECLS_FNDECL(size_t) Recls_GetErrorString( recls_rc_t rc - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetErrorString"); - - recls_assert(NULL != buffer); - - if(rc == RECLS_RC_SEARCH_NO_CURRENT) - { - strncpy(buffer, "Search has no current node", cchBuffer); - } - else if(rc == RECLS_RC_INVALID_DIRECTORY) - { - strncpy(buffer, "Invalid directory", cchBuffer); - } - else if(rc == RECLS_RC_NO_MORE_DATA) - { - strncpy(buffer, "No more data", cchBuffer); - } - else if(rc == RECLS_RC_OUT_OF_MEMORY) - { - strncpy(buffer, "No more memory", cchBuffer); - } - - return strlen(buffer); -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Property elicitation - */ - -RECLS_FNDECL(size_t) Recls_GetDirectoryPathProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetDirectoryPathProperty"); - - recls_assert(NULL != fileInfo); - - struct recls_strptrs_t directoryPath = - { - fileInfo->path.begin /* Directory path is defined by start of path ... */ - , fileInfo->directory.end /* ... to end of directory. */ - }; - - return Recls_GetStringProperty_(&directoryPath, buffer, cchBuffer); -} - -RECLS_FNDECL(recls_bool_t) Recls_IsFileReadOnly(recls_info_t fileInfo) -{ - function_scope_trace("Recls_IsFileReadOnly"); - - recls_assert(NULL != fileInfo); - - return (fileInfo->attributes & S_IWRITE) == 0; -} - -RECLS_FNDECL(recls_bool_t) Recls_IsFileDirectory(recls_info_t fileInfo) -{ - function_scope_trace("Recls_IsFileDirectory"); - - recls_assert(NULL != fileInfo); - - return (fileInfo->attributes & S_IFMT) == S_IFDIR; -} - -RECLS_FNDECL(recls_bool_t) Recls_IsFileLink(recls_info_t fileInfo) -{ - function_scope_trace("Recls_IsFileLink"); - - recls_assert(NULL != fileInfo); - ((void)fileInfo); - - return false; -} - -RECLS_FNDECL(recls_time_t) Recls_GetCreationTime(recls_info_t fileInfo) -{ - function_scope_trace("Recls_GetCreationTime"); - - recls_assert(NULL != fileInfo); - - return fileInfo->modificationTime; -} - -RECLS_FNDECL(recls_time_t) Recls_GetLastStatusChangeTime(recls_info_t fileInfo) -{ - function_scope_trace("Recls_GetLastStatusChangeTime"); - - recls_assert(NULL != fileInfo); - - return fileInfo->lastStatusChangeTime; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_api_win32.cpp b/etc/c/recls/recls_api_win32.cpp deleted file mode 100644 index 7c22c5443d4..00000000000 --- a/etc/c/recls/recls_api_win32.cpp +++ /dev/null @@ -1,1053 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_api_win32.cpp - * - * Purpose: Win32 implementation file for the recls API. - * - * Created: 16th August 2003 - * Updated: 28th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" -#include "recls_util.h" - -#include - -#include -#include -#include - -#include -#include - -#include - -#include "recls_debug.h" - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -winstl_ns_using(basic_findfile_sequence) - -typedef winstl_ns_qual(filesystem_traits) traits_type; // We need to do this, because VC is a bit thick - -/* ///////////////////////////////////////////////////////////////////////////// - * Utility functions - */ - -#if defined(_DEBUG) - -/* static */ tls_index function_scope::sm_index; - -#endif /* _DEBUG */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -static recls_info_t create_entryinfo_from_psrecord(recls_char_t const *rootDir, recls_uint32_t flags, WIN32_FIND_DATA const &findData) -{ - typedef recls_char_t char_type; - - function_scope_trace("create_entryinfo_from_psrecord"); - - // size of structure is: - // - // offsetof(struct recls_fileinfo_t, data) - // + directory parts - // + full path (+ null) - // + short name (+ null) - - size_t cchRootDir = traits_type::str_len(rootDir); - - recls_assert(cchRootDir > 0); - recls_assert(rootDir[cchRootDir - 1] == traits_type::path_name_separator()); - - size_t cchFileName = traits_type::str_len(findData.cFileName); - size_t cDirParts = ((flags & RECLS_F_DIRECTORY_PARTS) == RECLS_F_DIRECTORY_PARTS) ? count_dir_parts(rootDir + 2, rootDir + cchRootDir) : 0; - size_t cbPath = align_up_size(sizeof(char_type) * (1 + cchRootDir + cchFileName)); - size_t cbAlt = align_up_size(sizeof(char_type) * (1 + RECLS_NUM_ELEMENTS(findData.cAlternateFileName))); - size_t cb = offsetof(struct recls_fileinfo_t, data) - + cDirParts * sizeof(recls_strptrs_t) - + cbPath - + cbAlt; - - struct recls_fileinfo_t *info = const_cast(FileInfo_Allocate(cb)); - - if(NULL != info) - { - char_type *fullPath = (char_type*)&info->data[cDirParts * sizeof(recls_strptrs_t)]; - char_type *altName = (char_type*)&info->data[cDirParts * sizeof(recls_strptrs_t) + cbPath]; - - // full path - traits_type::str_copy(fullPath, rootDir); - traits_type::str_cat(fullPath, findData.cFileName); - info->path.begin = fullPath; - info->path.end = fullPath + cchRootDir + cchFileName; - - // drive, directory, file (name + ext) - info->drive = fullPath[0]; - info->directory.begin = fullPath + 2; - info->directory.end = fullPath + cchRootDir; - info->fileName.begin = info->directory.end; - info->fileName.end = strrchr(info->directory.end, '.'); - if(NULL != info->fileName.end) - { - info->fileExt.begin = info->fileName.end + 1; - info->fileExt.end = info->directory.end + cchFileName; - } - else - { - info->fileName.end = info->directory.end + cchFileName; - info->fileExt.begin = info->directory.end + cchFileName; - info->fileExt.end = info->directory.end + cchFileName; - } - - // determine the directory parts - char_type const *p = info->directory.begin; - char_type const *l = info->directory.end; - struct recls_strptrs_t *begin = (struct recls_strptrs_t*)&info->data[0]; - - info->directoryParts.begin = begin; - info->directoryParts.end = begin + cDirParts; - - if(info->directoryParts.begin != info->directoryParts.end) - { - recls_assert((flags & RECLS_F_DIRECTORY_PARTS) == RECLS_F_DIRECTORY_PARTS); - - begin->begin = p; - - for(; p != l; ++p) - { - if(*p == traits_type::path_name_separator()) - { - begin->end = p + 1; - - if(++begin != info->directoryParts.end) - { - begin->begin = p + 1; - } - } - } - } - - // alt name - traits_type::str_copy(altName, findData.cAlternateFileName); - info->shortFile.begin = altName; - info->shortFile.end = altName + traits_type::str_len(altName); - - // attributes - info->attributes = findData.dwFileAttributes; - - // time, size - info->creationTime = findData.ftCreationTime; - info->modificationTime = findData.ftLastWriteTime; - info->lastAccessTime = findData.ftLastAccessTime; - info->size.u.HighPart = findData.nFileSizeHigh; - info->size.u.LowPart = findData.nFileSizeLow; - - // Checks - recls_assert(info->path.begin < info->path.end); - - recls_assert(info->directory.begin < info->directory.end); - recls_assert(info->path.begin <= info->directory.begin); - recls_assert(info->directory.end <= info->path.end); - - recls_assert(info->fileName.begin <= info->fileName.end); - - recls_assert(info->fileExt.begin <= info->fileExt.end); - - recls_assert(info->fileName.begin < info->fileExt.end); - recls_assert(info->fileName.end <= info->fileExt.begin); - } - - return info; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * PlatformDirectoryNode - */ - -class PlatformDirectoryNode - : public ReclsDNode -{ -public: - typedef recls_char_t char_type; - typedef PlatformDirectoryNode class_type; -private: - typedef basic_findfile_sequence directory_sequence_t; - typedef basic_findfile_sequence entry_sequence_t; - -// Construction -private: - PlatformDirectoryNode(recls_uint32_t flags, char_type const *rootDir, char_type const *pattern); -public: - virtual ~PlatformDirectoryNode(); - - static PlatformDirectoryNode *FindAndCreate(recls_uint32_t flags, char_type const *rootDir, char_type const *pattern); - static PlatformDirectoryNode *FindAndCreate(recls_uint32_t flags, char_type const *rootDir, char_type const *subDir, char_type const *pattern); - -// ReclsDNode methods -private: - virtual recls_rc_t GetNext(); - virtual recls_rc_t GetDetails(recls_info_t *pinfo); - virtual recls_rc_t GetNextDetails(recls_info_t *pinfo); - -// Implementation -private: - recls_rc_t Initialise(); - - recls_bool_t _is_valid() const; - -#if defined(RECLS_COMPILER_IS_BORLAND) - static directory_sequence_t::const_iterator _select_iter(int b, directory_sequence_t::const_iterator trueVal, directory_sequence_t::const_iterator falseVal) - { - // I can't explain it, but Borland does not like the tertiary operator and the copy-ctors of the iterators - if(b) - { - return trueVal; - } - else - { - return falseVal; - } - } -#endif /* !RECLS_COMPILER_IS_BORLAND */ - static int _ssFlags_from_reclsFlags(recls_uint32_t flags) - { - recls_assert(0 == (flags & RECLS_F_LINKS)); // Doesn't work with links - recls_assert(0 == (flags & RECLS_F_DEVICES)); // Doesn't work with devices - - int ssFlags = 0; - - if(0 != (flags & RECLS_F_FILES)) - { - ssFlags |= entry_sequence_t::files; - } - if(0 != (flags & RECLS_F_DIRECTORIES)) - { - ssFlags |= entry_sequence_t::directories; - } - - return ssFlags; - } - -// Members -private: - recls_info_t m_current; - ReclsDNode *m_dnode; - recls_uint32_t const m_flags; - entry_sequence_t m_entries; - entry_sequence_t::const_iterator m_entriesBegin; - directory_sequence_t m_directories; - directory_sequence_t::const_iterator m_directoriesBegin; - char_type m_rootDir[RECLS_PATH_MAX]; - char_type m_pattern[RECLS_PATH_MAX]; -}; - -PlatformDirectoryNode::PlatformDirectoryNode(recls_uint32_t flags, PlatformDirectoryNode::char_type const *rootDir, PlatformDirectoryNode::char_type const *pattern) - : m_current(NULL) - , m_dnode(NULL) - , m_flags(flags) - , m_entries(rootDir, pattern, _ssFlags_from_reclsFlags(flags)) - , m_entriesBegin(m_entries.begin()) - , m_directories(rootDir, traits_type::pattern_all(), directory_sequence_t::directories) -#if !defined(RECLS_COMPILER_IS_BORLAND) - , m_directoriesBegin((flags & RECLS_F_RECURSIVE) ? m_directories.begin() : m_directories.end()) -#else - , m_directoriesBegin(_select_iter((flags & RECLS_F_RECURSIVE), m_directories.begin(), m_directories.end())) -#endif /* !RECLS_COMPILER_IS_BORLAND */ -{ - function_scope_trace("PlatformDirectoryNode::PlatformDirectoryNode"); - -#if defined(RECLS_COMPILER_IS_BORLAND) -// m_directoriesBegin = ((flags & RECLS_F_RECURSIVE) ? m_directories.begin() : m_directories.end()); -#endif /* !RECLS_COMPILER_IS_BORLAND */ - - traits_type::str_copy(m_rootDir, rootDir); - traits_type::ensure_dir_end(m_rootDir); - traits_type::str_copy(m_pattern, pattern); - - recls_assert(stlsoft_raw_offsetof(PlatformDirectoryNode, m_entries) < stlsoft_raw_offsetof(PlatformDirectoryNode, m_entriesBegin)); - recls_assert(stlsoft_raw_offsetof(PlatformDirectoryNode, m_directories) < stlsoft_raw_offsetof(PlatformDirectoryNode, m_directoriesBegin)); -} - -inline /* static */ PlatformDirectoryNode *PlatformDirectoryNode::FindAndCreate(recls_uint32_t flags, PlatformDirectoryNode::char_type const *rootDir, PlatformDirectoryNode::char_type const *pattern) -{ - PlatformDirectoryNode *node; - - function_scope_trace("PlatformDirectoryNode::FindAndCreate"); - -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - try - { -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - node = new PlatformDirectoryNode(flags, rootDir, pattern); -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - } - catch(std::bad_alloc &) - { - node = NULL; - } -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - - if(NULL != node) - { - // Ensure that it, or one of its sub-nodes, has matching entries. - recls_rc_t rc = node->Initialise(); - - if(RECLS_FAILED(rc)) - { - delete node; - - node = NULL; - } - } - - recls_assert(NULL == node || node->_is_valid()); - - return node; -} - -inline /* static */ PlatformDirectoryNode *PlatformDirectoryNode::FindAndCreate(recls_uint32_t flags, PlatformDirectoryNode::char_type const *rootDir, PlatformDirectoryNode::char_type const *subDir, PlatformDirectoryNode::char_type const *pattern) -{ - char_type compositeDir[RECLS_PATH_MAX]; - - recls_assert(rootDir[traits_type::str_len(rootDir) - 1] == traits_type::path_name_separator()); - - traits_type::str_copy(compositeDir, rootDir); - traits_type::str_cat(compositeDir, subDir); - - return FindAndCreate(flags, compositeDir, pattern); -} - -PlatformDirectoryNode::~PlatformDirectoryNode() -{ - function_scope_trace("PlatformDirectoryNode::~PlatformDirectoryNode"); - - FileInfo_Release(m_current); - - delete m_dnode; -} - -recls_rc_t PlatformDirectoryNode::Initialise() -{ - function_scope_trace("PlatformDirectoryNode::Initialise"); - - recls_rc_t rc; - - recls_assert(NULL == m_current); - recls_assert(NULL == m_dnode); - - if(m_entriesBegin != m_entries.end()) - { - // (i) Try getting a file first, - m_current = create_entryinfo_from_psrecord(m_rootDir, m_flags, (*m_entriesBegin).get_find_data()); - - if(NULL == m_current) - { - rc = RECLS_RC_OUT_OF_MEMORY; - } - else - { - rc = RECLS_RC_OK; - } - } - else - { - if(m_directoriesBegin == m_directories.end()) - { - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - do - { -#if 0 -// m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, m_rootDir, (*m_directoriesBegin, m_pattern); -#else /* ? 0 */ - // The way basic_findfile_sequence<> works - m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, (*m_directoriesBegin).get_path(), m_pattern); -#endif /* 0 */ - - } while(NULL == m_dnode && ++m_directoriesBegin != m_directories.end()); - - rc = (NULL == m_dnode) ? RECLS_RC_NO_MORE_DATA : RECLS_RC_OK; - } - } - - if(RECLS_SUCCEEDED(rc)) - { - recls_assert(_is_valid()); - } - - return rc; -} - -recls_bool_t PlatformDirectoryNode::_is_valid() const -{ - function_scope_trace("PlatformDirectoryNode::_is_valid"); - - recls_rc_t rc = RECLS_RC_OK; - -#ifdef STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT -# pragma message("Flesh these out") -#endif /* STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT */ - if(RECLS_SUCCEEDED(rc)) - { - - } - - if(RECLS_SUCCEEDED(rc)) - { - } - - if(RECLS_SUCCEEDED(rc)) - { - } - - if(RECLS_SUCCEEDED(rc)) - { - } - - // (i) Either we are enumerating files (m_current != NULL) or directories (m_dnode != NULL), but not both - recls_assert(NULL == m_current || NULL == m_dnode); - // (ii) Either we are enumerating files (m_current != NULL) or there are no more files to enumerate - recls_assert(NULL != m_current || m_entriesBegin == m_entries.end()); - - return RECLS_SUCCEEDED(rc); -} - - -recls_rc_t PlatformDirectoryNode::GetNext() -{ - function_scope_trace("PlatformDirectoryNode::GetNext"); - - recls_assert(_is_valid()); - - /* Searching operates as follows: - * - * 1. Return all the contents of the files - * 2. Return the contents of the directories. - * - * Hence, if m_dnode is non-NULL, we've already searched - */ - - /* States: - * - * - Iterating files: m_entriesBegin != m_entries.end(), m_dnode is NULL, m_directoriesBegin != m_directories.end() - * - Iterating directories: m_directoriesBegin != m_directories.end(), m_dnode is non-NULL, m_current is NULL - * - */ - - // Invariants - - // (i) Either we are enumerating files (m_current != NULL) or directories (m_dnode != NULL), but not both - recls_assert(NULL == m_current || NULL == m_dnode); - // (ii) Either we are enumerating files (m_current != NULL) or there are no more files to enumerate - recls_assert(NULL != m_current || m_entriesBegin == m_entries.end()); - - recls_rc_t rc = RECLS_RC_NO_MORE_DATA; - - if(NULL != m_current) - { - // Currently enumerating through the files - - recls_assert(m_entriesBegin != m_entries.end()); - recls_assert(NULL == m_dnode); - - // Advance, and check for end of sequence - ++m_entriesBegin; - - FileInfo_Release(m_current); - if(m_entriesBegin != m_entries.end()) - { - // Still enumerating, so just update m_current - m_current = create_entryinfo_from_psrecord(m_rootDir, m_flags, (*m_entriesBegin).get_find_data()); - - rc = RECLS_RC_OK; - } - else - { - // No more left in the files sequence, so delete m_current - m_current = NULL; - - rc = RECLS_RC_NO_MORE_DATA; - } - } - - if(NULL == m_current) - { - // Now we are either enumerating the directories, or we've already done so - - if(NULL != m_dnode) - { - // Currently enumerating the directories - rc = m_dnode->GetNext(); - - if(RECLS_RC_NO_MORE_DATA == rc) - { - ++m_directoriesBegin; - - delete m_dnode; - - m_dnode = NULL; - } - } - - if(m_directoriesBegin == m_directories.end()) - { - // Enumeration is complete. - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - if(NULL == m_dnode) - { - do - { - // Creation of the node will cause it to enter the first enumeration - // state. However, if there are no matching - - recls_assert(m_directoriesBegin != m_directories.end()); - -#if 0 -// m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, m_rootDir, *m_directoriesBegin, m_pattern); -#else /* ? 0 */ - // The way basic_findfile_sequence<> works - m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, (*m_directoriesBegin).get_path(), m_pattern); -#endif /* 0 */ - - if(NULL != m_dnode) - { - rc = RECLS_RC_OK; - } - else - { - ++m_directoriesBegin; - } - - } while(NULL == m_dnode && m_directoriesBegin != m_directories.end()); - } - } - } - - recls_assert(_is_valid()); - - return rc; -} - -recls_rc_t PlatformDirectoryNode::GetDetails(recls_info_t *pinfo) -{ - function_scope_trace("PlatformDirectoryNode::GetDetails"); - - recls_assert(_is_valid()); - - recls_rc_t rc; - - recls_assert(NULL != pinfo); - recls_assert(NULL == m_current || NULL == m_dnode); - - if(NULL != m_current) - { - // Currently searching for files from the current directory - - recls_assert(NULL == m_dnode); - - rc = FileInfo_Copy(m_current, pinfo); - -#ifdef _DEBUG - { - recls_char_t buffer[RECLS_PATH_MAX]; - - Recls_GetPathProperty(m_current, buffer, stlsoft_num_elements(buffer)); - - debug_printf(" [%s]\n", buffer); - } -#endif /* _DEBUG */ - } - else if(NULL != m_dnode) - { - recls_assert(NULL == m_current); - - // Sub-directory searching is active, so get from there. - - rc = m_dnode->GetDetails(pinfo); - } - else - { - // Enumeration has completed - rc = RECLS_RC_NO_MORE_DATA; - } - - recls_assert(_is_valid()); - - return rc; -} - -recls_rc_t PlatformDirectoryNode::GetNextDetails(recls_info_t *pinfo) -{ - function_scope_trace("PlatformDirectoryNode::GetNextDetails"); - - recls_assert(_is_valid()); - recls_assert(NULL != pinfo); - - recls_rc_t rc = GetNext(); - - if(RECLS_SUCCEEDED(rc)) - { - rc = GetDetails(pinfo); - } - - recls_assert(_is_valid()); - - return rc; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * ReclsSearchInfo - */ - -void *ReclsSearchInfo::operator new(size_t cb, int cDirParts, size_t cbRootDir) -{ - function_scope_trace("ReclsSearchInfo::operator new"); - - cbRootDir = align_up_size(cbRootDir); - - recls_assert(cb > stlsoft_raw_offsetof(ReclsSearchInfo, data)); - - cb = stlsoft_raw_offsetof(ReclsSearchInfo, data) - + (cDirParts) * sizeof(recls_strptrs_t) - + cbRootDir; - - return malloc(cb); -} - -#if !defined(RECLS_COMPILER_IS_BORLAND) && \ - !defined(RECLS_COMPILER_IS_DMC) && \ - !defined(RECLS_COMPILER_IS_INTEL) && \ - !defined(RECLS_COMPILER_IS_WATCOM) -void ReclsSearchInfo::operator delete(void *pv, int /* cDirParts */, size_t /* cbRootDir */) -{ - function_scope_trace("ReclsSearchInfo::operator delete"); - - free(pv); -} -#endif /* !RECLS_COMPILER_IS_BORLAND && !RECLS_COMPILER_IS_DMC */ - -void ReclsSearchInfo::operator delete(void *pv) -{ - function_scope_trace("ReclsSearchInfo::operator delete"); - - free(pv); -} - -inline /* static */ recls_rc_t ReclsSearchInfo::FindAndCreate(ReclsSearchInfo::char_type const *rootDir, ReclsSearchInfo::char_type const *pattern, recls_uint32_t flags, ReclsSearchInfo **ppsi) -{ - function_scope_trace("ReclsSearchInfo::FindAndCreate"); - - recls_rc_t rc; - ReclsSearchInfo *si; - char_type fullPath[RECLS_PATH_MAX]; - size_t cchFullPath; - - *ppsi = NULL; - - cchFullPath = traits_type::get_full_path_name(rootDir, RECLS_NUM_ELEMENTS(fullPath), fullPath); - if( 0 == cchFullPath || - !file_exists(fullPath)) - { - rc = RECLS_RC_INVALID_DIRECTORY; - } - else - { - traits_type::ensure_dir_end(fullPath); - - size_t lenSearchRoot = traits_type::str_len(fullPath); - - recls_assert(0 < lenSearchRoot); - - rootDir = fullPath; - - // Count the directory parts. This is always done for the ReclsSearchInfo class, since it - // uses them to recurse. - char_type const *begin = rootDir + 2; - char_type const *const end = rootDir + lenSearchRoot; - int cDirParts = count_dir_parts(begin, end); - -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - try - { -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - si = new(cDirParts, sizeof(char_type) * (1 + lenSearchRoot)) ReclsSearchInfo(cDirParts, rootDir, pattern, flags); -#ifdef RECLS_COMPILER_THROWS_ON_NEW_FAIL - } - catch(std::bad_alloc &) - { - si = NULL; - } -#endif /* RECLS_COMPILER_THROWS_ON_NEW_FAIL */ - - if(NULL == si) - { - rc = RECLS_RC_FAIL; - } - else - { - // This is a nasty hack. It's tantamount to ctor & create function, so - // should be made more elegant soon. - if(NULL == si->m_dnode) - { - delete si; - - si = NULL; - - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - *ppsi = si; - - rc = RECLS_RC_OK; - } - } - } - - return rc; -} - -ReclsSearchInfo::char_type const *ReclsSearchInfo::_calc_rootDir(int cDirParts, ReclsSearchInfo::char_type const *rootDir) -{ - function_scope_trace("ReclsSearchInfo::_calc_rootDir"); - - // Root dir is located after file parts, and before pattern - return traits_type::str_copy((char_type*)&data[cDirParts * sizeof(recls_strptrs_t)], rootDir); -} - -ReclsSearchInfo::ReclsSearchInfo( int cDirParts - , ReclsSearchInfo::char_type const *rootDir - , ReclsSearchInfo::char_type const *pattern - , recls_uint32_t flags) - : m_flags(flags) - , m_lastError(RECLS_RC_OK) - , m_rootDir(_calc_rootDir(cDirParts, rootDir)) -{ - function_scope_trace("ReclsSearchInfo::ReclsSearchInfo"); - - recls_assert(NULL != rootDir); - recls_assert(NULL != pattern); - recls_assert(traits_type::str_len(rootDir) < RECLS_PATH_MAX); - recls_assert(traits_type::str_len(pattern) < RECLS_PATH_MAX); - - // Initialise the directory parts. - - recls_assert(rootDir[1] == ':'); - -// char_type const *p = rootDir + 2; -// struct recls_strptrs_t *begin = (struct recls_strptrs_t*)&data[0]; - - // Now start the search - m_dnode = PlatformDirectoryNode::FindAndCreate(m_flags, rootDir, pattern); -} - -// Operations -recls_rc_t ReclsSearchInfo::GetNext() -{ - function_scope_trace("ReclsSearchInfo::GetNext"); - - recls_assert(NULL != m_dnode); - - m_lastError = m_dnode->GetNext(); - - if(RECLS_RC_NO_MORE_DATA == m_lastError) - { - delete m_dnode; - - m_dnode = NULL; - } - - return m_lastError; -} - -recls_rc_t ReclsSearchInfo::GetDetails(recls_info_t *pinfo) -{ - function_scope_trace("ReclsSearchInfo::GetDetails"); - - recls_assert(NULL != m_dnode); - - return (m_lastError = m_dnode->GetDetails(pinfo)); -} - -recls_rc_t ReclsSearchInfo::GetNextDetails(recls_info_t *pinfo) -{ - function_scope_trace("ReclsSearchInfo::GetNextDetails"); - - recls_assert(NULL != m_dnode); - - m_lastError = m_dnode->GetNextDetails(pinfo); - - if(RECLS_RC_NO_MORE_DATA == m_lastError) - { - delete m_dnode; - } - - return m_lastError; -} - -// Accessors - -recls_rc_t ReclsSearchInfo::GetLastError() const -{ - function_scope_trace("ReclsSearchInfo::GetLastError"); - - return m_lastError; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Search control - */ - -RECLS_FNDECL(recls_rc_t) Recls_Search( recls_char_t const *searchRoot - , recls_char_t const *pattern - , recls_uint32_t flags - , hrecls_t *phSrch) -{ - function_scope_trace("Recls_Search"); - - recls_assert(NULL != searchRoot); - recls_assert(NULL != pattern); - recls_assert(NULL != phSrch); - - *phSrch = ReclsSearchInfo::ToHandle(NULL); - - recls_rc_t rc; - - // Validate the search root - if( NULL == searchRoot || - 0 == *searchRoot) - { - searchRoot = "."; - } - - // Validate the flags - if(0 == (flags & RECLS_F_TYPEMASK)) - { - flags |= RECLS_F_FILES; - } - - // Since Win32 does not support all search types, we need to inform - // the caller if they ask to create a search that can never be - // satisfied. - if(0 == (flags & (RECLS_F_FILES | RECLS_F_DIRECTORIES))) - { - rc = RECLS_RC_INVALID_SEARCH_TYPE; - } - // Validate the pattern. - else if('\0' == *pattern) - { - rc = RECLS_RC_NO_MORE_DATA; - } - else - { - ReclsSearchInfo *si; - - rc = ReclsSearchInfo::FindAndCreate(searchRoot, pattern, flags, &si); - - if(RECLS_SUCCEEDED(rc)) - { - *phSrch = ReclsSearchInfo::ToHandle(si); - - rc = RECLS_RC_OK; - } - } - - return rc; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Error handling - */ - -RECLS_FNDECL(size_t) Recls_GetErrorString( recls_rc_t rc - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetErrorString"); - - recls_assert(NULL != buffer); - - if(rc == RECLS_RC_SEARCH_NO_CURRENT) - { - strncpy(buffer, "Search has no current node", cchBuffer); - } - else if(rc == RECLS_RC_INVALID_DIRECTORY) - { - strncpy(buffer, "Invalid directory", cchBuffer); - } - else if(rc == RECLS_RC_NO_MORE_DATA) - { - strncpy(buffer, "No more data", cchBuffer); - } - else if(rc == RECLS_RC_OUT_OF_MEMORY) - { - strncpy(buffer, "No more memory", cchBuffer); - } - - return strlen(buffer); -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Property elicitation - */ - -RECLS_FNDECL(size_t) Recls_GetDirectoryPathProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetDirectoryPathProperty"); - - recls_assert(NULL != fileInfo); - - struct recls_strptrs_t directoryPath = - { - fileInfo->path.begin /* Directory path is defined by start of path ... */ - , fileInfo->directory.end /* ... to end of directory. */ - }; - - return Recls_GetStringProperty_(&directoryPath, buffer, cchBuffer); -} - -RECLS_FNDECL(size_t) Recls_GetShortFileProperty( recls_info_t fileInfo - , recls_char_t *buffer - , size_t cchBuffer) -{ - function_scope_trace("Recls_GetShortFileProperty"); - - recls_assert(NULL != fileInfo); - - return Recls_GetStringProperty_(&fileInfo->shortFile, buffer, cchBuffer); -} - -RECLS_FNDECL(void) Recls_GetDriveProperty( recls_info_t fileInfo - , recls_char_t *pchDrive) -{ - function_scope_trace("Recls_GetDriveProperty"); - - recls_assert(NULL != fileInfo); - recls_assert(NULL != pchDrive); - - *pchDrive = (recls_char_t)toupper(*fileInfo->path.begin); -} - -RECLS_FNDECL(recls_bool_t) Recls_IsFileReadOnly(recls_info_t fileInfo) -{ - function_scope_trace("Recls_IsFileReadOnly"); - - recls_assert(NULL != fileInfo); - - return fileInfo->attributes & FILE_ATTRIBUTE_READONLY; -} - -RECLS_FNDECL(recls_bool_t) Recls_IsFileDirectory(recls_info_t fileInfo) -{ - function_scope_trace("Recls_IsFileDirectory"); - - recls_assert(NULL != fileInfo); - - return fileInfo->attributes & FILE_ATTRIBUTE_DIRECTORY; -} - -RECLS_FNDECL(recls_bool_t) Recls_IsFileLink(recls_info_t fileInfo) -{ - function_scope_trace("Recls_IsFileLink"); - - recls_assert(NULL != fileInfo); - ((void)fileInfo); - - return false; -} - -RECLS_FNDECL(recls_time_t) Recls_GetCreationTime(recls_info_t fileInfo) -{ - function_scope_trace("Recls_GetCreationTime"); - - recls_assert(NULL != fileInfo); - - return fileInfo->creationTime; -} - -RECLS_FNDECL(recls_time_t) Recls_GetLastStatusChangeTime(recls_info_t fileInfo) -{ - function_scope_trace("Recls_GetLastStatusChangeTime"); - - recls_assert(NULL != fileInfo); - - return fileInfo->modificationTime; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_assert.h b/etc/c/recls/recls_assert.h deleted file mode 100644 index af7135029b5..00000000000 --- a/etc/c/recls/recls_assert.h +++ /dev/null @@ -1,128 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_assert.h - * - * Purpose: Compiler discrimination for the recls API. - * - * Created: 15th August 2003 - * Updated: 2nd November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_ASSERT -#define RECLS_INCL_H_RECLS_ASSERT - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_ASSERT_MAJOR 1 -# define RECLS_VER_H_RECLS_ASSERT_MINOR 0 -# define RECLS_VER_H_RECLS_ASSERT_REVISION 6 -# define RECLS_VER_H_RECLS_ASSERT_EDIT 6 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_assert.h Assertions for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" - -/** \def recls_assert Assert macro for the recls API - * - * \param x The expression that must evaluate to \c true - */ - -#if defined(RECLS_PLATFORM_IS_WIN32) && \ - defined(_MSC_VER) -# include // Prefer MSVCRT for VC++ and compatible compilers -# define recls_assert(x) _ASSERTE(x) -#else -# include -# define recls_assert(x) assert(x) -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Macros - */ - -/** \def recls_message_assert Assert macro for the recls API - * - * \param m The literal string describing the failed condition - * \param x The expression that must evaluate to \c true - */ - -#if defined(__WATCOMC__) - #define recls_message_assert(m, ) recls_assert(x) -#else - #define recls_message_assert(m, x) recls_assert((m, x)) -#endif /* __WATCOMC__ */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_ASSERT */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_compiler.h b/etc/c/recls/recls_compiler.h deleted file mode 100644 index 7ca0084975d..00000000000 --- a/etc/c/recls/recls_compiler.h +++ /dev/null @@ -1,202 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_compiler.h - * - * Purpose: Compiler discrimination for the recls API. - * - * Created: 15th August 2003 - * Updated: 23rd September 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_COMPILER -#define RECLS_INCL_H_RECLS_COMPILER - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_COMPILER_MAJOR 1 -# define RECLS_VER_H_RECLS_COMPILER_MINOR 0 -# define RECLS_VER_H_RECLS_COMPILER_REVISION 6 -# define RECLS_VER_H_RECLS_COMPILER_EDIT 6 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_compiler.h Compiler detection for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler detection - */ - -#if defined(__BORLANDC__) -# define RECLS_COMPILER_IS_BORLAND -#elif defined(__DMC__) -# define RECLS_COMPILER_IS_DMC -#elif defined(__GNUC__) -# define RECLS_COMPILER_IS_GCC -#elif defined(__INTEL_COMPILER) -# define RECLS_COMPILER_IS_INTEL -#elif defined(__MWERKS__) -# define RECLS_COMPILER_IS_MWERKS -#elif defined(__WATCOMC__) -# define RECLS_COMPILER_IS_WATCOM -#elif defined(_MSC_VER) -# define RECLS_COMPILER_IS_MSVC -#else -# error Compiler not recognised -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#if defined(RECLS_COMPILER_IS_BORLAND) -# include "recls_compiler_borland.h" -#elif defined(RECLS_COMPILER_IS_DMC) -# include "recls_compiler_dmc.h" -#elif defined(RECLS_COMPILER_IS_GCC) -# include "recls_compiler_gcc.h" -#elif defined(RECLS_COMPILER_IS_INTEL) -# include "recls_compiler_intel.h" -#elif defined(RECLS_COMPILER_IS_MWERKS) -# include "recls_compiler_mwerks.h" -#elif defined(RECLS_COMPILER_IS_WATCOM) -# include "recls_compiler_watcom.h" -#elif defined(RECLS_COMPILER_IS_MSVC) -# include "recls_compiler_msvc.h" -#else -# error Compiler not recognised. recls recognises Borland, CodeWarrior, Digital Mars, GCC, Intel, Visual C++ and Watcom. -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Calling convention - */ - -/** \def RECLS_CALLCONV_NULL Unspecified calling convention for the \c recls API */ -/** \def RECLS_CALLCONV_CDECL \c cdecl calling convention for the \c recls API */ -/** \def RECLS_CALLCONV_STDDECL \c stdcall calling convention for the \c recls API */ -/** \def RECLS_CALLCONV_FASTDECL \c fastcall calling convention for the \c recls API */ -/** \def RECLS_CALLCONV_DEFAULT Default calling convention for the \c recls API */ - -#define RECLS_CALLCONV_NULL -#ifdef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_CALLCONV_CDECL -# define RECLS_CALLCONV_STDDECL -# define RECLS_CALLCONV_FASTDECL -# define RECLS_CALLCONV_DEFAULT -#elif defined(RECLS_PLATFORM_IS_WIN32) -# define RECLS_CALLCONV_CDECL __cdecl -# define RECLS_CALLCONV_STDDECL __stdcall -# define RECLS_CALLCONV_FASTDECL __fastcall -# define RECLS_CALLCONV_DEFAULT __stdcall -#elif defined(RECLS_PLATFORM_IS_WIN16) -# define RECLS_CALLCONV_CDECL _cdecl -# define RECLS_CALLCONV_STDDECL _pascal -# define RECLS_CALLCONV_FASTDECL _pascal -# define RECLS_CALLCONV_DEFAULT _pascal -#elif defined(RECLS_PLATFORM_IS_UNIX) -# define RECLS_CALLCONV_CDECL -# define RECLS_CALLCONV_STDDECL -# define RECLS_CALLCONV_FASTDECL -# define RECLS_CALLCONV_DEFAULT -#else -# error Platform not recognised -#endif /* __SYNSOFT_VAL_OS_WIN16 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/** \def recls_bool_t The boolean type of the \c recls API */ -typedef unsigned int recls_bool_t; - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace typedefs - */ - -#if !defined(RECLS_NO_NAMESPACE) -typedef recls_sint8_t sint8_t; -typedef recls_uint8_t uint8_t; - -typedef recls_sint16_t sint16_t; -typedef recls_uint16_t uint16_t; - -typedef recls_sint32_t sint32_t; -typedef recls_uint32_t uint32_t; - -typedef recls_sint64_t sint64_t; -typedef recls_uint64_t uint64_t; - -typedef recls_bool_t bool_t; -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_COMPILER */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_compiler_dmc.h b/etc/c/recls/recls_compiler_dmc.h deleted file mode 100644 index 52ed5a58780..00000000000 --- a/etc/c/recls/recls_compiler_dmc.h +++ /dev/null @@ -1,137 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_compiler_dmc.h - * - * Purpose: Digital Mars specific types and includes for the recls API. - * - * Created: 17th August 2003 - * Updated: 2nd November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#if !defined(RECLS_INCL_H_RECLS_COMPILER) && \ - !defined(RECLS_DOCUMENTATION_SKIP_SECTION) -# error recls_compiler_dmc.h cannot be included directly. Include recls.h -#else - -#ifndef RECLS_COMPILER_IS_DMC -# error recls_compiler_dmc.h can only be used for Digital Mars compiler builds -#endif /* !RECLS_COMPILER_IS_DMC */ - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_COMPILER_DMC_MAJOR 1 -# define RECLS_VER_H_RECLS_COMPILER_DMC_MINOR 1 -# define RECLS_VER_H_RECLS_COMPILER_DMC_REVISION 1 -# define RECLS_VER_H_RECLS_COMPILER_DMC_EDIT 4 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_compiler_dmc.h Digital Mars C/C++-specific compiler definitions for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/** \def recls_byte_t The byte type for the \ref group_recls API */ -/** \def recls_sint8_t The 8-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint8_t The 8-bit unsigned integer type for the \ref group_recls API */ -/** \def recls_sint16_t The 16-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint16_t The 16-bit unsigned integer type for the \ref group_recls API */ -/** \def recls_sint32_t The 32-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint32_t The 32-bit unsigned integer type for the \ref group_recls API */ -/** \def recls_sint64_t The 64-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint64_t The 64-bit unsigned integer type for the \ref group_recls API */ - -typedef unsigned char recls_byte_t; - -typedef signed char recls_sint8_t; -typedef unsigned char recls_uint8_t; - -typedef signed short recls_sint16_t; -typedef unsigned short recls_uint16_t; - -typedef signed long recls_sint32_t; -typedef unsigned long recls_uint32_t; - -typedef signed __int64 recls_sint64_t; -typedef unsigned __int64 recls_uint64_t; - -/** \def recls_char_a_t The ANSI character type for the \ref group_recls API */ -/** \def recls_char_w_t The Unicode character type for the \ref group_recls API */ -typedef char recls_char_a_t; -typedef wchar_t recls_char_w_t; - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* RECLS_INCL_H_RECLS_COMPILER */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_compiler_gcc.h b/etc/c/recls/recls_compiler_gcc.h deleted file mode 100644 index 4a3bbe805d2..00000000000 --- a/etc/c/recls/recls_compiler_gcc.h +++ /dev/null @@ -1,137 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_compiler_gcc.h - * - * Purpose: Digital Mars specific types and includes for the recls API. - * - * Created: 17th August 2003 - * Updated: 2nd November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#if !defined(RECLS_INCL_H_RECLS_COMPILER) && \ - !defined(RECLS_DOCUMENTATION_SKIP_SECTION) -# error recls_compiler_gcc.h cannot be included directly. Include recls.h -#else - -#ifndef RECLS_COMPILER_IS_GCC -# error recls_compiler_gcc.h can only be used for GCC compiler builds -#endif /* !RECLS_COMPILER_IS_GCC */ - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_COMPILER_GCC_MAJOR 1 -# define RECLS_VER_H_RECLS_COMPILER_GCC_MINOR 1 -# define RECLS_VER_H_RECLS_COMPILER_GCC_REVISION 1 -# define RECLS_VER_H_RECLS_COMPILER_GCC_EDIT 4 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_compiler_gcc.h GCC-specific compiler definitions for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/** \def recls_byte_t The byte type for the \ref group_recls API */ -/** \def recls_sint8_t The 8-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint8_t The 8-bit unsigned integer type for the \ref group_recls API */ -/** \def recls_sint16_t The 16-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint16_t The 16-bit unsigned integer type for the \ref group_recls API */ -/** \def recls_sint32_t The 32-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint32_t The 32-bit unsigned integer type for the \ref group_recls API */ -/** \def recls_sint64_t The 64-bit signed integer type for the \ref group_recls API */ -/** \def recls_uint64_t The 64-bit unsigned integer type for the \ref group_recls API */ - -typedef unsigned char recls_byte_t; - -typedef signed char recls_sint8_t; -typedef unsigned char recls_uint8_t; - -typedef signed short recls_sint16_t; -typedef unsigned short recls_uint16_t; - -typedef signed long recls_sint32_t; -typedef unsigned long recls_uint32_t; - -typedef signed long long recls_sint64_t; -typedef unsigned long long recls_uint64_t; - -/** \def recls_char_a_t The ANSI character type for the \ref group_recls API */ -/** \def recls_char_w_t The Unicode character type for the \ref group_recls API */ -typedef char recls_char_a_t; -typedef wchar_t recls_char_w_t; - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* RECLS_INCL_H_RECLS_COMPILER */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_debug.h b/etc/c/recls/recls_debug.h deleted file mode 100644 index 3a65e7ee212..00000000000 --- a/etc/c/recls/recls_debug.h +++ /dev/null @@ -1,183 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_debug.h - * - * Purpose: Compiler discrimination for the recls API. - * - * Created: 30th September 2003 - * Updated: 24th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_DEBUG -#define RECLS_INCL_H_RECLS_DEBUG - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_DEBUG_MAJOR 1 -# define RECLS_VER_H_RECLS_DEBUG_MINOR 0 -# define RECLS_VER_H_RECLS_DEBUG_REVISION 6 -# define RECLS_VER_H_RECLS_DEBUG_EDIT 6 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_debug.h Debug infrastructure for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#if defined(RECLS_PLATFORM_IS_WIN32) && \ - defined(_DEBUG) -# include -# include -#endif /* _DEBUG && RECLS_PLATFORM_IS_WIN32 */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -#if defined(_DEBUG) && \ - defined(RECLS_PLATFORM_IS_WIN32) -winstl_ns_using(last_error_scope) -winstl_ns_using(tls_index) -#endif /* _DEBUG && RECLS_PLATFORM_IS_WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * debug_printf - */ - -#if defined(_DEBUG) && \ - defined(RECLS_PLATFORM_IS_WIN32) - -inline void debug_printf(char const *fmt, ...) -{ - va_list args; - char _sz[2048]; - - va_start(args, fmt); - - _vsnprintf(_sz, stlsoft_num_elements(_sz), fmt, args); - OutputDebugStringA(_sz); - - va_end(args); -} - -class function_scope -{ -public: - function_scope(char const *fn) - { - last_error_scope error_scope; - - strncpy(m_fn, fn, stlsoft_num_elements(m_fn) - 1); - debug_printf("%*s>> %s()\n", _post_inc(), "", m_fn); - } - ~function_scope() - { - last_error_scope error_scope; - - debug_printf("%*s<< %s()\n", _pre_dec(), "", m_fn); - } - -private: - typedef stlsoft::sint32_t int32_t; - - static int32_t _post_inc() - { - int32_t i = reinterpret_cast(::TlsGetValue(sm_index)); - int32_t r = i++; - - ::TlsSetValue(sm_index, reinterpret_cast(i)); - - return r; - } - static int32_t _pre_dec() - { - int32_t i = reinterpret_cast(::TlsGetValue(sm_index)); - int32_t r = --i; - - ::TlsSetValue(sm_index, reinterpret_cast(i)); - - return r; - } - -private: - char m_fn[1024]; - static tls_index sm_index; -}; - -# define function_scope_trace(f) function_scope _scope_ ## __LINE__(f) - -#else /* ? _DEBUG && RECLS_PLATFORM_IS_WIN32 */ -inline void _debug_printf(char const *, ...) -{} -# define debug_printf (0) ? ((void)0) : _debug_printf -# define function_scope_trace(f) do { ; } while(0) -#endif /* _DEBUG && RECLS_PLATFORM_IS_WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_DEBUG */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_defs.h b/etc/c/recls/recls_defs.h deleted file mode 100644 index 25c1edba387..00000000000 --- a/etc/c/recls/recls_defs.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_defs.h - * - * Purpose: Definitions for the recls API. - * - * Created: 15th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_DEFS -#define RECLS_INCL_H_RECLS_DEFS - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#if defined( - - -#ifdef __cplusplus - -#include - - - - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef RECLS_INCL_H_RECLS_DEFS - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_fileinfo.cpp b/etc/c/recls/recls_fileinfo.cpp deleted file mode 100644 index 0b3668175bb..00000000000 --- a/etc/c/recls/recls_fileinfo.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_api.cpp - * - * Purpose: Main (platform-independent) implementation file for the recls API. - * - * Created: 16th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" - -#ifdef __cplusplus -# include -#endif /* __cplusplus */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_fileinfo_unix.cpp b/etc/c/recls/recls_fileinfo_unix.cpp deleted file mode 100644 index 0d4d7d0b5e3..00000000000 --- a/etc/c/recls/recls_fileinfo_unix.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_fileinfo_unix.cpp - * - * Purpose: UNIX implementation for the file information blocks of the recls API. - * - * Created: 2nd November 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" - -#include -#include - -// For ease of debugging for those of you (us?) that prefer working on Win32, -// the definition of EMULATE_UNIX_ON_WIN32 will allow you to do so. -#if defined(EMULATE_UNIX_ON_WIN32) -# include -# if defined(_MT) || \ - defined(__MT__) -# ifndef _REENTRANT -# define _REENTRANT -# endif /* !_REENTRANT */ -# define RECLS_FILEINFO_MULTITHREADED -# endif /* _MT || __MT__ */ -#else /* ? EMULATE_UNIX_ON_WIN32 */ -# if defined(_REENTRANT) -# define RECLS_FILEINFO_MULTITHREADED -# endif /* _REENTRANT */ -#endif /* EMULATE_UNIX_ON_WIN32 */ - - -//#define RECLS_UNIX_USE_ATOMIC_OPERATIONS // Define this if you're on Linux (and you know what you're doing!) - -#if defined(RECLS_FILEINFO_MULTITHREADED) - // If we're multi-threading, then we have two options: -# if defined(RECLS_UNIX_USE_ATOMIC_OPERATIONS) - // 1. On Linux we can use the kernel's atomic operations, since all we need - // is atomic integer operations. Since these kernel operations are not - // standard, you must explicitly select them in your build by defining - // the symbol RECLS_UNIX_USE_ATOMIC_OPERATIONS -# include -# else /* ? RECLS_UNIX_USE_ATOMIC_OPERATIONS */ - // 2. On other UNIX systems we use the UNIXSTL thread_mutex class -# include -# endif /* !RECLS_UNIX_USE_ATOMIC_OPERATIONS */ -#else /* ? RECLS_FILEINFO_MULTITHREADED */ - // When not multi-threaded, we just use the STLSoft null_mutex class, which - // is just a stub -# include -#endif /* RECLS_FILEINFO_MULTITHREADED */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -#if defined(RECLS_FILEINFO_MULTITHREADED) && \ - defined(RECLS_UNIX_USE_ATOMIC_OPERATIONS) -typedef atomic_t rc_atomic_t; -# define rc_atomic_init(x) ATOMIC_INIT(x) -#else /* ? RECLS_FILEINFO_MULTITHREADED && RECLS_UNIX_USE_ATOMIC_OPERATIONS */ -typedef recls_sint32_t rc_atomic_t; -# define rc_atomic_init(x) x -#endif /* RECLS_FILEINFO_MULTITHREADED && RECLS_UNIX_USE_ATOMIC_OPERATIONS */ - -struct counted_recls_info_t -{ - volatile rc_atomic_t rc; - recls_uint32_t _; - struct recls_fileinfo_t info; -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace -{ -#else -static -#endif /* !RECLS_NO_NAMESPACE */ - -volatile rc_atomic_t s_createdInfoBlocks = rc_atomic_init(0); -volatile rc_atomic_t s_sharedInfoBlocks = rc_atomic_init(0); - -#if !defined(RECLS_NO_NAMESPACE) -} // namespace recls -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Helpers - */ - -#if !defined(RECLS_UNIX_USE_ATOMIC_OPERATIONS) -namespace -{ -#if defined(RECLS_FILEINFO_MULTITHREADED) -// unixstl::process_mutex s_mx(true); - unixstl::thread_mutex s_mx(true); - typedef unixstl::thread_mutex mutex_t; -#else /* ? RECLS_FILEINFO_MULTITHREADED */ - stlsoft::null_mutex s_mx; - - typedef stlsoft::null_mutex mutex_t; -#endif /* RECLS_FILEINFO_MULTITHREADED */ -} -#endif /* !RECLS_UNIX_USE_ATOMIC_OPERATIONS */ - -inline void RC_PreIncrement(rc_atomic_t volatile *p) -{ -#if defined(RECLS_UNIX_USE_ATOMIC_OPERATIONS) - - atomic_inc(p); - -#else /* ? RECLS_UNIX_USE_ATOMIC_OPERATIONS */ - stlsoft::lock_scope lock(s_mx); - - ++(*p); -#endif /* !RECLS_UNIX_USE_ATOMIC_OPERATIONS */ -} - -inline recls_sint32_t RC_PreDecrement(rc_atomic_t volatile *p) -{ -#if defined(RECLS_UNIX_USE_ATOMIC_OPERATIONS) - - return 1 + atomic_dec_and_test(p); - -#else /* ? RECLS_UNIX_USE_ATOMIC_OPERATIONS */ - stlsoft::lock_scope lock(s_mx); - - return --(*p); -#endif /* !RECLS_UNIX_USE_ATOMIC_OPERATIONS */ -} - -inline recls_sint32_t RC_ReadValue(rc_atomic_t volatile *p) -{ -#if defined(RECLS_UNIX_USE_ATOMIC_OPERATIONS) - - return atomic_read(p); - -#else /* ? RECLS_UNIX_USE_ATOMIC_OPERATIONS */ - stlsoft::lock_scope lock(s_mx); - - return (*p); -#endif /* !RECLS_UNIX_USE_ATOMIC_OPERATIONS */ -} - -inline struct counted_recls_info_t *counted_info_from_info(recls_info_t i) -{ - recls_assert(i != NULL); - - // can't be bothered with all the C++ casts here! - return (struct counted_recls_info_t *)((recls_byte_t*)i - offsetof(counted_recls_info_t, info)); -} - -inline recls_info_t info_from_counted_info(struct counted_recls_info_t * ci) -{ - recls_assert(ci != NULL); - - return &ci->info; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * File info functions - */ - -RECLS_FNDECL(recls_info_t) FileInfo_Allocate(size_t cb) -{ - // Simply allocate a lock-count prior to the main memory (but do it on an 8-byte block) - counted_recls_info_t *ci = static_cast(malloc(cb - sizeof(struct recls_fileinfo_t) + sizeof(struct counted_recls_info_t))); - recls_info_t info; - - if(NULL == ci) - { - info = NULL; - } - else - { - rc_atomic_t initial = rc_atomic_init(1); - - ci->rc = initial; // One initial reference - info = info_from_counted_info(ci); - - RC_PreIncrement(&s_createdInfoBlocks); - } - - return info; -} - -RECLS_FNDECL(void) FileInfo_Release(recls_info_t fileInfo) -{ - if(NULL != fileInfo) - { - counted_recls_info_t *pci = counted_info_from_info(fileInfo); - - if(0 == RC_PreDecrement(&pci->rc)) - { - free(pci); - - RC_PreDecrement(&s_createdInfoBlocks); - } - else - { - RC_PreDecrement(&s_sharedInfoBlocks); - } - } -} - -RECLS_FNDECL(recls_rc_t) FileInfo_Copy(recls_info_t fileInfo, recls_info_t *pinfo) -{ - recls_assert(NULL != pinfo); - - if(NULL != fileInfo) - { - counted_recls_info_t *pci = counted_info_from_info(fileInfo); - - RC_PreIncrement(&pci->rc); - RC_PreIncrement(&s_sharedInfoBlocks); - } - - *pinfo = fileInfo; - - return RECLS_RC_OK; -} - -RECLS_FNDECL(void) FileInfo_BlockCount(recls_sint32_t *pcCreated, recls_sint32_t *pcShared) -{ - recls_assert(NULL != pcCreated); - recls_assert(NULL != pcShared); - - *pcCreated = RC_ReadValue(&s_createdInfoBlocks); - *pcShared = RC_ReadValue(&s_sharedInfoBlocks); -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_fileinfo_win32.cpp b/etc/c/recls/recls_fileinfo_win32.cpp deleted file mode 100644 index 5ee13cd8837..00000000000 --- a/etc/c/recls/recls_fileinfo_win32.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_fileinfo_win32.cpp - * - * Purpose: Win32 implementation for the file information blocks of the recls API. - * - * Created: 16th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" - -#include - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace -{ -#else -static -#endif /* !RECLS_NO_NAMESPACE */ - -volatile recls_sint32_t s_createdInfoBlocks = 0; -volatile recls_sint32_t s_sharedInfoBlocks = 0; - -#if !defined(RECLS_NO_NAMESPACE) -} // namespace recls -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -struct counted_recls_info_t -{ - volatile recls_sint32_t rc; - recls_uint32_t _; - struct recls_fileinfo_t info; -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Helpers - */ - -inline recls_sint32_t RC_PreIncrement(recls_sint32_t volatile *p) -{ - return winstl::atomic_preincrement(p); -} - -inline recls_sint32_t RC_PreDecrement(recls_sint32_t volatile *p) -{ - return winstl::atomic_predecrement(p); -} - -inline struct counted_recls_info_t *counted_info_from_info(recls_info_t i) -{ - recls_assert(i != NULL); - - // can't be bothered with all the C++ casts here! - return (struct counted_recls_info_t *)((recls_byte_t*)i - offsetof(counted_recls_info_t, info)); -} - -inline recls_info_t info_from_counted_info(struct counted_recls_info_t * ci) -{ - recls_assert(ci != NULL); - - return &ci->info; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * File info functions - */ - -RECLS_FNDECL(recls_info_t) FileInfo_Allocate(size_t cb) -{ - // Simply allocate a lock-count prior to the main memory (but do it on an 8-byte block) - counted_recls_info_t *ci = static_cast(malloc(cb - sizeof(struct recls_fileinfo_t) + sizeof(struct counted_recls_info_t))); - recls_info_t info; - - if(NULL == ci) - { - info = NULL; - } - else - { - ci->rc = 1; // One initial reference - info = info_from_counted_info(ci); - - RC_PreIncrement(&s_createdInfoBlocks); - } - - return info; -} - -RECLS_FNDECL(void) FileInfo_Release(recls_info_t fileInfo) -{ - if(NULL != fileInfo) - { - counted_recls_info_t *pci = counted_info_from_info(fileInfo); - - if(0 == RC_PreDecrement(&pci->rc)) - { - free(pci); - - RC_PreDecrement(&s_createdInfoBlocks); - } - else - { - RC_PreDecrement(&s_sharedInfoBlocks); - } - } -} - -RECLS_FNDECL(recls_rc_t) FileInfo_Copy(recls_info_t fileInfo, recls_info_t *pinfo) -{ - recls_assert(NULL != pinfo); - - if(NULL != fileInfo) - { - counted_recls_info_t *pci = counted_info_from_info(fileInfo); - - RC_PreIncrement(&pci->rc); - RC_PreIncrement(&s_sharedInfoBlocks); - } - - *pinfo = fileInfo; - - return RECLS_RC_OK; -} - -RECLS_FNDECL(void) FileInfo_BlockCount(recls_sint32_t *pcCreated, recls_sint32_t *pcShared) -{ - recls_assert(NULL != pcCreated); - recls_assert(NULL != pcShared); - - // Because on 3.51 and 95, the InterlockedInc/Decrement functions do not - // return the values, we're going to fudge it - - RC_PreIncrement(&s_createdInfoBlocks); - recls_sint32_t createdInfoBlocks = s_createdInfoBlocks; - RC_PreDecrement(&s_createdInfoBlocks); - *pcCreated = createdInfoBlocks - 1; - - RC_PreIncrement(&s_sharedInfoBlocks); - recls_sint32_t sharedInfoBlocks = s_sharedInfoBlocks; - RC_PreDecrement(&s_sharedInfoBlocks); - *pcShared = sharedInfoBlocks - 1; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_internal.cpp b/etc/c/recls/recls_internal.cpp deleted file mode 100644 index 3505cf8e8f7..00000000000 --- a/etc/c/recls/recls_internal.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_internal.cpp - * - * Purpose: Implementation file for the recls API internal helpers. - * - * Created: 16th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" - -#include - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -static size_t recls_strncpy(recls_char_t *dest, size_t cchDest, recls_char_t const *src, size_t cchSrc) -{ - size_t cchWritten; - - if(cchDest < cchSrc) - { - /* Just to straight strncpy. */ - strncpy(dest, src, cchDest); - - cchWritten = cchDest; - } - else - { - strncpy(dest, src, cchSrc); - - if(cchSrc < cchDest) - { - /* Fill the rest up with blanks. */ - - memset(&dest[cchSrc], 0, sizeof(recls_char_t) * (cchDest - cchSrc)); - } - - cchWritten = cchSrc; - } - - return cchWritten; -} - -/* ////////////////////////////////////////////////////////////////////////// */ - -#if defined(RECLS_COMPILER_IS_DMC) || \ - defined(RECLS_COMPILER_IS_WATCOM) -RECLS_FNDECL(size_t) Recls_GetStringProperty_( struct recls_strptrs_t const * ptrs - , recls_char_t * buffer - , size_t cchBuffer) -#else -RECLS_FNDECL(size_t) Recls_GetStringProperty_( struct recls_strptrs_t const *const ptrs - , recls_char_t *const buffer - , size_t const cchBuffer) -#endif /* RECLS_COMPILER_IS_DMC || RECLS_COMPILER_IS_WATCOM */ -{ - recls_assert(NULL != ptrs); - - size_t cch = ptrs->end - ptrs->begin; - - if(NULL != buffer) - { - cch = recls_strncpy(buffer, cchBuffer, ptrs->begin, cch); - } - - return cch; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_internal.h b/etc/c/recls/recls_internal.h deleted file mode 100644 index d09951a0ec3..00000000000 --- a/etc/c/recls/recls_internal.h +++ /dev/null @@ -1,245 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_internal.h - * - * Purpose: Main header file for the recls API. - * - * Created: 15th August 2003 - * Updated: 24th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_INTERNAL -#define RECLS_INCL_H_RECLS_INTERNAL - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_INTERNAL_MAJOR 1 -# define RECLS_VER_H_RECLS_INTERNAL_MINOR 2 -# define RECLS_VER_H_RECLS_INTERNAL_REVISION 3 -# define RECLS_VER_H_RECLS_INTERNAL_EDIT 12 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef __cplusplus -# error This file can only be included in C++ compilation units -#endif /* __cplusplus */ - -#include "recls.h" - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Macros - */ - -#ifndef RECLS_NUM_ELEMENTS -# if defined(stlsoft_num_elements) -# define RECLS_NUM_ELEMENTS(x) stlsoft_num_elements(x) -# else /* ? stlsoft_num_elements */ -# define RECLS_NUM_ELEMENTS(x) (sizeof(x) / sizeof((x)[0])) -# endif /* stlsoft_num_elements */ -#endif /* !RECLS_NUM_ELEMENTS */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class ReclsDNode -/// Interface for directory nodes -/// -/// \note It has an ugly name-prefix if need to compile with compiler that does not support namespaces -struct ReclsDNode -{ - /// Destructory - /// - /// ReclsDNode instances are not reference-counted, but are - /// deleted by their owner. They are non-shareable. - virtual ~ReclsDNode() = 0; - - virtual recls_rc_t GetNext() = 0; - - virtual recls_rc_t GetDetails(recls_info_t *pinfo) = 0; - - virtual recls_rc_t GetNextDetails(recls_info_t *pinfo) = 0; -}; - -inline ReclsDNode::~ReclsDNode() -{} - -// class ReclsDNode -/// Search info structure -/// -/// \note It has an ugly name-prefix if need to compile with compiler that does not support namespaces -class ReclsSearchInfo -{ -public: - typedef recls_char_t char_type; - typedef ReclsSearchInfo class_type; - -// Allocation -private: - void *operator new(size_t cb, int cDirParts, size_t cbRootDir); -#if !defined(RECLS_COMPILER_IS_BORLAND) && \ - !defined(RECLS_COMPILER_IS_DMC) && \ - !defined(RECLS_COMPILER_IS_INTEL) && \ - !defined(RECLS_COMPILER_IS_WATCOM) - void operator delete(void *pv, int cDirParts, size_t cbRootDir); -#endif /* !RECLS_COMPILER_IS_BORLAND && !RECLS_COMPILER_IS_DMC */ -public: - void operator delete(void *pv); - -// Construction -protected: - ReclsSearchInfo(int cDirParts - , char_type const *rootDir - , char_type const *pattern - , recls_uint32_t flags); -public: - static recls_rc_t FindAndCreate(char_type const *rootDir - , char_type const *pattern - , recls_uint32_t flags - , ReclsSearchInfo **ppsi); - -// Operations -public: - recls_rc_t GetNext(); - - recls_rc_t GetDetails(recls_info_t *pinfo); - - recls_rc_t GetNextDetails(recls_info_t *pinfo); - -// Accessors -public: - recls_rc_t GetLastError() const; - -// Handle interconversion -public: - static hrecls_t ToHandle(ReclsSearchInfo *si); - static ReclsSearchInfo *FromHandle(hrecls_t h); - -// Implementation -private: - char_type const *_calc_rootDir(int cDirParts, char_type const *rootDir); - -// Members -private: - recls_uint32_t m_flags; - ReclsDNode *m_dnode; - recls_rc_t m_lastError; - char_type const * const m_rootDir; - - /** The opaque data of the search */ - recls_byte_t data[1]; - /* - * The data comprises: - * - * - root dir - * - */ - -// Not to be implemented -private: - ReclsSearchInfo(ReclsSearchInfo const &); - ReclsSearchInfo &operator =(ReclsSearchInfo const &); -}; - -inline /* static */ hrecls_t ReclsSearchInfo::ToHandle(ReclsSearchInfo *si) -{ - return hrecls_t(si); -} - -inline /* static */ ReclsSearchInfo *ReclsSearchInfo::FromHandle(hrecls_t h) -{ - return const_cast(reinterpret_cast(h)); -} - -/* ///////////////////////////////////////////////////////////////////////////// - * File info functions - */ - -RECLS_FNDECL(recls_info_t) FileInfo_Allocate( size_t cb); -RECLS_FNDECL(void) FileInfo_Release( recls_info_t fileInfo); -RECLS_FNDECL(recls_rc_t) FileInfo_Copy( recls_info_t fileInfo - , recls_info_t *pinfo); - -RECLS_FNDECL(void) FileInfo_BlockCount(recls_sint32_t *pcCreated - , recls_sint32_t *pcShared); - -/* ///////////////////////////////////////////////////////////////////////////// - * Helper functions - */ - -RECLS_FNDECL(size_t) Recls_GetStringProperty_( struct recls_strptrs_t const *ptrs - , recls_char_t *buffer - , size_t cchBuffer); - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_INTERNAL */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_language.h b/etc/c/recls/recls_language.h deleted file mode 100644 index 6393fd99ca7..00000000000 --- a/etc/c/recls/recls_language.h +++ /dev/null @@ -1,117 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_language.h - * - * Purpose: Platform discrimination for the recls API. - * - * Created: 15th August 2003 - * Updated: 23rd September 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_LANGUAGE -#define RECLS_INCL_H_RECLS_LANGUAGE - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_LANGUAGE_MAJOR 1 -# define RECLS_VER_H_RECLS_LANGUAGE_MINOR 0 -# define RECLS_VER_H_RECLS_LANGUAGE_REVISION 8 -# define RECLS_VER_H_RECLS_LANGUAGE_EDIT 8 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_language.h Language detection for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Linkage - */ - -/** \def RECLS_LINKAGE_C The linkage for recls functions. Is \c extern \c "C" in C++ and \c extern in C. */ - -#ifdef __cplusplus -# define RECLS_LINKAGE_C extern "C" -# define RECLS_LINKAGE_CPP extern "C++" -#else -# define RECLS_LINKAGE_C extern -#endif /* __cplusplus */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(__cplusplus) -# define RECLS_NO_NAMESPACE -#endif /* !__cplusplus */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_LANGUAGE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_platform.h b/etc/c/recls/recls_platform.h deleted file mode 100644 index f2c5138d27a..00000000000 --- a/etc/c/recls/recls_platform.h +++ /dev/null @@ -1,148 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_platform.h - * - * Purpose: Platform discrimination for the recls API. - * - * Created: 15th August 2003 - * Updated: 2nd November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_PLATFORM -#define RECLS_INCL_H_RECLS_PLATFORM - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_PLATFORM_MAJOR 1 -# define RECLS_VER_H_RECLS_PLATFORM_MINOR 2 -# define RECLS_VER_H_RECLS_PLATFORM_REVISION 2 -# define RECLS_VER_H_RECLS_PLATFORM_EDIT 10 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_platform.h Platform detection for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Platform recognition - * - * Define the symbol RECLS_OVERRIDE_PLATFORM to provide your own platform - * discrimination - */ - -#ifndef RECLS_OVERRIDE_PLATFORM -# if defined(WIN32) || \ - defined(_WIN32) -# define RECLS_PLATFORM_IS_WIN32 -# elif defined(unix) || \ - defined(UNIX) || \ - defined(__unix) || \ - defined(__unix__) || \ - ( defined(__xlC__) && \ - defined(_POWER) && \ - defined(_AIX)) -# define RECLS_PLATFORM_IS_UNIX -# else -# error Platform not (yet) recognised -# endif /* platform */ -#endif /* !RECLS_OVERRIDE_PLATFORM */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#if defined(RECLS_PLATFORM_IS_WIN32) -# include -#elif defined(RECLS_PLATFORM_IS_UNIX) -# include -#else -# error Platform not (yet) recognised -#endif /* platform */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -/** \def RECLS_PATH_MAX The maximum number of characters in a path on the host operating-system. */ - -#if defined(RECLS_PLATFORM_IS_WIN32) - -# define RECLS_PATH_MAX (_MAX_PATH) - -#elif defined(RECLS_PLATFORM_IS_UNIX) - -# define RECLS_PATH_MAX (PATH_MAX) - -#else - -# error Platform not (yet) recognised - -#endif /* platform */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_PLATFORM */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_platform_types.h b/etc/c/recls/recls_platform_types.h deleted file mode 100644 index 9d190b4dbc7..00000000000 --- a/etc/c/recls/recls_platform_types.h +++ /dev/null @@ -1,245 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_platform_types.h - * - * Purpose: Platform discrimination for the recls API. - * - * Created: 18th August 2003 - * Updated: 21st November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_PLATFORM_TYPES -#define RECLS_INCL_H_RECLS_PLATFORM_TYPES - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_PLATFORM_TYPES_MAJOR 1 -# define RECLS_VER_H_RECLS_PLATFORM_TYPES_MINOR 3 -# define RECLS_VER_H_RECLS_PLATFORM_TYPES_REVISION 1 -# define RECLS_VER_H_RECLS_PLATFORM_TYPES_EDIT 8 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_platform_types.h Platform-dependent types for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef RECLS_INCL_H_RECLS_PLATFORM -# error recls_platform_types.h must not be included directly. You should include recls.h -#endif /* !RECLS_INCL_H_RECLS_PLATFORM */ - -#if defined(RECLS_PLATFORM_IS_WIN32) -//# include -#elif defined(RECLS_PLATFORM_IS_UNIX) -# include -# include -#else -# error Platform not (yet) recognised -#endif /* platform */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Platform-dependent types - */ - -/** \def recls_time_t The time type for the recls API */ -/** \def recls_filesize_t The file-size type for the recls API */ - -#if defined(RECLS_PLATFORM_IS_WIN32) - - typedef FILETIME recls_time_t; - typedef ULARGE_INTEGER recls_filesize_t; - -#elif defined(RECLS_PLATFORM_IS_UNIX) - - typedef time_t recls_time_t; - typedef off_t recls_filesize_t; - -#else - -# error Platform not (yet) recognised - - typedef platform-dependent-type recls_time_t; - typedef platform-dependent-type recls_filesize_t; - -#endif /* platform */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -#ifdef RECLS_CHAR_TYPE_IS_CHAR -# undef RECLS_CHAR_TYPE_IS_CHAR -#endif /* RECLS_CHAR_TYPE_IS_CHAR */ - -#ifdef RECLS_CHAR_TYPE_IS_WCHAR -# undef RECLS_CHAR_TYPE_IS_WCHAR -#endif /* RECLS_CHAR_TYPE_IS_WCHAR */ - -/** The recls library ambient character type */ -#if 1 -typedef recls_char_a_t recls_char_t; -# define RECLS_CHAR_TYPE_IS_CHAR -#else /* ? 0 */ -typedef recls_char_w_t recls_char_t; -# define RECLS_CHAR_TYPE_IS_WCHAR -#endif /* 0 */ - - -/** An asymmetric range representing a sequence of characters (ie a string) */ -struct recls_strptrs_t -{ - /** Points to the start of the sequence. */ - recls_char_t const *begin; - /** Points to one-past-the-end of the sequence. */ - recls_char_t const *end; -}; - -/** An asymmetric range representing a sequence of recls_strptrs_t (ie a set of strings) */ -struct recls_strptrsptrs_t -{ - /** Points to the start of the sequence. */ - struct recls_strptrs_t const *begin; - /** Points to one-past-the-end of the sequence. */ - struct recls_strptrs_t const *end; -}; - -/** A file entry info structure - * - * \note Several parts of this structure are platform-dependent. - */ -struct recls_fileinfo_t -{ -/** \name attributes */ -/** @{ */ - /** The file attributes */ - recls_uint32_t attributes; -/** @} */ -/** \name Path components */ -/** @{ */ - /** The full path of the file */ - struct recls_strptrs_t path; -#if defined(RECLS_PLATFORM_IS_WIN32) - /** The short (8.3) path of the file - * - * \note This member is only defined for the Win32 platform. - */ - struct recls_strptrs_t shortFile; - /** The letter of the drive */ - recls_char_t drive; -#endif /* RECLS_PLATFORM_IS_WIN32 */ - /** The directory component */ - struct recls_strptrs_t directory; - /** The file name component (excluding extension) */ - struct recls_strptrs_t fileName; - /** The file extension component (excluding '.') */ - struct recls_strptrs_t fileExt; - /** The directory parts */ - struct recls_strptrsptrs_t directoryParts; -/** @} */ -/** \name File times */ -/** @{ */ -#if defined(RECLS_PLATFORM_IS_WIN32) - /** The time the file was created - * - * \note This member is only defined for the Win32 platform. - */ - recls_time_t creationTime; -#endif /* RECLS_PLATFORM_IS_WIN32 */ - /** The time the file was last modified */ - recls_time_t modificationTime; - /** The time the file was last accessed */ - recls_time_t lastAccessTime; -#if defined(RECLS_PLATFORM_IS_UNIX) - /** The time the file status was last changed - * - * \note This member is only defined for the UNIX platform. - */ - recls_time_t lastStatusChangeTime; -#endif /* RECLS_PLATFORM_IS_UNIX */ -/** @} */ -/** \name Size */ -/** @{ */ - /** The size of the file */ - recls_filesize_t size; -/** @} */ -/* data */ - /** The opaque data of the file; it is not accessible to any client code, and must not be manipulated in any way */ - recls_byte_t data[1]; - /* - * - * - full path - * - directory parts - * - */ -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_PLATFORM_TYPES */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_retcodes.h b/etc/c/recls/recls_retcodes.h deleted file mode 100644 index dbb69f4722c..00000000000 --- a/etc/c/recls/recls_retcodes.h +++ /dev/null @@ -1,111 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_retcodes.h - * - * Purpose: Return codes for the recls API. - * - * Created: 15th August 2003 - * Updated: 27th September 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#if !defined(RECLS_INCL_H_RECLS) && \ - !defined(RECLS_DOCUMENTATION_SKIP_SECTION) -# error recls_retcodes.h cannot be included directly. Include recls.h -#else - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_RETCODES_MAJOR 1 -# define RECLS_VER_H_RECLS_RETCODES_MINOR 1 -# define RECLS_VER_H_RECLS_RETCODES_REVISION 2 -# define RECLS_VER_H_RECLS_RETCODES_EDIT 10 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_retcodes.h Return codes for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -/** No search is currently active */ -#define RECLS_RC_SEARCH_NO_CURRENT ((RECLS_QUAL(recls_rc_t))(-1 - 1001)) -/** The directory was invalid, or does not exist */ -#define RECLS_RC_INVALID_DIRECTORY ((RECLS_QUAL(recls_rc_t))(-1 - 1002)) -/** No more data is available */ -#define RECLS_RC_NO_MORE_DATA ((RECLS_QUAL(recls_rc_t))(-1 - 1003)) -/** Memory exhaustion */ -#define RECLS_RC_OUT_OF_MEMORY ((RECLS_QUAL(recls_rc_t))(-1 - 1004)) -/** Function not implemented */ -#define RECLS_RC_NOT_IMPLEMENTED ((RECLS_QUAL(recls_rc_t))(-1 - 1005)) -/** Invalid search type */ -#define RECLS_RC_INVALID_SEARCH_TYPE ((RECLS_QUAL(recls_rc_t))(-1 - 1006)) - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_unix.h b/etc/c/recls/recls_unix.h deleted file mode 100644 index c337566229a..00000000000 --- a/etc/c/recls/recls_unix.h +++ /dev/null @@ -1,115 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_unix.h - * - * Purpose: UNIX-specific header file for the recls API. - * - * Created: 18th August 2003 - * Updated: 23rd September 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_UNIX -#define RECLS_INCL_H_RECLS_UNIX - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_UNIX_MAJOR 1 -# define RECLS_VER_H_RECLS_UNIX_MINOR 0 -# define RECLS_VER_H_RECLS_UNIX_REVISION 3 -# define RECLS_VER_H_RECLS_UNIX_EDIT 3 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_unix.h UNIX-specific parts of the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Strictness - */ - -#ifndef RECLS_NO_STRICT -# define RECLS_STRICT -#endif /* !RECLS_NO_STRICT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" - -#ifndef RECLS_PLATFORM_IS_UNIX -# error recls_unix.h is to be included in UNIX compilations only -#endif /* RECLS_PLATFORM_IS_UNIX */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Functions - */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_UNIX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_util.cpp b/etc/c/recls/recls_util.cpp deleted file mode 100644 index 4b2f7d07960..00000000000 --- a/etc/c/recls/recls_util.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_util.cpp - * - * Purpose: Platform-independent utility functions for the recls API. - * - * Created: 17th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" -#include "recls_util.h" - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -RECLS_LINKAGE_C size_t align_up_size(size_t i) -{ - return (size_t)((i + (4 - 1)) & ~(4 - 1)); -} - -RECLS_LINKAGE_C recls_bool_t is_dots(recls_char_t const *f) -{ - recls_assert(NULL != f); - - return ( f[0] == '.' && - f[1] == '\0') || - ( f[0] == '.' && - f[1] == '.' && - f[2] == '\0'); -} - -RECLS_LINKAGE_C size_t count_char_instances_a(recls_char_a_t const *begin, recls_char_a_t const *end, recls_char_a_t const ch) -{ - size_t cDirParts = 0; - - for(; begin != end; ++begin) - { - if(*begin == ch) - { - ++cDirParts; - } - } - - return cDirParts; -} - -RECLS_LINKAGE_C size_t count_char_instances_w(recls_char_w_t const *begin, recls_char_w_t const *end, recls_char_w_t const ch) -{ - size_t cDirParts = 0; - - for(; begin != end; ++begin) - { - if(*begin == ch) - { - ++cDirParts; - } - } - - return cDirParts; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_util.h b/etc/c/recls/recls_util.h deleted file mode 100644 index 86bddbb4832..00000000000 --- a/etc/c/recls/recls_util.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_util.h - * - * Purpose: Utility functions for the recls API. - * - * Created: 17th August 2003 - * Updated: 21st November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_UTIL -#define RECLS_INCL_H_RECLS_UTIL - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_UTIL_MAJOR 1 -# define RECLS_VER_H_RECLS_UTIL_MINOR 4 -# define RECLS_VER_H_RECLS_UTIL_REVISION 1 -# define RECLS_VER_H_RECLS_UTIL_EDIT 9 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_util.h Utility functions for the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Functions - */ - -RECLS_LINKAGE_C recls_bool_t is_dots(recls_char_t const *f); -RECLS_LINKAGE_C recls_bool_t file_exists(recls_char_t const *f); -RECLS_LINKAGE_C size_t align_up_size(size_t i); -RECLS_LINKAGE_C size_t count_char_instances_a(recls_char_a_t const *begin, recls_char_a_t const *end, recls_char_a_t const ch); -RECLS_LINKAGE_C size_t count_char_instances_w(recls_char_w_t const *begin, recls_char_w_t const *end, recls_char_w_t const ch); -RECLS_LINKAGE_C size_t count_dir_parts_a(recls_char_a_t const *begin, recls_char_a_t const *end); -RECLS_LINKAGE_C size_t count_dir_parts_w(recls_char_w_t const *begin, recls_char_w_t const *end); - -#ifdef __cplusplus -inline size_t count_dir_parts(recls_char_a_t const *begin, recls_char_a_t const *end) -{ - return count_dir_parts_a(begin, end); -} - -inline size_t count_dir_parts(recls_char_w_t const *begin, recls_char_w_t const *end) -{ - return count_dir_parts_w(begin, end); -} -#endif /* __cplusplus */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_UTIL */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_util_unix.cpp b/etc/c/recls/recls_util_unix.cpp deleted file mode 100644 index cbb10faebf6..00000000000 --- a/etc/c/recls/recls_util_unix.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_util_win32.cpp - * - * Purpose: Win32 utility functions for the recls API. - * - * Created: 17th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" -#include "recls_util.h" - -#include - -#include - -#include -#include - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -unixstl_ns_using(filesystem_traits) - -/* ////////////////////////////////////////////////////////////////////////// */ - -RECLS_LINKAGE_C recls_bool_t file_exists(recls_char_t const *f) -{ - struct stat st; - - return 0 == stat(f, &st) || errno != ENOENT; -} - -RECLS_LINKAGE_C size_t count_dir_parts_a(recls_char_a_t const *begin, recls_char_a_t const *end) -{ - return count_char_instances_a(begin, end, unixstl_ns_qual(filesystem_traits)::path_name_separator()); -} - -#if 0 -RECLS_LINKAGE_C size_t count_dir_parts_w(recls_char_w_t const *begin, recls_char_w_t const *end) -{ - return count_char_instances_w(begin, end, unixstl_ns_qual(filesystem_traits)::path_name_separator()); -} -#endif /* 0 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_util_win32.cpp b/etc/c/recls/recls_util_win32.cpp deleted file mode 100644 index 14ad883b2ae..00000000000 --- a/etc/c/recls/recls_util_win32.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_util_win32.cpp - * - * Purpose: Win32 utility functions for the recls API. - * - * Created: 17th August 2003 - * Updated: 27th November 2003 - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" -#include "recls_internal.h" -#include "recls_assert.h" -#include "recls_util.h" - -#include - -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -RECLS_LINKAGE_C recls_bool_t file_exists(recls_char_t const *f) -{ - return 0xFFFFFFFF != ::GetFileAttributes(f); -} - -RECLS_LINKAGE_C size_t count_dir_parts_a(recls_char_a_t const *begin, recls_char_a_t const *end) -{ - return count_char_instances_a(begin, end, winstl_ns_qual(filesystem_traits)::path_name_separator()); -} - -RECLS_LINKAGE_C size_t count_dir_parts_w(recls_char_w_t const *begin, recls_char_w_t const *end) -{ - return count_char_instances_w(begin, end, winstl_ns_qual(filesystem_traits)::path_name_separator()); -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/recls_win32.h b/etc/c/recls/recls_win32.h deleted file mode 100644 index 10d04656046..00000000000 --- a/etc/c/recls/recls_win32.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls_win32.h - * - * Purpose: Win32-specific header file for the recls API. - * - * Created: 18th August 2003 - * Updated: 21st November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/software - * http://www.recls.org/ - * - * email: submissions@recls.org for submissions - * admin@recls.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef RECLS_INCL_H_RECLS_WIN32 -#define RECLS_INCL_H_RECLS_WIN32 - -/* File version */ -#ifndef RECLS_DOCUMENTATION_SKIP_SECTION -# define RECLS_VER_H_RECLS_WIN32_MAJOR 1 -# define RECLS_VER_H_RECLS_WIN32_MINOR 1 -# define RECLS_VER_H_RECLS_WIN32_REVISION 2 -# define RECLS_VER_H_RECLS_WIN32_EDIT 6 -#endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */ - -/** \file recls_win32.h Win32-specific parts of the \ref group_recls API */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Strictness - */ - -#ifndef RECLS_NO_STRICT -# define RECLS_STRICT -#endif /* !RECLS_NO_STRICT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include "recls.h" - -#ifndef RECLS_PLATFORM_IS_WIN32 -# error recls_win32.h is to be included in Win32 compilations only -#endif /* RECLS_PLATFORM_IS_WIN32 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -namespace recls -{ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Functions - */ - -/** Gets the drive associated with the given file entry info structure - * - * \param hEntry The info entry structure. - * \param pchDrive Pointer to a character to receive the drive character. Cannot be NULL. The character will be in uppercase. - */ -RECLS_FNDECL(void) Recls_GetDriveProperty( recls_info_t hEntry - , recls_char_t *pchDrive); - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#if !defined(RECLS_NO_NAMESPACE) -} /* namespace recls */ -#endif /* !RECLS_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !RECLS_INCL_H_RECLS_WIN32 */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/recls/win32.mak b/etc/c/recls/win32.mak deleted file mode 100644 index 6b048c87c5d..00000000000 --- a/etc/c/recls/win32.mak +++ /dev/null @@ -1,69 +0,0 @@ -# ############################################################################## -# File: makefile.win32 -# -# Purpose: Digital Mars C/C++ 8.38+ makefile for the recls library (std.recls) -# -# Created: 24th November 2003 -# Updated: 24th November 2003 -# -# Copyright: Synesis Software Pty Ltd, (c) 2003. All rights reserved. -# -# Home: www.synesis.com.au/software -# -# ############################################################################## - -# ############################################################################## -# Macros - -CC = dmc - -RECLS_LIBDIR = . - -STLSOFT_RECLS_PATCH_INCLUDE = $(RECLS_INCLUDE) - -STLSOFT_INCLUDE = ..\stlsoft - -CCFLAGS = -wx -o -CCDEFS = -DNDEBUG - -CCARGS = $(CCFLAGS) $(CCDEFS) -c -I. -I$(STLSOFT_INCLUDE) -Ic:\dm\stlport\stlport - -################################################################################ -# Objects - -OBJS_C = \ - .\recls_api.obj \ - .\recls_fileinfo.obj \ - .\recls_internal.obj \ - .\recls_util.obj \ - .\recls_api_win32.obj \ - .\recls_fileinfo_win32.obj \ - .\recls_util_win32.obj - - -################################################################################ -# Suffix rules - -.c.obj: - $(CC) $(CCARGS) -o$@ $? - -.cpp.obj: - $(CC) $(CCARGS) -o$@ $? - -################################################################################ -# Targets - -target: $(RECLS_LIBDIR)\recls.lib - -clean: - @echo Cleaning other file types - @if exist $(RECLS_LIBDIR)\recls.lib del $(RECLS_LIBDIR)\recls.lib - @del $(OBJS_C) 2>NUL - @if exist *.map del *.map - -# executables - -$(RECLS_LIBDIR)\recls.lib: $(OBJS_C) - lib -c $@ $(OBJS_C) - -################################################################################ diff --git a/etc/c/stlsoft/stlsoft.h b/etc/c/stlsoft/stlsoft.h deleted file mode 100644 index aa4a5ddcbd8..00000000000 --- a/etc/c/stlsoft/stlsoft.h +++ /dev/null @@ -1,1994 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: stlsoft.h - * - * Purpose: Root header for the STLSoft libraries. Performs various compiler - * and platform discriminations, and definitions of types. - * - * Created: 15th January 2002 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT -#define _STLSOFT_INCL_H_STLSOFT - -/* File version */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _STLSOFT_VER_H_STLSOFT_MAJOR 1 -# define _STLSOFT_VER_H_STLSOFT_MINOR 48 -# define _STLSOFT_VER_H_STLSOFT_REVISION 2 -# define _STLSOFT_VER_H_STLSOFT_EDIT 166 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/** \file stlsoft.h The root header for the \ref STLSoft project, and for all other \ref projects "projects" */ - -/** \weakgroup projects STLSoft Projects - * - * \brief The Projects that comprise the STLSoft libraries - * - * The STLSoft libraries are split up into sub-projects, where each sub-project only - * depends on the STLSoft main project, which resides in the stlsoft - * namespace. - */ - -/** \defgroup STLSoft STLSoft - * \ingroup projects - * - * \brief     ... Robust, Lightweight, Cross-platform, Template Software ... - * - * The philosophy of STLSoft is very simple: providing robust and lightweight software to the development community. The main STLSoft project, STLSoft itself (located at the site you are viewing now) provides cross-platform, technology/API-neutral classes and functions that stand on their own and are useful as independent libraries. They also support the other sub-projects (COMSTL, UNIXSTL, WinSTL, etc.) which are targeted at specific operating systems, technologies and APIs. - - * The philosophy of COMSTL is essentially - * the same as that of the STLSoft - * organisation: providing robust and lightweight software to the Component - * Object Model (COM) development community. - * COMSTL provides template-based software - * that builds on that provided by COM and - * STLSoft in order to reduce programmer - * effort and increase robustness in the use of the COM. - * - * Namespaces - * - * The COMSTL namespace comstl - * is actually an alias for the namespace stlsoft::comstl_project, - * and as such all the COMSTL project components actually reside within the - * stlsoft namespace - * - * Dependencies - * - * As with all parts of the STLSoft libraries, there are no - * dependencies on COMSTL binary components - * and no need to compile COMSTL implementation - * files; COMSTL is 100% header-only! - * - * As with most of the STLSoft sub-projects, - * COMSTL depends only on - * - * - Selected headers from the C standard library, such as wchar.h - * - Selected headers from the C++ standard library, such as new, functional - * - Selected header files of the STLSoft main project - * - The header files particular to the technology area, in this case the COM library headers, such as objbase.h - * - The binary (static and dynamic libraries) components particular to the technology area, in this case the COM libraries that ship with the operating system and your compiler(s) - * - * In addition, some parts of the libraries exhibit different behaviour when - * translated in different contexts, such as with _WIN32_DCOM - * defined, or with iaccess.h include. In all - * cases the libraries function correctly in whatever context they are compiled. - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * STLSoft version - * - * The libraries version information is comprised of major, minor and revision - * components. - * - * The major version is denoted by the _STLSOFT_VER_MAJOR preprocessor symbol. - * A changes to the major version component implies that a dramatic change has - * occured in the libraries, such that considerable changes to source dependent - * on previous versions would need to be effected. - * - * The minor version is denoted by the _STLSOFT_VER_MINOR preprocessor symbol. - * Changes to the minor version component imply that a significant change has - * occured to the libraries, either in the addition of new functionality or in - * the destructive change to one or more components such that recomplilation and - * code change may be necessitated. - * - * The revision version is denoted by the _STLSOFT_VER_REVISIO preprocessor - * symbol. Changes to the revision version component imply that a bug has been - * fixed. Dependent code should be recompiled in order to pick up the changes. - * - * In addition to the individual version symbols - _STLSOFT_VER_MAJOR, - * _STLSOFT_VER_MINOR and _STLSOFT_VER_REVISION - a composite symbol _STLSOFT_VER - * is defined, where the upper 8 bits are 0, bits 16-23 represent the major - * component, bits 8-15 represent the minor component, and bits 0-7 represent - * the revision component. - * - * Each release of the libraries will bear a different version, and that version - * will also have its own symbol: Version 1.0.1 specifies _STLSOFT_VER_1_0_1. - * - * Thus the symbol _STLSOFT_VER may be compared meaningfully with a specific - * version symbol, e.g.# if _STLSOFT_VER >= _STLSOFT_VER_1_0_1 - */ - -/// \def _STLSOFT_VER_MAJOR -/// The major version number of STLSoft - -/// \def _STLSOFT_VER_MINOR -/// The minor version number of STLSoft - -/// \def _STLSOFT_VER_REVISION -/// The revision version number of STLSoft - -/// \def _STLSOFT_VER -/// The current composite version number of STLSoft - -#define _STLSOFT_VER_MAJOR 1 -#define _STLSOFT_VER_MINOR 6 -#define _STLSOFT_VER_REVISION 6 -#define _STLSOFT_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */ -#define _STLSOFT_VER_1_0_2 0x00010002 /*!< Version 1.0.2 */ -#define _STLSOFT_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */ -#define _STLSOFT_VER_1_1_2 0x00010102 /*!< Version 1.1.2 */ -#define _STLSOFT_VER_1_1_3 0x00010103 /*!< Version 1.1.3 */ -#define _STLSOFT_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */ -#define _STLSOFT_VER_1_3_1 0x00010301 /*!< Version 1.3.1 */ -#define _STLSOFT_VER_1_3_2 0x00010302 /*!< Version 1.3.2 */ -#define _STLSOFT_VER_1_4_1 0x00010401 /*!< Version 1.4.1 */ -#define _STLSOFT_VER_1_4_2 0x00010402 /*!< Version 1.4.2 */ -#define _STLSOFT_VER_1_4_3 0x00010403 /*!< Version 1.4.3 */ -#define _STLSOFT_VER_1_4_4 0x00010404 /*!< Version 1.4.4 */ -#define _STLSOFT_VER_1_4_5 0x00010405 /*!< Version 1.4.5 */ -#define _STLSOFT_VER_1_4_6 0x00010406 /*!< Version 1.4.6 */ -#define _STLSOFT_VER_1_5_1 0x00010501 /*!< Version 1.5.1 */ -#define _STLSOFT_VER_1_5_2 0x00010502 /*!< Version 1.5.2 */ -#define _STLSOFT_VER_1_6_1 0x00010601 /*!< Version 1.6.1 */ -#define _STLSOFT_VER_1_6_2 0x00010602 /*!< Version 1.6.2 */ -#define _STLSOFT_VER_1_6_3 0x00010603 /*!< Version 1.6.3 */ -#define _STLSOFT_VER_1_6_4 0x00010604 /*!< Version 1.6.4 */ -#define _STLSOFT_VER_1_6_5 0x00010605 /*!< Version 1.6.5 */ -#define _STLSOFT_VER_1_6_6 0x00010606 /*!< Version 1.6.6 */ - -#define _STLSOFT_VER _STLSOFT_VER_1_6_6 - -/* ///////////////////////////////////////////////////////////////////////////// - * Basic macros - */ - -/* Compilation messages - * - * To see certain informational messages during compilation define the - * preprocessor symbol _STLSOFT_COMPILE_VERBOSE - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define STLSOFT_STRINGIZE_(x) #x -# define STLSOFT_STRINGIZE(x) STLSOFT_STRINGIZE_(x) -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* Simple macro indirection - */ - -#define STLSOFT_MACRO_INDIRECT(x) x - -/* ///////////////////////////////////////////////////////////////////////////// - * Sanity checks - 1 - * - * C++ - must be C++ compilation unit - */ - -/* Must be C++. */ -#ifndef __cplusplus -# error The STLSoft libraries are only compatible with C++ compilation units -#endif /* __cplusplus */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler compatibility - * - * Currently the only compilers supported by the STLSoft libraries are - * - * Borland C++ 5.5, 5.51 & 5.6 - * Comeau 4.3.1 - * Digital Mars C/C++ 8.26 and above - * GCC 2.95, 2.96 & 3.2 - * Intel C/C++ 6.0 & 7.0 - * Metrowerks 2.4 & 3.0 (CodeWarrior 7.0 & 8.0) - * Visual C++ 4.2, 5.0, 6.0 & .NET - * Watcom C/C++ 11.0 - * - * The following compilers are intended to be supported in a future release: - * - * Comeau C++ - */ - -#ifdef __STLSOFT_COMPILER_IS_UNKNOWN -# undef __STLSOFT_COMPILER_IS_UNKNOWN -#endif /* __STLSOFT_COMPILER_IS_UNKNOWN */ - -#ifdef __STLSOFT_COMPILER_IS_BORLAND -# undef __STLSOFT_COMPILER_IS_BORLAND -#endif /* __STLSOFT_COMPILER_IS_BORLAND */ - -#ifdef __STLSOFT_COMPILER_IS_COMO -# undef __STLSOFT_COMPILER_IS_COMO -#endif /* __STLSOFT_COMPILER_IS_COMO */ - -#ifdef __STLSOFT_COMPILER_IS_DMC -# undef __STLSOFT_COMPILER_IS_DMC -#endif /* __STLSOFT_COMPILER_IS_DMC */ - -#ifdef __STLSOFT_COMPILER_IS_GCC -# undef __STLSOFT_COMPILER_IS_GCC -#endif /* __STLSOFT_COMPILER_IS_GCC */ - -#ifdef __STLSOFT_COMPILER_IS_INTEL -# undef __STLSOFT_COMPILER_IS_INTEL -#endif /* __STLSOFT_COMPILER_IS_INTEL */ - -#ifdef __STLSOFT_COMPILER_IS_MSVC -# undef __STLSOFT_COMPILER_IS_MSVC -#endif /* __STLSOFT_COMPILER_IS_MSVC */ - -#ifdef __STLSOFT_COMPILER_IS_MWERKS -# undef __STLSOFT_COMPILER_IS_MWERKS -#endif /* __STLSOFT_COMPILER_IS_MWERKS */ - -#ifdef __STLSOFT_COMPILER_IS_VECTORC -# undef __STLSOFT_COMPILER_IS_VECTORC -#endif /* __STLSOFT_COMPILER_IS_VECTORC */ - -#ifdef __STLSOFT_COMPILER_IS_WATCOM -# undef __STLSOFT_COMPILER_IS_WATCOM -#endif /* __STLSOFT_COMPILER_IS_WATCOM */ - -/* First we do a check to see whether other compilers are providing - * compatibility with Visual C++, and handle that. - */ - -#ifdef _MSC_VER -# if defined(__BORLANDC__) || /* Borland C/C++ */ \ - defined(__COMO__) || /* Comeau C/C++ */ \ - defined(__DMC__) || /* Digital Mars C/C++ */ \ - defined(__GNUC__) || /* GNU C/C++ */ \ - defined(__INTEL_COMPILER) || /* Intel C/C++ */ \ - defined(__MWERKS__) || /* Metrowerks C/C++ */ \ - defined(__WATCOMC__) /* Watcom C/C++ */ - /* Handle Microsoft Visual C++ support. */ -# if defined(_STLSOFT_NO_MSC_VER_SUPPORT) || \ - ( defined(_STLSOFT_STRICT) && \ - !defined(_STLSOFT_MSC_VER_SUPPORT)) -# undef _MSC_VER -# endif /* _STLSOFT_NO_MSC_VER_SUPPORT || (_STLSOFT_STRICT && _STLSOFT_MSC_VER_SUPPORT) */ -# endif /* compiler */ -#endif /* _MSC_VER */ - -#if defined(_STLSOFT_FORCE_CUSTOM_COMPILER) -# define __STLSOFT_COMPILER_LABEL_STRING "Custom (forced) compiler" -# define __STLSOFT_COMPILER_VERSION_STRING "Custom (forced) compiler" -# define __STLSOFT_COMPILER_IS_CUSTOM -# ifndef __STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME -# error When using the custom compiler option you must define the symbol __STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME, e.g. #define __STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME -# endif /* !__STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME */ - -#elif defined(__COMO__) /* Do Comeau next, so that no Comeau back-end server compilers are preferentially discriminated */ -/* Comeau C++ */ -# define __STLSOFT_COMPILER_IS_COMO -# define __STLSOFT_COMPILER_LABEL_STRING "Comeau C++" -# if __COMO_VERSION__ < 4300 -# error Only versions 4.3.0.1 and later of Comeau C++ compiler is supported by the STLSoft libraries -# elif (__COMO_VERSION__ == 4300) -# define __STLSOFT_COMPILER_VERSION_STRING "Comeau C++ 4.3.0.1" -# else -# define __STLSOFT_COMPILER_VERSION_STRING "Unknown version of Comeau C++" -# endif /* __COMO_VERSION__ */ - -#elif defined(__BORLANDC__) -/* Borland C++ */ -# define __STLSOFT_COMPILER_IS_BORLAND -# define __STLSOFT_COMPILER_LABEL_STRING "Borland C/C++" -# if 0 /* (__BORLANDC__ == 0x0460) */ -# define __STLSOFT_COMPILER_VERSION_STRING "Borland C++ 4.52" -# elif (__BORLANDC__ == 0x0550) -# define __STLSOFT_COMPILER_VERSION_STRING "Borland C++ 5.5" -# elif (__BORLANDC__ == 0x0551) -# define __STLSOFT_COMPILER_VERSION_STRING "Borland C++ 5.51" -# elif (__BORLANDC__ == 0x0560) -# define __STLSOFT_COMPILER_VERSION_STRING "Borland C++ 5.6" -# elif (__BORLANDC__ == 0x0564) -# define __STLSOFT_COMPILER_VERSION_STRING "Borland C++ 5.64 (C++ BuilderX)" -# else - /*# error Currently only versions 4.52, 5.5, 5.51 and 5.6 of the Borland C++ compiler are supported by the STLSoft libraries */ -# error Currently only versions 5.5, 5.51 and 5.6 of the Borland C++ compiler are supported by the STLSoft libraries -# endif /* __BORLANDC__ */ - -#elif defined(__DMC__) -/* Digital Mars C/C++ */ -# define __STLSOFT_COMPILER_IS_DMC -# define __STLSOFT_COMPILER_LABEL_STRING "Digital Mars C/C++" -# if (__DMC__ < 0x0826) -# error Only versions 8.26 and later of the Digital Mars C/C++ compilers are supported by the STLSoft libraries -# else -# if __DMC__ >= 0x0832 -# define __STLSOFT_COMPILER_VERSION_STRING __DMC_VERSION_STRING__ -# elif (__DMC__ == 0x0826) -# define __STLSOFT_COMPILER_VERSION_STRING "Digital Mars C/C++ 8.26" -# elif (__DMC__ == 0x0827) -# define __STLSOFT_COMPILER_VERSION_STRING "Digital Mars C/C++ 8.27" -# elif (__DMC__ == 0x0828) -# define __STLSOFT_COMPILER_VERSION_STRING "Digital Mars C/C++ 8.28" -# elif (__DMC__ == 0x0829) -# define __STLSOFT_COMPILER_VERSION_STRING "Digital Mars C/C++ 8.29" -# elif (__DMC__ == 0x0830) -# define __STLSOFT_COMPILER_VERSION_STRING "Digital Mars C/C++ 8.30" -# elif (__DMC__ == 0x0831) -# define __STLSOFT_COMPILER_VERSION_STRING "Digital Mars C/C++ 8.31" -# endif /* __DMC__ */ -# endif /* version */ - -#elif defined(__GNUC__) -/* GNU C/C++ */ -# define __STLSOFT_COMPILER_IS_GCC -# define __STLSOFT_COMPILER_LABEL_STRING "GNU C/C++" -# if __GNUC__ != 2 && \ - __GNUC__ != 3 && \ - __GNUC__ != 4 -# error GNU C/C++ compilers whose major version is not 2 or 3 are not currently supported by the STLSoft libraries -# elif __GNUC__ == 2 -# if __GNUC_MINOR__ < 95 -# error Currently only version 2.95 and above of the GNU C/C++ compiler is supported by the STLSoft libraries -# elif __GNUC_MINOR__ == 95 -# define __STLSOFT_COMPILER_VERSION_STRING "GNU C/C++ 2.95" -# elif __GNUC_MINOR__ == 96 -# define __STLSOFT_COMPILER_VERSION_STRING "GNU C/C++ 2.96" -# else -# define __STLSOFT_COMPILER_VERSION_STRING "GNU C/C++ >2.96 - you should be aware that this version may not be supported correctly" -# endif /* __GNUC__ != 2 */ -# elif __GNUC__ == 3 -# if __GNUC_MINOR__ == 2 -# define __STLSOFT_COMPILER_VERSION_STRING "GNU C/C++ 3.2" -# else -# define __STLSOFT_COMPILER_VERSION_STRING "GNU C/C++ >3.2 - you should be aware that this version may not be supported correctly" -# endif /* __GNUC__ != 2 */ -# elif __GNUC__ == 4 -# define __STLSOFT_COMPILER_VERSION_STRING "GNU C/C++ >= 4.0 - you should be aware that this version may not be supported correctly" -# endif /* __GNUC__ */ - -#elif defined(__INTEL_COMPILER) -/* Intel C++ */ -# define __STLSOFT_COMPILER_IS_INTEL -# define __STLSOFT_COMPILER_LABEL_STRING "Intel C/C++" -# if (__INTEL_COMPILER == 600) -# define __STLSOFT_COMPILER_VERSION_STRING "Intel C/C++ 6.0" -# elif (__INTEL_COMPILER == 700) -# define __STLSOFT_COMPILER_VERSION_STRING "Intel C/C++ 7.0" -# else -# error Only Intel C++ Compiler versions 6.0 and 7.0 currently supported by the STLSoft libraries -# endif /* __INTEL_COMPILER */ - -#elif defined(__MWERKS__) -/* Metrowerks C++ */ -# define __STLSOFT_COMPILER_IS_MWERKS -# define __STLSOFT_COMPILER_LABEL_STRING "Metrowerks CodeWarrior C/C++" -# if ((__MWERKS__ & 0xFF00) == 0x2400) -# define __STLSOFT_COMPILER_VERSION_STRING "Metrowerks CodeWarrior C++ 2.4" -# elif ((__MWERKS__ & 0xFF00) == 0x3000) -# define __STLSOFT_COMPILER_VERSION_STRING "Metrowerks CodeWarrior C++ 3.0" -# else -# error Only Metrowerks C++ Compiler 2.4 (CodeWarrior 7) and 3.0 (CodeWarrior 8) currently supported by the STLSoft libraries -# endif /* __MWERKS__ */ - -#elif defined(__VECTORC) -/* CodePlay Vector C/C++ */ -# define __STLSOFT_COMPILER_IS_VECTORC -# define __STLSOFT_COMPILER_LABEL_STRING "CodePlay VectorC C/C++" -# if (__VECTORC == 1) -# define __STLSOFT_COMPILER_VERSION_STRING "CodePlay VectorC C/C++" -# else -# error Currently only versions of the CodePlay Vector C/C++ compiler defining __VECTORC == 1 are supported by the STLSoft libraries -# endif /* __VECTORC */ - -#elif defined(__WATCOMC__) -/* Watcom C/C++ */ -# define __STLSOFT_COMPILER_IS_WATCOM -# define __STLSOFT_COMPILER_LABEL_STRING "Watcom C/C++" - -# if (__WATCOMC__ == 1100) -# define __STLSOFT_COMPILER_VERSION_STRING "Watcom C/C++ 11.0" -# elif (__WATCOMC__ == 1200) -# define __STLSOFT_COMPILER_VERSION_STRING "Open Watcom C/C++ 1.0 (Watcom 12.0)" -# else -# error Currently only versions 11.0 and 12.0 of the Watcom C/C++ compiler is supported by the STLSoft libraries -# endif /* __WATCOMC__ */ - -#elif defined(_MSC_VER) -/* Visual C++ */ -# define __STLSOFT_COMPILER_IS_MSVC -# define __STLSOFT_COMPILER_LABEL_STRING "Visual C++" - -# if (_MSC_VER == 1020) -# define __STLSOFT_COMPILER_VERSION_STRING "Visual C++ 4.2" -# elif (_MSC_VER == 1100) -# define __STLSOFT_COMPILER_VERSION_STRING "Visual C++ 5.0" -# elif (_MSC_VER == 1200) -# define __STLSOFT_COMPILER_VERSION_STRING "Visual C++ 6.0" -# elif (_MSC_VER == 1300) -# define __STLSOFT_COMPILER_VERSION_STRING "Visual C++ .NET (7.0)" -# elif (_MSC_VER == 1310) -# define __STLSOFT_COMPILER_VERSION_STRING "Visual C++ .NET (7.1)" -# else -# error Currently only versions 4.2, 5.0, 6.0, 7.0 & 7.1 of the Visual C++ compiler are supported by the STLSoft libraries -# endif /* _MSC_VER */ - -#else -/* No recognised compiler */ -# if defined(_STLSOFT_FORCE_UNKNOWN_COMPILER) || \ - defined(_STLSOFT_FORCE_ANY_COMPILER) -# define __STLSOFT_COMPILER_LABEL_STRING "Unknown (forced) compiler" -# define __STLSOFT_COMPILER_VERSION_STRING "Unknown (forced) compiler" -# define __STLSOFT_COMPILER_IS_UNKNOWN -# else -# error Compiler is not recognised. -# error Currently only Borland C++, Comeau C++, Digital Mars C/C++, GNU C/C++, -# error Intel C/C++, Metrowerks CodeWarrior, Visual C++ and Watcom C/C++ -# error compilers are supported by the STLSoft libraries -# error If you want to use the libraries with your compiler, you may specify the -# error _STLSOFT_FORCE_CUSTOM_COMPILER or _STLSOFT_FORCE_ANY_COMPILER pre-processor -# error symbols. -# error _STLSOFT_FORCE_ANY_COMPILER assumes that your compiler can support all -# error modern C++ compiler features, and causes the inclusion of the compiler -# error features file stlsoft_cccap_unknown.h, which is provided by STLSoft. -# error _STLSOFT_FORCE_CUSTOM_COMPILER requires that you specify the name of the -# error compiler features file in __STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME. -# error The idea is to use _STLSOFT_FORCE_ANY_COMPILER, to determine what language -# error features your compiler can support, and then copy, edit and use that file -# error via _STLSOFT_FORCE_CUSTOM_COMPILER and __STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME. -# endif /* _STLSOFT_FORCE_ANY_COMPILER */ - -#endif /* compiler tag */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler language feature support - * - * Various compilers support the language differently (or not at all), so these - * features are discriminated here and utilised by various means within the code - * in order to minimise the use of the preprocessor conditionals in the other - * libraries' source code. - */ - -/* Template support. - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_SUPPORT - */ - -#ifdef __STLSOFT_CF_TEMPLATE_SUPPORT -# undef __STLSOFT_CF_TEMPLATE_SUPPORT -#endif /* __STLSOFT_CF_TEMPLATE_SUPPORT */ - -/* Exception signature support. - * - * Discriminated symbol is __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT - */ -#ifdef __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT -# undef __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT -#endif /* __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT */ - -/* Native bool support. - * - * Discriminated symbol is __STLSOFT_CF_NATIVE_BOOL_SUPPORT - */ -#ifdef __STLSOFT_CF_NATIVE_BOOL_SUPPORT -# undef __STLSOFT_CF_NATIVE_BOOL_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_BOOL_SUPPORT */ - -/* Native / typedef'd wchar_t support. - * - * Discriminated symbols are __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT - * __STLSOFT_CF_TYPEDEF_WCHAR_T_SUPPORT - * - * Implementation symbol is __STLSOFT_NATIVE_WCHAR_T - */ -#ifdef __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT -# undef __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT */ - -#ifdef __STLSOFT_CF_TYPEDEF_WCHAR_T_SUPPORT -# undef __STLSOFT_CF_TYPEDEF_WCHAR_T_SUPPORT -#endif /* __STLSOFT_CF_TYPEDEF_WCHAR_T_SUPPORT */ - -#ifdef __STLSOFT_NATIVE_WCHAR_T -# undef __STLSOFT_NATIVE_WCHAR_T -#endif /* __STLSOFT_NATIVE_WCHAR_T */ - -/* 8-bit, 16-bit, 32-bit type support - * - * Discriminated symbol is __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT, - * __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT, - * __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT - * - * Implementation symbol are __STLSOFT_NATIVE_INT8_T, - * __STLSOFT_NATIVE_SINT8_T, - * __STLSOFT_NATIVE_UINT8_T, - * __STLSOFT_NATIVE_INT16_T, - * __STLSOFT_NATIVE_SINT16_T, - * __STLSOFT_NATIVE_UINT16_T, - * __STLSOFT_NATIVE_INT32_T, - * __STLSOFT_NATIVE_SINT32_T, - * __STLSOFT_NATIVE_UINT32_T - */ - -#ifdef __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT -# undef __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT */ - -#ifdef __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT -# undef __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT */ - -#ifdef __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT -# undef __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT */ - -#ifdef __STLSOFT_NATIVE_INT8_T -# undef __STLSOFT_NATIVE_INT8_T -#endif /* __STLSOFT_NATIVE_INT8_T */ -#ifdef __STLSOFT_NATIVE_SINT8_T -# undef __STLSOFT_NATIVE_SINT8_T -#endif /* __STLSOFT_NATIVE_SINT8_T */ -#ifdef __STLSOFT_NATIVE_UINT8_T -# undef __STLSOFT_NATIVE_UINT8_T -#endif /* __STLSOFT_NATIVE_UINT8_T */ - -#ifdef __STLSOFT_NATIVE_INT16_T -# undef __STLSOFT_NATIVE_INT16_T -#endif /* __STLSOFT_NATIVE_INT16_T */ -#ifdef __STLSOFT_NATIVE_SINT16_T -# undef __STLSOFT_NATIVE_SINT16_T -#endif /* __STLSOFT_NATIVE_SINT16_T */ -#ifdef __STLSOFT_NATIVE_UINT16_T -# undef __STLSOFT_NATIVE_UINT16_T -#endif /* __STLSOFT_NATIVE_UINT16_T */ - -#ifdef __STLSOFT_NATIVE_INT32_T -# undef __STLSOFT_NATIVE_INT32_T -#endif /* __STLSOFT_NATIVE_INT32_T */ -#ifdef __STLSOFT_NATIVE_SINT32_T -# undef __STLSOFT_NATIVE_SINT32_T -#endif /* __STLSOFT_NATIVE_SINT32_T */ -#ifdef __STLSOFT_NATIVE_UINT32_T -# undef __STLSOFT_NATIVE_UINT32_T -#endif /* __STLSOFT_NATIVE_UINT32_T */ - -/* 64-bit support. - * - * Discriminated symbols are __STLSOFT_CF_NATIVE___int64_SUPPORT, - * __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT and - * __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT. - * - * 64-bit support is discriminated in the following two forms: - * - * (i) long long - * (ii) __int64 - * - * Form (i) support is selectively preferred. Form (ii) support - * is only discriminated in the absence of form (i). - */ - -#ifdef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT -# undef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT */ - -#ifdef __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT -# undef __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT -#endif /* __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT */ - -#ifdef __STLSOFT_CF_NATIVE___int64_SUPPORT -# undef __STLSOFT_CF_NATIVE___int64_SUPPORT -#endif /* __STLSOFT_CF_NATIVE___int64_SUPPORT */ - -#ifdef __STLSOFT_CF_INT_DISTINCT_TYPE -# undef __STLSOFT_CF_INT_DISTINCT_TYPE -#endif /* __STLSOFT_CF_INT_DISTINCT_TYPE */ - -/* Compiler supports static assert. - * - * Discriminated symbol is __STLSOFT_CF_STATIC_ASSERT_SUPPORT - */ -#ifdef __STLSOFT_CF_STATIC_ASSERT_SUPPORT -# undef __STLSOFT_CF_STATIC_ASSERT_SUPPORT -#endif /* __STLSOFT_CF_STATIC_ASSERT_SUPPORT */ - -/* Function signature requires full-qualification. - * - * Discriminated symbol is __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED - */ -#ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED -# undef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED -#endif /* __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED */ - -/* Exception support. - * - * Discriminated symbol is __STLSOFT_CF_EXCEPTION_SUPPORT - */ -#ifdef __STLSOFT_CF_EXCEPTION_SUPPORT -# undef __STLSOFT_CF_EXCEPTION_SUPPORT -#endif /* __STLSOFT_CF_EXCEPTION_SUPPORT */ - -/* Template class default fundamental type argument support - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT - * - * Microsoft Visual C++ 4.2 does not support template default fundamental type arguments. - */ -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT -# undef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT */ - -/* Template class default class type argument support - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - * - * Microsoft Visual C++ 4.2 does not support template default class type arguments. - */ -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT -# undef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - -/* Member functions can appear as template parameters - * - * Discriminated symbol is STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT - */ -#ifdef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT -# undef STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT -#endif /* STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT */ - -/* Member template function support. - * - * Discriminated symbol is __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT - */ -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT -# undef __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT -#endif // __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT - -/* Member template constructor support. - * - * Discriminated symbol is __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT - */ -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT -# undef __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT -#endif // __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT - -/* Member template range method support. - * - * Discriminated symbol is __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT - */ -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT -# undef __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT -#endif // __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT - -/* Member template class support. - * - * Discriminated symbol is __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT - */ -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT -# undef __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT -#endif // __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT - -/* Template specialisation syntax support - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX - */ -#ifdef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -# undef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -#endif /* __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX */ - -/* Template partial specialisation support. - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT - */ -#ifdef __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT -# undef __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT -#endif // __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT - -/* Template out-of-class function specialisation support. - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT - */ -#ifdef __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT -# undef __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT -#endif /* __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT */ - -/* Standard library STL elements in std namespace. - * - * Discriminated symbol is __STLSOFT_CF_std_NAMESPACE - */ -#ifdef __STLSOFT_CF_std_NAMESPACE -# undef __STLSOFT_CF_std_NAMESPACE -#endif /* __STLSOFT_CF_std_NAMESPACE */ - -/* std::char_traits available. - * - * Discriminated symbol is __STLSOFT_CF_std_char_traits_AVAILABLE - */ -#ifdef __STLSOFT_CF_std_char_traits_AVAILABLE -# undef __STLSOFT_CF_std_char_traits_AVAILABLE -#endif /* __STLSOFT_CF_std_char_traits_AVAILABLE */ - -/* stl-like allocator classes provide allocate() hint argument - * - * Discriminated symbol is __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT - * - * Note: this should be resolving on the library, not the compiler - */ -#ifdef __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT -# undef __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT -#endif /* __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT */ - -/* stl-like allocator classes provide deallocate() object count argument - * - * Discriminated symbol is __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT - * - * Note: this should be resolving on the library, not the compiler - */ -#ifdef __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT -# undef __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT -#endif /* __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT */ - -/* Bidirectional iterator support - */ -#ifdef __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT -# undef __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT -#endif /* __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */ - -/* explicit keyword support - * - * Discriminated symbol is __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT - */ -#ifdef __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT -# undef __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT -#endif /* __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT */ - -/* mutable keyword support - * - * Discriminated symbol is __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT - */ -#ifdef __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT -# undef __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT -#endif /* __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT */ - -/* typename keyword support - * - * Discriminated symbols are __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT, - * __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT, - * __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT and - * __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT - * - * The typename keyword is actually used for two distinct purposes: the - * generic type placeholder in template parameter specifications, and the - * stipulation to compilers that a particular template derived construct - * is a type, rather than a member or operation. - * - * These two uses have varying support on different compilers, hence the - * STLSoft libraries utilise the ss_typename_param_k pseudo keyword for the - * first purpose, and the ss_typename_type_k pseudo keyword for the second. - * - * In addition, some compilers cannot handle the use of typename as a type - * qualifier in a template default parameter, so we further define the keyword - * ss_typename_type_def_k. And some cannot handle it in a constructor - * initialiser list, for which ss_typename_type_mil_k is defined. - */ -#ifdef __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT -# undef __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT -#endif /* __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT */ - -#ifdef __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT -# undef __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT -#endif /* __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT */ - -#ifdef __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT -# undef __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT -#endif /* __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT */ - -#ifdef __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT -# undef __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT -#endif /* __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT */ - -/* Move constructor support - * - * Discriminated symbol is __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT - */ -#ifdef __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT -# undef __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT -#endif /* __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */ - -/* Koening Lookup support - * - * Discriminated symbol is __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT - */ -#ifdef __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT -# undef __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT -#endif /* __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT */ - -/* Template template support - * - * Discriminated symbol is __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT - */ -#ifdef __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT -# undef __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT -#endif /* __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT */ - - -#ifdef __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT -# undef __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT -#endif /* __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT */ - -#ifdef __STLSOFT_CF_VENEER_SUPPORT -# undef __STLSOFT_CF_VENEER_SUPPORT -#endif /* __STLSOFT_CF_VENEER_SUPPORT */ - -#ifdef __STLSOFT_CF_TEMPLATE_SHIMS_NOT_SUPPORTED -# undef __STLSOFT_CF_TEMPLATE_SHIMS_NOT_SUPPORTED -#endif /* __STLSOFT_CF_TEMPLATE_SHIMS_NOT_SUPPORTED */ - -#ifdef __STLSOFT_CF_NEGATIVE_MODULUS_POSITIVE_GIVES_NEGATIVE_RESULT -# undef __STLSOFT_CF_NEGATIVE_MODULUS_POSITIVE_GIVES_NEGATIVE_RESULT -#endif /* __STLSOFT_CF_NEGATIVE_MODULUS_POSITIVE_GIVES_NEGATIVE_RESULT */ - -#ifdef STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT -# undef STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT -#endif /* STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - -#ifdef STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT -# undef STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT -#endif /* STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - -#ifdef STLSOFT_CF_FASTCALL_SUPPORTED -# undef STLSOFT_CF_FASTCALL_SUPPORTED -#endif /* STLSOFT_CF_FASTCALL_SUPPORTED */ - -#ifdef STLSOFT_CF_STDCALL_SUPPORTED -# undef STLSOFT_CF_STDCALL_SUPPORTED -#endif /* STLSOFT_CF_STDCALL_SUPPORTED */ - -#ifdef STSLSOFT_INLINE_ASM_SUPPORTED -# undef STSLSOFT_INLINE_ASM_SUPPORTED -#endif /* STSLSOFT_INLINE_ASM_SUPPORTED */ - -#ifdef STSLSOFT_ASM_IN_INLINE_SUPPORTED -# undef STSLSOFT_ASM_IN_INLINE_SUPPORTED -#endif /* STSLSOFT_ASM_IN_INLINE_SUPPORTED */ - -/* Now we include the appropriate compiler-specific header */ - -#if defined(__STLSOFT_COMPILER_IS_CUSTOM) -# include __STLSOFT_CF_CUSTOM_COMPILER_INCLUDE_NAME -#elif defined(__STLSOFT_COMPILER_IS_UNKNOWN) -# include "stlsoft_cccap_unknown.h" -#elif defined(__STLSOFT_COMPILER_IS_BORLAND) -# include "stlsoft_cccap_borland.h" -#elif defined(__STLSOFT_COMPILER_IS_COMO) -# include "stlsoft_cccap_como.h" -#elif defined(__STLSOFT_COMPILER_IS_DMC) -# include "stlsoft_cccap_dmc.h" -#elif defined(__STLSOFT_COMPILER_IS_GCC) -# include "stlsoft_cccap_gcc.h" -#elif defined(__STLSOFT_COMPILER_IS_INTEL) -# include "stlsoft_cccap_intel.h" -#elif defined(__STLSOFT_COMPILER_IS_MSVC) -# include "stlsoft_cccap_msvc.h" -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) -# include "stlsoft_cccap_mwerks.h" -#elif defined(__STLSOFT_COMPILER_IS_VECTORC) -# include "stlsoft_cccap_vectorc.h" -#elif defined(__STLSOFT_COMPILER_IS_WATCOM) -# include "stlsoft_cccap_watcom.h" -#else -# error Compiler not correctly discriminated -#endif /* compiler */ - -#if defined(_STLSOFT_COMPILE_VERBOSE) && \ - !defined(STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT) -# undef _STLSOFT_COMPILE_VERBOSE -# endif /* !STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT && _STLSOFT_COMPILE_VERBOSE */ - -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message(__STLSOFT_COMPILER_VERSION_STRING) -# endif /* STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT && _STLSOFT_COMPILE_VERBOSE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Sanity checks - 2 - * - * MBCS - none of the libraries code is written to support MBCS - */ - -/* Should not be MBCS. - * - * Only ANSI and Unicode character encoding schemese are explicitly supported. - */ -#ifdef _MBCS -# ifdef _STLSOFT_STRICT -# error The STLSoft libraries are not compatible with variable length character representation schemes such as MBCS -# else -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message("The STLSoft libraries are not compatible with variable length character representation schemes such as MBCS") -# endif /* _STLSOFT_COMPILE_VERBOSE */ -# endif /* _STLSOFT_STRICT */ -#endif /* _MBCS */ - - - - - -/* Template support */ -#ifndef __STLSOFT_CF_TEMPLATE_SUPPORT -# error Template support not detected. STLSoft libraries are template-based and require this support. -#endif /* __STLSOFT_CF_TEMPLATE_SUPPORT */ - - -/* Native 64-bit integer support */ -#if defined(__STLSOFT_CF_NATIVE___int64_SUPPORT) || \ - defined(__STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT) -# define __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT -#endif /* __STLSOFT_CF_NATIVE___int64_SUPPORT || __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT */ - -/* Out-of-class method definition argument full-qualification requirement */ -#ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED -# define _stlsoft_qualify_fn_arg(Q, T) Q::T -#else -# define _stlsoft_qualify_fn_arg(Q, T) T -#endif /* __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED */ - -/* Out-of-memory throws bad_alloc. - * - * Discriminated symbol is __STLSOFT_CF_NOTHROW_BAD_ALLOC - * - * By default, compilations with the Borland, and Watcom compilers throw - * bad_alloc in conditions of memory exhaustion, and those with Digital Mars - * and Microsoft do not. - * - * The Microsoft compilers do not throw bad_alloc for long established reasons, - * though they can be made to do so (see Matthew Wilson, "Generating - * Out-Of-Memory Exceptions", Windows Developer's Journal, Vol 12 Number 5, May - * 2001). This feature may be added in a forthcoming release of the libraries. - * - * The Digital Mars compiler appears to ship without any header files that - * define bad_alloc (whether in std or not), so it is therefore assumed that - * operator new will not throw exceptions in out of memory conditions. - * - * Define __STLSOFT_CF_THROW_BAD_ALLOC to force Microsoft to do so. - * Define __STLSOFT_CF_NO_THROW_BAD_ALLOC to prevent Borland/Comeau/Digital Mars/ - * GCC/Metrowerks/Watcom from doing so. - */ - -#ifndef __STLSOFT_CF_EXCEPTION_SUPPORT -# define __STLSOFT_CF_NOTHROW_BAD_ALLOC -#endif /* !__STLSOFT_CF_EXCEPTION_SUPPORT */ - -#ifdef __STLSOFT_CF_NOTHROW_BAD_ALLOC -# ifdef __STLSOFT_CF_THROW_BAD_ALLOC -# undef __STLSOFT_CF_THROW_BAD_ALLOC -# endif /* __STLSOFT_CF_THROW_BAD_ALLOC */ -#else - /* Leave it to whatever the compiler's capability discrimination has determined */ -#endif /* __STLSOFT_CF_NOTHROW_BAD_ALLOC */ - - -/* Template specialisation syntax support - */ -#ifdef __STLSOFT_TEMPLATE_SPECIALISATION -# undef __STLSOFT_TEMPLATE_SPECIALISATION -#endif /* __STLSOFT_TEMPLATE_SPECIALISATION */ - -#ifdef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -# define STLSOFT_TEMPLATE_SPECIALISATION template <> -#else -# define STLSOFT_TEMPLATE_SPECIALISATION -#endif /* __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX */ - - -/* Keyword support. - * - * Define _STLSOFT_FORCE_ALL_KEYWORDS to force the assumption of compiler - * support for all keywords. - * - * Define _STLSOFT_FORCE_KEYWORD_EXPLICIT to force the assumption of compiler - * support for the explicit keyword - * - * Define _STLSOFT_FORCE_KEYWORD_MUTABLE to force the assumption of compiler - * support for the mutable keyword - * - * Define _STLSOFT_FORCE_KEYWORD_TYPENAME to force the assumption of compiler - * support for the typename keyword - */ - -#ifdef _STLSOFT_FORCE_ALL_KEYWORDS -# define _STLSOFT_FORCE_KEYWORD_EXPLICIT -# define _STLSOFT_FORCE_KEYWORD_MUTABLE -# define _STLSOFT_FORCE_KEYWORD_TYPENAME -#endif /* _STLSOFT_FORCE_ALL_KEYWORDS */ - -#if !defined(__STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT) && \ - defined(_STLSOFT_FORCE_KEYWORD_EXPLICIT) -# define __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT -#endif /* !__STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT && _STLSOFT_FORCE_KEYWORD_EXPLICIT */ - -#if !defined(__STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT) && \ - defined(_STLSOFT_FORCE_KEYWORD_MUTABLE) -# define __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT -#endif /* !__STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT && _STLSOFT_FORCE_KEYWORD_MUTABLE */ - -#if !defined(__STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT) && \ - defined(_STLSOFT_FORCE_KEYWORD_TYPENAME) -# define __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT -#endif /* !__STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT && _STLSOFT_FORCE_KEYWORD_TYPENAME */ - -#if !defined(__STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT) && \ - defined(_STLSOFT_FORCE_KEYWORD_TYPENAME) -# define __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT -#endif /* !__STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT && _STLSOFT_FORCE_KEYWORD_TYPENAME */ - -#if !defined(__STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT) && \ - defined(_STLSOFT_FORCE_KEYWORD_TYPENAME) -# define __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT -#endif /* !__STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT && _STLSOFT_FORCE_KEYWORD_TYPENAME */ - -#if !defined(__STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT) && \ - defined(_STLSOFT_FORCE_KEYWORD_TYPENAME) -# define __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT -#endif /* !__STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT && _STLSOFT_FORCE_KEYWORD_TYPENAME */ - -/* ///////////////////////////////////////////////////////////////////////////// - * operator bool() - * - * If the symbol STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT - * is defined, operator bool should be defined as follows: - * - * class X - * { - * private: - * struct boolean { int i; } - * typedef int boolean::*boolean_t; - * public: - * operator boolean_t () const; - * - * otherwise it should be - * - * class X - * { - * private: - * typedef ss_bool_t boolean_t; - * public: - * operator boolean_t () const; - * - * - * If the symbol STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT - * is defined, it means that (!x) can de deduced by the compiler, otherwise it - * will need to be provided - * - * If STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT is not defined - * then STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT should not be - * defined, so we do a check here. - * - */ - -#if !defined(STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT) && \ - defined(STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT) -# error Cannot rely on use of boolean as pointer to member for operator ! -# error Undefine STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT when -# error STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT is not defined -#endif /* !STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT && STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Obsolete symbol definitions - * - * Define _STLSOFT_INCLUDE_OBSOLETE to include the definitions of symbols prior - * to version 1.5.1 - */ - -/* Verify that the significant changes to STLSoft 1.5.1 are checked with respect - * to other previously released projects - */ - -#if ( defined(_ATLSTL_VER) && \ - _ATLSTL_VER <= 0x00010204) || \ - ( defined(_COMSTL_VER) && \ - _COMSTL_VER <= 0x00010201) || \ - ( defined(_MFCSTL_VER) && \ - _MFCSTL_VER <= 0x00010202) || \ - ( defined(_UNIXSTL_VER) && \ - _UNIXSTL_VER <= 0x00000901) || \ - ( defined(_WINSTL_VER) && \ - _WINSTL_VER <= 0x00010201) -# ifdef _STLSOFT_STRICT -# error You are using an old version of one or more of ATLSTL, COMSTL, MFCSTL, UNIXSTL and WinSTL. Please upgrade all dependent projects in line with the STLSoft version you are using -# else -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message("You are using an old version of one or more of ATLSTL, COMSTL, MFCSTL, UNIXSTL and WinSTL. _STLSOFT_INCLUDE_OBSOLETE will be defined (but is not guaranteed to work!)") -# endif /* _STLSOFT_COMPILE_VERBOSE */ -# ifndef _STLSOFT_INCLUDE_OBSOLETE -# define _STLSOFT_INCLUDE_OBSOLETE -# endif /* !_STLSOFT_INCLUDE_OBSOLETE */ -# endif /* _STLSOFT_STRICT */ -#endif /* sub-project versions */ - -#ifdef _STLSOFT_INCLUDE_OBSOLETE -# include "stlsoft_cc_obsolete.h" -#endif /* _STLSOFT_INCLUDE_OBSOLETE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_NO_STD_INCLUDES -# include // standard types -# include // standard constants -#endif /* !_STLSOFT_NO_STD_INCLUDES */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Debugging - * - * The macro stlsoft_assert provides standard debug-mode assert functionality. - */ - -#if defined(_STLSOFT_NO_ASSERT) && \ - defined(__STLSOFT_CF_ASSERT_SUPPORT) -# undef __STLSOFT_CF_ASSERT_SUPPORT -#endif /* _STLSOFT_NO_ASSERT && __STLSOFT_CF_ASSERT_SUPPORT */ - -/// \def stlsoft_assert Defines a runtime assertion -/// -/// \param ex Must be non-zero, or an assertion will be fired -#ifdef __STLSOFT_CF_ASSERT_SUPPORT -# ifdef __STLSOFT_CF_USE_cassert - /* Using the standard assertion mechanism, located in */ -# include -# define stlsoft_assert(ex) assert(ex) -# else - /* Using either a custom or proprietary assertion mechanism, so must - * provide the header include name - */ -# ifndef __STLSOFT_CF_ASSERT_INCLUDE_NAME -# error Must supply an assert include filename with custom or proprietary assertion mechanism -# else -# include __STLSOFT_CF_ASSERT_INCLUDE_NAME -# endif /* !__STLSOFT_CF_ASSERT_INCLUDE_NAME */ -# endif /* __STLSOFT_CF_USE_cassert */ -# ifndef stlsoft_assert -# error If your compiler discrimination file supports assertions, it must defined stlsoft_assert() (taking a single parameter) -# endif /* !stlsoft_assert */ -#endif /* !__STLSOFT_CF_ASSERT_SUPPORT */ - -/// \def stlsoft_message_assert Defines a runtime assertion, with message -/// -/// \param ex Must be non-zero, or an assertion will be fired -/// \param _m The literal character string message to be included in the assertion -#if defined(__STLSOFT_CF_ASSERT_SUPPORT) -# if defined(__WATCOMC__) -# define stlsoft_message_assert(_m, ex) stlsoft_assert(ex) -# else -# define stlsoft_message_assert(_m, ex) stlsoft_assert((_m, ex)) -# endif /* __WATCOMC__ */ -#else -# define stlsoft_message_assert(_m, ex) -#endif /* __STLSOFT_CF_ASSERT_SUPPORT */ - -/// \def stlsoft_static_assert Defines a compile-time assertion -/// -/// \param ex Must be non-zero, or compilation will fail -#if defined(__STLSOFT_CF_STATIC_ASSERT_SUPPORT) -# if defined(__STLSOFT_COMPILER_IS_GCC) -# define stlsoft_static_assert(ex) do { typedef int ai[(ex) ? 1 : -1]; } while(0) -# else -# define stlsoft_static_assert(ex) do { typedef int ai[(ex) ? 1 : 0]; } while(0) -# endif /* compiler */ -#else -# define stlsoft_static_assert(ex) stlsoft_message_assert("Static assertion failed: ", (ex)) -#endif /* __STLSOFT_COMPILER_IS_DMC */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The STLSoft uses namespaces by default, unless the _STLSOFT_NO_NAMESPACES - * preprocessor symbol is defined, in which case all elements are placed within - * the global namespace. - * - * The macro stlsoft_ns_qual() macro can be used to refer to elements in the - * STLSoft libraries irrespective of whether they are in the stlsoft namespace - * or in the global namespace. - * - * Some compilers do not support the standard library in the std namespace, so - * the stlsoft_ns_qual_std() macro can be used to refer to elements in the - * STLSoft libraries irrespective of whether they are in the std namespace or - * in the global namespace. - */ - -/* No STLSoft namespaces means no stlsoft namespace */ -#ifdef _STLSOFT_NO_NAMESPACES -# define _STLSOFT_NO_NAMESPACE -#endif /* _STLSOFT_NO_NAMESPACES */ - -#ifndef _STLSOFT_NO_NAMESPACE -/// The STLSoft namespace - \c stlsoft - is the namespace for the STLSoft main -/// project, and the root namespace for all the other STLSoft projects, whose -/// individual namespaces reside within it. -namespace stlsoft -{ -#endif /* !_STLSOFT_NO_NAMESPACE */ - -/// \def stlsoft_ns_qual(x) -/// Qualifies with stlsoft:: if STLSoft is using namespaces or, if not, does not qualify - -/// \def stlsoft_ns_using(x) -/// Declares a using directive (with respect to stlsoft) if STLSoft is using namespaces or, if not, does nothing - -#ifndef _STLSOFT_NO_NAMESPACE -# define stlsoft_ns_qual(x) ::stlsoft::x -# define stlsoft_ns_using(x) using ::stlsoft::x; -#else -# define stlsoft_ns_qual(x) x -# define stlsoft_ns_using(x) -#endif /* !_STLSOFT_NO_NAMESPACE */ - -/// \def stlsoft_ns_qual_std(x) -/// Qualifies with std:: if STLSoft is being translated in the context of the standard library being within the std namespace or, if not, does not qualify - -/// \def stlsoft_ns_using_std(x) -/// Declares a using directive (with respect to std) if STLSoft is being translated in the context of the standard library being within the std namespace or, if not, does nothing - -#ifdef __STLSOFT_CF_std_NAMESPACE -# define stlsoft_ns_qual_std(x) ::std::x -# define stlsoft_ns_using_std(x) using ::std::x; -#else -# define stlsoft_ns_qual_std(x) x -# define stlsoft_ns_using_std(x) -#endif /* !__STLSOFT_CF_std_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - * - * The STLSoft uses a number of typedefs to aid in compiler-independence in the - * libraries' main code. - */ - -/* Type definitions - precursors */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - -/* ptrdiff_t - */ -#ifndef _STLSOFT_NO_STD_INCLUDES - typedef ptrdiff_t ss_ptrdiff_pr_t_; // ptr diff -#else - typedef int ss_ptrdiff_pr_t_; // ptr diff -#endif /* !_STLSOFT_NO_STD_INCLUDES */ - -/* size_t - */ -#ifndef _STLSOFT_NO_STD_INCLUDES - typedef size_t ss_size_pr_t_; // size -#else - typedef unsigned int ss_size_pr_t_; // size -#endif /* !_STLSOFT_NO_STD_INCLUDES */ - -/* wchar_t - * - * wchar_t is either a built-in type, or is defined to unsigned 16-bit value - */ - -#ifdef __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT - /* It's some kind of compiler native type. */ -# ifndef __STLSOFT_NATIVE_WCHAR_T - /* either wchar_t itself */ - typedef wchar_t ss_char_w_pr_t_; // Unicode char type -# else - /* or a compiler-specific type */ - typedef __STLSOFT_NATIVE_WCHAR_T ss_char_w_pr_t_; // Unicode char type -# endif /* !__STLSOFT_NATIVE_WCHAR_T */ -#elif defined(__STLSOFT_CF_TYPEDEF_WCHAR_T_SUPPORT) - typedef wchar_t ss_char_w_pr_t_; // Unicode char type -#else - /* It's some kind of library-defined type. */ -# ifndef _STLSOFT_NO_STD_INCLUDES - typedef wchar_t ss_char_w_pr_t_; // Unicode char type -# else - typedef unsigned short ss_char_w_pr_t_; // Unicode char type -# endif /* __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT */ -#endif /* !__STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT */ - -/* 8-bit */ -#ifdef __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT - typedef __STLSOFT_NATIVE_INT8_T ss_int8_pr_t_; - typedef __STLSOFT_NATIVE_SINT8_T ss_sint8_pr_t_; - typedef __STLSOFT_NATIVE_UINT8_T ss_uint8_pr_t_; -#else - typedef signed char ss_int8_pr_t_; - typedef signed char ss_sint8_pr_t_; - typedef unsigned char ss_uint8_pr_t_; -#endif /* __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT */ - -/* 16-bit */ -#ifdef __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT - typedef __STLSOFT_NATIVE_INT16_T ss_int16_pr_t_; - typedef __STLSOFT_NATIVE_SINT16_T ss_sint16_pr_t_; - typedef __STLSOFT_NATIVE_UINT16_T ss_uint16_pr_t_; -#else - typedef short ss_int16_pr_t_; - typedef signed short ss_sint16_pr_t_; - typedef unsigned short ss_uint16_pr_t_; -#endif /* __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT */ - -/* 32-bit */ -#ifdef __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT - typedef __STLSOFT_NATIVE_INT32_T ss_int32_pr_t_; - typedef __STLSOFT_NATIVE_SINT32_T ss_sint32_pr_t_; - typedef __STLSOFT_NATIVE_UINT32_T ss_uint32_pr_t_; -#else - typedef long ss_int32_pr_t_; - typedef signed long ss_sint32_pr_t_; - typedef unsigned long ss_uint32_pr_t_; -#endif /* __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT */ - -/* 64-bit */ -#ifdef __STLSOFT_CF_NATIVE___int64_SUPPORT - typedef __int64 ss_int64_pr_t_; - typedef signed __int64 ss_sint64_pr_t_; - typedef unsigned __int64 ss_uint64_pr_t_; -#elif defined(__STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT) - typedef long long ss_int64_pr_t_; - typedef signed long long ss_sint64_pr_t_; - typedef unsigned long long ss_uint64_pr_t_; -#endif /* __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT */ - -/* bool */ -#ifdef __STLSOFT_CF_NATIVE_BOOL_SUPPORT - typedef bool ss_bool_pr_t_; -#else - typedef unsigned int ss_bool_pr_t_; -#endif /* __STLSOFT_CF_NATIVE_BOOL_SUPPORT */ - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* Type definitions - proper */ - -typedef char ss_char_a_t; //!< Ansi char type -typedef ss_char_w_pr_t_ ss_char_w_t; //!< Unicode char type -typedef ss_int8_pr_t_ ss_int8_t; //!< 8-bit integer -typedef ss_sint8_pr_t_ ss_sint8_t; //!< 8-bit signed integer -typedef ss_uint8_pr_t_ ss_uint8_t; //!< 8-bit unsigned integer -typedef ss_int16_pr_t_ ss_int16_t; //!< 16-bit integer -typedef ss_sint16_pr_t_ ss_sint16_t; //!< 16-bit signed integer -typedef ss_uint16_pr_t_ ss_uint16_t; //!< 16-bit unsigned integer -typedef ss_int32_pr_t_ ss_int32_t; //!< 32-bit integer -typedef ss_sint32_pr_t_ ss_sint32_t; //!< 32-bit signed integer -typedef ss_uint32_pr_t_ ss_uint32_t; //!< 32-bit unsigned integer -#ifdef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT - typedef ss_int64_pr_t_ ss_int64_t; //!< 64-bit integer - typedef ss_sint64_pr_t_ ss_sint64_t; //!< 64-bit signed integer - typedef ss_uint64_pr_t_ ss_uint64_t; //!< 64-bit unsigned integer -#endif /* __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT */ -typedef short ss_short_t; //!< short integer -typedef int ss_int_t; //!< integer -typedef signed int ss_sint_t; //!< signed integer -typedef unsigned int ss_uint_t; //!< unsigned integer -typedef long ss_long_t; //!< long integer -typedef ss_uint8_t ss_byte_t; //!< Byte -typedef ss_bool_pr_t_ ss_bool_t; //!< bool -typedef ss_size_pr_t_ ss_size_t; //!< size -typedef ss_ptrdiff_pr_t_ ss_ptrdiff_t; //!< ptr diff -typedef long ss_streampos_t; //!< streampos -typedef long ss_streamoff_t; //!< streamoff - -#ifndef _STLSOFT_NO_NAMESPACE -typedef ss_char_a_t char_a_t; //!< Ansi char type -typedef ss_char_w_t char_w_t; //!< Unicode char type -typedef ss_int8_t int8_t; //!< 8-bit integer -typedef ss_sint8_t sint8_t; //!< 8-bit signed integer -typedef ss_uint8_t uint8_t; //!< 8-bit unsigned integer -typedef ss_int16_t int16_t; //!< 16-bit integer -typedef ss_sint16_t sint16_t; //!< 16-bit signed integer -typedef ss_uint16_t uint16_t; //!< 16-bit unsigned integer -typedef ss_int32_t int32_t; //!< 32-bit integer -typedef ss_sint32_t sint32_t; //!< 32-bit signed integer -typedef ss_uint32_t uint32_t; //!< 32-bit unsigned integer -# ifdef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT -typedef ss_int64_t int64_t; //!< 64-bit integer -typedef ss_sint64_t sint64_t; //!< 64-bit signed integer -typedef ss_uint64_t uint64_t; //!< 64-bit unsigned integer -# endif /* __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT */ -typedef ss_short_t short_t; //!< short integer -typedef ss_int_t int_t; //!< integer -typedef ss_sint_t sint_t; //!< signed integer -typedef ss_uint_t uint_t; //!< unsigned integer -typedef ss_long_t long_t; //!< long integer -typedef ss_byte_t byte_t; //!< Byte -typedef ss_bool_t bool_t; //!< bool -typedef ss_size_t size_t; //!< size -typedef ss_ptrdiff_t ptrdiff_t; //!< ptr diff -typedef ss_streampos_t streampos_t; //!< streampos -typedef ss_streamoff_t streamoff_t; //!< streamoff -#endif /* !_STLSOFT_NO_NAMESPACE */ - - -#if 0 -template -struct uintp_traits; - -STLSOFT_GEN_TRAIT_SPECIALISATION -struct uintp_traits<1> -{ - typedef uint8_t unsigned_type; -} - -typedef size_traits::signed_type sintp_t; -typedef size_traits::unsigned_type uintp_t; - -#endif /* 0 */ - - - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#ifdef __cplusplus -struct stlsoft_size_checker -{ -#ifdef __STLSOFT_COMPILER_IS_GCC -protected: // GCC is too "helpful" in this case, so must declare as protected -#else -private: -#endif /* __STLSOFT_COMPILER_IS_GCC */ - stlsoft_size_checker(); - ~stlsoft_size_checker() - { - // Char types - stlsoft_static_assert(sizeof(ss_char_a_t) >= 1); - stlsoft_static_assert(sizeof(ss_char_w_t) >= 2); - // 8-bit types - stlsoft_static_assert(sizeof(ss_int8_t) == 1); - stlsoft_static_assert(sizeof(ss_sint8_t) == sizeof(ss_int8_t)); - stlsoft_static_assert(sizeof(ss_uint8_t) == sizeof(ss_int8_t)); - // 16-bit types - stlsoft_static_assert(sizeof(ss_int16_t) == 2); - stlsoft_static_assert(sizeof(ss_sint16_t) == sizeof(ss_int16_t)); - stlsoft_static_assert(sizeof(ss_uint16_t) == sizeof(ss_int16_t)); - // 32-bit types - stlsoft_static_assert(sizeof(ss_int32_t) == 4); - stlsoft_static_assert(sizeof(ss_sint32_t) == sizeof(ss_int32_t)); - stlsoft_static_assert(sizeof(ss_uint32_t) == sizeof(ss_int32_t)); - // 64-bit types -#ifdef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT - stlsoft_static_assert(sizeof(ss_int64_t) == 8); - stlsoft_static_assert(sizeof(ss_sint64_t) == sizeof(ss_int64_t)); - stlsoft_static_assert(sizeof(ss_uint64_t) == sizeof(ss_int64_t)); -#endif /* __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT */ - // Integer types - stlsoft_static_assert(sizeof(ss_int_t) >= 1); - stlsoft_static_assert(sizeof(ss_sint_t) == sizeof(ss_int_t)); - stlsoft_static_assert(sizeof(ss_uint_t) == sizeof(ss_int_t)); - stlsoft_static_assert(sizeof(ss_long_t) >= sizeof(ss_int_t)); - // byte type - stlsoft_static_assert(sizeof(ss_byte_t) == 1); - // Bool type - stlsoft_static_assert(sizeof(ss_bool_t) >= 1); - // Other types - stlsoft_static_assert(sizeof(ss_size_t) >= 1); - stlsoft_static_assert(sizeof(ss_ptrdiff_t) >= 1); - stlsoft_static_assert(sizeof(ss_streampos_t) >= 1); - stlsoft_static_assert(sizeof(ss_streamoff_t) >= 1); - } -}; -#endif /* __cplusplus */ -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Keywords - * - * The STLSoft uses a number of preprocessor symbols to aid in compiler - * compatibility in the libraries' code. - * - * ss_explicit_k - explicit, or nothing - * ss_mutable_k - mutable, or nothing - * ss_typename_type_k - typename, or nothing (used within template - * definitions for declaring types derived from - * externally derived types) - * ss_typename_param_k - typename or class (used for template parameters) - * ss_typename_type_def_k - typename qualifier in template default parameters - * ss_typename_type_mil_k - typename qualifier in constructor initialiser lists - */ - -/// \def ss_explicit_k -/// -/// Evaluates to explicit on translators that support the keyword, otherwise to nothing -#ifdef __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT -# define ss_explicit_k explicit -#else -# define ss_explicit_k -#endif /* __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT */ - -/// \def ss_mutable_k -/// -/// Evaluates to mutable on translators that support the keyword, otherwise to nothing -#ifdef __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT -# define ss_mutable_k mutable -#else -# define ss_mutable_k -#endif /* __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT */ - -/// \def ss_typename_param_k -/// -/// Evaluates to typename on translators that support the keyword, otherwise to class -#ifdef __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT -# define ss_typename_param_k typename -#else -# define ss_typename_param_k class -#endif /* __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT */ - -/// \def ss_typename_type_k -/// -/// Evaluates to typename on translators that support the keyword, otherwise to nothing -#ifdef __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT -# define ss_typename_type_k typename -#else -# define ss_typename_type_k -#endif /* __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT */ - -/// \def ss_typename_type_def_k -/// -/// Evaluates to typename on translators that support the keyword, otherwise to nothing -#ifdef __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT -# define ss_typename_type_def_k typename -#else -# define ss_typename_type_def_k -#endif /* __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT */ - -/// \def ss_typename_type_mil_k -/// -/// Evaluates to typename on translators that support the keyword, otherwise to nothing -#ifdef __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT -# define ss_typename_type_mil_k typename -#else -# define ss_typename_type_mil_k -#endif /* __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT */ - - - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/* ///////////////////////////////////////////////////////////////////////////// - * Values - * - * Since the boolean type may not be supported natively on all compilers, the - * values of true and false may also not be provided. Hence the values of - * ss_true_v and ss_false_v are defined, and are used in all code. - */ - -#ifdef __STLSOFT_CF_NATIVE_BOOL_SUPPORT -# define ss_true_v (true) -# define ss_false_v (false) -#else -# define ss_true_v (1) -# define ss_false_v (0) -#endif /* __STLSOFT_CF_NATIVE_BOOL_SUPPORT */ - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ -/* ///////////////////////////////////////////////////////////////////////////// - * Code modification macros - */ - -/// \defgroup code_modification_macros Code Modification Macros -/// \ingroup STLSoft -/// \brief These macros are used to help out where compiler differences are -/// so great as to cause great disgusting messes in the class/function implementations -/// @{ - -/* Exception signatures. */ -#if !defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION) && \ - defined(__STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT) -# define stlsoft_throw_0() throw () -# define stlsoft_throw_1(x1) throw (x1) -# define stlsoft_throw_2(x1, x2) throw (x1, x2) -# define stlsoft_throw_3(x1, x2, x3) throw (x1, x2, x3) -# define stlsoft_throw_4(x1, x2, x3, x4) throw (x1, x2, x3, x4) -# define stlsoft_throw_5(x1, x2, x3, x4, x5) throw (x1, x2, x3, x4, x5) -# define stlsoft_throw_6(x1, x2, x3, x4, x5, x6) throw (x1, x2, x3, x4, x5, x6) -# define stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7) throw (x1, x2, x3, x4, x5, x6, x7) -# define stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) throw (x1, x2, x3, x4, x5, x6, x7, x8) -#else -# define stlsoft_throw_0() -# define stlsoft_throw_1(x1) -# define stlsoft_throw_2(x1, x2) -# define stlsoft_throw_3(x1, x2, x3) -# define stlsoft_throw_4(x1, x2, x3, x4) -# define stlsoft_throw_5(x1, x2, x3, x4, x5) -# define stlsoft_throw_6(x1, x2, x3, x4, x5, x6) -# define stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7) -# define stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) -#endif /* __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT && !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/// \def stlsoft_num_elements -/// -/// Evaluates, at compile time, to the number of elements within the given vector entity -/// -/// Is it used as follows: -/// -/// \htmlonly -/// -/// int               ai[20]; -///
-/// int               i     = 32; -///
-/// int               *pi   = &i; -///
-/// std::vector<int>  vi; -///
-///
-/// size_t            s_ai  = stlsoft_num_elements(ai);   // Ok -///
-/// size_t            s_i   = stlsoft_num_elements(i);    // Error -///
-/// size_t            s_pi  = stlsoft_num_elements(pi);   // Error -///
-/// size_t            s_vi  = stlsoft_num_elements(vi);   // Error -///
-///
-/// \endhtmlonly -/// -/// \note For most of the supported compilers, this macro will reject application to pointer -/// types, or to class types providing operator []. This helps to avoid the common -/// gotcha whereby (sizeof(ar) / sizeof(ar[0])) is applied to such types, without -/// causing a compiler error. - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _stlsoft_num_elements(ar) (sizeof(ar) / sizeof(0[(ar)])) - -# if defined(__cplusplus) && \ - defined(__STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT) -# if 0/* defined(__STLSOFT_COMPILER_IS_GCC) */ -# pragma pack(push, 1) -template -struct ss_array_size_struct -{ - ss_sint8_t c[N]; -}; -# pragma pack(pop) - -template -ss_array_size_struct ss_static_array_size(T (&)[N]); - -# define stlsoft_num_elements(ar) sizeof(stlsoft_ns_qual(ss_static_array_size)(ar)) -# else /* ? 0 */ -template -struct ss_array_size_struct -{ - ss_sint8_t c[N]; -}; - -template -ss_array_size_struct ss_static_array_size(T (&)[N]); - -# define stlsoft_num_elements(ar) sizeof(stlsoft_ns_qual(ss_static_array_size)(ar).c) -# endif /* 0 */ -# else -# define stlsoft_num_elements(ar) _stlsoft_num_elements(ar) -# endif /* __cplusplus && __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT */ -#else -# define stlsoft_num_elements(ar) -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/// \def stlsoft_raw_offsetof -/// -/// Evaluates, at compile time, the offset of a structure/class member - -#if defined(__STLSOFT_COMPILER_IS_GCC) && \ - __GNUC__ >= 3 -# define stlsoft_raw_offsetof(s, m) (reinterpret_cast(&reinterpret_cast(1)->m) - 1) -#else -# ifndef _STLSOFT_NO_STD_INCLUDES -# define stlsoft_raw_offsetof(s, m) offsetof(s, m) -# else -# define stlsoft_raw_offsetof(s, m) reinterpret_cast(&static_cast(0)->m) -# endif /* !_STLSOFT_NO_STD_INCLUDES */ -#endif /* __GNUC__ >= 3 */ - - -/* destroy function */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -template -void stlsoft_destroy_instance_fn(T *p) -{ - p->~T(); - - /* SSCB: Borland C++ and Visual C++ remove the dtor for basic - * structs, and then warn that p is unused. This reference - * suppresses that warning. - */ - ((void)p); -} -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/// \def stlsoft_destroy_instance -/// -/// Destroys the given instance \c p of the given type (\c t and \c _type) -#if defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION) || \ - defined(__STLSOFT_COMPILER_IS_DMC) -# define stlsoft_destroy_instance(t, _type, p) do { (p)->~t(); } while(0) -#else -# define stlsoft_destroy_instance(t, _type, p) stlsoft_destroy_instance_fn((p)) -#endif /* __STLSOFT_COMPILER_IS_DMC */ - -/// Generates an opaque type with the name \c type -/// -/// For example, the following defines two distinct opaque types: -/// -/// \htmlonly -/// -/// stlsoft_gen_opaque(HThread) -///
-/// stlsoft_gen_opaque(HProcess) -///
-///
-///
-/// \endhtmlonly -/// -/// The two types are incompatible with each other, and with any other types (except that -/// they are both convertible to void const * - -#define stlsoft_gen_opaque(type) typedef struct __stlsoft_htype##type{ int i;} const *type; - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/// Define a 'final' class, ie. one that cannot be inherited from -# define stlsoft_sterile_class(_cls) class __m__##_cls { private: __m__##_cls(){} ~__m__##_cls(){} friend class _cls; }; class _cls: public __m__##_cls -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/// \def STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND -/// \ingroup code_modification_macros -/// -/// \brief Declares a template (class) parameter to be a friend of the template. -/// -/// Is it used as follows: -/// -/// \htmlonly -/// -/// template<typename T> -///
-/// class Thing -///
-/// { -///
-///   STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(T); -///
-///
-/// private: -///
-///   int m_member; // Thing<T>::m_member visible to T -///
-/// }; -///
-///
-/// \endhtmlonly -/// -/// \note This is contrary to the C++-98 standard. Section 7.1.5.3(2) notes: "...within a class -/// template with a template type-parameter T, the declaration ["]friend class T;["] is ill-formed." -/// However, it gives the expected behaviour for all compilers currently supported by STLSoft - -#if defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION) || \ - defined(__STLSOFT_COMPILER_IS_BORLAND) || \ - defined(__STLSOFT_COMPILER_IS_COMO) || \ - defined(__STLSOFT_COMPILER_IS_DMC) || \ - ( defined(__STLSOFT_COMPILER_IS_GCC) && \ - __GNUC__ < 3) || \ - defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC) || \ - defined(__STLSOFT_COMPILER_IS_VECTORC) || \ - defined(__STLSOFT_COMPILER_IS_WATCOM) -# define STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(T) friend T -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) -# define STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(T) friend class T -#elif defined(__STLSOFT_COMPILER_IS_GCC) && \ - __GNUC__ >= 3 - -# define STLSOFT_DECLARE_TEMPLATE_PARAM_AS_FRIEND(T) \ - \ - struct friend_maker \ - { \ - typedef T T2; \ - }; \ - \ - typedef typename friend_maker::T2 friend_type; \ - \ - friend friend_type - -#else -# error Compiler not discriminated -#endif /* compiler */ - - -/// \def STLSOFT_GEN_TRAIT_SPECIALISATION -/// \ingroup code_modification_macros -/// -/// \brief Used to define a specialisation of a traits type -/// -#define STLSOFT_GEN_TRAIT_SPECIALISATION(TR, T, V) \ - \ - STLSOFT_TEMPLATE_SPECIALISATION \ - struct TR \ - { \ - enum { value = V }; \ - }; - - -/// \def STLSOFT_SUPPRESS_UNUSED -/// \ingroup code_modification_macros -/// -/// \brief Used to suppress unused variable warnings -/// -#ifdef __STLSOFT_COMPILER_IS_INTEL -# define STLSOFT_SUPPRESS_UNUSED(x) ((void)((x) = (x))) -#else /* ? __STLSOFT_COMPILER_IS_INTEL */ -# define STLSOFT_SUPPRESS_UNUSED(x) ((void)x) -#endif /* __STLSOFT_COMPILER_IS_INTEL */ - - - -/// @} - -/// \defgroup pointer_manipulation_functions Pointer Manipulation Functions -/// \ingroup STLSoft -/// \brief These functions assist in calculations with, and the manipulation of pointers -/// @{ - -/// Offsets a pointer by a number of bytes -/// -/// \param p The pointer to be offset -/// \param n The number of bytes to offset -/// \result \c p offset by \c bytes -template -inline void const *ptr_byte_offset(T const p, ss_ptrdiff_t n) -{ - return static_cast(static_cast(static_cast(p)) + n); -} - -/// Offsets a pointer by a number of elements -/// -/// \param p The pointer to be offset -/// \param n The number of elements to offset -/// \result \c p offset by \c elements -template -inline T const *ptr_offset(T const *p, ss_ptrdiff_t n) -{ - return p + n; -} - -/// Get the difference in bytes between two pointers -template -inline ss_ptrdiff_t ptr_byte_diff(T1 const *p1, T2 const *p2) -{ - return static_cast(static_cast(p1)) - static_cast(static_cast(p2)); -} - -/// Get the difference in elements between two pointers -template -inline ss_ptrdiff_t ptr_diff(T1 const *p1, T2 const *p2) -{ - return p1 - p2; -} - -/// @} // end of group pointer_manipulation_functions - -/* Mutable support */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -template -#ifdef __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT -inline T &mutable_access(T &t) -#else -inline T &mutable_access(T const &t) -#endif /* __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT */ -{ -#ifdef __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT - return t; -#else - return const_cast(t); -#endif /* __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT */ -} -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* Move constructor support */ -#ifdef __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT -# define stlsoft_define_move_rhs_type(t) t & -#else -# define stlsoft_define_move_rhs_type(t) t const & -#endif /* __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */ - -template -inline T &move_lhs_from_rhs(stlsoft_define_move_rhs_type(T) t) -{ -#ifdef __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT - return t; -#else - return const_cast(t); -#endif /* __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT */ -} - -/* ///////////////////////////////////////////////////////////////////////////// - * Memory - */ - -// function operator new -// -// When namespaces are being used, stlsoft provides its own placement new, -// otherwise it includes in order to access the global version. - -#ifdef _STLSOFT_NO_NAMESPACE -# if defined(__STLSOFT_COMPILER_IS_BORLAND) && \ - __BORLANDC__ < 0x0550 -# include -# else -# include -# endif /* __STLSOFT_COMPILER_IS_BORLAND && __BORLANDC__ < 0x0550 */ -#else -# if ( defined(__STLSOFT_COMPILER_IS_DMC) && \ - __DMC__ < 0x0833) || \ - ( defined(__STLSOFT_COMPILER_IS_MSVC) && \ - _MSC_VER < 1300) -inline void *operator new(ss_size_t /* si */, void *pv) -{ - return pv; -} -# endif /* compiler */ -#endif /* !_STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* !_STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_cccap_dmc.h b/etc/c/stlsoft/stlsoft_cccap_dmc.h deleted file mode 100644 index 5f369b709bf..00000000000 --- a/etc/c/stlsoft/stlsoft_cccap_dmc.h +++ /dev/null @@ -1,323 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: stlsoft_cccap_dmc.h - * - * Purpose: Compiler feature discrimination for Digital Mars C/C++. - * - * Created: 7th February 2003 - * Updated: 28th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT -# error This file must not be included independently of stlsoft.h -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -#ifdef _STLSOFT_INCL_H_STLSOFT_CCCAP_DMC -# error This file cannot be included more than once in any compilation unit -#endif /* _STLSOFT_INCL_H_STLSOFT_CCCAP_DMC */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -# define _STLSOFT_VER_H_STLSOFT_CCCAP_DMC_MAJOR 1 -# define _STLSOFT_VER_H_STLSOFT_CCCAP_DMC_MINOR 13 -# define _STLSOFT_VER_H_STLSOFT_CCCAP_DMC_REVISION 2 -# define _STLSOFT_VER_H_STLSOFT_CCCAP_DMC_EDIT 34 - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler features - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#include /* Needed to determine whether we're using STLport or SGI STL */ - -/* Messaging - */ - -#define STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT - -/* Types: - */ - -/* bool */ -#ifdef _BOOL_DEFINED -# define __STLSOFT_CF_NATIVE_BOOL_SUPPORT -#else - /* Not defined */ -#endif /* _BOOL_DEFINED */ - -/* wchar_t */ -#ifdef _WCHAR_T_DEFINED -# define __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT -#else - /* Not defined */ -#endif /* _WCHAR_T_DEFINED */ - -/* Native 8-bit integer */ -//#define __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT - -/* Native 16-bit integer */ -//#define __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT - -/* Native 32-bit integer */ -//#define __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT - -/* Native 64-bit integer */ -#define __STLSOFT_CF_NATIVE___int64_SUPPORT - -/* long long */ -#define __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT - -/* Are integers a unique type (i.e. not int8/16/32/64)? */ -#define __STLSOFT_CF_INT_DISTINCT_TYPE - -#if __DMC__ >= 0x0835 -# define __STLSOFT_CF_STATIC_ASSERT_SUPPORT -#endif /* __DMC__ */ - -/* Exception support */ -#ifdef _CPPUNWIND -# define __STLSOFT_CF_EXCEPTION_SUPPORT -#else - /* Not defined */ -#endif /* _CPPUNWIND */ - -/* */ -//#define __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED - -/* Namespace support */ - /* The current versions (up to and including 8.32) of the Digital Mars - * compiler have issues whereby out-of-class inline methods seem to be placed - * within their namespace of instantiation rather than of definition, so - * namespace support is turned off. - */ -#if __DMC__ < 0x833 -# define _STLSOFT_NO_NAMESPACES -#endif /* __DMC__ < 0x832 */ - -#define __STLSOFT_CF_NAMESPACE_SUPPORT - -#define STLSOFT_CF_ANONYMOUS_UNION_SUPPORT - -/* Template support */ -#define __STLSOFT_CF_TEMPLATE_SUPPORT - -//#define STLSOFT_CF_TEMPLATE_TYPE_REQUIRED_IN_ARGS - -//#define __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT - -//#define __STLSOFT_CF_THROW_BAD_ALLOC - -#define __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT - -#define __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - -#if __DMC__ >= 0x0837 -# define STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#if __DMC__ >= 0x0832 -# define __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#if __DMC__ >= 0x0832 -# define __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#if 0 /* __DMC__ >= 0x0836? */ -# define __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#if __DMC__ >= 0x0829 -# define __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#if __DMC__ >= 0x0829 -# define __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -#else - /* Not defined */ -#endif /* __DMC__ */ - -#if __DMC__ >= 0x0829 -# define __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -//#define __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT - -#ifdef _STLPORT_VERSION -# define __STLSOFT_CF_std_NAMESPACE -#else - /* Not defined */ -#endif /* _STLPORT_VERSION */ - -#define __STLSOFT_CF_std_char_traits_AVAILABLE - -#if 0 /* __DMC__ >= 0x0836? */ -# define __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#define __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT - -#if (__DMC__ >= 0x0829) -# define __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ >= 0x0829 */ - -#define __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT - -#define __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT - -#define __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT - -#define __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT - -#define __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT - -//#define __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT - -#define __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT - -#if __DMC__ >= 0x0834 -# define __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT -#endif /* __DMC__ */ - -//#define __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT - -#if __DMC__ >= 0x0838 -# define __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT -#else - /* Not defined */ -#endif /* __DMC__ */ - -#define __STLSOFT_CF_VENEER_SUPPORT - -// Shims are supported -//# define __STLSOFT_CF_TEMPLATE_SHIMS_NOT_SUPPORTED - -#define __STLSOFT_CF_NEGATIVE_MODULUS_POSITIVE_GIVES_NEGATIVE_RESULT - -#define STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT -#define STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT - -#if defined(_STLSOFT_CUSTOM_ASSERT) - /* You have defined the pre-processor symbol _STLSOFT_CUSTOM_ASSERT, - * which stipulates that you will be providing your own assert. This - * requires that you have defined _STLSOFT_CUSTOM_ASSERT() as a macro - * taking 1 parameter (the condition to assert). - * - * Suppose you have a function _DisplayAssert(), which has the - * following signature: - * - * void _DisplayAssert(char const *file, int line, char const *expression); - * - * Presumably you would also have your own assert macro, say MY_ASSERT(), - * defined as: - * - * #define MY_ASSERT(_x) ((void)((!(_x)) ? ((void)(_DisplayAssert(__FILE__, __LINE__, #_x))) : ((void)0))) - * - * so you would simply need to define _STLSOFT_CUSTOM_ASSERT() in terms of - * MY_ASSERT(), as in: - * - * #define _STLSOFT_CUSTOM_ASSERT(_x) MY_ASSERT(_x) - * - * where - */ -# define __STLSOFT_CF_ASSERT_SUPPORT -# define stlsoft_assert(_x) _STLSOFT_CUSTOM_ASSERT(_x) -# if defined(_STLSOFT_CUSTOM_ASSERT_INCLUDE) -# define __STLSOFT_CF_ASSERT_INCLUDE_NAME _STLSOFT_CUSTOM_ASSERT_INCLUDE -# else -# error You must define _STLSOFT_CUSTOM_ASSERT_INCLUDE along with _STLSOFT_CUSTOM_ASSERT() -# endif /* !_STLSOFT_CUSTOM_ASSERT_INCLUDE */ -#else -# define __STLSOFT_CF_ASSERT_SUPPORT - //#define __STLSOFT_CF_USE_cassert -# define __STLSOFT_CF_ASSERT_INCLUDE_NAME -# define stlsoft_assert(_x) assert(_x) -#endif /* _STLSOFT_CUSTOM_ASSERT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Calling convention - */ - -#define STLSOFT_CF_FASTCALL_SUPPORTED -#define STLSOFT_CF_STDCALL_SUPPORTED - -/* ///////////////////////////////////////////////////////////////////////////// - * Inline assembler - */ - -#define STSLSOFT_INLINE_ASM_SUPPORTED -#define STSLSOFT_ASM_IN_INLINE_SUPPORTED - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler warning suppression - */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_cccap_gcc.h b/etc/c/stlsoft/stlsoft_cccap_gcc.h deleted file mode 100644 index 17edd906c54..00000000000 --- a/etc/c/stlsoft/stlsoft_cccap_gcc.h +++ /dev/null @@ -1,255 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: stlsoft_cccap_gcc.h - * - * Purpose: Compiler feature discrimination for GNU C/C++. - * - * Created: 7th February 2003 - * Updated: 22nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT -# error This file must not be included independently of stlsoft.h -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -#ifdef _STLSOFT_INCL_H_STLSOFT_CCCAP_GCC -# error This file cannot be included more than once in any compilation unit -#endif /* _STLSOFT_INCL_H_STLSOFT_CCCAP_GCC */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#define _STLSOFT_VER_H_STLSOFT_CCCAP_GCC_MAJOR 1 -#define _STLSOFT_VER_H_STLSOFT_CCCAP_GCC_MINOR 10 -#define _STLSOFT_VER_H_STLSOFT_CCCAP_GCC_REVISION 1 -#define _STLSOFT_VER_H_STLSOFT_CCCAP_GCC_EDIT 22 - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler features - */ - -/* Messaging - */ - -//#define STLSOFT_CF_PRAGMA_MESSAGE_SUPPORT - -/* Types: - */ - -/* bool */ -#define __STLSOFT_CF_NATIVE_BOOL_SUPPORT - -/* wchar_t */ -//#define __STLSOFT_CF_NATIVE_WCHAR_T_SUPPORT - -/* Native 8-bit integer */ -//#define __STLSOFT_CF_NATIVE_8BIT_INT_SUPPORT - -/* Native 16-bit integer */ -//#define __STLSOFT_CF_NATIVE_16BIT_INT_SUPPORT - -/* Native 32-bit integer */ -//#define __STLSOFT_CF_NATIVE_32BIT_INT_SUPPORT - -/* Native 64-bit integer */ -//#define __STLSOFT_CF_NATIVE___int64_SUPPORT - -/* long long */ -#define __STLSOFT_CF_NATIVE_LONG_LONG_SUPPORT - -#define __STLSOFT_CF_INT_DISTINCT_TYPE - -#define __STLSOFT_CF_STATIC_ASSERT_SUPPORT - -/* Exception support */ -#define __STLSOFT_CF_EXCEPTION_SUPPORT - -/* */ -#define __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED - -/* Namespace support */ -//#define _STLSOFT_NO_NAMESPACES - -#define __STLSOFT_CF_NAMESPACE_SUPPORT - -#define STLSOFT_CF_ANONYMOUS_UNION_SUPPORT - -/* Template support */ -#define __STLSOFT_CF_TEMPLATE_SUPPORT - -//#define STLSOFT_CF_TEMPLATE_TYPE_REQUIRED_IN_ARGS - -#define __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT - -#define __STLSOFT_CF_THROW_BAD_ALLOC - -#define __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT - -#define __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - -#define STLSOFT_CF_MEM_FUNC_AS_TEMPLATE_PARAM_SUPPORT - -#define __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT - -#define __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT - -#define __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT - -#define __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT - -#define __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX - -#define __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT - -#define __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT - -#define __STLSOFT_CF_std_NAMESPACE - -#if __GNUC__ >= 3 -# define __STLSOFT_CF_std_char_traits_AVAILABLE -#endif /* */ - -#define __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT - -#define __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT - -#define __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT - -#define __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT - -#define __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT - -#define __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT - -#define __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT - -#define __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT - -//#define __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT - -//# define __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT - -#define __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT - -#define __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT - -#if __GNUC__ >= 3 -# define __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT -#endif /* 2.95+ */ - -#if __GNUC__ >= 3 -# define __STLSOFT_CF_VENEER_SUPPORT -#endif /* */ - -// Shims are supported -//# define __STLSOFT_CF_TEMPLATE_SHIMS_NOT_SUPPORTED - -#define __STLSOFT_CF_NEGATIVE_MODULUS_POSITIVE_GIVES_NEGATIVE_RESULT - -#define STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT -#define STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT - -#if defined(_STLSOFT_CUSTOM_ASSERT) - /* You have defined the pre-processor symbol _STLSOFT_CUSTOM_ASSERT, - * which stipulates that you will be providing your own assert. This - * requires that you have defined _STLSOFT_CUSTOM_ASSERT() as a macro - * taking 1 parameter (the condition to assert). - * - * Suppose you have a function _DisplayAssert(), which has the - * following signature: - * - * void _DisplayAssert(char const *file, int line, char const *expression); - * - * Presumably you would also have your own assert macro, say MY_ASSERT(), - * defined as: - * - * #define MY_ASSERT(_x) ((void)((!(_x)) ? ((void)(_DisplayAssert(__FILE__, __LINE__, #_x))) : ((void)0))) - * - * so you would simply need to define _STLSOFT_CUSTOM_ASSERT() in terms of - * MY_ASSERT(), as in: - * - * #define _STLSOFT_CUSTOM_ASSERT(_x) MY_ASSERT(_x) - * - * where - */ -# define __STLSOFT_CF_ASSERT_SUPPORT -# define stlsoft_assert(_x) _STLSOFT_CUSTOM_ASSERT(_x) -# if defined(_STLSOFT_CUSTOM_ASSERT_INCLUDE) -# define __STLSOFT_CF_ASSERT_INCLUDE_NAME _STLSOFT_CUSTOM_ASSERT_INCLUDE -# else -# error You must define _STLSOFT_CUSTOM_ASSERT_INCLUDE along with _STLSOFT_CUSTOM_ASSERT() -# endif /* !_STLSOFT_CUSTOM_ASSERT_INCLUDE */ -#else -# define __STLSOFT_CF_ASSERT_SUPPORT -//# define __STLSOFT_CF_USE_cassert -# define __STLSOFT_CF_ASSERT_INCLUDE_NAME -# define stlsoft_assert(_x) assert(_x) -#endif /* _STLSOFT_CUSTOM_ASSERT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Calling convention - */ - -#define STLSOFT_CF_FASTCALL_SUPPORTED -#define STLSOFT_CF_STDCALL_SUPPORTED - -/* ///////////////////////////////////////////////////////////////////////////// - * Inline assembler - */ - -//#define STSLSOFT_INLINE_ASM_SUPPORTED -//#define STSLSOFT_ASM_IN_INLINE_SUPPORTED - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler warning suppression - */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_iterator.h b/etc/c/stlsoft/stlsoft_iterator.h deleted file mode 100644 index a5a012b64a9..00000000000 --- a/etc/c/stlsoft/stlsoft_iterator.h +++ /dev/null @@ -1,766 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: stlsoft_iterator.h (originally MTIter.h, ::SynesisStl) - * - * Purpose: iterator classes. - * - * Created: 2nd January 2000 - * Updated: 28th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR -#define _STLSOFT_INCL_H_STLSOFT_ITERATOR - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _STLSOFT_VER_H_STLSOFT_ITERATOR_MAJOR 1 -# define _STLSOFT_VER_H_STLSOFT_ITERATOR_MINOR 14 -# define _STLSOFT_VER_H_STLSOFT_ITERATOR_REVISION 1 -# define _STLSOFT_VER_H_STLSOFT_ITERATOR_EDIT 43 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* //////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT -# include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ -#include // std::iterator, std::reverse_iterator, std::reverse_bidirectional_iterator - -/* ///////////////////////////////////////////////////////////////////////////// - * Warnings - */ - -/* This is here temporarily, until a better solution can be found. */ -#ifdef __STLSOFT_COMPILER_IS_MSVC -# pragma warning(disable : 4097) // suppresses: typedef-name 'identifier1' used as synonym for class-name 'identifier2' -#endif /* __STLSOFT_COMPILER_IS_MSVC */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _STLSOFT_NO_NAMESPACE -namespace stlsoft -{ -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Library identification - */ - -// This is all some hideous kludge caused by Dinkumware's standard library's -// failure to leave behind any definitive discriminatable vestige of its -// presence. - -#ifdef __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES -# undef __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES -#endif /* !__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES */ - -#ifdef __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 -# undef __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 -#endif /* !__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 */ - -#ifdef __STLSOFT_CF_STL_IS_STLPORT -# undef __STLSOFT_CF_STL_IS_STLPORT -#endif /* !__STLSOFT_CF_STL_IS_STLPORT */ - -/* Detect whether Dinkumware "may" be present - * - * Discriminated symbol is __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES - */ -#if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - ( defined(__STLSOFT_COMPILER_IS_MSVC) && \ - _MSC_VER >= 1200 && \ - _MSC_VER < 1310)) && \ - defined(_STD_BEGIN) && \ - defined(_STD_END) && \ - defined(_Mbstinit) -# define __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES -#endif /* _MSC_VER && _MSC_VER == 1300 */ - -#if defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES) && \ - defined(_DEPRECATED) && \ - defined(_HAS_TEMPLATE_PARTIAL_ORDERING) && \ - defined(_CPPLIB_VER) -# define __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 -#endif /* */ - -/* Detect whether STLport is present - * - * Discriminated symbol is __STLSOFT_CF_STL_IS_STLPORT - */ -#ifdef _STLPORT_VERSION -# define __STLSOFT_CF_STL_IS_STLPORT -#endif /* _STLPORT_VERSION */ - -/* Must be either Dinkumware or STLport if compiling with Intel or Visual C++ - */ -#if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - ( defined(__STLSOFT_COMPILER_IS_MSVC) && \ - _MSC_VER >= 1200 && \ - _MSC_VER < 1310)) && \ - ( !defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES) && \ - !defined(__STLSOFT_CF_STL_IS_STLPORT)) -# error When compiling with Intel C/C++ or Microsoft Visual C++, only the Dinkumware or STLport STL implementations are currently supported. -# error Please contact STLSoft (admin@stlsoft.org) if you need to support a different STL implementation with these compilers. -#endif /* (Intel || MSVC) && !DinkumWare && !STLport */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Iterator macros - */ - -/* reverse_iterator */ - -#if defined(__STLSOFT_COMPILER_IS_BORLAND) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_CUSTOM) || \ - defined(__STLSOFT_COMPILER_IS_UNKNOWN) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_DMC) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else /* ? __STLSOFT_CF_STL_IS_STLPORT */ -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -#elif defined(__STLSOFT_COMPILER_IS_COMO) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_GCC) -# if __GNUC__ < 3 -# define stlsoft_reverse_iterator(I, T, R, P, D) ::reverse_iterator -# else -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# endif /* __GNUC__ < 3 */ -#elif defined(__STLSOFT_COMPILER_IS_INTEL) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) || \ - defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# endif /* __STLSOFT_CF_STL_IS_STLPORT || __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 */ -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_MSVC) -# if _MSC_VER >= 1310 -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# elif defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# elif defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# endif /* __STLSOFT_CF_STL_IS_STLPORT || __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 */ -#elif defined(__STLSOFT_COMPILER_IS_WATCOM) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_reverse_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else -# error Watcom is not supported independently of STLport -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -#else -# error Compiler not recognised -#endif /* compiler */ - -/* reverse_bidirectional_iterator */ - -#if defined(__STLSOFT_COMPILER_IS_BORLAND) -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_CUSTOM) || \ - defined(__STLSOFT_COMPILER_IS_UNKNOWN) -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator) -#elif defined(__STLSOFT_COMPILER_IS_DMC) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else /* ? __STLSOFT_CF_STL_IS_STLPORT */ -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator) -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -#elif defined(__STLSOFT_COMPILER_IS_COMO) -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_GCC) -# if __GNUC__ < 3 -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) ::reverse_iterator -# else -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# endif /* __GNUC__ < 3 */ -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -#elif defined(__STLSOFT_COMPILER_IS_INTEL) -# ifdef __STLSOFT_CF_STL_IS_STLPORT -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator) -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -#elif defined(__STLSOFT_COMPILER_IS_MSVC) -# ifdef __STLSOFT_CF_STL_IS_STLPORT -# ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator) -# endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ -# else -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator) -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -#elif defined(__STLSOFT_COMPILER_IS_WATCOM) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) stlsoft_ns_qual_std(reverse_iterator) -# else -# error Watcom is not supported independently of STLport -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -#else -# error Compiler not recognised -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Iterators - */ - -// class iterator_base -/// Base type for iterator types -// -/// This class abstract std::iterator functionality for deriving classes, hiding -/// the inconsistencies and incompatibilities of the various compilers and/or -/// libraries supported by the STLSoft libraries. -/// -/// \param C The iterator category -/// \param T The value type -/// \param D The distance type -/// \param P The pointer type -/// \param R The reference type -template< ss_typename_param_k C /* category */ - , ss_typename_param_k T /* type */ - , ss_typename_param_k D /* distance */ - , ss_typename_param_k P /* pointer */ - , ss_typename_param_k R /* reference */ - > -struct iterator_base -#if defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC) - : public stlsoft_ns_qual_std(iterator) -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) - : public stlsoft_ns_qual_std(iterator) -#endif /* __STLSOFT_COMPILER_IS_MSVC */ -{ -#if defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC) - typedef stlsoft_ns_qual_std(iterator) parent_class_type; -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) - typedef stlsoft_ns_qual_std(iterator) parent_class_type; -#endif /* __STLSOFT_COMPILER_IS_MSVC */ - -public: -#if defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC) || \ - defined(__STLSOFT_COMPILER_IS_MWERKS) - typedef ss_typename_type_k parent_class_type::iterator_category iterator_category; - typedef ss_typename_type_k parent_class_type::value_type value_type; -# if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC)) && \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) - typedef ss_typename_type_k parent_class_type::distance_type difference_type; - typedef P pointer; - typedef R reference; -# else - typedef ss_typename_type_k parent_class_type::difference_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer pointer; - typedef ss_typename_type_k parent_class_type::reference reference; -# endif /* __STLSOFT_COMPILER_IS_MSVC */ - -#elif defined(__STLSOFT_COMPILER_IS_GCC) || \ - defined(__STLSOFT_COMPILER_IS_BORLAND) -# if defined(__STLSOFT_COMPILER_IS_GCC) -# if __GNUC__ < 3 - typedef __STD::input_iterator_tag iterator_category; -# else - typedef stlsoft_ns_qual_std(input_iterator_tag) iterator_category; -# endif /* __GNUC__ < 3 */ -# elif defined(__STLSOFT_COMPILER_IS_BORLAND) - typedef stlsoft_ns_qual_std(input_iterator_tag) iterator_category; -# endif /* __STLSOFT_COMPILER_IS_GCC || __STLSOFT_COMPILER_IS_BORLAND */ - typedef T value_type; - typedef D difference_type; - typedef P pointer; - typedef R reference; -#else - /* All other compilers. */ -# if defined(__STLSOFT_COMPILER_IS_CUSTOM) || \ - defined(__STLSOFT_COMPILER_IS_UNKNOWN) || \ - defined(__STLSOFT_COMPILER_IS_DMC) - typedef C iterator_category; - typedef T value_type; - typedef D difference_type; - typedef P pointer; - typedef R reference; -# elif defined(__STLSOFT_COMPILER_IS_WATCOM) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) - typedef ss_typename_type_k parent_class_type::distance_type difference_type; - typedef P pointer; - typedef R reference; -# else -# error Watcom is not supported independently of STLport -# endif /* __STLSOFT_CF_STL_IS_STLPORT */ -# else -# error Compiler not supported -# endif /* !__STLSOFT_COMPILER_IS_DMC */ -#endif /* __STLSOFT_COMPILER_IS_GCC || __STLSOFT_COMPILER_IS_BORLAND */ - - /* These two are for compatibility with older non-standard implementations, and - * will be benignly ignored by anything not requiring them. - */ - typedef pointer pointer_type; - typedef reference reference_type; -}; - - -// reverse_iterator_base, const_reverse_iterator_base, -// reverse_bidirectional_iterator_base and const_reverse_bidirectional_iterator_base -// -// These classes act as the base for reverse iterators, insulating deriving -// classes from the inconsistencies and incompatibilities of the various -// compilers and/or libraries supported by the STLSoft libraries. - -// class reverse_iterator_base -/// Base type for reverse_iterator types -// -/// This class acts as the base for reverse iterators, insulating deriving -/// classes from the inconsistencies and incompatibilities of the various -/// compilers and/or libraries supported by the STLSoft libraries. -/// -/// \param I The iterator type -/// \param T The value type -/// \param R The reference type -/// \param P The pointer type -/// \param D The distance type -template< ss_typename_param_k I - , ss_typename_param_k T - , ss_typename_param_k R - , ss_typename_param_k P - , ss_typename_param_k D - > -struct reverse_iterator_base - : public stlsoft_reverse_iterator(I, T, R, P, D) -{ -public: - typedef stlsoft_reverse_iterator(I, T, R, P, D) parent_class_type; - - typedef ss_typename_type_k parent_class_type::iterator_category iterator_category; - typedef ss_typename_type_k parent_class_type::value_type value_type; -# if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC)) && \ - _MSC_VER < 1300 && /* This is truly hideous, but since PJP doesn't put version numbers in the VC++ stl swill, we have no choice */ \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) - typedef ss_typename_type_k parent_class_type::distance_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer_type pointer; - typedef ss_typename_type_k parent_class_type::reference_type reference; -#else - typedef ss_typename_type_k parent_class_type::difference_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer pointer; - typedef ss_typename_type_k parent_class_type::reference reference; -#endif /* __STLSOFT_COMPILER_IS_MSVC */ - - /* These two are for compatibility with older non-standard implementations, and - * will be benignly ignored by anything not requiring them. - */ - typedef pointer pointer_type; - typedef reference reference_type; - -// Construction -public: - /// Constructor - ss_explicit_k reverse_iterator_base(I i) - : parent_class_type(i) - {} -}; - -// class const_reverse_iterator_base -/// Base type for const_reverse_iterator types -// -/// This class acts as the base for const reverse iterators, insulating deriving -/// classes from the inconsistencies and incompatibilities of the various -/// compilers and/or libraries supported by the STLSoft libraries. -/// -/// \param I The iterator type -/// \param T The value type -/// \param R The reference type -/// \param P The pointer type -/// \param D The distance type -template< ss_typename_param_k I - , ss_typename_param_k T - , ss_typename_param_k R - , ss_typename_param_k P - , ss_typename_param_k D - > -struct const_reverse_iterator_base - : public stlsoft_reverse_iterator(I, T, R, P, D) -{ -public: - typedef stlsoft_reverse_iterator(I, T, R, P, D) parent_class_type; - - typedef ss_typename_type_k parent_class_type::iterator_category iterator_category; - typedef ss_typename_type_k parent_class_type::value_type value_type; -# if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC)) && \ - _MSC_VER < 1300 && /* This is truly hideous, but since PJP doesn't put version numbers in the VC++ stl swill, we have no choice */ \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) - typedef ss_typename_type_k parent_class_type::distance_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer_type pointer; - typedef ss_typename_type_k parent_class_type::reference_type reference; -#else - typedef ss_typename_type_k parent_class_type::difference_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer pointer; - typedef ss_typename_type_k parent_class_type::reference reference; -#endif /* __STLSOFT_COMPILER_IS_MSVC && __STLSOFT_CF_STL_IS_STLPORT */ - - /* These two are for compatibility with older non-standard implementations, and - * will be benignly ignored by anything not requiring them. - */ - typedef pointer pointer_type; - typedef reference reference_type; - -// Construction -public: - /// Constructor - ss_explicit_k const_reverse_iterator_base(I i) - : parent_class_type(i) - {} -}; - -#ifdef __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT - -// class reverse_bidirectional_iterator_base -/// Base type for reverse_bidirectional_iterator types -// -/// This class acts as the base for reverse bidirectional iterators, -/// insulating deriving classes from the inconsistencies and incompatibilities -/// of the various compilers and/or libraries supported by the STLSoft libraries. -/// -/// \param I The iterator type -/// \param T The value type -/// \param R The reference type -/// \param P The pointer type -/// \param D The distance type -template< ss_typename_param_k I - , ss_typename_param_k T - , ss_typename_param_k R - , ss_typename_param_k P - , ss_typename_param_k D - > -struct reverse_bidirectional_iterator_base - : public stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) -{ -public: - typedef stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) parent_class_type; - - typedef ss_typename_type_k parent_class_type::iterator_category iterator_category; - typedef ss_typename_type_k parent_class_type::value_type value_type; -# if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC)) && \ - _MSC_VER < 1300 && /* This is truly hideous, but since PJP doesn't put version numbers in the VC++ stl swill, we have no choice */ \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) - typedef ss_typename_type_k parent_class_type::distance_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer_type pointer; - typedef ss_typename_type_k parent_class_type::reference_type reference; -#else - typedef ss_typename_type_k parent_class_type::difference_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer pointer; - typedef ss_typename_type_k parent_class_type::reference reference; -#endif /* __STLSOFT_COMPILER_IS_MSVC */ - - /* These two are for compatibility with older non-standard implementations, and - * will be benignly ignored by anything not requiring them. - */ - typedef pointer pointer_type; - typedef reference reference_type; - -// Construction -public: - /// Constructor - ss_explicit_k reverse_bidirectional_iterator_base(I i) - : parent_class_type(i) - {} -}; - -// class const_reverse_bidirectional_iterator_base -/// Base type for const_reverse_bidirectional_iterator types -// -/// This class acts as the base for const reverse bidirectional iterators, -/// insulating deriving classes from the inconsistencies and incompatibilities -/// of the various compilers and/or libraries supported by the STLSoft libraries. -/// -/// \param I The iterator type -/// \param T The value type -/// \param R The reference type -/// \param P The pointer type -/// \param D The distance type -template< ss_typename_param_k I - , ss_typename_param_k T - , ss_typename_param_k R - , ss_typename_param_k P - , ss_typename_param_k D - > -struct const_reverse_bidirectional_iterator_base - : public stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) -{ -public: - typedef stlsoft_reverse_bidirectional_iterator(I, T, R, P, D) parent_class_type; - - typedef ss_typename_type_k parent_class_type::iterator_category iterator_category; - typedef ss_typename_type_k parent_class_type::value_type value_type; -# if ( defined(__STLSOFT_COMPILER_IS_INTEL) || \ - defined(__STLSOFT_COMPILER_IS_MSVC)) && \ - _MSC_VER < 1300 && /* This is truly hideous, but since PJP doesn't put version numbers in the VC++ stl swill, we have no choice */ \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) - typedef ss_typename_type_k parent_class_type::distance_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer_type pointer; - typedef ss_typename_type_k parent_class_type::reference_type reference; -#else - typedef ss_typename_type_k parent_class_type::difference_type difference_type; - typedef ss_typename_type_k parent_class_type::pointer pointer; - typedef ss_typename_type_k parent_class_type::reference reference; -#endif /* __STLSOFT_COMPILER_IS_MSVC && __STLSOFT_CF_STL_IS_STLPORT */ - - /* These two are for compatibility with older non-standard implementations, and - * will be benignly ignored by anything not requiring them. - */ - typedef pointer pointer_type; - typedef reference reference_type; - -// Construction -public: - /// Constructor - ss_explicit_k const_reverse_bidirectional_iterator_base(I i) - : parent_class_type(i) - {} -}; - -#endif /* __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */ - -// Random access iterator support - -#ifdef __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* _STLSOFT_NO_NAMESPACE */ - -template< ss_typename_param_k _Ty - , ss_typename_param_k _Diff - , ss_typename_param_k _Pointer - , ss_typename_param_k _Reference - , ss_typename_param_k _Pointer2 - , ss_typename_param_k _Reference2 - > -class _Ptrit -{ -public: - typedef _Pointer iterator_type; - -private: - char x[1024]; -}; - -namespace std -{ - namespace test_dinkumware - { - template< ss_typename_param_k T1 - , ss_typename_param_k T2 - , bool S - > - struct select_type - { - typedef T1 selected_type; - }; - -#ifdef __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT - template< ss_typename_param_k T1 - , ss_typename_param_k T2 - > - struct select_type - { - typedef T2 selected_type; - }; -#endif //# ifdef __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT - - template< class V - , class P - , class R - > - class _Ptrit_tdkw - { - typedef _Ptrit _Ptrit_type; - - public: - typedef select_type<_Ptrit_type, P, sizeof(_Ptrit_type) < 1024>::selected_type iterator_type; - }; - - } -} - -#ifndef _STLSOFT_NO_NAMESPACE -namespace stlsoft -{ -#endif /* _STLSOFT_NO_NAMESPACE */ - -#endif /* !__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES */ - -/// Pointer iterator type -/// -/// \param V The value type -/// \param P The pointer type -/// \param R The reference type -template< ss_typename_param_k V - , ss_typename_param_k P - , ss_typename_param_k R - > -struct pointer_iterator -{ -#if defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES) && \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) -# if defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300) - typedef std::test_dinkumware::_Ptrit_tdkw::iterator_type iterator_type; -# else - typedef P iterator_type; -# endif /* __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 */ -#elif defined(__STLSOFT_COMPILER_IS_MSVC) && \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) && \ - defined(_XUTILITY_) && \ - _MSC_VER == 1300 - typedef std::_Ptrit iterator_type; -#else - typedef P iterator_type; -#endif /* !__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES */ -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#if defined(__STLSOFT_COMPILER_IS_DMC) && \ - !defined(__STLSOFT_CF_STL_IS_STLPORT) -template< ss_typename_param_k V - , ss_typename_param_k P - , ss_typename_param_k R - > -inline random_access_iterator_tag iterator_category(pointer_iterator::iterator_type const &) -{ - return random_access_iterator_tag(); -} - -template< ss_typename_param_k V - , ss_typename_param_k P - , ss_typename_param_k R - > -inline ptrdiff_t* distance_type(pointer_iterator::iterator_type const &) -{ - return static_cast(0); -} -#endif /* __STLSOFT_COMPILER_IS_DMC && !__STLSOFT_CF_STL_IS_STLPORT */ - -/* ////////////////////////////////////////////////////////////////////////// */ - - -/// Iterator category obtainer -/// -/// \param I The iterator type -/// \param i The iterator instance - -#if defined(__STLSOFT_COMPILER_IS_DMC) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)::iterator_category()) -//# error Digital Mars with STLport not yet supported -# else -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i)) -# endif /* */ -#elif defined(__STLSOFT_COMPILER_IS_INTEL) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)::iterator_category()) -# elif defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES) -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(_Iter_cat)(i)) -# else -# error -# endif /* */ -#elif defined(__STLSOFT_COMPILER_IS_MSVC) -# if defined(__STLSOFT_CF_STL_IS_STLPORT) -# if _MSC_VER < 1300 -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i)) -# else -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i)) -# endif /* _MSC_VER < 1300 */ -# elif defined(__STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES) -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(_Iter_cat)(i)) -# elif(_MSC_VER >= 1310) -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)::iterator_category()) -# elif(_MSC_VER >= 1200) -# error -# endif /* */ -#else -# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)::iterator_category()) -#endif /* __STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES && !__STLSOFT_CF_STL_IS_STLPORT */ - -#if 0 -template -struct queried_iterator_category -{ -}; - -template -query_iterator_category -#endif /* 0 */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _STLSOFT_INCL_H_STLSOFT_ITERATOR */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_lock_scope.h b/etc/c/stlsoft/stlsoft_lock_scope.h deleted file mode 100644 index e71e5992ba4..00000000000 --- a/etc/c/stlsoft/stlsoft_lock_scope.h +++ /dev/null @@ -1,237 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: stlsoft_lock_scope.h (originally MLLock.h, ::SynesisStd) - * - * Purpose: Synchronisation object lock scoping class. - * - * Created: 1st October 1994 - * Updated: 22nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT_LOCK_SCOPE -#define _STLSOFT_INCL_H_STLSOFT_LOCK_SCOPE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _STLSOFT_VER_H_STLSOFT_LOCK_SCOPE_MAJOR 3 -#define _STLSOFT_VER_H_STLSOFT_LOCK_SCOPE_MINOR 0 -#define _STLSOFT_VER_H_STLSOFT_LOCK_SCOPE_REVISION 2 -#define _STLSOFT_VER_H_STLSOFT_LOCK_SCOPE_EDIT 89 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT -# include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _STLSOFT_NO_NAMESPACE -namespace stlsoft -{ -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class lock_traits - -/// Traits class for lockable objects -/// -/// \param L The lockable class -template -struct lock_traits -{ -public: - /// The lockable type - typedef L lock_type; - /// The current parameterisation of this type - typedef lock_traits class_type; - -// Operations -public: - /// Locks the given lockable instance - static void lock(lock_type &c) - { - lock_instance(c); - } - - /// Unlocks the given lockable instance - static void unlock(lock_type &c) - { - unlock_instance(c); - } -}; - -// class lock_invert_traits - -/// Traits class for inverting the lock status of lockable objects -/// -/// \param L The lockable class -template -struct lock_invert_traits -{ -public: - /// The lockable type - typedef L lock_type; - /// The current parameterisation of this type - typedef lock_invert_traits class_type; - -// Operations -public: - /// Unlocks the given lockable instance - static void lock(lock_type &c) - { - unlock_instance(c); - } - - /// Locks the given lockable instance - static void unlock(lock_type &c) - { - lock_instance(c); - } -}; - -// class lock_traits_inverter - -/// Traits inverter class for inverting the lock behaviour of lockable traits types -/// -/// \param L The traits class -template -struct lock_traits_inverter -{ -public: - /// The traits type - typedef T traits_type; - /// The lockable type - typedef ss_typename_type_k traits_type::lock_type lock_type; - /// The current parameterisation of this type - typedef lock_traits_inverter class_type; - -// Operations -public: - /// Unlocks the given lockable instance - static void lock(lock_type &c) - { - traits_type::unlock(c); - } - - /// Locks the given lockable instance - static void unlock(lock_type &c) - { - traits_type::lock(c); - } -}; - -// class lock_scope - -/// This class scopes the lock status of a lockable type -/// -/// \param L The lockable type, e.g. stlsoft::null_mutex -/// \param T The lock traits. On translators that support default template arguments this defaults to lock_traits -template< ss_typename_param_k L -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = lock_traits -#else - , ss_typename_param_k T -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > -class lock_scope -{ -public: - /// The lockable type - typedef L lock_type; - /// The traits type - typedef T traits_type; - /// The current parameterisation of this type - typedef lock_scope class_type; - -// Construction -public: - /// Locks the lockable instance - lock_scope(lock_type &l) - : m_l(l) - { - traits_type::lock(m_l); - } - /// Unlocks the lockable instance - ~lock_scope() - { - traits_type::unlock(m_l); - } - -// Members -private: - lock_type &m_l; - -// Not to be implemented -private: - lock_scope(class_type const &rhs); - lock_scope &operator =(class_type const &rhs); -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_STLSOFT_INCL_H_STLSOFT_LOCK_SCOPE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_null.h b/etc/c/stlsoft/stlsoft_null.h deleted file mode 100644 index c09cb4b0496..00000000000 --- a/etc/c/stlsoft/stlsoft_null.h +++ /dev/null @@ -1,240 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: stlsoft_null.h - * - * Purpose: NULL_v template class. - * - * Created: 8th September 2002 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT_NULL -#define _STLSOFT_INCL_H_STLSOFT_NULL - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _STLSOFT_VER_H_STLSOFT_NULL_MAJOR 1 -#define _STLSOFT_VER_H_STLSOFT_NULL_MINOR 6 -#define _STLSOFT_VER_H_STLSOFT_NULL_REVISION 1 -#define _STLSOFT_VER_H_STLSOFT_NULL_EDIT 19 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT -# include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -/* _STLSOFT_NULL_v_DEFINED */ - -#ifdef _STLSOFT_NULL_v_DEFINED -# undef _STLSOFT_NULL_v_DEFINED -#endif /* _STLSOFT_NULL_v_DEFINED */ - -#define _STLSOFT_NULL_v_DEFINED - -#if defined(__STLSOFT_COMPILER_IS_DMC) -//# if __DMC__ < 0x0832 -# undef _STLSOFT_NULL_v_DEFINED -//# endif /* __DMC__ < 0x0832 */ -#elif defined(__STLSOFT_COMPILER_IS_MSVC) && \ - _MSC_VER < 1310 -# undef _STLSOFT_NULL_v_DEFINED -#elif defined(__STLSOFT_COMPILER_IS_WATCOM) -# undef _STLSOFT_NULL_v_DEFINED -#endif /* compiler */ - -/* _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT */ - -#ifdef _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT -# undef _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT -#endif /* _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT */ - -#define _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT - -#if defined(__STLSOFT_COMPILER_IS_GCC) -# undef _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) -# undef _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _STLSOFT_NO_NAMESPACE -namespace stlsoft -{ -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -#ifdef _STLSOFT_NULL_v_DEFINED - -/// \brief Represents a type that can be an active replacement for NULL -/// -/// This class can act as a replacement for the NULL macro, by being validly -/// assigned to or equated with pointer types only, as in -/// -/// int i = NULL; // error -/// int *p = NULL; // OK -/// -/// if(i == NULL) {} // error -/// if(NULL == i) {} // error -/// -/// if(p == NULL) {} // OK -/// if(NULL == p) {} // OK -/// -/// -/// When used via inclusion of the file stlsoft_nulldef.h, the macro NULL is -/// redefined as NULL_v(), such that expressions containing NULL will be valid -/// against pointers only. -struct NULL_v -{ -// Construction -public: - /// Default constructor - NULL_v() - {} - -/// Static creation -public: - static NULL_v create() - { - return NULL_v(); - } - -// Conversion -public: - /// Implicit conversion operator (convertible to any pointer type) - /// - /// \param T The type of the pointer to which an instance will be convertible - template - operator T *() const - { - return 0; - } - -#ifdef _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT - /// Implicit conversion operator (convertible to any pointer type) - /// - /// \param T The type of the pointer to which an instance will be convertible - template - operator T2 C::*() const - { - return 0; - } -#endif /* _STLSOFT_NULL_v_DEFINED_PTR_TO_MEMBER_SUPPORT */ - - /// Evaluates whether an instance of a type is null - /// - /// \param rhs A reference arbitrary type which will be compared to null - template - ss_bool_t equals(T const &rhs) const - { - return rhs == 0; - } - -// Not to be implemented -private: - void operator &() const; - - NULL_v(NULL_v const &); - NULL_v const &operator =(NULL_v const &); -}; - -#if 1 -/// operator == for NULL_v and an arbitrary type -template -inline ss_bool_t operator ==(NULL_v const &lhs, T const &rhs) -{ - return lhs.equals(rhs); -} - -/// operator == for an arbitrary type and NULL_v -template -inline ss_bool_t operator ==(T const &lhs, NULL_v const &rhs) -{ - return rhs.equals(lhs); -} - -/// operator != for NULL_v and an arbitrary type -template -inline ss_bool_t operator !=(NULL_v const &lhs, T const &rhs) -{ - return !lhs.equals(rhs); -} - -/// operator != for an arbitrary type and NULL_v -template -inline ss_bool_t operator !=(T const &lhs, NULL_v const &rhs) -{ - return !rhs.equals(lhs); -} -#endif /* 0 */ - -#endif /* _STLSOFT_NULL_v_DEFINED */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_STLSOFT_INCL_H_STLSOFT_NULL */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_null_mutex.h b/etc/c/stlsoft/stlsoft_null_mutex.h deleted file mode 100644 index f277aac4ba2..00000000000 --- a/etc/c/stlsoft/stlsoft_null_mutex.h +++ /dev/null @@ -1,162 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: stlsoft_null_mutex.h (originally MLMutex.h, ::SynesisStd) - * - * Purpose: Mutual exclusion model class. - * - * Date: 19th December 1997 - * Updated: 2nd July 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT_NULL_MUTEX -#define _STLSOFT_INCL_H_STLSOFT_NULL_MUTEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _STLSOFT_VER_H_STLSOFT_NULL_MUTEX_MAJOR 1 -#define _STLSOFT_VER_H_STLSOFT_NULL_MUTEX_MINOR 1 -#define _STLSOFT_VER_H_STLSOFT_NULL_MUTEX_REVISION 1 -#define _STLSOFT_VER_H_STLSOFT_NULL_MUTEX_EDIT 10 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT - #include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _STLSOFT_NO_NAMESPACE -namespace stlsoft -{ -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class null_mutex - -/// This class provides a null implementation of the mutex model -class null_mutex -{ -public: - typedef null_mutex class_type; - -// Construction -public: - /// Creates an instance of the mutex - null_mutex() stlsoft_throw_0() - {} - -// Operations -public: - /// Acquires a lock on the mutex, pending the thread until the lock is aquired - void lock() stlsoft_throw_0() - {} - /// Releases an aquired lock on the mutex - void unlock() stlsoft_throw_0() - {} - -// Not to be implemented -private: - null_mutex(class_type const &rhs); - null_mutex &operator =(class_type const &rhs); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Control shims - */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_sync_control Synchronisation Control Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects - -/// \defgroup stlsoft_sync_control_shims Synchronisation Control Shims (STLSoft) -/// \ingroup STLSoft concepts_shims_sync_control -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects -/// @{ - -/// This control \ref concepts_shims "shim" aquires a lock on the given mutex -/// -/// \param mx The mutex on which to aquire the lock -inline void lock_instance(null_mutex &) -{} - -/// This control ref concepts_shims "shim" releases a lock on the given mutex -/// -/// \param mx The mutex on which to release the lock -inline void unlock_instance(null_mutex &) -{} - -/// @} // end of group stlsoft_sync_control_shims - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_STLSOFT_INCL_H_STLSOFT_NULL_MUTEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_nulldef.h b/etc/c/stlsoft/stlsoft_nulldef.h deleted file mode 100644 index b7bfbc0b2bf..00000000000 --- a/etc/c/stlsoft/stlsoft_nulldef.h +++ /dev/null @@ -1,111 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: stlsoft_nulldef.h - * - * Purpose: Include for defining NULL to be the NULL_v template class. - * - * Created: 17th December 2002 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT_NULLDEF -#define _STLSOFT_INCL_H_STLSOFT_NULLDEF - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _STLSOFT_VER_H_STLSOFT_NULLDEF_MAJOR 1 -#define _STLSOFT_VER_H_STLSOFT_NULLDEF_MINOR 0 -#define _STLSOFT_VER_H_STLSOFT_NULLDEF_REVISION 5 -#define _STLSOFT_VER_H_STLSOFT_NULLDEF_EDIT 8 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT -# include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ -#ifndef _STLSOFT_INCL_H_STLSOFT_NULL -# include "stlsoft_null.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT_NULL */ - -#include // Always make sure that this is included, irrespective of - // its potential inclusion within stlsoft.h - -/* ///////////////////////////////////////////////////////////////////////////// - * Definitions - */ - -#ifndef NULL -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message("NULL not defined. This is potentially dangerous. You are advised to include its defining header before stlsoft_nulldef.h") -# endif /* _STLSOFT_COMPILE_VERBOSE */ -#endif /* !NULL */ - -#ifdef _STLSOFT_NULL_v_DEFINED -# ifdef __cplusplus -# ifdef NULL -# undef NULL -# endif /* NULL */ - /// \def NULL - /// - /// By including this file, \c NULL is (re-)defined to be stlsoft::NULL_v() - /// which means that any use of \c NULL must be with pointer types. -# define NULL stlsoft_ns_qual(NULL_v)::create() -# endif /* __cplusplus */ -#endif /* _STLSOFT_NULL_v_DEFINED */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_STLSOFT_INCL_H_STLSOFT_NULLDEF */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/stlsoft_static_initialisers.h b/etc/c/stlsoft/stlsoft_static_initialisers.h deleted file mode 100644 index fe0e60a7ddb..00000000000 --- a/etc/c/stlsoft/stlsoft_static_initialisers.h +++ /dev/null @@ -1,255 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: stlsoft_static_initialisers.h (formerly MLClsCtr.h, ::SynesisStd) - * - * Purpose: Class constructor. - * - * Created: 17th February 1997 - * Updated: 26th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/stlsoft - * http://www.stlsoft.org/ - * - * email: submissions@stlsoft.org for submissions - * admin@stlsoft.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _STLSOFT_INCL_H_STLSOFT_STATIC_INITIALISERS -#define _STLSOFT_INCL_H_STLSOFT_STATIC_INITIALISERS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _STLSOFT_VER_H_STLSOFT_STATIC_INITIALISERS_MAJOR 1 -# define _STLSOFT_VER_H_STLSOFT_STATIC_INITIALISERS_MINOR 8 -# define _STLSOFT_VER_H_STLSOFT_STATIC_INITIALISERS_REVISION 2 -# define _STLSOFT_VER_H_STLSOFT_STATIC_INITIALISERS_EDIT 191 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT -# include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _STLSOFT_NO_NAMESPACE -namespace stlsoft -{ -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -#if 0 -class method_constructor -{ -public: - template - method_constructor(T const &t, void (T::*const fn)()) - { - (t.*fn)(); - } - template - method_constructor(T const &t, R (T::*const fn)()) - { - (t.*fn)(); - } -}; -#endif /* 0 */ - -/// static_initialiser -/// -/// Initialises any non-class function or type -class static_initialiser -{ -public: - typedef static_initialiser class_type; - -/// \name Constructors -//@{ -public: -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT - template - static_initialiser(T const &/* t */) - {} - template - static_initialiser(T const * /* pt */) - {} -#else - static_initialiser(int /* t */) - {} - static_initialiser(void const * /* pt */) - {} -#endif // __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT -//@} - -/// \name Not to be implemented -//@{ -private: - static_initialiser(class_type const &); - static_initialiser &operator =(class_type const &); - -#ifdef __STLSOFT_COMPILER_IS_COMO - void *operator new(ss_size_t) stlsoft_throw_0() - { - return 0; - } -#else /* ? __STLSOFT_COMPILER_IS_COMO */ - void *operator new(ss_size_t) stlsoft_throw_0(); -#endif /* __STLSOFT_COMPILER_IS_COMO */ - void operator delete(void *) - {} -//@} -}; - - -class api_constructor -{ -/// \name Constructors -//@{ -public: - api_constructor(void (*pfnInit)(), void (*pfnUninit)()) - : m_pfnUninit(pfnUninit) - { - if(NULL != pfnInit) - { - (*pfnInit)(); - } - } - ~api_constructor() - { - if(NULL != m_pfnUninit) - { - (*m_pfnUninit)(); - } - } -//@} - -/// \name Members -//@{ -private: - void (*m_pfnUninit)(void); -//@} - -/// \name Not to be implemented -//@{ -private: - api_constructor(api_constructor const &); - api_constructor &operator =(api_constructor const &); - -#ifdef __STLSOFT_COMPILER_IS_COMO - void *operator new(ss_size_t) stlsoft_throw_0() - { - return 0; - } -#else /* ? __STLSOFT_COMPILER_IS_COMO */ - void *operator new(ss_size_t) stlsoft_throw_0(); -#endif /* __STLSOFT_COMPILER_IS_COMO */ - void operator delete(void *) - {} -//@} -}; - -template -class class_constructor - : protected api_constructor -{ -/// \name Member types -//@{ -public: - typedef void (*class_init_fn_t)(); - typedef void (*class_uninit_fn_t)(); - -//@} - -/// \name Constructors -//@{ -public: - ss_explicit_k class_constructor() - : api_constructor(&T::class_init, &T::class_uninit) - {} - - ss_explicit_k class_constructor( class_init_fn_t pfnInit - , class_uninit_fn_t pfnUninit) - : api_constructor(pfnInit, pfnUninit) - {} -//@} - -/// \name Not to be implemented -//@{ -private: - class_constructor(class_constructor const &); - class_constructor &operator =(class_constructor const &); - -#ifdef __STLSOFT_COMPILER_IS_COMO - void *operator new(ss_size_t) stlsoft_throw_0() - { - return 0; - } -#else /* ? __STLSOFT_COMPILER_IS_COMO */ - void *operator new(ss_size_t) stlsoft_throw_0(); -#endif /* __STLSOFT_COMPILER_IS_COMO */ - void operator delete(void *) - {} -//@} -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _STLSOFT_NO_NAMESPACE -} // namespace stlsoft -#endif /* _STLSOFT_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_STLSOFT_INCL_H_STLSOFT_STATIC_INITIALISERS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl.h b/etc/c/stlsoft/unixstl.h deleted file mode 100644 index 13f03e107a9..00000000000 --- a/etc/c/stlsoft/unixstl.h +++ /dev/null @@ -1,436 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl.h - * - * Purpose: Root header for the UNIXSTL libraries. Performs various compiler - * and platform discriminations, and definitions of types. - * - * Created: 15th January 2002 - * Updated: 16th October 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -#define _UNIXSTL_INCL_H_UNIXSTL - -/* File version */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_MINOR 5 -#define _UNIXSTL_VER_H_UNIXSTL_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_EDIT 28 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/** \file unixstl.h The root header for the \ref UNIXSTL project */ - -/** \weakgroup projects STLSoft Projects - * - * \brief The Projects that comprise the STLSoft libraries - */ - -/** \defgroup UNIXSTL UNIXSTL - * \ingroup projects - * - * \brief     Template Software for the UNIX Operating System - * - * The philosophy of UNIXSTL (http://unixstl.org/) is essentially the same as that - * of the STLSoft (http://stlsoft.org/) organisation: providing robust and - * lightweight software to the UNIX development - * community. UNIXSTL provides template-based software that builds on that - * provided by UNIX and STLSoft in order to reduce programmer effort and increase - * robustness in the use of the UNIX. - * - * Namespaces - * - * The UNIXSTL namespace unixstl is actually an alias for the - * namespace stlsoft::unixstl_project, and as such all the - * UNIXSTL project components actually reside within the - * stlsoft namespace. However, there is never any need to - * use the stlsoft::unixstl_project namespace in your code, - * and you should always use the alias unixstl. - * - * Dependencies - * - * As with all parts of the STLSoft libraries, there are no - * dependencies on UNIXSTL binary components and no need to compile UNIXSTL - * implementation files; UNIXSTL is 100% header-only! - * - * As with most of the STLSoft sub-projects, UNIXSTL depends only on: - * - * - Selected headers from the C standard library, such as wchar.h - * - Selected headers from the C++ standard library, such as new, functional - * - Selected header files of the STLSoft main project - * - The header files particular to the technology area, in this case the UNIX library headers, such as dirent.h - * - The binary (static and dynamic libraries) components particular to the technology area, in this case the UNIX libraries that ship with the operating system and your compiler(s) - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * UNIXSTL version - * - * The libraries version information is comprised of major, minor and revision - * components. - * - * The major version is denoted by the _UNIXSTL_VER_MAJOR preprocessor symbol. - * A changes to the major version component implies that a dramatic change has - * occurred in the libraries, such that considerable changes to source dependent - * on previous versions would need to be effected. - * - * The minor version is denoted by the _UNIXSTL_VER_MINOR preprocessor symbol. - * Changes to the minor version component imply that a significant change has - * occurred to the libraries, either in the addition of new functionality or in - * the destructive change to one or more components such that recomplilation and - * code change may be necessitated. - * - * The revision version is denoted by the _UNIXSTL_VER_REVISIO preprocessor - * symbol. Changes to the revision version component imply that a bug has been - * fixed. Dependent code should be recompiled in order to pick up the changes. - * - * In addition to the individual version symbols - _UNIXSTL_VER_MAJOR, - * _UNIXSTL_VER_MINOR and _UNIXSTL_VER_REVISION - a composite symbol _UNIXSTL_VER - * is defined, where the upper 8 bits are 0, bits 16-23 represent the major - * component, bits 8-15 represent the minor component, and bits 0-7 represent - * the revision component. - * - * Each release of the libraries will bear a different version, and that version - * will also have its own symbol: Version 1.0.1 specifies _UNIXSTL_VER_1_0_1. - * - * Thus the symbol _UNIXSTL_VER may be compared meaningfully with a specific - * version symbol, e.g. #if _UNIXSTL_VER >= _UNIXSTL_VER_1_0_1 - */ - -/// \def _UNIXSTL_VER_MAJOR -/// The major version number of UNIXSTL - -/// \def _UNIXSTL_VER_MINOR -/// The minor version number of UNIXSTL - -/// \def _UNIXSTL_VER_REVISION -/// The revision version number of UNIXSTL - -/// \def _UNIXSTL_VER -/// The current composite version number of UNIXSTL - -#define _UNIXSTL_VER_MAJOR 1 -#define _UNIXSTL_VER_MINOR 1 -#define _UNIXSTL_VER_REVISION 1 -#define _UNIXSTL_VER_0_9_1 0x00000901 /*!< Version 0.9.1 */ -#define _UNIXSTL_VER_0_9_2 0x00000902 /*!< Version 0.9.2 */ -#define _UNIXSTL_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */ -#define _UNIXSTL_VER_1_0_2 0x00010002 /*!< Version 1.0.2 */ -#define _UNIXSTL_VER_1_0_3 0x00010003 /*!< Version 1.0.3 */ -#define _UNIXSTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */ - -#define _UNIXSTL_VER _UNIXSTL_VER_1_1_1 - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _STLSOFT_INCL_H_STLSOFT - #include "stlsoft.h" // Include the STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * STLSoft version compatibility - */ - -#if !defined(_STLSOFT_VER_1_5_1) || \ - _STLSOFT_VER < _STLSOFT_VER_1_5_1 - #error This version of the UNIXSTL libraries requires STLSoft version 1.5.1 or later -#endif /* _STLSOFT_VER < _STLSOFT_VER_1_5_1 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler compatibility - * - * Currently the only compilers supported by the UNIXSTL libraries are - * - * GCC 2.95, 2.96, 3.2 - * Intel C/C++ 6.0 & 7.0 - */ - -#if defined(__STLSOFT_COMPILER_IS_GCC) -/* GNU C/C++ */ - #if __GNUC__ < 2 || \ - ( __GNUC__ == 2 && \ - __GNUC_MINOR__ < 95) - #error Versions of GNU C/C++ prior to 2.95 are not supported by the UNIXSTL libraries - #endif /* __GNUC__ */ - -#elif defined(__STLSOFT_COMPILER_IS_INTEL) -/* Intel C++ */ - #if (__INTEL_COMPILER < 700) - #error Versions of Intel C++ prior to 7.0 are not supported by the UNIXSTL libraries - #endif /* __INTEL_COMPILER */ - -#else -/* No recognised compiler */ -# ifdef _STLSOFT_FORCE_ANY_COMPILER -# define _UNIXSTL_COMPILER_IS_UNKNOWN -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message("Compiler is unknown to UNIXSTL") -# endif /* _STLSOFT_COMPILE_VERBOSE */ -# else -# error Currently only GNU C/C++ compiler supported by the UNIXSTL libraries -# endif /* _STLSOFT_FORCE_ANY_COMPILER */ -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Debugging - * - * The macro unixstl_assert provides standard debug-mode assert functionality. - */ - -/// Defines a runtime assertion -/// -/// \param _x Must be non-zero, or an assertion will be fired -#define unixstl_assert(_x) stlsoft_assert(_x) - -/// Defines a runtime assertion, with message -/// -/// \param _x Must be non-zero, or an assertion will be fired -/// \param _m The literal character string message to be included in the assertion -#define unixstl_message_assert(_m, _x) stlsoft_message_assert(_m, _x) - -/// Defines a compile-time assertion -/// -/// \param _x Must be non-zero, or compilation will fail -#define unixstl_static_assert(_x) stlsoft_static_assert(_x) - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The UNIXSTL components are contained within the unixstl namespace. This is - * usually an alias for stlsoft::unixstl_project, - * - * When compilers support namespaces they are defined by default. They can be - * undefined using a cascasing system, as follows: - * - * If _STLSOFT_NO_NAMESPACES is defined, then _UNIXSTL_NO_NAMESPACES is defined. - * - * If _UNIXSTL_NO_NAMESPACES is defined, then _UNIXSTL_NO_NAMESPACE is defined. - * - * If _UNIXSTL_NO_NAMESPACE is defined, then the UNIXSTL constructs are defined - * in the global scope. - * - * If _STLSOFT_NO_NAMESPACES, _UNIXSTL_NO_NAMESPACES and _UNIXSTL_NO_NAMESPACE are - * all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the - * namespace stlsoft does not exist), then the UNIXSTL constructs are defined - * within the unixstl namespace. The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition - * --------------------- -------------------- ----------------- - * not defined not defined = stlsoft::unixstl_project - * not defined defined not defined - * defined not defined unixstl - * defined defined not defined - * - * - * - * The macro unixstl_ns_qual() macro can be used to refer to elements in the - * UNIXSTL libraries irrespective of whether they are in the - * stlsoft::unixstl_project (or unixstl) namespace or in the global namespace. - * - * Furthermore, some compilers do not support the standard library in the std - * namespace, so the unixstl_ns_qual_std() macro can be used to refer to elements - * in the UNIXSTL libraries irrespective of whether they are in the std namespace - * or in the global namespace. - */ - -/* No STLSoft namespaces means no UNIXSTL namespaces */ -#ifdef _STLSOFT_NO_NAMESPACES - #define _UNIXSTL_NO_NAMESPACES -#endif /* _STLSOFT_NO_NAMESPACES */ - -/* No UNIXSTL namespaces means no unixstl namespace */ -#ifdef _UNIXSTL_NO_NAMESPACES - #define _UNIXSTL_NO_NAMESPACE -#endif /* _UNIXSTL_NO_NAMESPACES */ - -#ifndef _UNIXSTL_NO_NAMESPACE - #ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ - #else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -/// The UNIXSTL namespace - \c unixstl (aliased to \c stlsoft::unixstl_project) - is -/// the namespace for the UNIXSTL project. -namespace unixstl_project -{ - - #endif /* _STLSOFT_NO_NAMESPACE */ -#else -stlsoft_ns_using(move_lhs_from_rhs) -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/// \def unixstl_ns_qual(x) -/// Qualifies with unixstl:: if UNIXSTL is using namespaces or, if not, does not qualify - -/// \def unixstl_ns_using(x) -/// Declares a using directive (with respect to unixstl) if UNIXSTL is using namespaces or, if not, does nothing - -#ifndef _UNIXSTL_NO_NAMESPACE - #define unixstl_ns_qual(x) ::unixstl::x - #define unixstl_ns_using(x) using ::unixstl::x; -#else - #define unixstl_ns_qual(x) x - #define unixstl_ns_using(x) -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/// \def unixstl_ns_qual_std(x) -/// Qualifies with std:: if UNIXSTL is being translated in the context of the standard library being within the std namespace or, if not, does not qualify - -/// \def unixstl_ns_using_std(x) -/// Declares a using directive (with respect to std) if UNIXSTL is being translated in the context of the standard library being within the std namespace or, if not, does nothing - -#ifdef __STLSOFT_CF_std_NAMESPACE - #define unixstl_ns_qual_std(x) ::std::x - #define unixstl_ns_using_std(x) using ::std::x; -#else - #define unixstl_ns_qual_std(x) x - #define unixstl_ns_using_std(x) -#endif /* !__STLSOFT_CF_std_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - * - * The UNIXSTL uses a number of typedefs to aid in compiler-independence in the - * libraries' main code. - */ - -typedef stlsoft_ns_qual(ss_char_a_t) us_char_a_t; //!< Ansi char type -typedef stlsoft_ns_qual(ss_char_w_t) us_char_w_t; //!< Unicode char type -typedef stlsoft_ns_qual(ss_sint8_t) us_sint8_t; //!< 8-bit signed integer -typedef stlsoft_ns_qual(ss_uint8_t) us_uint8_t; //!< 8-bit unsigned integer -typedef stlsoft_ns_qual(ss_int16_t) us_int16_t; //!< 16-bit integer -typedef stlsoft_ns_qual(ss_sint16_t) us_sint16_t; //!< 16-bit signed integer -typedef stlsoft_ns_qual(ss_uint16_t) us_uint16_t; //!< 16-bit unsigned integer -typedef stlsoft_ns_qual(ss_int32_t) us_int32_t; //!< 32-bit integer -typedef stlsoft_ns_qual(ss_sint32_t) us_sint32_t; //!< 32-bit signed integer -typedef stlsoft_ns_qual(ss_uint32_t) us_uint32_t; //!< 32-bit unsigned integer -#ifdef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT -typedef stlsoft_ns_qual(ss_int64_t) us_int64_t; //!< 64-bit integer -typedef stlsoft_ns_qual(ss_sint64_t) us_sint64_t; //!< 64-bit signed integer -typedef stlsoft_ns_qual(ss_uint64_t) us_uint64_t; //!< 64-bit unsigned integer -#endif /* __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT */ -typedef stlsoft_ns_qual(ss_int_t) us_int_t; //!< integer -typedef stlsoft_ns_qual(ss_sint_t) us_sint_t; //!< signed integer -typedef stlsoft_ns_qual(ss_uint_t) us_uint_t; //!< unsigned integer -typedef stlsoft_ns_qual(ss_long_t) us_long_t; //!< long -typedef stlsoft_ns_qual(ss_bool_t) us_bool_t; //!< bool -typedef stlsoft_ns_qual(ss_size_t) us_size_t; //!< size -typedef stlsoft_ns_qual(ss_ptrdiff_t) us_ptrdiff_t; //!< ptr diff -typedef stlsoft_ns_qual(ss_streampos_t) us_streampos_t; //!< streampos -typedef stlsoft_ns_qual(ss_streamoff_t) us_streamoff_t; //!< streamoff - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/* ///////////////////////////////////////////////////////////////////////////// - * Values - * - * Since the boolean type may not be supported natively on all compilers, the - * values of true and false may also not be provided. Hence the values of - * us_true_v and us_false_v are defined, and are used in all code. - */ - -#define us_true_v ss_true_v -#define us_false_v ss_false_v - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ -/* ///////////////////////////////////////////////////////////////////////////// - * Code modification macros - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/* Exception signatures. */ -#define unixstl_throw_0() stlsoft_throw_0() -#define unixstl_throw_1(x1) stlsoft_throw_1(x1) -#define unixstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2) -#define unixstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3) -#define unixstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4) -#define unixstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5) -#define unixstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6) -#define unixstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7) -#define unixstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/// Evaluates, at compile time, to the number of elements within the given vector entity -#define unixstl_num_elements(_x) stlsoft_num_elements(_x) - -/// Destroys the given instance \c p of the given type (\c t and \c _type) -#define unixstl_destroy_instance(t, _type, p) stlsoft_destroy_instance(t, _type, p) - -/// Generates an opaque type with the name \c _htype -#define unixstl_gen_opaque(_htype) stlsoft_gen_opaque(_htype) - -/// Define a 'final' class, ie. one that cannot be inherited from -#define unixstl_sterile_class(_cls) stlsoft_sterile_class(_cls) - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE - #ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl - #else -} // namespace unixstl_project -} // namespace stlsoft -namespace unixstl = ::stlsoft::unixstl_project; - #endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_current_directory.h b/etc/c/stlsoft/unixstl_current_directory.h deleted file mode 100644 index ca6cbc2594b..00000000000 --- a/etc/c/stlsoft/unixstl_current_directory.h +++ /dev/null @@ -1,251 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_current_directory.h - * - * Purpose: Simple class that gets, and makes accessible, the current - * directory. - * - * Created: 1st November 2003 - * Updated: 2nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_CURRENT_DIRECTORY -#define _UNIXSTL_INCL_H_UNIXSTL_CURRENT_DIRECTORY - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_MINOR 0 -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_EDIT 2 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -# include "unixstl.h" // Include the WinSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS -# include "unixstl_filesystem_traits.h" // file_traits -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \weakgroup unixstl_filesystem_library File-System Library (WinSTL) -/// \ingroup WinSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating file-system objects for the Win32 API -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * basic_current_directory - * - * This class wraps the GetCurrentDirectory() API function, and effectively acts - * as a C-string of its value. - */ - -/// Represents the current directory -/// -/// \param C The character type -/// \param T The traits type. On translators that support default template arguments, this defaults to filesystem_traits -template< ss_typename_param_k C -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = filesystem_traits -#else - , ss_typename_param_k T /* = filesystem_traits */ -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > -class basic_current_directory -{ -public: - /// The char type - typedef C char_type; - /// The traits type - typedef T traits_type; - /// The current parameterisation of the type - typedef basic_current_directory class_type; - /// The size type - typedef us_size_t size_type; - -// Construction -public: - /// Default constructor - basic_current_directory(); - -// Operations -public: - /// Gets the current directory into the given buffer - static size_type get_path(char_type *buffer, size_type cchBuffer); - -// Attributes -public: - /// Returns a non-mutable (const) pointer to the path - char_type const *get_path() const; - /// Returns the length of the converted path - size_type length() const; - -// Conversions -public: - /// Implicit conversion to a non-mutable (const) pointer to the path - operator char_type const *() const - { - return get_path(); - } - -// Members -private: - char_type m_dir[1 + PATH_MAX]; - size_type const m_len; - -// Not to be implemented -private: - basic_current_directory(const class_type &); - basic_current_directory &operator =(const class_type &); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs for commonly encountered types - */ - -/// Instantiation of the basic_current_directory template for the ANSI character type \c char -typedef basic_current_directory > current_directory_a; -/// Instantiation of the basic_current_directory template for the Unicode character type \c wchar_t -typedef basic_current_directory > current_directory_w; - -/* ///////////////////////////////////////////////////////////////////////////// - * Implementation - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline basic_current_directory::basic_current_directory() - : m_len(get_path(m_dir, unixstl_num_elements(m_dir))) -{} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline /* static */ ss_typename_type_k basic_current_directory::size_type basic_current_directory::get_path(ss_typename_type_k basic_current_directory::char_type *buffer, ss_typename_type_k basic_current_directory::size_type cchBuffer) -{ - return static_cast(traits_type::get_current_directory(cchBuffer, buffer)); -} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline ss_typename_type_k basic_current_directory::char_type const *basic_current_directory::get_path() const -{ - return m_dir; -} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline ss_typename_type_k basic_current_directory::size_type basic_current_directory::length() const -{ - return m_len; -} - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _UNIXSTL_INCL_H_UNIXSTL_CURRENT_DIRECTORY */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_current_directory_scope.h b/etc/c/stlsoft/unixstl_current_directory_scope.h deleted file mode 100644 index 7082181981b..00000000000 --- a/etc/c/stlsoft/unixstl_current_directory_scope.h +++ /dev/null @@ -1,313 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_current_directory_scope.h (formerly MLPwdScp.h, ::SynesisStd) - * - * Purpose: Current working directory scoping class. - * - * Created: 12th November 1998 - * Updated: 2nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE -#define _UNIXSTL_INCL_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE_MAJOR 2 -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE_MINOR 4 -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE_EDIT 51 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_WINSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_UNIXSTL_INCL_H_WINSTL */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS -# include "unixstl_filesystem_traits.h" // file_traits -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS */ -#ifndef _STLSOFT_INCL_H_STLSOFT_STRING_ACCESS -# include "stlsoft_string_access.h" // stlsoft::c_str_ptr -#endif /* !_STLSOFT_INCL_H_STLSOFT_STRING_ACCESS */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS -# include "unixstl_string_access.h" // unixstl::c_str_ptr -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -stlsoft_ns_using(c_str_ptr) - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \defgroup unixstl_filesystem_library File-System Library (UNIXSTL) -/// \ingroup UNIXSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating UNIX file-system objects -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * basic_current_directory_scope - * - * This class pushes the given directory as the current directory upon - * construction, and pops back to the original at destruction. - */ - -/// \brief Current directory scoping class -/// -/// This class scopes the process's current directory, by changing to the path -/// given in the constructor, and then, if that succeeded, changing back in the -/// destructor -/// -/// \param C The character type (e.g. \c char, \c wchar_t) -/// \param T The file-system traits. In translators that support default template parameters that defaults to \c filesystem_traits - -template< ss_typename_param_k C -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = filesystem_traits -#else - , ss_typename_param_k T /* = filesystem_traits */ -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > -class basic_current_directory_scope -{ -public: - typedef C char_type; /*!< The character type */ -private: - typedef T traits_type; - typedef basic_current_directory_scope class_type; - -// Construction -public: - /// \brief Constructs a scope instance and changes to the given directory - /// - /// \param dir The name of the directory to change the current directory to - ss_explicit_k basic_current_directory_scope(char_type const *dir); -#if defined(__STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT) - /// \brief Constructs a scope instance and changes to the given directory - /// - /// \param dir The name of the directory to change the current directory to - template - ss_explicit_k basic_current_directory_scope(S const &dir) - { - _init(c_str_ptr(dir)); - } -#endif /* __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT */ - /// \brief Returns the current directory to its original location - ~basic_current_directory_scope() unixstl_throw_0(); - -// Conversions -public: - /// Returns a C-string pointer to the original directory - operator char_type const *() const; - -/// \name State -/// @{ -private: -#ifdef STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT - /// An opaque type to use for boolean evaluation - struct boolean { int i; }; - typedef int boolean::*boolean_t; -#else /* ? STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - typedef us_bool_t boolean_t; -#endif /* STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ -public: - /// Indicates whether the construction was successful - /// - /// \retval true The scope instance was successfully constructed and the current directory changed as per the constructor argument - /// \retval false The scope instance was not successfully constructed, and the current directory was unchanged. - operator boolean_t () const; -#ifndef STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT - /// Indicates whether the construction failed - /// - /// This method is the opposite of operator us_bool_t(), and the return values are inverted. - us_bool_t operator !() const; -#endif /* !STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - -/// @} - -// Implementation -private: - void _init(char_type const *dir); - -// Members -private: - char_type m_previous[1 + PATH_MAX]; - -// Not to be implemented -private: - basic_current_directory_scope(); - basic_current_directory_scope(class_type const &); - class_type const &operator =(class_type const &); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs for commonly encountered types - */ - -/// Instantiation of the basic_current_directory_scope template for the ANSI character type \c char -typedef basic_current_directory_scope > current_directory_scope_a; -/// Instantiation of the basic_current_directory_scope template for the Unicode character type \c wchar_t -typedef basic_current_directory_scope > current_directory_scope_w; - -/* ///////////////////////////////////////////////////////////////////////////// - * Implementation - */ - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline void basic_current_directory_scope::_init(ss_typename_type_k basic_current_directory_scope::char_type const *dir) -{ - if( 0 == traits_type::get_current_directory(unixstl_num_elements(m_previous), m_previous) || - !traits_type::set_current_directory(dir)) - { - m_previous[0] = '\0'; - } -} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline basic_current_directory_scope::basic_current_directory_scope(ss_typename_type_k basic_current_directory_scope::char_type const *dir) -{ - _init(c_str_ptr(dir)); -} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline basic_current_directory_scope::~basic_current_directory_scope() unixstl_throw_0() -{ - if(m_previous[0] != '\0') - { - traits_type::set_current_directory(m_previous); - } -} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline basic_current_directory_scope::operator ss_typename_type_k basic_current_directory_scope::char_type const *() const -{ - return m_previous; -} - -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline basic_current_directory_scope::operator ss_typename_type_k basic_current_directory_scope::boolean_t () const -{ -#ifdef STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT - return m_previous[0] != '\0' ? &boolean::i : NULL; -#else /* ? STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - return m_previous[0] != '\0'; -#endif /* STLSOFT_CF_OPERATOR_BOOL_AS_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ -} - -#ifndef STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT -template< ss_typename_param_k C - , ss_typename_param_k T - > -inline us_bool_t basic_current_directory_scope::operator !() const -{ - return !operator us_bool_t(); -} -#endif /* !STLSOFT_CF_OPERATOR_NOT_VIA_OPERATOR_POINTER_TO_MEMBER_SUPPORT */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _UNIXSTL_INCL_H_UNIXSTL_CURRENT_DIRECTORY_SCOPE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_environment_variable.h b/etc/c/stlsoft/unixstl_environment_variable.h deleted file mode 100644 index ac082dc8622..00000000000 --- a/etc/c/stlsoft/unixstl_environment_variable.h +++ /dev/null @@ -1,255 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_environment_variable.h - * - * Purpose: Simple class that provides access to an environment variable. - * - * Created: 2nd November 2003 - * Updated: 2nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_ENVIRONMENT_VARIABLE -#define _UNIXSTL_INCL_H_UNIXSTL_ENVIRONMENT_VARIABLE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_ENVIRONMENT_VARIABLE_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_ENVIRONMENT_VARIABLE_MINOR 3 -#define _UNIXSTL_VER_H_UNIXSTL_ENVIRONMENT_VARIABLE_REVISION 1 -#define _UNIXSTL_VER_H_UNIXSTL_ENVIRONMENT_VARIABLE_EDIT 14 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -# include "unixstl.h" // Include the WinSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_SYSTEM_VERSION -# include "unixstl_filesystem_traits.h" // Include the WinSTL get_environment_variable -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_SYSTEM_VERSION */ -#ifndef _STLSOFT_INCL_H_STLSOFT_STRING_ACCESS -# include "stlsoft_string_access.h" // stlsoft::c_str_ptr -#endif /* !_STLSOFT_INCL_H_STLSOFT_STRING_ACCESS */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS -# include "unixstl_string_access.h" // unixstl::c_str_ptr -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS */ -#ifndef _STLSOFT_INCL_H_STLSOFT_AUTO_BUFFER -# include "stlsoft_auto_buffer.h" // stlsoft::auto_buffer -#endif /* !_STLSOFT_INCL_H_STLSOFT_AUTO_BUFFER */ -#ifndef _STLSOFT_INCL_H_STLSOFT_MALLOC_ALLOCATOR -# include "stlsoft_malloc_allocator.h" // malloc_allocator -#endif /* _STLSOFT_INCL_H_STLSOFT_MALLOC_ALLOCATOR */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -stlsoft_ns_using(c_str_ptr) - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_system System Library -/// \ingroup libraries -/// \brief This library provides facilities for accessing system attributes - -/// \defgroup unixstl_system_library System Library (WinSTL) -/// \ingroup WinSTL libraries_system -/// \brief This library provides facilities for accessing Win32 system attributes -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * basic_environment_variable - * - * This class converts a relative path to an absolute one, and effectively acts - * as a C-string of its value. - */ - -/// Represents an environment variable -/// -/// \param C The character type -/// \param T The traits type. On translators that support default template arguments, this defaults to filesystem_traits -template< ss_typename_param_k C -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = filesystem_traits -#else - , ss_typename_param_k T /* = filesystem_traits */ -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > -class basic_environment_variable -{ -public: - /// The char type - typedef C char_type; - /// The traits type - typedef T traits_type; - /// The current parameterisation of the type - typedef basic_environment_variable class_type; - /// The size type - typedef size_t size_type; - -// Construction -public: - /// Create an instance representing the given environment variable - ss_explicit_k basic_environment_variable(char_type const *name) - : m_buffer(1 + traits_type::get_environment_variable(name, 0, 0)) - { - if( 0 == traits_type::get_environment_variable(name, m_buffer, m_buffer.size()) && - 0 != m_buffer.size()) - { - m_buffer[0] = 0; - } - } -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT - /// Create an instance representing the given environment variable - template - ss_explicit_k basic_environment_variable(S const &name) - : m_buffer(1 + traits_type::get_environment_variable(c_str_ptr(name), 0, 0)) - { - if( 0 == traits_type::get_environment_variable(c_str_ptr(name), m_buffer, m_buffer.size()) && - 0 != m_buffer.size()) - { - m_buffer[0] = 0; - } - } -#endif /* __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT */ - -// Conversions -public: - /// Implicit conversion to a non-mutable (const) pointer to the variable - operator char_type const *() const - { - return m_buffer.data(); - } - -// Attributes -public: - /// Returns the length of the variable - size_type length() const - { - return m_buffer.size() - 1; - } - -// Members -private: - typedef stlsoft_ns_qual(auto_buffer) > buffer_t; - - buffer_t m_buffer; - -// Not to be implemented -private: - basic_environment_variable(basic_environment_variable const &); - basic_environment_variable &operator =(basic_environment_variable const &); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs for commonly encountered types - */ - -/// Instantiation of the basic_environment_variable template for the ANSI character type \c char -typedef basic_environment_variable > environment_variable_a; -/// Instantiation of the basic_environment_variable template for the Unicode character type \c wchar_t -typedef basic_environment_variable > environment_variable_w; - -/* ///////////////////////////////////////////////////////////////////////////// - * Helper functions - */ - -#if !defined(__STLSOFT_COMPILER_IS_MSVC) || \ - _MSC_VER >= 1100 - -/// This helper function makes an environment variable without needing to -/// qualify the template parameter. -template -inline basic_environment_variable make_environment_variable(C const *path) -{ - return basic_environment_variable(path); -} - -#endif /* !(_MSC_VER < 1100) */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _UNIXSTL_INCL_H_UNIXSTL_ENVIRONMENT_VARIABLE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_filesystem_traits.h b/etc/c/stlsoft/unixstl_filesystem_traits.h deleted file mode 100644 index 708f6a8376c..00000000000 --- a/etc/c/stlsoft/unixstl_filesystem_traits.h +++ /dev/null @@ -1,462 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_filesystem_traits.h - * - * Purpose: Contains the filesystem_traits template class, and ANSI and - * Unicode specialisations thereof. - * - * Created: 15th November 2002 - * Updated: 3rd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS -#define _UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_FILESYSTEM_TRAITS_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_FILESYSTEM_TRAITS_MINOR 6 -#define _UNIXSTL_VER_H_UNIXSTL_FILESYSTEM_TRAITS_REVISION 1 -#define _UNIXSTL_VER_H_UNIXSTL_FILESYSTEM_TRAITS_EDIT 22 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_WINSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_UNIXSTL_INCL_H_WINSTL */ -#include -#include -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \defgroup unixstl_filesystem_library File-System Library (UNIXSTL) -/// \ingroup UNIXSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating UNIX file-system objects -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - * - * filesystem_traits - a traits template, along with - * filesystem_traits and - * filesystem_traits - */ - -/// \brief Traits class for file-system operations -/// -/// \param C The character type (e.g. \c char, \c wchar_t) -template -#ifdef __STLSOFT_DOCUMENTATION_SKIP_SECTION -struct filesystem_traits -{ -public: - typedef C char_type; /*!< The character type */ - typedef us_size_t size_type; /*!< The size type */ - -public: - // General string handling - - /// Copies the contents of \c src to \c dest - static char_type *str_copy(char_type *dest, char_type const *src); - /// Appends the contents of \c src to \c dest - static char_type *str_cat(char_type *dest, char_type const *src); - /// Comparies the contents of \c src and \c dest - static us_int_t str_compare(char_type const *s1, char_type const *s2); - /// Evaluates the length of \c src - static size_type str_len(char_type const *src); - - // File-system entry names - - /// Appends a path name separator to \c dir if one does not exist - static char_type *ensure_dir_end(char_type *dir); - /// Removes a path name separator to \c dir if one does not exist - static char_type *remove_dir_end(char_type *dir); - /// Returns \c true if dir is \c "." or \c ".." - static us_bool_t is_dots(char_type const *dir); - /// Returns the path separator - /// - /// This is the separator that is used to separate multiple paths on the operating system. On UNIX it is ':' - static char_type path_separator(); - /// Returns the path name separator - /// - /// This is the separator that is used to separate parts of a path on the operating system. On UNIX it is '/' - static char_type path_name_separator(); - /// Returns the wildcard pattern that represents all possible matches - /// - /// \note On UNIX it is '*' - static char_type const *pattern_all(); - /// Gets the full path name into the given buffer, returning a pointer to the file-part - static us_size_t get_full_path_name(char_type const *fileName, us_size_t cchBuffer, char_type *buffer, char_type **ppFile); - /// Gets the full path name into the given buffer - static us_size_t get_full_path_name(char_type const *fileName, us_size_t cchBuffer, char_type *buffer); - - // File system state - - /// Sets the current directory to \c dir - static us_bool_t set_current_directory(char_type const *dir); - /// Retrieves the name of the current directory into \c buffer up to a maximum of \c cchBuffer characters - static us_uint_t get_current_directory(us_uint_t cchBuffer, char_type *buffer); - - // Environment - - /// Gets an environment variable into the given buffer - static us_uint_t get_environment_variable(char_type const *name, char_type *buffer, us_uint_t cchBuffer); - /// Expands environment strings in \c src into \dest, up to a maximum \c cchDest characters - static us_uint_t expand_environment_strings(char_type const *src, char_type *buffer, us_uint_t cchBuffer); -}; -#else -struct filesystem_traits; - -#ifdef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -template <> -#endif /* __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX */ -struct filesystem_traits -{ -public: - typedef us_char_a_t char_type; - typedef us_size_t size_type; - -public: - // General string handling - static char_type *str_copy(char_type *dest, char_type const *src) - { - return strcpy(dest, src); - } - - static char_type *str_cat(char_type *dest, char_type const *src) - { - return strcat(dest, src); - } - - static us_int_t str_compare(char_type const *s1, char_type const *s2) - { - return strcmp(s1, s2); - } - - static size_type str_len(char_type const *src) - { - return static_cast(strlen(src)); - } - - // File-system entry names - static char_type *ensure_dir_end(char_type *dir) - { - char_type *end; - - for(end = dir; *end != '\0'; ++end) - {} - - if( dir < end && - *(end - 1) != path_name_separator()) - { - *end = path_name_separator(); - *(end + 1) = '\0'; - } - - return dir; - } - - static char_type *remove_dir_end(char_type *dir) - { - char_type *end; - - for(end = dir; *end != '\0'; ++end) - {} - - if( dir < end && - *(end - 1) == path_name_separator()) - { - *(end - 1) = '\0'; - } - - return dir; - } - - static us_bool_t is_dots(char_type const *dir) - { - return dir != 0 && - dir[0] == '.' && - ( dir[1] == '\0' || - ( dir[1] == '.' && - dir[2] == '\0')); - } - - static char_type path_separator() - { - return ':'; - } - - static char_type path_name_separator() - { - return '/'; - } - - static char_type const *pattern_all() - { - return "*"; - } - - static us_size_t get_full_path_name(char_type const *fileName, us_size_t cchBuffer, char_type *buffer, char_type **ppFile); - - static us_size_t get_full_path_name(char_type const *fileName, us_size_t cchBuffer, char_type *buffer) - { - unixstl_assert(buffer != NULL); - - if(fileName[0] == path_name_separator()) - { - str_copy(buffer, fileName); - } - else - { - get_current_directory(cchBuffer, buffer); - if(0 != str_compare(fileName, ".")) - { - ensure_dir_end(buffer); - str_cat(buffer, fileName); - } - } - - return str_len(buffer); - } - - // File system state - static us_bool_t set_current_directory(char_type const *dir) - { - return chdir(dir) == 0; - } - - static us_uint_t get_current_directory(us_uint_t cchBuffer, char_type *buffer) - { - return getcwd(buffer, cchBuffer) != 0; - } - - // Environment - - static us_uint_t get_environment_variable(char_type const *name, char_type *buffer, us_uint_t cchBuffer) - { - char *var = getenv(name); - - if(NULL == var) - { - return 0; - } - else - { - size_t var_len = strlen(var); - - strncpy(buffer, var, cchBuffer); - - return (var_len < cchBuffer) ? var_len : cchBuffer; - } - } - - static us_uint_t expand_environment_strings(char_type const *src, char_type *buffer, us_uint_t cchBuffer); -}; - -#if 0 -#ifdef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -template <> -#endif /* __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX */ -struct filesystem_traits -{ -public: - typedef us_char_w_t char_type; - typedef us_size_t size_type; - -public: - // General string handling - static char_type *str_copy(char_type *dest, char_type const *src) - { - return wcscpy(dest, src); - } - - static char_type *str_cat(char_type *dest, char_type const *src) - { - return wcscat(dest, src); - } - - static us_int_t str_compare(char_type const *s1, char_type const *s2) - { - return wcscmp(s1, s2); - } - - static size_type str_len(char_type const *src) - { - return static_cast(wcslen(src)); - } - - // File-system entry names - static char_type *ensure_dir_end(char_type *dir) - { - char_type *end; - - for(end = dir; *end != L'\0'; ++end) - {} - - if( dir < end && - *(end - 1) != path_name_separator()) - { - *end = path_name_separator(); - *(end + 1) = L'\0'; - } - - return dir; - } - - static char_type *remove_dir_end(char_type *dir) - { - char_type *end; - - for(end = dir; *end != L'\0'; ++end) - {} - - if( dir < end && - *(end - 1) == path_name_separator()) - { - *(end - 1) = L'\0'; - } - - return dir; - } - - static us_bool_t is_dots(char_type const *dir) - { - return dir != 0 && - dir[0] == '.' && - ( dir[1] == L'\0' || - ( dir[1] == L'.' && - dir[2] == L'\0')); - } - - static char_type path_separator() - { - return L':'; - } - - static char_type path_name_separator() - { - return L'/'; - } - - static char_type const *pattern_all() - { - return L"*"; - } - - static us_size_t get_full_path_name(char_type const *fileName, us_size_t cchBuffer, char_type *buffer, char_type **ppFile); - static us_size_t get_full_path_name(char_type const *fileName, us_size_t cchBuffer, char_type *buffer) - { - char_type *pFile; - - return get_full_path_name(fileName, cchBuffer, buffer, &pFile); - } - - // File system state - static us_bool_t set_current_directory(char_type const *dir); - - static us_uint_t get_current_directory(us_uint_t cchBuffer, char_type *buffer); -}; -#endif /* 0 */ - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_findfile_sequence.h b/etc/c/stlsoft/unixstl_findfile_sequence.h deleted file mode 100644 index 0fc860928da..00000000000 --- a/etc/c/stlsoft/unixstl_findfile_sequence.h +++ /dev/null @@ -1,170 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_findfile_sequence.h - * - * Purpose: findfile_sequence class. It is now implemented as a typedef to - * the glob_sequence class. - * - * Created: 15th January 2002 - * Updated: 3rd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _INCL_UNIXSTL_H_UNIXSTL_FINDFILE_SEQUENCE -#define _INCL_UNIXSTL_H_UNIXSTL_FINDFILE_SEQUENCE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_FINDFILE_SEQUENCE_MAJOR 2 -#define _UNIXSTL_VER_H_UNIXSTL_FINDFILE_SEQUENCE_MINOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_FINDFILE_SEQUENCE_REVISION 1 -#define _UNIXSTL_VER_H_UNIXSTL_FINDFILE_SEQUENCE_EDIT 43 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _INCL_UNIXSTL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_INCL_UNIXSTL_H_UNIXSTL */ - -#ifdef _UNIXSTL_FINDFILE_SEQUENCE_NO_BACK_SLASH_TERMINATOR -# define _UNIXSTL_GLOB_SEQUENCE_NO_BACK_SLASH_TERMINATOR -#endif /* _UNIXSTL_FINDFILE_SEQUENCE_NO_BACK_SLASH_TERMINATOR */ - -#ifndef _INCL_UNIXSTL_H_UNIXSTL_GLOB_SEQUENCE -# include "unixstl_glob_sequence.h" // glob_sequence -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_GLOB_SEQUENCE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The UNIXSTL components are contained within the unixstl namespace. This is - * actually an alias for stlsoft::unixstl_project, - * - * The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition - * --------------------- --------------------- ----------------- - * not defined not defined = stlsoft::unixstl_project - * not defined defined not defined - * defined not defined unixstl - * defined defined not defined - * - */ - -/* No STLSoft namespaces means no UNIXSTL namespaces */ -#ifdef _STLSOFT_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACES -#endif /* _STLSOFT_NO_NAMESPACES */ - -/* No UNIXSTL namespaces means no unixstl namespace */ -#ifdef _UNIXSTL_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACE -#endif /* _UNIXSTL_NO_NAMESPACES */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \defgroup unixstl_filesystem_library File-System Library (UNIXSTL) -/// \ingroup UNIXSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating UNIX file-system objects -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - */ - -typedef glob_sequence findfile_sequence; - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_FINDFILE_SEQUENCE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_functionals.h b/etc/c/stlsoft/unixstl_functionals.h deleted file mode 100644 index e7c087d0946..00000000000 --- a/etc/c/stlsoft/unixstl_functionals.h +++ /dev/null @@ -1,213 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_functionals.h - * - * Purpose: A number of useful functionals . - * - * Created: 2nd November 2003 - * Updated: 2nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_FUNCTIONALS -#define _UNIXSTL_INCL_H_UNIXSTL_FUNCTIONALS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_FUNCTIONALS_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_FUNCTIONALS_MINOR 0 -#define _UNIXSTL_VER_H_UNIXSTL_FUNCTIONALS_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_FUNCTIONALS_EDIT 3 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -# include "unixstl.h" // Include the WinSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#ifndef _STLSOFT_INCL_H_STLSOFT_STRING_ACCESS -# include "stlsoft_string_access.h" // c_str_ptr, etc. -#endif /* !_STLSOFT_INCL_H_STLSOFT_STRING_ACCESS */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS -# include "unixstl_string_access.h" // c_str_ptr, etc. -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS */ -#ifndef _UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS -# include "unixstl_filesystem_traits.h" -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_FILESYSTEM_TRAITS */ -#ifndef _UNIXSTL_FUNCTIONALS_NO_STD -# include -#endif /* _UNIXSTL_FUNCTIONALS_NO_STD */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -stlsoft_ns_using(c_str_ptr) - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -/// Function object that compares two file-system paths -/// -/// \param C The character type -template -struct compare_path -#ifndef _UNIXSTL_FUNCTIONALS_NO_STD - : unixstl_ns_qual_std(binary_function) -#endif /* _UNIXSTL_FUNCTIONALS_NO_STD */ -{ -public: - /// The character type - typedef C char_type; -#ifndef _UNIXSTL_FUNCTIONALS_NO_STD -private: - typedef unixstl_ns_qual_std(binary_function) parent_class_type; -public: - /// The first argument type - typedef ss_typename_type_k parent_class_type::first_argument_type first_argument_type; - /// The second argument type - typedef ss_typename_type_k parent_class_type::second_argument_type second_argument_type; - /// The result type - typedef ss_typename_type_k parent_class_type::result_type result_type; -#else - /// The first argument type - typedef const char_type *first_argument_type; - /// The second argument type - typedef const char_type *second_argument_type; - /// The result type - typedef us_bool_t result_type; -#endif /* _UNIXSTL_FUNCTIONALS_NO_STD */ - /// The traits type - typedef filesystem_traits traits_type; - /// The current parameterisation of the type - typedef compare_path class_type; - -public: - /// Function call, compares \c s1 with \c s2 - /// - /// \note The comparison is determined by evaluation the full-paths of both \c s1 and \c s2 -#ifdef __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT - template - result_type operator ()(T1 const &s1, T2 const &s2) - { - return _compare(c_str_ptr(s1), c_str_ptr(s2)); - } -#else - result_type operator ()(first_argument_type s1, second_argument_type s2) - { - return _compare(s1, s2); - } -#endif /* __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */ - -// Implementation -private: - result_type _compare(char_type const *s1, char_type const *s2) - { - char_type path1[PATH_MAX + 1]; - char_type path2[PATH_MAX + 1]; - result_type result; - - if(!traits_type::get_full_path_name(s1, unixstl_num_elements(path1), path1)) - { - result = false; - } - else if(!traits_type::get_full_path_name(s2, unixstl_num_elements(path2), path2)) - { - result = false; - } - else - { - traits_type::ensure_dir_end(path1); - traits_type::ensure_dir_end(path2); - - result = traits_type::str_compare(path1, path2) == 0; - } - - return result; - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _UNIXSTL_INCL_H_UNIXSTL_FUNCTIONALS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_glob_sequence.h b/etc/c/stlsoft/unixstl_glob_sequence.h deleted file mode 100644 index ecad16ea3e3..00000000000 --- a/etc/c/stlsoft/unixstl_glob_sequence.h +++ /dev/null @@ -1,536 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_glob_sequence.h (formerly unixstl_findfile_sequence.h) - * - * Purpose: glob_sequence class. - * - * Created: 15th January 2002 - * Updated: 10th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _INCL_UNIXSTL_H_UNIXSTL_GLOB_SEQUENCE -#define _INCL_UNIXSTL_H_UNIXSTL_GLOB_SEQUENCE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_GLOB_SEQUENCE_MAJOR 2 -#define _UNIXSTL_VER_H_UNIXSTL_GLOB_SEQUENCE_MINOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_GLOB_SEQUENCE_REVISION 4 -#define _UNIXSTL_VER_H_UNIXSTL_GLOB_SEQUENCE_EDIT 46 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _INCL_UNIXSTL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_INCL_UNIXSTL_H_UNIXSTL */ -#ifndef _INCL_UNIXSTL_H_UNIXSTL_FILESYSTEM_TRAITS -# include "unixstl_filesystem_traits.h" // filesystem_traits -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_FILESYSTEM_TRAITS */ -#ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR -# include "stlsoft_iterator.h" -#endif /* !_STLSOFT_INCL_H_STLSOFT_ITERATOR */ -#include -#include -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The UNIXSTL components are contained within the unixstl namespace. This is - * actually an alias for stlsoft::unixstl_project, - * - * The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition - * --------------------- --------------------- ----------------- - * not defined not defined = stlsoft::unixstl_project - * not defined defined not defined - * defined not defined unixstl - * defined defined not defined - * - */ - -/* No STLSoft namespaces means no UNIXSTL namespaces */ -#ifdef _STLSOFT_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACES -#endif /* _STLSOFT_NO_NAMESPACES */ - -/* No UNIXSTL namespaces means no unixstl namespace */ -#ifdef _UNIXSTL_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACE -#endif /* _UNIXSTL_NO_NAMESPACES */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \defgroup unixstl_filesystem_library File-System Library (UNIXSTL) -/// \ingroup UNIXSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating UNIX file-system objects -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -/// \brief STL-like readonly sequence based on the results of file-system wildcard matches -/// -/// This class presents and STL-like readonly sequence interface to allow the -/// iteration over the results of file-system wildcard matches. - -class glob_sequence -{ -private: - typedef glob_sequence class_type; -public: - /// The char type - typedef us_char_a_t char_type; - /// The value type - typedef char_type const *value_type; - /// The type of the const (non-mutating) iterator - typedef value_type *const_iterator; -private: -// typedef value_type &reference; - typedef value_type const &const_reference; -// typedef value_type *pointer; - typedef value_type const *const_pointer; -public: - /// The size type - typedef us_size_t size_type; - /// The difference type - typedef us_ptrdiff_t difference_type; - - /// The type of the const (non-mutating) reverse iterator - typedef stlsoft_ns_qual(reverse_iterator_base) < const_iterator - , value_type - , const_reference - , const_pointer - , difference_type - > const_reverse_iterator; - -public: - enum - { - includeDots = 0x0008 /*!< Requests that dots directories be included in the returned sequence */ - , directories = 0x0010 /*!< Causes the search to include directories */ - , files = 0x0020 /*!< Causes the search to include files */ - , noSort = 0x0100 /*!< Does not sort entries */ - , markDirs = 0x0200 /*!< Mark directories with a trailing path name separator */ - , - }; - -// Construction -public: - /// \brief Constructs a sequence according to the given criteria - /// - /// The constructor initialises a glob_sequence instance on the given - /// pattern with the given flags. - /// - /// \param pattern The pattern against which to match the file-system contents - /// \param flags Flags to alter the behaviour of the search - ss_explicit_k glob_sequence(char_type const *pattern, us_int_t flags = noSort) - : m_flags(validate_flags_(flags)) - { - m_cItems = _init(pattern); - } - - /// \brief Constructs a sequence according to the given criteria - /// - /// The constructor initialises a glob_sequence instance on the given - /// pattern with the given flags. - /// - /// \param directory The directory in which the pattern is located - /// \param pattern The pattern against which to match the file-system contents - /// \param flags Flags to alter the behaviour of the search - glob_sequence(char_type const *directory, char_type const *pattern, us_int_t flags = noSort) - : m_flags(validate_flags_(flags)) - { - m_cItems = _init(directory, pattern); - } - - // Releases any acquired resources - ~glob_sequence() unixstl_throw_0() - { - if(NULL != m_base) - { - globfree(&m_gl); - } - } - -// Attributes -public: - /// Returns the number of elements in the sequence - us_size_t size() const - { - return m_cItems; - } - - /// \brief Indicates whether the search sequence is empty - us_bool_t empty() const - { - return size() == 0; - } - - /// \brief Returns the value corresponding to the given index - /// - /// \note In debug-mode a runtime assert is applied to enforce that the index is valid. There is no release-time checking on the index validity! - value_type const operator [](size_type index) const - { - unixstl_message_assert("index access out of range in glob_sequence", index < m_cItems + 1); // Has to be +1, since legitimate to take address of one-past-the-end - - return m_base[index]; - } - -// Iteration -public: - /// Begins the iteration - /// - /// \return An iterator representing the start of the sequence - const_iterator begin() const - { - return m_base; - } - /// Ends the iteration - /// - /// \return An iterator representing the end of the sequence - const_iterator end() const - { - return m_base + m_cItems; - } - - /// Begins the reverse iteration - /// - /// \return An iterator representing the start of the reverse sequence - const_reverse_iterator rbegin() const - { - return const_reverse_iterator(end()); - } - /// Ends the reverse iteration - /// - /// \return An iterator representing the end of the reverse sequence - const_reverse_iterator rend() const - { - return const_reverse_iterator(begin()); - } - -// Implementation -private: - static us_int_t validate_flags_(us_int_t flags) - { - if((flags & (directories | files)) == 0) - { - flags |= (directories | files); - } - - if((flags & directories) == 0) - { - // It's more efficient to not bother doing a separate dots check if all - // directories are being elided. -// flags |= includeDots; - } - - return flags; - } - - // Returns true if pch == "" or "/" (or "\\"), false otherwise - static us_bool_t _is_end_of_path_elements(char_type const *pch, difference_type index) - { - return pch[index] == '\0' || - ( pch[index + 1] == '\0' && - ( -#if defined(_UNIXSTL_COMPILER_IS_UNKNOWN) && \ - !defined(_UNIXSTL_GLOB_SEQUENCE_NO_BACK_SLASH_TERMINATOR) - pch[index] == '\\' || -#endif /* _UNIXSTL_COMPILER_IS_UNKNOWN && !_UNIXSTL_GLOB_SEQUENCE_NO_BACK_SLASH_TERMINATOR */ - pch[index] == '/')); - } - - static us_bool_t _is_dots(char_type const *s, us_bool_t &bTwoDots) - { - return s != 0 && - s[0] == '.' && - ( (bTwoDots = false, _is_end_of_path_elements(s, 1)) || - (bTwoDots = true, ( s[1] == '.' && - _is_end_of_path_elements(s, 2)))); - } - - us_int_t _init(char_type const *directory, char_type const *pattern) - { - us_int_t glob_flags = 0; - char_type _directory[1 + PATH_MAX]; - char_type _pattern[1 + PATH_MAX]; - - // If a directory is given, always turn it into an absolute directory - if( NULL != directory && - 0 != *directory) - { - filesystem_traits::str_copy(_directory, directory); - filesystem_traits::ensure_dir_end(_directory); - directory = _directory; - } - - // If a directory is given, always prefix into pattern - if( NULL != directory && - 0 != *directory) - { - filesystem_traits::str_copy(_pattern, directory); - filesystem_traits::str_cat(_pattern, pattern); - - pattern = _pattern; - } - - if(m_flags & noSort) - { - glob_flags |= GLOB_NOSORT; - } - - if(m_flags & markDirs) - { - glob_flags |= GLOB_MARK; - } - - if((m_flags & (directories | files)) == directories) - { - glob_flags |= GLOB_ONLYDIR; - } - - if(0 == glob(pattern, glob_flags, NULL, &m_gl)) - { - char_type **base = m_gl.gl_pathv; - us_int_t cItems = m_gl.gl_pathc; - - if(!(m_flags & includeDots)) - { - // Now remove the dots. If located at the start of - // the gl buffer, then simply increment m_base to - // be above that. If not then rearrange the base - // two pointers such that they are there. - - us_bool_t foundDot1 = false; - us_bool_t foundDot2 = false; - char_type **begin = base; - char_type **end = begin + cItems; - - for(; begin != end; ++begin) - { - us_bool_t bTwoDots; - - if(_is_dots(*begin, bTwoDots)) - { - if(begin != base) - { - // Swap with whatever is at base[0] - char_type *t = *begin; - - *begin = *base; - *base = t; - } - - ++base; - --cItems; - - (bTwoDots ? foundDot2 : foundDot1) = true; - - if( foundDot1 && - foundDot2) - { - break; - } - } - } - } - - // We should be able to trust glob() to return only directories when - // asked, so we assume the following only needs to be done when - // have asked for files alone -#ifdef UNIXSTL_GLOB_SEQUENCE_ULTRA_CAUTIOUS - if((m_flags & (directories | files)) != (directories | files)) -#else /* ? UNIXSTL_GLOB_SEQUENCE_ULTRA_CAUTIOUS */ - if((m_flags & (directories | files)) == files) -#endif /* UNIXSTL_GLOB_SEQUENCE_ULTRA_CAUTIOUS */ - { - char_type **begin = base; - char_type **end = begin + cItems; - - for(; begin != end; ++begin) - { - // Now need to process the file, by using stat - struct stat st; - int res; - char_type buffer[PATH_MAX]; - char_type *entry = *begin; - - if(0 != (m_flags & markDirs)) - { - filesystem_traits::str_copy(buffer, entry); - filesystem_traits::remove_dir_end(buffer); - entry = buffer; - } - res = stat(entry, &st); - - if(0 != res) - { - // Failed to get info from entry. Must assume it is - // dead, so skip it - } - else - { -#ifdef UNIXSTL_GLOB_SEQUENCE_ULTRA_CAUTIOUS - if(m_flags & directories) // Want directories - { - if(S_IFDIR == (st.st_mode & S_IFDIR)) - { - continue; // A directory, so accept it - } - } -#endif /* UNIXSTL_GLOB_SEQUENCE_ULTRA_CAUTIOUS */ - if(m_flags & files) // Want files - { - if(S_IFREG == (st.st_mode & S_IFREG)) - { - continue; // A file, so accept it - } - } - } - - if(begin != base) - { - // Swap with whatever is at base[0] - char_type *t = *begin; - - *begin = *base; - *base = t; - } - - ++base; - --cItems; - } - } - - // Set m_base and m_cItems to the correct values, with - // or without dots. m_base is cast here to remove the - // need for const-casting throughout the rest of the - // class - m_base = const_cast(base); - - return cItems; - } - else - { - m_base = NULL; - - return 0; - } - } - - us_int_t _init(char_type const *pattern) - { - return _init(NULL, pattern); - } - -// Members -private: - us_int_t const m_flags; - glob_t m_gl; - char_type const **m_base; - us_int_t m_cItems; - -// Not to be implemented -private: - glob_sequence(class_type const &); - class_type const &operator =(class_type const &); -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_GLOB_SEQUENCE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_limits.h b/etc/c/stlsoft/unixstl_limits.h deleted file mode 100644 index ee12bcfedcf..00000000000 --- a/etc/c/stlsoft/unixstl_limits.h +++ /dev/null @@ -1,173 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_limits.h - * - * Purpose: Header for limits. - * - * Created: 14th November 2002 - * Updated: 2nd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _INCL_UNIXSTL_H_UNIXSTL_LIMITS -#define _INCL_UNIXSTL_H_UNIXSTL_LIMITS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_LIMITS_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_LIMITS_MINOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_LIMITS_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_LIMITS_EDIT 9 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _INCL_UNIXSTL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_INCL_UNIXSTL_H_UNIXSTL */ -#include -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The UNIXSTL components are contained within the unixstl namespace. This is - * actually an alias for stlsoft::unixstl_project, - * - * The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition - * --------------------- --------------------- ----------------- - * not defined not defined = stlsoft::unixstl_project - * not defined defined not defined - * defined not defined unixstl - * defined defined not defined - * - */ - -/* No STLSoft namespaces means no UNIXSTL namespaces */ -#ifdef _STLSOFT_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACES -#endif /* _STLSOFT_NO_NAMESPACES */ - -/* No UNIXSTL namespaces means no unixstl namespace */ -#ifdef _UNIXSTL_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACE -#endif /* _UNIXSTL_NO_NAMESPACES */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#else -stlsoft_ns_using(move_lhs_from_rhs) -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Constants and definitions - */ - -/* UNIXSTL_NAME_MAX */ - -/** \def UNIXSTL_NAME_MAX - * - * The maxiumum number of characters in a UNIXSTL file-system name - */ - -#ifdef NAME_MAX -# define UNIXSTL_NAME_MAX NAME_MAX -#elif defined(PATH_MAX) -# define UNIXSTL_NAME_MAX PATH_MAX -#else -# define UNIXSTL_NAME_MAX (512) -#endif /* NAME_MAX */ - -/* UNIXSTL_PATH_MAX */ - -/** \def UNIXSTL_PATH_MAX - * - * The maxiumum number of characters in a UNIXSTL file-system path - */ - -#ifdef PATH_MAX -# define UNIXSTL_PATH_MAX PATH_MAX -#else -# define UNIXSTL_PATH_MAX (512) -#endif /* NAME_MAX */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_LIMITS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_process_mutex.h b/etc/c/stlsoft/unixstl_process_mutex.h deleted file mode 100644 index 40b4e695ab7..00000000000 --- a/etc/c/stlsoft/unixstl_process_mutex.h +++ /dev/null @@ -1,296 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: unixstl_process_mutex.h - * - * Purpose: Intra-process mutext, based on PTHREADS. - * - * Date: 15th May 2002 - * Updated: 23rd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_PROCESS_MUTEX -#define _UNIXSTL_INCL_H_UNIXSTL_PROCESS_MUTEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _UNIXSTL_VER_H_UNIXSTL_PROCESS_MUTEX_MAJOR 1 -# define _UNIXSTL_VER_H_UNIXSTL_PROCESS_MUTEX_MINOR 3 -# define _UNIXSTL_VER_H_UNIXSTL_PROCESS_MUTEX_REVISION 4 -# define _UNIXSTL_VER_H_UNIXSTL_PROCESS_MUTEX_EDIT 15 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#if !defined(_REENTRANT) && \ - !defined(_POSIX_THREADS) -# error unixstl_process_mutex.h must be compiled in the context of PTHREADS -#endif /* !_REENTRANT && !_POSIX_THREADS */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class process_mutex -/// This class provides an implementation of the mutex model based on the Win32 CRITICAL_SECTION -class process_mutex -{ -public: - typedef process_mutex class_type; - -// Construction -public: - /// Creates an instance of the mutex - ss_explicit_k process_mutex(us_bool_t bRecursive) unixstl_throw_0() - : m_init(create_(&m_mx, 0, bRecursive)) - {} -#if defined(_POSIX_THREAD_PROCESS_SHARED) - /// Creates an instance of the mutex - process_mutex(int pshared, us_bool_t bRecursive) unixstl_throw_0() - : m_init(create_(&m_mx, pshared, bRecursive)) - {} -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - /// Destroys an instance of the mutex - ~process_mutex() unixstl_throw_0() - { - if(m_init) - { - ::pthread_mutex_destroy(&m_mx); - } - } - -// Operations -public: - /// Acquires a lock on the mutex, pending the thread until the lock is aquired - void lock() unixstl_throw_0() - { - pthread_mutex_lock(&m_mx); - } - /// Attempts to lock the mutex - /// - /// \return true if the mutex was aquired, or false if not - /// \note Only available with Windows NT 4 and later - bool try_lock() - { - return pthread_mutex_trylock(&m_mx) == 0; - } - /// Releases an aquired lock on the mutex - void unlock() unixstl_throw_0() - { - pthread_mutex_unlock(&m_mx); - } - -// Implementation -private: - static us_bool_t create_(pthread_mutex_t *mx, int pshared, us_bool_t bRecursive) - { - us_bool_t bSuccess = false; - pthread_mutexattr_t attr; - - if(0 == ::pthread_mutexattr_init(&attr)) - { - if( !bRecursive || - 0 == ::pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) - { -#if defined(_POSIX_THREAD_PROCESS_SHARED) - if(0 == ::pthread_mutexattr_setpshared(&attr, pshared)) -#else - ((void)pshared); -#endif /* _POSIX_THREAD_PROCESS_SHARED */ - { - if(0 == ::pthread_mutex_init(mx, &attr)) - { - bSuccess = true; - } - } - } - - ::pthread_mutexattr_destroy(&attr); - } - - return bSuccess; - } - -// Members -private: - pthread_mutex_t m_mx; // mx - us_bool_t m_init; - -// Not to be implemented -private: - process_mutex(class_type const &rhs); - process_mutex &operator =(class_type const &rhs); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Control shims - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_sync_control Synchronisation Control Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects - -/// \defgroup unixstl_sync_control_shims Synchronisation Control Shims (UNIXSTL) -/// \ingroup UNIXSTL concepts_shims_sync_control -/// \brief These \ref concepts_shims "shims" control the behaviour of Win32 synchronisation objects -/// @{ - -/// This control ref concepts_shims "shim" aquires a lock on the given mutex -/// -/// \param mx The mutex on which to aquire the lock -inline void lock_instance(unixstl_ns_qual(process_mutex) &mx) -{ - mx.lock(); -} - -/// This control ref concepts_shims "shim" releases a lock on the given mutex -/// -/// \param mx The mutex on which to release the lock -inline void unlock_instance(unixstl_ns_qual(process_mutex) &mx) -{ - mx.unlock(); -} - -/// @} // end of group unixstl_sync_control_shims - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -namespace unixstl -{ -# else -namespace unixstl_project -{ -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * lock_traits (for the compilers that do not support Koenig Lookup) - */ - -// class lock_traits -/// Traits for the process_mutex class (for compilers that do not support Koenig Lookup) -struct thread_mutex_lock_traits -{ -public: - /// The lockable type - typedef process_mutex lock_type; - typedef thread_mutex_lock_traits class_type; - -// Operations -public: - /// Lock the given process_mutex instance - static void lock(process_mutex &c) - { - lock_instance(c); - } - - /// Unlock the given process_mutex instance - static void unlock(process_mutex &c) - { - unlock_instance(c); - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_PROCESS_MUTEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_readdir_sequence.h b/etc/c/stlsoft/unixstl_readdir_sequence.h deleted file mode 100644 index 71998257858..00000000000 --- a/etc/c/stlsoft/unixstl_readdir_sequence.h +++ /dev/null @@ -1,553 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_readdir_sequence.h - * - * Purpose: readdir_sequence class. - * - * Created: 15th January 2002 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _INCL_UNIXSTL_H_UNIXSTL_READDIR_SEQUENCE -#define _INCL_UNIXSTL_H_UNIXSTL_READDIR_SEQUENCE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _UNIXSTL_VER_H_UNIXSTL_READDIR_SEQUENCE_MAJOR 1 -# define _UNIXSTL_VER_H_UNIXSTL_READDIR_SEQUENCE_MINOR 5 -# define _UNIXSTL_VER_H_UNIXSTL_READDIR_SEQUENCE_REVISION 2 -# define _UNIXSTL_VER_H_UNIXSTL_READDIR_SEQUENCE_EDIT 42 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _INCL_UNIXSTL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_INCL_UNIXSTL_H_UNIXSTL */ -#ifndef _INCL_UNIXSTL_H_UNIXSTL_LIMITS -# include "unixstl_limits.h" // UNIXSTL_NAME_MAX -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_LIMITS */ -#ifndef _STLSOFT_INCL_H_STLSOFT_FRAME_STRING -# include "stlsoft_frame_string.h" // stlsoft::basic_frame_string -#endif /* !_STLSOFT_INCL_H_STLSOFT_FRAME_STRING */ -#ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR -# include "stlsoft_iterator.h" -#endif /* !_STLSOFT_INCL_H_STLSOFT_ITERATOR */ - -#include -#include -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The UNIXSTL components are contained within the unixstl namespace. This is - * actually an alias for stlsoft::unixstl_project, - * - * The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition - * --------------------- --------------------- ----------------- - * not defined not defined = stlsoft::unixstl_project - * not defined defined not defined - * defined not defined unixstl - * defined defined not defined - * - */ - -/* No STLSoft namespaces means no UNIXSTL namespaces */ -#ifdef _STLSOFT_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACES -#endif /* _STLSOFT_NO_NAMESPACES */ - -/* No UNIXSTL namespaces means no unixstl namespace */ -#ifdef _UNIXSTL_NO_NAMESPACES -# define _UNIXSTL_NO_NAMESPACE -#endif /* _UNIXSTL_NO_NAMESPACES */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \defgroup unixstl_filesystem_library File-System Library (UNIXSTL) -/// \ingroup UNIXSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating UNIX file-system objects -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Utility classes - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -struct rds_shared_handle -{ - DIR *dir; - ss_sint32_t cRefs; - -public: - ss_explicit_k rds_shared_handle(DIR *d) - : dir(d) - , cRefs(1) - {} - void Release() - { - if(--cRefs == 0) - { - delete this; - } - } -#if defined(__STLSOFT_COMPILER_IS_GCC) -protected: -#else /* ? __STLSOFT_COMPILER_IS_GCC */ -private: -#endif /* __STLSOFT_COMPILER_IS_GCC */ - ~rds_shared_handle() - { - unixstl_message_assert("Shared search handle being destroyed with outstanding references!", 0 == cRefs); - - if(NULL != dir) - { - closedir(dir); - } - } -}; -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -/// \brief Iterator for readdir_sequence class -/// -/// This class performs as a non-mutating iterator (aka const iterator) for the -/// readdir_sequence class. -/// -/// - -class readdir_sequence_const_iterator - : public stlsoft_ns_qual(iterator_base) < unixstl_ns_qual_std(input_iterator_tag) - , struct dirent const * - , us_ptrdiff_t - , struct dirent const ** - , struct dirent const *& - > -{ -public: - /// The class type - typedef readdir_sequence_const_iterator class_type; - /// The type on the rhs of move expressions - typedef stlsoft_define_move_rhs_type(class_type) rhs_type; - /// The value type - typedef struct dirent const *value_type; -// typedef value_type *pointer; -// typedef value_type &reference; - -// Construction -private: - friend class readdir_sequence; - - enum - { - includeDots = 0x0008 /*!< Requests that dots directories be included in the returned sequence */ - , directories = 0x0010 /*!< Causes the search to include directories */ - , files = 0x0020 /*!< Causes the search to include files */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - , noSort = 0 /* 0x0100 */ //!< -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - , - }; - - /// Construct an instance and begin a sequence iteration on the given dir. - readdir_sequence_const_iterator(DIR *dir, us_uint_t flags) - : m_handle(new rds_shared_handle(dir)) - , m_entry(NULL) - , m_flags(flags) - { - // It's more efficient to not bother doing a separate dots check if all - // directories are being elided. - if(0 == (m_flags & directories)) - { - m_flags |= includeDots; - } - - if(NULL != m_handle) - { - operator ++(); - } - } - /// Constructs an instance based on the given directory entry - readdir_sequence_const_iterator(dirent *entry) - : m_handle(NULL) - , m_entry(entry) - {} -public: - /// Default constructor - readdir_sequence_const_iterator() - : m_handle(NULL) - , m_entry(NULL) - {} - /// Move constructor - readdir_sequence_const_iterator(class_type const &rhs) - : m_handle(rhs.m_handle) - , m_entry(rhs.m_entry) - { - if(NULL != m_handle) - { - ++m_handle->cRefs; - } - } - /// Release the search handle - ~readdir_sequence_const_iterator() unixstl_throw_0() - { - if(NULL != m_handle) - { - m_handle->Release(); - } - } - - /// Move assignment operator - class_type const &operator =(rhs_type rhs) - { - m_handle = rhs.m_handle; - if(NULL != m_handle) - { - m_handle->Release(); - } - - m_entry = rhs.m_entry; - m_flags = rhs.m_flags; - - if(NULL != m_handle) - { - ++m_handle->cRefs; - } - - return *this; - } - -// Accessors -public: - /// Returns the value representative - value_type operator *() const - { - unixstl_message_assert( "Dereferencing invalid iterator", NULL != m_entry); - - return m_entry; - } - - /// Moves the iteration on to the next point in the sequence, or end() if - /// the sequence is exhausted - class_type &operator ++() - { - unixstl_message_assert( "Incrementing invalid iterator", NULL != m_handle); - - for(;;) - { - m_entry = readdir(m_handle->dir); - - if(NULL != m_entry) - { - unixstl_assert(NULL != m_entry->d_name); - - if(0 == (m_flags & includeDots)) - { - if( m_entry->d_name[0] == '.' && - ( m_entry->d_name[1] == '\0' || - ( m_entry->d_name[1] == '.' && - m_entry->d_name[2] == '\0'))) - { - continue; // Don't want dots; skip it - } - } - - if((m_flags & (directories | files)) != (directories | files)) - { - // Now need to process the file, by using stat - struct stat st; - - if(0 != stat(m_entry->d_name, &st)) - { - // Failed to get info from entry. Must assume it is - // dead, so skip it - continue; - } - else - { - if(m_flags & directories) // Want directories - { - if(S_IFDIR == (st.st_mode & S_IFDIR)) - { - // It is a directory, so accept it - break; - } - } - if(m_flags & files) // Want files - { - if(S_IFREG == (st.st_mode & S_IFREG)) - { - // It is a file, so accept it - break; - } - } - - continue; // Not a match, so skip this entry - } - } - } - - break; - } - - if(NULL == m_entry) - { - unixstl_assert(NULL != m_handle); - - m_handle->Release(); - - m_handle = NULL; - } - - return *this; - } - /// Post-increment form of operator ++(). - /// - /// \note Because this version uses a temporary on which to call the - /// pre-increment form it is thereby less efficient, and should not be used - /// except where post-increment semantics are required. - class_type operator ++(int) - { - class_type ret(*this); - - operator ++(); - - return ret; - } - - /// Compares \c this for equality with \c rhs - /// - /// \param rhs The instance against which to test - /// \retval true if the iterators are equivalent - /// \retval false if the iterators are not equivalent - bool operator ==(class_type const &rhs) const - { - unixstl_assert(NULL == m_handle || NULL == rhs.m_handle || m_handle->dir == rhs.m_handle->dir); - - return m_entry == rhs.m_entry; - } - /// Compares \c this for inequality with \c rhs - /// - /// \param rhs The instance against which to test - /// \retval false if the iterators are equivalent - /// \retval true if the iterators are not equivalent - bool operator !=(class_type const &rhs) const - { - return !operator ==(rhs); - } - -// Members -private: - rds_shared_handle *m_handle; - struct dirent *m_entry; - us_uint_t m_flags; - -// Not to be implemented -private: -}; - - -/// \brief STL-like readonly sequence based on directory contents -/// -/// This class presents and STL-like readonly sequence interface to allow the -/// iteration over the contents of a directory. - -class readdir_sequence -{ -private: - typedef readdir_sequence class_type; -public: -// typedef us_size_t size_type; - typedef readdir_sequence_const_iterator const_iterator; - typedef readdir_sequence_const_iterator::value_type value_type; -// typedef readdir_sequence_const_iterator::pointer pointer; -// typedef readdir_sequence_const_iterator::pointer const const_pointer; -// typedef readdir_sequence_const_iterator::reference reference; - typedef readdir_sequence_const_iterator::reference const const_reference; - -private: - typedef stlsoft_ns_qual(basic_frame_string) < us_char_a_t - , UNIXSTL_NAME_MAX - > string_type; - -public: - enum - { - includeDots = const_iterator::includeDots /*!< Requests that dots directories be included in the returned sequence */ - , directories = const_iterator::directories /*!< Causes the search to include directories */ - , files = const_iterator::files /*!< Causes the search to include files */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - , noSort = const_iterator::noSort /* 0x0100 */ //!< -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - , - }; - -// Construction -public: - /// \brief Constructs a sequence according to the given criteria - /// - /// The constructor initialises a readdir_sequence instance on the given - /// directory with the given flags. - /// - /// \param name The directory whose contents are to be searched - /// \param flags Flags to alter the behaviour of the search - /// - /// \note The \c flags parameter defaults to directories | files because - /// this reflects the default behaviour of \c readdir(), and also because it is the - /// most efficient. - readdir_sequence(us_char_a_t const *name, us_int_t flags = directories | files) - : m_name(name) - , m_flags(validate_flags_(flags)) - {} - -// Iteration -public: - /// Begins the iteration - /// - /// \return An iterator representing the start of the sequence - const_iterator begin() const - { - DIR *dir = opendir(m_name.c_str()); - - return const_iterator(dir, m_flags); - } - /// Ends the iteration - /// - /// \return An iterator representing the end of the sequence - const_iterator end() const - { - return const_iterator(); - } - -// Attributes -public: -#if 0 - /// Returns the number of elements in the sequence - /// - /// \note Nor currently implemented - size_type size() const - { - return 0; - } -#endif /* 0 */ - - /// \brief Indicates whether the search sequence is empty - us_bool_t empty() const - { - return begin() != end(); - } - -// Implementation -private: - /// \brief Ensures that the flags are correct - static us_int_t validate_flags_(us_int_t flags) - { - return (0 == (flags & (directories | files))) ? (flags | (directories | files)) : flags; - } - -// Members -private: - string_type m_name; - us_int_t m_flags; -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_INCL_UNIXSTL_H_UNIXSTL_READDIR_SEQUENCE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_spin_mutex.h b/etc/c/stlsoft/unixstl_spin_mutex.h deleted file mode 100644 index 8a1133b484e..00000000000 --- a/etc/c/stlsoft/unixstl_spin_mutex.h +++ /dev/null @@ -1,260 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: unixstl_spin_mutex.h (originally MWSpinMx.h, ::SynesisWin) - * - * Purpose: Intra-process mutex, based on spin waits. - * - * Date: 27th August 1997 - * Updated: 23rd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_SPIN_MUTEX -#define _UNIXSTL_INCL_H_UNIXSTL_SPIN_MUTEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_SPIN_MUTEX_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_SPIN_MUTEX_MINOR 2 -#define _UNIXSTL_VER_H_UNIXSTL_SPIN_MUTEX_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_SPIN_MUTEX_EDIT 8 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#include // Only works for Linux. For other OSs, use unixstl_process_mutex.h - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class spin_mutex -/// This class provides an implementation of the mutex model based on a spinning mechanism -class spin_mutex -{ -public: - typedef spin_mutex class_type; - -// Construction -public: - /// Creates an instance of the mutex - ss_explicit_k spin_mutex(us_sint32_t *p) unixstl_throw_0() - : m_spinCount((NULL != p) ? p : &m_internalCount) - , m_internalCount(0) -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - , m_cLocks(0) -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - {} - /// Destroys an instance of the mutex - ~spin_mutex() unixstl_throw_0() - { -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - stlsoft_assert(m_cLocks == 0); -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - } - -// Operations -public: - /// Acquires a lock on the mutex, pending the thread until the lock is aquired - void lock() unixstl_throw_0() - { - for(; 0 != atomic_write((LPLONG)m_spinCount, 1); ::Sleep(1)) - {} -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - stlsoft_assert(++m_cLocks != 0); -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - } - /// Releases an aquired lock on the mutex - void unlock() unixstl_throw_0() - { -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - stlsoft_assert(m_cLocks-- != 0); -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - atomic_write(m_spinCount, 0); - } - -// Members -private: - us_sint32_t *m_spinCount; - us_sint32_t m_internalCount; -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - us_sint32_t m_cLocks; // Used as check on matched Lock/Unlock calls -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - -// Not to be implemented -private: - spin_mutex(class_type const &rhs); - spin_mutex &operator =(class_type const &rhs); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Control shims - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_sync_control Synchronisation Control Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects - -/// \defgroup unixstl_sync_control_shims Synchronisation Control Shims (UNIXSTL) -/// \ingroup UNIXSTL concepts_shims_sync_control -/// \brief These \ref concepts_shims "shims" control the behaviour of Win32 synchronisation objects -/// @{ - -/// This control ref concepts_shims "shim" aquires a lock on the given mutex -/// -/// \param mx The mutex on which to aquire the lock -inline void lock_instance(unixstl_ns_qual(spin_mutex) &mx) -{ - mx.lock(); -} - -/// This control ref concepts_shims "shim" releases a lock on the given mutex -/// -/// \param mx The mutex on which to release the lock -inline void unlock_instance(unixstl_ns_qual(spin_mutex) &mx) -{ - mx.unlock(); -} - -/// @} // end of group unixstl_sync_control_shims - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -namespace unixstl -{ -# else -namespace unixstl_project -{ -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * lock_traits (for the compilers that do not support Koenig Lookup) - */ - -// class lock_traits -/// Traits for the spin_mutex class (for compilers that do not support Koenig Lookup) -struct spin_mutex_lock_traits -{ -public: - /// The lockable type - typedef spin_mutex lock_type; - typedef spin_mutex_lock_traits class_type; - -// Operations -public: - /// Lock the given spin_mutex instance - static void lock(spin_mutex &c) - { - lock_instance(c); - } - - /// Unlock the given spin_mutex instance - static void unlock(spin_mutex &c) - { - unlock_instance(c); - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_WINSTL_INCL_H_UNIXSTL_SPIN_MUTEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_string_access.h b/etc/c/stlsoft/unixstl_string_access.h deleted file mode 100644 index 9761a77ee33..00000000000 --- a/etc/c/stlsoft/unixstl_string_access.h +++ /dev/null @@ -1,209 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: unixstl_string_access.h - * - * Purpose: Contains classes and functions for dealing with OLE/COM strings. - * - * Created: 11th January 2003 - * Updated: 13th August 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS -#define _UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _UNIXSTL_VER_H_UNIXSTL_STRING_ACCESS_MAJOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_STRING_ACCESS_MINOR 1 -#define _UNIXSTL_VER_H_UNIXSTL_STRING_ACCESS_REVISION 2 -#define _UNIXSTL_VER_H_UNIXSTL_STRING_ACCESS_EDIT 10 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL - #include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Forward declarations - */ - -struct dirent; - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The UNIXSTL components are contained within the unixstl namespace. This is - * actually an alias for stlsoft::unixstl_project, - * - * The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _UNIXSTL_NO_NAMESPACE unixstl definition - * --------------------- -------------------- ----------------- - * not defined not defined = stlsoft::unixstl_project - * not defined defined not defined - * defined not defined unixstl - * defined defined not defined - * - */ - -#ifndef _UNIXSTL_NO_NAMESPACE - #ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ - #else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - - #endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_string_access String Access Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" retrieve the C-string for arbitrary types - -/// \defgroup unixstl_string_access_shims String Access Shims (UNIXSTL) -/// \ingroup UNIXSTL concepts_shims_string_access -/// \brief These \ref concepts_shims "shims" retrieve the C-string for arbitrary types -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * c_str_ptr_null - * - * This can be applied to an expression, and the return value is either a - * pointer to the character string or NULL. - */ - -/// \brief Returns the corresponding C-string pointer of the dirent structure \c d, or NULL if \c d is empty -inline us_char_a_t const *c_str_ptr_null(struct dirent const *d) -{ - return (d == 0 || d->d_name[0] == 0) ? 0 : d->d_name; -} - -/// \brief Returns the corresponding C-string pointer of the dirent structure \c d, or NULL if \c d is empty -inline us_char_a_t const *c_str_ptr_null(struct dirent const &d) -{ - return d.d_name[0] == 0 ? 0 : d.d_name; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * c_str_ptr - * - * This can be applied to an expression, and the return value is either a - * pointer to the character string or to an empty string. - */ - -/// \brief Returns the corresponding C-string pointer of the dirent structure \c d -inline us_char_a_t const *c_str_ptr(struct dirent const *d) -{ - return (d == 0) ? "" : d->d_name; -} - -/// \brief Returns the corresponding C-string pointer of the dirent structure \c d -inline us_char_a_t const *c_str_ptr(struct dirent const &d) -{ - return d.d_name; -} - -/* ///////////////////////////////////////////////////////////////////////////// - * c_str_len - * - * This can be applied to an expression, and the return value is the number of - * characters in the character string in the expression. - */ - - -/* ///////////////////////////////////////////////////////////////////////////// - * c_str_size - * - * This can be applied to an expression, and the return value is the number of - * bytes required to store the character string in the expression, NOT including - * the null-terminating character. - */ - - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group unixstl_string_access_shims - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE - #ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl - #else -} // namespace unixstl_project -} // namespace stlsoft - #endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_STRING_ACCESS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/unixstl_thread_mutex.h b/etc/c/stlsoft/unixstl_thread_mutex.h deleted file mode 100644 index 8026002a22a..00000000000 --- a/etc/c/stlsoft/unixstl_thread_mutex.h +++ /dev/null @@ -1,283 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: unixstl_thread_mutex.h (originally MLCrtSct.h, ::SynesisStd) - * - * Purpose: Intra-process mutext, based on PTHREADS CRITICAL_SECTION. - * - * Date: 17th December 1996 - * Updated: 23rd November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/unixstl - * http://www.unixstl.org/ - * - * email: submissions@unixstl.org for submissions - * admin@unixstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _UNIXSTL_INCL_H_UNIXSTL_THREAD_MUTEX -#define _UNIXSTL_INCL_H_UNIXSTL_THREAD_MUTEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _UNIXSTL_VER_H_UNIXSTL_THREAD_MUTEX_MAJOR 1 -# define _UNIXSTL_VER_H_UNIXSTL_THREAD_MUTEX_MINOR 2 -# define _UNIXSTL_VER_H_UNIXSTL_THREAD_MUTEX_REVISION 2 -# define _UNIXSTL_VER_H_UNIXSTL_THREAD_MUTEX_EDIT 10 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _UNIXSTL_INCL_H_UNIXSTL -# include "unixstl.h" // Include the UNIXSTL root header -#endif /* !_UNIXSTL_INCL_H_UNIXSTL */ -#if !defined(_REENTRANT) && \ - !defined(_POSIX_THREADS) -# error unixstl_thread_mutex.h must be compiled in the context of PTHREADS -#endif /* !_REENTRANT && !_POSIX_THREADS */ -#include - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::unixstl */ -namespace unixstl -{ -# else -/* Define stlsoft::unixstl_project */ - -namespace stlsoft -{ - -namespace unixstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class thread_mutex -/// This class provides an implementation of the mutex model based on the PTHREADS mutex -class thread_mutex -{ -public: - typedef thread_mutex class_type; - -// Construction -public: - /// Creates an instance of the mutex - ss_explicit_k thread_mutex(us_bool_t bRecursive = true) unixstl_throw_0() - : m_init(create_(&m_mx, bRecursive)) - {} - /// Destroys an instance of the mutex - ~thread_mutex() unixstl_throw_0() - { - if(m_init) - { - ::pthread_mutex_destroy(&m_mx); - } - } - -// Operations -public: - /// Acquires a lock on the mutex, pending the thread until the lock is aquired - void lock() unixstl_throw_0() - { - pthread_mutex_lock(&m_mx); - } - /// Attempts to lock the mutex - /// - /// \return true if the mutex was aquired, or false if not - /// \note Only available with Windows NT 4 and later - bool try_lock() - { - return pthread_mutex_trylock(&m_mx) == 0; - } - /// Releases an aquired lock on the mutex - void unlock() unixstl_throw_0() - { - pthread_mutex_unlock(&m_mx); - } - -// Implementation -private: - static us_bool_t create_(pthread_mutex_t *mx, us_bool_t bRecursive) - { - us_bool_t bSuccess = false; - pthread_mutexattr_t attr; - - if(0 == ::pthread_mutexattr_init(&attr)) - { - if( !bRecursive || - 0 == ::pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) - { - if(0 == ::pthread_mutex_init(mx, &attr)) - { - bSuccess = true; - } - } - - ::pthread_mutexattr_destroy(&attr); - } - - return bSuccess; - } - -// Members -private: - pthread_mutex_t m_mx; // mx - us_bool_t m_init; - -// Not to be implemented -private: - thread_mutex(class_type const &rhs); - thread_mutex &operator =(class_type const &rhs); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Control shims - */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_sync_control Synchronisation Control Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects - -/// \defgroup unixstl_sync_control_shims Synchronisation Control Shims (UNIXSTL) -/// \ingroup UNIXSTL concepts_shims_sync_control -/// \brief These \ref concepts_shims "shims" control the behaviour of Win32 synchronisation objects -/// @{ - -/// This control ref concepts_shims "shim" aquires a lock on the given mutex -/// -/// \param mx The mutex on which to aquire the lock -inline void lock_instance(unixstl_ns_qual(thread_mutex) &mx) -{ - mx.lock(); -} - -/// This control ref concepts_shims "shim" releases a lock on the given mutex -/// -/// \param mx The mutex on which to release the lock -inline void unlock_instance(unixstl_ns_qual(thread_mutex) &mx) -{ - mx.unlock(); -} - -/// @} // end of group unixstl_sync_control_shims - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -namespace unixstl -{ -# else -namespace unixstl_project -{ -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * lock_traits (for the compilers that do not support Koenig Lookup) - */ - -// class lock_traits -/// Traits for the thread_mutex class (for compilers that do not support Koenig Lookup) -struct thread_mutex_lock_traits -{ -public: - /// The lockable type - typedef thread_mutex lock_type; - typedef thread_mutex_lock_traits class_type; - -// Operations -public: - /// Lock the given thread_mutex instance - static void lock(thread_mutex &c) - { - lock_instance(c); - } - - /// Unlock the given thread_mutex instance - static void unlock(thread_mutex &c) - { - unlock_instance(c); - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _UNIXSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace unixstl -# else -} // namespace unixstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_UNIXSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_UNIXSTL_INCL_H_UNIXSTL_THREAD_MUTEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl.h b/etc/c/stlsoft/winstl.h deleted file mode 100644 index b37f22a886a..00000000000 --- a/etc/c/stlsoft/winstl.h +++ /dev/null @@ -1,528 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: winstl.h - * - * Purpose: Root header for the WinSTL libraries. Performs various compiler - * and platform discriminations, and definitions of types. - * - * Created: 15th January 2002 - * Updated: 17th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL -#define _WINSTL_INCL_H_WINSTL - -/* File version */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _WINSTL_VER_H_WINSTL_MAJOR 1 -#define _WINSTL_VER_H_WINSTL_MINOR 26 -#define _WINSTL_VER_H_WINSTL_REVISION 1 -#define _WINSTL_VER_H_WINSTL_EDIT 100 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/** \file winstl.h The root header for the \ref WinSTL project */ - -/** \weakgroup projects STLSoft Projects - * - * \brief The Projects that comprise the STLSoft libraries - */ - -/** \defgroup WinSTL WinSTL - * \ingroup projects - * - * \brief     Where the Standard Template Library meets the Win32 API - * - * The philosophy of WinSTL (http://winstl.org/) is essentially the same as that - * of the STLSoft (http://stlsoft.org/) organisation: providing robust and - * lightweight software to the Win32 API development - * community. WinSTL provides template-based software that builds on that - * provided by Win and STLSoft in order to reduce programmer effort and increase - * robustness in the use of the Win. - * - * Namespaces - * - * The WinSTL namespace winstl is actually an alias for the - * namespace stlsoft::winstl_project, and as such all the - * WinSTL project components actually reside within the - * stlsoft namespace. However, there is never any need to - * use the stlsoft::winstl_project namespace in your code, - * and you should always use the alias winstl. - * - * Dependencies - * - * As with all parts of the STLSoft libraries, there are no - * dependencies on WinSTL binary components and no need to compile WinSTL - * implementation files; WinSTL is 100% header-only! - * - * As with most of the STLSoft sub-projects, WinSTL depends only on: - * - * - Selected headers from the C standard library, such as wchar.h - * - Selected headers from the C++ standard library, such as new, functional - * - Selected header files of the STLSoft main project - * - The header files particular to the technology area, in this case the Win32 API library headers, such as objbase.h - * - The binary (static and dynamic libraries) components particular to the technology area, in this case the Win32 API libraries that ship with the operating system and your compiler(s) - * - * In addition, some parts of the libraries exhibit different behaviour when - * translated in different contexts, such as the value of _WIN32_WINNT, - * or with ntsecapi.h include. In all - * cases the libraries function correctly in whatever context they are compiled. - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * WinSTL version - * - * The libraries version information is comprised of major, minor and revision - * components. - * - * The major version is denoted by the _WINSTL_VER_MAJOR preprocessor symbol. - * A changes to the major version component implies that a dramatic change has - * occurred in the libraries, such that considerable changes to source dependent - * on previous versions would need to be effected. - * - * The minor version is denoted by the _WINSTL_VER_MINOR preprocessor symbol. - * Changes to the minor version component imply that a significant change has - * occurred to the libraries, either in the addition of new functionality or in - * the destructive change to one or more components such that recomplilation and - * code change may be necessitated. - * - * The revision version is denoted by the _WINSTL_VER_REVISIO preprocessor - * symbol. Changes to the revision version component imply that a bug has been - * fixed. Dependent code should be recompiled in order to pick up the changes. - * - * In addition to the individual version symbols - _WINSTL_VER_MAJOR, - * _WINSTL_VER_MINOR and _WINSTL_VER_REVISION - a composite symbol _WINSTL_VER - * is defined, where the upper 8 bits are 0, bits 16-23 represent the major - * component, bits 8-15 represent the minor component, and bits 0-7 represent - * the revision component. - * - * Each release of the libraries will bear a different version, and that version - * will also have its own symbol: Version 1.0.1 specifies _WINSTL_VER_1_0_1. - * - * Thus the symbol _WINSTL_VER may be compared meaningfully with a specific - * version symbol, e.g. #if _WINSTL_VER >= _WINSTL_VER_1_0_1 - */ - -/// \def _WINSTL_VER_MAJOR -/// The major version number of WinSTL - -/// \def _WINSTL_VER_MINOR -/// The minor version number of WinSTL - -/// \def _WINSTL_VER_REVISION -/// The revision version number of WinSTL - -/// \def _WINSTL_VER -/// The current composite version number of WinSTL - -#define _WINSTL_VER_MAJOR 1 -#define _WINSTL_VER_MINOR 4 -#define _WINSTL_VER_REVISION 1 -#define _WINSTL_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */ -#define _WINSTL_VER_1_0_2 0x00010002 /*!< Version 1.0.2 */ -#define _WINSTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */ -#define _WINSTL_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */ -#define _WINSTL_VER_1_3_1 0x00010301 /*!< Version 1.3.1 */ -#define _WINSTL_VER_1_3_2 0x00010302 /*!< Version 1.3.2 */ -#define _WINSTL_VER_1_3_3 0x00010303 /*!< Version 1.3.3 */ -#define _WINSTL_VER_1_3_4 0x00010304 /*!< Version 1.3.4 */ -#define _WINSTL_VER_1_3_5 0x00010305 /*!< Version 1.3.5 */ -#define _WINSTL_VER_1_3_6 0x00010306 /*!< Version 1.3.6 */ -#define _WINSTL_VER_1_3_7 0x00010307 /*!< Version 1.3.7 */ -#define _WINSTL_VER_1_4_1 0x00010401 /*!< Version 1.4.1 */ - -#define _WINSTL_VER _WINSTL_VER_1_4_1 - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -/* Strict */ -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# ifndef STRICT -# if defined(_WINSTL_STRICT) || \ - ( !defined(_WINSTL_NO_STRICT) && \ - !defined(NO_STRICT)) -# define STRICT 1 -# endif /* !NO_STRICT && !_WINSTL_NO_STRICT */ -# endif /* STRICT */ -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -#ifndef _STLSOFT_INCL_H_STLSOFT -# include "stlsoft.h" // STLSoft root header -#endif /* !_STLSOFT_INCL_H_STLSOFT */ -#include // Windows base header - -/* ///////////////////////////////////////////////////////////////////////////// - * STLSoft version compatibility - */ - -#if !defined(_STLSOFT_VER_1_5_1) || \ - _STLSOFT_VER < _STLSOFT_VER_1_5_1 -# error This version of the WinSTL libraries requires STLSoft version 1.5.1 or later -#endif /* _STLSOFT_VER < _STLSOFT_VER_1_5_1 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Sanity checks - * - * Win32 - must be compiled in context of Win32 API - * MBCS - none of the libraries' code is written to support MBCS - */ - -/* Must be Win32 api. */ -#if !defined(WIN32) && \ - !defined(_WIN32) -# error The WinSTL libraries is currently only compatible with the Win32 API -#endif /* !WIN32 && !_WIN32 */ - -/* Should not be MBCS. */ -#ifdef _MBCS -# ifdef _WINSTL_STRICT -# error The WinSTL libraries are not compatible with variable length character representation schemes such as MBCS -# else -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message("The WinSTL libraries are not compatible with variable length character representation schemes such as MBCS") -# endif /* _STLSOFT_COMPILE_VERBOSE */ -# endif /* _WINSTL_STRICT */ -#endif /* _MBCS */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Compiler compatibility - * - * Currently the only compilers supported by the WinSTL libraries are - * - * Borland C++ 5.5, 5.51, 5.6 - * Digital Mars C/C++ 8.26 - 8.32 - * Metrowerks 2.4 & 3.0 (CodeWarrior 7.0 & 8.0) - * Intel C/C++ 6.0 & 7.0 - * Visual C++ 4.2, 5.0, 6.0, 7.0 - * Watcom C/C++ 11.0 - */ - -#if defined(__STLSOFT_COMPILER_IS_BORLAND) -/* Borland C++ */ -# if __BORLANDC__ < 0x0550 -# error Versions of Borland C++ prior to 5.5 are not supported by the WinSTL libraries -# endif /* __BORLANDC__ */ - -#elif defined(__STLSOFT_COMPILER_IS_COMO) -/* Comeau C++ */ -# if __COMO_VERSION__ < 4300 -# error Versions of Comeau C++ prior to 4.3 are not supported by the WinSTL libraries -# endif /* __COMO_VERSION__ */ - -#elif defined(__STLSOFT_COMPILER_IS_DMC) -/* Digital Mars C/C++ */ -# if __DMC__ < 0x0826 -# error Versions of Digital Mars C/C++ prior to 8.26 are not supported by the WinSTL libraries -# endif /* __DMC__ */ - -#elif defined(__STLSOFT_COMPILER_IS_GCC) -/* GNU C/C++ */ -# if __GNUC__ < 2 || \ - ( __GNUC__ == 2 && \ - __GNUC_MINOR__ < 95) -# error Versions of GNU C/C++ prior to 2.95 are not supported by the WinSTL libraries -# endif /* __GNUC__ */ - -#elif defined(__STLSOFT_COMPILER_IS_INTEL) -/* Intel C++ */ -# if (__INTEL_COMPILER < 600) -# error Versions of Intel C++ prior to 6.0 are not supported by the WinSTL libraries -# endif /* __INTEL_COMPILER */ - -#elif defined(__STLSOFT_COMPILER_IS_MWERKS) -/* Metrowerks C++ */ -# if (__MWERKS__ & 0xFF00) < 0x2400 -# error Versions of Metrowerks CodeWarrior C++ prior to 7.0 are not supported by the WinSTL libraries -# endif /* __MWERKS__ */ - -#elif defined(__STLSOFT_COMPILER_IS_MSVC) -/* Visual C++ */ -# if _MSC_VER < 1020 -# error Versions of Visual C++ prior to 4.2 are not supported by the WinSTL libraries -# endif /* _MSC_VER */ - -#elif defined(__STLSOFT_COMPILER_IS_VECTORC) -/* VectorC C/C++ */ - -#elif defined(__STLSOFT_COMPILER_IS_WATCOM) -/* Watcom C/C++ */ -# if (__WATCOMC__ < 1200) -# error Versions of Watcom C/C++ prior to 12.0 are not supported by the WinSTL libraries -# endif /* __WATCOMC__ */ - -#else -/* No recognised compiler */ -# ifdef _STLSOFT_FORCE_ANY_COMPILER -# define _WINSTL_COMPILER_IS_UNKNOWN -# ifdef _STLSOFT_COMPILE_VERBOSE -# pragma message("Compiler is unknown to WinSTL") -# endif /* _STLSOFT_COMPILE_VERBOSE */ -# else -# error Currently only Borland C++, Digital Mars C/C++, Intel C/C++, Metrowerks CodeWarrior and Visual C++ compilers are supported by the WinSTL libraries -# endif /* _STLSOFT_FORCE_ANY_COMPILER */ -#endif /* compiler */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Debugging - * - * The macro winstl_assert provides standard debug-mode assert functionality. - */ - -/// Defines a runtime assertion -/// -/// \param _x Must be non-zero, or an assertion will be fired -#define winstl_assert(_x) stlsoft_assert(_x) - -/// Defines a runtime assertion, with message -/// -/// \param _x Must be non-zero, or an assertion will be fired -/// \param _m The literal character string message to be included in the assertion -#define winstl_message_assert(_m, _x) stlsoft_message_assert(_m, _x) - -/// Defines a compile-time assertion -/// -/// \param _x Must be non-zero, or compilation will fail -#define winstl_static_assert(_x) stlsoft_static_assert(_x) - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - * - * The WinSTL components are contained within the winstl namespace. This is - * usually an alias for stlsoft::winstl_project, - * - * When compilers support namespaces they are defined by default. They can be - * undefined using a cascasing system, as follows: - * - * If _STLSOFT_NO_NAMESPACES is defined, then _WINSTL_NO_NAMESPACES is defined. - * - * If _WINSTL_NO_NAMESPACES is defined, then _WINSTL_NO_NAMESPACE is defined. - * - * If _WINSTL_NO_NAMESPACE is defined, then the WinSTL constructs are defined - * in the global scope. - * - * If _STLSOFT_NO_NAMESPACES, _WINSTL_NO_NAMESPACES and _WINSTL_NO_NAMESPACE are - * all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the - * namespace stlsoft does not exist), then the WinSTL constructs are defined - * within the winstl namespace. The definition matrix is as follows: - * - * _STLSOFT_NO_NAMESPACE _WINSTL_NO_NAMESPACE winstl definition - * --------------------- -------------------- ----------------- - * not defined not defined = stlsoft::winstl_project - * not defined defined not defined - * defined not defined winstl - * defined defined not defined - * - * - * - * The macro winstl_ns_qual() macro can be used to refer to elements in the - * WinSTL libraries irrespective of whether they are in the - * stlsoft::winstl_project (or winstl) namespace or in the global namespace. - * - * Furthermore, some compilers do not support the standard library in the std - * namespace, so the winstl_ns_qual_std() macro can be used to refer to elements - * in the WinSTL libraries irrespective of whether they are in the std namespace - * or in the global namespace. - */ - -/* No STLSoft namespaces means no WinSTL namespaces */ -#ifdef _STLSOFT_NO_NAMESPACES -# define _WINSTL_NO_NAMESPACES -#endif /* _STLSOFT_NO_NAMESPACES */ - -/* No WinSTL namespaces means no winstl namespace */ -#ifdef _WINSTL_NO_NAMESPACES -# define _WINSTL_NO_NAMESPACE -#endif /* _WINSTL_NO_NAMESPACES */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ -# else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -/// The WinSTL namespace - \c winstl (aliased to \c stlsoft::winstl_project) - is -/// the namespace for the WinSTL project. -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#else -stlsoft_ns_using(move_lhs_from_rhs) -#endif /* !_WINSTL_NO_NAMESPACE */ - -/// \def winstl_ns_qual(x) -/// Qualifies with winstl:: if WinSTL is using namespaces or, if not, does not qualify - -/// \def winstl_ns_using(x) -/// Declares a using directive (with respect to winstl) if WinSTL is using namespaces or, if not, does nothing - -#ifndef _WINSTL_NO_NAMESPACE -# define winstl_ns_qual(x) ::winstl::x -# define winstl_ns_using(x) using ::winstl::x; -#else -# define winstl_ns_qual(x) x -# define winstl_ns_using(x) -#endif /* !_WINSTL_NO_NAMESPACE */ - -/// \def winstl_ns_qual_std(x) -/// Qualifies with std:: if WinSTL is being translated in the context of the standard library being within the std namespace or, if not, does not qualify - -/// \def winstl_ns_using_std(x) -/// Declares a using directive (with respect to std) if WinSTL is being translated in the context of the standard library being within the std namespace or, if not, does nothing - -#ifdef __STLSOFT_CF_std_NAMESPACE -# define winstl_ns_qual_std(x) ::std::x -# define winstl_ns_using_std(x) using ::std::x; -#else -# define winstl_ns_qual_std(x) x -# define winstl_ns_using_std(x) -#endif /* !__STLSOFT_CF_std_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs - * - * The WinSTL uses a number of typedefs to aid in compiler-independence in the - * libraries' main code. - */ - -typedef stlsoft_ns_qual(ss_char_a_t) ws_char_a_t; //!< Ansi char type -typedef stlsoft_ns_qual(ss_char_w_t) ws_char_w_t; //!< Unicode char type -typedef stlsoft_ns_qual(ss_sint8_t) ws_sint8_t; //!< 8-bit signed integer -typedef stlsoft_ns_qual(ss_uint8_t) ws_uint8_t; //!< 8-bit unsigned integer -typedef stlsoft_ns_qual(ss_int16_t) ws_int16_t; //!< 16-bit integer -typedef stlsoft_ns_qual(ss_sint16_t) ws_sint16_t; //!< 16-bit signed integer -typedef stlsoft_ns_qual(ss_uint16_t) ws_uint16_t; //!< 16-bit unsigned integer -typedef stlsoft_ns_qual(ss_int32_t) ws_int32_t; //!< 32-bit integer -typedef stlsoft_ns_qual(ss_sint32_t) ws_sint32_t; //!< 32-bit signed integer -typedef stlsoft_ns_qual(ss_uint32_t) ws_uint32_t; //!< 32-bit unsigned integer -#ifdef __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT - typedef stlsoft_ns_qual(ss_int64_t) ws_int64_t; //!< 64-bit integer - typedef stlsoft_ns_qual(ss_sint64_t) ws_sint64_t; //!< 64-bit signed integer - typedef stlsoft_ns_qual(ss_uint64_t) ws_uint64_t; //!< 64-bit unsigned integer -#endif /* __STLSOFT_CF_NATIVE_64BIT_INTEGER_SUPPORT */ -typedef stlsoft_ns_qual(ss_int_t) ws_int_t; //!< integer -typedef stlsoft_ns_qual(ss_sint_t) ws_sint_t; //!< signed integer -typedef stlsoft_ns_qual(ss_uint_t) ws_uint_t; //!< unsigned integer -typedef stlsoft_ns_qual(ss_long_t) ws_long_t; //!< long -typedef stlsoft_ns_qual(ss_byte_t) ws_byte_t; //!< Byte -typedef stlsoft_ns_qual(ss_bool_t) ws_bool_t; //!< bool -typedef DWORD ws_dword_t; //!< dword -typedef stlsoft_ns_qual(ss_size_t) ws_size_t; //!< size -typedef stlsoft_ns_qual(ss_ptrdiff_t) ws_ptrdiff_t; //!< ptr diff -typedef stlsoft_ns_qual(ss_streampos_t) ws_streampos_t; //!< streampos -typedef stlsoft_ns_qual(ss_streamoff_t) ws_streamoff_t; //!< streamoff - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/* ///////////////////////////////////////////////////////////////////////////// - * Values - * - * Since the boolean type may not be supported natively on all compilers, the - * values of true and false may also not be provided. Hence the values of - * ws_true_v and ws_false_v are defined, and are used in all code. - */ - -#define ws_true_v ss_true_v -#define ws_false_v ss_false_v - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ -/* ///////////////////////////////////////////////////////////////////////////// - * Code modification macros - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/* Exception signatures. */ -# define winstl_throw_0() stlsoft_throw_0() -# define winstl_throw_1(x1) stlsoft_throw_1(x1) -# define winstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2) -# define winstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3) -# define winstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4) -# define winstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5) -# define winstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6) -# define winstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7) -# define winstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/// Evaluates, at compile time, to the number of elements within the given vector entity -#define winstl_num_elements(_x) stlsoft_num_elements(_x) - -/// Destroys the given instance \c p of the given type (\c t and \c _type) -#define winstl_destroy_instance(t, _type, p) stlsoft_destroy_instance(t, _type, p) - -/// Generates an opaque type with the name \c _htype -#define winstl_gen_opaque(_htype) stlsoft_gen_opaque(_htype) - -/// Define a 'final' class, ie. one that cannot be inherited from -#define winstl_sterile_class(_cls) stlsoft_sterile_class(_cls) - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -namespace winstl = ::stlsoft::winstl_project; -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _WINSTL_INCL_H_WINSTL */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_atomic_functions.h b/etc/c/stlsoft/winstl_atomic_functions.h deleted file mode 100644 index 2aa4909c3cb..00000000000 --- a/etc/c/stlsoft/winstl_atomic_functions.h +++ /dev/null @@ -1,1559 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: winstl_atomic_functions.h (formerly MLAtomic.cpp, ::SynesisStd) - * - * Purpose: WinSTL atomic functions. - * - * Created: 23rd October 1997 - * Updated: 17th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_ATOMIC_FUNCTIONS -#define _WINSTL_INCL_H_WINSTL_ATOMIC_FUNCTIONS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _WINSTL_VER_H_WINSTL_ATOMIC_FUNCTIONS_MAJOR 2 -#define _WINSTL_VER_H_WINSTL_ATOMIC_FUNCTIONS_MINOR 5 -#define _WINSTL_VER_H_WINSTL_ATOMIC_FUNCTIONS_REVISION 1 -#define _WINSTL_VER_H_WINSTL_ATOMIC_FUNCTIONS_EDIT 156 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL -# include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ -#ifndef _WINSTL_INCL_H_SPINMUTEXT -# include "winstl_spin_mutex.h" -#endif /* _WINSTL_INCL_H_SPINMUTEXT */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Compatibility - */ - -#if !defined(_M_IX86) -# error Not valid for processors other than Intel -#endif /* _M_IX86 */ - -#ifdef STLSOFT_ATOMIC_CALLCONV -# undef STLSOFT_ATOMIC_CALLCONV -#endif /* STLSOFT_ATOMIC_CALLCONV */ -#ifdef WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL -# undef WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL -#endif /* WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL */ -#ifdef WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL -# undef WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL -#endif /* WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL */ - -#ifndef STLSOFT_NO_FASTCALL -# if defined(__STLSOFT_COMPILER_IS_BORLAND) || \ - defined(__STLSOFT_COMPILER_IS_DMC) || \ - defined(__STLSOFT_COMPILER_IS_WATCOM) -# define STLSOFT_NO_FASTCALL -# endif /* compiler */ -#endif /* STLSOFT_NO_FASTCALL */ - -#if defined(STLSOFT_CF_FASTCALL_SUPPORTED) && \ - !defined(STLSOFT_NO_FASTCALL) -# define WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL -# define WINSTL_ATOMIC_FNS_CALLCONV __fastcall -#elif defined(STLSOFT_CF_STDCALL_SUPPORTED) -# define WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL -# define WINSTL_ATOMIC_FNS_CALLCONV __stdcall -#else -# error Need to define calling convention -#endif /* call-conv */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ -# else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_threading Threading Library -/// \ingroup libraries -/// \brief This library provides synchronisation and threading facilities - -/// \weakgroup winstl_perf_library Threading Library (WinSTL) -/// \ingroup WinSTL libraries_threading -/// \brief This library provides synchronisation and threading facilities for the Win32 API -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Implementation options - * - * Because some compilers can make the code actually faster when it the naked - * functions are not inline, we provide for that here. If you want to out-of-line - * the functions, then you just need to define WINSTL_ATOMIC_FNS_DECLARATION_ONLY - * in the code that uses it, and define WINSTL_ATOMIC_FNS_DEFINITION in one - * implementation file. - */ - -#ifdef WINSTL_ATOMIC_FNS_DECL_ -# undef WINSTL_ATOMIC_FNS_DECL_ -#endif /* WINSTL_ATOMIC_FNS_DECL_ */ - -#ifdef WINSTL_ATOMIC_FNS_IMPL_ -# undef WINSTL_ATOMIC_FNS_IMPL_ -#endif /* WINSTL_ATOMIC_FNS_IMPL_ */ - -#if defined(WINSTL_ATOMIC_FNS_DECLARATION_ONLY) -/* Only the function declarations are included */ -# define WINSTL_ATOMIC_FNS_DECL_(type) type WINSTL_ATOMIC_FNS_CALLCONV -#elif defined(WINSTL_ATOMIC_FNS_DEFINITION) -/* Only the function definitions are included */ -# ifdef STSLSOFT_INLINE_ASM_SUPPORTED -# define WINSTL_ATOMIC_FNS_IMPL_(type) __declspec(naked) type WINSTL_ATOMIC_FNS_CALLCONV -# else /* ? STSLSOFT_INLINE_ASM_SUPPORTED */ -# define WINSTL_ATOMIC_FNS_IMPL_(type) type WINSTL_ATOMIC_FNS_CALLCONV -# endif /* STSLSOFT_INLINE_ASM_SUPPORTED */ -#else -# if defined(__STLSOFT_COMPILER_IS_MWERKS) && \ - (__MWERKS__ & 0xFF00) < 0x3000 -# error CodeWarrior 7 and earlier does not generate correct code when inline naked functions are used -# endif /* __MWERKS__ & 0xFF00) < 0x3000 */ - -# ifdef STSLSOFT_INLINE_ASM_SUPPORTED - /* The default is to define them inline */ -# ifdef STSLSOFT_ASM_IN_INLINE_SUPPORTED -# define WINSTL_ATOMIC_FNS_DECL_(type) inline type WINSTL_ATOMIC_FNS_CALLCONV -# define WINSTL_ATOMIC_FNS_IMPL_(type) inline __declspec(naked) type WINSTL_ATOMIC_FNS_CALLCONV -# else /* ? STSLSOFT_ASM_IN_INLINE_SUPPORTED */ -# define WINSTL_ATOMIC_FNS_DECL_(type) type WINSTL_ATOMIC_FNS_CALLCONV -# define WINSTL_ATOMIC_FNS_IMPL_(type) static __declspec(naked) type WINSTL_ATOMIC_FNS_CALLCONV -# endif /* STSLSOFT_ASM_IN_INLINE_SUPPORTED */ -# else /* ? STSLSOFT_INLINE_ASM_SUPPORTED */ - /* ASM not supported, so we're using the Win32 functions */ -# define WINSTL_ATOMIC_FNS_DECL_(type) inline type WINSTL_ATOMIC_FNS_CALLCONV -# define WINSTL_ATOMIC_FNS_IMPL_(type) inline type WINSTL_ATOMIC_FNS_CALLCONV -# endif /* STSLSOFT_INLINE_ASM_SUPPORTED */ -#endif /* declaration / definition */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Atomic function declarations - */ - -#ifndef WINSTL_ATOMIC_FNS_DEFINITION - -/* Uni-processor variants */ -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_preincrement_up(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_predecrement_up(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postincrement_up(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postdecrement_up(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(void) atomic_increment_up(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(void) atomic_decrement_up(ws_sint32_t volatile *pl); - -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_write_up(ws_sint32_t volatile *pl, ws_sint32_t n); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_read_up(ws_sint32_t volatile const *pl); - -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postadd_up(ws_sint32_t volatile *pl, ws_sint32_t n); -inline ws_sint32_t atomic_preadd_up(ws_sint32_t volatile *pl, ws_sint32_t n); - - - -/* SMP variants */ -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_preincrement_smp(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_predecrement_smp(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postincrement_smp(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postdecrement_smp(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(void) atomic_increment_smp(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(void) atomic_decrement_smp(ws_sint32_t volatile *pl); - -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_write_smp(ws_sint32_t volatile *pl, ws_sint32_t n); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_read_smp(ws_sint32_t volatile const *pl); - -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postadd_smp(ws_sint32_t volatile *pl, ws_sint32_t n); -inline ws_sint32_t atomic_preadd_smp(ws_sint32_t volatile *pl, ws_sint32_t n); - - - -/* Multi-processor detection variants */ -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_preincrement(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_predecrement(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postincrement(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postdecrement(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(void) atomic_increment(ws_sint32_t volatile *pl); -WINSTL_ATOMIC_FNS_DECL_(void) atomic_decrement(ws_sint32_t volatile *pl); - -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_write(ws_sint32_t volatile *pl, ws_sint32_t n); -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_read(ws_sint32_t volatile const *pl); - -WINSTL_ATOMIC_FNS_DECL_(ws_sint32_t) atomic_postadd(ws_sint32_t volatile *pl, ws_sint32_t n); -inline ws_sint32_t atomic_preadd(ws_sint32_t volatile *pl, ws_sint32_t n); - - -#endif /* !WINSTL_ATOMIC_FNS_DEFINITION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Atomic function definitions - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - -# if !defined(WINSTL_ATOMIC_FNS_DECLARATION_ONLY) - -# ifdef STSLSOFT_INLINE_ASM_SUPPORTED -/* Inline assembler versions */ - -#ifdef __STLSOFT_COMPILER_IS_BORLAND -# pragma warn -8002 /* Suppresses: "Restarting compile using assembly" */ -# pragma warn -8070 /* Suppresses: "Function should return a value" */ -#endif /* __STLSOFT_COMPILER_IS_BORLAND */ - -// Uni-processor - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_preincrement_up(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is pre-increment, we need to inc eax to catch up with the - // real value - inc eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_predecrement_up(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is pre-decrement, we need to inc eax to catch up with the - // real value - dec eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postincrement_up(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is post-increment, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postdecrement_up(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is post-decrement, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment_up(ws_sint32_t volatile * /* pl */) -{ - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - add dword ptr [ecx], 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement_up(ws_sint32_t volatile * /* pl */) -{ - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - sub dword ptr [ecx], 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_read_up(ws_sint32_t volatile const * /* pl */) -{ - _asm - { - mov eax, 0 -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl - -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - // pop 0 into eax, which can then be atomically added into *pl (held - // in ecx), leaving the value unchanged. - xadd dword ptr [ecx], eax - - // Since it's an xadd it exchanges the previous value into eax, which - // is exactly what's required - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_write_up(ws_sint32_t volatile * /* pl */, ws_sint32_t /* n */) -{ - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Just exchange *pl and n - xchg dword ptr [ecx], edx - - // The previous value goes into edx, so me move it into eax for return - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - xchg dword ptr [ecx], eax - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } -} - - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postadd_up(ws_sint32_t volatile * /* pl */, ws_sint32_t /* n */) -{ - // Thanks to Eugene Gershnik for the fast-call implementation - __asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Simply atomically add them, which will leave the previous value - // in edx - xadd dword ptr [ecx], edx - - // Just need to move adx into eax to return it - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - - // Simply atomically add them, which will leave the previous value - // in edx - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - xadd dword ptr [ecx], eax - - // Just need to move adx into eax to return it - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } -} - -// Symmetric multi-processor - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_preincrement_smp(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is pre-increment, we need to inc eax to catch up with the - // real value - inc eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_predecrement_smp(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is pre-decrement, we need to inc eax to catch up with the - // real value - dec eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postincrement_smp(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is post-increment, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postdecrement_smp(ws_sint32_t volatile * /* pl */) -{ - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is post-decrement, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment_smp(ws_sint32_t volatile * /* pl */) -{ - __asm - { - call atomic_postincrement_smp -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement_smp(ws_sint32_t volatile * /* pl */) -{ - __asm - { - call atomic_postdecrement_smp -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_read_smp(ws_sint32_t volatile const * /* pl */) -{ - _asm - { - mov eax, 0 -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl - -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - // pop 0 into eax, which can then be atomically added into *pl (held - // in ecx), leaving the value unchanged. - lock xadd dword ptr [ecx], eax - - // Since it's an xadd it exchanges the previous value into eax, which - // is exactly what's required - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_write_smp(ws_sint32_t volatile * /* pl */, ws_sint32_t /* n */) -{ - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Just exchange *pl and n - /* lock */ xchg dword ptr [ecx], edx - - // The previous value goes into edx, so me move it into eax for return - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - /* lock */ xchg dword ptr [ecx], eax - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } -} - - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postadd_smp(ws_sint32_t volatile * /* pl */, ws_sint32_t /* n */) -{ - // Thanks to Eugene Gershnik for the fast-call implementation - __asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Simply atomically add them, which will leave the previous value - // in edx - lock xadd dword ptr [ecx], edx - - // Just need to move adx into eax to return it - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - - // Simply atomically add them, which will leave the previous value - // in edx - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - lock xadd dword ptr [ecx], eax - - // Just need to move adx into eax to return it - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } -} - -// Processor detecting - -namespace -{ - ws_bool_t is_host_up() - { - // All these statics are guaranteed to be zero as a result of the module/process loading - static ws_sint32_t s_spin; // The spin variable - static ws_bool_t s_init; // This is guaranteed to be zero - static ws_bool_t s_up; // This is the flag variably, also guaranteed to be zero - - // Simple spin lock - if(!s_init) // Low cost pre-test. In the unlikely event that another thread does come in and - { // also see this as false, the dual initialisation of all three statics is benign - spin_mutex smx(&s_spin); - - smx.lock(); - if(!s_init) - { - SYSTEM_INFO sys_info; - - ::GetSystemInfo(&sys_info); - - s_init = true; - - s_up = 1 == sys_info.dwNumberOfProcessors; - } - smx.unlock(); - } - - return s_up; - } - - // s_up is guaranteed to be zero at load time. - // - // There is a race condition with all static variables, since multiple threads - // can come in and one can have set the hidden flag variable without prior to - // setting the static variable itself, just at the time that an arbitrary number - // of other threads pick up the pre-initialised value. - // - // However, because the test here is whether to skip the lock, the pathological - // case is benign. The only cost in the very rare case where it happens is that - // the thread(s) will use bus locking until such time as the static is fully - // initialised. - static ws_bool_t s_up = is_host_up(); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_preincrement(ws_sint32_t volatile * /* pl */) -{ - if(s_up) - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is pre-increment, we need to inc eax to catch up with the - // real value - inc eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is pre-increment, we need to inc eax to catch up with the - // real value - inc eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_predecrement(ws_sint32_t volatile * /* pl */) -{ - if(s_up) - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is pre-decrement, we need to inc eax to catch up with the - // real value - dec eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is pre-decrement, we need to inc eax to catch up with the - // real value - dec eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postincrement(ws_sint32_t volatile * /* pl */) -{ - if(s_up) - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is post-increment, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is post-increment, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postdecrement(ws_sint32_t volatile * /* pl */) -{ - if(s_up) - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - xadd dword ptr [ecx], eax - - // Since this is post-decrement, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { - // pop 1 into eax, which can then be atomically added into *pl (held - // in ecx). Since it's an xadd it exchanges the previous value into eax - mov eax, -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - lock xadd dword ptr [ecx], eax - - // Since this is post-decrement, we need do nothing, since the previous - // value is in eax - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment(ws_sint32_t volatile * /* pl */) -{ - if(s_up) - { - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - add dword ptr [ecx], 1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - -#if defined(__STLSOFT_COMPILER_IS_VECTORC) - mov eax, 1 - lock xadd dword ptr [ecx], eax -#else /* ? compiler */ - // This might be wrong - lock add dword ptr [ecx], 1 -#endif /* compiler */ - - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement(ws_sint32_t volatile * /* pl */) -{ - if(s_up) - { - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - add dword ptr [ecx], -1 - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - -#if defined(__STLSOFT_COMPILER_IS_VECTORC) - mov eax, -1 - lock xadd dword ptr [ecx], eax -#else /* ? compiler */ - // This might be wrong - lock sub dword ptr [ecx], 1 -#endif /* compiler */ - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_read(ws_sint32_t volatile const * /* pl */) -{ - if(s_up) - { - _asm - { - mov eax, 0 -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl - -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - // pop 0 into eax, which can then be atomically added into *pl (held - // in ecx), leaving the value unchanged. - xadd dword ptr [ecx], eax - - // Since it's an xadd it exchanges the previous value into eax, which - // is exactly what's required - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } - else - { - _asm - { - mov eax, 0 -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl - -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack - mov ecx, dword ptr [esp + 4] -#else -# error Need to define calling convention -#endif /* call-conv */ - - // pop 0 into eax, which can then be atomically added into *pl (held - // in ecx), leaving the value unchanged. - lock xadd dword ptr [ecx], eax - - // Since it's an xadd it exchanges the previous value into eax, which - // is exactly what's required - -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - ret 4 -#endif /* call-conv */ - } - } -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_write(ws_sint32_t volatile * /* pl */, ws_sint32_t /* n */) -{ - _asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Just exchange *pl and n - lock xchg dword ptr [ecx], edx - - // The previous value goes into edx, so me move it into eax for return - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - xchg dword ptr [ecx], eax - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } -} - - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postadd(ws_sint32_t volatile * /* pl */, ws_sint32_t /* n */) -{ - // Thanks to Eugene Gershnik for the fast-call implementation - if(s_up) - { - __asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Simply atomically add them, which will leave the previous value - // in edx - xadd dword ptr [ecx], edx - - // Just need to move adx into eax to return it - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - - // Simply atomically add them, which will leave the previous value - // in edx - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - xadd dword ptr [ecx], eax - - // Just need to move adx into eax to return it - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } - } - else - { - __asm - { -#if defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_FASTCALL) - // __fastcall: ecx is pl, edx is n - - // Simply atomically add them, which will leave the previous value - // in edx - lock xadd dword ptr [ecx], edx - - // Just need to move adx into eax to return it - mov eax, edx - - ret -#elif defined(WINSTL_ATOMIC_FNS_CALLCONV_IS_STDCALL) - // __stdcall: arguments are on the stack: pl in esp+4, pl in esp+8 - - // Simply atomically add them, which will leave the previous value - // in edx - mov ecx, dword ptr [esp + 4] // Load the address of pl into ecx - mov eax, dword ptr [esp + 8] // Load the value into eax, so the return value will be there waiting - - lock xadd dword ptr [ecx], eax - - // Just need to move adx into eax to return it - - ret 8 -#else -# error Need to define calling convention -#endif /* call-conv */ - } - } -} - -#ifdef __STLSOFT_COMPILER_IS_BORLAND -# pragma warn .8070 /* Suppresses: "Function should return a value" */ -# pragma warn .8002 /* Suppresses: "Restarting compile using assembly" */ -#endif /* __STLSOFT_COMPILER_IS_BORLAND */ - -# else /* STSLSOFT_INLINE_ASM_SUPPORTED */ -/* Non-assembler versions - * - * These use the Win32 Interlocked functions. These are not guaranteed to give - * precise answers on Windows 95. - */ - - -/* Multi-processor detection variants */ -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_preincrement(ws_sint32_t volatile *pl) -{ - return ::InterlockedIncrement((LPLONG)pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_predecrement(ws_sint32_t volatile *pl) -{ - return ::InterlockedDecrement((LPLONG)pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postincrement(ws_sint32_t volatile *pl) -{ - ws_sint32_t pre = *pl; - - ::InterlockedIncrement((LPLONG)pl); - - return pre; -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postdecrement(ws_sint32_t volatile *pl) -{ - ws_sint32_t pre = *pl; - - ::InterlockedDecrement((LPLONG)pl); - - return pre; -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment(ws_sint32_t volatile *pl) -{ - ::InterlockedIncrement((LPLONG)pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement(ws_sint32_t volatile *pl) -{ - ::InterlockedDecrement((LPLONG)pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_write(ws_sint32_t volatile *pl, ws_sint32_t n) -{ - return ::InterlockedExchange((LPLONG)pl, n); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_read(ws_sint32_t volatile const *pl); -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postadd(ws_sint32_t volatile *pl, ws_sint32_t n); - - -/* Uni-processor variants */ - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_preincrement_up(ws_sint32_t volatile *pl) -{ - return atomic_preincrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_predecrement_up(ws_sint32_t volatile *pl) -{ - return atomic_predecrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postincrement_up(ws_sint32_t volatile *pl) -{ - return atomic_postincrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postdecrement_up(ws_sint32_t volatile *pl) -{ - return atomic_postdecrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment_up(ws_sint32_t volatile *pl) -{ - atomic_increment(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement_up(ws_sint32_t volatile *pl) -{ - atomic_decrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_write_up(ws_sint32_t volatile *pl, ws_sint32_t n) -{ - return atomic_write(pl, n); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_read_up(ws_sint32_t volatile const *pl); -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postadd_up(ws_sint32_t volatile *pl, ws_sint32_t n); - -/* SMP variants */ - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_preincrement_smp(ws_sint32_t volatile *pl) -{ - return atomic_preincrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_predecrement_smp(ws_sint32_t volatile *pl) -{ - return atomic_predecrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postincrement_smp(ws_sint32_t volatile *pl) -{ - return atomic_postincrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postdecrement_smp(ws_sint32_t volatile *pl) -{ - return atomic_postdecrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_increment_smp(ws_sint32_t volatile *pl) -{ - atomic_increment(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(void) atomic_decrement_smp(ws_sint32_t volatile *pl) -{ - atomic_decrement(pl); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_write_smp(ws_sint32_t volatile *pl, ws_sint32_t n) -{ - return atomic_write(pl, n); -} - -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_read_smp(ws_sint32_t volatile const *pl); -WINSTL_ATOMIC_FNS_IMPL_(ws_sint32_t) atomic_postadd_smp(ws_sint32_t volatile *pl, ws_sint32_t n); - -# endif /* STSLSOFT_INLINE_ASM_SUPPORTED */ - -# endif /* !WINSTL_ATOMIC_FNS_DECLARATION_ONLY */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Other inline atomic function - */ - -inline ws_sint32_t atomic_preadd_up(ws_sint32_t volatile *pl, ws_sint32_t n) -{ - return n + atomic_postadd_up(pl, n); -} - -inline ws_sint32_t atomic_preadd_smp(ws_sint32_t volatile *pl, ws_sint32_t n) -{ - return n + atomic_postadd_smp(pl, n); -} - -inline ws_sint32_t atomic_preadd(ws_sint32_t volatile *pl, ws_sint32_t n) -{ - return n + atomic_postadd(pl, n); -} - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group winstl_perf_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_WINSTL_INCL_H_WINSTL_ATOMIC_FUNCTIONS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_filesystem_traits.h b/etc/c/stlsoft/winstl_filesystem_traits.h deleted file mode 100644 index 0fd0befb68e..00000000000 --- a/etc/c/stlsoft/winstl_filesystem_traits.h +++ /dev/null @@ -1,646 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: winstl_filesystem_traits.h - * - * Purpose: Contains the filesystem_traits template class, and ANSI and - * Unicode specialisations thereof. - * - * Created: 15th November 2002 - * Updated: 28th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_FILESYSTEM_TRAITS -#define _WINSTL_INCL_H_WINSTL_FILESYSTEM_TRAITS - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _WINSTL_VER_H_WINSTL_FILESYSTEM_TRAITS_MAJOR 1 -# define _WINSTL_VER_H_WINSTL_FILESYSTEM_TRAITS_MINOR 7 -# define _WINSTL_VER_H_WINSTL_FILESYSTEM_TRAITS_REVISION 1 -# define _WINSTL_VER_H_WINSTL_FILESYSTEM_TRAITS_EDIT 23 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL -# include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ - -/* ///////////////////////////////////////////////////////////////////////////// - * FindVolume API declarations - * - * The FindVolume API is not visible in the Windows headers unless _WIN32_WINNT - * is defined as 0x0500 or greater. Where this definition is not present, the - * functions are declared here, unless _WINSTL_NO_FINDVOLUME_API is defined. - * - * Where _WINSTL_NO_FINDVOLUME_API is defined, the requisite members of the - * traits classes are undeclared. - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - -#ifndef _WINSTL_NO_FINDVOLUME_API -# if !defined(_WIN32_WINNT) || \ - (_WIN32_WINNT < 0x0500) - -HANDLE WINAPI FindFirstVolumeA( - LPSTR lpszVolumeName, // output buffer - DWORD cchBufferLength // size of output buffer -); - -HANDLE WINAPI FindFirstVolumeW( - LPWSTR lpszVolumeName, // output buffer - DWORD cchBufferLength // size of output buffer -); - -BOOL WINAPI FindNextVolumeA( - HANDLE hFindVolume, // volume search handle - LPSTR lpszVolumeName, // output buffer - DWORD cchBufferLength // size of output buffer -); - -BOOL WINAPI FindNextVolumeW( - HANDLE hFindVolume, // volume search handle - LPWSTR lpszVolumeName, // output buffer - DWORD cchBufferLength // size of output buffer -); - -BOOL WINAPI FindVolumeClose( - HANDLE hFindVolume - ); - -# endif /* _WIN32_WINNT < 0x0500 */ -#endif /* !_WINSTL_NO_FINDVOLUME_API */ - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ -# else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \weakgroup winstl_filesystem_library File-System Library (WinSTL) -/// \ingroup WinSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating file-system objects for the Win32 API -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -#ifdef __STLSOFT_DOCUMENTATION_SKIP_SECTION -/// Traits for accessing the correct file-system functions for a given character type -/// -/// filesystem_traits is a traits class for determining the correct file-system -/// structures and functions for a given character type. -/// -/// \param C The character type -template -struct filesystem_traits -{ -public: - /// The character type - typedef C char_type; - /// The size type - typedef ws_size_t size_type; - /// The difference type - typedef ws_ptrdiff_t difference_type; - /// The find data type - typedef WIN32_FIND_DATA find_data_type; // Placeholder only - -public: - // General string handling - - /// Copies the contents of \c src to \c dest - static char_type *str_copy(char_type *dest, char_type const *src); - /// Appends the contents of \c src to \c dest - static char_type *str_cat(char_type *dest, char_type const *src); - /// Comparies the contents of \c src and \c dest - static ws_int_t str_compare(char_type const *s1, char_type const *s2); - /// Comparies the contents of \c src and \c dest in a case-insensitive fashion - static ws_int_t str_compare_no_case(char_type const *s1, char_type const *s2); - /// Evaluates the length of \c src - static size_type str_len(char_type const *src); - - // File-system entry names - - /// Appends a file-system path separator to \c dir if one does not exist - static char_type *ensure_dir_end(char_type *dir); - /// Returns \c true if dir is \c "." or \c ".." - static ws_bool_t is_dots(char_type const *dir); - /// Returns the path separator - /// - /// This is the separator that is used to separate multiple paths on the operating system. On UNIX it is ':' - static char_type path_separator(); - /// Returns the path name separator - /// - /// This is the separator that is used to separate parts of a path on the operating system. On UNIX it is '/' - static char_type path_name_separator(); - /// Returns the wildcard pattern that represents all possible matches - /// - /// \note On Win32 it is '*.*' - static char_type const *pattern_all(); - /// Gets the full path name into the given buffer, returning a pointer to the file-part - static ws_dword_t get_full_path_name(char_type const *fileName, ws_dword_t cchBuffer, char_type *buffer, char_type **ppFile); - /// Gets the full path name into the given buffer - static ws_dword_t get_full_path_name(char_type const *fileName, ws_dword_t cchBuffer, char_type *buffer); - /// Gets the short path name into the given buffer - static ws_dword_t get_short_path_name(char_type const *fileName, char_type *buffer, ws_dword_t cchBuffer); - - // FindFile() API - - /// Initiate a file-system search - static HANDLE find_first_file(char_type const *spec, find_data_type *findData); -#if _WIN32_WINNT >= 0x0400 - /// Initiate a file-system search - NT4+-only - static HANDLE find_first_file_ex(char_type const *spec, FINDEX_SEARCH_OPS flags, find_data_type *findData); -#endif /* _WIN32_WINNT >= 0x0400 */ - /// Advance a given file-system search - static ws_bool_t find_next_file(HANDLE h, find_data_type *findData); - - // FindVolume() API - -#ifndef _WINSTL_NO_FINDVOLUME_API - /// Initiate a file-system volume search - static HANDLE find_first_volume(char_type *volume_name, size_type cch_volume_name); - /// Advance a given file-system volume search - static ws_bool_t find_next_volume(HANDLE h, char_type *volume_name, size_type cch_volume_name); -#endif // !_WINSTL_NO_FINDVOLUME_API - - // Modules - - /// Gets the full path name of the given module - static ws_dword_t get_module_filename(HINSTANCE hModule, char_type *buffer, ws_dword_t cchBuffer); - /// Gets the full path name of the system directory - static ws_uint_t get_system_directory(char_type *buffer, ws_uint_t cchBuffer); - /// Gets the full path name of the windows directory - static ws_uint_t get_windows_directory(char_type *buffer, ws_uint_t cchBuffer); - - // File system state - - /// Sets the current directory to \c dir - static ws_bool_t set_current_directory(char_type const *dir); - /// Retrieves the name of the current directory into \c buffer up to a maximum of \c cchBuffer characters - static ws_uint_t get_current_directory(ws_uint_t cchBuffer, char_type *buffer); - - /// Returns whether a file exists or not - static ws_bool_t file_exists(char_type const *fileName); - - // Environment - - /// Gets an environment variable into the given buffer - static ws_dword_t get_environment_variable(char_type const *name, char_type *buffer, ws_uint_t cchBuffer); - /// Expands environment strings in \c src into \dest, up to a maximum \c cchDest characters - static ws_dword_t expand_environment_strings(char_type const *src, char_type *buffer, ws_uint_t cchBuffer); -}; - -#else - -template -struct filesystem_traits; - -#ifdef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -template <> -#endif /* __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX */ -struct filesystem_traits -{ -public: - typedef ws_char_a_t char_type; - typedef ws_size_t size_type; - typedef ws_ptrdiff_t difference_type; - typedef WIN32_FIND_DATAA find_data_type; - -public: - // General string handling - static char_type *str_copy(char_type *dest, char_type const *src) - { - return lstrcpyA(dest, src); - } - - static char_type *str_cat(char_type *dest, char_type const *src) - { - return lstrcatA(dest, src); - } - - static ws_int_t str_compare(char_type const *s1, char_type const *s2) - { - return lstrcmpA(s1, s2); - } - - static ws_int_t str_compare_no_case(char_type const *s1, char_type const *s2) - { - return lstrcmpiA(s1, s2); - } - - static size_type str_len(char_type const *src) - { - return static_cast(lstrlenA(src)); - } - - // File-system entry names - static char_type *ensure_dir_end(char_type *dir) - { - char_type *end; - - for(end = dir; *end != '\0'; ++end) - {} - - if( dir < end && - *(end - 1) != path_name_separator()) - { - *end = path_name_separator(); - *(end + 1) = '\0'; - } - - return dir; - } - - static ws_bool_t is_dots(char_type const *dir) - { - return dir != 0 && - dir[0] == '.' && - ( dir[1] == '\0' || - ( dir[1] == '.' && - dir[2] == '\0')); - } - - static char_type path_separator() - { - return ';'; - } - - static char_type path_name_separator() - { - return '\\'; - } - - static char_type const *pattern_all() - { - return "*.*"; - } - - static ws_dword_t get_full_path_name(char_type const *fileName, ws_dword_t cchBuffer, char_type *buffer, char_type **ppFile) - { - return ::GetFullPathNameA(fileName, cchBuffer, buffer, ppFile); - } - - static ws_dword_t get_full_path_name(char_type const *fileName, ws_dword_t cchBuffer, char_type *buffer) - { - char_type *pFile; - - return get_full_path_name(fileName, cchBuffer, buffer, &pFile); - } - - static ws_dword_t get_short_path_name(char_type const *fileName, char_type *buffer, ws_dword_t cchBuffer) - { - return ::GetShortPathNameA(fileName, buffer, cchBuffer); - } - - // FindFile() API - static HANDLE find_first_file(char_type const *spec, find_data_type *findData) - { - return ::FindFirstFileA(spec, findData); - } - -#if _WIN32_WINNT >= 0x0400 - static HANDLE find_first_file_ex(char_type const *spec, FINDEX_SEARCH_OPS flags, find_data_type *findData) - { - return ::FindFirstFileExA(spec, FindExInfoStandard, findData, flags, NULL, 0); - } -#endif /* _WIN32_WINNT >= 0x0400 */ - - static ws_bool_t find_next_file(HANDLE h, find_data_type *findData) - { - return ::FindNextFileA(h, findData) != FALSE; - } - - // FindVolume() API -#ifndef _WINSTL_NO_FINDVOLUME_API - static HANDLE find_first_volume(char_type *volume_name, size_type cch_volume_name) - { - return ::FindFirstVolumeA(volume_name, cch_volume_name); - } - - static ws_bool_t find_next_volume(HANDLE h, char_type *volume_name, size_type cch_volume_name) - { - return ::FindNextVolumeA(h, volume_name, cch_volume_name) != FALSE; - } -#endif // !_WINSTL_NO_FINDVOLUME_API - - // Modules - static ws_dword_t get_module_filename(HINSTANCE hModule, char_type *buffer, ws_dword_t cchBuffer) - { - return ::GetModuleFileNameA(hModule, buffer, cchBuffer); - } - - static ws_uint_t get_system_directory(char_type *buffer, ws_uint_t cchBuffer) - { - return ::GetSystemDirectoryA(buffer, cchBuffer); - } - - static ws_uint_t get_windows_directory(char_type *buffer, ws_uint_t cchBuffer) - { - return ::GetWindowsDirectoryA(buffer, cchBuffer); - } - - // File system state - static ws_bool_t set_current_directory(char_type const *dir) - { - return ::SetCurrentDirectoryA(dir) != FALSE; - } - - static ws_uint_t get_current_directory(ws_uint_t cchBuffer, char_type *buffer) - { - return ::GetCurrentDirectoryA(cchBuffer, buffer); - } - - /// Returns whether a file exists or not - static ws_bool_t file_exists(char_type const *fileName) - { - return 0xFFFFFFFF != ::GetFileAttributesA(fileName); - } - - // Environment - static ws_dword_t get_environment_variable(char_type const *name, char_type *buffer, ws_uint_t cchBuffer) - { - return ::GetEnvironmentVariableA(name, buffer, cchBuffer); - } - - static size_type expand_environment_strings(char_type const *src, char_type *dest, size_type cch_dest) - { - return static_cast(::ExpandEnvironmentStringsA(src, dest, cch_dest)); - } -}; - -#ifdef __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX -template <> -#endif /* __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX */ -struct filesystem_traits -{ -public: - typedef ws_char_w_t char_type; - typedef ws_size_t size_type; - typedef ws_ptrdiff_t difference_type; - typedef WIN32_FIND_DATAW find_data_type; - -public: - // General string handling - static char_type *str_copy(char_type *dest, char_type const *src) - { - return lstrcpyW(dest, src); - } - - static char_type *str_cat(char_type *dest, char_type const *src) - { - return lstrcatW(dest, src); - } - - static ws_int_t str_compare(char_type const *s1, char_type const *s2) - { - return lstrcmpW(s1, s2); - } - - static ws_int_t str_compare_no_case(char_type const *s1, char_type const *s2) - { - return lstrcmpiW(s1, s2); - } - - static size_type str_len(char_type const *src) - { - return static_cast(lstrlenW(src)); - } - - // File-system entry names - static char_type *ensure_dir_end(char_type *dir) - { - char_type *end; - - for(end = dir; *end != L'\0'; ++end) - {} - - if( dir < end && - *(end - 1) != path_name_separator()) - { - *end = path_name_separator(); - *(end + 1) = L'\0'; - } - - return dir; - } - - static ws_bool_t is_dots(char_type const *dir) - { - return dir != 0 && - dir[0] == '.' && - ( dir[1] == L'\0' || - ( dir[1] == L'.' && - dir[2] == L'\0')); - } - - static char_type path_separator() - { - return L';'; - } - - static char_type path_name_separator() - { - return L'\\'; - } - - static char_type const *pattern_all() - { - return L"*.*"; - } - - static ws_dword_t get_full_path_name(char_type const *fileName, ws_dword_t cchBuffer, char_type *buffer, char_type **ppFile) - { - winstl_message_assert("GetFullPathNameW() will crash when the file-name and buffer parameters are the same", fileName != buffer); - - return ::GetFullPathNameW(fileName, cchBuffer, buffer, ppFile); - } - - static ws_dword_t get_full_path_name(char_type const *fileName, ws_dword_t cchBuffer, char_type *buffer) - { - char_type *pFile; - - return get_full_path_name(fileName, cchBuffer, buffer, &pFile); - } - - static ws_dword_t get_short_path_name(char_type const *fileName, char_type *buffer, ws_dword_t cchBuffer) - { - return ::GetShortPathNameW(fileName, buffer, cchBuffer); - } - - // FindFile() API - static HANDLE find_first_file(char_type const *spec, find_data_type *findData) - { - return ::FindFirstFileW(spec, findData); - } - -#if _WIN32_WINNT >= 0x0400 - static HANDLE find_first_file_ex(char_type const *spec, FINDEX_SEARCH_OPS flags, find_data_type *findData) - { - return ::FindFirstFileExW(spec, FindExInfoStandard, findData, flags, NULL, 0); - } -#endif /* _WIN32_WINNT >= 0x0400 */ - - static ws_bool_t find_next_file(HANDLE h, find_data_type *findData) - { - return ::FindNextFileW(h, findData) != FALSE; - } - - // FindVolume() API -#ifndef _WINSTL_NO_FINDVOLUME_API - static HANDLE find_first_volume(char_type *volume_name, size_type cch_volume_name) - { - return ::FindFirstVolumeW(volume_name, cch_volume_name); - } - - static ws_bool_t find_next_volume(HANDLE h, char_type *volume_name, size_type cch_volume_name) - { - return ::FindNextVolumeW(h, volume_name, cch_volume_name) != FALSE; - } -#endif // !_WINSTL_NO_FINDVOLUME_API - - // Modules - static ws_dword_t get_module_filename(HINSTANCE hModule, char_type *buffer, ws_dword_t cchBuffer) - { - return ::GetModuleFileNameW(hModule, buffer, cchBuffer); - } - - static ws_uint_t get_system_directory(char_type *buffer, ws_uint_t cchBuffer) - { - return ::GetSystemDirectoryW(buffer, cchBuffer); - } - - static ws_uint_t get_windows_directory(char_type *buffer, ws_uint_t cchBuffer) - { - return ::GetWindowsDirectoryW(buffer, cchBuffer); - } - - // File system state - static ws_bool_t set_current_directory(char_type const *dir) - { - return ::SetCurrentDirectoryW(dir) != FALSE; - } - - static ws_uint_t get_current_directory(ws_uint_t cchBuffer, char_type *buffer) - { - return ::GetCurrentDirectoryW(cchBuffer, buffer); - } - - /// Returns whether a file exists or not - static ws_bool_t file_exists(char_type const *fileName) - { - return 0xFFFFFFFF != ::GetFileAttributesW(fileName); - } - - // Environment - static ws_dword_t get_environment_variable(char_type const *name, char_type *buffer, ws_uint_t cchBuffer) - { - return ::GetEnvironmentVariableW(name, buffer, cchBuffer); - } - - static size_type expand_environment_strings(char_type const *src, char_type *dest, size_type cch_dest) - { - return static_cast(::ExpandEnvironmentStringsW(src, dest, cch_dest)); - } -}; - -#endif /* __STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group winstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _WINSTL_INCL_H_WINSTL_FILESYSTEM_TRAITS */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_findfile_sequence.h b/etc/c/stlsoft/winstl_findfile_sequence.h deleted file mode 100644 index 2f2da089018..00000000000 --- a/etc/c/stlsoft/winstl_findfile_sequence.h +++ /dev/null @@ -1,901 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: winstl_findfile_sequence.h - * - * Purpose: Contains the basic_findfile_sequence template class, and ANSI - * and Unicode specialisations thereof. - * - * Notes: 1. The original implementation of the class had the const_iterator - * and value_type as nested classes. Unfortunately, Visual C++ 5 & - * 6 both had either compilation or linking problems so these are - * regretably now implemented as independent classes. - * - * 2. This class was described in detail in the article - * "Adapting Windows Enumeration Models to STL Iterator Concepts" - * (http://www.windevnet.com/documents/win0303a/), in the March - * 2003 issue of Windows Developer Network (http://windevnet.com). - * - * Created: 15th January 2002 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_FINDFILE_SEQUENCE -#define _WINSTL_INCL_H_WINSTL_FINDFILE_SEQUENCE - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _WINSTL_VER_H_WINSTL_FINDFILE_SEQUENCE_MAJOR 1 -# define _WINSTL_VER_H_WINSTL_FINDFILE_SEQUENCE_MINOR 17 -# define _WINSTL_VER_H_WINSTL_FINDFILE_SEQUENCE_REVISION 3 -# define _WINSTL_VER_H_WINSTL_FINDFILE_SEQUENCE_EDIT 80 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL -# include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ -#ifndef _WINSTL_INCL_H_WINSTL_FILESYSTEM_TRAITS -# include "winstl_filesystem_traits.h" // file_traits -#endif /* !_WINSTL_INCL_H_WINSTL_FILESYSTEM_TRAITS */ -#ifndef _WINSTL_INCL_H_WINSTL_SYSTEM_VERSION -# include "winstl_system_version.h" // winnt(), major() -#endif /* !_WINSTL_INCL_H_WINSTL_SYSTEM_VERSION */ -#ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR -# include "stlsoft_iterator.h" // iterator_base -#endif /* !_STLSOFT_INCL_H_STLSOFT_ITERATOR */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Pre-processor - * - * Definition of the - */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ -# else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_filesystem File-System Library -/// \ingroup libraries -/// \brief This library provides facilities for defining and manipulating file-system objects - -/// \weakgroup winstl_filesystem_library File-System Library (WinSTL) -/// \ingroup WinSTL libraries_filesystem -/// \brief This library provides facilities for defining and manipulating file-system objects for the Win32 API -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Forward declarations - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - -template -class basic_findfile_sequence_value_type; - -template -class basic_findfile_sequence_const_input_iterator; - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Utility classes - */ - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -struct ffs_shared_handle -{ - HANDLE hSrch; - ss_sint32_t cRefs; - -public: - ss_explicit_k ffs_shared_handle(HANDLE h) - : hSrch(h) - , cRefs(1) - {} - void Release() - { - if(--cRefs == 0) - { - delete this; - } - } -#if defined(__STLSOFT_COMPILER_IS_GCC) -protected: -#else /* ? __STLSOFT_COMPILER_IS_GCC */ -private: -#endif /* __STLSOFT_COMPILER_IS_GCC */ - ~ffs_shared_handle() - { - winstl_message_assert("Shared search handle being destroyed with outstanding references!", 0 == cRefs); - - if(hSrch != INVALID_HANDLE_VALUE) - { - ::FindClose(hSrch); - } - } -}; -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class basic_findfile_sequence -/// Presents an STL-like sequence interface over the items on the file-system -/// -/// \param C The character type -/// \param T The traits type. On translators that support default template arguments this defaults to filesystem_traits -/// -/// \note This class was described in detail in the article -/// "Adapting Windows Enumeration Models to STL Iterator Concepts" -/// (http://www.windevnet.com/documents/win0303a/), in the March 2003 issue of -/// Windows Developer Network (http://windevnet.com). -template< ss_typename_param_k C -#ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = filesystem_traits -#else - , ss_typename_param_k T /* = filesystem_traits */ -#endif /* __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > -class basic_findfile_sequence -{ -public: - /// The character type - typedef C char_type; - /// The traits type - typedef T traits_type; - /// The current parameterisation of the type - typedef basic_findfile_sequence class_type; - /// The value type - typedef basic_findfile_sequence_value_type value_type; - /// The non-mutating (const) iterator type supporting the Input Iterator concept - typedef basic_findfile_sequence_const_input_iterator const_input_iterator; - /// The non-mutating (const) iterator type - typedef const_input_iterator const_iterator; - /// The reference type - typedef value_type &reference; - /// The non-mutable (const) reference type - typedef value_type const &const_reference; - /// The find-data type - typedef ss_typename_type_k traits_type::find_data_type find_data_type; - /// The size type - typedef ws_size_t size_type; - - enum - { - includeDots = 0x0008 //!< Causes the search to include the "." and ".." directories, which are elided by default - , directories = 0x0010 //!< Causes the search to include directories - , files = 0x0020 //!< Causes the search to include files -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - , noSort = 0 /* 0x0100 */ //!< -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - , - }; - -// Construction -public: - /// Commence a search according to the given search pattern and flags - ss_explicit_k basic_findfile_sequence(char_type const *searchSpec, ws_int_t flags = directories | files); - /// Commence a search according to the given search pattern and flags, relative to \c directory - basic_findfile_sequence(char_type const *directory, char_type const *searchSpec, ws_int_t flags = directories | files); - /// Destructor - ~basic_findfile_sequence() winstl_throw_0(); - -// Iteration -public: - /// Begins the iteration - /// - /// \return An iterator representing the start of the sequence - const_iterator begin() const; - /// Ends the iteration - /// - /// \return An iterator representing the end of the sequence - const_iterator end() const; - -// Attributes -public: - /// Returns the directory of the search - /// - /// \note Will be the empty string for instances created with the first constructor - char_type const *get_directory() const; - -// State -public: - /// Returns the number of items in the sequence - size_type size() const; - /// Indicates whether the sequence is empty - ws_bool_t empty() const; - /// Returns the maximum number of items in the sequence - static size_type max_size(); - -// Members -private: - friend class basic_findfile_sequence_value_type; - friend class basic_findfile_sequence_const_input_iterator; - - char_type m_directory[_MAX_DIR + 1]; - char_type m_subpath[_MAX_PATH + 1]; - char_type m_search[_MAX_PATH + 1]; - ws_int_t m_flags; - -// Implementation -private: - static ws_int_t validate_flags_(ws_int_t flags); - static void extract_subpath_(char_type *dest, char_type const *searchSpec); - - static HANDLE find_first_file_(char_type const *spec, ws_int_t flags, find_data_type *findData); - HANDLE begin_(find_data_type &findData) const; - -// Not to be implemented -private: - basic_findfile_sequence(class_type const &); - basic_findfile_sequence const &operator =(class_type const &); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Typedefs for commonly encountered types - */ - -/// Instantiation of the basic_findfile_sequence template for the ANSI character type \c char -typedef basic_findfile_sequence > findfile_sequence_a; -/// Instantiation of the basic_findfile_sequence template for the Unicode character type \c wchar_t -typedef basic_findfile_sequence > findfile_sequence_w; -/// Instantiation of the basic_findfile_sequence template for the Win32 character type \c TCHAR -typedef basic_findfile_sequence > findfile_sequence; - -/* ////////////////////////////////////////////////////////////////////////// */ - -// class basic_findfile_sequence_value_type -/// Value type for the basic_findfile_sequence -template< ss_typename_param_k C - , ss_typename_param_k T - > -class basic_findfile_sequence_value_type -{ -public: - /// The character type - typedef C char_type; - /// The traits type - typedef T traits_type; - /// The current parameterisation of the type - typedef basic_findfile_sequence_value_type class_type; - /// The find-data type - typedef ss_typename_type_k traits_type::find_data_type find_data_type; - -public: - /// Default constructor - basic_findfile_sequence_value_type(); -private: - basic_findfile_sequence_value_type(find_data_type const &data, char_type const *path) - : m_data(data) - { - traits_type::str_copy(m_path, path); - traits_type::ensure_dir_end(m_path); - traits_type::str_cat(m_path, data.cFileName); - } -public: - /// Denstructor - ~basic_findfile_sequence_value_type() winstl_throw_0(); - - /// Copy assignment operator - class_type &operator =(class_type const &rhs); - - /// Returns a non-mutating reference to find-data - find_data_type const &get_find_data() const; - /// Returns a non-mutating reference to find-data - /// - /// \deprecated This method may be removed in a future release. get_find_data() should be used instead - find_data_type const &GetFindData() const; // Deprecated - - /// Returns the filename part of the item - char_type const *get_filename() const; - /// Returns the short form of the filename part of the item - char_type const *get_short_filename() const; - /// Returns the full path of the item - char_type const *get_path() const; - - /// Implicit conversion to a pointer-to-const of the full path - operator char_type const * () const; - -// Members -private: - friend class basic_findfile_sequence_const_input_iterator; - - find_data_type m_data; - char_type m_path[_MAX_PATH + 1]; -}; - -// class basic_findfile_sequence_const_input_iterator -/// Iterator type for the basic_findfile_sequence supporting the Input Iterator concept -template -class basic_findfile_sequence_const_input_iterator - : public stlsoft_ns_qual(iterator_base) -{ -public: - /// The character type - typedef C char_type; - /// The traits type - typedef T traits_type; - /// The value type - typedef V value_type; - /// The current parameterisation of the type - typedef basic_findfile_sequence_const_input_iterator class_type; - /// The find-data type - typedef ss_typename_type_k traits_type::find_data_type find_data_type; -private: - typedef basic_findfile_sequence sequence_type; - -private: - basic_findfile_sequence_const_input_iterator(sequence_type const &l, HANDLE hSrch, find_data_type const &data) - : m_list(&l) - , m_handle(new ffs_shared_handle(hSrch)) - , m_data(data) - {} - basic_findfile_sequence_const_input_iterator(sequence_type const &l); -public: - /// Default constructor - basic_findfile_sequence_const_input_iterator(); - /// Move constructor - basic_findfile_sequence_const_input_iterator(class_type const &rhs); - /// Denstructor - ~basic_findfile_sequence_const_input_iterator() winstl_throw_0(); - -public: - /// Pre-increment operator - class_type &operator ++(); - /// Post-increment operator - class_type operator ++(int); - /// Dereference to return the value at the current position - const value_type operator *() const; - /// Evaluates whether \c this and \c rhs are equivalent - ws_bool_t operator ==(class_type const &rhs) const; - /// Evaluates whether \c this and \c rhs are not equivalent - ws_bool_t operator !=(class_type const &rhs) const; - -// Members -private: - friend class basic_findfile_sequence; - - sequence_type const * const m_list; - ffs_shared_handle *m_handle; - ss_typename_type_k traits_type::find_data_type m_data; - -// Not to be implemented -private: - basic_findfile_sequence_const_input_iterator &operator =(class_type const &rhs); -}; - -/////////////////////////////////////////////////////////////////////////////// -// Shims - -template -inline ws_bool_t is_empty(basic_findfile_sequence const &s) -{ - return s.empty(); -} - -/////////////////////////////////////////////////////////////////////////////// -// Implementation - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION - -// basic_findfile_sequence - -template -inline /* static */ HANDLE basic_findfile_sequence::find_first_file_(ss_typename_type_k basic_findfile_sequence::char_type const *spec, ws_int_t flags, ss_typename_type_k basic_findfile_sequence::find_data_type *findData) -{ - HANDLE hSrch; - -#if _WIN32_WINNT >= 0x0400 - if( (directories == (flags & (directories | files))) && - system_version::winnt() && - system_version::major() >= 4) - { - hSrch = traits_type::find_first_file_ex(spec, FindExSearchLimitToDirectories , findData); - } - else -#else - ((void)flags); -#endif /* _WIN32_WINNT >= 0x0400 */ - { - hSrch = traits_type::find_first_file(spec, findData); - } - - return hSrch; -} - -template -inline HANDLE basic_findfile_sequence::begin_(ss_typename_type_k basic_findfile_sequence::find_data_type &findData) const -{ - HANDLE hSrch = find_first_file_(m_search, m_flags, &findData); - - if(hSrch != INVALID_HANDLE_VALUE) - { - // Now need to validate against the flags - - for(; hSrch != INVALID_HANDLE_VALUE; ) - { - if((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) - { - // A file, and files requested, so break - if(m_flags & files) - { - break; - } - } - else - { - if(traits_type::is_dots(findData.cFileName)) - { - if(m_flags & includeDots) - { - // A dots file, and dots are requested - break; - } - } - else if(m_flags & directories) - { - // A directory, and directories requested - break; - } - } - - if(!traits_type::find_next_file(hSrch, &findData)) - { - ::FindClose(hSrch); - - hSrch = INVALID_HANDLE_VALUE; - - break; - } - } - } - - return hSrch; -} - -template -inline /* static */ ws_int_t basic_findfile_sequence::validate_flags_(ws_int_t flags) -{ - return (flags & (directories | files)) == 0 ? (flags | (directories | files)) : flags; -} - -template -inline /* static */ void basic_findfile_sequence::extract_subpath_(char_type *dest, char_type const *searchSpec) -{ - char_type *pFile; - - traits_type::get_full_path_name(searchSpec, _MAX_PATH, dest, &pFile); - - if(pFile != 0) - { - *pFile = '\0'; - } -} - -// Construction -template -inline basic_findfile_sequence::basic_findfile_sequence(char_type const *searchSpec, ws_int_t flags /* = directories | files */) - : m_flags(validate_flags_(flags)) -{ - m_directory[0] = '\0'; - - traits_type::str_copy(m_search, searchSpec); - - extract_subpath_(m_subpath, searchSpec); -} - -template -inline basic_findfile_sequence::basic_findfile_sequence(char_type const *directory, char_type const * searchSpec, ws_int_t flags /* = directories | files */) - : m_flags(validate_flags_(flags)) -{ - traits_type::str_copy(m_directory, directory); - - traits_type::str_copy(m_search, directory); - traits_type::ensure_dir_end(m_search); - traits_type::str_cat(m_search, searchSpec); - - extract_subpath_(m_subpath, m_search); -} - -template -inline basic_findfile_sequence::~basic_findfile_sequence() winstl_throw_0() -{} - -// Iteration -template -inline ss_typename_type_k basic_findfile_sequence::const_iterator basic_findfile_sequence::begin() const -{ - ss_typename_type_k traits_type::find_data_type findData; - HANDLE hSrch = begin_(findData); - - if(hSrch == INVALID_HANDLE_VALUE) - { - return const_input_iterator(*this); - } - else - { - return const_input_iterator(*this, hSrch, findData); - } -} - -template -inline ss_typename_type_k basic_findfile_sequence::const_iterator basic_findfile_sequence::end() const -{ - return const_input_iterator(*this); -} - -// Attributes -template -ss_typename_type_k basic_findfile_sequence::char_type const *basic_findfile_sequence::get_directory() const -{ - return m_directory; -} - -// State -template -inline ss_typename_type_k basic_findfile_sequence::size_type basic_findfile_sequence::size() const -{ - const_input_iterator b = begin(); - const_input_iterator e = end(); - size_type c = 0; - - for(; b != e; ++b) - { - ++c; - } - - return c; -} - -template -inline ws_bool_t basic_findfile_sequence::empty() const -{ - return begin() == end(); -} - -template -inline /* static */ ss_typename_type_k basic_findfile_sequence::size_type basic_findfile_sequence::max_size() -{ - return static_cast(-1); -} - -// basic_findfile_sequence_value_type - -template -inline basic_findfile_sequence_value_type::basic_findfile_sequence_value_type() -{ - m_data.dwFileAttributes = 0xFFFFFFFF; - m_data.cFileName[0] = '\0'; - m_data.cAlternateFileName[0] = '\0'; - m_path[0] = '\0'; -} - - -template -inline basic_findfile_sequence_value_type::~basic_findfile_sequence_value_type() winstl_throw_0() -{} - -#if 0 -template -#ifdef __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED -inline basic_findfile_sequence_value_type::operator basic_findfile_sequence_value_type::char_type const *() const -#else -inline basic_findfile_sequence_value_type::operator char_type const *() const -#endif /* __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED */ -{ - return m_data.cFileName; -} -#endif /* 0 */ - -template -inline ss_typename_type_k basic_findfile_sequence_value_type::find_data_type const &basic_findfile_sequence_value_type::get_find_data() const -{ - return m_data; -} - -template -inline ss_typename_type_k basic_findfile_sequence_value_type::find_data_type const &basic_findfile_sequence_value_type::GetFindData() const -{ - return get_find_data(); -} - -template -inline ss_typename_type_k basic_findfile_sequence_value_type::char_type const *basic_findfile_sequence_value_type::get_filename() const -{ - return m_data.cFileName; -} - -template -inline ss_typename_type_k basic_findfile_sequence_value_type::char_type const *basic_findfile_sequence_value_type::get_short_filename() const -{ - return m_data.cAlternateFileName[0] != '\0' ? m_data.cAlternateFileName : m_data.cFileName; -} - -template -inline ss_typename_type_k basic_findfile_sequence_value_type::char_type const *basic_findfile_sequence_value_type::get_path() const -{ - return m_path; -} - -template -#if defined(__STLSOFT_COMPILER_IS_GCC) || \ - ( defined(__STLSOFT_COMPILER_IS_MSVC) && \ - _MSC_VER < 1100) -inline basic_findfile_sequence_value_type::operator C const * () const -#else -inline basic_findfile_sequence_value_type::operator ss_typename_type_k basic_findfile_sequence_value_type::char_type const * () const -#endif /* !__GNUC__ */ -{ - return get_path(); -} - -// operator == () -template -inline ws_bool_t operator == (basic_findfile_sequence_value_type const &lhs, basic_findfile_sequence_value_type const &rhs) -{ - return 0 == basic_findfile_sequence_value_type::traits_type::str_compare(lhs.get_path(), rhs.get_path()); -} - -template -inline ws_bool_t operator == (basic_findfile_sequence_value_type const &lhs, C const *rhs) -{ - return 0 == basic_findfile_sequence_value_type::traits_type::str_compare(lhs.get_path(), rhs); -} - -template -inline ws_bool_t operator == (C const *lhs, basic_findfile_sequence_value_type const &rhs) -{ - return 0 == basic_findfile_sequence_value_type::traits_type::str_compare(lhs, rhs.get_path()); -} - -// basic_findfile_sequence_const_input_iterator - -template -inline basic_findfile_sequence_const_input_iterator::basic_findfile_sequence_const_input_iterator() - : m_list(NULL) - , m_handle(NULL) -{} - -template -inline basic_findfile_sequence_const_input_iterator::basic_findfile_sequence_const_input_iterator(sequence_type const &l) - : m_list(&l) - , m_handle(NULL) -{} - -template -inline basic_findfile_sequence_const_input_iterator::basic_findfile_sequence_const_input_iterator(class_type const &rhs) - : m_list(rhs.m_list) - , m_handle(rhs.m_handle) - , m_data(rhs.m_data) -{ - if(NULL != m_handle) - { - ++m_handle->cRefs; - } -} - -template -inline ss_typename_type_k basic_findfile_sequence_const_input_iterator::class_type &basic_findfile_sequence_const_input_iterator::operator =(ss_typename_param_k basic_findfile_sequence_const_input_iterator::class_type const &rhs) -{ - winstl_message_assert("Assigning iterators from separate sequences", m_list == rhs.m_list); // Should only be comparing iterators from same container - - m_handle = rhs.m_handle; - m_data = rhs.m_data; - - if(NULL != m_handle) - { - ++m_handle->cRefs; - } - - return *this; -} - -template -inline basic_findfile_sequence_const_input_iterator::~basic_findfile_sequence_const_input_iterator() winstl_throw_0() -{ - if(NULL != m_handle) - { - m_handle->Release(); - } -} - -template -inline ss_typename_type_k basic_findfile_sequence_const_input_iterator::class_type &basic_findfile_sequence_const_input_iterator::operator ++() -{ - ws_int_t flags = m_list->m_flags; - - winstl_message_assert("Attempting to increment an invalid iterator!", NULL != m_handle); - - for(; m_handle->hSrch != INVALID_HANDLE_VALUE; ) - { - if(!traits_type::find_next_file(m_handle->hSrch, &m_data)) - { - m_handle->Release(); - - m_handle = NULL; - - break; - } - else - { - if((m_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) - { - // A file, and files requested, so break - if(flags & sequence_type::files) - { - break; - } - } - else - { - if(traits_type::is_dots(m_data.cFileName)) - { - if(flags & sequence_type::includeDots) - { - // A dots file, and dots are requested - break; - } - } - else if(flags & sequence_type::directories) - { - // A directory, and directories requested - break; - } - } - } - } - - return *this; -} - -template -inline ss_typename_type_k basic_findfile_sequence_const_input_iterator::class_type basic_findfile_sequence_const_input_iterator::operator ++(int) -{ - class_type ret(*this); - - operator ++(); - - return ret; -} - -template -inline const ss_typename_type_k basic_findfile_sequence_const_input_iterator::value_type basic_findfile_sequence_const_input_iterator::operator *() const -{ - if(NULL != m_handle) - { - return value_type(m_data, m_list->m_subpath); - } - else - { - winstl_message_assert("Dereferencing end()-valued iterator", 0); - - return value_type(); - } -} - -template -inline ws_bool_t basic_findfile_sequence_const_input_iterator::operator ==(class_type const &rhs) const -{ - ws_bool_t eq; - - // Should only be comparing iterators from same container - winstl_message_assert("Comparing iterators from separate sequences", m_list == rhs.m_list); - - // Not equal if one but not both handles is the INVALID_HANDLE_VALUE - // or if the data is not equal. - if( (NULL == m_handle) != (NULL == rhs.m_handle) || - ( NULL != m_handle && - traits_type::str_compare(m_data.cFileName, rhs.m_data.cFileName) != 0)) - { - eq = ws_false_v; - } - else - { - eq = ws_true_v; - } - - return eq; -} - -template -inline ws_bool_t basic_findfile_sequence_const_input_iterator::operator !=(class_type const &rhs) const -{ - return ! operator ==(rhs); -} - -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group winstl_filesystem_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _WINSTL_INCL_H_WINSTL_FINDFILE_SEQUENCE */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_spin_mutex.h b/etc/c/stlsoft/winstl_spin_mutex.h deleted file mode 100644 index b3cb5ba06f8..00000000000 --- a/etc/c/stlsoft/winstl_spin_mutex.h +++ /dev/null @@ -1,261 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: winstl_spin_mutex.h (originally MWSpinMx.h, ::SynesisWin) - * - * Purpose: Intra-process mutex, based on spin waits. - * - * Date: 27th August 1997 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_SPIN_MUTEX -#define _WINSTL_INCL_H_WINSTL_SPIN_MUTEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _WINSTL_VER_H_WINSTL_SPIN_MUTEX_MAJOR 1 -#define _WINSTL_VER_H_WINSTL_SPIN_MUTEX_MINOR 3 -#define _WINSTL_VER_H_WINSTL_SPIN_MUTEX_REVISION 3 -#define _WINSTL_VER_H_WINSTL_SPIN_MUTEX_EDIT 12 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL -# include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ -# else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class spin_mutex -/// This class provides an implementation of the mutex model based on a spinning mechanism -class spin_mutex -{ -public: - typedef spin_mutex class_type; - -// Construction -public: - /// Creates an instance of the mutex - ss_explicit_k spin_mutex(ws_sint32_t *p) winstl_throw_0() - : m_spinCount((NULL != p) ? p : &m_internalCount) - , m_internalCount(0) -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - , m_cLocks(0) -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - {} - /// Destroys an instance of the mutex - ~spin_mutex() winstl_throw_0() - { -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - stlsoft_assert(m_cLocks == 0); -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - } - -// Operations -public: - /// Acquires a lock on the mutex, pending the thread until the lock is aquired - void lock() winstl_throw_0() - { - for(; 0 != ::InterlockedExchange((LPLONG)m_spinCount, 1); ::Sleep(1)) - {} -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - stlsoft_assert(++m_cLocks != 0); -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - } - /// Releases an aquired lock on the mutex - void unlock() winstl_throw_0() - { -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - stlsoft_assert(m_cLocks-- != 0); -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - ::InterlockedExchange((LPLONG)m_spinCount, 0); - } - -// Members -private: - ws_sint32_t *m_spinCount; - ws_sint32_t m_internalCount; -#ifdef STLSOFT_SPINMUTEX_COUNT_LOCKS - ws_sint32_t m_cLocks; // Used as check on matched Lock/Unlock calls -#endif // STLSOFT_SPINMUTEX_COUNT_LOCKS - -// Not to be implemented -private: - spin_mutex(class_type const &rhs); - spin_mutex &operator =(class_type const &rhs); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Control shims - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_sync_control Synchronisation Control Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects - -/// \defgroup winstl_sync_control_shims Synchronisation Control Shims (WinSTL) -/// \ingroup WinSTL concepts_shims_sync_control -/// \brief These \ref concepts_shims "shims" control the behaviour of Win32 synchronisation objects -/// @{ - -/// This control ref concepts_shims "shim" aquires a lock on the given mutex -/// -/// \param mx The mutex on which to aquire the lock -inline void lock_instance(winstl_ns_qual(spin_mutex) &mx) -{ - mx.lock(); -} - -/// This control ref concepts_shims "shim" releases a lock on the given mutex -/// -/// \param mx The mutex on which to release the lock -inline void unlock_instance(winstl_ns_qual(spin_mutex) &mx) -{ - mx.unlock(); -} - -/// @} // end of group winstl_sync_control_shims - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -namespace winstl { -# else -namespace winstl_project { -# if defined(__STLSOFT_COMPILER_IS_BORLAND) -using ::stlsoft::lock_instance; -using ::stlsoft::unlock_instance; -# endif /* __STLSOFT_COMPILER_IS_BORLAND */ -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * lock_traits (for the compilers that do not support Koenig Lookup) - */ - -// class lock_traits -/// Traits for the spin_mutex class (for compilers that do not support Koenig Lookup) -struct spin_mutex_lock_traits -{ -public: - /// The lockable type - typedef spin_mutex lock_type; - typedef spin_mutex_lock_traits class_type; - -// Operations -public: - /// Lock the given spin_mutex instance - static void lock(spin_mutex &c) - { - lock_instance(c); - } - - /// Unlock the given spin_mutex instance - static void unlock(spin_mutex &c) - { - unlock_instance(c); - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_WINSTL_INCL_H_WINSTL_SPIN_MUTEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_system_version.h b/etc/c/stlsoft/winstl_system_version.h deleted file mode 100644 index 50058bd5853..00000000000 --- a/etc/c/stlsoft/winstl_system_version.h +++ /dev/null @@ -1,222 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: winstl_system_version.h - * - * Purpose: Contains the basic_system_version class, which provides - * information about the host system version. - * - * Created: 10th February 2002 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_SYSTEM_VERSION -#define _WINSTL_INCL_H_WINSTL_SYSTEM_VERSION - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _WINSTL_VER_H_WINSTL_SYSTEM_VERSION_MAJOR 1 -# define _WINSTL_VER_H_WINSTL_SYSTEM_VERSION_MINOR 5 -# define _WINSTL_VER_H_WINSTL_SYSTEM_VERSION_REVISION 2 -# define _WINSTL_VER_H_WINSTL_SYSTEM_VERSION_EDIT 22 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL - #include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE - #ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ - #else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - - #endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_system System Library -/// \ingroup libraries -/// \brief This library provides facilities for accessing system attributes - -/// \defgroup winstl_system_library System Library (WinSTL) -/// \ingroup WinSTL libraries_system -/// \brief This library provides facilities for accessing Win32 system attributes -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -/// Provides system version information -/// -/// This class wraps the GetSystemInfo() API function. Since the information that -/// this function provides is constant for any particular active system for its -/// lifetime, the function is called only once, as implemented via the -/// _get_versioninfo() method. -class system_version -{ -public: - typedef system_version class_type; - -// Operations -public: - - // Operating system type - - /// Returns \c true if the operating system is one of the NT family (NT, 2000, XP, .NET) - static ws_bool_t winnt() - { - return _get_versioninfo().dwPlatformId == VER_PLATFORM_WIN32_NT; - } - - /// Returns \c true if the operating system is one of the 95 family (95, 98, ME) - static ws_bool_t win9x() - { - return _get_versioninfo().dwPlatformId == VER_PLATFORM_WIN32_WINDOWS; - } - - /// Returns \c true if the operating system is Win32s - static ws_bool_t win32s() - { - return _get_versioninfo().dwPlatformId == VER_PLATFORM_WIN32s; - } - - // Operating system version - - /// Returns the operating system major version - static ws_uint_t major() - { - return _get_versioninfo().dwMajorVersion; - } - - /// Returns the operating system minor version - static ws_uint_t minor() - { - return _get_versioninfo().dwMinorVersion; - } - - // Build number - - /// Returns the operating system build number - static ws_uint32_t build_number() - { - return winnt() ? _get_versioninfo().dwBuildNumber : LOWORD(_get_versioninfo().dwBuildNumber); - } - - // Structure access - - /// Provides a non-mutable (const) reference to the \c OSVERSIONINFO instance - static const OSVERSIONINFO &get_versioninfo() - { - return _get_versioninfo(); - } - -// Implementation -private: - /// Unfortunately, something in this technique scares the Borland compilers (5.5 - /// and 5.51) into Internal compiler errors so the s_init variable in - /// _get_versioninfo() is int rather than bool when compiling for borland. - static OSVERSIONINFO &_get_versioninfo() - { - static OSVERSIONINFO s_versioninfo; -#ifdef __STLSOFT_COMPILER_IS_BORLAND - /* WSCB: Borland has an internal compiler error if use ws_bool_t */ - static ws_int_t s_init = (s_versioninfo.dwOSVersionInfoSize = sizeof(s_versioninfo), ::GetVersionEx(&s_versioninfo), ws_true_v); -#else - static ws_bool_t s_init = (s_versioninfo.dwOSVersionInfoSize = sizeof(s_versioninfo), ::GetVersionEx(&s_versioninfo), ws_true_v); -#endif /* __STLSOFT_COMPILER_IS_BORLAND */ - - STLSOFT_SUPPRESS_UNUSED(s_init); // Placate GCC - - return s_versioninfo; - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group winstl_system_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE - #ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl - #else -} // namespace winstl_project -} // namespace stlsoft - #endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _WINSTL_INCL_H_WINSTL_SYSTEM_VERSION */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_thread_mutex.h b/etc/c/stlsoft/winstl_thread_mutex.h deleted file mode 100644 index 21444b0d01a..00000000000 --- a/etc/c/stlsoft/winstl_thread_mutex.h +++ /dev/null @@ -1,299 +0,0 @@ -/* //////////////////////////////////////////////////////////////////////////// - * File: winstl_thread_mutex.h (originally MWCrtSct.h, ::SynesisWin) - * - * Purpose: Intra-process mutex, based on Windows CRITICAL_SECTION. - * - * Date: 17th December 1996 - * Updated: 24th November 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_THREAD_MUTEX -#define _WINSTL_INCL_H_WINSTL_THREAD_MUTEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -#define _WINSTL_VER_H_WINSTL_THREAD_MUTEX_MAJOR 1 -#define _WINSTL_VER_H_WINSTL_THREAD_MUTEX_MINOR 3 -#define _WINSTL_VER_H_WINSTL_THREAD_MUTEX_REVISION 4 -#define _WINSTL_VER_H_WINSTL_THREAD_MUTEX_EDIT 14 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL -# include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ -# else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Spin-count support - */ - -#ifdef __WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT -# undef __WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT -#endif /* __WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT */ - -#ifdef __WINSTL_THREAD_MUTEX_TRY_LOCK_SUPPORT -# undef __WINSTL_THREAD_MUTEX_TRY_LOCK_SUPPORT -#endif /* __WINSTL_THREAD_MUTEX_TRY_LOCK_SUPPORT */ - -#if defined(_WIN32_WINNT) && \ - _WIN32_WINNT >= 0x0403 -# define __WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT -#endif /* _WIN32_WINNT >= 0x0403 */ - -#if defined(_WIN32_WINNT) && \ - _WIN32_WINNT >= 0x0400 -# define __WINSTL_THREAD_MUTEX_TRY_LOCK_SUPPORT -#endif /* _WIN32_WINNT >= 0x0400 */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -// class thread_mutex -/// This class provides an implementation of the mutex model based on the Win32 CRITICAL_SECTION -class thread_mutex -{ -public: - typedef thread_mutex class_type; - -// Construction -public: - /// Creates an instance of the mutex - thread_mutex() winstl_throw_0() - { - ::InitializeCriticalSection(&m_cs); - } -#if defined(__WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT) - /// Creates an instance of the mutex and sets its spin count - /// - /// \param spinCount The new spin count for the mutex - /// \note Only available with Windows NT 4 SP3 and later - thread_mutex(ws_dword_t spinCount) winstl_throw_0() - { - ::InitializeCriticalSectionAndSpinCount(&m_cs, spinCount); - } -#endif /* __WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT */ - /// Destroys an instance of the mutex - ~thread_mutex() winstl_throw_0() - { - ::DeleteCriticalSection(&m_cs); - } - -// Operations -public: - /// Acquires a lock on the mutex, pending the thread until the lock is aquired - void lock() winstl_throw_0() - { - ::EnterCriticalSection(&m_cs); - } -#if defined(__WINSTL_THREAD_MUTEX_TRY_LOCK_SUPPORT) - /// Attempts to lock the mutex - /// - /// \return true if the mutex was aquired, or false if not - /// \note Only available with Windows NT 4 and later - bool try_lock() - { - return ::TryEnterCriticalSection(&m_cs) != FALSE; - } -#endif /* __WINSTL_THREAD_MUTEX_TRY_LOCK_SUPPORT */ - /// Releases an aquired lock on the mutex - void unlock() winstl_throw_0() - { - ::LeaveCriticalSection(&m_cs); - } - -#if defined(__WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT) - /// Sets the spin count for the mutex - /// - /// \param spinCount The new spin count for the mutex - /// \return The previous spin count associated with the mutex - /// \note Only available with Windows NT 4 SP3 and later - ws_dword_t set_spin_count(ws_dword_t spinCount) winstl_throw_0() - { - return ::SetCriticalSectionSpinCount(&m_cs, spinCount); - } -#endif /* __WINSTL_THREAD_MUTEX_SPIN_COUNT_SUPPORT */ - -// Members -private: - CRITICAL_SECTION m_cs; // critical section - -// Not to be implemented -private: - thread_mutex(class_type const &rhs); - thread_mutex &operator =(class_type const &rhs); -}; - -/* ///////////////////////////////////////////////////////////////////////////// - * Control shims - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/// \weakgroup concepts STLSoft Concepts - -/// \weakgroup concepts_shims Shims -/// \ingroup concepts - -/// \weakgroup concepts_shims_sync_control Synchronisation Control Shims -/// \ingroup concepts_shims -/// \brief These \ref concepts_shims "shims" control the behaviour of synchronisation objects - -/// \defgroup winstl_sync_control_shims Synchronisation Control Shims (WinSTL) -/// \ingroup WinSTL concepts_shims_sync_control -/// \brief These \ref concepts_shims "shims" control the behaviour of Win32 synchronisation objects -/// @{ - -/// This control ref concepts_shims "shim" aquires a lock on the given mutex -/// -/// \param mx The mutex on which to aquire the lock -inline void lock_instance(winstl_ns_qual(thread_mutex) &mx) -{ - mx.lock(); -} - -/// This control ref concepts_shims "shim" releases a lock on the given mutex -/// -/// \param mx The mutex on which to release the lock -inline void unlock_instance(winstl_ns_qual(thread_mutex) &mx) -{ - mx.unlock(); -} - -/// @} // end of group winstl_sync_control_shims - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -namespace winstl { -# else -namespace winstl_project { -# if defined(__STLSOFT_COMPILER_IS_BORLAND) -using ::stlsoft::lock_instance; -using ::stlsoft::unlock_instance; -# endif /* __STLSOFT_COMPILER_IS_BORLAND */ -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ///////////////////////////////////////////////////////////////////////////// - * lock_traits (for the compilers that do not support Koenig Lookup) - */ - -// class lock_traits -/// Traits for the thread_mutex class (for compilers that do not support Koenig Lookup) -struct thread_mutex_lock_traits -{ -public: - /// The lockable type - typedef thread_mutex lock_type; - typedef thread_mutex_lock_traits class_type; - -// Operations -public: - /// Lock the given thread_mutex instance - static void lock(thread_mutex &c) - { - lock_instance(c); - } - - /// Unlock the given thread_mutex instance - static void unlock(thread_mutex &c) - { - unlock_instance(c); - } -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* !_WINSTL_INCL_H_WINSTL_THREAD_MUTEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/etc/c/stlsoft/winstl_tls_index.h b/etc/c/stlsoft/winstl_tls_index.h deleted file mode 100644 index 332c7114b75..00000000000 --- a/etc/c/stlsoft/winstl_tls_index.h +++ /dev/null @@ -1,185 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: winstl_tls_index.h (formerly in MWTlsFns.h, ::SynesisWin) - * - * Purpose: Win32 TLS slot index. - * - * Created: 20th January 1999 - * Updated: 24th September 2003 - * - * Author: Matthew Wilson, Synesis Software Pty Ltd. - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.synesis.com.au/winstl - * http://www.winstl.org/ - * - * email: submissions@winstl.org for submissions - * admin@winstl.org for other enquiries - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - -#ifndef _WINSTL_INCL_H_WINSTL_TLS_INDEX -#define _WINSTL_INCL_H_WINSTL_TLS_INDEX - -#ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION -# define _WINSTL_VER_H_WINSTL_TLS_INDEX_MAJOR 1 -# define _WINSTL_VER_H_WINSTL_TLS_INDEX_MINOR 0 -# define _WINSTL_VER_H_WINSTL_TLS_INDEX_REVISION 1 -# define _WINSTL_VER_H_WINSTL_TLS_INDEX_EDIT 2 -#endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Includes - */ - -#ifndef _WINSTL_INCL_H_WINSTL -# include "winstl.h" // Include the WinSTL root header -#endif /* !_WINSTL_INCL_H_WINSTL */ - -/* ///////////////////////////////////////////////////////////////////////////// - * Namespace - */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -/* There is no stlsoft namespace, so must define ::winstl */ -namespace winstl -{ - #else -/* Define stlsoft::winstl_project */ - -namespace stlsoft -{ - -namespace winstl_project -{ - -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// \weakgroup libraries STLSoft Libraries -/// \brief The individual libraries - -/// \weakgroup libraries_system System Library -/// \ingroup libraries -/// \brief This library provides facilities for accessing system attributes - -/// \defgroup winstl_system_library System Library (WinSTL) -/// \ingroup WinSTL libraries_system -/// \brief This library provides facilities for accessing Win32 system attributes -/// @{ - -/* ///////////////////////////////////////////////////////////////////////////// - * Classes - */ - -/// A TLS index -/// -/// -class tls_index -{ -public: - typedef tls_index class_type; - -/// Operations -/// @{ -public: - ss_explicit_k tls_index() stlsoft_throw_0() - : m_dwIndex(::TlsAlloc()) - { - if(0xFFFFFFFF == m_dwIndex) - { - ::RaiseException(STATUS_NO_MEMORY, EXCEPTION_NONCONTINUABLE, 0, 0); - } - } - ~tls_index() stlsoft_throw_0() - { - if(0xFFFFFFFF != m_dwIndex) - { - ::TlsFree(m_dwIndex); - } - } - -/// @} - -/// Operations -/// @{ -public: - operator ws_dword_t () const - { - return m_dwIndex; - } - -/// @} - -// Members -private: - ws_dword_t m_dwIndex; - -// Not to be implemented -private: - tls_index(tls_index const &); - tls_index &operator =(tls_index const &); -}; - -/* ////////////////////////////////////////////////////////////////////////// */ - -/// @} // end of group winstl_system_library - -/* ////////////////////////////////////////////////////////////////////////// */ - -#ifndef _WINSTL_NO_NAMESPACE -# ifdef _STLSOFT_NO_NAMESPACE -} // namespace winstl -# else -} // namespace winstl_project -} // namespace stlsoft -# endif /* _STLSOFT_NO_NAMESPACE */ -#endif /* !_WINSTL_NO_NAMESPACE */ - -/* ////////////////////////////////////////////////////////////////////////// */ - -#endif /* _WINSTL_INCL_H_WINSTL_TLS_INDEX */ - -/* ////////////////////////////////////////////////////////////////////////// */ diff --git a/internal/adi.d b/internal/adi.d index 563e8f12798..7baa6a47d46 100644 --- a/internal/adi.d +++ b/internal/adi.d @@ -1,7 +1,7 @@ //_ adi.d /* - * Copyright (C) 2000-2005 by Digital Mars, www.digitalmars.com + * Copyright (C) 2000-2006 by Digital Mars, www.digitalmars.com * Written by Walter Bright * * This software is provided 'as-is', without any express or implied @@ -37,8 +37,8 @@ import std.outofmemory; struct Array { - int length; - void *ptr; + size_t length; + void* ptr; } /********************************************** @@ -56,8 +56,8 @@ extern (C) long _adReverseChar(char[] a) char* hi = &a[length - 1]; while (lo < hi) - { char clo = *lo; - char chi = *hi; + { auto clo = *lo; + auto chi = *hi; //printf("lo = %d, hi = %d\n", lo, hi); if (clo <= 0x7F && chi <= 0x7F) @@ -147,8 +147,8 @@ extern (C) long _adReverseWchar(wchar[] a) wchar* hi = &a[length - 1]; while (lo < hi) - { wchar clo = *lo; - wchar chi = *hi; + { auto clo = *lo; + auto chi = *hi; if ((clo < 0xD800 || clo > 0xDFFF) && (chi < 0xD800 || chi > 0xDFFF)) @@ -230,7 +230,7 @@ extern (C) long _adReverse(Array a, int szelem) { if (a.length >= 2) { - byte *tmp; + byte* tmp; byte[16] buffer; void* lo = a.ptr; @@ -416,9 +416,8 @@ extern (C) long _adDup(Array a, int szelem) body { Array r; - int size; - size = a.length * szelem; + auto size = a.length * szelem; r.ptr = cast(void *) new byte[size]; r.length = a.length; memcpy(r.ptr, a.ptr, size); @@ -453,9 +452,8 @@ extern (C) long _adDupBit(Array a) body { Array r; - int size; - size = (a.length + 31) / 32; + auto size = (a.length + 31) / 32; r.ptr = cast(void *) new uint[size]; r.length = a.length; memcpy(r.ptr, a.ptr, size * uint.sizeof); @@ -490,10 +488,10 @@ extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) //printf("a1.length = %d, a2.length = %d\n", a1.length, a2.length); if (a1.length != a2.length) return 0; // not equal - int sz = ti.tsize(); + auto sz = ti.tsize(); //printf("sz = %d\n", sz); - void *p1 = a1.ptr; - void *p2 = a2.ptr; + auto p1 = a1.ptr; + auto p2 = a2.ptr; /+ for (int i = 0; i < a1.length; i++) @@ -502,7 +500,11 @@ extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) } +/ - for (int i = 0; i < a1.length; i++) + if (sz == 1) + // We should really have a ti.isPOD() check for this + return (memcmp(p1, p2, a1.length) == 0); + + for (size_t i = 0; i < a1.length; i++) { if (!ti.equals(p1 + i * sz, p2 + i * sz)) return 0; // not equal @@ -528,13 +530,13 @@ unittest */ extern (C) int _adEqBit(Array a1, Array a2) -{ int i; +{ size_t i; if (a1.length != a2.length) return 0; // not equal - byte *p1 = cast(byte*)a1.ptr; - byte *p2 = cast(byte*)a2.ptr; - uint n = a1.length / 8; + auto p1 = cast(byte*)a1.ptr; + auto p2 = cast(byte*)a2.ptr; + auto n = a1.length / 8; for (i = 0; i < n; i++) { if (p1[i] != p2[i]) @@ -571,24 +573,32 @@ unittest extern (C) int _adCmp(Array a1, Array a2, TypeInfo ti) { - int len; - //printf("adCmp()\n"); - len = a1.length; + auto len = a1.length; if (a2.length < len) len = a2.length; - int sz = ti.tsize(); + auto sz = ti.tsize(); void *p1 = a1.ptr; void *p2 = a2.ptr; - for (int i = 0; i < len; i++) - { - int c; - c = ti.compare(p1 + i * sz, p2 + i * sz); + if (sz == 1) + { // We should really have a ti.isPOD() check for this + auto c = memcmp(p1, p2, len); if (c) return c; } - return cast(int)a1.length - cast(int)a2.length; + else + { + for (size_t i = 0; i < len; i++) + { + auto c = ti.compare(p1 + i * sz, p2 + i * sz); + if (c) + return c; + } + } + if (a1.length == a2.length) + return 0; + return (a1.length > a2.length) ? 1 : -1; } unittest diff --git a/internal/gc/gc.d b/internal/gc/gc.d index a97a5b5c04c..f7385bde4e4 100644 --- a/internal/gc/gc.d +++ b/internal/gc/gc.d @@ -565,7 +565,14 @@ size_t newCapacity(size_t newlength, size_t size) return i; } - long mult = 100 + (1000L * size) / (6 * log2plus1(newcap)); + /* The following setting for mult sets how much bigger + * the new size will be over what is actually needed. + * 100 means the same size, more means proportionally more. + * More means faster but more memory consumption. + */ + //long mult = 100 + (1000L * size) / (6 * log2plus1(newcap)); + long mult = 100 + (1000L * size) / log2plus1(newcap); + // testing shows 1.02 for large arrays is about the point of diminishing return if (mult < 102) mult = 102; diff --git a/linux.mak b/linux.mak index da798fab11d..414e39c3611 100644 --- a/linux.mak +++ b/linux.mak @@ -69,7 +69,7 @@ OBJS= asserterror.o deh2.o switch.o complex.o gcstats.o \ ti_Afloat.o ti_Adouble.o ti_Areal.o \ ti_Acfloat.o ti_Acdouble.o ti_Acreal.o \ ti_void.o \ - date.o dateparse.o llmath.o math2.o Czlib.o Dzlib.o zip.o recls.o + date.o dateparse.o llmath.o math2.o Czlib.o Dzlib.o zip.o ZLIB_OBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \ etc/c/zlib/crc32.o etc/c/zlib/gzio.o \ @@ -78,14 +78,6 @@ ZLIB_OBJS= etc/c/zlib/adler32.o etc/c/zlib/compress.o \ etc/c/zlib/inflate.o etc/c/zlib/infback.o \ etc/c/zlib/inftrees.o etc/c/zlib/inffast.o -RECLS_OBJS= etc/c/recls/recls_api.o \ - etc/c/recls/recls_fileinfo.o \ - etc/c/recls/recls_internal.o \ - etc/c/recls/recls_util.o \ - etc/c/recls/recls_api_unix.o \ - etc/c/recls/recls_fileinfo_unix.o \ - etc/c/recls/recls_util_unix.o - GC_OBJS= internal/gc/gc.o internal/gc/gcx.o \ internal/gc/gcbits.o internal/gc/gclinux.o @@ -97,7 +89,7 @@ SRC_STD= std/zlib.d std/zip.d std/stdint.d std/conv.d std/utf.d std/uri.d \ std/outbuffer.d std/math2.d std/thread.d std/md5.d std/base64.d \ std/asserterror.d std/dateparse.d std/outofmemory.d std/mmfile.d \ std/intrinsic.d std/array.d std/switcherr.d std/syserror.d \ - std/regexp.d std/random.d std/stream.d std/process.d std/recls.d \ + std/regexp.d std/random.d std/stream.d std/process.d \ std/socket.d std/socketstream.d std/loader.d std/stdarg.d \ std/stdio.d std/format.d std/perf.d std/openrj.d std/uni.d \ std/boxer.d std/cstream.d std/demangle.d std/cover.d std/bitarray.d @@ -195,171 +187,14 @@ SRC_GC= internal/gc/gc.d \ internal/gc/win32.mak \ internal/gc/linux.mak -SRC_STLSOFT= \ - etc/c/stlsoft/stlsoft_null_mutex.h \ - etc/c/stlsoft/unixstl_string_access.h \ - etc/c/stlsoft/unixstl.h \ - etc/c/stlsoft/winstl_tls_index.h \ - etc/c/stlsoft/unixstl_environment_variable.h \ - etc/c/stlsoft/unixstl_functionals.h \ - etc/c/stlsoft/unixstl_current_directory.h \ - etc/c/stlsoft/unixstl_limits.h \ - etc/c/stlsoft/unixstl_current_directory_scope.h \ - etc/c/stlsoft/unixstl_filesystem_traits.h \ - etc/c/stlsoft/unixstl_findfile_sequence.h \ - etc/c/stlsoft/unixstl_glob_sequence.h \ - etc/c/stlsoft/winstl.h \ - etc/c/stlsoft/winstl_atomic_functions.h \ - etc/c/stlsoft/stlsoft_cccap_gcc.h \ - etc/c/stlsoft/stlsoft_lock_scope.h \ - etc/c/stlsoft/unixstl_thread_mutex.h \ - etc/c/stlsoft/unixstl_spin_mutex.h \ - etc/c/stlsoft/unixstl_process_mutex.h \ - etc/c/stlsoft/stlsoft_null.h \ - etc/c/stlsoft/stlsoft_nulldef.h \ - etc/c/stlsoft/winstl_thread_mutex.h \ - etc/c/stlsoft/winstl_spin_mutex.h \ - etc/c/stlsoft/winstl_system_version.h \ - etc/c/stlsoft/winstl_findfile_sequence.h \ - etc/c/stlsoft/unixstl_readdir_sequence.h \ - etc/c/stlsoft/stlsoft.h \ - etc/c/stlsoft/stlsoft_static_initialisers.h \ - etc/c/stlsoft/stlsoft_iterator.h \ - etc/c/stlsoft/stlsoft_cccap_dmc.h \ - etc/c/stlsoft/winstl_filesystem_traits.h - -SRC_RECLS= \ - etc/c/recls/recls_compiler.h \ - etc/c/recls/recls_language.h \ - etc/c/recls/recls_unix.h \ - etc/c/recls/recls_retcodes.h \ - etc/c/recls/recls_assert.h \ - etc/c/recls/recls_platform.h \ - etc/c/recls/recls_win32.h \ - etc/c/recls/recls.h \ - etc/c/recls/recls_util.h \ - etc/c/recls/recls_compiler_dmc.h \ - etc/c/recls/recls_compiler_gcc.h \ - etc/c/recls/recls_platform_types.h \ - etc/c/recls/recls_internal.h \ - etc/c/recls/recls_debug.h \ - etc/c/recls/recls_fileinfo_win32.cpp \ - etc/c/recls/recls_api_unix.cpp \ - etc/c/recls/recls_api.cpp \ - etc/c/recls/recls_util_win32.cpp \ - etc/c/recls/recls_util_unix.cpp \ - etc/c/recls/recls_util.cpp \ - etc/c/recls/recls_internal.cpp \ - etc/c/recls/recls_fileinfo.cpp \ - etc/c/recls/recls_defs.h \ - etc/c/recls/recls_fileinfo_unix.cpp \ - etc/c/recls/recls_api_win32.cpp \ - etc/c/recls/win32.mak \ - etc/c/recls/linux.mak \ - etc/c/recls/recls.lib - -SRC_STLSOFT_NEW= \ - etc/c/stlsoft/winstl_file_path_buffer.h \ - etc/c/stlsoft/inetstl_connection.h \ - etc/c/stlsoft/inetstl_filesystem_traits.h \ - etc/c/stlsoft/inetstl_findfile_sequence.h \ - etc/c/stlsoft/inetstl_searchspec_sequence.h \ - etc/c/stlsoft/inetstl_session.h \ - etc/c/stlsoft/stlsoft.h \ - etc/c/stlsoft/stlsoft_allocator_base.h \ - etc/c/stlsoft/inetstl.h \ - etc/c/stlsoft/stlsoft_auto_buffer.h \ - etc/c/stlsoft/stlsoft_cccap_dmc.h \ - etc/c/stlsoft/stlsoft_cccap_gcc.h \ - etc/c/stlsoft/stlsoft_char_traits.h \ - etc/c/stlsoft/stlsoft_constraints.h \ - etc/c/stlsoft/stlsoft_exceptions.h \ - etc/c/stlsoft/stlsoft_iterator.h \ - etc/c/stlsoft/stlsoft_meta.h \ - etc/c/stlsoft/stlsoft_new_allocator.h \ - etc/c/stlsoft/stlsoft_any_caster.h \ - etc/c/stlsoft/stlsoft_nulldef.h \ - etc/c/stlsoft/stlsoft_sap_cast.h \ - etc/c/stlsoft/stlsoft_searchspec_sequence.h \ - etc/c/stlsoft/stlsoft_sign_traits.h \ - etc/c/stlsoft/stlsoft_simple_algorithms.h \ - etc/c/stlsoft/stlsoft_simple_string.h \ - etc/c/stlsoft/stlsoft_size_traits.h \ - etc/c/stlsoft/stlsoft_string_access.h \ - etc/c/stlsoft/stlsoft_string_tokeniser.h \ - etc/c/stlsoft/stlsoft_type_traits.h \ - etc/c/stlsoft/unixstl.h \ - etc/c/stlsoft/unixstl_filesystem_traits.h \ - etc/c/stlsoft/unixstl_file_path_buffer.h \ - etc/c/stlsoft/unixstl_glob_sequence.h \ - etc/c/stlsoft/unixstl_string_access.h \ - etc/c/stlsoft/unixstl_thread_mutex.h \ - etc/c/stlsoft/winstl.h \ - etc/c/stlsoft/winstl_atomic_functions.h \ - etc/c/stlsoft/winstl_char_conversions.h \ - etc/c/stlsoft/winstl_filesystem_traits.h \ - etc/c/stlsoft/winstl_spin_mutex.h \ - etc/c/stlsoft/winstl_findfile_sequence.h \ - etc/c/stlsoft/winstl_processheap_allocator.h \ - etc/c/stlsoft/winstl_system_version.h \ - etc/c/stlsoft/stlsoft_null.h - -SRC_RECLS_NEW= \ - etc/c/recls/recls_compiler_gcc.h \ - etc/c/recls/recls_retcodes.h \ - etc/c/recls/EntryFunctions.h \ - etc/c/recls/recls_platform_types.h \ - etc/c/recls/recls.h \ - etc/c/recls/recls_wininet_dl.h \ - etc/c/recls/ReclsFileSearch.h \ - etc/c/recls/ReclsFileSearchDirectoryNode_unix.cpp \ - etc/c/recls/ReclsFileSearchDirectoryNode_unix.h \ - etc/c/recls/ReclsFileSearchDirectoryNode_win32.cpp \ - etc/c/recls/ReclsFileSearchDirectoryNode_win32.h \ - etc/c/recls/recls_wininet_dl.cpp \ - etc/c/recls/ReclsFileSearch_unix.cpp \ - etc/c/recls/ReclsFileSearch_win32.cpp \ - etc/c/recls/recls_win32.h \ - etc/c/recls/ReclsFtpSearch.h \ - etc/c/recls/ReclsFtpSearchDirectoryNode_win32.cpp \ - etc/c/recls/ReclsFtpSearchDirectoryNode_win32.h \ - etc/c/recls/recls_util_win32.cpp \ - etc/c/recls/ReclsFtpSearch_win32.cpp \ - etc/c/recls/recls_util_unix.cpp \ - etc/c/recls/recls_api.cpp \ - etc/c/recls/recls_util.h \ - etc/c/recls/recls_api_unix.cpp \ - etc/c/recls/recls_api_win32.cpp \ - etc/c/recls/recls_util.cpp \ - etc/c/recls/recls_assert.h \ - etc/c/recls/recls_compiler.h \ - etc/c/recls/recls_compiler_dmc.h \ - etc/c/recls/recls_platform.h \ - etc/c/recls/recls_debug.h \ - etc/c/recls/recls_defs.h \ - etc/c/recls/recls_fileinfo.cpp \ - etc/c/recls/recls_fileinfo_unix.cpp \ - etc/c/recls/recls_fileinfo_win32.cpp \ - etc/c/recls/recls_unix.h \ - etc/c/recls/recls_ftp.h \ - etc/c/recls/recls_ftp_api_win32.cpp \ - etc/c/recls/recls_internal.cpp \ - etc/c/recls/recls_internal.h \ - etc/c/recls/recls_roots_win32.cpp \ - etc/c/recls/recls_language.h \ - etc/c/recls/recls_roots_unix.cpp \ - etc/c/recls/win32.mak \ - etc/c/recls/linux.mak - ALLSRCS = $(SRC) $(SRC_STD) $(SRC_STD_C) $(SRC_TI) $(SRC_INT) $(SRC_STD_WIN) \ $(SRC_STD_C_WIN) $(SRC_STD_C_LINUX) $(SRC_ETC) $(SRC_ETC_C) \ - $(SRC_ZLIB) $(SRC_GC) \ - $(SRC_RECLS) $(SRC_STLSOFT) + $(SRC_ZLIB) $(SRC_GC) #libphobos.a : $(OBJS) internal/gc/dmgc.a linux.mak -libphobos.a : $(OBJS) internal/gc/dmgc.a $(ZLIB_OBJS) $(RECLS_OBJS) linux.mak - ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS) $(RECLS_OBJS) +libphobos.a : $(OBJS) internal/gc/dmgc.a $(ZLIB_OBJS) linux.mak + ar -r $@ $(OBJS) $(ZLIB_OBJS) $(GC_OBJS) ########################################################### @@ -369,12 +204,6 @@ internal/gc/dmgc.a: # cd ../.. make -C ./internal/gc -f linux.mak dmgc.a -$(RECLS_OBJS): -# cd etc/c/recls -# make -f linux.mak -# cd ../../.. - make -C ./etc/c/recls -f linux.mak - $(ZLIB_OBJS): # cd etc/c/zlib # make -f linux.mak @@ -548,9 +377,6 @@ process.o : std/process.d random.o : std/random.d $(DMD) -c $(DFLAGS) std/random.d -recls.o : std/recls.d - $(DMD) -c $(DFLAGS) std/recls.d - regexp.o : std/regexp.d $(DMD) -c $(DFLAGS) std/regexp.d diff --git a/std.ddoc b/std.ddoc index 72e5077f910..1dbc58d7aae 100644 --- a/std.ddoc +++ b/std.ddoc @@ -68,7 +68,6 @@ DDOC = std.path
 std.process
 std.random
std.recls
 std.regexp
 std.socket
 std.socketstream
diff --git a/std/boxer.d b/std/boxer.d index b3493fd040c..636008be1d6 100644 --- a/std/boxer.d +++ b/std/boxer.d @@ -1,11 +1,69 @@ -/* This module is written by Burton Radons and placed into the public domain. */ +/** + * This module is a set of types and functions for converting any object (value + * or heap) into a generic box type, allowing the user to pass that object + * around without knowing what's in the box, and then allowing him to recover + * the value afterwards. + * + * Example: +--- +// Convert the integer 45 into a box. +Box b = box(45); + +// Recover the integer and cast it to real. +real r = unbox!(real)(b); +--- + * + * That is the basic interface and will usually be all that you need to + * understand. If it cannot unbox the object to the given type, it throws + * UnboxException. As demonstrated, it uses implicit casts to behave in the exact + * same way that static types behave. So for example, you can unbox from int to + * real, but you cannot unbox from real to int: that would require an explicit + * cast. + * + * This therefore means that attempting to unbox an int as a string will throw + * an error instead of formatting it. In general, you can call the toString method + * on the box and receive a good result, depending upon whether std.string.format + * accepts it. + * + * Boxes can be compared to one another and they can be used as keys for + * associative arrays. + * + * There are also functions for converting to and from arrays of boxes. + * + * Example: +--- +// Convert arguments into an array of boxes. +Box[] a = boxArray(1, 45.4, "foobar"); + +// Convert an array of boxes back into arguments. +TypeInfo[] arg_types; +void* arg_data; + +boxArrayToArguments(a, arg_types, arg_data); + +// Convert the arguments back into boxes using a +// different form of the function. +a = boxArray(arg_types, arg_data); +--- + * One use of this is to support a variadic function more easily and robustly; + * simply call "boxArray(_arguments, _argptr)", then do whatever you need to do + * with the array. + * + * Authors: + * Burton Radons + * License: + * Public Domain + * Macros: + * WIKI=Phobos/StdBoxer + */ + module std.boxer; private import std.format; private import std.string; private import std.utf; -/** These functions and types allow packing objects into generic containers + /* These functions and types allow packing objects into generic containers * and recovering them later. This comes into play in a wide spectrum of * utilities, such as with a scripting language, or as additional user data * for an object. @@ -75,11 +133,14 @@ private enum TypeClass Other, /**< Any other type, such as delegates, function pointers, struct, void... */ } -/** A box object contains a value in a generic fashion, allowing it to be - * passed from one place to another without having to know its type. It is - * created by calling the box function, and you can recover the value by - * instantiating the unbox template. - */ +/** + * Box is a generic container for objects (both value and heap), allowing the + * user to box them in a generic form and recover them later. + * A box object contains a value in a generic fashion, allowing it to be + * passed from one place to another without having to know its type. It is + * created by calling the box function, and you can recover the value by + * instantiating the unbox template. + */ struct Box { private TypeInfo p_type; /**< The type of the contained object. */ @@ -167,22 +228,33 @@ struct Box return false; } - /** Return the type of the contained object. */ + /** + * Property for the type contained by the box. + * This is initially null and cannot be assigned directly. + * Returns: the type of the contained object. + */ TypeInfo type() { return p_type; } - /** Return the data array. */ + /** + * Property for the data pointer to the value of the box. + * This is initially null and cannot be assigned directly. + * Returns: the data array. + */ void[] data() { size_t size = type.tsize(); return size <= p_shortData.length ? p_shortData[0..size] : p_longData[0..size]; } - - /** Attempt to convert the object to a string by doing D formatting on it. - */ + + /** + * Attempt to convert the boxed value into a string using std.string.format; + * this will throw if that function cannot handle it. If the box is + * uninitialized then this returns "". + */ char[] toString() { if (type is null) @@ -242,8 +314,11 @@ struct Box return cast(bool)type.equals(data, other.data); } - - /** Implement the equals operator. */ + + /** + * Compare this box's value with another box. This implicitly casts if the + * types are different, identical to the regular type system. + */ bool opEquals(Box other) { return opEqualsInternal(other, false); @@ -294,20 +369,29 @@ struct Box return type.compare(data, other.data); } - - /** Implement the compare operator. */ + + /** + * Compare this box's value with another box. This implicitly casts if the + * types are different, identical to the regular type system. + */ float opCmp(Box other) { return opCmpInternal(other, false); } - - uint toHash() + + /** + * Return the value's hash. + */ + hash_t toHash() { return type.getHash(data); } } - -/** Create a box out of the first argument passed. */ + +/** + * Box the single argument passed to the function. If more or fewer than one + * argument is passed, this will assert. + */ Box box(...) in { @@ -318,7 +402,11 @@ body return box(_arguments[0], _argptr); } -/** Assign the parameters, copying data as needed. */ +/** + * Box the explicitly-defined object. type must not be null; data must not be + * null if the type's size is greater than zero. + * The data is copied. + */ Box box(TypeInfo type, void* data) in { @@ -344,7 +432,9 @@ private size_t argumentLength(size_t baseLength) return (baseLength + int.sizeof - 1) & ~(int.sizeof - 1); } -/** Box each argument in the list. */ +/** + * Convert a list of arguments into a list of boxes. + */ Box[] boxArray(TypeInfo[] types, void* data) { Box[] array = new Box[types.length]; @@ -358,13 +448,17 @@ Box[] boxArray(TypeInfo[] types, void* data) return array; } -/** Box each argument passed to the function, returning an array of boxes. */ +/** + * Box each argument passed to the function, returning an array of boxes. + */ Box[] boxArray(...) { return boxArray(_arguments, _argptr); } -/** Convert an array of boxes into an array of arguments. */ +/** + * Convert an array of boxes into an array of arguments. + */ void boxArrayToArguments(Box[] arguments, out TypeInfo[] types, out void* data) { size_t dataLength; @@ -386,16 +480,20 @@ void boxArrayToArguments(Box[] arguments, out TypeInfo[] types, out void* data) } } -/** This is thrown if you try to unbox an incompatible type. */ +/** + * This class is thrown if unbox is unable to cast the value into the desired + * result. + */ class UnboxException : Exception { - /** The boxed object spawning the error. */ - Box object; - - /** The type that we tried to unbox as. */ - TypeInfo outputType; - - /** Assign parameters and the message. */ + Box object; /// This is the box that the user attempted to unbox. + + TypeInfo outputType; /// This is the type that the user attempted to unbox the value as. + + /** + * Assign parameters and create the message in the form + * "Could not unbox from type ... to ... ." + */ this(Box object, TypeInfo outputType) { this.object = object; @@ -490,13 +588,28 @@ private template unboxCastImaginary(T) } } -/** This unbox template takes a template parameter and returns a function that - * takes a box object and returns the specified type. If it cannot cast to - * the type, it throws UnboxException. For example: - * - * Box y = box(4); - * int x = unbox!(int) (y); - */ +/** + * The unbox template takes a type parameter and returns a function that + * takes a box object and returns the specified type. + * + * To use it, instantiate the template with the desired result type, and then + * call the function with the box to convert. + * This will implicitly cast base types as necessary and in a way consistent + * with static types - for example, it will cast a boxed byte into int, but it + * won't cast a boxed float into short. + * + * Throws: UnboxException if it cannot cast + * + * Example: + * --- + * Box b = box(4.5); + * bit u = unboxable!(real)(b); // This is true. + * real r = unbox!(real)(b); + * + * Box y = box(4); + * int x = unbox!(int) (y); + * --- + */ template unbox(T) { T unbox(Box value) @@ -599,9 +712,10 @@ template unbox(T : void*) } } -/** Return whether the value can be unboxed to this type without throwing - * UnboxException. - */ +/** + * Return whether the value can be unboxed as the given type; if this returns + * false, attempting to do so will throw UnboxException. + */ template unboxable(T) { bool unboxable(Box value) diff --git a/std/c/linux/linux.d b/std/c/linux/linux.d index dfb870b65b2..cf07a70cc6b 100644 --- a/std/c/linux/linux.d +++ b/std/c/linux/linux.d @@ -380,3 +380,115 @@ extern (C) int getpwnam_r(char*, passwd*, void*, size_t, passwd**); } + +extern (C) +{ + /* pthread declarations taken from pthread headers and + http://svn.dsource.org/projects/bindings/trunk/pthreads.d + */ + + /* from bits/types.h + */ + + typedef int __time_t; + + /* from time.h + */ + + struct timespec + { + __time_t tv_sec; /* seconds */ + int tv_nsec; /* nanosecs. */ + } + + /* from bits/pthreadtypes.h + */ + + struct _pthread_descr_struct + { + /* Not defined in the headers ??? + Just needed here to typedef + the _pthread_descr pointer + */ + } + + typedef _pthread_descr_struct* _pthread_descr; + + struct _pthread_fastlock + { + int __status; + int __spinlock; + } + + typedef long __pthread_cond_align_t; + + struct pthread_cond_t + { + _pthread_fastlock __c_lock; + _pthread_descr __c_waiting; + char[48 + - _pthread_fastlock.sizeof + - _pthread_descr.sizeof + - __pthread_cond_align_t.sizeof + ] __padding; + __pthread_cond_align_t __align; + } + + struct pthread_condattr_t + { + int __dummy; + } + + struct pthread_mutex_t + { + int __m_reserved; + int __m_count; + _pthread_descr __m_owner; + int __m_kind; + _pthread_fastlock __m_lock; + } + + struct pthread_mutexattr_t + { + int __mutexkind; + } + + /* from pthread.h + */ + + int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*); + int pthread_mutex_destroy(pthread_mutex_t*); + int pthread_mutex_trylock(pthread_mutex_t*); + int pthread_mutex_lock(pthread_mutex_t*); + int pthread_mutex_unlock(pthread_mutex_t*); + + int pthread_mutexattr_init(pthread_mutexattr_t*); + int pthread_mutexattr_destroy(pthread_mutexattr_t*); + + int pthread_cond_init(pthread_cond_t*, pthread_condattr_t*); + int pthread_cond_destroy(pthread_cond_t*); + int pthread_cond_signal(pthread_cond_t*); + int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*); + int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, timespec*); +} + +extern (C) +{ + /* from semaphore.h + */ + + struct sem_t + { + _pthread_fastlock __sem_lock; + int __sem_value; + void* __sem_waiting; + } + + int sem_init(sem_t*, int, uint); + int sem_wait(sem_t*); + int sem_trywait(sem_t*); + int sem_post(sem_t*); + int sem_getvalue(sem_t*, int*); + int sem_destroy(sem_t*); +} + diff --git a/std/c/windows/windows.d b/std/c/windows/windows.d index fd76ea6ba3d..45cdf7b761e 100644 --- a/std/c/windows/windows.d +++ b/std/c/windows/windows.d @@ -2708,4 +2708,11 @@ export HWND SetFocus(HWND hWnd); export int wsprintfA(LPSTR, LPCSTR, ...); export int wsprintfW(LPWSTR, LPCWSTR, ...); + +const uint INFINITE = uint.max; +const uint WAIT_OBJECT_0 = 0; + +export HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCTSTR lpName); +export HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCTSTR lpName); +export BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount); } diff --git a/std/date.d b/std/date.d index 2c8e0ad6848..53833fe6101 100644 --- a/std/date.d +++ b/std/date.d @@ -3,6 +3,9 @@ * Dates are represented in several formats. The date implementation revolves * around a central type, d_time, from which other formats are converted to and * from. + * Dates are calculated using the Gregorian calendar. + * References: + * $(LINK2 http://en.wikipedia.org/wiki/Gregorian_calendar, Gregorian calendar (Wikipedia)) * Macros: * WIKI = Phobos/StdDate */ @@ -84,6 +87,8 @@ const int[12] mdays = [ 0,31,59,90,120,151,181,212,243,273,304,334 ]; /******************************** * Compute year and week [1..53] from t. The ISO 8601 week 1 is the first week * of the year that includes January 4. Monday is the first day of the week. + * References: + * $(LINK2 http://en.wikipedia.org/wiki/ISO_8601, ISO 8601 (Wikipedia)) */ void toISO8601YearWeek(d_time t, out int year, out int week) @@ -220,6 +225,10 @@ d_time TimeFromYear(int y) return cast(d_time)msPerDay * DayFromYear(y); } +/***************************** + * Calculates the year from the d_time t. + */ + int YearFromTime(d_time t) { int y; @@ -244,11 +253,30 @@ int YearFromTime(d_time t) return y; } +/******************************* + * Determines if d_time t is a leap year. + * + * A leap year is every 4 years except years ending in 00 that are not + * divsible by 400. + * + * Returns: !=0 if it is a leap year. + * + * References: + * $(LINK2 http://en.wikipedia.org/wiki/Leap_year, Wikipedia) + */ + int inLeapYear(d_time t) { return LeapYear(YearFromTime(t)); } +/***************************** + * Calculates the month from the d_time t. + * + * Returns: Integer in the range 0..11, where + * 0 represents January and 11 represents December. + */ + int MonthFromTime(d_time t) { int day; @@ -298,14 +326,17 @@ int MonthFromTime(d_time t) else if (day < 365) month = 11; else - { assert(0); - month = -1; // keep /W4 happy - } + assert(0); } } return month; } +/******************************* + * Compute which day in a month a d_time t is. + * Returns: + * Integer in the range 1..31 + */ int DateFromTime(d_time t) { int day; @@ -334,11 +365,16 @@ int DateFromTime(d_time t) case 11: date = day - 333 - leap; break; default: assert(0); - date = -1; // keep /W4 happy } return date; } +/******************************* + * Compute which day of the week a d_time t is. + * Returns: + * Integer in the range 0..6, where 0 represents Sunday + * and 6 represents Saturday. + */ int WeekDay(d_time t) { int w; diff --git a/std/mmfile.d b/std/mmfile.d index d974a7141d5..d9b46337080 100644 --- a/std/mmfile.d +++ b/std/mmfile.d @@ -1,11 +1,13 @@ // Copyright (c) 2004 by Digital Mars // All Rights Reserved -// written by Walter Bright and Matthew Wilson (Sysesis Software Pty Ltd.) +// written by Walter Bright and Matthew Wilson (Synesis Software Pty Ltd.) // www.digitalmars.com // www.synesis.com.au/software -/* - * Memory mapped files. +/** + * Read and write memory mapped files. + * Macros: + * WIKI=Phobos/StdMmfile */ module std.mmfile; @@ -39,24 +41,49 @@ else static assert(0); } - +/** + * MmFile objects control the memory mapped file resource. + */ class MmFile { + /** + * The mode the memory mapped file is opened with. + */ enum Mode - { Read, // read existing file - ReadWriteNew, // delete existing file, write new file - ReadWrite, // read/write existing file, create if not existing - ReadCopyOnWrite, // read/write existing file, copy on write + { Read, /// read existing file + ReadWriteNew, /// delete existing file, write new file + ReadWrite, /// read/write existing file, create if not existing + ReadCopyOnWrite, /// read/write existing file, copy on write } - /* Open for reading + /** + * Open memory mapped file filename for reading. + * File is closed when the object instance is deleted. + * Throws: + * std.file.FileException */ this(char[] filename) { this(filename, Mode.Read, 0, null); } - /* Open + /** + * Open memory mapped file filename in mode. + * File is closed when the object instance is deleted. + * Params: + * filename = name of the file. + * If null, an anonymous file mapping is created. + * mode = access mode defined above. + * size = the size of the file. If 0, it is taken to be the + * size of the existing file. + * address = the preferred address to map the file to, + * although the system is not required to honor it. + * If null, the system selects the most convenient address. + * window = preferred block size of the amount of data to map at one time + * with 0 meaning map the entire file. The window size must be a + * multiple of the memory allocation page size. + * Throws: + * std.file.FileException */ this(char[] filename, Mode mode, ulong size, void* address, size_t window = 0) @@ -267,6 +294,9 @@ class MmFile } } + /** + * Flushes pending output and closes the memory mapped file. + */ ~this() { debug (MMFILE) printf("MmFile.~this()\n"); @@ -317,24 +347,36 @@ class MmFile } } + /** + * Gives size in bytes of the memory mapped file. + */ ulong length() { debug (MMFILE) printf("MmFile.length()\n"); return size; } + /** + * Read-only property returning the file mode. + */ Mode mode() { debug (MMFILE) printf("MmFile.mode()\n"); return mMode; } + /** + * Returns entire file contents as an array. + */ void[] opSlice() { debug (MMFILE) printf("MmFile.opSlice()\n"); return opSlice(0,size); } + /** + * Returns slice of file contents as an array. + */ void[] opSlice(ulong i1, ulong i2) { debug (MMFILE) printf("MmFile.opSlice(%lld, %lld)\n", i1, i2); @@ -344,7 +386,9 @@ class MmFile return data[off1 .. off2]; } - + /** + * Returns byte at index i in file. + */ ubyte opIndex(ulong i) { debug (MMFILE) printf("MmFile.opIndex(%lld)\n", i); @@ -353,6 +397,9 @@ class MmFile return (cast(ubyte[])data)[off]; } + /** + * Sets and returns byte at index i in file to value. + */ ubyte opIndexAssign(ubyte value, ulong i) { debug (MMFILE) printf("MmFile.opIndex(%lld, %d)\n", i, value); diff --git a/std/openrj.d b/std/openrj.d index dfd35d26ee6..2923a75f3dc 100644 --- a/std/openrj.d +++ b/std/openrj.d @@ -29,11 +29,20 @@ * - This notice may not be removed or altered from any source * distribution. * - * ////////////////////////////////////////////////////////////////////////// */ + * ////////////////////////////////////////////////////////////////////////// + * Altered by Walter Bright. + */ -/* \file std/openrj.d Open-RJ/D mapping for the D standard library +/** + * Open-RJ mapping for the D standard library. * + * Authors: + * Matthew Wilson + * References: + * $(LINK2 http://www.openrj.org/, Open-RJ) + * Macros: + * WIKI=Phobos/StdOpenrj */ /* ///////////////////////////////////////////////////////////////////////////// @@ -58,7 +67,7 @@ private import std.string; * Version information */ -/// This'll be moved out to somewhere common soon +// This'll be moved out to somewhere common soon private struct Version { @@ -86,7 +95,7 @@ public static Version VERSION = * Structs */ -/// This'll be moved out to somewhere common soon +// This'll be moved out to somewhere common soon private struct EnumString { @@ -132,10 +141,13 @@ private template enum_to_string(T) /** Flags that moderate the creation of Databases */ public enum ORJ_FLAG { - ORDER_FIELDS = 0x0001 /*!< Arranges the fields in alphabetical order */ - , ELIDE_BLANK_RECORDS = 0x0002 /*!< Causes blank records to be ignored */ + ORDER_FIELDS = 0x0001, /// Arranges the fields in alphabetical order + ELIDE_BLANK_RECORDS = 0x0002, /// Causes blank records to be ignored } +/** + * + */ public char[] toString(ORJ_FLAG f) { const EnumString strings[] = @@ -150,17 +162,20 @@ public char[] toString(ORJ_FLAG f) /** General error codes */ public enum ORJRC { - SUCCESS = 0 /*!< Operation was successful */ - , CANNOT_OPEN_JAR_FILE /*!< The given file does not exist, or cannot be accessed */ - , NO_RECORDS /*!< The database file contained no records */ - , OUT_OF_MEMORY /*!< The API suffered memory exhaustion */ - , BAD_FILE_READ /*!< A read operation failed */ - , PARSE_ERROR /*!< Parsing of the database file failed due to a syntax error */ - , INVALID_INDEX /*!< An invalid index was specified */ - , UNEXPECTED /*!< An unexpected condition was encountered */ - , INVALID_CONTENT /*!< The database file contained invalid content */ + SUCCESS = 0, /// Operation was successful + CANNOT_OPEN_JAR_FILE, /// The given file does not exist, or cannot be accessed + NO_RECORDS, /// The database file contained no records + OUT_OF_MEMORY, /// The API suffered memory exhaustion + BAD_FILE_READ, /// A read operation failed + PARSE_ERROR, /// Parsing of the database file failed due to a syntax error + INVALID_INDEX, /// An invalid index was specified + UNEXPECTED, /// An unexpected condition was encountered + INVALID_CONTENT, /// The database file contained invalid content } +/** + * + */ public char[] toString(ORJRC f) { const EnumString strings[] = @@ -182,13 +197,16 @@ public char[] toString(ORJRC f) /** Parsing error codes */ public enum ORJ_PARSE_ERROR { - SUCCESS = 0 /*!< Parsing was successful */ - , RECORD_SEPARATOR_IN_CONTINUATION /*!< A record separator was encountered during a content line continuation */ - , UNFINISHED_LINE /*!< The last line in the database was not terminated by a line-feed */ - , UNFINISHED_FIELD /*!< The last field in the database file was not terminated by a record separator */ - , UNFINISHED_RECORD /*!< The last record in the database file was not terminated by a record separator */ + SUCCESS = 0, /// Parsing was successful + RECORD_SEPARATOR_IN_CONTINUATION, /// A record separator was encountered during a content line continuation + UNFINISHED_LINE, /// The last line in the database was not terminated by a line-feed + UNFINISHED_FIELD, /// The last field in the database file was not terminated by a record separator + UNFINISHED_RECORD, /// The last record in the database file was not terminated by a record separator } +/** + * + */ public char[] toString(ORJ_PARSE_ERROR f) { const EnumString strings[] = @@ -207,24 +225,29 @@ public char[] toString(ORJ_PARSE_ERROR f) * Classes */ +/** + * + */ class OpenRJException : public Exception { -/// \name Construction -/// @{ +/* \name Construction */ + protected: this(char[] message) { super(message); } -/// @} + } +/** + * + */ class DatabaseException : public OpenRJException { -/// \name Construction -/// @{ +/* \name Construction */ private: this(char[] details, ORJRC rc) { @@ -289,24 +312,33 @@ private: super(message); } -/// @} -/// \name Attributes -/// @{ +/* \name Attributes */ public: + + /** + * + */ ORJRC rc() { return m_rc; } + + /** + * + */ ORJ_PARSE_ERROR parseError() { return m_pe; } + + /** + * + */ int lineNum() { return m_lineNum; } -/// @} // Members private: @@ -315,30 +347,32 @@ private: ORJ_PARSE_ERROR m_pe; } +/** + * + */ class InvalidKeyException : public OpenRJException { -/// \name Construction -/// @{ +/* \name Construction */ private: this(char[] message) { super(message); } -/// @} } +/** + * + */ class InvalidTypeException : public OpenRJException { -/// \name Construction -/// @{ +/* \name Construction */ private: this(char[] message) { super(message); } -/// @} } /* ///////////////////////////////////////////////////////////////////////////// @@ -348,8 +382,8 @@ private: /// Represents a field in the database class Field { -/// \name Construction -/// @{ +/* \name Construction */ + private: this(char[] name, char[] value/* , Record record */) in @@ -363,27 +397,39 @@ private: m_value = value; /* m_record = record; */ } -/// @} -/// \name Attributes -/// @{ + +/* \name Attributes */ + public: + + /** + * + */ final char[] name() { return m_name; } + + /** + * + */ final char[] value() { return m_value; } + + /** + * + */ Record record() { return m_record; } -/// @} -/// \name Comparison -/// @{ + +/* \name Comparison */ + /+ public: int opCmp(Object rhs) @@ -419,7 +465,7 @@ public: return res; } +/ -/// @} + // Members private: @@ -431,16 +477,16 @@ private: /// Represents a record in the database, consisting of a set of fields class Record { -/// \name Types -/// @{ +/* \name Types */ + public: alias object.size_t size_type; alias object.size_t index_type; alias object.ptrdiff_t difference_type; -/// @} -/// \name Construction -/// @{ + +/* \name Construction */ + private: this(Field[] fields, uint flags, Database database) { @@ -461,26 +507,39 @@ private: m_database = database; } -/// @} -/// \name Attributes -/// @{ + +/* \name Attributes */ + public: + + /** + * + */ uint numFields() { return m_fields.length; } + /** + * + */ uint length() { return numFields(); } + /** + * + */ Field[] fields() { return m_fields.dup; } + /** + * + */ Field opIndex(index_type index) in { @@ -491,11 +550,17 @@ public: return m_fields[index]; } + /** + * + */ char[] opIndex(char[] fieldName) { return getField(fieldName).value; } + /** + * + */ Field getField(char[] fieldName) in { @@ -513,6 +578,9 @@ public: return field; } + /** + * + */ Field findField(char[] fieldName) in { @@ -525,20 +593,30 @@ public: return (null is pfield) ? null : *pfield; } + /** + * + */ int hasField(char[] fieldName) { return null !is findField(fieldName); } + /** + * + */ Database database() { return m_database; } -/// @} -/// \name Enumeration -/// @{ + +/* \name Enumeration */ + public: + + /** + * + */ int opApply(int delegate(inout Field field) dg) { int result = 0; @@ -556,6 +634,9 @@ public: return result; } + /** + * + */ int opApply(int delegate(in char[] name, in char[] value) dg) { int result = 0; @@ -572,7 +653,7 @@ public: return result; } -/// @} + // Members private: @@ -581,18 +662,22 @@ private: Database m_database; } + +/** + * + */ class Database { -/// \name Types -/// @{ +/* \name Types */ + public: alias object.size_t size_type; alias object.size_t index_type; alias object.ptrdiff_t difference_type; -/// @} -/// \name Construction -/// @{ + +/* \name Construction */ + private: void init_(char[][] lines, uint flags) { @@ -726,6 +811,10 @@ private: m_numLines = lines.length; } public: + + /** + * + */ this(char[] memory, uint flags) { char[][] lines = split(memory, "\n"); @@ -733,52 +822,83 @@ public: init_(lines, flags); } + /** + * + */ this(char[][] lines, uint flags) { init_(lines, flags); } -/// @} -/// \name Attributes -/// @{ + +/* \name Attributes */ + public: + + /** + * + */ size_type numRecords() { return m_records.length; } + + /** + * + */ size_type numFields() { return m_fields.length; } + + /** + * + */ size_type numLines() { return m_numLines; } -/// @} -/// \name Attributes -/// @{ + +/* \name Attributes */ + public: + + /** + * + */ uint flags() { return m_flags; } + /** + * + */ Record[] records() { return m_records.dup; } + /** + * + */ Field[] fields() { return m_fields.dup; } + /** + * + */ uint length() { return numRecords(); } + /** + * + */ Record opIndex(index_type index) in { @@ -788,11 +908,15 @@ public: { return m_records[index]; } -/// @} -/// \name Searching -/// @{ + +/* \name Searching */ + public: + + /** + * + */ Record[] getRecordsContainingField(char[] fieldName) { Record[] records; @@ -808,6 +932,9 @@ public: return records; } + /** + * + */ Record[] getRecordsContainingField(char[] fieldName, char[] fieldValue) { Record[] records; @@ -861,11 +988,15 @@ public: return records; } -/// @} -/// \name Enumeration -/// @{ + +/* \name Enumeration */ + public: + + /** + * + */ int opApply(int delegate(inout Record record) dg) { int result = 0; @@ -882,6 +1013,10 @@ public: return result; } + + /** + * + */ int opApply(int delegate(inout Field field) dg) { int result = 0; @@ -898,7 +1033,7 @@ public: return result; } -/// @} + // Members private: diff --git a/std/recls.d b/std/recls.d deleted file mode 100644 index 0a0a9212393..00000000000 --- a/std/recls.d +++ /dev/null @@ -1,1087 +0,0 @@ -/* ///////////////////////////////////////////////////////////////////////////// - * File: recls.d - * - * Purpose: D mapping for the recls library. recls is a platform-independent - * recursive search library. It is mapped to several languages, - * including D. recls was written by Matthew Wilson, as the first - * exemplar for his "Positive Integration" column in C/C++ User's - * Journal. - * - * Created 10th Octover 2003 - * Updated: 27th November 2003 - * - * Author: Matthew Wilson - * - * License: (Licensed under the Synesis Software Standard Source License) - * - * Copyright (C) 2002-2003, Synesis Software Pty Ltd. - * - * All rights reserved. - * - * www: http://www.recls.org/ - * http://www.synesis.com.au/software - * http://www.synsoft.org/ - * - * email: admin@recls.org - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * (i) Redistributions of source code must retain the above - * copyright notice and contact information, this list of - * conditions and the following disclaimer. - * - * (ii) Any derived versions of this software (howsoever modified) - * remain the sole property of Synesis Software. - * - * (iii) Any derived versions of this software (howsoever modified) - * remain subject to all these conditions. - * - * (iv) Neither the name of Synesis Software nor the names of any - * subdivisions, employees or agents of Synesis Software, nor the - * names of any other contributors to this software may be used to - * endorse or promote products derived from this software without - * specific prior written permission. - * - * This source code is provided by Synesis Software "as is" and any - * warranties, whether expressed or implied, including, but not - * limited to, the implied warranties of merchantability and - * fitness for a particular purpose are disclaimed. In no event - * shall the Synesis Software be liable for any direct, indirect, - * incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods - * or services; loss of use, data, or profits; or business - * interruption) however caused and on any theory of liability, - * whether in contract, strict liability, or tort (including - * negligence or otherwise) arising in any way out of the use of - * this software, even if advised of the possibility of such - * damage. - * - * ////////////////////////////////////////////////////////////////////////// */ - - - -//////////////////////////////////////////////////////////////////////////////// -// Module - -module std.recls; - -//////////////////////////////////////////////////////////////////////////////// -// Imports - -import std.string; - -version (linux) -{ - private import std.c.time; - private import std.c.linux.linux; -} - -//////////////////////////////////////////////////////////////////////////////// -// Public types - -private alias int recls_sint32_t; -/// Unsigned 32-bit integer, used for flags -public alias uint recls_uint32_t; -/// boolean type, used in the recls API functions -public typedef int recls_bool_t; -/// boolean type, used in the recls class mappings -public alias recls_bool_t boolean; - -version(Windows) -{ - /// Win32 time type - public struct recls_time_t - { - uint dwLowDateTime; - uint dwHighDateTime; - }; - - /// Win32 file size type - alias ulong recls_filesize_t; -} -else version(linux) -{ - /// UNIX time type - typedef time_t recls_time_t; - - /// UNIX file size type - typedef off_t recls_filesize_t; -} - -/// The recls search handle type. -public typedef void *hrecls_t; -/// The recls entry handle type. -public typedef void *recls_info_t; -/// The recls entry process callback function parameter type. */ -public typedef void *recls_process_fn_param_t; - -/// The return code of the recls API -public typedef recls_sint32_t recls_rc_t; - -/// Returns non-zero if the given return code represents a failure condition. -public recls_bool_t RECLS_FAILED(recls_rc_t rc) -{ - return cast(recls_bool_t)(rc < 0); -} - -/// Returns non-zero if the given return code represents a success condition. -public recls_bool_t RECLS_SUCCEEDED(recls_rc_t rc) -{ - return cast(recls_bool_t)!RECLS_FAILED(rc); -} - -//////////////////////////////////////////////////////////////////////////////// -// Values - -/** General success code */ -public const recls_rc_t RECLS_RC_OK = cast(recls_rc_t)(0); - -/** Return code that indicates that there is no more data available from an otherwise valid search. */ -public const recls_rc_t RECLS_RC_NO_MORE_DATA = cast(recls_rc_t)(-1004); - -/// The flags used to moderate the recls search behaviour -public enum RECLS_FLAG -{ - RECLS_F_FILES = 0x00000001 /*!< Include files in search. Included by default if none specified */ - , RECLS_F_DIRECTORIES = 0x00000002 /*!< Include directories in search. Not currently supported. */ - , RECLS_F_LINKS = 0x00000004 /*!< Include links in search. Ignored in Win32. */ - , RECLS_F_DEVICES = 0x00000008 /*!< Include devices in search. Not currently supported. */ - , RECLS_F_TYPEMASK = 0x00000FFF - , RECLS_F_RECURSIVE = 0x00010000 /*!< Searches given directory and all sub-directories */ - , RECLS_F_NO_FOLLOW_LINKS = 0x00020000 /*!< Does not expand links */ - , RECLS_F_DIRECTORY_PARTS = 0x00040000 /*!< Fills out the directory parts. Supported from version 1.1.1 onwards. */ - , RECLS_F_DETAILS_LATER = 0x00080000 /*!< Does not fill out anything other than the path. Not currently supported. */ -}; - -//////////////////////////////////////////////////////////////////////////////// -// Private recls API declarations - -extern (Windows) -{ - private recls_rc_t Recls_Search( char *searchRoot - , char *pattern - , recls_uint32_t flags - , hrecls_t *phSrch); - - typedef int (*hrecls_process_fn_t)(recls_info_t info, recls_process_fn_param_t param); - - private recls_rc_t Recls_SearchProcess( char *searchRoot - , char *pattern - , recls_uint32_t flags - , hrecls_process_fn_t pfn - , recls_process_fn_param_t param); - - private void Recls_SearchClose(in hrecls_t hSrch); - - private recls_rc_t Recls_GetNext(in hrecls_t hSrch); - - private recls_rc_t Recls_GetDetails(in hrecls_t hSrch, out recls_info_t pinfo); - - private recls_rc_t Recls_GetNextDetails(in hrecls_t hSrch, out recls_info_t pinfo); - - private void Recls_CloseDetails(in recls_info_t fileInfo); - - private recls_rc_t Recls_CopyDetails(in recls_info_t fileInfo, in recls_info_t *pinfo); - - private recls_rc_t Recls_OutstandingDetails(in hrecls_t hSrch, out recls_uint32_t count); - - private recls_rc_t Recls_GetLastError(in hrecls_t hSrch); - - private int Recls_GetErrorString(in recls_rc_t rc, in char *buffer, in uint cchBuffer); - - private int Recls_GetLastErrorString(in hrecls_t hSrch, in char *buffer, in uint cchBuffer); - - private uint Recls_GetPathProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - -version(Windows) -{ - private void Recls_GetDriveProperty(in recls_info_t fileInfo, out char chDrive); -} - - private uint Recls_GetDirectoryProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - - private uint Recls_GetDirectoryPathProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - - private uint Recls_GetFileProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - - private uint Recls_GetShortFileProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - - private uint Recls_GetFileNameProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - - private uint Recls_GetFileExtProperty(in recls_info_t fileInfo, in char *buffer, in uint cchBuffer); - - private uint Recls_GetDirectoryPartProperty(in recls_info_t fileInfo, in int part, in char *buffer, in uint cchBuffer); - - private recls_bool_t Recls_IsFileReadOnly(in recls_info_t fileInfo); - - private recls_bool_t Recls_IsFileDirectory(in recls_info_t fileInfo); - - private recls_bool_t Recls_IsFileLink(in recls_info_t fileInfo); - - private void Recls_GetSizeProperty(in recls_info_t fileInfo, recls_filesize_t *size); - - private recls_time_t Recls_GetCreationTime(in recls_info_t fileInfo); - - private recls_time_t Recls_GetModificationTime(in recls_info_t fileInfo); - - private recls_time_t Recls_GetLastAccessTime(in recls_info_t fileInfo); - - private recls_time_t Recls_GetLastStatusChangeTime(in recls_info_t fileInfo); - -} - -//////////////////////////////////////////////////////////////////////////////// -// Public functions - -/// Creates a search -/// -/// \param searchRoot -/// \param pattern -/// \param flags -/// \param hSrch -/// \return -/// \retval - -public recls_rc_t Search_Create(in char[] searchRoot, in char[] pattern, in int flags, out hrecls_t hSrch) -{ - return Recls_Search(toStringz(searchRoot), toStringz(pattern), flags, &hSrch); -} - -/+ -private extern(Windows) int process_fn(recls_info_t entry, recls_process_fn_param_t p) -{ - return dg(Entry._make_Entry(entry), p); -} - -public recls_rc_t Search_Process( in char[] searchRoot - , in char[] pattern - , in int flags - , int delegate(in Entry entry, recls_process_fn_param_t param) dg - , recls_process_fn_param_t param) -{ -/* extern(Windows) int process_fn(recls_info_t entry, recls_process_fn_param_t p) - { - return dg(Entry._make_Entry(entry), p); - } - */ - return Recls_SearchProcess(searchRoot, pattern, flags, process_fn, param); -} -+/ - -/// Advances the given search to the next position -/// -/// \param hSrch handle identifying the search -/// \return return code indicating status of the operation -/// \return RECLS_ -public recls_rc_t Search_GetNext(in hrecls_t hSrch) -{ - return Recls_GetNext(hSrch); -} - -/// Closes the given search -/// -/// \param hSrch handle identifying the search -public void Search_Close(inout hrecls_t hSrch) -{ - Recls_SearchClose(hSrch); - - hSrch = null; -} - -public recls_rc_t Search_GetEntry(in hrecls_t hSrch, out recls_info_t entry) -{ - return Recls_GetDetails(hSrch, entry); -} - -public recls_rc_t Search_GetNextEntry(in hrecls_t hSrch, out recls_info_t entry) -{ - return Recls_GetNextDetails(hSrch, entry); -} - -public void Search_CloseEntry(inout recls_info_t entry) -{ - Recls_CloseDetails(entry); - - entry = null; -} - -public recls_info_t Search_CopyEntry(in recls_info_t entry) -{ - recls_info_t copy; - - if(RECLS_FAILED(Recls_CopyDetails(entry, ©))) - { - copy = null; - } - - return copy; -} - -public recls_rc_t Search_OutstandingDetails(in hrecls_t hSrch, out recls_uint32_t count) -{ - return Recls_OutstandingDetails(hSrch, count); -} - -public recls_rc_t Search_GetLastError(in hrecls_t hSrch) -{ - return Recls_GetLastError(hSrch); -} - -public char[] Search_GetErrorString(in recls_rc_t rc) -{ - uint cch = Recls_GetErrorString(rc, null, 0); - char[] err = new char[cch]; - - cch = Recls_GetErrorString(rc, err, err.length); - - assert(cch <= err.length); - - return err; -} - -public char[] Search_GetEntryPath(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetPathProperty(entry, null, 0); - char[] path = new char[cch]; - - cch = Recls_GetPathProperty(entry, path, path.length); - - assert(cch <= path.length); - - return path; -} - -version(Windows) -{ -public char Search_GetEntryDrive(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - char chDrive; - - return (Recls_GetDriveProperty(entry, chDrive), chDrive); -} -} - -public char[] Search_GetEntryDirectory(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetDirectoryProperty(entry, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetDirectoryProperty(entry, str, str.length); - - assert(cch <= str.length); - - return str; -} - -public char[] Search_GetEntryDirectoryPath(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetDirectoryPathProperty(entry, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetDirectoryPathProperty(entry, str, str.length); - - assert(cch <= str.length); - - return str; -} - -public char[] Search_GetEntryFile(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetFileProperty(entry, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetFileProperty(entry, str, str.length); - - assert(cch <= str.length); - - return str; -} - -public char[] Search_GetEntryShortFile(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetShortFileProperty(entry, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetShortFileProperty(entry, str, str.length); - - assert(cch <= str.length); - - return str; -} - -public char[] Search_GetEntryFileName(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetFileNameProperty(entry, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetFileNameProperty(entry, str, str.length); - - assert(cch <= str.length); - - return str; -} - -public char[] Search_GetEntryFileExt(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cch = Recls_GetFileExtProperty(entry, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetFileExtProperty(entry, str, str.length); - - assert(cch <= str.length); - - return str; -} - -public char[][] Search_GetEntryDirectoryParts(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - uint cParts = Recls_GetDirectoryPartProperty(entry, -1, null, 0); - char[][] parts = new char[][cParts]; - - for(int i = 0; i < cParts; ++i) - { - uint cch = Recls_GetDirectoryPartProperty(entry, i, null, 0); - char[] str = new char[cch]; - - cch = Recls_GetDirectoryPartProperty(entry, i, str, str.length); - - assert(cch <= str.length); - - parts[i] = str; - } - - return parts; -} - -public boolean Search_IsEntryReadOnly(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_IsFileReadOnly(entry); -} - -public boolean Search_IsEntryDirectory(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_IsFileDirectory(entry); -} - -public boolean Search_IsEntryLink(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_IsFileLink(entry); -} - -public recls_filesize_t Search_GetEntrySize(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - recls_filesize_t size; - - return (Recls_GetSizeProperty(entry, &size), size); -} - -public recls_time_t Search_GetEntryCreationTime(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_GetCreationTime(entry); -} - -public recls_time_t Search_GetEntryModificationTime(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_GetModificationTime(entry); -} - -public recls_time_t Search_GetEntryLastAccessTime(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_GetLastAccessTime(entry); -} - -public recls_time_t Search_GetEntryLastStatusChangeTime(in recls_info_t entry) -in -{ - assert(null !is entry); -} -body -{ - return Recls_GetLastStatusChangeTime(entry); -} - -//////////////////////////////////////////////////////////////////////////////// -// Classes - -/// Represents a search -public class Search -{ -/// \name Construction -public: - /// Create a search object with the given searchRoot, pattern and flags - /// - /// \param searchRoot The root directory of the search. If null, or the empty string, the current directory is assumed - /// \param pattern The search pattern. If null, or the empty string, all entries are returned - /// \param flags The flags with moderate the search - this(in char[] searchRoot, in char[] pattern, in uint flags) - { - m_searchRoot = searchRoot; - m_pattern = pattern; - m_flags = flags; - } - -/// \name Types -public: - class Enumerator - { - public: - this(hrecls_t hSrch, recls_rc_t lastError) - { - m_hSrch = hSrch; - m_lastError = lastError; - } - public: - ~this() - { - if(null != m_hSrch) - { - Search_Close(m_hSrch); - } - } - - public: - boolean HasEntry() - { - return RECLS_SUCCEEDED(m_lastError); - } - - Entry CurrentEntry() - in - { - assert(null !is m_hSrch); - } - body - { - recls_info_t entry; - recls_rc_t rc = Search_GetEntry(m_hSrch, entry); - - m_lastError = rc; - - try - { - return Entry._make_Entry(entry); - } - finally - { - Search_CloseEntry(entry); - } - } - - recls_rc_t LastError() - { - return m_lastError; - } - - public: - boolean GetNextEntry() - in - { - assert(null != m_hSrch); - } - body - { - recls_rc_t rc = Search_GetNext(m_hSrch); - - m_lastError = rc; - - if(RECLS_FAILED(rc)) - { - Search_Close(m_hSrch); - - if(RECLS_RC_NO_MORE_DATA != rc) - { - // throw new ReclsException("Search continuation failed", rc); - } - } - - return RECLS_SUCCEEDED(rc); - } - - /// Members - private: - hrecls_t m_hSrch; // NOTE THAT D DOES STRONG TYPEDEFS (see true-typedefs) - recls_rc_t m_lastError; - } - -/// Operations -public: - Enumerator Enumerate() - { - hrecls_t hSrch; - recls_rc_t rc = Search_Create(m_searchRoot, m_pattern, m_flags, hSrch); - - try - { - return new Enumerator(hSrch, rc); - } - catch(Exception x) - { - Search_Close(hSrch); - - throw x; - } - } - -public: - int opApply(int delegate(inout Entry entry) dg) - { - int result = 0; - hrecls_t hSrch; - recls_rc_t rc = Search_Create(m_searchRoot, m_pattern, m_flags, hSrch); - recls_info_t entry; - - do - { - if(RECLS_FAILED(rc)) - { - if(RECLS_RC_NO_MORE_DATA != rc) - { - // throw new ReclsException("Search continuation failed", rc); - } - - result = 1; - } - else - { - rc = Search_GetEntry(hSrch, entry); - - if(RECLS_FAILED(rc)) - { - if(RECLS_RC_NO_MORE_DATA != rc) - { - // throw new ReclsException("Search continuation failed", rc); - } - - result = 1; - } - else - { - try - { - Entry e = Entry._make_Entry(entry); - - result = dg(e); - } - finally - { - Search_CloseEntry(entry); - } - } - - rc = Search_GetNextEntry(hSrch, entry); - } - - } while(result == 0); - - return result; - } - -/// Members -private: - char[] m_searchRoot; - char[] m_pattern; - uint m_flags; -} - -/* public class Boolean -{ -public: - this(boolean value) - { - m_value = value; - } - - op() - { - return m_value != 0; - } - -private: - boolean m_value; -} - */ - -/// Represents a search entry -public class Entry -{ - invariant - { - if(null != m_entry) - { - // Now do all the checks to verify that the various components of the path are valid - - // Since we cannot call member functions (as that would end up in recursion) - // the only thing we can do is to "test" the validity of the entry handle, so - // we just add a reference, and then release it - recls_info_t entry = Search_CopyEntry(m_entry); - - assert(null !is entry); - - Recls_CloseDetails(entry); - } - } - -private: - /// This is necessary, because DMD 0.73 generates code - /// that goes into an infinite loop when creating an - /// Entry instance with a non-null entry - static Entry _make_Entry(recls_info_t entry) - { - recls_info_t copy = Search_CopyEntry(entry); - Entry e = null; - - try - { - e = new Entry(null); - - e.m_entry = entry; - } - catch(Exception x) - { - Search_CloseEntry(copy); - - throw x; - } - - return e; - } - - this(recls_info_t entry) - { - m_entry = entry; - } - ~this() - { - if(null !is m_entry) - { - Search_CloseEntry(m_entry); - } - } - -public: - /// The full path of the entry - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield "/usr/include/recls/recls_assert.h" - char[] GetPath() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryPath(m_entry); - } - /// The full path of the entry - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield "/usr/include/recls/recls_assert.h" - char[] Path() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryPath(m_entry); - } -version(Windows) -{ - /// The drive component of the entry's path - /// - /// \note For "H:\Dev\include\recls\recls_assert.h" this would yield 'H' - char Drive() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryDrive(m_entry); - } -} // version(Windows) - /// The directory component of the entry's path - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield "/usr/include/recls/" - char[] Directory() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryDirectory(m_entry); - } - /// The full location component of the entry's path. - /// - /// \note This is everything before the filename+fileext. On Win32 systems for "H:\Dev\include\recls\recls_assert.h" this would yield "H:\Dev\include\recls\" - char[] DirectoryPath() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryDirectoryPath(m_entry); - } - /// An array of strings representing the parts of the Directory property - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield [ "/", "usr/", "include/", "recls/"] - char[][] DirectoryParts() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryDirectoryParts(m_entry); - } - /// The file component of the entry's path - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield "recls_assert.h" - char[] File() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryFile(m_entry); - } - /// The short equivalent of the entry's File property - /// - /// \note On Win32 systems, this is the 8.3 form, e.g. "recls_~1.h". On other systems this is identical to the File property - char[] ShortFile() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryShortFile(m_entry); - } - /// The file name component of the entry's path - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield "recls_assert" - char[] FileName() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryFileName(m_entry); - } - /// The file extension component of the entry's path - /// - /// \note For "/usr/include/recls/recls_assert.h" this would yield "h" - char[] FileExt() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryFileExt(m_entry); - } - - /// The time the entry was created - recls_time_t CreationTime() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryCreationTime(m_entry); - } - /// The time the entry was last modified - recls_time_t ModificationTime() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryModificationTime(m_entry); - } - /// The time the entry was last accessed - recls_time_t LastAccessTime() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryLastAccessTime(m_entry); - } - /// The time the entry's last status changed - recls_time_t LastStatusChangeTime() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntryLastStatusChangeTime(m_entry); - } - - /// The size of the entry - recls_filesize_t Size() - in - { - assert(null !is m_entry); - } - body - { - return Search_GetEntrySize(m_entry); - } - - /// Indicates whether the entry is read-only - boolean IsReadOnly() - in - { - assert(null !is m_entry); - } - body - { - return Search_IsEntryReadOnly(m_entry); - } - /// Indicates whether the entry is a directory - boolean IsDirectory() - in - { - assert(null !is m_entry); - } - body - { - return Search_IsEntryDirectory(m_entry); - } - /// Indicates whether the entry is a link - boolean IsLink() - in - { - assert(null !is m_entry); - } - body - { - return Search_IsEntryLink(m_entry); - } - -/// Members -private: - recls_info_t m_entry; -} - -//////////////////////////////////////////////////////////////////////////////// - -unittest -{ - Search search = new Search(".", "*.*", RECLS_FLAG.RECLS_F_RECURSIVE); - - foreach(Entry entry; search) - { - entry.Path(); -version(Windows) -{ - entry.Drive(); -} // version(Windows) - entry.Directory(); - entry.DirectoryPath(); - entry.DirectoryParts(); - entry.File(); - entry.ShortFile(); - entry.FileName(); - entry.FileExt(); - entry.CreationTime(); - entry.ModificationTime(); - entry.LastAccessTime(); - entry.LastStatusChangeTime(); - entry.Size(); - entry.IsReadOnly(); - entry.IsDirectory(); - entry.IsLink(); - } -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/std/regexp.d b/std/regexp.d index 3ded238ab7e..eb0fd8c9fa3 100644 --- a/std/regexp.d +++ b/std/regexp.d @@ -188,6 +188,21 @@ char[] sub(char[] string, char[] pattern, char[] delegate(RegExp) dg, char[] att int eo = r.pmatch[0].rm_eo; rchar[] replacement = dg(r); + + // Optimize by using std.string.replace if possible - Dave Fladebo + rchar[] slice = result[offset + so .. offset + eo]; + if (r.attributes & RegExp.REA.global && // global, so replace all + !(r.attributes & RegExp.REA.ignoreCase) && // not ignoring case + !(r.attributes & RegExp.REA.multiline) && // not multiline + pattern == slice && // simple pattern (exact match, no special characters) + format == replacement) // simple format, not $ formats + { + debug(regexp) + printf("pattern: %.*s, slice: %.*s, format: %.*s, replacement: %.*s\n",pattern,result[offset + so .. offset + eo],format,replacement); + result = std.string.replace(result,slice,replacement); + break; + } + result = replaceSlice(result, result[offset + so .. offset + eo], replacement); if (r.attributes & RegExp.REA.global) @@ -848,6 +863,21 @@ public rchar[] replace(rchar[] string, rchar[] format) int eo = pmatch[0].rm_eo; rchar[] replacement = replace(format); + + // Optimize by using std.string.replace if possible - Dave Fladebo + rchar[] slice = result[offset + so .. offset + eo]; + if (attributes & REA.global && // global, so replace all + !(attributes & REA.ignoreCase) && // not ignoring case + !(attributes & REA.multiline) && // not multiline + pattern == slice && // simple pattern (exact match, no special characters) + format == replacement) // simple format, not $ formats + { + debug(regexp) + printf("pattern: %.*s, slice: %.*s, format: %.*s, replacement: %.*s\n",pattern,result[offset + so .. offset + eo],format,replacement); + result = std.string.replace(result,slice,replacement); + break; + } + result = replaceSlice(result, result[offset + so .. offset + eo], replacement); if (attributes & REA.global) diff --git a/std/socketstream.d b/std/socketstream.d index c2919982163..c974a4f48b9 100644 --- a/std/socketstream.d +++ b/std/socketstream.d @@ -18,18 +18,39 @@ 3. This notice may not be removed or altered from any source distribution. */ +/************** + * SocketStream is a stream for a blocking, + * connected Socket. + * + * For Win32 systems, link with ws2_32.lib. + * + * Example: + * See /dmd/samples/d/htmlget.d + * Authors: Christopher E. Miller + * References: + * $(LINK2 std_stream.html, std.stream) + * Macros: WIKI=Phobos/StdSocketstream + */ module std.socketstream; private import std.stream; private import std.socket; +/************** + * SocketStream is a stream for a blocking, + * connected Socket. + */ class SocketStream: Stream { - private: + private: Socket sock; - public: + public: + + /** + * Constructs a SocketStream with the specified Socket and FileMode flags. + */ this(Socket sock, FileMode mode) { if(mode & FileMode.In) @@ -40,17 +61,26 @@ class SocketStream: Stream this.sock = sock; } + /** + * Uses mode FileMode.In | FileMode.Out. + */ this(Socket sock) { writeable = readable = true; this.sock = sock; } + /** + * Property to get the Socket that is being streamed. + */ Socket socket() { return sock; } + /** + * Attempts to read the entire block, waiting if necessary. + */ override uint readBlock(void* _buffer, uint size) { ubyte* buffer = cast(ubyte*)_buffer; @@ -68,6 +98,9 @@ class SocketStream: Stream return len; } + /** + * Attempts to write the entire block, waiting if necessary. + */ override uint writeBlock(void* _buffer, uint size) { ubyte* buffer = cast(ubyte*)_buffer; @@ -84,17 +117,27 @@ class SocketStream: Stream return len; } + /** + * + */ override ulong seek(long offset, SeekPos whence) { throw new SeekException("Cannot seek a socket."); return 0; } + /** + * Does not return the entire stream because that would + * require the remote connection to be closed. + */ override char[] toString() { return sock.toString(); } + /** + * Close the Socket. + */ override void close() { sock.close(); diff --git a/std/stream.d b/std/stream.d index a0f6cce783b..3a93ce8c65b 100644 --- a/std/stream.d +++ b/std/stream.d @@ -2075,33 +2075,33 @@ class File: Stream { */ class BufferedFile: BufferedStream { - // opens file for reading + /// opens file for reading this() { super(new File()); } - // opens file in requested mode and buffer size + /// opens file in requested mode and buffer size this(char[] filename, FileMode mode = FileMode.In, uint bufferSize = DefaultBufferSize) { super(new File(filename,mode),bufferSize); } - // opens file for reading with requested buffer size + /// opens file for reading with requested buffer size this(File file, uint bufferSize = DefaultBufferSize) { super(file,bufferSize); } - // opens existing handle; use with care! + /// opens existing handle; use with care! this(HANDLE hFile, FileMode mode, uint buffersize) { super(new File(hFile,mode),buffersize); } - // opens file in requested mode + /// opens file in requested mode void open(char[] filename, FileMode mode = FileMode.In) { File sf = cast(File)s; sf.open(filename,mode); resetSource(); } - // creates file in requested mode + /// creates file in requested mode void create(char[] filename, FileMode mode = FileMode.Out) { File sf = cast(File)s; sf.create(filename,mode); diff --git a/std/thread.d b/std/thread.d index 803ec9c4685..6a8f5406cce 100644 --- a/std/thread.d +++ b/std/thread.d @@ -76,26 +76,31 @@ class Thread { /** * Constructor used by classes derived from Thread that override main(). + * The optional stacksize parameter default value of 0 will cause threads + * to be created with the default size for the executable - Dave Fladebo */ - this() + this(size_t stacksize = 0) { + this.stacksize = stacksize; } /** * Constructor used by classes derived from Thread that override run(). */ - this(int (*fp)(void *), void *arg) + this(int (*fp)(void *), void *arg, size_t stacksize = 0) { this.fp = fp; this.arg = arg; + this.stacksize = stacksize; } /** * Constructor used by classes derived from Thread that override run(). */ - this(int delegate() dg) + this(int delegate() dg, size_t stacksize = 0) { this.dg = dg; + this.stacksize = stacksize; } /** @@ -104,7 +109,6 @@ class Thread */ thread_hdl hdl; - thread_id id; void* stackBottom; /** @@ -134,7 +138,7 @@ class Thread } state = TS.RUNNING; - hdl = _beginthreadex(null, 0, &threadstart, this, 0, &id); + hdl = _beginthreadex(null, cast(uint)stacksize, &threadstart, this, 0, &id); if (hdl == cast(thread_hdl)0) { state = TS.TERMINATED; allThreads[idx] = null; @@ -249,6 +253,15 @@ class Thread error("set priority"); } + /** + * Returns non-zero if this thread is the current thread. + */ + int isSelf() + { + //printf("id = %d, self = %d\n", id, pthread_self()); + return (id == GetCurrentThreadId()); + } + /** * Returns a reference to the Thread for the thread that called the * function. @@ -361,6 +374,8 @@ class Thread TS state; int idx = -1; // index into allThreads[] + thread_id id; + size_t stacksize = 0; int (*fp)(void *); void *arg; @@ -502,17 +517,20 @@ struct sigaction_t void (*sa_restorer)(); } -struct _pthread_fastlock -{ - int __status; - int __spinlock; -} - -struct sem_t +struct pthread_attr_t { - _pthread_fastlock __sem_lock; - int __sem_value; - void* __sem_waiting; + int __detachstate; + int __schedpolicy; + struct __schedparam + { + int __sched_priority; + } + int __inheritsched; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void *__stackaddr; + size_t __stacksize; } unittest @@ -529,14 +547,28 @@ extern (C) int pthread_kill(pthread_t, int); pthread_t pthread_self(); int pthread_equal(pthread_t, pthread_t); - int sem_wait(sem_t*); - int sem_init(sem_t*, int, uint); - int sem_post(sem_t*); + int pthread_attr_init(pthread_attr_t*); + int pthread_attr_setstacksize(pthread_attr_t *, size_t); + int pthread_cancel(pthread_t); + int pthread_setcancelstate(int, int*); + int pthread_setcanceltype(int, int*); int sched_yield(); int sigfillset(sigset_t*); int sigdelset(sigset_t*, int); int sigaction(int, sigaction_t*, sigaction_t*); int sigsuspend(sigset_t*); + + enum + { + PTHREAD_CANCEL_ENABLE, + PTHREAD_CANCEL_DISABLE + } + + enum + { + PTHREAD_CANCEL_DEFERRED, + PTHREAD_CANCEL_ASYNCHRONOUS + } } class ThreadError : Error @@ -549,19 +581,30 @@ class ThreadError : Error class Thread { - this() + // The optional stacksize parameter default value of 0 will cause threads + // to be created with the default pthread size - Dave Fladebo + this(size_t stacksize = 0) { + init(stacksize); } - this(int (*fp)(void *), void *arg) + this(int (*fp)(void *), void *arg, size_t stacksize = 0) { this.fp = fp; this.arg = arg; + init(stacksize); } - this(int delegate() dg) + this(int delegate() dg, size_t stacksize = 0) { this.dg = dg; + init(stacksize); + } + + ~this() + { + pthread_cond_destroy(&waitCond); + pthread_mutex_destroy(&waitMtx); } pthread_t id; @@ -593,7 +636,9 @@ class Thread state = TS.RUNNING; int result; //printf("creating thread x%x\n", this); - result = pthread_create(&id, null, &threadstart, this); + //result = pthread_create(&id, null, &threadstart, this); + // Create with thread attributes to allow non-default stack size - Dave Fladebo + result = pthread_create(&id, &threadAttrs, &threadstart, this); if (result) { state = TS.TERMINATED; allThreads[idx] = null; @@ -627,16 +672,51 @@ class Thread void wait(uint milliseconds) { - wait(); - /+ not implemented + // Implemented for POSIX systems by Dave Fladebo if (this is getThis()) error("wait on self"); if (state == TS.RUNNING) - { DWORD dw; + { + timespec ts; + timeval tv; + + pthread_mutex_lock(&waitMtx); + gettimeofday(&tv, null); + ts.tv_sec = cast(__time_t)tv.tv_sec + cast(__time_t)(milliseconds / 1_000); + ts.tv_nsec = (tv.tv_usec * 1_000) + ((milliseconds % 1_000) * 1_000_000); + if (ts.tv_nsec > 1_000_000_000) + { + ts.tv_sec += 1; + ts.tv_nsec -= 1_000_000_000; + } + if (pthread_cond_timedwait(&waitCond, &waitMtx, &ts)) + { + int oldstate, oldtype; + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); - dw = WaitForSingleObject(hdl, milliseconds); + if (pthread_cancel(id)) // thread was not completed in the timeout period, cancel it + { + pthread_mutex_unlock(&waitMtx); + error("cannot terminate thread via timed wait"); + } + + pthread_setcancelstate(oldstate, null); + pthread_setcanceltype(oldtype, null); + + state = TS.TERMINATED; + allThreads[idx] = null; + idx = -1; + nthreads--; + + pthread_mutex_unlock(&waitMtx); + } + else + { + pthread_mutex_unlock(&waitMtx); + wait(); // condition has been signalled as complete (see threadstart()), terminate normally + } } - +/ } enum TS @@ -806,13 +886,22 @@ class Thread static uint allThreadsDim; static Object threadLock; - static Thread[/*_POSIX_THREAD_THREADS_MAX*/ 100] allThreads; + + // Set max to Windows equivalent for compatibility. + // pthread_create will fail gracefully if stack limit + // is reached prior to allThreads max. + static Thread[0x400] allThreads; + static sem_t flagSuspend; TS state; int idx = -1; // index into allThreads[] int flags = 0; + pthread_attr_t threadAttrs; + pthread_mutex_t waitMtx; + pthread_cond_t waitCond; + int (*fp)(void *); void *arg; @@ -823,6 +912,24 @@ class Thread throw new ThreadError(msg); } + void init(size_t stackSize) + { + // set to default values regardless + // passing this as the 2nd arg. for pthread_create() + // w/o setting an attribute is equivalent to passing null. + pthread_attr_init(&threadAttrs); + if (stackSize > 0) + { + if (pthread_attr_setstacksize(&threadAttrs,stackSize)) + error("cannot set stack size"); + } + + if (pthread_mutex_init(&waitMtx, null)) + error("cannot initialize wait mutex"); + + if (pthread_cond_init(&waitCond, null)) + error("cannot initialize wait condition"); + } /************************************************ * This is just a wrapper to interface between C rtl and Thread.run(). @@ -842,6 +949,8 @@ class Thread t.stackBottom = getESP(); try { + if(t.state == TS.RUNNING) + pthread_cond_signal(&t.waitCond); // signal the wait condition (see the timed wait function) result = t.run(); } catch (Object o) @@ -937,7 +1046,6 @@ class Thread } assert(sig == SIGUSR1); - sem_post(&flagSuspend); sigset_t sigmask; result = sigfillset(&sigmask); @@ -948,6 +1056,8 @@ class Thread Thread t = getThis(); t.stackTop = getESP(); t.flags &= ~1; + // Release the semaphore _after_ stackTop is set + sem_post(&flagSuspend); while (1) { sigsuspend(&sigmask); // suspend until SIGUSR2