Skip to content

Commit 3f0ba16

Browse files
committed
some Prefs parsers added
1 parent 89397bf commit 3f0ba16

File tree

2 files changed

+549
-10
lines changed

2 files changed

+549
-10
lines changed

internal/chunks/database.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ var structData = map[string]ChunkData{
111111

112112
"PREF": {nil, "Preferences"},
113113
"PREF.PRHD": {handlePrefPrhd, "Preferences Header"},
114-
"PREF.ASL ": {nil, "ASL Preferences"},
115-
"PREF.FONT": {nil, "Font Preferences"},
116-
"PREF.ICTL": {nil, "IControl Preferences"},
117-
"PREF.INPT": {nil, "Input Preferences"},
118-
"PREF.KMSW": {nil, "Keyboard/Mouse Preferences"},
114+
"PREF.ASL ": {handlePrefAsl, "ASL Preferences"},
115+
"PREF.FONT": {handlePrefFont, "Font Preferences"},
116+
"PREF.ICTL": {handlePrefIctl, "IControl Preferences"},
117+
"PREF.INPT": {handlePrefInpt, "Input Preferences"},
118+
"PREF.KMSW": {handlePrefKmsw, "Keyboard/Mouse Preferences"},
119119
"PREF.LCLE": {nil, "Locale Preferences"},
120120
"PREF.PALT": {nil, "Palette Preferences"},
121121
"PREF.CMAP": {handleIlbmCmap, "Color Map"},
@@ -258,3 +258,20 @@ func getByte(data []byte, offset *uint32) (int8, error) {
258258
*offset++
259259
return result, nil
260260
}
261+
262+
// getStringBuffer reads a string from the data at the given offset.
263+
// The numer of bytes to read is given by bufLen. The offset is incremented
264+
// by the bufLen.
265+
// In case of an error, it returns "" and the error. The offset is unchanged.
266+
func getStringBuffer(data []byte, offset *uint32, bufLen uint32) (string, error) {
267+
var result string
268+
269+
if len(data) < int(*offset+bufLen) {
270+
return "", fmt.Errorf("data too short for String")
271+
}
272+
high := int(*offset + bufLen)
273+
result = string(data[*offset:high])
274+
275+
*offset += bufLen
276+
return result, nil
277+
}

0 commit comments

Comments
 (0)