File: common.h

package info (click to toggle)
hashrat 1.10.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,984 kB
  • sloc: ansic: 21,832; sh: 369; makefile: 187
file content (144 lines) | stat: -rw-r--r-- 3,427 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

#ifndef HASHRAT_COMMON_H
#define HASHRAT_COMMON_H

#include "libUseful-3/libUseful.h"
#include "glob.h"


#define ACT_NONE 0
#define ACT_HASH 1
#define ACT_HASHDIR 2
#define ACT_HASH_LISTFILE 3
#define ACT_PRINTUSAGE 4
#define ACT_CGI 6
#define ACT_SIGN 7
#define ACT_CHECKSIGN 8
#define ACT_CHECK       10
#define ACT_CHECK_LIST  11
#define ACT_CHECK_MEMCACHED 12
#define ACT_CHECK_XATTR 13
#define ACT_LOADMATCHES 20
#define ACT_FINDMATCHES 21
#define ACT_FINDMATCHES_MEMCACHED 22
#define ACT_FINDDUPLICATES 23
#define ACT_BACKUP 24
#define ACT_CHECKBACKUP 25


#define FLAG_NEXTARG 1
//Two flags with the same values, but used in different contexts
#define FLAG_ERROR 2
#define FLAG_VERBOSE 2
//---------------------------
#define FLAG_DEVMODE         8
#define FLAG_DIR_INFO       32
#define FLAG_TRAD_OUTPUT    64
#define FLAG_BSD_OUTPUT    128 
#define FLAG_XSELECT       256 
#define FLAG_XATTR         512
#define FLAG_TXATTR       1024
#define FLAG_MEMCACHED    2048
#define FLAG_OUTPUT_FAILS 8192 
#define FLAG_FULLCHECK   32768
#define FLAG_HMAC        65536
#define FLAG_HIDE_INPUT 131072
#define FLAG_STAR_INPUT 262144
#define FLAG_LINEMODE  1048576
#define FLAG_RAW       2097152
#define FLAG_COLOR     4194304
#define FLAG_NET       8388608
#define FLAG_UPDATE   16777216

//map cgi options to console-mode options that make no sense in .cgi mode
#define CGI_DOHASH FLAG_NEXTARG
#define CGI_NOOPTIONS FLAG_TRAD_OUTPUT
#define CGI_HIDETEXT  FLAG_BSD_OUTPUT
#define CGI_SHOWTEXT  FLAG_XSELECT

//the first few of these must be low because they will go in a 16-bit value in
//the 'include/exclude' list
#define CTX_INCLUDE 2
#define CTX_EXCLUDE 4
#define CTX_MTIME   8
#define CTX_MMIN    16
#define CTX_MYEAR    32
#define CTX_RECURSE  128
#define CTX_HASH_AND_RECURSE  256
#define CTX_DEREFERENCE 512
#define CTX_XATTR 1024
#define CTX_MEMCACHED 2048
#define CTX_STORE_XATTR 4096
#define CTX_STORE_MEMCACHED 8192
#define CTX_STORE_FILE  16384
#define CTX_XATTR_ROOT  32768
#define CTX_XATTR_CACHE 65536
#define CTX_EXES  131072          
#define CTX_CACHED 262144
#define CTX_ONE_FS 524288


#define RESULT_PASS 1
#define RESULT_FAIL 2
#define RESULT_WARN 4
#define RESULT_LOCATED 8
#define FLAG_RESULT_MASK 15
#define RESULT_RUNHOOK 8192



#define FP_HASSTAT 1

#define BLOCKSIZE 4096

#define IGNORE -1

#define VERSION "1.10.2"


typedef struct
{
int Flags;
char *Path;
char *Hash;
char *HashType;
char *Data;
struct stat FStat;
void *Next;
} TFingerprint;


typedef struct
{
STREAM *NetCon;
STREAM *Out; 
STREAM *Aux; 
HASH *Hash;
char *HashType;
char *HashStr;
char *Targets;
int Action;
int Flags;
int Encoding;  
dev_t StartingFS;
ListNode *Vars;
} HashratCtx;


extern int Flags;
extern char *DiffHook;
extern char *Key;
extern char *LocalHost;
extern const char *HashratHashTypes[];
extern ListNode *IncludeExclude;
extern int MatchCount, DiffCount;
extern time_t Now;

TFingerprint *TFingerprintCreate(const char *Hash, const char *HashType, const char *Data, const char *Path);
void HashratCtxDestroy(void *p_Ctx);
void HashratStoreHash(HashratCtx *Ctx, const char *Path, struct stat *Stat, const char *Hash);
int HashratOutputInfo(HashratCtx *Ctx, STREAM *S, const char *Path, struct stat *Stat, const char *Hash);
void RunHookScript(const char *Hook, const char *Path, const char *Other);
char *ReformatHash(char *RetStr, const char *Str, int OutputLen, int SegmentSize, char SegmentChar);

#endif