{-# LINE 1 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 2 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 3 "src/Bindings/LXC/AttachOptions.hsc" #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Bindings.LXC.AttachOptions
-- Copyright   :  (c) Nickolay Kudasov 2014
-- License     :  BSD-style (see the file LICENSE)
--
-- Maintainer  :  nickolay.kudasov@gmail.com
--
-- Options and structures to run commands inside LXC containers.
-- You can get more info about LXC at <https://help.ubuntu.com/lts/serverguide/lxc.html> and <https://linuxcontainers.org>.
--
-----------------------------------------------------------------------------
module Bindings.LXC.AttachOptions (
  -- * Attach env policy
  c'LXC_ATTACH_KEEP_ENV,
  c'LXC_ATTACH_CLEAR_ENV,
  -- * Attach flags
  c'LXC_ATTACH_MOVE_TO_CGROUP,
  c'LXC_ATTACH_DROP_CAPABILITIES,
  c'LXC_ATTACH_SET_PERSONALITY,
  c'LXC_ATTACH_LSM_EXEC,
  c'LXC_ATTACH_REMOUNT_PROC_SYS,
  c'LXC_ATTACH_LSM_NOW,
  c'LXC_ATTACH_DEFAULT,
  c'LXC_ATTACH_LSM,
  -- * Attach options
  C'lxc_attach_options_t(..),
  p'lxc_attach_options_t'attach_flags,
  p'lxc_attach_options_t'namespaces,
  p'lxc_attach_options_t'personality,
  p'lxc_attach_options_t'initial_cwd,
  p'lxc_attach_options_t'uid,
  p'lxc_attach_options_t'gid,
  p'lxc_attach_options_t'env_policy,
  p'lxc_attach_options_t'extra_env_vars,
  p'lxc_attach_options_t'extra_keep_env,
  p'lxc_attach_options_t'stdin_fd,
  p'lxc_attach_options_t'stdout_fd,
  p'lxc_attach_options_t'stderr_fd,
  -- * Attach command
  C'lxc_attach_command_t(..),
  p'lxc_attach_command_t'program,
  p'lxc_attach_command_t'argv,
  -- * Attach @exec@ functions
  C_lxc_attach_exec_t(..),
  c'lxc_attach_run_command,
  p'lxc_attach_run_command,
  c'lxc_attach_run_shell,
  p'lxc_attach_run_shell,
) where
import Foreign.Ptr (Ptr,FunPtr,plusPtr)
import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)
import Foreign.Storable
import Foreign.C.Types
import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray,pokeArray)
import Data.Int
import Data.Word

{-# LINE 55 "src/Bindings/LXC/AttachOptions.hsc" #-}
import Bindings.LXC.Sys.Types

type C_lxc_attach_exec_t = FunPtr (Ptr () -> IO CInt)

type C'lxc_attach_env_policy_t = CUInt

{-# LINE 60 "src/Bindings/LXC/AttachOptions.hsc" #-}

c'LXC_ATTACH_KEEP_ENV = 0
c'LXC_ATTACH_KEEP_ENV :: (Num a) => a

{-# LINE 62 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_CLEAR_ENV = 1
c'LXC_ATTACH_CLEAR_ENV :: (Num a) => a

{-# LINE 63 "src/Bindings/LXC/AttachOptions.hsc" #-}

c'LXC_ATTACH_MOVE_TO_CGROUP = 1
c'LXC_ATTACH_MOVE_TO_CGROUP :: (Num a) => a

{-# LINE 65 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_DROP_CAPABILITIES = 2
c'LXC_ATTACH_DROP_CAPABILITIES :: (Num a) => a

{-# LINE 66 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_SET_PERSONALITY = 4
c'LXC_ATTACH_SET_PERSONALITY :: (Num a) => a

{-# LINE 67 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_LSM_EXEC = 8
c'LXC_ATTACH_LSM_EXEC :: (Num a) => a

{-# LINE 68 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_REMOUNT_PROC_SYS = 65536
c'LXC_ATTACH_REMOUNT_PROC_SYS :: (Num a) => a

{-# LINE 69 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_LSM_NOW = 131072
c'LXC_ATTACH_LSM_NOW :: (Num a) => a

{-# LINE 70 "src/Bindings/LXC/AttachOptions.hsc" #-}
c'LXC_ATTACH_DEFAULT = 65535
c'LXC_ATTACH_DEFAULT :: (Num a) => a

{-# LINE 71 "src/Bindings/LXC/AttachOptions.hsc" #-}

c'LXC_ATTACH_LSM = 131080
c'LXC_ATTACH_LSM :: (Num a) => a

{-# LINE 73 "src/Bindings/LXC/AttachOptions.hsc" #-}


{-# LINE 75 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 76 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 77 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 78 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 79 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 80 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 81 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 82 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 83 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 84 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 85 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 86 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 87 "src/Bindings/LXC/AttachOptions.hsc" #-}
data C'lxc_attach_options_t = C'lxc_attach_options_t{
  c'lxc_attach_options_t'attach_flags :: CInt,
  c'lxc_attach_options_t'namespaces :: CInt,
  c'lxc_attach_options_t'personality :: CLong,
  c'lxc_attach_options_t'initial_cwd :: CString,
  c'lxc_attach_options_t'uid :: C'uid_t,
  c'lxc_attach_options_t'gid :: C'gid_t,
  c'lxc_attach_options_t'env_policy :: C'lxc_attach_env_policy_t,
  c'lxc_attach_options_t'extra_env_vars :: Ptr CString,
  c'lxc_attach_options_t'extra_keep_env :: Ptr CString,
  c'lxc_attach_options_t'stdin_fd :: CInt,
  c'lxc_attach_options_t'stdout_fd :: CInt,
  c'lxc_attach_options_t'stderr_fd :: CInt
} deriving (Eq,Show)
p'lxc_attach_options_t'attach_flags p = plusPtr p 0
p'lxc_attach_options_t'attach_flags :: Ptr (C'lxc_attach_options_t) -> Ptr (CInt)
p'lxc_attach_options_t'namespaces p = plusPtr p 4
p'lxc_attach_options_t'namespaces :: Ptr (C'lxc_attach_options_t) -> Ptr (CInt)
p'lxc_attach_options_t'personality p = plusPtr p 8
p'lxc_attach_options_t'personality :: Ptr (C'lxc_attach_options_t) -> Ptr (CLong)
p'lxc_attach_options_t'initial_cwd p = plusPtr p 16
p'lxc_attach_options_t'initial_cwd :: Ptr (C'lxc_attach_options_t) -> Ptr (CString)
p'lxc_attach_options_t'uid p = plusPtr p 24
p'lxc_attach_options_t'uid :: Ptr (C'lxc_attach_options_t) -> Ptr (C'uid_t)
p'lxc_attach_options_t'gid p = plusPtr p 28
p'lxc_attach_options_t'gid :: Ptr (C'lxc_attach_options_t) -> Ptr (C'gid_t)
p'lxc_attach_options_t'env_policy p = plusPtr p 32
p'lxc_attach_options_t'env_policy :: Ptr (C'lxc_attach_options_t) -> Ptr (C'lxc_attach_env_policy_t)
p'lxc_attach_options_t'extra_env_vars p = plusPtr p 40
p'lxc_attach_options_t'extra_env_vars :: Ptr (C'lxc_attach_options_t) -> Ptr (Ptr CString)
p'lxc_attach_options_t'extra_keep_env p = plusPtr p 48
p'lxc_attach_options_t'extra_keep_env :: Ptr (C'lxc_attach_options_t) -> Ptr (Ptr CString)
p'lxc_attach_options_t'stdin_fd p = plusPtr p 56
p'lxc_attach_options_t'stdin_fd :: Ptr (C'lxc_attach_options_t) -> Ptr (CInt)
p'lxc_attach_options_t'stdout_fd p = plusPtr p 60
p'lxc_attach_options_t'stdout_fd :: Ptr (C'lxc_attach_options_t) -> Ptr (CInt)
p'lxc_attach_options_t'stderr_fd p = plusPtr p 64
p'lxc_attach_options_t'stderr_fd :: Ptr (C'lxc_attach_options_t) -> Ptr (CInt)
instance Storable C'lxc_attach_options_t where
  sizeOf _ = 72
  alignment _ = 8
  peek p = do
    v0 <- peekByteOff p 0
    v1 <- peekByteOff p 4
    v2 <- peekByteOff p 8
    v3 <- peekByteOff p 16
    v4 <- peekByteOff p 24
    v5 <- peekByteOff p 28
    v6 <- peekByteOff p 32
    v7 <- peekByteOff p 40
    v8 <- peekByteOff p 48
    v9 <- peekByteOff p 56
    v10 <- peekByteOff p 60
    v11 <- peekByteOff p 64
    return $ C'lxc_attach_options_t v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11
  poke p (C'lxc_attach_options_t v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11) = do
    pokeByteOff p 0 v0
    pokeByteOff p 4 v1
    pokeByteOff p 8 v2
    pokeByteOff p 16 v3
    pokeByteOff p 24 v4
    pokeByteOff p 28 v5
    pokeByteOff p 32 v6
    pokeByteOff p 40 v7
    pokeByteOff p 48 v8
    pokeByteOff p 56 v9
    pokeByteOff p 60 v10
    pokeByteOff p 64 v11
    return ()

{-# LINE 88 "src/Bindings/LXC/AttachOptions.hsc" #-}


{-# LINE 90 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 91 "src/Bindings/LXC/AttachOptions.hsc" #-}

{-# LINE 92 "src/Bindings/LXC/AttachOptions.hsc" #-}
data C'lxc_attach_command_t = C'lxc_attach_command_t{
  c'lxc_attach_command_t'program :: CString,
  c'lxc_attach_command_t'argv :: Ptr CString
} deriving (Eq,Show)
p'lxc_attach_command_t'program p = plusPtr p 0
p'lxc_attach_command_t'program :: Ptr (C'lxc_attach_command_t) -> Ptr (CString)
p'lxc_attach_command_t'argv p = plusPtr p 8
p'lxc_attach_command_t'argv :: Ptr (C'lxc_attach_command_t) -> Ptr (Ptr CString)
instance Storable C'lxc_attach_command_t where
  sizeOf _ = 16
  alignment _ = 8
  peek p = do
    v0 <- peekByteOff p 0
    v1 <- peekByteOff p 8
    return $ C'lxc_attach_command_t v0 v1
  poke p (C'lxc_attach_command_t v0 v1) = do
    pokeByteOff p 0 v0
    pokeByteOff p 8 v1
    return ()

{-# LINE 93 "src/Bindings/LXC/AttachOptions.hsc" #-}

foreign import ccall "lxc_attach_run_command" c'lxc_attach_run_command
  :: Ptr () -> IO CInt
foreign import ccall "&lxc_attach_run_command" p'lxc_attach_run_command
  :: FunPtr (Ptr () -> IO CInt)

{-# LINE 95 "src/Bindings/LXC/AttachOptions.hsc" #-}
foreign import ccall "lxc_attach_run_shell" c'lxc_attach_run_shell
  :: Ptr () -> IO CInt
foreign import ccall "&lxc_attach_run_shell" p'lxc_attach_run_shell
  :: FunPtr (Ptr () -> IO CInt)

{-# LINE 96 "src/Bindings/LXC/AttachOptions.hsc" #-}