]> git.ipfire.org Git - collecty.git/commitdiff
graph: Move all stuff that is needed to draw graphs into a new header
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Oct 2025 11:37:07 +0000 (11:37 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Oct 2025 11:37:07 +0000 (11:37 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/graph.h
src/daemon/graphs/graph.h [new file with mode: 0644]
src/daemon/graphs/loadavg.c

index cb466c3e69cea94731951329b9522198de96bc74..ef2e564d7e8fb23ff57e511300dab38356910b1e 100644 (file)
@@ -105,6 +105,7 @@ dist_collectyd_SOURCES = \
        src/daemon/graph-bus.h \
        src/daemon/graphs.c \
        src/daemon/graphs.h \
+       src/daemon/graphs/graph.h \
        src/daemon/graphs/loadavg.c \
        src/daemon/graphs/loadavg.h \
        src/daemon/i18n.h \
index c51ea2408148a15a840a4b2a82e2120da09e836d..59a9abc454630c87fc703bc5f49c60f9b037038e 100644 (file)
@@ -78,26 +78,4 @@ typedef struct collecty_graph_render_options {
 int collecty_graph_render(collecty_graph* self, const char* object,
        const collecty_graph_render_options* options, char** buffer, size_t* length);
 
-/*
-       Helpers to write things faster...
-*/
-
-#define HEADER                 "COMMENT:" COLUMN
-#define EMPTY_COLUMN   "COMMENT:                                "
-#define EMPTY_LINE             "COMMENT: \\n"
-
-#define LABEL                  "%-30s"
-
-// A column is exactly 16 characters wide
-#define COLUMN                 "%16s"
-#define FLOAT                  "%%14.2lf"
-#define EOL                            "\\j"
-
-// Draw a LINE, AREA, etc.
-#define DRAW(what, field, color) what ":" field color
-#define DRAW_WITH_LABEL(what, field, color) DRAW(what, field, color) ":" LABEL
-
-// Add something to the legend of the graph
-#define PRINT_FLOAT(field) "GPRINT:" field ":" FLOAT
-
 #endif /* COLLECTY_GRAPH_H */
diff --git a/src/daemon/graphs/graph.h b/src/daemon/graphs/graph.h
new file mode 100644 (file)
index 0000000..ad299aa
--- /dev/null
@@ -0,0 +1,59 @@
+/*#############################################################################
+#                                                                             #
+# 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_GRAPH_H
+#define COLLECTY_GRAPHS_GRAPH_H
+
+/*
+       This is a convenience header that includes several things that we need
+       in all the graphs.
+*/
+
+// Include colors
+#include "../colors.h"
+
+// Include translation
+#include "../i18n.h"
+
+// Include utils
+#include "../util.h"
+
+#define HEADER                 "COMMENT:" COLUMN
+#define EMPTY_COLUMN   "COMMENT:                                "
+#define EMPTY_LINE             "COMMENT: \\n"
+
+// Labels are 30 characters wide
+#define LABEL                  "%-30s"
+
+// A column is exactly 16 characters wide
+#define COLUMN                 "%16s"
+#define FLOAT                  "%%14.2lf"
+
+// Macro to terminate a line
+#define EOL                            "\\j"
+
+// Draw a LINE, AREA, etc.
+#define DRAW(what, field, color) what ":" field color
+#define DRAW_WITH_LABEL(what, field, color) DRAW(what, field, color) ":" LABEL
+
+// Add something to the legend of the graph
+#define PRINT_FLOAT(field) "GPRINT:" field ":" FLOAT
+
+#endif /* COLLECTY_GRAPHS_GRAPH_H */
index 16c4782ffdd5fefd550b7258814d1df16501f236..3520f9c868aeb4189dcc82580d33687edfedbd38 100644 (file)
 
 #include <limits.h>
 
-#include "../colors.h"
-#include "../graph.h"
-#include "../i18n.h"
-#include "../util.h"
+#include "graph.h"
 #include "loadavg.h"
 
 // Set some colors