[BACK]Return to names.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Annotation of src/usr.bin/file/names.h, Revision 1.8

1.8     ! chl         1: /*     $OpenBSD: names.h,v 1.7 2008/05/08 01:40:56 chl Exp $ */
1.1       deraadt     2: /*
1.4       ian         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.
1.1       deraadt    28:  */
1.6       tedu       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:  *
1.8     ! chl        36:  * $Id: names.h,v 1.7 2008/05/08 01:40:56 chl Exp $
1.6       tedu       37:  */
                     38:
                     39: /*
                     40:        modified by Chris Lowth - 9 April 2000
                     41:        to add mime type strings to the types table.
                     42: */
1.1       deraadt    43:
                     44: /* these types are used to index the table 'types': keep em in sync! */
1.6       tedu       45: #define        L_C     0               /* first and foremost on UNIX */
                     46: #define        L_CC    1               /* Bjarne's postincrement */
1.8     ! chl        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 */
1.1       deraadt    59:
1.6       tedu       60: static const struct {
1.8     ! chl        61:        char human[48];
        !            62:        char mime[16];
1.6       tedu       63: } types[] = {
                     64:        { "C program",                                  "text/x-c", },
                     65:        { "C++ program",                                "text/x-c++" },
                     66:        { "make commands",                              "text/x-makefile" },
                     67:        { "PL/1 program",                               "text/x-pl1" },
                     68:        { "assembler program",                          "text/x-asm" },
                     69:        { "English",                                    "text/plain" },
                     70:        { "Pascal program",                             "text/x-pascal" },
                     71:        { "mail",                                       "text/x-mail" },
                     72:        { "news",                                       "text/x-news" },
                     73:        { "Java program",                               "text/x-java" },
                     74:        { "HTML document",                              "text/html", },
                     75:        { "BCPL program",                               "text/x-bcpl" },
                     76:        { "M4 macro language pre-processor",            "text/x-m4" },
                     77:        { "PO (gettext message catalogue)",             "text/x-po" },
1.8     ! chl        78:        { "cannot happen error on names.h/types",       "error/x-error" }
1.6       tedu       79: };
1.1       deraadt    80:
1.6       tedu       81: /*
                     82:  * XXX - how should we distinguish Java from C++?
                     83:  * The trick used in a Debian snapshot, of having "extends" or "implements"
                     84:  * as tags for Java, doesn't work very well, given that those keywords
                     85:  * are often preceded by "class", which flags it as C++.
                     86:  *
                     87:  * Perhaps we need to be able to say
                     88:  *
                     89:  *     If "class" then
                     90:  *
                     91:  *             if "extends" or "implements" then
                     92:  *                     Java
                     93:  *             else
                     94:  *                     C++
                     95:  *     endif
                     96:  *
                     97:  * Or should we use other keywords, such as "package" or "import"?
                     98:  * Unfortunately, Ada95 uses "package", and Modula-3 uses "import",
                     99:  * although I infer from the language spec at
                    100:  *
                    101:  *     http://www.research.digital.com/SRC/m3defn/html/m3.html
                    102:  *
                    103:  * that Modula-3 uses "IMPORT" rather than "import", i.e. it must be
                    104:  * in all caps.
                    105:  *
                    106:  * So, for now, we go with "import".  We must put it before the C++
                    107:  * stuff, so that we don't misidentify Java as C++.  Not using "package"
                    108:  * means we won't identify stuff that defines a package but imports
                    109:  * nothing; hopefully, very little Java code imports nothing (one of the
                    110:  * reasons for doing OO programming is to import as much as possible
                    111:  * and write only what you need to, right?).
                    112:  *
                    113:  * Unfortunately, "import" may cause us to misidentify English text
                    114:  * as Java, as it comes after "the" and "The".  Perhaps we need a fancier
                    115:  * heuristic to identify Java?
                    116:  */
1.8     ! chl       117: static const struct names {
        !           118:        char name[14];
1.1       deraadt   119:        short type;
                    120: } names[] = {
                    121:        /* These must be sorted by eye for optimal hit rate */
                    122:        /* Add to this list only after substantial meditation */
1.6       tedu      123:        {"msgid",       L_PO},
                    124:        {"dnl",         L_M4},
                    125:        {"import",      L_JAVA},
                    126:        {"\"libhdr\"",  L_BCPL},
                    127:        {"\"LIBHDR\"",  L_BCPL},
1.3       millert   128:        {"//",          L_CC},
                    129:        {"template",    L_CC},
                    130:        {"virtual",     L_CC},
                    131:        {"class",       L_CC},
                    132:        {"public:",     L_CC},
                    133:        {"private:",    L_CC},
1.1       deraadt   134:        {"/*",          L_C},   /* must precede "The", "the", etc. */
                    135:        {"#include",    L_C},
                    136:        {"char",        L_C},
                    137:        {"The",         L_ENG},
                    138:        {"the",         L_ENG},
                    139:        {"double",      L_C},
                    140:        {"extern",      L_C},
                    141:        {"float",       L_C},
                    142:        {"struct",      L_C},
                    143:        {"union",       L_C},
                    144:        {"CFLAGS",      L_MAKE},
                    145:        {"LDFLAGS",     L_MAKE},
                    146:        {"all:",        L_MAKE},
                    147:        {".PRECIOUS",   L_MAKE},
                    148:        {".ascii",      L_MACH},
                    149:        {".asciiz",     L_MACH},
                    150:        {".byte",       L_MACH},
                    151:        {".even",       L_MACH},
                    152:        {".globl",      L_MACH},
                    153:        {".text",       L_MACH},
                    154:        {"clr",         L_MACH},
                    155:        {"(input,",     L_PAS},
1.7       chl       156:        {"program",     L_PAS},
                    157:        {"record",      L_PAS},
1.1       deraadt   158:        {"dcl",         L_PLI},
                    159:        {"Received:",   L_MAIL},
                    160:        {">From",       L_MAIL},
                    161:        {"Return-Path:",L_MAIL},
                    162:        {"Cc:",         L_MAIL},
                    163:        {"Newsgroups:", L_NEWS},
                    164:        {"Path:",       L_NEWS},
                    165:        {"Organization:",L_NEWS},
1.6       tedu      166:        {"href=",       L_HTML},
                    167:        {"HREF=",       L_HTML},
                    168:        {"<body",       L_HTML},
                    169:        {"<BODY",       L_HTML},
                    170:        {"<html",       L_HTML},
                    171:        {"<HTML",       L_HTML},
1.8     ! chl       172:        {"<!--",        L_HTML},
1.1       deraadt   173: };
1.8     ! chl       174: #define NNAMES (sizeof(names)/sizeof(struct names))