All pastes #26754 Raw Edit

Miscellany

public text v1 · immutable
#26754 ·published 2005-10-26 15:33 UTC
rendered paste body
#!/usr/bin/ruby
def pad4(a=0x00,b=0x00,c=0x00,d=0x00)
        return a.chr+b.chr+c.chr+d.chr;
end
def int16tostr(from)
        return (from/256*3).chr+((from/256*2)-(256)).chr+((from/256*1)-(256*2)).chr+(from-(256*3)).chr
end
def make_mhfd(totlen,numchild)
        ret="mhfd";#header
        ret+=pad4(0x84)#header size
        ret+=int16tostr(totlen)#total length
        ret+=pad4(0x01)# allways 1
        ret+=pad4(0x0d)# version num
        ret+=int16tostr(numchild);
        ret+=pad4(0x00)# unchecked id
        ret+=pad4(0x02)# allways 2
        ret.ljust(132);
        return ret;
end
puts make_mhfd(3000,2);