aboutsummaryrefslogtreecommitdiff
path: root/include/file_processor.h
diff options
context:
space:
mode:
authorThorsten Töpper <atsutane@freethoughts.de>2026-02-07 21:43:17 +0100
committerThorsten Töpper <atsutane@freethoughts.de>2026-02-07 21:43:17 +0100
commiteed2d1323441861f2d41f0ecc0a72fcc9190fa5f (patch)
tree779cd7c1768504308e9957cfbc5cfc271e89f1c5 /include/file_processor.h
parentb7d09007d04c3b7c38848dd05d6105f3354b6b15 (diff)
downloadduplicate_finder-eed2d1323441861f2d41f0ecc0a72fcc9190fa5f.tar.gz
duplicate_finder-eed2d1323441861f2d41f0ecc0a72fcc9190fa5f.tar.bz2
file processor: Copied from my small-utils project
Diffstat (limited to 'include/file_processor.h')
-rw-r--r--include/file_processor.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/file_processor.h b/include/file_processor.h
new file mode 100644
index 0000000..8cfb6de
--- /dev/null
+++ b/include/file_processor.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+
+/* Copyright 2026 Thorsten Töpper
+ *
+ * vim:ts=4:sw=4:expandtab
+ */
+#ifndef FILE_PROCESSOR_H
+#define FILE_PROCESSOR_H
+
+#include <sys/stat.h>
+
+#define DF_BYTE_SIZE_256 32
+#define DF_BYTE_SIZE_512 64
+
+/* Aliases for convenience, currently all algorithms are part of the default
+ * provider. */
+#define DF_OSSL_BLAKE2 "BLAKE2B-512"
+#define DF_OSSL_SHA256 "SHA2-256"
+#define DF_OSSL_SHA512 "SHA2-512"
+
+/**
+ * information about a file
+ * Contains filepath, stat() results, hash values of multiple algorithms.
+ * TODO: Organize the paths in a global pool (list/tree/map) and only refer there
+ * without any free() calls triggered through the pointer in the struct.
+ */
+struct df_fileinfo {
+ char *path; /**< pointer to the path of the file */
+ char *name; /**< pointer to the name of the file */
+ unsigned char blake2[DF_BYTE_SIZE_512]; /**< The BLAKE2-512 hash in binary form */
+ unsigned char sha256[DF_BYTE_SIZE_256]; /**< The SHA256 hash in binary form. */
+ unsigned char sha512[DF_BYTE_SIZE_512]; /**< The SHA512 hash in binary form. */
+ struct stat statbuf; /**< Result of lstat() call. Symlinks are to be ignored and filtered out earlier. */
+};
+
+
+/*=========== FUNCTIONS ===========*/
+int process_file(struct df_fileinfo *info);
+
+#endif
+