Documentation
¶
Index ¶
- func CollectSectionsByType(pctx *ParserContext) map[uint16][]SectionInfo
- func ConfigureLogger(jsonOutput bool, debugLevel bool, quiet bool) (*zap.Logger, error)
- func EncodeJSONIndent(w io.Writer, v any) error
- func FormatNA(s string) string
- func NewIndentedEncoder(w io.Writer) *json.Encoder
- func ParseFilterTypes(s string) map[string]struct{}
- func ReadSectionBytes(ctx *ParserContext, s SectionInfo) ([]byte, error)
- func ValidateFirmwarePath(firmwarePath string) error
- func WithinRange(off uint64, rng string) bool
- type ParserContext
- type SectionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectSectionsByType ¶
func CollectSectionsByType(pctx *ParserContext) map[uint16][]SectionInfo
CollectSectionsByType groups sections by type and sorts each slice by offset.
func ConfigureLogger ¶
ConfigureLogger creates and configures a zap logger based on the output format and log level
func EncodeJSONIndent ¶
EncodeJSONIndent writes v as pretty JSON to w with 2‑space indentation.
func NewIndentedEncoder ¶
NewIndentedEncoder returns a JSON encoder that writes to w with 2‑space indentation.
func ParseFilterTypes ¶
ParseFilterTypes converts comma-separated section names to a set (uppercased)
func ReadSectionBytes ¶
func ReadSectionBytes(ctx *ParserContext, s SectionInfo) ([]byte, error)
ReadSectionBytes reads section payload plus trailer CRC if present and not encrypted.
func ValidateFirmwarePath ¶
ValidateFirmwarePath validates that the firmware path is provided
func WithinRange ¶
WithinRange checks whether an offset is inside an optional start:end range where each bound can be hex (0x...) or decimal. Empty start or end act as open bounds; malformed inputs fall back to allowing everything.
Types ¶
type ParserContext ¶
type ParserContext struct {
Logger *zap.Logger
FirmwarePath string
Reader *parser.FirmwareReader
Parser *fs4.Parser
}
ParserContext provides shared resources for commands needing a parsed firmware
func InitializeFirmwareParser ¶
func InitializeFirmwareParser(firmwarePath string, logger *zap.Logger) (*ParserContext, error)
InitializeFirmwareParser creates and initializes a firmware parser This consolidates the common pattern used across commands
func (*ParserContext) Close ¶
func (ctx *ParserContext) Close()
Close releases resources held by the context
type SectionInfo ¶
type SectionInfo struct {
Type uint16
Name string
Offset uint64
Size uint32
CRCType types.CRCType
Encrypted bool
Reader interfaces.CompleteSectionInterface
}
SectionInfo captures common metadata used for comparisons and dumping.