Index

lognestmonster / logstream

A general-purpose single-header C logging library and parser for event-based logs. (Incomplete)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
20901 Dec 2020 11:43c5334b7UpdateJosh Stockin1240G

Blob @ lognestmonster / tests / hexdump.lua

text/plain452 bytesdownload raw
1function 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
9end
10
11function hex(val, width)
12 dump(val, width)
13 print()
14end
15
16function 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()
22end
23
24return 2
25