summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorJoey Hess2014-03-30 00:08:02 -0400
committerJoey Hess2014-03-30 00:08:02 -0400
commit92957b27ece2d4fb2eb4ce9121dd26ee94985b48 (patch)
treec25c4dbd5d497958ba011ad7382ab92fc3cc8f45 /Utility
parent0ab0216d0b400fae78a6a6916ef9f82ed31dc0fa (diff)
cabalized and added a wrapper program
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Network.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Utility/Network.hs b/Utility/Network.hs
new file mode 100644
index 00000000..62523c9e
--- /dev/null
+++ b/Utility/Network.hs
@@ -0,0 +1,21 @@
+{- network functions
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Utility.Network where
+
+import Utility.Process
+import Utility.Exception
+
+import Control.Applicative
+
+{- Haskell lacks uname(2) bindings, except in the
+ - Bindings.Uname addon. Rather than depend on that,
+ - use uname -n when available. -}
+getHostname :: IO (Maybe String)
+getHostname = catchMaybeIO uname_node
+ where
+ uname_node = takeWhile (/= '\n') <$> readProcess "uname" ["-n"]