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 #ifndef CORE_FXCRT_EXTENSION_H_ | 7 #ifndef CORE_FXCRT_EXTENSION_H_ |
8 #define CORE_FXCRT_EXTENSION_H_ | 8 #define CORE_FXCRT_EXTENSION_H_ |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 28 matching lines...) Expand all Loading... |
39 public: | 39 public: |
40 CFX_CRTFileAccess(); | 40 CFX_CRTFileAccess(); |
41 ~CFX_CRTFileAccess() override; | 41 ~CFX_CRTFileAccess() override; |
42 | 42 |
43 // IFX_FileAccess | 43 // IFX_FileAccess |
44 void Release() override; | 44 void Release() override; |
45 IFX_FileAccess* Retain() override; | 45 IFX_FileAccess* Retain() override; |
46 void GetPath(CFX_WideString& wsPath) override; | 46 void GetPath(CFX_WideString& wsPath) override; |
47 IFX_SeekableStream* CreateFileStream(uint32_t dwModes) override; | 47 IFX_SeekableStream* CreateFileStream(uint32_t dwModes) override; |
48 | 48 |
49 FX_BOOL Init(const CFX_WideStringC& wsPath); | 49 bool Init(const CFX_WideStringC& wsPath); |
50 | 50 |
51 protected: | 51 protected: |
52 CFX_WideString m_path; | 52 CFX_WideString m_path; |
53 uint32_t m_RefCount; | 53 uint32_t m_RefCount; |
54 }; | 54 }; |
55 #endif // PDF_ENABLE_XFA | 55 #endif // PDF_ENABLE_XFA |
56 | 56 |
57 class CFX_CRTFileStream final : public IFX_SeekableStream { | 57 class CFX_CRTFileStream final : public IFX_SeekableStream { |
58 public: | 58 public: |
59 explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA); | 59 explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA); |
(...skipping 14 matching lines...) Expand all Loading... |
74 std::unique_ptr<IFXCRT_FileAccess> m_pFile; | 74 std::unique_ptr<IFXCRT_FileAccess> m_pFile; |
75 uint32_t m_dwCount; | 75 uint32_t m_dwCount; |
76 }; | 76 }; |
77 | 77 |
78 #define FX_MEMSTREAM_BlockSize (64 * 1024) | 78 #define FX_MEMSTREAM_BlockSize (64 * 1024) |
79 #define FX_MEMSTREAM_Consecutive 0x01 | 79 #define FX_MEMSTREAM_Consecutive 0x01 |
80 #define FX_MEMSTREAM_TakeOver 0x02 | 80 #define FX_MEMSTREAM_TakeOver 0x02 |
81 | 81 |
82 class CFX_MemoryStream final : public IFX_MemoryStream { | 82 class CFX_MemoryStream final : public IFX_MemoryStream { |
83 public: | 83 public: |
84 explicit CFX_MemoryStream(FX_BOOL bConsecutive); | 84 explicit CFX_MemoryStream(bool bConsecutive); |
85 CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver); | 85 CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, bool bTakeOver); |
86 ~CFX_MemoryStream() override; | 86 ~CFX_MemoryStream() override; |
87 | 87 |
88 // IFX_MemoryStream | 88 // IFX_MemoryStream |
89 IFX_SeekableStream* Retain() override; | 89 IFX_SeekableStream* Retain() override; |
90 void Release() override; | 90 void Release() override; |
91 FX_FILESIZE GetSize() override; | 91 FX_FILESIZE GetSize() override; |
92 bool IsEOF() override; | 92 bool IsEOF() override; |
93 FX_FILESIZE GetPosition() override; | 93 FX_FILESIZE GetPosition() override; |
94 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; | 94 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; |
95 size_t ReadBlock(void* buffer, size_t size) override; | 95 size_t ReadBlock(void* buffer, size_t size) override; |
96 bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override; | 96 bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override; |
97 bool Flush() override; | 97 bool Flush() override; |
98 bool IsConsecutive() const override; | 98 bool IsConsecutive() const override; |
99 void EstimateSize(size_t nInitSize, size_t nGrowSize) override; | 99 void EstimateSize(size_t nInitSize, size_t nGrowSize) override; |
100 uint8_t* GetBuffer() const override; | 100 uint8_t* GetBuffer() const override; |
101 void AttachBuffer(uint8_t* pBuffer, | 101 void AttachBuffer(uint8_t* pBuffer, |
102 size_t nSize, | 102 size_t nSize, |
103 bool bTakeOver = FALSE) override; | 103 bool bTakeOver = false) override; |
104 void DetachBuffer() override; | 104 void DetachBuffer() override; |
105 | 105 |
106 protected: | 106 protected: |
107 CFX_ArrayTemplate<uint8_t*> m_Blocks; | 107 CFX_ArrayTemplate<uint8_t*> m_Blocks; |
108 uint32_t m_dwCount; | 108 uint32_t m_dwCount; |
109 size_t m_nTotalSize; | 109 size_t m_nTotalSize; |
110 size_t m_nCurSize; | 110 size_t m_nCurSize; |
111 size_t m_nCurPos; | 111 size_t m_nCurPos; |
112 size_t m_nGrowSize; | 112 size_t m_nGrowSize; |
113 uint32_t m_dwFlags; | 113 uint32_t m_dwFlags; |
114 FX_BOOL ExpandBlocks(size_t size); | 114 bool ExpandBlocks(size_t size); |
115 }; | 115 }; |
116 | 116 |
117 #ifdef __cplusplus | 117 #ifdef __cplusplus |
118 extern "C" { | 118 extern "C" { |
119 #endif | 119 #endif |
120 #define MT_N 848 | 120 #define MT_N 848 |
121 #define MT_M 456 | 121 #define MT_M 456 |
122 #define MT_Matrix_A 0x9908b0df | 122 #define MT_Matrix_A 0x9908b0df |
123 #define MT_Upper_Mask 0x80000000 | 123 #define MT_Upper_Mask 0x80000000 |
124 #define MT_Lower_Mask 0x7fffffff | 124 #define MT_Lower_Mask 0x7fffffff |
125 struct FX_MTRANDOMCONTEXT { | 125 struct FX_MTRANDOMCONTEXT { |
126 FX_MTRANDOMCONTEXT() { | 126 FX_MTRANDOMCONTEXT() { |
127 mti = MT_N + 1; | 127 mti = MT_N + 1; |
128 bHaveSeed = FALSE; | 128 bHaveSeed = false; |
129 } | 129 } |
130 uint32_t mti; | 130 uint32_t mti; |
131 FX_BOOL bHaveSeed; | 131 bool bHaveSeed; |
132 uint32_t mt[MT_N]; | 132 uint32_t mt[MT_N]; |
133 }; | 133 }; |
134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 134 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
135 FX_BOOL FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount); | 135 bool FX_GenerateCryptoRandom(uint32_t* pBuffer, int32_t iCount); |
136 #endif | 136 #endif |
137 #ifdef __cplusplus | 137 #ifdef __cplusplus |
138 } | 138 } |
139 #endif | 139 #endif |
140 | 140 |
141 #endif // CORE_FXCRT_EXTENSION_H_ | 141 #endif // CORE_FXCRT_EXTENSION_H_ |
OLD | NEW |