Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:35

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_PERMISSIONS_HPP
0012 #define BOOST_INTERPROCESS_PERMISSIONS_HPP
0013 
0014 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0015 
0016 #ifndef BOOST_CONFIG_HPP
0017 #  include <boost/config.hpp>
0018 #endif
0019 #
0020 #if defined(BOOST_HAS_PRAGMA_ONCE)
0021 #  pragma once
0022 #endif
0023 
0024 #include <boost/interprocess/detail/config_begin.hpp>
0025 #include <boost/interprocess/detail/workaround.hpp>
0026 #include <boost/interprocess/interprocess_fwd.hpp>
0027 
0028 #if defined(BOOST_INTERPROCESS_WINDOWS)
0029 
0030 #include <boost/interprocess/detail/win32_api.hpp>
0031 
0032 #else
0033 
0034 #include <sys/stat.h>
0035 
0036 #endif
0037 
0038 #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0039 
0040 //!\file
0041 //!Describes permissions class
0042 
0043 namespace boost {
0044 namespace interprocess {
0045 
0046 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0047 
0048 #if defined(BOOST_INTERPROCESS_WINDOWS)
0049 
0050 namespace ipcdetail {
0051 
0052 template <int Dummy>
0053 struct unrestricted_permissions_holder
0054 {
0055    static winapi::interprocess_all_access_security unrestricted;
0056 };
0057 
0058 template<int Dummy>
0059 winapi::interprocess_all_access_security unrestricted_permissions_holder<Dummy>::unrestricted;
0060 
0061 }  //namespace ipcdetail {
0062 
0063 #endif   //defined BOOST_INTERPROCESS_WINDOWS
0064 
0065 #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0066 
0067 //!The permissions class represents permissions to be set to shared memory or
0068 //!files, that can be constructed form usual permission representations:
0069 //!a SECURITY_ATTRIBUTES pointer in windows or ORed rwx chmod integer in UNIX.
0070 class permissions
0071 {
0072    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0073 
0074    #if defined(BOOST_INTERPROCESS_WINDOWS)
0075    typedef void*  os_permissions_type;
0076    #else
0077    typedef ::mode_t    os_permissions_type;
0078    #endif
0079    os_permissions_type  m_perm;
0080 
0081    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0082 
0083    public:
0084    //!Constructs a permissions object from a user provided os-dependent
0085    //!permissions.
0086    permissions(os_permissions_type type) BOOST_NOEXCEPT
0087       : m_perm(type)
0088    {}
0089 
0090    //!Constructs a default permissions object:
0091    //!A null security attributes pointer for windows or 0644
0092    //!for UNIX.
0093    permissions() BOOST_NOEXCEPT
0094    {  set_default(); }
0095 
0096    //!Sets permissions to default values:
0097    //!A null security attributes pointer for windows or 0644
0098    //!for UNIX.
0099    void set_default() BOOST_NOEXCEPT
0100    {
0101       #if defined (BOOST_INTERPROCESS_WINDOWS)
0102       m_perm = 0;
0103       #else
0104       m_perm = 0644;
0105       #endif
0106    }
0107 
0108    //!Sets permissions to unrestricted access:
0109    //!A null DACL for windows or 0666 for UNIX.
0110    void set_unrestricted() BOOST_NOEXCEPT
0111    {
0112       #if defined (BOOST_INTERPROCESS_WINDOWS)
0113       m_perm = &ipcdetail::unrestricted_permissions_holder<0>::unrestricted;
0114       #else
0115       m_perm = 0666;
0116       #endif
0117    }
0118 
0119    //!Sets permissions from a user provided os-dependent
0120    //!permissions.
0121    void set_permissions(os_permissions_type perm) BOOST_NOEXCEPT
0122    {  m_perm = perm; }
0123 
0124    //!Returns stored os-dependent
0125    //!permissions
0126    os_permissions_type get_permissions() const BOOST_NOEXCEPT
0127    {  return m_perm; }
0128 };
0129 
0130 }  //namespace interprocess {
0131 }  //namespace boost {
0132 
0133 #include <boost/interprocess/detail/config_end.hpp>
0134 
0135 #endif   //BOOST_INTERPROCESS_PERMISSIONS_HPP
0136