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 #ifdef PDF_ENABLE_XFA |
| 17 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { |
| 18 if (wsPath.GetLength() == 0) |
| 19 return NULL; |
| 20 |
| 21 CFX_CRTFileAccess* pFA = NULL; |
| 22 pFA = new CFX_CRTFileAccess; |
| 23 if (NULL == pFA) |
| 24 return NULL; |
| 25 |
| 26 pFA->Init(wsPath); |
| 27 return pFA; |
| 28 } |
| 29 #endif |
16 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { | 30 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { |
17 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | 31 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); |
18 if (!pFA) { | 32 if (!pFA) { |
19 return NULL; | 33 return NULL; |
20 } | 34 } |
21 if (!pFA->Open(filename, dwModes)) { | 35 if (!pFA->Open(filename, dwModes)) { |
22 pFA->Release(); | 36 pFA->Release(); |
23 return NULL; | 37 return NULL; |
24 } | 38 } |
25 return new CFX_CRTFileStream(pFA); | 39 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) { | 307 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { |
294 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 308 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
295 FX_GenerateCryptoRandom(pBuffer, iCount); | 309 FX_GenerateCryptoRandom(pBuffer, iCount); |
296 #else | 310 #else |
297 FX_Random_GenerateBase(pBuffer, iCount); | 311 FX_Random_GenerateBase(pBuffer, iCount); |
298 #endif | 312 #endif |
299 } | 313 } |
300 #ifdef __cplusplus | 314 #ifdef __cplusplus |
301 } | 315 } |
302 #endif | 316 #endif |
| 317 #ifdef PDF_ENABLE_XFA |
| 318 #ifdef __cplusplus |
| 319 extern "C" { |
| 320 #endif |
| 321 void FX_GUID_CreateV4(FX_LPGUID pGUID) { |
| 322 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ |
| 323 _FX_OS_ == _FX_WIN64_) |
| 324 #ifdef _FX_WINAPI_PARTITION_DESKTOP_ |
| 325 if (!FX_GenerateCryptoRandom((FX_DWORD*)pGUID, 4)) { |
| 326 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); |
| 327 } |
| 328 #else |
| 329 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); |
| 330 #endif |
| 331 #else |
| 332 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); |
| 333 #endif |
| 334 uint8_t& b = ((uint8_t*)pGUID)[6]; |
| 335 b = (b & 0x0F) | 0x40; |
| 336 } |
| 337 const FX_CHAR* gs_FX_pHexChars = "0123456789ABCDEF"; |
| 338 void FX_GUID_ToString(FX_LPCGUID pGUID, |
| 339 CFX_ByteString& bsStr, |
| 340 FX_BOOL bSeparator) { |
| 341 FX_CHAR* pBuf = bsStr.GetBuffer(40); |
| 342 uint8_t b; |
| 343 for (int32_t i = 0; i < 16; i++) { |
| 344 b = ((const uint8_t*)pGUID)[i]; |
| 345 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
| 346 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
| 347 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 348 *pBuf++ = L'-'; |
| 349 } |
| 350 } |
| 351 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 352 } |
| 353 #ifdef __cplusplus |
| 354 } |
| 355 #endif |
| 356 #endif |
OLD | NEW |