… | |
… | |
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> |
|
|
24 | |
22 | #include "parse_routines.h" |
25 | #include "parse_routines.h" |
|
|
26 | #include "error.h" |
|
|
27 | |
|
|
28 | #ifdef DMALLOC |
|
|
29 | #include <dmalloc.h> |
|
|
30 | #endif |
23 | |
31 | |
24 | int psiconv_parse_word_status_section(const psiconv_buffer buf, int lev, |
32 | int psiconv_parse_word_status_section(const psiconv_buffer buf, int lev, |
25 | psiconv_u32 off, int *length, |
33 | psiconv_u32 off, int *length, |
26 | psiconv_word_status_section *result) |
34 | psiconv_word_status_section *result) |
27 | { |
35 | { |
… | |
… | |
133 | psiconv_debug(lev+2,off+len,"Cursor position: %08x", |
141 | psiconv_debug(lev+2,off+len,"Cursor position: %08x", |
134 | (*result)->cursor_position); |
142 | (*result)->cursor_position); |
135 | len += 0x04; |
143 | len += 0x04; |
136 | |
144 | |
137 | psiconv_progress(lev+2,off+len,"Going to read display size"); |
145 | psiconv_progress(lev+2,off+len,"Going to read display size"); |
138 | (*result)->cursor_position = psiconv_read_u32(buf,lev+2,off + len,&res); |
146 | (*result)->display_size = psiconv_read_u32(buf,lev+2,off + len,&res); |
139 | if (res) |
147 | if (res) |
140 | goto ERROR2; |
148 | goto ERROR2; |
141 | psiconv_debug(lev+2,off+len,"Display size: %08x", |
149 | psiconv_debug(lev+2,off+len,"Display size: %08x", |
142 | (*result)->cursor_position); |
150 | (*result)->display_size); |
143 | len += 0x04; |
151 | len += 0x04; |
144 | |
152 | |
145 | if (length) |
153 | if (length) |
146 | *length = len; |
154 | *length = len; |
147 | |
155 | |
… | |
… | |
304 | if (res) |
312 | if (res) |
305 | goto ERROR6; |
313 | goto ERROR6; |
306 | psiconv_debug(lev+3,off+len,"Outline Level: %08x", style->outline_level); |
314 | psiconv_debug(lev+3,off+len,"Outline Level: %08x", style->outline_level); |
307 | len += 4; |
315 | len += 4; |
308 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
316 | psiconv_progress(lev+3,off+len,"Going to read the character codes"); |
309 | if (!(style->character = psiconv_basic_character_layout())) |
317 | if (!(style->character = psiconv_clone_character_layout((*result)->normal->character))) |
310 | goto ERROR6; |
318 | goto ERROR6; |
311 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
319 | if ((res = psiconv_parse_character_layout_list(buf,lev+3,off+len,&leng, |
312 | style->character))) |
320 | style->character))) |
313 | goto ERROR7; |
321 | goto ERROR7; |
314 | len += leng; |
322 | len += leng; |
315 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
323 | psiconv_progress(lev+3,off+len,"Going to read the paragraph codes"); |
316 | if (!(style->paragraph = psiconv_basic_paragraph_layout())) |
324 | if (!(style->paragraph = psiconv_clone_paragraph_layout((*result)->normal->paragraph))) |
317 | goto ERROR7; |
325 | goto ERROR7; |
318 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
326 | if ((res = psiconv_parse_paragraph_layout_list(buf,lev+3,off+len,&leng, |
319 | style->paragraph))) |
327 | style->paragraph))) |
320 | goto ERROR8; |
328 | goto ERROR8; |
321 | len += leng; |
329 | len += leng; |
|
|
330 | } |
|
|
331 | |
|
|
332 | psiconv_progress(lev+2,off+len,"Reading trailing bytes"); |
|
|
333 | for (i = 0; i < psiconv_list_length((*result)->styles); i++) { |
|
|
334 | temp = psiconv_read_u8(buf,lev+3,off+len,&res); |
|
|
335 | if (res) |
|
|
336 | goto ERROR4; |
|
|
337 | if (temp != 0xff) { |
|
|
338 | psiconv_warn(lev+3,off+len,"Unknown trailing style byte"); |
|
|
339 | psiconv_debug(lev+3,off+len,"Trailing byte: %02x expected, read %02x", |
|
|
340 | 0xff,temp); |
|
|
341 | } else |
|
|
342 | psiconv_debug(lev+3,off+len,"Read trailing byte 0xff"); |
|
|
343 | len++; |
322 | } |
344 | } |
323 | |
345 | |
324 | if (length) |
346 | if (length) |
325 | *length = len; |
347 | *length = len; |
326 | |
348 | |