… | |
… | |
44 | (*result) = malloc(sizeof(**result)); |
44 | (*result) = malloc(sizeof(**result)); |
45 | |
45 | |
46 | psiconv_progress(lev+2,off+len,"Going to read UID1 to UID3"); |
46 | psiconv_progress(lev+2,off+len,"Going to read UID1 to UID3"); |
47 | (*result)->uid1 = psiconv_read_u32(buf,lev+2,off+len); |
47 | (*result)->uid1 = psiconv_read_u32(buf,lev+2,off+len); |
48 | psiconv_debug(lev+2,off+len,"UID1: %08x",(*result)->uid1); |
48 | psiconv_debug(lev+2,off+len,"UID1: %08x",(*result)->uid1); |
|
|
49 | if ((*result)->uid1 == PSICONV_ID_CLIPART) { |
|
|
50 | /* That's all folks... */ |
|
|
51 | (*result)->file = psiconv_clipart_file; |
|
|
52 | (*result)->uid2 = 0; |
|
|
53 | (*result)->uid3 = 0; |
|
|
54 | (*result)->checksum = 0; |
|
|
55 | len += 4; |
|
|
56 | psiconv_debug(lev+2,off+len,"File is a Clipart file"); |
|
|
57 | goto DONE; |
|
|
58 | } |
49 | if ((*result)->uid1 != PSICONV_ID_PSION5) { |
59 | if ((*result)->uid1 != PSICONV_ID_PSION5) { |
50 | psiconv_warn(lev+2,off+len,"UID1 has unknown value. This is probably " |
60 | psiconv_warn(lev+2,off+len,"UID1 has unknown value. This is probably " |
51 | "not a (parsable) Psion 5 file"); |
61 | "not a (parsable) Psion 5 file"); |
52 | res = -1; |
62 | res = -1; |
53 | } |
63 | } |
… | |
… | |
66 | (*result)->file = psiconv_word_file; |
76 | (*result)->file = psiconv_word_file; |
67 | psiconv_debug(lev+2,off+len,"File is a Word file"); |
77 | psiconv_debug(lev+2,off+len,"File is a Word file"); |
68 | } else if ((*result)->uid3 == PSICONV_ID_TEXTED) { |
78 | } else if ((*result)->uid3 == PSICONV_ID_TEXTED) { |
69 | (*result)->file = psiconv_texted_file; |
79 | (*result)->file = psiconv_texted_file; |
70 | psiconv_debug(lev+2,off+len,"File is a TextEd file"); |
80 | psiconv_debug(lev+2,off+len,"File is a TextEd file"); |
|
|
81 | } else if ((*result)->uid3 == PSICONV_ID_SKETCH) { |
|
|
82 | (*result)->file = psiconv_sketch_file; |
|
|
83 | psiconv_debug(lev+2,off+len,"File is a Sketch file"); |
71 | } |
84 | } |
72 | } else if ((*result)->uid2 == PSICONV_ID_MBM_FILE) { |
85 | } else if ((*result)->uid2 == PSICONV_ID_MBM_FILE) { |
73 | (*result)->file = psiconv_mbm_file; |
86 | (*result)->file = psiconv_mbm_file; |
74 | if ((*result)->uid3 != 0x00) |
87 | if ((*result)->uid3 != 0x00) |
75 | psiconv_warn(lev+2,off+len,"UID3 set in MBM file?!?"); |
88 | psiconv_warn(lev+2,off+len,"UID3 set in MBM file?!?"); |
76 | psiconv_debug(lev+2,off+len,"File is a MBM file"); |
89 | psiconv_debug(lev+2,off+len,"File is a MBM file"); |
… | |
… | |
92 | psiconv_checkuid((*result)->uid1,(*result)->uid2, |
105 | psiconv_checkuid((*result)->uid1,(*result)->uid2, |
93 | (*result)->uid3),temp); |
106 | (*result)->uid3),temp); |
94 | res = -1; |
107 | res = -1; |
95 | } |
108 | } |
96 | len += 4; |
109 | len += 4; |
97 | |
110 | |
|
|
111 | DONE: |
98 | if (length) |
112 | if (length) |
99 | *length = len; |
113 | *length = len; |
100 | |
114 | |
101 | psiconv_progress(lev+1,off+len-1, |
115 | psiconv_progress(lev+1,off+len-1, |
102 | "End of Header Section (total length: %08x)",len); |
116 | "End of Header Section (total length: %08x)",len); |
… | |
… | |
144 | |
158 | |
145 | if (length) |
159 | if (length) |
146 | *length = len; |
160 | *length = len; |
147 | |
161 | |
148 | psiconv_progress(lev+1,off+len-1,"End of section table section " |
162 | psiconv_progress(lev+1,off+len-1,"End of section table section " |
149 | "(total length: %08x", len); |
163 | "(total length: %08x)", len); |
150 | |
164 | |
151 | return res; |
165 | return res; |
152 | } |
166 | } |
153 | |
167 | |
154 | int psiconv_parse_application_id_section(const psiconv_buffer buf, int lev, |
168 | int psiconv_parse_application_id_section(const psiconv_buffer buf, int lev, |
… | |
… | |
244 | free(para); |
258 | free(para); |
245 | |
259 | |
246 | /* Initialize the remaining parts of each paragraph */ |
260 | /* Initialize the remaining parts of each paragraph */ |
247 | for (i = 0; i < psiconv_list_length(*result); i ++) { |
261 | for (i = 0; i < psiconv_list_length(*result); i ++) { |
248 | para = psiconv_list_get(*result,i); |
262 | para = psiconv_list_get(*result,i); |
249 | para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout)); |
263 | para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout_s)); |
250 | para->replacements = psiconv_list_new(sizeof(struct psiconv_replacement)); |
264 | para->replacements = psiconv_list_new(sizeof(struct psiconv_replacement_s)); |
251 | para->base_style = 0; |
265 | para->base_style = 0; |
252 | para->base_character = psiconv_basic_character_layout(); |
266 | para->base_character = psiconv_basic_character_layout(); |
253 | para->base_paragraph = psiconv_basic_paragraph_layout(); |
267 | para->base_paragraph = psiconv_basic_paragraph_layout(); |
254 | } |
268 | } |
255 | |
269 | |
… | |
… | |
276 | int res = 0; |
290 | int res = 0; |
277 | int len = 0; |
291 | int len = 0; |
278 | psiconv_u32 temp; |
292 | psiconv_u32 temp; |
279 | int parse_styles,nr,i,j,total,leng,line_length; |
293 | int parse_styles,nr,i,j,total,leng,line_length; |
280 | |
294 | |
281 | typedef struct anon_style |
295 | typedef struct anon_style_s |
282 | { |
296 | { |
283 | int nr; |
297 | int nr; |
284 | psiconv_s16 base_style; |
298 | psiconv_s16 base_style; |
285 | psiconv_character_layout character; |
299 | psiconv_character_layout character; |
286 | psiconv_paragraph_layout paragraph; |
300 | psiconv_paragraph_layout paragraph; |
287 | } *anon_style; |
301 | } *anon_style; |
288 | |
302 | |
289 | typedef psiconv_list anon_style_list; /* of struct anon_style */ |
303 | typedef psiconv_list anon_style_list; /* of struct anon_style */ |
290 | |
304 | |
291 | anon_style_list anon_styles; |
305 | anon_style_list anon_styles; |
292 | struct anon_style anon; |
306 | struct anon_style_s anon; |
293 | anon_style anon_ptr=NULL; |
307 | anon_style anon_ptr=NULL; |
294 | |
308 | |
295 | psiconv_paragraph para; |
309 | psiconv_paragraph para; |
296 | struct psiconv_in_line_layout in_line; |
310 | struct psiconv_in_line_layout_s in_line; |
297 | |
311 | |
298 | int *inline_count; |
312 | int *inline_count; |
299 | |
313 | |
300 | |
314 | |
301 | psiconv_progress(lev+1,off,"Going to read the layout section"); |
315 | psiconv_progress(lev+1,off,"Going to read the layout section"); |
… | |
… | |
382 | for (i = 0; i < nr; i ++) { |
396 | for (i = 0; i < nr; i ++) { |
383 | psiconv_progress(lev+3,off+len,"Element %d",i); |
397 | psiconv_progress(lev+3,off+len,"Element %d",i); |
384 | if (i >= psiconv_list_length(result)) { |
398 | if (i >= psiconv_list_length(result)) { |
385 | psiconv_debug(lev+4,off+len,"Going to allocate a new element"); |
399 | psiconv_debug(lev+4,off+len,"Going to allocate a new element"); |
386 | para = malloc(sizeof(*para)); |
400 | para = malloc(sizeof(*para)); |
387 | para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout)); |
401 | para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout_s)); |
388 | para->base_style = 0; |
402 | para->base_style = 0; |
389 | para->base_character = psiconv_basic_character_layout(); |
403 | para->base_character = psiconv_basic_character_layout(); |
390 | para->base_paragraph = psiconv_basic_paragraph_layout(); |
404 | para->base_paragraph = psiconv_basic_paragraph_layout(); |
391 | free(para); |
405 | free(para); |
392 | } |
406 | } |
… | |
… | |
438 | } else { |
452 | } else { |
439 | psiconv_debug(lev+4,off+len,"Type: %02x (not based on a paragraph type)" |
453 | psiconv_debug(lev+4,off+len,"Type: %02x (not based on a paragraph type)" |
440 | ,temp); |
454 | ,temp); |
441 | len += 0x01; |
455 | len += 0x01; |
442 | if (parse_styles) { |
456 | if (parse_styles) { |
443 | psiconv_progress(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len), |
457 | psiconv_progress(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len)+4, |
444 | "Going to read the paragraph element base style"); |
458 | "Going to read the paragraph element base style"); |
445 | temp = psiconv_read_u8(buf,lev+4, |
459 | temp = psiconv_read_u8(buf,lev+4, |
446 | off+len+psiconv_read_u32(buf,lev+4,off+len)); |
460 | off+len+psiconv_read_u32(buf,lev+4,off+len)+4); |
447 | psiconv_debug(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len), |
461 | psiconv_debug(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len)+4, |
448 | "Style: %02x",temp); |
462 | "Style: %02x",temp); |
449 | } else |
463 | } else |
450 | temp = 0x00; |
464 | temp = 0x00; |
451 | psiconv_free_paragraph_layout(para->base_paragraph); |
465 | psiconv_free_paragraph_layout(para->base_paragraph); |
452 | psiconv_free_character_layout(para->base_character); |
466 | psiconv_free_character_layout(para->base_character); |
… | |
… | |
572 | styles_section->normal = malloc(sizeof(*styles_section->normal)); |
586 | styles_section->normal = malloc(sizeof(*styles_section->normal)); |
573 | styles_section->normal->character = psiconv_clone_character_layout(base_char); |
587 | styles_section->normal->character = psiconv_clone_character_layout(base_char); |
574 | styles_section->normal->paragraph = psiconv_clone_paragraph_layout(base_para); |
588 | styles_section->normal->paragraph = psiconv_clone_paragraph_layout(base_para); |
575 | styles_section->normal->hotkey = 0; |
589 | styles_section->normal->hotkey = 0; |
576 | styles_section->normal->name = strdup(""); |
590 | styles_section->normal->name = strdup(""); |
577 | styles_section->styles = psiconv_list_new(sizeof(struct psiconv_word_style)); |
591 | styles_section->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)); |
578 | |
592 | |
579 | res = psiconv_parse_layout_section(buf,lev,off,length,result, |
593 | res = psiconv_parse_layout_section(buf,lev,off,length,result, |
580 | styles_section,0); |
594 | styles_section,0); |
581 | |
595 | |
582 | psiconv_free_word_styles_section(styles_section); |
596 | psiconv_free_word_styles_section(styles_section); |