From 4ea47594ae90c6bced19a41dcfbc22df459a03d6 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 31 Jan 2026 21:04:19 -0500 Subject: [PATCH] Port config package --- 0.go | 16 ++++++++++++++++ README.md | 9 +++++---- go.mod | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/0.go b/0.go index 189fcca..fac2772 100644 --- a/0.go +++ b/0.go @@ -47,3 +47,19 @@ func FreeArray(items *C.PascalString, count C.int) { } C.free(unsafe.Pointer(items)) } + +// safeStringDeref safely dereferences a string pointer, returning empty string if nil. +func safeStringDeref(s *string) string { + if s == nil { + return "" + } + return *s +} + +// safeBoolDeref safely dereferences a bool pointer, returning false if nil. +func safeBoolDeref(b *bool) bool { + if b == nil { + return false + } + return *b +} diff --git a/README.md b/README.md index f37cb0a..2a3cc05 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ to export to C. ### Building `go build -buildmode=c-archive`. ### Functions -All relevant exported libmutton functions have C functions of the same name. +All relevant exported libmutton functions have C counterparts with similar names. Functions with multiple return values all have CGO-generated structs to store the return values. These structs are named `_return`, as per CGO. All functions perform similar basic operations, with a couple caveats: @@ -75,9 +75,9 @@ int main() { - [ ] CopyString(clearClipboardAutomatically bool, copySubject string) error - [ ] LaunchClearProcess(copySubject string) - [ ] TOTPCopier(secret string, errorChan chan<- error, done <-chan bool) -- [ ] config - - [ ] Write(cfg *CfgT, appendMode bool) error - - [ ] Load() (*CfgT, error) +- [X] config + - [X] Write(cfg *CfgT, appendMode bool) error + - [X] Load() (*CfgT, error) - [ ] core - [ ] EntryAddPrecheck(realPath string) (uint8, error) - [ ] EntryIsNotEmpty(entryData []string) bool @@ -86,6 +86,7 @@ int main() { - [ ] GetOldEntryData(realPath string, field int, rcwPassword []byte) ([]string, error) - [ ] LibmuttonInit(inputCB func(prompt string) string, rcwPassword []byte, ...) error - [ ] RCWSanityCheckGen(password []byte) error + - [ ] VerifyEntries(rcwPassword []byte) error - [ ] WriteEntry(realPath string, decSlice []string, passwordIsNew bool, rcwPassword []byte) error - [X] crypt - [X] ~~VAR: RetryPassword bool~~ (RCWD not supported) diff --git a/go.mod b/go.mod index 4222652..9c52b45 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module cmutton -go 1.25.6 +go 1.26rc2 require ( github.com/rwinkhart/libmutton v0.4.3-0.20260124190333-b963ccf33e54