Rebol Programming/decode-cgi

= USAGE: = DECODE-CGI args

= DESCRIPTION: = Converts CGI argument string to a block of set-words and value strings.

DECODE-CGI is a function value. = ARGUMENTS =
 * args -- Starts at first argument word. (Type: any-string)

= SOURCE CODE = decode-cgi: func [ {Converts CGI argument string to a block of set-words and value strings.} args [any-string!] "Starts at first argument word." /local block name value here tmp ][   block: make block! 7    parse/all args [ any [ copy name [to #"=" | to #"&" | to end] skip here: (               if tmp: find name #"&" [                    here: skip here (offset? tmp name) - 2                    clear tmp                ]                 name: to-set-word dehex name                 either tmp: find block name [                    tmp: next tmp                     if not block? value: first tmp [                        change/only tmp reduce [value]                    ]                     tmp: first tmp                ] [                    append tmp: block name                ]            ) :here [ [copy value to #"&" skip | copy value to end] (                   append tmp either none? value [copy ""] [                        replace/all dehex replace/all value #"+" #" " crlf newline                    ]                ) ]       ]         end ]    block ]