#!/bin/sh # yawp! crlf() { # crlf < INPUT ## Convert LF to CRLF sed 's/$/ /g' } http_response() { # http_response [STATUS:-200 OK] < CONTENT cat <
$(env) $(cat | tee /dev/shm/yawp)
$(form_decode < /dev/shm/yawp)
EOF } form_decode() { # form_decode << INPUT (application/x-www-form-urlencoded) # TODO: multipart/form-data ..? crlf | awk '/%[0-9A-Fa-f][0-9A-Fa-f]/ { while (s = match($0, "%[0-9A-Fa-f][0-9a-fA-F]") > 0) { chr = ""; hexdigits = "0123456789abcdef"; value = 16 * (index(hexdigits,tolower(substr($0,RSTART+1,1))) - 1); value += index(hexdigits,tolower(substr($0,RSTART+2,1))) - 1; chr = sprintf("%c", value); value = 0; $0 = substr($0, 1, RSTART - 1) chr substr($0, RSTART + RLENGTH); } } {gsub(/+/," ");gsub(/&/,"\n");print} ' } new_post() { http_response < YAWP!

EOF } display_posts() { debug_env } main "$@"