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

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

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

Revision 2 Revision 168
1/* 1/*
2 parse_layout.c - Part of psiconv, a PSION 5 file formats converter 2 parse_layout.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
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 <math.h> 24#include <math.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_color(const psiconv_buffer buf, int lev, psiconv_u32 off, 29#ifdef DMALLOC
30#include <dmalloc.h>
31#endif
32
33
34int psiconv_parse_color(const psiconv_config config,
35 const psiconv_buffer buf, int lev, psiconv_u32 off,
28 int *length, psiconv_color *result) 36 int *length, psiconv_color *result)
29{ 37{
30 int res = 0; 38 int res = 0;
31 int len = 0; 39 int len = 0;
32 40
33 psiconv_progress(lev+1,off,"Going to parse color"); 41 psiconv_progress(config,lev+1,off,"Going to parse color");
34 *result = malloc(sizeof(**result)); 42 if (!(*result = malloc(sizeof(**result))))
43 goto ERROR1;
35 44
36 (*result)->red = psiconv_read_u8(buf,lev+2,off+len); 45 (*result)->red = psiconv_read_u8(config,buf,lev+2,off+len,&res);
46 if (res)
47 goto ERROR2;
37 (*result)->green = psiconv_read_u8(buf,lev+2,off+len+1); 48 (*result)->green = psiconv_read_u8(config,buf,lev+2,off+len+1,&res);
49 if (res)
50 goto ERROR2;
38 (*result)->blue = psiconv_read_u8(buf,lev+2,off+len+2); 51 (*result)->blue = psiconv_read_u8(config,buf,lev+2,off+len+2,&res);
52 if (res)
53 goto ERROR2;
39 len += 3; 54 len += 3;
40 55
41 psiconv_debug(lev+2,off,"Color: red %02x, green %02x, blue %02x", 56 psiconv_debug(config,lev+2,off,"Color: red %02x, green %02x, blue %02x",
42 (*result)->red, (*result)->green, (*result)->blue); 57 (*result)->red, (*result)->green, (*result)->blue);
43 if (length) 58 if (length)
44 *length = len; 59 *length = len;
45 60
46 psiconv_progress(lev+1,off+len-1,"End of color (total length: %08x)",len); 61 psiconv_progress(config,lev+1,off+len-1,"End of color (total length: %08x)",len);
62 return 0;
63
64ERROR2:
65 free(*result);
66ERROR1:
67 psiconv_warn(config,lev+1,off,"Reading of Color failed");
68 if (length)
69 *length = 0;
70 if (res == 0)
71 return -PSICONV_E_NOMEM;
72 else
47 return res; 73 return res;
48} 74}
49 75
50 76
51 77
52int psiconv_parse_font(const psiconv_buffer buf, int lev, psiconv_u32 off, 78int psiconv_parse_font(const psiconv_config config,
79 const psiconv_buffer buf, int lev, psiconv_u32 off,
53 int *length, psiconv_font *result) 80 int *length, psiconv_font *result)
54{ 81{
55 int res = 0; 82 int res = 0;
56 int strlength,i; 83 int strlength,i;
57 char *str_copy; 84 char *str_copy;
58 int len; 85 int len;
59 86
60 psiconv_progress(lev+1,off,"Going to parse font"); 87 psiconv_progress(config,lev+1,off,"Going to parse font");
61 *result = malloc(sizeof(**result)); 88 if (!(*result = malloc(sizeof(**result))))
89 goto ERROR1;
62 90
63 strlength = psiconv_read_u8(buf,lev+2,off); 91 strlength = psiconv_read_u8(config,buf,lev+2,off,&res);
92 if (res)
93 goto ERROR2;
64 (*result)->name = malloc(strlength); 94 if (!((*result)->name = malloc(strlength))) {
95 goto ERROR2;
96 }
65 for (i = 0; i < strlength-1; i++) 97 for (i = 0; (i < strlength-1) && !res; i++)
66 (*result)->name[i] = psiconv_read_u8(buf,lev+2,off + 1 + i); 98 (*result)->name[i] = psiconv_read_u8(config,buf,lev+2,off + 1 + i,&res);
99 if (res)
100 goto ERROR3;
67 (*result)->name[strlength-1] = 0; 101 (*result)->name[strlength-1] = 0;
68 (*result)->screenfont = psiconv_read_u8(buf,lev+2,off + strlength); 102 (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off + strlength,&res);
103 if (res)
104 goto ERROR3;
69 105
70 str_copy = psiconv_make_printable((*result)->name); 106 if (!(str_copy = psiconv_make_printable((*result)->name)))
107 goto ERROR3;
108
71 psiconv_debug(lev+2,off+1,"Found font `%s', displayed with screen font %02x", 109 psiconv_debug(config,lev+2,off+1,"Found font `%s', displayed with screen font %02x",
72 str_copy,(*result)->screenfont); 110 str_copy,(*result)->screenfont);
73 free(str_copy); 111 free(str_copy);
74 len = strlength + 1; 112 len = strlength + 1;
75 if (length) 113 if (length)
76 *length = len; 114 *length = len;
77 115
78 psiconv_progress(lev+1,off + len - 1,"End of font (total length: %08x)",len); 116 psiconv_progress(config,lev+1,off + len - 1,"End of font (total length: %08x)",len);
117 return 0;
118
119ERROR3:
120 free ((*result)->name);
121ERROR2:
122 free (*result);
123ERROR1:
124 psiconv_warn(config,lev+1,off,"Reading of Font failed");
125 if (length)
126 *length = 0;
127 if (!res)
128 return -PSICONV_E_NOMEM;
129 else
79 return res; 130 return res;
80} 131}
81 132
82int psiconv_parse_border(const psiconv_buffer buf,int lev,psiconv_u32 off, 133int psiconv_parse_border(const psiconv_config config,
134 const psiconv_buffer buf,int lev,psiconv_u32 off,
83 int *length, psiconv_border *result) 135 int *length, psiconv_border *result)
84{ 136{
85 int res = 0; 137 int res = 0;
86 int len = 0; 138 int len = 0;
87 psiconv_u32 temp; 139 psiconv_u32 temp;
88 int leng; 140 int leng;
89 141
90 psiconv_progress(lev+1,off,"Going to parse border data"); 142 psiconv_progress(config,lev+1,off,"Going to parse border data");
91 *result = malloc(sizeof(**result)); 143 if (!(*result = malloc(sizeof(**result)))) {
144 goto ERROR1;
145 }
92 146
93 psiconv_progress(lev+2,off+len,"Going to read border kind"); 147 psiconv_progress(config,lev+2,off+len,"Going to read border kind");
94 temp = psiconv_read_u8(buf,lev+2,off+len); 148 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
149 if (res)
150 goto ERROR2;
95 if (temp == 0x00) 151 if (temp == 0x00)
96 (*result)->kind = psiconv_border_none; 152 (*result)->kind = psiconv_border_none;
97 else if (temp == 0x01) 153 else if (temp == 0x01)
98 (*result)->kind = psiconv_border_solid; 154 (*result)->kind = psiconv_border_solid;
99 else if (temp == 0x02) 155 else if (temp == 0x02)
100 (*result)->kind = psiconv_border_double; 156 (*result)->kind = psiconv_border_double;
101 else if (temp == 0x03) 157 else if (temp == 0x03)
102 (*result)->kind = psiconv_border_dotted; 158 (*result)->kind = psiconv_border_dotted;
103 else if (temp == 0x04) 159 else if (temp == 0x04)
104 (*result)->kind = psiconv_border_striped; 160 (*result)->kind = psiconv_border_dashed;
105 else if (temp == 0x05) 161 else if (temp == 0x05)
106 (*result)->kind = psiconv_border_dotstripe; 162 (*result)->kind = psiconv_border_dotdashed;
107 else if (temp == 0x06) 163 else if (temp == 0x06)
108 (*result)->kind = psiconv_border_dotdotstripe; 164 (*result)->kind = psiconv_border_dotdotdashed;
109 else { 165 else {
110 psiconv_warn(lev+2,off,"Unknown border kind (defaults to `none')"); 166 psiconv_warn(config,lev+2,off,"Unknown border kind (defaults to `none')");
111 (*result)->kind = psiconv_border_none; 167 (*result)->kind = psiconv_border_none;
112 res = -1;
113 } 168 }
114 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 169 psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
115 len ++; 170 len ++;
116 171
117 psiconv_progress(lev+2,off+len,"Going to read border thickness"); 172 psiconv_progress(config,lev+2,off+len,"Going to read border thickness");
118 (*result)->thickness = psiconv_read_size(buf,lev+2,off+len,&leng); 173 (*result)->thickness = psiconv_read_size(config,buf,lev+2,off+len,&leng,&res);
174 if (res)
175 goto ERROR2;
176#if 0
177 /* This seems no longer necessary to test? */
119 if (((*result)->kind != psiconv_border_solid) && 178 if (((*result)->kind != psiconv_border_solid) &&
120 ((*result)->kind != psiconv_border_double) && 179 ((*result)->kind != psiconv_border_double) &&
121 ((*result)->thickness != 0.0) && 180 ((*result)->thickness != 0.0) &&
122 (fabs((*result)->thickness - 1/20) >= 1/1000)) { 181 (fabs((*result)->thickness - 1/20) >= 1/1000)) {
123 psiconv_warn(lev+2,off, 182 psiconv_warn(config,lev+2,off,
124 "Border thickness specified for unlikely border type"); 183 "Border thickness specified for unlikely border type");
125 res = -1;
126 } 184 }
185#endif
127 psiconv_debug(lev+2,off+len,"Thickness: %f",(*result)->thickness); 186 psiconv_debug(config,lev+2,off+len,"Thickness: %f",(*result)->thickness);
128 len += leng; 187 len += leng;
129 188
130 psiconv_progress(lev+2,off+len,"Going to read the border color"); 189 psiconv_progress(config,lev+2,off+len,"Going to read the border color");
131 res |= psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color); 190 if ((psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
191 goto ERROR2;
132 len += leng; 192 len += leng;
133 193
134 psiconv_progress(lev+2,off+len,"Going to read the final unknown byte " 194 psiconv_progress(config,lev+2,off+len,"Going to read the final unknown byte "
135 "(0x01 expected)"); 195 "(0x00 or 0x01 expected)");
136 temp = psiconv_read_u8(buf,lev+2,off + len); 196 temp = psiconv_read_u8(config,buf,lev+2,off + len,&res);
137 if (temp != 0x01) { 197 if (res)
198 goto ERROR3;
199 if ((temp != 0x01) && (temp != 0x00)) {
138 psiconv_warn(lev+2,off,"Unknown last byte in border specification"); 200 psiconv_warn(config,lev+2,off,"Unknown last byte in border specification");
139 psiconv_debug(lev+2,off+len, "Last byte: read %02x, expected %02x", 201 psiconv_debug(config,lev+2,off+len, "Last byte: read %02x, expected %02x or %02x",
140 temp,0x01); 202 temp,0x00,0x01);
141 res = -1;
142 } 203 }
143 len ++; 204 len ++;
144 205
145 if (length) 206 if (length)
146 *length = len; 207 *length = len;
147 208
148 psiconv_progress(lev+1,off + len - 1, 209 psiconv_progress(config,lev+1,off + len - 1,
149 "End of border (total length: %08x)",len); 210 "End of border (total length: %08x)",len);
150 211
212 return 0;
213
214ERROR3:
215 psiconv_free_color((*result)->color);
216ERROR2:
217 free (result);
218ERROR1:
219 psiconv_warn(config,lev+1,off,"Reading of Border failed");
220 if (length)
221 *length = 0;
222 if (!res)
223 return -PSICONV_E_NOMEM;
224 else
151 return res; 225 return res;
152} 226}
153 227
154int psiconv_parse_bullet(const psiconv_buffer buf,int lev,psiconv_u32 off, 228int psiconv_parse_bullet(const psiconv_config config,
229 const psiconv_buffer buf,int lev,psiconv_u32 off,
155 int *length, psiconv_bullet *result) 230 int *length, psiconv_bullet *result)
156{ 231{
157 int res = 0; 232 int res = 0;
158 int len = 0; 233 int len = 0;
159 int leng; 234 int leng;
160 int bullet_length; 235 int bullet_length;
161 236
162 *result = malloc(sizeof(**result)); 237 if (!(*result = malloc(sizeof(**result))))
238 goto ERROR1;
163 (*result)->on = psiconv_bool_true; 239 (*result)->on = psiconv_bool_true;
164 240
165 psiconv_progress(lev+1,off,"Going to parse bullet data"); 241 psiconv_progress(config,lev+1,off,"Going to parse bullet data");
166 psiconv_progress(lev+2,off+len,"Going to read bullet length"); 242 psiconv_progress(config,lev+2,off+len,"Going to read bullet length");
167 bullet_length = psiconv_read_u8(buf,lev+2,off+len); 243 bullet_length = psiconv_read_u8(config,buf,lev+2,off+len,&res);
244 if (res)
245 goto ERROR2;
168 psiconv_debug(lev+2,off+len,"Length: %02x",bullet_length); 246 psiconv_debug(config,lev+2,off+len,"Length: %02x",bullet_length);
169 len ++; 247 len ++;
170 248
171 psiconv_progress(lev+2,off+len,"Going to read bullet font size"); 249 psiconv_progress(config,lev+2,off+len,"Going to read bullet font size");
172 (*result)->font_size = psiconv_read_size(buf,lev+2,off+len, &leng); 250 (*result)->font_size = psiconv_read_size(config,buf,lev+2,off+len, &leng,&res);
251 if (res)
252 goto ERROR2;
173 len +=leng; 253 len +=leng;
174 254
175 psiconv_progress(lev+2,off+len,"Going to read bullet character"); 255 psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
176 (*result)->character = psiconv_read_u8(buf,lev+2,off+len); 256 (*result)->character = psiconv_read_u8(config,buf,lev+2,off+len,&res);
257 if (res)
258 goto ERROR2;
177 psiconv_debug(lev+2,off+len,"Character: %02x",(*result)->character); 259 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
178 len ++; 260 len ++;
179 261
180 psiconv_progress(lev+2,off+len,"Going to read indent on/off"); 262 psiconv_progress(config,lev+2,off+len,"Going to read indent on/off");
181 res |= psiconv_parse_bool(buf,lev+2,off+len,&leng,&(*result)->indent); 263 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
264 goto ERROR2;
182 psiconv_debug(lev+2,off+len,"Indent on: %02x",(*result)->indent); 265 psiconv_debug(config,lev+2,off+len,"Indent on: %02x",(*result)->indent);
183 len += leng; 266 len += leng;
184 267
185 psiconv_progress(lev+2,off+len,"Going to read bullet color"); 268 psiconv_progress(config,lev+2,off+len,"Going to read bullet color");
186 res |= psiconv_parse_color(buf,lev+2,off+len,&leng,&(*result)->color); 269 if ((res = psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
270 goto ERROR2;
187 len += leng; 271 len += leng;
188 272
189 psiconv_progress(lev+2,off+len,"Going to read bullet font"); 273 psiconv_progress(config,lev+2,off+len,"Going to read bullet font");
190 res |= psiconv_parse_font(buf,lev+2,off+len,&leng,&(*result)->font); 274 if ((res = psiconv_parse_font(config,buf,lev+2,off+len,&leng,&(*result)->font)))
275 goto ERROR3;
191 len += leng; 276 len += leng;
192 277
193 if (len != bullet_length + 1) { 278 if (len != bullet_length + 1) {
194 psiconv_warn(lev+2,off,"Bullet data structure length mismatch"); 279 psiconv_warn(config,lev+2,off,"Bullet data structure length mismatch");
195 psiconv_debug(lev+2,off,"Length: specified %02x, found %02x", 280 psiconv_debug(config,lev+2,off,"Length: specified %02x, found %02x",
196 bullet_length,len-1); 281 bullet_length,len-1);
197 res = -1;
198 } 282 }
199 283
200 psiconv_progress(lev+1,off + len - 1, 284 psiconv_progress(config,lev+1,off + len - 1,
201 "End of bullet data (total length: %08x)",len); 285 "End of bullet data (total length: %08x)",len);
202 286
203 if (length) 287 if (length)
204 *length = len; 288 *length = len;
289 return 0;
290
291ERROR3:
292 psiconv_free_color((*result)->color);
293ERROR2:
294 free (result);
295ERROR1:
296 psiconv_warn(config,lev+1,off,"Reading of Bullet failed");
297 if (length)
298 *length = 0;
299 if (!res)
300 return -PSICONV_E_NOMEM;
301 else
205 return res; 302 return res;
206} 303}
207 304
208int psiconv_parse_tab(const psiconv_buffer buf, int lev, psiconv_u32 off, 305int psiconv_parse_tab(const psiconv_config config,
306 const psiconv_buffer buf, int lev, psiconv_u32 off,
209 int *length, psiconv_tab *result) 307 int *length, psiconv_tab *result)
210{ 308{
211 int res = 0; 309 int res = 0;
212 int len = 0; 310 int len = 0;
213 int leng; 311 int leng;
214 psiconv_u8 temp; 312 psiconv_u8 temp;
215 313
216 psiconv_progress(lev+1,off,"Going to parse tab"); 314 psiconv_progress(config,lev+1,off,"Going to parse tab");
217 *result = malloc(sizeof(**result)); 315 if (!(*result = malloc(sizeof(**result))))
316 goto ERROR1;
218 317
219 psiconv_progress(lev+2,off,"Going to read tab location"); 318 psiconv_progress(config,lev+2,off,"Going to read tab location");
220 (*result)->location = psiconv_read_length(buf,lev+2,off+len,&leng); 319 (*result)->location = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
320 if (res)
321 goto ERROR2;
221 len += leng; 322 len += leng;
222 323
223 psiconv_progress(lev+2,off+len,"Going to read the tab kind"); 324 psiconv_progress(config,lev+2,off+len,"Going to read the tab kind");
224 temp = psiconv_read_u8(buf,lev+2,off+len); 325 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
326 if (res)
327 goto ERROR2;
225 if (temp == 1) 328 if (temp == 1)
226 (*result)->kind = psiconv_tab_left; 329 (*result)->kind = psiconv_tab_left;
227 else if (temp == 2) 330 else if (temp == 2)
228 (*result)->kind = psiconv_tab_centre; 331 (*result)->kind = psiconv_tab_centre;
229 else if (temp == 3) 332 else if (temp == 3)
230 (*result)->kind = psiconv_tab_right; 333 (*result)->kind = psiconv_tab_right;
231 else { 334 else {
232 res = -1;
233 psiconv_warn(lev+2,off+len,"Unknown tab kind argument"); 335 psiconv_warn(config,lev+2,off+len,"Unknown tab kind argument");
234 psiconv_debug(lev+2,off+len,"Kind found: %02x (defaulted to left tab)", 336 psiconv_debug(config,lev+2,off+len,"Kind found: %02x (defaulted to left tab)",
235 temp); 337 temp);
236 (*result)->kind = psiconv_tab_left; 338 (*result)->kind = psiconv_tab_left;
237 } 339 }
238 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 340 psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
239 len ++; 341 len ++;
240 342
241 if (length) 343 if (length)
242 *length = len; 344 *length = len;
243 345
244 psiconv_progress(lev+1,off+len-1,"End of tab (total length: %08x)",len); 346 psiconv_progress(config,lev+1,off+len-1,"End of tab (total length: %08x)",len);
245 return res; 347 return 0;
246 348
349ERROR2:
350 free (result);
351ERROR1:
352 psiconv_warn(config,lev+1,off,"Reading of Tab failed");
353 if (length)
354 *length = 0;
355 if (!res)
356 return -PSICONV_E_NOMEM;
357 else
358 return res;
247} 359}
248 360
249int psiconv_parse_paragraph_layout_list(const psiconv_buffer buf, int lev, 361int psiconv_parse_paragraph_layout_list(const psiconv_config config,
362 const psiconv_buffer buf, int lev,
250 psiconv_u32 off, int *length, 363 psiconv_u32 off, int *length,
251 psiconv_paragraph_layout result) 364 psiconv_paragraph_layout result)
252{ 365{
253 int res=0; 366 int res=0;
254 int len=0; 367 int len=0;
255 int list_length,leng,nr; 368 int list_length,leng,nr;
256 psiconv_u8 id; 369 psiconv_u8 id;
257 psiconv_u32 temp; 370 psiconv_u32 temp;
258 psiconv_tab tab; 371 psiconv_tab temp_tab;
372 psiconv_color temp_color;
373 psiconv_border temp_border;
374 psiconv_bullet temp_bullet;
259 375
260 psiconv_progress(lev+1,off,"Going to read paragraph layout list"); 376 psiconv_progress(config,lev+1,off,"Going to read paragraph layout list");
261 377
262 psiconv_progress(lev+2,off,"Going to read the list length"); 378 psiconv_progress(config,lev+2,off,"Going to read the list length");
263 list_length = psiconv_read_u32(buf,lev+2,off + len); 379 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
380 if (res)
381 goto ERROR1;
264 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 382 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
265 len += 4; 383 len += 4;
266 384
267 nr = 0; 385 nr = 0;
268 while(len - 4 < list_length) { 386 while(len - 4 < list_length) {
269 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 387 psiconv_progress(config,lev+2,off+len,"Going to read element %d",nr);
270 psiconv_progress(lev+3,off+len,"Going to read the element id"); 388 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
271 id = psiconv_read_u8(buf,lev+2,off+len); 389 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
390 if (res)
391 goto ERROR1;
272 psiconv_debug(lev+3,off+len,"Id: %02x",id); 392 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
273 len ++; 393 len ++;
274 switch(id) { 394 switch(id) {
275 case 0x01: 395 case 0x01:
276 psiconv_progress(lev+3,off+len,"Going to read background color"); 396 psiconv_progress(config,lev+3,off+len,"Going to read background color");
397 if ((res = psiconv_parse_color(config,buf,lev+3,off+len,&leng,&temp_color)))
398 goto ERROR1;
277 psiconv_free_color(result->back_color); 399 psiconv_free_color(result->back_color);
278 res |= psiconv_parse_color(buf,lev+3,off+len,&leng, 400 result->back_color = temp_color;
279 &result->back_color);
280 len += leng; 401 len += leng;
281 break; 402 break;
282 case 0x02: 403 case 0x02:
283 psiconv_progress(lev+3,off+len ,"Going to read indent left"); 404 psiconv_progress(config,lev+3,off+len ,"Going to read indent left");
284 result->indent_left = psiconv_read_length(buf,lev+3,off+len,&leng); 405 result->indent_left = psiconv_read_length(config,buf,lev+3,off+len,&leng,&res);
406 if (res)
407 goto ERROR1;
285 len += leng; 408 len += leng;
286 break; 409 break;
287 case 0x03: 410 case 0x03:
288 psiconv_progress(lev+3,off+len,"Going to read indent right"); 411 psiconv_progress(config,lev+3,off+len,"Going to read indent right");
289 result->indent_right = psiconv_read_length(buf,lev+2,off+len,&leng); 412 result->indent_right = psiconv_read_length(config,buf,lev+2,off+len,&leng,
413 &res);
414 if (res)
415 goto ERROR1;
290 len += leng; 416 len += leng;
291 break; 417 break;
292 case 0x04: 418 case 0x04:
293 psiconv_progress(lev+3,off+len,"Going to read indent left first line"); 419 psiconv_progress(config,lev+3,off+len,"Going to read indent left first line");
294 result->indent_first = psiconv_read_length(buf,lev+2,off+len, &leng); 420 result->indent_first = psiconv_read_length(config,buf,lev+2,off+len, &leng,
421 &res);
422 if (res)
423 goto ERROR1;
295 len += leng; 424 len += leng;
296 break; 425 break;
297 case 0x05: 426 case 0x05:
298 psiconv_progress(lev+3,off+len,"Going to read horizontal justify"); 427 psiconv_progress(config,lev+3,off+len,"Going to read horizontal justify");
299 temp = psiconv_read_u8(buf,lev+3,off+len); 428 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
429 if (res)
430 goto ERROR1;
300 if (temp == 0x00) 431 if (temp == 0x00)
301 result->justify_hor = psiconv_justify_left; 432 result->justify_hor = psiconv_justify_left;
302 else if (temp == 0x01) 433 else if (temp == 0x01)
303 result->justify_hor = psiconv_justify_centre; 434 result->justify_hor = psiconv_justify_centre;
304 else if (temp == 0x02) 435 else if (temp == 0x02)
305 result->justify_hor = psiconv_justify_right; 436 result->justify_hor = psiconv_justify_right;
306 else if (temp == 0x03) 437 else if (temp == 0x03)
307 result->justify_hor = psiconv_justify_full; 438 result->justify_hor = psiconv_justify_full;
308 else { 439 else {
309 res = -1;
310 psiconv_warn(lev+3,off+len, "Unknown horizontal justify argument " 440 psiconv_warn(config,lev+3,off+len, "Unknown horizontal justify argument "
311 "in paragraph layout codes list"); 441 "in paragraph layout codes list");
442 result->justify_hor = psiconv_justify_left;
312 } 443 }
313 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 444 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
314 len ++; 445 len ++;
315 break; 446 break;
316 case 0x06: 447 case 0x06:
317 psiconv_progress(lev+3,off+len,"Going to read vertical justify"); 448 psiconv_progress(config,lev+3,off+len,"Going to read vertical justify");
318 temp = psiconv_read_u8(buf,lev+3,off+len); 449 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
450 if (res)
451 goto ERROR1;
319 if (temp == 0x00) 452 if (temp == 0x00)
320 result->justify_ver = psiconv_justify_top; 453 result->justify_ver = psiconv_justify_top;
321 else if (temp == 0x01) 454 else if (temp == 0x01)
322 result->justify_ver = psiconv_justify_middle; 455 result->justify_ver = psiconv_justify_middle;
323 else if (temp == 0x02) 456 else if (temp == 0x02)
324 result->justify_ver = psiconv_justify_bottom; 457 result->justify_ver = psiconv_justify_bottom;
325 else { 458 else {
326 res = -1;
327 psiconv_warn(lev+3,off+len, "Unknown vertical justify argument " 459 psiconv_warn(config,lev+3,off+len, "Unknown vertical justify argument "
328 "in paragraph layout codes list"); 460 "in paragraph layout codes list");
461 result->justify_ver = psiconv_justify_bottom;
329 } 462 }
330 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 463 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
331 len ++; 464 len ++;
465 break;
332 case 0x07: 466 case 0x07:
333 psiconv_progress(lev+3,off+len,"Going to read interline distance"); 467 psiconv_progress(config,lev+3,off+len,"Going to read linespacing distance");
334 result->interline = psiconv_read_size(buf,lev+3,off+len,&leng); 468 result->linespacing = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
469 if (res)
470 goto ERROR1;
335 len += leng; 471 len += leng;
336 break; 472 break;
337 case 0x08: 473 case 0x08:
338 psiconv_progress(lev+3,off+len,"Going to read interline exact"); 474 psiconv_progress(config,lev+3,off+len,"Going to read linespacing exact");
339 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng, 475 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
340 &result->interline_exact); 476 &result->linespacing_exact)))
477 goto ERROR1;
341 len += leng; 478 len += leng;
342 break; 479 break;
343 case 0x09: 480 case 0x09:
344 psiconv_progress(lev+3,off+len,"Going to read top space"); 481 psiconv_progress(config,lev+3,off+len,"Going to read top space");
345 result->top_space = psiconv_read_size(buf,lev+3,off+len,&leng); 482 result->space_above = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
483 if (res)
484 goto ERROR1;
346 len += leng; 485 len += leng;
347 break; 486 break;
348 case 0x0a: 487 case 0x0a:
349 psiconv_progress(lev+3,off+len,"Going to read bottom space"); 488 psiconv_progress(config,lev+3,off+len,"Going to read bottom space");
350 result->bottom_space = psiconv_read_size(buf,lev+3,off+len,&leng); 489 result->space_below = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
490 if (res)
491 goto ERROR1;
351 len += leng; 492 len += leng;
352 break; 493 break;
353 case 0x0b: 494 case 0x0b:
354 psiconv_progress(lev+3,off+len,"Going to read on one page"); 495 psiconv_progress(config,lev+3,off+len,"Going to read on one page");
355 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng, 496 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
356 &result->on_one_page); 497 &result->keep_together)))
498 goto ERROR1;
357 len += leng; 499 len += leng;
358 break; 500 break;
359 case 0x0c: 501 case 0x0c:
360 psiconv_progress(lev+3,off+len,"Going to read together with"); 502 psiconv_progress(config,lev+3,off+len,"Going to read together with");
361 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng, 503 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
362 &result->together_with); 504 &result->keep_with_next)))
505 goto ERROR1;
363 len += leng; 506 len += leng;
364 break; 507 break;
365 case 0x0d: 508 case 0x0d:
366 psiconv_progress(lev+3,off+len,"Going to read on next page"); 509 psiconv_progress(config,lev+3,off+len,"Going to read on next page");
367 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng, 510 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
368 &result->on_next_page); 511 &result->on_next_page)))
512 goto ERROR1;
369 len += leng; 513 len += leng;
370 break; 514 break;
371 case 0x0e: 515 case 0x0e:
372 psiconv_progress(lev+3,off+len,"Going to read no widow protection"); 516 psiconv_progress(config,lev+3,off+len,"Going to read no widow protection");
373 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng, 517 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
374 &result->no_widow_protection); 518 &result->no_widow_protection)))
519 goto ERROR1;
520 len += leng;
521 break;
522 case 0x0f:
523 psiconv_progress(config,lev+3,off+len,"Going to read wrap to fit cell limits");
524 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
525 &result->wrap_to_fit_cell)))
526 goto ERROR1;
375 len += leng; 527 len += leng;
376 break; 528 break;
377 case 0x10: 529 case 0x10:
378 psiconv_progress(lev+3,off+len,"Going to read border distance to text"); 530 psiconv_progress(config,lev+3,off+len,"Going to read border distance to text");
379 result->border_distance = psiconv_read_length(buf,lev+3, 531 result->border_distance = psiconv_read_length(config,buf,lev+3,
380 off+len,&leng); 532 off+len,&leng,&res);
533 if (res)
534 goto ERROR1;
381 len += leng; 535 len += leng;
382 break; 536 break;
383 case 0x11: 537 case 0x11:
384 psiconv_progress(lev+3,off+len,"Going to read top border"); 538 psiconv_progress(config,lev+3,off+len,"Going to read top border");
539 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
540 goto ERROR1;
385 psiconv_free_border(result->top_border); 541 psiconv_free_border(result->top_border);
386 res |= psiconv_parse_border(buf,lev+3,off+len,&leng, 542 result->top_border = temp_border;
387 &result->top_border);
388 len += leng; 543 len += leng;
389 break; 544 break;
390 case 0x12: 545 case 0x12:
391 psiconv_progress(lev+3,off+len,"Going to read bottom border"); 546 psiconv_progress(config,lev+3,off+len,"Going to read bottom border");
547 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
548 goto ERROR1;
392 psiconv_free_border(result->bottom_border); 549 psiconv_free_border(result->bottom_border);
393 res |= psiconv_parse_border(buf,lev+3,off+len,&leng, 550 result->bottom_border = temp_border;
394 &result->bottom_border);
395 len += leng; 551 len += leng;
396 break; 552 break;
397 case 0x13: 553 case 0x13:
398 psiconv_progress(lev+3,off+len,"Going to read left border"); 554 psiconv_progress(config,lev+3,off+len,"Going to read left border");
555 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
556 goto ERROR1;
399 psiconv_free_border(result->left_border); 557 psiconv_free_border(result->left_border);
400 res |= psiconv_parse_border(buf,lev+3,off+len,&leng, 558 result->left_border = temp_border;
401 &result->left_border);
402 len += leng; 559 len += leng;
403 break; 560 break;
404 case 0x14: 561 case 0x14:
405 psiconv_progress(lev+3,off+len,"Going to read right border"); 562 psiconv_progress(config,lev+3,off+len,"Going to read right border");
563 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
564 goto ERROR1;
406 psiconv_free_border(result->right_border); 565 psiconv_free_border(result->right_border);
407 res |= psiconv_parse_border(buf,lev+3,off+len,&leng, 566 result->right_border = temp_border;
408 &result->right_border);
409 len += leng; 567 len += leng;
410 break; 568 break;
411 case 0x15: 569 case 0x15:
412 psiconv_progress(lev+3,off+len,"Going to read bullet"); 570 psiconv_progress(config,lev+3,off+len,"Going to read bullet");
571 if ((res = psiconv_parse_bullet(config,buf,lev+3,off+len,&leng,&temp_bullet)))
572 goto ERROR1;
413 psiconv_free_bullet(result->bullet); 573 psiconv_free_bullet(result->bullet);
414 res |= psiconv_parse_bullet(buf,lev+3,off+len,&leng, 574 result->bullet = temp_bullet;
415 &result->bullet);
416 len += leng; 575 len += leng;
417 break; 576 break;
418 case 0x16: 577 case 0x16:
419 psiconv_progress(lev+3,off+len,"Going to read standard tabs"); 578 psiconv_progress(config,lev+3,off+len,"Going to read standard tabs");
420 result->tabs->normal = psiconv_read_length(buf,lev+3,off+len,&leng); 579 result->tabs->normal = psiconv_read_length(config,buf,lev+3,off+len,&leng,
580 &res);
581 if (res)
582 goto ERROR1;
421 len += leng; 583 len += leng;
422 break; 584 break;
423 case 0x17: 585 case 0x17:
424 psiconv_progress(lev+3,off+len,"Going to read extra tab"); 586 psiconv_progress(config,lev+3,off+len,"Going to read extra tab");
425 res |= psiconv_parse_tab(buf,lev+3,off+len,&leng,&tab); 587 if ((res = psiconv_parse_tab(config,buf,lev+3,off+len,&leng,&temp_tab)))
588 goto ERROR1;
426 psiconv_list_add(result->tabs->extras,tab); 589 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
590 psiconv_free_tab(temp_tab);
591 goto ERROR1;
592 }
593 psiconv_free_tab(temp_tab);
427 len += leng; 594 len += leng;
428 break; 595 break;
429 default: 596 default:
430 psiconv_warn(lev+3,off+len, 597 psiconv_warn(config,lev+3,off+len,
431 "Unknown code in paragraph layout codes list"); 598 "Unknown code in paragraph layout codes list");
432 psiconv_debug(lev+3,off+len,"Code: %02x",id); 599 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
433 len ++; 600 len ++;
434 res = -1;
435 break; 601 break;
436 } 602 }
437 nr ++; 603 nr ++;
438 } 604 }
439 605
440 if (len - 4 != list_length) { 606 if (len - 4 != list_length) {
441 psiconv_warn(lev+2,off+len, 607 psiconv_warn(config,lev+2,off+len,
442 "Read past end of paragraph layout codes list. I probably lost track" 608 "Read past end of paragraph layout codes list. I probably lost track"
443 "somewhere!"); 609 "somewhere!");
444 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 610 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
445 len-4,list_length); 611 len-4,list_length);
612 res = PSICONV_E_PARSE;
613 goto ERROR1;
446 } 614 }
447 615
448 len = list_length + 4; 616 len = list_length + 4;
449 617
450 psiconv_progress(lev+1,off+len, 618 psiconv_progress(config,lev+1,off+len,
451 "End of paragraph layout list (total length: %08x)",len); 619 "End of paragraph layout list (total length: %08x)",len);
452 620
453 if (length) 621 if (length)
454 *length = len; 622 *length = len;
623 return 0;
624
625ERROR1:
626 psiconv_warn(config,lev+1,off,"Reading of paragraph_layout_list failed");
627 if (length)
628 *length = 0;
629 if (!res)
630 return -PSICONV_E_NOMEM;
631 else
455 return res; 632 return res;
456} 633}
457 634
458int psiconv_parse_character_layout_list(const psiconv_buffer buf, int lev, 635int psiconv_parse_character_layout_list(const psiconv_config config,
636 const psiconv_buffer buf, int lev,
459 psiconv_u32 off, int *length, 637 psiconv_u32 off, int *length,
460 psiconv_character_layout result) 638 psiconv_character_layout result)
461{ 639{
462 int res=0; 640 int res=0;
463 int len=0; 641 int len=0;
464 int list_length,leng,nr; 642 int list_length,leng,nr;
465 psiconv_u8 id; 643 psiconv_u8 id;
466 psiconv_u32 temp; 644 psiconv_u32 temp;
645 psiconv_color temp_color;
646 psiconv_font temp_font;
467 647
468 psiconv_progress(lev+1,off,"Going to read character layout codes"); 648 psiconv_progress(config,lev+1,off,"Going to read character layout codes");
469 649
470 psiconv_progress(lev+2,off,"Going to read the list length"); 650 psiconv_progress(config,lev+2,off,"Going to read the list length");
471 list_length = psiconv_read_u32(buf,lev+2,off + len); 651 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
652 if (res)
653 goto ERROR1;
472 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 654 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
473 len += 4; 655 len += 4;
474 656
475 nr = 0; 657 nr = 0;
476 while(len-4 < list_length) { 658 while(len-4 < list_length) {
477 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 659 psiconv_progress(config,lev+2,off+len,"Going to read element %d",nr);
478 psiconv_progress(lev+3,off+len,"Going to read the element id"); 660 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
479 id = psiconv_read_u8(buf,lev+2,off+len); 661 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
662 if (res)
663 goto ERROR1;
480 psiconv_debug(lev+3,off+len,"Id: %02x",id); 664 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
481 len ++; 665 len ++;
482 switch(id) { 666 switch(id) {
667 case 0x18:
668 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
669 len ++;
670 break;
483 case 0x19: 671 case 0x19:
484 psiconv_progress(lev+3,off+len,"Going to read text color"); 672 psiconv_progress(config,lev+3,off+len,"Going to read text color");
673 if ((res = psiconv_parse_color(config,buf,lev+3,off+len, &leng,&temp_color)))
674 goto ERROR1;
485 psiconv_free_color(result->color); 675 psiconv_free_color(result->color);
486 res |= psiconv_parse_color(buf,lev+3,off+len, &leng,&result->color); 676 result->color = temp_color;
487 len += leng; 677 len += leng;
488 break; 678 break;
489 case 0x1a: 679 case 0x1a:
490 psiconv_progress(lev+3,off+len,"Going to read background color (?)"); 680 psiconv_progress(config,lev+3,off+len,"Going to read background color (?)");
681 if ((res = psiconv_parse_color(config,buf,lev+2,off+len, &leng,&temp_color)))
682 goto ERROR1;
491 psiconv_free_color(result->back_color); 683 psiconv_free_color(result->back_color);
492 res |= psiconv_parse_color(buf,lev+2,off+len, &leng, 684 result->back_color = temp_color;
493 &result->back_color); 685 len += leng;
686 break;
687 case 0x1b:
688 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
494 len += leng; 689 len ++;
495 break; 690 break;
496 case 0x1c: 691 case 0x1c:
497 psiconv_progress(lev+3,off+len,"Going to read font size"); 692 psiconv_progress(config,lev+3,off+len,"Going to read font size");
498 result->font_size = psiconv_read_size(buf,lev+3,off+len,&leng); 693 result->font_size = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
694 if (res)
695 goto ERROR1;
499 len += leng; 696 len += leng;
500 break; 697 break;
501 case 0x1d: 698 case 0x1d:
502 psiconv_progress(lev+3,off+len,"Going to read italic"); 699 psiconv_progress(config,lev+3,off+len,"Going to read italic");
503 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->italic); 700 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->italic)))
701 goto ERROR1;
504 len += leng; 702 len += leng;
505 break; 703 break;
506 case 0x1e: 704 case 0x1e:
507 psiconv_progress(lev+3,off+len,"Going to read bold"); 705 psiconv_progress(config,lev+3,off+len,"Going to read bold");
508 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->bold); 706 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->bold)))
707 goto ERROR1;
509 len += leng; 708 len += leng;
510 break; 709 break;
511 case 0x1f: 710 case 0x1f:
512 psiconv_progress(lev+3,off+len,"Going to read super_sub"); 711 psiconv_progress(config,lev+3,off+len,"Going to read super_sub");
513 temp = psiconv_read_u8(buf,lev+3,off+len); 712 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
713 if (res)
714 goto ERROR1;
514 if (temp == 0x00) 715 if (temp == 0x00)
515 result->super_sub = psiconv_normalscript; 716 result->super_sub = psiconv_normalscript;
516 else if (temp == 0x01) 717 else if (temp == 0x01)
517 result->super_sub = psiconv_superscript; 718 result->super_sub = psiconv_superscript;
518 else if (temp == 0x02) 719 else if (temp == 0x02)
519 result->super_sub = psiconv_subscript; 720 result->super_sub = psiconv_subscript;
520 else { 721 else {
521 psiconv_warn(lev+3,off+len, 722 psiconv_warn(config,lev+3,off+len,
522 "Unknown super_sub argument in character layout codes list"); 723 "Unknown super_sub argument in character layout codes list");
523 res = -1;
524 } 724 }
525 psiconv_debug(lev+3,off+len,"Super_sub: %02x",temp); 725 psiconv_debug(config,lev+3,off+len,"Super_sub: %02x",temp);
526 len ++; 726 len ++;
527 break; 727 break;
528 case 0x20: 728 case 0x20:
529 psiconv_progress(lev+3,off+len,"Going to read underline"); 729 psiconv_progress(config,lev+3,off+len,"Going to read underline");
530 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->underline); 730 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
731 &result->underline)))
732 goto ERROR1;
531 len += leng; 733 len += leng;
532 break; 734 break;
533 case 0x21: 735 case 0x21:
534 psiconv_progress(lev+3,off+len,"Going to read strike_out"); 736 psiconv_progress(config,lev+3,off+len,"Going to read strikethrough");
535 res |= psiconv_parse_bool(buf,lev+3,off+len,&leng,&result->strike_out); 737 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
738 &result->strikethrough)))
739 goto ERROR1;
536 len += leng; 740 len += leng;
537 break; 741 break;
538 case 0x22: 742 case 0x22:
539 psiconv_progress(lev+3,off+len,"Going to read font"); 743 psiconv_progress(config,lev+3,off+len,"Going to read font");
744 if ((res = psiconv_parse_font(config,buf,lev+3,off+len, &leng, &temp_font)))
745 goto ERROR1;
540 psiconv_free_font(result->font); 746 psiconv_free_font(result->font);
541 res |= psiconv_parse_font(buf,lev+3,off+len, &leng, &result->font); 747 result->font = temp_font;
748 len += leng;
749 break;
750 case 0x23:
751 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
542 len += leng; 752 len ++;
753 break;
754 case 0x24:
755 psiconv_progress(config,lev+3,off+len,
756 "Going to read unknown code 0x24 (%02x expected)", 0);
757 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
758 if (res)
759 goto ERROR1;
760 if (temp != 0) {
761 psiconv_warn(config,lev+3,off+len,
762 "Unknown code 0x24 value != 0x0 (0x%02x)", temp);
763 }
764 len ++;
543 break; 765 break;
544 default: 766 default:
545 psiconv_warn(lev+3,off+len,"Unknown code in character layout list"); 767 psiconv_warn(config,lev+3,off+len,"Unknown code in character layout list");
546 psiconv_debug(lev+3,off+len,"Code: %02x",id); 768 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
547 len ++; 769 len ++;
548 res = -1;
549 break; 770 break;
550 } 771 }
551 nr ++; 772 nr ++;
552 } 773 }
553 774
554 if (len - 4 != list_length) { 775 if (len - 4 != list_length) {
555 psiconv_warn(lev+2,off+len, 776 psiconv_warn(config,lev+2,off+len,
556 "Read past end of character layout codes list. I probably lost track" 777 "Read past end of character layout codes list. I probably lost track"
557 "somewhere!"); 778 "somewhere!");
558 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 779 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
559 len-4,list_length); 780 len-4,list_length);
781 res = PSICONV_E_PARSE;
782 goto ERROR1;
560 } 783 }
561 784
562 len = list_length + 4; 785 len = list_length + 4;
563 786
564 psiconv_progress(lev+1,off+len, 787 psiconv_progress(config,lev+1,off+len,
565 "End of character layout list (total length: %08x)",len); 788 "End of character layout list (total length: %08x)",len);
566 789
567 if (length) 790 if (length)
568 *length = len; 791 *length = len;
569 return res; 792 return res;
793
794ERROR1:
795 psiconv_warn(config,lev+1,off,"Reading of character_layout_list failed");
796 if (length)
797 *length = 0;
798 if (!res)
799 return -PSICONV_E_NOMEM;
800 else
801 return res;
570} 802}

Legend:
Removed from v.2  
changed lines
  Added in v.168

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