|
Packit Service |
a2ae7a |
(* Lens for the textual representation of Windows registry files, as used *)
|
|
Packit Service |
a2ae7a |
(* by wine etc. *)
|
|
Packit Service |
a2ae7a |
(* This is pretty quick and dirty, as it doesn't put a lot of finesse on *)
|
|
Packit Service |
a2ae7a |
(* splitting up values that have structure, e.g. hex arrays or *)
|
|
Packit Service |
a2ae7a |
(* collections of paths. *)
|
|
Packit Service |
a2ae7a |
module Wine =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* We handle Unix and DOS line endings, though we can only add one or the *)
|
|
Packit Service |
a2ae7a |
(* other to new lines. Maybe provide a function to gather that from the *)
|
|
Packit Service |
a2ae7a |
(* current file ? *)
|
|
Packit Service |
a2ae7a |
let eol = del /[ \t]*\r?\n/ "\n"
|
|
Packit Service |
a2ae7a |
let comment = [ label "#comment" . del /[ \t]*;;[ \t]*/ ";; "
|
|
Packit Service |
a2ae7a |
. store /([^ \t\r\n].*[^ \t\r\n]|[^ \t\r\n])/ . eol ]
|
|
Packit Service |
a2ae7a |
let empty = [ eol ]
|
|
Packit Service |
a2ae7a |
let dels = Util.del_str
|
|
Packit Service |
a2ae7a |
let del_ws = Util.del_ws_spc
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let header =
|
|
Packit Service |
a2ae7a |
[ label "registry" . store /[a-zA-Z0-9 \t]*[a-zA-Z0-9]/ ] .
|
|
Packit Service |
a2ae7a |
del /[ \t]*Version[ \t]*/ " Version " .
|
|
Packit Service |
a2ae7a |
[ label "version" . store /[0-9.]+/ ] . eol
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let qstr =
|
|
Packit Service |
a2ae7a |
let re = /([^"\n]|\\\\.)*/ - /@|"@"/ in (* " Relax, emacs *)
|
|
Packit Service |
a2ae7a |
dels "\"" . store re . dels "\""
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let typed_val =
|
|
Packit Service |
a2ae7a |
([ label "type" . store /dword|hex(\\([0-9]+\\))?/ ] . dels ":" .
|
|
Packit Service |
a2ae7a |
[ label "value" . store /[a-zA-Z0-9,()]+(\\\\\r?\n[ \t]*[a-zA-Z0-9,]+)*/])
|
|
Packit Service |
a2ae7a |
|([ label "type" . store /str\\([0-9]+\\)/ ] . dels ":" .
|
|
Packit Service |
a2ae7a |
dels "\"" . [ label "value" . store /[^"\n]*/ ] . dels "\"") (* " Relax, emacs *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let entry =
|
|
Packit Service |
a2ae7a |
let qkey = [ label "key" . qstr ] in
|
|
Packit Service |
a2ae7a |
let eq = del /[ \t]*=[ \t]*/ "=" in
|
|
Packit Service |
a2ae7a |
let qstore = [ label "value" . qstr ] in
|
|
Packit Service |
a2ae7a |
[ label "entry" . qkey . eq . (qstore|typed_val) . eol ]
|
|
Packit Service |
a2ae7a |
|[label "anon" . del /"?@"?/ "@" . eq . (qstore|typed_val) .eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let section =
|
|
Packit Service |
a2ae7a |
let ts = [ label "timestamp" . store Rx.integer ] in
|
|
Packit Service |
a2ae7a |
[ label "section" . del /[ \t]*\\[/ "[" .
|
|
Packit Service |
a2ae7a |
store /[^]\n]+/ . dels "]" . (del_ws . ts)? . eol .
|
|
Packit Service |
a2ae7a |
(entry|empty|comment)* ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = header . (empty|comment)* . section*
|