@program lib-cgiparse.muf 1 10000 d i $include $lib/alynna $include $lib/cgi $pubdef : $def }w }cat descr swap descrnotify $def WWW "$var/www" match $def mpiprop "WWW" 0 parseprop $def mpilist "{eval:{list:" swap strcat ",this}}" strcat "WWW" 0 parsempi $def mpiparse "WWW" 0 parsempi $pubdef }w }cat descr swap descrnotify $pubdef WWW "$var/www" match $pubdef mpiprop "WWW" 0 parseprop $pubdef mpilist "{eval:{list:" swap strcat ",this}}" strcat "WWW" 0 parsempi $pubdef mpiparse "WWW" 0 parsempi $pubdef writelist foreach swap pop { swap myref dup not if pop me @ then swap mpiparse "
" }w repeat $pubdef writelistraw foreach swap pop { swap }w repeat $pubdef setlist { swap foreach swap pop dup not if pop "{null}" then repeat }array array_put_proplist $pubdef getlist array_get_proplist { swap foreach swap pop dup not if pop "" then dup "{null}" stringcmp not if pop "" then repeat }array $pubdef tagesc "'" "'" subst "<" "<" subst ">" ">" subst : inline[ str:quick -- dirty ] var dirty { "$include $lib/alynna" "$include $lib/cgiparse" "INCLUDE_WEBVARS" ": quick" "PARSE_HEADERS" quick @ "; PUBLIC quick" }array quick ! frand ftostr "" "0." subst newprogram dirty ! dirty @ "*WebForth" match setown dirty @ 1 quick @ program_insertlines pop dirty @ 0 compile not if dirty @ recycle "INLINE: Error compiling MUF code" exit then depth try dirty @ "quick" call catch dirty @ recycle "INLINE: " swap strcat exit endcatch dirty @ recycle ; PUBLIC inline ( ************** Begin Alynna's header parse ******************** ) $def data webdata @ swap [] $def head webheaders @ swap [] $def post postdata @ swap [] 0 [] $def raw postdata @ swap [] $def INCLUDE_WEBVARS lvar webdata lvar webheaders lvar postdata lvar wpath lvar wparam $def PARSE_HEADERS cgiparse webdata ! webheaders ! postdata ! wpath ! wparam ! $pubdef data webdata @ swap [] $pubdef head webheaders @ swap [] $pubdef post postdata @ swap [] 0 [] $pubdef raw postdata @ swap [] $pubdef INCLUDE_WEBVARS lvar webdata lvar webheaders lvar postdata lvar wpath lvar wparam $pubdef PARSE_HEADERS cgiparse webdata ! webheaders ! postdata ! wpath ! wparam ! INCLUDE_WEBVARS : cgiparse[ -- str:param str:path ] "USER.SOCKINFO" event_exists if { "USER.SOCKINFO" }list event_waitfor pop "Data" [] else descr httpdata then webdata ! "HeaderData" data webheaders ! "POSTDATA" data dup array? not if pop 0 then postdata ! "TheDEST" data "?" split swap webdata @ "path" ->[] webdata ! webdata @ "param" ->[] webdata ! "param" data wparam ! "path" data wpath ! wparam @ wpath @ postdata @ webheaders @ webdata @ ; PUBLIC cgiparse $libdef cgiparse : mpi.handler var cmd var arg PARSE_HEADERS " " split arg ! cmd ! cmd @ tolower case "data" smatch when arg @ data tostr end "inline" smatch when arg @ inline tostr end "head" smatch when arg @ head tostr end "post" smatch when arg @ post tostr end "raw" smatch when arg @ raw tostr end "path" smatch when wpath @ tostr end "param" smatch when wparam @ tostr end "pver" smatch when version "(" split swap pop ")" split pop end endcase ; . c q @reg lib-cgiparse=lib/cgiparse @set #0=_msgmacs/wcgi: @set #0=_msgmacs/wdata:{muf:$lib/cgiparse,data {:1}} @set #0=_msgmacs/winline:{muf:$lib/cgiparse,inline {:1}} @set #0=_msgmacs/whead:{muf:$lib/cgiparse,head {:1}} @set #0=_msgmacs/wpost:{muf:$lib/cgiparse,post {:1}} @set #0=_msgmacs/wraw:{muf:$lib/cgiparse,raw {:1}} @set #0=_msgmacs/wpath:{muf:$lib/cgiparse,path} @set #0=_msgmacs/wparam:{muf:$lib/cgiparse,param} @set #0=_msgmacs/wver:{muf:$lib/cgiparse,pver} @set #0=_msgmacs/inline:{muf:$muf/inline,{:1}}