-
Notifications
You must be signed in to change notification settings - Fork 0
/
dircomp.h
57 lines (42 loc) · 1.39 KB
/
dircomp.h
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
57
/*
dircomp - A directory comparison tool
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*/
# ifndef DIRCOMP_GUARD
# define DIRCOMP_GUARD
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#include <dirent.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#include <sys/stat.h>
#define BYTES_TO_READ_AT_ONCE 512000 // 500KiB
#if BYTES_TO_READ_AT_ONCE > SIZE_MAX
#error Compile-time error: The specified value of BYTES_TO_READ_AT_ONCE is too large for this system.
#endif
struct arguments{
char* directory1;
char* directory2;
bool r; // recursive
bool v; // verbose
bool h; // help
bool f; // fast
bool d; // comparison by digest
};
struct arguments get_arguments(int, char**);
// Reference: https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html
bool analyze_directories(char*, char*, struct arguments*);
int byte_by_byte_file_comparison(char*, char*);
int hash_by_hash_file_comparison(char*, char*);
unsigned char* sha1(char*);
unsigned char* sha1_legacy(char*);
char* combine_path(char*, char*);
void print_help(void);
#endif