blob: 06b6d1dade5958e77094cef5f7c5776d315c34b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/* 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
#define DF_STR_SIZE_256 64
#define DF_STR_SIZE_512 128
/* 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"
/**
* The hashes in human-readable strings
*/
struct df_hashstrings {
char blake2[DF_STR_SIZE_512+1];
char sha256[DF_STR_SIZE_256+1];
char sha512[DF_STR_SIZE_512+1];
};
/**
* 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 */
#if 0
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. */
#endif
struct df_hashstrings hashes; /**< The BLAKE2-512, SHA256 and SHA512 hash of the file */
struct stat statbuf; /**< Result of lstat() call. Symlinks are to be ignored and filtered out earlier. */
};
/*=========== FUNCTIONS ===========*/
int process_file(struct df_fileinfo *info);
int process_gdbm_content();
#endif
|