'--------------------------------------------------------------------------- ' ' GetFormTuples() - Create the array of POST form input key=value pairs ' '--------------------------------------------------------------------------- Private Sub GetFormTuples() Dim sList As String Dim i As Integer, j As Integer, k As Integer Dim l As Integer, m As Integer, n As Integer Dim s As Long Dim buf As String Dim extName As String Dim extFile As Integer Dim extlen As Long n = 0 ' Index in array ReDim Preserve CGI_FormTuples(n) As Tuple ' Increase array size ' ' Do the easy one first: [Form Literal] ' sList = GetProfile("Form Literal", "") ' Get key list l = Len(sList) ' Length incl. trailing null i = 1 ' Start at 1st character Do While i < l ' Safety stop here j = InStr(i, sList, Chr$(0)) ' J -> next null CGI_FormTuples(n).key = Mid$(sList, i, j - i) ' Get Key, then value CGI_FormTuples(n).value = GetProfile("Form Literal", CGI_FormTuples(n).key) i = j + 1 ' Bump pointer n = n + 1 ' Bump array index ReDim Preserve CGI_FormTuples(n) As Tuple ' Increase array size Loop ' ' Now do the external ones: [Form External] ' sList = GetProfile("Form External", "") ' Get key list l = Len(sList) ' Length incl. trailing null i = 1 ' Start at 1st character extFile = FreeFile Do While i < l ' Safety stop here j = InStr(i, sList, Chr$(0)) ' J -> next null CGI_FormTuples(n).key = Mid$(sList, i, j - i) ' Get Key, then pathname buf = GetProfile("Form External", CGI_FormTuples(n).key) k = InStr(buf, " ") ' Split file & length extName = Mid$(buf, 1, k - 1) ' Pathname k = k + 1 extlen = CLng(Mid$(buf, k, Len(buf) - k + 1)) ' Length ' ' Use feature of GET to read content in one call ' Open extName For Binary Access Read As #extFile CGI_FormTuples(n).value = String$(extlen, " ") ' Breathe in... Get #extFile, , CGI_FormTuples(n).value 'GULP! Close #extFile i = j + 1 ' Bump pointer n = n + 1 ' Bump array index ReDim Preserve CGI_FormTuples(n) As Tuple ' Increase array size Loop CGI_NumFormTuples = n ' Number of fields decoded n = 0 ' Reset counter ' ' Next, the [Form Huge] section. Will this ever get executed? ' sList = GetProfile("Form Huge", "") ' Get key list l = Len(sList) ' Length incl. trailing null i = 1 ' Start at 1st character Do While i < l ' Safety stop here j = InStr(i, sList, Chr$(0)) ' J -> next null CGI_HugeTuples(n).key = Mid$(sList, i, j - i) ' Get Key buf = GetProfile("Form Huge", CGI_HugeTuples(n).key) ' "offset length" k = InStr(buf, " ") ' Delimiter CGI_HugeTuples(n).offset = CLng(Mid$(buf, 1, (k - 1))) CGI_HugeTuples(n).length = CLng(Mid$(buf, k, (Len(buf) - k + 1))) i = j + 1 ' Bump pointer n = n + 1 ' Bump array index ReDim Preserve CGI_FormTuples(n) As Tuple ' Increase array size Loop CGI_NumHugeTuples = n ' Fill in global count n = 0 ' Reset counter ' ' Finally, the [Form File] section. ' sList = GetProfile("Form File", "") ' Get key list l = Len(sList) ' Length incl. trailing null i = 1 ' Start at 1st character Do While ((i < l) And (n < MAX_FILE_TUPLES)) ' Safety stop here j = InStr(i, sList, Chr$(0)) ' J -> next null CGI_FileTuples(n).key = Mid$(sList, i, j - i) ' Get Key buf = GetProfile("Form File", CGI_FileTuples(n).key) ParseFileValue buf, CGI_FileTuples(n) ' Complicated, use Sub i = j + 1 ' Bump pointer n = n + 1 ' Bump array index Loop CGI_NumFileTuples = n ' Fill in global count End Sub