An example in powerbasic #COMPILE EXE "FCGIecho.exe" ' #INCLUDE "FCGX_Header.bas" '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤' FUNCTION WINMAIN LOCAL i, StdInLen, DecLen AS LONG LOCAL sReply, sTemp AS STRING LOCAL FCGXReq AS FCGX_REQUEST ' ' Intialize Databases etc here '- Create the STDIN/STDOUT/STDERR buffers, Connect with the Web Server IF FCGX_InitRequest(FCGXReq, 0, 0) < 0 THEN EXIT FUNCTION ' Error Occured DO '- Execution blocked here until an HTTP request arrives IF FCGX_Accept_r(FCGXReq) < 0 THEN 'IF RetVal <> -1 THEN PRINT #hClientDbg, FCGXReq.@pzLastErr ' Error Occured not SIGTERM EXIT LOOP END IF '============ '- The reply must begin with a valid HTTP header sReply = "Content-Type: text/html" + $CRLF+$CRLF sReply = sReply + "ReqCount: " + STR$(FCGXReq.ReqCount)+"<BR>" ' Request Count '============ '- Echo the Query String IF LEN(FCGXReq.@pzQuery) THEN sReply = sReply + "'GET' Data: <BR>" sReply = sReply + FCGXReq.@pzQuery + "<BR>" END IF sReply = sReply + "<BR>" '============ '- Echo any POST data StdInLen = FCGXReq.@pIn.LenStored IF StdInLen THEN sReply = sReply + "CONTENT_LENGTH: " + STR$(FCGXReq.ContLen)+"<BR>" sReply = sReply + "StdInLen=" + STR$(StdInLen)+"<BR>" sTemp = NUL$(StdInLen) ' Create a string lng enough for the return IF FCGX_GetStr(STRPTR(sTemp), StdInLen, FCGXReq.pIn) < 0 THEN EXIT LOOP ' Fill sTemp from the StdIn Buffer sReply = sReply + "'POST' Data: <BR> <PRE>" ' Show text as formatted DecLen = FCGX_URLDecode(STRPTR(sTemp), LEN(sTemp)) ' Decode in place sReply = sReply + LEFT$(sTemp, DecLen) +"</PRE><BR>" ' Decoded END IF '============ '- Put the Reply in the STDOUT buffer IF FCGX_PutStr(STRPTR(sReply), LEN(sReply), FCGXReq.pOut) < 0 THEN EXIT LOOP ' Error Occured '- Flush Buffers, Send Request Termination Record, Empty the STDIN/STDOUT/STDERR buffers IF FCGX_Finish_r(FCGXReq) < 0 THEN EXIT LOOP ' Error Occured LOOP ' Close Databases etc here END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤' |