diff --git a/c/src/p2fa.c b/c/src/p2fa.c index 7d81343..c907b66 100644 --- a/c/src/p2fa.c +++ b/c/src/p2fa.c @@ -106,8 +106,8 @@ void code(UWORD *blackImage, char* confName) { void config(UWORD *blackImage, char* configName) { GoString goConfName = { configName, strlen(configName) }; - struct getConfig_return getConfigReturn = getConfig(goConfName); - if (getConfigReturn.r1 == -1) { + const char *config = getConfig(goConfName); + if (config == NULL) { DebugLine(10, 0, "Config not found\n"); return; } @@ -119,15 +119,14 @@ void config(UWORD *blackImage, char* configName) { DebugLine(14, 10, "MADE IT TO HERE --------------------------------------"); - Paint_DrawString(5, 5, getConfigReturn.r0, &Font12, WHITE, BLACK); + Paint_DrawString(5, 5, config, &Font12, WHITE, BLACK); + //Paint_DrawString(5, 5, getConfigReturn.r0, &Font12, WHITE, BLACK); EPD_2in13_V4_Display(blackImage); int ch = getch(); if (ch == 'q') { - free(getConfigReturn.r0); return; } - free(getConfigReturn.r0); } void drawTotpHome(UWORD *blackImage, char** configNames, int *length) { diff --git a/go/totp.go b/go/totp.go index f6276cd..5b22f03 100644 --- a/go/totp.go +++ b/go/totp.go @@ -157,7 +157,7 @@ func getConfigNames() (**C.char, C.int) { } //export getConfig -func getConfig(configName string) (*C.char, C.int) { +func getConfig(configName string) *C.char { files, err := os.ReadDir(homeDir + "/.totp") if err != nil { log.Fatal(err) @@ -178,10 +178,10 @@ func getConfig(configName string) (*C.char, C.int) { cStr := C.CString(fileStr) runtime.KeepAlive(fileStr) - return cStr, (C.int)(len(fileStr)) + return cStr } } - return nil, -1 + return nil } //export getCode