-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Parser for .netrc files
--   
--   This package provides a parser and a printer for so-called
--   <tt>.netrc</tt> files.
--   
--   See <a>netrc(5)</a> manual page for more information about
--   <tt>.netrc</tt> files.
@package netrc
@version 0.2.0.0


-- | Provides parser for <tt>$HOME/.netrc</tt> files
--   
--   The implemented grammar is approximately:
--   
--   <pre>
--   NETRC := (WS|&lt;comment&gt;)* (ENTRY (WS+ &lt;comment&gt;*)+)* ENTRY?
--   
--   ENTRY := 'machine' WS+ &lt;value&gt; WS+ ((account|username|password) WS+ &lt;value&gt;)*
--          | 'default' WS+ (('account'|'username'|'password') WS+ &lt;value&gt;)*
--          | 'macdef' &lt;value&gt; LF (&lt;line&gt; LF)* LF
--   
--   WS := (LF|SPC|TAB)
--   
--   &lt;line&gt;  := !LF+
--   &lt;value&gt; := !WS+
--   &lt;comment&gt; := '#' !LF* LF
--   </pre>
--   
--   As an extension to the <tt>.netrc</tt>-format as described in .e.g.
--   <a>netrc(5)</a>, <tt>#</tt>-style comments are tolerated. Comments are
--   currently only allowed before, between, and after
--   <tt>machine</tt>/<tt>default</tt>/<tt>macdef</tt> entries. Be aware
--   though that such <tt>#</tt>-comment are not supported by all
--   <tt>.netrc</tt>-aware applications, including <tt>ftp(1)</tt>.
module Network.NetRc

-- | Represents (semantic) contents of a <tt>.netrc</tt> file
data NetRc
NetRc :: [NetRcHost] -> [NetRcMacDef] -> NetRc

-- | <tt>machine</tt>/<tt>default</tt> entries
--   
--   <b>Note</b>: If it exists, the <tt>default</tt> entry ought to be the
--   last entry, otherwise it can cause later entries to become invisible
--   for some implementations (e.g. <tt>ftp(1)</tt>)
[nrHosts] :: NetRc -> [NetRcHost]

-- | Non-associated <tt>macdef</tt> entries
--   
--   <b>Note</b>: <tt>macdef</tt> entries not associated with host-entries
--   are invisible to some applications (e.g. <tt>ftp(1)</tt>).
[nrMacros] :: NetRc -> [NetRcMacDef]

-- | <tt>machine</tt> and <tt>default</tt> entries describe remote accounts
--   
--   <b>Invariant</b>: fields must not contain any <tt>TAB</tt>s,
--   <tt>SPACE</tt>, or <tt>LF</tt>s.
data NetRcHost
NetRcHost :: !ByteString -> !ByteString -> !ByteString -> !ByteString -> [NetRcMacDef] -> NetRcHost

-- | Remote machine name (<tt>""</tt> for <tt>default</tt>-entries)
[nrhName] :: NetRcHost -> !ByteString

-- | <tt>login</tt> property (<tt>""</tt> if missing)
[nrhLogin] :: NetRcHost -> !ByteString

-- | <tt>password</tt> property (<tt>""</tt> if missing)
[nrhPassword] :: NetRcHost -> !ByteString

-- | <tt>account</tt> property (<tt>""</tt> if missing)
[nrhAccount] :: NetRcHost -> !ByteString

-- | associated <tt>macdef</tt> entries
[nrhMacros] :: NetRcHost -> [NetRcMacDef]

-- | <tt>macdef</tt> entries defining <tt>ftp</tt> macros
data NetRcMacDef
NetRcMacDef :: !ByteString -> !ByteString -> NetRcMacDef

-- | Name of <tt>macdef</tt> entry
--   
--   <b>Invariant</b>: must not contain any <tt>TAB</tt>s, <tt>SPACE</tt>,
--   or <tt>LF</tt>s
[nrmName] :: NetRcMacDef -> !ByteString

-- | Raw <tt>macdef</tt> body
--   
--   <b>Invariant</b>: must not contain null-lines, i.e. consecutive
--   <tt>LF</tt>s
[nrmBody] :: NetRcMacDef -> !ByteString

-- | Construct a <a>ByteString</a> <a>Builder</a>
netRcToBuilder :: NetRc -> Builder

-- | Format <a>NetRc</a> into a <a>ByteString</a>
--   
--   This is currently just a convenience wrapper around
--   <a>netRcToBuilder</a>
netRcToByteString :: NetRc -> ByteString

-- | <a>Text.Parsec.ByteString</a> <a>Parser</a> for <tt>.netrc</tt>
--   grammar
netRcParsec :: Parser NetRc

-- | Convenience wrapper for <a>netRcParsec</a> parser
--   
--   This is basically just
--   
--   <pre>
--   <a>parseNetRc</a> = <a>parse</a> (<a>netRcParsec</a> &lt;* <a>eof</a>)
--   </pre>
--   
--   This wrapper is mostly useful for avoiding to have to import Parsec
--   modules (and to build-depend explicitly on <tt>parsec</tt>).
parseNetRc :: SourceName -> ByteString -> Either ParseError NetRc

-- | Reads and parses default <tt>$HOME/.netrc</tt>
--   
--   Returns <a>Nothing</a> if <tt>$HOME</tt> variable undefined and/or if
--   <tt>.netrc</tt> if missing. Throws standard IO exceptions in case of
--   other filesystem-errors.
--   
--   <b>Note</b>: This function performs no permission sanity-checking on
--   the <tt>.netrc</tt> file
readUserNetRc :: IO (Maybe (Either ParseError NetRc))
instance GHC.Show.Show Network.NetRc.PVal
instance GHC.Generics.Generic Network.NetRc.NetRc
instance Data.Data.Data Network.NetRc.NetRc
instance GHC.Show.Show Network.NetRc.NetRc
instance GHC.Classes.Ord Network.NetRc.NetRc
instance GHC.Classes.Eq Network.NetRc.NetRc
instance GHC.Generics.Generic Network.NetRc.NetRcHost
instance Data.Data.Data Network.NetRc.NetRcHost
instance GHC.Show.Show Network.NetRc.NetRcHost
instance GHC.Classes.Ord Network.NetRc.NetRcHost
instance GHC.Classes.Eq Network.NetRc.NetRcHost
instance GHC.Generics.Generic Network.NetRc.NetRcMacDef
instance Data.Data.Data Network.NetRc.NetRcMacDef
instance GHC.Show.Show Network.NetRc.NetRcMacDef
instance GHC.Classes.Ord Network.NetRc.NetRcMacDef
instance GHC.Classes.Eq Network.NetRc.NetRcMacDef
instance Control.DeepSeq.NFData Network.NetRc.NetRc
instance Control.DeepSeq.NFData Network.NetRc.NetRcHost
instance Control.DeepSeq.NFData Network.NetRc.NetRcMacDef
