rhodes 5.5.15 → 5.5.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (458) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +48 -13
  3. data/doc/oss/WM_CE_Installation_And_Build_Guidelines.md +1 -1
  4. data/lib/commonAPI/barcode/ext.yml +6 -2
  5. data/lib/commonAPI/barcode/ext/barcode.xml +1 -1
  6. data/lib/commonAPI/barcode/ext/build.bat +8 -0
  7. data/lib/commonAPI/barcode/ext/platform/qt/Barcode.pro +90 -0
  8. data/lib/commonAPI/barcode/ext/platform/qt/Rakefile +35 -0
  9. data/lib/commonAPI/barcode/ext/platform/qt/resources/barcode.qrc +10 -0
  10. data/lib/commonAPI/barcode/ext/platform/qt/resources/buttonBack.png +0 -0
  11. data/lib/commonAPI/barcode/ext/platform/qt/resources/buttonRetry.png +0 -0
  12. data/lib/commonAPI/barcode/ext/platform/qt/resources/buttonSave.png +0 -0
  13. data/lib/commonAPI/barcode/ext/platform/qt/resources/scanner_sound.wav +0 -0
  14. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeController.cpp +40 -0
  15. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeController.h +57 -0
  16. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeDialogBuilder.h +52 -0
  17. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeDialogView.cpp +175 -0
  18. data/lib/commonAPI/barcode/ext/platform/qt/src/BarcodeDialogView.h +68 -0
  19. data/lib/commonAPI/barcode/ext/platform/qt/src/Barcode_impl.cpp +109 -0
  20. data/lib/commonAPI/barcode/ext/platform/qt/src/decoderthread.cpp +39 -0
  21. data/lib/commonAPI/barcode/ext/platform/qt/src/decoderthread.h +29 -0
  22. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/CameraImageWrapper.cpp +131 -0
  23. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/CameraImageWrapper.h +39 -0
  24. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing.h +173 -0
  25. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing.pri +277 -0
  26. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing_global.h +13 -0
  27. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/imagehandler.cpp +45 -0
  28. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/imagehandler.h +23 -0
  29. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/qzxing.cpp +303 -0
  30. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigInteger.cc +405 -0
  31. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigInteger.hh +215 -0
  32. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerAlgorithms.cc +70 -0
  33. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerAlgorithms.hh +25 -0
  34. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerLibrary.hh +8 -0
  35. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerUtils.cc +50 -0
  36. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigIntegerUtils.hh +72 -0
  37. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsigned.cc +697 -0
  38. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsigned.hh +418 -0
  39. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsignedInABase.cc +125 -0
  40. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/BigUnsignedInABase.hh +122 -0
  41. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/ChangeLog +146 -0
  42. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/NumberlikeArray.hh +177 -0
  43. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/bigint/README +71 -0
  44. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/win32/zxing/iconv.h +14 -0
  45. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/win32/zxing/msvc/stdint.h +247 -0
  46. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/win32/zxing/win_iconv.c +2035 -0
  47. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BarcodeFormat.cpp +40 -0
  48. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BarcodeFormat.h +60 -0
  49. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Binarizer.cpp +45 -0
  50. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Binarizer.h +50 -0
  51. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BinaryBitmap.cpp +70 -0
  52. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/BinaryBitmap.h +56 -0
  53. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ChecksumException.cpp +28 -0
  54. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ChecksumException.h +34 -0
  55. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/DecodeHints.cpp +148 -0
  56. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/DecodeHints.h +85 -0
  57. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Exception.cpp +43 -0
  58. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Exception.h +51 -0
  59. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/FormatException.cpp +41 -0
  60. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/FormatException.h +37 -0
  61. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/IllegalStateException.h +35 -0
  62. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/InvertedLuminanceSource.cpp +68 -0
  63. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/InvertedLuminanceSource.h +48 -0
  64. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/LuminanceSource.cpp +86 -0
  65. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/LuminanceSource.h +59 -0
  66. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/MultiFormatReader.cpp +124 -0
  67. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/MultiFormatReader.h +48 -0
  68. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/NotFoundException.h +35 -0
  69. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Reader.cpp +31 -0
  70. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Reader.h +40 -0
  71. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ReaderException.h +37 -0
  72. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Result.cpp +66 -0
  73. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/Result.h +57 -0
  74. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultIO.cpp +34 -0
  75. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPoint.cpp +108 -0
  76. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPoint.h +55 -0
  77. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPointCallback.cpp +26 -0
  78. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ResultPointCallback.h +39 -0
  79. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/WriterException.h +17 -0
  80. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/ZXing.h +140 -0
  81. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecDetectorResult.cpp +54 -0
  82. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecDetectorResult.h +48 -0
  83. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecReader.cpp +68 -0
  84. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/AztecReader.h +49 -0
  85. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/decoder/AztecDecoder.cpp +495 -0
  86. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/decoder/Decoder.h +69 -0
  87. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/detector/AztecDetector.cpp +548 -0
  88. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/aztec/detector/Detector.h +92 -0
  89. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Array.h +173 -0
  90. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitArray.cpp +237 -0
  91. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitArray.h +97 -0
  92. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitArrayIO.cpp +31 -0
  93. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitMatrix.cpp +143 -0
  94. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitMatrix.h +91 -0
  95. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitSource.cpp +76 -0
  96. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/BitSource.h +74 -0
  97. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/CharacterSetECI.cpp +104 -0
  98. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/CharacterSetECI.h +53 -0
  99. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Counted.h +140 -0
  100. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DecoderResult.cpp +51 -0
  101. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DecoderResult.h +54 -0
  102. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DetectorResult.cpp +39 -0
  103. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/DetectorResult.h +43 -0
  104. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GlobalHistogramBinarizer.cpp +212 -0
  105. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GlobalHistogramBinarizer.h +48 -0
  106. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleLuminanceSource.cpp +80 -0
  107. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleLuminanceSource.h +53 -0
  108. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp +81 -0
  109. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h +46 -0
  110. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GridSampler.cpp +122 -0
  111. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/GridSampler.h +45 -0
  112. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/HybridBinarizer.cpp +226 -0
  113. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/HybridBinarizer.h +67 -0
  114. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/IllegalArgumentException.cpp +27 -0
  115. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/IllegalArgumentException.h +36 -0
  116. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/PerspectiveTransform.cpp +107 -0
  117. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/PerspectiveTransform.h +49 -0
  118. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Point.h +47 -0
  119. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Str.cpp +61 -0
  120. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/Str.h +51 -0
  121. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/StringUtils.cpp +198 -0
  122. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/StringUtils.h +52 -0
  123. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/JavaMath.h +43 -0
  124. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/MathUtils.h +57 -0
  125. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/MonochromeRectangleDetector.cpp +175 -0
  126. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/MonochromeRectangleDetector.h +62 -0
  127. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/WhiteRectangleDetector.cpp +330 -0
  128. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/detector/WhiteRectangleDetector.h +59 -0
  129. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGF.cpp +150 -0
  130. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGF.h +73 -0
  131. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGFPoly.cpp +218 -0
  132. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/GenericGFPoly.h +56 -0
  133. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.cpp +174 -0
  134. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h +49 -0
  135. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp +30 -0
  136. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/common/reedsolomon/ReedSolomonException.h +33 -0
  137. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/DataMatrixReader.cpp +54 -0
  138. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/DataMatrixReader.h +45 -0
  139. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/DataMatrixVersion.cpp +199 -0
  140. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/Version.h +87 -0
  141. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/BitMatrixParser.h +59 -0
  142. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataBlock.h +49 -0
  143. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +361 -0
  144. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp +113 -0
  145. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp +416 -0
  146. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp +93 -0
  147. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h +104 -0
  148. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/decoder/Decoder.h +49 -0
  149. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/CornerPoint.h +43 -0
  150. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DataMatrixCornerPoint.cpp +46 -0
  151. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp +447 -0
  152. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DataMatrixDetectorException.cpp +23 -0
  153. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/Detector.h +94 -0
  154. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/datamatrix/detector/DetectorException.h +23 -0
  155. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/ByQuadrantReader.cpp +75 -0
  156. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/ByQuadrantReader.h +42 -0
  157. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp +137 -0
  158. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/GenericMultipleBarcodeReader.h +51 -0
  159. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/MultipleBarcodeReader.cpp +29 -0
  160. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/MultipleBarcodeReader.h +41 -0
  161. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/QRCodeMultiReader.cpp +58 -0
  162. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/QRCodeMultiReader.h +36 -0
  163. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiDetector.cpp +47 -0
  164. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiDetector.h +37 -0
  165. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +236 -0
  166. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h +47 -0
  167. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/CodaBarReader.cpp +340 -0
  168. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/CodaBarReader.h +57 -0
  169. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code128Reader.cpp +497 -0
  170. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code128Reader.h +48 -0
  171. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code39Reader.cpp +329 -0
  172. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code39Reader.h +63 -0
  173. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code93Reader.cpp +293 -0
  174. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/Code93Reader.h +58 -0
  175. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN13Reader.cpp +85 -0
  176. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN13Reader.h +49 -0
  177. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN8Reader.cpp +65 -0
  178. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/EAN8Reader.h +47 -0
  179. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/ITFReader.cpp +337 -0
  180. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/ITFReader.h +54 -0
  181. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatOneDReader.cpp +96 -0
  182. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatOneDReader.h +38 -0
  183. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatUPCEANReader.cpp +110 -0
  184. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/MultiFormatUPCEANReader.h +41 -0
  185. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDReader.cpp +228 -0
  186. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDReader.h +81 -0
  187. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDResultPoint.cpp +28 -0
  188. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/OneDResultPoint.h +35 -0
  189. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCAReader.cpp +71 -0
  190. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCAReader.h +50 -0
  191. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEANReader.cpp +309 -0
  192. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEANReader.h +88 -0
  193. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEReader.cpp +146 -0
  194. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/oned/UPCEReader.h +47 -0
  195. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/PDF417Reader.cpp +170 -0
  196. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/PDF417Reader.h +49 -0
  197. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/BitMatrixParser.h +84 -0
  198. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h +84 -0
  199. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/Decoder.h +62 -0
  200. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp +997 -0
  201. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp +563 -0
  202. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/PDF417Decoder.cpp +118 -0
  203. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp +214 -0
  204. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h +71 -0
  205. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp +120 -0
  206. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusGF.h +72 -0
  207. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp +284 -0
  208. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h +68 -0
  209. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/Detector.h +106 -0
  210. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/LinesSampler.cpp +719 -0
  211. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/LinesSampler.h +122 -0
  212. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/pdf417/detector/PDF417Detector.cpp +664 -0
  213. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/ErrorCorrectionLevel.h +55 -0
  214. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/FormatInformation.h +54 -0
  215. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRCodeReader.cpp +52 -0
  216. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRCodeReader.h +48 -0
  217. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp +70 -0
  218. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRFormatInformation.cpp +117 -0
  219. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/QRVersion.cpp +566 -0
  220. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/Version.h +86 -0
  221. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/BitMatrixParser.h +56 -0
  222. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/DataBlock.h +50 -0
  223. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/DataMask.h +50 -0
  224. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h +72 -0
  225. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/Decoder.h +46 -0
  226. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/Mode.h +68 -0
  227. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp +183 -0
  228. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDataBlock.cpp +118 -0
  229. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDataMask.cpp +159 -0
  230. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp +433 -0
  231. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRDecoder.cpp +107 -0
  232. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/decoder/QRMode.cpp +118 -0
  233. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/AlignmentPattern.h +45 -0
  234. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h +68 -0
  235. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/Detector.h +69 -0
  236. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/FinderPattern.h +48 -0
  237. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/FinderPatternFinder.h +80 -0
  238. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/FinderPatternInfo.h +47 -0
  239. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRAlignmentPattern.cpp +47 -0
  240. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp +208 -0
  241. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRDetector.cpp +315 -0
  242. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRFinderPattern.cpp +69 -0
  243. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp +638 -0
  244. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/zxing/zxing/qrcode/detector/QRFinderPatternInfo.cpp +41 -0
  245. data/lib/commonAPI/coreapi/ext.yml +1 -1
  246. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/network/Network.java +21 -7
  247. data/lib/commonAPI/coreapi/ext/platform/qt/coreapi.pro +10 -0
  248. data/lib/commonAPI/coreapi/ext/platform/wm/src/Registry.cpp +57 -7
  249. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.cpp +11 -0
  250. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.h +2 -0
  251. data/lib/commonAPI/coreapi/ext/shared/qt/NavbarImpl.cpp +1 -1
  252. data/lib/commonAPI/coreapi/ext/system.xml +3 -0
  253. data/lib/commonAPI/coreapi/ext/webview.xml +0 -2
  254. data/lib/commonAPI/coreapi/public/api/rhonodejsapi.js +921 -0
  255. data/lib/commonAPI/mediacapture/ext.yml +1 -0
  256. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +3 -2
  257. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +260 -230
  258. data/lib/commonAPI/mediacapture/ext/platform/qt/MediaCapture.pro +17 -5
  259. data/lib/commonAPI/mediacapture/ext/platform/qt/resources/buttonBack.png +0 -0
  260. data/lib/commonAPI/mediacapture/ext/platform/qt/resources/mediacapture.qrc +1 -0
  261. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CCameraData.cpp +11 -4
  262. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CCameraData.h +4 -7
  263. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraDialogView.h +1 -6
  264. data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraRefresher.h +54 -0
  265. data/lib/commonAPI/mediacapture/ext/platform/qt/src/Camera_impl.cpp +15 -21
  266. data/lib/commonAPI/mediacapture/ext/platform/qt/src/ImageFilenameGetterResult.h +7 -2
  267. data/lib/commonAPI/mediacapture/ext/platform/qt/src/cameradialogview.cpp +34 -32
  268. data/lib/extensions/zlib/ext/zlib.pro +11 -0
  269. data/platform/android/Rhodes/jni/src/fileapi.cpp +36 -22
  270. data/platform/iphone/Classes/SimpleMainView.m +1 -1
  271. data/platform/shared/api_generator/MethodResult.cpp +22 -7
  272. data/platform/shared/api_generator/MethodResult.h +3 -1
  273. data/platform/shared/api_generator/iphone/CMethodResult.m +6 -2
  274. data/platform/shared/api_generator/js_helpers.cpp +19 -0
  275. data/platform/shared/api_generator/js_helpers.h +23 -0
  276. data/platform/shared/common/RhoConf.cpp +0 -1
  277. data/platform/shared/common/RhoPort.h +3 -0
  278. data/platform/shared/common/RhodesApp.cpp +46 -11
  279. data/platform/shared/common/RhodesApp.h +7 -0
  280. data/platform/shared/common/RhodesAppBase.cpp +5 -1
  281. data/platform/shared/common/RhodesAppBase.h +8 -1
  282. data/platform/shared/common/ThreadQueue.h +1 -1
  283. data/platform/shared/common/map/BaseMapEngine.cpp +2 -0
  284. data/platform/shared/net/HttpServer.cpp +0 -1
  285. data/platform/shared/qt/RhoSimulator.pro +11 -0
  286. data/platform/shared/qt/RhoSimulator_dev.pro +12 -2
  287. data/platform/shared/qt/curl/curl.pro +10 -0
  288. data/platform/shared/qt/rhodes/guithreadfunchelper.h +29 -0
  289. data/platform/shared/qt/rhodes/iexecutable.h +9 -0
  290. data/platform/shared/qt/rhodes/impl/MainWindowImpl.cpp +10 -21
  291. data/platform/shared/qt/rhodes/impl/MainWindowImpl.h +1 -1
  292. data/platform/shared/qt/rhodes/impl/QtSystemImpl.cpp +15 -1
  293. data/platform/shared/qt/rhodes/impl/RhoThreadImpl.cpp +7 -7
  294. data/platform/shared/qt/rhodes/mainwindowinterface.h +12 -0
  295. data/platform/shared/qt/rhodes/newVersion/DateTimeDialog.cpp +96 -0
  296. data/platform/shared/qt/rhodes/newVersion/DateTimeDialog.h +54 -0
  297. data/platform/shared/qt/rhodes/newVersion/ExternalWebView.cpp +45 -0
  298. data/platform/shared/qt/rhodes/newVersion/ExternalWebView.h +47 -0
  299. data/platform/shared/qt/rhodes/newVersion/QWebEngineViewSelectionSuppressor.h +103 -0
  300. data/platform/shared/qt/rhodes/newVersion/QtMainWindow.cpp +1181 -0
  301. data/platform/shared/qt/rhodes/newVersion/QtMainWindow.h +194 -0
  302. data/platform/shared/qt/rhodes/newVersion/QtNativeTabBar.cpp +107 -0
  303. data/platform/shared/qt/rhodes/newVersion/QtNativeTabBar.h +40 -0
  304. data/platform/shared/qt/rhodes/newVersion/RhoNativeApiCall.cpp +51 -0
  305. data/platform/shared/qt/rhodes/newVersion/RhoNativeApiCall.h +52 -0
  306. data/platform/shared/qt/rhodes/newVersion/main.cpp +280 -0
  307. data/platform/shared/qt/rhodes/newVersion/qtwebenginepage.cpp +19 -0
  308. data/platform/shared/qt/rhodes/newVersion/qtwebenginepage.h +21 -0
  309. data/platform/shared/qt/rhodes/newVersion/qtwebengineview.cpp +6 -0
  310. data/platform/shared/qt/rhodes/newVersion/qtwebengineview.h +18 -0
  311. data/platform/shared/qt/rhodes/{DateTimeDialog.cpp → oldVersion/DateTimeDialog.cpp} +0 -0
  312. data/platform/shared/qt/rhodes/{DateTimeDialog.h → oldVersion/DateTimeDialog.h} +0 -0
  313. data/platform/shared/qt/rhodes/{DateTimeDialog.ui → oldVersion/DateTimeDialog.ui} +0 -0
  314. data/platform/shared/qt/rhodes/{ExternalWebView.cpp → oldVersion/ExternalWebView.cpp} +0 -0
  315. data/platform/shared/qt/rhodes/{ExternalWebView.h → oldVersion/ExternalWebView.h} +0 -0
  316. data/platform/shared/qt/rhodes/{ExternalWebView.ui → oldVersion/ExternalWebView.ui} +0 -0
  317. data/platform/shared/qt/rhodes/{QtMainWindow.cpp → oldVersion/QtMainWindow.cpp} +4 -1
  318. data/platform/shared/qt/rhodes/{QtMainWindow.h → oldVersion/QtMainWindow.h} +8 -5
  319. data/platform/shared/qt/rhodes/{QtMainWindow.ui → oldVersion/QtMainWindow.ui} +0 -0
  320. data/platform/shared/qt/rhodes/{QtNativeTabBar.cpp → oldVersion/QtNativeTabBar.cpp} +0 -0
  321. data/platform/shared/qt/rhodes/{QtNativeTabBar.h → oldVersion/QtNativeTabBar.h} +0 -0
  322. data/platform/shared/qt/rhodes/{QtWebInspector.cpp → oldVersion/QtWebInspector.cpp} +0 -0
  323. data/platform/shared/qt/rhodes/{QtWebInspector.h → oldVersion/QtWebInspector.h} +0 -0
  324. data/platform/shared/qt/rhodes/{QtWebInspector.ui → oldVersion/QtWebInspector.ui} +0 -0
  325. data/platform/shared/qt/rhodes/{QtWebPage.cpp → oldVersion/QtWebPage.cpp} +0 -0
  326. data/platform/shared/qt/rhodes/{QtWebPage.h → oldVersion/QtWebPage.h} +0 -0
  327. data/platform/shared/qt/rhodes/{RhoNativeApiCall.cpp → oldVersion/RhoNativeApiCall.cpp} +0 -0
  328. data/platform/shared/qt/rhodes/{RhoNativeApiCall.h → oldVersion/RhoNativeApiCall.h} +0 -0
  329. data/platform/shared/qt/rhodes/{main.cpp → oldVersion/main.cpp} +2 -0
  330. data/platform/shared/qt/rhodes/{qkineticscroller.cpp → oldVersion/qkineticscroller.cpp} +0 -0
  331. data/platform/shared/qt/rhodes/{qkineticscroller.h → oldVersion/qkineticscroller.h} +0 -0
  332. data/platform/shared/qt/rhodes/{qkineticscroller_p.h → oldVersion/qkineticscroller_p.h} +0 -0
  333. data/platform/shared/qt/rhodes/{qtflickgesture.cpp → oldVersion/qtflickgesture.cpp} +0 -0
  334. data/platform/shared/qt/rhodes/{qtflickgesture_p.h → oldVersion/qtflickgesture_p.h} +0 -0
  335. data/platform/shared/qt/rhodes/{qtscroller.cpp → oldVersion/qtscroller.cpp} +0 -0
  336. data/platform/shared/qt/rhodes/{qtscroller.h → oldVersion/qtscroller.h} +0 -0
  337. data/platform/shared/qt/rhodes/{qtscroller_p.h → oldVersion/qtscroller_p.h} +0 -0
  338. data/platform/shared/qt/rhodes/{qtscrollerfilter.cpp → oldVersion/qtscrollerfilter.cpp} +0 -0
  339. data/platform/shared/qt/rhodes/{qtscrollerfilter_p.h → oldVersion/qtscrollerfilter_p.h} +0 -0
  340. data/platform/shared/qt/rhodes/{qtscrollerproperties.cpp → oldVersion/qtscrollerproperties.cpp} +0 -0
  341. data/platform/shared/qt/rhodes/{qtscrollerproperties.h → oldVersion/qtscrollerproperties.h} +0 -0
  342. data/platform/shared/qt/rhodes/{qtscrollerproperties_p.h → oldVersion/qtscrollerproperties_p.h} +0 -0
  343. data/platform/shared/qt/rhodes/{qtscrollevent.cpp → oldVersion/qtscrollevent.cpp} +0 -0
  344. data/platform/shared/qt/rhodes/{qtscrollevent.h → oldVersion/qtscrollevent.h} +0 -0
  345. data/platform/shared/qt/rhodes/{qtscrollevent_p.h → oldVersion/qtscrollevent_p.h} +0 -0
  346. data/platform/shared/qt/rhodes/{qwebviewkineticscroller.cpp → oldVersion/qwebviewkineticscroller.cpp} +0 -0
  347. data/platform/shared/qt/rhodes/{qwebviewkineticscroller.h → oldVersion/qwebviewkineticscroller.h} +0 -0
  348. data/platform/shared/qt/rhodes/{qwebviewselectionsuppressor.h → oldVersion/qwebviewselectionsuppressor.h} +0 -0
  349. data/platform/shared/qt/rhodes/rhodes.pro +92 -47
  350. data/platform/shared/qt/rholib/rholib.pro +32 -19
  351. data/platform/shared/qt/rubylib/rubylib.pro +12 -0
  352. data/platform/shared/qt/sqlite3/sqlite3.pro +11 -1
  353. data/platform/shared/qt/syncengine/syncengine.pro +10 -0
  354. data/platform/shared/ruby/eval.c +2 -4
  355. data/platform/shared/ruby/eval_intern.h +12 -0
  356. data/platform/shared/ruby/ext/rho/extensions.c +6 -2
  357. data/platform/shared/ruby/include/ruby/missing.h +6 -4
  358. data/platform/shared/ruby/io.c +27 -0
  359. data/platform/shared/ruby/numeric.c +5 -2
  360. data/platform/shared/ruby/time.c +4 -0
  361. data/platform/shared/ruby/win32/win32 backup.c +5808 -0
  362. data/platform/shared/ruby/win32/win32.c +2254 -2131
  363. data/platform/shared/unzip/deflate.cpp +6 -1
  364. data/platform/shared/unzip/gunzip.cpp +1 -1
  365. data/platform/shared/unzip/unzip.cpp +3 -6
  366. data/platform/shared/unzip/zip.cpp +1 -25
  367. data/platform/shared/unzip/zutil.cpp +1 -1
  368. data/platform/shared/unzip/zutil.h +1 -1
  369. data/platform/win32/RhoSimulator/rho/Databases/Databases.db +0 -0
  370. data/platform/win32/RhoSimulator/rho/WebpageIcons.db +0 -0
  371. data/platform/win32/RhoSimulator/rho/rholog.txt_pos +0 -0
  372. data/platform/win32/RhoSimulator/rhosimulator/Databases/Databases.db +0 -0
  373. data/platform/win32/RhoSimulator/rhosimulator/WebpageIcons.db +0 -0
  374. data/platform/win32/RhoSimulator/rhosimulator/rholog.txt_pos +0 -0
  375. data/platform/wm/build/build_inf.js +7 -3
  376. data/platform/wm/build/wm.rake +96 -30
  377. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +3 -1
  378. data/rakefile.rb +48 -13
  379. data/res/generators/rhogen.rb +87 -8
  380. data/res/generators/templates/api/cpp/montana_js_wrap.cpp +1 -1
  381. data/res/generators/templates/application/nodejs/main.js +501 -0
  382. data/res/generators/templates/application/nodejs/rhoapp.js +71 -0
  383. data/res/generators/templates/application/nodejs/server/app.js +19 -0
  384. data/res/generators/templates/application/nodejs/server/package.json +16 -0
  385. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.css +587 -0
  386. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.css.map +1 -0
  387. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.min.css +6 -0
  388. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap-theme.min.css.map +1 -0
  389. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.css +6757 -0
  390. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.css.map +1 -0
  391. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.min.css +6 -0
  392. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/css/bootstrap.min.css.map +1 -0
  393. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.eot +0 -0
  394. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.svg +288 -0
  395. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.ttf +0 -0
  396. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.woff +0 -0
  397. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/fonts/glyphicons-halflings-regular.woff2 +0 -0
  398. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/js/bootstrap.js +2377 -0
  399. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/js/bootstrap.min.js +7 -0
  400. data/res/generators/templates/application/nodejs/server/public/bootstrap-3.3.7/js/npm.js +13 -0
  401. data/res/generators/templates/application/nodejs/server/public/images/bar/back_btn.png +0 -0
  402. data/res/generators/templates/application/nodejs/server/public/images/bar/back_btn@2x.png +0 -0
  403. data/res/generators/templates/application/nodejs/server/public/images/bar/back_btn@3x.png +0 -0
  404. data/res/generators/templates/application/nodejs/server/public/images/bar/forward_btn.png +0 -0
  405. data/res/generators/templates/application/nodejs/server/public/images/bar/forward_btn@2x.png +0 -0
  406. data/res/generators/templates/application/nodejs/server/public/images/bar/forward_btn@3x.png +0 -0
  407. data/res/generators/templates/application/nodejs/server/public/images/bar/gears.png +0 -0
  408. data/res/generators/templates/application/nodejs/server/public/images/bar/gears@2x.png +0 -0
  409. data/res/generators/templates/application/nodejs/server/public/images/bar/gears@3x.png +0 -0
  410. data/res/generators/templates/application/nodejs/server/public/images/bar/home_btn.png +0 -0
  411. data/res/generators/templates/application/nodejs/server/public/images/bar/home_btn@2x.png +0 -0
  412. data/res/generators/templates/application/nodejs/server/public/images/bar/home_btn@3x.png +0 -0
  413. data/res/generators/templates/application/nodejs/server/public/images/bar/sync_btn.png +0 -0
  414. data/res/generators/templates/application/nodejs/server/public/images/bar/sync_btn@2x.png +0 -0
  415. data/res/generators/templates/application/nodejs/server/public/images/bar/sync_btn@3x.png +0 -0
  416. data/res/generators/templates/application/nodejs/server/public/jquery/jquery-3.1.1.min.js +4 -0
  417. data/res/generators/templates/application/nodejs/server/public/jquery/jquery-3.1.1.min.map +1 -0
  418. data/res/generators/templates/application/nodejs_build.yml +76 -0
  419. data/res/generators/templates/application/nodejs_rhoconfig.txt +137 -0
  420. data/version +1 -1
  421. metadata +345 -77
  422. data/platform/win32/RhoSimulator/D3Dcompiler_46.dll +0 -0
  423. data/platform/win32/RhoSimulator/Qt5Core.dll +0 -0
  424. data/platform/win32/RhoSimulator/Qt5Gui.dll +0 -0
  425. data/platform/win32/RhoSimulator/Qt5Multimedia.dll +0 -0
  426. data/platform/win32/RhoSimulator/Qt5MultimediaWidgets.dll +0 -0
  427. data/platform/win32/RhoSimulator/Qt5Network.dll +0 -0
  428. data/platform/win32/RhoSimulator/Qt5OpenGL.dll +0 -0
  429. data/platform/win32/RhoSimulator/Qt5PrintSupport.dll +0 -0
  430. data/platform/win32/RhoSimulator/Qt5Qml.dll +0 -0
  431. data/platform/win32/RhoSimulator/Qt5Quick.dll +0 -0
  432. data/platform/win32/RhoSimulator/Qt5Sensors.dll +0 -0
  433. data/platform/win32/RhoSimulator/Qt5Sql.dll +0 -0
  434. data/platform/win32/RhoSimulator/Qt5V8.dll +0 -0
  435. data/platform/win32/RhoSimulator/Qt5WebKit.dll +0 -0
  436. data/platform/win32/RhoSimulator/Qt5WebKitWidgets.dll +0 -0
  437. data/platform/win32/RhoSimulator/Qt5Widgets.dll +0 -0
  438. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  439. data/platform/win32/RhoSimulator/icudt52.dll +0 -0
  440. data/platform/win32/RhoSimulator/icuin52.dll +0 -0
  441. data/platform/win32/RhoSimulator/icuuc52.dll +0 -0
  442. data/platform/win32/RhoSimulator/imageformats/qgif.dll +0 -0
  443. data/platform/win32/RhoSimulator/imageformats/qico.dll +0 -0
  444. data/platform/win32/RhoSimulator/imageformats/qjpeg.dll +0 -0
  445. data/platform/win32/RhoSimulator/imageformats/qmng.dll +0 -0
  446. data/platform/win32/RhoSimulator/imageformats/qsvg.dll +0 -0
  447. data/platform/win32/RhoSimulator/imageformats/qtga.dll +0 -0
  448. data/platform/win32/RhoSimulator/imageformats/qtiff.dll +0 -0
  449. data/platform/win32/RhoSimulator/imageformats/qwbmp.dll +0 -0
  450. data/platform/win32/RhoSimulator/libEGL.dll +0 -0
  451. data/platform/win32/RhoSimulator/libGLESv2.dll +0 -0
  452. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  453. data/platform/win32/RhoSimulator/msvcp110.dll +0 -0
  454. data/platform/win32/RhoSimulator/msvcr110.dll +0 -0
  455. data/platform/win32/RhoSimulator/platforms/qwindows.dll +0 -0
  456. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  457. data/platform/win32/RhoSimulator/vccorlib110.dll +0 -0
  458. data/platform/win32/RhoSimulator/vcomp110.dll +0 -0
@@ -0,0 +1,14 @@
1
+ #ifndef _LIBICONV_H
2
+ #define _LIBICONV_H
3
+ #include <stddef.h>
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+ typedef void* iconv_t;
8
+ iconv_t iconv_open(const char *tocode, const char *fromcode);
9
+ int iconv_close(iconv_t cd);
10
+ size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
11
+ #ifdef __cplusplus
12
+ }
13
+ #endif
14
+ #endif//_LIBICONV_H
@@ -0,0 +1,247 @@
1
+ // ISO C9x compliant stdint.h for Microsoft Visual Studio
2
+ // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3
+ //
4
+ // Copyright (c) 2006-2008 Alexander Chemeris
5
+ //
6
+ // Redistribution and use in source and binary forms, with or without
7
+ // modification, are permitted provided that the following conditions are met:
8
+ //
9
+ // 1. Redistributions of source code must retain the above copyright notice,
10
+ // this list of conditions and the following disclaimer.
11
+ //
12
+ // 2. Redistributions in binary form must reproduce the above copyright
13
+ // notice, this list of conditions and the following disclaimer in the
14
+ // documentation and/or other materials provided with the distribution.
15
+ //
16
+ // 3. The name of the author may be used to endorse or promote products
17
+ // derived from this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20
+ // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
22
+ // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
+ // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
+ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
+ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
+ // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ //
30
+ ///////////////////////////////////////////////////////////////////////////////
31
+
32
+ #ifndef _MSC_VER // [
33
+ #error "Use this header only with Microsoft Visual C++ compilers!"
34
+ #endif // _MSC_VER ]
35
+
36
+ #ifndef _MSC_STDINT_H_ // [
37
+ #define _MSC_STDINT_H_
38
+
39
+ #if _MSC_VER > 1000
40
+ #pragma once
41
+ #endif
42
+
43
+ #include <limits.h>
44
+
45
+ // For Visual Studio 6 in C++ mode and for many Visual Studio versions when
46
+ // compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
47
+ // or compiler give many errors like this:
48
+ // error C2733: second C linkage of overloaded function 'wmemchr' not allowed
49
+ #ifdef __cplusplus
50
+ extern "C" {
51
+ #endif
52
+ # include <wchar.h>
53
+ #ifdef __cplusplus
54
+ }
55
+ #endif
56
+
57
+ // Define _W64 macros to mark types changing their size, like intptr_t.
58
+ #ifndef _W64
59
+ # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
60
+ # define _W64 __w64
61
+ # else
62
+ # define _W64
63
+ # endif
64
+ #endif
65
+
66
+
67
+ // 7.18.1 Integer types
68
+
69
+ // 7.18.1.1 Exact-width integer types
70
+
71
+ // Visual Studio 6 and Embedded Visual C++ 4 doesn't
72
+ // realize that, e.g. char has the same size as __int8
73
+ // so we give up on __intX for them.
74
+ #if (_MSC_VER < 1300)
75
+ typedef signed char int8_t;
76
+ typedef signed short int16_t;
77
+ typedef signed int int32_t;
78
+ typedef unsigned char uint8_t;
79
+ typedef unsigned short uint16_t;
80
+ typedef unsigned int uint32_t;
81
+ #else
82
+ typedef signed __int8 int8_t;
83
+ typedef signed __int16 int16_t;
84
+ typedef signed __int32 int32_t;
85
+ typedef unsigned __int8 uint8_t;
86
+ typedef unsigned __int16 uint16_t;
87
+ typedef unsigned __int32 uint32_t;
88
+ #endif
89
+ typedef signed __int64 int64_t;
90
+ typedef unsigned __int64 uint64_t;
91
+
92
+
93
+ // 7.18.1.2 Minimum-width integer types
94
+ typedef int8_t int_least8_t;
95
+ typedef int16_t int_least16_t;
96
+ typedef int32_t int_least32_t;
97
+ typedef int64_t int_least64_t;
98
+ typedef uint8_t uint_least8_t;
99
+ typedef uint16_t uint_least16_t;
100
+ typedef uint32_t uint_least32_t;
101
+ typedef uint64_t uint_least64_t;
102
+
103
+ // 7.18.1.3 Fastest minimum-width integer types
104
+ typedef int8_t int_fast8_t;
105
+ typedef int16_t int_fast16_t;
106
+ typedef int32_t int_fast32_t;
107
+ typedef int64_t int_fast64_t;
108
+ typedef uint8_t uint_fast8_t;
109
+ typedef uint16_t uint_fast16_t;
110
+ typedef uint32_t uint_fast32_t;
111
+ typedef uint64_t uint_fast64_t;
112
+
113
+ // 7.18.1.4 Integer types capable of holding object pointers
114
+ #ifdef _WIN64 // [
115
+ typedef signed __int64 intptr_t;
116
+ typedef unsigned __int64 uintptr_t;
117
+ #else // _WIN64 ][
118
+ typedef _W64 signed int intptr_t;
119
+ typedef _W64 unsigned int uintptr_t;
120
+ #endif // _WIN64 ]
121
+
122
+ // 7.18.1.5 Greatest-width integer types
123
+ typedef int64_t intmax_t;
124
+ typedef uint64_t uintmax_t;
125
+
126
+
127
+ // 7.18.2 Limits of specified-width integer types
128
+
129
+ #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
130
+
131
+ // 7.18.2.1 Limits of exact-width integer types
132
+ #define INT8_MIN ((int8_t)_I8_MIN)
133
+ #define INT8_MAX _I8_MAX
134
+ #define INT16_MIN ((int16_t)_I16_MIN)
135
+ #define INT16_MAX _I16_MAX
136
+ #define INT32_MIN ((int32_t)_I32_MIN)
137
+ #define INT32_MAX _I32_MAX
138
+ #define INT64_MIN ((int64_t)_I64_MIN)
139
+ #define INT64_MAX _I64_MAX
140
+ #define UINT8_MAX _UI8_MAX
141
+ #define UINT16_MAX _UI16_MAX
142
+ #define UINT32_MAX _UI32_MAX
143
+ #define UINT64_MAX _UI64_MAX
144
+
145
+ // 7.18.2.2 Limits of minimum-width integer types
146
+ #define INT_LEAST8_MIN INT8_MIN
147
+ #define INT_LEAST8_MAX INT8_MAX
148
+ #define INT_LEAST16_MIN INT16_MIN
149
+ #define INT_LEAST16_MAX INT16_MAX
150
+ #define INT_LEAST32_MIN INT32_MIN
151
+ #define INT_LEAST32_MAX INT32_MAX
152
+ #define INT_LEAST64_MIN INT64_MIN
153
+ #define INT_LEAST64_MAX INT64_MAX
154
+ #define UINT_LEAST8_MAX UINT8_MAX
155
+ #define UINT_LEAST16_MAX UINT16_MAX
156
+ #define UINT_LEAST32_MAX UINT32_MAX
157
+ #define UINT_LEAST64_MAX UINT64_MAX
158
+
159
+ // 7.18.2.3 Limits of fastest minimum-width integer types
160
+ #define INT_FAST8_MIN INT8_MIN
161
+ #define INT_FAST8_MAX INT8_MAX
162
+ #define INT_FAST16_MIN INT16_MIN
163
+ #define INT_FAST16_MAX INT16_MAX
164
+ #define INT_FAST32_MIN INT32_MIN
165
+ #define INT_FAST32_MAX INT32_MAX
166
+ #define INT_FAST64_MIN INT64_MIN
167
+ #define INT_FAST64_MAX INT64_MAX
168
+ #define UINT_FAST8_MAX UINT8_MAX
169
+ #define UINT_FAST16_MAX UINT16_MAX
170
+ #define UINT_FAST32_MAX UINT32_MAX
171
+ #define UINT_FAST64_MAX UINT64_MAX
172
+
173
+ // 7.18.2.4 Limits of integer types capable of holding object pointers
174
+ #ifdef _WIN64 // [
175
+ # define INTPTR_MIN INT64_MIN
176
+ # define INTPTR_MAX INT64_MAX
177
+ # define UINTPTR_MAX UINT64_MAX
178
+ #else // _WIN64 ][
179
+ # define INTPTR_MIN INT32_MIN
180
+ # define INTPTR_MAX INT32_MAX
181
+ # define UINTPTR_MAX UINT32_MAX
182
+ #endif // _WIN64 ]
183
+
184
+ // 7.18.2.5 Limits of greatest-width integer types
185
+ #define INTMAX_MIN INT64_MIN
186
+ #define INTMAX_MAX INT64_MAX
187
+ #define UINTMAX_MAX UINT64_MAX
188
+
189
+ // 7.18.3 Limits of other integer types
190
+
191
+ #ifdef _WIN64 // [
192
+ # define PTRDIFF_MIN _I64_MIN
193
+ # define PTRDIFF_MAX _I64_MAX
194
+ #else // _WIN64 ][
195
+ # define PTRDIFF_MIN _I32_MIN
196
+ # define PTRDIFF_MAX _I32_MAX
197
+ #endif // _WIN64 ]
198
+
199
+ #define SIG_ATOMIC_MIN INT_MIN
200
+ #define SIG_ATOMIC_MAX INT_MAX
201
+
202
+ #ifndef SIZE_MAX // [
203
+ # ifdef _WIN64 // [
204
+ # define SIZE_MAX _UI64_MAX
205
+ # else // _WIN64 ][
206
+ # define SIZE_MAX _UI32_MAX
207
+ # endif // _WIN64 ]
208
+ #endif // SIZE_MAX ]
209
+
210
+ // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
211
+ #ifndef WCHAR_MIN // [
212
+ # define WCHAR_MIN 0
213
+ #endif // WCHAR_MIN ]
214
+ #ifndef WCHAR_MAX // [
215
+ # define WCHAR_MAX _UI16_MAX
216
+ #endif // WCHAR_MAX ]
217
+
218
+ #define WINT_MIN 0
219
+ #define WINT_MAX _UI16_MAX
220
+
221
+ #endif // __STDC_LIMIT_MACROS ]
222
+
223
+
224
+ // 7.18.4 Limits of other integer types
225
+
226
+ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
227
+
228
+ // 7.18.4.1 Macros for minimum-width integer constants
229
+
230
+ #define INT8_C(val) val##i8
231
+ #define INT16_C(val) val##i16
232
+ #define INT32_C(val) val##i32
233
+ #define INT64_C(val) val##i64
234
+
235
+ #define UINT8_C(val) val##ui8
236
+ #define UINT16_C(val) val##ui16
237
+ #define UINT32_C(val) val##ui32
238
+ #define UINT64_C(val) val##ui64
239
+
240
+ // 7.18.4.2 Macros for greatest-width integer constants
241
+ #define INTMAX_C INT64_C
242
+ #define UINTMAX_C UINT64_C
243
+
244
+ #endif // __STDC_CONSTANT_MACROS ]
245
+
246
+
247
+ #endif // _MSC_STDINT_H_ ]
@@ -0,0 +1,2035 @@
1
+ /*
2
+ * iconv implementation using Win32 API to convert.
3
+ *
4
+ * This file is placed in the public domain.
5
+ */
6
+
7
+ /* for WC_NO_BEST_FIT_CHARS */
8
+ #ifndef WINVER
9
+ # define WINVER 0x0500
10
+ #endif
11
+
12
+ #define STRICT
13
+ #include <windows.h>
14
+ #include <errno.h>
15
+ #include <string.h>
16
+ #include <stdlib.h>
17
+
18
+ /* WORKAROUND: */
19
+ #ifndef UNDER_CE
20
+ #define GetProcAddressA GetProcAddress
21
+ #endif
22
+
23
+ #if 0
24
+ # define MAKE_EXE
25
+ # define MAKE_DLL
26
+ # define USE_LIBICONV_DLL
27
+ #endif
28
+
29
+ #if !defined(DEFAULT_LIBICONV_DLL)
30
+ # define DEFAULT_LIBICONV_DLL ""
31
+ #endif
32
+
33
+ #define MB_CHAR_MAX 16
34
+
35
+ #define UNICODE_MODE_BOM_DONE 1
36
+ #define UNICODE_MODE_SWAPPED 2
37
+
38
+ #define FLAG_USE_BOM 1
39
+ #define FLAG_TRANSLIT 2 /* //TRANSLIT */
40
+ #define FLAG_IGNORE 4 /* //IGNORE */
41
+
42
+ typedef unsigned char uchar;
43
+ typedef unsigned short ushort;
44
+ typedef unsigned int uint;
45
+
46
+ typedef void* iconv_t;
47
+
48
+ iconv_t iconv_open(const char *tocode, const char *fromcode);
49
+ int iconv_close(iconv_t cd);
50
+ size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
51
+
52
+ /* libiconv interface for vim */
53
+ #if defined(MAKE_DLL)
54
+ int
55
+ iconvctl (iconv_t cd, int request, void* argument)
56
+ {
57
+ /* not supported */
58
+ return 0;
59
+ }
60
+ #endif
61
+
62
+ typedef struct compat_t compat_t;
63
+ typedef struct csconv_t csconv_t;
64
+ typedef struct rec_iconv_t rec_iconv_t;
65
+
66
+ typedef iconv_t (*f_iconv_open)(const char *tocode, const char *fromcode);
67
+ typedef int (*f_iconv_close)(iconv_t cd);
68
+ typedef size_t (*f_iconv)(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
69
+ typedef int* (*f_errno)(void);
70
+ typedef int (*f_mbtowc)(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize);
71
+ typedef int (*f_wctomb)(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize);
72
+ typedef int (*f_mblen)(csconv_t *cv, const uchar *buf, int bufsize);
73
+ typedef int (*f_flush)(csconv_t *cv, uchar *buf, int bufsize);
74
+
75
+ #define COMPAT_IN 1
76
+ #define COMPAT_OUT 2
77
+
78
+ /* unicode mapping for compatibility with other conversion table. */
79
+ struct compat_t {
80
+ uint in;
81
+ uint out;
82
+ uint flag;
83
+ };
84
+
85
+ struct csconv_t {
86
+ int codepage;
87
+ int flags;
88
+ f_mbtowc mbtowc;
89
+ f_wctomb wctomb;
90
+ f_mblen mblen;
91
+ f_flush flush;
92
+ DWORD mode;
93
+ compat_t *compat;
94
+ };
95
+
96
+ struct rec_iconv_t {
97
+ iconv_t cd;
98
+ f_iconv_close iconv_close;
99
+ f_iconv iconv;
100
+ f_errno _errno;
101
+ csconv_t from;
102
+ csconv_t to;
103
+ #if defined(USE_LIBICONV_DLL)
104
+ HMODULE hlibiconv;
105
+ #endif
106
+ };
107
+
108
+ static int win_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode);
109
+ static int win_iconv_close(iconv_t cd);
110
+ static size_t win_iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
111
+
112
+ static int load_mlang();
113
+ static int make_csconv(const char *name, csconv_t *cv);
114
+ static int name_to_codepage(const char *name);
115
+ static uint utf16_to_ucs4(const ushort *wbuf);
116
+ static void ucs4_to_utf16(uint wc, ushort *wbuf, int *wbufsize);
117
+ static int mbtowc_flags(int codepage);
118
+ static int must_use_null_useddefaultchar(int codepage);
119
+ static char *strrstr(const char *str, const char *token);
120
+ static char *xstrndup(const char *s, size_t n);
121
+ static int seterror(int err);
122
+
123
+ #if defined(USE_LIBICONV_DLL)
124
+ static int libiconv_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode);
125
+ static PVOID MyImageDirectoryEntryToData(LPVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size);
126
+ static HMODULE find_imported_module_by_funcname(HMODULE hModule, const char *funcname);
127
+
128
+ static HMODULE hwiniconv;
129
+ #endif
130
+
131
+ static int sbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize);
132
+ static int dbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize);
133
+ static int mbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize);
134
+ static int utf8_mblen(csconv_t *cv, const uchar *buf, int bufsize);
135
+ static int eucjp_mblen(csconv_t *cv, const uchar *buf, int bufsize);
136
+
137
+ static int kernel_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize);
138
+ static int kernel_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize);
139
+ static int mlang_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize);
140
+ static int mlang_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize);
141
+ static int utf16_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize);
142
+ static int utf16_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize);
143
+ static int utf32_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize);
144
+ static int utf32_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize);
145
+ static int iso2022jp_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize);
146
+ static int iso2022jp_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize);
147
+ static int iso2022jp_flush(csconv_t *cv, uchar *buf, int bufsize);
148
+
149
+ static struct {
150
+ int codepage;
151
+ const char *name;
152
+ } codepage_alias[] = {
153
+ {65001, "CP65001"},
154
+ {65001, "UTF8"},
155
+ {65001, "UTF-8"},
156
+
157
+ {1200, "CP1200"},
158
+ {1200, "UTF16LE"},
159
+ {1200, "UTF-16LE"},
160
+ {1200, "UCS2LE"},
161
+ {1200, "UCS-2LE"},
162
+
163
+ {1201, "CP1201"},
164
+ {1201, "UTF16BE"},
165
+ {1201, "UTF-16BE"},
166
+ {1201, "UCS2BE"},
167
+ {1201, "UCS-2BE"},
168
+ {1201, "unicodeFFFE"},
169
+
170
+ {12000, "CP12000"},
171
+ {12000, "UTF32LE"},
172
+ {12000, "UTF-32LE"},
173
+ {12000, "UCS4LE"},
174
+ {12000, "UCS-4LE"},
175
+
176
+ {12001, "CP12001"},
177
+ {12001, "UTF32BE"},
178
+ {12001, "UTF-32BE"},
179
+ {12001, "UCS4BE"},
180
+ {12001, "UCS-4BE"},
181
+
182
+ #ifndef GLIB_COMPILATION
183
+ /*
184
+ * Default is big endian.
185
+ * See rfc2781 4.3 Interpreting text labelled as UTF-16.
186
+ */
187
+ {1201, "UTF16"},
188
+ {1201, "UTF-16"},
189
+ {1201, "UCS2"},
190
+ {1201, "UCS-2"},
191
+ {12001, "UTF32"},
192
+ {12001, "UTF-32"},
193
+ {12001, "UCS-4"},
194
+ {12001, "UCS4"},
195
+ #else
196
+ /* Default is little endian, because the platform is */
197
+ {1200, "UTF16"},
198
+ {1200, "UTF-16"},
199
+ {1200, "UCS2"},
200
+ {1200, "UCS-2"},
201
+ {12000, "UTF32"},
202
+ {12000, "UTF-32"},
203
+ {12000, "UCS4"},
204
+ {12000, "UCS-4"},
205
+ #endif
206
+
207
+ /* copy from libiconv `iconv -l` */
208
+ /* !IsValidCodePage(367) */
209
+ {20127, "ANSI_X3.4-1968"},
210
+ {20127, "ANSI_X3.4-1986"},
211
+ {20127, "ASCII"},
212
+ {20127, "CP367"},
213
+ {20127, "IBM367"},
214
+ {20127, "ISO-IR-6"},
215
+ {20127, "ISO646-US"},
216
+ {20127, "ISO_646.IRV:1991"},
217
+ {20127, "US"},
218
+ {20127, "US-ASCII"},
219
+ {20127, "CSASCII"},
220
+
221
+ /* !IsValidCodePage(819) */
222
+ {1252, "CP819"},
223
+ {1252, "IBM819"},
224
+ {28591, "ISO-8859-1"},
225
+ {28591, "ISO-IR-100"},
226
+ {28591, "ISO8859-1"},
227
+ {28591, "ISO_8859-1"},
228
+ {28591, "ISO_8859-1:1987"},
229
+ {28591, "L1"},
230
+ {28591, "LATIN1"},
231
+ {28591, "CSISOLATIN1"},
232
+
233
+ {1250, "CP1250"},
234
+ {1250, "MS-EE"},
235
+ {1250, "WINDOWS-1250"},
236
+
237
+ {1251, "CP1251"},
238
+ {1251, "MS-CYRL"},
239
+ {1251, "WINDOWS-1251"},
240
+
241
+ {1252, "CP1252"},
242
+ {1252, "MS-ANSI"},
243
+ {1252, "WINDOWS-1252"},
244
+
245
+ {1253, "CP1253"},
246
+ {1253, "MS-GREEK"},
247
+ {1253, "WINDOWS-1253"},
248
+
249
+ {1254, "CP1254"},
250
+ {1254, "MS-TURK"},
251
+ {1254, "WINDOWS-1254"},
252
+
253
+ {1255, "CP1255"},
254
+ {1255, "MS-HEBR"},
255
+ {1255, "WINDOWS-1255"},
256
+
257
+ {1256, "CP1256"},
258
+ {1256, "MS-ARAB"},
259
+ {1256, "WINDOWS-1256"},
260
+
261
+ {1257, "CP1257"},
262
+ {1257, "WINBALTRIM"},
263
+ {1257, "WINDOWS-1257"},
264
+
265
+ {1258, "CP1258"},
266
+ {1258, "WINDOWS-1258"},
267
+
268
+ {850, "850"},
269
+ {850, "CP850"},
270
+ {850, "IBM850"},
271
+ {850, "CSPC850MULTILINGUAL"},
272
+
273
+ /* !IsValidCodePage(862) */
274
+ {862, "862"},
275
+ {862, "CP862"},
276
+ {862, "IBM862"},
277
+ {862, "CSPC862LATINHEBREW"},
278
+
279
+ {866, "866"},
280
+ {866, "CP866"},
281
+ {866, "IBM866"},
282
+ {866, "CSIBM866"},
283
+
284
+ /* !IsValidCodePage(154) */
285
+ {154, "CP154"},
286
+ {154, "CYRILLIC-ASIAN"},
287
+ {154, "PT154"},
288
+ {154, "PTCP154"},
289
+ {154, "CSPTCP154"},
290
+
291
+ /* !IsValidCodePage(1133) */
292
+ {1133, "CP1133"},
293
+ {1133, "IBM-CP1133"},
294
+
295
+ {874, "CP874"},
296
+ {874, "WINDOWS-874"},
297
+
298
+ /* !IsValidCodePage(51932) */
299
+ {51932, "CP51932"},
300
+ {51932, "MS51932"},
301
+ {51932, "WINDOWS-51932"},
302
+ {51932, "EUC-JP"},
303
+
304
+ {932, "CP932"},
305
+ {932, "MS932"},
306
+ {932, "SHIFFT_JIS"},
307
+ {932, "SHIFFT_JIS-MS"},
308
+ {932, "SJIS"},
309
+ {932, "SJIS-MS"},
310
+ {932, "SJIS-OPEN"},
311
+ {932, "SJIS-WIN"},
312
+ {932, "WINDOWS-31J"},
313
+ {932, "WINDOWS-932"},
314
+ {932, "CSWINDOWS31J"},
315
+
316
+ {50221, "CP50221"},
317
+ {50221, "ISO-2022-JP"},
318
+ {50221, "ISO-2022-JP-MS"},
319
+ {50221, "ISO2022-JP"},
320
+ {50221, "ISO2022-JP-MS"},
321
+ {50221, "MS50221"},
322
+ {50221, "WINDOWS-50221"},
323
+
324
+ {936, "CP936"},
325
+ {936, "GBK"},
326
+ {936, "MS936"},
327
+ {936, "WINDOWS-936"},
328
+
329
+ {950, "CP950"},
330
+ {950, "BIG5"},
331
+ {950, "BIG5HKSCS"},
332
+ {950, "BIG5-HKSCS"},
333
+
334
+ {949, "CP949"},
335
+ {949, "UHC"},
336
+ {949, "EUC-KR"},
337
+
338
+ {1361, "CP1361"},
339
+ {1361, "JOHAB"},
340
+
341
+ {437, "437"},
342
+ {437, "CP437"},
343
+ {437, "IBM437"},
344
+ {437, "CSPC8CODEPAGE437"},
345
+
346
+ {737, "CP737"},
347
+
348
+ {775, "CP775"},
349
+ {775, "IBM775"},
350
+ {775, "CSPC775BALTIC"},
351
+
352
+ {852, "852"},
353
+ {852, "CP852"},
354
+ {852, "IBM852"},
355
+ {852, "CSPCP852"},
356
+
357
+ /* !IsValidCodePage(853) */
358
+ {853, "CP853"},
359
+
360
+ {855, "855"},
361
+ {855, "CP855"},
362
+ {855, "IBM855"},
363
+ {855, "CSIBM855"},
364
+
365
+ {857, "857"},
366
+ {857, "CP857"},
367
+ {857, "IBM857"},
368
+ {857, "CSIBM857"},
369
+
370
+ /* !IsValidCodePage(858) */
371
+ {858, "CP858"},
372
+
373
+ {860, "860"},
374
+ {860, "CP860"},
375
+ {860, "IBM860"},
376
+ {860, "CSIBM860"},
377
+
378
+ {861, "861"},
379
+ {861, "CP-IS"},
380
+ {861, "CP861"},
381
+ {861, "IBM861"},
382
+ {861, "CSIBM861"},
383
+
384
+ {863, "863"},
385
+ {863, "CP863"},
386
+ {863, "IBM863"},
387
+ {863, "CSIBM863"},
388
+
389
+ {864, "CP864"},
390
+ {864, "IBM864"},
391
+ {864, "CSIBM864"},
392
+
393
+ {865, "865"},
394
+ {865, "CP865"},
395
+ {865, "IBM865"},
396
+ {865, "CSIBM865"},
397
+
398
+ {869, "869"},
399
+ {869, "CP-GR"},
400
+ {869, "CP869"},
401
+ {869, "IBM869"},
402
+ {869, "CSIBM869"},
403
+
404
+ /* !IsValidCodePage(1152) */
405
+ {1125, "CP1125"},
406
+
407
+ /*
408
+ * Code Page Identifiers
409
+ * http://msdn2.microsoft.com/en-us/library/ms776446.aspx
410
+ */
411
+ {37, "IBM037"}, /* IBM EBCDIC US-Canada */
412
+ {437, "IBM437"}, /* OEM United States */
413
+ {500, "IBM500"}, /* IBM EBCDIC International */
414
+ {708, "ASMO-708"}, /* Arabic (ASMO 708) */
415
+ /* 709 Arabic (ASMO-449+, BCON V4) */
416
+ /* 710 Arabic - Transparent Arabic */
417
+ {720, "DOS-720"}, /* Arabic (Transparent ASMO); Arabic (DOS) */
418
+ {737, "ibm737"}, /* OEM Greek (formerly 437G); Greek (DOS) */
419
+ {775, "ibm775"}, /* OEM Baltic; Baltic (DOS) */
420
+ {850, "ibm850"}, /* OEM Multilingual Latin 1; Western European (DOS) */
421
+ {852, "ibm852"}, /* OEM Latin 2; Central European (DOS) */
422
+ {855, "IBM855"}, /* OEM Cyrillic (primarily Russian) */
423
+ {857, "ibm857"}, /* OEM Turkish; Turkish (DOS) */
424
+ {858, "IBM00858"}, /* OEM Multilingual Latin 1 + Euro symbol */
425
+ {860, "IBM860"}, /* OEM Portuguese; Portuguese (DOS) */
426
+ {861, "ibm861"}, /* OEM Icelandic; Icelandic (DOS) */
427
+ {862, "DOS-862"}, /* OEM Hebrew; Hebrew (DOS) */
428
+ {863, "IBM863"}, /* OEM French Canadian; French Canadian (DOS) */
429
+ {864, "IBM864"}, /* OEM Arabic; Arabic (864) */
430
+ {865, "IBM865"}, /* OEM Nordic; Nordic (DOS) */
431
+ {866, "cp866"}, /* OEM Russian; Cyrillic (DOS) */
432
+ {869, "ibm869"}, /* OEM Modern Greek; Greek, Modern (DOS) */
433
+ {870, "IBM870"}, /* IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 */
434
+ {874, "windows-874"}, /* ANSI/OEM Thai (same as 28605, ISO 8859-15); Thai (Windows) */
435
+ {875, "cp875"}, /* IBM EBCDIC Greek Modern */
436
+ {932, "shift_jis"}, /* ANSI/OEM Japanese; Japanese (Shift-JIS) */
437
+ {932, "shift-jis"}, /* alternative name for it */
438
+ {936, "gb2312"}, /* ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) */
439
+ {949, "ks_c_5601-1987"}, /* ANSI/OEM Korean (Unified Hangul Code) */
440
+ {950, "big5"}, /* ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) */
441
+ {950, "big5hkscs"}, /* ANSI/OEM Traditional Chinese (Hong Kong SAR); Chinese Traditional (Big5-HKSCS) */
442
+ {950, "big5-hkscs"}, /* alternative name for it */
443
+ {1026, "IBM1026"}, /* IBM EBCDIC Turkish (Latin 5) */
444
+ {1047, "IBM01047"}, /* IBM EBCDIC Latin 1/Open System */
445
+ {1140, "IBM01140"}, /* IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) */
446
+ {1141, "IBM01141"}, /* IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) */
447
+ {1142, "IBM01142"}, /* IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) */
448
+ {1143, "IBM01143"}, /* IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) */
449
+ {1144, "IBM01144"}, /* IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) */
450
+ {1145, "IBM01145"}, /* IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) */
451
+ {1146, "IBM01146"}, /* IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) */
452
+ {1147, "IBM01147"}, /* IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) */
453
+ {1148, "IBM01148"}, /* IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) */
454
+ {1149, "IBM01149"}, /* IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) */
455
+ {1250, "windows-1250"}, /* ANSI Central European; Central European (Windows) */
456
+ {1251, "windows-1251"}, /* ANSI Cyrillic; Cyrillic (Windows) */
457
+ {1252, "windows-1252"}, /* ANSI Latin 1; Western European (Windows) */
458
+ {1253, "windows-1253"}, /* ANSI Greek; Greek (Windows) */
459
+ {1254, "windows-1254"}, /* ANSI Turkish; Turkish (Windows) */
460
+ {1255, "windows-1255"}, /* ANSI Hebrew; Hebrew (Windows) */
461
+ {1256, "windows-1256"}, /* ANSI Arabic; Arabic (Windows) */
462
+ {1257, "windows-1257"}, /* ANSI Baltic; Baltic (Windows) */
463
+ {1258, "windows-1258"}, /* ANSI/OEM Vietnamese; Vietnamese (Windows) */
464
+ {1361, "Johab"}, /* Korean (Johab) */
465
+ {10000, "macintosh"}, /* MAC Roman; Western European (Mac) */
466
+ {10001, "x-mac-japanese"}, /* Japanese (Mac) */
467
+ {10002, "x-mac-chinesetrad"}, /* MAC Traditional Chinese (Big5); Chinese Traditional (Mac) */
468
+ {10003, "x-mac-korean"}, /* Korean (Mac) */
469
+ {10004, "x-mac-arabic"}, /* Arabic (Mac) */
470
+ {10005, "x-mac-hebrew"}, /* Hebrew (Mac) */
471
+ {10006, "x-mac-greek"}, /* Greek (Mac) */
472
+ {10007, "x-mac-cyrillic"}, /* Cyrillic (Mac) */
473
+ {10008, "x-mac-chinesesimp"}, /* MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) */
474
+ {10010, "x-mac-romanian"}, /* Romanian (Mac) */
475
+ {10017, "x-mac-ukrainian"}, /* Ukrainian (Mac) */
476
+ {10021, "x-mac-thai"}, /* Thai (Mac) */
477
+ {10029, "x-mac-ce"}, /* MAC Latin 2; Central European (Mac) */
478
+ {10079, "x-mac-icelandic"}, /* Icelandic (Mac) */
479
+ {10081, "x-mac-turkish"}, /* Turkish (Mac) */
480
+ {10082, "x-mac-croatian"}, /* Croatian (Mac) */
481
+ {20000, "x-Chinese_CNS"}, /* CNS Taiwan; Chinese Traditional (CNS) */
482
+ {20001, "x-cp20001"}, /* TCA Taiwan */
483
+ {20002, "x_Chinese-Eten"}, /* Eten Taiwan; Chinese Traditional (Eten) */
484
+ {20003, "x-cp20003"}, /* IBM5550 Taiwan */
485
+ {20004, "x-cp20004"}, /* TeleText Taiwan */
486
+ {20005, "x-cp20005"}, /* Wang Taiwan */
487
+ {20105, "x-IA5"}, /* IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) */
488
+ {20106, "x-IA5-German"}, /* IA5 German (7-bit) */
489
+ {20107, "x-IA5-Swedish"}, /* IA5 Swedish (7-bit) */
490
+ {20108, "x-IA5-Norwegian"}, /* IA5 Norwegian (7-bit) */
491
+ {20127, "us-ascii"}, /* US-ASCII (7-bit) */
492
+ {20261, "x-cp20261"}, /* T.61 */
493
+ {20269, "x-cp20269"}, /* ISO 6937 Non-Spacing Accent */
494
+ {20273, "IBM273"}, /* IBM EBCDIC Germany */
495
+ {20277, "IBM277"}, /* IBM EBCDIC Denmark-Norway */
496
+ {20278, "IBM278"}, /* IBM EBCDIC Finland-Sweden */
497
+ {20280, "IBM280"}, /* IBM EBCDIC Italy */
498
+ {20284, "IBM284"}, /* IBM EBCDIC Latin America-Spain */
499
+ {20285, "IBM285"}, /* IBM EBCDIC United Kingdom */
500
+ {20290, "IBM290"}, /* IBM EBCDIC Japanese Katakana Extended */
501
+ {20297, "IBM297"}, /* IBM EBCDIC France */
502
+ {20420, "IBM420"}, /* IBM EBCDIC Arabic */
503
+ {20423, "IBM423"}, /* IBM EBCDIC Greek */
504
+ {20424, "IBM424"}, /* IBM EBCDIC Hebrew */
505
+ {20833, "x-EBCDIC-KoreanExtended"}, /* IBM EBCDIC Korean Extended */
506
+ {20838, "IBM-Thai"}, /* IBM EBCDIC Thai */
507
+ {20866, "koi8-r"}, /* Russian (KOI8-R); Cyrillic (KOI8-R) */
508
+ {20871, "IBM871"}, /* IBM EBCDIC Icelandic */
509
+ {20880, "IBM880"}, /* IBM EBCDIC Cyrillic Russian */
510
+ {20905, "IBM905"}, /* IBM EBCDIC Turkish */
511
+ {20924, "IBM00924"}, /* IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) */
512
+ {20932, "EUC-JP"}, /* Japanese (JIS 0208-1990 and 0121-1990) */
513
+ {20936, "x-cp20936"}, /* Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) */
514
+ {20949, "x-cp20949"}, /* Korean Wansung */
515
+ {21025, "cp1025"}, /* IBM EBCDIC Cyrillic Serbian-Bulgarian */
516
+ /* 21027 (deprecated) */
517
+ {21866, "koi8-u"}, /* Ukrainian (KOI8-U); Cyrillic (KOI8-U) */
518
+ {28591, "iso-8859-1"}, /* ISO 8859-1 Latin 1; Western European (ISO) */
519
+ {28591, "iso8859-1"}, /* ISO 8859-1 Latin 1; Western European (ISO) */
520
+ {28592, "iso-8859-2"}, /* ISO 8859-2 Central European; Central European (ISO) */
521
+ {28592, "iso8859-2"}, /* ISO 8859-2 Central European; Central European (ISO) */
522
+ {28593, "iso-8859-3"}, /* ISO 8859-3 Latin 3 */
523
+ {28593, "iso8859-3"}, /* ISO 8859-3 Latin 3 */
524
+ {28594, "iso-8859-4"}, /* ISO 8859-4 Baltic */
525
+ {28594, "iso8859-4"}, /* ISO 8859-4 Baltic */
526
+ {28595, "iso-8859-5"}, /* ISO 8859-5 Cyrillic */
527
+ {28595, "iso8859-5"}, /* ISO 8859-5 Cyrillic */
528
+ {28596, "iso-8859-6"}, /* ISO 8859-6 Arabic */
529
+ {28596, "iso8859-6"}, /* ISO 8859-6 Arabic */
530
+ {28597, "iso-8859-7"}, /* ISO 8859-7 Greek */
531
+ {28597, "iso8859-7"}, /* ISO 8859-7 Greek */
532
+ {28598, "iso-8859-8"}, /* ISO 8859-8 Hebrew; Hebrew (ISO-Visual) */
533
+ {28598, "iso8859-8"}, /* ISO 8859-8 Hebrew; Hebrew (ISO-Visual) */
534
+ {28599, "iso-8859-9"}, /* ISO 8859-9 Turkish */
535
+ {28599, "iso8859-9"}, /* ISO 8859-9 Turkish */
536
+ {28603, "iso-8859-13"}, /* ISO 8859-13 Estonian */
537
+ {28603, "iso8859-13"}, /* ISO 8859-13 Estonian */
538
+ {28605, "iso-8859-15"}, /* ISO 8859-15 Latin 9 */
539
+ {28605, "iso8859-15"}, /* ISO 8859-15 Latin 9 */
540
+ {29001, "x-Europa"}, /* Europa 3 */
541
+ {38598, "iso-8859-8-i"}, /* ISO 8859-8 Hebrew; Hebrew (ISO-Logical) */
542
+ {38598, "iso8859-8-i"}, /* ISO 8859-8 Hebrew; Hebrew (ISO-Logical) */
543
+ {50220, "iso-2022-jp"}, /* ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) */
544
+ {50221, "csISO2022JP"}, /* ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) */
545
+ {50222, "iso-2022-jp"}, /* ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) */
546
+ {50225, "iso-2022-kr"}, /* ISO 2022 Korean */
547
+ {50225, "iso2022-kr"}, /* ISO 2022 Korean */
548
+ {50227, "x-cp50227"}, /* ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) */
549
+ /* 50229 ISO 2022 Traditional Chinese */
550
+ /* 50930 EBCDIC Japanese (Katakana) Extended */
551
+ /* 50931 EBCDIC US-Canada and Japanese */
552
+ /* 50933 EBCDIC Korean Extended and Korean */
553
+ /* 50935 EBCDIC Simplified Chinese Extended and Simplified Chinese */
554
+ /* 50936 EBCDIC Simplified Chinese */
555
+ /* 50937 EBCDIC US-Canada and Traditional Chinese */
556
+ /* 50939 EBCDIC Japanese (Latin) Extended and Japanese */
557
+ {51932, "euc-jp"}, /* EUC Japanese */
558
+ {51936, "EUC-CN"}, /* EUC Simplified Chinese; Chinese Simplified (EUC) */
559
+ {51949, "euc-kr"}, /* EUC Korean */
560
+ /* 51950 EUC Traditional Chinese */
561
+ {52936, "hz-gb-2312"}, /* HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) */
562
+ {54936, "GB18030"}, /* Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) */
563
+ {57002, "x-iscii-de"}, /* ISCII Devanagari */
564
+ {57003, "x-iscii-be"}, /* ISCII Bengali */
565
+ {57004, "x-iscii-ta"}, /* ISCII Tamil */
566
+ {57005, "x-iscii-te"}, /* ISCII Telugu */
567
+ {57006, "x-iscii-as"}, /* ISCII Assamese */
568
+ {57007, "x-iscii-or"}, /* ISCII Oriya */
569
+ {57008, "x-iscii-ka"}, /* ISCII Kannada */
570
+ {57009, "x-iscii-ma"}, /* ISCII Malayalam */
571
+ {57010, "x-iscii-gu"}, /* ISCII Gujarati */
572
+ {57011, "x-iscii-pa"}, /* ISCII Punjabi */
573
+
574
+ {0, NULL}
575
+ };
576
+
577
+ /*
578
+ * SJIS SHIFTJIS table CP932 table
579
+ * ---- --------------------------- --------------------------------
580
+ * 5C U+00A5 YEN SIGN U+005C REVERSE SOLIDUS
581
+ * 7E U+203E OVERLINE U+007E TILDE
582
+ * 815C U+2014 EM DASH U+2015 HORIZONTAL BAR
583
+ * 815F U+005C REVERSE SOLIDUS U+FF3C FULLWIDTH REVERSE SOLIDUS
584
+ * 8160 U+301C WAVE DASH U+FF5E FULLWIDTH TILDE
585
+ * 8161 U+2016 DOUBLE VERTICAL LINE U+2225 PARALLEL TO
586
+ * 817C U+2212 MINUS SIGN U+FF0D FULLWIDTH HYPHEN-MINUS
587
+ * 8191 U+00A2 CENT SIGN U+FFE0 FULLWIDTH CENT SIGN
588
+ * 8192 U+00A3 POUND SIGN U+FFE1 FULLWIDTH POUND SIGN
589
+ * 81CA U+00AC NOT SIGN U+FFE2 FULLWIDTH NOT SIGN
590
+ *
591
+ * EUC-JP and ISO-2022-JP should be compatible with CP932.
592
+ *
593
+ * Kernel and MLang have different Unicode mapping table. Make sure
594
+ * which API is used.
595
+ */
596
+ static compat_t cp932_compat[] = {
597
+ {0x00A5, 0x005C, COMPAT_OUT},
598
+ {0x203E, 0x007E, COMPAT_OUT},
599
+ {0x2014, 0x2015, COMPAT_OUT},
600
+ {0x301C, 0xFF5E, COMPAT_OUT},
601
+ {0x2016, 0x2225, COMPAT_OUT},
602
+ {0x2212, 0xFF0D, COMPAT_OUT},
603
+ {0x00A2, 0xFFE0, COMPAT_OUT},
604
+ {0x00A3, 0xFFE1, COMPAT_OUT},
605
+ {0x00AC, 0xFFE2, COMPAT_OUT},
606
+ {0, 0, 0}
607
+ };
608
+
609
+ static compat_t cp20932_compat[] = {
610
+ {0x00A5, 0x005C, COMPAT_OUT},
611
+ {0x203E, 0x007E, COMPAT_OUT},
612
+ {0x2014, 0x2015, COMPAT_OUT},
613
+ {0xFF5E, 0x301C, COMPAT_OUT|COMPAT_IN},
614
+ {0x2225, 0x2016, COMPAT_OUT|COMPAT_IN},
615
+ {0xFF0D, 0x2212, COMPAT_OUT|COMPAT_IN},
616
+ {0xFFE0, 0x00A2, COMPAT_OUT|COMPAT_IN},
617
+ {0xFFE1, 0x00A3, COMPAT_OUT|COMPAT_IN},
618
+ {0xFFE2, 0x00AC, COMPAT_OUT|COMPAT_IN},
619
+ {0, 0, 0}
620
+ };
621
+
622
+ static compat_t *cp51932_compat = cp932_compat;
623
+
624
+ /* cp20932_compat for kernel. cp932_compat for mlang. */
625
+ static compat_t *cp5022x_compat = cp932_compat;
626
+
627
+ typedef HRESULT (WINAPI *CONVERTINETSTRING)(
628
+ LPDWORD lpdwMode,
629
+ DWORD dwSrcEncoding,
630
+ DWORD dwDstEncoding,
631
+ LPCSTR lpSrcStr,
632
+ LPINT lpnSrcSize,
633
+ LPBYTE lpDstStr,
634
+ LPINT lpnDstSize
635
+ );
636
+ typedef HRESULT (WINAPI *CONVERTINETMULTIBYTETOUNICODE)(
637
+ LPDWORD lpdwMode,
638
+ DWORD dwSrcEncoding,
639
+ LPCSTR lpSrcStr,
640
+ LPINT lpnMultiCharCount,
641
+ LPWSTR lpDstStr,
642
+ LPINT lpnWideCharCount
643
+ );
644
+ typedef HRESULT (WINAPI *CONVERTINETUNICODETOMULTIBYTE)(
645
+ LPDWORD lpdwMode,
646
+ DWORD dwEncoding,
647
+ LPCWSTR lpSrcStr,
648
+ LPINT lpnWideCharCount,
649
+ LPSTR lpDstStr,
650
+ LPINT lpnMultiCharCount
651
+ );
652
+ typedef HRESULT (WINAPI *ISCONVERTINETSTRINGAVAILABLE)(
653
+ DWORD dwSrcEncoding,
654
+ DWORD dwDstEncoding
655
+ );
656
+ typedef HRESULT (WINAPI *LCIDTORFC1766A)(
657
+ LCID Locale,
658
+ LPSTR pszRfc1766,
659
+ int nChar
660
+ );
661
+ typedef HRESULT (WINAPI *LCIDTORFC1766W)(
662
+ LCID Locale,
663
+ LPWSTR pszRfc1766,
664
+ int nChar
665
+ );
666
+ typedef HRESULT (WINAPI *RFC1766TOLCIDA)(
667
+ LCID *pLocale,
668
+ LPSTR pszRfc1766
669
+ );
670
+ typedef HRESULT (WINAPI *RFC1766TOLCIDW)(
671
+ LCID *pLocale,
672
+ LPWSTR pszRfc1766
673
+ );
674
+ static CONVERTINETSTRING ConvertINetString;
675
+ static CONVERTINETMULTIBYTETOUNICODE ConvertINetMultiByteToUnicode;
676
+ static CONVERTINETUNICODETOMULTIBYTE ConvertINetUnicodeToMultiByte;
677
+ static ISCONVERTINETSTRINGAVAILABLE IsConvertINetStringAvailable;
678
+ static LCIDTORFC1766A LcidToRfc1766A;
679
+ static RFC1766TOLCIDA Rfc1766ToLcidA;
680
+
681
+ static int
682
+ load_mlang()
683
+ {
684
+ HMODULE h;
685
+ if (ConvertINetString != NULL)
686
+ return TRUE;
687
+ h = LoadLibrary(TEXT("mlang.dll"));
688
+ if (!h)
689
+ return FALSE;
690
+ ConvertINetString = (CONVERTINETSTRING)GetProcAddressA(h, "ConvertINetString");
691
+ ConvertINetMultiByteToUnicode = (CONVERTINETMULTIBYTETOUNICODE)GetProcAddressA(h, "ConvertINetMultiByteToUnicode");
692
+ ConvertINetUnicodeToMultiByte = (CONVERTINETUNICODETOMULTIBYTE)GetProcAddressA(h, "ConvertINetUnicodeToMultiByte");
693
+ IsConvertINetStringAvailable = (ISCONVERTINETSTRINGAVAILABLE)GetProcAddressA(h, "IsConvertINetStringAvailable");
694
+ LcidToRfc1766A = (LCIDTORFC1766A)GetProcAddressA(h, "LcidToRfc1766A");
695
+ Rfc1766ToLcidA = (RFC1766TOLCIDA)GetProcAddressA(h, "Rfc1766ToLcidA");
696
+ return TRUE;
697
+ }
698
+
699
+ iconv_t
700
+ iconv_open(const char *tocode, const char *fromcode)
701
+ {
702
+ rec_iconv_t *cd;
703
+
704
+ cd = (rec_iconv_t *)calloc(1, sizeof(rec_iconv_t));
705
+ if (cd == NULL)
706
+ return (iconv_t)(-1);
707
+
708
+ #if defined(USE_LIBICONV_DLL)
709
+ errno = 0;
710
+ if (libiconv_iconv_open(cd, tocode, fromcode))
711
+ return (iconv_t)cd;
712
+ #endif
713
+
714
+ /* reset the errno to prevent reporting wrong error code.
715
+ * 0 for unsorted error. */
716
+ errno = 0;
717
+ if (win_iconv_open(cd, tocode, fromcode))
718
+ return (iconv_t)cd;
719
+
720
+ free(cd);
721
+
722
+ return (iconv_t)(-1);
723
+ }
724
+
725
+ int
726
+ iconv_close(iconv_t _cd)
727
+ {
728
+ rec_iconv_t *cd = (rec_iconv_t *)_cd;
729
+ int r = cd->iconv_close(cd->cd);
730
+ int e = *(cd->_errno());
731
+ #if defined(USE_LIBICONV_DLL)
732
+ if (cd->hlibiconv != NULL)
733
+ FreeLibrary(cd->hlibiconv);
734
+ #endif
735
+ free(cd);
736
+ errno = e;
737
+ return r;
738
+ }
739
+
740
+ size_t
741
+ iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
742
+ {
743
+ rec_iconv_t *cd = (rec_iconv_t *)_cd;
744
+ size_t r = cd->iconv(cd->cd, inbuf, inbytesleft, outbuf, outbytesleft);
745
+ errno = *(cd->_errno());
746
+ return r;
747
+ }
748
+
749
+ static int
750
+ win_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode)
751
+ {
752
+ if (!make_csconv(fromcode, &cd->from) || !make_csconv(tocode, &cd->to))
753
+ return FALSE;
754
+ cd->iconv_close = win_iconv_close;
755
+ cd->iconv = win_iconv;
756
+ cd->_errno = _errno;
757
+ cd->cd = (iconv_t)cd;
758
+ return TRUE;
759
+ }
760
+
761
+ static int
762
+ win_iconv_close(iconv_t cd)
763
+ {
764
+ return 0;
765
+ }
766
+
767
+ static size_t
768
+ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
769
+ {
770
+ rec_iconv_t *cd = (rec_iconv_t *)_cd;
771
+ ushort wbuf[MB_CHAR_MAX]; /* enough room for one character */
772
+ int insize;
773
+ int outsize;
774
+ int wsize;
775
+ DWORD frommode;
776
+ DWORD tomode;
777
+ uint wc;
778
+ compat_t *cp;
779
+ int i;
780
+
781
+ if (inbuf == NULL || *inbuf == NULL)
782
+ {
783
+ if (outbuf != NULL && *outbuf != NULL && cd->to.flush != NULL)
784
+ {
785
+ tomode = cd->to.mode;
786
+ outsize = cd->to.flush(&cd->to, (uchar *)*outbuf, *outbytesleft);
787
+ if (outsize == -1)
788
+ {
789
+ if ((cd->to.flags & FLAG_IGNORE) && errno != E2BIG)
790
+ {
791
+ outsize = 0;
792
+ }
793
+ else
794
+ {
795
+ cd->to.mode = tomode;
796
+ return (size_t)(-1);
797
+ }
798
+ }
799
+ *outbuf += outsize;
800
+ *outbytesleft -= outsize;
801
+ }
802
+ cd->from.mode = 0;
803
+ cd->to.mode = 0;
804
+ return 0;
805
+ }
806
+
807
+ while (*inbytesleft != 0)
808
+ {
809
+ frommode = cd->from.mode;
810
+ tomode = cd->to.mode;
811
+ wsize = MB_CHAR_MAX;
812
+
813
+ insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf, *inbytesleft, wbuf, &wsize);
814
+ if (insize == -1)
815
+ {
816
+ if (cd->to.flags & FLAG_IGNORE)
817
+ {
818
+ cd->from.mode = frommode;
819
+ insize = 1;
820
+ wsize = 0;
821
+ }
822
+ else
823
+ {
824
+ cd->from.mode = frommode;
825
+ return (size_t)(-1);
826
+ }
827
+ }
828
+
829
+ if (wsize == 0)
830
+ {
831
+ *inbuf += insize;
832
+ *inbytesleft -= insize;
833
+ continue;
834
+ }
835
+
836
+ if (cd->from.compat != NULL)
837
+ {
838
+ wc = utf16_to_ucs4(wbuf);
839
+ cp = cd->from.compat;
840
+ for (i = 0; cp[i].in != 0; ++i)
841
+ {
842
+ if ((cp[i].flag & COMPAT_IN) && cp[i].out == wc)
843
+ {
844
+ ucs4_to_utf16(cp[i].in, wbuf, &wsize);
845
+ break;
846
+ }
847
+ }
848
+ }
849
+
850
+ if (cd->to.compat != NULL)
851
+ {
852
+ wc = utf16_to_ucs4(wbuf);
853
+ cp = cd->to.compat;
854
+ for (i = 0; cp[i].in != 0; ++i)
855
+ {
856
+ if ((cp[i].flag & COMPAT_OUT) && cp[i].in == wc)
857
+ {
858
+ ucs4_to_utf16(cp[i].out, wbuf, &wsize);
859
+ break;
860
+ }
861
+ }
862
+ }
863
+
864
+ outsize = cd->to.wctomb(&cd->to, wbuf, wsize, (uchar *)*outbuf, *outbytesleft);
865
+ if (outsize == -1)
866
+ {
867
+ if ((cd->to.flags & FLAG_IGNORE) && errno != E2BIG)
868
+ {
869
+ cd->to.mode = tomode;
870
+ outsize = 0;
871
+ }
872
+ else
873
+ {
874
+ cd->from.mode = frommode;
875
+ cd->to.mode = tomode;
876
+ return (size_t)(-1);
877
+ }
878
+ }
879
+
880
+ *inbuf += insize;
881
+ *outbuf += outsize;
882
+ *inbytesleft -= insize;
883
+ *outbytesleft -= outsize;
884
+ }
885
+
886
+ return 0;
887
+ }
888
+
889
+ static int
890
+ make_csconv(const char *_name, csconv_t *cv)
891
+ {
892
+ CPINFO cpinfo;
893
+ int use_compat = TRUE;
894
+ int flag = 0;
895
+ char *name;
896
+ char *p;
897
+
898
+ name = xstrndup(_name, strlen(_name));
899
+ if (name == NULL)
900
+ return FALSE;
901
+
902
+ /* check for option "enc_name//opt1//opt2" */
903
+ while ((p = strrstr(name, "//")) != NULL)
904
+ {
905
+ if (_stricmp(p + 2, "nocompat") == 0)
906
+ use_compat = FALSE;
907
+ else if (_stricmp(p + 2, "translit") == 0)
908
+ flag |= FLAG_TRANSLIT;
909
+ else if (_stricmp(p + 2, "ignore") == 0)
910
+ flag |= FLAG_IGNORE;
911
+ *p = 0;
912
+ }
913
+
914
+ cv->mode = 0;
915
+ cv->flags = flag;
916
+ cv->mblen = NULL;
917
+ cv->flush = NULL;
918
+ cv->compat = NULL;
919
+ cv->codepage = name_to_codepage(name);
920
+ if (cv->codepage == 1200 || cv->codepage == 1201)
921
+ {
922
+ cv->mbtowc = utf16_mbtowc;
923
+ cv->wctomb = utf16_wctomb;
924
+ if (_stricmp(name, "UTF-16") == 0 || _stricmp(name, "UTF16") == 0 ||
925
+ _stricmp(name, "UCS-2") == 0 || _stricmp(name, "UCS2") == 0)
926
+ cv->flags |= FLAG_USE_BOM;
927
+ }
928
+ else if (cv->codepage == 12000 || cv->codepage == 12001)
929
+ {
930
+ cv->mbtowc = utf32_mbtowc;
931
+ cv->wctomb = utf32_wctomb;
932
+ if (_stricmp(name, "UTF-32") == 0 || _stricmp(name, "UTF32") == 0 ||
933
+ _stricmp(name, "UCS-4") == 0 || _stricmp(name, "UCS4") == 0)
934
+ cv->flags |= FLAG_USE_BOM;
935
+ }
936
+ else if (cv->codepage == 65001)
937
+ {
938
+ cv->mbtowc = kernel_mbtowc;
939
+ cv->wctomb = kernel_wctomb;
940
+ cv->mblen = utf8_mblen;
941
+ }
942
+ else if ((cv->codepage == 50220 || cv->codepage == 50221 || cv->codepage == 50222) && load_mlang())
943
+ {
944
+ cv->mbtowc = iso2022jp_mbtowc;
945
+ cv->wctomb = iso2022jp_wctomb;
946
+ cv->flush = iso2022jp_flush;
947
+ }
948
+ else if (cv->codepage == 51932 && load_mlang())
949
+ {
950
+ cv->mbtowc = mlang_mbtowc;
951
+ cv->wctomb = mlang_wctomb;
952
+ cv->mblen = eucjp_mblen;
953
+ }
954
+ else if (IsValidCodePage(cv->codepage)
955
+ && GetCPInfo(cv->codepage, &cpinfo) != 0)
956
+ {
957
+ cv->mbtowc = kernel_mbtowc;
958
+ cv->wctomb = kernel_wctomb;
959
+ if (cpinfo.MaxCharSize == 1)
960
+ cv->mblen = sbcs_mblen;
961
+ else if (cpinfo.MaxCharSize == 2)
962
+ cv->mblen = dbcs_mblen;
963
+ else
964
+ cv->mblen = mbcs_mblen;
965
+ }
966
+ else
967
+ {
968
+ /* not supported */
969
+ free(name);
970
+ errno = EINVAL;
971
+ return FALSE;
972
+ }
973
+
974
+ if (use_compat)
975
+ {
976
+ switch (cv->codepage)
977
+ {
978
+ case 932: cv->compat = cp932_compat; break;
979
+ case 20932: cv->compat = cp20932_compat; break;
980
+ case 51932: cv->compat = cp51932_compat; break;
981
+ case 50220: case 50221: case 50222: cv->compat = cp5022x_compat; break;
982
+ }
983
+ }
984
+
985
+ free(name);
986
+
987
+ return TRUE;
988
+ }
989
+
990
+ static int
991
+ name_to_codepage(const char *name)
992
+ {
993
+ int i;
994
+
995
+ if (*name == '\0' ||
996
+ strcmp(name, "char") == 0)
997
+ return GetACP();
998
+ else if (strcmp(name, "wchar_t") == 0)
999
+ return 1200;
1000
+ else if (_strnicmp(name, "cp", 2) == 0)
1001
+ return atoi(name + 2); /* CP123 */
1002
+ else if ('0' <= name[0] && name[0] <= '9')
1003
+ return atoi(name); /* 123 */
1004
+ else if (_strnicmp(name, "xx", 2) == 0)
1005
+ return atoi(name + 2); /* XX123 for debug */
1006
+
1007
+ for (i = 0; codepage_alias[i].name != NULL; ++i)
1008
+ if (_stricmp(name, codepage_alias[i].name) == 0)
1009
+ return codepage_alias[i].codepage;
1010
+ return -1;
1011
+ }
1012
+
1013
+ /*
1014
+ * http://www.faqs.org/rfcs/rfc2781.html
1015
+ */
1016
+ static uint
1017
+ utf16_to_ucs4(const ushort *wbuf)
1018
+ {
1019
+ uint wc = wbuf[0];
1020
+ if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF)
1021
+ wc = ((wbuf[0] & 0x3FF) << 10) + (wbuf[1] & 0x3FF) + 0x10000;
1022
+ return wc;
1023
+ }
1024
+
1025
+ static void
1026
+ ucs4_to_utf16(uint wc, ushort *wbuf, int *wbufsize)
1027
+ {
1028
+ if (wc < 0x10000)
1029
+ {
1030
+ wbuf[0] = wc;
1031
+ *wbufsize = 1;
1032
+ }
1033
+ else
1034
+ {
1035
+ wc -= 0x10000;
1036
+ wbuf[0] = 0xD800 | ((wc >> 10) & 0x3FF);
1037
+ wbuf[1] = 0xDC00 | (wc & 0x3FF);
1038
+ *wbufsize = 2;
1039
+ }
1040
+ }
1041
+
1042
+ /*
1043
+ * Check if codepage is one of those for which the dwFlags parameter
1044
+ * to MultiByteToWideChar() must be zero. Return zero or
1045
+ * MB_ERR_INVALID_CHARS. The docs in Platform SDK for for Windows
1046
+ * Server 2003 R2 claims that also codepage 65001 is one of these, but
1047
+ * that doesn't seem to be the case. The MSDN docs for MSVS2008 leave
1048
+ * out 65001 (UTF-8), and that indeed seems to be the case on XP, it
1049
+ * works fine to pass MB_ERR_INVALID_CHARS in dwFlags when converting
1050
+ * from UTF-8.
1051
+ */
1052
+ static int
1053
+ mbtowc_flags(int codepage)
1054
+ {
1055
+ return (codepage == 50220 || codepage == 50221 ||
1056
+ codepage == 50222 || codepage == 50225 ||
1057
+ codepage == 50227 || codepage == 50229 ||
1058
+ codepage == 52936 || codepage == 54936 ||
1059
+ (codepage >= 57002 && codepage <= 57011) ||
1060
+ codepage == 65000 || codepage == 42) ? 0 : MB_ERR_INVALID_CHARS;
1061
+ }
1062
+
1063
+ /*
1064
+ * Check if codepage is one those for which the lpUsedDefaultChar
1065
+ * parameter to WideCharToMultiByte() must be NULL. The docs in
1066
+ * Platform SDK for for Windows Server 2003 R2 claims that this is the
1067
+ * list below, while the MSDN docs for MSVS2008 claim that it is only
1068
+ * for 65000 (UTF-7) and 65001 (UTF-8). This time the earlier Platform
1069
+ * SDK seems to be correct, at least for XP.
1070
+ */
1071
+ static int
1072
+ must_use_null_useddefaultchar(int codepage)
1073
+ {
1074
+ return (codepage == 65000 || codepage == 65001 ||
1075
+ codepage == 50220 || codepage == 50221 ||
1076
+ codepage == 50222 || codepage == 50225 ||
1077
+ codepage == 50227 || codepage == 50229 ||
1078
+ codepage == 52936 || codepage == 54936 ||
1079
+ (codepage >= 57002 && codepage <= 57011) ||
1080
+ codepage == 42);
1081
+ }
1082
+
1083
+ static char *
1084
+ strrstr(const char *str, const char *token)
1085
+ {
1086
+ int len = strlen(token);
1087
+ const char *p = str + strlen(str);
1088
+
1089
+ while (str <= --p)
1090
+ if (p[0] == token[0] && strncmp(p, token, len) == 0)
1091
+ return (char *)p;
1092
+ return NULL;
1093
+ }
1094
+
1095
+ static char *
1096
+ xstrndup(const char *s, size_t n)
1097
+ {
1098
+ char *p;
1099
+
1100
+ p = (char *)malloc(n + 1);
1101
+ if (p == NULL)
1102
+ return NULL;
1103
+ memcpy(p, s, n);
1104
+ p[n] = '\0';
1105
+ return p;
1106
+ }
1107
+
1108
+ static int
1109
+ seterror(int err)
1110
+ {
1111
+ errno = err;
1112
+ return -1;
1113
+ }
1114
+
1115
+ #if defined(USE_LIBICONV_DLL)
1116
+ static int
1117
+ libiconv_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode)
1118
+ {
1119
+ HMODULE hlibiconv = NULL;
1120
+ HMODULE hmsvcrt = NULL;
1121
+ char *dllname;
1122
+ const char *p;
1123
+ const char *e;
1124
+ f_iconv_open _iconv_open;
1125
+
1126
+ /*
1127
+ * always try to load dll, so that we can switch dll in runtime.
1128
+ */
1129
+
1130
+ /* XXX: getenv() can't get variable set by SetEnvironmentVariable() */
1131
+ p = getenv("WINICONV_LIBICONV_DLL");
1132
+ if (p == NULL)
1133
+ p = DEFAULT_LIBICONV_DLL;
1134
+ /* parse comma separated value */
1135
+ for ( ; *p != 0; p = (*e == ',') ? e + 1 : e)
1136
+ {
1137
+ e = strchr(p, ',');
1138
+ if (p == e)
1139
+ continue;
1140
+ else if (e == NULL)
1141
+ e = p + strlen(p);
1142
+ dllname = xstrndup(p, e - p);
1143
+ if (dllname == NULL)
1144
+ return FALSE;
1145
+ hlibiconv = LoadLibraryA(dllname);
1146
+ free(dllname);
1147
+ if (hlibiconv != NULL)
1148
+ {
1149
+ if (hlibiconv == hwiniconv)
1150
+ {
1151
+ FreeLibrary(hlibiconv);
1152
+ hlibiconv = NULL;
1153
+ continue;
1154
+ }
1155
+ break;
1156
+ }
1157
+ }
1158
+
1159
+ if (hlibiconv == NULL)
1160
+ goto failed;
1161
+
1162
+ hmsvcrt = find_imported_module_by_funcname(hlibiconv, "_errno");
1163
+ if (hmsvcrt == NULL)
1164
+ goto failed;
1165
+
1166
+ _iconv_open = (f_iconv_open)GetProcAddressA(hlibiconv, "libiconv_open");
1167
+ if (_iconv_open == NULL)
1168
+ _iconv_open = (f_iconv_open)GetProcAddressA(hlibiconv, "iconv_open");
1169
+ cd->iconv_close = (f_iconv_close)GetProcAddressA(hlibiconv, "libiconv_close");
1170
+ if (cd->iconv_close == NULL)
1171
+ cd->iconv_close = (f_iconv_close)GetProcAddressA(hlibiconv, "iconv_close");
1172
+ cd->iconv = (f_iconv)GetProcAddressA(hlibiconv, "libiconv");
1173
+ if (cd->iconv == NULL)
1174
+ cd->iconv = (f_iconv)GetProcAddressA(hlibiconv, "iconv");
1175
+ cd->_errno = (f_errno)GetProcAddressA(hmsvcrt, "_errno");
1176
+ if (_iconv_open == NULL || cd->iconv_close == NULL
1177
+ || cd->iconv == NULL || cd->_errno == NULL)
1178
+ goto failed;
1179
+
1180
+ cd->cd = _iconv_open(tocode, fromcode);
1181
+ if (cd->cd == (iconv_t)(-1))
1182
+ goto failed;
1183
+
1184
+ cd->hlibiconv = hlibiconv;
1185
+ return TRUE;
1186
+
1187
+ failed:
1188
+ if (hlibiconv != NULL)
1189
+ FreeLibrary(hlibiconv);
1190
+ /* do not free hmsvcrt which is obtained by GetModuleHandle() */
1191
+ return FALSE;
1192
+ }
1193
+
1194
+ /*
1195
+ * Reference:
1196
+ * http://forums.belution.com/ja/vc/000/234/78s.shtml
1197
+ * http://nienie.com/~masapico/api_ImageDirectoryEntryToData.html
1198
+ *
1199
+ * The formal way is
1200
+ * imagehlp.h or dbghelp.h
1201
+ * imagehlp.lib or dbghelp.lib
1202
+ * ImageDirectoryEntryToData()
1203
+ */
1204
+ #define TO_DOS_HEADER(base) ((PIMAGE_DOS_HEADER)(base))
1205
+ #define TO_NT_HEADERS(base) ((PIMAGE_NT_HEADERS)((LPBYTE)(base) + TO_DOS_HEADER(base)->e_lfanew))
1206
+ static PVOID
1207
+ MyImageDirectoryEntryToData(LPVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size)
1208
+ {
1209
+ /* TODO: MappedAsImage? */
1210
+ PIMAGE_DATA_DIRECTORY p;
1211
+ p = TO_NT_HEADERS(Base)->OptionalHeader.DataDirectory + DirectoryEntry;
1212
+ if (p->VirtualAddress == 0) {
1213
+ *Size = 0;
1214
+ return NULL;
1215
+ }
1216
+ *Size = p->Size;
1217
+ return (PVOID)((LPBYTE)Base + p->VirtualAddress);
1218
+ }
1219
+
1220
+ static HMODULE
1221
+ find_imported_module_by_funcname(HMODULE hModule, const char *funcname)
1222
+ {
1223
+ DWORD_PTR Base;
1224
+ ULONG Size;
1225
+ PIMAGE_IMPORT_DESCRIPTOR Imp;
1226
+ PIMAGE_THUNK_DATA Name; /* Import Name Table */
1227
+ PIMAGE_IMPORT_BY_NAME ImpName;
1228
+
1229
+ Base = (DWORD_PTR)hModule;
1230
+ Imp = (PIMAGE_IMPORT_DESCRIPTOR)MyImageDirectoryEntryToData(
1231
+ (LPVOID)Base,
1232
+ TRUE,
1233
+ IMAGE_DIRECTORY_ENTRY_IMPORT,
1234
+ &Size);
1235
+ if (Imp == NULL)
1236
+ return NULL;
1237
+ for ( ; Imp->OriginalFirstThunk != 0; ++Imp)
1238
+ {
1239
+ Name = (PIMAGE_THUNK_DATA)(Base + Imp->OriginalFirstThunk);
1240
+ for ( ; Name->u1.Ordinal != 0; ++Name)
1241
+ {
1242
+ if (!IMAGE_SNAP_BY_ORDINAL(Name->u1.Ordinal))
1243
+ {
1244
+ ImpName = (PIMAGE_IMPORT_BY_NAME)
1245
+ (Base + (DWORD_PTR)Name->u1.AddressOfData);
1246
+ if (strcmp((char *)ImpName->Name, funcname) == 0)
1247
+ return GetModuleHandleA((char *)(Base + Imp->Name));
1248
+ }
1249
+ }
1250
+ }
1251
+ return NULL;
1252
+ }
1253
+ #endif
1254
+
1255
+ static int
1256
+ sbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize)
1257
+ {
1258
+ return 1;
1259
+ }
1260
+
1261
+ static int
1262
+ dbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize)
1263
+ {
1264
+ int len = IsDBCSLeadByteEx(cv->codepage, buf[0]) ? 2 : 1;
1265
+ if (bufsize < len)
1266
+ return seterror(EINVAL);
1267
+ return len;
1268
+ }
1269
+
1270
+ static int
1271
+ mbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize)
1272
+ {
1273
+ int len = 0;
1274
+
1275
+ if (cv->codepage == 54936) {
1276
+ if (buf[0] <= 0x7F) len = 1;
1277
+ else if (buf[0] >= 0x81 && buf[0] <= 0xFE &&
1278
+ bufsize >= 2 &&
1279
+ ((buf[1] >= 0x40 && buf[1] <= 0x7E) ||
1280
+ (buf[1] >= 0x80 && buf[1] <= 0xFE))) len = 2;
1281
+ else if (buf[0] >= 0x81 && buf[0] <= 0xFE &&
1282
+ bufsize >= 4 &&
1283
+ buf[1] >= 0x30 && buf[1] <= 0x39) len = 4;
1284
+ else
1285
+ return seterror(EINVAL);
1286
+ return len;
1287
+ }
1288
+ else
1289
+ return seterror(EINVAL);
1290
+ }
1291
+
1292
+ static int
1293
+ utf8_mblen(csconv_t *cv, const uchar *buf, int bufsize)
1294
+ {
1295
+ int len = 0;
1296
+
1297
+ if (buf[0] < 0x80) len = 1;
1298
+ else if ((buf[0] & 0xE0) == 0xC0) len = 2;
1299
+ else if ((buf[0] & 0xF0) == 0xE0) len = 3;
1300
+ else if ((buf[0] & 0xF8) == 0xF0) len = 4;
1301
+ else if ((buf[0] & 0xFC) == 0xF8) len = 5;
1302
+ else if ((buf[0] & 0xFE) == 0xFC) len = 6;
1303
+
1304
+ if (len == 0)
1305
+ return seterror(EILSEQ);
1306
+ else if (bufsize < len)
1307
+ return seterror(EINVAL);
1308
+ return len;
1309
+ }
1310
+
1311
+ static int
1312
+ eucjp_mblen(csconv_t *cv, const uchar *buf, int bufsize)
1313
+ {
1314
+ if (buf[0] < 0x80) /* ASCII */
1315
+ return 1;
1316
+ else if (buf[0] == 0x8E) /* JIS X 0201 */
1317
+ {
1318
+ if (bufsize < 2)
1319
+ return seterror(EINVAL);
1320
+ else if (!(0xA1 <= buf[1] && buf[1] <= 0xDF))
1321
+ return seterror(EILSEQ);
1322
+ return 2;
1323
+ }
1324
+ else if (buf[0] == 0x8F) /* JIS X 0212 */
1325
+ {
1326
+ if (bufsize < 3)
1327
+ return seterror(EINVAL);
1328
+ else if (!(0xA1 <= buf[1] && buf[1] <= 0xFE)
1329
+ || !(0xA1 <= buf[2] && buf[2] <= 0xFE))
1330
+ return seterror(EILSEQ);
1331
+ return 3;
1332
+ }
1333
+ else /* JIS X 0208 */
1334
+ {
1335
+ if (bufsize < 2)
1336
+ return seterror(EINVAL);
1337
+ else if (!(0xA1 <= buf[0] && buf[0] <= 0xFE)
1338
+ || !(0xA1 <= buf[1] && buf[1] <= 0xFE))
1339
+ return seterror(EILSEQ);
1340
+ return 2;
1341
+ }
1342
+ }
1343
+
1344
+ static int
1345
+ kernel_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize)
1346
+ {
1347
+ int len;
1348
+
1349
+ len = cv->mblen(cv, buf, bufsize);
1350
+ if (len == -1)
1351
+ return -1;
1352
+ *wbufsize = MultiByteToWideChar(cv->codepage, mbtowc_flags (cv->codepage),
1353
+ (const char *)buf, len, (wchar_t *)wbuf, *wbufsize);
1354
+ if (*wbufsize == 0)
1355
+ return seterror(EILSEQ);
1356
+ return len;
1357
+ }
1358
+
1359
+ static int
1360
+ kernel_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize)
1361
+ {
1362
+ BOOL usedDefaultChar = 0;
1363
+ BOOL *p = NULL;
1364
+ int flags = 0;
1365
+ int len;
1366
+
1367
+ if (bufsize == 0)
1368
+ return seterror(E2BIG);
1369
+ if (!must_use_null_useddefaultchar(cv->codepage))
1370
+ {
1371
+ p = &usedDefaultChar;
1372
+ #ifdef WC_NO_BEST_FIT_CHARS
1373
+ if (!(cv->flags & FLAG_TRANSLIT))
1374
+ flags |= WC_NO_BEST_FIT_CHARS;
1375
+ #endif
1376
+ }
1377
+ len = WideCharToMultiByte(cv->codepage, flags,
1378
+ (const wchar_t *)wbuf, wbufsize, (char *)buf, bufsize, NULL, p);
1379
+ if (len == 0)
1380
+ {
1381
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1382
+ return seterror(E2BIG);
1383
+ return seterror(EILSEQ);
1384
+ }
1385
+ else if (usedDefaultChar && !(cv->flags & FLAG_TRANSLIT))
1386
+ return seterror(EILSEQ);
1387
+ else if (cv->mblen(cv, buf, len) != len) /* validate result */
1388
+ return seterror(EILSEQ);
1389
+ return len;
1390
+ }
1391
+
1392
+ /*
1393
+ * It seems that the mode (cv->mode) is fixnum.
1394
+ * For example, when converting iso-2022-jp(cp50221) to unicode:
1395
+ * in ascii sequence: mode=0xC42C0000
1396
+ * in jisx0208 sequence: mode=0xC42C0001
1397
+ * "C42C" is same for each convert session.
1398
+ * It should be: ((codepage-1)<<16)|state
1399
+ */
1400
+ static int
1401
+ mlang_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize)
1402
+ {
1403
+ int len;
1404
+ int insize;
1405
+ HRESULT hr;
1406
+
1407
+ len = cv->mblen(cv, buf, bufsize);
1408
+ if (len == -1)
1409
+ return -1;
1410
+ insize = len;
1411
+ hr = ConvertINetMultiByteToUnicode(&cv->mode, cv->codepage,
1412
+ (const char *)buf, &insize, (wchar_t *)wbuf, wbufsize);
1413
+ if (hr != S_OK || insize != len)
1414
+ return seterror(EILSEQ);
1415
+ return len;
1416
+ }
1417
+
1418
+ static int
1419
+ mlang_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize)
1420
+ {
1421
+ char tmpbuf[MB_CHAR_MAX]; /* enough room for one character */
1422
+ int tmpsize = MB_CHAR_MAX;
1423
+ int insize = wbufsize;
1424
+ HRESULT hr;
1425
+
1426
+ hr = ConvertINetUnicodeToMultiByte(&cv->mode, cv->codepage,
1427
+ (const wchar_t *)wbuf, &wbufsize, tmpbuf, &tmpsize);
1428
+ if (hr != S_OK || insize != wbufsize)
1429
+ return seterror(EILSEQ);
1430
+ else if (bufsize < tmpsize)
1431
+ return seterror(E2BIG);
1432
+ else if (cv->mblen(cv, (uchar *)tmpbuf, tmpsize) != tmpsize)
1433
+ return seterror(EILSEQ);
1434
+ memcpy(buf, tmpbuf, tmpsize);
1435
+ return tmpsize;
1436
+ }
1437
+
1438
+ static int
1439
+ utf16_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize)
1440
+ {
1441
+ int codepage = cv->codepage;
1442
+
1443
+ /* swap endian: 1200 <-> 1201 */
1444
+ if (cv->mode & UNICODE_MODE_SWAPPED)
1445
+ codepage ^= 1;
1446
+
1447
+ if (bufsize < 2)
1448
+ return seterror(EINVAL);
1449
+ if (codepage == 1200) /* little endian */
1450
+ wbuf[0] = (buf[1] << 8) | buf[0];
1451
+ else if (codepage == 1201) /* big endian */
1452
+ wbuf[0] = (buf[0] << 8) | buf[1];
1453
+
1454
+ if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE))
1455
+ {
1456
+ cv->mode |= UNICODE_MODE_BOM_DONE;
1457
+ if (wbuf[0] == 0xFFFE)
1458
+ {
1459
+ cv->mode |= UNICODE_MODE_SWAPPED;
1460
+ *wbufsize = 0;
1461
+ return 2;
1462
+ }
1463
+ else if (wbuf[0] == 0xFEFF)
1464
+ {
1465
+ *wbufsize = 0;
1466
+ return 2;
1467
+ }
1468
+ }
1469
+
1470
+ if (0xDC00 <= wbuf[0] && wbuf[0] <= 0xDFFF)
1471
+ return seterror(EILSEQ);
1472
+ if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF)
1473
+ {
1474
+ if (bufsize < 4)
1475
+ return seterror(EINVAL);
1476
+ if (codepage == 1200) /* little endian */
1477
+ wbuf[1] = (buf[3] << 8) | buf[2];
1478
+ else if (codepage == 1201) /* big endian */
1479
+ wbuf[1] = (buf[2] << 8) | buf[3];
1480
+ if (!(0xDC00 <= wbuf[1] && wbuf[1] <= 0xDFFF))
1481
+ return seterror(EILSEQ);
1482
+ *wbufsize = 2;
1483
+ return 4;
1484
+ }
1485
+ *wbufsize = 1;
1486
+ return 2;
1487
+ }
1488
+
1489
+ static int
1490
+ utf16_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize)
1491
+ {
1492
+ if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE))
1493
+ {
1494
+ int r;
1495
+
1496
+ cv->mode |= UNICODE_MODE_BOM_DONE;
1497
+ if (bufsize < 2)
1498
+ return seterror(E2BIG);
1499
+ if (cv->codepage == 1200) /* little endian */
1500
+ memcpy(buf, "\xFF\xFE", 2);
1501
+ else if (cv->codepage == 1201) /* big endian */
1502
+ memcpy(buf, "\xFE\xFF", 2);
1503
+
1504
+ r = utf16_wctomb(cv, wbuf, wbufsize, buf + 2, bufsize - 2);
1505
+ if (r == -1)
1506
+ return -1;
1507
+ return r + 2;
1508
+ }
1509
+
1510
+ if (bufsize < 2)
1511
+ return seterror(E2BIG);
1512
+ if (cv->codepage == 1200) /* little endian */
1513
+ {
1514
+ buf[0] = (wbuf[0] & 0x00FF);
1515
+ buf[1] = (wbuf[0] & 0xFF00) >> 8;
1516
+ }
1517
+ else if (cv->codepage == 1201) /* big endian */
1518
+ {
1519
+ buf[0] = (wbuf[0] & 0xFF00) >> 8;
1520
+ buf[1] = (wbuf[0] & 0x00FF);
1521
+ }
1522
+ if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF)
1523
+ {
1524
+ if (bufsize < 4)
1525
+ return seterror(E2BIG);
1526
+ if (cv->codepage == 1200) /* little endian */
1527
+ {
1528
+ buf[2] = (wbuf[1] & 0x00FF);
1529
+ buf[3] = (wbuf[1] & 0xFF00) >> 8;
1530
+ }
1531
+ else if (cv->codepage == 1201) /* big endian */
1532
+ {
1533
+ buf[2] = (wbuf[1] & 0xFF00) >> 8;
1534
+ buf[3] = (wbuf[1] & 0x00FF);
1535
+ }
1536
+ return 4;
1537
+ }
1538
+ return 2;
1539
+ }
1540
+
1541
+ static int
1542
+ utf32_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize)
1543
+ {
1544
+ int codepage = cv->codepage;
1545
+ uint wc;
1546
+
1547
+ /* swap endian: 12000 <-> 12001 */
1548
+ if (cv->mode & UNICODE_MODE_SWAPPED)
1549
+ codepage ^= 1;
1550
+
1551
+ if (bufsize < 4)
1552
+ return seterror(EINVAL);
1553
+ if (codepage == 12000) /* little endian */
1554
+ wc = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
1555
+ else if (codepage == 12001) /* big endian */
1556
+ wc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
1557
+
1558
+ if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE))
1559
+ {
1560
+ cv->mode |= UNICODE_MODE_BOM_DONE;
1561
+ if (wc == 0xFFFE0000)
1562
+ {
1563
+ cv->mode |= UNICODE_MODE_SWAPPED;
1564
+ *wbufsize = 0;
1565
+ return 4;
1566
+ }
1567
+ else if (wc == 0x0000FEFF)
1568
+ {
1569
+ *wbufsize = 0;
1570
+ return 4;
1571
+ }
1572
+ }
1573
+
1574
+ if ((0xD800 <= wc && wc <= 0xDFFF) || 0x10FFFF < wc)
1575
+ return seterror(EILSEQ);
1576
+ ucs4_to_utf16(wc, wbuf, wbufsize);
1577
+ return 4;
1578
+ }
1579
+
1580
+ static int
1581
+ utf32_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize)
1582
+ {
1583
+ uint wc;
1584
+
1585
+ if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE))
1586
+ {
1587
+ int r;
1588
+
1589
+ cv->mode |= UNICODE_MODE_BOM_DONE;
1590
+ if (bufsize < 4)
1591
+ return seterror(E2BIG);
1592
+ if (cv->codepage == 12000) /* little endian */
1593
+ memcpy(buf, "\xFF\xFE\x00\x00", 4);
1594
+ else if (cv->codepage == 12001) /* big endian */
1595
+ memcpy(buf, "\x00\x00\xFE\xFF", 4);
1596
+
1597
+ r = utf32_wctomb(cv, wbuf, wbufsize, buf + 4, bufsize - 4);
1598
+ if (r == -1)
1599
+ return -1;
1600
+ return r + 4;
1601
+ }
1602
+
1603
+ if (bufsize < 4)
1604
+ return seterror(E2BIG);
1605
+ wc = utf16_to_ucs4(wbuf);
1606
+ if (cv->codepage == 12000) /* little endian */
1607
+ {
1608
+ buf[0] = wc & 0x000000FF;
1609
+ buf[1] = (wc & 0x0000FF00) >> 8;
1610
+ buf[2] = (wc & 0x00FF0000) >> 16;
1611
+ buf[3] = (wc & 0xFF000000) >> 24;
1612
+ }
1613
+ else if (cv->codepage == 12001) /* big endian */
1614
+ {
1615
+ buf[0] = (wc & 0xFF000000) >> 24;
1616
+ buf[1] = (wc & 0x00FF0000) >> 16;
1617
+ buf[2] = (wc & 0x0000FF00) >> 8;
1618
+ buf[3] = wc & 0x000000FF;
1619
+ }
1620
+ return 4;
1621
+ }
1622
+
1623
+ /*
1624
+ * 50220: ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS)
1625
+ * 50221: ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow
1626
+ * 1 byte Kana)
1627
+ * 50222: ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte
1628
+ * Kana - SO/SI)
1629
+ *
1630
+ * MultiByteToWideChar() and WideCharToMultiByte() behave differently
1631
+ * depending on Windows version. On XP, WideCharToMultiByte() doesn't
1632
+ * terminate result sequence with ascii escape. But Vista does.
1633
+ * Use MLang instead.
1634
+ */
1635
+
1636
+ #define ISO2022_MODE(cs, shift) (((cs) << 8) | (shift))
1637
+ #define ISO2022_MODE_CS(mode) (((mode) >> 8) & 0xFF)
1638
+ #define ISO2022_MODE_SHIFT(mode) ((mode) & 0xFF)
1639
+
1640
+ #define ISO2022_SI 0
1641
+ #define ISO2022_SO 1
1642
+
1643
+ /* shift in */
1644
+ static const char iso2022_SI_seq[] = "\x0F";
1645
+ /* shift out */
1646
+ static const char iso2022_SO_seq[] = "\x0E";
1647
+
1648
+ typedef struct iso2022_esc_t iso2022_esc_t;
1649
+ struct iso2022_esc_t {
1650
+ const char *esc;
1651
+ int esc_len;
1652
+ int len;
1653
+ int cs;
1654
+ };
1655
+
1656
+ #define ISO2022JP_CS_ASCII 0
1657
+ #define ISO2022JP_CS_JISX0201_ROMAN 1
1658
+ #define ISO2022JP_CS_JISX0201_KANA 2
1659
+ #define ISO2022JP_CS_JISX0208_1978 3
1660
+ #define ISO2022JP_CS_JISX0208_1983 4
1661
+ #define ISO2022JP_CS_JISX0212 5
1662
+
1663
+ static iso2022_esc_t iso2022jp_esc[] = {
1664
+ {"\x1B\x28\x42", 3, 1, ISO2022JP_CS_ASCII},
1665
+ {"\x1B\x28\x4A", 3, 1, ISO2022JP_CS_JISX0201_ROMAN},
1666
+ {"\x1B\x28\x49", 3, 1, ISO2022JP_CS_JISX0201_KANA},
1667
+ {"\x1B\x24\x40", 3, 2, ISO2022JP_CS_JISX0208_1983}, /* unify 1978 with 1983 */
1668
+ {"\x1B\x24\x42", 3, 2, ISO2022JP_CS_JISX0208_1983},
1669
+ {"\x1B\x24\x28\x44", 4, 2, ISO2022JP_CS_JISX0212},
1670
+ {NULL, 0, 0, 0}
1671
+ };
1672
+
1673
+ static int
1674
+ iso2022jp_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize)
1675
+ {
1676
+ iso2022_esc_t *iesc = iso2022jp_esc;
1677
+ char tmp[MB_CHAR_MAX];
1678
+ int insize;
1679
+ HRESULT hr;
1680
+ DWORD dummy = 0;
1681
+ int len;
1682
+ int esc_len;
1683
+ int cs;
1684
+ int shift;
1685
+ int i;
1686
+
1687
+ if (buf[0] == 0x1B)
1688
+ {
1689
+ for (i = 0; iesc[i].esc != NULL; ++i)
1690
+ {
1691
+ esc_len = iesc[i].esc_len;
1692
+ if (bufsize < esc_len)
1693
+ {
1694
+ if (strncmp((char *)buf, iesc[i].esc, bufsize) == 0)
1695
+ return seterror(EINVAL);
1696
+ }
1697
+ else
1698
+ {
1699
+ if (strncmp((char *)buf, iesc[i].esc, esc_len) == 0)
1700
+ {
1701
+ cv->mode = ISO2022_MODE(iesc[i].cs, ISO2022_SI);
1702
+ *wbufsize = 0;
1703
+ return esc_len;
1704
+ }
1705
+ }
1706
+ }
1707
+ /* not supported escape sequence */
1708
+ return seterror(EILSEQ);
1709
+ }
1710
+ else if (buf[0] == iso2022_SO_seq[0])
1711
+ {
1712
+ cv->mode = ISO2022_MODE(ISO2022_MODE_CS(cv->mode), ISO2022_SO);
1713
+ *wbufsize = 0;
1714
+ return 1;
1715
+ }
1716
+ else if (buf[0] == iso2022_SI_seq[0])
1717
+ {
1718
+ cv->mode = ISO2022_MODE(ISO2022_MODE_CS(cv->mode), ISO2022_SI);
1719
+ *wbufsize = 0;
1720
+ return 1;
1721
+ }
1722
+
1723
+ cs = ISO2022_MODE_CS(cv->mode);
1724
+ shift = ISO2022_MODE_SHIFT(cv->mode);
1725
+
1726
+ /* reset the mode for informal sequence */
1727
+ if (buf[0] < 0x20)
1728
+ {
1729
+ cs = ISO2022JP_CS_ASCII;
1730
+ shift = ISO2022_SI;
1731
+ }
1732
+
1733
+ len = iesc[cs].len;
1734
+ if (bufsize < len)
1735
+ return seterror(EINVAL);
1736
+ for (i = 0; i < len; ++i)
1737
+ if (!(buf[i] < 0x80))
1738
+ return seterror(EILSEQ);
1739
+ esc_len = iesc[cs].esc_len;
1740
+ memcpy(tmp, iesc[cs].esc, esc_len);
1741
+ if (shift == ISO2022_SO)
1742
+ {
1743
+ memcpy(tmp + esc_len, iso2022_SO_seq, 1);
1744
+ esc_len += 1;
1745
+ }
1746
+ memcpy(tmp + esc_len, buf, len);
1747
+
1748
+ if ((cv->codepage == 50220 || cv->codepage == 50221
1749
+ || cv->codepage == 50222) && shift == ISO2022_SO)
1750
+ {
1751
+ /* XXX: shift-out cannot be used for mbtowc (both kernel and
1752
+ * mlang) */
1753
+ esc_len = iesc[ISO2022JP_CS_JISX0201_KANA].esc_len;
1754
+ memcpy(tmp, iesc[ISO2022JP_CS_JISX0201_KANA].esc, esc_len);
1755
+ memcpy(tmp + esc_len, buf, len);
1756
+ }
1757
+
1758
+ insize = len + esc_len;
1759
+ hr = ConvertINetMultiByteToUnicode(&dummy, cv->codepage,
1760
+ (const char *)tmp, &insize, (wchar_t *)wbuf, wbufsize);
1761
+ if (hr != S_OK || insize != len + esc_len)
1762
+ return seterror(EILSEQ);
1763
+
1764
+ /* Check for conversion error. Assuming defaultChar is 0x3F. */
1765
+ /* ascii should be converted from ascii */
1766
+ if (wbuf[0] == buf[0]
1767
+ && cv->mode != ISO2022_MODE(ISO2022JP_CS_ASCII, ISO2022_SI))
1768
+ return seterror(EILSEQ);
1769
+
1770
+ /* reset the mode for informal sequence */
1771
+ if (cv->mode != ISO2022_MODE(cs, shift))
1772
+ cv->mode = ISO2022_MODE(cs, shift);
1773
+
1774
+ return len;
1775
+ }
1776
+
1777
+ static int
1778
+ iso2022jp_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize)
1779
+ {
1780
+ iso2022_esc_t *iesc = iso2022jp_esc;
1781
+ char tmp[MB_CHAR_MAX];
1782
+ int tmpsize = MB_CHAR_MAX;
1783
+ int insize = wbufsize;
1784
+ HRESULT hr;
1785
+ DWORD dummy = 0;
1786
+ int len;
1787
+ int esc_len;
1788
+ int cs;
1789
+ int shift;
1790
+ int i;
1791
+
1792
+ /*
1793
+ * MultiByte = [escape sequence] + character + [escape sequence]
1794
+ *
1795
+ * Whether trailing escape sequence is added depends on which API is
1796
+ * used (kernel or MLang, and its version).
1797
+ */
1798
+ hr = ConvertINetUnicodeToMultiByte(&dummy, cv->codepage,
1799
+ (const wchar_t *)wbuf, &wbufsize, tmp, &tmpsize);
1800
+ if (hr != S_OK || insize != wbufsize)
1801
+ return seterror(EILSEQ);
1802
+ else if (bufsize < tmpsize)
1803
+ return seterror(E2BIG);
1804
+
1805
+ if (tmpsize == 1)
1806
+ {
1807
+ cs = ISO2022JP_CS_ASCII;
1808
+ esc_len = 0;
1809
+ }
1810
+ else
1811
+ {
1812
+ for (i = 1; iesc[i].esc != NULL; ++i)
1813
+ {
1814
+ esc_len = iesc[i].esc_len;
1815
+ if (strncmp(tmp, iesc[i].esc, esc_len) == 0)
1816
+ {
1817
+ cs = iesc[i].cs;
1818
+ break;
1819
+ }
1820
+ }
1821
+ if (iesc[i].esc == NULL)
1822
+ /* not supported escape sequence */
1823
+ return seterror(EILSEQ);
1824
+ }
1825
+
1826
+ shift = ISO2022_SI;
1827
+ if (tmp[esc_len] == iso2022_SO_seq[0])
1828
+ {
1829
+ shift = ISO2022_SO;
1830
+ esc_len += 1;
1831
+ }
1832
+
1833
+ len = iesc[cs].len;
1834
+
1835
+ /* Check for converting error. Assuming defaultChar is 0x3F. */
1836
+ /* ascii should be converted from ascii */
1837
+ if (cs == ISO2022JP_CS_ASCII && !(wbuf[0] < 0x80))
1838
+ return seterror(EILSEQ);
1839
+ else if (tmpsize < esc_len + len)
1840
+ return seterror(EILSEQ);
1841
+
1842
+ if (cv->mode == ISO2022_MODE(cs, shift))
1843
+ {
1844
+ /* remove escape sequence */
1845
+ if (esc_len != 0)
1846
+ memmove(tmp, tmp + esc_len, len);
1847
+ esc_len = 0;
1848
+ }
1849
+ else
1850
+ {
1851
+ if (cs == ISO2022JP_CS_ASCII)
1852
+ {
1853
+ esc_len = iesc[ISO2022JP_CS_ASCII].esc_len;
1854
+ memmove(tmp + esc_len, tmp, len);
1855
+ memcpy(tmp, iesc[ISO2022JP_CS_ASCII].esc, esc_len);
1856
+ }
1857
+ if (ISO2022_MODE_SHIFT(cv->mode) == ISO2022_SO)
1858
+ {
1859
+ /* shift-in before changing to other mode */
1860
+ memmove(tmp + 1, tmp, len + esc_len);
1861
+ memcpy(tmp, iso2022_SI_seq, 1);
1862
+ esc_len += 1;
1863
+ }
1864
+ }
1865
+
1866
+ if (bufsize < len + esc_len)
1867
+ return seterror(E2BIG);
1868
+ memcpy(buf, tmp, len + esc_len);
1869
+ cv->mode = ISO2022_MODE(cs, shift);
1870
+ return len + esc_len;
1871
+ }
1872
+
1873
+ static int
1874
+ iso2022jp_flush(csconv_t *cv, uchar *buf, int bufsize)
1875
+ {
1876
+ iso2022_esc_t *iesc = iso2022jp_esc;
1877
+ int esc_len;
1878
+
1879
+ if (cv->mode != ISO2022_MODE(ISO2022JP_CS_ASCII, ISO2022_SI))
1880
+ {
1881
+ esc_len = 0;
1882
+ if (ISO2022_MODE_SHIFT(cv->mode) != ISO2022_SI)
1883
+ esc_len += 1;
1884
+ if (ISO2022_MODE_CS(cv->mode) != ISO2022JP_CS_ASCII)
1885
+ esc_len += iesc[ISO2022JP_CS_ASCII].esc_len;
1886
+ if (bufsize < esc_len)
1887
+ return seterror(E2BIG);
1888
+
1889
+ esc_len = 0;
1890
+ if (ISO2022_MODE_SHIFT(cv->mode) != ISO2022_SI)
1891
+ {
1892
+ memcpy(buf, iso2022_SI_seq, 1);
1893
+ esc_len += 1;
1894
+ }
1895
+ if (ISO2022_MODE_CS(cv->mode) != ISO2022JP_CS_ASCII)
1896
+ {
1897
+ memcpy(buf + esc_len, iesc[ISO2022JP_CS_ASCII].esc,
1898
+ iesc[ISO2022JP_CS_ASCII].esc_len);
1899
+ esc_len += iesc[ISO2022JP_CS_ASCII].esc_len;
1900
+ }
1901
+ return esc_len;
1902
+ }
1903
+ return 0;
1904
+ }
1905
+
1906
+ #if defined(MAKE_DLL) && defined(USE_LIBICONV_DLL)
1907
+ BOOL WINAPI
1908
+ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
1909
+ {
1910
+ switch( fdwReason )
1911
+ {
1912
+ case DLL_PROCESS_ATTACH:
1913
+ hwiniconv = (HMODULE)hinstDLL;
1914
+ break;
1915
+ case DLL_THREAD_ATTACH:
1916
+ case DLL_THREAD_DETACH:
1917
+ case DLL_PROCESS_DETACH:
1918
+ break;
1919
+ }
1920
+ return TRUE;
1921
+ }
1922
+ #endif
1923
+
1924
+ #if defined(MAKE_EXE)
1925
+ #include <stdio.h>
1926
+ #include <fcntl.h>
1927
+ #include <io.h>
1928
+ int
1929
+ main(int argc, char **argv)
1930
+ {
1931
+ char *fromcode = NULL;
1932
+ char *tocode = NULL;
1933
+ int i;
1934
+ char inbuf[BUFSIZ];
1935
+ char outbuf[BUFSIZ];
1936
+ char *pin;
1937
+ char *pout;
1938
+ size_t inbytesleft;
1939
+ size_t outbytesleft;
1940
+ size_t rest = 0;
1941
+ iconv_t cd;
1942
+ size_t r;
1943
+ FILE *in = stdin;
1944
+ int ignore = 0;
1945
+ char *p;
1946
+
1947
+ _setmode(_fileno(stdin), _O_BINARY);
1948
+ _setmode(_fileno(stdout), _O_BINARY);
1949
+
1950
+ for (i = 1; i < argc; ++i)
1951
+ {
1952
+ if (strcmp(argv[i], "-l") == 0)
1953
+ {
1954
+ for (i = 0; codepage_alias[i].name != NULL; ++i)
1955
+ printf("%s\n", codepage_alias[i].name);
1956
+ return 0;
1957
+ }
1958
+
1959
+ if (strcmp(argv[i], "-f") == 0)
1960
+ fromcode = argv[++i];
1961
+ else if (strcmp(argv[i], "-t") == 0)
1962
+ tocode = argv[++i];
1963
+ else if (strcmp(argv[i], "-c") == 0)
1964
+ ignore = 1;
1965
+ else
1966
+ {
1967
+ in = fopen(argv[i], "rb");
1968
+ if (in == NULL)
1969
+ {
1970
+ fprintf(stderr, "cannot open %s\n", argv[i]);
1971
+ return 1;
1972
+ }
1973
+ break;
1974
+ }
1975
+ }
1976
+
1977
+ if (fromcode == NULL || tocode == NULL)
1978
+ {
1979
+ printf("usage: %s [-c] -f from-enc -t to-enc [file]\n", argv[0]);
1980
+ return 0;
1981
+ }
1982
+
1983
+ if (ignore)
1984
+ {
1985
+ p = tocode;
1986
+ tocode = (char *)malloc(strlen(p) + strlen("//IGNORE") + 1);
1987
+ if (tocode == NULL)
1988
+ {
1989
+ perror("fatal error");
1990
+ return 1;
1991
+ }
1992
+ strcpy(tocode, p);
1993
+ strcat(tocode, "//IGNORE");
1994
+ }
1995
+
1996
+ cd = iconv_open(tocode, fromcode);
1997
+ if (cd == (iconv_t)(-1))
1998
+ {
1999
+ perror("iconv_open error");
2000
+ return 1;
2001
+ }
2002
+
2003
+ while ((inbytesleft = fread(inbuf + rest, 1, sizeof(inbuf) - rest, in)) != 0
2004
+ || rest != 0)
2005
+ {
2006
+ inbytesleft += rest;
2007
+ pin = inbuf;
2008
+ pout = outbuf;
2009
+ outbytesleft = sizeof(outbuf);
2010
+ r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft);
2011
+ fwrite(outbuf, 1, sizeof(outbuf) - outbytesleft, stdout);
2012
+ if (r == (size_t)(-1) && errno != E2BIG && (errno != EINVAL || feof(in)))
2013
+ {
2014
+ perror("conversion error");
2015
+ return 1;
2016
+ }
2017
+ memmove(inbuf, pin, inbytesleft);
2018
+ rest = inbytesleft;
2019
+ }
2020
+ pout = outbuf;
2021
+ outbytesleft = sizeof(outbuf);
2022
+ r = iconv(cd, NULL, NULL, &pout, &outbytesleft);
2023
+ fwrite(outbuf, 1, sizeof(outbuf) - outbytesleft, stdout);
2024
+ if (r == (size_t)(-1))
2025
+ {
2026
+ perror("conversion error");
2027
+ return 1;
2028
+ }
2029
+
2030
+ iconv_close(cd);
2031
+
2032
+ return 0;
2033
+ }
2034
+ #endif
2035
+