Imported Upstream version 3.7
[platform/upstream/ccache.git] / src / hashutil.h
1 // Copyright (C) 2009-2018 Joel Rosdahl
2 //
3 // This program is free software; you can redistribute it and/or modify it
4 // under the terms of the GNU General Public License as published by the Free
5 // Software Foundation; either version 3 of the License, or (at your option)
6 // any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITHOUT
9 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 //
13 // You should have received a copy of the GNU General Public License along with
14 // this program; if not, write to the Free Software Foundation, Inc., 51
15 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 #ifndef HASHUTIL_H
18 #define HASHUTIL_H
19
20 #include "conf.h"
21 #include "hash.h"
22 #include <inttypes.h>
23
24 struct file_hash
25 {
26         uint8_t hash[16];
27         uint32_t size;
28 };
29
30 unsigned hash_from_string(void *str);
31 unsigned hash_from_int(int i);
32 int strings_equal(void *str1, void *str2);
33 int file_hashes_equal(struct file_hash *fh1, struct file_hash *fh2);
34
35 #define HASH_SOURCE_CODE_OK 0
36 #define HASH_SOURCE_CODE_ERROR 1
37 #define HASH_SOURCE_CODE_FOUND_DATE 2
38 #define HASH_SOURCE_CODE_FOUND_TIME 4
39
40 int check_for_temporal_macros(const char *str, size_t len);
41 int hash_source_code_string(
42         struct conf *conf, struct hash *hash, const char *str, size_t len,
43         const char *path);
44 int hash_source_code_file(
45         struct conf *conf, struct hash *hash, const char *path);
46 bool hash_command_output(struct hash *hash, const char *command,
47                          const char *compiler);
48 bool hash_multicommand_output(struct hash *hash, const char *command,
49                               const char *compiler);
50
51 #endif