Browse code

Added .clang-format style rules, clam-format script to automate formatting of ClamAV code, and preparing select files so that clang-format does not alter carefully formatted sections.

Micah Snyder authored on 2018/12/04 02:37:58
Showing 46 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,117 @@
0
+---
1
+Language:        Cpp
2
+AccessModifierOffset: -2
3
+AlignAfterOpenBracket: Align
4
+AlignConsecutiveAssignments: true
5
+AlignConsecutiveDeclarations: false
6
+AlignEscapedNewlines: Left
7
+AlignOperands:   true
8
+AlignTrailingComments: true
9
+AllowAllParametersOfDeclarationOnNextLine: true
10
+AllowShortBlocksOnASingleLine: false
11
+AllowShortCaseLabelsOnASingleLine: false
12
+AllowShortFunctionsOnASingleLine: Empty
13
+AllowShortIfStatementsOnASingleLine: true
14
+AllowShortLoopsOnASingleLine: true
15
+AlwaysBreakAfterDefinitionReturnType: None
16
+AlwaysBreakAfterReturnType: None
17
+AlwaysBreakBeforeMultilineStrings: false
18
+AlwaysBreakTemplateDeclarations: MultiLine
19
+BinPackArguments: true
20
+BinPackParameters: true
21
+BraceWrapping:   
22
+  AfterClass:      true
23
+  AfterControlStatement: false
24
+  AfterEnum:       false
25
+  AfterFunction:   true
26
+  AfterNamespace:  true
27
+  AfterObjCDeclaration: false
28
+  AfterStruct:     false
29
+  AfterUnion:      false
30
+  AfterExternBlock: false
31
+  BeforeCatch:     false
32
+  BeforeElse:      false
33
+  IndentBraces:    false
34
+  SplitEmptyFunction: true
35
+  SplitEmptyRecord: true
36
+  SplitEmptyNamespace: true
37
+BreakBeforeBinaryOperators: None
38
+BreakBeforeBraces: Linux
39
+BreakBeforeInheritanceComma: false
40
+BreakInheritanceList: BeforeColon
41
+BreakBeforeTernaryOperators: true
42
+BreakConstructorInitializersBeforeComma: false
43
+BreakConstructorInitializers: BeforeColon
44
+BreakAfterJavaFieldAnnotations: false
45
+BreakStringLiterals: true
46
+ColumnLimit:     0
47
+CommentPragmas:  '^ IWYU pragma:'
48
+CompactNamespaces: false
49
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
50
+ConstructorInitializerIndentWidth: 4
51
+ContinuationIndentWidth: 4
52
+Cpp11BracedListStyle: true
53
+DerivePointerAlignment: true
54
+DisableFormat:   false
55
+ExperimentalAutoDetectBinPacking: false
56
+FixNamespaceComments: true
57
+ForEachMacros:   
58
+  - foreach
59
+  - Q_FOREACH
60
+  - BOOST_FOREACH
61
+IncludeBlocks:   Preserve
62
+IncludeCategories: 
63
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
64
+    Priority:        2
65
+  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
66
+    Priority:        3
67
+  - Regex:           '.*'
68
+    Priority:        1
69
+IncludeIsMainRegex: '(Test)?$'
70
+IndentCaseLabels: true
71
+IndentPPDirectives: None
72
+IndentWidth:     4
73
+IndentWrappedFunctionNames: false
74
+JavaScriptQuotes: Leave
75
+JavaScriptWrapImports: true
76
+KeepEmptyLinesAtTheStartOfBlocks: true
77
+MacroBlockBegin: ''
78
+MacroBlockEnd:   ''
79
+MaxEmptyLinesToKeep: 1
80
+NamespaceIndentation: None
81
+ObjCBinPackProtocolList: Auto
82
+ObjCBlockIndentWidth: 2
83
+ObjCSpaceAfterProperty: false
84
+ObjCSpaceBeforeProtocolList: true
85
+PenaltyBreakAssignment: 2
86
+PenaltyBreakBeforeFirstCallParameter: 19
87
+PenaltyBreakComment: 300
88
+PenaltyBreakFirstLessLess: 120
89
+PenaltyBreakString: 1000
90
+PenaltyBreakTemplateDeclaration: 10
91
+PenaltyExcessCharacter: 1000000
92
+PenaltyReturnTypeOnItsOwnLine: 60
93
+PointerAlignment: Right
94
+ReflowComments:  true
95
+SortIncludes:    false
96
+SortUsingDeclarations: true
97
+SpaceAfterCStyleCast: false
98
+SpaceAfterTemplateKeyword: true
99
+SpaceBeforeAssignmentOperators: true
100
+SpaceBeforeCpp11BracedList: false
101
+SpaceBeforeCtorInitializerColon: true
102
+SpaceBeforeInheritanceColon: true
103
+SpaceBeforeParens: ControlStatements
104
+SpaceBeforeRangeBasedForLoopColon: true
105
+SpaceInEmptyParentheses: false
106
+SpacesBeforeTrailingComments: 1
107
+SpacesInAngles:  false
108
+SpacesInContainerLiterals: true
109
+SpacesInCStyleCastParentheses: false
110
+SpacesInParentheses: false
111
+SpacesInSquareBrackets: false
112
+Standard:        Cpp11
113
+TabWidth:        8
114
+UseTab:          Never
115
+...
116
+
0 117
new file mode 100755
... ...
@@ -0,0 +1,73 @@
0
+#!/bin/bash
1
+
2
+clang-format -style='{ Language: Cpp, UseTab: Never, IndentWidth: 4, AlignTrailingComments: true, AlignConsecutiveAssignments: true, AlignAfterOpenBracket: true, AlignEscapedNewlines: Left, AlignOperands: true, AllowShortFunctionsOnASingleLine: Empty, AllowShortIfStatementsOnASingleLine: true, AllowShortLoopsOnASingleLine: true, BreakBeforeBraces: Linux, BreakBeforeTernaryOperators: true, ColumnLimit: 0, FixNamespaceComments: true, SortIncludes: false, MaxEmptyLinesToKeep: 1, SpaceBeforeParens: ControlStatements, IndentCaseLabels: true, DerivePointerAlignment: true }' -dump-config > .clang-format
3
+
4
+clang-format -i -verbose clamav-milter/*.c
5
+clang-format -i -verbose clamav-milter/*.h
6
+clang-format -i -verbose clambc/*.c
7
+clang-format -i -verbose clambc/*.h
8
+clang-format -i -verbose clamconf/*.c
9
+clang-format -i -verbose clamconf/*.h
10
+clang-format -i -verbose clamd/*.c
11
+clang-format -i -verbose clamd/*.h
12
+clang-format -i -verbose clamdscan/*.c
13
+clang-format -i -verbose clamdscan/*.h
14
+clang-format -i -verbose clamdtop/*.c
15
+clang-format -i -verbose clamdtop/*.h
16
+clang-format -i -verbose clamscan/*.c
17
+clang-format -i -verbose clamscan/*.h
18
+clang-format -i -verbose clamsubmit/*.c
19
+clang-format -i -verbose clamsubmit/*.h
20
+clang-format -i -verbose examples/*.c
21
+clang-format -i -verbose examples/*.h
22
+clang-format -i -verbose examples/fileprop_analysis/*.c
23
+clang-format -i -verbose examples/fileprop_analysis/old/*.c
24
+clang-format -i -verbose freshclam/*.c
25
+clang-format -i -verbose freshclam/*.h
26
+clang-format -i -verbose libclamav/*.c
27
+clang-format -i -verbose libclamav/*.h
28
+clang-format -i -verbose libclamav/jsparse/*.c
29
+clang-format -i -verbose libclamav/jsparse/*.h
30
+clang-format -i -verbose libclamav/lzw/*.c
31
+clang-format -i -verbose libclamav/lzw/*.h
32
+clang-format -i -verbose libclamav/nsis/nulsft.*
33
+clang-format -i -verbose libclamunrar_iface/*.c
34
+clang-format -i -verbose libclamunrar_iface/*.h
35
+clang-format -i -verbose libfreshclam/*.c
36
+clang-format -i -verbose libfreshclam/*.h
37
+clang-format -i -verbose shared/*.c
38
+clang-format -i -verbose shared/*.h
39
+clang-format -i -verbose sigtool/*.c
40
+clang-format -i -verbose sigtool/*.h
41
+clang-format -i -verbose unit_tests/*.c
42
+clang-format -i -verbose unit_tests/*.h
43
+clang-format -i -verbose win32/compat/*.c
44
+clang-format -i -verbose win32/compat/*.h
45
+clang-format -i -verbose win32/*.h
46
+
47
+# Undo changes to specific files (whitelist)
48
+git checkout clamd/fts.c
49
+git checkout clamd/priv_fts.h
50
+git checkout libclamav/iana_cctld.h
51
+git checkout libclamav/bytecode_api_decl.c
52
+git checkout libclamav/bytecode_api_impl.h
53
+git checkout libclamav/bytecode_hooks.h
54
+git checkout libclamav/rijndael.c
55
+git checkout libclamav/rijndael.h
56
+git checkout libclamav/yara_lexer.c
57
+git checkout libclamav/yara_grammar.c
58
+git checkout libclamav/yara_grammar.h
59
+git checkout libclamav/yara_exec.c
60
+git checkout libclamav/yara_exec.h
61
+git checkout libclamav/yara_compiler.h
62
+git checkout libclamav/yara_compiler.h
63
+git checkout libclamav/yara_parser.h
64
+git checkout libclamav/yara_hash.c
65
+git checkout libclamav/yara_hash.h
66
+git checkout libclamav/yara_arena.c
67
+git checkout libclamav/yara_arena.h
68
+git checkout libclamav/inffixed64.h
69
+git checkout libclamav/inflate64.h
70
+git checkout libclamav/inflate64.c
71
+git checkout libclamav/inflate64_priv.h
72
+git checkout shared/queue.h
... ...
@@ -446,7 +446,7 @@ sfsistat clamfi_eom(SMFICTX *ctx) {
446 446
 				} else if(pid > 0) {
447 447
 				    int wret;
448 448
 				    pthread_mutex_unlock(&virusaction_lock);
449
-				    while((wret = waitpid(pid, &ret, 0)) == -1 && errno == EINTR);
449
+				    while ((wret = waitpid(pid, &ret, 0)) == -1 && errno == EINTR) continue;
450 450
 				    if(wret<0)
451 451
 					logg("!VirusEvent: waitpid() failed: %s\n", cli_strerror(errno, er, sizeof(er)));
452 452
 				    else {
... ...
@@ -175,7 +175,7 @@ virusaction (const char *filename, const char *virname,
175 175
     else if (pid > 0)
176 176
     {                           /* parent */
177 177
         pthread_mutex_unlock (&virusaction_lock);
178
-        while (waitpid (pid, NULL, 0) == -1 && errno == EINTR);
178
+        while (waitpid (pid, NULL, 0) == -1 && errno == EINTR) continue;
179 179
     }
180 180
     else
181 181
     {
... ...
@@ -669,7 +669,7 @@ int parallel_client_scan(char *file, int scantype, int *infected, int *err, int
669 669
     }
670 670
 
671 671
     sendln(cdata.sockd, "zEND", 5);
672
-    while(cdata.ids && !dspresult(&cdata));
672
+    while (cdata.ids && !dspresult(&cdata)) continue;
673 673
     closesocket(cdata.sockd);
674 674
 
675 675
     *infected += cdata.infected;
... ...
@@ -860,7 +860,7 @@ int scanmanager(const struct optstruct *opts)
860 860
     }
861 861
 
862 862
     if((ret = cl_engine_compile(engine)) != 0) {
863
-        logg("!Database initialization error: %s\n", cl_strerror(ret));;
863
+        logg("!Database initialization error: %s\n", cl_strerror(ret));
864 864
 
865 865
         cl_engine_free(engine);
866 866
         return 2;
... ...
@@ -440,7 +440,7 @@ int main(int argc, char *argv[])
440 440
     }
441 441
     curl_easy_setopt(clam_curl, CURLOPT_COOKIE, str);
442 442
     free(str);
443
-    curl_formadd(&post, &last, CURLFORM_COPYNAME, "utf8", CURLFORM_COPYCONTENTS, "\x27" "\x13", CURLFORM_END);
443
+    curl_formadd(&post, &last, CURLFORM_COPYNAME, "utf8", CURLFORM_COPYCONTENTS, "\x27\x13", CURLFORM_END);
444 444
     curl_formadd(&post, &last, CURLFORM_COPYNAME, "authenticity_token", CURLFORM_COPYCONTENTS, authenticity_token, CURLFORM_END);
445 445
     curl_formadd(&post, &last, CURLFORM_COPYNAME, "submissionID", CURLFORM_COPYCONTENTS, submissionID, CURLFORM_END);
446 446
     curl_formadd(&post, &last, CURLFORM_COPYNAME, "type", CURLFORM_COPYCONTENTS, malware?"malware":"fp", CURLFORM_END);
... ...
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
82 82
 
83 83
     /* build engine */
84 84
     if((ret = cl_engine_compile(engine)) != CL_SUCCESS) {
85
-	printf("Database initialization error: %s\n", cl_strerror(ret));;
85
+	printf("Database initialization error: %s\n", cl_strerror(ret));
86 86
         cl_engine_free(engine);
87 87
 	close(fd);
88 88
 	return 2;
... ...
@@ -187,7 +187,7 @@ static int
187 187
 download (const struct optstruct *opts, const char *cfgfile)
188 188
 {
189 189
     time_t currtime;
190
-    int ret = 0, try = 1, maxattempts = 0;
190
+    int ret = 0, attempt = 1, maxattempts = 0;
191 191
     const struct optstruct *opt;
192 192
 
193 193
     time(&currtime);
... ...
@@ -207,17 +207,17 @@ download (const struct optstruct *opts, const char *cfgfile)
207 207
     {
208 208
         while (opt)
209 209
         {
210
-            ret = downloadmanager (opts, opt->strarg, try);
210
+            ret = downloadmanager (opts, opt->strarg, attempt);
211 211
 #ifndef _WIN32
212 212
             alarm (0);
213 213
 #endif
214 214
             if (ret == FCE_CONNECTION || ret == FCE_BADCVD
215 215
                 || ret == FCE_FAILEDGET || ret == FCE_MIRRORNOTSYNC)
216 216
             {
217
-                if (try < maxattempts)
217
+                if (attempt < maxattempts)
218 218
                 {
219 219
                     logg ("Trying again in 5 secs...\n");
220
-                    try++;
220
+                    attempt++;
221 221
                     sleep (5);
222 222
                     continue;
223 223
                 }
... ...
@@ -229,7 +229,7 @@ download (const struct optstruct *opts, const char *cfgfile)
229 229
                     {
230 230
                         logg ("Update failed. Your network may be down or none of the mirrors listed in %s is working. Check https://www.clamav.net/documents/official-mirror-faq for possible reasons.\n", cfgfile);
231 231
                     }
232
-                    try = 1;
232
+                    attempt = 1;
233 233
                 }
234 234
 
235 235
             }
... ...
@@ -1597,7 +1597,7 @@ test_database_wrap (const char *file, const char *newdb, int bytecode)
1597 1597
         }
1598 1598
         fclose (f);
1599 1599
 
1600
-        while ((ret = waitpid (pid, &status, 0)) == -1 && errno == EINTR);
1600
+        while ((ret = waitpid (pid, &status, 0)) == -1 && errno == EINTR) continue;
1601 1601
         if (ret == -1 && errno != ECHILD)
1602 1602
             logg ("^waitpid() failed: %s\n", strerror (errno));
1603 1603
         cli_chomp (firstline);
... ...
@@ -48,9 +48,9 @@
48 48
 
49 49
 #ifndef timercmp
50 50
 #define timercmp(a, b, cmp)          \
51
-  (((a)->tv_sec == (b)->tv_sec) ?     \
52
-   ((a)->tv_usec cmp (b)->tv_usec) :  \
53
-   ((a)->tv_sec cmp (b)->tv_sec))
51
+  (((a)->tv_sec == (b)->tv_sec)      \
52
+   ? ((a)->tv_usec cmp (b)->tv_usec)   \
53
+   : ((a)->tv_sec cmp (b)->tv_sec))
54 54
 #endif /* timercmp */
55 55
 
56 56
 #ifndef timersub
... ...
@@ -204,7 +204,7 @@ int cli_scanapm(cli_ctx *ctx)
204 204
                 !strncmp((char*)apentry.type, "Apple_Driver_ATAPI", 32) ||
205 205
                 !strncmp((char*)apentry.type, "Apple_Patches",      32)) {
206 206
 
207
-                partsize = apentry.pBlockCount * 2048;;
207
+                partsize = apentry.pBlockCount * 2048;
208 208
             }
209 209
         }
210 210
 
... ...
@@ -281,7 +281,7 @@ static int apm_prtn_intxn(cli_ctx *ctx, struct apm_partition_info *aptable, size
281 281
                 !strncmp((char*)apentry.type, "Apple_Driver_ATAPI", 32) ||
282 282
                 !strncmp((char*)apentry.type, "Apple_Patches",      32)) {
283 283
 
284
-                apentry.pBlockCount = apentry.pBlockCount * 4;;
284
+                apentry.pBlockCount = apentry.pBlockCount * 4;
285 285
             }
286 286
         }
287 287
 
... ...
@@ -2170,7 +2170,7 @@ int asn1_load_mscat(fmap_t *map, struct cl_engine *engine) {
2170 2170
             }
2171 2171
             if(!engine->hm_fp) {
2172 2172
                 if(!(engine->hm_fp = mpool_calloc(engine->mempool, 1, sizeof(*db)))) {
2173
-                    tag.size = 1;;
2173
+                    tag.size = 1;
2174 2174
                     return 1;
2175 2175
                 }
2176 2176
 #ifdef USE_MPOOL
... ...
@@ -34,6 +34,7 @@
34 34
 #include "binhex.h"
35 35
 
36 36
 
37
+// clang-format off
37 38
 static const uint8_t hqxtbl[] = {
38 39
     /*           00   01   02   03   04   05   06   07   08   09   0a   0b   0c   0d   0e   0f */
39 40
     /* 00-0f */	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
... ...
@@ -45,6 +46,7 @@ static const uint8_t hqxtbl[] = {
45 45
     /* 60-6f */	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0xff,0x37,0x38,0x39,0x3a,0x3b,0x3c,0xff,0xff,
46 46
     /* 70-7f */	0x3d,0x3e,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
47 47
 };
48
+// clang-format on
48 49
 
49 50
 #define BH_FLUSH_SZ (BUFSIZ - 256)
50 51
 
... ...
@@ -30,7 +30,8 @@
30 30
  * fallback.
31 31
  * Usually bytecode.cvd will contain this bytecode */
32 32
 
33
-static const char* builtin_bc_startup = "ClamBCafhhbfkjmld|afefdfggifnf```aa```|biacflfafmfbfcfmb`cnbacacmbachcccmbgfbfcc`ccchcbfdf``bgcaap`clamcoincidencejb:4096\n"
33
+static const char* builtin_bc_startup =
34
+"ClamBCafhhbfkjmld|afefdfggifnf```aa```|biacflfafmfbfcfmb`cnbacacmbachcccmbgfbfcc`ccchcbfdf``bgcaap`clamcoincidencejb:4096\n"
34 35
 "\n"
35 36
 "Teddaaahdabahdacahdadahdaeahdafahdagahebfgebidebegebdgebgdebkdebcgebbgebageb`gebofebnfebmfebedeblfebkfebjfebadcbgab`bb`bb`bb`bb`bb`bb`bbifbifbifbifbifbifbifahahahahahahahahahebneebifaaaaaaaab`baabb`bb`baacb`bbadb`baacb`bboeb`baacb`bb`bb`baadb`bbadb`bb`baadb`bbadbadb`bdbadahdbkaahdbbcahdbibahdb`eahdbddahdbodahdbdaahdaiahdakahdamahdahahdbncahdbnbah\n"
36 37
 "Ebjdaibcdbbf|bcaefnfgfifnfefoedfcfofnfffoelfeffgeflf``bbdbbf|bkaefnfgfifnfefoeffegnfcfdgifofnfaflfifdgigoelfeffgeflf``agbcf|baadfefbfeggfoe`gbgifnfdgoeegifnfdg``bcabcf|afdgefcgdgbc``afbdf|b`adfefbfeggfoe`gbgifnfdgoecgdgbg``bhdbef|b`agfefdgoeefnffgifbgofnfmfefnfdg``aabff|afdgefcgdgac``bidbgf|bdadfifcgafbflfefoebfigdgefcfofdfefoeifff``bjdbgf|aodfifcgafbflfefoejfifdgoeifff``\n"
... ...
@@ -80,25 +80,23 @@ enum BytecodeKind {
80 80
 enum FunctionalityLevels {
81 81
     FUNC_LEVEL_096       = 51, /* LibClamAV release 0.96.0: bytecode engine released */
82 82
     FUNC_LEVEL_096_dev   = 52,
83
-    FUNC_LEVEL_096_1     = 53, /* LibClamAV release 0.96.1: logical signature use of VI/macros
84
-                                * requires this minimum functionality level */
83
+    FUNC_LEVEL_096_1     = 53, /* LibClamAV release 0.96.1: logical signature use of VI/macros requires this minimum functionality level */
85 84
     FUNC_LEVEL_096_1_dev = 54,
86 85
     FUNC_LEVEL_096_2     = 54, /* LibClamAV release 0.96.2: PDF Hooks require this minimum level */
87 86
     FUNC_LEVEL_096_2_dev = 55,
88 87
     FUNC_LEVEL_096_3     = 55, /* LibClamAV release 0.96.3: BC_PE_ALL bytecodes require this minimum level */
89
-    FUNC_LEVEL_096_4     = 56, /* LibClamAV release 0.96.4: minimum recommended engine version, older versions 
90
-                                * have quadratic load time */
88
+    FUNC_LEVEL_096_4     = 56, /* LibClamAV release 0.96.4: minimum recommended engine version, older versions have quadratic load time */
91 89
     FUNC_LEVEL_096_5     = 58, /* LibClamAV release 0.96.5 */
92 90
     FUNC_LEVEL_097       = 60, /* LibClamAV release 0.97.0: older bytecodes may incorrectly use 57 */
93 91
     FUNC_LEVEL_097_1     = 61, /* LibClamAV release 0.97.1 */
94 92
     FUNC_LEVEL_097_2     = 62, /* LibClamAV release 0.97.2 */
95
-    FUNC_LEVEL_097_3     = 63, /* LibClamAV release 0.97.3 */ /*last bcc changes as former team resigns*/
93
+    FUNC_LEVEL_097_3     = 63, /* LibClamAV release 0.97.3: last bcc changes as former team resigns*/
96 94
     FUNC_LEVEL_097_4     = 64, /* LibClamAV release 0.97.4 */
97 95
     FUNC_LEVEL_097_5     = 65, /* LibClamAV release 0.97.5 */
98 96
     FUNC_LEVEL_097_6     = 67, /* LibClamAV release 0.97.6 */
99 97
     FUNC_LEVEL_097_7     = 68, /* LibClamAV release 0.97.7 */
100 98
     FUNC_LEVEL_097_8     = 69, /* LibClamAV release 0.97.8 */
101
-    FUNC_LEVEL_098_1     = 76, /* LibClamAV release 0.98.1 */ /*last syncing to clamav*/
99
+    FUNC_LEVEL_098_1     = 76, /* LibClamAV release 0.98.1: last syncing to clamav*/
102 100
     FUNC_LEVEL_098_2     = 77, /* LibClamAV release 0.98.2 */
103 101
     FUNC_LEVEL_098_3     = 77, /* LibClamAV release 0.98.3 */
104 102
     FUNC_LEVEL_098_4     = 77, /* LibClamAV release 0.98.4 */
... ...
@@ -209,6 +207,7 @@ enum bc_json_type {
209 209
 \group_engine
210 210
  * Scan option flag values for engine_scan_options(). *DEPRECATED*
211 211
  */
212
+// clang-format off
212 213
 #define CL_SCAN_RAW                     0x0
213 214
 #define CL_SCAN_ARCHIVE                 0x1
214 215
 #define CL_SCAN_MAIL                    0x2
... ...
@@ -242,7 +241,7 @@ enum bc_json_type {
242 242
 //#define UNUSED                        0x20000000
243 243
 #define CL_SCAN_PERFORMANCE_INFO        0x40000000 /* Collect performance timings */
244 244
 #define CL_SCAN_INTERNAL_COLLECT_SHA    0x80000000 /* Enables hash output in sha-collect builds - for internal use only */
245
-
245
+// clang-format on
246 246
 
247 247
 #ifdef __CLAMBC__
248 248
 
... ...
@@ -706,12 +706,14 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct
706 706
             DEFINE_BINOP(OP_BC_OR, res = op0 | op1);
707 707
             DEFINE_BINOP(OP_BC_XOR, res = op0 ^ op1);
708 708
 
709
+// clang-format off
709 710
             DEFINE_SCASTOP(OP_BC_SEXT,
710 711
                           CHOOSE(READ1(sres, inst->u.cast.source); res = sres ? ~0 : 0,
711 712
                                  READ8(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask),
712 713
                                  READ16(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask),
713 714
                                  READ32(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask),
714 715
                                  READ64(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask)));
716
+// clang-format on
715 717
             DEFINE_CASTOP(OP_BC_ZEXT,
716 718
                           CHOOSE(READ1(res, inst->u.cast.source),
717 719
                                  READ8(res, inst->u.cast.source),
... ...
@@ -123,6 +123,7 @@ typedef enum cl_error_t {
123 123
 } cl_error_t;
124 124
 
125 125
 /* db options */
126
+// clang-format off
126 127
 #define CL_DB_PHISHING          0x2
127 128
 #define CL_DB_PHISHING_URLS     0x8
128 129
 #define CL_DB_PUA               0x10
... ...
@@ -195,9 +196,9 @@ struct cl_scan_options {
195 195
 #define CL_SCAN_DEV_COLLECT_PERFORMANCE_INFO        0x2 /* collect performance timings */
196 196
 
197 197
 /* cl_countsigs options */
198
-#define CL_COUNTSIGS_OFFICIAL	    0x1
199
-#define CL_COUNTSIGS_UNOFFICIAL	    0x2
200
-#define CL_COUNTSIGS_ALL	    (CL_COUNTSIGS_OFFICIAL | CL_COUNTSIGS_UNOFFICIAL)
198
+#define CL_COUNTSIGS_OFFICIAL                       0x1
199
+#define CL_COUNTSIGS_UNOFFICIAL                     0x2
200
+#define CL_COUNTSIGS_ALL                            (CL_COUNTSIGS_OFFICIAL | CL_COUNTSIGS_UNOFFICIAL)
201 201
 
202 202
 /* For the new engine_options bit field in the engine */
203 203
 #define ENGINE_OPTIONS_NONE             0x0
... ...
@@ -206,6 +207,7 @@ struct cl_scan_options {
206 206
 #define ENGINE_OPTIONS_DISABLE_PE_STATS 0x4
207 207
 #define ENGINE_OPTIONS_DISABLE_PE_CERTS 0x8
208 208
 #define ENGINE_OPTIONS_PE_DUMPCERTS     0x10
209
+// clang-format on
209 210
 
210 211
 struct cl_engine;
211 212
 struct cl_settings;
... ...
@@ -269,7 +271,7 @@ extern struct cl_engine *cl_engine_new(void);
269 269
 enum cl_engine_field {
270 270
     CL_ENGINE_MAX_SCANSIZE,	    /* uint64_t */
271 271
     CL_ENGINE_MAX_FILESIZE,	    /* uint64_t */
272
-    CL_ENGINE_MAX_RECURSION,	    /* uint32_t	*/
272
+    CL_ENGINE_MAX_RECURSION,	    /* uint32_t */
273 273
     CL_ENGINE_MAX_FILES,	    /* uint32_t */
274 274
     CL_ENGINE_MIN_CC_COUNT,	    /* uint32_t */
275 275
     CL_ENGINE_MIN_SSN_COUNT,	    /* uint32_t */
... ...
@@ -315,8 +317,7 @@ enum bytecode_mode {
315 315
     CL_BYTECODE_MODE_AUTO=0, /* JIT if possible, fallback to interpreter */
316 316
     CL_BYTECODE_MODE_JIT, /* force JIT */
317 317
     CL_BYTECODE_MODE_INTERPRETER, /* force interpreter */
318
-    CL_BYTECODE_MODE_TEST, /* both JIT and interpreter, compare results,
319
-			      all failures are fatal */
318
+    CL_BYTECODE_MODE_TEST, /* both JIT and interpreter, compare results, all failures are fatal */
320 319
     CL_BYTECODE_MODE_OFF /* for query only, not settable */
321 320
 };
322 321
 
... ...
@@ -45,94 +45,96 @@ struct cli_dconf {
45 45
     uint32_t pcre;
46 46
 };
47 47
 
48
+// clang-format off
49
+
48 50
 /* PE flags */
49
-#define PE_CONF_PARITE	    0x1
50
-#define PE_CONF_KRIZ	    0x2
51
-#define PE_CONF_MAGISTR	    0x4
52
-#define PE_CONF_POLIPOS	    0x8
53
-#define PE_CONF_MD5SECT	    0x10
54
-#define PE_CONF_UPX	    0x20
55
-#define PE_CONF_FSG	    0x40
56
-#define PE_CONF_SWIZZOR     0x80
57
-#define PE_CONF_PETITE	    0x100
58
-#define PE_CONF_PESPIN	    0x200
59
-#define PE_CONF_YC	    0x400
60
-#define PE_CONF_WWPACK	    0x800
61
-#define PE_CONF_NSPACK	    0x1000
62
-#define PE_CONF_MEW	    0x2000
63
-#define PE_CONF_UPACK	    0x4000
64
-#define PE_CONF_ASPACK	    0x8000
65
-#define PE_CONF_CATALOG	    0x10000
66
-#define PE_CONF_CERTS       0x20000
67
-#define PE_CONF_MATCHICON   0x40000
68
-#define PE_CONF_IMPTBL      0x80000
51
+#define PE_CONF_PARITE    0x1
52
+#define PE_CONF_KRIZ      0x2
53
+#define PE_CONF_MAGISTR   0x4
54
+#define PE_CONF_POLIPOS   0x8
55
+#define PE_CONF_MD5SECT   0x10
56
+#define PE_CONF_UPX       0x20
57
+#define PE_CONF_FSG       0x40
58
+#define PE_CONF_SWIZZOR   0x80
59
+#define PE_CONF_PETITE    0x100
60
+#define PE_CONF_PESPIN    0x200
61
+#define PE_CONF_YC        0x400
62
+#define PE_CONF_WWPACK    0x800
63
+#define PE_CONF_NSPACK    0x1000
64
+#define PE_CONF_MEW       0x2000
65
+#define PE_CONF_UPACK     0x4000
66
+#define PE_CONF_ASPACK    0x8000
67
+#define PE_CONF_CATALOG   0x10000
68
+#define PE_CONF_CERTS     0x20000
69
+#define PE_CONF_MATCHICON 0x40000
70
+#define PE_CONF_IMPTBL    0x80000
69 71
 
70 72
 /* Archive flags */
71
-#define ARCH_CONF_RAR	    0x1
72
-#define ARCH_CONF_ZIP	    0x2
73
-#define ARCH_CONF_GZ	    0x4
74
-#define ARCH_CONF_BZ	    0x8
75
-#define ARCH_CONF_SZDD	    0x10
76
-#define ARCH_CONF_CAB	    0x20
77
-#define ARCH_CONF_CHM	    0x40
78
-#define ARCH_CONF_OLE2	    0x80
79
-#define ARCH_CONF_TAR	    0x100
80
-#define ARCH_CONF_BINHEX    0x200
81
-#define ARCH_CONF_SIS	    0x400
82
-#define ARCH_CONF_NSIS	    0x800
83
-#define ARCH_CONF_ARJ       0x1000
84
-#define ARCH_CONF_AUTOIT    0x2000
85
-#define ARCH_CONF_CPIO	    0x4000
86
-#define ARCH_CONF_ISHIELD   0x8000
87
-#define ARCH_CONF_7Z        0x10000
88
-#define ARCH_CONF_ISO9660   0x20000
89
-#define ARCH_CONF_DMG       0x40000
90
-#define ARCH_CONF_XAR       0x80000
91
-#define ARCH_CONF_HFSPLUS   0x100000
92
-#define ARCH_CONF_XZ        0x200000
93
-#define ARCH_CONF_PASSWD    0x400000
94
-#define ARCH_CONF_MBR       0x800000
95
-#define ARCH_CONF_GPT       0x1000000
96
-#define ARCH_CONF_APM       0x2000000
73
+#define ARCH_CONF_RAR     0x1
74
+#define ARCH_CONF_ZIP     0x2
75
+#define ARCH_CONF_GZ      0x4
76
+#define ARCH_CONF_BZ      0x8
77
+#define ARCH_CONF_SZDD    0x10
78
+#define ARCH_CONF_CAB     0x20
79
+#define ARCH_CONF_CHM     0x40
80
+#define ARCH_CONF_OLE2    0x80
81
+#define ARCH_CONF_TAR     0x100
82
+#define ARCH_CONF_BINHEX  0x200
83
+#define ARCH_CONF_SIS     0x400
84
+#define ARCH_CONF_NSIS    0x800
85
+#define ARCH_CONF_ARJ     0x1000
86
+#define ARCH_CONF_AUTOIT  0x2000
87
+#define ARCH_CONF_CPIO    0x4000
88
+#define ARCH_CONF_ISHIELD 0x8000
89
+#define ARCH_CONF_7Z      0x10000
90
+#define ARCH_CONF_ISO9660 0x20000
91
+#define ARCH_CONF_DMG     0x40000
92
+#define ARCH_CONF_XAR     0x80000
93
+#define ARCH_CONF_HFSPLUS 0x100000
94
+#define ARCH_CONF_XZ      0x200000
95
+#define ARCH_CONF_PASSWD  0x400000
96
+#define ARCH_CONF_MBR     0x800000
97
+#define ARCH_CONF_GPT     0x1000000
98
+#define ARCH_CONF_APM     0x2000000
97 99
 
98 100
 /* Document flags */
99
-#define DOC_CONF_HTML		0x1
100
-#define DOC_CONF_RTF		0x2
101
-#define DOC_CONF_PDF		0x4
102
-#define DOC_CONF_SCRIPT 	0x8
103
-#define DOC_CONF_HTML_SKIPRAW	0x10
104
-#define DOC_CONF_JSNORM         0x20
105
-#define DOC_CONF_SWF		0x40
106
-#define DOC_CONF_MSXML		0x80
107
-#define DOC_CONF_OOXML		0x100
108
-#define DOC_CONF_HWP		0x200
101
+#define DOC_CONF_HTML         0x1
102
+#define DOC_CONF_RTF          0x2
103
+#define DOC_CONF_PDF          0x4
104
+#define DOC_CONF_SCRIPT       0x8
105
+#define DOC_CONF_HTML_SKIPRAW 0x10
106
+#define DOC_CONF_JSNORM       0x20
107
+#define DOC_CONF_SWF          0x40
108
+#define DOC_CONF_MSXML        0x80
109
+#define DOC_CONF_OOXML        0x100
110
+#define DOC_CONF_HWP          0x200
109 111
 
110 112
 /* Mail flags */
111
-#define MAIL_CONF_MBOX	    0x1
112
-#define MAIL_CONF_TNEF	    0x2
113
+#define MAIL_CONF_MBOX 0x1
114
+#define MAIL_CONF_TNEF 0x2
113 115
 
114 116
 /* Other flags */
115
-#define OTHER_CONF_UUENC    0x1
116
-#define OTHER_CONF_SCRENC   0x2
117
-#define OTHER_CONF_RIFF	    0x4
118
-#define OTHER_CONF_JPEG	    0x8
119
-#define OTHER_CONF_CRYPTFF  0x10
120
-#define OTHER_CONF_DLP	    0x20
121
-#define OTHER_CONF_MYDOOMLOG	0x40
117
+#define OTHER_CONF_UUENC        0x1
118
+#define OTHER_CONF_SCRENC       0x2
119
+#define OTHER_CONF_RIFF         0x4
120
+#define OTHER_CONF_JPEG         0x8
121
+#define OTHER_CONF_CRYPTFF      0x10
122
+#define OTHER_CONF_DLP          0x20
123
+#define OTHER_CONF_MYDOOMLOG    0x40
122 124
 #define OTHER_CONF_PREFILTERING 0x80
123
-#define OTHER_CONF_PDFNAMEOBJ	0x100
124
-#define OTHER_CONF_PRTNINTXN	0x200
125
-#define OTHER_CONF_LZW		0x400
125
+#define OTHER_CONF_PDFNAMEOBJ   0x100
126
+#define OTHER_CONF_PRTNINTXN    0x200
127
+#define OTHER_CONF_LZW          0x400
126 128
 
127 129
 /* Phishing flags */
128
-#define PHISHING_CONF_ENGINE   0x1
129
-#define PHISHING_CONF_ENTCONV  0x2
130
+#define PHISHING_CONF_ENGINE  0x1
131
+#define PHISHING_CONF_ENTCONV 0x2
130 132
 
131 133
 /* Bytecode flags */
132 134
 #define BYTECODE_INTERPRETER 0x1
133
-#define BYTECODE_JIT_X86 0x2
134
-#define BYTECODE_JIT_PPC 0x4
135
-#define BYTECODE_JIT_ARM 0x8
135
+#define BYTECODE_JIT_X86     0x2
136
+#define BYTECODE_JIT_PPC     0x4
137
+#define BYTECODE_JIT_ARM     0x8
136 138
 
137 139
 /* Stats/Intel flags */
138 140
 #define DCONF_STATS_DISABLED            0x1
... ...
@@ -143,6 +145,8 @@ struct cli_dconf {
143 143
 #define PCRE_CONF_OPTIONS 0x2
144 144
 #define PCRE_CONF_GLOBAL  0x4
145 145
 
146
+// clang-format on
147
+
146 148
 #define BYTECODE_ENGINE_MASK (BYTECODE_INTERPRETER | BYTECODE_JIT_X86 | BYTECODE_JIT_PPC | BYTECODE_JIT_ARM)
147 149
 
148 150
 #ifdef USE_MPOOL
... ...
@@ -22,35 +22,39 @@
22 22
 #ifndef __DEFAULT_H
23 23
 #define __DEFAULT_H
24 24
 
25
-#define CLI_DEFAULT_AC_MINDEPTH	    2
26
-#define CLI_DEFAULT_AC_MAXDEPTH	    3
27
-#define CLI_DEFAULT_AC_TRACKLEN	    8
25
+// clang-format off
28 26
 
29
-#define CLI_DEFAULT_LSIG_BUFSIZE    32768
30
-#define CLI_DEFAULT_DBIO_BUFSIZE    CLI_DEFAULT_LSIG_BUFSIZE + 1
27
+#define CLI_DEFAULT_AC_MINDEPTH  2
28
+#define CLI_DEFAULT_AC_MAXDEPTH  3
29
+#define CLI_DEFAULT_AC_TRACKLEN  8
31 30
 
32
-#define CLI_DEFAULT_BM_OFFMODE_FSIZE	262144
31
+#define CLI_DEFAULT_LSIG_BUFSIZE 32768
32
+#define CLI_DEFAULT_DBIO_BUFSIZE CLI_DEFAULT_LSIG_BUFSIZE + 1
33 33
 
34
-#define CLI_DEFAULT_MAXSCANSIZE	    104857600
35
-#define CLI_DEFAULT_MAXFILESIZE	    26214400
36
-#define CLI_DEFAULT_MAXRECLEVEL	    16
37
-#define CLI_DEFAULT_MAXFILES	    10000
38
-#define CLI_DEFAULT_MIN_CC_COUNT    3
39
-#define CLI_DEFAULT_MIN_SSN_COUNT   3
34
+#define CLI_DEFAULT_BM_OFFMODE_FSIZE 262144
40 35
 
41
-#define CLI_DEFAULT_MAXEMBEDDEDPE       10485760
42
-#define CLI_DEFAULT_MAXHTMLNORMALIZE    10485760
43
-#define CLI_DEFAULT_MAXHTMLNOTAGS       2097152
44
-#define CLI_DEFAULT_MAXSCRIPTNORMALIZE  5242880
45
-#define CLI_DEFAULT_MAXZIPTYPERCG       1048576
46
-#define CLI_DEFAULT_MAXICONSPE          100
47
-#define CLI_DEFAULT_MAXRECHWP3          16
36
+#define CLI_DEFAULT_MAXSCANSIZE   104857600
37
+#define CLI_DEFAULT_MAXFILESIZE   26214400
38
+#define CLI_DEFAULT_MAXRECLEVEL   16
39
+#define CLI_DEFAULT_MAXFILES      10000
40
+#define CLI_DEFAULT_MIN_CC_COUNT  3
41
+#define CLI_DEFAULT_MIN_SSN_COUNT 3
48 42
 
49
-#define CLI_DEFAULT_MAXPARTITIONS       50
43
+#define CLI_DEFAULT_MAXEMBEDDEDPE      10485760
44
+#define CLI_DEFAULT_MAXHTMLNORMALIZE   10485760
45
+#define CLI_DEFAULT_MAXHTMLNOTAGS      2097152
46
+#define CLI_DEFAULT_MAXSCRIPTNORMALIZE 5242880
47
+#define CLI_DEFAULT_MAXZIPTYPERCG      1048576
48
+#define CLI_DEFAULT_MAXICONSPE         100
49
+#define CLI_DEFAULT_MAXRECHWP3         16
50
+
51
+#define CLI_DEFAULT_MAXPARTITIONS 50
50 52
 
51 53
 /* TODO - set better defaults */
52
-#define CLI_DEFAULT_PCRE_MATCH_LIMIT     100000
53
-#define CLI_DEFAULT_PCRE_RECMATCH_LIMIT  2000
54
-#define CLI_DEFAULT_PCRE_MAX_FILESIZE    26214400
54
+#define CLI_DEFAULT_PCRE_MATCH_LIMIT    100000
55
+#define CLI_DEFAULT_PCRE_RECMATCH_LIMIT 2000
56
+#define CLI_DEFAULT_PCRE_MAX_FILESIZE   26214400
57
+
58
+// clang-format on
55 59
 
56 60
 #endif
... ...
@@ -34,6 +34,8 @@
34 34
 #include "disasm.h"
35 35
 #include "clamav.h"
36 36
 
37
+// clang-format off
38
+
37 39
 enum ADDRS {
38 40
   ADDR_REG_EAX,
39 41
   ADDR_REG_ECX,
... ...
@@ -1176,6 +1178,7 @@ static const struct OPCODES x86ops[2][256] = {{
1176 1176
 
1177 1177
 }};
1178 1178
 
1179
+// clang-format on
1179 1180
 
1180 1181
 static const char *dis_size[] = {"byte", "word", "dword", "fword", "qword", "tword", "acab"};
1181 1182
 
... ...
@@ -50,87 +50,89 @@
50 50
 #define UNZIP_PRIVATE
51 51
 #include "unzip.h"
52 52
 
53
+// clang-format off
53 54
 static const struct ftmap_s {
54 55
     const char *name;
55 56
     cli_file_t code;
56 57
 } ftmap[] = {
57
-    { "CL_TYPE_TEXT_ASCII",	CL_TYPE_TEXT_ASCII	},
58
-    { "CL_TYPE_TEXT_UTF8",	CL_TYPE_TEXT_UTF8	},
59
-    { "CL_TYPE_TEXT_UTF16LE",	CL_TYPE_TEXT_UTF16LE	},
60
-    { "CL_TYPE_TEXT_UTF16BE",	CL_TYPE_TEXT_UTF16BE	},
61
-    { "CL_TYPE_BINARY_DATA",	CL_TYPE_BINARY_DATA	},
62
-    { "CL_TYPE_IGNORED",	CL_TYPE_IGNORED		},
63
-    { "CL_TYPE_ANY",		CL_TYPE_ANY		},
64
-    { "CL_TYPE_MSEXE",		CL_TYPE_MSEXE		},
65
-    { "CL_TYPE_ELF",		CL_TYPE_ELF		},
66
-    { "CL_TYPE_MACHO",		CL_TYPE_MACHO		},
67
-    { "CL_TYPE_MACHO_UNIBIN",	CL_TYPE_MACHO_UNIBIN	},
68
-    { "CL_TYPE_POSIX_TAR",	CL_TYPE_POSIX_TAR	},
69
-    { "CL_TYPE_OLD_TAR",	CL_TYPE_OLD_TAR		},
70
-    { "CL_TYPE_CPIO_OLD",	CL_TYPE_CPIO_OLD	},
71
-    { "CL_TYPE_CPIO_ODC",	CL_TYPE_CPIO_ODC	},
72
-    { "CL_TYPE_CPIO_NEWC",	CL_TYPE_CPIO_NEWC	},
73
-    { "CL_TYPE_CPIO_CRC",	CL_TYPE_CPIO_CRC	},
74
-    { "CL_TYPE_GZ",		CL_TYPE_GZ		},
75
-    { "CL_TYPE_ZIP",		CL_TYPE_ZIP		},
76
-    { "CL_TYPE_BZ",		CL_TYPE_BZ		},
77
-    { "CL_TYPE_RAR",		CL_TYPE_RAR		},
78
-    { "CL_TYPE_ARJ",		CL_TYPE_ARJ		},
79
-    { "CL_TYPE_MSSZDD",		CL_TYPE_MSSZDD		},
80
-    { "CL_TYPE_MSOLE2",		CL_TYPE_MSOLE2		},
81
-    { "CL_TYPE_MSCAB",		CL_TYPE_MSCAB		},
82
-    { "CL_TYPE_MSCHM",		CL_TYPE_MSCHM		},
83
-    { "CL_TYPE_SIS",		CL_TYPE_SIS		},
84
-    { "CL_TYPE_SCRENC",		CL_TYPE_SCRENC		},
85
-    { "CL_TYPE_GRAPHICS",	CL_TYPE_GRAPHICS	},
86
-    { "CL_TYPE_RIFF",		CL_TYPE_RIFF		},
87
-    { "CL_TYPE_BINHEX",		CL_TYPE_BINHEX		},
88
-    { "CL_TYPE_TNEF",		CL_TYPE_TNEF		},
89
-    { "CL_TYPE_CRYPTFF",	CL_TYPE_CRYPTFF		},
90
-    { "CL_TYPE_PDF",		CL_TYPE_PDF		},
91
-    { "CL_TYPE_UUENCODED",	CL_TYPE_UUENCODED	},
92
-    { "CL_TYPE_HTML_UTF16",	CL_TYPE_HTML_UTF16	},
93
-    { "CL_TYPE_SCRIPT",         CL_TYPE_SCRIPT          },
94
-    { "CL_TYPE_RTF",		CL_TYPE_RTF		},
95
-    { "CL_TYPE_HTML",		CL_TYPE_HTML		},
96
-    { "CL_TYPE_MAIL",		CL_TYPE_MAIL		},
97
-    { "CL_TYPE_SFX",		CL_TYPE_SFX		},
98
-    { "CL_TYPE_ZIPSFX",		CL_TYPE_ZIPSFX		},
99
-    { "CL_TYPE_RARSFX",		CL_TYPE_RARSFX		},
100
-    { "CL_TYPE_CABSFX",		CL_TYPE_CABSFX		},
101
-    { "CL_TYPE_ARJSFX",		CL_TYPE_ARJSFX		},
102
-    { "CL_TYPE_NULSFT",		CL_TYPE_NULSFT		},
103
-    { "CL_TYPE_AUTOIT",		CL_TYPE_AUTOIT		},
104
-    { "CL_TYPE_ISHIELD_MSI",	CL_TYPE_ISHIELD_MSI	},
105
-    { "CL_TYPE_7Z",		CL_TYPE_7Z		},
106
-    { "CL_TYPE_7ZSFX",		CL_TYPE_7ZSFX		},
107
-    { "CL_TYPE_SWF",		CL_TYPE_SWF		},
108
-    { "CL_TYPE_ISO9660",	CL_TYPE_ISO9660		},
109
-    { "CL_TYPE_JAVA",		CL_TYPE_JAVA		},
110
-    { "CL_TYPE_DMG",		CL_TYPE_DMG		},
111
-    { "CL_TYPE_MBR",		CL_TYPE_MBR		},
112
-    { "CL_TYPE_GPT",		CL_TYPE_GPT		},
113
-    { "CL_TYPE_APM",		CL_TYPE_APM		},
114
-    { "CL_TYPE_XAR",		CL_TYPE_XAR		},
115
-    { "CL_TYPE_PART_ANY",	CL_TYPE_PART_ANY	},
116
-    { "CL_TYPE_PART_HFSPLUS",	CL_TYPE_PART_HFSPLUS	},
117
-    { "CL_TYPE_XZ",     	CL_TYPE_XZ      	},
118
-    { "CL_TYPE_OOXML_WORD",	CL_TYPE_OOXML_WORD     	},
119
-    { "CL_TYPE_OOXML_PPT",	CL_TYPE_OOXML_PPT     	},
120
-    { "CL_TYPE_OOXML_XL",	CL_TYPE_OOXML_XL     	},
121
-    { "CL_TYPE_INTERNAL",	CL_TYPE_INTERNAL     	},
122
-    { "CL_TYPE_XDP",		CL_TYPE_XDP		},
123
-    { "CL_TYPE_XML_WORD",	CL_TYPE_XML_WORD	},
124
-    { "CL_TYPE_XML_XL",		CL_TYPE_XML_XL		},
125
-    { "CL_TYPE_HWP3",		CL_TYPE_HWP3		},
126
-    { "CL_TYPE_XML_HWP",	CL_TYPE_XML_HWP		},
127
-    { "CL_TYPE_HWPOLE2",	CL_TYPE_HWPOLE2		},
128
-    { "CL_TYPE_OOXML_HWP",	CL_TYPE_OOXML_HWP	},
129
-    { "CL_TYPE_PS",		CL_TYPE_PS		},
130
-    { "CL_TYPE_MHTML",		CL_TYPE_MHTML		},
131
-    { "CL_TYPE_LNK", 		CL_TYPE_LNK		},
132
-    { NULL,			CL_TYPE_IGNORED		}
58
+    { "CL_TYPE_TEXT_ASCII",   CL_TYPE_TEXT_ASCII   },
59
+    { "CL_TYPE_TEXT_UTF8",    CL_TYPE_TEXT_UTF8    },
60
+    { "CL_TYPE_TEXT_UTF16LE", CL_TYPE_TEXT_UTF16LE },
61
+    { "CL_TYPE_TEXT_UTF16BE", CL_TYPE_TEXT_UTF16BE },
62
+    { "CL_TYPE_BINARY_DATA",  CL_TYPE_BINARY_DATA  },
63
+    { "CL_TYPE_IGNORED",      CL_TYPE_IGNORED      },
64
+    { "CL_TYPE_ANY",          CL_TYPE_ANY          },
65
+    { "CL_TYPE_MSEXE",        CL_TYPE_MSEXE        },
66
+    { "CL_TYPE_ELF",          CL_TYPE_ELF          },
67
+    { "CL_TYPE_MACHO",        CL_TYPE_MACHO        },
68
+    { "CL_TYPE_MACHO_UNIBIN", CL_TYPE_MACHO_UNIBIN },
69
+    { "CL_TYPE_POSIX_TAR",    CL_TYPE_POSIX_TAR    },
70
+    { "CL_TYPE_OLD_TAR",      CL_TYPE_OLD_TAR      },
71
+    { "CL_TYPE_CPIO_OLD",     CL_TYPE_CPIO_OLD     },
72
+    { "CL_TYPE_CPIO_ODC",     CL_TYPE_CPIO_ODC     },
73
+    { "CL_TYPE_CPIO_NEWC",    CL_TYPE_CPIO_NEWC    },
74
+    { "CL_TYPE_CPIO_CRC",     CL_TYPE_CPIO_CRC     },
75
+    { "CL_TYPE_GZ",           CL_TYPE_GZ           },
76
+    { "CL_TYPE_ZIP",          CL_TYPE_ZIP          },
77
+    { "CL_TYPE_BZ",           CL_TYPE_BZ           },
78
+    { "CL_TYPE_RAR",          CL_TYPE_RAR          },
79
+    { "CL_TYPE_ARJ",          CL_TYPE_ARJ          },
80
+    { "CL_TYPE_MSSZDD",       CL_TYPE_MSSZDD       },
81
+    { "CL_TYPE_MSOLE2",       CL_TYPE_MSOLE2       },
82
+    { "CL_TYPE_MSCAB",        CL_TYPE_MSCAB        },
83
+    { "CL_TYPE_MSCHM",        CL_TYPE_MSCHM        },
84
+    { "CL_TYPE_SIS",          CL_TYPE_SIS          },
85
+    { "CL_TYPE_SCRENC",       CL_TYPE_SCRENC       },
86
+    { "CL_TYPE_GRAPHICS",     CL_TYPE_GRAPHICS     },
87
+    { "CL_TYPE_RIFF",         CL_TYPE_RIFF         },
88
+    { "CL_TYPE_BINHEX",       CL_TYPE_BINHEX       },
89
+    { "CL_TYPE_TNEF",         CL_TYPE_TNEF         },
90
+    { "CL_TYPE_CRYPTFF",      CL_TYPE_CRYPTFF      },
91
+    { "CL_TYPE_PDF",          CL_TYPE_PDF          },
92
+    { "CL_TYPE_UUENCODED",    CL_TYPE_UUENCODED    },
93
+    { "CL_TYPE_HTML_UTF16",   CL_TYPE_HTML_UTF16   },
94
+    { "CL_TYPE_SCRIPT",       CL_TYPE_SCRIPT       },
95
+    { "CL_TYPE_RTF",          CL_TYPE_RTF          },
96
+    { "CL_TYPE_HTML",         CL_TYPE_HTML         },
97
+    { "CL_TYPE_MAIL",         CL_TYPE_MAIL         },
98
+    { "CL_TYPE_SFX",          CL_TYPE_SFX          },
99
+    { "CL_TYPE_ZIPSFX",       CL_TYPE_ZIPSFX       },
100
+    { "CL_TYPE_RARSFX",       CL_TYPE_RARSFX       },
101
+    { "CL_TYPE_CABSFX",       CL_TYPE_CABSFX       },
102
+    { "CL_TYPE_ARJSFX",       CL_TYPE_ARJSFX       },
103
+    { "CL_TYPE_NULSFT",       CL_TYPE_NULSFT       },
104
+    { "CL_TYPE_AUTOIT",       CL_TYPE_AUTOIT       },
105
+    { "CL_TYPE_ISHIELD_MSI",  CL_TYPE_ISHIELD_MSI  },
106
+    { "CL_TYPE_7Z",           CL_TYPE_7Z           },
107
+    { "CL_TYPE_7ZSFX",        CL_TYPE_7ZSFX        },
108
+    { "CL_TYPE_SWF",          CL_TYPE_SWF          },
109
+    { "CL_TYPE_ISO9660",      CL_TYPE_ISO9660      },
110
+    { "CL_TYPE_JAVA",         CL_TYPE_JAVA         },
111
+    { "CL_TYPE_DMG",          CL_TYPE_DMG          },
112
+    { "CL_TYPE_MBR",          CL_TYPE_MBR          },
113
+    { "CL_TYPE_GPT",          CL_TYPE_GPT          },
114
+    { "CL_TYPE_APM",          CL_TYPE_APM          },
115
+    { "CL_TYPE_XAR",          CL_TYPE_XAR          },
116
+    { "CL_TYPE_PART_ANY",     CL_TYPE_PART_ANY     },
117
+    { "CL_TYPE_PART_HFSPLUS", CL_TYPE_PART_HFSPLUS },
118
+    { "CL_TYPE_XZ",           CL_TYPE_XZ           },
119
+    { "CL_TYPE_OOXML_WORD",   CL_TYPE_OOXML_WORD   },
120
+    { "CL_TYPE_OOXML_PPT",    CL_TYPE_OOXML_PPT    },
121
+    { "CL_TYPE_OOXML_XL",     CL_TYPE_OOXML_XL     },
122
+    { "CL_TYPE_INTERNAL",     CL_TYPE_INTERNAL     },
123
+    { "CL_TYPE_XDP",          CL_TYPE_XDP          },
124
+    { "CL_TYPE_XML_WORD",     CL_TYPE_XML_WORD     },
125
+    { "CL_TYPE_XML_XL",       CL_TYPE_XML_XL       },
126
+    { "CL_TYPE_HWP3",         CL_TYPE_HWP3         },
127
+    { "CL_TYPE_XML_HWP",      CL_TYPE_XML_HWP      },
128
+    { "CL_TYPE_HWPOLE2",      CL_TYPE_HWPOLE2      },
129
+    { "CL_TYPE_OOXML_HWP",    CL_TYPE_OOXML_HWP    },
130
+    { "CL_TYPE_PS",           CL_TYPE_PS           },
131
+    { "CL_TYPE_MHTML",        CL_TYPE_MHTML        },
132
+    { "CL_TYPE_LNK",          CL_TYPE_LNK          },
133
+    { NULL,                   CL_TYPE_IGNORED      }
133 134
 };
135
+// clang-format on
134 136
 
135 137
 cli_file_t cli_partitiontype(const unsigned char *buf, size_t buflen, const struct cl_engine *engine);
136 138
 
... ...
@@ -217,6 +219,7 @@ cli_file_t cli_filetype(const unsigned char *buf, size_t buflen, const struct cl
217 217
 int is_tar(const unsigned char *buf, unsigned int nbytes);
218 218
 
219 219
 /* organize by length, cannot exceed SIZEOF_LH */
220
+// clang-format off
220 221
 const struct ooxml_ftcodes {
221 222
     const char *entry;
222 223
     size_t len;
... ...
@@ -240,6 +243,8 @@ const struct ooxml_ftcodes {
240 240
     { "META-INF/container.xml", 22, CL_TYPE_ZIP         }, /* HWP */
241 241
     { NULL,                      0, CL_TYPE_ANY         }
242 242
 };
243
+// clang-format on
244
+
243 245
 /* set to biggest ooxml_detect len */
244 246
 #define OOXML_DETECT_MAXLEN 22
245 247
 
... ...
@@ -401,7 +401,7 @@ static int gpt_validate_header(cli_ctx *ctx, struct gpt_header hdr, size_t secto
401 401
     hdr.tableStartLBA = le64_to_host(hdr.tableStartLBA);
402 402
     hdr.tableNumEntries = le32_to_host(hdr.tableNumEntries);
403 403
     hdr.tableEntrySize = le32_to_host(hdr.tableEntrySize);
404
-    hdr.tableCRC32 = le32_to_host(hdr.tableCRC32);;
404
+    hdr.tableCRC32 = le32_to_host(hdr.tableCRC32);
405 405
 
406 406
     ptable_start = hdr.tableStartLBA * sectorsize;
407 407
     ptable_len = hdr.tableNumEntries * hdr.tableEntrySize;
... ...
@@ -100,6 +100,7 @@ struct tag_contents {
100 100
 	unsigned char contents[MAX_TAG_CONTENTS_LENGTH + 1];
101 101
 };
102 102
 
103
+// clang-format off
103 104
 static const int base64_chars[256] = {
104 105
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
105 106
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
... ...
@@ -118,6 +119,7 @@ static const int base64_chars[256] = {
118 118
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
119 119
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
120 120
 };
121
+// clang-format on
121 122
 
122 123
 int table_order[] = {
123 124
        00, 02, 01, 00, 02, 01, 02, 01, 01, 02, 01, 02, 00, 01, 02, 01,
... ...
@@ -1065,7 +1065,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1065 1065
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: box cell paragraph list starts @ %llu\n", level, p, (long long unsigned)offset);
1066 1066
                     for (i = 0; i < ncells; i++) {
1067 1067
                         l = 0;
1068
-                        while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS));
1068
+                        while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS)) continue;
1069 1069
                         if (ret != CL_SUCCESS)
1070 1070
                             return ret;
1071 1071
                     }
... ...
@@ -1073,7 +1073,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1073 1073
                     /* box caption paragraph list */
1074 1074
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: box cell caption paragraph list starts @ %llu\n", level, p, (long long unsigned)offset);
1075 1075
                     l = 0;
1076
-                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS));
1076
+                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS)) continue;
1077 1077
                     if (ret != CL_SUCCESS)
1078 1078
                         return ret;
1079 1079
                     break;
... ...
@@ -1110,7 +1110,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1110 1110
                     /* caption paragraph list */
1111 1111
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: drawing caption paragraph list starts @ %llu\n", level, p, (long long unsigned)offset);
1112 1112
                     l = 0;
1113
-                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS));
1113
+                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS)) continue;
1114 1114
                     if (ret != CL_SUCCESS)
1115 1115
                         return ret;
1116 1116
                     break;
... ...
@@ -1155,7 +1155,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1155 1155
                     /* hidden description paragraph list */
1156 1156
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: hidden description paragraph list starts @ %llu\n", level, p, (long long unsigned)offset);
1157 1157
                     l = 0;
1158
-                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS));
1158
+                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS)) continue;
1159 1159
                     if (ret != CL_SUCCESS)
1160 1160
                         return ret;
1161 1161
                     break;
... ...
@@ -1197,7 +1197,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1197 1197
                     /* content paragraph list */
1198 1198
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: header/footer paragraph list starts @ %llu\n", level, p, (long long unsigned)offset);
1199 1199
                     l = 0;
1200
-                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS));
1200
+                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS)) continue;
1201 1201
                     if (ret != CL_SUCCESS)
1202 1202
                         return ret;
1203 1203
                     break;
... ...
@@ -1225,7 +1225,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1225 1225
                     /* content paragraph list */
1226 1226
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: footnote/endnote paragraph list starts @ %llu\n", level, p, (long long unsigned)offset);
1227 1227
                     l = 0;
1228
-                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS));
1228
+                    while (!l && ((ret = parsehwp3_paragraph(ctx, map, sp++, level+1, &offset, &l)) == CL_SUCCESS)) continue;
1229 1229
                     if (ret != CL_SUCCESS)
1230 1230
                         return ret;
1231 1231
                     break;
... ...
@@ -1840,7 +1840,7 @@ static int hwp3_cb(void *cbdata, int fd, const char* filepath, cli_ctx *ctx)
1840 1840
     last = 0;
1841 1841
     /* Paragraphs - variable */
1842 1842
     /* Paragraphs - are terminated with 0x0d00[13(CR) as hchar], empty paragraph marks end of section and do NOT end with 0x0d00 */
1843
-    while (!last && ((ret = parsehwp3_paragraph(ctx, map, p++, 0, &offset, &last)) == CL_SUCCESS));
1843
+    while (!last && ((ret = parsehwp3_paragraph(ctx, map, p++, 0, &offset, &last)) == CL_SUCCESS)) continue;
1844 1844
     /* return is never a virus */
1845 1845
     if (ret != CL_SUCCESS) {
1846 1846
         if (dmap)
... ...
@@ -1854,7 +1854,7 @@ static int hwp3_cb(void *cbdata, int fd, const char* filepath, cli_ctx *ctx)
1854 1854
 
1855 1855
     last = 0;
1856 1856
     /* 'additional information block #1's - attachments and media */
1857
-    while (!last && ((ret = parsehwp3_infoblk_1(ctx, map, &offset, &last)) == CL_SUCCESS));
1857
+    while (!last && ((ret = parsehwp3_infoblk_1(ctx, map, &offset, &last)) == CL_SUCCESS)) continue;
1858 1858
 
1859 1859
     /* scan the uncompressed stream - both compressed and uncompressed cases [ALLMATCH] */
1860 1860
     if ((ret == CL_SUCCESS) || ((SCAN_ALLMATCHES) && (ret == CL_VIRUS))) {
... ...
@@ -24,6 +24,7 @@
24 24
 
25 25
 #include "others.h"
26 26
 
27
+// clang-format off
27 28
 #define HWP5_COMPRESSED     0x1
28 29
 #define HWP5_PASSWORD       0x2
29 30
 #define HWP5_DISTRIBUTABLE  0x4
... ...
@@ -36,6 +37,7 @@
36 36
 #define HWP5_CERT_EXTRA     0x200
37 37
 #define HWP5_CERT_DRM       0x400
38 38
 #define HWP5_CCL            0x800
39
+// clang-format on
39 40
 
40 41
 typedef struct hwp5_header {
41 42
     uint8_t signature[32];
... ...
@@ -47,6 +47,8 @@
47 47
 
48 48
 #include "mpool.h"
49 49
 
50
+// clang-format off
51
+
50 52
 #define AC_SPECIAL_ALT_CHAR             1
51 53
 #define AC_SPECIAL_ALT_STR_FIXED        2
52 54
 #define AC_SPECIAL_ALT_STR              3
... ...
@@ -86,6 +88,8 @@ static char boundary[256] = {
86 86
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
87 87
 };
88 88
 
89
+// clang-format on
90
+
89 91
 static inline int insert_list(struct cli_matcher *root, struct cli_ac_patt *pattern, struct cli_ac_node *pt)
90 92
 {
91 93
     struct cli_ac_list *ph, *new, *ph_prev, *ph_add_after;
... ...
@@ -45,26 +45,29 @@ struct cli_target_info {
45 45
 #include "fmap.h"
46 46
 #include "mpool.h"
47 47
 
48
-#define CLI_MATCH_METADATA	0xff00
49
-#define CLI_MATCH_WILDCARD	0x0f00
50
-#define CLI_MATCH_CHAR		0x0000
51
-#define CLI_MATCH_NOCASE	0x1000
52
-#define CLI_MATCH_IGNORE	0x0100
53
-#define CLI_MATCH_SPECIAL	0x0200
54
-#define CLI_MATCH_NIBBLE_HIGH	0x0300
55
-#define CLI_MATCH_NIBBLE_LOW	0x0400
48
+// clang-format off
49
+
50
+#define CLI_MATCH_METADATA    0xff00
51
+#define CLI_MATCH_WILDCARD    0x0f00
52
+#define CLI_MATCH_CHAR        0x0000
53
+#define CLI_MATCH_NOCASE      0x1000
54
+#define CLI_MATCH_IGNORE      0x0100
55
+#define CLI_MATCH_SPECIAL     0x0200
56
+#define CLI_MATCH_NIBBLE_HIGH 0x0300
57
+#define CLI_MATCH_NIBBLE_LOW  0x0400
58
+
59
+#define CLI_TDB_UINT        0
60
+#define CLI_TDB_RANGE       1
61
+#define CLI_TDB_STR         2
62
+#define CLI_TDB_RANGE2      3
63
+#define CLI_TDB_FTYPE       4
64
+#define CLI_TDB_FTYPE_EXPR  5
56 65
 
57 66
 struct cli_lsig_tdb {
58
-#define CLI_TDB_UINT		0
59
-#define CLI_TDB_RANGE		1
60
-#define CLI_TDB_STR		2
61
-#define CLI_TDB_RANGE2		3
62
-#define CLI_TDB_FTYPE		4
63
-#define CLI_TDB_FTYPE_EXPR	5
64
-    uint32_t *val, *range;
65
-    char *str;
66
-    uint32_t cnt[3];
67
-    uint32_t subsigs;
67
+    uint32_t       *val, *range;
68
+    char           *str;
69
+    uint32_t       cnt[3];
70
+    uint32_t       subsigs;
68 71
 
69 72
     const uint32_t *target;
70 73
     const uint32_t *engine, *nos, *ep, *filesize;
... ...
@@ -72,15 +75,17 @@ struct cli_lsig_tdb {
72 72
     const uint32_t *intermediates;
73 73
     /*
74 74
     const uint32_t *sectoff, *sectrva, *sectvsz, *sectraw, *sectrsz,
75
-		   *secturva, *sectuvsz, *secturaw, *sectursz;
75
+                   *secturva, *sectuvsz, *secturaw, *sectursz;
76 76
     */
77
-    const char *icongrp1, *icongrp2;
78
-    uint32_t *macro_ptids;
77
+    const char     *icongrp1, *icongrp2;
78
+    uint32_t       *macro_ptids;
79 79
 #ifdef USE_MPOOL
80
-    mpool_t *mempool;
80
+    mpool_t        *mempool;
81 81
 #endif
82 82
 };
83 83
 
84
+// clang-format on
85
+
84 86
 #define CLI_LSIG_FLAG_PRIVATE 0x01
85 87
 
86 88
 struct cli_bc;
... ...
@@ -174,6 +179,8 @@ struct cli_mtarget {
174 174
     uint8_t target_count; /* must be synced with non-zero values in the target array */
175 175
 };
176 176
 
177
+// clang-format off
178
+
177 179
 #define CLI_MTARGETS 15
178 180
 static const struct cli_mtarget cli_mtargets[CLI_MTARGETS] =  {
179 181
     { {0, 0},                                   "GENERIC",      0,  0, 1, 1 },
... ...
@@ -194,7 +201,7 @@ static const struct cli_mtarget cli_mtargets[CLI_MTARGETS] =  {
194 194
 };
195 195
 
196 196
 #define CLI_OFF_ANY         0xffffffff
197
-#define CLI_OFF_NONE	    0xfffffffe
197
+#define CLI_OFF_NONE        0xfffffffe
198 198
 #define CLI_OFF_ABSOLUTE    1
199 199
 #define CLI_OFF_EOF_MINUS   2
200 200
 #define CLI_OFF_EP_PLUS     3
... ...
@@ -203,7 +210,9 @@ static const struct cli_mtarget cli_mtargets[CLI_MTARGETS] =  {
203 203
 #define CLI_OFF_SX_PLUS     6
204 204
 #define CLI_OFF_VERSION     7
205 205
 #define CLI_OFF_MACRO       8
206
-#define CLI_OFF_SE	    9
206
+#define CLI_OFF_SE          9
207
+
208
+// clang-format on
207 209
 
208 210
 int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata);
209 211
 
... ...
@@ -168,12 +168,12 @@ typedef	enum {
168 168
  * more than one machine you must make sure that .../partial is on a shared
169 169
  * network filesystem
170 170
  */
171
-/*#define	NEW_WORLD*/
172 171
 
173
-/*#define	SCAN_UNENCODED_BOUNCES	*//*
174
-					 * Slows things down a lot and only catches unencoded copies
175
-					 * of EICAR within bounces, which don't matter
176
-					 */
172
+/*
173
+ * Slows things down a lot and only catches unencoded copies
174
+ * of EICAR within bounces, which don't matter
175
+ */
176
+//#define	SCAN_UNENCODED_BOUNCES
177 177
 
178 178
 typedef	struct	mbox_ctx {
179 179
 	const	char	*dir;
... ...
@@ -2386,8 +2386,7 @@ rfc2231(const char *in)
2386 2386
 
2387 2387
 	*out++ = '=';
2388 2388
 
2389
-	while(*ptr++ != '=')
2390
-		;
2389
+	while (*ptr++ != '=') continue;
2391 2390
 
2392 2391
 	/*
2393 2392
 	 * We don't do anything with the language and character set, just skip
... ...
@@ -58,7 +58,7 @@ ole2_convert_utf(summary_ctx_t *sctx, char *begin, size_t sz, const char *encodi
58 58
     char *buf, *p1, *p2;
59 59
     off_t offset;
60 60
     size_t inlen, outlen, nonrev, sz2;
61
-    int i, try;
61
+    int i, attempt;
62 62
     iconv_t cd;
63 63
 #endif
64 64
     /* applies in the both case */
... ...
@@ -131,9 +131,9 @@ ole2_convert_utf(summary_ctx_t *sctx, char *begin, size_t sz, const char *encodi
131 131
     }
132 132
     else {
133 133
         offset = 0;
134
-        for (try = 1; try <= 3; ++try) {
134
+        for (attempt = 1; attempt <= 3; ++attempt) {
135 135
             /* charset to UTF-8 should never exceed sz*6 */
136
-            sz2 = (try*2) * sz;
136
+            sz2 = (attempt*2) * sz;
137 137
             /* use cli_realloc, reuse the buffer that has already been translated */
138 138
             outbuf = (char *)cli_realloc(outbuf, sz2+1);
139 139
             if (!outbuf) {
... ...
@@ -166,9 +166,9 @@ ole2_convert_utf(summary_ctx_t *sctx, char *begin, size_t sz, const char *encodi
166 166
             //cli_dbgmsg("%u %s\n", inlen, outbuf);
167 167
 
168 168
             offset = sz2 - outlen;
169
-            if (try < 3)
169
+            if (attempt < 3)
170 170
                 cli_dbgmsg("ole2_convert_utf: outbuf is too small, resizing %llu -> %llu\n",
171
-                           (long long unsigned)((try*2) * sz), (long long unsigned)(((try+1)*2) * sz));
171
+                           (long long unsigned)((attempt*2) * sz), (long long unsigned)(((attempt+1)*2) * sz));
172 172
         }
173 173
 
174 174
         if (errno == E2BIG && nonrev == (size_t)-1) {
... ...
@@ -955,7 +955,7 @@ int cli_ole2_summary_json(cli_ctx *ctx, int fd, int mode)
955 955
     if (sumstub.byte_order != 0xfffe) {
956 956
         cli_dbgmsg("ole2_summary_json: byteorder 0x%x is invalid\n", sumstub.byte_order);
957 957
         sctx.flags |= OLE2_SUMMARY_ERROR_INVALID_ENTRY;
958
-        return cli_ole2_summary_json_cleanup(&sctx, CL_EFORMAT);;
958
+        return cli_ole2_summary_json_cleanup(&sctx, CL_EFORMAT);
959 959
     }
960 960
     sumstub.version = sum16_endian_convert(sumstub.version); /*unused*/
961 961
     sumstub.system = sum32_endian_convert(sumstub.system); /*unused*/
... ...
@@ -47,33 +47,34 @@
47 47
 
48 48
 #define MSXML_READBUFF SCANBUFF
49 49
 
50
+// clang-format off
51
+
50 52
 static const struct key_entry msxml_keys[] = {
51
-    { "worddocument",       "WordDocument",       MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
52
-    { "workbook",           "Workbook",           MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
53
-
54
-    { "bindata",            "BinaryData",         MSXML_SCAN_B64 | MSXML_JSON_COUNT | MSXML_JSON_ROOT },
55
-    { "documentproperties", "DocumentProperties", MSXML_JSON_ROOT },
56
-    { "author",             "Author",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
57
-    { "lastauthor",         "LastAuthor",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
58
-    { "revision",           "Revision",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
59
-    { "totaltime",          "TotalTime",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
60
-    { "created",            "Created",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
61
-    { "lastsaved",          "LastSaved",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
62
-    { "pages",              "Pages",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
63
-    { "words",              "Words",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
64
-    { "characters",         "Characters",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
65
-    { "lines",              "Lines",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
66
-    { "paragraph",          "Paragraph",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
67
-    { "characterswithspaces", "CharactersWithSpaces", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
68
-    { "version",            "Version",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
69
-
70
-    { "allowpng",           "AllowPNG",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
71
-
72
-    { "fonts",              "Fonts",              MSXML_IGNORE_ELEM },
73
-    { "styles",             "Styles",             MSXML_IGNORE_ELEM }
53
+    { "worddocument",         "WordDocument",           MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
54
+    { "workbook",             "Workbook",               MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
55
+    { "bindata",              "BinaryData",             MSXML_SCAN_B64 | MSXML_JSON_COUNT | MSXML_JSON_ROOT },
56
+    { "documentproperties",   "DocumentProperties",     MSXML_JSON_ROOT },
57
+    { "author",               "Author",                 MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
58
+    { "lastauthor",           "LastAuthor",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
59
+    { "revision",             "Revision",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
60
+    { "totaltime",            "TotalTime",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
61
+    { "created",              "Created",                MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
62
+    { "lastsaved",            "LastSaved",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
63
+    { "pages",                "Pages",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
64
+    { "words",                "Words",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
65
+    { "characters",           "Characters",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
66
+    { "lines",                "Lines",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
67
+    { "paragraph",            "Paragraph",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
68
+    { "characterswithspaces", "CharactersWithSpaces",   MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
69
+    { "version",              "Version",                MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
70
+    { "allowpng",             "AllowPNG",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
71
+    { "fonts",                "Fonts",                  MSXML_IGNORE_ELEM },
72
+    { "styles",               "Styles",                 MSXML_IGNORE_ELEM }
74 73
 };
75 74
 static size_t num_msxml_keys = sizeof(msxml_keys) / sizeof(struct key_entry);
76 75
 
76
+// clang-format on
77
+
77 78
 static inline size_t msxml_read_cb_new_window(struct msxml_cbdata *cbdata)
78 79
 {
79 80
     const unsigned char *new_window = NULL;
... ...
@@ -43,57 +43,72 @@
43 43
 
44 44
 #if HAVE_LIBXML2 && HAVE_JSON
45 45
 
46
+// clang-format off
47
+
46 48
 /*** OOXML MSDOC ***/
47 49
 static const struct key_entry ooxml_keys[] = {
48
-    { "coreproperties",     "CoreProperties",     MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
49
-    { "title",              "Title",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
50
-    { "subject",            "Subject",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
51
-    { "creator",            "Author",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
52
-    { "keywords",           "Keywords",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
53
-    { "comments",           "Comments",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
54
-    { "description",        "Description",        MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
55
-    { "lastmodifiedby",     "LastAuthor",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
56
-    { "revision",           "Revision",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
57
-    { "created",            "Created",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
58
-    { "modified",           "Modified",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
59
-    { "category",           "Category",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
60
-    { "contentstatus",      "ContentStatus",      MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
61
-
62
-    { "properties",         "ExtendedProperties", MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
63
-    { "application",        "Application",        MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
64
-    { "appversion",         "AppVersion",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
65
-    { "characters",         "Characters",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
50
+    { "coreproperties",     "CoreProperties",         MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
51
+    { "title",              "Title",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
52
+    { "subject",            "Subject",                MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
53
+    { "creator",            "Author",                 MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
54
+    { "keywords",           "Keywords",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
55
+    { "comments",           "Comments",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
56
+    { "description",        "Description",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
57
+    { "lastmodifiedby",     "LastAuthor",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
58
+    { "revision",           "Revision",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
59
+    { "created",            "Created",                MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
60
+    { "modified",           "Modified",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
61
+    { "category",           "Category",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
62
+    { "contentstatus",      "ContentStatus",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
63
+    { "properties",         "ExtendedProperties",     MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
64
+    { "application",        "Application",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
65
+    { "appversion",         "AppVersion",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
66
+    { "characters",         "Characters",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
66 67
     { "characterswithspaces", "CharactersWithSpaces", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
67
-    { "company",            "Company",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
68
-    { "digsig",             "DigSig",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
69
-    { "docsecurity",        "DocSecurity",        MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
70
-    //{ "headingpairs",       "HeadingPairs",       MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
71
-    { "hiddenslides",       "HiddenSlides",       MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
72
-    { "hlinks",             "HLinks",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
73
-    { "hyperlinkbase",      "HyperlinkBase",      MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
74
-    { "hyperlinkschanged",  "HyperlinksChanged",  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
75
-    { "lines",              "Lines",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
76
-    { "linksuptodate",      "LinksUpToDate",      MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
77
-    { "manager",            "Manager",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
78
-    { "mmclips",            "MultimediaClips",    MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
79
-    { "notes",              "Notes",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
80
-    { "pages",              "Pages",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
81
-    { "paragraphs",         "Paragraphs",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
82
-    { "presentationformat", "PresentationFormat", MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
83
-    //{ "properties",         "Properties",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
84
-    { "scalecrop",          "ScaleCrop",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
85
-    { "shareddoc",          "SharedDocs",         MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
86
-    { "slides",             "Slides",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
87
-    { "template",           "Template",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
88
-    //{ "titleofparts",       "TitleOfParts",       MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
89
-    { "totaltime",          "TotalTime",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
90
-    { "words",              "Words",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
68
+    { "company",            "Company",                MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
69
+    { "digsig",             "DigSig",                 MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
70
+    { "docsecurity",        "DocSecurity",            MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
71
+    //{ "headingpairs",       "HeadingPairs",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
72
+    { "hiddenslides",       "HiddenSlides",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
73
+    { "hlinks",             "HLinks",                 MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
74
+    { "hyperlinkbase",      "HyperlinkBase",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
75
+    { "hyperlinkschanged",  "HyperlinksChanged",      MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
76
+    { "lines",              "Lines",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
77
+    { "linksuptodate",      "LinksUpToDate",          MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
78
+    { "manager",            "Manager",                MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
79
+    { "mmclips",            "MultimediaClips",        MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
80
+    { "notes",              "Notes",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
81
+    { "pages",              "Pages",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
82
+    { "paragraphs",         "Paragraphs",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
83
+    { "presentationformat", "PresentationFormat",     MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
84
+    //{ "properties",         "Properties",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
85
+    { "scalecrop",          "ScaleCrop",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
86
+    { "shareddoc",          "SharedDocs",             MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
87
+    { "slides",             "Slides",                 MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
88
+    { "template",           "Template",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
89
+    //{ "titleofparts",       "TitleOfParts",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
90
+    { "totaltime",          "TotalTime",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
91
+    { "words",              "Words",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
91 92
 
92 93
     /* Should NOT Exist */
93
-    { "bindata",            "BinaryData",         MSXML_SCAN_B64 | MSXML_JSON_COUNT | MSXML_JSON_ROOT }
94
+    { "bindata",            "BinaryData",             MSXML_SCAN_B64 | MSXML_JSON_COUNT | MSXML_JSON_ROOT }
94 95
 };
95 96
 static size_t num_ooxml_keys = sizeof(ooxml_keys) / sizeof(struct key_entry);
96 97
 
98
+/*** OOXML HWP ***/
99
+static const struct key_entry ooxml_hwp_keys[] = {
100
+    { "hcfversion",         "HCFVersion",             MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
101
+    { "package",            "Properties",             MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
102
+    { "metadata",           "Metadata",               MSXML_JSON_WRKPTR | MSXML_JSON_ATTRIB },
103
+    { "title",              "Title",                  MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
104
+    { "language",           "Language",               MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
105
+    { "meta",               "MetaFields",             MSXML_JSON_WRKPTR | MSXML_JSON_ATTRIB | MSXML_JSON_VALUE | MSXML_JSON_COUNT | MSXML_JSON_MULTI },
106
+    { "item",               "Contents",               MSXML_JSON_WRKPTR | MSXML_JSON_ATTRIB | MSXML_JSON_COUNT | MSXML_JSON_MULTI }
107
+};
108
+static size_t num_ooxml_hwp_keys = sizeof(ooxml_hwp_keys) / sizeof(struct key_entry);
109
+
110
+// clang-format on
111
+
97 112
 static int ooxml_updatelimits(int fd, cli_ctx *ctx)
98 113
 {
99 114
     STATBUF sb;
... ...
@@ -339,19 +354,6 @@ static int ooxml_content_cb(int fd, const char* filepath, cli_ctx *ctx)
339 339
     return ret;
340 340
 }
341 341
 
342
-/*** OOXML HWP ***/
343
-static const struct key_entry ooxml_hwp_keys[] = {
344
-    { "hcfversion",         "HCFVersion",         MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
345
-
346
-    { "package",            "Properties",         MSXML_JSON_ROOT | MSXML_JSON_ATTRIB },
347
-    { "metadata",           "Metadata",           MSXML_JSON_WRKPTR | MSXML_JSON_ATTRIB },
348
-    { "title",              "Title",              MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
349
-    { "language",           "Language",           MSXML_JSON_WRKPTR | MSXML_JSON_VALUE },
350
-    { "meta",               "MetaFields",         MSXML_JSON_WRKPTR | MSXML_JSON_ATTRIB | MSXML_JSON_VALUE | MSXML_JSON_COUNT | MSXML_JSON_MULTI },
351
-    { "item",               "Contents",           MSXML_JSON_WRKPTR | MSXML_JSON_ATTRIB | MSXML_JSON_COUNT | MSXML_JSON_MULTI }
352
-};
353
-static size_t num_ooxml_hwp_keys = sizeof(ooxml_hwp_keys) / sizeof(struct key_entry);
354
-
355 342
 static int ooxml_hwp_cb(int fd, const char* filepath, cli_ctx *ctx)
356 343
 {
357 344
     int ret = CL_SUCCESS;
... ...
@@ -71,8 +71,7 @@
71 71
 struct pdf_token {
72 72
     uint32_t flags;    /* tracking flags */
73 73
     uint32_t success;  /* successfully decoded filters */
74
-
75
-    uint32_t length;   /* length of current content */ /* TODO: transition to size_t */
74
+    uint32_t length;   /* length of current content; TODO: transition to size_t */
76 75
     uint8_t *content;  /* content stream */
77 76
 };
78 77
 
... ...
@@ -250,6 +250,7 @@ static const int gaussk[]={1,2,1};
250 250
 static const int gkernsz = (sizeof(gaussk) / sizeof(gaussk[0]));
251 251
 
252 252
 #ifndef USE_FLOATS
253
+// clang-format off
253 254
     static const uint32_t rtable[256][3] = {
254 255
         {0x00000000,0x00000000,0x00000000}, {0x00033475,0x0001a70c,0x00002675},
255 256
         {0x000668e9,0x00034e18,0x00004ceb}, {0x00099d5e,0x0004f525,0x00007360},
... ...
@@ -642,6 +643,7 @@ static const int gkernsz = (sizeof(gaussk) / sizeof(gaussk[0]));
642 642
         {0x119089da,0x07069d8a,0x5c81c488}, {0x11b93635,0x0716e27b,0x5d57faec},
643 643
         {0x11e2194b,0x07273d51,0x5e2f5196}, {0x120b3333,0x0737ae14,0x5f07c8f3},
644 644
     };
645
+// clang-format on
645 646
 #endif
646 647
 
647 648
 #ifdef USE_FLOATS
... ...
@@ -1381,35 +1381,38 @@ struct lsig_attrib {
1381 1381
 /* TODO: rework this */
1382 1382
 static int lsigattribs(char *attribs, struct cli_lsig_tdb *tdb)
1383 1383
 {
1384
-    struct lsig_attrib attrtab[] = {
1384
+// clang-format off
1385 1385
 #define ATTRIB_TOKENS   10
1386 1386
 #define EXPR_TOKEN_MAX  16
1387
-        { "Target",         CLI_TDB_UINT,   (void **) &tdb->target      },
1388
-        { "Engine",         CLI_TDB_RANGE,  (void **) &tdb->engine      },
1387
+    struct lsig_attrib attrtab[] = {
1388
+        { "Target",             CLI_TDB_UINT,       (void **) &tdb->target          },
1389
+        { "Engine",             CLI_TDB_RANGE,      (void **) &tdb->engine          },
1389 1390
 
1390
-        { "FileSize",       CLI_TDB_RANGE,  (void **) &tdb->filesize    },
1391
-        { "EntryPoint",     CLI_TDB_RANGE,  (void **) &tdb->ep      },
1392
-        { "NumberOfSections",   CLI_TDB_RANGE,  (void **) &tdb->nos     },
1391
+        { "FileSize",           CLI_TDB_RANGE,      (void **) &tdb->filesize        },
1392
+        { "EntryPoint",         CLI_TDB_RANGE,      (void **) &tdb->ep              },
1393
+        { "NumberOfSections",   CLI_TDB_RANGE,      (void **) &tdb->nos             },
1393 1394
 
1394
-        { "IconGroup1",     CLI_TDB_STR,    (void **) &tdb->icongrp1    },
1395
-        { "IconGroup2",     CLI_TDB_STR,    (void **) &tdb->icongrp2    },
1395
+        { "IconGroup1",         CLI_TDB_STR,        (void **) &tdb->icongrp1        },
1396
+        { "IconGroup2",         CLI_TDB_STR,        (void **) &tdb->icongrp2        },
1396 1397
 
1397
-        { "Container",      CLI_TDB_FTYPE,  (void **) &tdb->container   },
1398
-        { "HandlerType",        CLI_TDB_FTYPE,  (void **) &tdb->handlertype },
1399
-        { "Intermediates",  CLI_TDB_FTYPE_EXPR, (void **) &tdb->intermediates },
1398
+        { "Container",          CLI_TDB_FTYPE,      (void **) &tdb->container       },
1399
+        { "HandlerType",        CLI_TDB_FTYPE,      (void **) &tdb->handlertype     },
1400
+        { "Intermediates",      CLI_TDB_FTYPE_EXPR, (void **) &tdb->intermediates   },
1400 1401
 /*
1401
-        { "SectOff",    CLI_TDB_RANGE2, (void **) &tdb->sectoff     },
1402
-        { "SectRVA",    CLI_TDB_RANGE2, (void **) &tdb->sectrva     },
1403
-        { "SectVSZ",    CLI_TDB_RANGE2, (void **) &tdb->sectvsz     },
1404
-        { "SectRAW",    CLI_TDB_RANGE2, (void **) &tdb->sectraw     },
1405
-        { "SectRSZ",    CLI_TDB_RANGE2, (void **) &tdb->sectrsz     },
1406
-        { "SectURVA",   CLI_TDB_RANGE2, (void **) &tdb->secturva    },
1407
-        { "SectUVSZ",   CLI_TDB_RANGE2, (void **) &tdb->sectuvsz    },
1408
-        { "SectURAW",   CLI_TDB_RANGE2, (void **) &tdb->secturaw    },
1409
-        { "SectURSZ",   CLI_TDB_RANGE2, (void **) &tdb->sectursz    },
1402
+        { "SectOff",            CLI_TDB_RANGE2,     (void **) &tdb->sectoff         },
1403
+        { "SectRVA",            CLI_TDB_RANGE2,     (void **) &tdb->sectrva         },
1404
+        { "SectVSZ",            CLI_TDB_RANGE2,     (void **) &tdb->sectvsz         },
1405
+        { "SectRAW",            CLI_TDB_RANGE2,     (void **) &tdb->sectraw         },
1406
+        { "SectRSZ",            CLI_TDB_RANGE2,     (void **) &tdb->sectrsz         },
1407
+        { "SectURVA",           CLI_TDB_RANGE2,     (void **) &tdb->secturva        },
1408
+        { "SectUVSZ",           CLI_TDB_RANGE2,     (void **) &tdb->sectuvsz        },
1409
+        { "SectURAW",           CLI_TDB_RANGE2,     (void **) &tdb->secturaw        },
1410
+        { "SectURSZ",           CLI_TDB_RANGE2,     (void **) &tdb->sectursz        },
1410 1411
 */
1411
-        { NULL,     0,          NULL,               }
1412
+        { NULL,                 0,                  NULL,                           }
1412 1413
     };
1414
+// clang-format on
1415
+
1413 1416
     struct lsig_attrib *apt;
1414 1417
     char *tokens[ATTRIB_TOKENS], *pt, *pt2;
1415 1418
     unsigned int v1, v2, v3, i, j, tokens_count, have_newext = 0;
... ...
@@ -4304,7 +4307,7 @@ int cli_load(const char *filename, struct cl_engine *engine, unsigned int *signo
4304 4304
 
4305 4305
 
4306 4306
     if(dbio && dbio->chkonly) {
4307
-	while(cli_dbgets(buff, FILEBUFF, NULL, dbio));
4307
+	while (cli_dbgets(buff, FILEBUFF, NULL, dbio)) continue;
4308 4308
 	return CL_SUCCESS;
4309 4309
     }
4310 4310
 
... ...
@@ -27,6 +27,7 @@
27 27
 
28 28
 #include "sf_base64decode.h"
29 29
 
30
+// clang-format off
30 31
 uint8_t sf_decode64tab[256] = {
31 32
         100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
32 33
         100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
... ...
@@ -44,6 +45,7 @@ uint8_t sf_decode64tab[256] = {
44 44
         100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
45 45
         100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
46 46
         100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
47
+// clang-format on
47 48
 
48 49
 /* base64decode assumes the input data terminates with '=' and/or at the end of the input buffer
49 50
  * at inbuf_size.  If extra characters exist within inbuf before inbuf_size is reached, it will
... ...
@@ -45,6 +45,8 @@
45 45
 #include "jsparse/textbuf.h"
46 46
 #include "platform.h"
47 47
 
48
+// clang-format off
49
+
48 50
 static const int hex_chars[256] = {
49 51
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
50 52
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
... ...
@@ -64,6 +66,8 @@ static const int hex_chars[256] = {
64 64
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
65 65
 };
66 66
 
67
+// clang-format on
68
+
67 69
 static inline int cli_hex2int(const char c)
68 70
 {
69 71
 	return hex_chars[(const unsigned char)c];
... ...
@@ -442,7 +446,7 @@ char *cli_strrcpy(char *dest, const char *source) /* by NJH */
442 442
 	return NULL;
443 443
     }
444 444
 
445
-    while((*dest++ = *source++));
445
+    while((*dest++ = *source++)) continue;
446 446
 
447 447
     return --dest;
448 448
 }
... ...
@@ -39,186 +39,190 @@ int cli_scanswf(cli_ctx *ctx);
39 39
 
40 40
 typedef enum
41 41
 {
42
-    TAG_END			= 0,
43
-    TAG_SHOWFRAME		= 1,
44
-    TAG_DEFINESHAPE		= 2,
45
-    TAG_FREECHARACTER		= 3,
46
-    TAG_PLACEOBJECT		= 4,
47
-    TAG_REMOVEOBJECT		= 5,
48
-    TAG_DEFINEBITS		= 6,
49
-    TAG_DEFINEBUTTON		= 7,
50
-    TAG_JPEGTABLES		= 8,
51
-    TAG_SETBACKGROUNDCOLOR	= 9,
52
-    TAG_DEFINEFONT		= 10,
53
-    TAG_DEFINETEXT		= 11,
54
-    TAG_DOACTION		= 12,
55
-    TAG_DEFINEFONTINFO		= 13,
56
-    TAG_DEFINESOUND		= 14,
57
-    TAG_STARTSOUND		= 15,
58
-    TAG_STOPSOUND		= 16,
59
-    TAG_DEFINEBUTTONSOUND	= 17,
60
-    TAG_SOUNDSTREAMHEAD		= 18,
61
-    TAG_SOUNDSTREAMBLOCK	= 19,
62
-    TAG_DEFINEBITSLOSSLESS	= 20,
63
-    TAG_DEFINEBITSJPEG2		= 21,
64
-    TAG_DEFINESHAPE2		= 22,
65
-    TAG_DEFINEBUTTONCXFORM	= 23,
66
-    TAG_PROTECT			= 24,
67
-    TAG_PATHSAREPOSTSCRIPT	= 25,
68
-    TAG_PLACEOBJECT2		= 26,
69
-    TAG_REMOVEOBJECT2		= 28,
70
-    TAG_SYNCFRAME		= 29,
71
-    TAG_FREEALL			= 31,
72
-    TAG_DEFINESHAPE3		= 32,
73
-    TAG_DEFINETEXT2		= 33,
74
-    TAG_DEFINEBUTTON2		= 34,
75
-    TAG_DEFINEBITSJPEG3		= 35,
76
-    TAG_DEFINEBITSLOSSLESS2	= 36,
77
-    TAG_DEFINEEDITTEXT		= 37,
78
-    TAG_DEFINEVIDEO		= 38,
79
-    TAG_DEFINEMOVIECLIP		= 39,
80
-    TAG_NAMECHARACTER		= 40,
81
-    TAG_SERIALNUMBER		= 41,
82
-    TAG_DEFINETEXTFORMAT	= 42,
83
-    TAG_FRAMELABEL		= 43,
84
-    TAG_SOUNDSTREAMHEAD2	= 45,
85
-    TAG_DEFINEMORPHSHAPE	= 46,
86
-    TAG_GENFRAME		= 47,
87
-    TAG_DEFINEFONT2		= 48,
88
-    TAG_GENCOMMAND		= 49,
89
-    TAG_DEFINECOMMANDOBJ	= 50,
90
-    TAG_CHARACTERSET		= 51,
91
-    TAG_FONTREF			= 52,
92
-    TAG_EXPORTASSETS		= 56,
93
-    TAG_IMPORTASSETS		= 57,
94
-    TAG_ENABLEDEBUGGER		= 58,
95
-    TAG_INITMOVIECLIP		= 59,
96
-    TAG_DEFINEVIDEOSTREAM	= 60,
97
-    TAG_VIDEOFRAME		= 61,
98
-    TAG_DEFINEFONTINFO2		= 62,
99
-    TAG_DEBUGID			= 63,
100
-    TAG_ENABLEDEBUGGER2		= 64,
101
-    TAG_SCRIPTLIMITS		= 65,
102
-    TAG_SETTABINDEX		= 66,
103
-    TAG_DEFINESHAPE4		= 67,
104
-    TAG_FILEATTRIBUTES		= 69,
105
-    TAG_PLACEOBJECT3		= 70,
106
-    TAG_IMPORTASSETS2		= 71,
107
-    TAG_DEFINEFONTINFO3		= 73,
108
-    TAG_DEFINETEXTINFO		= 74,
109
-    TAG_DEFINEFONT3		= 75,
110
-    TAG_AVM2DECL		= 76,
111
-    TAG_METADATA		= 77,
112
-    TAG_SLICE9			= 78,
113
-    TAG_AVM2ACTION		= 82,
114
-    TAG_DEFINESHAPE5		= 83,
115
-    TAG_DEFINEMORPHSHAPE2	= 84,
116
-    TAG_DEFINESFLABELDATA	= 86,
117
-    TAG_DEFINEBINARYDATA	= 87,
118
-    TAG_DEFINEFONTNAME		= 88,
119
-    TAG_STARTSOUND2		= 89,
120
-    TAG_DEFINEBITSJPEG4		= 90,
121
-    TAG_DEFINEFONT4		= 91,
122
-    TAG_ENABLETELEMETRY		= 93,
123
-    TAG_DEFINEBITSPTR		= 1023,
124
-    TAG_UNKNOWN			= 9999
42
+    TAG_END = 0,
43
+    TAG_SHOWFRAME = 1,
44
+    TAG_DEFINESHAPE = 2,
45
+    TAG_FREECHARACTER = 3,
46
+    TAG_PLACEOBJECT = 4,
47
+    TAG_REMOVEOBJECT = 5,
48
+    TAG_DEFINEBITS = 6,
49
+    TAG_DEFINEBUTTON = 7,
50
+    TAG_JPEGTABLES = 8,
51
+    TAG_SETBACKGROUNDCOLOR = 9,
52
+    TAG_DEFINEFONT = 10,
53
+    TAG_DEFINETEXT = 11,
54
+    TAG_DOACTION = 12,
55
+    TAG_DEFINEFONTINFO = 13,
56
+    TAG_DEFINESOUND = 14,
57
+    TAG_STARTSOUND = 15,
58
+    TAG_STOPSOUND = 16,
59
+    TAG_DEFINEBUTTONSOUND = 17,
60
+    TAG_SOUNDSTREAMHEAD = 18,
61
+    TAG_SOUNDSTREAMBLOCK = 19,
62
+    TAG_DEFINEBITSLOSSLESS = 20,
63
+    TAG_DEFINEBITSJPEG2 = 21,
64
+    TAG_DEFINESHAPE2 = 22,
65
+    TAG_DEFINEBUTTONCXFORM = 23,
66
+    TAG_PROTECT = 24,
67
+    TAG_PATHSAREPOSTSCRIPT = 25,
68
+    TAG_PLACEOBJECT2 = 26,
69
+    TAG_REMOVEOBJECT2 = 28,
70
+    TAG_SYNCFRAME = 29,
71
+    TAG_FREEALL = 31,
72
+    TAG_DEFINESHAPE3 = 32,
73
+    TAG_DEFINETEXT2 = 33,
74
+    TAG_DEFINEBUTTON2 = 34,
75
+    TAG_DEFINEBITSJPEG3 = 35,
76
+    TAG_DEFINEBITSLOSSLESS2 = 36,
77
+    TAG_DEFINEEDITTEXT = 37,
78
+    TAG_DEFINEVIDEO = 38,
79
+    TAG_DEFINEMOVIECLIP = 39,
80
+    TAG_NAMECHARACTER = 40,
81
+    TAG_SERIALNUMBER = 41,
82
+    TAG_DEFINETEXTFORMAT = 42,
83
+    TAG_FRAMELABEL = 43,
84
+    TAG_SOUNDSTREAMHEAD2 = 45,
85
+    TAG_DEFINEMORPHSHAPE = 46,
86
+    TAG_GENFRAME = 47,
87
+    TAG_DEFINEFONT2 = 48,
88
+    TAG_GENCOMMAND = 49,
89
+    TAG_DEFINECOMMANDOBJ = 50,
90
+    TAG_CHARACTERSET = 51,
91
+    TAG_FONTREF = 52,
92
+    TAG_EXPORTASSETS = 56,
93
+    TAG_IMPORTASSETS = 57,
94
+    TAG_ENABLEDEBUGGER = 58,
95
+    TAG_INITMOVIECLIP = 59,
96
+    TAG_DEFINEVIDEOSTREAM = 60,
97
+    TAG_VIDEOFRAME = 61,
98
+    TAG_DEFINEFONTINFO2 = 62,
99
+    TAG_DEBUGID = 63,
100
+    TAG_ENABLEDEBUGGER2 = 64,
101
+    TAG_SCRIPTLIMITS = 65,
102
+    TAG_SETTABINDEX = 66,
103
+    TAG_DEFINESHAPE4 = 67,
104
+    TAG_FILEATTRIBUTES = 69,
105
+    TAG_PLACEOBJECT3 = 70,
106
+    TAG_IMPORTASSETS2 = 71,
107
+    TAG_DEFINEFONTINFO3 = 73,
108
+    TAG_DEFINETEXTINFO = 74,
109
+    TAG_DEFINEFONT3 = 75,
110
+    TAG_AVM2DECL = 76,
111
+    TAG_METADATA = 77,
112
+    TAG_SLICE9 = 78,
113
+    TAG_AVM2ACTION = 82,
114
+    TAG_DEFINESHAPE5 = 83,
115
+    TAG_DEFINEMORPHSHAPE2 = 84,
116
+    TAG_DEFINESFLABELDATA = 86,
117
+    TAG_DEFINEBINARYDATA = 87,
118
+    TAG_DEFINEFONTNAME = 88,
119
+    TAG_STARTSOUND2 = 89,
120
+    TAG_DEFINEBITSJPEG4 = 90,
121
+    TAG_DEFINEFONT4 = 91,
122
+    TAG_ENABLETELEMETRY = 93,
123
+    TAG_DEFINEBITSPTR = 1023,
124
+    TAG_UNKNOWN = 9999
125 125
 } tag_id;
126 126
 
127
+// clang-format off
127 128
 static const struct tag_names_s {
128 129
     const char *name;
129 130
     tag_id  id;
130 131
 } tag_names[] = {
131
-    { "TAG_END",			TAG_END			},
132
-    { "TAG_SHOWFRAME",			TAG_SHOWFRAME		},
133
-    { "TAG_DEFINESHAPE",		TAG_DEFINESHAPE		},
134
-    { "TAG_FREECHARACTER",		TAG_FREECHARACTER	},
135
-    { "TAG_PLACEOBJECT",		TAG_PLACEOBJECT		},
136
-    { "TAG_REMOVEOBJECT",		TAG_REMOVEOBJECT	},
137
-    { "TAG_DEFINEBITS",			TAG_DEFINEBITS		},
138
-    { "TAG_DEFINEBUTTON",		TAG_DEFINEBUTTON	},
139
-    { "TAG_JPEGTABLES",			TAG_JPEGTABLES		},
140
-    { "TAG_SETBACKGROUNDCOLOR",		TAG_SETBACKGROUNDCOLOR	},
141
-    { "TAG_DEFINEFONT",			TAG_DEFINEFONT		},
142
-    { "TAG_DEFINETEXT",			TAG_DEFINETEXT		},
143
-    { "TAG_DOACTION",			TAG_DOACTION		},
144
-    { "TAG_DEFINEFONTINFO",		TAG_DEFINEFONTINFO	},
145
-    { "TAG_DEFINESOUND",		TAG_DEFINESOUND		},
146
-    { "TAG_STARTSOUND",			TAG_STARTSOUND		},
147
-    { "TAG_STOPSOUND",			TAG_STOPSOUND		},
148
-    { "TAG_DEFINEBUTTONSOUND",		TAG_DEFINEBUTTONSOUND	},
149
-    { "TAG_SOUNDSTREAMHEAD",		TAG_SOUNDSTREAMHEAD	},
150
-    { "TAG_SOUNDSTREAMBLOCK",		TAG_SOUNDSTREAMBLOCK	},
151
-    { "TAG_DEFINEBITSLOSSLESS",		TAG_DEFINEBITSLOSSLESS	},
152
-    { "TAG_DEFINEBITSJPEG2",		TAG_DEFINEBITSJPEG2	},
153
-    { "TAG_DEFINESHAPE2",		TAG_DEFINESHAPE2	},
154
-    { "TAG_DEFINEBUTTONCXFORM",		TAG_DEFINEBUTTONCXFORM	},
155
-    { "TAG_PROTECT",			TAG_PROTECT		},
156
-    { "TAG_PATHSAREPOSTSCRIPT",		TAG_PATHSAREPOSTSCRIPT	},
157
-    { "TAG_PLACEOBJECT2",		TAG_PLACEOBJECT2	},
158
-    { "TAG_REMOVEOBJECT2",		TAG_REMOVEOBJECT2	},
159
-    { "TAG_SYNCFRAME",			TAG_SYNCFRAME		},
160
-    { "TAG_FREEALL",			TAG_FREEALL		},
161
-    { "TAG_DEFINESHAPE3",		TAG_DEFINESHAPE3	},
162
-    { "TAG_DEFINETEXT2",		TAG_DEFINETEXT2		},
163
-    { "TAG_DEFINEBUTTON2",		TAG_DEFINEBUTTON2	},
164
-    { "TAG_DEFINEBITSJPEG3",		TAG_DEFINEBITSJPEG3	},
165
-    { "TAG_DEFINEBITSLOSSLESS2",	TAG_DEFINEBITSLOSSLESS2	},
166
-    { "TAG_DEFINEEDITTEXT",		TAG_DEFINEEDITTEXT	},
167
-    { "TAG_DEFINEVIDEO",		TAG_DEFINEVIDEO		},
168
-    { "TAG_DEFINEMOVIECLIP",		TAG_DEFINEMOVIECLIP	},
169
-    { "TAG_NAMECHARACTER",		TAG_NAMECHARACTER	},
170
-    { "TAG_SERIALNUMBER",		TAG_SERIALNUMBER	},
171
-    { "TAG_DEFINETEXTFORMAT",		TAG_DEFINETEXTFORMAT	},
172
-    { "TAG_FRAMELABEL",			TAG_FRAMELABEL		},
173
-    { "TAG_SOUNDSTREAMHEAD2",		TAG_SOUNDSTREAMHEAD2	},
174
-    { "TAG_DEFINEMORPHSHAPE",		TAG_DEFINEMORPHSHAPE	},
175
-    { "TAG_GENFRAME",			TAG_GENFRAME		},
176
-    { "TAG_DEFINEFONT2",		TAG_DEFINEFONT2		},
177
-    { "TAG_GENCOMMAND",			TAG_GENCOMMAND		},
178
-    { "TAG_DEFINECOMMANDOBJ",		TAG_DEFINECOMMANDOBJ	},
179
-    { "TAG_CHARACTERSET",		TAG_CHARACTERSET	},
180
-    { "TAG_FONTREF",			TAG_FONTREF		},
181
-    { "TAG_EXPORTASSETS",		TAG_EXPORTASSETS	},
182
-    { "TAG_IMPORTASSETS",		TAG_IMPORTASSETS	},
183
-    { "TAG_ENABLEDEBUGGER",		TAG_ENABLEDEBUGGER	},
184
-    { "TAG_INITMOVIECLIP",		TAG_INITMOVIECLIP	},
185
-    { "TAG_DEFINEVIDEOSTREAM",		TAG_DEFINEVIDEOSTREAM	},
186
-    { "TAG_VIDEOFRAME",			TAG_VIDEOFRAME		},
187
-    { "TAG_DEFINEFONTINFO2",		TAG_DEFINEFONTINFO2	},
188
-    { "TAG_DEBUGID",			TAG_DEBUGID		},
189
-    { "TAG_ENABLEDEBUGGER2",		TAG_ENABLEDEBUGGER2	},
190
-    { "TAG_SCRIPTLIMITS",		TAG_SCRIPTLIMITS	},
191
-    { "TAG_SETTABINDEX",		TAG_SETTABINDEX		},
192
-    { "TAG_DEFINESHAPE4",		TAG_DEFINESHAPE4	},
193
-    { "TAG_FILEATTRIBUTES",		TAG_FILEATTRIBUTES	},
194
-    { "TAG_PLACEOBJECT3",		TAG_PLACEOBJECT3	},
195
-    { "TAG_IMPORTASSETS2",		TAG_IMPORTASSETS2	},
196
-    { "TAG_DEFINEFONTINFO3",		TAG_DEFINEFONTINFO3	},
197
-    { "TAG_DEFINETEXTINFO",		TAG_DEFINETEXTINFO	},
198
-    { "TAG_DEFINEFONT3",		TAG_DEFINEFONT3		},
199
-    { "TAG_AVM2DECL",			TAG_AVM2DECL		},
200
-    { "TAG_METADATA",			TAG_METADATA		},
201
-    { "TAG_SLICE9",			TAG_SLICE9		},
202
-    { "TAG_AVM2ACTION",			TAG_AVM2ACTION		},
203
-    { "TAG_DEFINESHAPE5",		TAG_DEFINESHAPE5	},
204
-    { "TAG_DEFINEMORPHSHAPE2",		TAG_DEFINEMORPHSHAPE2	},
205
-    { "TAG_DEFINESFLABELDATA",		TAG_DEFINESFLABELDATA	},
206
-    { "TAG_DEFINEBINARYDATA",		TAG_DEFINEBINARYDATA	},
207
-    { "TAG_DEFINEFONTNAME",		TAG_DEFINEFONTNAME	},
208
-    { "TAG_STARTSOUND2",		TAG_STARTSOUND2		},
209
-    { "TAG_DEFINEBITSJPEG4",		TAG_DEFINEBITSJPEG4	},
210
-    { "TAG_DEFINEFONT4",		TAG_DEFINEFONT4		},
211
-    { "TAG_ENABLETELEMETRY",		TAG_ENABLETELEMETRY	},
212
-    { "TAG_DEFINEBITSPTR",		TAG_DEFINEBITSPTR	},
213
-    { NULL,				TAG_UNKNOWN		},
132
+    { "TAG_END",                 TAG_END                },
133
+    { "TAG_SHOWFRAME",           TAG_SHOWFRAME          },
134
+    { "TAG_DEFINESHAPE",         TAG_DEFINESHAPE        },
135
+    { "TAG_FREECHARACTER",       TAG_FREECHARACTER      },
136
+    { "TAG_PLACEOBJECT",         TAG_PLACEOBJECT        },
137
+    { "TAG_REMOVEOBJECT",        TAG_REMOVEOBJECT       },
138
+    { "TAG_DEFINEBITS",          TAG_DEFINEBITS         },
139
+    { "TAG_DEFINEBUTTON",        TAG_DEFINEBUTTON       },
140
+    { "TAG_JPEGTABLES",          TAG_JPEGTABLES         },
141
+    { "TAG_SETBACKGROUNDCOLOR",  TAG_SETBACKGROUNDCOLOR },
142
+    { "TAG_DEFINEFONT",          TAG_DEFINEFONT         },
143
+    { "TAG_DEFINETEXT",          TAG_DEFINETEXT         },
144
+    { "TAG_DOACTION",            TAG_DOACTION           },
145
+    { "TAG_DEFINEFONTINFO",      TAG_DEFINEFONTINFO     },
146
+    { "TAG_DEFINESOUND",         TAG_DEFINESOUND        },
147
+    { "TAG_STARTSOUND",          TAG_STARTSOUND         },
148
+    { "TAG_STOPSOUND",           TAG_STOPSOUND          },
149
+    { "TAG_DEFINEBUTTONSOUND",   TAG_DEFINEBUTTONSOUND  },
150
+    { "TAG_SOUNDSTREAMHEAD",     TAG_SOUNDSTREAMHEAD    },
151
+    { "TAG_SOUNDSTREAMBLOCK",    TAG_SOUNDSTREAMBLOCK   },
152
+    { "TAG_DEFINEBITSLOSSLESS",  TAG_DEFINEBITSLOSSLESS },
153
+    { "TAG_DEFINEBITSJPEG2",     TAG_DEFINEBITSJPEG2    },
154
+    { "TAG_DEFINESHAPE2",        TAG_DEFINESHAPE2       },
155
+    { "TAG_DEFINEBUTTONCXFORM",  TAG_DEFINEBUTTONCXFORM },
156
+    { "TAG_PROTECT",             TAG_PROTECT            },
157
+    { "TAG_PATHSAREPOSTSCRIPT",  TAG_PATHSAREPOSTSCRIPT },
158
+    { "TAG_PLACEOBJECT2",        TAG_PLACEOBJECT2       },
159
+    { "TAG_REMOVEOBJECT2",       TAG_REMOVEOBJECT2      },
160
+    { "TAG_SYNCFRAME",           TAG_SYNCFRAME          },
161
+    { "TAG_FREEALL",             TAG_FREEALL            },
162
+    { "TAG_DEFINESHAPE3",        TAG_DEFINESHAPE3       },
163
+    { "TAG_DEFINETEXT2",         TAG_DEFINETEXT2        },
164
+    { "TAG_DEFINEBUTTON2",       TAG_DEFINEBUTTON2      },
165
+    { "TAG_DEFINEBITSJPEG3",     TAG_DEFINEBITSJPEG3    },
166
+    { "TAG_DEFINEBITSLOSSLESS2", TAG_DEFINEBITSLOSSLESS2},
167
+    { "TAG_DEFINEEDITTEXT",      TAG_DEFINEEDITTEXT     },
168
+    { "TAG_DEFINEVIDEO",         TAG_DEFINEVIDEO        },
169
+    { "TAG_DEFINEMOVIECLIP",     TAG_DEFINEMOVIECLIP    },
170
+    { "TAG_NAMECHARACTER",       TAG_NAMECHARACTER      },
171
+    { "TAG_SERIALNUMBER",        TAG_SERIALNUMBER       },
172
+    { "TAG_DEFINETEXTFORMAT",    TAG_DEFINETEXTFORMAT   },
173
+    { "TAG_FRAMELABEL",          TAG_FRAMELABEL         },
174
+    { "TAG_SOUNDSTREAMHEAD2",    TAG_SOUNDSTREAMHEAD2   },
175
+    { "TAG_DEFINEMORPHSHAPE",    TAG_DEFINEMORPHSHAPE   },
176
+    { "TAG_GENFRAME",            TAG_GENFRAME           },
177
+    { "TAG_DEFINEFONT2",         TAG_DEFINEFONT2        },
178
+    { "TAG_GENCOMMAND",          TAG_GENCOMMAND         },
179
+    { "TAG_DEFINECOMMANDOBJ",    TAG_DEFINECOMMANDOBJ   },
180
+    { "TAG_CHARACTERSET",        TAG_CHARACTERSET       },
181
+    { "TAG_FONTREF",             TAG_FONTREF            },
182
+    { "TAG_EXPORTASSETS",        TAG_EXPORTASSETS       },
183
+    { "TAG_IMPORTASSETS",        TAG_IMPORTASSETS       },
184
+    { "TAG_ENABLEDEBUGGER",      TAG_ENABLEDEBUGGER     },
185
+    { "TAG_INITMOVIECLIP",       TAG_INITMOVIECLIP      },
186
+    { "TAG_DEFINEVIDEOSTREAM",   TAG_DEFINEVIDEOSTREAM  },
187
+    { "TAG_VIDEOFRAME",          TAG_VIDEOFRAME         },
188
+    { "TAG_DEFINEFONTINFO2",     TAG_DEFINEFONTINFO2    },
189
+    { "TAG_DEBUGID",             TAG_DEBUGID            },
190
+    { "TAG_ENABLEDEBUGGER2",     TAG_ENABLEDEBUGGER2    },
191
+    { "TAG_SCRIPTLIMITS",        TAG_SCRIPTLIMITS       },
192
+    { "TAG_SETTABINDEX",         TAG_SETTABINDEX        },
193
+    { "TAG_DEFINESHAPE4",        TAG_DEFINESHAPE4       },
194
+    { "TAG_FILEATTRIBUTES",      TAG_FILEATTRIBUTES     },
195
+    { "TAG_PLACEOBJECT3",        TAG_PLACEOBJECT3       },
196
+    { "TAG_IMPORTASSETS2",       TAG_IMPORTASSETS2      },
197
+    { "TAG_DEFINEFONTINFO3",     TAG_DEFINEFONTINFO3    },
198
+    { "TAG_DEFINETEXTINFO",      TAG_DEFINETEXTINFO     },
199
+    { "TAG_DEFINEFONT3",         TAG_DEFINEFONT3        },
200
+    { "TAG_AVM2DECL",            TAG_AVM2DECL           },
201
+    { "TAG_METADATA",            TAG_METADATA           },
202
+    { "TAG_SLICE9",              TAG_SLICE9             },
203
+    { "TAG_AVM2ACTION",          TAG_AVM2ACTION         },
204
+    { "TAG_DEFINESHAPE5",        TAG_DEFINESHAPE5       },
205
+    { "TAG_DEFINEMORPHSHAPE2",   TAG_DEFINEMORPHSHAPE2  },
206
+    { "TAG_DEFINESFLABELDATA",   TAG_DEFINESFLABELDATA  },
207
+    { "TAG_DEFINEBINARYDATA",    TAG_DEFINEBINARYDATA   },
208
+    { "TAG_DEFINEFONTNAME",      TAG_DEFINEFONTNAME     },
209
+    { "TAG_STARTSOUND2",         TAG_STARTSOUND2        },
210
+    { "TAG_DEFINEBITSJPEG4",     TAG_DEFINEBITSJPEG4    },
211
+    { "TAG_DEFINEFONT4",         TAG_DEFINEFONT4        },
212
+    { "TAG_ENABLETELEMETRY",     TAG_ENABLETELEMETRY    },
213
+    { "TAG_DEFINEBITSPTR",       TAG_DEFINEBITSPTR      },
214
+    { NULL,                      TAG_UNKNOWN            },
214 215
 };
216
+// clang-format on
215 217
 
218
+// clang-format off
216 219
 #define SWF_ATTR_USENETWORK                 0x01
217 220
 #define SWF_ATTR_RELATIVEURLS               0x02
218 221
 #define SWF_ATTR_SUPPRESSCROSSDOMAINCACHE   0x04
219 222
 #define SWF_ATTR_ACTIONSCRIPT3              0x08
220 223
 #define SWF_ATTR_HASMETADATA                0x10
221
-#define SWF_ATTR_USEDIRECTBLIT		    0x20
222
-#define SWF_ATTR_USEGPU			    0x40
224
+#define SWF_ATTR_USEDIRECTBLIT              0x20
225
+#define SWF_ATTR_USEGPU                     0x40
226
+// clang-format on
223 227
 
224 228
 #endif
... ...
@@ -54,27 +54,29 @@
54 54
 #define I 2   /* character appears in ISO-8859 text */
55 55
 #define X 3   /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
56 56
 
57
+// clang-format off
57 58
 static char text_chars[256] = {
58
-	/*                  BEL BS HT LF    FF CR    */
59
-	F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F,  /* 0x0X */
60
-        /*                              ESC          */
61
-	F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F,  /* 0x1X */
62
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x2X */
63
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x3X */
64
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x4X */
65
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x5X */
66
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x6X */
67
-	T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F,  /* 0x7X */
68
-	/*            NEL                            */
69
-	X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X,  /* 0x8X */
70
-	X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,  /* 0x9X */
71
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xaX */
72
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xbX */
73
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xcX */
74
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xdX */
75
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xeX */
76
-	I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I   /* 0xfX */
59
+    /*                  BEL BS HT LF    FF CR    */
60
+    F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F,  /* 0x0X */
61
+    /*                              ESC          */
62
+    F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F,  /* 0x1X */
63
+    T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x2X */
64
+    T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x3X */
65
+    T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x4X */
66
+    T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x5X */
67
+    T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,  /* 0x6X */
68
+    T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F,  /* 0x7X */
69
+    /*            NEL                            */
70
+    X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X,  /* 0x8X */
71
+    X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,  /* 0x9X */
72
+    I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xaX */
73
+    I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xbX */
74
+    I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xcX */
75
+    I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xdX */
76
+    I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,  /* 0xeX */
77
+    I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I   /* 0xfX */
77 78
 };
79
+// clang-format on
78 80
 
79 81
 static int td_isascii(const unsigned char *buf, unsigned int len)
80 82
 {
... ...
@@ -87,11 +89,11 @@ static int td_isascii(const unsigned char *buf, unsigned int len)
87 87
 	//    not been validated to correctly handle multibyte UTF8. 
88 88
 	// /* Check for the Byte-Order-Mark for UTF-8 */
89 89
 	// if ((len >= 3) &&
90
-	// 	(buf[0] == 0xEF) &&
91
-	// 	(buf[1] == 0xBB) &&
92
-	// 	(buf[2] == 0xBF))
90
+	//    (buf[0] == 0xEF) &&
91
+	//    (buf[1] == 0xBB) &&
92
+	//    (buf[2] == 0xBF))
93 93
 	// {
94
-	// 	return 0;
94
+	//    return 0;
95 95
 	// }
96 96
 
97 97
 	/* Validate that the data all falls within the bounds of 
... ...
@@ -50,7 +50,7 @@ int unzip_search_add(struct zip_requests *, const char *, size_t);
50 50
 int unzip_search(cli_ctx *, fmap_t *, struct zip_requests *);
51 51
 int unzip_search_single(cli_ctx *, const char *, size_t, uint32_t *);
52 52
 
53
-
53
+// clang-format off
54 54
 #ifdef UNZIP_PRIVATE
55 55
 #define F_ENCR  (1<<0)
56 56
 #define F_ALGO1 (1<<1)
... ...
@@ -68,6 +68,7 @@ int unzip_search_single(cli_ctx *, const char *, size_t, uint32_t *);
68 68
 #define F_MSKED (1<<13)
69 69
 #define F_RSVD3 (1<<14)
70 70
 #define F_RSVD4 (1<<15)
71
+// clang-format on
71 72
 
72 73
 enum ALGO {
73 74
   ALG_STORED,
... ...
@@ -110,17 +111,19 @@ enum ALGO {
110 110
 /*   char extra[elen] */
111 111
 /* } __attribute__((packed)); */
112 112
 
113
-#define LH_magic	((uint32_t)cli_readint32((uint8_t *)(lh)+0))
114
-#define LH_version	((uint16_t)cli_readint16((uint8_t *)(lh)+4))
115
-#define LH_flags	((uint16_t)cli_readint16((uint8_t *)(lh)+6))
116
-#define LH_method	((uint16_t)cli_readint16((uint8_t *)(lh)+8))
117
-#define LH_mtime	((uint32_t)cli_readint32((uint8_t *)(lh)+10))
118
-#define LH_crc32	((uint32_t)cli_readint32((uint8_t *)(lh)+14))
119
-#define LH_csize	((uint32_t)cli_readint32((uint8_t *)(lh)+18))
120
-#define LH_usize	((uint32_t)cli_readint32((uint8_t *)(lh)+22))
121
-#define LH_flen 	((uint16_t)cli_readint16((uint8_t *)(lh)+26))
122
-#define LH_elen 	((uint16_t)cli_readint16((uint8_t *)(lh)+28))
113
+// clang-format off
114
+#define LH_magic   ((uint32_t)cli_readint32((uint8_t *)(lh)+0))
115
+#define LH_version ((uint16_t)cli_readint16((uint8_t *)(lh)+4))
116
+#define LH_flags   ((uint16_t)cli_readint16((uint8_t *)(lh)+6))
117
+#define LH_method  ((uint16_t)cli_readint16((uint8_t *)(lh)+8))
118
+#define LH_mtime   ((uint32_t)cli_readint32((uint8_t *)(lh)+10))
119
+#define LH_crc32   ((uint32_t)cli_readint32((uint8_t *)(lh)+14))
120
+#define LH_csize   ((uint32_t)cli_readint32((uint8_t *)(lh)+18))
121
+#define LH_usize   ((uint32_t)cli_readint32((uint8_t *)(lh)+22))
122
+#define LH_flen    ((uint16_t)cli_readint16((uint8_t *)(lh)+26))
123
+#define LH_elen    ((uint16_t)cli_readint16((uint8_t *)(lh)+28))
123 124
 #define SIZEOF_LH 30
125
+// clang-format on
124 126
 
125 127
 /* struct CH { */
126 128
 /*   uint32_t magic; */
... ...
@@ -144,23 +147,25 @@ enum ALGO {
144 144
 /*   char comment[clen] */
145 145
 /* } __attribute__((packed)); */
146 146
 
147
-#define CH_magic	((uint32_t)cli_readint32((uint8_t *)(ch)+0))
148
-#define CH_vermade	((uint16_t)cli_readint16((uint8_t *)(ch)+4))
149
-#define CH_verneed	((uint16_t)cli_readint16((uint8_t *)(ch)+6))
150
-#define CH_flags	((uint16_t)cli_readint16((uint8_t *)(ch)+8))
151
-#define CH_method	((uint16_t)cli_readint16((uint8_t *)(ch)+10))
152
-#define CH_mtime	((uint32_t)cli_readint32((uint8_t *)(ch)+12))
153
-#define CH_crc32	((uint32_t)cli_readint32((uint8_t *)(ch)+16))
154
-#define CH_csize	((uint32_t)cli_readint32((uint8_t *)(ch)+20))
155
-#define CH_usize	((uint32_t)cli_readint32((uint8_t *)(ch)+24))
156
-#define CH_flen 	((uint16_t)cli_readint16((uint8_t *)(ch)+28))
157
-#define CH_elen 	((uint16_t)cli_readint16((uint8_t *)(ch)+30))
158
-#define CH_clen 	((uint16_t)cli_readint16((uint8_t *)(ch)+32))
159
-#define CH_dsk  	((uint16_t)cli_readint16((uint8_t *)(ch)+34))
160
-#define CH_iattrib	((uint16_t)cli_readint16((uint8_t *)(ch)+36))
161
-#define CH_eattrib	((uint32_t)cli_readint32((uint8_t *)(ch)+38))
162
-#define CH_off  	((uint32_t)cli_readint32((uint8_t *)(ch)+42))
147
+// clang-format off
148
+#define CH_magic   ((uint32_t)cli_readint32((uint8_t *)(ch)+0))
149
+#define CH_vermade ((uint16_t)cli_readint16((uint8_t *)(ch)+4))
150
+#define CH_verneed ((uint16_t)cli_readint16((uint8_t *)(ch)+6))
151
+#define CH_flags   ((uint16_t)cli_readint16((uint8_t *)(ch)+8))
152
+#define CH_method  ((uint16_t)cli_readint16((uint8_t *)(ch)+10))
153
+#define CH_mtime   ((uint32_t)cli_readint32((uint8_t *)(ch)+12))
154
+#define CH_crc32   ((uint32_t)cli_readint32((uint8_t *)(ch)+16))
155
+#define CH_csize   ((uint32_t)cli_readint32((uint8_t *)(ch)+20))
156
+#define CH_usize   ((uint32_t)cli_readint32((uint8_t *)(ch)+24))
157
+#define CH_flen    ((uint16_t)cli_readint16((uint8_t *)(ch)+28))
158
+#define CH_elen    ((uint16_t)cli_readint16((uint8_t *)(ch)+30))
159
+#define CH_clen    ((uint16_t)cli_readint16((uint8_t *)(ch)+32))
160
+#define CH_dsk     ((uint16_t)cli_readint16((uint8_t *)(ch)+34))
161
+#define CH_iattrib ((uint16_t)cli_readint16((uint8_t *)(ch)+36))
162
+#define CH_eattrib ((uint32_t)cli_readint32((uint8_t *)(ch)+38))
163
+#define CH_off     ((uint32_t)cli_readint32((uint8_t *)(ch)+42))
163 164
 #define SIZEOF_CH 46
165
+// clang-format on
164 166
 
165 167
 #define SIZEOF_EH 12
166 168
 #endif /* UNZIP_PRIVATE */
... ...
@@ -50,13 +50,15 @@ struct xar_header {
50 50
     uint32_t chksum_alg; /* 0 = none */
51 51
 };
52 52
 
53
-#define XAR_HEADER_MAGIC 0x78617221
54
-#define XAR_HEADER_VERSION 0
53
+// clang-format off
54
+#define XAR_HEADER_MAGIC    0x78617221
55
+#define XAR_HEADER_VERSION  0
55 56
 
56 57
 #define XAR_CKSUM_NONE   0
57 58
 #define XAR_CKSUM_SHA1   1
58 59
 #define XAR_CKSUM_MD5    2
59 60
 #define XAR_CKSUM_OTHER  3
61
+// clang-format on
60 62
 
61 63
 #ifdef HAVE_PRAGMA_PACK
62 64
 #pragma pack()
... ...
@@ -19,8 +19,9 @@
19 19
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 20
  */
21 21
 
22
-/* Most of this file was derived from yara 2.1.0 libyara/yara.h and
23
-   other YARA header files. Following is the YARA copyright. */
22
+/* Most of this file was derived from Yara 2.1.0 libyara/yara.h and
23
+ * other YARA header files. Following is the YARA copyright. */
24
+
24 25
 /*
25 26
 Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved.
26 27
 
... ...
@@ -45,7 +46,11 @@ limitations under the License.
45 45
 #include "others.h"
46 46
 #include "str.h"
47 47
 
48
-/* From libyara/include/yara/types.h            */
48
+// clang-format off
49
+
50
+/*
51
+ * From libyara/include/yara/types.h
52
+ */
49 53
 #define DECLARE_REFERENCE(type, name) \
50 54
     union { type name; int64_t name##_; }
51 55
 
... ...
@@ -54,7 +59,6 @@ limitations under the License.
54 54
 #define META_TYPE_STRING    2
55 55
 #define META_TYPE_BOOLEAN   3
56 56
 
57
-
58 57
 #define STRING_GFLAGS_REFERENCED        0x01
59 58
 #define STRING_GFLAGS_HEXADECIMAL       0x02
60 59
 #define STRING_GFLAGS_NO_CASE           0x04
... ...
@@ -163,44 +167,44 @@ limitations under the License.
163 163
 
164 164
 typedef struct _YR_OBJECT
165 165
 {
166
-  OBJECT_COMMON_FIELDS
166
+    OBJECT_COMMON_FIELDS
167 167
 
168 168
 } YR_OBJECT;
169 169
 
170 170
 typedef struct _YR_OBJECT_INTEGER
171 171
 {
172
-  OBJECT_COMMON_FIELDS
173
-  int64_t value;
172
+    OBJECT_COMMON_FIELDS
173
+    int64_t value;
174 174
 
175 175
 } YR_OBJECT_INTEGER;
176 176
 
177 177
 
178 178
 typedef struct _YR_OBJECT_STRING
179 179
 {
180
-  OBJECT_COMMON_FIELDS
181
-  char* value;
180
+    OBJECT_COMMON_FIELDS
181
+    char* value;
182 182
 
183 183
 } YR_OBJECT_STRING;
184 184
 
185 185
 typedef struct _YR_OBJECT_ARRAY
186 186
 {
187
-  OBJECT_COMMON_FIELDS
188
-  struct _YR_ARRAY_ITEMS* items;
187
+    OBJECT_COMMON_FIELDS
188
+    struct _YR_ARRAY_ITEMS* items;
189 189
 
190 190
 } YR_OBJECT_ARRAY;
191 191
 
192 192
 typedef struct _YR_SCAN_CONTEXT
193 193
 {
194
-  uint64_t  file_size;
195
-  uint64_t  entry_point;
194
+    uint64_t  file_size;
195
+    uint64_t  entry_point;
196 196
 
197
-  int flags;
198
-  void* user_data;
197
+    int flags;
198
+    void* user_data;
199 199
 
200
-  //YR_MEMORY_BLOCK*  mem_block;
201
-  YR_HASH_TABLE*  objects_table;
202
-  //YR_CALLBACK_FUNC  callback;
203
-  fmap_t * fmap;
200
+    //YR_MEMORY_BLOCK*  mem_block;
201
+    YR_HASH_TABLE*  objects_table;
202
+    //YR_CALLBACK_FUNC  callback;
203
+    fmap_t * fmap;
204 204
 } YR_SCAN_CONTEXT;
205 205
 
206 206
 struct _YR_OBJECT_FUNCTION;
... ...
@@ -212,23 +216,25 @@ typedef int (*YR_MODULE_FUNC)(
212 212
 
213 213
 typedef struct _YR_OBJECT_FUNCTION
214 214
 {
215
-  OBJECT_COMMON_FIELDS
215
+    OBJECT_COMMON_FIELDS
216 216
 
217
-  const char* arguments_fmt;
217
+    const char* arguments_fmt;
218 218
 
219
-  YR_OBJECT* return_obj;
220
-  YR_MODULE_FUNC code;
219
+    YR_OBJECT* return_obj;
220
+    YR_MODULE_FUNC code;
221 221
 
222 222
 } YR_OBJECT_FUNCTION;
223 223
 
224 224
 typedef struct _YR_ARRAY_ITEMS
225 225
 {
226
-  int count;
227
-  YR_OBJECT* objects[1];
226
+    int count;
227
+    YR_OBJECT* objects[1];
228 228
 
229 229
 } YR_ARRAY_ITEMS;
230 230
 
231
-/* From libyara/include/yara/sizedstr.h            */
231
+/*
232
+ * From libyara/include/yara/sizedstr.h
233
+ */
232 234
 #define SIZED_STRING_FLAGS_NO_CASE  1
233 235
 #define SIZED_STRING_FLAGS_DOT_ALL  2
234 236
 
... ...
@@ -241,7 +247,9 @@ typedef struct _SIZED_STRING
241 241
 } SIZED_STRING;
242 242
 
243 243
 
244
-/* From libyara/include/yara/error.h            */
244
+/*
245
+ * From libyara/include/yara/error.h
246
+ */
245 247
 #ifndef ERROR_SUCCESS
246 248
 #define ERROR_SUCCESS                           0
247 249
 #endif
... ...
@@ -287,21 +295,23 @@ typedef struct _SIZED_STRING
287 287
 #define ERROR_WRONG_NUMBER_OF_ARGUMENTS         40
288 288
 
289 289
 #define FAIL_ON_ERROR(x) { \
290
-  int result = (x); \
291
-  if (result != ERROR_SUCCESS) \
292
-    return result; \
290
+    int result = (x); \
291
+    if (result != ERROR_SUCCESS) \
292
+        return result; \
293 293
 }
294 294
 
295 295
 #define FAIL_ON_COMPILER_ERROR(x) { \
296
-  compiler->last_result = (x); \
297
-  if (compiler->last_result != ERROR_SUCCESS) { \
298
-    if (compiler->last_result == ERROR_INSUFICIENT_MEMORY) \
299
-      yyfatal(yyscanner, "YARA fatal error: terminating rule parse\n"); \
300
-    return compiler->last_result; \
301
-  } \
296
+    compiler->last_result = (x); \
297
+    if (compiler->last_result != ERROR_SUCCESS) { \
298
+        if (compiler->last_result == ERROR_INSUFICIENT_MEMORY) \
299
+            yyfatal(yyscanner, "YARA fatal error: terminating rule parse\n"); \
300
+        return compiler->last_result; \
301
+    } \
302 302
 }
303 303
 
304
-/* From libyara/include/yara/re.h            */
304
+/*
305
+ * From libyara/include/yara/re.h
306
+ */
305 307
 #define RE_FLAGS_FAST_HEX_REGEXP          0x02
306 308
 #define RE_FLAGS_BACKWARDS                0x04
307 309
 #define RE_FLAGS_EXHAUSTIVE               0x08
... ...
@@ -309,96 +319,100 @@ typedef struct _SIZED_STRING
309 309
 #define RE_FLAGS_NO_CASE                  0x20
310 310
 #define RE_FLAGS_SCAN                     0x40
311 311
 #define RE_FLAGS_DOT_ALL                  0x80
312
-#define RE_FLAGS_NOT_AT_START            0x100
312
+#define RE_FLAGS_NOT_AT_START             0x100
313 313
 
314 314
 typedef struct _YR_META
315 315
 {
316
-  int32_t type;
317
-  int32_t integer;
316
+    int32_t type;
317
+    int32_t integer;
318 318
 
319
-  DECLARE_REFERENCE(char*, identifier);
320
-  DECLARE_REFERENCE(char*, string);
319
+    DECLARE_REFERENCE(char*, identifier);
320
+    DECLARE_REFERENCE(char*, string);
321 321
 
322 322
 } YR_META;
323 323
 
324 324
 #if REAL_YARA
325 325
 typedef struct _YR_STRING
326 326
 {
327
-  int32_t g_flags;
328
-  int32_t length;
327
+    int32_t g_flags;
328
+    int32_t length;
329 329
 
330
-  DECLARE_REFERENCE(char*, identifier);
331
-  DECLARE_REFERENCE(uint8_t*, string);
332
-  DECLARE_REFERENCE(struct _YR_STRING*, chained_to);
330
+    DECLARE_REFERENCE(char*, identifier);
331
+    DECLARE_REFERENCE(uint8_t*, string);
332
+    DECLARE_REFERENCE(struct _YR_STRING*, chained_to);
333 333
 
334
-  int32_t chain_gap_min;
335
-  int32_t chain_gap_max;
334
+    int32_t chain_gap_min;
335
+    int32_t chain_gap_max;
336 336
 
337
-    //  YR_MATCHES matches[MAX_THREADS];
338
-    //  YR_MATCHES unconfirmed_matches[MAX_THREADS];
337
+        //  YR_MATCHES matches[MAX_THREADS];
338
+        //  YR_MATCHES unconfirmed_matches[MAX_THREADS];
339 339
 
340 340
 } YR_STRING;
341 341
 #endif
342 342
 
343 343
 typedef struct _YR_EXTERNAL_VARIABLE
344 344
 {
345
-  int32_t type;
346
-  int64_t integer;
345
+    int32_t type;
346
+    int64_t integer;
347 347
 
348
-  DECLARE_REFERENCE(char*, identifier);
349
-  DECLARE_REFERENCE(char*, string);
348
+    DECLARE_REFERENCE(char*, identifier);
349
+    DECLARE_REFERENCE(char*, string);
350 350
 
351 351
 } YR_EXTERNAL_VARIABLE;
352 352
 
353 353
 typedef struct _YR_NAMESPACE
354 354
 {
355 355
 
356
-  DECLARE_REFERENCE(char*, name);
356
+    DECLARE_REFERENCE(char*, name);
357 357
 
358 358
 } YR_NAMESPACE;
359 359
 
360
-/* From libyara/include/yara/exec.h            */
360
+/*
361
+ * From libyara/include/yara/exec.h
362
+ */
361 363
 typedef struct RE RE;
362 364
 typedef struct RE_NODE RE_NODE;
363 365
 
364 366
 struct RE_NODE
365 367
 {
366
-  int type;
368
+    int type;
367 369
 
368
-  union {
369
-    int value;
370
-    int count;
371
-    int start;
372
-  };
370
+    union {
371
+        int value;
372
+        int count;
373
+        int start;
374
+    };
373 375
 
374
-  union {
375
-    int mask;
376
-    int end;
377
-  };
376
+    union {
377
+        int mask;
378
+        int end;
379
+    };
378 380
 
379
-  int greedy;
381
+    int greedy;
380 382
 
381
-  uint8_t* class_vector;
383
+    uint8_t* class_vector;
382 384
 
383
-  RE_NODE* left;
384
-  RE_NODE* right;
385
+    RE_NODE* left;
386
+    RE_NODE* right;
385 387
 
386
-  void* forward_code;
387
-  void* backward_code;
388
+    void* forward_code;
389
+    void* backward_code;
388 390
 };
389 391
 
390 392
 
391 393
 struct RE {
392 394
 
393
-  uint32_t flags;
394
-  RE_NODE* root_node;
395
+    uint32_t flags;
396
+    RE_NODE* root_node;
395 397
 
396
-  const char* error_message;
397
-  int error_code;
398
+    const char* error_message;
399
+    int error_code;
398 400
 };
399 401
 
400 402
 
401
-/* From libyara/include/yara/limits.h            */
403
+/*
404
+ * From libyara/include/yara/limits.h
405
+ */
402 406
 #define MAX_COMPILER_ERROR_EXTRA_INFO   256
403 407
 #define MAX_LOOP_NESTING                4
404 408
 #define MAX_FUNCTION_ARGS               128
... ...
@@ -406,10 +420,12 @@ struct RE {
406 406
 #define LEX_BUF_SIZE                    1024
407 407
 #define MAX_INCLUDE_DEPTH               16
408 408
 #ifndef MAX_PATH
409
-#define MAX_PATH 1024
409
+#define MAX_PATH                        1024
410 410
 #endif
411 411
 
412
-/* From libyara/include/yara/object.h            */
412
+/*
413
+ * From libyara/include/yara/object.h
414
+ */
413 415
 #define OBJECT_TYPE_INTEGER     1
414 416
 #define OBJECT_TYPE_STRING      2
415 417
 #define OBJECT_TYPE_STRUCTURE   3
... ...
@@ -417,7 +433,9 @@ struct RE {
417 417
 #define OBJECT_TYPE_FUNCTION    5
418 418
 #define OBJECT_TYPE_REGEXP      6
419 419
 
420
-/* From libyara/include/yara/utils.h */
420
+/*
421
+ * From libyara/include/yara/utils.h
422
+ */
421 423
 #define UINT64_TO_PTR(type, x)  ((type)(size_t) x)
422 424
 #define PTR_TO_UINT64(x)  ((uint64_t) (size_t) x)
423 425
 
... ...
@@ -431,7 +449,9 @@ struct RE {
431 431
 #define RULE_OFFSETS    32
432 432
 #endif
433 433
 
434
-/* YARA to ClamAV function mappings */
434
+/*
435
+ * YARA to ClamAV function mappings
436
+ */
435 437
 #define yr_strdup cli_strdup
436 438
 #define yr_malloc cli_malloc
437 439
 #define yr_realloc cli_realloc
... ...
@@ -443,7 +463,9 @@ struct RE {
443 443
 #define strlcpy cli_strlcpy
444 444
 #define strlcat cli_strlcat
445 445
 
446
-/* YARA-defined structure replacements for ClamAV */
446
+/*
447
+ * YARA-defined structure replacements for ClamAV
448
+ */
447 449
 struct _yc_rule {
448 450
     STAILQ_ENTRY(_yc_rule) link;
449 451
     STAILQ_HEAD(sq, _yc_string) strings;
... ...
@@ -469,5 +491,7 @@ typedef struct _yc_string {
469 469
 typedef yc_rule YR_RULE;
470 470
 typedef yc_string YR_STRING;
471 471
 
472
+// clang-format on
473
+
472 474
 #endif
473 475
 
... ...
@@ -59,9 +59,9 @@ limitations under the License.
59 59
 #include "others.h"
60 60
 #endif
61 61
 
62
-#define todigit(x)  ((x) >='A'&& (x) <='F')? \
63
-                    ((uint8_t) (x - 'A' + 10)) : \
64
-                    ((uint8_t) (x - '0'))
62
+#define todigit(x)  ((x) >='A'&& (x) <='F') \
63
+                    ? ((uint8_t) (x - 'A' + 10)) \
64
+                    : ((uint8_t) (x - '0'))
65 65
 
66 66
 
67 67
 int yr_parser_emit(
... ...
@@ -69,7 +69,7 @@ char updtmpdir[512], dbdir[512];
69 69
 static int
70 70
 download (const struct optstruct *opts, const char *cfgfile)
71 71
 {
72
-    int ret = 0, try = 1, maxattempts = 0;
72
+    int ret = 0, attempt = 1, maxattempts = 0;
73 73
     const struct optstruct *opt;
74 74
     
75 75
     
... ...
@@ -86,17 +86,17 @@ download (const struct optstruct *opts, const char *cfgfile)
86 86
     {
87 87
         while (opt)
88 88
         {
89
-            ret = downloadmanager (opts, opt->strarg, try);
89
+            ret = downloadmanager (opts, opt->strarg, attempt);
90 90
 #ifndef _WIN32
91 91
             alarm (0);
92 92
 #endif
93 93
             if (ret == FCE_CONNECTION || ret == FCE_BADCVD
94 94
                 || ret == FCE_FAILEDGET || ret == FCE_MIRRORNOTSYNC)
95 95
             {
96
-                if (try < maxattempts)
96
+                if (attempt < maxattempts)
97 97
                 {
98 98
                     logg ("Trying again in 5 secs...\n");
99
-                    try++;
99
+                    attempt++;
100 100
                     sleep (5);
101 101
                     continue;
102 102
                 }
... ...
@@ -23,21 +23,23 @@
23 23
 #define __OPTPARSER_H
24 24
 
25 25
 /* don't share bits! */
26
-#define OPT_CLAMD	1
27
-#define OPT_FRESHCLAM	2
28
-#define OPT_MILTER	4
29
-#define OPT_CLAMSCAN	8
30
-#define OPT_CLAMDSCAN	16
31
-#define OPT_SIGTOOL	32
32
-#define OPT_CLAMCONF	64
33
-#define OPT_CLAMDTOP	128
34
-#define OPT_CLAMBC      256
35
-#define OPT_DEPRECATED	512
26
+// clang-format off
27
+#define OPT_CLAMD           1
28
+#define OPT_FRESHCLAM       2
29
+#define OPT_MILTER          4
30
+#define OPT_CLAMSCAN        8
31
+#define OPT_CLAMDSCAN       16
32
+#define OPT_SIGTOOL         32
33
+#define OPT_CLAMCONF        64
34
+#define OPT_CLAMDTOP        128
35
+#define OPT_CLAMBC          256
36
+#define OPT_DEPRECATED      512
36 37
 
37
-#define CLOPT_TYPE_STRING  1	/* quoted/regular string */
38
-#define CLOPT_TYPE_NUMBER  2	/* raw number */
39
-#define CLOPT_TYPE_SIZE    3	/* number possibly followed by modifiers (M/m or K/k) */
40
-#define CLOPT_TYPE_BOOL    4	/* boolean */
38
+#define CLOPT_TYPE_STRING   1    /* quoted/regular string */
39
+#define CLOPT_TYPE_NUMBER   2    /* raw number */
40
+#define CLOPT_TYPE_SIZE     3    /* number possibly followed by modifiers (M/m or K/k) */
41
+#define CLOPT_TYPE_BOOL     4    /* boolean */
42
+// clang-format on
41 43
 
42 44
 struct optstruct {
43 45
     char *name;