Skip to content

Commit

Permalink
some Prefs parsers added
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrust committed Jan 5, 2025
1 parent 89397bf commit 3f0ba16
Show file tree
Hide file tree
Showing 2 changed files with 549 additions and 10 deletions.
27 changes: 22 additions & 5 deletions internal/chunks/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ var structData = map[string]ChunkData{

"PREF": {nil, "Preferences"},
"PREF.PRHD": {handlePrefPrhd, "Preferences Header"},
"PREF.ASL ": {nil, "ASL Preferences"},
"PREF.FONT": {nil, "Font Preferences"},
"PREF.ICTL": {nil, "IControl Preferences"},
"PREF.INPT": {nil, "Input Preferences"},
"PREF.KMSW": {nil, "Keyboard/Mouse Preferences"},
"PREF.ASL ": {handlePrefAsl, "ASL Preferences"},
"PREF.FONT": {handlePrefFont, "Font Preferences"},
"PREF.ICTL": {handlePrefIctl, "IControl Preferences"},
"PREF.INPT": {handlePrefInpt, "Input Preferences"},
"PREF.KMSW": {handlePrefKmsw, "Keyboard/Mouse Preferences"},
"PREF.LCLE": {nil, "Locale Preferences"},
"PREF.PALT": {nil, "Palette Preferences"},
"PREF.CMAP": {handleIlbmCmap, "Color Map"},
Expand Down Expand Up @@ -258,3 +258,20 @@ func getByte(data []byte, offset *uint32) (int8, error) {
*offset++
return result, nil
}

// getStringBuffer reads a string from the data at the given offset.
// The numer of bytes to read is given by bufLen. The offset is incremented
// by the bufLen.
// In case of an error, it returns "" and the error. The offset is unchanged.
func getStringBuffer(data []byte, offset *uint32, bufLen uint32) (string, error) {
var result string

if len(data) < int(*offset+bufLen) {
return "", fmt.Errorf("data too short for String")
}
high := int(*offset + bufLen)
result = string(data[*offset:high])

*offset += bufLen
return result, nil
}
Loading

0 comments on commit 3f0ba16

Please sign in to comment.