names.h 4.5 KB

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