diff options
| author | Drahflow <drahflow@gmx.de> | 2013-09-02 11:27:01 +0200 |
|---|---|---|
| committer | Drahflow <drahflow@gmx.de> | 2013-09-02 11:27:01 +0200 |
| commit | 92b6155a1c3a209936dddebb8bf3372ebee78f94 (patch) | |
| tree | 8680757163dc8dbbea513b60f27945ec9c021af9 /elymas/lib/bin.ey | |
| parent | dd98844bd4968664f9dd7be996df596873733ecd (diff) | |
I CAN HAZ TCP/IP CONNECTION!
Very crappy HTTP client:
"drahflow.name:80" net .tcp .connect "+" via
"GET / HTTP/1.0\n\n" +writeall
4096 +read dump
Diffstat (limited to 'elymas/lib/bin.ey')
| -rw-r--r-- | elymas/lib/bin.ey | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/elymas/lib/bin.ey b/elymas/lib/bin.ey index 74caa04..9216d69 100644 --- a/elymas/lib/bin.ey +++ b/elymas/lib/bin.ey @@ -2,21 +2,63 @@ # as binary data structures < + { + { 8 uw } /u64 deffd + { 4 uw } /u32 deffd + { 2 uw } /u16 deffd + { 1 uw } /u8 deffd + { 8 unw } /un64 deffd + { 4 unw } /un32 deffd + { 2 unw } /un16 deffd + { 1 unw } /un8 deffd + }" /defBitVariants deffd + < # 0 -> number of bytes to combine into unsigned int # 1 -> string - # 0 <- string from (w+1)th byte onwards - # 1 <- first w bytes of string interpreted as unsigned int + # 0 <- first w bytes of string interpreted as unsigned int + # 1 <- string from (w+1)th byte onwards { ==w ==s w s str .postfix [ 0 w range s each ] 256 math .unbase - } /uw deff - - { 8 uw } /u64 deff - { 4 uw } /u32 deff - { 2 uw } /u16 deff - { 1 uw } /u8 deff - > /scan defv -> /bin defv + } /uw deffst + + # network byte order (i.e. big endian) + { ==w ==s + w s str .postfix + [ 0 w range reverse s each ] 256 math .unbase + } /unw deffst + + defBitVariants + > /scan defvd + + < + # 0 -> number of bytes to produce + # 1 -> int to convert to bytes + # 0 <- string enlengthened by binary encoded integer + { ==w ==i + w str .alloc ==s + 0 w range { 0 -01 s =[] }" each + i 256 math .base _ dom { -101*0 s =[] }" each -- + s + } /uw deffst + + # network byte order (i.e. big endian) + { ==w ==i + w str .alloc ==s + 0 w range { 0 -01 s =[] }" each + i 256 math .base _ dom { -101*0 w 1 sub -01 sub s =[] }" each -- + s + } /unw deffst + + defBitVariants + > /produce defvd + + < + { produce .uw cat } /uw deffst + { produce .unw cat } /unw deffst + defBitVariants + > /print defvd +> /bin defvd # vim: syn=elymas |
