… | |
… | |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
21 | #include "compat.h" |
21 | #include "compat.h" |
22 | |
22 | |
23 | #include <stdlib.h> |
23 | #include <stdlib.h> |
|
|
24 | #include <string.h> |
24 | |
25 | |
25 | #include "parse.h" |
26 | #include "parse.h" |
26 | #include "parse_routines.h" |
27 | #include "parse_routines.h" |
|
|
28 | |
|
|
29 | #ifdef DMALLOC |
|
|
30 | #include <dmalloc.h> |
|
|
31 | #endif |
|
|
32 | |
27 | |
33 | |
28 | psiconv_file_type_t psiconv_file_type(psiconv_buffer buf,int *length, |
34 | psiconv_file_type_t psiconv_file_type(psiconv_buffer buf,int *length, |
29 | psiconv_header_section *result) |
35 | psiconv_header_section *result) |
30 | { |
36 | { |
31 | psiconv_header_section header; |
37 | psiconv_header_section header; |
… | |
… | |
684 | char *temp_str; |
690 | char *temp_str; |
685 | psiconv_u32 pwd_sec = 0; |
691 | psiconv_u32 pwd_sec = 0; |
686 | psiconv_u32 status_sec = 0; |
692 | psiconv_u32 status_sec = 0; |
687 | psiconv_u32 page_sec = 0; |
693 | psiconv_u32 page_sec = 0; |
688 | psiconv_u32 applid_sec = 0; |
694 | psiconv_u32 applid_sec = 0; |
|
|
695 | psiconv_u32 workbook_sec = 0; |
689 | psiconv_section_table_entry entry; |
696 | psiconv_section_table_entry entry; |
690 | psiconv_u32 sto; |
697 | psiconv_u32 sto; |
691 | int i; |
698 | int i; |
692 | |
699 | |
693 | psiconv_progress(lev+1,off,"Going to read a sheet file"); |
700 | psiconv_progress(lev+1,off,"Going to read a sheet file"); |
… | |
… | |
724 | "Found the Password section at %08x",pwd_sec); |
731 | "Found the Password section at %08x",pwd_sec); |
725 | psiconv_warn(lev+3,sto, |
732 | psiconv_warn(lev+3,sto, |
726 | "Password section found - can't read encrypted data"); |
733 | "Password section found - can't read encrypted data"); |
727 | res = -PSICONV_E_PARSE; |
734 | res = -PSICONV_E_PARSE; |
728 | goto ERROR3; |
735 | goto ERROR3; |
|
|
736 | } else if (entry->id == PSICONV_ID_SHEET_WORKBOOK_SECTION) { |
|
|
737 | workbook_sec = entry->offset; |
|
|
738 | psiconv_debug(lev+3,sto, |
|
|
739 | "Found the Sheet Workbook section at %08x",workbook_sec); |
729 | } else if (entry->id == PSICONV_ID_SHEET_STATUS_SECTION) { |
740 | } else if (entry->id == PSICONV_ID_SHEET_STATUS_SECTION) { |
730 | status_sec = entry->offset; |
741 | status_sec = entry->offset; |
731 | psiconv_debug(lev+3,sto, |
742 | psiconv_debug(lev+3,sto, |
732 | "Found the Sheet Status section at %08x",status_sec); |
743 | "Found the Sheet Status section at %08x",status_sec); |
733 | } else { |
744 | } else { |
… | |
… | |
772 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
783 | psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", |
773 | PSICONV_ID_SHEET,appl_id->id); |
784 | PSICONV_ID_SHEET,appl_id->id); |
774 | if (!(temp_str = psiconv_make_printable(appl_id->name))) |
785 | if (!(temp_str = psiconv_make_printable(appl_id->name))) |
775 | goto ERROR5; |
786 | goto ERROR5; |
776 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
787 | psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", |
777 | "Word.app",temp_str); |
788 | "Sheet.app",temp_str); |
778 | free(temp_str); |
789 | free(temp_str); |
779 | res = -PSICONV_E_PARSE; |
790 | res = -PSICONV_E_PARSE; |
780 | goto ERROR5; |
791 | goto ERROR5; |
781 | } |
792 | } |
782 | |
793 | |
… | |
… | |
793 | if ((res = psiconv_parse_page_layout_section(buf,lev+2,page_sec,NULL, |
804 | if ((res = psiconv_parse_page_layout_section(buf,lev+2,page_sec,NULL, |
794 | &(*result)->page_sec))) |
805 | &(*result)->page_sec))) |
795 | goto ERROR5; |
806 | goto ERROR5; |
796 | } |
807 | } |
797 | |
808 | |
|
|
809 | psiconv_progress(lev+2,sto, |
|
|
810 | "Looking for the Sheet Workbook section"); |
|
|
811 | if (! workbook_sec) { |
|
|
812 | psiconv_warn(lev+2,sto, |
|
|
813 | "Sheet workbook section not found in the section table"); |
|
|
814 | res = -PSICONV_E_PARSE; |
|
|
815 | goto ERROR6; |
|
|
816 | } else { |
|
|
817 | psiconv_debug(lev+2,sto, |
|
|
818 | "Sheet workbook section at offset %08x",page_sec); |
|
|
819 | if ((res = psiconv_parse_sheet_workbook_section(buf,lev+2,workbook_sec,NULL, |
|
|
820 | &(*result)->workbook_sec))) |
|
|
821 | goto ERROR6; |
|
|
822 | } |
|
|
823 | |
798 | psiconv_free_application_id_section(appl_id); |
824 | psiconv_free_application_id_section(appl_id); |
799 | psiconv_free_section_table_section(table); |
825 | psiconv_free_section_table_section(table); |
800 | |
826 | |
801 | psiconv_progress(lev+1,off,"End of Sheet file"); |
827 | psiconv_progress(lev+1,off,"End of Sheet file"); |
802 | return 0; |
828 | return 0; |
803 | |
829 | |
804 | |
830 | ERROR6: |
|
|
831 | psiconv_free_page_layout_section((*result)->page_sec); |
805 | ERROR5: |
832 | ERROR5: |
806 | psiconv_free_application_id_section(appl_id); |
833 | psiconv_free_application_id_section(appl_id); |
807 | ERROR4: |
834 | ERROR4: |
808 | psiconv_free_sheet_status_section((*result)->status_sec); |
835 | psiconv_free_sheet_status_section((*result)->status_sec); |
809 | ERROR3: |
836 | ERROR3: |