| 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 |
| 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 11 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 11 #include <wincrypt.h> | 12 #include <wincrypt.h> |
| 12 #else | 13 #else |
| 13 #include <ctime> | 14 #include <ctime> |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { | 17 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { |
| 17 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | 18 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); |
| 18 if (!pFA) { | 19 if (!pFA) { |
| 19 return NULL; | 20 return NULL; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); | 44 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); |
| 44 } | 45 } |
| 45 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, | 46 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, |
| 46 size_t dwSize, | 47 size_t dwSize, |
| 47 FX_BOOL bTakeOver) { | 48 FX_BOOL bTakeOver) { |
| 48 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); | 49 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); |
| 49 } | 50 } |
| 50 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { | 51 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { |
| 51 return new CFX_MemoryStream(bConsecutive); | 52 return new CFX_MemoryStream(bConsecutive); |
| 52 } | 53 } |
| 53 #ifdef __cplusplus | 54 |
| 54 extern "C" { | |
| 55 #endif | |
| 56 FX_FLOAT FXSYS_tan(FX_FLOAT a) { | 55 FX_FLOAT FXSYS_tan(FX_FLOAT a) { |
| 57 return (FX_FLOAT)tan(a); | 56 return (FX_FLOAT)tan(a); |
| 58 } | 57 } |
| 59 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { | 58 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { |
| 60 return FXSYS_log(x) / FXSYS_log(b); | 59 return FXSYS_log(x) / FXSYS_log(b); |
| 61 } | 60 } |
| 62 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, | 61 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, |
| 63 int32_t iLength, | 62 int32_t iLength, |
| 64 int32_t* pUsedLen) { | 63 int32_t* pUsedLen) { |
| 65 FXSYS_assert(pcsStr != NULL); | 64 FXSYS_assert(pcsStr != NULL); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 while (pStr < pStrEnd) { | 181 while (pStr < pStrEnd) { |
| 183 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++); | 182 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++); |
| 184 } | 183 } |
| 185 } else { | 184 } else { |
| 186 while (pStr < pStrEnd) { | 185 while (pStr < pStrEnd) { |
| 187 dwHashCode = 1313 * dwHashCode + *pStr++; | 186 dwHashCode = 1313 * dwHashCode + *pStr++; |
| 188 } | 187 } |
| 189 } | 188 } |
| 190 return dwHashCode; | 189 return dwHashCode; |
| 191 } | 190 } |
| 192 #ifdef __cplusplus | 191 |
| 193 } | |
| 194 #endif | |
| 195 #ifdef __cplusplus | |
| 196 extern "C" { | |
| 197 #endif | |
| 198 void* FX_Random_MT_Start(FX_DWORD dwSeed) { | 192 void* FX_Random_MT_Start(FX_DWORD dwSeed) { |
| 199 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); | 193 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); |
| 200 pContext->mt[0] = dwSeed; | 194 pContext->mt[0] = dwSeed; |
| 201 FX_DWORD& i = pContext->mti; | 195 FX_DWORD& i = pContext->mti; |
| 202 FX_DWORD* pBuf = pContext->mt; | 196 FX_DWORD* pBuf = pContext->mt; |
| 203 for (i = 1; i < MT_N; i++) { | 197 for (i = 1; i < MT_N; i++) { |
| 204 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); | 198 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); |
| 205 } | 199 } |
| 206 pContext->bHaveSeed = TRUE; | 200 pContext->bHaveSeed = TRUE; |
| 207 return pContext; | 201 return pContext; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 return TRUE; | 284 return TRUE; |
| 291 } | 285 } |
| 292 #endif | 286 #endif |
| 293 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { | 287 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { |
| 294 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 288 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 295 FX_GenerateCryptoRandom(pBuffer, iCount); | 289 FX_GenerateCryptoRandom(pBuffer, iCount); |
| 296 #else | 290 #else |
| 297 FX_Random_GenerateBase(pBuffer, iCount); | 291 FX_Random_GenerateBase(pBuffer, iCount); |
| 298 #endif | 292 #endif |
| 299 } | 293 } |
| 300 #ifdef __cplusplus | 294 |
| 301 } | |
| 302 #endif | |
| OLD | NEW |