file/src/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  * $Id: names.h,v 1.25 2004/09/11 19:15:57 christos 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_FORT  2               /* the oldest one */
00047 #define L_MAKE  3               /* Makefiles */
00048 #define L_PLI   4               /* PL/1 */
00049 #define L_MACH  5               /* some kinda assembler */
00050 #define L_ENG   6               /* English */
00051 #define L_PAS   7               /* Pascal */
00052 #define L_MAIL  8               /* Electronic mail */
00053 #define L_NEWS  9               /* Usenet Netnews */
00054 #define L_JAVA  10              /* Java code */
00055 #define L_HTML  11              /* HTML */
00056 #define L_BCPL  12              /* BCPL */
00057 #define L_M4    13              /* M4 */
00058 #define L_PO    14              /* PO */
00059 
00060 /*@unchecked@*/ /*@observer@*/
00061 static const struct {
00062 /*@observer@*/ /*@null@*/
00063         const char *human;
00064 /*@observer@*/ /*@null@*/
00065         const char *mime;
00066 } types[] = {
00067         { "C program",                                  "text/x-c", },
00068         { "C++ program",                                "text/x-c++" },
00069         { "FORTRAN program",                            "text/x-fortran" },
00070         { "make commands",                              "text/x-makefile" },
00071         { "PL/1 program",                               "text/x-pl1" },
00072         { "assembler program",                          "text/x-asm" },
00073         { "English",                                    "text/plain" },
00074         { "Pascal program",                             "text/x-pascal" },
00075         { "mail",                                       "text/x-mail" },
00076         { "news",                                       "text/x-news" },
00077         { "Java program",                               "text/x-java" },
00078         { "HTML document",                              "text/html", },
00079         { "BCPL program",                               "text/x-bcpl" },
00080         { "M4 macro language pre-processor",            "text/x-m4" },
00081         { "PO (gettext message catalogue)",             "text/x-po" },
00082         { "cannot happen error on names.h/types",       "error/x-error" },
00083         { 0, 0}
00084 };
00085 
00086 /*
00087  * XXX - how should we distinguish Java from C++?
00088  * The trick used in a Debian snapshot, of having "extends" or "implements"
00089  * as tags for Java, doesn't work very well, given that those keywords
00090  * are often preceded by "class", which flags it as C++.
00091  *
00092  * Perhaps we need to be able to say
00093  *
00094  *      If "class" then
00095  *
00096  *              if "extends" or "implements" then
00097  *                      Java
00098  *              else
00099  *                      C++
00100  *      endif
00101  *
00102  * Or should we use other keywords, such as "package" or "import"?
00103  * Unfortunately, Ada95 uses "package", and Modula-3 uses "import",
00104  * although I infer from the language spec at
00105  *
00106  *      http://www.research.digital.com/SRC/m3defn/html/m3.html
00107  *
00108  * that Modula-3 uses "IMPORT" rather than "import", i.e. it must be
00109  * in all caps.
00110  *
00111  * So, for now, we go with "import".  We must put it before the C++
00112  * stuff, so that we don't misidentify Java as C++.  Not using "package"
00113  * means we won't identify stuff that defines a package but imports
00114  * nothing; hopefully, very little Java code imports nothing (one of the
00115  * reasons for doing OO programming is to import as much as possible
00116  * and write only what you need to, right?).
00117  *
00118  * Unfortunately, "import" may cause us to misidentify English text
00119  * as Java, as it comes after "the" and "The".  Perhaps we need a fancier
00120  * heuristic to identify Java?
00121  */
00122 /*@unchecked@*/ /*@observer@*/
00123 static struct names {
00124 /*@observer@*/ /*@relnull@*/
00125         const char *name;
00126         short type;
00127 } names[] = {
00128         /* These must be sorted by eye for optimal hit rate */
00129         /* Add to this list only after substantial meditation */
00130         {"msgid",       L_PO},
00131         {"dnl",         L_M4},
00132         {"import",      L_JAVA},
00133         {"\"libhdr\"",  L_BCPL},
00134         {"\"LIBHDR\"",  L_BCPL},
00135         {"//",          L_CC},
00136         {"template",    L_CC},
00137         {"virtual",     L_CC},
00138         {"class",       L_CC},
00139         {"public:",     L_CC},
00140         {"private:",    L_CC},
00141         {"/*",          L_C},   /* must precede "The", "the", etc. */
00142         {"#include",    L_C},
00143         {"char",        L_C},
00144         {"The",         L_ENG},
00145         {"the",         L_ENG},
00146         {"double",      L_C},
00147         {"extern",      L_C},
00148         {"float",       L_C},
00149         {"struct",      L_C},
00150         {"union",       L_C},
00151         {"CFLAGS",      L_MAKE},
00152         {"LDFLAGS",     L_MAKE},
00153         {"all:",        L_MAKE},
00154         {".PRECIOUS",   L_MAKE},
00155 /* Too many files of text have these words in them.  Find another way
00156  * to recognize Fortrash.
00157  */
00158 #ifdef  NOTDEF
00159         {"subroutine",  L_FORT},
00160         {"function",    L_FORT},
00161         {"block",       L_FORT},
00162         {"common",      L_FORT},
00163         {"dimension",   L_FORT},
00164         {"integer",     L_FORT},
00165         {"data",        L_FORT},
00166 #endif  /*NOTDEF*/
00167         {".ascii",      L_MACH},
00168         {".asciiz",     L_MACH},
00169         {".byte",       L_MACH},
00170         {".even",       L_MACH},
00171         {".globl",      L_MACH},
00172         {".text",       L_MACH},
00173         {"clr",         L_MACH},
00174         {"(input,",     L_PAS},
00175         {"dcl",         L_PLI},
00176         {"Received:",   L_MAIL},
00177         {">From",       L_MAIL},
00178         {"Return-Path:",L_MAIL},
00179         {"Cc:",         L_MAIL},
00180         {"Newsgroups:", L_NEWS},
00181         {"Path:",       L_NEWS},
00182         {"Organization:",L_NEWS},
00183         {"href=",       L_HTML},
00184         {"HREF=",       L_HTML},
00185         {"<body",       L_HTML},
00186         {"<BODY",       L_HTML},
00187         {"<html",       L_HTML},
00188         {"<HTML",       L_HTML},
00189         {NULL,          0}
00190 };
00191 #define NNAMES ((sizeof(names)/sizeof(struct names)) - 1)

Generated on Fri Oct 12 08:44:53 2007 for rpm by  doxygen 1.5.2