| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Network.NetRc
Contents
Description
Provides parser for $HOME/.netrc files
The implemented grammar is approximately:
NETRC := (WS|<comment>)* (ENTRY (WS+ <comment>*)+)* ENTRY?
ENTRY := 'machine' WS+ <value> WS+ ((account|username|password) WS+ <value>)*
| 'default' WS+ (('account'|'username'|'password') WS+ <value>)*
| 'macdef' <value> LF (<line> LF)* LF
WS := (LF|SPC|TAB)
<line> := !LF+
<value> := !WS+
<comment> := '#' !LF* LFAs an extension to the .netrc-format as described in .e.g.
netrc(5), #-style comments are
tolerated. Comments are currently only allowed before, between,
and after machine/default/macdef entries. Be aware though
that such #-comment are not supported by all .netrc-aware
applications, including ftp(1).
- data NetRc = NetRc {
- nrHosts :: [NetRcHost]
- nrMacros :: [NetRcMacDef]
- data NetRcHost = NetRcHost {
- nrhName :: !ByteString
- nrhLogin :: !ByteString
- nrhPassword :: !ByteString
- nrhAccount :: !ByteString
- nrhMacros :: [NetRcMacDef]
- data NetRcMacDef = NetRcMacDef {
- nrmName :: !ByteString
- nrmBody :: !ByteString
- netRcToBuilder :: NetRc -> Builder
- netRcToByteString :: NetRc -> ByteString
- netRcParsec :: Parser NetRc
- parseNetRc :: SourceName -> ByteString -> Either ParseError NetRc
- readUserNetRc :: IO (Maybe (Either ParseError NetRc))
Types
Represents (semantic) contents of a .netrc file
Constructors
| NetRc | |
Fields
| |
machine and default entries describe remote accounts
Invariant: fields must not contain any TABs, SPACE, or LFs.
Constructors
| NetRcHost | |
Fields
| |
data NetRcMacDef Source
macdef entries defining ftp macros
Constructors
| NetRcMacDef | |
Fields
| |
Formatters
netRcToBuilder :: NetRc -> Builder Source
Construct a ByteString Builder
netRcToByteString :: NetRc -> ByteString Source
Format NetRc into a ByteString
This is currently just a convenience wrapper around netRcToBuilder
Parsers
netRcParsec :: Parser NetRc Source
Text.Parsec.ByteString Parser for .netrc grammar
parseNetRc :: SourceName -> ByteString -> Either ParseError NetRc Source
Convenience wrapper for netRcParsec parser
This is basically just
parseNetRc=parse(netRcParsec<*eof)
This wrapper is mostly useful for avoiding to have to import Parsec
modules (and to build-depend explicitly on parsec).
Utilities
readUserNetRc :: IO (Maybe (Either ParseError NetRc)) Source
Reads and parses default $HOME/.netrc
Returns Nothing if $HOME variable undefined and/or if .netrc if missing.
Throws standard IO exceptions in case of other filesystem-errors.
Note: This function performs no permission sanity-checking on
the .netrc file