[[ 12 "Translate" ]] [[ 19 "SSI" ]] [[ 21 "ICQ" ]]
[[ 34 "Unknown Family" ]] } ;
-: ch>lower ( int -- int ) dup LETTER? [ HEX: 20 + ] when ;
-: ch>upper ( int -- int ) dup letter? [ HEX: 20 - ] when ;
-: >lower ( seq -- seq ) [ ch>lower ] map ;
-: >upper ( seq -- seq ) [ ch>upper ] map ;
-
: sanitize-name ( name -- name ) HEX: 20 swap remove >lower ;
: hash-swap ( hash -- hash )
conn get swap with-unscoped-stream ;
: read-aim ( -- bc )
- [ [
- head-byte drop
- head-byte drop
- head-short drop
- head-short head-string
- ] with-aim ] catch [ "Socket error" print throw ] when
+ [
+ [
+ head-byte drop
+ head-byte drop
+ head-short drop
+ head-short head-string
+ ] with-aim
+ ] catch [ "Socket error" print throw ] when
"Received: " write dup hexdump ;
: make-snac ( fam subtype flags req-id -- )
type get
{
- { [ dup 0 = ] [ drop name get bid get gid get { } clone f f <buddy>
+ { [ dup 0 = ] [ drop name get bid get gid get V{ } clone f f <buddy>
dup name get sanitize-name buddy-hash-name get set-hash bid get buddy-hash-id get set-hash ] }
{ [ dup 1 = ] [ drop name get dup length 0 = [ drop ] [ gid get <group>
dup name get sanitize-name group-hash-name get set-hash gid get group-hash-id get set-hash ] if ] }
- { [ dup 3 = ] [ drop name get bid get gid get { } clone f f <buddy>
+ { [ dup 3 = ] [ drop name get bid get gid get V{ } clone f f <buddy>
dup name get sanitize-name banned-hash-name get set-hash bid get banned-hash-id get set-hash ] }
{ [ t ] [ drop "Unknown 19-6 type" print ] }
} cond
HEX: 000000ff bitand unparse % ] "" make ;
-
-
! doesn't compile
! : >nvector ( elems n -- )
! { } clone swap [ drop swap add ] each reverse ;
: 4vector ( elems -- )
- { } clone 4 [ drop swap add ] each reverse ;
+ V{ } clone 4 [ drop swap add ] each reverse ;
! TODO: make this work for types other than ""
: papply ( seq seq -- seq )
: writeln ( string -- )
write terpri ;
-! wrote this months and months ago..
! NEEDS REFACTORING, GOSH!
! Hexdump
: (print-offset) ( lineno -- )
] "" make write ;
: hexdump ( str -- )
-! drop ;
dup length (print-length) (print-bytes) ;
: save-current-scope
- unscoped-stack get [ { } clone unscoped-stack set ] unless
+ unscoped-stack get [ V{ } clone unscoped-stack set ] unless
swap dup unscoped-stream set unscoped-stack get push ;
: set-previous-scope
- ! unscoped-stream get contents .
- ! [
- ! "UNREAD BYTES" writeln
- ! hexdump
- ! ] when
unscoped-stack get dup length 1 > [
[ pop ] keep nip peek unscoped-stream set ] [
pop drop
: (head-u128) ( str -- u128 )
16 swap head endian> ;
-
+! 8 bits
: head-byte ( -- byte )
1 unscoped-stream get stream-read first ;
+! 16 bits
: head-short ( -- short )
2 unscoped-stream get stream-read (head-short) ;
+! 32 bits
: head-int ( -- int )
4 unscoped-stream get stream-read (head-int) ;
+! 64 bits
: head-longlong ( -- longlong )
8 unscoped-stream get stream-read (head-longlong) ;