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

Legend:
Removed from v.2  
changed lines
  Added in v.45

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