| 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 | 6 |
| 7 #include "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
| 8 #include "../../include/fxcrt/fx_ext.h" | 8 #include "../../include/fxcrt/fx_ext.h" |
| 9 #include "extension.h" | 9 #include "extension.h" |
| 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 11 #include <wincrypt.h> | 11 #include <wincrypt.h> |
| 12 #else | 12 #else |
| 13 #include <ctime> | 13 #include <ctime> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #include <cctype> |
| 17 |
| 18 int HexCharToDigit(char c) { |
| 19 if (!std::isxdigit(c)) |
| 20 return 0; |
| 21 char upchar = std::toupper(c); |
| 22 return upchar > '9' ? upchar - 'A' + 10 : upchar - '0'; |
| 23 } |
| 24 |
| 16 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { | 25 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { |
| 17 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | 26 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); |
| 18 if (!pFA) { | 27 if (!pFA) { |
| 19 return NULL; | 28 return NULL; |
| 20 } | 29 } |
| 21 if (!pFA->Open(filename, dwModes)) { | 30 if (!pFA->Open(filename, dwModes)) { |
| 22 pFA->Release(); | 31 pFA->Release(); |
| 23 return NULL; | 32 return NULL; |
| 24 } | 33 } |
| 25 return new CFX_CRTFileStream(pFA); | 34 return new CFX_CRTFileStream(pFA); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { | 302 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { |
| 294 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 303 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 295 FX_GenerateCryptoRandom(pBuffer, iCount); | 304 FX_GenerateCryptoRandom(pBuffer, iCount); |
| 296 #else | 305 #else |
| 297 FX_Random_GenerateBase(pBuffer, iCount); | 306 FX_Random_GenerateBase(pBuffer, iCount); |
| 298 #endif | 307 #endif |
| 299 } | 308 } |
| 300 #ifdef __cplusplus | 309 #ifdef __cplusplus |
| 301 } | 310 } |
| 302 #endif | 311 #endif |
| OLD | NEW |