> 32) & 0xffffffff; } sub enc_I8 { $data .= pack "c", $_[0]; } sub enc_I16 { enc_U16 unpack "S", pack "s", $_[0]; } sub enc_I32 { enc_U32 unpack "I", pack "i", $_[0]; } sub enc_DATA { # a dream! $data .= $_[0]; } sub enc_STRING { # should use encode for speed and clarity ;) $data .= pack "v*", map ord, split //, $_[0]; } sub enc_CONSTANT { # nop } sub enc_password { require Math::BigInt; # I insist on 32-bit-perl.. should use C # $hash must be 64 bit my $hash = new Math::BigInt; $hash = $hash * 1055 + ord for split //, $_[0]; enc_U64 $hash; } sub enc_HEX { die "enc_HEX not defined for good"; } ]]> ############################################################################# # types ############################################################################# # structures ############################################################################# # "less" primitive types ############################################################################# # messages } 1; dec_ :: State [Word8] [Char] dec_ = do -- decode UCS-2 string of length -- the first 0 terminates the string, but not the field enc_ = -- likewise, encode as UCS-2, fill space with 0 dec_ :: State [Word8] [Char] dec_ = do -- decode ASCII string of length -- the first 0 terminates the string, but not the field enc_ = -- likewise, encode as ASCII, fill space with 0 dec_ = do n <- dec return n * (1 / ) enc_ n = enc $ n * -- $r->{} = (my $array = []); while (length $data) { push @$array, dec_ ; } -- decode next only when -- <- dec -- default -- enc defined $_[0]{} ? $_[0]{ s } : ( ); dec_ = do -- result has class -- enc_ s = -- dec__ = do -- type "" -- enc__ = encU16 0x