package winpwn

import "time"

// Arch identifies the target architecture, the winpwn analogue of pwntools'
// context.arch. Windows has no big-endian target, so unlike pwntools this
// only ever changes pointer width (P32 vs P64 callers), never byte order --
// P16/P32/P64 stay little-endian-only by design (see packing.go).
type Arch int

const (
	ArchX86 Arch = iota
	ArchX64
)

func (a Arch) String() string {
	if a == ArchX86 {
		return "x86"
	}
	return "x64"
}

// LogLevel gates which Log* calls in log.go actually print, the winpwn
// analogue of pwntools' context.log_level.
type LogLevel int

const (
	LogLevelDebug LogLevel = iota
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelSilent
)

// Ctx is the global, mutable settings object every winpwn entry point reads
// defaults from -- the analogue of pwntools' single shared pwnlib.context
// object. Mutate the package-level Context variable directly, the same way
// scripts do `context.arch = 'amd64'` in pwntools.
type Ctx struct {
	Arch     Arch
	LogLevel LogLevel

	// Timeout is the default per-call deadline for Tube.Recv*/Send*
	// (zero means block forever, matching pwntools' Timeout.forever).
	// Override per tube with (*Tube).SetTimeout.
	Timeout time.Duration

	// Newline is what SendLine appends and RecvLine splits on.
	Newline []byte
}

// Context is the single global settings instance. There is deliberately no
// constructor/getter ceremony around it -- read or write its fields directly,
// exactly like pwntools' module-level `context`.
var Context = &Ctx{
	Arch:     ArchX64,
	LogLevel: LogLevelInfo,
	Timeout:  0,
	Newline:  []byte("\n"),
}
