'--------------------------------------------------------------------------- ' ' InitializeCGI() - Fill in all of the CGI variables, etc. ' ' Read the profile file name from the command line, then fill in ' the CGI globals, the Accept type list and the Extra headers list. ' Then open the input and output files. ' ' Returns True if OK, False if some sort of error. See ReturnError() ' for info on how errors are handled. ' ' NOTE: Assumes that the CGI error handler has been armed with On Error '--------------------------------------------------------------------------- Sub InitializeCGI() Dim sect As String Dim argc As Integer Static argv(MAX_CMDARGS) As String Dim buf As String CGI_DebugMode = True ' Initialization errors are very bad ' ' Parse the command line. We need the profile file name (duh!) ' and the output file name NOW, so we can return any errors we ' trap. The error handler writes to the output file. ' argc = GetArgs(argv()) CGI_ProfileFile = argv(0) sect = "CGI" CGI_ServerSoftware = GetProfile(sect, "Server Software") CGI_ServerName = GetProfile(sect, "Server Name") CGI_RequestProtocol = GetProfile(sect, "Request Protocol") CGI_ServerAdmin = GetProfile(sect, "Server Admin") CGI_Version = GetProfile(sect, "CGI Version") CGI_RequestMethod = GetProfile(sect, "Request Method") buf = GetProfile(sect, "Request Keep-Alive") ' Y or N If (Left$(buf, 1) = "Y") Then ' Must start with Y CGI_RequestKeepAlive = True Else CGI_RequestKeepAlive = False End If CGI_LogicalPath = GetProfile(sect, "Logical Path") CGI_PhysicalPath = GetProfile(sect, "Physical Path") CGI_ExecutablePath = GetProfile(sect, "Executable Path") CGI_QueryString = GetProfile(sect, "Query String") CGI_RemoteHost = GetProfile(sect, "Remote Host") CGI_RemoteAddr = GetProfile(sect, "Remote Address") CGI_RequestRange = GetProfile(sect, "Request Range") CGI_Referer = GetProfile(sect, "Referer") CGI_From = GetProfile(sect, "From") CGI_UserAgent = GetProfile(sect, "User Agent") CGI_AuthUser = GetProfile(sect, "Authenticated Username") CGI_AuthPass = GetProfile(sect, "Authenticated Password") CGI_AuthRealm = GetProfile(sect, "Authentication Realm") CGI_AuthType = GetProfile(sect, "Authentication Method") CGI_ContentType = GetProfile(sect, "Content Type") buf = GetProfile(sect, "Content Length") If buf = "" Then CGI_ContentLength = 0 Else CGI_ContentLength = CLng(buf) End If buf = GetProfile(sect, "Server Port") If buf = "" Then CGI_ServerPort = -1 Else CGI_ServerPort = CInt(buf) End If sect = "System" CGI_ContentFile = GetProfile(sect, "Content File") CGI_OutputFile = GetProfile(sect, "Output File") CGI_OutputFN = FreeFile Open CGI_OutputFile For Output Access Write As #CGI_OutputFN buf = GetProfile(sect, "GMT Offset") If buf <> "" Then ' Protect against errors CGI_GMTOffset = CVDate(Val(buf) / 86400#) ' Timeserial GMT offset Else CGI_GMTOffset = 0 End If buf = GetProfile(sect, "Debug Mode") ' Y or N If (Left$(buf, 1) = "Y") Then ' Must start with Y CGI_DebugMode = True Else CGI_DebugMode = False End If GetAcceptTypes ' Enumerate Accept: types into tuples GetExtraHeaders ' Enumerate extra headers into tuples GetFormTuples ' Decode any POST form input into tuples End Sub