src/daemon/ctx.h \
src/daemon/daemon.c \
src/daemon/daemon.h \
+ src/daemon/graph.c \
+ src/daemon/graph.h \
src/daemon/graph-bus.c \
src/daemon/graph-bus.h \
src/daemon/logging.c \
#include <systemd/sd-bus.h>
+#include "graph.h"
#include "graph-bus.h"
static int collecty_graph_node_enumerator(sd_bus* bus,
static int collecty_graph_object_find(sd_bus* bus, const char* path,
const char* interface, void* data, void** found, sd_bus_error* error) {
-#if 0
collecty_daemon* daemon = data;
collecty_graph* graph = NULL;
char* name = NULL;
if (r <= 0)
return 0;
+#if 0
// Find the graph
graph = collecty_daemon_get_graph_by_name(daemon, name);
if (!graph)
return 0;
+#endif
// Match!
- *found = collecy_graph_unref(graph);
-#endif
+ *found = collecty_graph_unref(graph);
return 1;
}
--- /dev/null
+/*#############################################################################
+# #
+# collecty - A system statistics collection daemon for IPFire #
+# Copyright (C) 2025 IPFire Development Team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include "ctx.h"
+#include "daemon.h"
+#include "graph.h"
+
+struct collecty_graph {
+ collecty_ctx* ctx;
+ int nrefs;
+
+ // Daemon
+ collecty_daemon* daemon;
+};
+
+static void collecty_graph_free(collecty_graph* self) {
+ if (self->daemon)
+ collecty_daemon_unref(self->daemon);
+ if (self->ctx)
+ collecty_ctx_unref(self->ctx);
+ free(self);
+}
+
+int collecty_graph_create(collecty_graph** graph,
+ collecty_ctx* ctx, collecty_daemon* daemon) {
+ collecty_graph* self = NULL;
+
+ // Allocate some memory
+ self = calloc(1, sizeof(*self));
+ if (!self)
+ return -errno;
+
+ // Initialize the reference counter
+ self->nrefs = 1;
+
+ // Store a reference to the context
+ self->ctx = collecty_ctx_ref(ctx);
+
+ // Store a reference to the daemon
+ self->daemon = collecty_daemon_ref(daemon);
+
+ // Return the pointer
+ *graph = self;
+ return 0;
+}
+
+collecty_graph* collecty_graph_ref(collecty_graph* self) {
+ ++self->nrefs;
+ return self;
+}
+
+collecty_graph* collecty_graph_unref(collecty_graph* self) {
+ if (--self->nrefs > 0)
+ return self;
+
+ collecty_graph_free(self);
+ return NULL;
+}
--- /dev/null
+/*#############################################################################
+# #
+# collecty - A system statistics collection daemon for IPFire #
+# Copyright (C) 2025 IPFire Development Team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef COLLECTY_GRAPH_H
+#define COLLECTY_GRAPH_H
+
+typedef struct collecty_graph collecty_graph;
+
+#include "ctx.h"
+#include "daemon.h"
+
+int collecty_graph_create(collecty_graph** graph, collecty_ctx* ctx, collecty_daemon* daemon);
+
+collecty_graph* collecty_graph_ref(collecty_graph* self);
+collecty_graph* collecty_graph_unref(collecty_graph* self);
+
+#endif /* COLLECTY_GRAPH_H */