diff --git a/README.md b/README.md index e0e1a02..f37cb0a 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,10 @@ int main() { ``` # Progress -- [ ] age - - [ ] AllPasswordEntries(forceReage bool, rcwPassword []byte) error - - [ ] Entry(vanityPath string, timestamp int64) error - - [ ] TranslateAgeTimestamp(timestamp *int64) uint8 +- [X] age + - [X] AllPasswordEntries(forceReage bool, rcwPassword []byte) error + - [X] Entry(vanityPath string, timestamp int64) error + - [X] TranslateAgeTimestamp(timestamp *int64) uint8 - [ ] clip - [ ] ClearArgument() error - [ ] ClearProcess(assignedContents string) error diff --git a/age.go b/age.go new file mode 100644 index 0000000..a045eb3 --- /dev/null +++ b/age.go @@ -0,0 +1,38 @@ +package main + +// #include +// #include "types.h" +import "C" +import ( + "github.com/rwinkhart/libmutton/age" +) + +// AgeEntry returns: +// err +// +//export AgeEntry +func AgeEntry(vanityPath C.PascalString, timestamp int64) *C.char { + if err := age.Entry(C.GoStringN(vanityPath.data, vanityPath.len), timestamp); err != nil { + return C.CString(err.Error()) + } + return nil +} + +// AgeAllPasswordEntries returns: +// err +// +//export AgeAllPasswordEntries +func AgeAllPasswordEntries(forceReage bool, rcwPassword C.PascalString) *C.char { + if err := age.AllPasswordEntries(forceReage, []byte(C.GoStringN(rcwPassword.data, rcwPassword.len))); err != nil { + return C.CString(err.Error()) + } + return nil +} + +// TranslateAgeTimestamp returns: +// ageStatusMagicNum (0 -> no age, 1 -> fresh, 2 -> expiring soon (within a month), 3 -> expired) +// +//export TranslateAgeTimestamp +func TranslateAgeTimestamp(timestamp *int64) uint8 { + return age.TranslateAgeTimestamp(timestamp) +}