source: project/wiki/eggref/5/blob-utils @ 35889

Last change on this file since 35889 was 35889, checked in by kon, 9 months ago

rel 2.0.0

File size: 7.9 KB
Line 
1[[tags: egg]]
2
3== blob-utils
4
5[[toc:]]
6
7
8== Documentation
9
10==== Usage
11
12<enscript language=scheme>
13(require-extension blob-utils)
14</enscript>
15
16==== bytes->hexstring
17
18<procedure>(bytes->hexstring BV [START [END]]) -> string</procedure>
19
20Returns a hexadecimal represenation of {{BV}}.
21
22; {{BV}} : {{(or string blob srfi-4-vector)}}
23; {{START}} : {{fixnum}} ; 0..<last>
24; {{END}} : {{fixnum}} ; 0..<end>
25
26==== bytes-set-u8
27==== bytes-set-s8
28
29<procedure>(bytes-set-u8! BV IDX UINT)</procedure>
30<procedure>(bytes-set-s8! BV IDX INT)</procedure>
31
32; {{BV}} : {{(or string blob srfi-4-vector)}}
33; {{IDX}} : {{fixnum}} ; 0..<last>
34; {{UINT}} : {{fixnum}} ; 0..(2^8)-1
35; {{INT}} : {{fixnum}} ; -(2^7)..(2^7)-1
36
37==== bytes-set-u16
38==== bytes-set-s16
39
40<procedure>(bytes-set-u16! BV IDX UINT)</procedure>
41<procedure>(bytes-set-s16! BV IDX INT)</procedure>
42
43; {{BV}} : {{(or string blob srfi-4-vector)}}
44; {{IDX}} : {{fixnum}} ; 0..<last>
45; {{UINT}} : {{fixnum}} ; 0..(2^16)-1
46; {{INT}} : {{fixnum}} ; -(2^15)..(2^15)-1
47
48==== bytes-set-u32
49==== bytes-set-s32
50
51<procedure>(bytes-set-u32! BV IDX UINT)</procedure>
52<procedure>(bytes-set-s32! BV IDX INT)</procedure>
53
54; {{BV}} : {{(or string blob srfi-4-vector)}}
55; {{IDX}} : {{fixnum}} ; 0..<last>
56; {{UINT}} : {{number}} ; 0..(2^32)-1
57; {{INT}} : {{number}} ; -(2^31)..(2^31)-1
58
59==== bytes-set-u64
60==== bytes-set-s64
61
62<procedure>(bytes-set-u64! BV IDX UINT)</procedure>
63<procedure>(bytes-set-s64! BV IDX INT)</procedure>
64
65; {{BV}} : {{(or string blob srfi-4-vector)}}
66; {{IDX}} : {{fixnum}} ; 0..<last>
67; {{UINT}} : {{number}} ; 0..(2^64)-1
68; {{INT}} : {{number}} ; -(2^63)..(2^63)-1
69
70=== Blob Hexadecimal
71
72Blob representation as a hexadecimal string.
73
74==== Usage
75
76<enscript language=scheme>
77(require-extension blob-hexadecimal)
78</enscript>
79
80==== blob->hex
81
82<procedure>(blob->hex BLOB [START [END]]) -> string</procedure>
83
84Returns a hexadecimal represenation of the {{BLOB}} bytes.
85
86; {{BLOB}} : {{blob}}
87; {{START}} : {{fixnum}} ; 0..<last>
88; {{END}} : {{fixnum}} ; 0..<end>
89
90=== Blob Set Int
91
92Stuff integers into a blob.
93
94==== Usage
95
96<enscript language=scheme>
97(require-extension blob-set-int)
98</enscript>
99
100==== blob-set-u8!
101
102<procedure>(blob-set-u8! BLOB N [(OFFSET 0)])</procedure>
103
104Sets the byte at {{OFFSET}} to {{N}} in {{BLOB}}.
105
106==== blob-set-u16-le!
107
108<procedure>(blob-set-u16-le! BLOB N [(OFFSET 0)])</procedure>
109
110Sets the 2 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using little-endian byte order.
111
112==== blob-set-u16-be!
113
114<procedure>(blob-set-u16-be! BLOB N [(OFFSET 0)])</procedure>
115
116Sets the 2 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using big-endian byte order.
117
118==== blob-set-u32-le!
119
120<procedure>(blob-set-u32-le! BLOB N [(OFFSET 0)])</procedure>
121
122Sets the 4 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using little-endian byte order.
123
124==== blob-set-u32-be!
125
126<procedure>(blob-set-u32-be! BLOB N [(OFFSET 0)])</procedure>
127
128Sets the 4 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using big-endian byte order.
129
130==== blob-set-u64-le!
131
132<procedure>(blob-set-u64-le! BLOB N [(OFFSET 0)])</procedure>
133
134Sets the 8 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using little-endian byte order.
135
136==== blob-set-u64-be!
137
138<procedure>(blob-set-u64-be! BLOB N [(OFFSET 0)])</procedure>
139
140Sets the 8 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using big-endian byte order.
141
142==== *blob-set-u8!
143
144<procedure>(*blob-set-u8! BLOB N OFFSET)</procedure>
145
146Sets the byte at {{OFFSET}} to {{N}} in {{BLOB}}.
147
148Performs no argument checking.
149
150==== *blob-set-u16-le!
151
152<procedure>(*blob-set-u16-le! BLOB N OFFSET)</procedure>
153
154Sets the 2 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using little-endian byte order.
155
156Performs no argument checking.
157
158==== *blob-set-u16-be!
159
160<procedure>(*blob-set-u16-be! BLOB N OFFSET)</procedure>
161
162Sets the 2 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using big-endian byte order.
163
164Performs no argument checking.
165
166==== *blob-set-u32-le!
167
168<procedure>(*blob-set-u32-le! BLOB N OFFSET)</procedure>
169
170Sets the 4 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using little-endian byte order.
171
172Performs no argument checking.
173
174==== *blob-set-u32-be!
175
176<procedure>(*blob-set-u32-be! BLOB N OFFSET)</procedure>
177
178Sets the 4 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using big-endian byte order.
179
180Performs no argument checking.
181
182==== *blob-set-u64-le!
183
184<procedure>(*blob-set-u64-le! BLOB N OFFSET)</procedure>
185
186Sets the 8 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using little-endian byte order.
187
188Performs no argument checking.
189
190==== *blob-set-u64-be!
191
192<procedure>(*blob-set-u64-be! BLOB N OFFSET)</procedure>
193
194Sets the 8 bytes at {{OFFSET}} to {{N}} in {{BLOB}} using big-endian byte order.
195
196Performs no argument checking.
197
198=== Pack Integer
199
200Set integer in blob.
201
202==== Usage
203
204<enscript language=scheme>
205(require-extension pack-integer)
206</enscript>
207
208==== pack-u8
209
210<procedure>(pack-u8 N [kind: KIND] [start: START]) -> (or string blob u8vector)</procedure>
211
212Returns the number {{N}} packed into an object of {{KIND}}, at position {{START}}.
213
214; {{KIND}} : {{(or symbol (or string blob u8vector))}}
215; {{START}} : {{fixnum}} ; 0..<last>
216
217==== pack-u16
218
219<procedure>(pack-u16 N [kind: KIND] [start: START] [order: ORDER]) -> (or string blob u8vector)</procedure>
220
221Returns the number {{N}} packed into an object of {{KIND}}, at position {{START}}.
222
223; {{KIND}} : {{(or symbol (or string blob u8vector))}}
224; {{START}} : {{fixnum}} ; {{(<= 0 ...)}}
225; {{ORDER}} : {{symbol}} ; {{big-endian be big little-endian le little}}
226
227==== pack-u32
228
229<procedure>(pack-u32 N [kind: KIND] [start: START] [order: ORDER]) -> (or string blob u8vector)</procedure>
230
231Returns the number {{N}} packed into an object of {{KIND}}, at position {{START}}.
232
233; {{KIND}} : {{(or symbol (or string blob u8vector))}}
234; {{START}} : {{fixnum}} ; {{(<= 0 ...)}}
235; {{ORDER}} : {{symbol}} ; {{big-endian be big little-endian le little}}
236
237==== pack-u64
238
239<procedure>(pack-u64 N [kind: KIND] [start: START] [order: ORDER]) -> (or string blob u8vector)</procedure>
240
241Returns the number {{N}} packed into an object of {{KIND}}, at position {{START}}.
242
243; {{KIND}} : {{(or symbol (or string blob u8vector))}}
244; {{START}} : {{fixnum}} ; {{(<= 0 ...)}}
245; {{ORDER}} : {{symbol}} ; {{big-endian be big little-endian le little}}
246
247==== pack-integer
248
249<procedure>(pack-integer N [kind: KIND] [start: START] [order: ORDER]) -> (or string blob u8vector)</procedure>
250
251Returns the number {{N}} packed into an object of {{KIND}}, at position {{START}}.
252
253; {{KIND}} : {{(or symbol (or string blob u8vector))}}
254; {{START}} : {{fixnum}} ; {{(<= 0 ...)}}
255; {{ORDER}} : {{symbol}} ; {{big-endian be big little-endian le little}}
256
257
258== Notes
259
260* The {{pack-int}} & {{blob-utils}} APIs overlap.
261
262* The {{pack-int}} API should be bit-indexed.
263
264
265== Requirements
266
267[[string-utils]]
268[[check-errors]]
269
270[[test]]
271
272
273== Author
274
275[[/users/kon-lovett|Kon Lovett]]
276
277
278== Version history
279
280; 2.0.0 : CHICKEN 5 release.
281; 1.2.0 : Added {{blob-utils}} module.
282; 1.1.0 : Added {{pack-integer}} module.
283; 1.0.4 :
284; 1.0.3 : Reverted 64 bit support.
285; 1.0.2 : Removed 64 bit support.
286; 1.0.1 :
287; 1.0.0 : Hello (Some from string-utils)
288
289
290== License
291
292Copyright (C) 2012-2018 Kon Lovett.  All rights reserved.
293
294Permission is hereby granted, free of charge, to any person obtaining a
295copy of this software and associated documentation files (the Software),
296to deal in the Software without restriction, including without limitation
297the rights to use, copy, modify, merge, publish, distribute, sublicense,
298and/or sell copies of the Software, and to permit persons to whom the
299Software is furnished to do so, subject to the following conditions:
300
301The above copyright notice and this permission notice shall be included
302in all copies or substantial portions of the Software.
303
304THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
305IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
306FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
307THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
308OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
309ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
310OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.