some more ydecode hacking
This commit is contained in:
parent
ffe0a85311
commit
e1a489354b
1 changed files with 59 additions and 36 deletions
|
|
@ -49,6 +49,7 @@ def initialize(nntpservers, groupname, newsrc="~/.newsrc")
|
||||||
del_server(server)
|
del_server(server)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ymap = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def reconnect(server)
|
def reconnect(server)
|
||||||
|
|
@ -693,6 +694,12 @@ end
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
def ydecode(data, outfile=nil)
|
def ydecode(data, outfile=nil)
|
||||||
|
if @ymap.empty?
|
||||||
|
(-106..255).each do |b|
|
||||||
|
@ymap[b]=((b-42)%256)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
case data.type.to_s
|
case data.type.to_s
|
||||||
when "Array"
|
when "Array"
|
||||||
print "Calling _ydecode_array\n" if Debuglevel>0
|
print "Calling _ydecode_array\n" if Debuglevel>0
|
||||||
|
|
@ -710,6 +717,21 @@ def ydecode(data, outfile=nil)
|
||||||
return mode, filename, body
|
return mode, filename, body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def _ydecode_line(line)
|
||||||
|
i = 0
|
||||||
|
ll = line.length
|
||||||
|
ostr = ''
|
||||||
|
while i < ll
|
||||||
|
if line[i] == 0x3d
|
||||||
|
i += 1
|
||||||
|
line[i] -= 64
|
||||||
|
end
|
||||||
|
ostr << @ymap[line[i]]
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
return ostr, ostr.length
|
||||||
|
end
|
||||||
|
|
||||||
def _ydecode_file(file, outfile)
|
def _ydecode_file(file, outfile)
|
||||||
mode = 0600
|
mode = 0600
|
||||||
filename = "unknown"
|
filename = "unknown"
|
||||||
|
|
@ -718,11 +740,7 @@ def _ydecode_file(file, outfile)
|
||||||
bytes = 0
|
bytes = 0
|
||||||
total = 0
|
total = 0
|
||||||
oldpartend = 0
|
oldpartend = 0
|
||||||
|
search_begin = false
|
||||||
ymap = {}
|
|
||||||
(-106..255).each do |b|
|
|
||||||
ymap[b]=((b-42)%256)
|
|
||||||
end
|
|
||||||
|
|
||||||
while (! file.eof)
|
while (! file.eof)
|
||||||
line = file.gets
|
line = file.gets
|
||||||
|
|
@ -782,13 +800,13 @@ def _ydecode_file(file, outfile)
|
||||||
end
|
end
|
||||||
return mode, filename
|
return mode, filename
|
||||||
end
|
end
|
||||||
search_begin = 1
|
search_begin = true
|
||||||
bytes = 0
|
bytes = 0
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if search_begin && line =~ /^\=ybegin\s+(.*)\Z/
|
if search_begin && line =~ /^\=ybegin\s+(.*)\Z/
|
||||||
m = $1
|
m = $1
|
||||||
search_begin = 0
|
search_begin = false
|
||||||
if m =~ /^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*))\Z/
|
if m =~ /^\s*(part\=(\d+)\s+)?(total\=(\d+)\s+)?(line\=(\d+))(\s*size\=(\d+))(\s*name=(.*))\Z/
|
||||||
part = $2.to_i
|
part = $2.to_i
|
||||||
total = $4.to_i
|
total = $4.to_i
|
||||||
|
|
@ -799,7 +817,7 @@ def _ydecode_file(file, outfile)
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if search_begin == 1
|
if search_begin == true
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
if line =~ /^=ypart\s+(\s*begin=(\d+))(\s+end=(\d+))/
|
||||||
|
|
@ -820,19 +838,20 @@ def _ydecode_file(file, outfile)
|
||||||
# print "linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
# print "linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
||||||
# end
|
# end
|
||||||
|
|
||||||
i = 0
|
# i = 0
|
||||||
ll = line.length
|
# ll = line.length
|
||||||
ostr = ''
|
# ostr = ''
|
||||||
while i < ll
|
# while i < ll
|
||||||
if line[i] == 0x3d
|
# if line[i] == 0x3d
|
||||||
i += 1
|
# i += 1
|
||||||
line[i] -= 64
|
# line[i] -= 64
|
||||||
end
|
# end
|
||||||
ostr << ymap[line[i]]
|
# ostr << ymap[line[i]]
|
||||||
i += 1
|
# i += 1
|
||||||
end
|
# end
|
||||||
|
ostr, ostrl = _ydecode_line(line)
|
||||||
outfile << ostr
|
outfile << ostr
|
||||||
bytes += ostr.length
|
bytes += ostrl
|
||||||
end
|
end
|
||||||
|
|
||||||
print "No \"=yend\" found!!!\n"
|
print "No \"=yend\" found!!!\n"
|
||||||
|
|
@ -846,13 +865,14 @@ def _ydecode_array(data)
|
||||||
filename = "unknown"
|
filename = "unknown"
|
||||||
c = 0
|
c = 0
|
||||||
lines = data.length
|
lines = data.length
|
||||||
|
bytes = 0
|
||||||
percent = 0
|
percent = 0
|
||||||
mark = lines/100
|
mark = lines/100
|
||||||
|
|
||||||
ymap = {}
|
# ymap = {}
|
||||||
(-106..255).each do |b|
|
# (-106..255).each do |b|
|
||||||
ymap[b]=((b-42)%256)
|
# ymap[b]=((b-42)%256)
|
||||||
end
|
# end
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while (i < data.length)
|
while (i < data.length)
|
||||||
|
|
@ -906,19 +926,22 @@ def _ydecode_array(data)
|
||||||
# print "#{i}: linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
# print "#{i}: linesize mismatch, was #{line.length}, should be #{linesize}...\n"
|
||||||
# end
|
# end
|
||||||
|
|
||||||
i = 0
|
# j = 0
|
||||||
ll = line.length
|
# ll = line.length
|
||||||
ostr = ''
|
# ostr = ''
|
||||||
while i < ll
|
# while j < ll
|
||||||
if line[i] == 0x3d
|
# if line[j] == 0x3d
|
||||||
i += 1
|
# j += 1
|
||||||
line[i] -= 64
|
# line[j] -= 64
|
||||||
end
|
# end
|
||||||
ostr << ymap[line[i]]
|
# ostr << ymap[line[j]]
|
||||||
i += 1
|
# j += 1
|
||||||
end
|
# end
|
||||||
|
# decode << ostr
|
||||||
|
# bytes += ostr.length
|
||||||
|
ostr, ostrl = _ydecode_line(line)
|
||||||
decode << ostr
|
decode << ostr
|
||||||
bytes += ostr.length
|
bytes += ostrl
|
||||||
|
|
||||||
# special = 0
|
# special = 0
|
||||||
# str = ""
|
# str = ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue