--- psiconv/trunk/lib/psiconv/parse_common.c 2004/01/04 22:20:43 183 +++ psiconv/trunk/lib/psiconv/parse_common.c 2004/01/06 20:15:01 184 @@ -71,7 +71,7 @@ goto DONE; } if ((*result)->uid1 != PSICONV_ID_PSION5) { - psiconv_warn(config,lev+2,off+len, + psiconv_error(config,lev+2,off+len, "UID1 has unknown value. This is probably " "not a (parsable) Psion 5 file"); res = -PSICONV_E_PARSE; @@ -125,7 +125,7 @@ (*result)->uid3)) psiconv_debug(config,lev+2,off+len,"Checksum %08x is correct",temp); else { - psiconv_warn(config,lev+2,off+len,"Checksum failed, file corrupted!"); + psiconv_error(config,lev+2,off+len,"Checksum failed, file corrupted!"); psiconv_debug(config,lev+2,off+len,"Expected checksum %08x, found %08x", psiconv_checkuid((*result)->uid1,(*result)->uid2, (*result)->uid3),temp); @@ -146,7 +146,7 @@ ERROR2: free(*result); ERROR1: - psiconv_warn(config,lev+1,off,"Reading of Header Section failed"); + psiconv_error(config,lev+1,off,"Reading of Header Section failed"); if (length) *length = 0; if (res == 0) @@ -213,7 +213,7 @@ ERROR2: psiconv_list_free(*result); ERROR1: - psiconv_warn(config,lev+1,off,"Reading of Section Table Section failed"); + psiconv_error(config,lev+1,off,"Reading of Section Table Section failed"); if (length) *length = 0; if (res == 0) @@ -258,7 +258,7 @@ ERROR2: free(*result); ERROR1: - psiconv_warn(config,lev+1,off,"Reading of Application ID Section failed"); + psiconv_error(config,lev+1,off,"Reading of Application ID Section failed"); if (length) *length = 0; if (res == 0) @@ -277,9 +277,10 @@ psiconv_u32 text_len; psiconv_paragraph para; + psiconv_u8 temp; int nr; - int i,j,start,leng,temp; + int i,j,start,leng; char *str_copy; psiconv_progress(config,lev+1,off,"Going to parse the text section"); @@ -304,20 +305,20 @@ if (res) goto ERROR3; if (temp == 0x06) { - if (!(para->text = malloc(i - start + 1))) + if (!(para->text = malloc((sizeof((*(para->text))) * (i - start + 1))))) goto ERROR3; for (j = 0; j < i - start; j++) { temp = psiconv_read_u8(config,buf,lev+1,off + len + start + j,&res); if (res) goto ERROR4; - para->text[j] = temp; + para->text[j] = psiconv_unicode_from_char(config,temp); } para->text[j] = 0; if ((res = psiconv_list_add(*result,para))) goto ERROR4; - if (!(str_copy = psiconv_make_printable(para->text))) + if (!(str_copy = psiconv_make_printable(config,para->text))) goto ERROR3; psiconv_debug(config,lev+2,off+i+len,"Line %d: %d characters",nr, strlen(str_copy) +1); @@ -338,12 +339,12 @@ temp = psiconv_read_u8(config,buf,lev+2,off + start + j + len, &res); if (res) goto ERROR4; - para->text[j] = temp; + para->text[j] = psiconv_unicode_from_char(config,temp); } para->text[text_len - start] = 0; if ((res = psiconv_list_add(*result,para))) goto ERROR4; - if (!(str_copy = psiconv_make_printable(para->text))) + if (!(str_copy = psiconv_make_printable(config,para->text))) goto ERROR3; psiconv_debug(config,lev+2,off+start+len,"Last line: %d characters",nr, strlen(str_copy)+1); @@ -356,7 +357,7 @@ /* Initialize the remaining parts of each paragraph */ for (i = 0; i < psiconv_list_length(*result); i ++) { if (!(para = psiconv_list_get(*result,i))) { - psiconv_warn(config,lev+2,off+len,"Massive memory corruption"); + psiconv_error(config,lev+2,off+len,"Massive memory corruption"); goto ERROR2_0; } if (!(para->in_lines = psiconv_list_new(sizeof( @@ -392,7 +393,7 @@ ERROR2_0: for (j = 0; j < i; j++) { if (!(para = psiconv_list_get(*result,j))) { - psiconv_warn(config,lev+1,off,"Massive memory corruption..."); + psiconv_error(config,lev+1,off,"Massive memory corruption..."); break; } psiconv_list_free(para->in_lines); @@ -409,14 +410,14 @@ ERROR2: for (i = 0; i < psiconv_list_length(*result);i++) { if (!(para = psiconv_list_get(*result,i))) { - psiconv_warn(config,lev+1,off,"Massive memory corruption..."); + psiconv_error(config,lev+1,off,"Massive memory corruption..."); break; } free(para->text); } psiconv_list_free(*result); ERROR1: - psiconv_warn(config,lev+1,off,"Reading of Text Section failed"); + psiconv_error(config,lev+1,off,"Reading of Text Section failed"); if (length) *length = 0; if (!res) @@ -590,12 +591,12 @@ temp = psiconv_read_u32(config,buf,lev+4,off+len,&res); if (res) goto ERROR4; - if (temp != strlen(para->text)+1) { + if (temp != psiconv_unicode_strlen(para->text)+1) { psiconv_warn(config,lev+4,off+len, "Disagreement of the length of paragraph in layout section"); psiconv_debug(config,lev+4,off+len, "Paragraph length: layout section says %d, counted %d", - temp,strlen(para->text)+1); + temp,psiconv_unicode_strlen(para->text)+1); } else psiconv_debug(config,lev+4,off+len,"Paragraph length: %d",temp); len += 4; @@ -608,7 +609,7 @@ psiconv_debug(config,lev+4,off+len,"Type: %02x",temp); for (j = 0; j < psiconv_list_length(anon_styles); j++) { if (!(anon_ptr = psiconv_list_get(anon_styles,j))) { - psiconv_warn(config,lev+4,off+len,"Massive memory curruption"); + psiconv_error(config,lev+4,off+len,"Massive memory curruption"); goto ERROR4; } if (temp == anon_ptr->nr) @@ -619,7 +620,7 @@ psiconv_debug(config,lev+4,off+len,"Unknown type - using base styles instead"); para->base_style = 0; if (!(temp_style = psiconv_get_style(styles,0))) { - psiconv_warn(config,lev+4,off,"Base style unknown"); + psiconv_error(config,lev+4,off,"Base style unknown"); goto ERROR4; } if (!(temp_para = psiconv_clone_paragraph_layout @@ -667,7 +668,7 @@ if (!(temp_style = psiconv_get_style (styles,temp))) { psiconv_warn(config,lev+4,off,"Unknown Style referenced"); if (!(temp_style = psiconv_get_style(styles,0))) { - psiconv_warn(config,lev+4,off,"Base style unknown"); + psiconv_error(config,lev+4,off,"Base style unknown"); goto ERROR4; } } @@ -714,7 +715,7 @@ total = 0; for (i = 0; i < psiconv_list_length(result); i++) { if (!(para = psiconv_list_get(result,i))) { - psiconv_warn(config,lev+3,off+len,"Massive memory corruption"); + psiconv_error(config,lev+3,off+len,"Massive memory corruption"); goto ERROR4; } line_length = -1; @@ -797,11 +798,11 @@ } else if (temp != 0x00) { psiconv_warn(config,lev+4,off+len,"Layout section unknown inline type"); } - if (line_length + in_line.length > strlen(para->text)) { + if (line_length + in_line.length > psiconv_unicode_strlen(para->text)) { psiconv_warn(config,lev+4,off+len, "Layout section inlines: line length mismatch"); res = -1; - in_line.length = strlen(para->text) - line_length; + in_line.length = psiconv_unicode_strlen(para->text) - line_length; } line_length += in_line.length; if ((res = psiconv_list_add(para->in_lines,&in_line))) @@ -819,7 +820,7 @@ for (i = 0 ; i < psiconv_list_length(anon_styles); i ++) { if (!(anon_ptr = psiconv_list_get(anon_styles,i))) { - psiconv_warn(config,lev+4,off+len,"Massive memory corruption"); + psiconv_error(config,lev+4,off+len,"Massive memory corruption"); goto ERROR2; } psiconv_free_character_layout(anon_ptr->character); @@ -861,7 +862,7 @@ ERROR3: for (i = 0; i < psiconv_list_length(anon_styles); i++) { if (!(anon_ptr = psiconv_list_get(anon_styles,i))) { - psiconv_warn(config,lev+1,off,"Massive memory corruption"); + psiconv_error(config,lev+1,off,"Massive memory corruption"); break; } psiconv_free_paragraph_layout(anon_ptr->paragraph); @@ -871,7 +872,7 @@ ERROR2: psiconv_list_free(anon_styles); ERROR1: - psiconv_warn(config,lev+1,off,"Reading of Layout Section failed"); + psiconv_error(config,lev+1,off,"Reading of Layout Section failed"); if (length) *length = 0; if (!res) @@ -912,7 +913,8 @@ psiconv_clone_paragraph_layout(base_para))) goto ERROR4; styles_section->normal->hotkey = 0; - if (!(styles_section->normal->name = strdup(""))) + if (( res = psiconv_unicode_from_chars(config,"", + &styles_section->normal->name))) goto ERROR5; if (!(styles_section->styles = psiconv_list_new(sizeof( struct psiconv_word_style_s)))) @@ -935,7 +937,7 @@ ERROR2: free(styles_section); ERROR1: - psiconv_warn(config,lev+1,off,"Reading of Styleless Layout Section failed"); + psiconv_error(config,lev+1,off,"Reading of Styleless Layout Section failed"); if (length) *length = 0; if (!res) @@ -1083,7 +1085,7 @@ ERROR2: psiconv_free_section_table_section(table); ERROR1: - psiconv_warn(config,lev+1,off,"Reading Embedded Object failed"); + psiconv_error(config,lev+1,off,"Reading Embedded Object failed"); if (length) *length = 0; @@ -1132,7 +1134,7 @@ } } if (i == psiconv_list_length(table)) { - psiconv_warn(config,lev+2,off,"No Application ID Section found"); + psiconv_error(config,lev+2,off,"No Application ID Section found"); res = PSICONV_E_PARSE; goto ERROR2; } @@ -1234,7 +1236,7 @@ ERROR2: free(*result); ERROR1: - psiconv_warn(config,lev+1,off+len,"Reading of Object Display Section failed"); + psiconv_error(config,lev+1,off+len,"Reading of Object Display Section failed"); if (length) *length=0; if (!res) @@ -1289,7 +1291,7 @@ ERROR2: free(*result); ERROR1: - psiconv_warn(config,lev+1,off+len,"Reading of Object Icon Section failed"); + psiconv_error(config,lev+1,off+len,"Reading of Object Icon Section failed"); if (length) *length=0; if (!res)