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

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

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