| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
| 7 /* | 7 /* |
| 8 * Copyright 2008 ZXing authors | 8 * Copyright 2008 ZXing authors |
| 9 * | 9 * |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 }; | 35 }; |
| 36 const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = { | 36 const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = { |
| 37 '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', | 37 '*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
| 38 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', | 38 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', |
| 39 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' | 39 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' |
| 40 }; | 40 }; |
| 41 const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = { | 41 const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = { |
| 42 '\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', | 42 '\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', |
| 43 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}',
'~', (FX_CHAR) 127 | 43 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}',
'~', (FX_CHAR) 127 |
| 44 }; | 44 }; |
| 45 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::PAD_ENCODE = 0; | 45 const int32_t CBC_DataMatrixDecodedBitStreamParser::PAD_ENCODE = 0; |
| 46 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::ASCII_ENCODE = 1; | 46 const int32_t CBC_DataMatrixDecodedBitStreamParser::ASCII_ENCODE = 1; |
| 47 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::C40_ENCODE = 2; | 47 const int32_t CBC_DataMatrixDecodedBitStreamParser::C40_ENCODE = 2; |
| 48 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::TEXT_ENCODE = 3; | 48 const int32_t CBC_DataMatrixDecodedBitStreamParser::TEXT_ENCODE = 3; |
| 49 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::ANSIX12_ENCODE = 4; | 49 const int32_t CBC_DataMatrixDecodedBitStreamParser::ANSIX12_ENCODE = 4; |
| 50 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::EDIFACT_ENCODE = 5; | 50 const int32_t CBC_DataMatrixDecodedBitStreamParser::EDIFACT_ENCODE = 5; |
| 51 const FX_INT32 CBC_DataMatrixDecodedBitStreamParser::BASE256_ENCODE = 6; | 51 const int32_t CBC_DataMatrixDecodedBitStreamParser::BASE256_ENCODE = 6; |
| 52 CBC_DataMatrixDecodedBitStreamParser::CBC_DataMatrixDecodedBitStreamParser() | 52 CBC_DataMatrixDecodedBitStreamParser::CBC_DataMatrixDecodedBitStreamParser() |
| 53 { | 53 { |
| 54 } | 54 } |
| 55 CBC_DataMatrixDecodedBitStreamParser::~CBC_DataMatrixDecodedBitStreamParser() | 55 CBC_DataMatrixDecodedBitStreamParser::~CBC_DataMatrixDecodedBitStreamParser() |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 CBC_CommonDecoderResult *CBC_DataMatrixDecodedBitStreamParser::Decode(CFX_ByteAr
ray &bytes, FX_INT32 &e) | 58 CBC_CommonDecoderResult *CBC_DataMatrixDecodedBitStreamParser::Decode(CFX_ByteAr
ray &bytes, int32_t &e) |
| 59 { | 59 { |
| 60 CBC_CommonBitSource bits(&bytes); | 60 CBC_CommonBitSource bits(&bytes); |
| 61 CFX_ByteString result; | 61 CFX_ByteString result; |
| 62 CFX_ByteString resultTrailer; | 62 CFX_ByteString resultTrailer; |
| 63 CFX_Int32Array byteSegments; | 63 CFX_Int32Array byteSegments; |
| 64 FX_INT32 mode = ASCII_ENCODE; | 64 int32_t mode = ASCII_ENCODE; |
| 65 do { | 65 do { |
| 66 if (mode == 1) { | 66 if (mode == 1) { |
| 67 mode = DecodeAsciiSegment(&bits, result, resultTrailer, e); | 67 mode = DecodeAsciiSegment(&bits, result, resultTrailer, e); |
| 68 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 68 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 69 } else { | 69 } else { |
| 70 switch (mode) { | 70 switch (mode) { |
| 71 case 2: | 71 case 2: |
| 72 DecodeC40Segment(&bits, result, e); | 72 DecodeC40Segment(&bits, result, e); |
| 73 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 73 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 74 break; | 74 break; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 97 } | 97 } |
| 98 } while (mode != PAD_ENCODE && bits.Available() > 0); | 98 } while (mode != PAD_ENCODE && bits.Available() > 0); |
| 99 if (resultTrailer.GetLength() > 0) { | 99 if (resultTrailer.GetLength() > 0) { |
| 100 result += resultTrailer; | 100 result += resultTrailer; |
| 101 } | 101 } |
| 102 CBC_CommonDecoderResult *tempCp = FX_NEW CBC_CommonDecoderResult(); | 102 CBC_CommonDecoderResult *tempCp = FX_NEW CBC_CommonDecoderResult(); |
| 103 tempCp->Init(bytes, result, (byteSegments.GetSize() <= 0) ? CFX_Int32Array()
: byteSegments, NULL, e); | 103 tempCp->Init(bytes, result, (byteSegments.GetSize() <= 0) ? CFX_Int32Array()
: byteSegments, NULL, e); |
| 104 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 104 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 105 return tempCp; | 105 return tempCp; |
| 106 } | 106 } |
| 107 FX_INT32 CBC_DataMatrixDecodedBitStreamParser::DecodeAsciiSegment(CBC_CommonBitS
ource *bits, CFX_ByteString &result, CFX_ByteString &resultTrailer, FX_INT32 &e) | 107 int32_t CBC_DataMatrixDecodedBitStreamParser::DecodeAsciiSegment(CBC_CommonBitSo
urce *bits, CFX_ByteString &result, CFX_ByteString &resultTrailer, int32_t &e) |
| 108 { | 108 { |
| 109 FX_CHAR buffer[128]; | 109 FX_CHAR buffer[128]; |
| 110 FX_BOOL upperShift = FALSE; | 110 FX_BOOL upperShift = FALSE; |
| 111 do { | 111 do { |
| 112 FX_INT32 oneByte = bits->ReadBits(8, e); | 112 int32_t oneByte = bits->ReadBits(8, e); |
| 113 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | 113 BC_EXCEPTION_CHECK_ReturnValue(e, 0); |
| 114 if (oneByte == 0) { | 114 if (oneByte == 0) { |
| 115 e = BCExceptionFormatException; | 115 e = BCExceptionFormatException; |
| 116 return 0; | 116 return 0; |
| 117 } else if (oneByte <= 128) { | 117 } else if (oneByte <= 128) { |
| 118 oneByte = upperShift ? oneByte + 128 : oneByte; | 118 oneByte = upperShift ? oneByte + 128 : oneByte; |
| 119 upperShift = FALSE; | 119 upperShift = FALSE; |
| 120 result += ((FX_CHAR) (oneByte - 1)); | 120 result += ((FX_CHAR) (oneByte - 1)); |
| 121 return ASCII_ENCODE; | 121 return ASCII_ENCODE; |
| 122 } else if (oneByte == 129) { | 122 } else if (oneByte == 129) { |
| 123 return PAD_ENCODE; | 123 return PAD_ENCODE; |
| 124 } else if (oneByte <= 229) { | 124 } else if (oneByte <= 229) { |
| 125 FX_INT32 value = oneByte - 130; | 125 int32_t value = oneByte - 130; |
| 126 #if defined(_FX_WINAPI_PARTITION_APP_) | 126 #if defined(_FX_WINAPI_PARTITION_APP_) |
| 127 memset(buffer, 0, sizeof(FX_CHAR) * 128); | 127 memset(buffer, 0, sizeof(FX_CHAR) * 128); |
| 128 _itoa_s(value, buffer, 128, 10); | 128 _itoa_s(value, buffer, 128, 10); |
| 129 #else | 129 #else |
| 130 FXSYS_itoa(value, buffer, 10); | 130 FXSYS_itoa(value, buffer, 10); |
| 131 #endif | 131 #endif |
| 132 if (value < 10) { | 132 if (value < 10) { |
| 133 result += '0'; | 133 result += '0'; |
| 134 buffer[1] = '\0'; | 134 buffer[1] = '\0'; |
| 135 } else { | 135 } else { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } else if (oneByte >= 242) { | 167 } else if (oneByte >= 242) { |
| 168 if (oneByte == 254 && bits->Available() == 0) { | 168 if (oneByte == 254 && bits->Available() == 0) { |
| 169 } else { | 169 } else { |
| 170 e = BCExceptionFormatException; | 170 e = BCExceptionFormatException; |
| 171 return 0; | 171 return 0; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 } while (bits->Available() > 0); | 174 } while (bits->Available() > 0); |
| 175 return ASCII_ENCODE; | 175 return ASCII_ENCODE; |
| 176 } | 176 } |
| 177 void CBC_DataMatrixDecodedBitStreamParser::DecodeC40Segment(CBC_CommonBitSource
*bits, CFX_ByteString &result, FX_INT32 &e) | 177 void CBC_DataMatrixDecodedBitStreamParser::DecodeC40Segment(CBC_CommonBitSource
*bits, CFX_ByteString &result, int32_t &e) |
| 178 { | 178 { |
| 179 FX_BOOL upperShift = FALSE; | 179 FX_BOOL upperShift = FALSE; |
| 180 CFX_Int32Array cValues; | 180 CFX_Int32Array cValues; |
| 181 cValues.SetSize(3); | 181 cValues.SetSize(3); |
| 182 do { | 182 do { |
| 183 if (bits->Available() == 8) { | 183 if (bits->Available() == 8) { |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 FX_INT32 firstByte = bits->ReadBits(8, e); | 186 int32_t firstByte = bits->ReadBits(8, e); |
| 187 BC_EXCEPTION_CHECK_ReturnVoid(e); | 187 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 188 if (firstByte == 254) { | 188 if (firstByte == 254) { |
| 189 return; | 189 return; |
| 190 } | 190 } |
| 191 FX_INT32 tempp = bits->ReadBits(8, e); | 191 int32_t tempp = bits->ReadBits(8, e); |
| 192 BC_EXCEPTION_CHECK_ReturnVoid(e); | 192 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 193 ParseTwoBytes(firstByte, tempp, cValues); | 193 ParseTwoBytes(firstByte, tempp, cValues); |
| 194 FX_INT32 shift = 0; | 194 int32_t shift = 0; |
| 195 FX_INT32 i; | 195 int32_t i; |
| 196 for (i = 0; i < 3; i++) { | 196 for (i = 0; i < 3; i++) { |
| 197 FX_INT32 cValue = cValues[i]; | 197 int32_t cValue = cValues[i]; |
| 198 switch (shift) { | 198 switch (shift) { |
| 199 case 0: | 199 case 0: |
| 200 if (cValue < 3) { | 200 if (cValue < 3) { |
| 201 shift = cValue + 1; | 201 shift = cValue + 1; |
| 202 } else if (cValue < 27) { | 202 } else if (cValue < 27) { |
| 203 FX_CHAR c40char = C40_BASIC_SET_CHARS[cValue]; | 203 FX_CHAR c40char = C40_BASIC_SET_CHARS[cValue]; |
| 204 if (upperShift) { | 204 if (upperShift) { |
| 205 result += (FX_CHAR) (c40char + 128); | 205 result += (FX_CHAR) (c40char + 128); |
| 206 upperShift = FALSE; | 206 upperShift = FALSE; |
| 207 } else { | 207 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 shift = 0; | 251 shift = 0; |
| 252 break; | 252 break; |
| 253 default: | 253 default: |
| 254 break; | 254 break; |
| 255 e = BCExceptionFormatException; | 255 e = BCExceptionFormatException; |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 } while (bits->Available() > 0); | 259 } while (bits->Available() > 0); |
| 260 } | 260 } |
| 261 void CBC_DataMatrixDecodedBitStreamParser::DecodeTextSegment(CBC_CommonBitSource
*bits, CFX_ByteString &result, FX_INT32 &e) | 261 void CBC_DataMatrixDecodedBitStreamParser::DecodeTextSegment(CBC_CommonBitSource
*bits, CFX_ByteString &result, int32_t &e) |
| 262 { | 262 { |
| 263 FX_BOOL upperShift = FALSE; | 263 FX_BOOL upperShift = FALSE; |
| 264 CFX_Int32Array cValues; | 264 CFX_Int32Array cValues; |
| 265 cValues.SetSize(3); | 265 cValues.SetSize(3); |
| 266 FX_INT32 shift = 0; | 266 int32_t shift = 0; |
| 267 do { | 267 do { |
| 268 if (bits->Available() == 8) { | 268 if (bits->Available() == 8) { |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 FX_INT32 firstByte = bits->ReadBits(8, e); | 271 int32_t firstByte = bits->ReadBits(8, e); |
| 272 BC_EXCEPTION_CHECK_ReturnVoid(e); | 272 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 273 if (firstByte == 254) { | 273 if (firstByte == 254) { |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 FX_INT32 inTp = bits->ReadBits(8, e); | 276 int32_t inTp = bits->ReadBits(8, e); |
| 277 BC_EXCEPTION_CHECK_ReturnVoid(e); | 277 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 278 ParseTwoBytes(firstByte, inTp, cValues); | 278 ParseTwoBytes(firstByte, inTp, cValues); |
| 279 for (FX_INT32 i = 0; i < 3; i++) { | 279 for (int32_t i = 0; i < 3; i++) { |
| 280 FX_INT32 cValue = cValues[i]; | 280 int32_t cValue = cValues[i]; |
| 281 switch (shift) { | 281 switch (shift) { |
| 282 case 0: | 282 case 0: |
| 283 if (cValue < 3) { | 283 if (cValue < 3) { |
| 284 shift = cValue + 1; | 284 shift = cValue + 1; |
| 285 } else if (cValue < 40) { | 285 } else if (cValue < 40) { |
| 286 FX_CHAR textChar = TEXT_BASIC_SET_CHARS[cValue]; | 286 FX_CHAR textChar = TEXT_BASIC_SET_CHARS[cValue]; |
| 287 if (upperShift) { | 287 if (upperShift) { |
| 288 result += (FX_CHAR) (textChar + 128); | 288 result += (FX_CHAR) (textChar + 128); |
| 289 upperShift = FALSE; | 289 upperShift = FALSE; |
| 290 } else { | 290 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 break; | 341 break; |
| 342 default: | 342 default: |
| 343 break; | 343 break; |
| 344 e = BCExceptionFormatException; | 344 e = BCExceptionFormatException; |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 } while (bits->Available() > 0); | 348 } while (bits->Available() > 0); |
| 349 } | 349 } |
| 350 void CBC_DataMatrixDecodedBitStreamParser::DecodeAnsiX12Segment(CBC_CommonBitSou
rce *bits, CFX_ByteString &result, FX_INT32 &e) | 350 void CBC_DataMatrixDecodedBitStreamParser::DecodeAnsiX12Segment(CBC_CommonBitSou
rce *bits, CFX_ByteString &result, int32_t &e) |
| 351 { | 351 { |
| 352 CFX_Int32Array cValues; | 352 CFX_Int32Array cValues; |
| 353 cValues.SetSize(3); | 353 cValues.SetSize(3); |
| 354 do { | 354 do { |
| 355 if (bits->Available() == 8) { | 355 if (bits->Available() == 8) { |
| 356 return; | 356 return; |
| 357 } | 357 } |
| 358 FX_INT32 firstByte = bits->ReadBits(8, e); | 358 int32_t firstByte = bits->ReadBits(8, e); |
| 359 BC_EXCEPTION_CHECK_ReturnVoid(e); | 359 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 360 if (firstByte == 254) { | 360 if (firstByte == 254) { |
| 361 return; | 361 return; |
| 362 } | 362 } |
| 363 FX_INT32 iTemp1 = bits->ReadBits(8, e); | 363 int32_t iTemp1 = bits->ReadBits(8, e); |
| 364 BC_EXCEPTION_CHECK_ReturnVoid(e); | 364 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 365 ParseTwoBytes(firstByte, iTemp1, cValues); | 365 ParseTwoBytes(firstByte, iTemp1, cValues); |
| 366 FX_INT32 i; | 366 int32_t i; |
| 367 for (i = 0; i < 3; i++) { | 367 for (i = 0; i < 3; i++) { |
| 368 FX_INT32 cValue = cValues[i]; | 368 int32_t cValue = cValues[i]; |
| 369 if (cValue == 0) { | 369 if (cValue == 0) { |
| 370 BC_FX_ByteString_Append(result, 1, '\r'); | 370 BC_FX_ByteString_Append(result, 1, '\r'); |
| 371 } else if (cValue == 1) { | 371 } else if (cValue == 1) { |
| 372 BC_FX_ByteString_Append(result, 1, '*'); | 372 BC_FX_ByteString_Append(result, 1, '*'); |
| 373 } else if (cValue == 2) { | 373 } else if (cValue == 2) { |
| 374 BC_FX_ByteString_Append(result, 1, '>'); | 374 BC_FX_ByteString_Append(result, 1, '>'); |
| 375 } else if (cValue == 3) { | 375 } else if (cValue == 3) { |
| 376 BC_FX_ByteString_Append(result, 1, ' '); | 376 BC_FX_ByteString_Append(result, 1, ' '); |
| 377 } else if (cValue < 14) { | 377 } else if (cValue < 14) { |
| 378 BC_FX_ByteString_Append(result, 1, (FX_CHAR) (cValue + 44)); | 378 BC_FX_ByteString_Append(result, 1, (FX_CHAR) (cValue + 44)); |
| 379 } else if (cValue < 40) { | 379 } else if (cValue < 40) { |
| 380 BC_FX_ByteString_Append(result, 1, (FX_CHAR) (cValue + 51)); | 380 BC_FX_ByteString_Append(result, 1, (FX_CHAR) (cValue + 51)); |
| 381 } else { | 381 } else { |
| 382 e = BCExceptionFormatException; | 382 e = BCExceptionFormatException; |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 } while (bits->Available() > 0); | 386 } while (bits->Available() > 0); |
| 387 } | 387 } |
| 388 void CBC_DataMatrixDecodedBitStreamParser::ParseTwoBytes(FX_INT32 firstByte, FX_
INT32 secondByte, CFX_Int32Array &result) | 388 void CBC_DataMatrixDecodedBitStreamParser::ParseTwoBytes(int32_t firstByte, int3
2_t secondByte, CFX_Int32Array &result) |
| 389 { | 389 { |
| 390 FX_INT32 fullBitValue = (firstByte << 8) + secondByte - 1; | 390 int32_t fullBitValue = (firstByte << 8) + secondByte - 1; |
| 391 FX_INT32 temp = fullBitValue / 1600; | 391 int32_t temp = fullBitValue / 1600; |
| 392 result[0] = temp; | 392 result[0] = temp; |
| 393 fullBitValue -= temp * 1600; | 393 fullBitValue -= temp * 1600; |
| 394 temp = fullBitValue / 40; | 394 temp = fullBitValue / 40; |
| 395 result[1] = temp; | 395 result[1] = temp; |
| 396 result[2] = fullBitValue - temp * 40; | 396 result[2] = fullBitValue - temp * 40; |
| 397 } | 397 } |
| 398 void CBC_DataMatrixDecodedBitStreamParser::DecodeEdifactSegment(CBC_CommonBitSou
rce *bits, CFX_ByteString &result, FX_INT32 &e) | 398 void CBC_DataMatrixDecodedBitStreamParser::DecodeEdifactSegment(CBC_CommonBitSou
rce *bits, CFX_ByteString &result, int32_t &e) |
| 399 { | 399 { |
| 400 FX_CHAR buffer[128]; | 400 FX_CHAR buffer[128]; |
| 401 FX_BOOL unlatch = FALSE; | 401 FX_BOOL unlatch = FALSE; |
| 402 do { | 402 do { |
| 403 if (bits->Available() <= 16) { | 403 if (bits->Available() <= 16) { |
| 404 return; | 404 return; |
| 405 } | 405 } |
| 406 FX_INT32 i; | 406 int32_t i; |
| 407 for (i = 0; i < 4; i++) { | 407 for (i = 0; i < 4; i++) { |
| 408 FX_INT32 edifactValue = bits->ReadBits(6, e); | 408 int32_t edifactValue = bits->ReadBits(6, e); |
| 409 BC_EXCEPTION_CHECK_ReturnVoid(e); | 409 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 410 if (edifactValue == 0x1F) { | 410 if (edifactValue == 0x1F) { |
| 411 unlatch = TRUE; | 411 unlatch = TRUE; |
| 412 } | 412 } |
| 413 if (!unlatch) { | 413 if (!unlatch) { |
| 414 if ((edifactValue & 32) == 0) { | 414 if ((edifactValue & 32) == 0) { |
| 415 edifactValue |= 64; | 415 edifactValue |= 64; |
| 416 } | 416 } |
| 417 #if defined(_FX_WINAPI_PARTITION_APP_) | 417 #if defined(_FX_WINAPI_PARTITION_APP_) |
| 418 memset(buffer, 0, sizeof(FX_CHAR) * 128); | 418 memset(buffer, 0, sizeof(FX_CHAR) * 128); |
| 419 _itoa_s(edifactValue, buffer, 128, 10); | 419 _itoa_s(edifactValue, buffer, 128, 10); |
| 420 result += buffer; | 420 result += buffer; |
| 421 #else | 421 #else |
| 422 result += FXSYS_itoa(edifactValue, buffer, 10); | 422 result += FXSYS_itoa(edifactValue, buffer, 10); |
| 423 #endif | 423 #endif |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 } while (!unlatch && bits->Available() > 0); | 426 } while (!unlatch && bits->Available() > 0); |
| 427 } | 427 } |
| 428 void CBC_DataMatrixDecodedBitStreamParser::DecodeBase256Segment(CBC_CommonBitSou
rce *bits, CFX_ByteString &result, CFX_Int32Array &byteSegments, FX_INT32 &e) | 428 void CBC_DataMatrixDecodedBitStreamParser::DecodeBase256Segment(CBC_CommonBitSou
rce *bits, CFX_ByteString &result, CFX_Int32Array &byteSegments, int32_t &e) |
| 429 { | 429 { |
| 430 FX_INT32 codewordPosition = 1 + bits->getByteOffset(); | 430 int32_t codewordPosition = 1 + bits->getByteOffset(); |
| 431 FX_INT32 iTmp = bits->ReadBits(8, e); | 431 int32_t iTmp = bits->ReadBits(8, e); |
| 432 BC_EXCEPTION_CHECK_ReturnVoid(e); | 432 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 433 FX_INT32 d1 = Unrandomize255State(iTmp, codewordPosition++); | 433 int32_t d1 = Unrandomize255State(iTmp, codewordPosition++); |
| 434 FX_INT32 count; | 434 int32_t count; |
| 435 if (d1 == 0) { | 435 if (d1 == 0) { |
| 436 count = bits->Available() / 8; | 436 count = bits->Available() / 8; |
| 437 } else if (d1 < 250) { | 437 } else if (d1 < 250) { |
| 438 count = d1; | 438 count = d1; |
| 439 } else { | 439 } else { |
| 440 FX_INT32 iTmp3 = bits->ReadBits(8, e); | 440 int32_t iTmp3 = bits->ReadBits(8, e); |
| 441 BC_EXCEPTION_CHECK_ReturnVoid(e); | 441 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 442 count = 250 * (d1 - 249) + Unrandomize255State(iTmp3, codewordPosition++
); | 442 count = 250 * (d1 - 249) + Unrandomize255State(iTmp3, codewordPosition++
); |
| 443 } | 443 } |
| 444 if (count < 0) { | 444 if (count < 0) { |
| 445 e = BCExceptionFormatException; | 445 e = BCExceptionFormatException; |
| 446 return; | 446 return; |
| 447 } | 447 } |
| 448 CFX_ByteArray *bytes = FX_NEW CFX_ByteArray(); | 448 CFX_ByteArray *bytes = FX_NEW CFX_ByteArray(); |
| 449 bytes->SetSize(count); | 449 bytes->SetSize(count); |
| 450 FX_INT32 i; | 450 int32_t i; |
| 451 for (i = 0; i < count; i++) { | 451 for (i = 0; i < count; i++) { |
| 452 if (bits->Available() < 8) { | 452 if (bits->Available() < 8) { |
| 453 e = BCExceptionFormatException; | 453 e = BCExceptionFormatException; |
| 454 delete bytes; | 454 delete bytes; |
| 455 return; | 455 return; |
| 456 } | 456 } |
| 457 FX_INT32 iTemp5 = bits->ReadBits(8, e); | 457 int32_t iTemp5 = bits->ReadBits(8, e); |
| 458 if (e != BCExceptionNO) { | 458 if (e != BCExceptionNO) { |
| 459 delete bytes; | 459 delete bytes; |
| 460 return; | 460 return; |
| 461 } | 461 } |
| 462 bytes->SetAt(i, Unrandomize255State(iTemp5, codewordPosition++)); | 462 bytes->SetAt(i, Unrandomize255State(iTemp5, codewordPosition++)); |
| 463 } | 463 } |
| 464 BC_FX_ByteString_Append(result, *bytes); | 464 BC_FX_ByteString_Append(result, *bytes); |
| 465 delete bytes; | 465 delete bytes; |
| 466 } | 466 } |
| 467 FX_BYTE CBC_DataMatrixDecodedBitStreamParser::Unrandomize255State(FX_INT32 rando
mizedBase256Codeword, FX_INT32 base256CodewordPosition) | 467 uint8_t CBC_DataMatrixDecodedBitStreamParser::Unrandomize255State(int32_t random
izedBase256Codeword, int32_t base256CodewordPosition) |
| 468 { | 468 { |
| 469 FX_INT32 pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; | 469 int32_t pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; |
| 470 FX_INT32 tempVariable = randomizedBase256Codeword - pseudoRandomNumber; | 470 int32_t tempVariable = randomizedBase256Codeword - pseudoRandomNumber; |
| 471 return (FX_BYTE) (tempVariable >= 0 ? tempVariable : tempVariable + 256); | 471 return (uint8_t) (tempVariable >= 0 ? tempVariable : tempVariable + 256); |
| 472 } | 472 } |
| OLD | NEW |