kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit ae03e60f074ab0657e3591c570c68faaaa5f3f65
parent 362138ea2ae512be3a69278c60ed70e2a17d8e43
Author: lash <dev@holbrook.no>
Date:   Wed, 28 Feb 2024 16:17:12 +0000

Allocate for settings

Diffstat:
Msrc/context.c | 1+
Msrc/gtk/main.c | 4++++
Msrc/settings.c | 13++++++++++---
Msrc/settings.h | 2++
4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/context.c b/src/context.c @@ -1,5 +1,6 @@ #include <string.h> #include "context.h" +#include "settings.h" void kee_context_new(struct kee_context *ctx, void *front) { memset(ctx, 0, sizeof(struct kee_context)); diff --git a/src/gtk/main.c b/src/gtk/main.c @@ -4,6 +4,7 @@ #include "ui.h" #include "context.h" #include "menu.h" +#include "settings.h" static void startup(GtkApplication *app, gpointer user_data) { @@ -30,6 +31,9 @@ int main(int argc, char **argv) { } kee_context_new(&ctx, &ui); + + settings_new_from_xdg(&ctx.settings); + settings_init(&ctx.settings); db_connect(&ctx.db, "./testdata_mdb"); g_signal_connect (ui.gapp, "startup", G_CALLBACK (startup), &ui); diff --git a/src/settings.c b/src/settings.c @@ -9,8 +9,9 @@ #include "debug.h" #include "settings.h" -#define KEE_SETTINGS_DATANAME "kee" +#define KEE_SETTINGS_NAME "kee" #define KEE_SETTINGS_CAP 4096 +#define KEE_SETTINGS_ITEM_CAP 1024 /** * \todo make xdg optional @@ -18,18 +19,24 @@ int settings_new_from_xdg(struct kee_settings *z) { xdgHandle xdg; const char *s; + unsigned char *p; xdgInitHandle(&xdg); memset(z, 0, sizeof(struct kee_settings)); z->data = malloc(KEE_SETTINGS_CAP); + p = z->data; + p += KEE_SETTINGS_ITEM_CAP; + z->run = p; + p += KEE_SETTINGS_ITEM_CAP; + z->locktime = p; s = xdgDataHome(&xdg); - sprintf((char*)z->data, "%s/%s", s, KEE_SETTINGS_DATANAME); + sprintf((char*)z->data, "%s/%s", s, KEE_SETTINGS_NAME); s = xdgRuntimeDirectory(&xdg); - sprintf((char*)z->run, "%s/%s", s, KEE_SETTINGS_DATANAME); + sprintf((char*)z->run, "%s/%s", s, KEE_SETTINGS_NAME); return ERR_OK; } diff --git a/src/settings.h b/src/settings.h @@ -51,4 +51,6 @@ unsigned char *settings_get(struct kee_settings *z, enum SettingsType typ); */ int settings_set(struct kee_settings *z, enum SettingsType typ, unsigned char* v); +int settings_new_from_xdg(struct kee_settings *z); + #endif // KEE_SETTINGS