]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - contrib/file/magic/Magdir/c-lang
Update file(1) to new version with security update. [EN-18:02.file]
[FreeBSD/releng/10.3.git] / contrib / file / magic / Magdir / c-lang
1 #------------------------------------------------------------------------------
2 # $File: c-lang,v 1.26 2017/08/14 07:40:38 christos Exp $
3 # c-lang:  file(1) magic for C and related languages programs
4 #
5 # The strength is to beat standard HTML
6
7 # BCPL
8 0       search/8192     "libhdr"        BCPL source text
9 !:mime  text/x-bcpl
10 0       search/8192     "LIBHDR"        BCPL source text
11 !:mime  text/x-bcpl
12
13 # C
14 # Check for class if include is found, otherwise class is beaten by include becouse of lowered strength
15 0       regex   \^#include                      C
16 >0      regex   \^class[[:space:]]+
17 >>&0    regex   \\{[\.\*]\\}(;)?$                       \b++
18 >&0     clear   x                               source text
19 !:strength + 13
20 !:mime  text/x-c
21 0       regex   \^#[[:space:]]*pragma   C source text
22 !:mime  text/x-c
23 0       regex   \^#[[:space:]]*(if\|ifn)def
24 >&0     regex   \^#[[:space:]]*endif$   C source text
25 !:mime  text/x-c
26 0       regex   \^#[[:space:]]*(if\|ifn)def
27 >&0     regex   \^#[[:space:]]*define   C source text
28 !:mime  text/x-c
29 0       regex   \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$                   C source text
30 !:mime  text/x-c
31 0       regex   \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$                 C source text
32 !:mime  text/x-c
33 0       regex   \^[[:space:]]*extern[[:space:]]+                C source text
34 !:mime  text/x-c
35 0       regex   \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$                  C source text
36 !:mime  text/x-c
37 0       regex   \^struct[[:space:]]+            C source text
38 !:mime  text/x-c
39 0       regex   \^union[[:space:]]+             C source text
40 !:mime  text/x-c
41 0       search/8192     main(
42 >&0 regex       \\)[[:space:]]*\\{              C source text
43 !:mime  text/x-c
44
45 # C++
46 # The strength of these rules is increased so they beat the C rules above
47 0       regex   \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{        C++ source text
48 !:strength + 30
49 !:mime  text/x-c++
50 # using namespace [namespace] or using std::[lib]
51 0       regex   \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*;              C++ source text
52 !:strength + 30
53 !:mime  text/x-c++
54 0       regex   \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$     C++ source text
55 !:strength + 30
56 !:mime  text/x-c++
57 0       regex   \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$            C++ source text
58 !:strength + 30
59 !:mime  text/x-c++
60 # But class alone is reduced to avoid beating php (Jens Schleusener)
61 0       regex   \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$         C++ source text
62 !:strength + 13
63 !:mime  text/x-c++
64 0       regex   \^[[:space:]]*public:           C++ source text
65 !:strength + 30
66 !:mime  text/x-c++
67 0       regex   \^[[:space:]]*private:          C++ source text
68 !:strength + 30
69 !:mime  text/x-c++
70 0       regex   \^[[:space:]]*protected:                C++ source text
71 !:strength + 30
72 !:mime  text/x-c++
73
74 # Objective-C
75 0       regex   \^#import                       Objective-C source text
76 !:strength + 25
77 !:mime  text/x-objective-c
78
79 # From: Mikhail Teterin <mi@aldan.algebra.com>
80 0       string          cscope          cscope reference data
81 >7      string          x               version %.2s
82 # We skip the path here, because it is often long (so file will
83 # truncate it) and mostly redundant.
84 # The inverted index functionality was added some time between
85 # versions 11 and 15, so look for -q if version is above 14:
86 >7      string          >14
87 >>10    search/100      \ -q\           with inverted index
88 >10     search/100      \ -c\           text (non-compressed)