Did you ever find rb yenc source code?
I'm working on a version that doesn't quite work...would appreciate
some debugging help or would really appreciate it if you could share
your yenc source with me. Not interested in buying class because I'm
building a specialized nntp client.
=====
Short Story:
- Need yenc source for realbasic
- Please send me working source if you can
- The code below ends up with extra chars in the jpg file
- File does not quite render properly. Need some help debugging?
- Eyes are tired of looking at this for 5 days.
- Need help quick!! Thanks
Long Story:
I've been staring at this yenc code for a couple of days and would
really appreciate some help.
I'm writing a special purpose nntp client and need to decode a yenc
encoded file (single part).
Using the following code I end up with extra characters in the file
(jpg) and problems decoding the image.
Can someone take a look? I'm sure I'm not the only one trying to write
a yenc in realbasic. I'd also appreciate someone sharing some source
with me!!! Thanks, Neo
I call this from DataAvailable after I've gotten a full download.
Sub (EncodedData as string, version as integer)
Dim strFilename As String
Dim intLineLength As Integer
Dim lngFileSize As Integer
Dim arrLines(-1) As String
Dim varLine As Variant
Dim strLine As String
Dim arrParse(-1) As String
Dim varElement As Variant
Dim lngFileEnd As Integer
Dim lngFileBegin As Integer
Dim bytData As memoryBlock
Dim strCommand As String
Dim lngVersion As Integer
Dim blnEscapeChar As Boolean
Dim lngPart As Integer
Dim f as folderitem
Dim WriteBytesToFile as binaryStream
lngVersion = 1
arrLines = Split(EncodedData, EndofLine)
For Each varLine In arrLines
strLine = CStr(varLine)
If Left(strLine, 2) = "=y" Then
strLine = Right(strLine, Len(strLine) - 2)
strCommand=lowercase(strLine.nthField(" ",1))
If InStr(strCommand, "begin") > 0 Then
If Len(strCommand) > 5 Then
lngVersion = val(Right(strCommand, Len(strCommand) - 5))
strCommand = "begin"
End If
If Version > 0 Then
lngVersion = Version
End If
End If
Select Case strCommand
Case "begin"
arrParse = Split(strLine, " ")
For Each varElement In arrParse
If InStr(CStr(varElement), "=") > 0 Then
Select Case CStr(varElement.nthfield("=",1))
Case "line"
intLineLength = CDbl(varElement.nthfield("=",2))
Case "size"
lngFileSize = CDbl(varElement.nthfield("=",2))
lngFileEnd = (lngFileSize - 1)
bytData = newmemoryBlock(lngFileSize-1)
Case "name"
strFilename = CStr(varElement.nthfield("=",2))
strFilename = Replace(strFilename, Chr(34), "")
strFilename = strFilename
End Select
End If
Next varElement
Case "end"
f=GetFolderItem(strFilename)
WriteBytesToFile=f.createBinaryFile("text")
WriteBytesToFile.Write bytData.StringValue(0,lngFileBegin-1)
WriteBytesToFile.close
End Select
ElseIf ((intLineLength > 0) And (lngFileSize > 0) And
(Len(strFilename) > 0)) Then
Do Until strLine =""
bytData.byte(lngFileBegin) = Asc(Left(strLine, 1))
If bytData.byte(lngFileBegin) = 61 Then
blnEscapeChar = True
Else
If blnEscapeChar Then
bytData.byte(lngFileBegin) = (bytData.byte(lngFileBegin) -
64)
blnEscapeChar = False
End If
bytData.byte(lngFileBegin) = (bytData.byte(lngFileBegin) - 42)
lngFileBegin = lngFileBegin + 1
End If
strLine = Right(strLine, Len(strLine) - 1)
Loop
End If
Next varLine
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|