Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
11 KiB

  1. /*===========================================================================
  2. nametab.h
  3. this header contains ASCII and UTF-8 tables for qualified
  4. name checking + macros for comparing multibyte UTF-8 sequences:
  5. UTF8_GET_NAMING2 and UTF8_GET_NAMING3
  6. UTF8_GET_NAMING... and UTF-8 tables are stolen from EXPAT
  7. note: DO NOT increment parameters in these macro calls i.e.
  8. ISMAPCH(whitespace, *c++) will return invalid value
  9. memory usage:
  10. namingBitmap (16x80): 1280 bytes
  11. nmstrtPages & namePages (2x8x32) 512 bytes
  12. 4 ascii tables (4x32) 128 bytes
  13. ---------------------------------------------------
  14. total 1920 bytes
  15. TODO: fix ascii tables (separate to pages to save space)
  16. see parsifal.h for copyright info
  17. ===========================================================================*/
  18. #ifndef NAMETAB__H
  19. #define NAMETAB__H
  20. #include "xmlcfg.h" /* for UINT32 */
  21. /* ascii tables generated by GENMAPS.C */
  22. static const XMLCH nameStartAscii[32] = {
  23. 0x00, 0x00, 0x00, 0x00,
  24. 0x00, 0x00, 0x00, 0x04,
  25. 0xFE, 0xFF, 0xFF, 0x87,
  26. 0xFE, 0xFF, 0xFF, 0x07,
  27. 0x00, 0x00, 0x00, 0x00,
  28. 0x00, 0x00, 0x00, 0x00,
  29. 0x00, 0x00, 0x00, 0x00,
  30. 0x00, 0x00, 0x00, 0x00
  31. }; /* ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_: */
  32. static const XMLCH nameAscii[32] = {
  33. 0x00, 0x00, 0x00, 0x00,
  34. 0x00, 0x60, 0xFF, 0x07,
  35. 0xFE, 0xFF, 0xFF, 0x87,
  36. 0xFE, 0xFF, 0xFF, 0x07,
  37. 0x00, 0x00, 0x00, 0x00,
  38. 0x00, 0x00, 0x00, 0x00,
  39. 0x00, 0x00, 0x00, 0x00,
  40. 0x00, 0x00, 0x00, 0x00
  41. }; /* ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_:0123456789.- */
  42. static const XMLCH whitespace[32] = {
  43. 0x00, 0x26, 0x00, 0x00,
  44. 0x01, 0x00, 0x00, 0x00,
  45. 0x00, 0x00, 0x00, 0x00,
  46. 0x00, 0x00, 0x00, 0x00,
  47. 0x00, 0x00, 0x00, 0x00,
  48. 0x00, 0x00, 0x00, 0x00,
  49. 0x00, 0x00, 0x00, 0x00,
  50. 0x00, 0x00, 0x00, 0x00
  51. };
  52. static const XMLCH illByte[32] = {
  53. 0xFF, 0xD9, 0xFF, 0xFF,
  54. 0x00, 0x00, 0x00, 0x00,
  55. 0x00, 0x00, 0x00, 0x00,
  56. 0x00, 0x00, 0x00, 0x00,
  57. 0x00, 0x00, 0x00, 0x00,
  58. 0x00, 0x00, 0x00, 0x00,
  59. 0x00, 0x00, 0x00, 0x00,
  60. 0x00, 0x00, 0x00, 0x00
  61. }; /* from \0x0 to \0x1f excluding whitespace chars 0x9, 0xA, 0xD */
  62. #define utf8_isName2(c) (UTF8_GET_NAMING2(namePages, (c)))
  63. #define utf8_isName3(c) (UTF8_GET_NAMING3(namePages, (c)))
  64. #define utf8_isNmstrt2(c) (UTF8_GET_NAMING2(nmstrtPages, (c)))
  65. #define utf8_isNmstrt3(c) (UTF8_GET_NAMING3(nmstrtPages, (c)))
  66. /* the rest is stolen from EXPAT: */
  67. /* A 2 byte UTF-8 representation splits the characters 11 bits
  68. between the bottom 5 and 6 bits of the bytes.
  69. We need 8 bits to index into pages, 3 bits to add to that index and
  70. 5 bits to generate the mask. */
  71. #define UTF8_GET_NAMING2(pages, byte) \
  72. (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
  73. + ((((byte)[0]) & 3) << 1) \
  74. + ((((byte)[1]) >> 5) & 1)] \
  75. & (1 << (((byte)[1]) & 0x1F)))
  76. /* A 3 byte UTF-8 representation splits the characters 16 bits
  77. between the bottom 4, 6 and 6 bits of the bytes.
  78. We need 8 bits to index into pages, 3 bits to add to that index and
  79. 5 bits to generate the mask. */
  80. #define UTF8_GET_NAMING3(pages, byte) \
  81. (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \
  82. + ((((byte)[1]) >> 2) & 0xF)] \
  83. << 3) \
  84. + ((((byte)[1]) & 3) << 1) \
  85. + ((((byte)[2]) >> 5) & 1)] \
  86. & (1 << (((byte)[2]) & 0x1F)))
  87. static const UINT32 namingBitmap[] = {
  88. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  89. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  90. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  91. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  92. 0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
  93. 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
  94. 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
  95. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
  96. 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
  97. 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
  98. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  99. 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
  100. 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
  101. 0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
  102. 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
  103. 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
  104. 0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
  105. 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
  106. 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
  107. 0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
  108. 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
  109. 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
  110. 0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
  111. 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
  112. 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
  113. 0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
  114. 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
  115. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  116. 0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
  117. 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
  118. 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
  119. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  120. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  121. 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
  122. 0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
  123. 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
  124. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  125. 0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
  126. 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
  127. 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
  128. 0x00000000, 0x00004C40, 0x00000000, 0x00000000,
  129. 0x00000007, 0x00000000, 0x00000000, 0x00000000,
  130. 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
  131. 0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
  132. 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
  133. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  134. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  135. 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
  136. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  137. 0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
  138. 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
  139. 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
  140. 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
  141. 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
  142. 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
  143. 0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
  144. 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
  145. 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
  146. 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
  147. 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
  148. 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
  149. 0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
  150. 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
  151. 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
  152. 0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
  153. 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
  154. 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
  155. 0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
  156. 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
  157. 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
  158. 0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
  159. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  160. 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
  161. 0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
  162. 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
  163. 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
  164. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  165. 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
  166. 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
  167. 0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
  168. };
  169. static const unsigned char nmstrtPages[] = {
  170. 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
  171. 0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  172. 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  173. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
  174. 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  175. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  176. 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  177. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  178. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  179. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
  180. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  181. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  182. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  183. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  184. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  185. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  186. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  187. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  188. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  189. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
  190. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  191. 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
  192. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  193. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  194. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  195. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  196. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
  197. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  198. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  199. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  200. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  201. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  202. };
  203. static const unsigned char namePages[] = {
  204. 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
  205. 0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
  206. 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  207. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
  208. 0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  209. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  210. 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  211. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  212. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  213. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
  214. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  215. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  216. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  217. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  218. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  219. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  220. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  221. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  222. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  223. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
  224. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  225. 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
  226. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  227. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  228. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  229. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  230. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
  231. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  232. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  233. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  234. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  235. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  236. };
  237. #endif /* NAMETAB__H */