]> git.ipfire.org Git - telemetry.git/commitdiff
util: Remove the old file walking functions
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 16:10:12 +0000 (16:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 16:10:12 +0000 (16:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/parse.c
src/daemon/string.h
src/daemon/util.c
src/daemon/util.h

index be18f390f115688cffca3d3bf151418adce20c0f..191a0ac1521e588cbbeccfdced4108cf2cb88bb9 100644 (file)
@@ -19,6 +19,7 @@
 #############################################################################*/
 
 #include <ctype.h>
+#include <stdlib.h>
 
 #include "parse.h"
 #include "string.h"
index 4114770843bab506d8e0a43a8c837bb211ae381a..ea13db89d14bae01b161f735d03877f5212892aa 100644 (file)
@@ -24,6 +24,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <string.h>
 
 #include "util.h"
index 48224b69e5ea3305f4d92ed9ec8fe6e5f2519a86..57b86b6d85df4c31f1fac8cb09f0e3d4ace3564b 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <errno.h>
 #include <stdarg.h>
-#include <stdint.h>
 #include <stdio.h>
 
 #include "string.h"
@@ -51,67 +50,3 @@ int collecty_format_title(char** title, const char* format, ...) {
 
        return 0;
 }
-
-int collecty_fwalk(FILE* f, collecty_fwalk_callback callback, void* data) {
-       char* line = NULL;
-       size_t length = 0;
-       size_t l = 0;
-       int r;
-
-       // Start at the beginning of the stream
-       r = fseek(f, 0L, SEEK_SET);
-       if (r < 0)
-               return -errno;
-
-       // Walk through all lines
-       for (;;) {
-               // Fetch the next line
-               r = getline(&line, &length, f);
-               if (r < 0) {
-                       // Reset r if have reached the end of the file
-                       if (feof(f))
-                               r = 0;
-
-                       break;
-               }
-
-               // Remove the trailing newline
-               collecty_string_rstrip(line);
-
-               // Determine the length of the line
-               l = strlen(line);
-
-               // Call the callback
-               r = callback(line, l, data);
-               if (r < 0)
-                       break;
-       }
-
-       // Cleanup
-       if (line)
-               free(line);
-
-       return r;
-}
-
-int collecty_fwalk_buffer(const char* buffer, const size_t length,
-               collecty_fwalk_callback callback, void* data) {
-       FILE* f = NULL;
-       int r;
-
-       // Open as a file handle
-       f = fmemopen((char*)buffer, length, "r");
-       if (!f) {
-               r = -errno;
-               goto ERROR;
-       }
-
-       // Walk through all lines
-       r = collecty_fwalk(f, callback, data);
-
-ERROR:
-       if (f)
-               fclose(f);
-
-       return r;
-}
index aea5718dffea938dd27fe18c501975f5e0a7d79c..295b9391aeb1010b540f6581b1057916b157b90b 100644 (file)
@@ -21,9 +21,7 @@
 #ifndef COLLECTY_UTIL_H
 #define COLLECTY_UTIL_H
 
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <stddef.h>
 
 // Preprocessor macro to make something a string
 #define STRINGIFY(x) #x
@@ -50,11 +48,4 @@ int __collecty_format_number(char* buffer, size_t length, int number);
 int collecty_format_title(char** title, const char* format, ...)
        __attribute__((format(printf, 2, 3)));
 
-typedef int (*collecty_fwalk_callback)(const char* line, const size_t length, void* data);
-
-int collecty_fwalk(FILE* f, collecty_fwalk_callback callback, void* data);
-
-int collecty_fwalk_buffer(const char* buffer, const size_t length,
-       collecty_fwalk_callback callback, void* data);
-
 #endif /* COLLECTY_UTIL_H */