[go: up one dir, main page]

File: cgi.chh

package info (click to toggle)
chpp 0.3.2-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,024 kB
  • ctags: 5,131
  • sloc: ansic: 29,956; cpp: 575; sh: 500; makefile: 314; yacc: 265; asm: 261; lex: 64
file content (68 lines) | stat: -rw-r--r-- 2,718 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef __CGI_CHH__
#define __CGI_CHH__
#include files.chh
\
%define(translateCRLF,str,
    %sgsub([%schr(13)][%schr(10)],%str,%'\n')
)\
\
%define(cgiGetParameters,
%locals(result,lst,contype,conparm,line,regs,value,name,qstring,
    %<result=%hash()>\
    %if(%hcontains(%env,CONTENT_TYPE),
        %<lst=%ssplit(%'[ \n\t]*;[ \n\t]*',%env{CONTENT_TYPE})>\
        %<contype=%lst[0]>\
        %ldelete(%&lst,0)\
        %<conparm=%hash()>\
        %foreach(str,%lst,
            %<lst=%ssplit(=,%str)>\
            %if(%[%llength(%lst)==2],
                %<conparm{%lst[0]}=%lst[1]>
            )
        )
    ,
        %<contype=application/x-www-form-urlencoded>
    )\
    %case(%contype,
        %list(application/x-www-form-urlencoded),
            %if(%[%slength(%env{QUERY_STRING}) > 0],
                %<qstring=%env{QUERY_STRING}>
            ,
                %<qstring=%frest(%stdin)>
            )\
            %foreach(str,%ssplit(&,%qstring),
                %<lst=%ssplit(=,%str)>\
                %if(%[%llength(%lst)==2],
                    %<result{%lst[0]}=%w3urldecode(%lst[1])>
                )
            ),
        %list(multipart/form-data),
            %<regs=%list()>\
            %<line=%translateCRLF(%fgets(%stdin))>\
            %while(%and(%not(%feof(%stdin)),%equal(%line,--%conparm{boundary}%'\n')),
                 %<line=%translateCRLF(%fgets(%stdin))>\
                 %if(%[%smatch(%'^Content-Disposition: form-data; name=\"([^\"]+)\"(; filename=\"([^\"]+)\")?',%line,%&regs) != -1],
                     %<name=%regs[1]>\
                     %if(%slength(%regs[2]),
                         %<value=%hash(filename,%regs[3])>\
                         %<line=%translateCRLF(%fgets(%stdin))>\
                         %if(%not(%smatch(%'^Content-Type: (.+)',%line,%&regs)),
                             %<value{type}=%regs[1]>\
                             %<line=%fgets(%stdin)>
                         )\
                         %<line=%translateCRLF(%fgets(%stdin))>\
                         %<value{content}=%while(%smatch(^--%conparm{boundary},%line),%line%<line=%translateCRLF(%fgets(%stdin))>)>\
                         %<value{content}=%ssub(%value{content},0,%[%slength(%value{content})-1])>
                     ,
                         %<line=%fgets(%stdin)>\
                         %<line=%translateCRLF(%fgets(%stdin))>\
                         %<value=%while(%smatch(^--%conparm{boundary},%line),%line%<line=%translateCRLF(%fgets(%stdin))>)>\
                         %<value=%ssub(%value,0,%[%slength(%value)-1])>
                     )\
                     %<result{%name}=%&value>
                 )
            )
    )\
    %&result
))\
#endif