G:/ScriptBasic/source/extensions/cgi/interface.c

Go to the documentation of this file.
00001 /*
00002 
00003   FILE   : interface.c
00004   HEADER : interface.h
00005   BAS    : cgi.bas
00006   AUTHOR: Peter Verhas
00007 
00008   DATE: June 22, 2002.
00009 
00010   CONTENT:
00011   This is the interface.c file for the ScriptBasic module CGI
00012 
00013 NTLIBS:
00014 UXLIBS:
00015 DWLIBS:
00016 MCLIBS:
00017 */
00018 
00019 #include <stdio.h>
00020 #include <string.h>
00021 
00022 #ifdef WIN32
00023 #include <httpext.h>
00024 #endif
00025 
00026 #include "../../basext.h"
00027 #include "cgi.h"
00028 
00029 /*
00030 TO_BAS:
00031 ' When requestiong SaveFile for a field name that does not exist
00032 const ErrorNoFile           = &H00080000
00033 const ErrorBufferOverflow   = &H00080001
00034 const ErrorContentTooLarge  = &H00080002
00035 const ErrorMethodIsInvalid  = &H00080003
00036 const ErrorNoDebugFile      = &H00080004
00037 const ErrorNotImplemented   = &H00080005
00038 const ErrorEndOfFile        = &H00080006
00039 const ErrorIllFormedUpload  = &H00080007
00040 const ErrorFileTooLarge     = &H00080008
00041 const ErrorMethodNotAllowed = &H0008000A
00042 
00043 ' constants for setting option cgi$Method
00044 const None   = &H00000000
00045 const Get    = &H00000001
00046 const Post   = &H00000002
00047 const Upload = &H00000006
00048 const Put    = &H00000008
00049 const Del    = &H00000010
00050 const Copy   = &H00000020
00051 const Move   = &H00000040
00052 const Head   = &H00000080
00053 
00054 Function Param(ParameterName)
00055 local ParameterValue
00056 
00057   ParameterValue = GetParam(ParameterName)
00058   If NOT IsDefined(ParameterValue) Then
00059     ParameterValue = PostParam(ParameterName)
00060   End If
00061 
00062   Param = ParameterValue
00063 End Function
00064 
00065 '
00066 ' cgi::ResolveHtml(Text)
00067 ' Resolve an HTML text given as argument
00068 '
00069 sub ResolveHtml(HtmlText)
00070   ResolveHtml = GetHtmlTemplate(HtmlText,1)
00071 end sub
00072 
00073 '
00074 ' cgi::EmitHtmlTemplate(FileName)
00075 ' emit the content of the HTML template to the web client
00076 '
00077 sub EmitHtmlTemplate(FileName)
00078   print GetHtmlTemplate(FileName)
00079 end sub
00080 
00081 sub Header(State,ContentType)
00082   if isDefined(HeaderWasPrinted) then exit sub
00083   HeaderWasPrinted = TRUE
00084   if ServerSoftware() like "Microsoft-IIS*" then
00085     print "HTTP/1.0 ",State,"\nContent-Type: ",ContentType,"\n"
00086   else
00087     print "Status: ",State,"\nContent-Type: ",ContentType,"\n"
00088   end if
00089 end sub
00090 
00091 sub RequestBasicAuthentication(Realm)
00092   if not IsDefined(Realm) then Realm = "Basic Authentication Realm"
00093   Header 401,"text/html"
00094   print "WWW-Authenticate: Basic realm=\"",Realm,"\"\n"
00095 end sub
00096 
00097 sub SetCookie(CookieName,CookieValue,CookieDomain,CookiePath,CookieExpires,CookieIsSecure)
00098   print "Set-cookie: ",CookieName,"=",CookieValue,";"
00099   if IsDefined( CookieDomain ) then
00100     print " domain=",CookieDomain,";"
00101   end if
00102   if IsDefined( CookiePath ) then
00103     print " path=",CookiePath,";"
00104   end if
00105   if IsDefined(CookieExpires) then
00106     print FormatDate("expires=WDN, DD-MON-YY HH:mm:ss GMT;",CookieExpires)
00107   end if
00108 'Wdy, DD-Mon-YY HH:MM:SS GMT
00109   if CookieIsSecure then
00110     print " secure"
00111   end if
00112   print "\n"
00113 end sub
00114 
00115 sub FinishHeader
00116   if isDefined(HeaderWasFinished) then exit sub
00117   HeaderWasFinished = TRUE
00118   print "\n"
00119 end sub
00120 
00121 function Cookie(CookieName)
00122   local RawCookieText,CookieList,i,LikeString,CookieValue
00123 
00124   RawCookieText = RawCookie()
00125   splita RawCookieText by ";" to CookieList
00126   LikeString = CookieName & "=*"
00127   i = 0
00128   while IsDefined(CookieList[i])
00129    CookieList[i] = trim(CookieList[i])
00130    if CookieList[i] LIKE LikeString then
00131      split CookieList[i] by "=" to CookieName,CookieValue
00132      Cookie = CookieValue
00133      exit function
00134    end if
00135    i = i + 1
00136   wend
00137 ' by default function return value is undef when cookie is not found
00138 end function
00139 
00140 */
00141 
00183 
00219 
00254 
00284 
00308 
00322 
00360 
00420 
00481 
00563 
00609 
00646 
00711 
00734 
00737 
00744 
00747 
00754 
00757 
00766 
00769 
00787 
00790 
00800 
00803 
00810 
00813 
00820 
00823 
00832 
00835 
00847 
00850 
00857 
00860 
00869 
00872 
00879 
00882 
00888 
00891 
00899 
00902 
00909 
00912 
00921 
00924 
00932 
00958 
00961 
01004 
01196 
01201 
01231 
01247 
01264 
01312 
01321 
01366 
01367 
01368 
01369 
01375 
01392 
01394 
01406 
01408 
01410 
01421 
01422 
01424 
01426 
01438 
01441 
01455 
01460 
01461 
01462 
01468 
01481 
01482 
01494 
01496 
01498 
01506 
01507 
01509 
01511 
01526 
01536 
01537 
01540 

Generated on Sun Mar 12 23:56:28 2006 for ScriptBasic by  doxygen 1.4.6-NO