--- psiconv/trunk/lib/psiconv/parse_image.c 1999/12/03 23:13:55 42 +++ psiconv/trunk/lib/psiconv/parse_image.c 1999/12/04 00:40:10 43 @@ -448,3 +448,87 @@ return res; } + +int psiconv_parse_clipart_section(const psiconv_buffer buf,int lev, + psiconv_u32 off, int *length, + psiconv_clipart_section *result) +{ + int res=0; + int len=0; + int leng; + psiconv_u32 temp; + + psiconv_progress(lev+1,off+len,"Going to read the clipart section"); + *result = malloc(sizeof(**result)); + + psiconv_progress(lev+2,off+len,"Going to read the section ID"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != PSICONV_ID_CLIPART_ITEM) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, + PSICONV_ID_CLIPART_ITEM); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Clipart ID: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read an unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0x02) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, + 0x02); + res = -1; + } else + psiconv_debug(lev+2,off+len,"First unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read a second unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Second unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read a third unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Third unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read a fourth unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if ((temp != 0x0c) && (temp != 0x08)) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x or %08x",temp, + 0x0c, 0x08); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Fourth unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read the Paint Data Section"); + res |= psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng, + &((*result)->picture)); + len += leng; + + if (length) + *length = len; + + psiconv_progress(lev,off+len-1, + "End of clipart section (total length: %08x)", len); + + return res; +}