Line data Source code
1 : #include "precizer.h"
2 :
3 : /**
4 : *
5 : * Decide whether or not to protect the relative
6 : * path from checksum recalculation by comparing it
7 : * with PCRE2 regular expressions passed as arguments
8 : * with --lock-checksum=
9 : *
10 : */
11 1968 : LockChecksum match_checksum_lock_pattern(
12 : const char *relative_path,
13 : bool *lock_checksum_showed_once)
14 : {
15 1968 : if(config->lock_checksum == NULL)
16 : {
17 : // Nothing to lock
18 1632 : return(DO_NOT_LOCK_CHECKSUM);
19 : }
20 :
21 708 : for(int i = 0; config->lock_checksum[i] != NULL; ++i)
22 : {
23 462 : REGEXP result = regexp_match(config->lock_checksum[i],relative_path,lock_checksum_showed_once);
24 :
25 462 : if(MATCH == result)
26 : {
27 : // Lock that file checksum from recalculation
28 90 : return(LOCK_CHECKSUM);
29 :
30 372 : } else if(REGEXP_ERROR == result){
31 :
32 0 : return(FAIL_REGEXP_LOCK_CHECKSUM);
33 :
34 : }
35 : }
36 :
37 : // No regexp matched
38 246 : return(DO_NOT_LOCK_CHECKSUM);
39 : }
|