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_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize); | 227 void ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize); |
228 | 228 |
229 const uint8_t* m_pData; | 229 const uint8_t* m_pData; |
230 FX_DWORD m_dwSize; | 230 FX_DWORD m_dwSize; |
231 FX_DWORD m_dwCurPos; | 231 FX_DWORD m_dwCurPos; |
232 }; | 232 }; |
233 | 233 |
234 class CPDF_SyntaxParser { | 234 class CPDF_SyntaxParser { |
235 public: | 235 public: |
236 CPDF_SyntaxParser(); | 236 CPDF_SyntaxParser(); |
237 virtual ~CPDF_SyntaxParser(); | 237 ~CPDF_SyntaxParser(); |
238 | 238 |
239 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); | 239 void InitParser(IFX_FileRead* pFileAccess, FX_DWORD HeaderOffset); |
240 | 240 |
241 FX_FILESIZE SavePos() const { return m_Pos; } | 241 FX_FILESIZE SavePos() const { return m_Pos; } |
242 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } | 242 void RestorePos(FX_FILESIZE pos) { m_Pos = pos; } |
243 | 243 |
244 CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList, | 244 CPDF_Object* GetObject(CPDF_IndirectObjectHolder* pObjList, |
245 FX_DWORD objnum, | 245 FX_DWORD objnum, |
246 FX_DWORD gennum, | 246 FX_DWORD gennum, |
247 FX_BOOL bDecrypt); | 247 FX_BOOL bDecrypt); |
(...skipping 13 matching lines...) Expand all Loading... |
261 FX_BOOL bWholeWord, | 261 FX_BOOL bWholeWord, |
262 FX_FILESIZE limit); | 262 FX_FILESIZE limit); |
263 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit); | 263 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit); |
264 | 264 |
265 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler); | 265 void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler); |
266 | 266 |
267 FX_BOOL ReadBlock(uint8_t* pBuf, FX_DWORD size); | 267 FX_BOOL ReadBlock(uint8_t* pBuf, FX_DWORD size); |
268 FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch); | 268 FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch); |
269 CFX_ByteString GetNextWord(bool* bIsNumber); | 269 CFX_ByteString GetNextWord(bool* bIsNumber); |
270 | 270 |
271 protected: | 271 private: |
272 friend class CPDF_Parser; | 272 friend class CPDF_Parser; |
273 friend class CPDF_DataAvail; | 273 friend class CPDF_DataAvail; |
274 friend class fpdf_parser_parser_ReadHexString_Test; | 274 friend class fpdf_parser_parser_ReadHexString_Test; |
275 | 275 |
276 static const int kParserMaxRecursionDepth = 64; | 276 static const int kParserMaxRecursionDepth = 64; |
277 static int s_CurrentRecursionDepth; | 277 static int s_CurrentRecursionDepth; |
278 | 278 |
279 virtual FX_BOOL GetNextChar(uint8_t& ch); | 279 uint32_t GetDirectNum(); |
280 | 280 |
| 281 FX_BOOL GetNextChar(uint8_t& ch); |
281 FX_BOOL GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch); | 282 FX_BOOL GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch); |
282 | |
283 void GetNextWordInternal(bool* bIsNumber); | 283 void GetNextWordInternal(bool* bIsNumber); |
284 | |
285 bool IsWholeWord(FX_FILESIZE startpos, | 284 bool IsWholeWord(FX_FILESIZE startpos, |
286 FX_FILESIZE limit, | 285 FX_FILESIZE limit, |
287 const CFX_ByteStringC& tag, | 286 const CFX_ByteStringC& tag, |
288 FX_BOOL checkKeyword); | 287 FX_BOOL checkKeyword); |
289 | 288 |
290 CFX_ByteString ReadString(); | 289 CFX_ByteString ReadString(); |
291 | |
292 CFX_ByteString ReadHexString(); | 290 CFX_ByteString ReadHexString(); |
293 | |
294 unsigned int ReadEOLMarkers(FX_FILESIZE pos); | 291 unsigned int ReadEOLMarkers(FX_FILESIZE pos); |
295 | |
296 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, | 292 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, |
297 FX_DWORD objnum, | 293 FX_DWORD objnum, |
298 FX_DWORD gennum); | 294 FX_DWORD gennum); |
299 | 295 |
300 FX_FILESIZE m_Pos; | 296 FX_FILESIZE m_Pos; |
301 int m_MetadataObjnum; | 297 int m_MetadataObjnum; |
302 IFX_FileRead* m_pFileAccess; | 298 IFX_FileRead* m_pFileAccess; |
303 FX_DWORD m_HeaderOffset; | 299 FX_DWORD m_HeaderOffset; |
304 FX_FILESIZE m_FileLen; | 300 FX_FILESIZE m_FileLen; |
305 uint8_t* m_pFileBuf; | 301 uint8_t* m_pFileBuf; |
306 FX_DWORD m_BufSize; | 302 FX_DWORD m_BufSize; |
307 FX_FILESIZE m_BufOffset; | 303 FX_FILESIZE m_BufOffset; |
308 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; | 304 std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; |
309 uint8_t m_WordBuffer[257]; | 305 uint8_t m_WordBuffer[257]; |
310 FX_DWORD m_WordSize; | 306 FX_DWORD m_WordSize; |
311 | |
312 private: | |
313 uint32_t GetDirectNum(); | |
314 }; | 307 }; |
315 | 308 |
316 class CPDF_Parser { | 309 class CPDF_Parser { |
317 public: | 310 public: |
318 enum Error { | 311 enum Error { |
319 SUCCESS = 0, | 312 SUCCESS = 0, |
320 FILE_ERROR, | 313 FILE_ERROR, |
321 FORMAT_ERROR, | 314 FORMAT_ERROR, |
322 PASSWORD_ERROR, | 315 PASSWORD_ERROR, |
323 HANDLER_ERROR | 316 HANDLER_ERROR |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 FX_DWORD src_size, | 850 FX_DWORD src_size, |
858 const CPDF_Dictionary* pDict, | 851 const CPDF_Dictionary* pDict, |
859 uint8_t*& dest_buf, | 852 uint8_t*& dest_buf, |
860 FX_DWORD& dest_size, | 853 FX_DWORD& dest_size, |
861 CFX_ByteString& ImageEncoding, | 854 CFX_ByteString& ImageEncoding, |
862 CPDF_Dictionary*& pImageParms, | 855 CPDF_Dictionary*& pImageParms, |
863 FX_DWORD estimated_size, | 856 FX_DWORD estimated_size, |
864 FX_BOOL bImageAcc); | 857 FX_BOOL bImageAcc); |
865 | 858 |
866 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 859 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
OLD | NEW |