chiark / gitweb /
many improvements: use Get/SetAssocData for idtables to avoid globals, and adns bindi...
[chiark-tcl.git] / base / tables-examples.tct
index 69a4fb63b523f0fbc9a9d41a8e7a4989d5c11a8c..98c6cd98cca3118383b2dcf483e4cf1ce01fbbec 100644 (file)
 Type hb:                       HBytes_Value @
-Init hb                                @.start=0; @.end=0;
+Init hb                                hbytes_sentinel(&@);
+
 Type hbv:                      HBytes_Var @
-Init hbv                       @.hb=0; @.obj=0; @.var=0;
-Fini hbv                       fini_hbv(ip, rc, &@);
+Init hbv                       @.hb=0; init_somethingv(&@.sth);
+Fini hbv                       fini_somethingv(ip, rc, &@.sth);
+
+Type constv(Tcl_ObjType*):     Tcl_Obj *@
+
+Type maskmapv:                 MaskMap_Var @
+Init maskmapv                  @.mm=0; init_somethingv(&@.sth);
+Fini maskmapv                  fini_somethingv(ip, rc, &@.sth);
+
+Type sockaddr:                 SockAddr_Value @
+Init sockaddr                  sockaddr_clear(&@);
+
+Type iddata(const IdDataSpec *idds):   void *@
+Type ulong:                    uint32_t @
+Type long:                     long @
+Type string:                   const char *@
+
+Type adnsresults:              adns_answer *@
+Init adnsresults               @=0;
+Fini adnsresults               free(@);
+
+Type charfrom(const char *opts, const char *what):     int
 
 H-Include      "hbytes.h"
 
-Untabled
+Table toplevel TopLevel_Command
        hbytes
                subcmd  enum(HBytes_SubCommand, "hbytes subcommand")
-               obj     ...
+               ...     obj
+       dgram-socket
+               subcmd  enum(DgramSocket_SubCommand,"dgram-socket subcommand")
+               ...     obj
+       tuntap-socket-raw
+           subcmd enum(TunSocket_SubCommand,"tuntap-socket-raw subcommand")
+           ... obj
+       ulong
+               subcmd  enum(ULong_SubCommand,"ulong subcommand")
+               ...     obj
+       adns
+               subcmd  enum(Adns_SubCommand,"adns subcommand")
+               ...     obj
+
+Table adns Adns_SubCommand
+       lookup
+               rrtype  enum(AdnsTclRRTypeInfo, "rrtype")
+               domain  string
+               ...     obj
+               =>      obj
+       synch
+               rrtype  enum(AdnsTclRRTypeInfo, "rrtype")
+               domain  string
+               ...     obj
+               =>      obj
+       asynch
+               on_yes  obj
+               on_no   obj
+               on_fail obj
+               xargs   obj
+               rrtype  enum(AdnsTclRRTypeInfo, "rrtype")
+               domain  string
+               ...     obj
+               =>      iddata(&adnstcl_queries)
+       asynch-cancel
+               query   iddata(&adnstcl_queries)
+       new-resolver
+               ...     obj
+               =>      iddata(&adnstcl_resolvers)
+       destroy-resolver
+               res     iddata(&adnstcl_resolvers)
+
+Table maskmap MaskMap_SubCommand
+       lookup
+               map     constv(&maskmap_type)
+               addr    hb
+               ?def    obj
+               =>      obj
+       amend
+               map     maskmapv
+               prefix  obj
+               preflen obj
+               data    obj
+
+Table ulong ULong_SubCommand
+       ul2int
+               v       ulong
+               =>      int
+       int2ul
+               v       int
+               =>      ulong
+       mask
+               a       ulong
+               b       ulong
+               =>      ulong
+       add
+               a       ulong
+               b       ulong
+               =>      ulong
+       multiply
+               a       ulong
+               b       ulong
+               =>      ulong
+       subtract
+               a       ulong
+               b       ulong
+               =>      ulong
+       compare
+               a       ulong
+               b       ulong
+               =>      int
+       shift
+               right   charfrom("lr", "shift direction")
+               v       ulong
+               bits    int
+               =>      ulong
+       ul2bitfields
+               value   ulong
+               ...     obj
+               =>      int
+       bitfields2ul
+               base    ulong
+               ...     obj
+               =>      ulong
 
 Table hbytes HBytes_SubCommand
        raw2h
@@ -18,50 +132,158 @@ Table hbytes HBytes_SubCommand
        h2raw
                hex     hb
                =>      obj
-       prefix
-               v       hbv
-               str     ...
-       append
-               v       hbv
-               str     ...
-       concat
+       ushort2h
+               value   long
+               =>      hb
+       h2ushort
+               hex     hb
+               =>      long
+       length
+               v       hb
+               =>      int
+       compare
+               a       hb
+               b       hb
+               =>      int
+       range
+               v       hb
+               start   int
+               size    int
+               =>      hb
+       prepend
+               v       hbv
+               ...     str
+       append
+               v       hbv
+               ...     str
+       rep-info
+               v       obj
+               =>      obj
+       concat
+               ...     str
+               =>      hb
+       unprepend
+               v       hbv
+               length  int
+               =>      hb
+       unappend
+               v       hbv
+               length  int
+               =>      hb
+       chopto
+               v       hbv
+               length  int
+               =>      hb
+       overwrite
                v       hbv
-               str     ...
-       unprepend
+               start   int
+               sub     hb
+       trimleft
                v       hbv
+       zeroes
                length  int
                =>      hb
-       unappend
-               v       hbv
-               length  int
+       repeat
+               v       hb
+               count   int
                =>      hb
-       chopto
+       xor
                v       hbv
+               d       hb
+       random
                length  int
                =>      hb
-       pkcs5
-               meth    enum(PadMethod, "hbytes pad subcommand")
-               obj     ...
-       blockcipher
-               encrypt charfrom("de","encrypt/decrypt")
+       pad
+               op      enum(PadOp, "hbytes pad subcommand")
                v       hbv
+               blocksz obj
+               meth    enum(PadMethodInfo, "pad method")
+               ...     methargs
+       blockcipher
+               op      enum(BlockCipherOp, "op")
+               ...     obj
+       hash
+               alg     enum(HashAlgInfo, "hash alg")
+               message hb
+               =>      hb
+       hmac
+               alg     enum(HashAlgInfo, "hash alg for hmac")
+               message hb
+               key     obj
+               ?maclen obj
+               =>      hb
+       hash-prop
+               prop    enum(HashAlgPropInfo, "prop")
+               alg     enum(HashAlgInfo, "alg")
+               =>      int
+       mask-map
+               subcmd  enum(MaskMap_SubCommand, "hbytes mask-map subcommand")
+               ...     obj
+
+Table padmethodinfo PadMethodInfo
+       pkcs5
+               =>      int
+       rfc2406
+               nxthdr  obj
+               =>      int
+
+Table dgram_socket DgramSocket_SubCommand
+       create
+               local   sockaddr
+               =>      iddata(&dgram_socks)
+       close
+               sock    iddata(&dgram_socks)
+       transmit
+               sock    iddata(&dgram_socks)
+               data    hb
+               remote  sockaddr
+       on-receive
+               sock    iddata(&dgram_socks)
+               ?script obj
+
+Table tuntap_socket_raw TunSocket_SubCommand
+       create
+               ?ifname string
+               =>      iddata(&tuntap_socks)
+       close
+               sock    iddata(&tuntap_socks)
+       ifname
+               sock    iddata(&tuntap_socks)
+               =>      string
+       receive
+               sock    iddata(&tuntap_socks)
+               data    hb
+       on-transmit
+               sock    iddata(&tuntap_socks)
+               mtu     long
+               ?script obj
+
+Table blockcipherop BlockCipherOp
+       e       1
+               v       hbv
+               alg     enum(BlockCipherAlgInfo, "alg")
+               key     obj
+               mode    enum(BlockCipherModeInfo, "mode")
+               ?iv     hb
+               =>      hb
+       d       0
+               v       hbv
+               alg     enum(BlockCipherAlgInfo, "alg")
+               key     obj
+               mode    enum(BlockCipherModeInfo, "mode")
+               ?iv     hb
+               =>      hb
+       mac     -1
+               msg     hb
                alg     enum(BlockCipherAlgInfo, "alg")
-               mode    enum(BlockCipherModeInfo, "mode")
-               ?iv     hb
+               key     obj
+               mode    enum(BlockCipherModeInfo, "mode")
+               iv      hb
                =>      hb
-       hash
-               alg     enum(HashAlgInfo, "hash alg")
-               message hb
-               =>      hb
-       hmac
-               alg     enum(HashAlgInfo, "hash alg for hmac")
-               message hb
-               key     hb
-               maclen  int
-               =>      hb
-
-Table padmethod PadMethod
-       pa      1, 0
+       prop    -1
+               prop    enum(BlockCipherPropInfo, "prop")
+               alg     enum(BlockCipherAlgInfo, "alg")
+               =>      int
 
-EntryExtra PadMethod
-       int pad, algname;
+EntryExtra BlockCipherOp
+       int encrypt;