Anonymous avatar Anonymous committed 5f5749f

Experiments with haddock

Comments (0)

Files changed (1)

Network/DNSSD/Services.chs

 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE TypeFamilies #-}
 module Network.DNSSD.Services
-     ( register
-     , browse
-     , createPortMapping
-     , resolve
-     , getAddrInfo
-     , enumerateDomains
-     , enumerateDomainsS
-     , ServiceResult
+    (
+-- * Common types
+       ServiceResult
      , ServiceRef
-     , BrowseReply          (..)
      , ReplyWithInterface   (..)
-     , RegisterReply        (..)
-     , PortMappingReply     (..)
-     , ResolveReply         (..)
-     , EnumerateDomainsReply(..)
      , DNSServiceProtocol   (..)
      , Proto
      , DNSServiceFlag       (..)
      , StopService          (..)
+     , CallbackFunc
+     , Flags
+     , InterfaceIndex
+     , ServiceFunc
+-- * DNS-SD functionality
+-- $stopService
+
+-- ** Service registration
+     , register
+     , RegisterReply        (..)
+-- ** Browsing for services     
+     , browse
+     , BrowseReply          (..)
+-- ** NAT port mapping
+     , createPortMapping
+     , PortMappingReply     (..)
+-- ** Service resolving
+     , resolve
+     , ResolveReply         (..)
+-- ** Quering address information
+     , getAddrInfo
+     , GetAddrInfoReply     (..)
+-- ** Domain enumeration
+     , enumerateDomains
+     , enumerateDomainsS
+     , EnumerateDomainsReply(..)
 )-- {{{
  where
+
+
 import Foreign.Ptr
 import Foreign.C.Types
 
 
 #include <dns_sd.h>
 
+-- $stopService
+-- dns-sd functions return the instance of 'StopService'. 'stopService' function should be used to
+-- stop the running service and prevent future invocations of a callback function. The service
+-- is active until stopped
 
 type Proto = [DNSServiceProtocol] -- {{{
 marshalProto :: Proto -> CUInt
 
 
 -- Service replies {{{
+-- | Most callbacks take 'InterfaceIndex' and 'Flags' parameters so we group them together
 data ReplyWithInterface = ReplyWithInterface Flags InterfaceIndex deriving Show 
 data EnumerateDomainsReply t = EnumerateDomainsReply ReplyWithInterface t deriving Show
 data BrowseReply t = BrowseReply {brIfaceFlag :: ReplyWithInterface , brServiceName :: t, brRegType :: t, brDomain :: t} deriving Show
 data RegisterReply t = RegisterReply 
     Flags
-    t     -- name
-    t     -- regtype
-    t     -- domain
+    t     --  name
+    t     --  regtype
+    t     --  domain
  deriving Show
 
 data PortMappingReply = PortMappingReply
 
 type family DeFun t
 type instance DeFun (FunPtr t) = t
+
+-- | All services take 'CallbackFunc', 'Flags' and 'InterfaceIndex' parameters so we capture 
+-- | this with 'ServiceFunc' type
 type ServiceFunc cb = CallbackFunc cb -> Flags -> InterfaceIndex -> IO (ServiceResult ServiceRef)
 
 -- Enum domains {{{ 
 foreign import ccall "wrapper"
     mkEnumDomainReply :: DeFun DNSServiceDomainEnumReply -> IO DNSServiceDomainEnumReply
 
-
+-- | Enumerate domains (browse or registration).
 enumerateDomains :: StringLike a => ServiceFunc (EnumerateDomainsReply a)
 enumerateDomains cb = 
         createAll 
 
 register 
     :: StringLike t
-    => Maybe t
-    -> t
-    -> Maybe t
-    -> Maybe t
-    -> PortNumber
-    -> Maybe ByteString
-    -> CallbackFunc (RegisterReply t)
-    -> Flags
+    => Maybe t                                  -- ^ name of service
+    -> t                                        -- ^ registration type (like "_ssh._tcp")
+    -> Maybe t                                  -- ^ domain to register in
+    -> Maybe t                                  -- ^ host
+    -> PortNumber                               -- ^ 'PortNumber' on which service is running
+    -> Maybe ByteString                         -- ^ TXT record
+    -> CallbackFunc (RegisterReply t)           -- ^ Callback function
+    -> Flags                                    
     -> InterfaceIndex 
     -> IO (ServiceResult (RecServiceRefAdd))
 register nq rq dq hq p txt cb = 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.