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

Legend:
Removed from v.63  
changed lines
  Added in v.182

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