Parcel #fp7winnq7r5h5iu
Created by Anonymous
Public
Created April 26, 2025 Expires in 17 days
Loading editor...
#ifndef DETECT_DUPS_H #define DETECT_DUPS_H #define _XOPEN_SOURCE 500 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ftw.h> #include <sys/stat.h> #include <openssl/evp.h> #include <openssl/md5.h> #include <unistd.h> #include <errno.h> #include "uthash.h" // Structure to store file paths for hard links typedef struct path_node { char *path; struct path_node *next; } PathNode; // Structure to store soft link information typedef struct soft_link { ino_t inode; int count; int link_num; PathNode *paths; struct soft_link *next; } SoftLink; // Structure to store hard link information typedef struct hard_link { ino_t inode; int count; PathNode *paths; SoftLink *soft_links; struct hard_link *next; } HardLink; // Structure to store file information with the same MD5 hash typedef struct file_info { char md5_hash[33]; // MD5 hash is 32 chars + null terminator HardLink *hard_links; struct file_info *next; } FileInfo; // Hash table structure for MD5 hashes typedef struct hash_entry { char md5_hash[33]; FileInfo *file_info; UT_hash_handle hh; } HashEntry; // Process files using nftw static int render_file_info(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf); // Calculate MD5 hash of a file char* calculate_md5(const char *filename); // Add a file to the appropriate data structures void add_file(const char *path, const struct stat *sb, char *md5_hash); // Print the results void print_results(); // Free memory void cleanup(); #endif // DETECT_DUPS_H