/[public]/psiconv/trunk/lib/psiconv/parse_driver.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_driver.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 13 Revision 42
22 22
23#include "parse.h" 23#include "parse.h"
24#include "parse_routines.h" 24#include "parse_routines.h"
25#include "data.h" 25#include "data.h"
26 26
27psiconv_file_type_t psiconv_file_type(psiconv_buffer buf) 27psiconv_file_type_t psiconv_file_type(psiconv_buffer buf,int *length,
28 psiconv_header_section *result)
28{ 29{
29 psiconv_header_section header; 30 psiconv_header_section header;
30 psiconv_file_type_t res; 31 psiconv_file_type_t res;
32 int leng;
31 33
32 psiconv_parse_header_section(buf,0,0,NULL,&header); 34 psiconv_parse_header_section(buf,0,0,&leng,&header);
33 res = header->file; 35 res = header->file;
36 if (result)
37 *result = header;
38 else
34 psiconv_free_header_section(header); 39 psiconv_free_header_section(header);
40 if (length)
41 *length = leng;
35 return res; 42 return res;
36} 43}
37 44
38int psiconv_parse(const psiconv_buffer buf,psiconv_file *result) 45int psiconv_parse(const psiconv_buffer buf,psiconv_file *result)
39{ 46{
40 int res=0; 47 int res=0;
41 int lev=0; 48 int lev=0;
42 int off=0; 49 int off=0;
50 int leng;
43 51
44 (*result) = malloc(sizeof(**result)); 52 (*result) = malloc(sizeof(**result));
45 53
46 (*result)->type = psiconv_file_type(buf); 54 (*result)->type = psiconv_file_type(buf,&leng,NULL);
47 if ((*result)->type == psiconv_unknown_file) { 55 if ((*result)->type == psiconv_unknown_file) {
48 psiconv_warn(lev+1,off,"Unknown file type: can't parse!"); 56 psiconv_warn(lev+1,off,"Unknown file type: can't parse!");
49 (*result)->file = NULL; 57 (*result)->file = NULL;
50 res = -1; 58 res = -1;
51 } else if ((*result)->type == psiconv_word_file) 59 } else if ((*result)->type == psiconv_word_file)
52 res = psiconv_parse_word_file(buf,lev+2,off, 60 res = psiconv_parse_word_file(buf,lev+2,leng,
53 (psiconv_word_f *)(&((*result)->file))); 61 (psiconv_word_f *)(&((*result)->file)));
54 else if ((*result)->type == psiconv_texted_file) 62 else if ((*result)->type == psiconv_texted_file)
55 res = psiconv_parse_texted_file(buf,lev+2,off, 63 res = psiconv_parse_texted_file(buf,lev+2,leng,
56 (psiconv_texted_f *)(&((*result)->file))); 64 (psiconv_texted_f *)(&((*result)->file)));
57 else if ((*result)->type == psiconv_mbm_file) 65 else if ((*result)->type == psiconv_mbm_file)
58 res = psiconv_parse_mbm_file(buf,lev+2,off, 66 res = psiconv_parse_mbm_file(buf,lev+2,leng,
59 (psiconv_mbm_f *)(&((*result)->file))); 67 (psiconv_mbm_f *)(&((*result)->file)));
68 else if ((*result)->type == psiconv_sketch_file)
69 res = psiconv_parse_sketch_file(buf,lev+2,leng,
70 (psiconv_sketch_f *)(&((*result)->file)));
71 else if ((*result)->type == psiconv_clipart_file)
72 res = psiconv_parse_clipart_file(buf,lev+2,leng,
73 (psiconv_clipart_f *)(&((*result)->file)));
60 else { 74 else {
61 psiconv_warn(lev+1,off,"Can't parse this file yet!"); 75 psiconv_warn(lev+1,off,"Can't parse this file yet!");
62 (*result)->file = NULL; 76 (*result)->file = NULL;
63 } 77 }
64 res = -1; 78 res = -1;
65 79
66 return res; 80 return res;
67} 81}
68 82
83int psiconv_parse_clipart_file(const psiconv_buffer buf,int lev,
84 psiconv_u32 off, psiconv_clipart_f *result)
85{
86 int res=0;
87 (*result) = malloc(sizeof(**result));
88 return 0;
89}
90
69int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off, 91int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off,
70 psiconv_mbm_f *result) 92 psiconv_mbm_f *result)
71{ 93{
72 int res=0; 94 int res=0;
73 int i; 95 int i;
74 psiconv_mbm_jumptable_section table; 96 psiconv_jumptable_section table;
75 psiconv_paint_data_section paint; 97 psiconv_paint_data_section paint;
76 psiconv_header_section header;
77 psiconv_u32 *entry; 98 psiconv_u32 *entry;
99 psiconv_u32 sto;
78 100
79 psiconv_progress(lev+1,off,"Going to read a mbm file"); 101 psiconv_progress(lev+1,off,"Going to read a mbm file");
80 *result = malloc(sizeof(**result)); 102 *result = malloc(sizeof(**result));
81 103
82 psiconv_progress(lev+2,off, "Going to read the header section"); 104 psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable");
83 res |= psiconv_parse_header_section(buf,lev+2,off,NULL,&header); 105 sto = psiconv_read_u32(buf,lev+2,off);
106 psiconv_debug(lev+2,off,"Offset: %08x",sto);
84 107
85 psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); 108 psiconv_progress(lev+2,off,"Going to read the MBM jumptable");
86 res |= psiconv_parse_mbm_jumptable_section(buf,lev+2, 109 res |= psiconv_parse_jumptable_section(buf,lev+2,sto, NULL,&table);
87 header->section_table_offset,
88 NULL,&table);
89 110
90 psiconv_progress(lev+2,off,"Going to read the picture sections"); 111 psiconv_progress(lev+2,off,"Going to read the picture sections");
91 (*result)->sections = psiconv_list_new(sizeof(*paint)); 112 (*result)->sections = psiconv_list_new(sizeof(*paint));
92 for (i = 0; i < psiconv_list_length(table); i ++) { 113 for (i = 0; i < psiconv_list_length(table); i ++) {
93 entry = psiconv_list_get(table,i); 114 entry = psiconv_list_get(table,i);
94 psiconv_progress(lev+3,off,"Going to read picture section %i",i); 115 psiconv_progress(lev+3,off,"Going to read picture section %i",i);
95 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,&paint); 116 psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,&paint);
96 psiconv_list_add((*result)->sections,paint); 117 psiconv_list_add((*result)->sections,paint);
97 } 118 }
98 119
99 psiconv_free_header_section(header);
100 psiconv_free_mbm_jumptable_section(table); 120 psiconv_free_jumptable_section(table);
101 psiconv_progress(lev+1,off,"End of mbm file"); 121 psiconv_progress(lev+1,off,"End of mbm file");
102 return res; 122 return res;
103} 123}
104 124
125int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev,
126 psiconv_u32 off,
127 psiconv_sketch_f *result)
128{
129 psiconv_section_table_section table;
130 psiconv_application_id_section appl_id;
131 psiconv_u32 applid_sec = 0;
132 psiconv_u32 sketch_sec = 0;
133 psiconv_u32 sto;
134 psiconv_section_table_entry entry;
135 int i;
136 int res=0;
137 char *temp_str;
138
139 psiconv_progress(lev+1,off,"Going to read a sketch file");
140 *result = malloc(sizeof(**result));
141
142 psiconv_progress(lev+2,off,
143 "Going to read the offset of the section table section");
144 sto = psiconv_read_u32(buf,lev+2,off);
145 psiconv_debug(lev+2,off,"Offset: %08x",sto);
146
147 psiconv_progress(lev+2,sto, "Going to read the section table section");
148 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
149
150 for (i = 0; i < psiconv_list_length(table); i ++) {
151 psiconv_progress(lev+2,sto, "Going to read entry %d",i);
152 entry = psiconv_list_get(table,i);
153 if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
154 applid_sec = entry->offset;
155 psiconv_debug(lev+3,sto,
156 "Found the Application ID section at %08x",applid_sec);
157 } else if (entry->id == PSICONV_ID_SKETCH_SECTION) {
158 sketch_sec = entry->offset;
159 psiconv_debug(lev+3,sto,
160 "Found the Sketch section at %08x",sketch_sec);
161 } else {
162 psiconv_warn(lev+3,sto,
163 "Found unknown section in the Section Table");
164 psiconv_debug(lev+3,sto,
165 "Section ID %08x, offset %08x",entry->id,entry->offset);
166 res = -1;
167 }
168 }
169
170 psiconv_progress(lev+2,sto, "Looking for the Application ID section");
171 if (! applid_sec) {
172 psiconv_warn(lev+2,sto,
173 "Application ID section not found in the section table");
174 res = -1;
175 } else {
176 psiconv_debug(lev+2,sto,
177 "Application ID section at offset %08x",applid_sec);
178 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL,
179 &appl_id);
180 }
181 if ((appl_id->id != PSICONV_ID_SKETCH) ||
182 strcmp(appl_id->name,"Paint.app")) {
183 psiconv_warn(lev+2,applid_sec,
184 "Application ID section contains unexpected data");
185 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
186 PSICONV_ID_SKETCH,appl_id->id);
187 temp_str = psiconv_make_printable(appl_id->name);
188 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
189 "Paint.app",temp_str);
190 free(temp_str);
191 }
192
193 psiconv_progress(lev+2,sto, "Looking for the Sketch section");
194 if (! sketch_sec) {
195 psiconv_warn(lev+2,sto,
196 "Sketch section not found in the section table");
197 res = -1;
198 } else {
199 psiconv_debug(lev+2,sto,
200 "Sketch section at offset %08x",applid_sec);
201 res |= psiconv_parse_sketch_section(buf,lev+2,sketch_sec,NULL,0,
202 &(*result)->sketch_sec);
203 }
204
205 psiconv_free_application_id_section(appl_id);
206 psiconv_free_section_table_section(table);
207
208 psiconv_progress(lev+1,off,"End of word file");
209 return res;
210}
211
212
213
105int psiconv_parse_texted_file(const psiconv_buffer buf,int lev, psiconv_u32 off, 214int psiconv_parse_texted_file(const psiconv_buffer buf,int lev,
215 psiconv_u32 off,
106 psiconv_texted_f *result) 216 psiconv_texted_f *result)
107{ 217{
108 int res=0; 218 int res=0;
109 psiconv_header_section header;
110 psiconv_section_table_section table; 219 psiconv_section_table_section table;
111 psiconv_application_id_section appl_id; 220 psiconv_application_id_section appl_id;
112 char *temp_str; 221 char *temp_str;
113 psiconv_character_layout base_char; 222 psiconv_character_layout base_char;
114 psiconv_paragraph_layout base_para; 223 psiconv_paragraph_layout base_para;
115 psiconv_u32 page_sec = 0; 224 psiconv_u32 page_sec = 0;
116 psiconv_u32 texted_sec = 0; 225 psiconv_u32 texted_sec = 0;
117 psiconv_u32 applid_sec = 0; 226 psiconv_u32 applid_sec = 0;
227 psiconv_u32 sto;
118 psiconv_section_table_entry entry; 228 psiconv_section_table_entry entry;
119 int i; 229 int i;
120 230
121 psiconv_progress(lev+1,off,"Going to read a texted file"); 231 psiconv_progress(lev+1,off,"Going to read a texted file");
122 *result = malloc(sizeof(**result)); 232 *result = malloc(sizeof(**result));
123 233
124 psiconv_progress(lev+2,off, "Going to read the header section"); 234 psiconv_progress(lev+2,off,
125 res |= psiconv_parse_header_section(buf,lev+2,off,NULL,&header);
126
127 psiconv_progress(lev+2,header->section_table_offset,
128 "Going to read the section table section"); 235 "Going to read the offset of the section table section");
236 sto = psiconv_read_u32(buf,lev+2,off);
237 psiconv_debug(lev+2,off,"Offset: %08x",sto);
238
239 psiconv_progress(lev+2,sto, "Going to read the section table section");
129 res |= psiconv_parse_section_table_section(buf,lev+2, 240 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
130 header->section_table_offset,
131 NULL,&table);
132 241
133 for (i = 0; i < psiconv_list_length(table); i ++) { 242 for (i = 0; i < psiconv_list_length(table); i ++) {
134 psiconv_progress(lev+2,header->section_table_offset, 243 psiconv_progress(lev+2,sto, "Going to read entry %d",i);
135 "Going to read entry %d",i);
136 entry = psiconv_list_get(table,i); 244 entry = psiconv_list_get(table,i);
137 if (entry->id == PSICONV_ID_APPL_ID_SECTION) { 245 if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
138 applid_sec = entry->offset; 246 applid_sec = entry->offset;
139 psiconv_debug(lev+3,header->section_table_offset, 247 psiconv_debug(lev+3,sto,
140 "Found the Application ID section at %08x",applid_sec); 248 "Found the Application ID section at %08x",applid_sec);
141 } else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) { 249 } else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) {
142 page_sec = entry->offset; 250 page_sec = entry->offset;
143 psiconv_debug(lev+3,header->section_table_offset, 251 psiconv_debug(lev+3,sto,
144 "Found the Page Layout section at %08x",page_sec); 252 "Found the Page Layout section at %08x",page_sec);
145 } else if (entry->id == PSICONV_ID_TEXTED) { 253 } else if (entry->id == PSICONV_ID_TEXTED) {
146 texted_sec = entry->offset; 254 texted_sec = entry->offset;
147 psiconv_debug(lev+3,header->section_table_offset, 255 psiconv_debug(lev+3,sto,
148 "Found the TextEd section at %08x",texted_sec); 256 "Found the TextEd section at %08x",texted_sec);
149 } else { 257 } else {
150 psiconv_warn(lev+3,header->section_table_offset, 258 psiconv_warn(lev+3,sto,
151 "Found unknown section in the Section Table"); 259 "Found unknown section in the Section Table");
152 psiconv_debug(lev+3,header->section_table_offset, 260 psiconv_debug(lev+3,sto,
153 "Section ID %08x, offset %08x",entry->id,entry->offset); 261 "Section ID %08x, offset %08x",entry->id,entry->offset);
154 res = -1; 262 res = -1;
155 } 263 }
156 } 264 }
157 265
158 psiconv_progress(lev+2,header->section_table_offset, 266 psiconv_progress(lev+2,sto, "Looking for the Application ID section");
159 "Looking for the Application ID section");
160 if (! applid_sec) { 267 if (! applid_sec) {
161 psiconv_warn(lev+2,header->section_table_offset, 268 psiconv_warn(lev+2,sto,
162 "Application ID section not found in the section table"); 269 "Application ID section not found in the section table");
163 res = -1; 270 res = -1;
164 } else { 271 } else {
165 psiconv_debug(lev+2,header->section_table_offset, 272 psiconv_debug(lev+2,sto,
166 "Application ID section at offset %08x",applid_sec); 273 "Application ID section at offset %08x",applid_sec);
167 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL, 274 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL,
168 &appl_id); 275 &appl_id);
169 } 276 }
170 if ((appl_id->id != PSICONV_ID_TEXTED) || 277 if ((appl_id->id != PSICONV_ID_TEXTED) ||
173 "Application ID section contains unexpected data"); 280 "Application ID section contains unexpected data");
174 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", 281 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
175 PSICONV_ID_TEXTED,appl_id->id); 282 PSICONV_ID_TEXTED,appl_id->id);
176 temp_str = psiconv_make_printable(appl_id->name); 283 temp_str = psiconv_make_printable(appl_id->name);
177 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", 284 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
178 PSICONV_ID_TEXTED,temp_str); 285 "TextEd.app",temp_str);
179 free(temp_str); 286 free(temp_str);
180 } 287 }
181 288
182 psiconv_progress(lev+2,header->section_table_offset, 289 psiconv_progress(lev+2,sto,
183 "Looking for the Page layout section"); 290 "Looking for the Page layout section");
184 if (! page_sec) { 291 if (! page_sec) {
185 psiconv_warn(lev+2,header->section_table_offset, 292 psiconv_warn(lev+2,sto,
186 "Page layout section not found in the section table"); 293 "Page layout section not found in the section table");
187 (*result)->page_sec = NULL; 294 (*result)->page_sec = NULL;
188 res = -1; 295 res = -1;
189 } else { 296 } else {
190 psiconv_debug(lev+2,header->section_table_offset, 297 psiconv_debug(lev+2,sto,
191 "Page layout section at offset %08x",page_sec); 298 "Page layout section at offset %08x",page_sec);
192 res |= psiconv_parse_page_layout_section(buf,lev+2,page_sec,NULL, 299 res |= psiconv_parse_page_layout_section(buf,lev+2,page_sec,NULL,
193 &(*result)->page_sec); 300 &(*result)->page_sec);
194 } 301 }
195 302
196 base_char = psiconv_basic_character_layout(); 303 base_char = psiconv_basic_character_layout();
197 base_para = psiconv_basic_paragraph_layout(); 304 base_para = psiconv_basic_paragraph_layout();
198 305
199 psiconv_progress(lev+2,header->section_table_offset, 306 psiconv_progress(lev+2,sto,
200 "Looking for the TextEd section"); 307 "Looking for the TextEd section");
201 if (! texted_sec) { 308 if (! texted_sec) {
202 psiconv_warn(lev+2,header->section_table_offset, 309 psiconv_warn(lev+2,sto,
203 "TextEd section not found in the section table"); 310 "TextEd section not found in the section table");
204 (*result)->texted_sec = NULL; 311 (*result)->texted_sec = NULL;
205 res = -1; 312 res = -1;
206 } else { 313 } else {
207 psiconv_debug(lev+2,header->section_table_offset, 314 psiconv_debug(lev+2,sto, "TextEd section at offset %08x",texted_sec);
208 "TextEd section at offset %08x",texted_sec);
209 res |= psiconv_parse_texted_section(buf,lev+2,texted_sec,NULL, 315 res |= psiconv_parse_texted_section(buf,lev+2,texted_sec,NULL,
210 &(*result)->texted_sec, 316 &(*result)->texted_sec,
211 base_char,base_para); 317 base_char,base_para);
212 } 318 }
213 psiconv_free_character_layout(base_char); 319 psiconv_free_character_layout(base_char);
214 psiconv_free_paragraph_layout(base_para); 320 psiconv_free_paragraph_layout(base_para);
215 321
216 psiconv_free_application_id_section(appl_id); 322 psiconv_free_application_id_section(appl_id);
217 psiconv_free_header_section(header);
218 psiconv_free_section_table_section(table); 323 psiconv_free_section_table_section(table);
219 324
220 psiconv_progress(lev+1,off,"End of word file"); 325 psiconv_progress(lev+1,off,"End of word file");
221 return res; 326 return res;
222} 327}
223 328
224int psiconv_parse_word_file(const psiconv_buffer buf,int lev, psiconv_u32 off, 329int psiconv_parse_word_file(const psiconv_buffer buf,int lev, psiconv_u32 off,
225 psiconv_word_f *result) 330 psiconv_word_f *result)
226{ 331{
227 int res=0; 332 int res=0;
228 psiconv_header_section header;
229 psiconv_section_table_section table; 333 psiconv_section_table_section table;
230 psiconv_application_id_section appl_id; 334 psiconv_application_id_section appl_id;
231 char *temp_str; 335 char *temp_str;
232 psiconv_u32 pwd_sec = 0; 336 psiconv_u32 pwd_sec = 0;
233 psiconv_u32 status_sec = 0; 337 psiconv_u32 status_sec = 0;
235 psiconv_u32 page_sec = 0; 339 psiconv_u32 page_sec = 0;
236 psiconv_u32 text_sec = 0; 340 psiconv_u32 text_sec = 0;
237 psiconv_u32 layout_sec = 0; 341 psiconv_u32 layout_sec = 0;
238 psiconv_u32 applid_sec = 0; 342 psiconv_u32 applid_sec = 0;
239 psiconv_section_table_entry entry; 343 psiconv_section_table_entry entry;
344 psiconv_u32 sto;
240 int i; 345 int i;
241 346
242 psiconv_progress(lev+1,off,"Going to read a word file"); 347 psiconv_progress(lev+1,off,"Going to read a word file");
243 *result = malloc(sizeof(**result)); 348 *result = malloc(sizeof(**result));
244 349
245 psiconv_progress(lev+2,off, "Going to read the header section"); 350 psiconv_progress(lev+2,off,
246 res |= psiconv_parse_header_section(buf,lev+2,off,NULL,&header); 351 "Going to read the offset of the section table section");
352 sto = psiconv_read_u32(buf,lev+2,off);
353 psiconv_debug(lev+2,off,"Offset: %08x",sto);
247 354
248 psiconv_progress(lev+2,header->section_table_offset, 355 psiconv_progress(lev+2,sto,
249 "Going to read the section table section"); 356 "Going to read the section table section");
250 res |= psiconv_parse_section_table_section(buf,lev+2, 357 res |= psiconv_parse_section_table_section(buf,lev+2,sto, NULL,&table);
251 header->section_table_offset,
252 NULL,&table);
253 358
254 for (i = 0; i < psiconv_list_length(table); i ++) { 359 for (i = 0; i < psiconv_list_length(table); i ++) {
255 psiconv_progress(lev+2,header->section_table_offset, 360 psiconv_progress(lev+2,sto, "Going to read entry %d",i);
256 "Going to read entry %d",i);
257 entry = psiconv_list_get(table,i); 361 entry = psiconv_list_get(table,i);
258 if (entry->id == PSICONV_ID_APPL_ID_SECTION) { 362 if (entry->id == PSICONV_ID_APPL_ID_SECTION) {
259 applid_sec = entry->offset; 363 applid_sec = entry->offset;
260 psiconv_debug(lev+3,header->section_table_offset, 364 psiconv_debug(lev+3,sto,
261 "Found the Application ID section at %08x",applid_sec); 365 "Found the Application ID section at %08x",applid_sec);
262 } else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) { 366 } else if (entry->id == PSICONV_ID_PAGE_LAYOUT_SECTION) {
263 page_sec = entry->offset; 367 page_sec = entry->offset;
264 psiconv_debug(lev+3,header->section_table_offset, 368 psiconv_debug(lev+3,sto,
265 "Found the Page Layout section at %08x",page_sec); 369 "Found the Page Layout section at %08x",page_sec);
266 } else if (entry->id == PSICONV_ID_TEXT_SECTION) { 370 } else if (entry->id == PSICONV_ID_TEXT_SECTION) {
267 text_sec = entry->offset; 371 text_sec = entry->offset;
268 psiconv_debug(lev+3,header->section_table_offset, 372 psiconv_debug(lev+3,sto, "Found the Text section at %08x",text_sec);
269 "Found the Text section at %08x",text_sec);
270 } else if (entry->id == PSICONV_ID_PASSWORD_SECTION) { 373 } else if (entry->id == PSICONV_ID_PASSWORD_SECTION) {
271 pwd_sec = entry->offset; 374 pwd_sec = entry->offset;
272 psiconv_debug(lev+3,header->section_table_offset, 375 psiconv_debug(lev+3,sto,
273 "Found the Password section at %08x",pwd_sec); 376 "Found the Password section at %08x",pwd_sec);
274 psiconv_warn(lev+3,header->section_table_offset, 377 psiconv_warn(lev+3,sto,
275 "Password section found - can't read encrypted data"); 378 "Password section found - can't read encrypted data");
276 res = -1; 379 res = -1;
277 } else if (entry->id == PSICONV_ID_WORD_STATUS_SECTION) { 380 } else if (entry->id == PSICONV_ID_WORD_STATUS_SECTION) {
278 status_sec = entry->offset; 381 status_sec = entry->offset;
279 psiconv_debug(lev+3,header->section_table_offset, 382 psiconv_debug(lev+3,sto,
280 "Found the Word Status section at %08x",status_sec); 383 "Found the Word Status section at %08x",status_sec);
281 } else if (entry->id == PSICONV_ID_WORD_STYLES_SECTION) { 384 } else if (entry->id == PSICONV_ID_WORD_STYLES_SECTION) {
282 styles_sec = entry->offset; 385 styles_sec = entry->offset;
283 psiconv_debug(lev+3,header->section_table_offset, 386 psiconv_debug(lev+3,sto,
284 "Found the Word Styles section at %08x",styles_sec); 387 "Found the Word Styles section at %08x",styles_sec);
285 } else if (entry->id == PSICONV_ID_LAYOUT_SECTION) { 388 } else if (entry->id == PSICONV_ID_LAYOUT_SECTION) {
286 layout_sec = entry->offset; 389 layout_sec = entry->offset;
287 psiconv_debug(lev+3,header->section_table_offset, 390 psiconv_debug(lev+3,sto,
288 "Found the Layout section at %08x",layout_sec); 391 "Found the Layout section at %08x",layout_sec);
289 } else { 392 } else {
290 psiconv_warn(lev+3,header->section_table_offset, 393 psiconv_warn(lev+3,sto,
291 "Found unknown section in the Section Table"); 394 "Found unknown section in the Section Table");
292 psiconv_debug(lev+3,header->section_table_offset, 395 psiconv_debug(lev+3,sto,
293 "Section ID %08x, offset %08x",entry->id,entry->offset); 396 "Section ID %08x, offset %08x",entry->id,entry->offset);
294 res = -1; 397 res = -1;
295 } 398 }
296 } 399 }
297 400
298 401
299 psiconv_progress(lev+2,header->section_table_offset, 402 psiconv_progress(lev+2,sto,
300 "Looking for the Status section"); 403 "Looking for the Status section");
301 if (!status_sec) { 404 if (!status_sec) {
302 psiconv_warn(lev+2,header->section_table_offset,
303 "Status section not found in the section table"); 405 psiconv_warn(lev+2,sto, "Status section not found in the section table");
304 res = -1; 406 res = -1;
305 } else { 407 } else {
306 psiconv_debug(lev+2,header->section_table_offset, 408 psiconv_debug(lev+2,sto, "Status section at offset %08x",status_sec);
307 "Status section at offset %08x",status_sec);
308 res |= psiconv_parse_word_status_section(buf,lev+2,status_sec,NULL, 409 res |= psiconv_parse_word_status_section(buf,lev+2,status_sec,NULL,
309 &((*result)->status_sec)); 410 &((*result)->status_sec));
310 } 411 }
311 412
312 psiconv_progress(lev+2,header->section_table_offset, 413 psiconv_progress(lev+2,sto, "Looking for the Application ID section");
313 "Looking for the Application ID section");
314 if (! applid_sec) { 414 if (! applid_sec) {
315 psiconv_warn(lev+2,header->section_table_offset, 415 psiconv_warn(lev+2,sto,
316 "Application ID section not found in the section table"); 416 "Application ID section not found in the section table");
317 res = -1; 417 res = -1;
318 } else { 418 } else {
319 psiconv_debug(lev+2,header->section_table_offset, 419 psiconv_debug(lev+2,sto,
320 "Application ID section at offset %08x",applid_sec); 420 "Application ID section at offset %08x",applid_sec);
321 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL, 421 res |= psiconv_parse_application_id_section(buf,lev+2,applid_sec,NULL,
322 &appl_id); 422 &appl_id);
323 } 423 }
324 if ((appl_id->id != PSICONV_ID_WORD) || 424 if ((appl_id->id != PSICONV_ID_WORD) ||
327 "Application ID section contains unexpected data"); 427 "Application ID section contains unexpected data");
328 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found", 428 psiconv_debug(lev+2,applid_sec,"ID: %08x expected, %08x found",
329 PSICONV_ID_WORD,appl_id->id); 429 PSICONV_ID_WORD,appl_id->id);
330 temp_str = psiconv_make_printable(appl_id->name); 430 temp_str = psiconv_make_printable(appl_id->name);
331 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found", 431 psiconv_debug(lev+2,applid_sec,"Name: `%s' expected, `%s' found",
332 PSICONV_ID_WORD,temp_str); 432 "Word.app",temp_str);
333 free(temp_str); 433 free(temp_str);
334 } 434 }
335 435
336 psiconv_progress(lev+2,header->section_table_offset, 436 psiconv_progress(lev+2,sto,
337 "Looking for the Page layout section"); 437 "Looking for the Page layout section");
338 if (! page_sec) { 438 if (! page_sec) {
339 psiconv_warn(lev+2,header->section_table_offset, 439 psiconv_warn(lev+2,sto,
340 "Page layout section not found in the section table"); 440 "Page layout section not found in the section table");
341 (*result)->page_sec = NULL; 441 (*result)->page_sec = NULL;
342 res = -1; 442 res = -1;
343 } else { 443 } else {
344 psiconv_debug(lev+2,header->section_table_offset, 444 psiconv_debug(lev+2,sto,
345 "Page layout section at offset %08x",page_sec); 445 "Page layout section at offset %08x",page_sec);
346 res |= psiconv_parse_page_layout_section(buf,lev+2,page_sec,NULL, 446 res |= psiconv_parse_page_layout_section(buf,lev+2,page_sec,NULL,
347 &(*result)->page_sec); 447 &(*result)->page_sec);
348 } 448 }
349 449
350 psiconv_progress(lev+2,header->section_table_offset, 450 psiconv_progress(lev+2,sto,
351 "Looking for the Word Style section"); 451 "Looking for the Word Style section");
352 if (!styles_sec) { 452 if (!styles_sec) {
353 psiconv_warn(lev+2,header->section_table_offset, 453 psiconv_warn(lev+2,sto,
354 "Word styles section not found in the section table"); 454 "Word styles section not found in the section table");
355 (*result)->styles_sec = NULL; 455 (*result)->styles_sec = NULL;
356 res = -1; 456 res = -1;
357 } else { 457 } else {
358 psiconv_debug(lev+2,header->section_table_offset, 458 psiconv_debug(lev+2,sto,
359 "Word styles section at offset %08x",styles_sec); 459 "Word styles section at offset %08x",styles_sec);
360 res |= psiconv_parse_word_styles_section(buf,lev+2,styles_sec,NULL, 460 res |= psiconv_parse_word_styles_section(buf,lev+2,styles_sec,NULL,
361 &(*result)->styles_sec); 461 &(*result)->styles_sec);
362 } 462 }
363 463
364 psiconv_progress(lev+2,header->section_table_offset, 464 psiconv_progress(lev+2,sto,
365 "Looking for the Text section"); 465 "Looking for the Text section");
366 if (!text_sec) { 466 if (!text_sec) {
367 psiconv_warn(lev+2,header->section_table_offset, 467 psiconv_warn(lev+2,sto, "Text section not found in the section table");
368 "Text section not found in the section table");
369 (*result)->paragraphs = NULL; 468 (*result)->paragraphs = NULL;
370 res = -1; 469 res = -1;
371 } else { 470 } else {
372 psiconv_debug(lev+2,header->section_table_offset, 471 psiconv_debug(lev+2,sto,
373 "Text section at offset %08x",text_sec); 472 "Text section at offset %08x",text_sec);
374 res |= psiconv_parse_text_section(buf,lev+2,text_sec,NULL, 473 res |= psiconv_parse_text_section(buf,lev+2,text_sec,NULL,
375 &(*result)->paragraphs); 474 &(*result)->paragraphs);
376 } 475 }
377 476
378 if (((*result)->paragraphs) && ((*result)->styles_sec)) { 477 if (((*result)->paragraphs) && ((*result)->styles_sec)) {
379 psiconv_progress(lev+2,header->section_table_offset, 478 psiconv_progress(lev+2,sto,
380 "Looking for the Layout section"); 479 "Looking for the Layout section");
381 if (!layout_sec) { 480 if (!layout_sec) {
382 psiconv_debug(lev+2,header->section_table_offset, 481 psiconv_debug(lev+2,sto,
383 "Layout section not found in the section table"); 482 "Layout section not found in the section table");
384 res = -1; 483 res = -1;
385 } else { 484 } else {
386 psiconv_debug(lev+2,header->section_table_offset, 485 psiconv_debug(lev+2,sto,
387 "Layout section at offset %08x",layout_sec); 486 "Layout section at offset %08x",layout_sec);
388 res |= psiconv_parse_styled_layout_section(buf,lev+2,layout_sec,NULL, 487 res |= psiconv_parse_styled_layout_section(buf,lev+2,layout_sec,NULL,
389 (*result)->paragraphs, 488 (*result)->paragraphs,
390 (*result)->styles_sec); 489 (*result)->styles_sec);
391 } 490 }
392 } else 491 } else
393 psiconv_debug(lev+2,header->section_table_offset, 492 psiconv_debug(lev+2,sto,
394 "Skipping search for Layout section, as either the " 493 "Skipping search for Layout section, as either the "
395 "text or the word styles section was not found"); 494 "text or the word styles section was not found");
396 495
397 psiconv_free_application_id_section(appl_id); 496 psiconv_free_application_id_section(appl_id);
398 psiconv_free_header_section(header);
399 psiconv_free_section_table_section(table); 497 psiconv_free_section_table_section(table);
400 498
401 psiconv_progress(lev+1,off,"End of word file"); 499 psiconv_progress(lev+1,off,"End of word file");
402 return res; 500 return res;
403} 501}

Legend:
Removed from v.13  
changed lines
  Added in v.42

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26