Merge from vendor branch NTPD:
[dragonfly.git] / contrib / file / names.h
1 /*
2  * Names.h - names and types used by ascmagic in file(1).
3  * These tokens are here because they can appear anywhere in
4  * the first HOWMANY bytes, while tokens in MAGIC must
5  * appear at fixed offsets into the file. Don't make HOWMANY
6  * too high unless you have a very fast CPU.
7  *
8  * Copyright (c) Ian F. Darwin, 1987.
9  * Written by Ian F. Darwin.
10  *
11  * See LEGAL.NOTICE
12  *
13  * $Id: names.h,v 1.19 2002/05/16 15:01:41 christos Exp $
14  */
15
16 /*
17         modified by Chris Lowth - 9 April 2000
18         to add mime type strings to the types table.
19 */
20
21 /* these types are used to index the table 'types': keep em in sync! */
22 #define L_C     0               /* first and foremost on UNIX */
23 #define L_CC    1               /* Bjarne's postincrement */
24 #define L_FORT  2               /* the oldest one */
25 #define L_MAKE  3               /* Makefiles */
26 #define L_PLI   4               /* PL/1 */
27 #define L_MACH  5               /* some kinda assembler */
28 #define L_ENG   6               /* English */
29 #define L_PAS   7               /* Pascal */
30 #define L_MAIL  8               /* Electronic mail */
31 #define L_NEWS  9               /* Usenet Netnews */
32 #define L_JAVA  10              /* Java code */
33 #define L_HTML  11              /* HTML */
34 #define L_BCPL  12              /* BCPL */
35 #define L_M4    13              /* M4 */
36
37 static const struct {
38         char *human;
39         char *mime;
40 } types[] = {
41         { "C program",                                  "text/x-c", },
42         { "C++ program",                                "text/x-c++" },
43         { "FORTRAN program",                            "text/x-fortran" },
44         { "make commands",                              "text/x-makefile" },
45         { "PL/1 program",                               "text/x-pl1" },
46         { "assembler program",                          "text/x-asm" },
47         { "English",                                    "text/plain, English" },
48         { "Pascal program",                             "text/x-pascal" },
49         { "mail",                                       "text/x-mail" },
50         { "news",                                       "text/x-news" },
51         { "Java program",                               "text/x-java" },
52         { "HTML document",                              "text/html", },
53         { "BCPL program",                               "text/x-bcpl" },
54         { "M4 macro language pre-processor",            "text/x-m4" },
55         { "can't happen error on names.h/types",        "error/x-error" },
56         { 0, 0}
57 };
58
59 /*
60  * XXX - how should we distinguish Java from C++?
61  * The trick used in a Debian snapshot, of having "extends" or "implements"
62  * as tags for Java, doesn't work very well, given that those keywords
63  * are often preceded by "class", which flags it as C++.
64  *
65  * Perhaps we need to be able to say
66  *
67  *      If "class" then
68  *
69  *              if "extends" or "implements" then
70  *                      Java
71  *              else
72  *                      C++
73  *      endif
74  *
75  * Or should we use other keywords, such as "package" or "import"?
76  * Unfortunately, Ada95 uses "package", and Modula-3 uses "import",
77  * although I infer from the language spec at
78  *
79  *      http://www.research.digital.com/SRC/m3defn/html/m3.html
80  *
81  * that Modula-3 uses "IMPORT" rather than "import", i.e. it must be
82  * in all caps.
83  *
84  * So, for now, we go with "import".  We must put it before the C++
85  * stuff, so that we don't misidentify Java as C++.  Not using "package"
86  * means we won't identify stuff that defines a package but imports
87  * nothing; hopefully, very little Java code imports nothing (one of the
88  * reasons for doing OO programming is to import as much as possible
89  * and write only what you need to, right?).
90  *
91  * Unfortunately, "import" may cause us to misidentify English text
92  * as Java, as it comes after "the" and "The".  Perhaps we need a fancier
93  * heuristic to identify Java?
94  */
95 static struct names {
96         const char *name;
97         short type;
98 } names[] = {
99         /* These must be sorted by eye for optimal hit rate */
100         /* Add to this list only after substantial meditation */
101         {"dnl",         L_M4},
102         {"import",      L_JAVA},
103         {"\"libhdr\"",  L_BCPL},
104         {"\"LIBHDR\"",  L_BCPL},
105         {"//",          L_CC},
106         {"template",    L_CC},
107         {"virtual",     L_CC},
108         {"class",       L_CC},
109         {"public:",     L_CC},
110         {"private:",    L_CC},
111         {"/*",          L_C},   /* must precede "The", "the", etc. */
112         {"#include",    L_C},
113         {"char",        L_C},
114         {"The",         L_ENG},
115         {"the",         L_ENG},
116         {"double",      L_C},
117         {"extern",      L_C},
118         {"float",       L_C},
119         {"struct",      L_C},
120         {"union",       L_C},
121         {"CFLAGS",      L_MAKE},
122         {"LDFLAGS",     L_MAKE},
123         {"all:",        L_MAKE},
124         {".PRECIOUS",   L_MAKE},
125 /* Too many files of text have these words in them.  Find another way
126  * to recognize Fortrash.
127  */
128 #ifdef  NOTDEF
129         {"subroutine",  L_FORT},
130         {"function",    L_FORT},
131         {"block",       L_FORT},
132         {"common",      L_FORT},
133         {"dimension",   L_FORT},
134         {"integer",     L_FORT},
135         {"data",        L_FORT},
136 #endif  /*NOTDEF*/
137         {".ascii",      L_MACH},
138         {".asciiz",     L_MACH},
139         {".byte",       L_MACH},
140         {".even",       L_MACH},
141         {".globl",      L_MACH},
142         {".text",       L_MACH},
143         {"clr",         L_MACH},
144         {"(input,",     L_PAS},
145         {"dcl",         L_PLI},
146         {"Received:",   L_MAIL},
147         {">From",       L_MAIL},
148         {"Return-Path:",L_MAIL},
149         {"Cc:",         L_MAIL},
150         {"Newsgroups:", L_NEWS},
151         {"Path:",       L_NEWS},
152         {"Organization:",L_NEWS},
153         {"href=",       L_HTML},
154         {"HREF=",       L_HTML},
155         {"<body",       L_HTML},
156         {"<BODY",       L_HTML},
157         {NULL,          0}
158 };
159 #define NNAMES ((sizeof(names)/sizeof(struct names)) - 1)