summaryrefslogtreecommitdiff
path: root/ghc/misc/examples/posix/po011/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/misc/examples/posix/po011/Main.hs')
-rw-r--r--ghc/misc/examples/posix/po011/Main.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/ghc/misc/examples/posix/po011/Main.hs b/ghc/misc/examples/posix/po011/Main.hs
new file mode 100644
index 0000000000..3d78924157
--- /dev/null
+++ b/ghc/misc/examples/posix/po011/Main.hs
@@ -0,0 +1,22 @@
+import LibPosix
+
+main =
+ getGroupEntryForName "grasp" >>= \ grasp ->
+ getGroupEntryForName "staff" >>= \ staff ->
+ putStr (ge2String grasp) >>
+ putChar '\n' >>
+ putStr (ge2String staff) >>
+ putChar '\n' >>
+ getGroupEntryForID (groupID grasp) >>= \ guid ->
+ getGroupEntryForID (groupID staff) >>= \ suid ->
+ putStr (ge2String guid) >>
+ putChar '\n' >>
+ putStr (ge2String suid) >>
+ putChar '\n'
+
+ge2String ge =
+ name ++ (':' : (show gid) ++ (':' : members))
+ where
+ name = groupName ge
+ gid = groupID ge
+ members = foldr (\x y -> x ++ (',' : y)) "" (groupMembers ge) \ No newline at end of file