A general-purpose single-header C logging library and parser for event-based logs. (Incomplete)
{#} | Time | Hash | Subject | Author | # | (+) | (-) | GPG? |
---|---|---|---|---|---|---|---|---|
209 | 01 Dec 2020 11:43 | c5334b7 | Update | Josh Stockin | 1 | 24 | 0 | G |
1 | function dump(val, width) |
2 | if val == nil then val = 0 end |
3 | if width == nil then width = 1 end |
4 | for i=1, width do -- little endian |
5 | local shift = ((i - 1) * 8) |
6 | local mask = 0xFF << shift |
7 | io.write(string.format("%02X ", (val & mask) >> shift)) |
8 | end |
9 | end |
10 | |
11 | function hex(val, width) |
12 | dump(val, width) |
13 | print() |
14 | end |
15 | |
16 | function hexs(str) |
17 | -- convert string to a stream of hex values |
18 | for c in str:gmatch(".") do |
19 | dump(c:byte()) |
20 | end |
21 | print() |
22 | end |
23 | |
24 | return 2 |
25 |