--- psiconv/trunk/lib/psiconv/parse_common.c 1999/10/03 21:10:47 2 +++ psiconv/trunk/lib/psiconv/parse_common.c 2000/12/13 16:30:21 63 @@ -1,6 +1,6 @@ /* parse_common.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999 Frodo Looijaard + Copyright (c) 1999, 2000 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ */ #include "config.h" +#include "compat.h" #include #include @@ -45,6 +46,16 @@ psiconv_progress(lev+2,off+len,"Going to read UID1 to UID3"); (*result)->uid1 = psiconv_read_u32(buf,lev+2,off+len); psiconv_debug(lev+2,off+len,"UID1: %08x",(*result)->uid1); + if ((*result)->uid1 == PSICONV_ID_CLIPART) { + /* That's all folks... */ + (*result)->file = psiconv_clipart_file; + (*result)->uid2 = 0; + (*result)->uid3 = 0; + (*result)->checksum = 0; + len += 4; + psiconv_debug(lev+2,off+len,"File is a Clipart file"); + goto DONE; + } if ((*result)->uid1 != PSICONV_ID_PSION5) { psiconv_warn(lev+2,off+len,"UID1 has unknown value. This is probably " "not a (parsable) Psion 5 file"); @@ -67,8 +78,16 @@ } else if ((*result)->uid3 == PSICONV_ID_TEXTED) { (*result)->file = psiconv_texted_file; psiconv_debug(lev+2,off+len,"File is a TextEd file"); - } - } + } else if ((*result)->uid3 == PSICONV_ID_SKETCH) { + (*result)->file = psiconv_sketch_file; + psiconv_debug(lev+2,off+len,"File is a Sketch file"); + } + } else if ((*result)->uid2 == PSICONV_ID_MBM_FILE) { + (*result)->file = psiconv_mbm_file; + if ((*result)->uid3 != 0x00) + psiconv_warn(lev+2,off+len,"UID3 set in MBM file?!?"); + psiconv_debug(lev+2,off+len,"File is a MBM file"); + } } if ((*result)->file == psiconv_unknown_file) { psiconv_warn(lev+2,off+len,"Unknown file type"); @@ -88,13 +107,8 @@ res = -1; } len += 4; - - psiconv_progress(lev+2,off+len,"Going to read Section Table Section offset"); - (*result)->section_table_offset = psiconv_read_u32(buf,lev+2,off+len); - psiconv_debug(lev+2,off+len,"Section Table Section starts at offset %08x", - (*result)->section_table_offset) ; - len += 4; +DONE: if (length) *length = len; @@ -146,7 +160,7 @@ *length = len; psiconv_progress(lev+1,off+len-1,"End of section table section " - "(total length: %08x", len); + "(total length: %08x)", len); return res; } @@ -246,8 +260,8 @@ /* Initialize the remaining parts of each paragraph */ for (i = 0; i < psiconv_list_length(*result); i ++) { para = psiconv_list_get(*result,i); - para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout)); - para->replacements = psiconv_list_new(sizeof(struct psiconv_replacement)); + para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout_s)); + para->replacements = psiconv_list_new(sizeof(struct psiconv_replacement_s)); para->base_style = 0; para->base_character = psiconv_basic_character_layout(); para->base_paragraph = psiconv_basic_paragraph_layout(); @@ -278,7 +292,7 @@ psiconv_u32 temp; int parse_styles,nr,i,j,total,leng,line_length; - typedef struct anon_style + typedef struct anon_style_s { int nr; psiconv_s16 base_style; @@ -289,11 +303,11 @@ typedef psiconv_list anon_style_list; /* of struct anon_style */ anon_style_list anon_styles; - struct anon_style anon; + struct anon_style_s anon; anon_style anon_ptr=NULL; psiconv_paragraph para; - struct psiconv_in_line_layout in_line; + struct psiconv_in_line_layout_s in_line; int *inline_count; @@ -384,7 +398,7 @@ if (i >= psiconv_list_length(result)) { psiconv_debug(lev+4,off+len,"Going to allocate a new element"); para = malloc(sizeof(*para)); - para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout)); + para->in_lines = psiconv_list_new(sizeof(struct psiconv_in_line_layout_s)); para->base_style = 0; para->base_character = psiconv_basic_character_layout(); para->base_paragraph = psiconv_basic_paragraph_layout(); @@ -440,11 +454,11 @@ ,temp); len += 0x01; if (parse_styles) { - psiconv_progress(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len), + psiconv_progress(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len)+4, "Going to read the paragraph element base style"); temp = psiconv_read_u8(buf,lev+4, - off+len+psiconv_read_u32(buf,lev+4,off+len)); - psiconv_debug(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len), + off+len+psiconv_read_u32(buf,lev+4,off+len)+4); + psiconv_debug(lev+4,off+len+psiconv_read_u32(buf,lev+4,off+len)+4, "Style: %02x",temp); } else temp = 0x00; @@ -574,7 +588,7 @@ styles_section->normal->paragraph = psiconv_clone_paragraph_layout(base_para); styles_section->normal->hotkey = 0; styles_section->normal->name = strdup(""); - styles_section->styles = psiconv_list_new(sizeof(struct psiconv_word_style)); + styles_section->styles = psiconv_list_new(sizeof(struct psiconv_word_style_s)); res = psiconv_parse_layout_section(buf,lev,off,length,result, styles_section,0);