diff options
author | Araq <rumpf_a@web.de> | 2010-11-18 22:26:20 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2010-11-18 22:26:20 +0100 |
commit | adf13aaea379d482ad4289d349a9d475bc2c06a6 (patch) | |
tree | 4c18d447545c35fa7c1f4ce7db566f96db67a080 /lib/pure/cookies.nim | |
parent | 8ee63f98364259b2d1b6c02d050e0efccecbcf9b (diff) | |
download | Nim-adf13aaea379d482ad4289d349a9d475bc2c06a6.tar.gz |
docgen understands and ignores *when false*
Diffstat (limited to 'lib/pure/cookies.nim')
-rw-r--r-- | lib/pure/cookies.nim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/pure/cookies.nim b/lib/pure/cookies.nim new file mode 100644 index 000000000..eed6c7512 --- /dev/null +++ b/lib/pure/cookies.nim @@ -0,0 +1,30 @@ +# +# +# Nimrod's Runtime Library +# (c) Copyright 2010 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module implements helper procs for parsing Cookies. + +import strtabs + +proc parseCookies*(s: string): PStringTable = + ## parses cookies into a string table. + result = newStringTable(modeCaseInsensitive) + var i = 0 + while true: + while s[i] == ' ' or s[i] == '\t': inc(i) + var keystart = i + while s[i] != '=' and s[i] != '\0': inc(i) + var keyend = i-1 + if s[i] == '\0': break + inc(i) # skip '=' + var valstart = i + while s[i] != ';' and s[i] != '\0': inc(i) + result[copy(s, keystart, keyend)] = copy(s, valstart, i-1) + if s[i] == '\0': break + inc(i) # skip ';' + |