From 243c88e20bad08a7b2fe268cec3a7b5129f461a2 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 20 Apr 2024 19:08:55 +0530 Subject: npassd: init --- include/npassd/common.h | 1 + include/npassd/service.h | 14 ++++++++++++++ include/npassd/session.h | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 include/npassd/common.h create mode 100644 include/npassd/service.h create mode 100644 include/npassd/session.h (limited to 'include') diff --git a/include/npassd/common.h b/include/npassd/common.h new file mode 100644 index 0000000..b3ef866 --- /dev/null +++ b/include/npassd/common.h @@ -0,0 +1 @@ +#define DBUS_OBJECT_PATH "/org/freedesktop/secrets" diff --git a/include/npassd/service.h b/include/npassd/service.h new file mode 100644 index 0000000..e1a42fc --- /dev/null +++ b/include/npassd/service.h @@ -0,0 +1,14 @@ +#include + +#include "npassd/session.h" + +#define MAX_SESSION 128 + +struct service { + sd_bus *bus; + sd_bus_slot *slot; + struct session session[MAX_SESSION]; +}; + +int service_init(sd_bus *bus, struct service *service); +void service_free(struct service *service); diff --git a/include/npassd/session.h b/include/npassd/session.h new file mode 100644 index 0000000..6763c6a --- /dev/null +++ b/include/npassd/session.h @@ -0,0 +1,19 @@ +#include +#include + +#include "npassd/common.h" + +#define SESSION_IFACE "org.freedesktop.Secret.Session" + +/* reusable slots */ +struct session { + bool isactive; + sd_bus_slot *slot; + /* +32 for snprintf("/session/%d") */ + char path[sizeof(DBUS_OBJECT_PATH) + 32]; +}; + +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 *s, unsigned slot_no); -- cgit v1.2.3