Dim arg As String
Dim temp As String
Dim item As NotesItem
Dim db As NotesDatabase
Dim type1 As String
Dim ti As Integer
Dim tt As String
Dim grRead As String
Dim grWrite As String
Dim session As NotesSession
Dim note As NotesDocument
Public Class RequestContentParser
Private psRC As String
Private piAmpPos As Integer
Private iTempPrev As Integer ' tracks where the last field value was...
Sub new(Byval sRequest_Content As String)
psRC = sRequest_Content
piAmpPos = 0
End Sub
Private Function Unescape(Byval s As String) As String
Dim iPercent As Integer
Dim iPlus As Integer
Dim sL As String
Dim sM As String
Dim sR As String
Dim result As Variant
' result = Evaluate(|@URLDecode("UTF-8";"|+s+|")|)
' s=result(0)
iPercent = Instr(s,"%")
iPlus = Instr(s,"+")
If iPlus = 0 Then
If iPercent = 0 Then 'neither percent nor plus was found.
Unescape = s
Else 'plus not found, deal with percent
sL = Left$(s,iPercent-1)
sM = Mid$(s,iPercent+1,2)
sR = Mid$(s, iPercent+3)
Unescape = sL + Chr$(Cint("&h" & sM)) + Unescape(sR)
End If
Elseif iPercent = 0 Or iPlus < iPercent Then 'percent doesn't exist or plus comes before percent, deal with plus
sL = Left$(s, iPlus - 1)
sR = Mid$(s, iPlus + 1)
Unescape = sL + " " + Unescape(sR)
Else 'percent comes before plus, deal with percent
sL = Left$(s,iPercent-1)
sM = Mid$(s,iPercent+1,2)
sR = Mid$(s, iPercent+3)
Unescape = sL + Chr$(Cint("&h" & sM)) + Unescape(sR)
End If
End Function
Public Function GetFieldValues(sFieldName As String) As Variant 'rtns an array, if null then returns single value in array of value ""
'lets return an array of field values
Dim rtn() As String
Redim rtn(0) As String
iTempPrev = 1
Dim tmpString As String
tmpString = GetNextFieldValue(sFieldName)
Dim i As Integer
i = 0
If tmpString = "" Then
rtn(i) = ""
Else
While Not tmpString = ""
Redim Preserve rtn(i)
rtn(i) = tmpString
i = i+1
tmpString = GetNextFieldValue(sFieldName)
Wend
End If
GetFieldValues = rtn
End Function
Private Function GetNextFieldValue(sFieldName As String) As String
Dim iAmpPos As Integer
Dim iFieldPos As Integer
Dim iValPos As Integer
Dim sValue As String
iFieldPos = Instr( iTempPrev, "&" + psRC, "&" + sFieldName + "=")
If iFieldPos = 0 Then
GetNextFieldValue = ""
Else
iValPos = iFieldPos + 1 + Len(sFieldName)
iAmpPos = Instr(iValPos, psRC, "&")
iTempPrev = iValPos
If iAmpPos = iValPos Then
GetNextFieldValue = ""
Elseif iAmpPos < iValPos Then 'its the last value in the string....
GetNextFieldValue = Unescape(Mid(psRC, iValPos))
Else
GetNextFieldValue = Unescape(Mid(psRC, iValPos, iAmpPos - iValPos))
End If
End If
End Function
End Class