Mercurial > projects > libpws
annotate tools/format-dump.awk @ 3:2b9244d20ecf
Add awk script to pretty print pwsdump output
author | Guido Berhoerster <guido+libpws@berhoerster.name> |
---|---|
date | Fri, 03 Apr 2015 14:57:57 +0200 |
parents | |
children |
rev | line source |
---|---|
3
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
1 # |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
2 # Copyright (C) 2016 Guido Berhoerster <guido+pws@berhoerster.name> |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
3 # |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
4 # Permission is hereby granted, free of charge, to any person obtaining |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
5 # a copy of this software and associated documentation files (the |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
6 # "Software"), to deal in the Software without restriction, including |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
7 # without limitation the rights to use, copy, modify, merge, publish, |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
8 # distribute, sublicense, and/or sell copies of the Software, and to |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
9 # permit persons to whom the Software is furnished to do so, subject to |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
10 # the following conditions: |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
11 # |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
12 # The above copyright notice and this permission notice shall be included |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
13 # in all copies or substantial portions of the Software. |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
14 # |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
18 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
19 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
20 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
21 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
22 # |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
23 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
24 function hextodec(hex, len, dec, i, xdigit, decdigit) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
25 len = length(hex) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
26 dec = 0 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
27 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
28 for (i = 1; i <= len; i++) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
29 xdigit = tolower(substr(hex, i, 1)) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
30 if (xdigit ~ /[0123456789abcdef]/) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
31 decdigit = xdigits[xdigit] |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
32 } else { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
33 return 0 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
34 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
35 dec += decdigit * (16 ^ (len - i)) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
36 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
37 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
38 return dec |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
39 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
40 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
41 function get_header_field_description(type) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
42 return (type in header_field_description) ? \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
43 header_field_description[type] : "Unknown" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
44 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
45 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
46 function get_record_field_description(type) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
47 return (type in record_field_description) ? \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
48 record_field_description[type] : "Unknown" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
49 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
50 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
51 BEGIN { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
52 xdigits["0"] = 0 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
53 xdigits["1"] = 1 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
54 xdigits["2"] = 2 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
55 xdigits["3"] = 3 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
56 xdigits["4"] = 4 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
57 xdigits["5"] = 5 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
58 xdigits["6"] = 6 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
59 xdigits["7"] = 7 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
60 xdigits["8"] = 8 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
61 xdigits["9"] = 9 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
62 xdigits["a"] = 10 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
63 xdigits["b"] = 11 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
64 xdigits["c"] = 12 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
65 xdigits["d"] = 13 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
66 xdigits["e"] = 14 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
67 xdigits["f"] = 15 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
68 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
69 header_field_description[0] = "Version" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
70 header_field_description[1] = "UUID" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
71 header_field_description[2] = "Non-default preferences" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
72 header_field_description[3] = "Tree Display Status" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
73 header_field_description[4] = "Timestamp of last save" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
74 header_field_description[5] = "Who performed last save" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
75 header_field_description[6] = "What performed last save" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
76 header_field_description[7] = "Last saved by user" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
77 header_field_description[8] = "Last saved on host" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
78 header_field_description[9] = "Database Name" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
79 header_field_description[10] = "Database Description" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
80 header_field_description[11] = "Database Filters" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
81 header_field_description[12] = "Reserved" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
82 header_field_description[13] = "Reserved" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
83 header_field_description[14] = "Reserved" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
84 header_field_description[15] = "Recently Used Entries" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
85 header_field_description[16] = "Named Password Policies" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
86 header_field_description[17] = "Empty Groups" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
87 header_field_description[18] = "Yubico" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
88 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
89 record_field_description[1] = "UUID" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
90 record_field_description[2] = "Group" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
91 record_field_description[3] = "Title" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
92 record_field_description[4] = "Username" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
93 record_field_description[5] = "Notes" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
94 record_field_description[6] = "Password" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
95 record_field_description[7] = "Creation Time" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
96 record_field_description[8] = "Password Modification Time" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
97 record_field_description[9] = "Last Access Time" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
98 record_field_description[10] = "Password Expiry Time" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
99 record_field_description[11] = "Reserved" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
100 record_field_description[12] = "Last Modification Time" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
101 record_field_description[13] = "URL" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
102 record_field_description[14] = "Autotype" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
103 record_field_description[15] = "Password History" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
104 record_field_description[16] = "Password Policy" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
105 record_field_description[17] = "Password Expiry Interval" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
106 record_field_description[18] = "Run command" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
107 record_field_description[19] = "Double-Click Action" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
108 record_field_description[20] = "EMail address" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
109 record_field_description[21] = "Protected Entry" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
110 record_field_description[22] = "Own symbols for password" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
111 record_field_description[23] = "Shift Double-Click Action" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
112 record_field_description[24] = "Password Policy Name" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
113 record_field_description[25] = "Entry keyboard shortcut" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
114 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
115 for (type in header_field_description) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
116 description_len = length(record_field_description[type]) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
117 if (description_len > header_field_description_max_len) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
118 header_field_description_max_len = description_len |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
119 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
120 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
121 for (type in record_field_description) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
122 description_len = length(record_field_description[type]) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
123 if (description_len > record_field_description_max_len) { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
124 record_field_description_max_len = description_len |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
125 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
126 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
127 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
128 lineno = 1 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
129 record = 1 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
130 state = "INITIAL" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
131 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
132 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
133 { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
134 lineno++ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
135 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
136 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
137 /^#/ { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
138 next |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
139 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
140 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
141 state == "INITIAL" && /^[Hh][eE][Aa][Dd][Ee][Rr]$/ { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
142 print "Header:" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
143 state = "HEADER" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
144 next |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
145 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
146 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
147 state ~ /HEADER|RECORD/ && /^[Rr][Ee][Cc][Oo][Rr][Dd] / { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
148 printf("\nRecord %d:\n", record++) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
149 state = "RECORD" |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
150 next |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
151 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
152 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
153 state ~ /HEADER|RECORD/ && \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
154 /^[0123456789AaBbCcDdEeFf][0123456789AaBbCcDdEeFf]:/ { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
155 type = hextodec(substr($0, 1, 2)) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
156 value = substr($0, 4) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
157 printf("%*s (0x%02x): %s\n", state == "HEADER" ? \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
158 header_field_description_max_len : \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
159 record_field_description_max_len, \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
160 state == "HEADER" ? get_header_field_description(type) : \ |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
161 get_record_field_description(type), type, value) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
162 next |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
163 } |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
164 |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
165 { |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
166 print "syntax error in line " lineno |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
167 exit(1) |
2b9244d20ecf
Add awk script to pretty print pwsdump output
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
168 } |