[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / posix / po010 / Main.hs
diff --git a/ghc/misc/examples/posix/po010/Main.hs b/ghc/misc/examples/posix/po010/Main.hs
new file mode 100644 (file)
index 0000000..bfc8909
--- /dev/null
@@ -0,0 +1,24 @@
+import LibPosix
+
+main =
+    getUserEntryForName "mattson" >>= \ mattson ->
+    getUserEntryForName "partain" >>= \ partain ->
+    putStr (ue2String mattson) >>
+    putChar '\n' >>    
+    putStr (ue2String partain) >>
+    putChar '\n' >>    
+    getUserEntryForID (userID mattson) >>= \ muid ->
+    getUserEntryForID (userID partain) >>= \ puid ->
+    putStr (ue2String muid) >>
+    putChar '\n' >>    
+    putStr (ue2String puid) >>
+    putChar '\n'
+
+ue2String ue =
+    name ++ (':' : (show uid) ++ (':' : (show gid) ++ (':' : home ++ (':' : shell))))
+  where
+    name = userName ue
+    uid = userID ue
+    gid = userGroupID ue
+    home = homeDirectory ue
+    shell = userShell ue
\ No newline at end of file