nls_euc-jp.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. /*
  2. * linux/fs/nls/nls_euc-jp.c
  3. *
  4. * Added `OSF/JVC Recommended Code Set Conversion Specification
  5. * between Japanese EUC and Shift-JIS' support: <hirofumi@mail.parknet.co.jp>
  6. * (http://www.opengroup.or.jp/jvc/cde/sjis-euc-e.html)
  7. */
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/string.h>
  11. #include <linux/nls.h>
  12. #include <linux/errno.h>
  13. static struct nls_table *p_nls;
  14. #define IS_SJIS_LOW_BYTE(l) ((0x40 <= (l)) && ((l) <= 0xFC) && ((l) != 0x7F))
  15. /* JIS X 0208 (include NEC spesial characters) */
  16. #define IS_SJIS_JISX0208(h, l) ((((0x81 <= (h)) && ((h) <= 0x9F)) \
  17. || ((0xE0 <= (h)) && ((h) <= 0xEA))) \
  18. && IS_SJIS_LOW_BYTE(l))
  19. #define IS_SJIS_JISX0201KANA(c) ((0xA1 <= (c)) && ((c) <= 0xDF))
  20. #define IS_SJIS_UDC_LOW(h, l) (((0xF0 <= (h)) && ((h) <= 0xF4)) \
  21. && IS_SJIS_LOW_BYTE(l))
  22. #define IS_SJIS_UDC_HI(h, l) (((0xF5 <= (h)) && ((h) <= 0xF9)) \
  23. && IS_SJIS_LOW_BYTE(l))
  24. #define IS_SJIS_IBM(h, l) (((0xFA <= (h)) && ((h) <= 0xFC)) \
  25. && IS_SJIS_LOW_BYTE(l))
  26. #define IS_SJIS_NECIBM(h, l) (((0xED <= (h)) && ((h) <= 0xEE)) \
  27. && IS_SJIS_LOW_BYTE(l))
  28. #define MAP_SJIS2EUC(sjis_hi, sjis_lo, sjis_p, euc_hi, euc_lo, euc_p) { \
  29. if ((sjis_lo) >= 0x9F) { \
  30. (euc_hi) = (sjis_hi) * 2 - (((sjis_p) * 2 - (euc_p)) - 1); \
  31. (euc_lo) = (sjis_lo) + 2; \
  32. } else { \
  33. (euc_hi) = (sjis_hi) * 2 - ((sjis_p) * 2 - (euc_p)); \
  34. (euc_lo) = (sjis_lo) + ((sjis_lo) >= 0x7F ? 0x60 : 0x61); \
  35. } \
  36. } while(0)
  37. #define SS2 (0x8E) /* Single Shift 2 */
  38. #define SS3 (0x8F) /* Single Shift 3 */
  39. #define IS_EUC_BYTE(c) ((0xA1 <= (c)) && ((c) <= 0xFE))
  40. #define IS_EUC_JISX0208(h, l) (IS_EUC_BYTE(h) && IS_EUC_BYTE(l))
  41. #define IS_EUC_JISX0201KANA(h, l) (((h) == SS2) && (0xA1 <= (l) && (l) <= 0xDF))
  42. #define IS_EUC_UDC_LOW(h, l) (((0xF5 <= (h)) && ((h) <= 0xFE)) \
  43. && IS_EUC_BYTE(l))
  44. #define IS_EUC_UDC_HI(h, l) IS_EUC_UDC_LOW(h, l) /* G3 block */
  45. #define MAP_EUC2SJIS(euc_hi, euc_lo, euc_p, sjis_hi, sjis_lo, sjis_p) { \
  46. if ((euc_hi) & 1) { \
  47. (sjis_hi) = (euc_hi) / 2 + ((sjis_p) - (euc_p) / 2); \
  48. (sjis_lo) = (euc_lo) - ((euc_lo) >= 0xE0 ? 0x60 : 0x61); \
  49. } else { \
  50. (sjis_hi) = (euc_hi) / 2 + (((sjis_p) - (euc_p) / 2) - 1); \
  51. (sjis_lo) = (euc_lo) - 2; \
  52. } \
  53. } while(0)
  54. /* SJIS IBM extended characters to EUC map */
  55. static const unsigned char sjisibm2euc_map[][2] = {
  56. {0xF3, 0xF3}, {0xF3, 0xF4}, {0xF3, 0xF5}, {0xF3, 0xF6}, {0xF3, 0xF7},
  57. {0xF3, 0xF8}, {0xF3, 0xF9}, {0xF3, 0xFA}, {0xF3, 0xFB}, {0xF3, 0xFC},
  58. {0xF3, 0xFD}, {0xF3, 0xFE}, {0xF4, 0xA1}, {0xF4, 0xA2}, {0xF4, 0xA3},
  59. {0xF4, 0xA4}, {0xF4, 0xA5}, {0xF4, 0xA6}, {0xF4, 0xA7}, {0xF4, 0xA8},
  60. {0xA2, 0xCC}, {0xA2, 0xC3}, {0xF4, 0xA9}, {0xF4, 0xAA}, {0xF4, 0xAB},
  61. {0xF4, 0xAC}, {0xF4, 0xAD}, {0xA2, 0xE8}, {0xD4, 0xE3}, {0xDC, 0xDF},
  62. {0xE4, 0xE9}, {0xE3, 0xF8}, {0xD9, 0xA1}, {0xB1, 0xBB}, {0xF4, 0xAE},
  63. {0xC2, 0xAD}, {0xC3, 0xFC}, {0xE4, 0xD0}, {0xC2, 0xBF}, {0xBC, 0xF4},
  64. {0xB0, 0xA9}, {0xB0, 0xC8}, {0xF4, 0xAF}, {0xB0, 0xD2}, {0xB0, 0xD4},
  65. {0xB0, 0xE3}, {0xB0, 0xEE}, {0xB1, 0xA7}, {0xB1, 0xA3}, {0xB1, 0xAC},
  66. {0xB1, 0xA9}, {0xB1, 0xBE}, {0xB1, 0xDF}, {0xB1, 0xD8}, {0xB1, 0xC8},
  67. {0xB1, 0xD7}, {0xB1, 0xE3}, {0xB1, 0xF4}, {0xB1, 0xE1}, {0xB2, 0xA3},
  68. {0xF4, 0xB0}, {0xB2, 0xBB}, {0xB2, 0xE6}, {0x00, 0x00}, {0xB2, 0xED},
  69. {0xB2, 0xF5}, {0xB2, 0xFC}, {0xF4, 0xB1}, {0xB3, 0xB5}, {0xB3, 0xD8},
  70. {0xB3, 0xDB}, {0xB3, 0xE5}, {0xB3, 0xEE}, {0xB3, 0xFB}, {0xF4, 0xB2},
  71. {0xF4, 0xB3}, {0xB4, 0xC0}, {0xB4, 0xC7}, {0xB4, 0xD0}, {0xB4, 0xDE},
  72. {0xF4, 0xB4}, {0xB5, 0xAA}, {0xF4, 0xB5}, {0xB5, 0xAF}, {0xB5, 0xC4},
  73. {0xB5, 0xE8}, {0xF4, 0xB6}, {0xB7, 0xC2}, {0xB7, 0xE4}, {0xB7, 0xE8},
  74. {0xB7, 0xE7}, {0xF4, 0xB7}, {0xF4, 0xB8}, {0xF4, 0xB9}, {0xB8, 0xCE},
  75. {0xB8, 0xE1}, {0xB8, 0xF5}, {0xB8, 0xF7}, {0xB8, 0xF8}, {0xB8, 0xFC},
  76. {0xB9, 0xAF}, {0xB9, 0xB7}, {0xBA, 0xBE}, {0xBA, 0xDB}, {0xCD, 0xAA},
  77. {0xBA, 0xE1}, {0xF4, 0xBA}, {0xBA, 0xEB}, {0xBB, 0xB3}, {0xBB, 0xB8},
  78. {0xF4, 0xBB}, {0xBB, 0xCA}, {0xF4, 0xBC}, {0xF4, 0xBD}, {0xBB, 0xD0},
  79. {0xBB, 0xDE}, {0xBB, 0xF4}, {0xBB, 0xF5}, {0xBB, 0xF9}, {0xBC, 0xE4},
  80. {0xBC, 0xED}, {0xBC, 0xFE}, {0xF4, 0xBE}, {0xBD, 0xC2}, {0xBD, 0xE7},
  81. {0xF4, 0xBF}, {0xBD, 0xF0}, {0xBE, 0xB0}, {0xBE, 0xAC}, {0xF4, 0xC0},
  82. {0xBE, 0xB3}, {0xBE, 0xBD}, {0xBE, 0xCD}, {0xBE, 0xC9}, {0xBE, 0xE4},
  83. {0xBF, 0xA8}, {0xBF, 0xC9}, {0xC0, 0xC4}, {0xC0, 0xE4}, {0xC0, 0xF4},
  84. {0xC1, 0xA6}, {0xF4, 0xC1}, {0xC1, 0xF5}, {0xC1, 0xFC}, {0xF4, 0xC2},
  85. {0xC1, 0xF8}, {0xC2, 0xAB}, {0xC2, 0xA1}, {0xC2, 0xA5}, {0xF4, 0xC3},
  86. {0xC2, 0xB8}, {0xC2, 0xBA}, {0xF4, 0xC4}, {0xC2, 0xC4}, {0xC2, 0xD2},
  87. {0xC2, 0xD7}, {0xC2, 0xDB}, {0xC2, 0xDE}, {0xC2, 0xED}, {0xC2, 0xF0},
  88. {0xF4, 0xC5}, {0xC3, 0xA1}, {0xC3, 0xB5}, {0xC3, 0xC9}, {0xC3, 0xB9},
  89. {0xF4, 0xC6}, {0xC3, 0xD8}, {0xC3, 0xFE}, {0xF4, 0xC7}, {0xC4, 0xCC},
  90. {0xF4, 0xC8}, {0xC4, 0xD9}, {0xC4, 0xEA}, {0xC4, 0xFD}, {0xF4, 0xC9},
  91. {0xC5, 0xA7}, {0xC5, 0xB5}, {0xC5, 0xB6}, {0xF4, 0xCA}, {0xC5, 0xD5},
  92. {0xC6, 0xB8}, {0xC6, 0xD7}, {0xC6, 0xE0}, {0xC6, 0xEA}, {0xC6, 0xE3},
  93. {0xC7, 0xA1}, {0xC7, 0xAB}, {0xC7, 0xC7}, {0xC7, 0xC3}, {0xC7, 0xCB},
  94. {0xC7, 0xCF}, {0xC7, 0xD9}, {0xF4, 0xCB}, {0xF4, 0xCC}, {0xC7, 0xE6},
  95. {0xC7, 0xEE}, {0xC7, 0xFC}, {0xC7, 0xEB}, {0xC7, 0xF0}, {0xC8, 0xB1},
  96. {0xC8, 0xE5}, {0xC8, 0xF8}, {0xC9, 0xA6}, {0xC9, 0xAB}, {0xC9, 0xAD},
  97. {0xF4, 0xCD}, {0xC9, 0xCA}, {0xC9, 0xD3}, {0xC9, 0xE9}, {0xC9, 0xE3},
  98. {0xC9, 0xFC}, {0xC9, 0xF4}, {0xC9, 0xF5}, {0xF4, 0xCE}, {0xCA, 0xB3},
  99. {0xCA, 0xBD}, {0xCA, 0xEF}, {0xCA, 0xF1}, {0xCB, 0xAE}, {0xF4, 0xCF},
  100. {0xCB, 0xCA}, {0xCB, 0xE6}, {0xCB, 0xEA}, {0xCB, 0xF0}, {0xCB, 0xF4},
  101. {0xCB, 0xEE}, {0xCC, 0xA5}, {0xCB, 0xF9}, {0xCC, 0xAB}, {0xCC, 0xAE},
  102. {0xCC, 0xAD}, {0xCC, 0xB2}, {0xCC, 0xC2}, {0xCC, 0xD0}, {0xCC, 0xD9},
  103. {0xF4, 0xD0}, {0xCD, 0xBB}, {0xF4, 0xD1}, {0xCE, 0xBB}, {0xF4, 0xD2},
  104. {0xCE, 0xBA}, {0xCE, 0xC3}, {0xF4, 0xD3}, {0xCE, 0xF2}, {0xB3, 0xDD},
  105. {0xCF, 0xD5}, {0xCF, 0xE2}, {0xCF, 0xE9}, {0xCF, 0xED}, {0xF4, 0xD4},
  106. {0xF4, 0xD5}, {0xF4, 0xD6}, {0x00, 0x00}, {0xF4, 0xD7}, {0xD0, 0xE5},
  107. {0xF4, 0xD8}, {0xD0, 0xE9}, {0xD1, 0xE8}, {0xF4, 0xD9}, {0xF4, 0xDA},
  108. {0xD1, 0xEC}, {0xD2, 0xBB}, {0xF4, 0xDB}, {0xD3, 0xE1}, {0xD3, 0xE8},
  109. {0xD4, 0xA7}, {0xF4, 0xDC}, {0xF4, 0xDD}, {0xD4, 0xD4}, {0xD4, 0xF2},
  110. {0xD5, 0xAE}, {0xF4, 0xDE}, {0xD7, 0xDE}, {0xF4, 0xDF}, {0xD8, 0xA2},
  111. {0xD8, 0xB7}, {0xD8, 0xC1}, {0xD8, 0xD1}, {0xD8, 0xF4}, {0xD9, 0xC6},
  112. {0xD9, 0xC8}, {0xD9, 0xD1}, {0xF4, 0xE0}, {0xF4, 0xE1}, {0xF4, 0xE2},
  113. {0xF4, 0xE3}, {0xF4, 0xE4}, {0xDC, 0xD3}, {0xDD, 0xC8}, {0xDD, 0xD4},
  114. {0xDD, 0xEA}, {0xDD, 0xFA}, {0xDE, 0xA4}, {0xDE, 0xB0}, {0xF4, 0xE5},
  115. {0xDE, 0xB5}, {0xDE, 0xCB}, {0xF4, 0xE6}, {0xDF, 0xB9}, {0xF4, 0xE7},
  116. {0xDF, 0xC3}, {0xF4, 0xE8}, {0xF4, 0xE9}, {0xE0, 0xD9}, {0xF4, 0xEA},
  117. {0xF4, 0xEB}, {0xE1, 0xE2}, {0xF4, 0xEC}, {0xF4, 0xED}, {0xF4, 0xEE},
  118. {0xE2, 0xC7}, {0xE3, 0xA8}, {0xE3, 0xA6}, {0xE3, 0xA9}, {0xE3, 0xAF},
  119. {0xE3, 0xB0}, {0xE3, 0xAA}, {0xE3, 0xAB}, {0xE3, 0xBC}, {0xE3, 0xC1},
  120. {0xE3, 0xBF}, {0xE3, 0xD5}, {0xE3, 0xD8}, {0xE3, 0xD6}, {0xE3, 0xDF},
  121. {0xE3, 0xE3}, {0xE3, 0xE1}, {0xE3, 0xD4}, {0xE3, 0xE9}, {0xE4, 0xA6},
  122. {0xE3, 0xF1}, {0xE3, 0xF2}, {0xE4, 0xCB}, {0xE4, 0xC1}, {0xE4, 0xC3},
  123. {0xE4, 0xBE}, {0xF4, 0xEF}, {0xE4, 0xC0}, {0xE4, 0xC7}, {0xE4, 0xBF},
  124. {0xE4, 0xE0}, {0xE4, 0xDE}, {0xE4, 0xD1}, {0xF4, 0xF0}, {0xE4, 0xDC},
  125. {0xE4, 0xD2}, {0xE4, 0xDB}, {0xE4, 0xD4}, {0xE4, 0xFA}, {0xE4, 0xEF},
  126. {0xE5, 0xB3}, {0xE5, 0xBF}, {0xE5, 0xC9}, {0xE5, 0xD0}, {0xE5, 0xE2},
  127. {0xE5, 0xEA}, {0xE5, 0xEB}, {0xF4, 0xF1}, {0xF4, 0xF2}, {0xF4, 0xF3},
  128. {0xE6, 0xE8}, {0xE6, 0xEF}, {0xE7, 0xAC}, {0xF4, 0xF4}, {0xE7, 0xAE},
  129. {0xF4, 0xF5}, {0xE7, 0xB1}, {0xF4, 0xF6}, {0xE7, 0xB2}, {0xE8, 0xB1},
  130. {0xE8, 0xB6}, {0xF4, 0xF7}, {0xF4, 0xF8}, {0xE8, 0xDD}, {0xF4, 0xF9},
  131. {0xF4, 0xFA}, {0xE9, 0xD1}, {0xF4, 0xFB}, {0xE9, 0xED}, {0xEA, 0xCD},
  132. {0xF4, 0xFC}, {0xEA, 0xDB}, {0xEA, 0xE6}, {0xEA, 0xEA}, {0xEB, 0xA5},
  133. {0xEB, 0xFB}, {0xEB, 0xFA}, {0xF4, 0xFD}, {0xEC, 0xD6}, {0xF4, 0xFE},
  134. };
  135. #define IS_EUC_IBM2JISX0208(h, l) \
  136. (((h) == 0xA2 && (l) == 0xCC) || ((h) == 0xA2 && (l) == 0xE8))
  137. /* EUC to SJIS IBM extended characters map (G3 JIS X 0212 block) */
  138. static struct {
  139. unsigned short euc;
  140. unsigned char sjis[2];
  141. } euc2sjisibm_jisx0212_map[] = {
  142. {0xA2C3, {0xFA, 0x55}}, {0xB0A9, {0xFA, 0x68}}, {0xB0C8, {0xFA, 0x69}},
  143. {0xB0D2, {0xFA, 0x6B}}, {0xB0D4, {0xFA, 0x6C}}, {0xB0E3, {0xFA, 0x6D}},
  144. {0xB0EE, {0xFA, 0x6E}}, {0xB1A3, {0xFA, 0x70}}, {0xB1A7, {0xFA, 0x6F}},
  145. {0xB1A9, {0xFA, 0x72}}, {0xB1AC, {0xFA, 0x71}}, {0xB1BB, {0xFA, 0x61}},
  146. {0xB1BE, {0xFA, 0x73}}, {0xB1C8, {0xFA, 0x76}}, {0xB1D7, {0xFA, 0x77}},
  147. {0xB1D8, {0xFA, 0x75}}, {0xB1DF, {0xFA, 0x74}}, {0xB1E1, {0xFA, 0x7A}},
  148. {0xB1E3, {0xFA, 0x78}}, {0xB1F4, {0xFA, 0x79}}, {0xB2A3, {0xFA, 0x7B}},
  149. {0xB2BB, {0xFA, 0x7D}}, {0xB2E6, {0xFA, 0x7E}}, {0xB2ED, {0xFA, 0x80}},
  150. {0xB2F5, {0xFA, 0x81}}, {0xB2FC, {0xFA, 0x82}}, {0xB3B5, {0xFA, 0x84}},
  151. {0xB3D8, {0xFA, 0x85}}, {0xB3DB, {0xFA, 0x86}}, {0xB3DD, {0xFB, 0x77}},
  152. {0xB3E5, {0xFA, 0x87}}, {0xB3EE, {0xFA, 0x88}}, {0xB3FB, {0xFA, 0x89}},
  153. {0xB4C0, {0xFA, 0x8C}}, {0xB4C7, {0xFA, 0x8D}}, {0xB4D0, {0xFA, 0x8E}},
  154. {0xB4DE, {0xFA, 0x8F}}, {0xB5AA, {0xFA, 0x91}}, {0xB5AF, {0xFA, 0x93}},
  155. {0xB5C4, {0xFA, 0x94}}, {0xB5E8, {0xFA, 0x95}}, {0xB7C2, {0xFA, 0x97}},
  156. {0xB7E4, {0xFA, 0x98}}, {0xB7E7, {0xFA, 0x9A}}, {0xB7E8, {0xFA, 0x99}},
  157. {0xB8CE, {0xFA, 0x9E}}, {0xB8E1, {0xFA, 0x9F}}, {0xB8F5, {0xFA, 0xA0}},
  158. {0xB8F7, {0xFA, 0xA1}}, {0xB8F8, {0xFA, 0xA2}}, {0xB8FC, {0xFA, 0xA3}},
  159. {0xB9AF, {0xFA, 0xA4}}, {0xB9B7, {0xFA, 0xA5}}, {0xBABE, {0xFA, 0xA6}},
  160. {0xBADB, {0xFA, 0xA7}}, {0xBAE1, {0xFA, 0xA9}}, {0xBAEB, {0xFA, 0xAB}},
  161. {0xBBB3, {0xFA, 0xAC}}, {0xBBB8, {0xFA, 0xAD}}, {0xBBCA, {0xFA, 0xAF}},
  162. {0xBBD0, {0xFA, 0xB2}}, {0xBBDE, {0xFA, 0xB3}}, {0xBBF4, {0xFA, 0xB4}},
  163. {0xBBF5, {0xFA, 0xB5}}, {0xBBF9, {0xFA, 0xB6}}, {0xBCE4, {0xFA, 0xB7}},
  164. {0xBCED, {0xFA, 0xB8}}, {0xBCF4, {0xFA, 0x67}}, {0xBCFE, {0xFA, 0xB9}},
  165. {0xBDC2, {0xFA, 0xBB}}, {0xBDE7, {0xFA, 0xBC}}, {0xBDF0, {0xFA, 0xBE}},
  166. {0xBEAC, {0xFA, 0xC0}}, {0xBEB0, {0xFA, 0xBF}}, {0xBEB3, {0xFA, 0xC2}},
  167. {0xBEBD, {0xFA, 0xC3}}, {0xBEC9, {0xFA, 0xC5}}, {0xBECD, {0xFA, 0xC4}},
  168. {0xBEE4, {0xFA, 0xC6}}, {0xBFA8, {0xFA, 0xC7}}, {0xBFC9, {0xFA, 0xC8}},
  169. {0xC0C4, {0xFA, 0xC9}}, {0xC0E4, {0xFA, 0xCA}}, {0xC0F4, {0xFA, 0xCB}},
  170. {0xC1A6, {0xFA, 0xCC}}, {0xC1F5, {0xFA, 0xCE}}, {0xC1F8, {0xFA, 0xD1}},
  171. {0xC1FC, {0xFA, 0xCF}}, {0xC2A1, {0xFA, 0xD3}}, {0xC2A5, {0xFA, 0xD4}},
  172. {0xC2AB, {0xFA, 0xD2}}, {0xC2AD, {0xFA, 0x63}}, {0xC2B8, {0xFA, 0xD6}},
  173. {0xC2BA, {0xFA, 0xD7}}, {0xC2BF, {0xFA, 0x66}}, {0xC2C4, {0xFA, 0xD9}},
  174. {0xC2D2, {0xFA, 0xDA}}, {0xC2D7, {0xFA, 0xDB}}, {0xC2DB, {0xFA, 0xDC}},
  175. {0xC2DE, {0xFA, 0xDD}}, {0xC2ED, {0xFA, 0xDE}}, {0xC2F0, {0xFA, 0xDF}},
  176. {0xC3A1, {0xFA, 0xE1}}, {0xC3B5, {0xFA, 0xE2}}, {0xC3B9, {0xFA, 0xE4}},
  177. {0xC3C9, {0xFA, 0xE3}}, {0xC3D8, {0xFA, 0xE6}}, {0xC3FC, {0xFA, 0x64}},
  178. {0xC3FE, {0xFA, 0xE7}}, {0xC4CC, {0xFA, 0xE9}}, {0xC4D9, {0xFA, 0xEB}},
  179. {0xC4EA, {0xFA, 0xEC}}, {0xC4FD, {0xFA, 0xED}}, {0xC5A7, {0xFA, 0xEF}},
  180. {0xC5B5, {0xFA, 0xF0}}, {0xC5B6, {0xFA, 0xF1}}, {0xC5D5, {0xFA, 0xF3}},
  181. {0xC6B8, {0xFA, 0xF4}}, {0xC6D7, {0xFA, 0xF5}}, {0xC6E0, {0xFA, 0xF6}},
  182. {0xC6E3, {0xFA, 0xF8}}, {0xC6EA, {0xFA, 0xF7}}, {0xC7A1, {0xFA, 0xF9}},
  183. {0xC7AB, {0xFA, 0xFA}}, {0xC7C3, {0xFA, 0xFC}}, {0xC7C7, {0xFA, 0xFB}},
  184. {0xC7CB, {0xFB, 0x40}}, {0xC7CF, {0xFB, 0x41}}, {0xC7D9, {0xFB, 0x42}},
  185. {0xC7E6, {0xFB, 0x45}}, {0xC7EB, {0xFB, 0x48}}, {0xC7EE, {0xFB, 0x46}},
  186. {0xC7F0, {0xFB, 0x49}}, {0xC7FC, {0xFB, 0x47}}, {0xC8B1, {0xFB, 0x4A}},
  187. {0xC8E5, {0xFB, 0x4B}}, {0xC8F8, {0xFB, 0x4C}}, {0xC9A6, {0xFB, 0x4D}},
  188. {0xC9AB, {0xFB, 0x4E}}, {0xC9AD, {0xFB, 0x4F}}, {0xC9CA, {0xFB, 0x51}},
  189. {0xC9D3, {0xFB, 0x52}}, {0xC9E3, {0xFB, 0x54}}, {0xC9E9, {0xFB, 0x53}},
  190. {0xC9F4, {0xFB, 0x56}}, {0xC9F5, {0xFB, 0x57}}, {0xC9FC, {0xFB, 0x55}},
  191. {0xCAB3, {0xFB, 0x59}}, {0xCABD, {0xFB, 0x5A}}, {0xCAEF, {0xFB, 0x5B}},
  192. {0xCAF1, {0xFB, 0x5C}}, {0xCBAE, {0xFB, 0x5D}}, {0xCBCA, {0xFB, 0x5F}},
  193. {0xCBE6, {0xFB, 0x60}}, {0xCBEA, {0xFB, 0x61}}, {0xCBEE, {0xFB, 0x64}},
  194. {0xCBF0, {0xFB, 0x62}}, {0xCBF4, {0xFB, 0x63}}, {0xCBF9, {0xFB, 0x66}},
  195. {0xCCA5, {0xFB, 0x65}}, {0xCCAB, {0xFB, 0x67}}, {0xCCAD, {0xFB, 0x69}},
  196. {0xCCAE, {0xFB, 0x68}}, {0xCCB2, {0xFB, 0x6A}}, {0xCCC2, {0xFB, 0x6B}},
  197. {0xCCD0, {0xFB, 0x6C}}, {0xCCD9, {0xFB, 0x6D}}, {0xCDAA, {0xFA, 0xA8}},
  198. {0xCDBB, {0xFB, 0x6F}}, {0xCEBA, {0xFB, 0x73}}, {0xCEBB, {0xFB, 0x71}},
  199. {0xCEC3, {0xFB, 0x74}}, {0xCEF2, {0xFB, 0x76}}, {0xCFD5, {0xFB, 0x78}},
  200. {0xCFE2, {0xFB, 0x79}}, {0xCFE9, {0xFB, 0x7A}}, {0xCFED, {0xFB, 0x7B}},
  201. {0xD0E5, {0xFB, 0x81}}, {0xD0E9, {0xFB, 0x83}}, {0xD1E8, {0xFB, 0x84}},
  202. {0xD1EC, {0xFB, 0x87}}, {0xD2BB, {0xFB, 0x88}}, {0xD3E1, {0xFB, 0x8A}},
  203. {0xD3E8, {0xFB, 0x8B}}, {0xD4A7, {0xFB, 0x8C}}, {0xD4D4, {0xFB, 0x8F}},
  204. {0xD4E3, {0xFA, 0x5C}}, {0xD4F2, {0xFB, 0x90}}, {0xD5AE, {0xFB, 0x91}},
  205. {0xD7DE, {0xFB, 0x93}}, {0xD8A2, {0xFB, 0x95}}, {0xD8B7, {0xFB, 0x96}},
  206. {0xD8C1, {0xFB, 0x97}}, {0xD8D1, {0xFB, 0x98}}, {0xD8F4, {0xFB, 0x99}},
  207. {0xD9A1, {0xFA, 0x60}}, {0xD9C6, {0xFB, 0x9A}}, {0xD9C8, {0xFB, 0x9B}},
  208. {0xD9D1, {0xFB, 0x9C}}, {0xDCD3, {0xFB, 0xA2}}, {0xDCDF, {0xFA, 0x5D}},
  209. {0xDDC8, {0xFB, 0xA3}}, {0xDDD4, {0xFB, 0xA4}}, {0xDDEA, {0xFB, 0xA5}},
  210. {0xDDFA, {0xFB, 0xA6}}, {0xDEA4, {0xFB, 0xA7}}, {0xDEB0, {0xFB, 0xA8}},
  211. {0xDEB5, {0xFB, 0xAA}}, {0xDECB, {0xFB, 0xAB}}, {0xDFB9, {0xFB, 0xAD}},
  212. {0xDFC3, {0xFB, 0xAF}}, {0xE0D9, {0xFB, 0xB2}}, {0xE1E2, {0xFB, 0xB5}},
  213. {0xE2C7, {0xFB, 0xB9}}, {0xE3A6, {0xFB, 0xBB}}, {0xE3A8, {0xFB, 0xBA}},
  214. {0xE3A9, {0xFB, 0xBC}}, {0xE3AA, {0xFB, 0xBF}}, {0xE3AB, {0xFB, 0xC0}},
  215. {0xE3AF, {0xFB, 0xBD}}, {0xE3B0, {0xFB, 0xBE}}, {0xE3BC, {0xFB, 0xC1}},
  216. {0xE3BF, {0xFB, 0xC3}}, {0xE3C1, {0xFB, 0xC2}}, {0xE3D4, {0xFB, 0xCA}},
  217. {0xE3D5, {0xFB, 0xC4}}, {0xE3D6, {0xFB, 0xC6}}, {0xE3D8, {0xFB, 0xC5}},
  218. {0xE3DF, {0xFB, 0xC7}}, {0xE3E1, {0xFB, 0xC9}}, {0xE3E3, {0xFB, 0xC8}},
  219. {0xE3E9, {0xFB, 0xCB}}, {0xE3F1, {0xFB, 0xCD}}, {0xE3F2, {0xFB, 0xCE}},
  220. {0xE3F8, {0xFA, 0x5F}}, {0xE4A6, {0xFB, 0xCC}}, {0xE4BE, {0xFB, 0xD2}},
  221. {0xE4BF, {0xFB, 0xD6}}, {0xE4C0, {0xFB, 0xD4}}, {0xE4C1, {0xFB, 0xD0}},
  222. {0xE4C3, {0xFB, 0xD1}}, {0xE4C7, {0xFB, 0xD5}}, {0xE4CB, {0xFB, 0xCF}},
  223. {0xE4D0, {0xFA, 0x65}}, {0xE4D1, {0xFB, 0xD9}}, {0xE4D2, {0xFB, 0xDC}},
  224. {0xE4D4, {0xFB, 0xDE}}, {0xE4DB, {0xFB, 0xDD}}, {0xE4DC, {0xFB, 0xDB}},
  225. {0xE4DE, {0xFB, 0xD8}}, {0xE4E0, {0xFB, 0xD7}}, {0xE4E9, {0xFA, 0x5E}},
  226. {0xE4EF, {0xFB, 0xE0}}, {0xE4FA, {0xFB, 0xDF}}, {0xE5B3, {0xFB, 0xE1}},
  227. {0xE5BF, {0xFB, 0xE2}}, {0xE5C9, {0xFB, 0xE3}}, {0xE5D0, {0xFB, 0xE4}},
  228. {0xE5E2, {0xFB, 0xE5}}, {0xE5EA, {0xFB, 0xE6}}, {0xE5EB, {0xFB, 0xE7}},
  229. {0xE6E8, {0xFB, 0xEB}}, {0xE6EF, {0xFB, 0xEC}}, {0xE7AC, {0xFB, 0xED}},
  230. {0xE7AE, {0xFB, 0xEF}}, {0xE7B1, {0xFB, 0xF1}}, {0xE7B2, {0xFB, 0xF3}},
  231. {0xE8B1, {0xFB, 0xF4}}, {0xE8B6, {0xFB, 0xF5}}, {0xE8DD, {0xFB, 0xF8}},
  232. {0xE9D1, {0xFB, 0xFB}}, {0xE9ED, {0xFC, 0x40}}, {0xEACD, {0xFC, 0x41}},
  233. {0xEADB, {0xFC, 0x43}}, {0xEAE6, {0xFC, 0x44}}, {0xEAEA, {0xFC, 0x45}},
  234. {0xEBA5, {0xFC, 0x46}}, {0xEBFA, {0xFC, 0x48}}, {0xEBFB, {0xFC, 0x47}},
  235. {0xECD6, {0xFC, 0x4A}},
  236. };
  237. /* EUC to SJIS IBM extended characters map (G3 Upper block) */
  238. static const unsigned char euc2sjisibm_g3upper_map[][2] = {
  239. {0xFA, 0x40}, {0xFA, 0x41}, {0xFA, 0x42}, {0xFA, 0x43}, {0xFA, 0x44},
  240. {0xFA, 0x45}, {0xFA, 0x46}, {0xFA, 0x47}, {0xFA, 0x48}, {0xFA, 0x49},
  241. {0xFA, 0x4A}, {0xFA, 0x4B}, {0xFA, 0x4C}, {0xFA, 0x4D}, {0xFA, 0x4E},
  242. {0xFA, 0x4F}, {0xFA, 0x50}, {0xFA, 0x51}, {0xFA, 0x52}, {0xFA, 0x53},
  243. {0xFA, 0x56}, {0xFA, 0x57}, {0xFA, 0x58}, {0xFA, 0x59}, {0xFA, 0x5A},
  244. {0xFA, 0x62}, {0xFA, 0x6A}, {0xFA, 0x7C}, {0xFA, 0x83}, {0xFA, 0x8A},
  245. {0xFA, 0x8B}, {0xFA, 0x90}, {0xFA, 0x92}, {0xFA, 0x96}, {0xFA, 0x9B},
  246. {0xFA, 0x9C}, {0xFA, 0x9D}, {0xFA, 0xAA}, {0xFA, 0xAE}, {0xFA, 0xB0},
  247. {0xFA, 0xB1}, {0xFA, 0xBA}, {0xFA, 0xBD}, {0xFA, 0xC1}, {0xFA, 0xCD},
  248. {0xFA, 0xD0}, {0xFA, 0xD5}, {0xFA, 0xD8}, {0xFA, 0xE0}, {0xFA, 0xE5},
  249. {0xFA, 0xE8}, {0xFA, 0xEA}, {0xFA, 0xEE}, {0xFA, 0xF2}, {0xFB, 0x43},
  250. {0xFB, 0x44}, {0xFB, 0x50}, {0xFB, 0x58}, {0xFB, 0x5E}, {0xFB, 0x6E},
  251. {0xFB, 0x70}, {0xFB, 0x72}, {0xFB, 0x75}, {0xFB, 0x7C}, {0xFB, 0x7D},
  252. {0xFB, 0x7E}, {0xFB, 0x80}, {0xFB, 0x82}, {0xFB, 0x85}, {0xFB, 0x86},
  253. {0xFB, 0x89}, {0xFB, 0x8D}, {0xFB, 0x8E}, {0xFB, 0x92}, {0xFB, 0x94},
  254. {0xFB, 0x9D}, {0xFB, 0x9E}, {0xFB, 0x9F}, {0xFB, 0xA0}, {0xFB, 0xA1},
  255. {0xFB, 0xA9}, {0xFB, 0xAC}, {0xFB, 0xAE}, {0xFB, 0xB0}, {0xFB, 0xB1},
  256. {0xFB, 0xB3}, {0xFB, 0xB4}, {0xFB, 0xB6}, {0xFB, 0xB7}, {0xFB, 0xB8},
  257. {0xFB, 0xD3}, {0xFB, 0xDA}, {0xFB, 0xE8}, {0xFB, 0xE9}, {0xFB, 0xEA},
  258. {0xFB, 0xEE}, {0xFB, 0xF0}, {0xFB, 0xF2}, {0xFB, 0xF6}, {0xFB, 0xF7},
  259. {0xFB, 0xF9}, {0xFB, 0xFA}, {0xFB, 0xFC}, {0xFC, 0x42}, {0xFC, 0x49},
  260. {0xFC, 0x4B},
  261. };
  262. static inline int sjisibm2euc(unsigned char *euc, const unsigned char sjis_hi,
  263. const unsigned char sjis_lo);
  264. static inline int euc2sjisibm_jisx0212(unsigned char *sjis, const unsigned char euc_hi,
  265. const unsigned char euc_lo);
  266. static inline int euc2sjisibm_g3upper(unsigned char *sjis, const unsigned char euc_hi,
  267. const unsigned char euc_lo);
  268. static inline int euc2sjisibm(unsigned char *sjis, const unsigned char euc_hi,
  269. const unsigned char euc_lo);
  270. static inline int sjisnec2sjisibm(unsigned char *sjisibm,
  271. const unsigned char sjisnec_hi,
  272. const unsigned char sjisnec_lo);
  273. /* SJIS IBM extended characters to EUC */
  274. static inline int sjisibm2euc(unsigned char *euc, const unsigned char sjis_hi,
  275. const unsigned char sjis_lo)
  276. {
  277. int index;
  278. index = ((sjis_hi - 0xFA) * (0xFD - 0x40)) + (sjis_lo - 0x40);
  279. if (IS_EUC_IBM2JISX0208(sjisibm2euc_map[index][0],
  280. sjisibm2euc_map[index][1])) {
  281. euc[0] = sjisibm2euc_map[index][0];
  282. euc[1] = sjisibm2euc_map[index][1];
  283. return 2;
  284. } else {
  285. euc[0] = SS3;
  286. euc[1] = sjisibm2euc_map[index][0];
  287. euc[2] = sjisibm2euc_map[index][1];
  288. return 3;
  289. }
  290. }
  291. /* EUC to SJIS IBM extended characters (G3 JIS X 0212 block) */
  292. static inline int euc2sjisibm_jisx0212(unsigned char *sjis, const unsigned char euc_hi,
  293. const unsigned char euc_lo)
  294. {
  295. int index, min_index, max_index;
  296. unsigned short euc;
  297. min_index = 0;
  298. max_index = ARRAY_SIZE(euc2sjisibm_jisx0212_map) - 1;
  299. euc = (euc_hi << 8) | euc_lo;
  300. while (min_index <= max_index) {
  301. index = (min_index + max_index) / 2;
  302. if (euc < euc2sjisibm_jisx0212_map[index].euc)
  303. max_index = index - 1;
  304. else
  305. min_index = index + 1;
  306. if (euc == euc2sjisibm_jisx0212_map[index].euc) {
  307. sjis[0] = euc2sjisibm_jisx0212_map[index].sjis[0];
  308. sjis[1] = euc2sjisibm_jisx0212_map[index].sjis[1];
  309. return 3;
  310. }
  311. }
  312. return 0;
  313. }
  314. /* EUC to SJIS IBM extended characters (G3 Upper block) */
  315. static inline int euc2sjisibm_g3upper(unsigned char *sjis, const unsigned char euc_hi,
  316. const unsigned char euc_lo)
  317. {
  318. int index;
  319. if (euc_hi == 0xF3)
  320. index = ((euc_hi << 8) | euc_lo) - 0xF3F3;
  321. else
  322. index = ((euc_hi << 8) | euc_lo) - 0xF4A1 + 12;
  323. if ((index < 0) || (index >= ARRAY_SIZE(euc2sjisibm_g3upper_map)))
  324. return 0;
  325. sjis[0] = euc2sjisibm_g3upper_map[index][0];
  326. sjis[1] = euc2sjisibm_g3upper_map[index][1];
  327. return 3;
  328. }
  329. /* EUC to SJIS IBM extended characters (G3 block) */
  330. static inline int euc2sjisibm(unsigned char *sjis, const unsigned char euc_hi,
  331. const unsigned char euc_lo)
  332. {
  333. int n;
  334. #if 0
  335. if ((euc_hi == 0xA2) && (euc_lo == 0xCC)) {
  336. sjis[0] = 0xFA;
  337. sjis[1] = 0x54;
  338. return 2;
  339. } else if ((euc_hi == 0xA2) && (euc_lo == 0xE8)) {
  340. sjis[0] = 0xFA;
  341. sjis[1] = 0x5B;
  342. return 2;
  343. }
  344. #endif
  345. if ((n = euc2sjisibm_g3upper(sjis, euc_hi, euc_lo))) {
  346. return n;
  347. } else if ((n = euc2sjisibm_jisx0212(sjis, euc_hi, euc_lo))) {
  348. return n;
  349. }
  350. return 0;
  351. }
  352. /* NEC/IBM extended characters to IBM extended characters */
  353. static inline int sjisnec2sjisibm(unsigned char *sjisibm,
  354. const unsigned char sjisnec_hi,
  355. const unsigned char sjisnec_lo)
  356. {
  357. int count;
  358. if (! IS_SJIS_NECIBM(sjisnec_hi, sjisnec_lo))
  359. return 0;
  360. if ((sjisnec_hi == 0xEE) && (sjisnec_lo == 0xF9)) {
  361. sjisibm[0] = 0x81;
  362. sjisibm[1] = 0xCA;
  363. return 2;
  364. }
  365. if ((sjisnec_hi == 0xEE) && (sjisnec_lo >= 0xEF)) {
  366. count = (sjisnec_hi << 8 | sjisnec_lo)
  367. - (sjisnec_lo <= 0xF9 ? 0xEEEF : (0xEEEF - 10));
  368. } else {
  369. count = (sjisnec_hi - 0xED) * (0xFC - 0x40)
  370. + (sjisnec_lo - 0x40) + (0x5C - 0x40);
  371. if (sjisnec_lo >= 0x7F)
  372. count--;
  373. }
  374. sjisibm[0] = 0xFA + (count / (0xFC - 0x40));
  375. sjisibm[1] = 0x40 + (count % (0xFC - 0x40));
  376. if (sjisibm[1] >= 0x7F)
  377. sjisibm[1]++;
  378. return 2;
  379. }
  380. static int uni2char(const wchar_t uni,
  381. unsigned char *out, int boundlen)
  382. {
  383. int n;
  384. if (!p_nls)
  385. return -EINVAL;
  386. if ((n = p_nls->uni2char(uni, out, boundlen)) < 0)
  387. return n;
  388. /* translate SJIS into EUC-JP */
  389. if (n == 1) {
  390. if (IS_SJIS_JISX0201KANA(out[0])) {
  391. /* JIS X 0201 KANA */
  392. if (boundlen < 2)
  393. return -ENAMETOOLONG;
  394. out[1] = out[0];
  395. out[0] = SS2;
  396. return 2;
  397. }
  398. } else if (n == 2) {
  399. /* NEC/IBM extended characters to IBM extended characters */
  400. sjisnec2sjisibm(out, out[0], out[1]);
  401. if (IS_SJIS_UDC_LOW(out[0], out[1])) {
  402. /* User defined characters half low */
  403. MAP_SJIS2EUC(out[0], out[1], 0xF0, out[0], out[1], 0xF5);
  404. } else if (IS_SJIS_UDC_HI(out[0], out[1])) {
  405. /* User defined characters half high */
  406. unsigned char ch, cl;
  407. if (boundlen < 3)
  408. return -ENAMETOOLONG;
  409. n = 3; ch = out[0]; cl = out[1];
  410. out[0] = SS3;
  411. MAP_SJIS2EUC(ch, cl, 0xF5, out[1], out[2], 0xF5);
  412. } else if (IS_SJIS_IBM(out[0], out[1])) {
  413. /* IBM extended characters */
  414. unsigned char euc[3], i;
  415. n = sjisibm2euc(euc, out[0], out[1]);
  416. if (boundlen < n)
  417. return -ENAMETOOLONG;
  418. for (i = 0; i < n; i++)
  419. out[i] = euc[i];
  420. } else if (IS_SJIS_JISX0208(out[0], out[1])) {
  421. /* JIS X 0208 (include NEC special characters) */
  422. out[0] = (out[0]^0xA0)*2 + 0x5F;
  423. if (out[1] > 0x9E)
  424. out[0]++;
  425. if (out[1] < 0x7F)
  426. out[1] = out[1] + 0x61;
  427. else if (out[1] < 0x9F)
  428. out[1] = out[1] + 0x60;
  429. else
  430. out[1] = out[1] + 0x02;
  431. } else {
  432. /* Invalid characters */
  433. return -EINVAL;
  434. }
  435. }
  436. else
  437. return -EINVAL;
  438. return n;
  439. }
  440. static int char2uni(const unsigned char *rawstring, int boundlen,
  441. wchar_t *uni)
  442. {
  443. unsigned char sjis_temp[2];
  444. int euc_offset, n;
  445. if ( !p_nls )
  446. return -EINVAL;
  447. if (boundlen <= 0)
  448. return -ENAMETOOLONG;
  449. /* translate EUC-JP into SJIS */
  450. if (rawstring[0] > 0x7F) {
  451. if (rawstring[0] == SS3) {
  452. if (boundlen < 3)
  453. return -EINVAL;
  454. euc_offset = 3;
  455. if (IS_EUC_UDC_HI(rawstring[1], rawstring[2])) {
  456. /* User defined characters half high */
  457. MAP_EUC2SJIS(rawstring[1], rawstring[2], 0xF5,
  458. sjis_temp[0], sjis_temp[1], 0xF5);
  459. } else if (euc2sjisibm(sjis_temp,rawstring[1],rawstring[2])) {
  460. /* IBM extended characters */
  461. } else {
  462. /* JIS X 0212 and Invalid characters*/
  463. return -EINVAL;
  464. /* 'GETA' with SJIS coding */
  465. /* sjis_temp[0] = 0x81; */
  466. /* sjis_temp[1] = 0xAC; */
  467. }
  468. } else {
  469. if (boundlen < 2)
  470. return -EINVAL;
  471. euc_offset = 2;
  472. if (IS_EUC_JISX0201KANA(rawstring[0], rawstring[1])) {
  473. /* JIS X 0201 KANA */
  474. sjis_temp[0] = rawstring[1];
  475. sjis_temp[1] = 0x00;
  476. } else if (IS_EUC_UDC_LOW(rawstring[0], rawstring[1])) {
  477. /* User defined characters half low */
  478. MAP_EUC2SJIS(rawstring[0], rawstring[1], 0xF5,
  479. sjis_temp[0], sjis_temp[1], 0xF0);
  480. } else if (IS_EUC_JISX0208(rawstring[0], rawstring[1])) {
  481. /* JIS X 0208 (include NEC spesial characters) */
  482. sjis_temp[0] = ((rawstring[0]-0x5f)/2) ^ 0xA0;
  483. if (!(rawstring[0] & 1))
  484. sjis_temp[1] = rawstring[1] - 0x02;
  485. else if (rawstring[1] < 0xE0)
  486. sjis_temp[1] = rawstring[1] - 0x61;
  487. else
  488. sjis_temp[1] = rawstring[1] - 0x60;
  489. } else {
  490. /* Invalid characters */
  491. return -EINVAL;
  492. }
  493. }
  494. } else {
  495. euc_offset = 1;
  496. /* JIS X 0201 ROMAJI */
  497. sjis_temp[0] = rawstring[0];
  498. sjis_temp[1] = 0x00;
  499. }
  500. if ( (n = p_nls->char2uni(sjis_temp, sizeof(sjis_temp), uni)) < 0)
  501. return n;
  502. return euc_offset;
  503. }
  504. static struct nls_table table = {
  505. .charset = "euc-jp",
  506. .uni2char = uni2char,
  507. .char2uni = char2uni,
  508. };
  509. static int __init init_nls_euc_jp(void)
  510. {
  511. p_nls = load_nls("cp932");
  512. if (p_nls) {
  513. table.charset2upper = p_nls->charset2upper;
  514. table.charset2lower = p_nls->charset2lower;
  515. return register_nls(&table);
  516. }
  517. return -EINVAL;
  518. }
  519. static void __exit exit_nls_euc_jp(void)
  520. {
  521. unregister_nls(&table);
  522. unload_nls(p_nls);
  523. }
  524. module_init(init_nls_euc_jp)
  525. module_exit(exit_nls_euc_jp)
  526. MODULE_LICENSE("Dual BSD/GPL");