chiark / gitweb /
some maskmap stuff;
[chiark-tcl.git] / base / tables-examples.tct
1 Type hb:                        HBytes_Value @
2 Init hb                         hbytes_sentinel(&@);
3
4 Type hbv:                       HBytes_Var @
5 Init hbv                        @.hb=0; init_somethingv(&@.sth);
6 Fini hbv                        fini_somethingv(ip, rc, &@.sth);
7
8 Type maskmapv:                  MaskMap_Var @
9 Init maskmapv                   @.mm=0; init_somethingv(&@.sth);
10 Fini maskmapv                   fini_somethingv(ip, rc, &@.sth);
11
12 Type sockaddr:                  SockAddr_Value @
13 Init sockaddr                   sockaddr_clear(&@);
14
15 Type iddata(IdDataTable *tab):  void *@
16 Type ulong:                     uint32_t @
17 Type long:                      long @
18 Type string:                    const char *@
19
20 Type charfrom(const char *opts, const char *what):      int
21
22 H-Include       "hbytes.h"
23
24 Table toplevel TopLevel_Command
25         hbytes
26                 subcmd  enum(HBytes_SubCommand, "hbytes subcommand")
27                 ...     obj
28         dgram-socket
29                 subcmd  enum(DgramSocket_SubCommand,"dgram-socket subcommand")
30                 ...     obj
31         tuntap-socket-raw
32             subcmd enum(TunSocket_SubCommand,"tuntap-socket-raw subcommand")
33             ... obj
34         ulong
35                 subcmd  enum(ULong_SubCommand,"ulong subcommand")
36                 ...     obj
37         mask-map
38                 subcmd  enum(MaskMap_SubCommand, "hbytes mask-map subcommand")
39                 ...     obj
40
41 Table maskmap MaskMap_SubCommand
42         lookup
43                 map     maskmapv
44                 addr    hb
45                 ?def    obj
46                 =>      obj
47         amend
48                 map     maskmapv
49                 prefix  hb
50                 preflen int
51                 data    obj
52
53 Table ulong ULong_SubCommand
54         ul2int
55                 v       ulong
56                 =>      int
57         int2ul
58                 v       int
59                 =>      ulong
60         mask
61                 a       ulong
62                 b       ulong
63                 =>      ulong
64         add
65                 a       ulong
66                 b       ulong
67                 =>      ulong
68         multiply
69                 a       ulong
70                 b       ulong
71                 =>      ulong
72         subtract
73                 a       ulong
74                 b       ulong
75                 =>      ulong
76         compare
77                 a       ulong
78                 b       ulong
79                 =>      int
80         shift
81                 right   charfrom("lr", "shift direction")
82                 v       ulong
83                 bits    int
84                 =>      ulong
85         ul2bitfields
86                 value   ulong
87                 ...     obj
88                 =>      int
89         bitfields2ul
90                 base    ulong
91                 ...     obj
92                 =>      ulong
93
94 Table hbytes HBytes_SubCommand
95         raw2h
96                 binary  obj
97                 =>      hb
98         h2raw
99                 hex     hb
100                 =>      obj
101         ushort2h
102                 value   long
103                 =>      hb
104         h2ushort
105                 hex     hb
106                 =>      long
107         length
108                 v       hb
109                 =>      int
110         compare
111                 a       hb
112                 b       hb
113                 =>      int
114         range
115                 v       hb
116                 start   int
117                 size    int
118                 =>      hb
119         prepend
120                 v       hbv
121                 ...     str
122         append
123                 v       hbv
124                 ...     str
125         rep-info
126                 v       obj
127                 =>      obj
128         concat
129                 ...     str
130                 =>      hb
131         unprepend
132                 v       hbv
133                 length  int
134                 =>      hb
135         unappend
136                 v       hbv
137                 length  int
138                 =>      hb
139         chopto
140                 v       hbv
141                 length  int
142                 =>      hb
143         overwrite
144                 v       hbv
145                 start   int
146                 sub     hb
147         trimleft
148                 v       hbv
149         zeroes
150                 length  int
151                 =>      hb
152         repeat
153                 v       hb
154                 count   int
155                 =>      hb
156         xor
157                 v       hbv
158                 d       hb
159         random
160                 length  int
161                 =>      hb
162         pad
163                 op      enum(PadOp, "hbytes pad subcommand")
164                 v       hbv
165                 blocksz obj
166                 meth    enum(PadMethodInfo, "pad method")
167                 ...     methargs
168         blockcipher
169                 op      enum(BlockCipherOp, "op")
170                 ...     obj
171         hash
172                 alg     enum(HashAlgInfo, "hash alg")
173                 message hb
174                 =>      hb
175         hmac
176                 alg     enum(HashAlgInfo, "hash alg for hmac")
177                 message hb
178                 key     obj
179                 ?maclen obj
180                 =>      hb
181         hash-prop
182                 prop    enum(HashAlgPropInfo, "prop")
183                 alg     enum(HashAlgInfo, "alg")
184                 =>      int
185
186 Table padmethodinfo PadMethodInfo
187         pkcs5
188                 =>      int
189         rfc2406
190                 nxthdr  obj
191                 =>      int
192
193 Table dgram_socket DgramSocket_SubCommand
194         create
195                 local   sockaddr
196                 =>      iddata(&dgram_socks)
197         close
198                 sock    iddata(&dgram_socks)
199         transmit
200                 sock    iddata(&dgram_socks)
201                 data    hb
202                 remote  sockaddr
203         on-receive
204                 sock    iddata(&dgram_socks)
205                 ?script obj
206
207 Table tuntap_socket_raw TunSocket_SubCommand
208         create
209                 ?ifname string
210                 =>      iddata(&tuntap_socks)
211         close
212                 sock    iddata(&tuntap_socks)
213         ifname
214                 sock    iddata(&tuntap_socks)
215                 =>      string
216         receive
217                 sock    iddata(&tuntap_socks)
218                 data    hb
219         on-transmit
220                 sock    iddata(&tuntap_socks)
221                 mtu     long
222                 ?script obj
223
224 Table blockcipherop BlockCipherOp
225         e       1
226                 v       hbv
227                 alg     enum(BlockCipherAlgInfo, "alg")
228                 key     obj
229                 mode    enum(BlockCipherModeInfo, "mode")
230                 ?iv     hb
231                 =>      hb
232         d       0
233                 v       hbv
234                 alg     enum(BlockCipherAlgInfo, "alg")
235                 key     obj
236                 mode    enum(BlockCipherModeInfo, "mode")
237                 ?iv     hb
238                 =>      hb
239         mac     -1
240                 msg     hb
241                 alg     enum(BlockCipherAlgInfo, "alg")
242                 key     obj
243                 mode    enum(BlockCipherModeInfo, "mode")
244                 iv      hb
245                 =>      hb
246         prop    -1
247                 prop    enum(BlockCipherPropInfo, "prop")
248                 alg     enum(BlockCipherAlgInfo, "alg")
249                 =>      int
250
251 EntryExtra BlockCipherOp
252         int encrypt;