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

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

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