systemd-api (empty) → 0.1.0.0
raw patch · 3 files changed
+95/−0 lines, 3 filesdep +basedep +byte-orderdep +byteslice
Dependencies added: base, byte-order, byteslice, posix-api, primitive, text-short
Files
- LICENSE +30/−0
- src/Linux/Systemd.hs +36/−0
- systemd-api.cabal +29/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2023, Andrew Martin++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Andrew Martin nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS 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.
+ src/Linux/Systemd.hs view
@@ -0,0 +1,36 @@+module Linux.Systemd+ ( listenFds+ , isSocket+ ) where++import Foreign.C.Types (CInt(..))+import System.Posix.Types (Fd(..))+import Foreign.C.Error (Errno,getErrno)+import Posix.Socket (Type(..),Family(..))++foreign import ccall unsafe "systemd/sd-daemon.h sd_listen_fds"+ c_listenFds :: CInt -> IO CInt++foreign import ccall unsafe "systemd/sd-daemon.h sd_is_socket"+ c_isSocket :: Fd -> Family -> Type -> CInt -> IO CInt++-- | Check for file descriptors passed by the system manager. Returns+-- the number of received file descriptors. If no file descriptors+-- have been received, zero is returned.+listenFds ::+ CInt -- ^ unset environment (non-zero unsets @LISTEN_FDS@, @LISTEN_PID@, and @LISTEN_FDNAMES@)+ -> IO (Either Errno CInt)+listenFds a = c_listenFds a >>= errorsFromInt++isSocket :: + Fd -- ^ File descriptor+ -> Family -- ^ Socket family+ -> Type -- ^ Socket type+ -> CInt -- ^ Positive: require listen mode. Zero: require non-listening mode.+ -> IO (Either Errno CInt)+isSocket a b c d = c_isSocket a b c d >>= errorsFromInt++errorsFromInt :: CInt -> IO (Either Errno CInt)+errorsFromInt r = if r >= 0+ then pure (Right r)+ else fmap Left getErrno
+ systemd-api.cabal view
@@ -0,0 +1,29 @@+cabal-version: 2.2+name: systemd-api+version: 0.1.0.0+synopsis: systemd bindings+description: Bindings to various systemd functions+homepage: https://github.com/byteverse/systemd-api+license: BSD-3-Clause+license-file: LICENSE+author: Andrew Martin+maintainer: andrew.thaddeus@gmail.com+copyright: 2023 Andrew Martin+category: System+build-type: Simple++library+ exposed-modules:+ Linux.Systemd+ build-depends:+ , base >=4.17.1 && <5+ , byte-order >= 0.1.2 && <0.2+ , byteslice >= 0.2.10 && <0.3+ , primitive >= 0.7 && <0.10+ , text-short >=0.1.5+ , posix-api >=0.5+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall -O2+ extra-libraries: systemd+ build-tool-depends: hsc2hs:hsc2hs >= 0.68.5