/[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 184
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, 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;
231 int bullet_length; 237 int bullet_length;
238 psiconv_u8 temp;
232 239
233 if (!(*result = malloc(sizeof(**result)))) 240 if (!(*result = malloc(sizeof(**result))))
234 goto ERROR1; 241 goto ERROR1;
235 (*result)->on = psiconv_bool_true; 242 (*result)->on = psiconv_bool_true;
236 243
237 psiconv_progress(lev+1,off,"Going to parse bullet data"); 244 psiconv_progress(config,lev+1,off,"Going to parse bullet data");
238 psiconv_progress(lev+2,off+len,"Going to read bullet length"); 245 psiconv_progress(config,lev+2,off+len,"Going to read bullet length");
239 bullet_length = psiconv_read_u8(buf,lev+2,off+len,&res); 246 bullet_length = psiconv_read_u8(config,buf,lev+2,off+len,&res);
240 if (res) 247 if (res)
241 goto ERROR2; 248 goto ERROR2;
242 psiconv_debug(lev+2,off+len,"Length: %02x",bullet_length); 249 psiconv_debug(config,lev+2,off+len,"Length: %02x",bullet_length);
243 len ++; 250 len ++;
244 251
245 psiconv_progress(lev+2,off+len,"Going to read bullet font size"); 252 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); 253 (*result)->font_size = psiconv_read_size(config,buf,lev+2,off+len, &leng,&res);
247 if (res) 254 if (res)
248 goto ERROR2; 255 goto ERROR2;
249 len +=leng; 256 len +=leng;
250 257
251 psiconv_progress(lev+2,off+len,"Going to read bullet character"); 258 psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
252 (*result)->character = psiconv_read_u8(buf,lev+2,off+len,&res); 259 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
253 if (res) 260 if (res)
254 goto ERROR2; 261 goto ERROR2;
262 (*result)->character = psiconv_unicode_from_char(config,temp);
255 psiconv_debug(lev+2,off+len,"Character: %02x",(*result)->character); 263 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
256 len ++; 264 len ++;
257 265
258 psiconv_progress(lev+2,off+len,"Going to read indent on/off"); 266 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))) 267 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
260 goto ERROR2; 268 goto ERROR2;
261 psiconv_debug(lev+2,off+len,"Indent on: %02x",(*result)->indent); 269 psiconv_debug(config,lev+2,off+len,"Indent on: %02x",(*result)->indent);
262 len += leng; 270 len += leng;
263 271
264 psiconv_progress(lev+2,off+len,"Going to read bullet color"); 272 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))) 273 if ((res = psiconv_parse_color(config,buf,lev+2,off+len,&leng,&(*result)->color)))
266 goto ERROR2; 274 goto ERROR2;
267 len += leng; 275 len += leng;
268 276
269 psiconv_progress(lev+2,off+len,"Going to read bullet font"); 277 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))) 278 if ((res = psiconv_parse_font(config,buf,lev+2,off+len,&leng,&(*result)->font)))
271 goto ERROR3; 279 goto ERROR3;
272 len += leng; 280 len += leng;
273 281
274 if (len != bullet_length + 1) { 282 if (len != bullet_length + 1) {
275 psiconv_warn(lev+2,off,"Bullet data structure length mismatch"); 283 psiconv_warn(config,lev+2,off,"Bullet data structure length mismatch");
276 psiconv_debug(lev+2,off,"Length: specified %02x, found %02x", 284 psiconv_debug(config,lev+2,off,"Length: specified %02x, found %02x",
277 bullet_length,len-1); 285 bullet_length,len-1);
278 } 286 }
279 287
280 psiconv_progress(lev+1,off + len - 1, 288 psiconv_progress(config,lev+1,off + len - 1,
281 "End of bullet data (total length: %08x)",len); 289 "End of bullet data (total length: %08x)",len);
282 290
283 if (length) 291 if (length)
284 *length = len; 292 *length = len;
285 return 0; 293 return 0;
287ERROR3: 295ERROR3:
288 psiconv_free_color((*result)->color); 296 psiconv_free_color((*result)->color);
289ERROR2: 297ERROR2:
290 free (result); 298 free (result);
291ERROR1: 299ERROR1:
292 psiconv_warn(lev+1,off,"Reading of Bullet failed"); 300 psiconv_error(config,lev+1,off,"Reading of Bullet failed");
293 if (length) 301 if (length)
294 *length = 0; 302 *length = 0;
295 if (!res) 303 if (!res)
296 return -PSICONV_E_NOMEM; 304 return -PSICONV_E_NOMEM;
297 else 305 else
298 return res; 306 return res;
299} 307}
300 308
301int psiconv_parse_tab(const psiconv_buffer buf, int lev, psiconv_u32 off, 309int psiconv_parse_tab(const psiconv_config config,
310 const psiconv_buffer buf, int lev, psiconv_u32 off,
302 int *length, psiconv_tab *result) 311 int *length, psiconv_tab *result)
303{ 312{
304 int res = 0; 313 int res = 0;
305 int len = 0; 314 int len = 0;
306 int leng; 315 int leng;
307 psiconv_u8 temp; 316 psiconv_u8 temp;
308 317
309 psiconv_progress(lev+1,off,"Going to parse tab"); 318 psiconv_progress(config,lev+1,off,"Going to parse tab");
310 if (!(*result = malloc(sizeof(**result)))) 319 if (!(*result = malloc(sizeof(**result))))
311 goto ERROR1; 320 goto ERROR1;
312 321
313 psiconv_progress(lev+2,off,"Going to read tab location"); 322 psiconv_progress(config,lev+2,off,"Going to read tab location");
314 (*result)->location = psiconv_read_length(buf,lev+2,off+len,&leng,&res); 323 (*result)->location = psiconv_read_length(config,buf,lev+2,off+len,&leng,&res);
315 if (res) 324 if (res)
316 goto ERROR2; 325 goto ERROR2;
317 len += leng; 326 len += leng;
318 327
319 psiconv_progress(lev+2,off+len,"Going to read the tab kind"); 328 psiconv_progress(config,lev+2,off+len,"Going to read the tab kind");
320 temp = psiconv_read_u8(buf,lev+2,off+len,&res); 329 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
321 if (res) 330 if (res)
322 goto ERROR2; 331 goto ERROR2;
323 if (temp == 1) 332 if (temp == 1)
324 (*result)->kind = psiconv_tab_left; 333 (*result)->kind = psiconv_tab_left;
325 else if (temp == 2) 334 else if (temp == 2)
326 (*result)->kind = psiconv_tab_centre; 335 (*result)->kind = psiconv_tab_centre;
327 else if (temp == 3) 336 else if (temp == 3)
328 (*result)->kind = psiconv_tab_right; 337 (*result)->kind = psiconv_tab_right;
329 else { 338 else {
330 psiconv_warn(lev+2,off+len,"Unknown tab kind argument"); 339 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)", 340 psiconv_debug(config,lev+2,off+len,"Kind found: %02x (defaulted to left tab)",
332 temp); 341 temp);
333 (*result)->kind = psiconv_tab_left; 342 (*result)->kind = psiconv_tab_left;
334 } 343 }
335 psiconv_debug(lev+2,off+len,"Kind: %02x",temp); 344 psiconv_debug(config,lev+2,off+len,"Kind: %02x",temp);
336 len ++; 345 len ++;
337 346
338 if (length) 347 if (length)
339 *length = len; 348 *length = len;
340 349
341 psiconv_progress(lev+1,off+len-1,"End of tab (total length: %08x)",len); 350 psiconv_progress(config,lev+1,off+len-1,"End of tab (total length: %08x)",len);
342 return 0; 351 return 0;
343 352
344ERROR2: 353ERROR2:
345 free (result); 354 free (result);
346ERROR1: 355ERROR1:
347 psiconv_warn(lev+1,off,"Reading of Tab failed"); 356 psiconv_error(config,lev+1,off,"Reading of Tab failed");
348 if (length) 357 if (length)
349 *length = 0; 358 *length = 0;
350 if (!res) 359 if (!res)
351 return -PSICONV_E_NOMEM; 360 return -PSICONV_E_NOMEM;
352 else 361 else
353 return res; 362 return res;
354} 363}
355 364
356int psiconv_parse_paragraph_layout_list(const psiconv_buffer buf, int lev, 365int psiconv_parse_paragraph_layout_list(const psiconv_config config,
366 const psiconv_buffer buf, int lev,
357 psiconv_u32 off, int *length, 367 psiconv_u32 off, int *length,
358 psiconv_paragraph_layout result) 368 psiconv_paragraph_layout result)
359{ 369{
360 int res=0; 370 int res=0;
361 int len=0; 371 int len=0;
365 psiconv_tab temp_tab; 375 psiconv_tab temp_tab;
366 psiconv_color temp_color; 376 psiconv_color temp_color;
367 psiconv_border temp_border; 377 psiconv_border temp_border;
368 psiconv_bullet temp_bullet; 378 psiconv_bullet temp_bullet;
369 379
370 psiconv_progress(lev+1,off,"Going to read paragraph layout list"); 380 psiconv_progress(config,lev+1,off,"Going to read paragraph layout list");
371 381
372 psiconv_progress(lev+2,off,"Going to read the list length"); 382 psiconv_progress(config,lev+2,off,"Going to read the list length");
373 list_length = psiconv_read_u32(buf,lev+2,off + len,&res); 383 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
374 if (res) 384 if (res)
375 goto ERROR1; 385 goto ERROR1;
376 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 386 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
377 len += 4; 387 len += 4;
378 388
379 nr = 0; 389 nr = 0;
380 while(len - 4 < list_length) { 390 while(len - 4 < list_length) {
381 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 391 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"); 392 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
383 id = psiconv_read_u8(buf,lev+2,off+len,&res); 393 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
384 if (res) 394 if (res)
385 goto ERROR1; 395 goto ERROR1;
386 psiconv_debug(lev+3,off+len,"Id: %02x",id); 396 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
387 len ++; 397 len ++;
388 switch(id) { 398 switch(id) {
389 case 0x01: 399 case 0x01:
390 psiconv_progress(lev+3,off+len,"Going to read background color"); 400 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))) 401 if ((res = psiconv_parse_color(config,buf,lev+3,off+len,&leng,&temp_color)))
392 goto ERROR1; 402 goto ERROR1;
393 psiconv_free_color(result->back_color); 403 psiconv_free_color(result->back_color);
394 result->back_color = temp_color; 404 result->back_color = temp_color;
395 len += leng; 405 len += leng;
396 break; 406 break;
397 case 0x02: 407 case 0x02:
398 psiconv_progress(lev+3,off+len ,"Going to read indent left"); 408 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); 409 result->indent_left = psiconv_read_length(config,buf,lev+3,off+len,&leng,&res);
400 if (res) 410 if (res)
401 goto ERROR1; 411 goto ERROR1;
402 len += leng; 412 len += leng;
403 break; 413 break;
404 case 0x03: 414 case 0x03:
405 psiconv_progress(lev+3,off+len,"Going to read indent right"); 415 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, 416 result->indent_right = psiconv_read_length(config,buf,lev+2,off+len,&leng,
407 &res); 417 &res);
408 if (res) 418 if (res)
409 goto ERROR1; 419 goto ERROR1;
410 len += leng; 420 len += leng;
411 break; 421 break;
412 case 0x04: 422 case 0x04:
413 psiconv_progress(lev+3,off+len,"Going to read indent left first line"); 423 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, 424 result->indent_first = psiconv_read_length(config,buf,lev+2,off+len, &leng,
415 &res); 425 &res);
416 if (res) 426 if (res)
417 goto ERROR1; 427 goto ERROR1;
418 len += leng; 428 len += leng;
419 break; 429 break;
420 case 0x05: 430 case 0x05:
421 psiconv_progress(lev+3,off+len,"Going to read horizontal justify"); 431 psiconv_progress(config,lev+3,off+len,"Going to read horizontal justify");
422 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 432 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
423 if (res) 433 if (res)
424 goto ERROR1; 434 goto ERROR1;
425 if (temp == 0x00) 435 if (temp == 0x00)
426 result->justify_hor = psiconv_justify_left; 436 result->justify_hor = psiconv_justify_left;
427 else if (temp == 0x01) 437 else if (temp == 0x01)
429 else if (temp == 0x02) 439 else if (temp == 0x02)
430 result->justify_hor = psiconv_justify_right; 440 result->justify_hor = psiconv_justify_right;
431 else if (temp == 0x03) 441 else if (temp == 0x03)
432 result->justify_hor = psiconv_justify_full; 442 result->justify_hor = psiconv_justify_full;
433 else { 443 else {
434 psiconv_warn(lev+3,off+len, "Unknown horizontal justify argument " 444 psiconv_warn(config,lev+3,off+len, "Unknown horizontal justify argument "
435 "in paragraph layout codes list"); 445 "in paragraph layout codes list");
436 result->justify_hor = psiconv_justify_left; 446 result->justify_hor = psiconv_justify_left;
437 } 447 }
438 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 448 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
439 len ++; 449 len ++;
440 break; 450 break;
441 case 0x06: 451 case 0x06:
442 psiconv_progress(lev+3,off+len,"Going to read vertical justify"); 452 psiconv_progress(config,lev+3,off+len,"Going to read vertical justify");
443 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 453 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
444 if (res) 454 if (res)
445 goto ERROR1; 455 goto ERROR1;
446 if (temp == 0x00) 456 if (temp == 0x00)
447 result->justify_ver = psiconv_justify_top; 457 result->justify_ver = psiconv_justify_top;
448 else if (temp == 0x01) 458 else if (temp == 0x01)
449 result->justify_ver = psiconv_justify_middle; 459 result->justify_ver = psiconv_justify_middle;
450 else if (temp == 0x02) 460 else if (temp == 0x02)
451 result->justify_ver = psiconv_justify_bottom; 461 result->justify_ver = psiconv_justify_bottom;
452 else { 462 else {
453 psiconv_warn(lev+3,off+len, "Unknown vertical justify argument " 463 psiconv_warn(config,lev+3,off+len, "Unknown vertical justify argument "
454 "in paragraph layout codes list"); 464 "in paragraph layout codes list");
455 result->justify_ver = psiconv_justify_bottom; 465 result->justify_ver = psiconv_justify_bottom;
456 } 466 }
457 psiconv_debug(lev+3,off+len,"Justify: %02x",temp); 467 psiconv_debug(config,lev+3,off+len,"Justify: %02x",temp);
458 len ++; 468 len ++;
459 break; 469 break;
460 case 0x07: 470 case 0x07:
461 psiconv_progress(lev+3,off+len,"Going to read linespacing distance"); 471 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); 472 result->linespacing = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
463 if (res) 473 if (res)
464 goto ERROR1; 474 goto ERROR1;
465 len += leng; 475 len += leng;
466 break; 476 break;
467 case 0x08: 477 case 0x08:
468 psiconv_progress(lev+3,off+len,"Going to read linespacing exact"); 478 psiconv_progress(config,lev+3,off+len,"Going to read linespacing exact");
469 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 479 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
470 &result->linespacing_exact))) 480 &result->linespacing_exact)))
471 goto ERROR1; 481 goto ERROR1;
472 len += leng; 482 len += leng;
473 break; 483 break;
474 case 0x09: 484 case 0x09:
475 psiconv_progress(lev+3,off+len,"Going to read top space"); 485 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); 486 result->space_above = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
477 if (res) 487 if (res)
478 goto ERROR1; 488 goto ERROR1;
479 len += leng; 489 len += leng;
480 break; 490 break;
481 case 0x0a: 491 case 0x0a:
482 psiconv_progress(lev+3,off+len,"Going to read bottom space"); 492 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); 493 result->space_below = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
484 if (res) 494 if (res)
485 goto ERROR1; 495 goto ERROR1;
486 len += leng; 496 len += leng;
487 break; 497 break;
488 case 0x0b: 498 case 0x0b:
489 psiconv_progress(lev+3,off+len,"Going to read on one page"); 499 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, 500 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
491 &result->keep_together))) 501 &result->keep_together)))
492 goto ERROR1; 502 goto ERROR1;
493 len += leng; 503 len += leng;
494 break; 504 break;
495 case 0x0c: 505 case 0x0c:
496 psiconv_progress(lev+3,off+len,"Going to read together with"); 506 psiconv_progress(config,lev+3,off+len,"Going to read together with");
497 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 507 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
498 &result->keep_with_next))) 508 &result->keep_with_next)))
499 goto ERROR1; 509 goto ERROR1;
500 len += leng; 510 len += leng;
501 break; 511 break;
502 case 0x0d: 512 case 0x0d:
503 psiconv_progress(lev+3,off+len,"Going to read on next page"); 513 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, 514 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
505 &result->on_next_page))) 515 &result->on_next_page)))
506 goto ERROR1; 516 goto ERROR1;
507 len += leng; 517 len += leng;
508 break; 518 break;
509 case 0x0e: 519 case 0x0e:
510 psiconv_progress(lev+3,off+len,"Going to read no widow protection"); 520 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, 521 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
512 &result->no_widow_protection))) 522 &result->no_widow_protection)))
513 goto ERROR1; 523 goto ERROR1;
514 len += leng; 524 len += leng;
515 break; 525 break;
516 case 0x0f: 526 case 0x0f:
517 psiconv_progress(lev+3,off+len,"Going to read wrap to fit cell limits"); 527 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, 528 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
519 &result->wrap_to_fit_cell))) 529 &result->wrap_to_fit_cell)))
520 goto ERROR1; 530 goto ERROR1;
521 len += leng; 531 len += leng;
522 break; 532 break;
523 case 0x10: 533 case 0x10:
524 psiconv_progress(lev+3,off+len,"Going to read border distance to text"); 534 psiconv_progress(config,lev+3,off+len,"Going to read border distance to text");
525 result->border_distance = psiconv_read_length(buf,lev+3, 535 result->border_distance = psiconv_read_length(config,buf,lev+3,
526 off+len,&leng,&res); 536 off+len,&leng,&res);
527 if (res) 537 if (res)
528 goto ERROR1; 538 goto ERROR1;
529 len += leng; 539 len += leng;
530 break; 540 break;
531 case 0x11: 541 case 0x11:
532 psiconv_progress(lev+3,off+len,"Going to read top border"); 542 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))) 543 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
534 goto ERROR1; 544 goto ERROR1;
535 psiconv_free_border(result->top_border); 545 psiconv_free_border(result->top_border);
536 result->top_border = temp_border; 546 result->top_border = temp_border;
537 len += leng; 547 len += leng;
538 break; 548 break;
539 case 0x12: 549 case 0x12:
540 psiconv_progress(lev+3,off+len,"Going to read bottom border"); 550 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))) 551 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
542 goto ERROR1; 552 goto ERROR1;
543 psiconv_free_border(result->bottom_border); 553 psiconv_free_border(result->bottom_border);
544 result->bottom_border = temp_border; 554 result->bottom_border = temp_border;
545 len += leng; 555 len += leng;
546 break; 556 break;
547 case 0x13: 557 case 0x13:
548 psiconv_progress(lev+3,off+len,"Going to read left border"); 558 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))) 559 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
550 goto ERROR1; 560 goto ERROR1;
551 psiconv_free_border(result->left_border); 561 psiconv_free_border(result->left_border);
552 result->left_border = temp_border; 562 result->left_border = temp_border;
553 len += leng; 563 len += leng;
554 break; 564 break;
555 case 0x14: 565 case 0x14:
556 psiconv_progress(lev+3,off+len,"Going to read right border"); 566 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))) 567 if ((res = psiconv_parse_border(config,buf,lev+3,off+len,&leng,&temp_border)))
558 goto ERROR1; 568 goto ERROR1;
559 psiconv_free_border(result->right_border); 569 psiconv_free_border(result->right_border);
560 result->right_border = temp_border; 570 result->right_border = temp_border;
561 len += leng; 571 len += leng;
562 break; 572 break;
563 case 0x15: 573 case 0x15:
564 psiconv_progress(lev+3,off+len,"Going to read bullet"); 574 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))) 575 if ((res = psiconv_parse_bullet(config,buf,lev+3,off+len,&leng,&temp_bullet)))
566 goto ERROR1; 576 goto ERROR1;
567 psiconv_free_bullet(result->bullet); 577 psiconv_free_bullet(result->bullet);
568 result->bullet = temp_bullet; 578 result->bullet = temp_bullet;
569 len += leng; 579 len += leng;
570 break; 580 break;
571 case 0x16: 581 case 0x16:
572 psiconv_progress(lev+3,off+len,"Going to read standard tabs"); 582 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, 583 result->tabs->normal = psiconv_read_length(config,buf,lev+3,off+len,&leng,
574 &res); 584 &res);
575 if (res) 585 if (res)
576 goto ERROR1; 586 goto ERROR1;
577 len += leng; 587 len += leng;
578 break; 588 break;
579 case 0x17: 589 case 0x17:
580 psiconv_progress(lev+3,off+len,"Going to read extra tab"); 590 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))) 591 if ((res = psiconv_parse_tab(config,buf,lev+3,off+len,&leng,&temp_tab)))
582 goto ERROR1; 592 goto ERROR1;
583 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) { 593 if ((res = psiconv_list_add(result->tabs->extras,temp_tab))) {
584 psiconv_free_tab(temp_tab); 594 psiconv_free_tab(temp_tab);
585 goto ERROR1; 595 goto ERROR1;
586 } 596 }
597 psiconv_free_tab(temp_tab);
587 len += leng; 598 len += leng;
588 break; 599 break;
589 default: 600 default:
590 psiconv_warn(lev+3,off+len, 601 psiconv_warn(config,lev+3,off+len,
591 "Unknown code in paragraph layout codes list"); 602 "Unknown code in paragraph layout codes list");
592 psiconv_debug(lev+3,off+len,"Code: %02x",id); 603 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
593 len ++; 604 len ++;
594 break; 605 break;
595 } 606 }
596 nr ++; 607 nr ++;
597 } 608 }
598 609
599 if (len - 4 != list_length) { 610 if (len - 4 != list_length) {
600 psiconv_warn(lev+2,off+len, 611 psiconv_error(config,lev+2,off+len,
601 "Read past end of paragraph layout codes list. I probably lost track" 612 "Read past end of paragraph layout codes list. I probably lost track "
602 "somewhere!"); 613 "somewhere!");
603 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 614 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
604 len-4,list_length); 615 len-4,list_length);
605 res = PSICONV_E_PARSE; 616 res = PSICONV_E_PARSE;
606 goto ERROR1; 617 goto ERROR1;
607 } 618 }
608 619
609 len = list_length + 4; 620 len = list_length + 4;
610 621
611 psiconv_progress(lev+1,off+len, 622 psiconv_progress(config,lev+1,off+len,
612 "End of paragraph layout list (total length: %08x)",len); 623 "End of paragraph layout list (total length: %08x)",len);
613 624
614 if (length) 625 if (length)
615 *length = len; 626 *length = len;
616 return 0; 627 return 0;
617 628
618ERROR1: 629ERROR1:
619 psiconv_warn(lev+1,off,"Reading of paragraph_layout_list failed"); 630 psiconv_error(config,lev+1,off,"Reading of paragraph_layout_list failed");
620 if (length) 631 if (length)
621 *length = 0; 632 *length = 0;
622 if (!res) 633 if (!res)
623 return -PSICONV_E_NOMEM; 634 return -PSICONV_E_NOMEM;
624 else 635 else
625 return res; 636 return res;
626} 637}
627 638
628int psiconv_parse_character_layout_list(const psiconv_buffer buf, int lev, 639int psiconv_parse_character_layout_list(const psiconv_config config,
640 const psiconv_buffer buf, int lev,
629 psiconv_u32 off, int *length, 641 psiconv_u32 off, int *length,
630 psiconv_character_layout result) 642 psiconv_character_layout result)
631{ 643{
632 int res=0; 644 int res=0;
633 int len=0; 645 int len=0;
635 psiconv_u8 id; 647 psiconv_u8 id;
636 psiconv_u32 temp; 648 psiconv_u32 temp;
637 psiconv_color temp_color; 649 psiconv_color temp_color;
638 psiconv_font temp_font; 650 psiconv_font temp_font;
639 651
640 psiconv_progress(lev+1,off,"Going to read character layout codes"); 652 psiconv_progress(config,lev+1,off,"Going to read character layout codes");
641 653
642 psiconv_progress(lev+2,off,"Going to read the list length"); 654 psiconv_progress(config,lev+2,off,"Going to read the list length");
643 list_length = psiconv_read_u32(buf,lev+2,off + len,&res); 655 list_length = psiconv_read_u32(config,buf,lev+2,off + len,&res);
644 if (res) 656 if (res)
645 goto ERROR1; 657 goto ERROR1;
646 psiconv_debug(lev+2,off,"Length in bytes: %08x",list_length); 658 psiconv_debug(config,lev+2,off,"Length in bytes: %08x",list_length);
647 len += 4; 659 len += 4;
648 660
649 nr = 0; 661 nr = 0;
650 while(len-4 < list_length) { 662 while(len-4 < list_length) {
651 psiconv_progress(lev+2,off+len,"Going to read element %d",nr); 663 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"); 664 psiconv_progress(config,lev+3,off+len,"Going to read the element id");
653 id = psiconv_read_u8(buf,lev+2,off+len,&res); 665 id = psiconv_read_u8(config,buf,lev+2,off+len,&res);
654 if (res) 666 if (res)
655 goto ERROR1; 667 goto ERROR1;
656 psiconv_debug(lev+3,off+len,"Id: %02x",id); 668 psiconv_debug(config,lev+3,off+len,"Id: %02x",id);
657 len ++; 669 len ++;
658 switch(id) { 670 switch(id) {
659 case 0x18: 671 case 0x18:
660 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); 672 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
661 len ++; 673 len ++;
662 break; 674 break;
663 case 0x19: 675 case 0x19:
664 psiconv_progress(lev+3,off+len,"Going to read text color"); 676 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))) 677 if ((res = psiconv_parse_color(config,buf,lev+3,off+len, &leng,&temp_color)))
666 goto ERROR1; 678 goto ERROR1;
667 psiconv_free_color(result->color); 679 psiconv_free_color(result->color);
668 result->color = temp_color; 680 result->color = temp_color;
669 len += leng; 681 len += leng;
670 break; 682 break;
671 case 0x1a: 683 case 0x1a:
672 psiconv_progress(lev+3,off+len,"Going to read background color (?)"); 684 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))) 685 if ((res = psiconv_parse_color(config,buf,lev+2,off+len, &leng,&temp_color)))
674 goto ERROR1; 686 goto ERROR1;
675 psiconv_free_color(result->back_color); 687 psiconv_free_color(result->back_color);
676 result->back_color = temp_color; 688 result->back_color = temp_color;
677 len += leng; 689 len += leng;
678 break; 690 break;
679 case 0x1b: 691 case 0x1b:
680 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); 692 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
681 len ++; 693 len ++;
682 break; 694 break;
683 case 0x1c: 695 case 0x1c:
684 psiconv_progress(lev+3,off+len,"Going to read font size"); 696 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); 697 result->font_size = psiconv_read_size(config,buf,lev+3,off+len,&leng,&res);
686 if (res) 698 if (res)
687 goto ERROR1; 699 goto ERROR1;
688 len += leng; 700 len += leng;
689 break; 701 break;
690 case 0x1d: 702 case 0x1d:
691 psiconv_progress(lev+3,off+len,"Going to read italic"); 703 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))) 704 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->italic)))
693 goto ERROR1; 705 goto ERROR1;
694 len += leng; 706 len += leng;
695 break; 707 break;
696 case 0x1e: 708 case 0x1e:
697 psiconv_progress(lev+3,off+len,"Going to read bold"); 709 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))) 710 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,&result->bold)))
699 goto ERROR1; 711 goto ERROR1;
700 len += leng; 712 len += leng;
701 break; 713 break;
702 case 0x1f: 714 case 0x1f:
703 psiconv_progress(lev+3,off+len,"Going to read super_sub"); 715 psiconv_progress(config,lev+3,off+len,"Going to read super_sub");
704 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 716 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
705 if (res) 717 if (res)
706 goto ERROR1; 718 goto ERROR1;
707 if (temp == 0x00) 719 if (temp == 0x00)
708 result->super_sub = psiconv_normalscript; 720 result->super_sub = psiconv_normalscript;
709 else if (temp == 0x01) 721 else if (temp == 0x01)
710 result->super_sub = psiconv_superscript; 722 result->super_sub = psiconv_superscript;
711 else if (temp == 0x02) 723 else if (temp == 0x02)
712 result->super_sub = psiconv_subscript; 724 result->super_sub = psiconv_subscript;
713 else { 725 else {
714 psiconv_warn(lev+3,off+len, 726 psiconv_warn(config,lev+3,off+len,
715 "Unknown super_sub argument in character layout codes list"); 727 "Unknown super_sub argument in character layout codes list");
716 } 728 }
717 psiconv_debug(lev+3,off+len,"Super_sub: %02x",temp); 729 psiconv_debug(config,lev+3,off+len,"Super_sub: %02x",temp);
718 len ++; 730 len ++;
719 break; 731 break;
720 case 0x20: 732 case 0x20:
721 psiconv_progress(lev+3,off+len,"Going to read underline"); 733 psiconv_progress(config,lev+3,off+len,"Going to read underline");
722 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 734 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
723 &result->underline))) 735 &result->underline)))
724 goto ERROR1; 736 goto ERROR1;
725 len += leng; 737 len += leng;
726 break; 738 break;
727 case 0x21: 739 case 0x21:
728 psiconv_progress(lev+3,off+len,"Going to read strikethrough"); 740 psiconv_progress(config,lev+3,off+len,"Going to read strikethrough");
729 if ((res = psiconv_parse_bool(buf,lev+3,off+len,&leng, 741 if ((res = psiconv_parse_bool(config,buf,lev+3,off+len,&leng,
730 &result->strikethrough))) 742 &result->strikethrough)))
731 goto ERROR1; 743 goto ERROR1;
732 len += leng; 744 len += leng;
733 break; 745 break;
734 case 0x22: 746 case 0x22:
735 psiconv_progress(lev+3,off+len,"Going to read font"); 747 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))) 748 if ((res = psiconv_parse_font(config,buf,lev+3,off+len, &leng, &temp_font)))
737 goto ERROR1; 749 goto ERROR1;
738 psiconv_free_font(result->font); 750 psiconv_free_font(result->font);
739 result->font = temp_font; 751 result->font = temp_font;
740 len += leng; 752 len += leng;
741 break; 753 break;
742 case 0x23: 754 case 0x23:
743 psiconv_progress(lev+3,off+len,"Going to skip an unknown setting"); 755 psiconv_progress(config,lev+3,off+len,"Going to skip an unknown setting");
744 len ++; 756 len ++;
745 break; 757 break;
746 case 0x24: 758 case 0x24:
747 psiconv_progress(lev+3,off+len, 759 psiconv_progress(config,lev+3,off+len,
748 "Going to read unknown code 0x24 (%02x expected)", 0); 760 "Going to read unknown code 0x24 (%02x expected)", 0);
749 temp = psiconv_read_u8(buf,lev+3,off+len,&res); 761 temp = psiconv_read_u8(config,buf,lev+3,off+len,&res);
750 if (res) 762 if (res)
751 goto ERROR1; 763 goto ERROR1;
752 if (temp != 0) { 764 if (temp != 0) {
753 psiconv_warn(lev+3,off+len, 765 psiconv_warn(config,lev+3,off+len,
754 "Unknown code 0x24 value != 0x0 (0x%02x)", temp); 766 "Unknown code 0x24 value != 0x0 (0x%02x)", temp);
755 } 767 }
756 len ++; 768 len ++;
757 break; 769 break;
758 default: 770 default:
759 psiconv_warn(lev+3,off+len,"Unknown code in character layout list"); 771 psiconv_warn(config,lev+3,off+len,"Unknown code in character layout list");
760 psiconv_debug(lev+3,off+len,"Code: %02x",id); 772 psiconv_debug(config,lev+3,off+len,"Code: %02x",id);
761 len ++; 773 len ++;
762 break; 774 break;
763 } 775 }
764 nr ++; 776 nr ++;
765 } 777 }
766 778
767 if (len - 4 != list_length) { 779 if (len - 4 != list_length) {
768 psiconv_warn(lev+2,off+len, 780 psiconv_error(config,lev+2,off+len,
769 "Read past end of character layout codes list. I probably lost track" 781 "Read past end of character layout codes list. I probably lost track "
770 "somewhere!"); 782 "somewhere!");
771 psiconv_debug(lev+2,off+len,"Read %d characters instead of %d", 783 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
772 len-4,list_length); 784 len-4,list_length);
773 res = PSICONV_E_PARSE; 785 res = PSICONV_E_PARSE;
774 goto ERROR1; 786 goto ERROR1;
775 } 787 }
776 788
777 len = list_length + 4; 789 len = list_length + 4;
778 790
779 psiconv_progress(lev+1,off+len, 791 psiconv_progress(config,lev+1,off+len,
780 "End of character layout list (total length: %08x)",len); 792 "End of character layout list (total length: %08x)",len);
781 793
782 if (length) 794 if (length)
783 *length = len; 795 *length = len;
784 return res; 796 return res;
785 797
786ERROR1: 798ERROR1:
787 psiconv_warn(lev+1,off,"Reading of character_layout_list failed"); 799 psiconv_error(config,lev+1,off,"Reading of character_layout_list failed");
788 if (length) 800 if (length)
789 *length = 0; 801 *length = 0;
790 if (!res) 802 if (!res)
791 return -PSICONV_E_NOMEM; 803 return -PSICONV_E_NOMEM;
792 else 804 else

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

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