Back to index

php5  5.3.10
names.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Ian F. Darwin 1986-1995.
00003  * Software written by Ian F. Darwin and others;
00004  * maintained 1995-present by Christos Zoulas and others.
00005  * 
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice immediately at the beginning of the file, without modification,
00011  *    this list of conditions, and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  *  
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00017  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
00020  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00022  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00023  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00024  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00025  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00026  * SUCH DAMAGE.
00027  */
00028 /*
00029  * Names.h - names and types used by ascmagic in file(1).
00030  * These tokens are here because they can appear anywhere in
00031  * the first HOWMANY bytes, while tokens in MAGIC must
00032  * appear at fixed offsets into the file. Don't make HOWMANY
00033  * too high unless you have a very fast CPU.
00034  *
00035  * $File: names.h,v 1.32 2008/02/11 00:19:29 rrt Exp $
00036  */
00037 
00038 /*
00039        modified by Chris Lowth - 9 April 2000
00040        to add mime type strings to the types table.
00041 */
00042 
00043 /* these types are used to index the table 'types': keep em in sync! */
00044 #define       L_C    0             /* first and foremost on UNIX */
00045 #define       L_CC   1             /* Bjarne's postincrement */
00046 #define       L_MAKE 2             /* Makefiles */
00047 #define       L_PLI  3             /* PL/1 */
00048 #define       L_MACH 4             /* some kinda assembler */
00049 #define       L_ENG  5             /* English */
00050 #define       L_PAS  6             /* Pascal */
00051 #define       L_MAIL 7             /* Electronic mail */
00052 #define       L_NEWS 8             /* Usenet Netnews */
00053 #define       L_JAVA 9             /* Java code */
00054 #define       L_HTML 10            /* HTML */
00055 #define       L_BCPL 11            /* BCPL */
00056 #define       L_M4   12            /* M4 */
00057 #define       L_PO   13            /* PO */
00058 
00059 static const struct {
00060        char human[48];
00061        char mime[16];
00062 } types[] = {
00063        { "C program",                                   "text/x-c", },
00064        { "C++ program",                          "text/x-c++" },
00065        { "make commands",                        "text/x-makefile" },
00066        { "PL/1 program",                         "text/x-pl1" },
00067        { "assembler program",                           "text/x-asm" },
00068        { "English",                              "text/plain" },
00069        { "Pascal program",                       "text/x-pascal" },
00070        { "mail",                                 "text/x-mail" },
00071        { "news",                                 "text/x-news" },
00072        { "Java program",                         "text/x-java" },
00073        { "HTML document",                        "text/html", },
00074        { "BCPL program",                         "text/x-bcpl" },
00075        { "M4 macro language pre-processor",             "text/x-m4" },
00076        { "PO (gettext message catalogue)",             "text/x-po" },
00077        { "cannot happen error on names.h/types", "error/x-error" }
00078 };
00079 
00080 /*
00081  * XXX - how should we distinguish Java from C++?
00082  * The trick used in a Debian snapshot, of having "extends" or "implements"
00083  * as tags for Java, doesn't work very well, given that those keywords
00084  * are often preceded by "class", which flags it as C++.
00085  *
00086  * Perhaps we need to be able to say
00087  *
00088  *     If "class" then
00089  *
00090  *            if "extends" or "implements" then
00091  *                   Java
00092  *            else
00093  *                   C++
00094  *     endif
00095  *
00096  * Or should we use other keywords, such as "package" or "import"?
00097  * Unfortunately, Ada95 uses "package", and Modula-3 uses "import",
00098  * although I infer from the language spec at
00099  *
00100  *     http://www.research.digital.com/SRC/m3defn/html/m3.html
00101  *
00102  * that Modula-3 uses "IMPORT" rather than "import", i.e. it must be
00103  * in all caps.
00104  *
00105  * So, for now, we go with "import".  We must put it before the C++
00106  * stuff, so that we don't misidentify Java as C++.  Not using "package"
00107  * means we won't identify stuff that defines a package but imports
00108  * nothing; hopefully, very little Java code imports nothing (one of the
00109  * reasons for doing OO programming is to import as much as possible
00110  * and write only what you need to, right?).
00111  *
00112  * Unfortunately, "import" may cause us to misidentify English text
00113  * as Java, as it comes after "the" and "The".  Perhaps we need a fancier
00114  * heuristic to identify Java?
00115  */
00116 static const struct names {
00117        char name[14];
00118        short type;
00119 } names[] = {
00120        /* These must be sorted by eye for optimal hit rate */
00121        /* Add to this list only after substantial meditation */
00122        {"msgid",     L_PO},
00123        {"dnl",              L_M4},
00124        {"import",    L_JAVA},
00125        {"\"libhdr\"",       L_BCPL},
00126        {"\"LIBHDR\"",       L_BCPL},
00127        {"//",        L_CC},
00128        {"template",  L_CC},
00129        {"virtual",   L_CC},
00130        {"class",     L_CC},
00131        {"public:",   L_CC},
00132        {"private:",  L_CC},
00133        {"/*",        L_C},  /* must precede "The", "the", etc. */
00134        {"#include",  L_C},
00135        {"char",      L_C},
00136        {"The",              L_ENG},
00137        {"the",              L_ENG},
00138        {"double",    L_C},
00139        {"extern",    L_C},
00140        {"float",     L_C},
00141        {"struct",    L_C},
00142        {"union",     L_C},
00143        {"CFLAGS",    L_MAKE},
00144        {"LDFLAGS",   L_MAKE},
00145        {"all:",      L_MAKE},
00146        {".PRECIOUS", L_MAKE},
00147        {".ascii",    L_MACH},
00148        {".asciiz",   L_MACH},
00149        {".byte",     L_MACH},
00150        {".even",     L_MACH},
00151        {".globl",    L_MACH},
00152        {".text",     L_MACH},
00153        {"clr",              L_MACH},
00154        {"(input,",   L_PAS},
00155        {"program",   L_PAS},
00156        {"record",    L_PAS},
00157        {"dcl",              L_PLI},
00158        {"Received:", L_MAIL},
00159        {">From",     L_MAIL},
00160        {"Return-Path:",L_MAIL},
00161        {"Cc:",              L_MAIL},
00162        {"Newsgroups:",      L_NEWS},
00163        {"Path:",     L_NEWS},
00164        {"Organization:",L_NEWS},
00165        {"href=",     L_HTML},
00166        {"HREF=",     L_HTML},
00167        {"<body",     L_HTML},
00168        {"<BODY",     L_HTML},
00169        {"<html",     L_HTML},
00170        {"<HTML",     L_HTML},
00171        {"<!--",      L_HTML},
00172 };
00173 #define NNAMES (sizeof(names)/sizeof(struct names))