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

Legend:
Removed from v.12  
changed lines
  Added in v.41

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