diff options
author | joe <joe@jerkface.net> | 2013-06-17 16:19:15 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-06-17 16:19:15 -0400 |
commit | 7adaccbf993c602f09b2b9e7dea0360ac0dce93e (patch) | |
tree | 6c4b3aaa4c551ae8d8b897725d0cb5791836878c /Presence/UTmp.hs | |
parent | 5982df9112b7e5fe7bcab62434771f1ca979e14d (diff) |
Switched UTmp.users to return ByteStrings instead of Strings.
Diffstat (limited to 'Presence/UTmp.hs')
-rw-r--r-- | Presence/UTmp.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Presence/UTmp.hs b/Presence/UTmp.hs index c2549a88..481612e3 100644 --- a/Presence/UTmp.hs +++ b/Presence/UTmp.hs | |||
@@ -1,9 +1,9 @@ | |||
1 | |||
2 | {-# LANGUAGE TemplateHaskell #-} | 1 | {-# LANGUAGE TemplateHaskell #-} |
3 | module UTmp (users, utmp_file) where | 2 | module UTmp (users, utmp_file) where |
4 | 3 | ||
5 | import qualified Data.ByteString as S | 4 | import qualified Data.ByteString as S |
6 | import qualified Data.ByteString.Char8 as C | 5 | import qualified Data.ByteString.Char8 as C |
6 | import qualified Data.ByteString.Lazy.Char8 as L | ||
7 | import Data.BitSyntax | 7 | import Data.BitSyntax |
8 | import Data.Functor.Identity | 8 | import Data.Functor.Identity |
9 | import Data.Maybe | 9 | import Data.Maybe |
@@ -80,11 +80,15 @@ processAlive pid = do | |||
80 | catchError (do { signalProcess nullSignal pid ; return True }) | 80 | catchError (do { signalProcess nullSignal pid ; return True }) |
81 | $ \e -> do { return (not ( isDoesNotExistError e)); } | 81 | $ \e -> do { return (not ( isDoesNotExistError e)); } |
82 | 82 | ||
83 | type UserName = L.ByteString | ||
84 | type Tty = L.ByteString | ||
85 | |||
86 | users :: IO [(UserName, Tty, ProcessID)] | ||
83 | users = do | 87 | users = do |
84 | us <- utmp | 88 | us <- utmp |
85 | let us' = map interp_utmp_record us | 89 | let us' = map interp_utmp_record us |
86 | us'' = mapMaybe user_proc us' | 90 | us'' = mapMaybe user_proc us' |
87 | user_proc (u,tty,pid,USER_PROCESS) = Just (u,tty,pid) | 91 | user_proc (u,tty,pid,USER_PROCESS) = Just (L.pack u,L.pack tty,pid) |
88 | user_proc _ = Nothing | 92 | user_proc _ = Nothing |
89 | onThrd f (_,_,pid) = f pid | 93 | onThrd f (_,_,pid) = f pid |
90 | us3 <- filterM (onThrd processAlive) us'' | 94 | us3 <- filterM (onThrd processAlive) us'' |