Port age package

This commit is contained in:
2026-01-24 14:34:08 -05:00
parent 66ffb1a2be
commit 5ae7b41d76
2 changed files with 42 additions and 4 deletions
+38
View File
@@ -0,0 +1,38 @@
package main
// #include <stdlib.h>
// #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)
}