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 "../fxcrt/fx_ext.h" | 10 #include "../fxcrt/fx_ext.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 #define PDFWORD_EOF 0 | 196 #define PDFWORD_EOF 0 |
197 #define PDFWORD_NUMBER 1 | 197 #define PDFWORD_NUMBER 1 |
198 #define PDFWORD_TEXT 2 | 198 #define PDFWORD_TEXT 2 |
199 #define PDFWORD_DELIMITER 3 | 199 #define PDFWORD_DELIMITER 3 |
200 #define PDFWORD_NAME 4 | 200 #define PDFWORD_NAME 4 |
201 class CPDF_SimpleParser | 201 class CPDF_SimpleParser |
202 { | 202 { |
203 public: | 203 public: |
204 | 204 |
205 CPDF_SimpleParser(FX_LPCBYTE pData, FX_DWORD dwSize); | 205 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); |
206 | 206 |
207 CPDF_SimpleParser(FX_BSTR str); | 207 CPDF_SimpleParser(FX_BSTR str); |
208 | 208 |
209 CFX_ByteStringC GetWord(); | 209 CFX_ByteStringC GetWord(); |
210 | 210 |
211 FX_BOOL SearchToken(FX_BSTR token); | 211 FX_BOOL SearchToken(FX_BSTR token); |
212 | 212 |
213 FX_BOOL SkipWord(FX_BSTR token); | 213 FX_BOOL SkipWord(FX_BSTR token); |
214 | 214 |
215 FX_BOOL FindTagPair(FX_BSTR start_token, FX_BSTR
end_token, | 215 FX_BOOL FindTagPair(FX_BSTR start_token, FX_BSTR
end_token, |
216 FX_DWORD& start_pos, FX_DWORD& end_pos); | 216 FX_DWORD& start_pos, FX_DWORD& end_pos); |
217 | 217 |
218 FX_BOOL FindTagParam(FX_BSTR token, int nParams)
; | 218 FX_BOOL FindTagParam(FX_BSTR token, int nParams)
; |
219 | 219 |
220 FX_DWORD GetPos() | 220 FX_DWORD GetPos() |
221 { | 221 { |
222 return m_dwCurPos; | 222 return m_dwCurPos; |
223 } | 223 } |
224 | 224 |
225 void SetPos(FX_DWORD pos) | 225 void SetPos(FX_DWORD pos) |
226 { | 226 { |
227 ASSERT(pos <= m_dwSize); | 227 ASSERT(pos <= m_dwSize); |
228 m_dwCurPos = pos; | 228 m_dwCurPos = pos; |
229 } | 229 } |
230 private: | 230 private: |
231 | 231 |
232 void» » » » ParseWord(FX_LPCBYTE& pStart, FX_DWORD&
dwSize, int& type); | 232 void» » » » ParseWord(const uint8_t*& pStart, FX_DWO
RD& dwSize, int& type); |
233 | 233 |
234 FX_LPCBYTE» » » m_pData; | 234 const uint8_t*» » » m_pData; |
235 | 235 |
236 FX_DWORD m_dwSize; | 236 FX_DWORD m_dwSize; |
237 | 237 |
238 FX_DWORD m_dwCurPos; | 238 FX_DWORD m_dwCurPos; |
239 }; | 239 }; |
240 class CPDF_SyntaxParser | 240 class CPDF_SyntaxParser |
241 { | 241 { |
242 public: | 242 public: |
243 | 243 |
244 CPDF_SyntaxParser(); | 244 CPDF_SyntaxParser(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 protected: | 299 protected: |
300 static const int kParserMaxRecursionDepth = 64; | 300 static const int kParserMaxRecursionDepth = 64; |
301 static int s_CurrentRecursionDepth; | 301 static int s_CurrentRecursionDepth; |
302 | 302 |
303 virtual FX_BOOL GetNextChar(uint8_t& ch); | 303 virtual FX_BOOL GetNextChar(uint8_t& ch); |
304 | 304 |
305 FX_BOOL GetCharAtBackward(FX_FILESIZE pos, uint8
_t& ch); | 305 FX_BOOL GetCharAtBackward(FX_FILESIZE pos, uint8
_t& ch); |
306 | 306 |
307 void GetNextWord(); | 307 void GetNextWord(); |
308 | 308 |
309 FX_BOOL» » » » IsWholeWord(FX_FILESIZE startpos, FX_FIL
ESIZE limit, FX_LPCBYTE tag, FX_DWORD taglen); | 309 FX_BOOL» » » » IsWholeWord(FX_FILESIZE startpos, FX_FIL
ESIZE limit, const uint8_t* tag, FX_DWORD taglen); |
310 | 310 |
311 CFX_ByteString ReadString(); | 311 CFX_ByteString ReadString(); |
312 | 312 |
313 CFX_ByteString ReadHexString(); | 313 CFX_ByteString ReadHexString(); |
314 | 314 |
315 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
* pContext, FX_DWORD objnum, FX_DWORD gennum); | 315 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
* pContext, FX_DWORD objnum, FX_DWORD gennum); |
316 | 316 |
317 FX_FILESIZE m_Pos; | 317 FX_FILESIZE m_Pos; |
318 | 318 |
319 FX_BOOL m_bFileStream; | 319 FX_BOOL m_bFileStream; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 #define PDFPARSE_ERROR_PASSWORD 3 | 366 #define PDFPARSE_ERROR_PASSWORD 3 |
367 #define PDFPARSE_ERROR_HANDLER 4 | 367 #define PDFPARSE_ERROR_HANDLER 4 |
368 #define PDFPARSE_ERROR_CERT 5 | 368 #define PDFPARSE_ERROR_CERT 5 |
369 | 369 |
370 class CPDF_Parser | 370 class CPDF_Parser |
371 { | 371 { |
372 public: | 372 public: |
373 CPDF_Parser(); | 373 CPDF_Parser(); |
374 ~CPDF_Parser(); | 374 ~CPDF_Parser(); |
375 | 375 |
376 FX_DWORD» » » StartParse(FX_LPCSTR filename, FX_BOOL bReParse
= FALSE); | 376 FX_DWORD» » » StartParse(const FX_CHAR* filename, FX_BOOL bReP
arse = FALSE); |
377 FX_DWORD» » » StartParse(FX_LPCWSTR filename, FX_BOOL bReParse
= FALSE); | 377 FX_DWORD» » » StartParse(const FX_WCHAR* filename, FX_BOOL bRe
Parse = FALSE); |
378 FX_DWORD StartParse(IFX_FileRead* pFile, FX_BOOL bReParse
= FALSE, FX_BOOL bOwnFileRead = TRUE); | 378 FX_DWORD StartParse(IFX_FileRead* pFile, FX_BOOL bReParse
= FALSE, FX_BOOL bOwnFileRead = TRUE); |
379 | 379 |
380 void CloseParser(FX_BOOL bReParse = FALSE); | 380 void CloseParser(FX_BOOL bReParse = FALSE); |
381 | 381 |
382 FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE); | 382 FX_DWORD GetPermissions(FX_BOOL bCheckRevision = FALSE); |
383 | 383 |
384 FX_BOOL IsOwner(); | 384 FX_BOOL IsOwner(); |
385 | 385 |
386 void SetPassword(const FX_CHAR* password) | 386 void SetPassword(const FX_CHAR* password) |
387 { | 387 { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 public: | 585 public: |
586 | 586 |
587 virtual ~CPDF_SecurityHandler() {} | 587 virtual ~CPDF_SecurityHandler() {} |
588 | 588 |
589 virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict) = 0; | 589 virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict) = 0; |
590 | 590 |
591 virtual FX_DWORD GetPermissions() = 0; | 591 virtual FX_DWORD GetPermissions() = 0; |
592 | 592 |
593 virtual FX_BOOL IsOwner() = 0; | 593 virtual FX_BOOL IsOwner() = 0; |
594 | 594 |
595 virtual FX_BOOL» » GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, in
t& keylen) = 0; | 595 virtual FX_BOOL» » GetCryptInfo(int& cipher, const uint8_t*& buffer
, int& keylen) = 0; |
596 | 596 |
597 virtual FX_BOOL IsMetadataEncrypted() | 597 virtual FX_BOOL IsMetadataEncrypted() |
598 { | 598 { |
599 return TRUE; | 599 return TRUE; |
600 } | 600 } |
601 | 601 |
602 virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0; | 602 virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0; |
603 | 603 |
604 virtual CPDF_StandardSecurityHandler* GetStandardHandler() | 604 virtual CPDF_StandardSecurityHandler* GetStandardHandler() |
605 { | 605 { |
606 return NULL; | 606 return NULL; |
607 } | 607 } |
608 }; | 608 }; |
609 #define PDF_ENCRYPT_CONTENT 0 | 609 #define PDF_ENCRYPT_CONTENT 0 |
610 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler | 610 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler |
611 { | 611 { |
612 public: | 612 public: |
613 CPDF_StandardSecurityHandler(); | 613 CPDF_StandardSecurityHandler(); |
614 | 614 |
615 virtual ~CPDF_StandardSecurityHandler(); | 615 virtual ~CPDF_StandardSecurityHandler(); |
616 virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict); | 616 virtual FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict); |
617 virtual FX_DWORD GetPermissions(); | 617 virtual FX_DWORD GetPermissions(); |
618 virtual FX_BOOL IsOwner() | 618 virtual FX_BOOL IsOwner() |
619 { | 619 { |
620 return m_bOwner; | 620 return m_bOwner; |
621 } | 621 } |
622 virtual FX_BOOL» » GetCryptInfo(int& cipher, FX_LPCBYTE& buffer, in
t& keylen); | 622 virtual FX_BOOL» » GetCryptInfo(int& cipher, const uint8_t*& buffer
, int& keylen); |
623 virtual FX_BOOL IsMetadataEncrypted(); | 623 virtual FX_BOOL IsMetadataEncrypted(); |
624 virtual CPDF_CryptoHandler* CreateCryptoHandler(); | 624 virtual CPDF_CryptoHandler* CreateCryptoHandler(); |
625 virtual CPDF_StandardSecurityHandler* GetStandardHandler() | 625 virtual CPDF_StandardSecurityHandler* GetStandardHandler() |
626 { | 626 { |
627 return this; | 627 return this; |
628 } | 628 } |
629 | 629 |
630 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, | 630 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, |
631 FX_LPCBYTE user_pass, FX_DWORD user_size, | 631 const uint8_t* user_pass, FX_DWORD user_size, |
632 FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_
DWORD type = PDF_ENCRYPT_CONTENT); | 632 const uint8_t* owner_pass, FX_DWORD owner_size,
FX_DWORD type = PDF_ENCRYPT_CONTENT); |
633 | 633 |
634 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, | 634 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, |
635 FX_LPCBYTE user_pass, FX_DWORD user_size, FX_DW
ORD type = PDF_ENCRYPT_CONTENT); | 635 const uint8_t* user_pass, FX_DWORD user_size, F
X_DWORD type = PDF_ENCRYPT_CONTENT); |
636 | 636 |
637 CFX_ByteString» » GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD
pass_size); | 637 CFX_ByteString» » GetUserPassword(const uint8_t* owner_pass, FX_DW
ORD pass_size); |
638 CFX_ByteString» » GetUserPassword(FX_LPCBYTE owner_pass, FX_DWORD
pass_size, int32_t key_len); | 638 CFX_ByteString» » GetUserPassword(const uint8_t* owner_pass, FX_DW
ORD pass_size, int32_t key_len); |
639 int GetVersion() | 639 int GetVersion() |
640 { | 640 { |
641 return m_Version; | 641 return m_Version; |
642 } | 642 } |
643 int GetRevision() | 643 int GetRevision() |
644 { | 644 { |
645 return m_Revision; | 645 return m_Revision; |
646 } | 646 } |
647 | 647 |
648 int»» » » » CheckPassword(FX_LPCBYTE password, FX_DW
ORD pass_size, FX_BOOL bOwner, FX_LPBYTE key); | 648 int»» » » » CheckPassword(const uint8_t* password, F
X_DWORD pass_size, FX_BOOL bOwner, uint8_t* key); |
649 int»» » » » CheckPassword(FX_LPCBYTE password, FX_DW
ORD pass_size, FX_BOOL bOwner, FX_LPBYTE key, int key_len); | 649 int»» » » » CheckPassword(const uint8_t* password, F
X_DWORD pass_size, FX_BOOL bOwner, uint8_t* key, int key_len); |
650 private: | 650 private: |
651 | 651 |
652 int m_Version; | 652 int m_Version; |
653 | 653 |
654 int m_Revision; | 654 int m_Revision; |
655 | 655 |
656 CPDF_Parser* m_pParser; | 656 CPDF_Parser* m_pParser; |
657 | 657 |
658 CPDF_Dictionary* m_pEncryptDict; | 658 CPDF_Dictionary* m_pEncryptDict; |
659 | 659 |
660 FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict); | 660 FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict); |
661 FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict,
FX_DWORD type, int& cipher, int& key_len); | 661 FX_BOOL LoadDict(CPDF_Dictionary* pEncryptDict,
FX_DWORD type, int& cipher, int& key_len); |
662 | 662 |
663 FX_BOOL» » » » CheckUserPassword(FX_LPCBYTE password, F
X_DWORD pass_size, | 663 FX_BOOL» » » » CheckUserPassword(const uint8_t* passwor
d, FX_DWORD pass_size, |
664 FX_BOOL bIgnoreEncryptMeta, FX_LPBYTE
key, int32_t key_len); | 664 FX_BOOL bIgnoreEncryptMeta, uint8_t* k
ey, int32_t key_len); |
665 | 665 |
666 FX_BOOL» » » » CheckOwnerPassword(FX_LPCBYTE password,
FX_DWORD pass_size, FX_LPBYTE key, int32_t key_len); | 666 FX_BOOL» » » » CheckOwnerPassword(const uint8_t* passwo
rd, FX_DWORD pass_size, uint8_t* key, int32_t key_len); |
667 FX_BOOL» » » » AES256_CheckPassword(FX_LPCBYTE password
, FX_DWORD size, FX_BOOL bOwner, FX_LPBYTE key); | 667 FX_BOOL» » » » AES256_CheckPassword(const uint8_t* pass
word, FX_DWORD size, FX_BOOL bOwner, uint8_t* key); |
668 void» » » » AES256_SetPassword(CPDF_Dictionary* pEnc
ryptDict, FX_LPCBYTE password, FX_DWORD size, FX_BOOL bOwner, FX_LPCBYTE key); | 668 void» » » » AES256_SetPassword(CPDF_Dictionary* pEnc
ryptDict, const uint8_t* password, FX_DWORD size, FX_BOOL bOwner, const uint8_t*
key); |
669 void» » » » AES256_SetPerms(CPDF_Dictionary* pEncryp
tDict, FX_DWORD permission, FX_BOOL bEncryptMetadata, FX_LPCBYTE key); | 669 void» » » » AES256_SetPerms(CPDF_Dictionary* pEncryp
tDict, FX_DWORD permission, FX_BOOL bEncryptMetadata, const uint8_t* key); |
670 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, | 670 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, |
671 FX_LPCBYTE user_pass, FX_DWORD user_size, | 671 const uint8_t* user_pass, FX_DWORD user_size, |
672 FX_LPCBYTE owner_pass, FX_DWORD owner_size, FX_
BOOL bDefault, FX_DWORD type); | 672 const uint8_t* owner_pass, FX_DWORD owner_size,
FX_BOOL bDefault, FX_DWORD type); |
673 FX_BOOL CheckSecurity(int32_t key_len); | 673 FX_BOOL CheckSecurity(int32_t key_len); |
674 | 674 |
675 FX_BOOL m_bOwner; | 675 FX_BOOL m_bOwner; |
676 | 676 |
677 FX_DWORD m_Permissions; | 677 FX_DWORD m_Permissions; |
678 | 678 |
679 int m_Cipher; | 679 int m_Cipher; |
680 | 680 |
681 uint8_t m_EncryptKey[32]; | 681 uint8_t m_EncryptKey[32]; |
682 | 682 |
683 int m_KeyLen; | 683 int m_KeyLen; |
684 }; | 684 }; |
685 class CPDF_CryptoHandler | 685 class CPDF_CryptoHandler |
686 { | 686 { |
687 public: | 687 public: |
688 | 688 |
689 virtual ~CPDF_CryptoHandler() {} | 689 virtual ~CPDF_CryptoHandler() {} |
690 | 690 |
691 virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler) = 0; | 691 virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler) = 0; |
692 | 692 |
693 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0; | 693 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0; |
694 | 694 |
695 virtual FX_LPVOID» DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0; | 695 virtual void*» DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0; |
696 | 696 |
697 virtual FX_BOOL» » DecryptStream(FX_LPVOID context, FX_LPCBYTE src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0; | 697 virtual FX_BOOL» » DecryptStream(void* context, const uint8_t* src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0; |
698 | 698 |
699 virtual FX_BOOL» » DecryptFinish(FX_LPVOID context, CFX_BinaryBuf&
dest_buf) = 0; | 699 virtual FX_BOOL» » DecryptFinish(void* context, CFX_BinaryBuf& dest
_buf) = 0; |
700 | 700 |
701 | 701 |
702 virtual FX_DWORD» EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPC
BYTE src_buf, FX_DWORD src_size) = 0; | 702 virtual FX_DWORD» EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const
uint8_t* src_buf, FX_DWORD src_size) = 0; |
703 | 703 |
704 virtual FX_BOOL» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, FX_LPCBYTE src_buf, FX_DWORD src_size, | 704 virtual FX_BOOL» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, const uint8_t* src_buf, FX_DWORD src_size, |
705 FX_LPBYTE dest_buf, FX_DWORD& dest_size)
= 0; | 705 uint8_t* dest_buf, FX_DWORD& dest_size) =
0; |
706 | 706 |
707 void Decrypt(FX_DWORD objnum, FX_DWORD versio
n, CFX_ByteString& str); | 707 void Decrypt(FX_DWORD objnum, FX_DWORD versio
n, CFX_ByteString& str); |
708 }; | 708 }; |
709 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler | 709 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler |
710 { | 710 { |
711 public: | 711 public: |
712 | 712 |
713 CPDF_StandardCryptoHandler(); | 713 CPDF_StandardCryptoHandler(); |
714 | 714 |
715 virtual ~CPDF_StandardCryptoHandler(); | 715 virtual ~CPDF_StandardCryptoHandler(); |
716 | 716 |
717 FX_BOOL» » » » Init(int cipher, FX_LPCBYTE key, int key
len); | 717 FX_BOOL» » » » Init(int cipher, const uint8_t* key, int
keylen); |
718 virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler); | 718 virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler); |
719 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size); | 719 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size); |
720 virtual FX_LPVOID» DecryptStart(FX_DWORD objnum, FX_DWORD gennum); | 720 virtual void*» DecryptStart(FX_DWORD objnum, FX_DWORD gennum); |
721 virtual FX_BOOL» » DecryptStream(FX_LPVOID context, FX_LPCBYTE src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); | 721 virtual FX_BOOL» » DecryptStream(void* context, const uint8_t* src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); |
722 virtual FX_BOOL» » DecryptFinish(FX_LPVOID context, CFX_BinaryBuf&
dest_buf); | 722 virtual FX_BOOL» » DecryptFinish(void* context, CFX_BinaryBuf& dest
_buf); |
723 virtual FX_DWORD» EncryptGetSize(FX_DWORD objnum, FX_DWORD version, FX_LPC
BYTE src_buf, FX_DWORD src_size); | 723 virtual FX_DWORD» EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const
uint8_t* src_buf, FX_DWORD src_size); |
724 virtual FX_BOOL» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, FX_LPCBYTE src_buf, FX_DWORD src_size, | 724 virtual FX_BOOL» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, const uint8_t* src_buf, FX_DWORD src_size, |
725 FX_LPBYTE dest_buf, FX_DWORD& dest_size); | 725 uint8_t* dest_buf, FX_DWORD& dest_size); |
726 protected: | 726 protected: |
727 | 727 |
728 virtual void» » CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX
_DWORD gennum, FX_LPCBYTE src_buf, FX_DWORD src_size, | 728 virtual void» » CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX
_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, |
729 FX_LPBYTE dest_buf, FX_DWORD& dest_size); | 729 uint8_t* dest_buf, FX_DWORD& dest_size); |
730 virtual FX_LPVOID» CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEn
crypt); | 730 virtual void*» CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEn
crypt); |
731 virtual FX_BOOL» » CryptStream(FX_LPVOID context, FX_LPCBYTE src_bu
f, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt); | 731 virtual FX_BOOL» » CryptStream(void* context, const uint8_t* src_bu
f, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt); |
732 virtual FX_BOOL» » CryptFinish(FX_LPVOID context, CFX_BinaryBuf& de
st_buf, FX_BOOL bEncrypt); | 732 virtual FX_BOOL» » CryptFinish(void* context, CFX_BinaryBuf& dest_b
uf, FX_BOOL bEncrypt); |
733 | 733 |
734 uint8_t m_EncryptKey[32]; | 734 uint8_t m_EncryptKey[32]; |
735 | 735 |
736 int m_KeyLen; | 736 int m_KeyLen; |
737 | 737 |
738 int m_Cipher; | 738 int m_Cipher; |
739 | 739 |
740 FX_LPBYTE» » » m_pAESContext; | 740 uint8_t*» » » m_pAESContext; |
741 }; | 741 }; |
742 class CPDF_Point | 742 class CPDF_Point |
743 { | 743 { |
744 public: | 744 public: |
745 | 745 |
746 CPDF_Point(FX_FLOAT xx, FX_FLOAT yy) | 746 CPDF_Point(FX_FLOAT xx, FX_FLOAT yy) |
747 { | 747 { |
748 x = xx; | 748 x = xx; |
749 y = yy; | 749 y = yy; |
750 } | 750 } |
751 | 751 |
752 FX_FLOAT x; | 752 FX_FLOAT x; |
753 | 753 |
754 FX_FLOAT y; | 754 FX_FLOAT y; |
755 }; | 755 }; |
756 | 756 |
757 #define CPDF_Rect CFX_FloatRect | 757 #define CPDF_Rect CFX_FloatRect |
758 #define CPDF_Matrix CFX_AffineMatrix | 758 #define CPDF_Matrix CFX_AffineMatrix |
759 CFX_ByteString PDF_NameDecode(FX_BSTR orig); | 759 CFX_ByteString PDF_NameDecode(FX_BSTR orig); |
760 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); | 760 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); |
761 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); | 761 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); |
762 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE)
; | 762 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE)
; |
763 CFX_WideString PDF_DecodeText(FX_LPCBYTE pData, FX_DWORD size, CFX_CharMap* pCha
rMap = NULL); | 763 CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size, CFX_CharMap*
pCharMap = NULL); |
764 inline CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr, CFX_CharMap* pC
harMap = NULL) { | 764 inline CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr, CFX_CharMap* pC
harMap = NULL) { |
765 return PDF_DecodeText((FX_LPCBYTE)bstr.c_str(), bstr.GetLength(), pCharMap); | 765 return PDF_DecodeText((const uint8_t*)bstr.c_str(), bstr.GetLength(), pCharM
ap); |
766 } | 766 } |
767 CFX_ByteString PDF_EncodeText(FX_LPCWSTR pString, int len = -1, CFX_CharMap* pCh
arMap = NULL); | 767 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1, CFX_CharMap
* pCharMap = NULL); |
768 inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, CFX_CharMap* pCh
arMap = NULL) { | 768 inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, CFX_CharMap* pCh
arMap = NULL) { |
769 return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); | 769 return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); |
770 } | 770 } |
771 FX_FLOAT PDF_ClipFloat(FX_FLOAT f); | 771 FX_FLOAT PDF_ClipFloat(FX_FLOAT f); |
772 class CFDF_Document : public CPDF_IndirectObjects | 772 class CFDF_Document : public CPDF_IndirectObjects |
773 { | 773 { |
774 public: | 774 public: |
775 static CFDF_Document* CreateNewDoc(); | 775 static CFDF_Document* CreateNewDoc(); |
776 static CFDF_Document* ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile = FALS
E); | 776 static CFDF_Document* ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile = FALS
E); |
777 static CFDF_Document* ParseMemory(FX_LPCBYTE pData, FX_DWORD size); | 777 static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); |
778 | 778 |
779 ~CFDF_Document(); | 779 ~CFDF_Document(); |
780 | 780 |
781 FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) c
onst; | 781 FX_BOOL WriteBuf(CFX_ByteTextBuf& buf) c
onst; |
782 | 782 |
783 CPDF_Dictionary* GetRoot() const | 783 CPDF_Dictionary* GetRoot() const |
784 { | 784 { |
785 return m_pRootDict; | 785 return m_pRootDict; |
786 } | 786 } |
787 | 787 |
788 CFX_WideString GetWin32Path() const; | 788 CFX_WideString GetWin32Path() const; |
789 protected: | 789 protected: |
790 | 790 |
791 CFDF_Document(); | 791 CFDF_Document(); |
792 void ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile); | 792 void ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile); |
793 CPDF_Dictionary* m_pRootDict; | 793 CPDF_Dictionary* m_pRootDict; |
794 IFX_FileRead* m_pFile; | 794 IFX_FileRead* m_pFile; |
795 FX_BOOL m_bOwnFile; | 795 FX_BOOL m_bOwnFile; |
796 }; | 796 }; |
797 | 797 |
798 CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec); | 798 CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec); |
799 void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const
CFX_WideString& fullpath); | 799 void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const
CFX_WideString& fullpath); |
800 | 800 |
801 void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf,
FX_DWORD& dest_size); | 801 void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size); |
802 FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_
buf, FX_DWORD& dest_size); | 802 FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_b
uf, FX_DWORD& dest_size); |
803 FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& d
est_buf, FX_DWORD& dest_size); | 803 FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& de
st_buf, FX_DWORD& dest_size); |
804 class CPDF_NumberTree | 804 class CPDF_NumberTree |
805 { | 805 { |
806 public: | 806 public: |
807 | 807 |
808 CPDF_NumberTree(CPDF_Dictionary* pRoot) | 808 CPDF_NumberTree(CPDF_Dictionary* pRoot) |
809 { | 809 { |
810 m_pRoot = pRoot; | 810 m_pRoot = pRoot; |
811 } | 811 } |
812 | 812 |
813 CPDF_Object* LookupValue(int num); | 813 CPDF_Object* LookupValue(int num); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 PDF_DATAAVAIL_PAGE, | 909 PDF_DATAAVAIL_PAGE, |
910 PDF_DATAAVAIL_PAGE_LATERLOAD, | 910 PDF_DATAAVAIL_PAGE_LATERLOAD, |
911 PDF_DATAAVAIL_RESOURCES, | 911 PDF_DATAAVAIL_RESOURCES, |
912 PDF_DATAAVAIL_DONE, | 912 PDF_DATAAVAIL_DONE, |
913 PDF_DATAAVAIL_ERROR, | 913 PDF_DATAAVAIL_ERROR, |
914 PDF_DATAAVAIL_LOADALLFILE, | 914 PDF_DATAAVAIL_LOADALLFILE, |
915 PDF_DATAAVAIL_TRAILER_APPEND | 915 PDF_DATAAVAIL_TRAILER_APPEND |
916 }; | 916 }; |
917 | 917 |
918 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 918 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
OLD | NEW |