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

Legend:
Removed from v.143  
changed lines
  Added in v.270

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