\begin{code}
{-# OPTIONS -#include "cbits/ghcSockets.h" #-}
+#include "config.h"
+
module BSD (
HostName,
getServiceByName, -- :: ServiceName -> ProtocolName -> IO ServiceEntry
getServiceByPort, -- :: PortNumber -> ProtocolName -> IO ServiceEntry
getServicePortNumber, -- :: ServiceName -> IO PortNumber
+
+#ifndef cygwin32_TARGET_OS
getServiceEntry, -- :: IO ServiceEntry
setServiceEntry, -- :: Bool -> IO ()
endServiceEntry, -- :: IO ()
getServiceEntries, -- :: Bool -> IO [ServiceEntry]
+#endif
ProtocolName,
ProtocolNumber,
getProtocolByNumber, -- :: ProtocolNumber -> IO ProtcolEntry
getProtocolNumber, -- :: ProtocolName -> ProtocolNumber
+#ifndef cygwin32_TARGET_OS
setProtocolEntry, -- :: Bool -> IO ()
getProtocolEntry, -- :: IO ProtocolEntry
endProtocolEntry, -- :: IO ()
getProtocolEntries, -- :: Bool -> IO [ProtocolEntry]
+#endif
PortNumber,
mkPortNumber, -- :: Int -> PortNumber
getHostByAddr, -- :: HostAddress -> Family -> IO HostEntry
hostAddress, -- :: HostEntry -> HostAddress
+#ifndef cygwin32_TARGET_OS
setHostEntry, -- :: Bool -> IO ()
getHostEntry, -- :: IO HostEntry
endHostEntry, -- :: IO ()
getHostEntries, -- :: Bool -> IO [HostEntry]
+#endif
NetworkName,
NetworkAddr,
NetworkEntry(..),
+#ifndef cygwin32_TARGET_OS
getNetworkByName, -- :: NetworkName -> IO NetworkEntry
getNetworkByAddr, -- :: NetworkAddr -> Family -> IO NetworkEntry
setNetworkEntry, -- :: Bool -> IO ()
getNetworkEntry, -- :: IO NetworkEntry
endNetworkEntry, -- :: IO ()
getNetworkEntries -- :: Bool -> IO [NetworkEntry]
-
-) where
+#endif
+ ) where
import GlaExts
(ServiceEntry _ _ port _) <- getServiceByName name "tcp"
return port
+#ifndef cygwin32_TARGET_OS
getServiceEntry :: IO ServiceEntry
getServiceEntry = do
ptr <- _ccall_ getservent
getServiceEntries stayOpen = do
setServiceEntry stayOpen
getEntries (getServiceEntry) (endServiceEntry)
-
+#endif
\end{code}
The following relate directly to the corresponding \tr{UNIX} {C} calls for
getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry
getProtocolNumber :: ProtocolName -> IO ProtocolNumber
+#ifndef cygwin32_TARGET_OS
setProtocolEntry :: Bool -> IO () -- Keep DB Open ?
getProtocolEntry :: IO ProtocolEntry -- Next Protocol Entry from DB
endProtocolEntry :: IO ()
getProtocolEntries :: Bool -> IO [ProtocolEntry]
+#endif
\end{code}
\begin{code}
(ProtocolEntry _ _ num) <- getProtocolByName proto
return num
+#ifndef cygwin32_TARGET_OS
--getProtocolEntry :: IO ProtocolEntry -- Next Protocol Entry from DB
getProtocolEntry = do
ptr <- _ccall_ getprotoent
getProtocolEntries stayOpen = do
setProtocolEntry stayOpen
getEntries (getProtocolEntry) (endProtocolEntry)
+#endif
\end{code}
then fail (IOError Nothing NoSuchThing "no such host entry")
else unpackHostEntry ptr
+#ifndef cygwin32_TARGET_OS
getHostEntry :: IO HostEntry
getHostEntry = do
ptr <- _ccall_ gethostent
getHostEntries stayOpen = do
setHostEntry stayOpen
getEntries (getHostEntry) (endHostEntry)
-
+#endif
\end{code}
%***************************************************************************
networkFamily :: Family, -- type
networkAddress :: NetworkAddr
}
-
+#ifndef cygwin32_TARGET_OS
getNetworkByName :: NetworkName -> IO NetworkEntry
getNetworkByName name = do
ptr <- _ccall_ getnetbyname name
getNetworkEntries stayOpen = do
setNetworkEntry stayOpen
getEntries (getNetworkEntry) (endNetworkEntry)
+#endif
\end{code}