--- psiconv/trunk/lib/psiconv/parse_page.c 2003/11/23 21:47:24 167 +++ psiconv/trunk/lib/psiconv/parse_page.c 2003/11/25 17:57:05 168 @@ -31,7 +31,8 @@ #endif -int psiconv_parse_page_header(const psiconv_buffer buf,int lev,psiconv_u32 off, +int psiconv_parse_page_header(const psiconv_config config, + const psiconv_buffer buf,int lev,psiconv_u32 off, int *length,psiconv_page_header *result) { int res = 0; @@ -39,13 +40,13 @@ int i,leng,has_content; psiconv_u32 temp; - psiconv_progress(lev+1,off,"Going to read a page header (or footer)"); + psiconv_progress(config,lev+1,off,"Going to read a page header (or footer)"); if (!(*result = malloc(sizeof(**result)))) goto ERROR1; - psiconv_progress(lev+2,off+len, + psiconv_progress(config,lev+2,off+len, "Going to read the has_content flag"); - temp = psiconv_read_u8(buf,lev+2,off+len,&res); + temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); if (res) goto ERROR2; if (temp == 0x00) @@ -53,58 +54,58 @@ else if (temp == 0x01) has_content = 1; else { - psiconv_warn(lev+2,off+len, + psiconv_warn(config,lev+2,off+len, "Page header has_content flag unknown value (assumed default)"); - psiconv_debug(lev+2,off+len,"Flag: %02x",temp); + psiconv_debug(config,lev+2,off+len,"Flag: %02x",temp); has_content = 1; } - psiconv_debug(lev+2,off+len,"Has_content flag: %02x",has_content); + psiconv_debug(config,lev+2,off+len,"Has_content flag: %02x",has_content); len += 1; - psiconv_progress(lev+2,off+len,"Going to read displayed-on-first-page flag"); - if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng, + psiconv_progress(config,lev+2,off+len,"Going to read displayed-on-first-page flag"); + if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng, &(*result)->on_first_page))) goto ERROR2; len += leng; - psiconv_progress(lev+2,off+len,"Going to read three zero bytes"); + psiconv_progress(config,lev+2,off+len,"Going to read three zero bytes"); for (i = 0; i < 0x03; i++,len++) { - temp = psiconv_read_u8(buf,lev+2,off+len,&res); + temp = psiconv_read_u8(config,buf,lev+2,off+len,&res); if (res) goto ERROR2; if (temp != 0x00) { - psiconv_warn(lev+2,off+len, + psiconv_warn(config,lev+2,off+len, "Page Header unknown value in zero bytes section"); - psiconv_debug(lev+2,off+len,"Byte %d: read %02x, expected %02x", + psiconv_debug(config,lev+2,off+len,"Byte %d: read %02x, expected %02x", i,temp,0x00); } } - psiconv_progress(lev+2,off+len,"Going to read base paragraph layout"); + psiconv_progress(config,lev+2,off+len,"Going to read base paragraph layout"); if (!((*result)->base_paragraph_layout = psiconv_basic_paragraph_layout())) goto ERROR2; if (has_content) { - if ((res = psiconv_parse_paragraph_layout_list(buf,lev+2,off+len,&leng, + if ((res = psiconv_parse_paragraph_layout_list(config,buf,lev+2,off+len,&leng, (*result)->base_paragraph_layout))) goto ERROR3; len += leng; } - psiconv_progress(lev+2,off+len,"Going to read base character layout"); + psiconv_progress(config,lev+2,off+len,"Going to read base character layout"); if (!((*result)->base_character_layout = psiconv_basic_character_layout())) goto ERROR3; if (has_content) { - if ((res = psiconv_parse_character_layout_list(buf,lev+2,off+len,&leng, + if ((res = psiconv_parse_character_layout_list(config,buf,lev+2,off+len,&leng, (*result)->base_character_layout))) goto ERROR4; } len += leng; - psiconv_progress(lev+2,off+len,"Going to read the TextEd section"); + psiconv_progress(config,lev+2,off+len,"Going to read the TextEd section"); if (has_content) { - if ((res = psiconv_parse_texted_section(buf,lev+2,off+len,&leng, + if ((res = psiconv_parse_texted_section(config,buf,lev+2,off+len,&leng, &(*result)->text, (*result)->base_character_layout, (*result)->base_paragraph_layout))) @@ -117,7 +118,7 @@ if (length) *length = len; - psiconv_progress(lev+1,off+len-1,"End of page header" + psiconv_progress(config,lev+1,off+len-1,"End of page header" "(total length: %08x", len); return res; @@ -129,7 +130,7 @@ ERROR2: free (*result); ERROR1: - psiconv_warn(lev+1,off,"Reading of Page Header failed"); + psiconv_warn(config,lev+1,off,"Reading of Page Header failed"); if (length) *length = 0; if (!res) @@ -138,7 +139,8 @@ return res; } -int psiconv_parse_page_layout_section(const psiconv_buffer buf,int lev, +int psiconv_parse_page_layout_section(const psiconv_config config, + const psiconv_buffer buf,int lev, psiconv_u32 off, int *length, psiconv_page_layout_section *result) { @@ -147,111 +149,111 @@ int leng; psiconv_u32 temp; - psiconv_progress(lev+1,off,"Going to read the page layout section"); + psiconv_progress(config,lev+1,off,"Going to read the page layout section"); if (!(*result = malloc(sizeof(**result)))) goto ERROR1; - psiconv_progress(lev+2,off+len,"Going to read first page number"); - (*result)->first_page_nr = psiconv_read_u32(buf,lev+2,off+len,&res); + psiconv_progress(config,lev+2,off+len,"Going to read first page number"); + (*result)->first_page_nr = psiconv_read_u32(config,buf,lev+2,off+len,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"First page: %d",(*result)->first_page_nr); + psiconv_debug(config,lev+2,off+len,"First page: %d",(*result)->first_page_nr); len += 4; - psiconv_progress(lev+2,off+len,"Going to read header distance"); - (*result)->header_dist = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read header distance"); + (*result)->header_dist = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"Header distance: %6.3f",(*result)->header_dist); + psiconv_debug(config,lev+2,off+len,"Header distance: %6.3f",(*result)->header_dist); len += leng; - psiconv_progress(lev+2,off+len,"Going to read footer distance"); - (*result)->footer_dist = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read footer distance"); + (*result)->footer_dist = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"Footer distance: %6.3f",(*result)->footer_dist); + psiconv_debug(config,lev+2,off+len,"Footer distance: %6.3f",(*result)->footer_dist); len += leng; - psiconv_progress(lev+2,off+len,"Going to read the left margin"); - (*result)->left_margin = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read the left margin"); + (*result)->left_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"Left margin: %6.3f",(*result)->left_margin); + psiconv_debug(config,lev+2,off+len,"Left margin: %6.3f",(*result)->left_margin); len += leng; - psiconv_progress(lev+2,off+len,"Going read the to right margin"); - (*result)->right_margin = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going read the to right margin"); + (*result)->right_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"Right margin: %6.3f",(*result)->right_margin); + psiconv_debug(config,lev+2,off+len,"Right margin: %6.3f",(*result)->right_margin); len += leng; - psiconv_progress(lev+2,off+len,"Going to read the top margin"); - (*result)->top_margin = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read the top margin"); + (*result)->top_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"Top margin: %6.3f",(*result)->top_margin); + psiconv_debug(config,lev+2,off+len,"Top margin: %6.3f",(*result)->top_margin); len += leng; - psiconv_progress(lev+2,off+len,"Going to read the bottom margin"); - (*result)->bottom_margin = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read the bottom margin"); + (*result)->bottom_margin = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR2; - psiconv_debug(lev+2,off+len,"Bottom margin: %6.3f",(*result)->bottom_margin); + psiconv_debug(config,lev+2,off+len,"Bottom margin: %6.3f",(*result)->bottom_margin); len += leng; - psiconv_progress(lev+2,off+len,"Going to read the header"); - if ((res = psiconv_parse_page_header(buf,lev+2,off+len,&leng, + psiconv_progress(config,lev+2,off+len,"Going to read the header"); + if ((res = psiconv_parse_page_header(config,buf,lev+2,off+len,&leng, &(*result)->header))) goto ERROR2; len += leng; - psiconv_progress(lev+2,off+len,"Going to read the footer"); - if ((res = psiconv_parse_page_header(buf,lev+2,off+len,&leng, + psiconv_progress(config,lev+2,off+len,"Going to read the footer"); + if ((res = psiconv_parse_page_header(config,buf,lev+2,off+len,&leng, &(*result)->footer))) goto ERROR3; len += leng; - psiconv_progress(lev+2,off+len,"Going to read page dimensions id"); - temp = psiconv_read_u32(buf,lev+2,off+len,&res); + psiconv_progress(config,lev+2,off+len,"Going to read page dimensions id"); + temp = psiconv_read_u32(config,buf,lev+2,off+len,&res); if (res) goto ERROR4; if ((temp != PSICONV_ID_PAGE_DIMENSIONS1) && (temp != PSICONV_ID_PAGE_DIMENSIONS2)) { - psiconv_warn(lev+2,off+len, + psiconv_warn(config,lev+2,off+len, "Page layout section page dimensions marker not found"); - psiconv_debug(lev+2,off+len, + psiconv_debug(config,lev+2,off+len, "Page dimensions marker: read %08x, expected %08x or %08x", temp, PSICONV_ID_PAGE_DIMENSIONS1, PSICONV_ID_PAGE_DIMENSIONS2); } len += 4; - psiconv_progress(lev+2,off+len,"Going to read the page width"); - (*result)->page_width = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read the page width"); + (*result)->page_width = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR4; - psiconv_debug(lev+2,off+len,"Page width: %6.3f",(*result)->page_width); + psiconv_debug(config,lev+2,off+len,"Page width: %6.3f",(*result)->page_width); len += leng; - psiconv_progress(lev+2,off+len,"Going to read the page height"); - (*result)->page_height = psiconv_read_length(buf,lev+2,off+len,&leng,&res); + psiconv_progress(config,lev+2,off+len,"Going to read the page height"); + (*result)->page_height = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res); if (res) goto ERROR4; - psiconv_debug(lev+2,off+len,"Page height: %6.3f",(*result)->page_height); + psiconv_debug(config,lev+2,off+len,"Page height: %6.3f",(*result)->page_height); len += leng; - psiconv_progress(lev+2,off+len,"Going to read page portrait/landscape"); - if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->landscape))) + psiconv_progress(config,lev+2,off+len,"Going to read page portrait/landscape"); + if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->landscape))) goto ERROR4; - psiconv_debug(lev+2,off+len,"Landscape: %d",(*result)->landscape); + psiconv_debug(config,lev+2,off+len,"Landscape: %d",(*result)->landscape); len += leng; if (length) *length = len; - psiconv_progress(lev,off+len-1,"End of page section (total length: %08x)", + psiconv_progress(config,lev,off+len-1,"End of page section (total length: %08x)", len); return res; @@ -263,7 +265,7 @@ ERROR2: free (*result); ERROR1: - psiconv_warn(lev+1,off,"Reading of Page Section failed"); + psiconv_warn(config,lev+1,off,"Reading of Page Section failed"); if (length) *length = 0; if (!res)