| 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 "core/include/fxcrt/fx_basic.h" | 7 #include "core/include/fxcrt/fx_basic.h" |
| 8 #include "core/include/fxcrt/fx_ext.h" | 8 #include "core/include/fxcrt/fx_ext.h" |
| 9 #include "extension.h" | 9 #include "extension.h" |
| 10 | 10 |
| 11 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 11 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 12 #include <wincrypt.h> | 12 #include <wincrypt.h> |
| 13 #else | 13 #else |
| 14 #include <ctime> | 14 #include <ctime> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #ifdef PDF_ENABLE_XFA | 17 #ifdef PDF_ENABLE_XFA |
| 18 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { | 18 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { |
| 19 if (wsPath.GetLength() == 0) | 19 if (wsPath.GetLength() == 0) |
| 20 return NULL; | 20 return NULL; |
| 21 | 21 |
| 22 CFX_CRTFileAccess* pFA = NULL; | 22 CFX_CRTFileAccess* pFA = NULL; |
| 23 pFA = new CFX_CRTFileAccess; | 23 pFA = new CFX_CRTFileAccess; |
| 24 if (NULL == pFA) | 24 if (NULL == pFA) |
| 25 return NULL; | 25 return NULL; |
| 26 | 26 |
| 27 pFA->Init(wsPath); | 27 pFA->Init(wsPath); |
| 28 return pFA; | 28 return pFA; |
| 29 } | 29 } |
| 30 #endif | 30 #endif // PDF_ENABLE_XFA |
| 31 |
| 31 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { | 32 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { |
| 32 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | 33 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); |
| 33 if (!pFA) { | 34 if (!pFA) { |
| 34 return NULL; | 35 return NULL; |
| 35 } | 36 } |
| 36 if (!pFA->Open(filename, dwModes)) { | 37 if (!pFA->Open(filename, dwModes)) { |
| 37 pFA->Release(); | 38 pFA->Release(); |
| 38 return NULL; | 39 return NULL; |
| 39 } | 40 } |
| 40 return new CFX_CRTFileStream(pFA); | 41 return new CFX_CRTFileStream(pFA); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return TRUE; | 299 return TRUE; |
| 299 } | 300 } |
| 300 #endif | 301 #endif |
| 301 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { | 302 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { |
| 302 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 303 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 303 FX_GenerateCryptoRandom(pBuffer, iCount); | 304 FX_GenerateCryptoRandom(pBuffer, iCount); |
| 304 #else | 305 #else |
| 305 FX_Random_GenerateBase(pBuffer, iCount); | 306 FX_Random_GenerateBase(pBuffer, iCount); |
| 306 #endif | 307 #endif |
| 307 } | 308 } |
| 309 |
| 308 #ifdef PDF_ENABLE_XFA | 310 #ifdef PDF_ENABLE_XFA |
| 309 | |
| 310 void FX_GUID_CreateV4(FX_LPGUID pGUID) { | 311 void FX_GUID_CreateV4(FX_LPGUID pGUID) { |
| 311 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ | 312 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ |
| 312 _FX_OS_ == _FX_WIN64_) | 313 _FX_OS_ == _FX_WIN64_) |
| 313 #ifdef _FX_WINAPI_PARTITION_DESKTOP_ | 314 #ifdef _FX_WINAPI_PARTITION_DESKTOP_ |
| 314 if (!FX_GenerateCryptoRandom((FX_DWORD*)pGUID, 4)) { | 315 if (!FX_GenerateCryptoRandom((FX_DWORD*)pGUID, 4)) { |
| 315 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); | 316 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); |
| 316 } | 317 } |
| 317 #else | 318 #else |
| 318 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); | 319 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); |
| 319 #endif | 320 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 332 for (int32_t i = 0; i < 16; i++) { | 333 for (int32_t i = 0; i < 16; i++) { |
| 333 b = ((const uint8_t*)pGUID)[i]; | 334 b = ((const uint8_t*)pGUID)[i]; |
| 334 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 335 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
| 335 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 336 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
| 336 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 337 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 337 *pBuf++ = L'-'; | 338 *pBuf++ = L'-'; |
| 338 } | 339 } |
| 339 } | 340 } |
| 340 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 341 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 341 } | 342 } |
| 342 #endif | 343 #endif // PDF_ENABLE_XFA |
| OLD | NEW |