aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-04-26 22:48:10 +0530
committersinanmohd <sinan@sinanmohd.com>2024-04-27 10:59:14 +0530
commit06e3f1885fc112093f867cd5d7a8b163ef28650c (patch)
treee60eb7e80f76d45f294131ab8de2d9ce1f0c1657 /include
parent8ce5f52567f486dbad1eb3f91383f62395df7581 (diff)
npassd/session: refactor
- mak use of list(3)
Diffstat (limited to 'include')
-rw-r--r--include/npassd/service.h4
-rw-r--r--include/npassd/session.h21
2 files changed, 12 insertions, 13 deletions
diff --git a/include/npassd/service.h b/include/npassd/service.h
index 6219dd6..b7c71af 100644
--- a/include/npassd/service.h
+++ b/include/npassd/service.h
@@ -1,4 +1,5 @@
#include <sqlite3.h>
+#include <sys/queue.h>
#include <systemd/sd-bus.h>
#include "npassd/session.h"
@@ -8,8 +9,9 @@
struct service {
sd_bus *bus;
sd_bus_slot *slot;
+
struct sqlite3 *db;
- struct session session[MAX_SESSION];
+ struct session_dlist sessions;
};
int service_init(sd_bus *bus, struct service *service);
diff --git a/include/npassd/session.h b/include/npassd/session.h
index a3aa705..48d4fed 100644
--- a/include/npassd/session.h
+++ b/include/npassd/session.h
@@ -1,22 +1,19 @@
#include <stdbool.h>
+#include <sys/queue.h>
#include <systemd/sd-bus.h>
#include "npassd/common.h"
#define SESSION_IFACE "org.freedesktop.Secret.Session"
-#define MAX_OWNER_LEN 64
-/* reusable slots */
struct session {
- bool isactive;
- sd_bus_slot *slot;
- char owner[MAX_OWNER_LEN];
- /* +32 for snprintf("/session/%d") */
- char path[sizeof(DBUS_OBJECT_PATH) + 32];
+ sd_bus_slot *slot, *slot_singal;
+ char *owner, *path;
+
+ LIST_ENTRY(session) dlist;
};
-void session_init(struct session *s, size_t n);
-int session_slot_available(struct session *s, size_t n);
-int session_free(struct session *s);
-int session_new(sd_bus *bus, struct session *session, unsigned session_no,
- const char *owner);
+LIST_HEAD(session_dlist, session);
+
+void session_free(struct session *s);
+int session_new(sd_bus *bus, struct session **session, const char *owner);