Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 16:57:17

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