From 9e4ada689727829f5a8c3cdd16540134bb9532df Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Wed, 20 Nov 2024 00:39:27 -0500 Subject: [PATCH] qwrtyuo --- .gitignore | 3 ++- c/libs/go_p2fa.h | 2 +- c/src/p2fa.c | 3 ++- go/totp.go | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e392155..8523ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -115,4 +115,5 @@ _deps c/build !c/Makefile -go/go_p2fa.h \ No newline at end of file +go/go_p2fa.h +c/libs/go_p2fa.h \ No newline at end of file diff --git a/c/libs/go_p2fa.h b/c/libs/go_p2fa.h index cdac00b..c8e2c45 100644 --- a/c/libs/go_p2fa.h +++ b/c/libs/go_p2fa.h @@ -76,7 +76,7 @@ extern "C" { extern __declspec(dllexport) void loadConfigs(); extern __declspec(dllexport) GoSlice getConfigNames(); -extern __declspec(dllexport) GoString getCode(GoString configName); +extern __declspec(dllexport) char* getCode(GoString configName); extern __declspec(dllexport) GoUint64 getTimeRemaining(GoInt n); extern __declspec(dllexport) GoUint64 getTimeRemainingMS(GoInt n); diff --git a/c/src/p2fa.c b/c/src/p2fa.c index 6fadbf5..1898a09 100644 --- a/c/src/p2fa.c +++ b/c/src/p2fa.c @@ -28,7 +28,8 @@ int draw() { Paint_Clear(WHITE); const char *confName = "default"; GoString confStr = {confName, strlen(confName)}; - Paint_DrawString(5, 5, getCode(confStr).p, &Font24, WHITE, BLACK); + const char *code = getCode(confStr); + Paint_DrawString(5, 5, code, &Font24, WHITE, BLACK); DEV_Delay_ms(5000); diff --git a/go/totp.go b/go/totp.go index 54a3c5b..5236c9f 100644 --- a/go/totp.go +++ b/go/totp.go @@ -133,10 +133,11 @@ func getConfigNames() []string { } //export getCode -func getCode(configName string) string { +func getCode(configName string) *C.char { code := configs[configName].TOTP() + cCode := C.CString(code) runtime.KeepAlive(code) - return code + return cCode } //export getTimeRemaining