[augeas-devel] augeas: master - Wine: new lens and test
David Lutterkort
lutter at fedoraproject.org
Tue Oct 20 13:54:39 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=31b606df30249b82bc9cd2c02a3298d20ab79947
Commit: 31b606df30249b82bc9cd2c02a3298d20ab79947
Parent: 49c35b31a6909961e35127e31b9865b834a68377
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Tue Oct 20 14:40:15 2009 +0200
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Tue Oct 20 15:54:08 2009 +0200
Wine: new lens and test
Lens for parsing textual Windows registry files
---
lenses/tests/test_wine.aug | 163 ++++++++++++++++++++++++++++++++++++++++++++
lenses/wine.aug | 46 ++++++++++++
tests/Makefile.am | 1 +
3 files changed, 210 insertions(+), 0 deletions(-)
diff --git a/lenses/tests/test_wine.aug b/lenses/tests/test_wine.aug
new file mode 100644
index 0000000..3faf31f
--- /dev/null
+++ b/lenses/tests/test_wine.aug
@@ -0,0 +1,163 @@
+module Test_wine =
+
+let s1 = "WINE REGISTRY Version 2
+;; All keys relative to \\Machine
+
+[Software\\Borland\\Database Engine\\Settings\\SYSTEM\\INIT] 1255960431
+\"SHAREDMEMLOCATION\"=\"9000\"
+
+[Software\\Classes\\.gif] 1255960430
+@=\"giffile\"
+\"Content Type\"=\"image/gif\"
+
+[Software\\Classes\\CLSID\\{083863F1-70DE-11D0-BD40-00A0C911CE86}\\Instance\\{1B544C20-FD0B-11CE-8C63-00AA0044B51E}] 1255960430
+\"CLSID\"=\"{1B544C20-FD0B-11CE-8C63-00AA0044B51E}\"
+\"FilterData\"=hex:02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,30,70,69,33,\
+ 9f,53,00,20,af,0b,a7,70,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,\
+ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
+\"FriendlyName\"=\"AVI Splitter\"
+
+[Software\\Classes\\CLSID\\{0AFACED1-E828-11D1-9187-B532F1E9575D}\\ShellFolder] 1255960429
+\"Attributes\"=dword:60010000
+\"CallForAttributes\"=dword:f0000000
+"
+
+test Wine.lns get s1 =
+ { "registry" = "WINE REGISTRY" }
+ { "version" = "2" }
+ { "#comment" = "All keys relative to \Machine" }
+ { }
+ { "section" = "Software\Borland\Database Engine\Settings\SYSTEM\INIT"
+ { "timestamp" = "1255960431" }
+ { "entry"
+ { "key" = "SHAREDMEMLOCATION" }
+ { "value" = "9000" } }
+ { } }
+ { "section" = "Software\Classes\.gif"
+ { "timestamp" = "1255960430" }
+ { "anon" { "value" = "giffile" } }
+ { "entry"
+ { "key" = "Content Type" }
+ { "value" = "image/gif" } }
+ { } }
+ { "section" = "Software\Classes\CLSID\{083863F1-70DE-11D0-BD40-00A0C911CE86}\Instance\{1B544C20-FD0B-11CE-8C63-00AA0044B51E}"
+ { "timestamp" = "1255960430" }
+ { "entry"
+ { "key" = "CLSID" }
+ { "value" = "{1B544C20-FD0B-11CE-8C63-00AA0044B51E}" } }
+ { "entry"
+ { "key" = "FilterData" }
+ { "type" = "hex" }
+ { "value" = "02,00,00,00,00,00,60,00,02,00,00,00,00,00,00,00,30,70,69,33,\
+ 9f,53,00,20,af,0b,a7,70,76,69,64,73,00,00,10,00,80,00,00,aa,00,38,9b,71,00,\
+ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00" } }
+ { "entry"
+ { "key" = "FriendlyName" }
+ { "value" = "AVI Splitter" } }
+ { } }
+ { "section" = "Software\Classes\CLSID\{0AFACED1-E828-11D1-9187-B532F1E9575D}\ShellFolder"
+ { "timestamp" = "1255960429" }
+ { "entry"
+ { "key" = "Attributes" }
+ { "type" = "dword" }
+ { "value" = "60010000" } }
+ { "entry"
+ { "key" = "CallForAttributes" }
+ { "type" = "dword" }
+ { "value" = "f0000000" } } }
+
+(* The weird 'str(2)' type *)
+let s2 = "[Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders] 1248768928
+\"AppData\"=str(2):\"%USERPROFILE%\\Application Data\"
+\"Cache\"=str(2):\"%USERPROFILE%\\Local Settings\\Temporary Internet Files\"
+\"Cookies\"=str(2):\"%USERPROFILE%\\Cookies\"
+\"Desktop\"=str(2):\"%USERPROFILE%\\Desktop\"
+"
+
+test Wine.section get s2 =
+ { "section" =
+ "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
+ { "timestamp" = "1248768928" }
+ { "entry"
+ { "key" = "AppData" }
+ { "type" = "str(2)" }
+ { "value" = "%USERPROFILE%\Application Data" } }
+ { "entry"
+ { "key" = "Cache" }
+ { "type" = "str(2)" }
+ { "value" = "%USERPROFILE%\Local Settings\Temporary Internet Files" } }
+ { "entry"
+ { "key" = "Cookies" }
+ { "type" = "str(2)" }
+ { "value" = "%USERPROFILE%\Cookies" } }
+ { "entry"
+ { "key" = "Desktop" }
+ { "type" = "str(2)" }
+ { "value" = "%USERPROFILE%\Desktop" } } }
+
+(* Quoted doublequotes embedded in the string *)
+let s3 = "[Software\\Classes\\CLSID\\Shell\\OpenHomePage\\Command] 1248768931
+@=\"\\\"C:\\Program Files\\Internet Explorer\\iexplore.exe\\\"\"\n"
+
+test Wine.section get s3 =
+ { "section" = "Software\Classes\CLSID\Shell\OpenHomePage\Command"
+ { "timestamp" = "1248768931" }
+ { "anon"
+ { "value" = "\\\"C:\Program Files\Internet Explorer\iexplore.exe\\\"" } } }
+
+(* There's a str(7) type, too *)
+let s4 = "[Software\\Microsoft\\Cryptography\\OID\\EncodingType 1\\CertDllVerifyRevocation\\DEFAULT] 1248768928
+\"Dll\"=str(7):\"cryptnet.dll\0\"\n"
+
+test Wine.section get s4 =
+ { "section" = "Software\Microsoft\Cryptography\OID\EncodingType 1\CertDllVerifyRevocation\DEFAULT"
+ { "timestamp" = "1248768928" }
+ { "entry"
+ { "key" = "Dll" }
+ { "type" = "str(7)" }
+ { "value" = "cryptnet.dll\0" } } }
+
+(* The Windows Registry Editor header *)
+test Wine.header get "Windows Registry Editor Version 5.00\n" =
+ { "registry" = "Windows Registry Editor" }
+ { "version" = "5.00" }
+
+(* The type hex(7) *)
+let s5 = "[HKEY_LOCAL_MACHINE\SOFTWARE\ADFS]
+\"Patches\"=hex(7):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,61,00,\
+ 64,00,66,00,73,00,73,00,70,00,32,00,2e,00,6d,00,73,00,70,00,\
+ 00,00,00,00,f8
+"
+test Wine.section get s5 =
+ { "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\ADFS"
+ { "entry"
+ { "key" = "Patches" }
+ { "type" = "hex(7)" }
+ { "value" = "25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,5c,00,61,00,\
+ 64,00,66,00,73,00,73,00,70,00,32,00,2e,00,6d,00,73,00,70,00,\
+ 00,00,00,00,f8" } } }
+
+(* Test DOS line endings *)
+let s6 = "Windows Registry Editor Version 5.00\r\n\r
+[HKEY_LOCAL_MACHINE\SOFTWARE\C07ft5Y\WinXP]\r
+\"@\"=\"\"\r
+\r
+[HKEY_LOCAL_MACHINE\SOFTWARE\Classes]\r\n"
+
+test Wine.lns get s6 =
+ { "registry" = "Windows Registry Editor" }
+ { "version" = "5.00" }
+ { }
+ { "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\C07ft5Y\WinXP"
+ { "anon" { "value" = "" } }
+ { } }
+ { "section" = "HKEY_LOCAL_MACHINE\SOFTWARE\Classes" }
+
+(* Keys can contain '/' *)
+let s7 =
+"\"application/vnd.ms-xpsdocument\"=\"{c18d5e87-12b4-46a3-ae40-67cf39bc6758}\"\n"
+
+test Wine.entry get s7 =
+ { "entry"
+ { "key" = "application/vnd.ms-xpsdocument" }
+ { "value" = "{c18d5e87-12b4-46a3-ae40-67cf39bc6758}" } }
diff --git a/lenses/wine.aug b/lenses/wine.aug
new file mode 100644
index 0000000..bd43a17
--- /dev/null
+++ b/lenses/wine.aug
@@ -0,0 +1,46 @@
+(* Lens for the textual representation of Windows registry files, as used *)
+(* by wine etc. *)
+(* This is pretty quick and dirty, as it doesn't put a lot of finesse on *)
+(* splitting up values that have structure, e.g. hex arrays or *)
+(* collections of paths. *)
+module Wine =
+
+(* We handle Unix and DOS line endings, though we can only add one or the *)
+(* other to new lines. Maybe provide a function to gather that from the *)
+(* current file ? *)
+let eol = del /[ \t]*\r?\n/ "\n"
+let comment = [ label "#comment" . del /[ \t]*;;[ \t]*/ ";; "
+ . store /([^ \t\r\n].*[^ \t\r\n]|[^ \t\r\n])/ . eol ]
+let empty = [ eol ]
+let dels = Util.del_str
+let del_ws = Util.del_ws_spc
+
+let header =
+ [ label "registry" . store /[a-zA-Z0-9 \t]*[a-zA-Z0-9]/ ] .
+ del /[ \t]*Version[ \t]*/ " Version " .
+ [ label "version" . store /[0-9.]+/ ] . eol
+
+let qstr =
+ let re = /([^"\n]|\\\\.)*/ - /@|"@"/ in (* " Relax, emacs *)
+ dels "\"" . store re . dels "\""
+
+let typed_val =
+ ([ label "type" . store /dword|hex(\\([0-9]+\\))?/ ] . dels ":" .
+ [ label "value" . store /[a-zA-Z0-9,()]+(\\\\\r?\n[ \t]*[a-zA-Z0-9,]+)*/])
+ |([ label "type" . store /str\\([0-9]+\\)/ ] . dels ":" .
+ dels "\"" . [ label "value" . store /[^"\n]*/ ] . dels "\"") (* " Relax, emacs *)
+
+let entry =
+ let qkey = [ label "key" . qstr ] in
+ let eq = del /[ \t]*=[ \t]*/ "=" in
+ let qstore = [ label "value" . qstr ] in
+ [ label "entry" . qkey . eq . (qstore|typed_val) . eol ]
+ |[label "anon" . del /"?@"?/ "@" . eq . (qstore|typed_val) .eol ]
+
+let section =
+ let ts = [ label "timestamp" . store Rx.integer ] in
+ [ label "section" . del /[ \t]*\\[/ "[" .
+ store /[^]\n]+/ . dels "]" . (del_ws . ts)? . eol .
+ (entry|empty|comment)* ]
+
+let lns = header . (empty|comment)* . section*
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bbd447e..8d5baf3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -63,6 +63,7 @@ lens_tests = \
lens-sysctl.sh \
lens-vsftpd.sh \
lens-webmin.sh \
+ lens-wine.sh \
lens-xinetd.sh \
lens-xorg.sh \
lens-grub.sh \
More information about the augeas-devel
mailing list