Reading Registry Documents
Use libreg to read a registry batch document without applying it. This is
useful for an importer that shows a document before asking the user to apply
its changes.
Before you start #
- Install matching
libregandlibreg-develpackages. - Install a C compiler and
pkg-config. - Supply a UTF-8 JSON document in the registry batch format.
Parse the document #
-
Include
peios/reg.hand create a span containing the JSON bytes. This example uses an empty batch, so it needs no live registry access:int -
Save the example as
read-document.c, then compile it against the installed library:
Check the result #
Run ./read-document. It prints the empty batch and exits successfully:
The handle owns the returned JSON bytes. The example writes them before freeing the handle. For an application that retains the document in another format, copy those bytes while the handle is still alive.
See libreg(3) for export, apply, errors, and lifetime requirements. Parsing
alone doesn't check whether you have permission to apply a document.