getServiceByName name proto = do
ptr <- _ccall_ getservbyname name proto
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getServiceByName" "no such service entry")
+ then ioError (IOError Nothing NoSuchThing "getServiceByName" "no such service entry")
else unpackServiceEntry ptr
getServiceByPort :: PortNumber
getServiceByPort (PNum port) proto = do
ptr <- _ccall_ getservbyport port proto
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getServiceByPort" "no such service entry")
+ then ioError (IOError Nothing NoSuchThing "getServiceByPort" "no such service entry")
else unpackServiceEntry ptr
getServicePortNumber :: ServiceName -> IO PortNumber
getServiceEntry = do
ptr <- _ccall_ getservent
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getServiceEntry" "no such service entry")
+ then ioError (IOError Nothing NoSuchThing "getServiceEntry" "no such service entry")
else unpackServiceEntry ptr
setServiceEntry :: Bool -> IO ()
getProtocolByName name = do
ptr <- _ccall_ getprotobyname name
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getProtocolByName" "no such protocol entry")
+ then ioError (IOError Nothing NoSuchThing "getProtocolByName" "no such protocol entry")
else unpackProtocolEntry ptr
--getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry
getProtocolByNumber num = do
ptr <- _ccall_ getprotobynumber num
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getProtocolByNumber" "no such protocol entry")
+ then ioError (IOError Nothing NoSuchThing "getProtocolByNumber" "no such protocol entry")
else unpackProtocolEntry ptr
--getProtocolNumber :: ProtocolName -> IO ProtocolNumber
getProtocolEntry = do
ptr <- _ccall_ getprotoent
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getProtocolEntry" "no such protocol entry")
+ then ioError (IOError Nothing NoSuchThing "getProtocolEntry" "no such protocol entry")
else unpackProtocolEntry ptr
--setProtocolEntry :: Bool -> IO () -- Keep DB Open ?
getHostByName name = do
ptr <- _ccall_ gethostbyname name
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getHostByName" "no such host entry")
+ then ioError (IOError Nothing NoSuchThing "getHostByName" "no such host entry")
else unpackHostEntry ptr
getHostByAddr :: Family -> HostAddress -> IO HostEntry
addr
(packFamily family)
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getHostByAddr" "no such host entry")
+ then ioError (IOError Nothing NoSuchThing "getHostByAddr" "no such host entry")
else unpackHostEntry ptr
#ifndef cygwin32_TARGET_OS
getHostEntry = do
ptr <- _ccall_ gethostent
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getHostEntry" "unable to retrieve host entry")
+ then ioError (IOError Nothing NoSuchThing "getHostEntry" "unable to retrieve host entry")
else unpackHostEntry ptr
setHostEntry :: Bool -> IO ()
getNetworkByName name = do
ptr <- _ccall_ getnetbyname name
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getNetworkByName" "no such network entry")
+ then ioError (IOError Nothing NoSuchThing "getNetworkByName" "no such network entry")
else unpackNetworkEntry ptr
getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry
getNetworkByAddr addr family = do
ptr <- _ccall_ getnetbyaddr addr (packFamily family)
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getNetworkByAddr" "no such network entry")
+ then ioError (IOError Nothing NoSuchThing "getNetworkByAddr" "no such network entry")
else unpackNetworkEntry ptr
getNetworkEntry :: IO NetworkEntry
getNetworkEntry = do
ptr <- _ccall_ getnetent
if ptr == nullAddr
- then fail (IOError Nothing NoSuchThing "getNetworkEntry" "no more network entries")
+ then ioError (IOError Nothing NoSuchThing "getNetworkEntry" "no more network entries")
else unpackNetworkEntry ptr
setNetworkEntry :: Bool -> IO ()
getHostName = do
ptr <- stToIO (newCharArray (0,256))
rc <- _casm_ ``%r=gethostname(%0, 256);'' ptr
- if rc == -1
- then fail (userError "getHostName: unable to determine host name")
+ if rc == ((-1)::Int)
+ then ioError (userError "getHostName: unable to determine host name")
else do
ba <- stToIO (unsafeFreezeByteArray ptr)
return (unpackCStringBA ba)
\begin{code}
unpackServiceEntry :: Addr -> PrimIO ServiceEntry
unpackServiceEntry ptr = do
- str <- _casm_ ``%r = ((struct servent*)%0)->s_name;'' ptr
- name <- unpackCStringIO str
+ pname <- _casm_ ``%r = ((struct servent*)%0)->s_name;'' ptr
+ name <- unpackCStringIO pname
alias <- _casm_ ``%r = ((struct servent*)%0)->s_aliases;'' ptr
aliases <- unvectorize alias 0
port <- _casm_ ``%r = (int)(((struct servent*)%0)->s_port);'' ptr
symlink :: String -> String -> IO ()
symlink actual_path sym_path = do
rc <- _ccall_ symlink actual_path sym_path
- if rc == 0 then
+ if rc == (0::Int) then
return ()
else do
_ccall_ convertErrno
cstr <- _ccall_ getErrStr__
estr <- unpackCStringIO cstr
- fail (userError ("BSD.symlink: " ++ estr))
+ ioError (userError ("BSD.symlink: " ++ estr))
#endif
#ifdef HAVE_READLINK
_ccall_ convertErrno
cstr <- _ccall_ getErrStr__
estr <- unpackCStringIO cstr
- fail (userError ("BSD.readlink: " ++ estr))
+ ioError (userError ("BSD.readlink: " ++ estr))
where
path_max = (``PATH_MAX''::Int)
#endif