cliutil

package
v0.0.0-...-341aec2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2025 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func ConfigureLogger(jsonOutput bool, debugLevel bool, quiet bool) (*zap.Logger, error)

ConfigureLogger creates and configures a zap logger based on the output format and log level

func EncodeJSONIndent

func EncodeJSONIndent(w io.Writer, v any) error

EncodeJSONIndent writes v as pretty JSON to w with 2‑space indentation.

func FormatNA

func FormatNA(s string) string

FormatNA formats empty strings as "N/A" for display consistency

func NewIndentedEncoder

func NewIndentedEncoder(w io.Writer) *json.Encoder

NewIndentedEncoder returns a JSON encoder that writes to w with 2‑space indentation.

func ParseFilterTypes

func ParseFilterTypes(s string) map[string]struct{}

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

func ValidateFirmwarePath(firmwarePath string) error

ValidateFirmwarePath validates that the firmware path is provided

func WithinRange

func WithinRange(off uint64, rng string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL