Rizin
unix-like reverse engineering framework and cli tools
names.h
Go to the documentation of this file.
1 /* $OpenBSD: names.h,v 1.8 2009/04/24 18:54:34 chl Exp $ */
2 /*
3  * Copyright (c) Ian F. Darwin 1986-1995.
4  * Software written by Ian F. Darwin and others;
5  * maintained 1995-present by Christos Zoulas and others.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice immediately at the beginning of the file, without modification,
12  * this list of conditions, and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 /*
30  * Names.h - names and types used by ascmagic in file(1).
31  * These tokens are here because they can appear anywhere in
32  * the first HOWMANY bytes, while tokens in MAGIC must
33  * appear at fixed offsets into the file. Don't make HOWMANY
34  * too high unless you have a very fast CPU.
35  *
36  * $Id: names.h,v 1.8 2009/04/24 18:54:34 chl Exp $
37  */
38 
39 /*
40  modified by Chris Lowth - 9 April 2000
41  to add mime type strings to the types table.
42 */
43 
44 /* these types are used to index the table 'types': keep em in sync! */
45 #define L_C 0 /* first and foremost on UNIX */
46 #define L_CC 1 /* Bjarne's postincrement */
47 #define L_MAKE 2 /* Makefiles */
48 #define L_PLI 3 /* PL/1 */
49 #define L_MACH 4 /* some kinda assembler */
50 #define L_ENG 5 /* English */
51 #define L_PAS 6 /* Pascal */
52 #define L_MAIL 7 /* Electronic mail */
53 #define L_NEWS 8 /* Usenet Netnews */
54 #define L_JAVA 9 /* Java code */
55 #define L_HTML 10 /* HTML */
56 #define L_BCPL 11 /* BCPL */
57 #define L_M4 12 /* M4 */
58 #define L_PO 13 /* PO */
59 
60 static const struct {
61  char human[48];
62  char mime[16];
63 } types[] = {
64  {
65  "C program",
66  "text/x-c",
67  },
68  { "C++ program", "text/x-c++" },
69  { "make commands", "text/x-makefile" },
70  { "PL/1 program", "text/x-pl1" },
71  { "assembler program", "text/x-asm" },
72  { "English", "text/plain" },
73  { "Pascal program", "text/x-pascal" },
74  { "mail", "text/x-mail" },
75  { "news", "text/x-news" },
76  { "Java program", "text/x-java" },
77  {
78  "HTML document",
79  "text/html",
80  },
81  { "BCPL program", "text/x-bcpl" },
82  { "M4 macro language pre-processor", "text/x-m4" },
83  { "PO (gettext message catalogue)", "text/x-po" },
84  { "cannot happen error on names.h/types", "error/x-error" }
85 };
86 
87 /*
88  * XXX - how should we distinguish Java from C++?
89  * The trick used in a Debian snapshot, of having "extends" or "implements"
90  * as tags for Java, doesn't work very well, given that those keywords
91  * are often preceded by "class", which flags it as C++.
92  *
93  * Perhaps we need to be able to say
94  *
95  * If "class" then
96  *
97  * if "extends" or "implements" then
98  * Java
99  * else
100  * C++
101  * endif
102  *
103  * Or should we use other keywords, such as "package" or "import"?
104  * Unfortunately, Ada95 uses "package", and Modula-3 uses "import",
105  * although I infer from the language spec at
106  *
107  * http://www.research.digital.com/SRC/m3defn/html/m3.html
108  *
109  * that Modula-3 uses "IMPORT" rather than "import", i.e. it must be
110  * in all caps.
111  *
112  * So, for now, we go with "import". We must put it before the C++
113  * stuff, so that we don't misidentify Java as C++. Not using "package"
114  * means we won't identify stuff that defines a package but imports
115  * nothing; hopefully, very little Java code imports nothing (one of the
116  * reasons for doing OO programming is to import as much as possible
117  * and write only what you need to, right?).
118  *
119  * Unfortunately, "import" may cause us to misidentify English text
120  * as Java, as it comes after "the" and "The". Perhaps we need a fancier
121  * heuristic to identify Java?
122  */
123 static const struct names {
124  char name[14];
125  short type;
126 } names[] = {
127  /* These must be sorted by eye for optimal hit rate */
128  /* Add to this list only after substantial meditation */
129  { "msgid", L_PO },
130  { "dnl", L_M4 },
131  { "import", L_JAVA },
132  { "\"libhdr\"", L_BCPL },
133  { "\"LIBHDR\"", L_BCPL },
134  { "//", L_CC },
135  { "template", L_CC },
136  { "virtual", L_CC },
137  { "class", L_CC },
138  { "public:", L_CC },
139  { "private:", L_CC },
140  { "/*", L_C }, /* must precede "The", "the", etc. */
141  { "#include", L_C },
142  { "char", L_C },
143  { "The", L_ENG },
144  { "the", L_ENG },
145  { "double", L_C },
146  { "extern", L_C },
147  { "float", L_C },
148  { "struct", L_C },
149  { "union", L_C },
150  { "CFLAGS", L_MAKE },
151  { "LDFLAGS", L_MAKE },
152  { "all:", L_MAKE },
153  { ".PRECIOUS", L_MAKE },
154  { ".ascii", L_MACH },
155  { ".asciiz", L_MACH },
156  { ".byte", L_MACH },
157  { ".even", L_MACH },
158  { ".globl", L_MACH },
159  { ".text", L_MACH },
160  { "clr", L_MACH },
161  { "(input,", L_PAS },
162  { "program", L_PAS },
163  { "record", L_PAS },
164  { "dcl", L_PLI },
165  { "Received:", L_MAIL },
166  { ">From", L_MAIL },
167  { "Return-Path:", L_MAIL },
168  { "Cc:", L_MAIL },
169  { "Newsgroups:", L_NEWS },
170  { "Path:", L_NEWS },
171  { "Organization:", L_NEWS },
172  { "href=", L_HTML },
173  { "HREF=", L_HTML },
174  { "<body", L_HTML },
175  { "<BODY", L_HTML },
176  { "<html", L_HTML },
177  { "<HTML", L_HTML },
178  { "<!--", L_HTML },
179 };
180 #define NNAMES (sizeof(names) / sizeof(struct names))
#define L_NEWS
Definition: names.h:53
#define L_C
Definition: names.h:45
#define L_JAVA
Definition: names.h:54
#define L_PAS
Definition: names.h:51
#define L_MACH
Definition: names.h:49
#define L_MAIL
Definition: names.h:52
char mime[16]
Definition: names.h:62
#define L_CC
Definition: names.h:46
#define L_ENG
Definition: names.h:50
#define L_BCPL
Definition: names.h:56
#define L_PO
Definition: names.h:58
char human[48]
Definition: names.h:61
#define L_MAKE
Definition: names.h:47
#define L_M4
Definition: names.h:57
#define L_PLI
Definition: names.h:48
static const struct @326 types[]
#define L_HTML
Definition: names.h:55
Definition: z80asm.h:102
Definition: names.h:123
short type
Definition: names.h:125