… | |
… | |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ |
18 | */ |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
|
|
21 | #include "compat.h" |
|
|
22 | |
21 | #include <stdlib.h> |
23 | #include <stdlib.h> |
22 | #include <string.h> |
24 | #include <string.h> |
23 | |
25 | |
24 | #include "data.h" |
|
|
25 | #include "parse_routines.h" |
26 | #include "parse_routines.h" |
|
|
27 | #include "error.h" |
26 | |
28 | |
27 | int psiconv_parse_page_header(const psiconv_buffer buf,int lev,psiconv_u32 off, |
29 | int psiconv_parse_page_header(const psiconv_buffer buf,int lev,psiconv_u32 off, |
28 | int *length,psiconv_page_header *result) |
30 | int *length,psiconv_page_header *result) |
29 | { |
31 | { |
30 | int res = 0; |
32 | int res = 0; |
… | |
… | |
37 | goto ERROR1; |
39 | goto ERROR1; |
38 | |
40 | |
39 | psiconv_progress(lev+2,off+len, |
41 | psiconv_progress(lev+2,off+len, |
40 | "Going to read the first byte (0x01 expected)"); |
42 | "Going to read the first byte (0x01 expected)"); |
41 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
43 | temp = psiconv_read_u8(buf,lev+2,off+len,&res); |
42 | if (!res) |
44 | if (res) |
43 | goto ERROR2; |
45 | goto ERROR2; |
44 | if (temp != 0x01) { |
46 | if (temp != 0x01) { |
45 | psiconv_warn(lev+2,off+len,"Page header first byte mismatch"); |
47 | psiconv_warn(lev+2,off+len,"Page header first byte mismatch"); |
46 | psiconv_debug(lev+2,off+len,"First byte: read %02x, expected %02x", |
48 | psiconv_debug(lev+2,off+len,"First byte: read %02x, expected %02x", |
47 | temp,0x01); |
49 | temp,0x01); |
… | |
… | |
199 | "Page layout section page dimensions marker not found"); |
201 | "Page layout section page dimensions marker not found"); |
200 | psiconv_debug(lev+2,off+len, |
202 | psiconv_debug(lev+2,off+len, |
201 | "Page dimensions marker: read %08x, expected %08x",temp, |
203 | "Page dimensions marker: read %08x, expected %08x",temp, |
202 | PSICONV_ID_PAGE_DIMENSIONS); |
204 | PSICONV_ID_PAGE_DIMENSIONS); |
203 | } |
205 | } |
|
|
206 | len += 4; |
204 | |
207 | |
205 | psiconv_progress(lev+2,off+len,"Going to read the page width"); |
208 | psiconv_progress(lev+2,off+len,"Going to read the page width"); |
206 | (*result)->page_width = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
209 | (*result)->page_width = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
207 | if (!res) |
210 | if (res) |
208 | goto ERROR4; |
211 | goto ERROR4; |
209 | psiconv_debug(lev+2,off+len,"Page width: %6.3f",(*result)->page_width); |
212 | psiconv_debug(lev+2,off+len,"Page width: %6.3f",(*result)->page_width); |
210 | len += leng; |
213 | len += leng; |
211 | |
214 | |
212 | psiconv_progress(lev+2,off+len,"Going to read the page height"); |
215 | psiconv_progress(lev+2,off+len,"Going to read the page height"); |
213 | (*result)->page_height = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
216 | (*result)->page_height = psiconv_read_length(buf,lev+2,off+len,&leng,&res); |
214 | if (!res) |
217 | if (res) |
215 | goto ERROR4; |
218 | goto ERROR4; |
216 | psiconv_debug(lev+2,off+len,"Page height: %6.3f",(*result)->page_height); |
219 | psiconv_debug(lev+2,off+len,"Page height: %6.3f",(*result)->page_height); |
217 | len += leng; |
220 | len += leng; |
218 | |
221 | |
219 | if (length) |
222 | if (length) |