Copyright | Matthew Harm Bekkema 2016 |
---|---|
License | GPL-2 |
Maintainer | mbekkema97@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe |
Language | Haskell2010 |
This module handles the Haskell representation of a passlist. A passlist file should have the following format:
Each entry separated by a newline. Each field of an entry separated by a tab.
The fields in order are: passListEntryInfo
, passListEntryLength
and
passListEntryMode
. If any field is missing or unparsable, default values
will be used.
This example passlist file:
google.com projecteuler.net 32 wiki.haskell.org Max nl
Would be parsed as the following PassList
:
[ PassListEntry {passListEntryInfo = "google.com", passListEntryLength = Nothing, passListEntryMode = ncl} , PassListEntry {passListEntryInfo = "projecteuler.net", passListEntryLength = Just 32, passListEntryMode = ncl} , PassListEntry {passListEntryInfo = "wiki.haskell.org", passListEntryLength = Nothing, passListEntryMode = nl} ]
- type PassList = [PassListEntry]
- data PassListEntry = PassListEntry {}
- stringToEntry :: String -> PassListEntry
- fileToEntries :: FilePath -> IO (Either IOException PassList)
- entryToString :: PassListEntry -> String
- entriesToFile :: FilePath -> PassList -> IO (Maybe IOException)
Data structures
type PassList = [PassListEntry] Source
Represents the password list.
data PassListEntry Source
Represents an entry in the password list.
PassListEntry | |
|
Parsing
stringToEntry :: String -> PassListEntry Source
Parses a string into a PassListEntry
. Should be used on each line of the
passlist file.
fileToEntries :: FilePath -> IO (Either IOException PassList) Source
Loads the specified file and parses it into a PassList
. Catches and
returns the IOException
on failure.
Saving
entryToString :: PassListEntry -> String Source
Turns a PassListEntry
back into a string parsable by stringToEntry
.
entriesToFile :: FilePath -> PassList -> IO (Maybe IOException) Source
Saves the PassList
to file. Catches and returns the IOException
on
failure.