/[public]/psiconv/trunk/lib/psiconv/parse_page.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/parse_page.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 64 Revision 76
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
27int psiconv_parse_page_header(const psiconv_buffer buf,int lev,psiconv_u32 off, 29int 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);
192 194
193 psiconv_progress(lev+2,off+len,"Going to read page dimensions id"); 195 psiconv_progress(lev+2,off+len,"Going to read page dimensions id");
194 temp = psiconv_read_u32(buf,lev+2,off+len,&res); 196 temp = psiconv_read_u32(buf,lev+2,off+len,&res);
195 if (res) 197 if (res)
196 goto ERROR4; 198 goto ERROR4;
197 if (temp != PSICONV_ID_PAGE_DIMENSIONS) { 199 if ((temp != PSICONV_ID_PAGE_DIMENSIONS1) &&
200 (temp != PSICONV_ID_PAGE_DIMENSIONS2)) {
198 psiconv_warn(lev+2,off+len, 201 psiconv_warn(lev+2,off+len,
199 "Page layout section page dimensions marker not found"); 202 "Page layout section page dimensions marker not found");
200 psiconv_debug(lev+2,off+len, 203 psiconv_debug(lev+2,off+len,
201 "Page dimensions marker: read %08x, expected %08x",temp, 204 "Page dimensions marker: read %08x, expected %08x or %08x",
205 temp, PSICONV_ID_PAGE_DIMENSIONS1,
202 PSICONV_ID_PAGE_DIMENSIONS); 206 PSICONV_ID_PAGE_DIMENSIONS2);
203 } 207 }
208 len += 4;
204 209
205 psiconv_progress(lev+2,off+len,"Going to read the page width"); 210 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); 211 (*result)->page_width = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
207 if (!res) 212 if (res)
208 goto ERROR4; 213 goto ERROR4;
209 psiconv_debug(lev+2,off+len,"Page width: %6.3f",(*result)->page_width); 214 psiconv_debug(lev+2,off+len,"Page width: %6.3f",(*result)->page_width);
210 len += leng; 215 len += leng;
211 216
212 psiconv_progress(lev+2,off+len,"Going to read the page height"); 217 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); 218 (*result)->page_height = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
214 if (!res) 219 if (res)
215 goto ERROR4; 220 goto ERROR4;
216 psiconv_debug(lev+2,off+len,"Page height: %6.3f",(*result)->page_height); 221 psiconv_debug(lev+2,off+len,"Page height: %6.3f",(*result)->page_height);
217 len += leng; 222 len += leng;
223
224 psiconv_progress(lev+2,off+len,"Going to read page portrait/landscape");
225 if ((res = psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->landscape)))
226 goto ERROR4;
227 psiconv_debug(lev+2,off+len,"Landscape: %d",(*result)->landscape);
228 len += leng;
229
218 230
219 if (length) 231 if (length)
220 *length = len; 232 *length = len;
221 233
222 psiconv_progress(lev,off+len-1,"End of page section (total length: %08x)", 234 psiconv_progress(lev,off+len-1,"End of page section (total length: %08x)",

Legend:
Removed from v.64  
changed lines
  Added in v.76

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26