names.h 4.0 KB

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