1 /*-
2  ***********************************************************************
3  *
4  * $Id: mask.h,v 1.21 2014/07/18 06:40:44 mavrik Exp $
5  *
6  ***********************************************************************
7  *
8  * Copyright 2005-2014 The FTimes Project, All Rights Reserved.
9  *
10  ***********************************************************************
11  */
12 #ifndef _MASK_H_INCLUDED
13 #define _MASK_H_INCLUDED
14 
15 /*-
16  ***********************************************************************
17  *
18  * Defines
19  *
20  ***********************************************************************
21  */
22 #define MASK_NAME_SIZE 32
23 
24 /*--------------------------------*/
25 #define CMP_NAME        0x00000001
26 #define CMP_DEV         0x00000002
27 #define CMP_INODE       0x00000004
28 #define CMP_VOLUME      0x00000008
29 #define CMP_FINDEX      0x00000010
30 #define CMP_MODE        0x00000020
31 #define CMP_ATTRIBUTES  0x00000040
32 #define CMP_NLINK       0x00000080
33 #define CMP_UID         0x00000100
34 #define CMP_GID         0x00000200
35 #define CMP_RDEV        0x00000400
36 #define CMP_ATIME       0x00000800
37 #define CMP_AMS         0x00001000
38 #define CMP_MTIME       0x00002000
39 #define CMP_MMS         0x00004000
40 #define CMP_CTIME       0x00008000
41 #define CMP_CMS         0x00010000
42 #define CMP_CHTIME      0x00020000
43 #define CMP_CHMS        0x00040000
44 #define CMP_SIZE        0x00080000
45 #define CMP_ALTSTREAMS  0x00100000
46 #define CMP_MD5         0x00200000
47 #define CMP_SHA1        0x00400000
48 #define CMP_SHA256      0x00800000
49 #define CMP_MAGIC       0x01000000
50 #define CMP_OWNER       0x02000000
51 #define CMP_GROUP       0x04000000
52 #define CMP_DACL        0x08000000
53 /*--------------------------------*/
54 #define CMP_ALL_MASK    0x0ffffffe /* The name field is excluded because it's a mandatory field. */
55 #define CMP_HASHES_MASK 0x00e00000
56 #define CMP_TIMES_MASK  0x0007f800
57 /*--------------------------------*/
58 
59 /*--------------------------------*/
60 #define DIG_ALL_MASK            ~0
61 /*--------------------------------*/
62 
63 #ifdef WIN32
64 /*--------------------------------*/
65 #define MAP_VOLUME      0x00000001
66 #define MAP_FINDEX      0x00000002
67 #define MAP_ATTRIBUTES  0x00000004
68 #define MAP_ATIME       0x00000008
69 #define MAP_MTIME       0x00000010
70 #define MAP_CTIME       0x00000020
71 #define MAP_CHTIME      0x00000040
72 #define MAP_SIZE        0x00000080
73 #define MAP_ALTSTREAMS  0x00000100
74 #define MAP_MD5         0x00000200
75 #define MAP_SHA1        0x00000400
76 #define MAP_SHA256      0x00000800
77 #define MAP_MAGIC       0x00001000
78 #define MAP_OWNER       0x00002000
79 #define MAP_GROUP       0x00004000
80 #define MAP_DACL        0x00008000
81 /*--------------------------------*/
82 #define MAP_ALL_MASK    0x0000ffff
83 #define MAP_HASHES_MASK 0x00000e00
84 #define MAP_TIMES_MASK  0x00000078
85 /*--------------------------------*/
86 #else
87 /*--------------------------------*/
88 #define MAP_DEV         0x00000001
89 #define MAP_INODE       0x00000002
90 #define MAP_MODE        0x00000004
91 #define MAP_NLINK       0x00000008
92 #define MAP_UID         0x00000010
93 #define MAP_GID         0x00000020
94 #define MAP_RDEV        0x00000040
95 #define MAP_ATIME       0x00000080
96 #define MAP_MTIME       0x00000100
97 #define MAP_CTIME       0x00000200
98 #define MAP_SIZE        0x00000400
99 #define MAP_MD5         0x00000800
100 #define MAP_SHA1        0x00001000
101 #define MAP_SHA256      0x00002000
102 #define MAP_MAGIC       0x00004000
103 /*--------------------------------*/
104 #define MAP_ALL_MASK    0x00007fff
105 #define MAP_HASHES_MASK 0x00003800
106 #define MAP_LSTAT_MASK  0x000007ff
107 #define MAP_TIMES_MASK  0x00000380
108 /*--------------------------------*/
109 #endif
110 
111 #define MASK_MASK_TYPE_USS 1
112 
113 #define MASK_RUNMODE_TYPE_CMP 1
114 #define MASK_RUNMODE_TYPE_DIG 2
115 #define MASK_RUNMODE_TYPE_MAP 3
116 
117 #define MASK_TABLE_TYPE_B2S 1
118 
119 /*-
120  ***********************************************************************
121  *
122  * Typedefs
123  *
124  ***********************************************************************
125  */
126 typedef struct _MASK_B2S_TABLE /* B2S - Bits 2 Set */
127 {
128   char                acName[MASK_NAME_SIZE];
129   int                 iBits2Set;
130 } MASK_B2S_TABLE;
131 
132 typedef struct _MASK_USS_MASK /* USS - User Supplied String */
133 {
134   char               *pcMask;
135   unsigned long       ulMask;
136 } MASK_USS_MASK;
137 
138 /*-
139  ***********************************************************************
140  *
141  * Macros
142  *
143  ***********************************************************************
144  */
145 #define MASK_BIT_IS_SET(mask, bit) (((mask) & (bit)) == (bit))
146 
147 /*-
148  ***********************************************************************
149  *
150  * Function Prototypes
151  *
152  ***********************************************************************
153  */
154 char               *MaskBuildMask(unsigned long ulMask, int iType, char *pcError);
155 void                MaskFreeMask(MASK_USS_MASK *psMask);
156 int                 MaskGetTableLength(int iType);
157 MASK_B2S_TABLE     *MaskGetTableReference(int iType);
158 MASK_USS_MASK      *MaskNewMask(char *pcError);
159 MASK_USS_MASK      *MaskParseMask(char *pcMask, int iType, char *pcError);
160 int                 MaskSetDynamicString(char **ppcValue, char *pcNewValue, char *pcError);
161 int                 MaskSetMask(MASK_USS_MASK *psMask, char *pcMask, char *pcError);
162 
163 #endif /* !_MASK_H_INCLUDED */
164