--- /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 "graphs.h"
+
+struct collecty_graphs {
+ collecty_ctx* ctx;
+ int nrefs;
+
+ // Daemon
+ collecty_daemon* daemon;
+};
+
+static void collecty_graphs_free(collecty_graphs* self) {
+ if (self->daemon)
+ collecty_daemon_unref(self->daemon);
+ if (self->ctx)
+ collecty_ctx_unref(self->ctx);
+ free(self);
+}
+
+int collecty_graphs_create(collecty_graphs** graphs,
+ collecty_ctx* ctx, collecty_daemon* daemon) {
+ collecty_graphs* 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
+ *graphs = self;
+ return 0;
+}
+
+collecty_graphs* collecty_graphs_ref(collecty_graphs* self) {
+ ++self->nrefs;
+ return self;
+}
+
+collecty_graphs* collecty_graphs_unref(collecty_graphs* self) {
+ if (--self->nrefs > 0)
+ return self;
+
+ collecty_graphs_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_GRAPHS_H
+#define COLLECTY_GRAPHS_H
+
+typedef struct collecty_graphs collecty_graphs;
+
+#include "ctx.h"
+#include "daemon.h"
+
+int collecty_graphs_create(collecty_graphs** graphs, collecty_ctx* ctx, collecty_daemon* daemon);
+
+collecty_graphs* collecty_graphs_ref(collecty_graphs* self);
+collecty_graphs* collecty_graphs_unref(collecty_graphs* self);
+
+#endif /* COLLECTY_GRAPHS_H */