--- psiconv/trunk/lib/psiconv/parse_sheet.c 2001/01/17 00:05:08 94 +++ psiconv/trunk/lib/psiconv/parse_sheet.c 2001/01/17 12:04:12 95 @@ -182,3 +182,77 @@ return res; } +int psiconv_parse_sheet_workbook_section(const psiconv_buffer buf, int lev, + psiconv_u32 off, int *length, + psiconv_sheet_workbook_section *result) +{ + int res=0; + psiconv_u32 temp; + int len=0; + + psiconv_progress(lev+1,off,"Going to read the sheet workbook section"); + if (!(*result = malloc(sizeof(**result)))) + goto ERROR1; + + psiconv_progress(lev+2,off+len, + "Going to read the initial byte (%02x expected)",0x04); + temp = psiconv_read_u8(buf,lev+2,off+len,&res); + if (res) + goto ERROR2; + if (temp != 0x04) { + psiconv_warn(lev+2,off+len, + "Sheet workbook section initial byte unknown value (ignored)"); + psiconv_debug(lev+2,off+len,"Initial byte: %02x",temp); + } + len ++; + + psiconv_progress(lev+2,off+len, + "Going to read the offset of the 1st ??? Section"); + temp = psiconv_read_u32(buf,lev+2,off+len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Offset: %04x",temp); + len += 4; + + psiconv_progress(lev+2,off+len, + "Going to read the offset of the 2nd ??? Section"); + temp = psiconv_read_u32(buf,lev+2,off+len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Offset: %04x",temp); + len += 4; + + psiconv_progress(lev+2,off+len, + "Going to read the offset of the 3rd ??? Section"); + temp = psiconv_read_u32(buf,lev+2,off+len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Offset: %04x",temp); + len += 4; + + psiconv_progress(lev+2,off+len, + "Going to read the offset of the 4th ??? Section"); + temp = psiconv_read_u32(buf,lev+2,off+len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Offset: %04x",temp); + len += 4; + + if (length) + *length = len; + + psiconv_progress(lev,off+len-1, + "End of sheet workbook section (total length: %08x)", len); + return 0; + +ERROR2: + free (*result); +ERROR1: + psiconv_warn(lev+1,off,"Reading of Sheet Workbook Section failed"); + if (length) + *length = 0; + if (!res) + return -PSICONV_E_NOMEM; + else + return res; +}